aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile33
-rw-r--r--lib/atf/Makefile.inc3
-rw-r--r--lib/atf/libatf-c++/Makefile3
-rw-r--r--lib/atf/libatf-c++/Makefile.inc1
-rw-r--r--lib/atf/libatf-c++/tests/Makefile1
-rw-r--r--lib/atf/libatf-c++/tests/Makefile.depend1
-rw-r--r--lib/atf/libatf-c++/tests/Makefile.inc1
-rw-r--r--lib/atf/libatf-c++/tests/detail/Makefile1
-rw-r--r--lib/atf/libatf-c/Makefile2
-rw-r--r--lib/atf/libatf-c/Makefile.inc1
-rw-r--r--lib/atf/libatf-c/tests/Makefile1
-rw-r--r--lib/atf/libatf-c/tests/Makefile.depend1
-rw-r--r--lib/atf/libatf-c/tests/Makefile.inc1
-rw-r--r--lib/atf/libatf-c/tests/detail/Makefile1
-rw-r--r--lib/atf/tests/Makefile1
-rw-r--r--lib/atf/tests/test-programs/Makefile1
-rw-r--r--lib/clang/Makefile1
-rw-r--r--lib/clang/Makefile.inc6
-rw-r--r--lib/clang/headers/Makefile69
-rw-r--r--lib/clang/include/Plugins/Plugins.def7
-rw-r--r--lib/clang/include/VCSVersion.inc6
-rw-r--r--lib/clang/include/clang/Basic/Version.inc12
-rw-r--r--lib/clang/include/clang/Config/config.h9
-rw-r--r--lib/clang/include/lld/Common/Version.inc4
-rw-r--r--lib/clang/include/lldb/API/SBLanguages.h101
-rw-r--r--lib/clang/include/lldb/Host/Config.h2
-rw-r--r--lib/clang/include/lldb/Version/Version.inc10
-rw-r--r--lib/clang/include/llvm/Config/AsmParsers.def26
-rw-r--r--lib/clang/include/llvm/Config/AsmPrinters.def26
-rw-r--r--lib/clang/include/llvm/Config/Disassemblers.def26
-rw-r--r--lib/clang/include/llvm/Config/TargetMCAs.def23
-rw-r--r--lib/clang/include/llvm/Config/Targets.def25
-rw-r--r--lib/clang/include/llvm/Config/abi-breaking.h4
-rw-r--r--lib/clang/include/llvm/Config/config.h21
-rw-r--r--lib/clang/include/llvm/Config/llvm-config.h121
-rw-r--r--lib/clang/include/llvm/Support/VCSRevision.h2
-rw-r--r--lib/clang/libclang/Makefile349
-rw-r--r--lib/clang/libclangminimal/Makefile2
-rw-r--r--lib/clang/liblldb/LLDBWrapLua.cpp18536
-rw-r--r--lib/clang/liblldb/Makefile90
-rw-r--r--lib/clang/liblldb/Makefile.depend8
-rw-r--r--lib/clang/libllvm/Makefile443
-rw-r--r--lib/clang/libllvm/Makefile.depend2
-rw-r--r--lib/clang/libllvmminimal/Makefile10
-rw-r--r--lib/clang/llvm.build.mk10
-rw-r--r--lib/clang/llvm.pre.mk3
-rw-r--r--lib/csu/Makefile1
-rw-r--r--lib/csu/Makefile.inc7
-rw-r--r--lib/csu/aarch64/Makefile1
-rw-r--r--lib/csu/aarch64/Makefile.depend (renamed from lib/libprocstat/zfs/Makefile.depend)0
-rw-r--r--lib/csu/aarch64/crt1_s.S8
-rw-r--r--lib/csu/aarch64/crti.S5
-rw-r--r--lib/csu/aarch64/crtn.S6
-rw-r--r--lib/csu/amd64/Makefile1
-rw-r--r--lib/csu/amd64/crt1_s.S15
-rw-r--r--lib/csu/arm/Makefile1
-rw-r--r--lib/csu/arm/crt1_c.c1
-rw-r--r--lib/csu/common/crtbegin.c44
-rw-r--r--lib/csu/common/crtbrand.S7
-rw-r--r--lib/csu/common/crtend.c15
-rw-r--r--lib/csu/common/feature_note.S7
-rw-r--r--lib/csu/common/ignore_init_note.S7
-rw-r--r--lib/csu/i386/Makefile1
-rw-r--r--lib/csu/powerpc/Makefile1
-rw-r--r--lib/csu/powerpc64/Makefile1
-rw-r--r--lib/csu/riscv/Makefile1
-rw-r--r--lib/csu/riscv/Makefile.depend11
-rw-r--r--lib/csu/tests/Makefile2
-rw-r--r--lib/csu/tests/Makefile.inc1
-rw-r--r--lib/csu/tests/Makefile.tests1
-rw-r--r--lib/csu/tests/cxx_constructors.cc1
-rw-r--r--lib/csu/tests/dso/Makefile5
-rw-r--r--lib/csu/tests/dynamic/Makefile1
-rw-r--r--lib/csu/tests/dynamiclib/Makefile1
-rw-r--r--lib/csu/tests/dynamicpie/Makefile1
-rw-r--r--lib/csu/tests/errno/Makefile18
-rw-r--r--lib/csu/tests/errno/errno_test.c23
-rw-r--r--lib/csu/tests/fini_test.c1
-rw-r--r--lib/csu/tests/init_test.c30
-rw-r--r--lib/csu/tests/static/Makefile1
-rw-r--r--lib/flua/Makefile4
-rw-r--r--lib/flua/libjail/Makefile15
-rw-r--r--lib/flua/libjail/jail.3lua277
-rw-r--r--lib/flua/libjail/lua_jail.c711
-rw-r--r--lib/geom/Makefile1
-rw-r--r--lib/geom/Makefile.classes1
-rw-r--r--lib/geom/Makefile.inc1
-rw-r--r--lib/geom/cache/Makefile2
-rw-r--r--lib/geom/concat/Makefile2
-rw-r--r--lib/geom/concat/gconcat.83
-rw-r--r--lib/geom/concat/geom_concat.c1
-rw-r--r--lib/geom/eli/Makefile5
-rw-r--r--lib/geom/eli/geli.848
-rw-r--r--lib/geom/eli/geom_eli.c1
-rw-r--r--lib/geom/journal/Makefile2
-rw-r--r--lib/geom/journal/geom_journal.c1
-rw-r--r--lib/geom/journal/geom_journal_ufs.c1
-rw-r--r--lib/geom/journal/gjournal.82
-rw-r--r--lib/geom/label/Makefile2
-rw-r--r--lib/geom/label/geom_label.c1
-rw-r--r--lib/geom/label/glabel.855
-rw-r--r--lib/geom/mirror/Makefile2
-rw-r--r--lib/geom/mirror/geom_mirror.c1
-rw-r--r--lib/geom/mirror/gmirror.83
-rw-r--r--lib/geom/mountver/Makefile2
-rw-r--r--lib/geom/multipath/Makefile2
-rw-r--r--lib/geom/multipath/geom_multipath.c1
-rw-r--r--lib/geom/nop/Makefile2
-rw-r--r--lib/geom/part/Makefile2
-rw-r--r--lib/geom/part/gpart.816
-rw-r--r--lib/geom/raid/Makefile4
-rw-r--r--lib/geom/raid/geom_raid.c1
-rw-r--r--lib/geom/raid/graid.87
-rw-r--r--lib/geom/raid3/Makefile2
-rw-r--r--lib/geom/raid3/geom_raid3.c1
-rw-r--r--lib/geom/raid3/graid3.83
-rw-r--r--lib/geom/shsec/Makefile2
-rw-r--r--lib/geom/shsec/geom_shsec.c1
-rw-r--r--lib/geom/shsec/gshsec.81
-rw-r--r--lib/geom/stripe/Makefile2
-rw-r--r--lib/geom/stripe/geom_stripe.c1
-rw-r--r--lib/geom/stripe/gstripe.83
-rw-r--r--lib/geom/union/Makefile2
-rw-r--r--lib/geom/union/Makefile.depend2
-rw-r--r--lib/geom/virstor/Makefile3
-rw-r--r--lib/geom/virstor/geom_virstor.c100
-rw-r--r--lib/googletest/Makefile1
-rw-r--r--lib/googletest/Makefile.inc1
-rw-r--r--lib/googletest/gmock/Makefile1
-rw-r--r--lib/googletest/gmock/Makefile.inc1
-rw-r--r--lib/googletest/gmock_main/Makefile1
-rw-r--r--lib/googletest/gmock_main/Makefile.inc1
-rw-r--r--lib/googletest/gtest/Makefile1
-rw-r--r--lib/googletest/gtest/Makefile.inc1
-rw-r--r--lib/googletest/gtest_main/Makefile1
-rw-r--r--lib/googletest/gtest_main/Makefile.inc1
-rw-r--r--lib/googletest/tests/Makefile1
-rw-r--r--lib/googletest/tests/Makefile.inc1
-rw-r--r--lib/googletest/tests/gmock/Makefile1
-rw-r--r--lib/googletest/tests/gmock_main/Makefile1
-rw-r--r--lib/googletest/tests/gtest/Makefile1
-rw-r--r--lib/googletest/tests/gtest_main/Makefile1
-rw-r--r--lib/lib80211/Makefile1
-rw-r--r--lib/lib80211/lib80211_regdomain.c5
-rw-r--r--lib/lib80211/regdomain.xml308
-rw-r--r--lib/lib9p/Makefile1
-rw-r--r--lib/lib9p/Makefile.depend19
-rw-r--r--lib/libalias/Makefile1
-rw-r--r--lib/libalias/Makefile.inc1
-rw-r--r--lib/libalias/libalias/Makefile1
-rw-r--r--lib/libalias/modules/Makefile1
-rw-r--r--lib/libalias/modules/Makefile.inc1
-rw-r--r--lib/libalias/modules/dummy/Makefile1
-rw-r--r--lib/libalias/modules/ftp/Makefile1
-rw-r--r--lib/libalias/modules/irc/Makefile1
-rw-r--r--lib/libalias/modules/nbt/Makefile1
-rw-r--r--lib/libalias/modules/pptp/Makefile1
-rw-r--r--lib/libalias/modules/skinny/Makefile1
-rw-r--r--lib/libalias/modules/smedia/Makefile1
-rw-r--r--lib/libarchive/Makefile3
-rw-r--r--lib/libarchive/Makefile.inc3
-rw-r--r--lib/libarchive/config_freebsd.h1
-rw-r--r--lib/libarchive/tests/Makefile73
-rw-r--r--lib/libauditd/Makefile1
-rw-r--r--lib/libbe/Makefile4
-rw-r--r--lib/libbe/be.c65
-rw-r--r--lib/libbe/be.h25
-rw-r--r--lib/libbe/be_access.c67
-rw-r--r--lib/libbe/be_error.c25
-rw-r--r--lib/libbe/be_impl.h26
-rw-r--r--lib/libbe/be_info.c32
-rw-r--r--lib/libbe/libbe.360
-rw-r--r--lib/libbe/tests/Makefile1
-rw-r--r--lib/libbe/tests/Makefile.depend17
-rw-r--r--lib/libbearssl/Makefile10
-rw-r--r--lib/libbearssl/Makefile.inc2
-rw-r--r--lib/libbearssl/Makefile.libsa.inc4
-rw-r--r--lib/libbegemot/Makefile1
-rw-r--r--lib/libblacklist/Makefile8
-rw-r--r--lib/libblocksruntime/Makefile1
-rw-r--r--lib/libbsddialog/Makefile5
-rw-r--r--lib/libbsddialog/Makefile.depend17
-rw-r--r--lib/libbsdstat/Makefile1
-rw-r--r--lib/libbsdstat/bsdstat.h2
-rw-r--r--lib/libbsm/Makefile6
-rw-r--r--lib/libbsnmp/Makefile1
-rw-r--r--lib/libbsnmp/Makefile.inc3
-rw-r--r--lib/libbsnmp/libbsnmp/Makefile2
-rw-r--r--lib/libbsnmp/tests/Makefile3
-rw-r--r--lib/libbz2/Makefile1
-rw-r--r--lib/libc++/Makefile413
-rw-r--r--lib/libc++/__assertion_handler41
-rw-r--r--lib/libc++/__config_site19
-rw-r--r--lib/libc++/libcxx.imp868
-rw-r--r--lib/libc++/module.modulemap1724
-rw-r--r--lib/libc++experimental/Makefile5
-rw-r--r--lib/libc++experimental/Makefile.depend3
-rw-r--r--lib/libc/Makefile38
-rw-r--r--lib/libc/Makefile.depend1
-rw-r--r--lib/libc/Versions.def6
-rw-r--r--lib/libc/aarch64/SYS.h68
-rw-r--r--lib/libc/aarch64/Symbol.map25
-rw-r--r--lib/libc/aarch64/gen/Makefile.inc5
-rw-r--r--lib/libc/aarch64/gen/_ctx_start.S4
-rw-r--r--lib/libc/aarch64/gen/_setjmp.S3
-rw-r--r--lib/libc/aarch64/gen/fabs.S4
-rw-r--r--lib/libc/aarch64/gen/flt_rounds.c1
-rw-r--r--lib/libc/aarch64/gen/fpgetmask.c1
-rw-r--r--lib/libc/aarch64/gen/fpsetmask.c1
-rw-r--r--lib/libc/aarch64/gen/getcontextx.c89
-rw-r--r--lib/libc/aarch64/gen/infinity.c1
-rw-r--r--lib/libc/aarch64/gen/makecontext.c11
-rw-r--r--lib/libc/aarch64/gen/setjmp.S3
-rw-r--r--lib/libc/aarch64/gen/sigsetjmp.S3
-rw-r--r--lib/libc/aarch64/static_tls.h44
-rw-r--r--lib/libc/aarch64/string/Makefile.inc28
-rw-r--r--lib/libc/aarch64/string/bcopy.c14
-rw-r--r--lib/libc/aarch64/string/bzero.c14
-rw-r--r--lib/libc/aarch64/string/memccpy.S271
-rw-r--r--lib/libc/aarch64/string/memchr.S4
-rw-r--r--lib/libc/aarch64/string/memcpy.S9
-rw-r--r--lib/libc/aarch64/string/memmove.S4
-rw-r--r--lib/libc/aarch64/string/strcat.c20
-rw-r--r--lib/libc/aarch64/string/strcmp.S350
-rw-r--r--lib/libc/aarch64/string/strcspn.S109
-rw-r--r--lib/libc/aarch64/string/strlcat.c27
-rw-r--r--lib/libc/aarch64/string/strlcpy.S316
-rw-r--r--lib/libc/aarch64/string/strlen.S45
-rw-r--r--lib/libc/aarch64/string/strncat.c31
-rw-r--r--lib/libc/aarch64/string/strncmp.S569
-rw-r--r--lib/libc/aarch64/string/strpbrk.c43
-rw-r--r--lib/libc/aarch64/string/strsep.c57
-rw-r--r--lib/libc/aarch64/string/strspn.S111
-rw-r--r--lib/libc/aarch64/string/timingsafe_bcmp.S113
-rw-r--r--lib/libc/aarch64/string/timingsafe_memcmp.S117
-rw-r--r--lib/libc/aarch64/sys/Makefile.inc13
-rw-r--r--lib/libc/aarch64/sys/__vdso_gettc.c74
-rw-r--r--lib/libc/aarch64/sys/cerror.S39
-rw-r--r--lib/libc/aarch64/sys/syscall.S32
-rw-r--r--lib/libc/aarch64/sys/vfork.S40
-rw-r--r--lib/libc/amd64/SYS.h53
-rw-r--r--lib/libc/amd64/Symbol.map40
-rw-r--r--lib/libc/amd64/gen/Makefile.inc4
-rw-r--r--lib/libc/amd64/gen/_setjmp.S3
-rw-r--r--lib/libc/amd64/gen/flt_rounds.c1
-rw-r--r--lib/libc/amd64/gen/infinity.c1
-rw-r--r--lib/libc/amd64/gen/makecontext.c1
-rw-r--r--lib/libc/amd64/gen/rfork_thread.S93
-rw-r--r--lib/libc/amd64/gen/setjmp.S3
-rw-r--r--lib/libc/amd64/gen/signalcontext.c1
-rw-r--r--lib/libc/amd64/gen/sigsetjmp.S2
-rw-r--r--lib/libc/amd64/static_tls.h44
-rw-r--r--lib/libc/amd64/stdlib/Makefile.inc2
-rw-r--r--lib/libc/amd64/string/Makefile.inc26
-rw-r--r--lib/libc/amd64/string/bcopy.c3
-rw-r--r--lib/libc/amd64/string/bzero.c3
-rw-r--r--lib/libc/amd64/string/memccpy.S260
-rw-r--r--lib/libc/amd64/string/memchr.S207
-rw-r--r--lib/libc/amd64/string/memcmp.S17
-rw-r--r--lib/libc/amd64/string/memrchr.S166
-rw-r--r--lib/libc/amd64/string/stpncpy.S283
-rw-r--r--lib/libc/amd64/string/strcat.S47
-rw-r--r--lib/libc/amd64/string/strcmp.S299
-rw-r--r--lib/libc/amd64/string/strcpy.c1
-rw-r--r--lib/libc/amd64/string/strcspn.S396
-rw-r--r--lib/libc/amd64/string/strlcat.c27
-rw-r--r--lib/libc/amd64/string/strlcpy.S281
-rw-r--r--lib/libc/amd64/string/strncat.c31
-rw-r--r--lib/libc/amd64/string/strncmp.S488
-rw-r--r--lib/libc/amd64/string/strncpy.c43
-rw-r--r--lib/libc/amd64/string/strnlen.c41
-rw-r--r--lib/libc/amd64/string/strpbrk.c43
-rw-r--r--lib/libc/amd64/string/strrchr.S209
-rw-r--r--lib/libc/amd64/string/strsep.c57
-rw-r--r--lib/libc/amd64/string/strspn.S358
-rw-r--r--lib/libc/amd64/string/timingsafe_bcmp.S232
-rw-r--r--lib/libc/amd64/string/timingsafe_memcmp.S145
-rw-r--r--lib/libc/amd64/sys/Makefile.inc12
-rw-r--r--lib/libc/amd64/sys/amd64_get_fsbase.c64
-rw-r--r--lib/libc/amd64/sys/amd64_get_gsbase.c64
-rw-r--r--lib/libc/amd64/sys/amd64_set_fsbase.c64
-rw-r--r--lib/libc/amd64/sys/amd64_set_gsbase.c64
-rw-r--r--lib/libc/amd64/sys/cerror.S58
-rw-r--r--lib/libc/amd64/sys/getcontext.S46
-rw-r--r--lib/libc/amd64/sys/vfork.S52
-rw-r--r--lib/libc/arm/SYS.h80
-rw-r--r--lib/libc/arm/Symbol.map31
-rw-r--r--lib/libc/arm/aeabi/Makefile.inc1
-rw-r--r--lib/libc/arm/aeabi/Symbol.map47
-rw-r--r--lib/libc/arm/aeabi/aeabi_atexit.c1
-rw-r--r--lib/libc/arm/aeabi/aeabi_double.c3
-rw-r--r--lib/libc/arm/aeabi/aeabi_float.c3
-rw-r--r--lib/libc/arm/aeabi/aeabi_int_div.S2
-rw-r--r--lib/libc/arm/aeabi/aeabi_unwind_cpp.c1
-rw-r--r--lib/libc/arm/aeabi/aeabi_unwind_exidx.c1
-rw-r--r--lib/libc/arm/aeabi/aeabi_vfp.h6
-rw-r--r--lib/libc/arm/gen/Makefile.inc2
-rw-r--r--lib/libc/arm/gen/_setjmp.S8
-rw-r--r--lib/libc/arm/gen/arm_drain_writebuf.c1
-rw-r--r--lib/libc/arm/gen/arm_initfini.c1
-rw-r--r--lib/libc/arm/gen/arm_sync_icache.c1
-rw-r--r--lib/libc/arm/gen/fabs.c1
-rw-r--r--lib/libc/arm/gen/flt_rounds.c1
-rw-r--r--lib/libc/arm/gen/fpgetmask_vfp.c5
-rw-r--r--lib/libc/arm/gen/fpgetround_vfp.c1
-rw-r--r--lib/libc/arm/gen/fpgetsticky_vfp.c5
-rw-r--r--lib/libc/arm/gen/fpsetmask_vfp.c1
-rw-r--r--lib/libc/arm/gen/fpsetround_vfp.c1
-rw-r--r--lib/libc/arm/gen/fpsetsticky_vfp.c1
-rw-r--r--lib/libc/arm/gen/getcontextx.c1
-rw-r--r--lib/libc/arm/gen/infinity.c1
-rw-r--r--lib/libc/arm/gen/makecontext.c11
-rw-r--r--lib/libc/arm/gen/setjmp.S4
-rw-r--r--lib/libc/arm/gen/signalcontext.c1
-rw-r--r--lib/libc/arm/static_tls.h45
-rw-r--r--lib/libc/arm/string/Makefile.inc1
-rw-r--r--lib/libc/arm/sys/Makefile.inc8
-rw-r--r--lib/libc/arm/sys/Ovfork.S56
-rw-r--r--lib/libc/arm/sys/__vdso_gettc.c89
-rw-r--r--lib/libc/arm/sys/cerror.S50
-rw-r--r--lib/libc/arm/sys/syscall.S39
-rw-r--r--lib/libc/capability/Makefile.inc2
-rw-r--r--lib/libc/capability/Symbol.map7
-rw-r--r--lib/libc/capability/cap_rights_init.319
-rw-r--r--lib/libc/compat-43/Makefile.inc6
-rw-r--r--lib/libc/compat-43/Symbol.map3
-rw-r--r--lib/libc/compat-43/creat.261
-rw-r--r--lib/libc/compat-43/creat.c55
-rw-r--r--lib/libc/compat-43/gethostid.32
-rw-r--r--lib/libc/compat-43/gethostid.c4
-rw-r--r--lib/libc/compat-43/getwd.c4
-rw-r--r--lib/libc/compat-43/killpg.22
-rw-r--r--lib/libc/compat-43/killpg.c4
-rw-r--r--lib/libc/compat-43/sethostid.c4
-rw-r--r--lib/libc/compat-43/setpgrp.c4
-rw-r--r--lib/libc/compat-43/setrgid.c4
-rw-r--r--lib/libc/compat-43/setruid.32
-rw-r--r--lib/libc/compat-43/setruid.c4
-rw-r--r--lib/libc/compat-43/sigcompat.c4
-rw-r--r--lib/libc/compat-43/sigpause.22
-rw-r--r--lib/libc/compat-43/sigsetmask.22
-rw-r--r--lib/libc/compat-43/sigvec.22
-rw-r--r--lib/libc/csu/aarch64/Makefile.inc3
-rw-r--r--lib/libc/csu/aarch64/reloc.c6
-rw-r--r--lib/libc/csu/amd64/Makefile.inc3
-rw-r--r--lib/libc/csu/amd64/reloc.c3
-rw-r--r--lib/libc/csu/arm/Makefile.inc3
-rw-r--r--lib/libc/csu/i386/Makefile.inc3
-rw-r--r--lib/libc/csu/i386/reloc.c3
-rw-r--r--lib/libc/csu/libc_start1.c37
-rw-r--r--lib/libc/csu/powerpc/Makefile.inc3
-rw-r--r--lib/libc/csu/powerpc64/Makefile.inc3
-rw-r--r--lib/libc/csu/powerpc64/reloc.c10
-rw-r--r--lib/libc/csu/powerpcspe/Makefile.inc3
-rw-r--r--lib/libc/csu/riscv/Makefile.inc3
-rw-r--r--lib/libc/csu/riscv/reloc.c56
-rw-r--r--lib/libc/db/Makefile.inc2
-rw-r--r--lib/libc/db/README1
-rw-r--r--lib/libc/db/Symbol.map4
-rw-r--r--lib/libc/db/btree/Makefile.inc2
-rw-r--r--lib/libc/db/btree/bt_close.c4
-rw-r--r--lib/libc/db/btree/bt_conv.c4
-rw-r--r--lib/libc/db/btree/bt_debug.c4
-rw-r--r--lib/libc/db/btree/bt_delete.c4
-rw-r--r--lib/libc/db/btree/bt_get.c4
-rw-r--r--lib/libc/db/btree/bt_open.c4
-rw-r--r--lib/libc/db/btree/bt_overflow.c4
-rw-r--r--lib/libc/db/btree/bt_page.c4
-rw-r--r--lib/libc/db/btree/bt_put.c4
-rw-r--r--lib/libc/db/btree/bt_search.c4
-rw-r--r--lib/libc/db/btree/bt_seq.c6
-rw-r--r--lib/libc/db/btree/bt_split.c4
-rw-r--r--lib/libc/db/btree/bt_utils.c6
-rw-r--r--lib/libc/db/btree/btree.h2
-rw-r--r--lib/libc/db/btree/extern.h2
-rw-r--r--lib/libc/db/db/Makefile.inc2
-rw-r--r--lib/libc/db/db/db.c4
-rw-r--r--lib/libc/db/docs/hash.usenix.ps1
-rw-r--r--lib/libc/db/docs/libtp.usenix.ps1
-rw-r--r--lib/libc/db/hash/Makefile.inc2
-rw-r--r--lib/libc/db/hash/README1
-rw-r--r--lib/libc/db/hash/extern.h2
-rw-r--r--lib/libc/db/hash/hash.c28
-rw-r--r--lib/libc/db/hash/hash.h2
-rw-r--r--lib/libc/db/hash/hash_bigkey.c4
-rw-r--r--lib/libc/db/hash/hash_buf.c4
-rw-r--r--lib/libc/db/hash/hash_func.c4
-rw-r--r--lib/libc/db/hash/hash_log2.c4
-rw-r--r--lib/libc/db/hash/hash_page.c4
-rw-r--r--lib/libc/db/hash/ndbm.c4
-rw-r--r--lib/libc/db/hash/page.h2
-rw-r--r--lib/libc/db/man/Makefile.inc4
-rw-r--r--lib/libc/db/man/btree.32
-rw-r--r--lib/libc/db/man/dbm.35
-rw-r--r--lib/libc/db/man/dbopen.37
-rw-r--r--lib/libc/db/man/hash.32
-rw-r--r--lib/libc/db/man/mpool.32
-rw-r--r--lib/libc/db/man/recno.32
-rw-r--r--lib/libc/db/mpool/Makefile.inc2
-rw-r--r--lib/libc/db/mpool/README1
-rw-r--r--lib/libc/db/mpool/mpool-compat.c1
-rw-r--r--lib/libc/db/mpool/mpool.c4
-rw-r--r--lib/libc/db/recno/Makefile.inc2
-rw-r--r--lib/libc/db/recno/extern.h2
-rw-r--r--lib/libc/db/recno/rec_close.c4
-rw-r--r--lib/libc/db/recno/rec_delete.c4
-rw-r--r--lib/libc/db/recno/rec_get.c4
-rw-r--r--lib/libc/db/recno/rec_open.c4
-rw-r--r--lib/libc/db/recno/rec_put.c4
-rw-r--r--lib/libc/db/recno/rec_search.c4
-rw-r--r--lib/libc/db/recno/rec_seq.c5
-rw-r--r--lib/libc/db/recno/rec_utils.c4
-rw-r--r--lib/libc/db/recno/recno.h2
-rw-r--r--lib/libc/db/test/Makefile2
-rw-r--r--lib/libc/db/test/README1
-rw-r--r--lib/libc/db/test/btree.tests/main.c4
-rw-r--r--lib/libc/db/test/dbtest.c10
-rw-r--r--lib/libc/db/test/hash.tests/driver2.c10
-rw-r--r--lib/libc/db/test/hash.tests/makedb.sh2
-rw-r--r--lib/libc/db/test/hash.tests/tcreat3.c10
-rw-r--r--lib/libc/db/test/hash.tests/tdel.c10
-rw-r--r--lib/libc/db/test/hash.tests/testit3
-rw-r--r--lib/libc/db/test/hash.tests/thash4.c10
-rw-r--r--lib/libc/db/test/hash.tests/tread2.c10
-rw-r--r--lib/libc/db/test/hash.tests/tseq.c10
-rw-r--r--lib/libc/db/test/hash.tests/tverify.c10
-rw-r--r--lib/libc/db/test/run.test3
-rw-r--r--lib/libc/gdtoa/Makefile.inc1
-rw-r--r--lib/libc/gdtoa/Symbol.map3
-rw-r--r--lib/libc/gdtoa/_hdtoa.c1
-rw-r--r--lib/libc/gdtoa/_hldtoa.c1
-rw-r--r--lib/libc/gdtoa/_ldtoa.c1
-rw-r--r--lib/libc/gdtoa/machdep_ldisQ.c1
-rw-r--r--lib/libc/gdtoa/machdep_ldisd.c1
-rw-r--r--lib/libc/gdtoa/machdep_ldisx.c1
-rw-r--r--lib/libc/gen/Makefile.inc64
-rw-r--r--lib/libc/gen/Symbol.map50
-rw-r--r--lib/libc/gen/__getosreldate.c67
-rw-r--r--lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c1
-rw-r--r--lib/libc/gen/__xuname.c3
-rw-r--r--lib/libc/gen/_once_stub.c1
-rw-r--r--lib/libc/gen/_pthread_stubs.c13
-rw-r--r--lib/libc/gen/_rand48.c1
-rw-r--r--lib/libc/gen/_spinlock_stub.c1
-rw-r--r--lib/libc/gen/_thread_init.c1
-rw-r--r--lib/libc/gen/aio_read2.c58
-rw-r--r--lib/libc/gen/aio_write2.c58
-rw-r--r--lib/libc/gen/alarm.34
-rw-r--r--lib/libc/gen/alarm.c2
-rw-r--r--lib/libc/gen/arc4random-compat.c1
-rw-r--r--lib/libc/gen/arc4random.324
-rw-r--r--lib/libc/gen/arc4random.c4
-rw-r--r--lib/libc/gen/arc4random_uniform.c71
-rw-r--r--lib/libc/gen/assert.c2
-rw-r--r--lib/libc/gen/auxv.3105
-rw-r--r--lib/libc/gen/auxv.c404
-rw-r--r--lib/libc/gen/basename.c1
-rw-r--r--lib/libc/gen/basename_compat.c1
-rw-r--r--lib/libc/gen/cap_sandboxed.c1
-rw-r--r--lib/libc/gen/check_utility_compat.c1
-rw-r--r--lib/libc/gen/clock.32
-rw-r--r--lib/libc/gen/clock.c2
-rw-r--r--lib/libc/gen/clock_getcpuclockid.c1
-rw-r--r--lib/libc/gen/closedir.c2
-rw-r--r--lib/libc/gen/confstr.32
-rw-r--r--lib/libc/gen/confstr.c2
-rw-r--r--lib/libc/gen/crypt.c2
-rw-r--r--lib/libc/gen/ctermid.32
-rw-r--r--lib/libc/gen/ctermid.c6
-rw-r--r--lib/libc/gen/daemon.32
-rw-r--r--lib/libc/gen/daemon.c2
-rw-r--r--lib/libc/gen/devname-compat11.c1
-rw-r--r--lib/libc/gen/devname.32
-rw-r--r--lib/libc/gen/devname.c2
-rw-r--r--lib/libc/gen/directory.32
-rw-r--r--lib/libc/gen/dirfd.c1
-rw-r--r--lib/libc/gen/dirname.c1
-rw-r--r--lib/libc/gen/dirname_compat.c1
-rw-r--r--lib/libc/gen/disklabel.c2
-rw-r--r--lib/libc/gen/dlfcn.c46
-rw-r--r--lib/libc/gen/dlopen.38
-rw-r--r--lib/libc/gen/drand48.c1
-rw-r--r--lib/libc/gen/dup3.315
-rw-r--r--lib/libc/gen/dup3.c10
-rw-r--r--lib/libc/gen/elf_utils.c27
-rw-r--r--lib/libc/gen/erand48.c1
-rw-r--r--lib/libc/gen/err.32
-rw-r--r--lib/libc/gen/err.c53
-rw-r--r--lib/libc/gen/errlst.c2
-rw-r--r--lib/libc/gen/errno.c30
-rw-r--r--lib/libc/gen/eventfd.c1
-rw-r--r--lib/libc/gen/exec.327
-rw-r--r--lib/libc/gen/exec.c235
-rw-r--r--lib/libc/gen/exect.c1
-rw-r--r--lib/libc/gen/fdevname.c1
-rw-r--r--lib/libc/gen/fdopendir.c63
-rw-r--r--lib/libc/gen/feature_present.c1
-rw-r--r--lib/libc/gen/fmtcheck.c1
-rw-r--r--lib/libc/gen/fmtmsg.c1
-rw-r--r--lib/libc/gen/fnmatch.310
-rw-r--r--lib/libc/gen/fnmatch.c229
-rw-r--r--lib/libc/gen/frexp.32
-rw-r--r--lib/libc/gen/fstab.c2
-rw-r--r--lib/libc/gen/ftok.c1
-rw-r--r--lib/libc/gen/fts-compat.c3
-rw-r--r--lib/libc/gen/fts-compat.h2
-rw-r--r--lib/libc/gen/fts-compat11.c3
-rw-r--r--lib/libc/gen/fts-compat11.h2
-rw-r--r--lib/libc/gen/fts.388
-rw-r--r--lib/libc/gen/fts.c298
-rw-r--r--lib/libc/gen/ftw-compat11.c1
-rw-r--r--lib/libc/gen/ftw.c1
-rw-r--r--lib/libc/gen/gen-private.h4
-rw-r--r--lib/libc/gen/getbootfile.32
-rw-r--r--lib/libc/gen/getbootfile.c3
-rw-r--r--lib/libc/gen/getbsize.32
-rw-r--r--lib/libc/gen/getbsize.c2
-rw-r--r--lib/libc/gen/getcap.32
-rw-r--r--lib/libc/gen/getcap.c2
-rw-r--r--lib/libc/gen/getcwd.32
-rw-r--r--lib/libc/gen/getcwd.c5
-rw-r--r--lib/libc/gen/getdiskbyname.32
-rw-r--r--lib/libc/gen/getdomainname.32
-rw-r--r--lib/libc/gen/getdomainname.c5
-rw-r--r--lib/libc/gen/getentropy.312
-rw-r--r--lib/libc/gen/getentropy.c107
-rw-r--r--lib/libc/gen/getfsent.32
-rw-r--r--lib/libc/gen/getgrent.32
-rw-r--r--lib/libc/gen/getgrent.c1
-rw-r--r--lib/libc/gen/getgrouplist.32
-rw-r--r--lib/libc/gen/getgrouplist.c5
-rw-r--r--lib/libc/gen/gethostname.32
-rw-r--r--lib/libc/gen/gethostname.c5
-rw-r--r--lib/libc/gen/getloadavg.32
-rw-r--r--lib/libc/gen/getloadavg.c2
-rw-r--r--lib/libc/gen/getlogin.c5
-rw-r--r--lib/libc/gen/getmntinfo-compat11.c3
-rw-r--r--lib/libc/gen/getmntinfo.32
-rw-r--r--lib/libc/gen/getmntinfo.c2
-rw-r--r--lib/libc/gen/getnetgrent.32
-rw-r--r--lib/libc/gen/getnetgrent.c2
-rw-r--r--lib/libc/gen/getosreldate.c2
-rw-r--r--lib/libc/gen/getpagesize.369
-rw-r--r--lib/libc/gen/getpagesize.c73
-rw-r--r--lib/libc/gen/getpagesizes.c85
-rw-r--r--lib/libc/gen/getpass.32
-rw-r--r--lib/libc/gen/getpeereid.34
-rw-r--r--lib/libc/gen/getpeereid.c1
-rw-r--r--lib/libc/gen/getprogname.c1
-rw-r--r--lib/libc/gen/getpwent.32
-rw-r--r--lib/libc/gen/getpwent.c1
-rw-r--r--lib/libc/gen/getttyent.32
-rw-r--r--lib/libc/gen/getttyent.c2
-rw-r--r--lib/libc/gen/getusershell.32
-rw-r--r--lib/libc/gen/getusershell.c2
-rw-r--r--lib/libc/gen/getutxent.c1
-rw-r--r--lib/libc/gen/getvfsbyname.32
-rw-r--r--lib/libc/gen/getvfsbyname.c4
-rw-r--r--lib/libc/gen/glob-compat11.c3
-rw-r--r--lib/libc/gen/glob-compat11.h3
-rw-r--r--lib/libc/gen/glob.368
-rw-r--r--lib/libc/gen/glob.c77
-rw-r--r--lib/libc/gen/initgroups.32
-rw-r--r--lib/libc/gen/initgroups.c2
-rw-r--r--lib/libc/gen/inotify.c48
-rw-r--r--lib/libc/gen/isatty.c2
-rw-r--r--lib/libc/gen/jrand48.c1
-rw-r--r--lib/libc/gen/lcong48.c1
-rw-r--r--lib/libc/gen/ldexp.32
-rw-r--r--lib/libc/gen/ldexp.c1
-rw-r--r--lib/libc/gen/libc_dlopen.c1
-rw-r--r--lib/libc/gen/libc_interposing_table.c55
-rw-r--r--lib/libc/gen/lockf.c84
-rw-r--r--lib/libc/gen/lrand48.c1
-rw-r--r--lib/libc/gen/makecontext.31
-rw-r--r--lib/libc/gen/memalign.c1
-rw-r--r--lib/libc/gen/memfd_create.c121
-rw-r--r--lib/libc/gen/modf.32
-rw-r--r--lib/libc/gen/modf.c2
-rw-r--r--lib/libc/gen/mrand48.c1
-rw-r--r--lib/libc/gen/nftw-compat11.c1
-rw-r--r--lib/libc/gen/nftw.c1
-rw-r--r--lib/libc/gen/nice.32
-rw-r--r--lib/libc/gen/nice.c2
-rw-r--r--lib/libc/gen/nlist.32
-rw-r--r--lib/libc/gen/nlist.c2
-rw-r--r--lib/libc/gen/nrand48.c1
-rw-r--r--lib/libc/gen/opendir.c321
-rw-r--r--lib/libc/gen/opendir2.c337
-rw-r--r--lib/libc/gen/pause.32
-rw-r--r--lib/libc/gen/pause.c2
-rw-r--r--lib/libc/gen/pmadvise.c1
-rw-r--r--lib/libc/gen/popen.32
-rw-r--r--lib/libc/gen/popen.c2
-rw-r--r--lib/libc/gen/posix_spawn.316
-rw-r--r--lib/libc/gen/posix_spawn.c27
-rw-r--r--lib/libc/gen/posix_spawn_file_actions_addopen.32
-rw-r--r--lib/libc/gen/posix_spawnattr_getflags.310
-rw-r--r--lib/libc/gen/psignal.378
-rw-r--r--lib/libc/gen/psignal.c8
-rw-r--r--lib/libc/gen/pututxline.c1
-rw-r--r--lib/libc/gen/pw_scan.c2
-rw-r--r--lib/libc/gen/pw_scan.h2
-rw-r--r--lib/libc/gen/raise.32
-rw-r--r--lib/libc/gen/raise.c2
-rw-r--r--lib/libc/gen/rand48.32
-rw-r--r--lib/libc/gen/readdir-compat11.c3
-rw-r--r--lib/libc/gen/readdir.c15
-rw-r--r--lib/libc/gen/readpassphrase.c1
-rw-r--r--lib/libc/gen/recvmmsg.c95
-rw-r--r--lib/libc/gen/rewinddir.c2
-rw-r--r--lib/libc/gen/rtld_get_var.3106
-rw-r--r--lib/libc/gen/scandir-compat11.c3
-rw-r--r--lib/libc/gen/scandir.3129
-rw-r--r--lib/libc/gen/scandir.c131
-rw-r--r--lib/libc/gen/seed48.c1
-rw-r--r--lib/libc/gen/seekdir.c2
-rw-r--r--lib/libc/gen/semctl.c1
-rw-r--r--lib/libc/gen/sendmmsg.c62
-rw-r--r--lib/libc/gen/setdomainname.c2
-rw-r--r--lib/libc/gen/sethostname.c2
-rw-r--r--lib/libc/gen/setjmp.32
-rw-r--r--lib/libc/gen/setjmperr.c2
-rw-r--r--lib/libc/gen/setmode.32
-rw-r--r--lib/libc/gen/setmode.c2
-rw-r--r--lib/libc/gen/setproctitle.34
-rw-r--r--lib/libc/gen/setproctitle.c1
-rw-r--r--lib/libc/gen/setprogname.c1
-rw-r--r--lib/libc/gen/sig2str.c113
-rw-r--r--lib/libc/gen/siginterrupt.32
-rw-r--r--lib/libc/gen/siginterrupt.c2
-rw-r--r--lib/libc/gen/siglist.c2
-rw-r--r--lib/libc/gen/signal.32
-rw-r--r--lib/libc/gen/signal.c2
-rw-r--r--lib/libc/gen/sigsetops.32
-rw-r--r--lib/libc/gen/sigsetops.c2
-rw-r--r--lib/libc/gen/sleep.382
-rw-r--r--lib/libc/gen/sleep.c6
-rw-r--r--lib/libc/gen/statvfs.c1
-rw-r--r--lib/libc/gen/strtofflags.32
-rw-r--r--lib/libc/gen/strtofflags.c2
-rw-r--r--lib/libc/gen/sysconf.32
-rw-r--r--lib/libc/gen/sysconf.c11
-rw-r--r--lib/libc/gen/sysctl.3175
-rw-r--r--lib/libc/gen/sysctl.c2
-rw-r--r--lib/libc/gen/sysctlbyname.c1
-rw-r--r--lib/libc/gen/sysctlnametomib.c1
-rw-r--r--lib/libc/gen/syslog.32
-rw-r--r--lib/libc/gen/syslog.c2
-rw-r--r--lib/libc/gen/tcgetpgrp.32
-rw-r--r--lib/libc/gen/tcsendbreak.32
-rw-r--r--lib/libc/gen/tcsetattr.32
-rw-r--r--lib/libc/gen/tcsetpgrp.32
-rw-r--r--lib/libc/gen/telldir.c6
-rw-r--r--lib/libc/gen/telldir.h7
-rw-r--r--lib/libc/gen/termios.c2
-rw-r--r--lib/libc/gen/time.32
-rw-r--r--lib/libc/gen/time.c2
-rw-r--r--lib/libc/gen/times.32
-rw-r--r--lib/libc/gen/times.c2
-rw-r--r--lib/libc/gen/timezone.368
-rw-r--r--lib/libc/gen/timezone.c9
-rw-r--r--lib/libc/gen/tls.c101
-rw-r--r--lib/libc/gen/trivial-getcontextx.c1
-rw-r--r--lib/libc/gen/ttyname.32
-rw-r--r--lib/libc/gen/ttyname.c5
-rw-r--r--lib/libc/gen/ttyslot.c2
-rw-r--r--lib/libc/gen/tzset.3325
-rw-r--r--lib/libc/gen/ualarm.34
-rw-r--r--lib/libc/gen/ualarm.c2
-rw-r--r--lib/libc/gen/uexterr_format.c35
-rw-r--r--lib/libc/gen/uexterr_gettext.c43
-rw-r--r--lib/libc/gen/uname.32
-rw-r--r--lib/libc/gen/uname.c2
-rw-r--r--lib/libc/gen/usleep.379
-rw-r--r--lib/libc/gen/usleep.c5
-rw-r--r--lib/libc/gen/utime.32
-rw-r--r--lib/libc/gen/utime.c2
-rw-r--r--lib/libc/gen/utxdb.c1
-rw-r--r--lib/libc/gen/valloc.32
-rw-r--r--lib/libc/gen/valloc.c2
-rw-r--r--lib/libc/gen/wait.c54
-rw-r--r--lib/libc/gen/wait3.c53
-rw-r--r--lib/libc/gen/waitid.c70
-rw-r--r--lib/libc/gen/waitpid.c54
-rw-r--r--lib/libc/gen/wordexp.c11
-rw-r--r--lib/libc/gmon/Makefile.inc2
-rw-r--r--lib/libc/gmon/Symbol.map4
-rw-r--r--lib/libc/gmon/gmon.c4
-rw-r--r--lib/libc/gmon/mcount.c4
-rw-r--r--lib/libc/gmon/moncontrol.32
-rw-r--r--lib/libc/i386/Makefile.inc1
-rw-r--r--lib/libc/i386/SYS.h57
-rw-r--r--lib/libc/i386/Symbol.map50
-rw-r--r--lib/libc/i386/gen/Makefile.inc4
-rw-r--r--lib/libc/i386/gen/_setjmp.S3
-rw-r--r--lib/libc/i386/gen/fabs.S3
-rw-r--r--lib/libc/i386/gen/flt_rounds.c1
-rw-r--r--lib/libc/i386/gen/infinity.c1
-rw-r--r--lib/libc/i386/gen/makecontext.c1
-rw-r--r--lib/libc/i386/gen/rfork_thread.S113
-rw-r--r--lib/libc/i386/gen/setjmp.S3
-rw-r--r--lib/libc/i386/gen/signalcontext.c1
-rw-r--r--lib/libc/i386/gen/sigsetjmp.S2
-rw-r--r--lib/libc/i386/static_tls.h44
-rw-r--r--lib/libc/i386/stdlib/Makefile.inc2
-rw-r--r--lib/libc/i386/string/Makefile.inc1
-rw-r--r--lib/libc/i386/sys/Makefile.inc16
-rw-r--r--lib/libc/i386/sys/Ovfork.S52
-rw-r--r--lib/libc/i386/sys/cerror.S66
-rw-r--r--lib/libc/i386/sys/getcontext.S46
-rw-r--r--lib/libc/i386/sys/i386_clr_watch.c46
-rw-r--r--lib/libc/i386/sys/i386_get_fsbase.c37
-rw-r--r--lib/libc/i386/sys/i386_get_gsbase.c37
-rw-r--r--lib/libc/i386/sys/i386_get_ioperm.c48
-rw-r--r--lib/libc/i386/sys/i386_get_ldt.2138
-rw-r--r--lib/libc/i386/sys/i386_get_ldt.c46
-rw-r--r--lib/libc/i386/sys/i386_set_fsbase.c37
-rw-r--r--lib/libc/i386/sys/i386_set_gsbase.c37
-rw-r--r--lib/libc/i386/sys/i386_set_ioperm.c42
-rw-r--r--lib/libc/i386/sys/i386_set_ldt.c46
-rw-r--r--lib/libc/i386/sys/i386_set_watch.3116
-rw-r--r--lib/libc/i386/sys/i386_set_watch.c84
-rw-r--r--lib/libc/i386/sys/i386_vm86.c41
-rw-r--r--lib/libc/i386/sys/syscall.S50
-rw-r--r--lib/libc/iconv/Makefile.inc1
-rw-r--r--lib/libc/iconv/Symbol.map41
-rw-r--r--lib/libc/iconv/bsd_iconv.c1
-rw-r--r--lib/libc/iconv/citrus_bcs.c1
-rw-r--r--lib/libc/iconv/citrus_bcs_strtol.c1
-rw-r--r--lib/libc/iconv/citrus_bcs_strtoul.c1
-rw-r--r--lib/libc/iconv/citrus_csmapper.c1
-rw-r--r--lib/libc/iconv/citrus_db.c1
-rw-r--r--lib/libc/iconv/citrus_db_factory.c1
-rw-r--r--lib/libc/iconv/citrus_db_hash.c1
-rw-r--r--lib/libc/iconv/citrus_esdb.c1
-rw-r--r--lib/libc/iconv/citrus_hash.c1
-rw-r--r--lib/libc/iconv/citrus_iconv.c1
-rw-r--r--lib/libc/iconv/citrus_lookup.c1
-rw-r--r--lib/libc/iconv/citrus_lookup_factory.c1
-rw-r--r--lib/libc/iconv/citrus_mapper.c1
-rw-r--r--lib/libc/iconv/citrus_memstream.c1
-rw-r--r--lib/libc/iconv/citrus_mmap.c1
-rw-r--r--lib/libc/iconv/citrus_module.c1
-rw-r--r--lib/libc/iconv/citrus_none.c1
-rw-r--r--lib/libc/iconv/citrus_pivot_factory.c1
-rw-r--r--lib/libc/iconv/citrus_prop.c1
-rw-r--r--lib/libc/iconv/citrus_stdenc.c1
-rw-r--r--lib/libc/include/block_abi.h2
-rw-r--r--lib/libc/include/compat.h2
-rw-r--r--lib/libc/include/errlst.h1
-rw-r--r--lib/libc/include/libc_private.h111
-rw-r--r--lib/libc/include/spinlock.h1
-rw-r--r--lib/libc/inet/Makefile.inc1
-rw-r--r--lib/libc/inet/Symbol.map3
-rw-r--r--lib/libc/inet/inet_addr.c5
-rw-r--r--lib/libc/inet/inet_cidr_ntop.c4
-rw-r--r--lib/libc/inet/inet_cidr_pton.c4
-rw-r--r--lib/libc/inet/inet_lnaof.c4
-rw-r--r--lib/libc/inet/inet_makeaddr.c4
-rw-r--r--lib/libc/inet/inet_net_ntop.c4
-rw-r--r--lib/libc/inet/inet_net_pton.c6
-rw-r--r--lib/libc/inet/inet_neta.c4
-rw-r--r--lib/libc/inet/inet_netof.c4
-rw-r--r--lib/libc/inet/inet_network.c4
-rw-r--r--lib/libc/inet/inet_ntoa.c5
-rw-r--r--lib/libc/inet/inet_ntop.c4
-rw-r--r--lib/libc/inet/inet_pton.c4
-rw-r--r--lib/libc/inet/nsap_addr.c4
-rw-r--r--lib/libc/isc/Makefile.inc1
-rw-r--r--lib/libc/isc/ev_streams.c4
-rw-r--r--lib/libc/isc/ev_timers.c4
-rw-r--r--lib/libc/locale/Makefile.inc2
-rw-r--r--lib/libc/locale/Symbol.map4
-rw-r--r--lib/libc/locale/ascii.c1
-rw-r--r--lib/libc/locale/big5.c4
-rw-r--r--lib/libc/locale/btowc.c1
-rw-r--r--lib/libc/locale/c16rtomb.c1
-rw-r--r--lib/libc/locale/c32rtomb.c1
-rw-r--r--lib/libc/locale/cXXrtomb_iconv.h1
-rw-r--r--lib/libc/locale/collate.c260
-rw-r--r--lib/libc/locale/collate.h12
-rw-r--r--lib/libc/locale/collcmp.c1
-rw-r--r--lib/libc/locale/ctype.32
-rw-r--r--lib/libc/locale/digittoint.32
-rw-r--r--lib/libc/locale/euc.52
-rw-r--r--lib/libc/locale/euc.c5
-rw-r--r--lib/libc/locale/fix_grouping.c1
-rw-r--r--lib/libc/locale/gbk.c1
-rw-r--r--lib/libc/locale/isalnum.32
-rw-r--r--lib/libc/locale/isalpha.32
-rw-r--r--lib/libc/locale/isascii.32
-rw-r--r--lib/libc/locale/isblank.32
-rw-r--r--lib/libc/locale/iscntrl.32
-rw-r--r--lib/libc/locale/isctype.c4
-rw-r--r--lib/libc/locale/isdigit.32
-rw-r--r--lib/libc/locale/isgraph.32
-rw-r--r--lib/libc/locale/islower.32
-rw-r--r--lib/libc/locale/isprint.32
-rw-r--r--lib/libc/locale/ispunct.32
-rw-r--r--lib/libc/locale/isspace.32
-rw-r--r--lib/libc/locale/isupper.32
-rw-r--r--lib/libc/locale/iswalnum.32
-rw-r--r--lib/libc/locale/iswctype.c1
-rw-r--r--lib/libc/locale/isxdigit.32
-rw-r--r--lib/libc/locale/ldpart.c1
-rw-r--r--lib/libc/locale/lmessages.c1
-rw-r--r--lib/libc/locale/lmonetary.c1
-rw-r--r--lib/libc/locale/lnumeric.c1
-rw-r--r--lib/libc/locale/localeconv.32
-rw-r--r--lib/libc/locale/localeconv.c6
-rw-r--r--lib/libc/locale/mblen.32
-rw-r--r--lib/libc/locale/mblen.c1
-rw-r--r--lib/libc/locale/mbrlen.c1
-rw-r--r--lib/libc/locale/mbrtoc16.c1
-rw-r--r--lib/libc/locale/mbrtoc32.c1
-rw-r--r--lib/libc/locale/mbrtocXX_iconv.h1
-rw-r--r--lib/libc/locale/mbrtowc.c1
-rw-r--r--lib/libc/locale/mbsinit.c1
-rw-r--r--lib/libc/locale/mbsnrtowcs.c1
-rw-r--r--lib/libc/locale/mbsrtowcs.c1
-rw-r--r--lib/libc/locale/mbstowcs.32
-rw-r--r--lib/libc/locale/mbstowcs.c1
-rw-r--r--lib/libc/locale/mbtowc.32
-rw-r--r--lib/libc/locale/mbtowc.c1
-rw-r--r--lib/libc/locale/mskanji.c4
-rw-r--r--lib/libc/locale/multibyte.32
-rw-r--r--lib/libc/locale/nextwctype.c1
-rw-r--r--lib/libc/locale/nl_langinfo.c1
-rw-r--r--lib/libc/locale/nomacros.c1
-rw-r--r--lib/libc/locale/none.c4
-rw-r--r--lib/libc/locale/rpmatch.c1
-rw-r--r--lib/libc/locale/rune.c4
-rw-r--r--lib/libc/locale/runetype.c1
-rw-r--r--lib/libc/locale/setlocale.32
-rw-r--r--lib/libc/locale/setlocale.c4
-rw-r--r--lib/libc/locale/setrunelocale.c1
-rw-r--r--lib/libc/locale/table.c4
-rw-r--r--lib/libc/locale/toascii.32
-rw-r--r--lib/libc/locale/tolower.32
-rw-r--r--lib/libc/locale/tolower.c1
-rw-r--r--lib/libc/locale/toupper.32
-rw-r--r--lib/libc/locale/toupper.c1
-rw-r--r--lib/libc/locale/towlower.32
-rw-r--r--lib/libc/locale/towupper.32
-rw-r--r--lib/libc/locale/utf8.52
-rw-r--r--lib/libc/locale/wcrtomb.c1
-rw-r--r--lib/libc/locale/wcsftime.c1
-rw-r--r--lib/libc/locale/wcsnrtombs.c1
-rw-r--r--lib/libc/locale/wcsrtombs.c1
-rw-r--r--lib/libc/locale/wcstod.c1
-rw-r--r--lib/libc/locale/wcstof.c1
-rw-r--r--lib/libc/locale/wcstoimax.c7
-rw-r--r--lib/libc/locale/wcstol.c1
-rw-r--r--lib/libc/locale/wcstold.c1
-rw-r--r--lib/libc/locale/wcstoll.c7
-rw-r--r--lib/libc/locale/wcstombs.32
-rw-r--r--lib/libc/locale/wcstombs.c1
-rw-r--r--lib/libc/locale/wcstoul.c1
-rw-r--r--lib/libc/locale/wcstoull.c7
-rw-r--r--lib/libc/locale/wcstoumax.c7
-rw-r--r--lib/libc/locale/wctob.c1
-rw-r--r--lib/libc/locale/wctomb.32
-rw-r--r--lib/libc/locale/wctomb.c1
-rw-r--r--lib/libc/locale/wctrans.c1
-rw-r--r--lib/libc/locale/wctype.c1
-rw-r--r--lib/libc/locale/wcwidth.c1
-rw-r--r--lib/libc/locale/xlocale.38
-rw-r--r--lib/libc/md/Makefile.inc3
-rw-r--r--lib/libc/nameser/Makefile.inc1
-rw-r--r--lib/libc/nameser/Symbol.map3
-rw-r--r--lib/libc/nameser/ns_name.c4
-rw-r--r--lib/libc/nameser/ns_netint.c4
-rw-r--r--lib/libc/nameser/ns_parse.c4
-rw-r--r--lib/libc/nameser/ns_print.c4
-rw-r--r--lib/libc/nameser/ns_samedomain.c4
-rw-r--r--lib/libc/nameser/ns_ttl.c4
-rw-r--r--lib/libc/net/Makefile.inc151
-rw-r--r--lib/libc/net/Symbol.hesiod.map12
-rw-r--r--lib/libc/net/Symbol.map22
-rw-r--r--lib/libc/net/base64.c1
-rw-r--r--lib/libc/net/byteorder.32
-rw-r--r--lib/libc/net/ether_addr.c1
-rw-r--r--lib/libc/net/eui64.c1
-rw-r--r--lib/libc/net/gai_strerror.c1
-rw-r--r--lib/libc/net/getaddrinfo.33
-rw-r--r--lib/libc/net/getaddrinfo.c59
-rw-r--r--lib/libc/net/gethostbydns.c11
-rw-r--r--lib/libc/net/gethostbyht.c4
-rw-r--r--lib/libc/net/gethostbyname.32
-rw-r--r--lib/libc/net/gethostbynis.c1
-rw-r--r--lib/libc/net/gethostnamadr.c1
-rw-r--r--lib/libc/net/getifaddrs.c1
-rw-r--r--lib/libc/net/getifmaddrs.c1
-rw-r--r--lib/libc/net/getipnodebyname.32
-rw-r--r--lib/libc/net/getnameinfo.c55
-rw-r--r--lib/libc/net/getnetbydns.c4
-rw-r--r--lib/libc/net/getnetbyht.c5
-rw-r--r--lib/libc/net/getnetbynis.c1
-rw-r--r--lib/libc/net/getnetent.32
-rw-r--r--lib/libc/net/getnetnamadr.c1
-rw-r--r--lib/libc/net/getproto.c4
-rw-r--r--lib/libc/net/getprotoent.32
-rw-r--r--lib/libc/net/getprotoent.c4
-rw-r--r--lib/libc/net/getprotoname.c4
-rw-r--r--lib/libc/net/getservent.32
-rw-r--r--lib/libc/net/getservent.c8
-rw-r--r--lib/libc/net/hesiod.c47
-rw-r--r--lib/libc/net/if_indextoname.c1
-rw-r--r--lib/libc/net/if_nameindex.c1
-rw-r--r--lib/libc/net/if_nametoindex.c1
-rw-r--r--lib/libc/net/inet.326
-rw-r--r--lib/libc/net/ip6opt.c1
-rw-r--r--lib/libc/net/linkaddr.379
-rw-r--r--lib/libc/net/linkaddr.c310
-rw-r--r--lib/libc/net/map_v4v6.c4
-rw-r--r--lib/libc/net/name6.c1
-rw-r--r--lib/libc/net/networks2
-rw-r--r--lib/libc/net/nscache.c1
-rw-r--r--lib/libc/net/nscachedcli.c1
-rw-r--r--lib/libc/net/nsdispatch.c1
-rw-r--r--lib/libc/net/nslexer.l6
-rw-r--r--lib/libc/net/nsparser.y1
-rw-r--r--lib/libc/net/nss_compat.c1
-rw-r--r--lib/libc/net/ntoh.c1
-rw-r--r--lib/libc/net/protocols3
-rw-r--r--lib/libc/net/rcmd.32
-rw-r--r--lib/libc/net/rcmd.c4
-rw-r--r--lib/libc/net/rcmdsh.c1
-rw-r--r--lib/libc/net/recv.c53
-rw-r--r--lib/libc/net/res_config.h4
-rw-r--r--lib/libc/net/resolver.37
-rw-r--r--lib/libc/net/rthdr.c1
-rw-r--r--lib/libc/net/sctp_bindx.318
-rw-r--r--lib/libc/net/sctp_connectx.316
-rw-r--r--lib/libc/net/sctp_freepaddrs.320
-rw-r--r--lib/libc/net/sctp_getaddrlen.32
-rw-r--r--lib/libc/net/sctp_getpaddrs.320
-rw-r--r--lib/libc/net/sctp_opt_info.32
-rw-r--r--lib/libc/net/sctp_recvmsg.3198
-rw-r--r--lib/libc/net/sctp_send.3192
-rw-r--r--lib/libc/net/sctp_sendmsg.38
-rw-r--r--lib/libc/net/sctp_sys_calls.c1
-rw-r--r--lib/libc/net/send.c53
-rw-r--r--lib/libc/net/sourcefilter.c1
-rw-r--r--lib/libc/net/vars.c1
-rw-r--r--lib/libc/nls/Makefile.inc1
-rw-r--r--lib/libc/nls/Symbol.map3
-rw-r--r--lib/libc/nls/catopen.313
-rw-r--r--lib/libc/nls/msgcat.c31
-rw-r--r--lib/libc/nls/ru_RU.KOI8-R.msg2
-rw-r--r--lib/libc/nls/ru_RU.UTF-8.msg263
-rw-r--r--lib/libc/posix1e/Makefile.inc13
-rw-r--r--lib/libc/posix1e/Symbol.map3
-rw-r--r--lib/libc/posix1e/acl.37
-rw-r--r--lib/libc/posix1e/acl_branding.c1
-rw-r--r--lib/libc/posix1e/acl_calc_mask.c1
-rw-r--r--lib/libc/posix1e/acl_cmp_np.31
-rw-r--r--lib/libc/posix1e/acl_cmp_np.c1
-rw-r--r--lib/libc/posix1e/acl_compat.c1
-rw-r--r--lib/libc/posix1e/acl_copy.c1
-rw-r--r--lib/libc/posix1e/acl_delete.c1
-rw-r--r--lib/libc/posix1e/acl_delete_entry.c1
-rw-r--r--lib/libc/posix1e/acl_entry.c1
-rw-r--r--lib/libc/posix1e/acl_equiv_mode_np.c4
-rw-r--r--lib/libc/posix1e/acl_extended_file_np.31
-rw-r--r--lib/libc/posix1e/acl_extended_file_np.c1
-rw-r--r--lib/libc/posix1e/acl_flag.c1
-rw-r--r--lib/libc/posix1e/acl_free.c1
-rw-r--r--lib/libc/posix1e/acl_from_mode_np.c1
-rw-r--r--lib/libc/posix1e/acl_from_text.c1
-rw-r--r--lib/libc/posix1e/acl_from_text_nfs4.c1
-rw-r--r--lib/libc/posix1e/acl_get.312
-rw-r--r--lib/libc/posix1e/acl_get.c1
-rw-r--r--lib/libc/posix1e/acl_get_entry.36
-rw-r--r--lib/libc/posix1e/acl_id_to_name.c1
-rw-r--r--lib/libc/posix1e/acl_init.c1
-rw-r--r--lib/libc/posix1e/acl_perm.c1
-rw-r--r--lib/libc/posix1e/acl_set.c1
-rw-r--r--lib/libc/posix1e/acl_strip.c1
-rw-r--r--lib/libc/posix1e/acl_support.c1
-rw-r--r--lib/libc/posix1e/acl_support_nfs4.c1
-rw-r--r--lib/libc/posix1e/acl_to_text.c3
-rw-r--r--lib/libc/posix1e/acl_to_text_nfs4.c4
-rw-r--r--lib/libc/posix1e/acl_valid.c1
-rw-r--r--lib/libc/posix1e/extattr.c1
-rw-r--r--lib/libc/posix1e/mac.c1
-rw-r--r--lib/libc/posix1e/mac_exec.c1
-rw-r--r--lib/libc/posix1e/mac_free.38
-rw-r--r--lib/libc/posix1e/mac_get.38
-rw-r--r--lib/libc/posix1e/mac_get.c1
-rw-r--r--lib/libc/posix1e/mac_prepare.38
-rw-r--r--lib/libc/posix1e/mac_set.c1
-rw-r--r--lib/libc/posix1e/mac_text.38
-rw-r--r--lib/libc/posix1e/posix1e.34
-rw-r--r--lib/libc/powerpc/Makefile.inc1
-rw-r--r--lib/libc/powerpc/SYS.h72
-rw-r--r--lib/libc/powerpc/Symbol.map28
-rw-r--r--lib/libc/powerpc/gen/Makefile.common1
-rw-r--r--lib/libc/powerpc/gen/Makefile.inc1
-rw-r--r--lib/libc/powerpc/gen/flt_rounds.c1
-rw-r--r--lib/libc/powerpc/gen/fpgetmask.c1
-rw-r--r--lib/libc/powerpc/gen/fpgetround.c1
-rw-r--r--lib/libc/powerpc/gen/fpgetsticky.c5
-rw-r--r--lib/libc/powerpc/gen/fpsetmask.c1
-rw-r--r--lib/libc/powerpc/gen/fpsetround.c1
-rw-r--r--lib/libc/powerpc/gen/makecontext.c1
-rw-r--r--lib/libc/powerpc/gen/signalcontext.c1
-rw-r--r--lib/libc/powerpc/gen/syncicache.c5
-rw-r--r--lib/libc/powerpc/static_tls.h44
-rw-r--r--lib/libc/powerpc/sys/Makefile.inc5
-rw-r--r--lib/libc/powerpc/sys/__vdso_gettc.c66
-rw-r--r--lib/libc/powerpc64/Makefile.inc1
-rw-r--r--lib/libc/powerpc64/SYS.h97
-rw-r--r--lib/libc/powerpc64/Symbol.map35
-rw-r--r--lib/libc/powerpc64/gen/Makefile.inc1
-rw-r--r--lib/libc/powerpc64/gen/_ctx_start.S14
-rw-r--r--lib/libc/powerpc64/gen/flt_rounds.c1
-rw-r--r--lib/libc/powerpc64/gen/fpgetmask.c1
-rw-r--r--lib/libc/powerpc64/gen/fpgetround.c1
-rw-r--r--lib/libc/powerpc64/gen/fpgetsticky.c5
-rw-r--r--lib/libc/powerpc64/gen/fpsetmask.c1
-rw-r--r--lib/libc/powerpc64/gen/fpsetround.c1
-rw-r--r--lib/libc/powerpc64/gen/makecontext.c4
-rw-r--r--lib/libc/powerpc64/gen/signalcontext.c1
-rw-r--r--lib/libc/powerpc64/gen/syncicache.c5
-rw-r--r--lib/libc/powerpc64/static_tls.h44
-rw-r--r--lib/libc/powerpc64/string/Makefile.inc1
-rw-r--r--lib/libc/powerpc64/string/bcopy_resolver.c1
-rw-r--r--lib/libc/powerpc64/string/strcpy.c1
-rw-r--r--lib/libc/powerpc64/string/strcpy_resolver.c1
-rw-r--r--lib/libc/powerpc64/string/strncpy.c1
-rw-r--r--lib/libc/powerpc64/string/strncpy_resolver.c1
-rw-r--r--lib/libc/powerpc64/sys/Makefile.inc5
-rw-r--r--lib/libc/powerpc64/sys/__vdso_gettc.c63
-rw-r--r--lib/libc/powerpcspe/Makefile.inc1
-rw-r--r--lib/libc/powerpcspe/_fpmath.h56
-rw-r--r--lib/libc/powerpcspe/gen/Makefile.inc1
-rw-r--r--lib/libc/powerpcspe/gen/flt_rounds.c1
-rw-r--r--lib/libc/powerpcspe/gen/fpgetmask.c1
-rw-r--r--lib/libc/powerpcspe/gen/fpgetround.c1
-rw-r--r--lib/libc/powerpcspe/gen/fpgetsticky.c5
-rw-r--r--lib/libc/powerpcspe/gen/fpsetmask.c1
-rw-r--r--lib/libc/powerpcspe/gen/fpsetround.c1
-rw-r--r--lib/libc/powerpcspe/sys/Makefile.inc3
-rw-r--r--lib/libc/quad/Makefile.inc2
-rw-r--r--lib/libc/quad/Symbol.map13
-rw-r--r--lib/libc/quad/TESTS/Makefile2
-rw-r--r--lib/libc/quad/TESTS/divrem.c10
-rw-r--r--lib/libc/quad/TESTS/mul.c10
-rw-r--r--lib/libc/quad/adddi3.c4
-rw-r--r--lib/libc/quad/anddi3.c4
-rw-r--r--lib/libc/quad/ashldi3.c4
-rw-r--r--lib/libc/quad/ashrdi3.c4
-rw-r--r--lib/libc/quad/cmpdi2.c4
-rw-r--r--lib/libc/quad/divdi3.c4
-rw-r--r--lib/libc/quad/fixdfdi.c4
-rw-r--r--lib/libc/quad/fixsfdi.c4
-rw-r--r--lib/libc/quad/fixunsdfdi.c4
-rw-r--r--lib/libc/quad/fixunssfdi.c4
-rw-r--r--lib/libc/quad/floatdidf.c4
-rw-r--r--lib/libc/quad/floatdisf.c4
-rw-r--r--lib/libc/quad/floatunsdidf.c4
-rw-r--r--lib/libc/quad/iordi3.c4
-rw-r--r--lib/libc/quad/lshldi3.c4
-rw-r--r--lib/libc/quad/lshrdi3.c4
-rw-r--r--lib/libc/quad/moddi3.c4
-rw-r--r--lib/libc/quad/muldi3.c4
-rw-r--r--lib/libc/quad/negdi2.c4
-rw-r--r--lib/libc/quad/notdi2.c4
-rw-r--r--lib/libc/quad/qdivrem.c4
-rw-r--r--lib/libc/quad/quad.h2
-rw-r--r--lib/libc/quad/subdi3.c4
-rw-r--r--lib/libc/quad/ucmpdi2.c4
-rw-r--r--lib/libc/quad/udivdi3.c4
-rw-r--r--lib/libc/quad/umoddi3.c4
-rw-r--r--lib/libc/quad/xordi3.c4
-rw-r--r--lib/libc/regex/COPYRIGHT2
-rw-r--r--lib/libc/regex/Makefile.inc2
-rw-r--r--lib/libc/regex/Symbol.map3
-rw-r--r--lib/libc/regex/WHATSNEW1
-rw-r--r--lib/libc/regex/cname.h2
-rw-r--r--lib/libc/regex/engine.c3
-rw-r--r--lib/libc/regex/grot/debug.c1
-rw-r--r--lib/libc/regex/grot/main.c1
-rw-r--r--lib/libc/regex/grot/split.c1
-rw-r--r--lib/libc/regex/re_format.72
-rw-r--r--lib/libc/regex/regcomp.c61
-rw-r--r--lib/libc/regex/regerror.c6
-rw-r--r--lib/libc/regex/regex.32
-rw-r--r--lib/libc/regex/regex2.h2
-rw-r--r--lib/libc/regex/regexec.c6
-rw-r--r--lib/libc/regex/regfree.c6
-rw-r--r--lib/libc/regex/utils.h2
-rw-r--r--lib/libc/resolv/Makefile.inc1
-rw-r--r--lib/libc/resolv/Symbol.map3
-rw-r--r--lib/libc/resolv/herror.c5
-rw-r--r--lib/libc/resolv/mtctxres.c1
-rw-r--r--lib/libc/resolv/res_comp.c5
-rw-r--r--lib/libc/resolv/res_data.c4
-rw-r--r--lib/libc/resolv/res_debug.c5
-rw-r--r--lib/libc/resolv/res_debug.h2
-rw-r--r--lib/libc/resolv/res_findzonecut.c4
-rw-r--r--lib/libc/resolv/res_init.c11
-rw-r--r--lib/libc/resolv/res_mkquery.c10
-rw-r--r--lib/libc/resolv/res_mkupdate.c8
-rw-r--r--lib/libc/resolv/res_query.c10
-rw-r--r--lib/libc/resolv/res_send.c54
-rw-r--r--lib/libc/resolv/res_update.c4
-rw-r--r--lib/libc/riscv/SYS.h70
-rw-r--r--lib/libc/riscv/Symbol.map25
-rw-r--r--lib/libc/riscv/gen/Makefile.inc1
-rw-r--r--lib/libc/riscv/gen/flt_rounds.c11
-rw-r--r--lib/libc/riscv/gen/fpgetmask.c1
-rw-r--r--lib/libc/riscv/gen/fpsetmask.c1
-rw-r--r--lib/libc/riscv/gen/infinity.c1
-rw-r--r--lib/libc/riscv/gen/makecontext.c1
-rw-r--r--lib/libc/riscv/static_tls.h44
-rw-r--r--lib/libc/riscv/sys/Makefile.inc10
-rw-r--r--lib/libc/riscv/sys/__vdso_gettc.c54
-rw-r--r--lib/libc/riscv/sys/syscall.S38
-rw-r--r--lib/libc/rpc/Makefile.inc8
-rw-r--r--lib/libc/rpc/Symbol.map38
-rw-r--r--lib/libc/rpc/auth_des.c5
-rw-r--r--lib/libc/rpc/auth_none.c5
-rw-r--r--lib/libc/rpc/auth_time.c3
-rw-r--r--lib/libc/rpc/auth_unix.c5
-rw-r--r--lib/libc/rpc/authdes_prot.c4
-rw-r--r--lib/libc/rpc/authunix_prot.c5
-rw-r--r--lib/libc/rpc/bindresvport.31
-rw-r--r--lib/libc/rpc/bindresvport.c5
-rw-r--r--lib/libc/rpc/clnt_bcast.c5
-rw-r--r--lib/libc/rpc/clnt_dg.c175
-rw-r--r--lib/libc/rpc/clnt_generic.c7
-rw-r--r--lib/libc/rpc/clnt_perror.c5
-rw-r--r--lib/libc/rpc/clnt_raw.c5
-rw-r--r--lib/libc/rpc/clnt_simple.c5
-rw-r--r--lib/libc/rpc/clnt_vc.c185
-rw-r--r--lib/libc/rpc/crypt_client.c1
-rw-r--r--lib/libc/rpc/des_crypt.31
-rw-r--r--lib/libc/rpc/des_crypt.c4
-rw-r--r--lib/libc/rpc/des_soft.c4
-rw-r--r--lib/libc/rpc/getnetconfig.31
-rw-r--r--lib/libc/rpc/getnetconfig.c4
-rw-r--r--lib/libc/rpc/getnetpath.31
-rw-r--r--lib/libc/rpc/getnetpath.c4
-rw-r--r--lib/libc/rpc/getpublickey.c4
-rw-r--r--lib/libc/rpc/getrpcent.31
-rw-r--r--lib/libc/rpc/getrpcent.c4
-rw-r--r--lib/libc/rpc/getrpcport.31
-rw-r--r--lib/libc/rpc/getrpcport.c5
-rw-r--r--lib/libc/rpc/key_call.c2
-rw-r--r--lib/libc/rpc/key_prot_xdr.c2
-rw-r--r--lib/libc/rpc/mt_misc.c2
-rw-r--r--lib/libc/rpc/netname.c4
-rw-r--r--lib/libc/rpc/netnamer.c4
-rw-r--r--lib/libc/rpc/pmap_clnt.c5
-rw-r--r--lib/libc/rpc/pmap_getmaps.c5
-rw-r--r--lib/libc/rpc/pmap_getport.c5
-rw-r--r--lib/libc/rpc/pmap_prot.c5
-rw-r--r--lib/libc/rpc/pmap_prot2.c5
-rw-r--r--lib/libc/rpc/pmap_rmt.c5
-rw-r--r--lib/libc/rpc/publickey.31
-rw-r--r--lib/libc/rpc/publickey.51
-rw-r--r--lib/libc/rpc/rpc.31
-rw-r--r--lib/libc/rpc/rpc.51
-rw-r--r--lib/libc/rpc/rpc_callmsg.c5
-rw-r--r--lib/libc/rpc/rpc_clnt_auth.32
-rw-r--r--lib/libc/rpc/rpc_clnt_calls.32
-rw-r--r--lib/libc/rpc/rpc_clnt_create.32
-rw-r--r--lib/libc/rpc/rpc_com.h4
-rw-r--r--lib/libc/rpc/rpc_commondata.c4
-rw-r--r--lib/libc/rpc/rpc_dtablesize.c5
-rw-r--r--lib/libc/rpc/rpc_generic.c28
-rw-r--r--lib/libc/rpc/rpc_prot.c5
-rw-r--r--lib/libc/rpc/rpc_secure.34
-rw-r--r--lib/libc/rpc/rpc_soc.31
-rw-r--r--lib/libc/rpc/rpc_soc.c6
-rw-r--r--lib/libc/rpc/rpc_svc_calls.32
-rw-r--r--lib/libc/rpc/rpc_svc_create.32
-rw-r--r--lib/libc/rpc/rpc_svc_err.32
-rw-r--r--lib/libc/rpc/rpc_svc_reg.32
-rw-r--r--lib/libc/rpc/rpc_xdr.32
-rw-r--r--lib/libc/rpc/rpcb_clnt.c7
-rw-r--r--lib/libc/rpc/rpcb_prot.c6
-rw-r--r--lib/libc/rpc/rpcb_st_xdr.c1
-rw-r--r--lib/libc/rpc/rpcbind.31
-rw-r--r--lib/libc/rpc/rpcdname.c4
-rw-r--r--lib/libc/rpc/rtime.31
-rw-r--r--lib/libc/rpc/rtime.c4
-rw-r--r--lib/libc/rpc/svc.c5
-rw-r--r--lib/libc/rpc/svc_auth.c5
-rw-r--r--lib/libc/rpc/svc_auth_des.c4
-rw-r--r--lib/libc/rpc/svc_auth_unix.c5
-rw-r--r--lib/libc/rpc/svc_dg.c4
-rw-r--r--lib/libc/rpc/svc_generic.c5
-rw-r--r--lib/libc/rpc/svc_nl.c373
-rw-r--r--lib/libc/rpc/svc_raw.c6
-rw-r--r--lib/libc/rpc/svc_run.c5
-rw-r--r--lib/libc/rpc/svc_simple.c2
-rw-r--r--lib/libc/rpc/svc_vc.c7
-rw-r--r--lib/libc/secure/Makefile.inc13
-rw-r--r--lib/libc/secure/Symbol.map23
-rw-r--r--lib/libc/secure/fgets_chk.c54
-rw-r--r--lib/libc/secure/libc_stack_protector.c137
-rw-r--r--lib/libc/secure/memcpy_chk.c51
-rw-r--r--lib/libc/secure/memmove_chk.c47
-rw-r--r--lib/libc/secure/mempcpy_chk.c49
-rw-r--r--lib/libc/secure/memset_chk.c46
-rw-r--r--lib/libc/secure/snprintf_chk.c56
-rw-r--r--lib/libc/secure/sprintf_chk.c61
-rw-r--r--lib/libc/secure/stack_protector.c138
-rw-r--r--lib/libc/secure/stpcpy_chk.c53
-rw-r--r--lib/libc/secure/stpncpy_chk.c51
-rw-r--r--lib/libc/secure/strcat_chk.c60
-rw-r--r--lib/libc/secure/strcpy_chk.c52
-rw-r--r--lib/libc/secure/strlcat_chk.c70
-rw-r--r--lib/libc/secure/strlcpy_chk.c43
-rw-r--r--lib/libc/secure/strncat_chk.c70
-rw-r--r--lib/libc/secure/strncpy_chk.c51
-rw-r--r--lib/libc/secure/vsnprintf_chk.c49
-rw-r--r--lib/libc/secure/vsprintf_chk.c58
-rw-r--r--lib/libc/softfloat/Symbol.map9
-rw-r--r--lib/libc/softfloat/bits32/softfloat.c1
-rw-r--r--lib/libc/softfloat/bits64/softfloat.c1
-rw-r--r--lib/libc/softfloat/eqdf2.c1
-rw-r--r--lib/libc/softfloat/eqsf2.c1
-rw-r--r--lib/libc/softfloat/eqtf2.c1
-rw-r--r--lib/libc/softfloat/fpgetmask.c6
-rw-r--r--lib/libc/softfloat/fpgetround.c1
-rw-r--r--lib/libc/softfloat/fpgetsticky.c6
-rw-r--r--lib/libc/softfloat/fpsetmask.c1
-rw-r--r--lib/libc/softfloat/fpsetround.c1
-rw-r--r--lib/libc/softfloat/fpsetsticky.c1
-rw-r--r--lib/libc/softfloat/gedf2.c1
-rw-r--r--lib/libc/softfloat/gesf2.c1
-rw-r--r--lib/libc/softfloat/getf2.c1
-rw-r--r--lib/libc/softfloat/gexf2.c1
-rw-r--r--lib/libc/softfloat/gtdf2.c1
-rw-r--r--lib/libc/softfloat/gtsf2.c1
-rw-r--r--lib/libc/softfloat/gttf2.c1
-rw-r--r--lib/libc/softfloat/gtxf2.c1
-rw-r--r--lib/libc/softfloat/ledf2.c1
-rw-r--r--lib/libc/softfloat/lesf2.c1
-rw-r--r--lib/libc/softfloat/letf2.c1
-rw-r--r--lib/libc/softfloat/ltdf2.c1
-rw-r--r--lib/libc/softfloat/ltsf2.c1
-rw-r--r--lib/libc/softfloat/lttf2.c1
-rw-r--r--lib/libc/softfloat/nedf2.c1
-rw-r--r--lib/libc/softfloat/negdf2.c1
-rw-r--r--lib/libc/softfloat/negsf2.c1
-rw-r--r--lib/libc/softfloat/negtf2.c1
-rw-r--r--lib/libc/softfloat/negxf2.c1
-rw-r--r--lib/libc/softfloat/nesf2.c1
-rw-r--r--lib/libc/softfloat/netf2.c1
-rw-r--r--lib/libc/softfloat/nexf2.c1
-rw-r--r--lib/libc/softfloat/timesoftfloat.c1
-rw-r--r--lib/libc/softfloat/unorddf2.c1
-rw-r--r--lib/libc/softfloat/unordsf2.c1
-rw-r--r--lib/libc/stdio/Makefile.inc120
-rw-r--r--lib/libc/stdio/Symbol.map5
-rw-r--r--lib/libc/stdio/_flock_stub.c1
-rw-r--r--lib/libc/stdio/asprintf.c1
-rw-r--r--lib/libc/stdio/clrerr.c4
-rw-r--r--lib/libc/stdio/dprintf.c1
-rw-r--r--lib/libc/stdio/fclose.37
-rw-r--r--lib/libc/stdio/fclose.c4
-rw-r--r--lib/libc/stdio/fcloseall.c1
-rw-r--r--lib/libc/stdio/fdopen.c22
-rw-r--r--lib/libc/stdio/feof.c4
-rw-r--r--lib/libc/stdio/ferror.322
-rw-r--r--lib/libc/stdio/ferror.c4
-rw-r--r--lib/libc/stdio/fflush.32
-rw-r--r--lib/libc/stdio/fflush.c31
-rw-r--r--lib/libc/stdio/fgetc.c4
-rw-r--r--lib/libc/stdio/fgetln.32
-rw-r--r--lib/libc/stdio/fgetln.c4
-rw-r--r--lib/libc/stdio/fgetpos.c4
-rw-r--r--lib/libc/stdio/fgets.35
-rw-r--r--lib/libc/stdio/fgets.c6
-rw-r--r--lib/libc/stdio/fgetwc.c1
-rw-r--r--lib/libc/stdio/fgetwln.32
-rw-r--r--lib/libc/stdio/fgetwln.c1
-rw-r--r--lib/libc/stdio/fgetws.32
-rw-r--r--lib/libc/stdio/fgetws.c1
-rw-r--r--lib/libc/stdio/fileno.c29
-rw-r--r--lib/libc/stdio/findfp.c4
-rw-r--r--lib/libc/stdio/flags.c4
-rw-r--r--lib/libc/stdio/floatio.h2
-rw-r--r--lib/libc/stdio/fmemopen.c11
-rw-r--r--lib/libc/stdio/fopen.32
-rw-r--r--lib/libc/stdio/fopen.c4
-rw-r--r--lib/libc/stdio/fopencookie.c1
-rw-r--r--lib/libc/stdio/fprintf.c4
-rw-r--r--lib/libc/stdio/fpurge.c4
-rw-r--r--lib/libc/stdio/fputc.c4
-rw-r--r--lib/libc/stdio/fputs.32
-rw-r--r--lib/libc/stdio/fputs.c4
-rw-r--r--lib/libc/stdio/fputwc.c1
-rw-r--r--lib/libc/stdio/fputws.32
-rw-r--r--lib/libc/stdio/fputws.c1
-rw-r--r--lib/libc/stdio/fread.32
-rw-r--r--lib/libc/stdio/fread.c8
-rw-r--r--lib/libc/stdio/freopen.c14
-rw-r--r--lib/libc/stdio/fscanf.c4
-rw-r--r--lib/libc/stdio/fseek.32
-rw-r--r--lib/libc/stdio/fseek.c4
-rw-r--r--lib/libc/stdio/fsetpos.c4
-rw-r--r--lib/libc/stdio/ftell.c4
-rw-r--r--lib/libc/stdio/funopen.32
-rw-r--r--lib/libc/stdio/funopen.c4
-rw-r--r--lib/libc/stdio/fvwrite.c18
-rw-r--r--lib/libc/stdio/fvwrite.h2
-rw-r--r--lib/libc/stdio/fwalk.c4
-rw-r--r--lib/libc/stdio/fwide.c1
-rw-r--r--lib/libc/stdio/fwprintf.c1
-rw-r--r--lib/libc/stdio/fwrite.c4
-rw-r--r--lib/libc/stdio/fwscanf.c1
-rw-r--r--lib/libc/stdio/getc.32
-rw-r--r--lib/libc/stdio/getc.c4
-rw-r--r--lib/libc/stdio/getchar.c4
-rw-r--r--lib/libc/stdio/getdelim.c1
-rw-r--r--lib/libc/stdio/getline.c1
-rw-r--r--lib/libc/stdio/gets.c4
-rw-r--r--lib/libc/stdio/gets_s.c4
-rw-r--r--lib/libc/stdio/getw.c4
-rw-r--r--lib/libc/stdio/getwc.32
-rw-r--r--lib/libc/stdio/getwc.c1
-rw-r--r--lib/libc/stdio/getwchar.c1
-rw-r--r--lib/libc/stdio/glue.h2
-rw-r--r--lib/libc/stdio/local.h4
-rw-r--r--lib/libc/stdio/makebuf.c4
-rw-r--r--lib/libc/stdio/mktemp.320
-rw-r--r--lib/libc/stdio/mktemp.c6
-rw-r--r--lib/libc/stdio/open_memstream.c1
-rw-r--r--lib/libc/stdio/open_wmemstream.c1
-rw-r--r--lib/libc/stdio/perror.c4
-rw-r--r--lib/libc/stdio/printf-pos.c4
-rw-r--r--lib/libc/stdio/printf.312
-rw-r--r--lib/libc/stdio/printf.c4
-rw-r--r--lib/libc/stdio/printflocal.h1
-rw-r--r--lib/libc/stdio/putc.32
-rw-r--r--lib/libc/stdio/putc.c4
-rw-r--r--lib/libc/stdio/putchar.c4
-rw-r--r--lib/libc/stdio/puts.c4
-rw-r--r--lib/libc/stdio/putw.c4
-rw-r--r--lib/libc/stdio/putwc.32
-rw-r--r--lib/libc/stdio/putwc.c1
-rw-r--r--lib/libc/stdio/putwchar.c1
-rw-r--r--lib/libc/stdio/refill.c4
-rw-r--r--lib/libc/stdio/remove.32
-rw-r--r--lib/libc/stdio/remove.c4
-rw-r--r--lib/libc/stdio/rewind.c4
-rw-r--r--lib/libc/stdio/rget.c4
-rw-r--r--lib/libc/stdio/scanf.332
-rw-r--r--lib/libc/stdio/scanf.c4
-rw-r--r--lib/libc/stdio/setbuf.32
-rw-r--r--lib/libc/stdio/setbuf.c4
-rw-r--r--lib/libc/stdio/setbuffer.c4
-rw-r--r--lib/libc/stdio/setvbuf.c4
-rw-r--r--lib/libc/stdio/snprintf.c20
-rw-r--r--lib/libc/stdio/sprintf.c6
-rw-r--r--lib/libc/stdio/sscanf.c4
-rw-r--r--lib/libc/stdio/stdio.34
-rw-r--r--lib/libc/stdio/stdio.c4
-rw-r--r--lib/libc/stdio/swprintf.c1
-rw-r--r--lib/libc/stdio/swscanf.c1
-rw-r--r--lib/libc/stdio/tempnam.c4
-rw-r--r--lib/libc/stdio/tmpfile.c4
-rw-r--r--lib/libc/stdio/tmpnam.32
-rw-r--r--lib/libc/stdio/tmpnam.c7
-rw-r--r--lib/libc/stdio/ungetc.32
-rw-r--r--lib/libc/stdio/ungetc.c4
-rw-r--r--lib/libc/stdio/ungetwc.32
-rw-r--r--lib/libc/stdio/ungetwc.c1
-rw-r--r--lib/libc/stdio/vasprintf.c6
-rw-r--r--lib/libc/stdio/vdprintf.c4
-rw-r--r--lib/libc/stdio/vfprintf.c82
-rw-r--r--lib/libc/stdio/vfscanf.c44
-rw-r--r--lib/libc/stdio/vfwprintf.c58
-rw-r--r--lib/libc/stdio/vfwscanf.c46
-rw-r--r--lib/libc/stdio/vprintf.c4
-rw-r--r--lib/libc/stdio/vscanf.c4
-rw-r--r--lib/libc/stdio/vsnprintf.c13
-rw-r--r--lib/libc/stdio/vsprintf.c16
-rw-r--r--lib/libc/stdio/vsscanf.c4
-rw-r--r--lib/libc/stdio/vswprintf.c4
-rw-r--r--lib/libc/stdio/vswscanf.c7
-rw-r--r--lib/libc/stdio/vwprintf.c1
-rw-r--r--lib/libc/stdio/vwscanf.c1
-rw-r--r--lib/libc/stdio/wbuf.c16
-rw-r--r--lib/libc/stdio/wprintf.32
-rw-r--r--lib/libc/stdio/wprintf.c1
-rw-r--r--lib/libc/stdio/wscanf.32
-rw-r--r--lib/libc/stdio/wscanf.c1
-rw-r--r--lib/libc/stdio/wsetup.c4
-rw-r--r--lib/libc/stdio/xprintf_errno.c13
-rw-r--r--lib/libc/stdlib/Makefile.inc56
-rw-r--r--lib/libc/stdlib/Symbol.map7
-rw-r--r--lib/libc/stdlib/abort.32
-rw-r--r--lib/libc/stdlib/abort.c4
-rw-r--r--lib/libc/stdlib/abs.32
-rw-r--r--lib/libc/stdlib/abs.c4
-rw-r--r--lib/libc/stdlib/alloca.387
-rw-r--r--lib/libc/stdlib/atexit.32
-rw-r--r--lib/libc/stdlib/atexit.c65
-rw-r--r--lib/libc/stdlib/atexit.h2
-rw-r--r--lib/libc/stdlib/atof.32
-rw-r--r--lib/libc/stdlib/atof.c4
-rw-r--r--lib/libc/stdlib/atoi.32
-rw-r--r--lib/libc/stdlib/atoi.c4
-rw-r--r--lib/libc/stdlib/atol.32
-rw-r--r--lib/libc/stdlib/atol.c4
-rw-r--r--lib/libc/stdlib/atoll.c1
-rw-r--r--lib/libc/stdlib/bsearch.32
-rw-r--r--lib/libc/stdlib/bsearch.c7
-rw-r--r--lib/libc/stdlib/cxa_thread_atexit.c1
-rw-r--r--lib/libc/stdlib/cxa_thread_atexit_impl.c3
-rw-r--r--lib/libc/stdlib/div.32
-rw-r--r--lib/libc/stdlib/div.c34
-rw-r--r--lib/libc/stdlib/exit.337
-rw-r--r--lib/libc/stdlib/exit.c25
-rw-r--r--lib/libc/stdlib/getenv.345
-rw-r--r--lib/libc/stdlib/getenv.c37
-rw-r--r--lib/libc/stdlib/getopt.32
-rw-r--r--lib/libc/stdlib/getopt.c4
-rw-r--r--lib/libc/stdlib/getopt_long.36
-rw-r--r--lib/libc/stdlib/getopt_long.c6
-rw-r--r--lib/libc/stdlib/getsubopt.32
-rw-r--r--lib/libc/stdlib/getsubopt.c4
-rw-r--r--lib/libc/stdlib/hcreate.c1
-rw-r--r--lib/libc/stdlib/hcreate_r.c1
-rw-r--r--lib/libc/stdlib/hdestroy_r.c1
-rw-r--r--lib/libc/stdlib/heapsort.c4
-rw-r--r--lib/libc/stdlib/hsearch_r.c1
-rw-r--r--lib/libc/stdlib/imaxabs.c1
-rw-r--r--lib/libc/stdlib/imaxdiv.c8
-rw-r--r--lib/libc/stdlib/insque.c1
-rw-r--r--lib/libc/stdlib/labs.32
-rw-r--r--lib/libc/stdlib/labs.c4
-rw-r--r--lib/libc/stdlib/ldiv.32
-rw-r--r--lib/libc/stdlib/ldiv.c11
-rw-r--r--lib/libc/stdlib/llabs.c1
-rw-r--r--lib/libc/stdlib/lldiv.c8
-rw-r--r--lib/libc/stdlib/lsearch.c1
-rw-r--r--lib/libc/stdlib/malloc/Symbol.map13
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/Makefile.inc12
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h367
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs_FreeBSD.h9
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h210
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/private_namespace.h420
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/public_namespace.h22
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h433
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_FreeBSD.h199
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_typedefs.h77
-rw-r--r--lib/libc/stdlib/malloc/jemalloc/jemalloc.32560
-rw-r--r--lib/libc/stdlib/memory.359
-rw-r--r--lib/libc/stdlib/merge.c4
-rw-r--r--lib/libc/stdlib/ptsname.317
-rw-r--r--lib/libc/stdlib/ptsname.c4
-rw-r--r--lib/libc/stdlib/qsort.349
-rw-r--r--lib/libc/stdlib/qsort.c4
-rw-r--r--lib/libc/stdlib/quick_exit.c40
-rw-r--r--lib/libc/stdlib/radixsort.32
-rw-r--r--lib/libc/stdlib/radixsort.c4
-rw-r--r--lib/libc/stdlib/rand.32
-rw-r--r--lib/libc/stdlib/rand.c4
-rw-r--r--lib/libc/stdlib/random.32
-rw-r--r--lib/libc/stdlib/random.c4
-rw-r--r--lib/libc/stdlib/reallocarray.34
-rw-r--r--lib/libc/stdlib/reallocarray.c1
-rw-r--r--lib/libc/stdlib/reallocf.32
-rw-r--r--lib/libc/stdlib/reallocf.c1
-rw-r--r--lib/libc/stdlib/realpath.32
-rw-r--r--lib/libc/stdlib/realpath.c38
-rw-r--r--lib/libc/stdlib/remque.c1
-rw-r--r--lib/libc/stdlib/set_constraint_handler_s.c1
-rw-r--r--lib/libc/stdlib/strfmon.38
-rw-r--r--lib/libc/stdlib/strfmon.c199
-rw-r--r--lib/libc/stdlib/strtod.32
-rw-r--r--lib/libc/stdlib/strtoimax.c4
-rw-r--r--lib/libc/stdlib/strtol.32
-rw-r--r--lib/libc/stdlib/strtol.c4
-rw-r--r--lib/libc/stdlib/strtold.c1
-rw-r--r--lib/libc/stdlib/strtoll.c4
-rw-r--r--lib/libc/stdlib/strtonum.c1
-rw-r--r--lib/libc/stdlib/strtoq.c4
-rw-r--r--lib/libc/stdlib/strtoul.32
-rw-r--r--lib/libc/stdlib/strtoul.c4
-rw-r--r--lib/libc/stdlib/strtoull.c4
-rw-r--r--lib/libc/stdlib/strtoumax.c4
-rw-r--r--lib/libc/stdlib/strtouq.c4
-rw-r--r--lib/libc/stdlib/system.36
-rw-r--r--lib/libc/stdlib/system.c4
-rw-r--r--lib/libc/stdlib/tdelete.c1
-rw-r--r--lib/libc/stdlib/tsearch.c1
-rw-r--r--lib/libc/stdtime/Makefile.inc5
-rw-r--r--lib/libc/stdtime/Symbol.map14
-rw-r--r--lib/libc/stdtime/ctime.320
-rw-r--r--lib/libc/stdtime/strftime.32
-rw-r--r--lib/libc/stdtime/strftime.c18
-rw-r--r--lib/libc/stdtime/strptime.37
-rw-r--r--lib/libc/stdtime/strptime.c30
-rw-r--r--lib/libc/stdtime/time32.c1
-rw-r--r--lib/libc/stdtime/timelocal.c1
-rw-r--r--lib/libc/stdtime/tzset.3344
-rw-r--r--lib/libc/string/Makefile.inc6
-rw-r--r--lib/libc/string/Symbol.map7
-rw-r--r--lib/libc/string/bcmp.32
-rw-r--r--lib/libc/string/bcmp.c4
-rw-r--r--lib/libc/string/bcopy.32
-rw-r--r--lib/libc/string/bcopy.c9
-rw-r--r--lib/libc/string/bstring.311
-rw-r--r--lib/libc/string/bzero.32
-rw-r--r--lib/libc/string/bzero.c1
-rw-r--r--lib/libc/string/ffs.32
-rw-r--r--lib/libc/string/ffs.c4
-rw-r--r--lib/libc/string/ffsl.c1
-rw-r--r--lib/libc/string/ffsll.c1
-rw-r--r--lib/libc/string/fls.c1
-rw-r--r--lib/libc/string/flsl.c1
-rw-r--r--lib/libc/string/flsll.c1
-rw-r--r--lib/libc/string/index.32
-rw-r--r--lib/libc/string/memccpy.333
-rw-r--r--lib/libc/string/memccpy.c6
-rw-r--r--lib/libc/string/memchr.324
-rw-r--r--lib/libc/string/memchr.c1
-rw-r--r--lib/libc/string/memcmp.343
-rw-r--r--lib/libc/string/memcmp.c4
-rw-r--r--lib/libc/string/memcpy.317
-rw-r--r--lib/libc/string/memcpy.c1
-rw-r--r--lib/libc/string/memmem.36
-rw-r--r--lib/libc/string/memmem.c1
-rw-r--r--lib/libc/string/memmove.32
-rw-r--r--lib/libc/string/memmove.c1
-rw-r--r--lib/libc/string/mempcpy.c5
-rw-r--r--lib/libc/string/memset.320
-rw-r--r--lib/libc/string/memset.c8
-rw-r--r--lib/libc/string/memset_explicit.c27
-rw-r--r--lib/libc/string/memset_s.c1
-rw-r--r--lib/libc/string/stpcpy.c6
-rw-r--r--lib/libc/string/stpncpy.c3
-rw-r--r--lib/libc/string/strcasecmp.32
-rw-r--r--lib/libc/string/strcasecmp.c4
-rw-r--r--lib/libc/string/strcasestr.c1
-rw-r--r--lib/libc/string/strcat.32
-rw-r--r--lib/libc/string/strcat.c6
-rw-r--r--lib/libc/string/strchr.32
-rw-r--r--lib/libc/string/strchr.c1
-rw-r--r--lib/libc/string/strchrnul.c1
-rw-r--r--lib/libc/string/strcmp.32
-rw-r--r--lib/libc/string/strcmp.c4
-rw-r--r--lib/libc/string/strcoll.32
-rw-r--r--lib/libc/string/strcoll.c1
-rw-r--r--lib/libc/string/strcpy.32
-rw-r--r--lib/libc/string/strcpy.c4
-rw-r--r--lib/libc/string/strcspn.c1
-rw-r--r--lib/libc/string/strdup.32
-rw-r--r--lib/libc/string/strdup.c4
-rw-r--r--lib/libc/string/strerror.32
-rw-r--r--lib/libc/string/strerror.c18
-rw-r--r--lib/libc/string/string.37
-rw-r--r--lib/libc/string/strlcat.c3
-rw-r--r--lib/libc/string/strlcpy.327
-rw-r--r--lib/libc/string/strlcpy.c3
-rw-r--r--lib/libc/string/strlen.37
-rw-r--r--lib/libc/string/strlen.c1
-rw-r--r--lib/libc/string/strmode.32
-rw-r--r--lib/libc/string/strmode.c4
-rw-r--r--lib/libc/string/strncat.c6
-rw-r--r--lib/libc/string/strncmp.c4
-rw-r--r--lib/libc/string/strncpy.c6
-rw-r--r--lib/libc/string/strndup.c1
-rw-r--r--lib/libc/string/strnlen.c1
-rw-r--r--lib/libc/string/strnstr.c4
-rw-r--r--lib/libc/string/strpbrk.32
-rw-r--r--lib/libc/string/strpbrk.c4
-rw-r--r--lib/libc/string/strrchr.c4
-rw-r--r--lib/libc/string/strsep.32
-rw-r--r--lib/libc/string/strsep.c4
-rw-r--r--lib/libc/string/strsignal.c4
-rw-r--r--lib/libc/string/strspn.32
-rw-r--r--lib/libc/string/strspn.c1
-rw-r--r--lib/libc/string/strstr.32
-rw-r--r--lib/libc/string/strstr.c1
-rw-r--r--lib/libc/string/strtok.32
-rw-r--r--lib/libc/string/strtok.c4
-rw-r--r--lib/libc/string/strxfrm.32
-rw-r--r--lib/libc/string/strxfrm.c1
-rw-r--r--lib/libc/string/swab.32
-rw-r--r--lib/libc/string/swab.c65
-rw-r--r--lib/libc/string/timingsafe_bcmp.32
-rw-r--r--lib/libc/string/timingsafe_bcmp.c1
-rw-r--r--lib/libc/string/timingsafe_memcmp.c1
-rw-r--r--lib/libc/string/wcpcpy.c7
-rw-r--r--lib/libc/string/wcpncpy.c5
-rw-r--r--lib/libc/string/wcscasecmp.c1
-rw-r--r--lib/libc/string/wcscat.c3
-rw-r--r--lib/libc/string/wcschr.c1
-rw-r--r--lib/libc/string/wcscmp.c10
-rw-r--r--lib/libc/string/wcscoll.32
-rw-r--r--lib/libc/string/wcscoll.c1
-rw-r--r--lib/libc/string/wcscpy.c3
-rw-r--r--lib/libc/string/wcsdup.c1
-rw-r--r--lib/libc/string/wcslcat.c3
-rw-r--r--lib/libc/string/wcslcpy.c3
-rw-r--r--lib/libc/string/wcsncasecmp.c1
-rw-r--r--lib/libc/string/wcsncat.c4
-rw-r--r--lib/libc/string/wcsncmp.c9
-rw-r--r--lib/libc/string/wcsncpy.c10
-rw-r--r--lib/libc/string/wcsnlen.c1
-rw-r--r--lib/libc/string/wcsrchr.c1
-rw-r--r--lib/libc/string/wcsstr.c6
-rw-r--r--lib/libc/string/wcstok.c1
-rw-r--r--lib/libc/string/wcswidth.c1
-rw-r--r--lib/libc/string/wcsxfrm.32
-rw-r--r--lib/libc/string/wcsxfrm.c1
-rw-r--r--lib/libc/string/wmemchr.38
-rw-r--r--lib/libc/string/wmemcpy.c4
-rw-r--r--lib/libc/string/wmemmove.c3
-rw-r--r--lib/libc/string/wmempcpy.c5
-rw-r--r--lib/libc/string/wmemset.c3
-rw-r--r--lib/libc/sys/Makefile.inc542
-rw-r--r--lib/libc/sys/POSIX2x_Fork.c1
-rw-r--r--lib/libc/sys/Symbol.map982
-rw-r--r--lib/libc/sys/__error.c58
-rw-r--r--lib/libc/sys/__vdso_gettimeofday.c197
-rw-r--r--lib/libc/sys/_exit.2124
-rw-r--r--lib/libc/sys/_umtx_op.21539
-rw-r--r--lib/libc/sys/accept.2238
-rw-r--r--lib/libc/sys/accept.c5
-rw-r--r--lib/libc/sys/accept4.c5
-rw-r--r--lib/libc/sys/access.2271
-rw-r--r--lib/libc/sys/acct.2132
-rw-r--r--lib/libc/sys/adjtime.2108
-rw-r--r--lib/libc/sys/aio_fsync.2186
-rw-r--r--lib/libc/sys/aio_read.2261
-rw-r--r--lib/libc/sys/aio_suspend.c6
-rw-r--r--lib/libc/sys/aio_waitcomplete.2135
-rw-r--r--lib/libc/sys/aio_write.2256
-rw-r--r--lib/libc/sys/bind.2140
-rw-r--r--lib/libc/sys/brk.2189
-rw-r--r--lib/libc/sys/brk.c1
-rw-r--r--lib/libc/sys/cap_rights_limit.2162
-rw-r--r--lib/libc/sys/chdir.2133
-rw-r--r--lib/libc/sys/chflags.2358
-rw-r--r--lib/libc/sys/chmod.2359
-rw-r--r--lib/libc/sys/chown.2300
-rw-r--r--lib/libc/sys/chroot.2164
-rw-r--r--lib/libc/sys/clock_gettime.2207
-rw-r--r--lib/libc/sys/clock_gettime.c56
-rw-r--r--lib/libc/sys/clock_nanosleep.c7
-rw-r--r--lib/libc/sys/close.2143
-rw-r--r--lib/libc/sys/close.c4
-rw-r--r--lib/libc/sys/closefrom.292
-rw-r--r--lib/libc/sys/closefrom.c11
-rw-r--r--lib/libc/sys/compat-ino64.h99
-rw-r--r--lib/libc/sys/compat-stub.c1
-rw-r--r--lib/libc/sys/connect.2184
-rw-r--r--lib/libc/sys/connect.c5
-rw-r--r--lib/libc/sys/copy_file_range.2210
-rw-r--r--lib/libc/sys/creat.c49
-rw-r--r--lib/libc/sys/dup.2170
-rw-r--r--lib/libc/sys/execve.2381
-rw-r--r--lib/libc/sys/fcntl.2792
-rw-r--r--lib/libc/sys/fcntl.c4
-rw-r--r--lib/libc/sys/fdatasync.c4
-rw-r--r--lib/libc/sys/fhlink.2255
-rw-r--r--lib/libc/sys/fhopen.2145
-rw-r--r--lib/libc/sys/fhreadlink.297
-rw-r--r--lib/libc/sys/flock.2172
-rw-r--r--lib/libc/sys/fork.2270
-rw-r--r--lib/libc/sys/fork.c4
-rw-r--r--lib/libc/sys/fstat.c51
-rw-r--r--lib/libc/sys/fstatat.c47
-rw-r--r--lib/libc/sys/fstatfs.c51
-rw-r--r--lib/libc/sys/fsync.2132
-rw-r--r--lib/libc/sys/fsync.c4
-rw-r--r--lib/libc/sys/getdents.c8
-rw-r--r--lib/libc/sys/getdirentries.2209
-rw-r--r--lib/libc/sys/getdirentries.c114
-rw-r--r--lib/libc/sys/getdtablesize.261
-rw-r--r--lib/libc/sys/getfh.2233
-rw-r--r--lib/libc/sys/getfsstat.2131
-rw-r--r--lib/libc/sys/getfsstat.c62
-rw-r--r--lib/libc/sys/getgid.284
-rw-r--r--lib/libc/sys/getgroups.2106
-rw-r--r--lib/libc/sys/getitimer.2194
-rw-r--r--lib/libc/sys/getlogin.2203
-rw-r--r--lib/libc/sys/getpeername.297
-rw-r--r--lib/libc/sys/getpgrp.2141
-rw-r--r--lib/libc/sys/getpid.289
-rw-r--r--lib/libc/sys/getpriority.2149
-rw-r--r--lib/libc/sys/getrlimit.2237
-rw-r--r--lib/libc/sys/getrusage.2185
-rw-r--r--lib/libc/sys/getsockname.297
-rw-r--r--lib/libc/sys/getsockopt.2624
-rw-r--r--lib/libc/sys/gettimeofday.2130
-rw-r--r--lib/libc/sys/gettimeofday.c52
-rw-r--r--lib/libc/sys/getuid.290
-rw-r--r--lib/libc/sys/interposing_table.c91
-rw-r--r--lib/libc/sys/intro.2767
-rw-r--r--lib/libc/sys/ioctl.2153
-rw-r--r--lib/libc/sys/jail.2412
-rw-r--r--lib/libc/sys/kevent.c8
-rw-r--r--lib/libc/sys/kill.2158
-rw-r--r--lib/libc/sys/kldfind.284
-rw-r--r--lib/libc/sys/kldfirstmod.274
-rw-r--r--lib/libc/sys/kldload.294
-rw-r--r--lib/libc/sys/kldnext.287
-rw-r--r--lib/libc/sys/kldstat.2131
-rw-r--r--lib/libc/sys/kldsym.2119
-rw-r--r--lib/libc/sys/kldunload.292
-rw-r--r--lib/libc/sys/kqueue.2887
-rw-r--r--lib/libc/sys/ktrace.2206
-rw-r--r--lib/libc/sys/link.2318
-rw-r--r--lib/libc/sys/lio_listio.2235
-rw-r--r--lib/libc/sys/listen.2203
-rw-r--r--lib/libc/sys/lockf.c82
-rw-r--r--lib/libc/sys/lseek.2245
-rw-r--r--lib/libc/sys/lstat.c14
-rw-r--r--lib/libc/sys/madvise.2185
-rw-r--r--lib/libc/sys/mincore.2151
-rw-r--r--lib/libc/sys/minherit.2150
-rw-r--r--lib/libc/sys/mkdir.2181
-rw-r--r--lib/libc/sys/mkfifo.2182
-rw-r--r--lib/libc/sys/mknod.2183
-rw-r--r--lib/libc/sys/mknod.c1
-rw-r--r--lib/libc/sys/mlock.2178
-rw-r--r--lib/libc/sys/mmap.2566
-rw-r--r--lib/libc/sys/mount.2402
-rw-r--r--lib/libc/sys/mprotect.2130
-rw-r--r--lib/libc/sys/mq_open.2332
-rw-r--r--lib/libc/sys/mq_unlink.2119
-rw-r--r--lib/libc/sys/msync.2125
-rw-r--r--lib/libc/sys/msync.c5
-rw-r--r--lib/libc/sys/munmap.277
-rw-r--r--lib/libc/sys/nanosleep.2221
-rw-r--r--lib/libc/sys/nanosleep.c5
-rw-r--r--lib/libc/sys/nfssvc.2257
-rw-r--r--lib/libc/sys/open.2687
-rw-r--r--lib/libc/sys/open.c4
-rw-r--r--lib/libc/sys/openat.c4
-rw-r--r--lib/libc/sys/pathconf.2268
-rw-r--r--lib/libc/sys/pdfork.c4
-rw-r--r--lib/libc/sys/pipe.2177
-rw-r--r--lib/libc/sys/pipe.c1
-rw-r--r--lib/libc/sys/poll.2293
-rw-r--r--lib/libc/sys/poll.c11
-rw-r--r--lib/libc/sys/posix_fadvise.2142
-rw-r--r--lib/libc/sys/posix_fallocate.2151
-rw-r--r--lib/libc/sys/ppoll.c15
-rw-r--r--lib/libc/sys/procctl.2857
-rw-r--r--lib/libc/sys/profil.2121
-rw-r--r--lib/libc/sys/pselect.c6
-rw-r--r--lib/libc/sys/ptrace.21435
-rw-r--r--lib/libc/sys/ptrace.c46
-rw-r--r--lib/libc/sys/quotactl.2262
-rw-r--r--lib/libc/sys/read.2309
-rw-r--r--lib/libc/sys/read.c5
-rw-r--r--lib/libc/sys/readlink.2159
-rw-r--r--lib/libc/sys/readv.c11
-rw-r--r--lib/libc/sys/reboot.2164
-rw-r--r--lib/libc/sys/recv.2396
-rw-r--r--lib/libc/sys/recv.c47
-rw-r--r--lib/libc/sys/recvfrom.c13
-rw-r--r--lib/libc/sys/recvmsg.c11
-rw-r--r--lib/libc/sys/rename.2341
-rw-r--r--lib/libc/sys/revoke.2109
-rw-r--r--lib/libc/sys/rmdir.2119
-rw-r--r--lib/libc/sys/sctp_generic_sendmsg.284
-rw-r--r--lib/libc/sys/sctp_peeloff.274
-rw-r--r--lib/libc/sys/select.2227
-rw-r--r--lib/libc/sys/select.c5
-rw-r--r--lib/libc/sys/send.2294
-rw-r--r--lib/libc/sys/send.c46
-rw-r--r--lib/libc/sys/sendfile.2443
-rw-r--r--lib/libc/sys/sendmsg.c5
-rw-r--r--lib/libc/sys/sendto.c7
-rw-r--r--lib/libc/sys/setcontext.c5
-rw-r--r--lib/libc/sys/setfib.2105
-rw-r--r--lib/libc/sys/setgroups.2103
-rw-r--r--lib/libc/sys/setpgid.2109
-rw-r--r--lib/libc/sys/setregid.289
-rw-r--r--lib/libc/sys/setreuid.289
-rw-r--r--lib/libc/sys/setsid.280
-rw-r--r--lib/libc/sys/setuid.2188
-rw-r--r--lib/libc/sys/shm_open.c94
-rw-r--r--lib/libc/sys/shutdown.2170
-rw-r--r--lib/libc/sys/sigaction.2794
-rw-r--r--lib/libc/sys/sigaction.c5
-rw-r--r--lib/libc/sys/sigaltstack.2161
-rw-r--r--lib/libc/sys/sigfastblock.2164
-rw-r--r--lib/libc/sys/sigpending.276
-rw-r--r--lib/libc/sys/sigprocmask.2130
-rw-r--r--lib/libc/sys/sigprocmask.c5
-rw-r--r--lib/libc/sys/sigqueue.2161
-rw-r--r--lib/libc/sys/sigreturn.288
-rw-r--r--lib/libc/sys/sigstack.249
-rw-r--r--lib/libc/sys/sigsuspend.284
-rw-r--r--lib/libc/sys/sigsuspend.c5
-rw-r--r--lib/libc/sys/sigtimedwait.c6
-rw-r--r--lib/libc/sys/sigwait.c20
-rw-r--r--lib/libc/sys/sigwaitinfo.c5
-rw-r--r--lib/libc/sys/socket.2351
-rw-r--r--lib/libc/sys/socketpair.2106
-rw-r--r--lib/libc/sys/stat.2491
-rw-r--r--lib/libc/sys/stat.c14
-rw-r--r--lib/libc/sys/statfs.2255
-rw-r--r--lib/libc/sys/statfs.c47
-rw-r--r--lib/libc/sys/swapcontext.c5
-rw-r--r--lib/libc/sys/swapon.2161
-rw-r--r--lib/libc/sys/symlink.2205
-rw-r--r--lib/libc/sys/sync.276
-rw-r--r--lib/libc/sys/sysarch.280
-rw-r--r--lib/libc/sys/syscall.276
-rw-r--r--lib/libc/sys/thr_exit.292
-rw-r--r--lib/libc/sys/thr_kill.2137
-rw-r--r--lib/libc/sys/thr_new.2247
-rw-r--r--lib/libc/sys/thr_self.292
-rw-r--r--lib/libc/sys/thr_set_name.296
-rw-r--r--lib/libc/sys/thr_suspend.2131
-rw-r--r--lib/libc/sys/thr_wake.2114
-rw-r--r--lib/libc/sys/timer_create.2198
-rw-r--r--lib/libc/sys/timerfd.2340
-rw-r--r--lib/libc/sys/trivial-vdso_tc.c46
-rw-r--r--lib/libc/sys/truncate.2169
-rw-r--r--lib/libc/sys/umask.287
-rw-r--r--lib/libc/sys/undelete.2106
-rw-r--r--lib/libc/sys/unlink.2283
-rw-r--r--lib/libc/sys/utimensat.2309
-rw-r--r--lib/libc/sys/utimes.2263
-rw-r--r--lib/libc/sys/vadvise.c1
-rw-r--r--lib/libc/sys/vfork.2144
-rw-r--r--lib/libc/sys/wait.2687
-rw-r--r--lib/libc/sys/wait.c50
-rw-r--r--lib/libc/sys/wait3.c49
-rw-r--r--lib/libc/sys/wait4.c5
-rw-r--r--lib/libc/sys/wait6.c6
-rw-r--r--lib/libc/sys/waitid.c67
-rw-r--r--lib/libc/sys/waitpid.c50
-rw-r--r--lib/libc/sys/write.2313
-rw-r--r--lib/libc/sys/write.c5
-rw-r--r--lib/libc/sys/writev.c5
-rw-r--r--lib/libc/tests/Makefile3
-rw-r--r--lib/libc/tests/Makefile.netbsd-tests1
-rw-r--r--lib/libc/tests/c063/Makefile1
-rw-r--r--lib/libc/tests/db/Makefile5
-rw-r--r--lib/libc/tests/db/dbm_nextkey_test.c53
-rw-r--r--lib/libc/tests/db/dbm_open_test.c52
-rw-r--r--lib/libc/tests/db/dbm_perm_test.c98
-rw-r--r--lib/libc/tests/gen/Makefile29
-rw-r--r--lib/libc/tests/gen/arc4random_test.c27
-rw-r--r--lib/libc/tests/gen/dir2_test.c1
-rw-r--r--lib/libc/tests/gen/dlopen_empty_test.c1
-rw-r--r--lib/libc/tests/gen/execve/Makefile1
-rw-r--r--lib/libc/tests/gen/fmtcheck_test.c1
-rw-r--r--lib/libc/tests/gen/fmtmsg_test.c1
-rw-r--r--lib/libc/tests/gen/fnmatch_test.c82
-rw-r--r--lib/libc/tests/gen/fnmatch_testcases.h1
-rw-r--r--lib/libc/tests/gen/fts_blocks_test.c68
-rw-r--r--lib/libc/tests/gen/fts_misc_test.c78
-rw-r--r--lib/libc/tests/gen/fts_options_test.c394
-rw-r--r--lib/libc/tests/gen/fts_test.h81
-rw-r--r--lib/libc/tests/gen/ftw_test.c1
-rw-r--r--lib/libc/tests/gen/getentropy_test.c12
-rw-r--r--lib/libc/tests/gen/getmntinfo_test.c1
-rw-r--r--lib/libc/tests/gen/glob2_test.c76
-rw-r--r--lib/libc/tests/gen/glob_blocks_test.c62
-rw-r--r--lib/libc/tests/gen/makecontext_test.c1
-rw-r--r--lib/libc/tests/gen/opendir_test.c145
-rw-r--r--lib/libc/tests/gen/popen_test.c1
-rw-r--r--lib/libc/tests/gen/posix_spawn/Makefile1
-rw-r--r--lib/libc/tests/gen/posix_spawn_test.c51
-rw-r--r--lib/libc/tests/gen/realpath2_test.c1
-rw-r--r--lib/libc/tests/gen/scandir_blocks_test.c118
-rw-r--r--lib/libc/tests/gen/scandir_test.c195
-rw-r--r--lib/libc/tests/gen/sig2str_test.c213
-rw-r--r--lib/libc/tests/gen/sigsetops_test.c1
-rw-r--r--lib/libc/tests/gen/test-fnmatch.c1
-rw-r--r--lib/libc/tests/gen/wordexp_test.c27
-rw-r--r--lib/libc/tests/hash/Makefile1
-rw-r--r--lib/libc/tests/iconv/Makefile1
-rw-r--r--lib/libc/tests/iconv/iconvctl_test.c1
-rw-r--r--lib/libc/tests/inet/Makefile1
-rw-r--r--lib/libc/tests/locale/Makefile1
-rw-r--r--lib/libc/tests/locale/btowc_test.c1
-rw-r--r--lib/libc/tests/locale/c16rtomb_test.c1
-rw-r--r--lib/libc/tests/locale/iswctype_test.c1
-rw-r--r--lib/libc/tests/locale/mblen_test.c1
-rw-r--r--lib/libc/tests/locale/mbrlen_test.c1
-rw-r--r--lib/libc/tests/locale/mbrtoc16_test.c1
-rw-r--r--lib/libc/tests/locale/mbrtowc_test.c1
-rw-r--r--lib/libc/tests/locale/mbsnrtowcs_test.c1
-rw-r--r--lib/libc/tests/locale/mbsrtowcs_test.c1
-rw-r--r--lib/libc/tests/locale/mbstowcs_test.c1
-rw-r--r--lib/libc/tests/locale/mbtowc_test.c1
-rw-r--r--lib/libc/tests/locale/towctrans_test.c1
-rw-r--r--lib/libc/tests/locale/wcrtomb_test.c1
-rw-r--r--lib/libc/tests/locale/wcsnrtombs_test.c1
-rw-r--r--lib/libc/tests/locale/wcsrtombs_test.c1
-rw-r--r--lib/libc/tests/locale/wcstombs_test.c1
-rw-r--r--lib/libc/tests/locale/wctomb_test.c14
-rw-r--r--lib/libc/tests/net/Makefile7
-rw-r--r--lib/libc/tests/net/getaddrinfo/Makefile42
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/basics_v4.exp42
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/basics_v4_only.exp50
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/basics_v4v6.exp50
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/basics_v4v6_prefer_v4.exp50
-rwxr-xr-xlib/libc/tests/net/getaddrinfo/data/generate_testdata.sh45
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_host_v4.exp44
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_host_v4_only.exp68
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_host_v4v6.exp68
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_host_v4v6_prefer_v4.exp68
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_serv_v4.exp17
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_serv_v4_only.exp20
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6.exp20
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6_prefer_v4.exp20
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/scoped.exp5
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/scoped_v4_only.exp5
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/scoped_v4v6_prefer_v4.exp5
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/sock_raw_v4.exp13
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/sock_raw_v4_only.exp15
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6.exp15
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6_prefer_v4.exp15
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/spec_fam_v4.exp7
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/spec_fam_v4_only.exp10
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6.exp10
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6_prefer_v4.exp10
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/unsup_fam.exp2
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4_only.exp2
-rw-r--r--lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4v6_prefer_v4.exp2
-rw-r--r--lib/libc/tests/net/getaddrinfo/getaddrinfo.c271
-rwxr-xr-xlib/libc/tests/net/getaddrinfo/getaddrinfo_test.sh443
-rw-r--r--lib/libc/tests/net/link_addr_test.cc532
-rw-r--r--lib/libc/tests/nss/Makefile1
-rw-r--r--lib/libc/tests/nss/getaddrinfo_test.c1
-rw-r--r--lib/libc/tests/nss/getgr_test.c5
-rw-r--r--lib/libc/tests/nss/gethostby_test.c1
-rw-r--r--lib/libc/tests/nss/getproto_test.c1
-rw-r--r--lib/libc/tests/nss/getpw_test.c5
-rw-r--r--lib/libc/tests/nss/getrpc_test.c1
-rw-r--r--lib/libc/tests/nss/getserv_test.c5
-rw-r--r--lib/libc/tests/nss/getusershell_test.c1
-rw-r--r--lib/libc/tests/regex/Makefile1
-rw-r--r--lib/libc/tests/regex/Makefile.inc1
-rwxr-xr-xlib/libc/tests/regex/multibyte.sh43
-rw-r--r--lib/libc/tests/resolv/Makefile1
-rw-r--r--lib/libc/tests/rpc/Makefile1
-rw-r--r--lib/libc/tests/secure/Makefile39
-rw-r--r--lib/libc/tests/secure/fortify_poll_test.c617
-rw-r--r--lib/libc/tests/secure/fortify_random_test.c316
-rw-r--r--lib/libc/tests/secure/fortify_select_test.c769
-rw-r--r--lib/libc/tests/secure/fortify_signal_test.c316
-rw-r--r--lib/libc/tests/secure/fortify_socket_test.c1971
-rw-r--r--lib/libc/tests/secure/fortify_stdio_test.c1559
-rw-r--r--lib/libc/tests/secure/fortify_stdlib_test.c610
-rw-r--r--lib/libc/tests/secure/fortify_string_test.c2271
-rw-r--r--lib/libc/tests/secure/fortify_strings_test.c615
-rw-r--r--lib/libc/tests/secure/fortify_uio_test.c917
-rw-r--r--lib/libc/tests/secure/fortify_unistd_test.c2199
-rw-r--r--lib/libc/tests/secure/fortify_wchar_test.c2124
-rwxr-xr-xlib/libc/tests/secure/generate-fortify-tests.lua1581
-rw-r--r--lib/libc/tests/setjmp/Makefile1
-rw-r--r--lib/libc/tests/ssp/Makefile5
-rw-r--r--lib/libc/tests/stdio/Makefile11
-rw-r--r--lib/libc/tests/stdio/fdopen_test.c1
-rw-r--r--lib/libc/tests/stdio/flushlbuf_test.c155
-rw-r--r--lib/libc/tests/stdio/fmemopen2_test.c34
-rw-r--r--lib/libc/tests/stdio/fopen_test.c1
-rw-r--r--lib/libc/tests/stdio/freopen_test.c1
-rw-r--r--lib/libc/tests/stdio/getdelim_test.c1
-rw-r--r--lib/libc/tests/stdio/gets_s_test.c1
-rw-r--r--lib/libc/tests/stdio/mkostemp_test.c1
-rw-r--r--lib/libc/tests/stdio/open_memstream2_test.c1
-rw-r--r--lib/libc/tests/stdio/open_wmemstream_test.c1
-rw-r--r--lib/libc/tests/stdio/perror_test.c1
-rw-r--r--lib/libc/tests/stdio/print_positional_test.c1
-rw-r--r--lib/libc/tests/stdio/printbasic_test.c1
-rw-r--r--lib/libc/tests/stdio/printfloat_test.c1
-rw-r--r--lib/libc/tests/stdio/scanfloat_test.c137
-rw-r--r--lib/libc/tests/stdio/snprintf_test.c87
-rw-r--r--lib/libc/tests/stdio/sscanf_test.c65
-rw-r--r--lib/libc/tests/stdio/swprintf_test.c206
-rw-r--r--lib/libc/tests/stdio/swscanf_test.c73
-rw-r--r--lib/libc/tests/stdlib/Makefile12
-rw-r--r--lib/libc/tests/stdlib/clearenv_test.c1
-rw-r--r--lib/libc/tests/stdlib/cxa_atexit_test.c132
-rw-r--r--lib/libc/tests/stdlib/cxa_thread_atexit_nothr_test.cc1
-rw-r--r--lib/libc/tests/stdlib/cxa_thread_atexit_test.cc1
-rw-r--r--lib/libc/tests/stdlib/dynthr_mod/Makefile2
-rw-r--r--lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c1
-rw-r--r--lib/libc/tests/stdlib/dynthr_test.c1
-rw-r--r--lib/libc/tests/stdlib/getenv_r_test.c69
-rw-r--r--lib/libc/tests/stdlib/heapsort_test.c1
-rw-r--r--lib/libc/tests/stdlib/libatexit/Makefile11
-rw-r--r--lib/libc/tests/stdlib/libatexit/libatexit.cc67
-rw-r--r--lib/libc/tests/stdlib/libc_exit_test.c154
-rw-r--r--lib/libc/tests/stdlib/mergesort_test.c1
-rw-r--r--lib/libc/tests/stdlib/qsort_r_compat_test.c1
-rw-r--r--lib/libc/tests/stdlib/qsort_r_test.c1
-rw-r--r--lib/libc/tests/stdlib/qsort_s_test.c1
-rw-r--r--lib/libc/tests/stdlib/qsort_test.c1
-rw-r--r--lib/libc/tests/stdlib/set_constraint_handler_s_test.c1
-rw-r--r--lib/libc/tests/stdlib/strfmon_test.c1
-rw-r--r--lib/libc/tests/stdlib/tsearch_test.c1
-rw-r--r--lib/libc/tests/stdtime/Makefile10
-rw-r--r--lib/libc/tests/stdtime/detect_tz_changes_test.c281
-rw-r--r--lib/libc/tests/stdtime/strptime_test.c50
-rw-r--r--lib/libc/tests/string/Makefile17
-rw-r--r--lib/libc/tests/string/bcmp_test.c32
-rw-r--r--lib/libc/tests/string/ffs_test.c1
-rw-r--r--lib/libc/tests/string/fls_test.c1
-rw-r--r--lib/libc/tests/string/memccpy_test.c229
-rw-r--r--lib/libc/tests/string/memcmp_test.c88
-rw-r--r--lib/libc/tests/string/memrchr_test.c116
-rw-r--r--lib/libc/tests/string/memset_s_test.c1
-rw-r--r--lib/libc/tests/string/memset_test.c29
-rw-r--r--lib/libc/tests/string/stpncpy_test.c100
-rw-r--r--lib/libc/tests/string/strcmp_test.c132
-rw-r--r--lib/libc/tests/string/strcspn_test.c269
-rw-r--r--lib/libc/tests/string/strlcpy_test.c183
-rw-r--r--lib/libc/tests/string/strncmp_test.c165
-rw-r--r--lib/libc/tests/string/strnlen_test.c141
-rw-r--r--lib/libc/tests/string/strspn_test.c30
-rw-r--r--lib/libc/tests/string/strxfrm_test.c1
-rw-r--r--lib/libc/tests/string/timingsafe_bcmp_test.c32
-rw-r--r--lib/libc/tests/string/timingsafe_memcmp_test.c32
-rw-r--r--lib/libc/tests/string/wcscasecmp_test.c1
-rw-r--r--lib/libc/tests/string/wcscoll_test.c1
-rw-r--r--lib/libc/tests/string/wcsnlen_test.c1
-rw-r--r--lib/libc/tests/sys/Makefile6
-rw-r--r--lib/libc/tests/sys/brk_test.c1
-rw-r--r--lib/libc/tests/sys/cpuset_test.c3
-rw-r--r--lib/libc/tests/sys/errno_test.c36
-rw-r--r--lib/libc/tests/sys/mlock_helper.c1
-rw-r--r--lib/libc/tests/sys/queue_test.c1
-rw-r--r--lib/libc/tests/sys/sendfile_test.c1
-rw-r--r--lib/libc/tests/sys/swapcontext_test.c63
-rw-r--r--lib/libc/tests/termios/Makefile1
-rw-r--r--lib/libc/tests/time/Makefile1
-rw-r--r--lib/libc/tests/tls/Makefile1
-rw-r--r--lib/libc/tests/tls/dso/Makefile2
-rw-r--r--lib/libc/tests/tls_dso/Makefile2
-rw-r--r--lib/libc/tests/ttyio/Makefile1
-rw-r--r--lib/libc/uuid/Makefile.inc1
-rw-r--r--lib/libc/uuid/Symbol.map3
-rw-r--r--lib/libc/uuid/uuid.310
-rw-r--r--lib/libc/uuid/uuid_stream.c1
-rw-r--r--lib/libc/x86/gen/Makefile.inc1
-rw-r--r--lib/libc/x86/gen/getcontextx.c1
-rw-r--r--lib/libc/x86/sys/Makefile.inc23
-rw-r--r--lib/libc/x86/sys/__vdso_gettc.c454
-rw-r--r--lib/libc/x86/sys/pkru.3203
-rw-r--r--lib/libc/x86/sys/pkru.c135
-rw-r--r--lib/libc/xdr/Makefile.inc19
-rw-r--r--lib/libc/xdr/Symbol.map3
-rw-r--r--lib/libc/xdr/xdr.31
-rw-r--r--lib/libc/xdr/xdr.c11
-rw-r--r--lib/libc/xdr/xdr_array.c5
-rw-r--r--lib/libc/xdr/xdr_float.c5
-rw-r--r--lib/libc/xdr/xdr_mem.c5
-rw-r--r--lib/libc/xdr/xdr_rec.c80
-rw-r--r--lib/libc/xdr/xdr_reference.c7
-rw-r--r--lib/libc/xdr/xdr_sizeof.c1
-rw-r--r--lib/libc/xdr/xdr_stdio.c5
-rw-r--r--lib/libc/yp/Makefile.inc2
-rw-r--r--lib/libc/yp/Symbol.map35
-rw-r--r--lib/libc/yp/xdryp.c1
-rw-r--r--lib/libc/yp/yplib.c3
-rw-r--r--lib/libc_nonshared/Makefile2
-rw-r--r--lib/libc_nonshared/Makefile.iconv1
-rw-r--r--lib/libcalendar/Makefile1
-rw-r--r--lib/libcam/Makefile6
-rw-r--r--lib/libcam/camlib.c1
-rw-r--r--lib/libcam/camlib.h1
-rw-r--r--lib/libcam/scsi_cmdparse.c1
-rw-r--r--lib/libcam/scsi_wrap.c1
-rw-r--r--lib/libcam/tests/Makefile1
-rw-r--r--lib/libcapsicum/Makefile1
-rw-r--r--lib/libcapsicum/capsicum_helpers.328
-rw-r--r--lib/libcapsicum/capsicum_helpers.h9
-rw-r--r--lib/libcasper/Makefile1
-rw-r--r--lib/libcasper/Makefile.inc1
-rw-r--r--lib/libcasper/libcasper/Makefile1
-rw-r--r--lib/libcasper/libcasper/libcasper.321
-rw-r--r--lib/libcasper/libcasper/libcasper.c1
-rw-r--r--lib/libcasper/libcasper/libcasper_service.c1
-rw-r--r--lib/libcasper/libcasper/service.c3
-rw-r--r--lib/libcasper/libcasper/zygote.c1
-rw-r--r--lib/libcasper/services/Makefile1
-rw-r--r--lib/libcasper/services/Makefile.inc1
-rw-r--r--lib/libcasper/services/cap_dns/Makefile1
-rw-r--r--lib/libcasper/services/cap_dns/cap_dns.c5
-rw-r--r--lib/libcasper/services/cap_dns/cap_dns.h1
-rw-r--r--lib/libcasper/services/cap_dns/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_dns/tests/Makefile.depend10
-rw-r--r--lib/libcasper/services/cap_dns/tests/dns_test.c39
-rw-r--r--lib/libcasper/services/cap_fileargs/Makefile1
-rw-r--r--lib/libcasper/services/cap_fileargs/cap_fileargs.314
-rw-r--r--lib/libcasper/services/cap_fileargs/cap_fileargs.c1
-rw-r--r--lib/libcasper/services/cap_fileargs/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_fileargs/tests/fileargs_test.c17
-rw-r--r--lib/libcasper/services/cap_grp/Makefile4
-rw-r--r--lib/libcasper/services/cap_grp/cap_grp.39
-rw-r--r--lib/libcasper/services/cap_grp/cap_grp.c1
-rw-r--r--lib/libcasper/services/cap_grp/cap_grp.h1
-rw-r--r--lib/libcasper/services/cap_grp/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_grp/tests/Makefile.depend8
-rw-r--r--lib/libcasper/services/cap_grp/tests/grp_test.c2
-rw-r--r--lib/libcasper/services/cap_net/Makefile1
-rw-r--r--lib/libcasper/services/cap_net/Makefile.depend17
-rw-r--r--lib/libcasper/services/cap_net/cap_net.328
-rw-r--r--lib/libcasper/services/cap_net/cap_net.c61
-rw-r--r--lib/libcasper/services/cap_net/cap_net.h22
-rw-r--r--lib/libcasper/services/cap_net/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_net/tests/net_test.c183
-rw-r--r--lib/libcasper/services/cap_netdb/Makefile4
-rw-r--r--lib/libcasper/services/cap_netdb/Makefile.depend17
-rw-r--r--lib/libcasper/services/cap_netdb/cap_netdb.36
-rw-r--r--lib/libcasper/services/cap_netdb/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_netdb/tests/netdb_test.c1
-rw-r--r--lib/libcasper/services/cap_pwd/Makefile4
-rw-r--r--lib/libcasper/services/cap_pwd/cap_pwd.37
-rw-r--r--lib/libcasper/services/cap_pwd/cap_pwd.c2
-rw-r--r--lib/libcasper/services/cap_pwd/cap_pwd.h1
-rw-r--r--lib/libcasper/services/cap_pwd/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_pwd/tests/Makefile.depend8
-rw-r--r--lib/libcasper/services/cap_pwd/tests/pwd_test.c2
-rw-r--r--lib/libcasper/services/cap_sysctl/Makefile1
-rw-r--r--lib/libcasper/services/cap_sysctl/cap_sysctl.311
-rw-r--r--lib/libcasper/services/cap_sysctl/cap_sysctl.c2
-rw-r--r--lib/libcasper/services/cap_sysctl/cap_sysctl.h1
-rw-r--r--lib/libcasper/services/cap_sysctl/tests/Makefile1
-rw-r--r--lib/libcasper/services/cap_sysctl/tests/Makefile.depend9
-rw-r--r--lib/libcasper/services/cap_sysctl/tests/sysctl_test.c2
-rw-r--r--lib/libcasper/services/cap_syslog/Makefile1
-rw-r--r--lib/libcasper/services/cap_syslog/cap_syslog.37
-rw-r--r--lib/libcasper/services/tests/Makefile1
-rw-r--r--lib/libcasper/tests/Makefile1
-rw-r--r--lib/libcbor/Makefile2
-rw-r--r--lib/libcbor/Makefile.depend16
-rw-r--r--lib/libclang_rt/Makefile153
-rw-r--r--lib/libclang_rt/Makefile.inc5
-rw-r--r--lib/libclang_rt/asan-preinit/Makefile1
-rw-r--r--lib/libclang_rt/asan/Makefile11
-rw-r--r--lib/libclang_rt/asan/Makefile.depend3
-rw-r--r--lib/libclang_rt/asan_cxx/Makefile1
-rw-r--r--lib/libclang_rt/asan_dynamic/Makefile11
-rw-r--r--lib/libclang_rt/asan_dynamic/Makefile.depend4
-rw-r--r--lib/libclang_rt/asan_static/Makefile1
-rw-r--r--lib/libclang_rt/cfi/Makefile8
-rw-r--r--lib/libclang_rt/cfi_diag/Makefile9
-rw-r--r--lib/libclang_rt/compiler-rt-vars.mk4
-rw-r--r--lib/libclang_rt/dd/Makefile8
-rw-r--r--lib/libclang_rt/fuzzer/Makefile1
-rw-r--r--lib/libclang_rt/fuzzer_interceptors/Makefile1
-rw-r--r--lib/libclang_rt/fuzzer_no_main/Makefile1
-rw-r--r--lib/libclang_rt/include/Makefile1
-rw-r--r--lib/libclang_rt/msan/Makefile10
-rw-r--r--lib/libclang_rt/msan_cxx/Makefile1
-rw-r--r--lib/libclang_rt/profile/Makefile1
-rw-r--r--lib/libclang_rt/safestack/Makefile2
-rw-r--r--lib/libclang_rt/safestack/Makefile.depend2
-rw-r--r--lib/libclang_rt/stats/Makefile8
-rw-r--r--lib/libclang_rt/stats/Makefile.depend3
-rw-r--r--lib/libclang_rt/stats_client/Makefile1
-rw-r--r--lib/libclang_rt/tsan/Makefile10
-rw-r--r--lib/libclang_rt/tsan_cxx/Makefile1
-rw-r--r--lib/libclang_rt/ubsan_minimal/Makefile3
-rw-r--r--lib/libclang_rt/ubsan_standalone/Makefile9
-rw-r--r--lib/libclang_rt/ubsan_standalone/Makefile.depend3
-rw-r--r--lib/libclang_rt/ubsan_standalone_cxx/Makefile1
-rw-r--r--lib/libclang_rt/ubsan_standalone_cxx/Makefile.depend2
-rw-r--r--lib/libclang_rt/xray-basic/Makefile3
-rw-r--r--lib/libclang_rt/xray-fdr/Makefile3
-rw-r--r--lib/libclang_rt/xray-profiling/Makefile3
-rw-r--r--lib/libclang_rt/xray/Makefile9
-rw-r--r--lib/libcom_err/Makefile3
-rw-r--r--lib/libcompat/4.1/ftime.380
-rw-r--r--lib/libcompat/4.1/ftime.c52
-rw-r--r--lib/libcompat/4.3/re_comp.32
-rw-r--r--lib/libcompat/4.3/re_comp.c2
-rw-r--r--lib/libcompat/4.3/rexec.32
-rw-r--r--lib/libcompat/4.3/rexec.c12
-rw-r--r--lib/libcompat/4.4/cuserid.c2
-rw-r--r--lib/libcompat/Makefile9
-rw-r--r--lib/libcompiler_rt/Makefile6
-rw-r--r--lib/libcompiler_rt/Makefile.inc117
-rw-r--r--lib/libcrypt/Makefile41
-rw-r--r--lib/libcrypt/crypt-md5.c6
-rw-r--r--lib/libcrypt/crypt-nthash.c11
-rw-r--r--lib/libcrypt/crypt-sha256.c7
-rw-r--r--lib/libcrypt/crypt-sha512.c7
-rw-r--r--lib/libcrypt/crypt.c1
-rw-r--r--lib/libcrypt/libcrypt.aldscript1
-rw-r--r--lib/libcrypt/libcrypt.ldscript1
-rw-r--r--lib/libcrypt/misc.c1
-rw-r--r--lib/libcrypt/tests/Makefile1
-rw-r--r--lib/libcxxrt/Makefile34
-rw-r--r--lib/libcxxrt/Version.map55
-rw-r--r--lib/libcxxrt/Version.map.arm366
-rw-r--r--lib/libder/Makefile13
-rw-r--r--lib/libdevctl/Makefile1
-rw-r--r--lib/libdevctl/devctl.32
-rw-r--r--lib/libdevctl/devctl.c1
-rw-r--r--lib/libdevdctl/Makefile1
-rw-r--r--lib/libdevdctl/consumer.h2
-rw-r--r--lib/libdevdctl/tests/Makefile1
-rw-r--r--lib/libdevinfo/Makefile3
-rw-r--r--lib/libdevinfo/devinfo.c2
-rw-r--r--lib/libdevinfo/devinfo.h3
-rw-r--r--lib/libdevstat/Makefile1
-rw-r--r--lib/libdevstat/devstat.32
-rw-r--r--lib/libdevstat/devstat.c2
-rw-r--r--lib/libdiff/Makefile20
-rw-r--r--lib/libdiff/tests/Makefile8
-rw-r--r--lib/libdiff/tests/libdiff_test.c62
-rw-r--r--lib/libdl/Makefile1
-rw-r--r--lib/libdl/Makefile.depend1
-rw-r--r--lib/libdl/Symbol.map9
-rw-r--r--lib/libdpv/Makefile1
-rw-r--r--lib/libdpv/dialogrc.c1
-rw-r--r--lib/libdpv/dprompt.c1
-rw-r--r--lib/libedit/Makefile2
-rw-r--r--lib/libedit/Makefile.depend1
-rw-r--r--lib/libedit/readline/Makefile1
-rw-r--r--lib/libefivar/FreeBSD-update2
-rw-r--r--lib/libefivar/efivar-dp-format.c91
-rw-r--r--lib/libefivar/efivar-dp-parse.c489
-rw-r--r--lib/libefivar/efivar-dp-xlate.c1
-rw-r--r--lib/libefivar/efivar.c71
-rw-r--r--lib/libefivar/efivar.h17
-rw-r--r--lib/libefivar/uefi-dplib.h8
-rw-r--r--lib/libefivar/uefi-dputil.c1
-rw-r--r--lib/libelf/Makefile1
-rw-r--r--lib/libevent1/Makefile1
-rw-r--r--lib/libexecinfo/Makefile1
-rw-r--r--lib/libexecinfo/tests/Makefile1
-rw-r--r--lib/libexecinfo/tests/sigtramp_test.c2
-rw-r--r--lib/libexpat/Makefile1
-rw-r--r--lib/libexpat/expat_config.h19
-rw-r--r--lib/libexpat/libbsdxml.34
-rw-r--r--lib/libfdt/Makefile29
-rw-r--r--lib/libfetch/Makefile1
-rw-r--r--lib/libfetch/common.c18
-rw-r--r--lib/libfetch/fetch.315
-rw-r--r--lib/libfetch/fetch.c10
-rw-r--r--lib/libfetch/file.c1
-rw-r--r--lib/libfido2/Makefile6
-rw-r--r--lib/libfido2/Makefile.depend17
-rw-r--r--lib/libfigpar/Makefile1
-rw-r--r--lib/libfigpar/figpar.c32
-rw-r--r--lib/libfigpar/string_m.c5
-rw-r--r--lib/libgcc_eh/Makefile1
-rw-r--r--lib/libgcc_eh/Makefile.inc5
-rw-r--r--lib/libgcc_s/Makefile1
-rw-r--r--lib/libgcc_s/Symbol.map107
-rw-r--r--lib/libgcc_s/Versions.def3
-rw-r--r--lib/libgcc_s/arm/Symbol.map68
-rw-r--r--lib/libgeom/Makefile1
-rw-r--r--lib/libgeom/geom_stats.c34
-rw-r--r--lib/libgeom/geom_util.c1
-rw-r--r--lib/libgeom/geom_xml2tree.c2
-rw-r--r--lib/libgpio/Makefile1
-rw-r--r--lib/libgpio/libgpio.h4
-rw-r--r--lib/libgssapi/Makefile1
-rw-r--r--lib/libiconv_modules/BIG5/Makefile1
-rw-r--r--lib/libiconv_modules/DECHanyu/Makefile1
-rw-r--r--lib/libiconv_modules/DECHanyu/citrus_dechanyu.c2
-rw-r--r--lib/libiconv_modules/EUC/Makefile1
-rw-r--r--lib/libiconv_modules/EUC/citrus_euc.c1
-rw-r--r--lib/libiconv_modules/EUCTW/Makefile1
-rw-r--r--lib/libiconv_modules/EUCTW/citrus_euctw.c1
-rw-r--r--lib/libiconv_modules/GBK2K/Makefile1
-rw-r--r--lib/libiconv_modules/GBK2K/citrus_gbk2k.c1
-rw-r--r--lib/libiconv_modules/HZ/Makefile1
-rw-r--r--lib/libiconv_modules/ISO2022/Makefile1
-rw-r--r--lib/libiconv_modules/ISO2022/citrus_iso2022.c1
-rw-r--r--lib/libiconv_modules/JOHAB/Makefile1
-rw-r--r--lib/libiconv_modules/JOHAB/citrus_johab.c2
-rw-r--r--lib/libiconv_modules/MSKanji/Makefile1
-rw-r--r--lib/libiconv_modules/MSKanji/citrus_mskanji.c2
-rw-r--r--lib/libiconv_modules/Makefile1
-rw-r--r--lib/libiconv_modules/Makefile.inc2
-rw-r--r--lib/libiconv_modules/UES/Makefile1
-rw-r--r--lib/libiconv_modules/UTF1632/Makefile1
-rw-r--r--lib/libiconv_modules/UTF7/Makefile1
-rw-r--r--lib/libiconv_modules/UTF8/Makefile1
-rw-r--r--lib/libiconv_modules/UTF8/citrus_utf8.c1
-rw-r--r--lib/libiconv_modules/VIQR/Makefile1
-rw-r--r--lib/libiconv_modules/ZW/Makefile1
-rw-r--r--lib/libiconv_modules/ZW/citrus_zw.c1
-rw-r--r--lib/libiconv_modules/iconv_none/Makefile1
-rw-r--r--lib/libiconv_modules/iconv_std/Makefile1
-rw-r--r--lib/libiconv_modules/mapper_646/Makefile1
-rw-r--r--lib/libiconv_modules/mapper_none/Makefile1
-rw-r--r--lib/libiconv_modules/mapper_parallel/Makefile1
-rw-r--r--lib/libiconv_modules/mapper_serial/Makefile1
-rw-r--r--lib/libiconv_modules/mapper_std/Makefile1
-rw-r--r--lib/libiconv_modules/mapper_zone/Makefile1
-rw-r--r--lib/libifconfig/Makefile1
-rw-r--r--lib/libifconfig/libifconfig.h7
-rw-r--r--lib/libifconfig/libifconfig_bridge.c68
-rw-r--r--lib/libifconfig/libifconfig_carp.c6
-rw-r--r--lib/libifconfig/libifconfig_sfp.c3
-rw-r--r--lib/libifconfig/sfp.lua4
-rw-r--r--lib/libipsec/ipsec_dump_policy.c5
-rw-r--r--lib/libipsec/ipsec_get_policylen.c3
-rw-r--r--lib/libipsec/ipsec_set_policy.36
-rw-r--r--lib/libipsec/ipsec_strerror.c1
-rw-r--r--lib/libipsec/pfkey.c7
-rw-r--r--lib/libipsec/pfkey_dump.c51
-rw-r--r--lib/libipsec/policy_parse.y22
-rw-r--r--lib/libipsec/test-policy.c1
-rw-r--r--lib/libipt/Makefile1
-rw-r--r--lib/libipt/Makefile.depend15
-rw-r--r--lib/libiscsiutil/Makefile.depend14
-rw-r--r--lib/libiscsiutil/libiscsiutil.h11
-rw-r--r--lib/libiscsiutil/log.c22
-rw-r--r--lib/libiscsiutil/pdu.c1
-rw-r--r--lib/libiscsiutil/utils.c71
-rw-r--r--lib/libjail/Makefile1
-rw-r--r--lib/libjail/jail.32
-rw-r--r--lib/libjail/jail.c91
-rw-r--r--lib/libjail/jail.h1
-rw-r--r--lib/libjail/jail_getid.c1
-rw-r--r--lib/libkiconv/Makefile1
-rw-r--r--lib/libkldelf/Makefile21
-rw-r--r--lib/libkldelf/Makefile.depend16
-rw-r--r--lib/libkldelf/ef.c652
-rw-r--r--lib/libkldelf/ef_aarch64.c81
-rw-r--r--lib/libkldelf/ef_amd64.c113
-rw-r--r--lib/libkldelf/ef_arm.c94
-rw-r--r--lib/libkldelf/ef_i386.c97
-rw-r--r--lib/libkldelf/ef_mips.c116
-rw-r--r--lib/libkldelf/ef_obj.c474
-rw-r--r--lib/libkldelf/ef_powerpc.c97
-rw-r--r--lib/libkldelf/ef_riscv.c85
-rw-r--r--lib/libkldelf/elf.c695
-rw-r--r--lib/libkldelf/kldelf.h327
-rw-r--r--lib/libkvm/Makefile2
-rw-r--r--lib/libkvm/kvm.32
-rw-r--r--lib/libkvm/kvm.c2
-rw-r--r--lib/libkvm/kvm.h3
-rw-r--r--lib/libkvm/kvm_amd64.c48
-rw-r--r--lib/libkvm/kvm_arm.c1
-rw-r--r--lib/libkvm/kvm_cptime.c1
-rw-r--r--lib/libkvm/kvm_geterr.32
-rw-r--r--lib/libkvm/kvm_getloadavg.32
-rw-r--r--lib/libkvm/kvm_getloadavg.c2
-rw-r--r--lib/libkvm/kvm_getprocs.32
-rw-r--r--lib/libkvm/kvm_getswapinfo.c1
-rw-r--r--lib/libkvm/kvm_i386.c2
-rw-r--r--lib/libkvm/kvm_minidump_powerpc64.c1
-rw-r--r--lib/libkvm/kvm_minidump_powerpc64_hpt.c1
-rw-r--r--lib/libkvm/kvm_nlist.32
-rw-r--r--lib/libkvm/kvm_open.317
-rw-r--r--lib/libkvm/kvm_pcpu.c1
-rw-r--r--lib/libkvm/kvm_powerpc.c1
-rw-r--r--lib/libkvm/kvm_powerpc64.c1
-rw-r--r--lib/libkvm/kvm_private.c1
-rw-r--r--lib/libkvm/kvm_private.h2
-rw-r--r--lib/libkvm/kvm_proc.c8
-rw-r--r--lib/libkvm/kvm_read.32
-rw-r--r--lib/libkvm/kvm_vnet.c1
-rw-r--r--lib/libkvm/tests/Makefile1
-rw-r--r--lib/libkvm/tests/kvm_geterr_test.c1
-rw-r--r--lib/libkvm/tests/kvm_open2_test.c1
-rw-r--r--lib/libkvm/tests/kvm_open_test.c1
-rw-r--r--lib/libkvm/tests/kvm_read_test.c1
-rw-r--r--lib/libkvm/tests/kvm_test_common.c1
-rw-r--r--lib/libldns/Makefile1
-rw-r--r--lib/liblua/Makefile1
-rw-r--r--lib/liblua/Makefile.depend13
-rw-r--r--lib/liblutok/Makefile5
-rw-r--r--lib/liblutok/Makefile.depend14
-rw-r--r--lib/liblzma/Makefile12
-rw-r--r--lib/liblzma/Symbol.map15
-rw-r--r--lib/liblzma/Versions.def8
-rw-r--r--lib/liblzma/config.h132
-rw-r--r--lib/libmagic/Makefile6
-rw-r--r--lib/libmagic/Makefile.depend1
-rw-r--r--lib/libmagic/config.h169
-rw-r--r--lib/libmd/Makefile261
-rw-r--r--lib/libmd/Symbol.map256
-rw-r--r--lib/libmd/aarch64/sha1block.S490
-rw-r--r--lib/libmd/aarch64/sha1dispatch.c24
-rw-r--r--lib/libmd/amd64/sha1block.S1851
-rw-r--r--lib/libmd/amd64/sha1dispatch.c77
-rw-r--r--lib/libmd/i386/sha.S1951
-rw-r--r--lib/libmd/md4.h55
-rw-r--r--lib/libmd/md4c.c299
-rw-r--r--lib/libmd/md5.h40
-rw-r--r--lib/libmd/md5c.c345
-rw-r--r--lib/libmd/mdX.321
-rw-r--r--lib/libmd/mdXhl.c5
-rw-r--r--lib/libmd/mddriver.c67
-rw-r--r--lib/libmd/ripemd.321
-rw-r--r--lib/libmd/ripemd.h8
-rw-r--r--lib/libmd/rmd160c.c11
-rw-r--r--lib/libmd/rmddriver.c49
-rw-r--r--lib/libmd/sha.327
-rw-r--r--lib/libmd/sha.h12
-rw-r--r--lib/libmd/sha0c.c3
-rw-r--r--lib/libmd/sha1c.c667
-rw-r--r--lib/libmd/sha256.327
-rw-r--r--lib/libmd/sha512.333
-rw-r--r--lib/libmd/shadriver.c86
-rw-r--r--lib/libmd/skein.333
-rw-r--r--lib/libmd/skeindriver.c69
-rw-r--r--lib/libmd/tests/Makefile255
-rw-r--r--lib/libmd/tests/mddriver.c66
-rw-r--r--lib/libmd/tests/rmddriver.c48
-rw-r--r--lib/libmd/tests/shadriver.c85
-rw-r--r--lib/libmd/tests/skeindriver.c68
-rw-r--r--lib/libmemstat/Makefile1
-rw-r--r--lib/libmemstat/memstat_malloc.c1
-rw-r--r--lib/libmilter/Makefile1
-rw-r--r--lib/libmixer/Makefile2
-rw-r--r--lib/libmixer/Makefile.depend16
-rw-r--r--lib/libmixer/Symbol.map4
-rw-r--r--lib/libmixer/mixer.392
-rw-r--r--lib/libmixer/mixer.c31
-rw-r--r--lib/libmixer/mixer.h1
-rw-r--r--lib/libmp/Makefile1
-rw-r--r--lib/libmp/tests/Makefile1
-rw-r--r--lib/libmt/Makefile1
-rw-r--r--lib/libmt/mtlib.c3
-rw-r--r--lib/libnetbsd/Makefile1
-rw-r--r--lib/libnetbsd/netinet/in.h2
-rw-r--r--lib/libnetbsd/sockaddr_snprintf.c1
-rw-r--r--lib/libnetbsd/strsuftoll.c1
-rw-r--r--lib/libnetbsd/util.c1
-rw-r--r--lib/libnetgraph/debug.c1
-rw-r--r--lib/libnetgraph/msg.c1
-rw-r--r--lib/libnetgraph/sock.c1
-rw-r--r--lib/libnetmap/Makefile.depend15
-rw-r--r--lib/libnetmap/nmreq.c5
-rw-r--r--lib/libnv/Makefile1
-rw-r--r--lib/libnv/common_impl.h1
-rw-r--r--lib/libnv/msgio.c1
-rw-r--r--lib/libnv/tests/Makefile9
-rw-r--r--lib/libnv/tests/dnv_tests.cc1
-rw-r--r--lib/libnv/tests/nv_array_tests.cc59
-rw-r--r--lib/libnv/tests/nvlist_add_test.c1
-rw-r--r--lib/libnv/tests/nvlist_exists_test.c1
-rw-r--r--lib/libnv/tests/nvlist_free_test.c1
-rw-r--r--lib/libnv/tests/nvlist_get_test.c1
-rw-r--r--lib/libnv/tests/nvlist_move_test.c1
-rw-r--r--lib/libnv/tests/nvlist_send_recv_test.c195
-rw-r--r--lib/libnvmf/Makefile24
-rw-r--r--lib/libnvmf/Makefile.depend12
-rw-r--r--lib/libnvmf/internal.h120
-rw-r--r--lib/libnvmf/libnvmf.h387
-rw-r--r--lib/libnvmf/nvmf_controller.c529
-rw-r--r--lib/libnvmf/nvmf_host.c1021
-rw-r--r--lib/libnvmf/nvmf_tcp.c1501
-rw-r--r--lib/libnvmf/nvmf_transport.c307
-rw-r--r--lib/libomp/Makefile21
-rw-r--r--lib/libomp/kmp_config.h8
-rw-r--r--lib/libomp/kmp_i18n_default.inc9
-rw-r--r--lib/libomp/kmp_i18n_id.inc5
-rw-r--r--lib/libomp/omp-tools.h34
-rw-r--r--lib/libomp/omp.h10
-rw-r--r--lib/libopenbsd/Makefile4
-rw-r--r--lib/libopenbsd/getdtablecount.c1
-rw-r--r--lib/libopenbsd/recallocarray.c82
-rw-r--r--lib/libopencsd/Makefile19
-rw-r--r--lib/libpam/libpam/Makefile3
-rw-r--r--lib/libpam/modules/Makefile.inc2
-rw-r--r--lib/libpam/modules/modules.inc1
-rw-r--r--lib/libpam/modules/pam_chroot/Makefile1
-rw-r--r--lib/libpam/modules/pam_chroot/pam_chroot.84
-rw-r--r--lib/libpam/modules/pam_chroot/pam_chroot.c1
-rw-r--r--lib/libpam/modules/pam_deny/pam_deny.84
-rw-r--r--lib/libpam/modules/pam_echo/Makefile1
-rw-r--r--lib/libpam/modules/pam_echo/pam_echo.84
-rw-r--r--lib/libpam/modules/pam_exec/Makefile1
-rw-r--r--lib/libpam/modules/pam_exec/pam_exec.86
-rw-r--r--lib/libpam/modules/pam_exec/pam_exec.c1
-rw-r--r--lib/libpam/modules/pam_ftpusers/Makefile1
-rw-r--r--lib/libpam/modules/pam_ftpusers/pam_ftpusers.84
-rw-r--r--lib/libpam/modules/pam_group/Makefile1
-rw-r--r--lib/libpam/modules/pam_group/pam_group.84
-rw-r--r--lib/libpam/modules/pam_group/pam_group.c1
-rw-r--r--lib/libpam/modules/pam_guest/Makefile1
-rw-r--r--lib/libpam/modules/pam_guest/pam_guest.84
-rw-r--r--lib/libpam/modules/pam_krb5/Makefile54
-rw-r--r--lib/libpam/modules/pam_krb5/config.h412
-rw-r--r--lib/libpam/modules/pam_krb5/pam-krb5.81025
-rw-r--r--lib/libpam/modules/pam_krb5/pam_krb5.84
-rw-r--r--lib/libpam/modules/pam_krb5/pam_krb5.c5
-rw-r--r--lib/libpam/modules/pam_ksu/Makefile11
-rw-r--r--lib/libpam/modules/pam_ksu/pam_ksu.84
-rw-r--r--lib/libpam/modules/pam_ksu/pam_ksu.c64
-rw-r--r--lib/libpam/modules/pam_lastlog/pam_lastlog.84
-rw-r--r--lib/libpam/modules/pam_login_access/login_access.c1
-rw-r--r--lib/libpam/modules/pam_nologin/pam_nologin.84
-rw-r--r--lib/libpam/modules/pam_nologin/pam_nologin.c1
-rw-r--r--lib/libpam/modules/pam_passwdqc/Makefile1
-rw-r--r--lib/libpam/modules/pam_passwdqc/pam_passwdqc.84
-rw-r--r--lib/libpam/modules/pam_permit/pam_permit.84
-rw-r--r--lib/libpam/modules/pam_radius/pam_radius.84
-rw-r--r--lib/libpam/modules/pam_radius/pam_radius.c1
-rw-r--r--lib/libpam/modules/pam_rhosts/Makefile1
-rw-r--r--lib/libpam/modules/pam_rhosts/pam_rhosts.84
-rw-r--r--lib/libpam/modules/pam_rootok/pam_rootok.84
-rw-r--r--lib/libpam/modules/pam_securetty/pam_securetty.84
-rw-r--r--lib/libpam/modules/pam_securetty/pam_securetty.c1
-rw-r--r--lib/libpam/modules/pam_self/pam_self.84
-rw-r--r--lib/libpam/modules/pam_ssh/pam_ssh.84
-rw-r--r--lib/libpam/modules/pam_ssh/pam_ssh.c1
-rw-r--r--lib/libpam/modules/pam_tacplus/pam_tacplus.c1
-rw-r--r--lib/libpam/modules/pam_unix/pam_unix.82
-rw-r--r--lib/libpam/modules/pam_unix/pam_unix.c1
-rw-r--r--lib/libpam/modules/pam_xdg/Makefile5
-rw-r--r--lib/libpam/modules/pam_xdg/pam_xdg.865
-rw-r--r--lib/libpam/modules/pam_xdg/pam_xdg.c329
-rw-r--r--lib/libpam/pam.d/Makefile17
-rw-r--r--lib/libpam/pam.d/ftp13
-rw-r--r--lib/libpam/pam.d/system1
-rw-r--r--lib/libpam/pam.d/xdm1
-rw-r--r--lib/libpathconv/Makefile1
-rw-r--r--lib/libpathconv/abs2rel.31
-rw-r--r--lib/libpathconv/rel2abs.31
-rw-r--r--lib/libpathconv/tests/Makefile1
-rw-r--r--lib/libpcap/Makefile1
-rw-r--r--lib/libpcap/Makefile.depend1
-rw-r--r--lib/libpcap/Makefile.depend.options2
-rw-r--r--lib/libpcap/config.h4
-rw-r--r--lib/libpfctl/Makefile1
-rw-r--r--lib/libpfctl/Makefile.depend12
-rw-r--r--lib/libpfctl/libpfctl.c2538
-rw-r--r--lib/libpfctl/libpfctl.h148
-rw-r--r--lib/libpjdlog/pjdlog.c1
-rw-r--r--lib/libpmc/Makefile8
-rw-r--r--lib/libpmc/Makefile.inc1
-rw-r--r--lib/libpmc/libpmc.c10
-rw-r--r--lib/libpmc/libpmc_pmu_util.c3
-rw-r--r--lib/libpmc/pmc.315
-rw-r--r--lib/libpmc/pmc.amd.3793
-rw-r--r--lib/libpmc/pmc.atom.33
-rw-r--r--lib/libpmc/pmc.atomsilvermont.33
-rw-r--r--lib/libpmc/pmc.cmn-600.34
-rw-r--r--lib/libpmc/pmc.core.33
-rw-r--r--lib/libpmc/pmc.core2.33
-rw-r--r--lib/libpmc/pmc.corei7.33
-rw-r--r--lib/libpmc/pmc.corei7uc.33
-rw-r--r--lib/libpmc/pmc.dmc-620.34
-rw-r--r--lib/libpmc/pmc.h1
-rw-r--r--lib/libpmc/pmc.haswell.33
-rw-r--r--lib/libpmc/pmc.haswelluc.33
-rw-r--r--lib/libpmc/pmc.haswellxeon.33
-rw-r--r--lib/libpmc/pmc.iaf.33
-rw-r--r--lib/libpmc/pmc.ivybridge.33
-rw-r--r--lib/libpmc/pmc.ivybridgexeon.33
-rw-r--r--lib/libpmc/pmc.k7.3260
-rw-r--r--lib/libpmc/pmc.k8.3793
-rw-r--r--lib/libpmc/pmc.sandybridge.33
-rw-r--r--lib/libpmc/pmc.sandybridgeuc.33
-rw-r--r--lib/libpmc/pmc.sandybridgexeon.33
-rw-r--r--lib/libpmc/pmc.soft.33
-rw-r--r--lib/libpmc/pmc.tsc.33
-rw-r--r--lib/libpmc/pmc.ucf.33
-rw-r--r--lib/libpmc/pmc.westmere.33
-rw-r--r--lib/libpmc/pmc.westmereuc.33
-rw-r--r--lib/libpmc/pmclog.c12
-rw-r--r--lib/libpmc/pmu-events/Makefile1
-rw-r--r--lib/libpmc/pmu-events/Makefile.depend10
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/branch.json82
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/cache.json828
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/core.json122
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/data-fabric.json1090
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/floating-point.json818
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/memory-controller.json101
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/memory.json174
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/other.json138
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/pipeline.json98
-rw-r--r--lib/libpmc/pmu-events/arch/x86/amdzen4/recommended.json418
-rw-r--r--lib/libpmc/pmu-events/arch/x86/mapfile.csv6
-rw-r--r--lib/libpmc/pmu-events/jevents.c4
-rw-r--r--lib/libpmcstat/libpmcstat_event.c1
-rw-r--r--lib/libpmcstat/libpmcstat_image.c9
-rw-r--r--lib/libpmcstat/libpmcstat_logging.c1
-rw-r--r--lib/libpmcstat/libpmcstat_process.c1
-rw-r--r--lib/libpmcstat/libpmcstat_string.c1
-rw-r--r--lib/libpmcstat/libpmcstat_symbol.c1
-rw-r--r--lib/libproc/Makefile3
-rw-r--r--lib/libproc/Makefile.inc1
-rw-r--r--lib/libproc/libproc.h2
-rw-r--r--lib/libproc/proc_bkpt.c2
-rw-r--r--lib/libproc/proc_create.c1
-rw-r--r--lib/libproc/proc_regs.c2
-rw-r--r--lib/libproc/proc_rtld.c1
-rw-r--r--lib/libproc/proc_sym.c1
-rw-r--r--lib/libproc/proc_util.c8
-rw-r--r--lib/libproc/tests/Makefile1
-rw-r--r--lib/libproc/tests/proc_test.c1
-rw-r--r--lib/libprocstat/Makefile26
-rw-r--r--lib/libprocstat/Symbol.map7
-rw-r--r--lib/libprocstat/cd9660.c4
-rw-r--r--lib/libprocstat/common_kvm.c1
-rw-r--r--lib/libprocstat/core.c69
-rw-r--r--lib/libprocstat/core.h3
-rw-r--r--lib/libprocstat/libprocstat.c234
-rw-r--r--lib/libprocstat/libprocstat.h14
-rw-r--r--lib/libprocstat/libprocstat_compat.c3
-rw-r--r--lib/libprocstat/msdosfs.c15
-rw-r--r--lib/libprocstat/smbfs.c3
-rw-r--r--lib/libprocstat/udf.c2
-rw-r--r--lib/libprocstat/zfs.c50
-rw-r--r--lib/libprocstat/zfs/Makefile26
-rw-r--r--lib/libprocstat/zfs_defs.c82
-rw-r--r--lib/libprocstat/zfs_defs.h36
-rw-r--r--lib/libradius/radlib.c5
-rw-r--r--lib/libregex/Makefile1
-rw-r--r--lib/libregex/Makefile.depend15
-rw-r--r--lib/libregex/tests/Makefile1
-rw-r--r--lib/librpcsec_gss/Makefile2
-rw-r--r--lib/librpcsec_gss/Symbol.map3
-rw-r--r--lib/librpcsvc/Makefile2
-rw-r--r--lib/librpcsvc/rnusers.c3
-rw-r--r--lib/librpcsvc/rstat.c3
-rw-r--r--lib/librpcsvc/rwall.c3
-rw-r--r--lib/librpcsvc/secretkey.c3
-rw-r--r--lib/librss/Makefile1
-rw-r--r--lib/librss/librss.34
-rw-r--r--lib/librss/librss.c1
-rw-r--r--lib/librt/Makefile.depend1
-rw-r--r--lib/librt/aio.c1
-rw-r--r--lib/librt/mq.c13
-rw-r--r--lib/librt/tests/Makefile1
-rw-r--r--lib/librt/timer.c1
-rw-r--r--lib/librtld_db/Makefile1
-rw-r--r--lib/librtld_db/librtld_db.31
-rw-r--r--lib/librtld_db/rtld_db.c2
-rw-r--r--lib/librtld_db/rtld_db.h1
-rw-r--r--lib/libsamplerate/Makefile18
-rw-r--r--lib/libsbuf/Makefile1
-rw-r--r--lib/libsbuf/tests/Makefile1
-rw-r--r--lib/libsbuf/tests/sbuf_core_test.c33
-rw-r--r--lib/libsbuf/tests/sbuf_stdio_test.c22
-rw-r--r--lib/libsbuf/tests/sbuf_string_test.c61
-rw-r--r--lib/libsecureboot/Makefile1
-rw-r--r--lib/libsecureboot/Makefile.inc13
-rw-r--r--lib/libsecureboot/Makefile.libsa.inc8
-rw-r--r--lib/libsecureboot/README.rst17
-rw-r--r--lib/libsecureboot/h/libsecureboot.h1
-rw-r--r--lib/libsecureboot/h/verify_file.h1
-rw-r--r--lib/libsecureboot/local.trust.mk145
-rw-r--r--lib/libsecureboot/openpgp/Makefile.inc1
-rw-r--r--lib/libsecureboot/openpgp/opgp_sig.c13
-rw-r--r--lib/libsecureboot/tests/Makefile1
-rw-r--r--lib/libsecureboot/vectx.c26
-rw-r--r--lib/libsecureboot/verify_file.c37
-rw-r--r--lib/libsecureboot/vets.c44
-rw-r--r--lib/libsm/Makefile1
-rw-r--r--lib/libsmb/Makefile1
-rw-r--r--lib/libsmdb/Makefile1
-rw-r--r--lib/libsmutil/Makefile1
-rw-r--r--lib/libsmutil/Makefile.depend1
-rw-r--r--lib/libsqlite3/Makefile1
-rw-r--r--lib/libssp/Makefile21
-rw-r--r--lib/libssp/Makefile.depend17
-rw-r--r--lib/libssp/Symbol.map11
-rw-r--r--lib/libssp/Versions.def5
-rw-r--r--lib/libssp/__builtin_object_size.3110
-rw-r--r--lib/libssp/fortify_stubs.c132
-rw-r--r--lib/libssp/ssp.3128
-rw-r--r--lib/libssp_nonshared/Makefile2
-rw-r--r--lib/libstats/Makefile1
-rw-r--r--lib/libstats/Makefile.depend15
-rw-r--r--lib/libstdbuf/Makefile1
-rw-r--r--lib/libstdthreads/Makefile1
-rw-r--r--lib/libstdthreads/mtx.c13
-rw-r--r--lib/libsys/Makefile80
-rw-r--r--lib/libsys/Makefile.depend14
-rw-r--r--lib/libsys/Makefile.sys553
-rw-r--r--lib/libsys/Symbol.map13
-rw-r--r--lib/libsys/Symbol.sys.map396
-rw-r--r--lib/libsys/Symbol.thr.map3
-rw-r--r--lib/libsys/__error.c57
-rw-r--r--lib/libsys/__getosreldate.c53
-rw-r--r--lib/libsys/__vdso_gettimeofday.c196
-rw-r--r--lib/libsys/_exit.2122
-rw-r--r--lib/libsys/_libsys.h877
-rw-r--r--lib/libsys/_umtx_op.21541
-rw-r--r--lib/libsys/_umtx_op_err.c39
-rw-r--r--lib/libsys/aarch64/Makefile.sys7
-rw-r--r--lib/libsys/aarch64/SYS.h62
-rw-r--r--lib/libsys/aarch64/__vdso_gettc.c73
-rw-r--r--lib/libsys/aarch64/cerror.S43
-rw-r--r--lib/libsys/aarch64/vfork.S43
-rw-r--r--lib/libsys/abort2.2 (renamed from lib/libc/sys/abort2.2)0
-rw-r--r--lib/libsys/accept.2248
-rw-r--r--lib/libsys/access.2277
-rw-r--r--lib/libsys/acct.2130
-rw-r--r--lib/libsys/adjtime.2106
-rw-r--r--lib/libsys/aio_cancel.2 (renamed from lib/libc/sys/aio_cancel.2)0
-rw-r--r--lib/libsys/aio_error.2 (renamed from lib/libc/sys/aio_error.2)0
-rw-r--r--lib/libsys/aio_fsync.2181
-rw-r--r--lib/libsys/aio_mlock.2 (renamed from lib/libc/sys/aio_mlock.2)0
-rw-r--r--lib/libsys/aio_read.2290
-rw-r--r--lib/libsys/aio_return.2 (renamed from lib/libc/sys/aio_return.2)0
-rw-r--r--lib/libsys/aio_suspend.2 (renamed from lib/libc/sys/aio_suspend.2)0
-rw-r--r--lib/libsys/aio_waitcomplete.2135
-rw-r--r--lib/libsys/aio_write.2291
-rw-r--r--lib/libsys/amd64/Makefile.sys9
-rw-r--r--lib/libsys/amd64/Makefile.thr1
-rw-r--r--lib/libsys/amd64/SYS.h59
-rw-r--r--lib/libsys/amd64/Symbol.sys.map22
-rw-r--r--lib/libsys/amd64/_umtx_op_err.S (renamed from lib/libthr/arch/amd64/amd64/_umtx_op_err.S)0
-rw-r--r--lib/libsys/amd64/amd64_get_fsbase.c63
-rw-r--r--lib/libsys/amd64/amd64_get_gsbase.c63
-rw-r--r--lib/libsys/amd64/amd64_set_fsbase.c63
-rw-r--r--lib/libsys/amd64/amd64_set_gsbase.c63
-rw-r--r--lib/libsys/amd64/amd64_set_tlsbase.c51
-rw-r--r--lib/libsys/amd64/cerror.S55
-rw-r--r--lib/libsys/amd64/getcontext.S45
-rw-r--r--lib/libsys/amd64/rfork_thread.S91
-rw-r--r--lib/libsys/amd64/vfork.S48
-rw-r--r--lib/libsys/arm/Makefile.sys6
-rw-r--r--lib/libsys/arm/SYS.h70
-rw-r--r--lib/libsys/arm/Symbol.sys.map3
-rw-r--r--lib/libsys/arm/__vdso_gettc.c81
-rw-r--r--lib/libsys/arm/cerror.S48
-rw-r--r--lib/libsys/arm/vfork.S58
-rw-r--r--lib/libsys/auxv.3111
-rw-r--r--lib/libsys/auxv.c444
-rw-r--r--lib/libsys/bind.2138
-rw-r--r--lib/libsys/bindat.2 (renamed from lib/libc/sys/bindat.2)0
-rw-r--r--lib/libsys/brk.2187
-rw-r--r--lib/libsys/cap_enter.2 (renamed from lib/libc/sys/cap_enter.2)0
-rw-r--r--lib/libsys/cap_fcntls_limit.2 (renamed from lib/libc/sys/cap_fcntls_limit.2)0
-rw-r--r--lib/libsys/cap_ioctls_limit.2 (renamed from lib/libc/sys/cap_ioctls_limit.2)0
-rw-r--r--lib/libsys/cap_rights_limit.2164
-rw-r--r--lib/libsys/chdir.2131
-rw-r--r--lib/libsys/chflags.2356
-rw-r--r--lib/libsys/chmod.2364
-rw-r--r--lib/libsys/chown.2298
-rw-r--r--lib/libsys/chroot.2215
-rw-r--r--lib/libsys/clock_gettime.2241
-rw-r--r--lib/libsys/clock_gettime.c55
-rw-r--r--lib/libsys/close.2138
-rw-r--r--lib/libsys/closefrom.299
-rw-r--r--lib/libsys/connect.2182
-rw-r--r--lib/libsys/connectat.2 (renamed from lib/libc/sys/connectat.2)0
-rw-r--r--lib/libsys/copy_file_range.2218
-rw-r--r--lib/libsys/cpuset.2 (renamed from lib/libc/sys/cpuset.2)0
-rw-r--r--lib/libsys/cpuset_getaffinity.2 (renamed from lib/libc/sys/cpuset_getaffinity.2)0
-rw-r--r--lib/libsys/cpuset_getdomain.2 (renamed from lib/libc/sys/cpuset_getdomain.2)0
-rw-r--r--lib/libsys/creat.259
-rw-r--r--lib/libsys/dup.2168
-rw-r--r--lib/libsys/eventfd.2 (renamed from lib/libc/sys/eventfd.2)0
-rw-r--r--lib/libsys/execve.2382
-rw-r--r--lib/libsys/extattr_get_file.2 (renamed from lib/libc/sys/extattr_get_file.2)0
-rw-r--r--lib/libsys/fcntl.2848
-rw-r--r--lib/libsys/ffclock.2 (renamed from lib/libc/sys/ffclock.2)0
-rw-r--r--lib/libsys/fhlink.2254
-rw-r--r--lib/libsys/fhopen.2160
-rw-r--r--lib/libsys/fhreadlink.296
-rw-r--r--lib/libsys/flock.2170
-rw-r--r--lib/libsys/fork.2278
-rw-r--r--lib/libsys/fspacectl.2 (renamed from lib/libc/sys/fspacectl.2)0
-rw-r--r--lib/libsys/fsync.2130
-rw-r--r--lib/libsys/getdirentries.2211
-rw-r--r--lib/libsys/getdtablesize.259
-rw-r--r--lib/libsys/getfh.2232
-rw-r--r--lib/libsys/getfsstat.2129
-rw-r--r--lib/libsys/getgid.282
-rw-r--r--lib/libsys/getgroups.2104
-rw-r--r--lib/libsys/getitimer.2192
-rw-r--r--lib/libsys/getlogin.2201
-rw-r--r--lib/libsys/getloginclass.2 (renamed from lib/libc/sys/getloginclass.2)0
-rw-r--r--lib/libsys/getpagesize.367
-rw-r--r--lib/libsys/getpagesize.c51
-rw-r--r--lib/libsys/getpagesizes.3 (renamed from lib/libc/gen/getpagesizes.3)0
-rw-r--r--lib/libsys/getpagesizes.c75
-rw-r--r--lib/libsys/getpeername.295
-rw-r--r--lib/libsys/getpgrp.2139
-rw-r--r--lib/libsys/getpid.287
-rw-r--r--lib/libsys/getpriority.2147
-rw-r--r--lib/libsys/getrandom.2 (renamed from lib/libc/sys/getrandom.2)0
-rw-r--r--lib/libsys/getrlimit.2242
-rw-r--r--lib/libsys/getrlimitusage.2100
-rw-r--r--lib/libsys/getrusage.2183
-rw-r--r--lib/libsys/getsid.2 (renamed from lib/libc/sys/getsid.2)0
-rw-r--r--lib/libsys/getsockname.295
-rw-r--r--lib/libsys/getsockopt.2696
-rw-r--r--lib/libsys/gettimeofday.2149
-rw-r--r--lib/libsys/gettimeofday.c51
-rw-r--r--lib/libsys/getuid.288
-rw-r--r--lib/libsys/i386/Makefile.sys15
-rw-r--r--lib/libsys/i386/Makefile.thr1
-rw-r--r--lib/libsys/i386/SYS.h58
-rw-r--r--lib/libsys/i386/Symbol.sys.map25
-rw-r--r--lib/libsys/i386/_umtx_op_err.S (renamed from lib/libthr/arch/i386/i386/_umtx_op_err.S)0
-rw-r--r--lib/libsys/i386/cerror.S63
-rw-r--r--lib/libsys/i386/getcontext.S45
-rw-r--r--lib/libsys/i386/i386_clr_watch.c45
-rw-r--r--lib/libsys/i386/i386_get_fsbase.c36
-rw-r--r--lib/libsys/i386/i386_get_gsbase.c36
-rw-r--r--lib/libsys/i386/i386_get_ioperm.2 (renamed from lib/libc/i386/sys/i386_get_ioperm.2)0
-rw-r--r--lib/libsys/i386/i386_get_ioperm.c47
-rw-r--r--lib/libsys/i386/i386_get_ldt.2136
-rw-r--r--lib/libsys/i386/i386_get_ldt.c45
-rw-r--r--lib/libsys/i386/i386_set_fsbase.c36
-rw-r--r--lib/libsys/i386/i386_set_gsbase.c36
-rw-r--r--lib/libsys/i386/i386_set_ioperm.c41
-rw-r--r--lib/libsys/i386/i386_set_ldt.c45
-rw-r--r--lib/libsys/i386/i386_set_watch.3116
-rw-r--r--lib/libsys/i386/i386_set_watch.c83
-rw-r--r--lib/libsys/i386/i386_vm86.2 (renamed from lib/libc/i386/sys/i386_vm86.2)0
-rw-r--r--lib/libsys/i386/i386_vm86.c40
-rw-r--r--lib/libsys/i386/rfork_thread.S111
-rw-r--r--lib/libsys/i386/syscall.S49
-rw-r--r--lib/libsys/i386/vfork.S48
-rw-r--r--lib/libsys/inotify.2379
-rw-r--r--lib/libsys/interposing_table.c82
-rw-r--r--lib/libsys/intro.2764
-rw-r--r--lib/libsys/ioctl.2151
-rw-r--r--lib/libsys/issetugid.2 (renamed from lib/libc/sys/issetugid.2)0
-rw-r--r--lib/libsys/jail.2414
-rw-r--r--lib/libsys/kcmp.2230
-rw-r--r--lib/libsys/kenv.2 (renamed from lib/libc/sys/kenv.2)0
-rw-r--r--lib/libsys/kill.2156
-rw-r--r--lib/libsys/kldfind.283
-rw-r--r--lib/libsys/kldfirstmod.273
-rw-r--r--lib/libsys/kldload.293
-rw-r--r--lib/libsys/kldnext.286
-rw-r--r--lib/libsys/kldstat.2130
-rw-r--r--lib/libsys/kldsym.2118
-rw-r--r--lib/libsys/kldunload.291
-rw-r--r--lib/libsys/kqueue.2904
-rw-r--r--lib/libsys/ktrace.2204
-rw-r--r--lib/libsys/libc_stubs.c11
-rw-r--r--lib/libsys/libsys.h25
-rw-r--r--lib/libsys/libsys_sigwait.c45
-rw-r--r--lib/libsys/link.2316
-rw-r--r--lib/libsys/lio_listio.2248
-rw-r--r--lib/libsys/listen.2201
-rw-r--r--lib/libsys/lockf.3 (renamed from lib/libc/gen/lockf.3)0
-rw-r--r--lib/libsys/lseek.2243
-rw-r--r--lib/libsys/madvise.2183
-rw-r--r--lib/libsys/membarrier.2151
-rw-r--r--lib/libsys/mincore.2149
-rw-r--r--lib/libsys/minherit.2148
-rw-r--r--lib/libsys/mkdir.2179
-rw-r--r--lib/libsys/mkfifo.2180
-rw-r--r--lib/libsys/mknod.2181
-rw-r--r--lib/libsys/mlock.2176
-rw-r--r--lib/libsys/mlockall.2 (renamed from lib/libc/sys/mlockall.2)0
-rw-r--r--lib/libsys/mmap.2564
-rw-r--r--lib/libsys/modfind.2 (renamed from lib/libc/sys/modfind.2)0
-rw-r--r--lib/libsys/modnext.2 (renamed from lib/libc/sys/modnext.2)0
-rw-r--r--lib/libsys/modstat.2 (renamed from lib/libc/sys/modstat.2)0
-rw-r--r--lib/libsys/mount.2400
-rw-r--r--lib/libsys/mprotect.2128
-rw-r--r--lib/libsys/mq_close.2 (renamed from lib/libc/sys/mq_close.2)0
-rw-r--r--lib/libsys/mq_getattr.2 (renamed from lib/libc/sys/mq_getattr.2)0
-rw-r--r--lib/libsys/mq_notify.2 (renamed from lib/libc/sys/mq_notify.2)0
-rw-r--r--lib/libsys/mq_open.2344
-rw-r--r--lib/libsys/mq_receive.2 (renamed from lib/libc/sys/mq_receive.2)0
-rw-r--r--lib/libsys/mq_send.2 (renamed from lib/libc/sys/mq_send.2)0
-rw-r--r--lib/libsys/mq_setattr.2 (renamed from lib/libc/sys/mq_setattr.2)0
-rw-r--r--lib/libsys/mq_unlink.2119
-rw-r--r--lib/libsys/msgctl.2 (renamed from lib/libc/sys/msgctl.2)0
-rw-r--r--lib/libsys/msgget.2 (renamed from lib/libc/sys/msgget.2)0
-rw-r--r--lib/libsys/msgrcv.2 (renamed from lib/libc/sys/msgrcv.2)0
-rw-r--r--lib/libsys/msgsnd.2 (renamed from lib/libc/sys/msgsnd.2)0
-rw-r--r--lib/libsys/msync.2123
-rw-r--r--lib/libsys/munmap.282
-rw-r--r--lib/libsys/nanosleep.2255
-rw-r--r--lib/libsys/nfssvc.2255
-rw-r--r--lib/libsys/ntp_adjtime.2 (renamed from lib/libc/sys/ntp_adjtime.2)0
-rw-r--r--lib/libsys/open.2880
-rw-r--r--lib/libsys/pathconf.2279
-rw-r--r--lib/libsys/pdfork.2 (renamed from lib/libc/sys/pdfork.2)0
-rw-r--r--lib/libsys/pipe.2182
-rw-r--r--lib/libsys/poll.2294
-rw-r--r--lib/libsys/posix_fadvise.2140
-rw-r--r--lib/libsys/posix_fallocate.2149
-rw-r--r--lib/libsys/posix_openpt.2 (renamed from lib/libc/sys/posix_openpt.2)0
-rw-r--r--lib/libsys/powerpc/Makefile.sys4
-rw-r--r--lib/libsys/powerpc/Makefile.thr1
-rw-r--r--lib/libsys/powerpc/SYS.h65
-rw-r--r--lib/libsys/powerpc/__vdso_gettc.c65
-rw-r--r--lib/libsys/powerpc/_umtx_op_err.S (renamed from lib/libthr/arch/powerpc/powerpc/_umtx_op_err.S)0
-rw-r--r--lib/libsys/powerpc/cerror.S (renamed from lib/libc/powerpc/sys/cerror.S)0
-rw-r--r--lib/libsys/powerpc64/Makefile.sys4
-rw-r--r--lib/libsys/powerpc64/SYS.h73
-rw-r--r--lib/libsys/powerpc64/__vdso_gettc.c62
-rw-r--r--lib/libsys/powerpc64/cerror.S (renamed from lib/libc/powerpc64/sys/cerror.S)0
-rw-r--r--lib/libsys/powerpcspe/Makefile.sys5
-rw-r--r--lib/libsys/procctl.2971
-rw-r--r--lib/libsys/profil.2119
-rw-r--r--lib/libsys/pselect.2 (renamed from lib/libc/sys/pselect.2)0
-rw-r--r--lib/libsys/ptrace.21451
-rw-r--r--lib/libsys/ptrace.c45
-rw-r--r--lib/libsys/quotactl.2260
-rw-r--r--lib/libsys/rctl_add_rule.2 (renamed from lib/libc/sys/rctl_add_rule.2)0
-rw-r--r--lib/libsys/read.2319
-rw-r--r--lib/libsys/readlink.2158
-rw-r--r--lib/libsys/reboot.2162
-rw-r--r--lib/libsys/recv.2402
-rw-r--r--lib/libsys/recvmmsg.c95
-rw-r--r--lib/libsys/rename.2343
-rw-r--r--lib/libsys/revoke.2107
-rw-r--r--lib/libsys/rfork.2 (renamed from lib/libc/sys/rfork.2)0
-rw-r--r--lib/libsys/rfork_thread.3 (renamed from lib/libc/gen/rfork_thread.3)0
-rw-r--r--lib/libsys/riscv/Makefile.sys5
-rw-r--r--lib/libsys/riscv/SYS.h63
-rw-r--r--lib/libsys/riscv/__vdso_gettc.c53
-rw-r--r--lib/libsys/riscv/cerror.S (renamed from lib/libc/riscv/sys/cerror.S)0
-rw-r--r--lib/libsys/riscv/vfork.S (renamed from lib/libc/riscv/sys/vfork.S)0
-rw-r--r--lib/libsys/rmdir.2117
-rw-r--r--lib/libsys/rtprio.2 (renamed from lib/libc/sys/rtprio.2)0
-rw-r--r--lib/libsys/sched_get_priority_max.2 (renamed from lib/libc/sys/sched_get_priority_max.2)0
-rw-r--r--lib/libsys/sched_getcpu.351
-rw-r--r--lib/libsys/sched_getcpu_gen.c (renamed from lib/libc/gen/sched_getcpu_gen.c)0
-rw-r--r--lib/libsys/sched_setparam.2 (renamed from lib/libc/sys/sched_setparam.2)0
-rw-r--r--lib/libsys/sched_setscheduler.2 (renamed from lib/libc/sys/sched_setscheduler.2)0
-rw-r--r--lib/libsys/sched_yield.2 (renamed from lib/libc/sys/sched_yield.2)0
-rw-r--r--lib/libsys/sctp_generic_recvmsg.2 (renamed from lib/libc/sys/sctp_generic_recvmsg.2)0
-rw-r--r--lib/libsys/sctp_generic_sendmsg.284
-rw-r--r--lib/libsys/sctp_peeloff.278
-rw-r--r--lib/libsys/select.2225
-rw-r--r--lib/libsys/semctl.2 (renamed from lib/libc/sys/semctl.2)0
-rw-r--r--lib/libsys/semget.2 (renamed from lib/libc/sys/semget.2)0
-rw-r--r--lib/libsys/semop.2 (renamed from lib/libc/sys/semop.2)0
-rw-r--r--lib/libsys/send.2292
-rw-r--r--lib/libsys/sendfile.2437
-rw-r--r--lib/libsys/sendmmsg.c61
-rw-r--r--lib/libsys/setcred.2290
-rw-r--r--lib/libsys/setfib.2110
-rw-r--r--lib/libsys/setgroups.2101
-rw-r--r--lib/libsys/setpgid.2107
-rw-r--r--lib/libsys/setregid.287
-rw-r--r--lib/libsys/setresuid.2 (renamed from lib/libc/sys/setresuid.2)0
-rw-r--r--lib/libsys/setreuid.287
-rw-r--r--lib/libsys/setsid.278
-rw-r--r--lib/libsys/setuid.2186
-rw-r--r--lib/libsys/shm_open.2 (renamed from lib/libc/sys/shm_open.2)0
-rw-r--r--lib/libsys/shmat.2 (renamed from lib/libc/sys/shmat.2)0
-rw-r--r--lib/libsys/shmctl.2 (renamed from lib/libc/sys/shmctl.2)0
-rw-r--r--lib/libsys/shmget.2 (renamed from lib/libc/sys/shmget.2)0
-rw-r--r--lib/libsys/shutdown.2168
-rw-r--r--lib/libsys/sigaction.2792
-rw-r--r--lib/libsys/sigaltstack.2159
-rw-r--r--lib/libsys/sigfastblock.2164
-rw-r--r--lib/libsys/sigpending.274
-rw-r--r--lib/libsys/sigprocmask.2128
-rw-r--r--lib/libsys/sigqueue.2178
-rw-r--r--lib/libsys/sigreturn.286
-rw-r--r--lib/libsys/sigstack.247
-rw-r--r--lib/libsys/sigsuspend.282
-rw-r--r--lib/libsys/sigwait.2 (renamed from lib/libc/sys/sigwait.2)0
-rw-r--r--lib/libsys/sigwaitinfo.2 (renamed from lib/libc/sys/sigwaitinfo.2)0
-rw-r--r--lib/libsys/sleep.380
-rw-r--r--lib/libsys/socket.2358
-rw-r--r--lib/libsys/socketpair.2105
-rw-r--r--lib/libsys/stat.2489
-rw-r--r--lib/libsys/statfs.2272
-rw-r--r--lib/libsys/swapon.2160
-rw-r--r--lib/libsys/symlink.2207
-rw-r--r--lib/libsys/sync.274
-rw-r--r--lib/libsys/sysarch.278
-rw-r--r--lib/libsys/syscall.274
-rw-r--r--lib/libsys/syscalls.map816
-rw-r--r--lib/libsys/thr_exit.292
-rw-r--r--lib/libsys/thr_kill.2137
-rw-r--r--lib/libsys/thr_new.2256
-rw-r--r--lib/libsys/thr_self.292
-rw-r--r--lib/libsys/thr_set_name.296
-rw-r--r--lib/libsys/thr_suspend.2131
-rw-r--r--lib/libsys/thr_wake.2114
-rw-r--r--lib/libsys/timer_create.2199
-rw-r--r--lib/libsys/timer_delete.2 (renamed from lib/libc/sys/timer_delete.2)0
-rw-r--r--lib/libsys/timer_settime.2 (renamed from lib/libc/sys/timer_settime.2)0
-rw-r--r--lib/libsys/timerfd.2347
-rw-r--r--lib/libsys/truncate.2167
-rw-r--r--lib/libsys/umask.285
-rw-r--r--lib/libsys/undelete.2104
-rw-r--r--lib/libsys/unlink.2281
-rw-r--r--lib/libsys/usleep.377
-rw-r--r--lib/libsys/utimensat.2307
-rw-r--r--lib/libsys/utimes.2261
-rw-r--r--lib/libsys/utrace.2 (renamed from lib/libc/sys/utrace.2)0
-rw-r--r--lib/libsys/uuidgen.2 (renamed from lib/libc/sys/uuidgen.2)0
-rw-r--r--lib/libsys/vfork.2142
-rw-r--r--lib/libsys/wait.2693
-rw-r--r--lib/libsys/write.2307
-rw-r--r--lib/libsys/x86/Makefile.sys24
-rw-r--r--lib/libsys/x86/__vdso_gettc.c453
-rw-r--r--lib/libsys/x86/pkru.3203
-rw-r--r--lib/libsys/x86/pkru.c134
-rw-r--r--lib/libsys/x86/sched_getcpu_x86.c (renamed from lib/libc/x86/sys/sched_getcpu_x86.c)0
-rw-r--r--lib/libsysdecode/Makefile10
-rw-r--r--lib/libsysdecode/errno.c1
-rw-r--r--lib/libsysdecode/flags.c30
-rw-r--r--lib/libsysdecode/linux.c1
-rw-r--r--lib/libsysdecode/mktables8
-rw-r--r--lib/libsysdecode/signal.c1
-rw-r--r--lib/libsysdecode/support.c1
-rw-r--r--lib/libsysdecode/sysdecode.h2
-rw-r--r--lib/libsysdecode/sysdecode_fcntl_arg.33
-rw-r--r--lib/libsysdecode/sysdecode_mask.312
-rw-r--r--lib/libsysdecode/sysdecode_sctp_sinfo_flags.32
-rw-r--r--lib/libsysdecode/utrace.c1
-rw-r--r--lib/libtacplus/taclib.c1
-rw-r--r--lib/libtelnet/Makefile5
-rw-r--r--lib/libthr/Makefile34
-rw-r--r--lib/libthr/Makefile.depend1
-rw-r--r--lib/libthr/arch/aarch64/Makefile.inc1
-rw-r--r--lib/libthr/arch/aarch64/include/pthread_md.h7
-rw-r--r--lib/libthr/arch/aarch64/include/pthread_tls.h44
-rw-r--r--lib/libthr/arch/amd64/Makefile.inc5
-rw-r--r--lib/libthr/arch/amd64/amd64/thr_machdep.c48
-rw-r--r--lib/libthr/arch/amd64/include/pthread_md.h11
-rw-r--r--lib/libthr/arch/amd64/include/pthread_tls.h44
-rw-r--r--lib/libthr/arch/arm/Makefile.inc3
-rw-r--r--lib/libthr/arch/arm/include/pthread_md.h2
-rw-r--r--lib/libthr/arch/arm/include/pthread_tls.h44
-rw-r--r--lib/libthr/arch/arm/thr_rtld_arm.c67
-rw-r--r--lib/libthr/arch/i386/Makefile.inc3
-rw-r--r--lib/libthr/arch/i386/include/pthread_md.h11
-rw-r--r--lib/libthr/arch/i386/include/pthread_tls.h44
-rw-r--r--lib/libthr/arch/powerpc/Makefile.inc2
-rw-r--r--lib/libthr/arch/powerpc/include/pthread_md.h7
-rw-r--r--lib/libthr/arch/powerpc/include/pthread_tls.h44
-rw-r--r--lib/libthr/arch/riscv/include/pthread_md.h7
-rw-r--r--lib/libthr/arch/riscv/include/pthread_tls.h44
-rw-r--r--lib/libthr/libthr.38
-rw-r--r--lib/libthr/plockstat.d1
-rw-r--r--lib/libthr/pthread.map10
-rw-r--r--lib/libthr/sys/Makefile.inc1
-rw-r--r--lib/libthr/sys/thr_error.c5
-rw-r--r--lib/libthr/tests/Makefile3
-rw-r--r--lib/libthr/tests/atfork_test.c280
-rw-r--r--lib/libthr/tests/dlopen/Makefile1
-rw-r--r--lib/libthr/tests/dlopen/dso/Makefile2
-rw-r--r--lib/libthr/tests/pthread_sigqueue_test.c120
-rw-r--r--lib/libthr/tests/umtx_op_test.c3
-rw-r--r--lib/libthr/thread/Makefile.inc2
-rw-r--r--lib/libthr/thread/thr_affinity.c1
-rw-r--r--lib/libthr/thread/thr_attr.c495
-rw-r--r--lib/libthr/thread/thr_autoinit.c1
-rw-r--r--lib/libthr/thread/thr_barrier.c1
-rw-r--r--lib/libthr/thread/thr_barrierattr.c1
-rw-r--r--lib/libthr/thread/thr_cancel.c26
-rw-r--r--lib/libthr/thread/thr_clean.c1
-rw-r--r--lib/libthr/thread/thr_concurrency.c1
-rw-r--r--lib/libthr/thread/thr_cond.c2
-rw-r--r--lib/libthr/thread/thr_condattr.c2
-rw-r--r--lib/libthr/thread/thr_create.c19
-rw-r--r--lib/libthr/thread/thr_ctrdtr.c1
-rw-r--r--lib/libthr/thread/thr_detach.c1
-rw-r--r--lib/libthr/thread/thr_equal.c1
-rw-r--r--lib/libthr/thread/thr_event.c1
-rw-r--r--lib/libthr/thread/thr_exit.c1
-rw-r--r--lib/libthr/thread/thr_fork.c21
-rw-r--r--lib/libthr/thread/thr_getcpuclockid.c1
-rw-r--r--lib/libthr/thread/thr_getprio.c1
-rw-r--r--lib/libthr/thread/thr_getschedparam.c1
-rw-r--r--lib/libthr/thread/thr_getthreadid_np.c3
-rw-r--r--lib/libthr/thread/thr_info.c1
-rw-r--r--lib/libthr/thread/thr_init.c14
-rw-r--r--lib/libthr/thread/thr_join.c1
-rw-r--r--lib/libthr/thread/thr_kern.c1
-rw-r--r--lib/libthr/thread/thr_kill.c1
-rw-r--r--lib/libthr/thread/thr_list.c52
-rw-r--r--lib/libthr/thread/thr_main_np.c1
-rw-r--r--lib/libthr/thread/thr_malloc.c15
-rw-r--r--lib/libthr/thread/thr_multi_np.c1
-rw-r--r--lib/libthr/thread/thr_mutex.c2
-rw-r--r--lib/libthr/thread/thr_mutexattr.c1
-rw-r--r--lib/libthr/thread/thr_once.c1
-rw-r--r--lib/libthr/thread/thr_printf.c1
-rw-r--r--lib/libthr/thread/thr_private.h27
-rw-r--r--lib/libthr/thread/thr_pshared.c1
-rw-r--r--lib/libthr/thread/thr_pspinlock.c1
-rw-r--r--lib/libthr/thread/thr_resume_np.c6
-rw-r--r--lib/libthr/thread/thr_rtld.c45
-rw-r--r--lib/libthr/thread/thr_rwlock.c3
-rw-r--r--lib/libthr/thread/thr_rwlockattr.c1
-rw-r--r--lib/libthr/thread/thr_self.c1
-rw-r--r--lib/libthr/thread/thr_sem.c1
-rw-r--r--lib/libthr/thread/thr_setprio.c1
-rw-r--r--lib/libthr/thread/thr_setschedparam.c1
-rw-r--r--lib/libthr/thread/thr_sig.c56
-rw-r--r--lib/libthr/thread/thr_sigqueue.c79
-rw-r--r--lib/libthr/thread/thr_single_np.c1
-rw-r--r--lib/libthr/thread/thr_sleepq.c5
-rw-r--r--lib/libthr/thread/thr_spec.c1
-rw-r--r--lib/libthr/thread/thr_spinlock.c1
-rw-r--r--lib/libthr/thread/thr_stack.c6
-rw-r--r--lib/libthr/thread/thr_suspend_np.c6
-rw-r--r--lib/libthr/thread/thr_switch_np.c6
-rw-r--r--lib/libthr/thread/thr_symbols.c1
-rw-r--r--lib/libthr/thread/thr_syscalls.c55
-rw-r--r--lib/libthr/thread/thr_umtx.c11
-rw-r--r--lib/libthr/thread/thr_umtx.h1
-rw-r--r--lib/libthr/thread/thr_yield.c1
-rw-r--r--lib/libthread_db/Makefile1
-rw-r--r--lib/libthread_db/arch/aarch64/libpthread_md.c2
-rw-r--r--lib/libthread_db/arch/arm/libpthread_md.c1
-rw-r--r--lib/libthread_db/arch/i386/libpthread_md.c1
-rw-r--r--lib/libthread_db/arch/powerpc/libpthread_md.c1
-rw-r--r--lib/libthread_db/arch/riscv/libpthread_md.c1
-rw-r--r--lib/libucl/Makefile1
-rw-r--r--lib/libufs/Makefile5
-rw-r--r--lib/libufs/block.c46
-rw-r--r--lib/libufs/cgroup.c1
-rw-r--r--lib/libufs/inode.c29
-rw-r--r--lib/libufs/libufs.32
-rw-r--r--lib/libufs/libufs.h61
-rw-r--r--lib/libufs/sblock.c4
-rw-r--r--lib/libufs/type.c13
-rw-r--r--lib/libufs/ufs_disk_close.39
-rw-r--r--lib/libugidfw/Makefile1
-rw-r--r--lib/libulog/Makefile4
-rw-r--r--lib/libulog/ulog_login.c7
-rw-r--r--lib/libunbound/Makefile7
-rw-r--r--lib/libunbound/config.h17
-rw-r--r--lib/libusb/libusb-1.0.pc.in2
-rw-r--r--lib/libusb/libusb.350
-rw-r--r--lib/libusb/libusb.h30
-rw-r--r--lib/libusb/libusb01.c2
-rw-r--r--lib/libusb/libusb10.c254
-rw-r--r--lib/libusb/libusb10.h49
-rw-r--r--lib/libusb/libusb10_desc.c11
-rw-r--r--lib/libusb/libusb10_hotplug.c205
-rw-r--r--lib/libusb/libusb10_io.c46
-rw-r--r--lib/libusb/libusb20.31
-rw-r--r--lib/libusb/libusb20.h1
-rw-r--r--lib/libusb/libusb20_desc.h6
-rw-r--r--lib/libusbhid/data.c1
-rw-r--r--lib/libusbhid/descr.c1
-rw-r--r--lib/libusbhid/descr_compat.c1
-rw-r--r--lib/libusbhid/usage.c1
-rw-r--r--lib/libusbhid/usbhid.h5
-rw-r--r--lib/libutil++/Makefile20
-rw-r--r--lib/libutil++/freebsd::FILE_up.341
-rw-r--r--lib/libutil++/freebsd::addrinfo_up.345
-rw-r--r--lib/libutil++/freebsd::fd_up.378
-rw-r--r--lib/libutil++/freebsd::malloc_up.350
-rw-r--r--lib/libutil++/freebsd::nvlist_up.337
-rw-r--r--lib/libutil++/freebsd::pidfile.3110
-rw-r--r--lib/libutil++/freebsd::stringf.348
-rw-r--r--lib/libutil++/libutil++.hh230
-rw-r--r--lib/libutil++/stringf.cc57
-rw-r--r--lib/libutil++/tests/Makefile12
-rw-r--r--lib/libutil++/tests/pidfile_test.cc44
-rw-r--r--lib/libutil++/tests/stringf_test.cc52
-rw-r--r--lib/libutil++/tests/up_test.cc33
-rw-r--r--lib/libutil/Makefile185
-rw-r--r--lib/libutil/Symbol.map126
-rw-r--r--lib/libutil/_secure_path.c1
-rw-r--r--lib/libutil/auth.c44
-rw-r--r--lib/libutil/cpuset.351
-rw-r--r--lib/libutil/cpuset.c98
-rw-r--r--lib/libutil/expand_number.356
-rw-r--r--lib/libutil/expand_number.c83
-rw-r--r--lib/libutil/fparseln.310
-rw-r--r--lib/libutil/fparseln.c10
-rw-r--r--lib/libutil/ftime.378
-rw-r--r--lib/libutil/ftime.c53
-rw-r--r--lib/libutil/getlocalbase.c1
-rw-r--r--lib/libutil/gr_util.c1
-rw-r--r--lib/libutil/hexdump.32
-rw-r--r--lib/libutil/hexdump.c3
-rw-r--r--lib/libutil/humanize_number.c1
-rw-r--r--lib/libutil/kinfo_getallproc.c1
-rw-r--r--lib/libutil/kinfo_getfile.c4
-rw-r--r--lib/libutil/kinfo_getproc.c1
-rw-r--r--lib/libutil/kinfo_getvmobject.c1
-rw-r--r--lib/libutil/libutil.h11
-rw-r--r--lib/libutil/login.conf.539
-rw-r--r--lib/libutil/login_auth.c1
-rw-r--r--lib/libutil/login_cap.328
-rw-r--r--lib/libutil/login_cap.c68
-rw-r--r--lib/libutil/login_cap.h4
-rw-r--r--lib/libutil/login_class.31
-rw-r--r--lib/libutil/login_class.c190
-rw-r--r--lib/libutil/login_crypt.c1
-rw-r--r--lib/libutil/login_ok.c1
-rw-r--r--lib/libutil/login_times.c1
-rw-r--r--lib/libutil/login_tty.c2
-rw-r--r--lib/libutil/mntopts.3377
-rw-r--r--lib/libutil/mntopts.c300
-rw-r--r--lib/libutil/mntopts.h114
-rw-r--r--lib/libutil/pidfile.368
-rw-r--r--lib/libutil/pidfile.c1
-rw-r--r--lib/libutil/property.c1
-rw-r--r--lib/libutil/pty.c2
-rw-r--r--lib/libutil/pw_util.31
-rw-r--r--lib/libutil/pw_util.c2
-rw-r--r--lib/libutil/realhostname.c1
-rw-r--r--lib/libutil/tests/Makefile1
-rw-r--r--lib/libutil/tests/expand_number_test.c219
-rw-r--r--lib/libutil/tests/flopen_test.c1
-rw-r--r--lib/libutil/tests/grp_test.c1
-rw-r--r--lib/libutil/tests/pidfile_test.c1
-rw-r--r--lib/libutil/tests/trimdomain-nodomain_test.c5
-rw-r--r--lib/libutil/tests/trimdomain_test.c5
-rw-r--r--lib/libutil/trimdomain.c1
-rw-r--r--lib/libutil/uucplock.c2
-rw-r--r--lib/libveriexec/Makefile1
-rw-r--r--lib/libveriexec/veriexec.32
-rw-r--r--lib/libveriexec/veriexec_check.c1
-rw-r--r--lib/libveriexec/veriexec_get.c1
-rw-r--r--lib/libvgl/bitmap.c1
-rw-r--r--lib/libvgl/main.c2
-rw-r--r--lib/libvmmapi/Makefile13
-rw-r--r--lib/libvmmapi/aarch64/Makefile.inc1
-rw-r--r--lib/libvmmapi/aarch64/vmmapi_machdep.c127
-rw-r--r--lib/libvmmapi/amd64/Makefile.inc5
-rw-r--r--lib/libvmmapi/amd64/vmmapi_freebsd_machdep.c343
-rw-r--r--lib/libvmmapi/amd64/vmmapi_machdep.c607
-rw-r--r--lib/libvmmapi/internal.h60
-rw-r--r--lib/libvmmapi/ppt.c144
-rw-r--r--lib/libvmmapi/riscv/Makefile.inc1
-rw-r--r--lib/libvmmapi/riscv/vmmapi_machdep.c118
-rw-r--r--lib/libvmmapi/vmmapi.c1031
-rw-r--r--lib/libvmmapi/vmmapi.h56
-rw-r--r--lib/libvmmapi/vmmapi_freebsd.c344
-rw-r--r--lib/libxo/Makefile1
-rw-r--r--lib/libxo/encoder/Makefile1
-rw-r--r--lib/libxo/encoder/csv/Makefile1
-rw-r--r--lib/libxo/encoder/csv/Makefile.depend17
-rw-r--r--lib/libxo/libxo/Makefile2
-rw-r--r--lib/libxo/libxo/Makefile.depend16
-rw-r--r--lib/libxo/tests/Makefile1
-rw-r--r--lib/libxo/tests/Makefile.depend5
-rw-r--r--lib/libxo/tests/encoder/Makefile1
-rw-r--r--lib/libxo/tests/encoder/Makefile.depend4
-rw-r--r--lib/liby/Makefile1
-rw-r--r--lib/liby/main.c3
-rw-r--r--lib/liby/yyerror.c3
-rw-r--r--lib/libyaml/Makefile29
-rw-r--r--lib/libypclnt/Makefile1
-rw-r--r--lib/libz/Makefile1
-rw-r--r--lib/libzstd/Makefile1
-rw-r--r--lib/msun/Makefile27
-rw-r--r--lib/msun/Symbol.map1
-rw-r--r--lib/msun/aarch64/Makefile.inc1
-rw-r--r--lib/msun/aarch64/fenv.h1
-rw-r--r--lib/msun/amd64/Makefile.inc1
-rw-r--r--lib/msun/amd64/fenv.c1
-rw-r--r--lib/msun/arm/Makefile.inc1
-rw-r--r--lib/msun/arm/fenv.c6
-rw-r--r--lib/msun/arm/fenv.h1
-rw-r--r--lib/msun/bsdsrc/b_exp.c2
-rw-r--r--lib/msun/bsdsrc/b_log.c2
-rw-r--r--lib/msun/bsdsrc/b_tgamma.c2
-rw-r--r--lib/msun/bsdsrc/mathimpl.h3
-rw-r--r--lib/msun/i387/Makefile.inc1
-rw-r--r--lib/msun/i387/fenv.c1
-rw-r--r--lib/msun/i387/invtrig.c1
-rw-r--r--lib/msun/ld128/b_tgammal.c53
-rw-r--r--lib/msun/ld128/e_lgammal_r.c2
-rw-r--r--lib/msun/ld128/e_powl.c1
-rw-r--r--lib/msun/ld128/e_rem_pio2l.h4
-rw-r--r--lib/msun/ld128/invtrig.c1
-rw-r--r--lib/msun/ld128/k_cosl.c2
-rw-r--r--lib/msun/ld128/k_expl.h1
-rw-r--r--lib/msun/ld128/k_sinl.c2
-rw-r--r--lib/msun/ld128/k_tanl.c3
-rw-r--r--lib/msun/ld128/s_cexpl.c1
-rw-r--r--lib/msun/ld128/s_erfl.c2
-rw-r--r--lib/msun/ld128/s_exp2l.c1
-rw-r--r--lib/msun/ld128/s_expl.c1
-rw-r--r--lib/msun/ld128/s_logl.c3
-rw-r--r--lib/msun/ld80/e_lgammal_r.c2
-rw-r--r--lib/msun/ld80/e_powl.c26
-rw-r--r--lib/msun/ld80/e_rem_pio2l.h4
-rw-r--r--lib/msun/ld80/invtrig.c1
-rw-r--r--lib/msun/ld80/k_cosl.c2
-rw-r--r--lib/msun/ld80/k_expl.h1
-rw-r--r--lib/msun/ld80/k_sinl.c2
-rw-r--r--lib/msun/ld80/k_tanl.c3
-rw-r--r--lib/msun/ld80/s_cexpl.c1
-rw-r--r--lib/msun/ld80/s_erfl.c2
-rw-r--r--lib/msun/ld80/s_exp2l.c1
-rw-r--r--lib/msun/ld80/s_expl.c1
-rw-r--r--lib/msun/ld80/s_logl.c3
-rw-r--r--lib/msun/man/acos.32
-rw-r--r--lib/msun/man/acosh.32
-rw-r--r--lib/msun/man/asin.32
-rw-r--r--lib/msun/man/asinh.32
-rw-r--r--lib/msun/man/atan.32
-rw-r--r--lib/msun/man/atan2.32
-rw-r--r--lib/msun/man/atanh.32
-rw-r--r--lib/msun/man/ceil.32
-rw-r--r--lib/msun/man/copysign.32
-rw-r--r--lib/msun/man/cos.32
-rw-r--r--lib/msun/man/cosh.32
-rw-r--r--lib/msun/man/cospi.320
-rw-r--r--lib/msun/man/erf.315
-rw-r--r--lib/msun/man/exp.32
-rw-r--r--lib/msun/man/fabs.34
-rw-r--r--lib/msun/man/floor.32
-rw-r--r--lib/msun/man/fmod.32
-rw-r--r--lib/msun/man/hypot.32
-rw-r--r--lib/msun/man/ieee.32
-rw-r--r--lib/msun/man/ieee_test.32
-rw-r--r--lib/msun/man/ilogb.32
-rw-r--r--lib/msun/man/j0.32
-rw-r--r--lib/msun/man/lgamma.321
-rw-r--r--lib/msun/man/math.32
-rw-r--r--lib/msun/man/nextafter.32
-rw-r--r--lib/msun/man/remainder.32
-rw-r--r--lib/msun/man/rint.32
-rw-r--r--lib/msun/man/scalbn.32
-rw-r--r--lib/msun/man/sin.34
-rw-r--r--lib/msun/man/sinh.32
-rw-r--r--lib/msun/man/sinpi.314
-rw-r--r--lib/msun/man/sqrt.32
-rw-r--r--lib/msun/man/tan.32
-rw-r--r--lib/msun/man/tanh.32
-rw-r--r--lib/msun/man/tanpi.317
-rw-r--r--lib/msun/powerpc/Makefile.inc1
-rw-r--r--lib/msun/riscv/Makefile.inc1
-rw-r--r--lib/msun/riscv/Symbol.map9
-rw-r--r--lib/msun/riscv/fenv.c8
-rw-r--r--lib/msun/riscv/fenv.h38
-rw-r--r--lib/msun/src/catrig.c1
-rw-r--r--lib/msun/src/catrigf.c1
-rw-r--r--lib/msun/src/catrigl.c1
-rw-r--r--lib/msun/src/e_acos.c2
-rw-r--r--lib/msun/src/e_acosf.c21
-rw-r--r--lib/msun/src/e_acosh.c2
-rw-r--r--lib/msun/src/e_acoshf.c1
-rw-r--r--lib/msun/src/e_acoshl.c2
-rw-r--r--lib/msun/src/e_acosl.c2
-rw-r--r--lib/msun/src/e_asin.c2
-rw-r--r--lib/msun/src/e_asinf.c23
-rw-r--r--lib/msun/src/e_asinl.c2
-rw-r--r--lib/msun/src/e_atan2.c2
-rw-r--r--lib/msun/src/e_atan2f.c1
-rw-r--r--lib/msun/src/e_atan2l.c2
-rw-r--r--lib/msun/src/e_atanh.c2
-rw-r--r--lib/msun/src/e_atanhf.c1
-rw-r--r--lib/msun/src/e_atanhl.c2
-rw-r--r--lib/msun/src/e_cosh.c2
-rw-r--r--lib/msun/src/e_coshf.c1
-rw-r--r--lib/msun/src/e_coshl.c1
-rw-r--r--lib/msun/src/e_exp.c2
-rw-r--r--lib/msun/src/e_expf.c1
-rw-r--r--lib/msun/src/e_fmod.c2
-rw-r--r--lib/msun/src/e_fmodf.c1
-rw-r--r--lib/msun/src/e_fmodl.c2
-rw-r--r--lib/msun/src/e_gamma.c2
-rw-r--r--lib/msun/src/e_gamma_r.c2
-rw-r--r--lib/msun/src/e_gammaf.c1
-rw-r--r--lib/msun/src/e_gammaf_r.c1
-rw-r--r--lib/msun/src/e_hypot.c2
-rw-r--r--lib/msun/src/e_hypotf.c1
-rw-r--r--lib/msun/src/e_hypotl.c2
-rw-r--r--lib/msun/src/e_j0.c2
-rw-r--r--lib/msun/src/e_j0f.c1
-rw-r--r--lib/msun/src/e_j1.c2
-rw-r--r--lib/msun/src/e_j1f.c1
-rw-r--r--lib/msun/src/e_jn.c2
-rw-r--r--lib/msun/src/e_jnf.c1
-rw-r--r--lib/msun/src/e_lgamma.c2
-rw-r--r--lib/msun/src/e_lgamma_r.c2
-rw-r--r--lib/msun/src/e_lgammaf.c1
-rw-r--r--lib/msun/src/e_lgammaf_r.c1
-rw-r--r--lib/msun/src/e_lgammal.c2
-rw-r--r--lib/msun/src/e_log.c2
-rw-r--r--lib/msun/src/e_log10.c2
-rw-r--r--lib/msun/src/e_log10f.c1
-rw-r--r--lib/msun/src/e_log2.c2
-rw-r--r--lib/msun/src/e_log2f.c1
-rw-r--r--lib/msun/src/e_logf.c1
-rw-r--r--lib/msun/src/e_pow.c8
-rw-r--r--lib/msun/src/e_powf.c7
-rw-r--r--lib/msun/src/e_rem_pio2.c6
-rw-r--r--lib/msun/src/e_rem_pio2f.c5
-rw-r--r--lib/msun/src/e_remainder.c2
-rw-r--r--lib/msun/src/e_remainderf.c1
-rw-r--r--lib/msun/src/e_remainderl.c1
-rw-r--r--lib/msun/src/e_scalb.c2
-rw-r--r--lib/msun/src/e_scalbf.c1
-rw-r--r--lib/msun/src/e_sinh.c2
-rw-r--r--lib/msun/src/e_sinhf.c1
-rw-r--r--lib/msun/src/e_sinhl.c1
-rw-r--r--lib/msun/src/e_sqrt.c2
-rw-r--r--lib/msun/src/e_sqrtf.c4
-rw-r--r--lib/msun/src/e_sqrtl.c1
-rw-r--r--lib/msun/src/k_cos.c2
-rw-r--r--lib/msun/src/k_cosf.c4
-rw-r--r--lib/msun/src/k_exp.c1
-rw-r--r--lib/msun/src/k_expf.c1
-rw-r--r--lib/msun/src/k_log.h2
-rw-r--r--lib/msun/src/k_logf.h1
-rw-r--r--lib/msun/src/k_rem_pio2.c2
-rw-r--r--lib/msun/src/k_sin.c2
-rw-r--r--lib/msun/src/k_sincos.h1
-rw-r--r--lib/msun/src/k_sincosf.h1
-rw-r--r--lib/msun/src/k_sincosl.h1
-rw-r--r--lib/msun/src/k_sinf.c4
-rw-r--r--lib/msun/src/k_tan.c4
-rw-r--r--lib/msun/src/k_tanf.c4
-rw-r--r--lib/msun/src/math.h36
-rw-r--r--lib/msun/src/math_private.h3
-rw-r--r--lib/msun/src/s_asinh.c2
-rw-r--r--lib/msun/src/s_asinhf.c1
-rw-r--r--lib/msun/src/s_asinhl.c2
-rw-r--r--lib/msun/src/s_atan.c2
-rw-r--r--lib/msun/src/s_atanf.c1
-rw-r--r--lib/msun/src/s_atanl.c2
-rw-r--r--lib/msun/src/s_carg.c1
-rw-r--r--lib/msun/src/s_cargf.c1
-rw-r--r--lib/msun/src/s_cargl.c1
-rw-r--r--lib/msun/src/s_cbrt.c6
-rw-r--r--lib/msun/src/s_cbrtf.c5
-rw-r--r--lib/msun/src/s_cbrtl.c3
-rw-r--r--lib/msun/src/s_ccosh.c1
-rw-r--r--lib/msun/src/s_ccoshf.c1
-rw-r--r--lib/msun/src/s_ceil.c2
-rw-r--r--lib/msun/src/s_ceilf.c1
-rw-r--r--lib/msun/src/s_ceill.c3
-rw-r--r--lib/msun/src/s_cexp.c1
-rw-r--r--lib/msun/src/s_cexpf.c1
-rw-r--r--lib/msun/src/s_clog.c1
-rw-r--r--lib/msun/src/s_clogf.c1
-rw-r--r--lib/msun/src/s_clogl.c1
-rw-r--r--lib/msun/src/s_copysign.c2
-rw-r--r--lib/msun/src/s_copysignf.c1
-rw-r--r--lib/msun/src/s_cos.c2
-rw-r--r--lib/msun/src/s_cosf.c1
-rw-r--r--lib/msun/src/s_cosl.c1
-rw-r--r--lib/msun/src/s_cpow.c1
-rw-r--r--lib/msun/src/s_cpowf.c1
-rw-r--r--lib/msun/src/s_cpowl.c1
-rw-r--r--lib/msun/src/s_cproj.c1
-rw-r--r--lib/msun/src/s_cprojf.c1
-rw-r--r--lib/msun/src/s_cprojl.c1
-rw-r--r--lib/msun/src/s_csinh.c1
-rw-r--r--lib/msun/src/s_csinhf.c1
-rw-r--r--lib/msun/src/s_csqrt.c1
-rw-r--r--lib/msun/src/s_csqrtf.c1
-rw-r--r--lib/msun/src/s_csqrtl.c1
-rw-r--r--lib/msun/src/s_ctanh.c1
-rw-r--r--lib/msun/src/s_ctanhf.c1
-rw-r--r--lib/msun/src/s_erf.c2
-rw-r--r--lib/msun/src/s_erff.c1
-rw-r--r--lib/msun/src/s_exp2.c3
-rw-r--r--lib/msun/src/s_exp2f.c3
-rw-r--r--lib/msun/src/s_expm1.c2
-rw-r--r--lib/msun/src/s_expm1f.c1
-rw-r--r--lib/msun/src/s_fabs.c2
-rw-r--r--lib/msun/src/s_fabsf.c1
-rw-r--r--lib/msun/src/s_fdim.c1
-rw-r--r--lib/msun/src/s_finite.c2
-rw-r--r--lib/msun/src/s_finitef.c1
-rw-r--r--lib/msun/src/s_floor.c2
-rw-r--r--lib/msun/src/s_floorf.c1
-rw-r--r--lib/msun/src/s_floorl.c3
-rw-r--r--lib/msun/src/s_fma.c15
-rw-r--r--lib/msun/src/s_fmaf.c1
-rw-r--r--lib/msun/src/s_fmal.c15
-rw-r--r--lib/msun/src/s_fmax.c1
-rw-r--r--lib/msun/src/s_fmaxf.c1
-rw-r--r--lib/msun/src/s_fmaxl.c1
-rw-r--r--lib/msun/src/s_fmin.c1
-rw-r--r--lib/msun/src/s_fminf.c1
-rw-r--r--lib/msun/src/s_fminl.c1
-rw-r--r--lib/msun/src/s_frexp.c2
-rw-r--r--lib/msun/src/s_frexpf.c1
-rw-r--r--lib/msun/src/s_ilogb.c2
-rw-r--r--lib/msun/src/s_ilogbf.c1
-rw-r--r--lib/msun/src/s_ilogbl.c2
-rw-r--r--lib/msun/src/s_llrint.c1
-rw-r--r--lib/msun/src/s_llrintf.c1
-rw-r--r--lib/msun/src/s_llrintl.c1
-rw-r--r--lib/msun/src/s_llround.c1
-rw-r--r--lib/msun/src/s_llroundf.c1
-rw-r--r--lib/msun/src/s_llroundl.c1
-rw-r--r--lib/msun/src/s_log1p.c2
-rw-r--r--lib/msun/src/s_log1pf.c1
-rw-r--r--lib/msun/src/s_logb.c2
-rw-r--r--lib/msun/src/s_logbf.c1
-rw-r--r--lib/msun/src/s_logbl.c2
-rw-r--r--lib/msun/src/s_lrint.c1
-rw-r--r--lib/msun/src/s_lrintf.c1
-rw-r--r--lib/msun/src/s_lrintl.c1
-rw-r--r--lib/msun/src/s_lround.c1
-rw-r--r--lib/msun/src/s_lroundf.c1
-rw-r--r--lib/msun/src/s_lroundl.c1
-rw-r--r--lib/msun/src/s_modf.c5
-rw-r--r--lib/msun/src/s_modff.c1
-rw-r--r--lib/msun/src/s_nearbyint.c1
-rw-r--r--lib/msun/src/s_nextafter.c2
-rw-r--r--lib/msun/src/s_nextafterf.c1
-rw-r--r--lib/msun/src/s_nextafterl.c2
-rw-r--r--lib/msun/src/s_nexttoward.c2
-rw-r--r--lib/msun/src/s_nexttowardf.c1
-rw-r--r--lib/msun/src/s_remquo.c2
-rw-r--r--lib/msun/src/s_remquof.c2
-rw-r--r--lib/msun/src/s_remquol.c2
-rw-r--r--lib/msun/src/s_rint.c2
-rw-r--r--lib/msun/src/s_rintf.c1
-rw-r--r--lib/msun/src/s_rintl.c1
-rw-r--r--lib/msun/src/s_round.c1
-rw-r--r--lib/msun/src/s_roundf.c1
-rw-r--r--lib/msun/src/s_roundl.c1
-rw-r--r--lib/msun/src/s_scalbln.c1
-rw-r--r--lib/msun/src/s_significand.c2
-rw-r--r--lib/msun/src/s_significandf.c1
-rw-r--r--lib/msun/src/s_sin.c2
-rw-r--r--lib/msun/src/s_sincos.c1
-rw-r--r--lib/msun/src/s_sincosf.c1
-rw-r--r--lib/msun/src/s_sincosl.c1
-rw-r--r--lib/msun/src/s_sinf.c1
-rw-r--r--lib/msun/src/s_sinl.c1
-rw-r--r--lib/msun/src/s_tan.c2
-rw-r--r--lib/msun/src/s_tanf.c1
-rw-r--r--lib/msun/src/s_tanh.c2
-rw-r--r--lib/msun/src/s_tanhf.c1
-rw-r--r--lib/msun/src/s_tanhl.c2
-rw-r--r--lib/msun/src/s_tanl.c1
-rw-r--r--lib/msun/src/s_tgammaf.c1
-rw-r--r--lib/msun/src/s_trunc.c2
-rw-r--r--lib/msun/src/s_truncf.c2
-rw-r--r--lib/msun/src/s_truncl.c3
-rw-r--r--lib/msun/src/w_cabs.c1
-rw-r--r--lib/msun/src/w_cabsf.c5
-rw-r--r--lib/msun/src/w_cabsl.c1
-rw-r--r--lib/msun/tests/Makefile1
-rw-r--r--lib/msun/tests/cexp_test.c1
-rw-r--r--lib/msun/tests/csqrt_test.c1
-rw-r--r--lib/msun/tests/ctrig_test.c1
-rw-r--r--lib/msun/tests/fenv_test.c1
-rw-r--r--lib/msun/tests/fma_test.c1
-rw-r--r--lib/msun/tests/invctrig_test.c1
-rw-r--r--lib/msun/tests/logarithm_test.c1
-rw-r--r--lib/msun/tests/nan_test.c1
-rw-r--r--lib/msun/tests/nearbyint_test.c1
-rw-r--r--lib/msun/tests/rem_test.c1
-rw-r--r--lib/msun/tests/trig_test.c1
-rw-r--r--lib/ncurses/Makefile1
-rw-r--r--lib/ncurses/Makefile.inc1
-rw-r--r--lib/ncurses/config.mk10
-rw-r--r--lib/ncurses/form/Makefile4
-rw-r--r--lib/ncurses/form/Makefile.depend1
-rw-r--r--lib/ncurses/menu/Makefile4
-rw-r--r--lib/ncurses/ncurses/Makefile13
-rw-r--r--lib/ncurses/ncurses/Makefile.depend1
-rw-r--r--lib/ncurses/ncurses/pathnames.h2
-rw-r--r--lib/ncurses/panel/Makefile4
-rw-r--r--lib/ncurses/panel/Makefile.depend1
-rw-r--r--lib/ncurses/tinfo/Makefile44
-rw-r--r--lib/ncurses/tinfo/Makefile.depend1
-rw-r--r--lib/ncurses/tinfo/ncurses_cfg.h63
-rw-r--r--lib/ncurses/tinfo/pathnames.h2
-rw-r--r--lib/ofed/Makefile1
-rw-r--r--lib/ofed/Makefile.inc1
-rw-r--r--lib/ofed/complib/Makefile2
-rw-r--r--lib/ofed/include/Makefile1
-rwxr-xr-xlib/ofed/libbnxtre/Makefile13
-rw-r--r--lib/ofed/libcxgb4/Makefile2
-rw-r--r--lib/ofed/libibcm/Makefile2
-rw-r--r--lib/ofed/libibmad/Makefile2
-rw-r--r--lib/ofed/libibnetdisc/Makefile3
-rw-r--r--lib/ofed/libibumad/Makefile2
-rw-r--r--lib/ofed/libibverbs/Makefile2
-rw-r--r--lib/ofed/libirdma/Makefile3
-rw-r--r--lib/ofed/libirdma/Makefile.depend18
-rw-r--r--lib/ofed/libmlx4/Makefile2
-rw-r--r--lib/ofed/libmlx5/Makefile2
-rw-r--r--lib/ofed/libopensm/Makefile2
-rw-r--r--lib/ofed/librdmacm/Makefile2
-rw-r--r--lib/ofed/libvendor/Makefile2
-rw-r--r--lib/tests/Makefile1
3578 files changed, 132784 insertions, 68872 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 49d28c1eb975..e5139b312a75 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
.include <src.opts.mk>
# The SUBDIR_BOOTSTRAP list is a small set of libraries which are used by many
@@ -17,9 +15,12 @@ SUBDIR_BOOTSTRAP= \
libc++ \
libc++experimental \
libcxxrt \
+ libder \
+ libdiff \
libelf \
libssp \
libssp_nonshared \
+ libsys \
msun
# The main list; please keep these sorted alphabetically.
@@ -66,6 +67,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
libiscsiutil \
libjail \
libkiconv \
+ libkldelf \
libkvm \
liblua \
liblzma \
@@ -77,6 +79,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
libnetbsd \
libnetmap \
libnv \
+ libnvmf \
libopenbsd \
libpam \
libpathconv \
@@ -89,6 +92,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
librss \
librt \
librtld_db \
+ libsamplerate \
libsbuf \
libsmb \
libstdbuf \
@@ -102,10 +106,12 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
libugidfw \
libulog \
libutil \
+ libutil++ \
${_libvgl} \
libwrap \
libxo \
liby \
+ libyaml \
libz \
libzstd \
ncurses \
@@ -123,9 +129,10 @@ SUBDIR_DEPEND_libbsnmp= ${_libnetgraph}
SUBDIR_DEPEND_libc++:= libcxxrt
# libssp_nonshared doesn't need to be linked into libc on every arch, but it is
# small enough to build that this bit of serialization is likely insignificant.
-SUBDIR_DEPEND_libc= libcompiler_rt libssp_nonshared
+SUBDIR_DEPEND_libc= libsys libcompiler_rt libssp_nonshared
SUBDIR_DEPEND_libcam= libsbuf
SUBDIR_DEPEND_libcasper= libnv
+SUBDIR_DEPEND_libcrypt= libmd
SUBDIR_DEPEND_libdevstat= libkvm
SUBDIR_DEPEND_libdpv= libfigpar ncurses libutil
SUBDIR_DEPEND_libedit= ncurses
@@ -138,6 +145,8 @@ SUBDIR_DEPEND_libpjdlog= libutil
SUBDIR_DEPEND_libprocstat= libkvm libutil
SUBDIR_DEPEND_libradius= libmd
SUBDIR_DEPEND_libsmb= libkiconv
+# See comment above about libssp_nonshared
+SUBDIR_DEPEND_libsys= libcompiler_rt libssp_nonshared
SUBDIR_DEPEND_libtacplus= libmd
SUBDIR_DEPEND_libulog= libmd
SUBDIR_DEPEND_libunbound= ${_libldns}
@@ -147,11 +156,6 @@ SUBDIR_DEPEND_libpcap= ofed
.endif
SUBDIR_DEPEND_nss_tacplus= libtacplus
-.if !defined(COMPAT_LIBCOMPAT)
-SUBDIR+= flua
-SUBDIR_DEPEND_flua= libjail
-.endif
-
# NB: keep these sorted by MK_* knobs
SUBDIR.${MK_BEARSSL}+= libbearssl libsecureboot
@@ -169,22 +173,29 @@ SUBDIR+= clang
SUBDIR.${MK_CUSE}+= libcuse
SUBDIR.${MK_TOOLCHAIN}+=libpe
SUBDIR.${MK_DIALOG}+= libdpv libfigpar
+SUBDIR.${MK_FDT}+= libfdt
SUBDIR.${MK_FILE}+= libmagic
SUBDIR.${MK_GPIO}+= libgpio
SUBDIR.${MK_GSSAPI}+= libgssapi librpcsec_gss
SUBDIR.${MK_ICONV}+= libiconv_modules
+.if ${MK_MITKRB5} == "no"
SUBDIR.${MK_KERBEROS_SUPPORT}+= libcom_err
+.endif
SUBDIR.${MK_LDNS}+= libldns
SUBDIR.${MK_STATS}+= libstats
# The libraries under libclang_rt can only be built by clang.
-.if ${COMPILER_TYPE} == "clang"
+.if (${COMPILER_TYPE} == "clang" || make(clean) || make(cleandir)) && \
+ ${MK_CLANG} != "no"
_libclang_rt= libclang_rt
.elif (${MK_ASAN} != "no" || ${MK_UBSAN} != "no") && make(all)
.error Requested build with sanitizers but cannot build runtime libraries!
.endif
+# This construct disables libefivar for 32-bit build.
+.if ${MACHINE_CPUARCH} != "i386"
SUBDIR.${MK_EFI}+= libefivar
+.endif
SUBDIR.${MK_GOOGLETEST}+= googletest
SUBDIR.${MK_NETGRAPH}+= libnetgraph
SUBDIR.${MK_NIS}+= libypclnt
@@ -199,6 +210,10 @@ SUBDIR.${MK_PMC}+= libopencsd
.if ${MACHINE_CPUARCH} == "amd64"
SUBDIR.${MK_PMC}+= libipt
+.endif
+
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "aarch64" || \
+ ${MACHINE_CPUARCH} == "riscv"
SUBDIR.${MK_BHYVE}+= libvmmapi
.endif
diff --git a/lib/atf/Makefile.inc b/lib/atf/Makefile.inc
index c776c2f8f84e..f8f329842eb4 100644
--- a/lib/atf/Makefile.inc
+++ b/lib/atf/Makefile.inc
@@ -27,6 +27,3 @@
CFLAGS+= -DHAVE_CONFIG_H
WARNS?= 3
-
-# Permit use of auto_ptr for compilers defaulting to C++17 or later
-CXXSTD= c++11
diff --git a/lib/atf/libatf-c++/Makefile b/lib/atf/libatf-c++/Makefile
index 221a16657c2a..985a79b7dc03 100644
--- a/lib/atf/libatf-c++/Makefile
+++ b/lib/atf/libatf-c++/Makefile
@@ -48,9 +48,6 @@ CFLAGS+= -I.
CFLAGS+= -DHAVE_CONFIG_H
-# Silence warnings about usage of deprecated std::auto_ptr
-CXXWARNFLAGS+= -Wno-deprecated-declarations
-
SRCS= application.cpp \
build.cpp \
check.cpp \
diff --git a/lib/atf/libatf-c++/Makefile.inc b/lib/atf/libatf-c++/Makefile.inc
index d3b5cbd3a79b..01b5f23410c8 100644
--- a/lib/atf/libatf-c++/Makefile.inc
+++ b/lib/atf/libatf-c++/Makefile.inc
@@ -1,2 +1 @@
-
.include "../Makefile.inc"
diff --git a/lib/atf/libatf-c++/tests/Makefile b/lib/atf/libatf-c++/tests/Makefile
index 570e9845a14a..dc052c19df67 100644
--- a/lib/atf/libatf-c++/tests/Makefile
+++ b/lib/atf/libatf-c++/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
PACKAGE= tests
diff --git a/lib/atf/libatf-c++/tests/Makefile.depend b/lib/atf/libatf-c++/tests/Makefile.depend
index e9c46a0b722a..7886e7624456 100644
--- a/lib/atf/libatf-c++/tests/Makefile.depend
+++ b/lib/atf/libatf-c++/tests/Makefile.depend
@@ -1,7 +1,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/atf/libatf-c++/tests/Makefile.inc b/lib/atf/libatf-c++/tests/Makefile.inc
index d3b5cbd3a79b..01b5f23410c8 100644
--- a/lib/atf/libatf-c++/tests/Makefile.inc
+++ b/lib/atf/libatf-c++/tests/Makefile.inc
@@ -1,2 +1 @@
-
.include "../Makefile.inc"
diff --git a/lib/atf/libatf-c++/tests/detail/Makefile b/lib/atf/libatf-c++/tests/detail/Makefile
index 63e7489e5720..4b95f8dbd663 100644
--- a/lib/atf/libatf-c++/tests/detail/Makefile
+++ b/lib/atf/libatf-c++/tests/detail/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c++/detail
diff --git a/lib/atf/libatf-c/Makefile b/lib/atf/libatf-c/Makefile
index 9fd36dc913f3..4cfee2ed824f 100644
--- a/lib/atf/libatf-c/Makefile
+++ b/lib/atf/libatf-c/Makefile
@@ -119,6 +119,8 @@ MLINKS+= atf-c.3 ATF_CHECK.3 \
atf-c.3 atf_tc_fail.3 \
atf-c.3 atf_tc_fail_nonfatal.3 \
atf-c.3 atf_tc_pass.3 \
+ atf-c.3 atf_tc_require_kmod.3 \
+ atf-c.3 atf_tc_require_prog.3 \
atf-c.3 atf_tc_skip.3 \
atf-c.3 atf_utils_cat_file.3 \
atf-c.3 atf_utils_compare_file.3 \
diff --git a/lib/atf/libatf-c/Makefile.inc b/lib/atf/libatf-c/Makefile.inc
index 692761e886b3..bb4b9697d845 100644
--- a/lib/atf/libatf-c/Makefile.inc
+++ b/lib/atf/libatf-c/Makefile.inc
@@ -1,4 +1,3 @@
-
.include "../Makefile.inc"
CFLAGS+= -DATF_BUILD_CC='"cc"'
diff --git a/lib/atf/libatf-c/tests/Makefile b/lib/atf/libatf-c/tests/Makefile
index 4cba59485f31..c81c18a91f00 100644
--- a/lib/atf/libatf-c/tests/Makefile
+++ b/lib/atf/libatf-c/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
PACKAGE= tests
diff --git a/lib/atf/libatf-c/tests/Makefile.depend b/lib/atf/libatf-c/tests/Makefile.depend
index 1af0c88e099c..462a1562f495 100644
--- a/lib/atf/libatf-c/tests/Makefile.depend
+++ b/lib/atf/libatf-c/tests/Makefile.depend
@@ -1,7 +1,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/atf/libatf-c/tests/Makefile.inc b/lib/atf/libatf-c/tests/Makefile.inc
index d3b5cbd3a79b..01b5f23410c8 100644
--- a/lib/atf/libatf-c/tests/Makefile.inc
+++ b/lib/atf/libatf-c/tests/Makefile.inc
@@ -1,2 +1 @@
-
.include "../Makefile.inc"
diff --git a/lib/atf/libatf-c/tests/detail/Makefile b/lib/atf/libatf-c/tests/detail/Makefile
index fb014b3497ad..5123f6f4d796 100644
--- a/lib/atf/libatf-c/tests/detail/Makefile
+++ b/lib/atf/libatf-c/tests/detail/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c/detail
diff --git a/lib/atf/tests/Makefile b/lib/atf/tests/Makefile
index 3c4e525aa46f..500ff0f20c3b 100644
--- a/lib/atf/tests/Makefile
+++ b/lib/atf/tests/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/lib/atf/tests/test-programs/Makefile b/lib/atf/tests/test-programs/Makefile
index a1999e236cec..b0b04f5fe988 100644
--- a/lib/atf/tests/test-programs/Makefile
+++ b/lib/atf/tests/test-programs/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
TESTSDIR= ${TESTSBASE}/lib/atf/test-programs
diff --git a/lib/clang/Makefile b/lib/clang/Makefile
index adbf15828f80..52093dd7cb26 100644
--- a/lib/clang/Makefile
+++ b/lib/clang/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
# These have to be built in order.
diff --git a/lib/clang/Makefile.inc b/lib/clang/Makefile.inc
index 0a2ae8f6b802..3678060fdec0 100644
--- a/lib/clang/Makefile.inc
+++ b/lib/clang/Makefile.inc
@@ -1,12 +1,14 @@
+.include <src.opts.mk>
-.include <bsd.compiler.mk>
-
+PACKAGE= clang
MK_PIE:= no # Explicit libXXX.a references
+.if ${MK_LLVM_FULL_DEBUGINFO} == "no"
.if ${COMPILER_TYPE} == "clang"
DEBUG_FILES_CFLAGS= -gline-tables-only
.else
DEBUG_FILES_CFLAGS= -g1
.endif
+.endif
WARNS?= 0
diff --git a/lib/clang/headers/Makefile b/lib/clang/headers/Makefile
index 3c657f9d1cc8..6e9a4b6d3020 100644
--- a/lib/clang/headers/Makefile
+++ b/lib/clang/headers/Makefile
@@ -1,15 +1,10 @@
-
+.include <bsd.init.mk>
.include "../clang.pre.mk"
.PATH: ${CLANG_SRCS}/lib/Headers
-INCSGROUPS= INCS CUDA HLSL OMP ORC PPC
-INCSDIR= ${LIBDIR}/clang/16/include
-CUDADIR= ${INCSDIR}/cuda_wrappers
-HLSLDIR= ${INCSDIR}/hlsl
-OMPDIR= ${INCSDIR}/openmp_wrappers
-PPCDIR= ${INCSDIR}/ppc_wrappers
-
+INCSGROUPS+= INCS
+INCSDIR= ${LIBDIR}/clang/19/include
INCS+= __clang_cuda_builtin_vars.h
INCS+= __clang_cuda_cmath.h
INCS+= __clang_cuda_complex_builtins.h
@@ -25,12 +20,30 @@ INCS+= __clang_hip_libdevice_declares.h
INCS+= __clang_hip_math.h
INCS+= __clang_hip_runtime_wrapper.h
INCS+= __clang_hip_stdlib.h
+INCS+= __stdarg___gnuc_va_list.h
+INCS+= __stdarg___va_copy.h
+INCS+= __stdarg_header_macro.h
+INCS+= __stdarg_va_arg.h
+INCS+= __stdarg_va_copy.h
+INCS+= __stdarg_va_list.h
+INCS+= __stddef_header_macro.h
INCS+= __stddef_max_align_t.h
+INCS+= __stddef_null.h
+INCS+= __stddef_nullptr_t.h
+INCS+= __stddef_offsetof.h
+INCS+= __stddef_ptrdiff_t.h
+INCS+= __stddef_rsize_t.h
+INCS+= __stddef_size_t.h
+INCS+= __stddef_unreachable.h
+INCS+= __stddef_wchar_t.h
+INCS+= __stddef_wint_t.h
INCS+= __wmmintrin_aes.h
INCS+= __wmmintrin_pclmul.h
+INCS+= adcintrin.h
INCS+= adxintrin.h
INCS+= altivec.h
INCS+= ammintrin.h
+INCS+= amxcomplexintrin.h
INCS+= amxfp16intrin.h
INCS+= amxintrin.h
INCS+= arm64intr.h
@@ -44,12 +57,10 @@ INCS+= avx512bitalgintrin.h
INCS+= avx512bwintrin.h
INCS+= avx512cdintrin.h
INCS+= avx512dqintrin.h
-INCS+= avx512erintrin.h
INCS+= avx512fintrin.h
INCS+= avx512fp16intrin.h
INCS+= avx512ifmaintrin.h
INCS+= avx512ifmavlintrin.h
-INCS+= avx512pfintrin.h
INCS+= avx512vbmi2intrin.h
INCS+= avx512vbmiintrin.h
INCS+= avx512vbmivlintrin.h
@@ -70,6 +81,7 @@ INCS+= avx512vpopcntdqvlintrin.h
INCS+= avxifmaintrin.h
INCS+= avxintrin.h
INCS+= avxneconvertintrin.h
+INCS+= avxvnniint16intrin.h
INCS+= avxvnniint8intrin.h
INCS+= avxvnniintrin.h
INCS+= bmi2intrin.h
@@ -104,6 +116,8 @@ INCS+= immintrin.h
INCS+= invpcidintrin.h
INCS+= keylockerintrin.h
INCS+= larchintrin.h
+INCS+= lasxintrin.h
+INCS+= lsxintrin.h
INCS+= lwpintrin.h
INCS+= lzcntintrin.h
INCS+= mm3dnow.h
@@ -122,20 +136,30 @@ INCS+= pmmintrin.h
INCS+= popcntintrin.h
INCS+= prfchiintrin.h
INCS+= prfchwintrin.h
+INCS+= ptrauth.h
INCS+= ptwriteintrin.h
INCS+= raointintrin.h
INCS+= rdpruintrin.h
INCS+= rdseedintrin.h
+INCS+= riscv_bitmanip.h
+INCS+= riscv_crypto.h
+INCS+= riscv_ntlh.h
INCS+= rtmintrin.h
INCS+= s390intrin.h
INCS+= serializeintrin.h
INCS+= sgxintrin.h
+INCS+= sha512intrin.h
INCS+= shaintrin.h
+INCS+= sifive_vector.h
+INCS+= sm3intrin.h
+INCS+= sm4intrin.h
INCS+= smmintrin.h
+INCS+= stdckdint.h
INCS+= tbmintrin.h
INCS+= tmmintrin.h
INCS+= tsxldtrkintrin.h
INCS+= uintrintrin.h
+INCS+= usermsrintrin.h
INCS+= vadefs.h
INCS+= vaesintrin.h
INCS+= vecintrin.h
@@ -156,12 +180,14 @@ INCS+= xsaveintrin.h
INCS+= xsaveoptintrin.h
INCS+= xsavesintrin.h
INCS+= xtestintrin.h
+INCS+= yvals_core.h
INCS+= ${GENINCS}
# Headers which possibly conflict with our own versions:
.ifdef INSTALL_CONFLICTING_CLANG_HEADERS
INCS+= float.h
INCS+= intrin.h
+INCS+= intrin0.h
INCS+= inttypes.h
INCS+= iso646.h
INCS+= limits.h
@@ -177,14 +203,26 @@ INCS+= unwind.h
INCS+= varargs.h
.endif # INSTALL_CONFLICTING_CLANG_HEADERS
+INCSGROUPS+= CUDA
+CUDADIR= ${INCSDIR}/cuda_wrappers
CUDA+= cuda_wrappers/algorithm
CUDA+= cuda_wrappers/cmath
CUDA+= cuda_wrappers/complex
CUDA+= cuda_wrappers/new
+INCSGROUPS+= CUDB
+CUDBDIR= ${INCSDIR}/cuda_wrappers/bits
+CUDB+= cuda_wrappers/bits/basic_string.h
+CUDB+= cuda_wrappers/bits/basic_string.tcc
+CUDB+= cuda_wrappers/bits/shared_ptr_base.h
+
+INCSGROUPS+= HLSL
+HLSLDIR= ${INCSDIR}/hlsl
HLSL+= hlsl/hlsl_basic_types.h
HLSL+= hlsl/hlsl_intrinsics.h
+INCSGROUPS+= OMP
+OMPDIR= ${INCSDIR}/openmp_wrappers
OMP+= openmp_wrappers/__clang_openmp_device_functions.h
OMP+= openmp_wrappers/cmath
OMP+= openmp_wrappers/complex
@@ -193,12 +231,15 @@ OMP+= openmp_wrappers/complex_cmath.h
OMP+= openmp_wrappers/math.h
OMP+= openmp_wrappers/new
+INCSGROUPS+= PPC
+PPCDIR= ${INCSDIR}/ppc_wrappers
PPC+= ppc_wrappers/bmi2intrin.h
PPC+= ppc_wrappers/bmiintrin.h
PPC+= ppc_wrappers/emmintrin.h
PPC+= ppc_wrappers/immintrin.h
PPC+= ppc_wrappers/mm_malloc.h
PPC+= ppc_wrappers/mmintrin.h
+PPC+= ppc_wrappers/nmmintrin.h
PPC+= ppc_wrappers/pmmintrin.h
PPC+= ppc_wrappers/smmintrin.h
PPC+= ppc_wrappers/tmmintrin.h
@@ -207,7 +248,7 @@ PPC+= ppc_wrappers/x86intrin.h
PPC+= ppc_wrappers/xmmintrin.h
.for hdr in bf16/bf16 cde/cde-header fp16/fp16 mve/mve-header neon/neon \
- sve/sve-header
+ sme/sme-header sve/sve-header
arm_${hdr:H}.h: ${CLANG_SRCS}/include/clang/Basic/arm_${hdr:H}.td
${CLANG_TBLGEN} -gen-arm-${hdr:T} \
-I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
@@ -215,6 +256,12 @@ arm_${hdr:H}.h: ${CLANG_SRCS}/include/clang/Basic/arm_${hdr:H}.td
GENINCS+= arm_${hdr:H}.h
.endfor
+arm_vector_types.h: ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+ ${CLANG_TBLGEN} -gen-arm-vector-type \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
+GENINCS+= arm_vector_types.h
+
.for hdr in vector/vector-header
riscv_${hdr:H}.h: ${CLANG_SRCS}/include/clang/Basic/riscv_${hdr:H}.td
${CLANG_TBLGEN} -gen-riscv-${hdr:T} \
diff --git a/lib/clang/include/Plugins/Plugins.def b/lib/clang/include/Plugins/Plugins.def
index a1224b71fc75..272e1f3aa5ee 100644
--- a/lib/clang/include/Plugins/Plugins.def
+++ b/lib/clang/include/Plugins/Plugins.def
@@ -33,12 +33,14 @@ LLDB_PLUGIN(ABIAArch64)
LLDB_PLUGIN(ABIARM)
LLDB_PLUGIN(ABIMips)
LLDB_PLUGIN(ABIPowerPC)
+LLDB_PLUGIN(ABIRISCV)
LLDB_PLUGIN(ABIX86)
LLDB_PLUGIN(ArchitectureArm)
LLDB_PLUGIN(ArchitectureMips)
LLDB_PLUGIN(ArchitecturePPC64)
LLDB_PLUGIN(ArchitectureAArch64)
LLDB_PLUGIN(DisassemblerLLVMC)
+LLDB_PLUGIN(DynamicLoaderFreeBSDKernel)
LLDB_PLUGIN(DynamicLoaderPosixDYLD)
LLDB_PLUGIN(DynamicLoaderStatic)
LLDB_PLUGIN(InstructionARM)
@@ -48,6 +50,7 @@ LLDB_PLUGIN(InstructionMIPS64)
LLDB_PLUGIN(InstructionPPC64)
LLDB_PLUGIN(InstructionRISCV)
LLDB_PLUGIN(InstrumentationRuntimeASan)
+LLDB_PLUGIN(InstrumentationRuntimeASanLibsanitizers)
LLDB_PLUGIN(InstrumentationRuntimeMainThreadChecker)
LLDB_PLUGIN(InstrumentationRuntimeTSan)
LLDB_PLUGIN(InstrumentationRuntimeUBSan)
@@ -58,9 +61,9 @@ LLDB_PLUGIN(MemoryHistoryASan)
LLDB_PLUGIN(ObjectContainerBSDArchive)
LLDB_PLUGIN(ObjectFileBreakpad)
LLDB_PLUGIN(ObjectFileELF)
-LLDB_PLUGIN(ObjectFileJIT)
LLDB_PLUGIN(PlatformFreeBSD)
LLDB_PLUGIN(PlatformGDB)
+LLDB_PLUGIN(PlatformQemuUser)
LLDB_PLUGIN(ScriptedProcess)
LLDB_PLUGIN(ProcessElfCore)
LLDB_PLUGIN(ProcessFreeBSDKernel)
@@ -69,6 +72,8 @@ LLDB_SCRIPT_PLUGIN(ScriptInterpreterLua)
LLDB_PLUGIN(SymbolFileBreakpad)
LLDB_PLUGIN(SymbolFileDWARF)
LLDB_PLUGIN(SymbolFileSymtab)
+LLDB_PLUGIN(SymbolLocatorDefault)
+LLDB_PLUGIN(SymbolLocatorDebuginfod)
LLDB_PLUGIN(SymbolVendorELF)
LLDB_PLUGIN(TypeSystemClang)
LLDB_PLUGIN(UnwindAssemblyInstEmulation)
diff --git a/lib/clang/include/VCSVersion.inc b/lib/clang/include/VCSVersion.inc
index 598871260c01..a18ba351aaab 100644
--- a/lib/clang/include/VCSVersion.inc
+++ b/lib/clang/include/VCSVersion.inc
@@ -1,8 +1,8 @@
-#define LLVM_REVISION "llvmorg-16.0.6-0-g7cbf1a259152"
+#define LLVM_REVISION "llvmorg-19.1.7-0-gcd708029e0b2"
#define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git"
-#define CLANG_REVISION "llvmorg-16.0.6-0-g7cbf1a259152"
+#define CLANG_REVISION "llvmorg-19.1.7-0-gcd708029e0b2"
#define CLANG_REPOSITORY "https://github.com/llvm/llvm-project.git"
-#define LLDB_REVISION "llvmorg-16.0.6-0-g7cbf1a259152"
+#define LLDB_REVISION "llvmorg-19.1.7-0-gcd708029e0b2"
#define LLDB_REPOSITORY "https://github.com/llvm/llvm-project.git"
diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc
index d5aa1ce51f33..92e55f9316cf 100644
--- a/lib/clang/include/clang/Basic/Version.inc
+++ b/lib/clang/include/clang/Basic/Version.inc
@@ -1,8 +1,8 @@
-#define CLANG_VERSION 16.0.6
-#define CLANG_VERSION_STRING "16.0.6"
-#define CLANG_VERSION_MAJOR 16
-#define CLANG_VERSION_MAJOR_STRING "16"
-#define CLANG_VERSION_MINOR 0
-#define CLANG_VERSION_PATCHLEVEL 6
+#define CLANG_VERSION 19.1.7
+#define CLANG_VERSION_STRING "19.1.7"
+#define CLANG_VERSION_MAJOR 19
+#define CLANG_VERSION_MAJOR_STRING "19"
+#define CLANG_VERSION_MINOR 1
+#define CLANG_VERSION_PATCHLEVEL 7
#define CLANG_VENDOR "FreeBSD "
diff --git a/lib/clang/include/clang/Config/config.h b/lib/clang/include/clang/Config/config.h
index b2c85aa23d19..4895c820620c 100644
--- a/lib/clang/include/clang/Config/config.h
+++ b/lib/clang/include/clang/Config/config.h
@@ -57,6 +57,12 @@
/* Define if we have sys/resource.h (rlimits) */
#define CLANG_HAVE_RLIMITS 1
+/* Define if we have dlfcn.h */
+#define CLANG_HAVE_DLFCN_H 1
+
+/* Define if dladdr() is available on this platform. */
+#define CLANG_HAVE_DLADDR 1
+
/* Linker version detected at compile time. */
/* #undef HOST_LINK_VERSION */
@@ -77,4 +83,7 @@
/* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */
#define CLANG_SPAWN_CC1 0
+/* Whether CIR is built into Clang */
+#define CLANG_ENABLE_CIR 0
+
#endif
diff --git a/lib/clang/include/lld/Common/Version.inc b/lib/clang/include/lld/Common/Version.inc
index b30a085c61cf..0643da4abbf4 100644
--- a/lib/clang/include/lld/Common/Version.inc
+++ b/lib/clang/include/lld/Common/Version.inc
@@ -1,4 +1,4 @@
// Local identifier in __FreeBSD_version style
-#define LLD_FREEBSD_VERSION 1500000
+#define LLD_FREEBSD_VERSION 1500001
-#define LLD_VERSION_STRING "16.0.6 (FreeBSD llvmorg-16.0.6-0-g7cbf1a259152-" __XSTRING(LLD_FREEBSD_VERSION) ")"
+#define LLD_VERSION_STRING "19.1.7 (FreeBSD llvmorg-19.1.7-0-gcd708029e0b2-" __XSTRING(LLD_FREEBSD_VERSION) ")"
diff --git a/lib/clang/include/lldb/API/SBLanguages.h b/lib/clang/include/lldb/API/SBLanguages.h
new file mode 100644
index 000000000000..115dd4145b42
--- /dev/null
+++ b/lib/clang/include/lldb/API/SBLanguages.h
@@ -0,0 +1,101 @@
+//===-- SBLanguages.h -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBLANGUAGE_H
+#define LLDB_API_SBLANGUAGE_H
+
+namespace lldb {
+/// Used by \ref SBExpressionOptions.
+/// These enumerations use the same language enumerations as the DWARF
+/// specification for ease of use and consistency.
+enum SBSourceLanguageName : uint16_t {
+ /// ISO Ada.
+ eLanguageNameAda = 0x0001,
+ /// BLISS.
+ eLanguageNameBLISS = 0x0002,
+ /// C (K&R and ISO).
+ eLanguageNameC = 0x0003,
+ /// ISO C++.
+ eLanguageNameC_plus_plus = 0x0004,
+ /// ISO Cobol.
+ eLanguageNameCobol = 0x0005,
+ /// Crystal.
+ eLanguageNameCrystal = 0x0006,
+ /// D.
+ eLanguageNameD = 0x0007,
+ /// Dylan.
+ eLanguageNameDylan = 0x0008,
+ /// ISO Fortran.
+ eLanguageNameFortran = 0x0009,
+ /// Go.
+ eLanguageNameGo = 0x000a,
+ /// Haskell.
+ eLanguageNameHaskell = 0x000b,
+ /// Java.
+ eLanguageNameJava = 0x000c,
+ /// Julia.
+ eLanguageNameJulia = 0x000d,
+ /// Kotlin.
+ eLanguageNameKotlin = 0x000e,
+ /// Modula 2.
+ eLanguageNameModula2 = 0x000f,
+ /// Modula 3.
+ eLanguageNameModula3 = 0x0010,
+ /// Objective C.
+ eLanguageNameObjC = 0x0011,
+ /// Objective C++.
+ eLanguageNameObjC_plus_plus = 0x0012,
+ /// OCaml.
+ eLanguageNameOCaml = 0x0013,
+ /// OpenCL C.
+ eLanguageNameOpenCL_C = 0x0014,
+ /// ISO Pascal.
+ eLanguageNamePascal = 0x0015,
+ /// ANSI PL/I.
+ eLanguageNamePLI = 0x0016,
+ /// Python.
+ eLanguageNamePython = 0x0017,
+ /// RenderScript Kernel Language.
+ eLanguageNameRenderScript = 0x0018,
+ /// Rust.
+ eLanguageNameRust = 0x0019,
+ /// Swift.
+ eLanguageNameSwift = 0x001a,
+ /// Unified Parallel C (UPC).
+ eLanguageNameUPC = 0x001b,
+ /// Zig.
+ eLanguageNameZig = 0x001c,
+ /// Assembly.
+ eLanguageNameAssembly = 0x001d,
+ /// C#.
+ eLanguageNameC_sharp = 0x001e,
+ /// Mojo.
+ eLanguageNameMojo = 0x001f,
+ /// OpenGL Shading Language.
+ eLanguageNameGLSL = 0x0020,
+ /// OpenGL ES Shading Language.
+ eLanguageNameGLSL_ES = 0x0021,
+ /// High Level Shading Language.
+ eLanguageNameHLSL = 0x0022,
+ /// OpenCL C++.
+ eLanguageNameOpenCL_CPP = 0x0023,
+ /// C++ for OpenCL.
+ eLanguageNameCPP_for_OpenCL = 0x0024,
+ /// SYCL.
+ eLanguageNameSYCL = 0x0025,
+ /// Ruby.
+ eLanguageNameRuby = 0x0026,
+ /// Move.
+ eLanguageNameMove = 0x0027,
+ /// Hylo.
+ eLanguageNameHylo = 0x0028,
+};
+
+} // namespace lldb
+
+#endif
diff --git a/lib/clang/include/lldb/Host/Config.h b/lib/clang/include/lldb/Host/Config.h
index 8f6bdf58790e..20783dd62c39 100644
--- a/lib/clang/include/lldb/Host/Config.h
+++ b/lib/clang/include/lldb/Host/Config.h
@@ -55,4 +55,6 @@
/* #undef LLDB_GLOBAL_INIT_DIRECTORY */
+#define LLDB_BUG_REPORT_URL "https://bugs.freebsd.org/submit/"
+
#endif // #ifndef LLDB_HOST_CONFIG_H
diff --git a/lib/clang/include/lldb/Version/Version.inc b/lib/clang/include/lldb/Version/Version.inc
index 99f8a8e09dea..02d44970ff54 100644
--- a/lib/clang/include/lldb/Version/Version.inc
+++ b/lib/clang/include/lldb/Version/Version.inc
@@ -1,6 +1,6 @@
-#define LLDB_VERSION 16.0.6
-#define LLDB_VERSION_STRING "16.0.6"
-#define LLDB_VERSION_MAJOR 16
-#define LLDB_VERSION_MINOR 0
-#define LLDB_VERSION_PATCH 6
+#define LLDB_VERSION 19.1.7
+#define LLDB_VERSION_STRING "19.1.7"
+#define LLDB_VERSION_MAJOR 19
+#define LLDB_VERSION_MINOR 1
+#define LLDB_VERSION_PATCH 7
/* #undef LLDB_FULL_VERSION_STRING */
diff --git a/lib/clang/include/llvm/Config/AsmParsers.def b/lib/clang/include/llvm/Config/AsmParsers.def
index e37ea136a87b..3dccab75a285 100644
--- a/lib/clang/include/llvm/Config/AsmParsers.def
+++ b/lib/clang/include/llvm/Config/AsmParsers.def
@@ -1,3 +1,25 @@
+/*===- llvm/Config/AsmParsers.def - LLVM Assembly Parsers -------*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file enumerates all of the assembly-language parsers *|
+|* supported by this build of LLVM. Clients of this file should define *|
+|* the LLVM_ASM_PARSER macro to be a function-like macro with a *|
+|* single parameter (the name of the target whose assembly can be *|
+|* generated); including this file will then enumerate all of the *|
+|* targets with assembly parsers. *|
+|* *|
+|* The set of targets supported by LLVM is generated at configuration *|
+|* time, at which point this header is generated. Do not modify this *|
+|* header directly. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
#ifndef LLVM_ASM_PARSER
# error Please define the macro LLVM_ASM_PARSER(TargetName)
#endif
@@ -20,11 +42,9 @@ LLVM_ASM_PARSER(PowerPC)
#ifdef LLVM_TARGET_ENABLE_RISCV
LLVM_ASM_PARSER(RISCV)
#endif
-#ifdef LLVM_TARGET_ENABLE_SPARC
-LLVM_ASM_PARSER(Sparc)
-#endif
#ifdef LLVM_TARGET_ENABLE_X86
LLVM_ASM_PARSER(X86)
#endif
+
#undef LLVM_ASM_PARSER
diff --git a/lib/clang/include/llvm/Config/AsmPrinters.def b/lib/clang/include/llvm/Config/AsmPrinters.def
index 819a52bc29e2..649b8353c926 100644
--- a/lib/clang/include/llvm/Config/AsmPrinters.def
+++ b/lib/clang/include/llvm/Config/AsmPrinters.def
@@ -1,3 +1,25 @@
+/*===- llvm/Config/AsmPrinters.def - LLVM Assembly Printers -----*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file enumerates all of the assembly-language printers *|
+|* supported by this build of LLVM. Clients of this file should define *|
+|* the LLVM_ASM_PRINTER macro to be a function-like macro with a *|
+|* single parameter (the name of the target whose assembly can be *|
+|* generated); including this file will then enumerate all of the *|
+|* targets with assembly printers. *|
+|* *|
+|* The set of targets supported by LLVM is generated at configuration *|
+|* time, at which point this header is generated. Do not modify this *|
+|* header directly. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
#ifndef LLVM_ASM_PRINTER
# error Please define the macro LLVM_ASM_PRINTER(TargetName)
#endif
@@ -20,11 +42,9 @@ LLVM_ASM_PRINTER(PowerPC)
#ifdef LLVM_TARGET_ENABLE_RISCV
LLVM_ASM_PRINTER(RISCV)
#endif
-#ifdef LLVM_TARGET_ENABLE_SPARC
-LLVM_ASM_PRINTER(Sparc)
-#endif
#ifdef LLVM_TARGET_ENABLE_X86
LLVM_ASM_PRINTER(X86)
#endif
+
#undef LLVM_ASM_PRINTER
diff --git a/lib/clang/include/llvm/Config/Disassemblers.def b/lib/clang/include/llvm/Config/Disassemblers.def
index 90ab73d82294..c44fa4e303e2 100644
--- a/lib/clang/include/llvm/Config/Disassemblers.def
+++ b/lib/clang/include/llvm/Config/Disassemblers.def
@@ -1,3 +1,25 @@
+/*===- llvm/Config/Disassemblers.def - LLVM Assembly Parsers ----*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file enumerates all of the assembly-language parsers *|
+|* supported by this build of LLVM. Clients of this file should define *|
+|* the LLVM_DISASSEMBLER macro to be a function-like macro with a *|
+|* single parameter (the name of the target whose assembly can be *|
+|* generated); including this file will then enumerate all of the *|
+|* targets with assembly parsers. *|
+|* *|
+|* The set of targets supported by LLVM is generated at configuration *|
+|* time, at which point this header is generated. Do not modify this *|
+|* header directly. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
#ifndef LLVM_DISASSEMBLER
# error Please define the macro LLVM_DISASSEMBLER(TargetName)
#endif
@@ -20,11 +42,9 @@ LLVM_DISASSEMBLER(PowerPC)
#ifdef LLVM_TARGET_ENABLE_RISCV
LLVM_DISASSEMBLER(RISCV)
#endif
-#ifdef LLVM_TARGET_ENABLE_SPARC
-LLVM_DISASSEMBLER(Sparc)
-#endif
#ifdef LLVM_TARGET_ENABLE_X86
LLVM_DISASSEMBLER(X86)
#endif
+
#undef LLVM_DISASSEMBLER
diff --git a/lib/clang/include/llvm/Config/TargetMCAs.def b/lib/clang/include/llvm/Config/TargetMCAs.def
index e7d4e60c0098..9be6b47e2536 100644
--- a/lib/clang/include/llvm/Config/TargetMCAs.def
+++ b/lib/clang/include/llvm/Config/TargetMCAs.def
@@ -1,3 +1,25 @@
+/*===------ llvm/Config/TargetMCAs.def - LLVM Target MCAs -------*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file enumerates all of the target MCAs *|
+|* supported by this build of LLVM. Clients of this file should define *|
+|* the LLVM_TARGETMCA macro to be a function-like macro with a *|
+|* single parameter (the name of the target whose assembly can be *|
+|* generated); including this file will then enumerate all of the *|
+|* targets with target MCAs. *|
+|* *|
+|* The set of targets supported by LLVM is generated at configuration *|
+|* time, at which point this header is generated. Do not modify this *|
+|* header directly. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
#ifndef LLVM_TARGETMCA
# error Please define the macro LLVM_TARGETMCA(TargetName)
#endif
@@ -9,4 +31,5 @@ LLVM_TARGETMCA(RISCV)
LLVM_TARGETMCA(X86)
#endif
+
#undef LLVM_TARGETMCA
diff --git a/lib/clang/include/llvm/Config/Targets.def b/lib/clang/include/llvm/Config/Targets.def
index a9a64ccd4202..d3332a51a2cc 100644
--- a/lib/clang/include/llvm/Config/Targets.def
+++ b/lib/clang/include/llvm/Config/Targets.def
@@ -1,3 +1,24 @@
+/*===- llvm/Config/Targets.def - LLVM Target Architectures ------*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file enumerates all of the target architectures supported by *|
+|* this build of LLVM. Clients of this file should define the *|
+|* LLVM_TARGET macro to be a function-like macro with a single *|
+|* parameter (the name of the target); including this file will then *|
+|* enumerate all of the targets. *|
+|* *|
+|* The set of targets supported by LLVM is generated at configuration *|
+|* time, at which point this header is generated. Do not modify this *|
+|* header directly. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
#ifndef LLVM_TARGET
# error Please define the macro LLVM_TARGET(TargetName)
#endif
@@ -20,11 +41,9 @@ LLVM_TARGET(PowerPC)
#ifdef LLVM_TARGET_ENABLE_RISCV
LLVM_TARGET(RISCV)
#endif
-#ifdef LLVM_TARGET_ENABLE_SPARC
-LLVM_TARGET(Sparc)
-#endif
#ifdef LLVM_TARGET_ENABLE_X86
LLVM_TARGET(X86)
#endif
+
#undef LLVM_TARGET
diff --git a/lib/clang/include/llvm/Config/abi-breaking.h b/lib/clang/include/llvm/Config/abi-breaking.h
index eb90be1fe37b..55e67e2ebad7 100644
--- a/lib/clang/include/llvm/Config/abi-breaking.h
+++ b/lib/clang/include/llvm/Config/abi-breaking.h
@@ -13,7 +13,11 @@
#define LLVM_ABI_BREAKING_CHECKS_H
/* Define to enable checks that alter the LLVM C++ ABI */
+#ifdef NDEBUG
+#define LLVM_ENABLE_ABI_BREAKING_CHECKS 0
+#else
#define LLVM_ENABLE_ABI_BREAKING_CHECKS 1
+#endif
/* Define to enable reverse iteration of unordered llvm containers */
#define LLVM_ENABLE_REVERSE_ITERATION 0
diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h
index 78af3cbddcd1..1968fb5072c9 100644
--- a/lib/clang/include/llvm/Config/config.h
+++ b/lib/clang/include/llvm/Config/config.h
@@ -196,9 +196,6 @@
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
-/* Define to 1 if you have the `strerror' function. */
-#define HAVE_STRERROR 1
-
/* Define to 1 if you have the `strerror_r' function. */
#define HAVE_STRERROR_R 1
@@ -236,15 +233,6 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
-/* Define if the setupterm() function is supported this platform. */
-#if defined(__FreeBSD__)
-/*
- * This is only needed for terminalHasColors(). When disabled LLVM falls back
- * to checking a list of TERM prefixes which is sufficient for a bootstrap tool.
- */
-#define LLVM_ENABLE_TERMINFO TRUE
-#endif
-
/* Define to 1 if you have the <termios.h> header file. */
#define HAVE_TERMIOS_H 1
@@ -323,6 +311,9 @@
/* Whether tools show host and target info when invoked with --version */
#define LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO 1
+/* Whether tools show optional build config flags when invoked with --version */
+#define LLVM_VERSION_PRINTER_SHOW_BUILD_CONFIG 1
+
/* Define if libxml2 is supported on this platform. */
/* #undef LLVM_ENABLE_LIBXML2 */
@@ -347,10 +338,10 @@
#define PACKAGE_NAME "LLVM"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "LLVM 16.0.6"
+#define PACKAGE_STRING "LLVM 19.1.7"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "16.0.6"
+#define PACKAGE_VERSION "19.1.7"
/* Define to the vendor of this package. */
/* #undef PACKAGE_VENDOR */
@@ -376,4 +367,6 @@
/* #undef HAVE_PROC_PID_RUSAGE */
+#define HAVE_BUILTIN_THREAD_POINTER 1
+
#endif
diff --git a/lib/clang/include/llvm/Config/llvm-config.h b/lib/clang/include/llvm/Config/llvm-config.h
index cdf493029a3a..4ca2d0083398 100644
--- a/lib/clang/include/llvm/Config/llvm-config.h
+++ b/lib/clang/include/llvm/Config/llvm-config.h
@@ -54,6 +54,109 @@
/* LLVM name for the native target MCA init function, if available */
/* #undef LLVM_NATIVE_TARGETMCA */
+/* Define if the AArch64 target is built in */
+#ifdef LLVM_TARGET_ENABLE_AARCH64
+#define LLVM_HAS_AARCH64_TARGET 1
+#else
+#define LLVM_HAS_AARCH64_TARGET 0
+#endif
+
+/* Define if the AMDGPU target is built in */
+#define LLVM_HAS_AMDGPU_TARGET 0
+
+/* Define if the ARC target is built in */
+#define LLVM_HAS_ARC_TARGET 0
+
+/* Define if the ARM target is built in */
+#ifdef LLVM_TARGET_ENABLE_ARM
+#define LLVM_HAS_ARM_TARGET 1
+#else
+#define LLVM_HAS_ARM_TARGET 0
+#endif
+
+/* Define if the AVR target is built in */
+#define LLVM_HAS_AVR_TARGET 0
+
+/* Define if the BPF target is built in */
+#ifdef LLVM_TARGET_ENABLE_BPF
+#define LLVM_HAS_BPF_TARGET 1
+#else
+#define LLVM_HAS_BPF_TARGET 0
+#endif
+
+/* Define if the CSKY target is built in */
+#define LLVM_HAS_CSKY_TARGET 0
+
+/* Define if the DirectX target is built in */
+#define LLVM_HAS_DIRECTX_TARGET 0
+
+/* Define if the Hexagon target is built in */
+#define LLVM_HAS_HEXAGON_TARGET 0
+
+/* Define if the Lanai target is built in */
+#define LLVM_HAS_LANAI_TARGET 0
+
+/* Define if the LoongArch target is built in */
+#define LLVM_HAS_LOONGARCH_TARGET 0
+
+/* Define if the M68k target is built in */
+#define LLVM_HAS_M68K_TARGET 0
+
+/* Define if the Mips target is built in */
+#ifdef LLVM_TARGET_ENABLE_MIPS
+#define LLVM_HAS_MIPS_TARGET 1
+#else
+#define LLVM_HAS_MIPS_TARGET 0
+#endif
+
+/* Define if the MSP430 target is built in */
+#define LLVM_HAS_MSP430_TARGET 0
+
+/* Define if the NVPTX target is built in */
+#define LLVM_HAS_NVPTX_TARGET 0
+
+/* Define if the PowerPC target is built in */
+#ifdef LLVM_TARGET_ENABLE_POWERPC
+#define LLVM_HAS_POWERPC_TARGET 1
+#else
+#define LLVM_HAS_POWERPC_TARGET 0
+#endif
+
+/* Define if the RISCV target is built in */
+#ifdef LLVM_TARGET_ENABLE_RISCV
+#define LLVM_HAS_RISCV_TARGET 1
+#else
+#define LLVM_HAS_RISCV_TARGET 0
+#endif
+
+/* Define if the Sparc target is built in */
+#define LLVM_HAS_SPARC_TARGET 0
+
+/* Define if the SPIRV target is built in */
+#define LLVM_HAS_SPIRV_TARGET 0
+
+/* Define if the SystemZ target is built in */
+#define LLVM_HAS_SYSTEMZ_TARGET 0
+
+/* Define if the VE target is built in */
+#define LLVM_HAS_VE_TARGET 0
+
+/* Define if the WebAssembly target is built in */
+#define LLVM_HAS_WEBASSEMBLY_TARGET 0
+
+/* Define if the X86 target is built in */
+#ifdef LLVM_TARGET_ENABLE_X86
+#define LLVM_HAS_X86_TARGET 1
+#else
+#define LLVM_HAS_X86_TARGET 0
+#endif
+
+/* Define if the XCore target is built in */
+#define LLVM_HAS_XCORE_TARGET 0
+
+/* Define if the Xtensa target is built in */
+#define LLVM_HAS_XTENSA_TARGET 0
+
/* Define if this is Unixish platform */
#define LLVM_ON_UNIX 1
@@ -67,16 +170,16 @@
#define LLVM_USE_PERF 0
/* Major version of the LLVM API */
-#define LLVM_VERSION_MAJOR 16
+#define LLVM_VERSION_MAJOR 19
/* Minor version of the LLVM API */
-#define LLVM_VERSION_MINOR 0
+#define LLVM_VERSION_MINOR 1
/* Patch version of the LLVM API */
-#define LLVM_VERSION_PATCH 6
+#define LLVM_VERSION_PATCH 7
/* LLVM version string */
-#define LLVM_VERSION_STRING "16.0.6"
+#define LLVM_VERSION_STRING "19.1.7"
/* Whether LLVM records statistics for use with GetStatistics(),
* PrintStatistics() or PrintStatisticsJSON()
@@ -98,17 +201,12 @@
/* Define if zstd compression is available */
#define LLVM_ENABLE_ZSTD 1
-/* Define if LLVM is using tflite instead of libtensorflow */
+/* Define if LLVM is using tflite */
/* #undef LLVM_HAVE_TFLITE */
/* Define to 1 if you have the <sysexits.h> header file. */
#define HAVE_SYSEXITS_H 1
-/* Define if the xar_open() function is supported on this platform. */
-#if defined(__APPLE__)
-#define LLVM_HAVE_LIBXAR 1
-#endif
-
/* Define if building libLLVM shared library */
/* #undef LLVM_BUILD_LLVM_DYLIB */
@@ -128,4 +226,7 @@
/* Define if plugins enabled */
/* #undef LLVM_ENABLE_PLUGINS */
+/* Define if logf128 is available */
+/* #undef LLVM_HAS_LOGF128 */
+
#endif
diff --git a/lib/clang/include/llvm/Support/VCSRevision.h b/lib/clang/include/llvm/Support/VCSRevision.h
index 02b970068e71..76aa3f075586 100644
--- a/lib/clang/include/llvm/Support/VCSRevision.h
+++ b/lib/clang/include/llvm/Support/VCSRevision.h
@@ -1,2 +1,2 @@
-#define LLVM_REVISION "llvmorg-16.0.6-0-g7cbf1a259152"
+#define LLVM_REVISION "llvmorg-19.1.7-0-gcd708029e0b2"
#define LLVM_REPOSITORY "https://github.com/llvm/llvm-project.git"
diff --git a/lib/clang/libclang/Makefile b/lib/clang/libclang/Makefile
index 1ae9fb225abc..7eb2c99b25c8 100644
--- a/lib/clang/libclang/Makefile
+++ b/lib/clang/libclang/Makefile
@@ -1,13 +1,28 @@
-
-.include <src.opts.mk>
+.include <bsd.init.mk>
.include "../clang.pre.mk"
+.if defined(TOOLS_PREFIX)
+# Build static library during cross-tools stage
LIB= clang
+INTERNALLIB=
+.else
+PACKAGE= clang
+SHLIB_CXX= clang
+SHLIB_MAJOR= 19
+PRIVATELIB=
+.if ${MACHINE} == "powerpc"
+# Work around "relocation R_PPC_GOT16 out of range" errors
+PICFLAG= -fPIC
+.endif
+.endif
+
+SHARED_CXXFLAGS+= -UPIC # To avoid compile errors
CFLAGS+= -I${.OBJDIR}
CFLAGS+= -I${OBJTOP}/lib/clang/libllvm
CFLAGS+= -I${CLANG_SRCS}/lib/Basic
CFLAGS+= -I${CLANG_SRCS}/lib/Driver
+CFLAGS+= -I${CLANG_SRCS}/lib/CodeGen
# Ensure FREEBSD_CC_VERSION is defined for Basic/Targets.cpp
CFLAGS.Targets.cpp+= -include ../freebsd_cc_version.h
@@ -25,6 +40,10 @@ SRCDIR= clang/lib
# SRCS_FUL: required for MK_CLANG_FULL
# SRCS_LDB: required for MK_LLDB
+SRCS_MIN+= APINotes/APINotesManager.cpp
+SRCS_MIN+= APINotes/APINotesReader.cpp
+SRCS_MIN+= APINotes/APINotesWriter.cpp
+SRCS_MIN+= APINotes/APINotesYAMLCompiler.cpp
SRCS_FUL+= ARCMigrate/ARCMT.cpp
SRCS_FUL+= ARCMigrate/ARCMTActions.cpp
SRCS_FUL+= ARCMigrate/FileRemapper.cpp
@@ -56,6 +75,7 @@ SRCS_MIN+= AST/ASTImporterLookupTable.cpp
SRCS_MIN+= AST/ASTStructuralEquivalence.cpp
SRCS_MIN+= AST/ASTTypeTraits.cpp
SRCS_MIN+= AST/AttrImpl.cpp
+SRCS_MIN+= AST/Availability.cpp
SRCS_MIN+= AST/CXXInheritance.cpp
SRCS_MIN+= AST/Comment.cpp
SRCS_MIN+= AST/CommentBriefParser.cpp
@@ -65,7 +85,7 @@ SRCS_MIN+= AST/CommentParser.cpp
SRCS_MIN+= AST/CommentSema.cpp
SRCS_MIN+= AST/ComparisonCategories.cpp
SRCS_MIN+= AST/ComputeDependence.cpp
-SRCS_FUL+= AST/DataCollection.cpp
+SRCS_MIN+= AST/DataCollection.cpp
SRCS_MIN+= AST/Decl.cpp
SRCS_MIN+= AST/DeclBase.cpp
SRCS_MIN+= AST/DeclCXX.cpp
@@ -87,19 +107,23 @@ SRCS_MIN+= AST/ExternalASTSource.cpp
SRCS_MIN+= AST/FormatString.cpp
SRCS_MIN+= AST/InheritViz.cpp
SRCS_MIN+= AST/Interp/ByteCodeEmitter.cpp
-SRCS_MIN+= AST/Interp/ByteCodeExprGen.cpp
-SRCS_MIN+= AST/Interp/ByteCodeGenError.cpp
-SRCS_MIN+= AST/Interp/ByteCodeStmtGen.cpp
+SRCS_MIN+= AST/Interp/Compiler.cpp
SRCS_MIN+= AST/Interp/Context.cpp
SRCS_MIN+= AST/Interp/Descriptor.cpp
+SRCS_MIN+= AST/Interp/DynamicAllocator.cpp
SRCS_MIN+= AST/Interp/EvalEmitter.cpp
+SRCS_MIN+= AST/Interp/EvaluationResult.cpp
+SRCS_MIN+= AST/Interp/Floating.cpp
SRCS_MIN+= AST/Interp/Frame.cpp
SRCS_MIN+= AST/Interp/Function.cpp
SRCS_MIN+= AST/Interp/Interp.cpp
SRCS_MIN+= AST/Interp/InterpBlock.cpp
+SRCS_MIN+= AST/Interp/InterpBuiltin.cpp
SRCS_MIN+= AST/Interp/InterpFrame.cpp
+SRCS_MIN+= AST/Interp/InterpShared.cpp
SRCS_MIN+= AST/Interp/InterpStack.cpp
SRCS_MIN+= AST/Interp/InterpState.cpp
+SRCS_MIN+= AST/Interp/MemberPointer.cpp
SRCS_MIN+= AST/Interp/Pointer.cpp
SRCS_MIN+= AST/Interp/PrimType.cpp
SRCS_MIN+= AST/Interp/Program.cpp
@@ -117,6 +141,7 @@ SRCS_MIN+= AST/NestedNameSpecifier.cpp
SRCS_MIN+= AST/ODRDiagsEmitter.cpp
SRCS_MIN+= AST/ODRHash.cpp
SRCS_MIN+= AST/OSLog.cpp
+SRCS_MIN+= AST/OpenACCClause.cpp
SRCS_MIN+= AST/OpenMPClause.cpp
SRCS_MIN+= AST/ParentMap.cpp
SRCS_MIN+= AST/ParentMapContext.cpp
@@ -132,6 +157,7 @@ SRCS_MIN+= AST/Stmt.cpp
SRCS_MIN+= AST/StmtCXX.cpp
SRCS_MIN+= AST/StmtIterator.cpp
SRCS_MIN+= AST/StmtObjC.cpp
+SRCS_MIN+= AST/StmtOpenACC.cpp
SRCS_MIN+= AST/StmtOpenMP.cpp
SRCS_MIN+= AST/StmtPrinter.cpp
SRCS_MIN+= AST/StmtProfile.cpp
@@ -147,7 +173,9 @@ SRCS_MIN+= AST/VTableBuilder.cpp
SRCS_MIN+= ASTMatchers/ASTMatchFinder.cpp
SRCS_MIN+= ASTMatchers/ASTMatchersInternal.cpp
SRCS_MIN+= ASTMatchers/Dynamic/Diagnostics.cpp
+SRCS_MIN+= ASTMatchers/Dynamic/Marshallers.cpp
SRCS_MIN+= ASTMatchers/Dynamic/Registry.cpp
+SRCS_MIN+= ASTMatchers/Dynamic/VariantValue.cpp
SRCS_MIN+= Analysis/AnalysisDeclContext.cpp
SRCS_MIN+= Analysis/BodyFarm.cpp
SRCS_MIN+= Analysis/CFG.cpp
@@ -158,8 +186,8 @@ SRCS_MIN+= Analysis/CalledOnceCheck.cpp
SRCS_MIN+= Analysis/CloneDetection.cpp
SRCS_MIN+= Analysis/CocoaConventions.cpp
SRCS_FUL+= Analysis/CodeInjector.cpp
-SRCS_MIN+= Analysis/Consumed.cpp
SRCS_MIN+= Analysis/ConstructionContext.cpp
+SRCS_MIN+= Analysis/Consumed.cpp
SRCS_FUL+= Analysis/Dominators.cpp
SRCS_MIN+= Analysis/ExprMutationAnalyzer.cpp
SRCS_FUL+= Analysis/IssueHash.cpp
@@ -176,6 +204,7 @@ SRCS_MIN+= Analysis/ThreadSafetyCommon.cpp
SRCS_MIN+= Analysis/ThreadSafetyTIL.cpp
SRCS_MIN+= Analysis/UninitializedValues.cpp
SRCS_MIN+= Analysis/UnsafeBufferUsage.cpp
+SRCS_MIN+= Basic/ASTSourceDescriptor.cpp
SRCS_MIN+= Basic/Attributes.cpp
SRCS_MIN+= Basic/Builtins.cpp
SRCS_MIN+= Basic/CLWarnings.cpp
@@ -200,12 +229,14 @@ SRCS_MIN+= Basic/ObjCRuntime.cpp
SRCS_MIN+= Basic/OpenCLOptions.cpp
SRCS_MIN+= Basic/OpenMPKinds.cpp
SRCS_MIN+= Basic/OperatorPrecedence.cpp
+SRCS_MIN+= Basic/ParsedAttrInfo.cpp
SRCS_MIN+= Basic/ProfileList.cpp
SRCS_MIN+= Basic/SanitizerSpecialCaseList.cpp
SRCS_MIN+= Basic/Sanitizers.cpp
SRCS_MIN+= Basic/Sarif.cpp
SRCS_MIN+= Basic/SourceLocation.cpp
SRCS_MIN+= Basic/SourceManager.cpp
+SRCS_MIN+= Basic/SourceMgrAdapter.cpp
SRCS_MIN+= Basic/Stack.cpp
SRCS_MIN+= Basic/TargetID.cpp
SRCS_MIN+= Basic/TargetInfo.cpp
@@ -223,8 +254,8 @@ SRCS_MIN+= Basic/Targets/Lanai.cpp
SRCS_MIN+= Basic/Targets/Le64.cpp
SRCS_MIN+= Basic/Targets/LoongArch.cpp
SRCS_MIN+= Basic/Targets/M68k.cpp
-SRCS_MIN+= Basic/Targets/Mips.cpp
SRCS_MIN+= Basic/Targets/MSP430.cpp
+SRCS_MIN+= Basic/Targets/Mips.cpp
SRCS_MIN+= Basic/Targets/NVPTX.cpp
SRCS_MIN+= Basic/Targets/OSTargets.cpp
SRCS_MIN+= Basic/Targets/PNaCl.cpp
@@ -244,6 +275,8 @@ SRCS_MIN+= Basic/Version.cpp
SRCS_MIN+= Basic/Warnings.cpp
SRCS_MIN+= Basic/XRayInstr.cpp
SRCS_MIN+= Basic/XRayLists.cpp
+SRCS_MIN+= CodeGen/ABIInfo.cpp
+SRCS_MIN+= CodeGen/ABIInfoImpl.cpp
SRCS_MIN+= CodeGen/BackendUtil.cpp
SRCS_MIN+= CodeGen/CGAtomic.cpp
SRCS_MIN+= CodeGen/CGBlocks.cpp
@@ -277,6 +310,7 @@ SRCS_MIN+= CodeGen/CGObjCRuntime.cpp
SRCS_MIN+= CodeGen/CGOpenCLRuntime.cpp
SRCS_MIN+= CodeGen/CGOpenMPRuntime.cpp
SRCS_MIN+= CodeGen/CGOpenMPRuntimeGPU.cpp
+SRCS_MIN+= CodeGen/CGPointerAuth.cpp
SRCS_MIN+= CodeGen/CGRecordLayoutBuilder.cpp
SRCS_MIN+= CodeGen/CGStmt.cpp
SRCS_MIN+= CodeGen/CGStmtOpenMP.cpp
@@ -291,6 +325,7 @@ SRCS_MIN+= CodeGen/CodeGenTypes.cpp
SRCS_MIN+= CodeGen/ConstantInitBuilder.cpp
SRCS_MIN+= CodeGen/CoverageMappingGen.cpp
SRCS_MIN+= CodeGen/ItaniumCXXABI.cpp
+SRCS_MIN+= CodeGen/LinkInModulesPass.cpp
SRCS_MIN+= CodeGen/MacroPPCallbacks.cpp
SRCS_MIN+= CodeGen/MicrosoftCXXABI.cpp
SRCS_MIN+= CodeGen/ModuleBuilder.cpp
@@ -299,6 +334,31 @@ SRCS_MIN+= CodeGen/PatternInit.cpp
SRCS_MIN+= CodeGen/SanitizerMetadata.cpp
SRCS_MIN+= CodeGen/SwiftCallingConv.cpp
SRCS_MIN+= CodeGen/TargetInfo.cpp
+SRCS_MIN+= CodeGen/Targets/AArch64.cpp
+SRCS_MIN+= CodeGen/Targets/AMDGPU.cpp
+SRCS_MIN+= CodeGen/Targets/ARC.cpp
+SRCS_MIN+= CodeGen/Targets/ARM.cpp
+SRCS_MIN+= CodeGen/Targets/AVR.cpp
+SRCS_MIN+= CodeGen/Targets/BPF.cpp
+SRCS_MIN+= CodeGen/Targets/CSKY.cpp
+SRCS_MIN+= CodeGen/Targets/Hexagon.cpp
+SRCS_MIN+= CodeGen/Targets/Lanai.cpp
+SRCS_MIN+= CodeGen/Targets/LoongArch.cpp
+SRCS_MIN+= CodeGen/Targets/M68k.cpp
+SRCS_MIN+= CodeGen/Targets/MSP430.cpp
+SRCS_MIN+= CodeGen/Targets/Mips.cpp
+SRCS_MIN+= CodeGen/Targets/NVPTX.cpp
+SRCS_MIN+= CodeGen/Targets/PNaCl.cpp
+SRCS_MIN+= CodeGen/Targets/PPC.cpp
+SRCS_MIN+= CodeGen/Targets/RISCV.cpp
+SRCS_MIN+= CodeGen/Targets/SPIR.cpp
+SRCS_MIN+= CodeGen/Targets/Sparc.cpp
+SRCS_MIN+= CodeGen/Targets/SystemZ.cpp
+SRCS_MIN+= CodeGen/Targets/TCE.cpp
+SRCS_MIN+= CodeGen/Targets/VE.cpp
+SRCS_MIN+= CodeGen/Targets/WebAssembly.cpp
+SRCS_MIN+= CodeGen/Targets/X86.cpp
+SRCS_MIN+= CodeGen/Targets/XCore.cpp
SRCS_MIN+= CodeGen/VarBypassDetector.cpp
SRCS_FUL+= CrossTU/CrossTranslationUnit.cpp
SRCS_MIN+= Driver/Action.cpp
@@ -308,6 +368,7 @@ SRCS_MIN+= Driver/Driver.cpp
SRCS_MIN+= Driver/DriverOptions.cpp
SRCS_MIN+= Driver/Job.cpp
SRCS_MIN+= Driver/Multilib.cpp
+SRCS_MIN+= Driver/MultilibBuilder.cpp
SRCS_MIN+= Driver/OptionUtils.cpp
SRCS_MIN+= Driver/Phases.cpp
SRCS_MIN+= Driver/SanitizerArgs.cpp
@@ -317,7 +378,6 @@ SRCS_MIN+= Driver/ToolChains/AIX.cpp
SRCS_MIN+= Driver/ToolChains/AMDGPU.cpp
SRCS_MIN+= Driver/ToolChains/AMDGPUOpenMP.cpp
SRCS_MIN+= Driver/ToolChains/AVR.cpp
-SRCS_MIN+= Driver/ToolChains/Ananas.cpp
SRCS_MIN+= Driver/ToolChains/Arch/AArch64.cpp
SRCS_MIN+= Driver/ToolChains/Arch/ARM.cpp
SRCS_MIN+= Driver/ToolChains/Arch/CSKY.cpp
@@ -333,9 +393,7 @@ SRCS_MIN+= Driver/ToolChains/Arch/X86.cpp
SRCS_MIN+= Driver/ToolChains/BareMetal.cpp
SRCS_MIN+= Driver/ToolChains/CSKYToolChain.cpp
SRCS_MIN+= Driver/ToolChains/Clang.cpp
-SRCS_MIN+= Driver/ToolChains/CloudABI.cpp
SRCS_MIN+= Driver/ToolChains/CommonArgs.cpp
-SRCS_MIN+= Driver/ToolChains/Contiki.cpp
SRCS_MIN+= Driver/ToolChains/CrossWindows.cpp
SRCS_MIN+= Driver/ToolChains/Cuda.cpp
SRCS_MIN+= Driver/ToolChains/Darwin.cpp
@@ -356,11 +414,10 @@ SRCS_MIN+= Driver/ToolChains/Linux.cpp
SRCS_MIN+= Driver/ToolChains/MSP430.cpp
SRCS_MIN+= Driver/ToolChains/MSVC.cpp
SRCS_MIN+= Driver/ToolChains/MinGW.cpp
-SRCS_MIN+= Driver/ToolChains/Minix.cpp
SRCS_MIN+= Driver/ToolChains/MipsLinux.cpp
-SRCS_MIN+= Driver/ToolChains/Myriad.cpp
SRCS_MIN+= Driver/ToolChains/NaCl.cpp
SRCS_MIN+= Driver/ToolChains/NetBSD.cpp
+SRCS_MIN+= Driver/ToolChains/OHOS.cpp
SRCS_MIN+= Driver/ToolChains/OpenBSD.cpp
SRCS_MIN+= Driver/ToolChains/PPCFreeBSD.cpp
SRCS_MIN+= Driver/ToolChains/PPCLinux.cpp
@@ -380,29 +437,31 @@ SRCS_MIN+= Edit/EditedSource.cpp
SRCS_MIN+= Edit/RewriteObjCFoundationAPI.cpp
SRCS_MIN+= ExtractAPI/API.cpp
SRCS_MIN+= ExtractAPI/APIIgnoresList.cpp
-SRCS_MIN+= ExtractAPI/AvailabilityInfo.cpp
SRCS_MIN+= ExtractAPI/DeclarationFragments.cpp
SRCS_MIN+= ExtractAPI/ExtractAPIConsumer.cpp
-SRCS_MIN+= ExtractAPI/ExtractAPIVisitor.cpp
SRCS_MIN+= ExtractAPI/Serialization/SymbolGraphSerializer.cpp
SRCS_MIN+= ExtractAPI/TypedefUnderlyingTypeResolver.cpp
-SRCS_EXT+= Format/AffectedRangeManager.cpp
-SRCS_EXT+= Format/BreakableToken.cpp
-SRCS_EXT+= Format/ContinuationIndenter.cpp
-SRCS_EXT+= Format/DefinitionBlockSeparator.cpp
-SRCS_EXT+= Format/Format.cpp
-SRCS_EXT+= Format/FormatToken.cpp
-SRCS_EXT+= Format/FormatTokenLexer.cpp
-SRCS_EXT+= Format/IntegerLiteralSeparatorFixer.cpp
-SRCS_EXT+= Format/NamespaceEndCommentsFixer.cpp
-SRCS_EXT+= Format/QualifierAlignmentFixer.cpp
-SRCS_EXT+= Format/SortJavaScriptImports.cpp
-SRCS_EXT+= Format/TokenAnalyzer.cpp
-SRCS_EXT+= Format/TokenAnnotator.cpp
-SRCS_EXT+= Format/UnwrappedLineFormatter.cpp
-SRCS_EXT+= Format/UnwrappedLineParser.cpp
-SRCS_EXT+= Format/UsingDeclarationsSorter.cpp
-SRCS_EXT+= Format/WhitespaceManager.cpp
+SRCS_MIN+= Format/AffectedRangeManager.cpp
+SRCS_MIN+= Format/BreakableToken.cpp
+SRCS_MIN+= Format/ContinuationIndenter.cpp
+SRCS_MIN+= Format/DefinitionBlockSeparator.cpp
+SRCS_MIN+= Format/Format.cpp
+SRCS_MIN+= Format/FormatToken.cpp
+SRCS_MIN+= Format/FormatTokenLexer.cpp
+SRCS_MIN+= Format/IntegerLiteralSeparatorFixer.cpp
+SRCS_MIN+= Format/MacroCallReconstructor.cpp
+SRCS_MIN+= Format/MacroExpander.cpp
+SRCS_EXT+= Format/MatchFilePath.cpp
+SRCS_MIN+= Format/NamespaceEndCommentsFixer.cpp
+SRCS_MIN+= Format/ObjCPropertyAttributeOrderFixer.cpp
+SRCS_MIN+= Format/QualifierAlignmentFixer.cpp
+SRCS_MIN+= Format/SortJavaScriptImports.cpp
+SRCS_MIN+= Format/TokenAnalyzer.cpp
+SRCS_MIN+= Format/TokenAnnotator.cpp
+SRCS_MIN+= Format/UnwrappedLineFormatter.cpp
+SRCS_MIN+= Format/UnwrappedLineParser.cpp
+SRCS_MIN+= Format/UsingDeclarationsSorter.cpp
+SRCS_MIN+= Format/WhitespaceManager.cpp
SRCS_MIN+= Frontend/ASTConsumers.cpp
SRCS_MIN+= Frontend/ASTMerge.cpp
SRCS_MIN+= Frontend/ASTUnit.cpp
@@ -450,10 +509,11 @@ SRCS_MIN+= Index/IndexTypeSourceInfo.cpp
SRCS_MIN+= Index/IndexingAction.cpp
SRCS_MIN+= Index/IndexingContext.cpp
SRCS_MIN+= Index/USRGeneration.cpp
+SRCS_MIN+= InstallAPI/HeaderFile.cpp
SRCS_MIN+= Lex/DependencyDirectivesScanner.cpp
-SRCS_MIN+= Lex/InitHeaderSearch.cpp
SRCS_MIN+= Lex/HeaderMap.cpp
SRCS_MIN+= Lex/HeaderSearch.cpp
+SRCS_MIN+= Lex/InitHeaderSearch.cpp
SRCS_MIN+= Lex/Lexer.cpp
SRCS_MIN+= Lex/LiteralSupport.cpp
SRCS_MIN+= Lex/MacroArgs.cpp
@@ -482,6 +542,7 @@ SRCS_MIN+= Parse/ParseExprCXX.cpp
SRCS_MIN+= Parse/ParseHLSL.cpp
SRCS_MIN+= Parse/ParseInit.cpp
SRCS_MIN+= Parse/ParseObjc.cpp
+SRCS_MIN+= Parse/ParseOpenACC.cpp
SRCS_MIN+= Parse/ParseOpenMP.cpp
SRCS_MIN+= Parse/ParsePragma.cpp
SRCS_MIN+= Parse/ParseStmt.cpp
@@ -495,6 +556,7 @@ SRCS_MIN+= Rewrite/RewriteRope.cpp
SRCS_MIN+= Rewrite/Rewriter.cpp
SRCS_MIN+= Rewrite/TokenRewriter.cpp
SRCS_MIN+= Sema/AnalysisBasedWarnings.cpp
+SRCS_MIN+= Sema/CheckExprLifetime.cpp
SRCS_MIN+= Sema/CodeCompleteConsumer.cpp
SRCS_MIN+= Sema/DeclSpec.cpp
SRCS_MIN+= Sema/DelayedDiagnostic.cpp
@@ -506,9 +568,16 @@ SRCS_MIN+= Sema/ParsedAttr.cpp
SRCS_MIN+= Sema/Scope.cpp
SRCS_MIN+= Sema/ScopeInfo.cpp
SRCS_MIN+= Sema/Sema.cpp
+SRCS_MIN+= Sema/SemaAMDGPU.cpp
+SRCS_MIN+= Sema/SemaAPINotes.cpp
+SRCS_MIN+= Sema/SemaARM.cpp
+SRCS_MIN+= Sema/SemaAVR.cpp
SRCS_MIN+= Sema/SemaAccess.cpp
SRCS_MIN+= Sema/SemaAttr.cpp
SRCS_MIN+= Sema/SemaAvailability.cpp
+SRCS_MIN+= Sema/SemaBPF.cpp
+SRCS_MIN+= Sema/SemaBase.cpp
+SRCS_MIN+= Sema/SemaBoundsSafety.cpp
SRCS_MIN+= Sema/SemaCUDA.cpp
SRCS_MIN+= Sema/SemaCXXScopeSpec.cpp
SRCS_MIN+= Sema/SemaCast.cpp
@@ -528,21 +597,36 @@ SRCS_MIN+= Sema/SemaExprMember.cpp
SRCS_MIN+= Sema/SemaExprObjC.cpp
SRCS_MIN+= Sema/SemaFixItUtils.cpp
SRCS_MIN+= Sema/SemaHLSL.cpp
+SRCS_MIN+= Sema/SemaHexagon.cpp
SRCS_MIN+= Sema/SemaInit.cpp
SRCS_MIN+= Sema/SemaLambda.cpp
SRCS_MIN+= Sema/SemaLookup.cpp
+SRCS_MIN+= Sema/SemaLoongArch.cpp
+SRCS_MIN+= Sema/SemaM68k.cpp
+SRCS_MIN+= Sema/SemaMIPS.cpp
+SRCS_MIN+= Sema/SemaMSP430.cpp
SRCS_MIN+= Sema/SemaModule.cpp
+SRCS_MIN+= Sema/SemaNVPTX.cpp
+SRCS_MIN+= Sema/SemaObjC.cpp
SRCS_MIN+= Sema/SemaObjCProperty.cpp
+SRCS_MIN+= Sema/SemaOpenACC.cpp
+SRCS_MIN+= Sema/SemaOpenCL.cpp
SRCS_MIN+= Sema/SemaOpenMP.cpp
SRCS_MIN+= Sema/SemaOverload.cpp
+SRCS_MIN+= Sema/SemaPPC.cpp
SRCS_MIN+= Sema/SemaPseudoObject.cpp
-SRCS_MIN+= Sema/SemaRISCVVectorLookup.cpp
+SRCS_MIN+= Sema/SemaRISCV.cpp
SRCS_MIN+= Sema/SemaSYCL.cpp
SRCS_MIN+= Sema/SemaStmt.cpp
SRCS_MIN+= Sema/SemaStmtAsm.cpp
SRCS_MIN+= Sema/SemaStmtAttr.cpp
+SRCS_MIN+= Sema/SemaSwift.cpp
+SRCS_MIN+= Sema/SemaSystemZ.cpp
+SRCS_MIN+= Sema/SemaWasm.cpp
+SRCS_MIN+= Sema/SemaX86.cpp
SRCS_MIN+= Sema/SemaTemplate.cpp
SRCS_MIN+= Sema/SemaTemplateDeduction.cpp
+SRCS_MIN+= Sema/SemaTemplateDeductionGuide.cpp
SRCS_MIN+= Sema/SemaTemplateInstantiate.cpp
SRCS_MIN+= Sema/SemaTemplateInstantiateDecl.cpp
SRCS_MIN+= Sema/SemaTemplateVariadic.cpp
@@ -567,12 +651,13 @@ SRCS_FUL+= StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
-SRCS_FUL+= StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CStringChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CStringSyntaxChecker.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/CXXDeleteChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CastSizeChecker.cpp
@@ -582,7 +667,7 @@ SRCS_FUL+= StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CheckPlacementNew.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
-SRCS_FUL+= StaticAnalyzer/Checkers/CheckSizeofPointer.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/CheckerDocumentation.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ChrootChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/CloneChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ContainerModeling.cpp
@@ -591,7 +676,6 @@ SRCS_FUL+= StaticAnalyzer/Checkers/DeadStoresChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/DebugCheckers.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/DebugContainerModeling.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/DebugIteratorModeling.cpp
-SRCS_FUL+= StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/DereferenceChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/DivZeroChecker.cpp
@@ -604,6 +688,7 @@ SRCS_FUL+= StaticAnalyzer/Checkers/ErrnoTesterChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/FixedAddressChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/GTestChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/GenericTaintChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
@@ -629,6 +714,7 @@ SRCS_FUL+= StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/MoveChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/NSErrorChecker.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/NonNullParamChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
@@ -650,6 +736,7 @@ SRCS_FUL+= StaticAnalyzer/Checkers/PointerIterationChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/PointerSortingChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/PointerSubChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/PutenvStackArrayChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
@@ -657,11 +744,13 @@ SRCS_FUL+= StaticAnalyzer/Checkers/ReturnUndefChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ReturnValueChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/RunLoopAutoreleaseLeakChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/SetgidSetuidOrderChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/SmartPtrChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/SmartPtrModeling.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+SRCS_FUL+= StaticAnalyzer/Checkers/StdVariantChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/StreamChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/StringChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/Taint.cpp
@@ -684,7 +773,6 @@ SRCS_FUL+= StaticAnalyzer/Checkers/VLASizeChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/ValistChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/VforkChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/VirtualCallChecker.cpp
-SRCS_FUL+= StaticAnalyzer/Checkers/cert/PutenvWithAutoChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
SRCS_FUL+= StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -700,6 +788,7 @@ SRCS_FUL+= StaticAnalyzer/Core/BasicValueFactory.cpp
SRCS_FUL+= StaticAnalyzer/Core/BlockCounter.cpp
SRCS_FUL+= StaticAnalyzer/Core/BugReporter.cpp
SRCS_FUL+= StaticAnalyzer/Core/BugReporterVisitors.cpp
+SRCS_FUL+= StaticAnalyzer/Core/BugSuppression.cpp
SRCS_FUL+= StaticAnalyzer/Core/CallDescription.cpp
SRCS_FUL+= StaticAnalyzer/Core/CallEvent.cpp
SRCS_FUL+= StaticAnalyzer/Core/Checker.cpp
@@ -739,6 +828,7 @@ SRCS_FUL+= StaticAnalyzer/Core/Store.cpp
SRCS_FUL+= StaticAnalyzer/Core/SymbolManager.cpp
SRCS_FUL+= StaticAnalyzer/Core/TextDiagnostics.cpp
SRCS_FUL+= StaticAnalyzer/Core/WorkList.cpp
+SRCS_FUL+= StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp
SRCS_FUL+= StaticAnalyzer/Frontend/AnalysisConsumer.cpp
SRCS_FUL+= StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
SRCS_FUL+= StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -751,10 +841,19 @@ SRCS_MIN+= Tooling/ArgumentsAdjusters.cpp
SRCS_MIN+= Tooling/CommonOptionsParser.cpp
SRCS_MIN+= Tooling/CompilationDatabase.cpp
SRCS_MIN+= Tooling/Core/Replacement.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningService.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningTool.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningWorker.cpp
+SRCS_MIN+= Tooling/DependencyScanning/ModuleDepCollector.cpp
+SRCS_MIN+= Tooling/ExpandResponseFilesCompilationDatabase.cpp
SRCS_MIN+= Tooling/FileMatchTrie.cpp
-SRCS_EXT+= Tooling/Inclusions/HeaderIncludes.cpp
-SRCS_EXT+= Tooling/Inclusions/IncludeStyle.cpp
+SRCS_MIN+= Tooling/GuessTargetAndModeCompilationDatabase.cpp
+SRCS_MIN+= Tooling/Inclusions/HeaderIncludes.cpp
+SRCS_MIN+= Tooling/Inclusions/IncludeStyle.cpp
+SRCS_MIN+= Tooling/InterpolatingCompilationDatabase.cpp
SRCS_MIN+= Tooling/JSONCompilationDatabase.cpp
+SRCS_MIN+= Tooling/LocateToolCompilationDatabase.cpp
SRCS_MIN+= Tooling/Refactoring.cpp
SRCS_MIN+= Tooling/RefactoringCallbacks.cpp
SRCS_MIN+= Tooling/Tooling.cpp
@@ -771,6 +870,21 @@ SRCS_ALL+= ${SRCS_LDB}
.endif
SRCS+= ${SRCS_ALL:O}
+LIBDEPS+= llvm
+
+.if defined(TOOLS_PREFIX)
+LIBPRIV=
+LIBEXT= a
+.else
+LIBPRIV= private
+LIBEXT= so
+.endif
+
+.for lib in ${LIBDEPS}
+DPADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT}
+LDADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT}
+.endfor
+
clang/AST/AbstractBasicReader.inc: \
${CLANG_SRCS}/include/clang/AST/PropertiesBase.td
${CLANG_TBLGEN} -gen-clang-basic-reader \
@@ -913,9 +1027,33 @@ clang/Basic/AttrSubMatchRulesList.inc: ${CLANG_SRCS}/include/clang/Basic/Attr.td
${CLANG_SRCS}/include/clang/Basic/Attr.td
TGHDRS+= clang/Basic/AttrSubMatchRulesList.inc
+clang/Basic/Builtins.inc: ${CLANG_SRCS}/include/clang/Basic/Builtins.td
+ ${CLANG_TBLGEN} -gen-clang-builtins \
+ -I ${CLANG_SRCS}/include -d ${.TARGET:C/$/.d/} -o ${.TARGET} \
+ ${CLANG_SRCS}/include/clang/Basic/Builtins.td
+TGHDRS+= clang/Basic/Builtins.inc
+
+clang/Basic/BuiltinsBPF.inc: ${CLANG_SRCS}/include/clang/Basic/Builtins.td
+ ${CLANG_TBLGEN} -gen-clang-builtins \
+ -I ${CLANG_SRCS}/include -d ${.TARGET:C/$/.d/} -o ${.TARGET} \
+ ${CLANG_SRCS}/include/clang/Basic/BuiltinsBPF.td
+TGHDRS+= clang/Basic/BuiltinsBPF.inc
+
+clang/Basic/BuiltinsRISCV.inc: ${CLANG_SRCS}/include/clang/Basic/Builtins.td
+ ${CLANG_TBLGEN} -gen-clang-builtins \
+ -I ${CLANG_SRCS}/include -d ${.TARGET:C/$/.d/} -o ${.TARGET} \
+ ${CLANG_SRCS}/include/clang/Basic/BuiltinsRISCV.td
+TGHDRS+= clang/Basic/BuiltinsRISCV.inc
+
+clang/Basic/RegularKeywordAttrInfo.inc: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -gen-clang-regular-keyword-attr-info \
+ -I ${CLANG_SRCS}/include -d ${.TARGET:C/$/.d/} -o ${.TARGET} \
+ ${CLANG_SRCS}/include/clang/Basic/Attr.td
+TGHDRS+= clang/Basic/RegularKeywordAttrInfo.inc
+
.for hdr in \
- AST Analysis Comment Common CrossTU Driver Frontend Lex Parse \
- Refactoring Sema Serialization SemaSerialization
+ AST Analysis Comment Common CrossTU Driver Frontend InstallAPI Lex \
+ Parse Refactoring Sema Serialization
clang/Basic/Diagnostic${hdr}Kinds.inc: \
${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
${CLANG_TBLGEN} -gen-clang-diags-defs -clang-component=${hdr} \
@@ -938,24 +1076,6 @@ clang/Basic/DiagnosticIndexName.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
TGHDRS+= clang/Basic/DiagnosticIndexName.inc
-clang/Basic/arm_fp16.inc: ${CLANG_SRCS}/include/clang/Basic/arm_fp16.td
- ${CLANG_TBLGEN} -gen-arm-neon-sema \
- -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
- -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_fp16.td
-TGHDRS+= clang/Basic/arm_fp16.inc
-
-clang/Basic/arm_neon.inc: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
- ${CLANG_TBLGEN} -gen-arm-neon-sema \
- -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
- -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
-TGHDRS+= clang/Basic/arm_neon.inc
-
-clang/Basic/arm_cde_builtins.inc: ${CLANG_SRCS}/include/clang/Basic/arm_cde.td
- ${CLANG_TBLGEN} -gen-arm-cde-builtin-def \
- -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
- -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_cde.td
-TGHDRS+= clang/Basic/arm_cde_builtins.inc
-
clang/Basic/arm_cde_builtin_aliases.inc: \
${CLANG_SRCS}/include/clang/Basic/arm_cde.td
${CLANG_TBLGEN} -gen-arm-cde-builtin-aliases \
@@ -976,11 +1096,17 @@ clang/Basic/arm_cde_builtin_sema.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_cde.td
TGHDRS+= clang/Basic/arm_cde_builtin_sema.inc
-clang/Basic/arm_mve_builtins.inc: ${CLANG_SRCS}/include/clang/Basic/arm_mve.td
- ${CLANG_TBLGEN} -gen-arm-mve-builtin-def \
+clang/Basic/arm_cde_builtins.inc: ${CLANG_SRCS}/include/clang/Basic/arm_cde.td
+ ${CLANG_TBLGEN} -gen-arm-cde-builtin-def \
-I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
- -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_mve.td
-TGHDRS+= clang/Basic/arm_mve_builtins.inc
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_cde.td
+TGHDRS+= clang/Basic/arm_cde_builtins.inc
+
+clang/Basic/arm_fp16.inc: ${CLANG_SRCS}/include/clang/Basic/arm_fp16.td
+ ${CLANG_TBLGEN} -gen-arm-neon-sema \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_fp16.td
+TGHDRS+= clang/Basic/arm_fp16.inc
clang/Basic/arm_mve_builtin_aliases.inc: \
${CLANG_SRCS}/include/clang/Basic/arm_mve.td
@@ -1002,11 +1128,52 @@ clang/Basic/arm_mve_builtin_sema.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_mve.td
TGHDRS+= clang/Basic/arm_mve_builtin_sema.inc
-clang/Basic/arm_sve_builtins.inc: ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
- ${CLANG_TBLGEN} -gen-arm-sve-builtins \
+clang/Basic/arm_mve_builtins.inc: ${CLANG_SRCS}/include/clang/Basic/arm_mve.td
+ ${CLANG_TBLGEN} -gen-arm-mve-builtin-def \
-I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
- -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
-TGHDRS+= clang/Basic/arm_sve_builtins.inc
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_mve.td
+TGHDRS+= clang/Basic/arm_mve_builtins.inc
+
+clang/Basic/arm_neon.inc: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
+ ${CLANG_TBLGEN} -gen-arm-neon-sema \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_neon.td
+TGHDRS+= clang/Basic/arm_neon.inc
+
+clang/Basic/arm_sme_builtin_cg.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+ ${CLANG_TBLGEN} -gen-arm-sme-builtin-codegen \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+TGHDRS+= clang/Basic/arm_sme_builtin_cg.inc
+
+clang/Basic/arm_sme_builtins.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+ ${CLANG_TBLGEN} -gen-arm-sme-builtins \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+TGHDRS+= clang/Basic/arm_sme_builtins.inc
+
+clang/Basic/arm_sme_builtins_za_state.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+ ${CLANG_TBLGEN} -gen-arm-sme-builtin-za-state \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+TGHDRS+= clang/Basic/arm_sme_builtins_za_state.inc
+
+clang/Basic/arm_sme_sema_rangechecks.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+ ${CLANG_TBLGEN} -gen-arm-sme-sema-rangechecks \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+TGHDRS+= clang/Basic/arm_sme_sema_rangechecks.inc
+
+clang/Basic/arm_sme_streaming_attrs.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+ ${CLANG_TBLGEN} -gen-arm-sme-streaming-attrs \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sme.td
+TGHDRS+= clang/Basic/arm_sme_streaming_attrs.inc
clang/Basic/arm_sve_builtin_cg.inc: ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
${CLANG_TBLGEN} -gen-arm-sve-builtin-codegen \
@@ -1014,6 +1181,12 @@ clang/Basic/arm_sve_builtin_cg.inc: ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
TGHDRS+= clang/Basic/arm_sve_builtin_cg.inc
+clang/Basic/arm_sve_builtins.inc: ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
+ ${CLANG_TBLGEN} -gen-arm-sve-builtins \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
+TGHDRS+= clang/Basic/arm_sve_builtins.inc
+
clang/Basic/arm_sve_sema_rangechecks.inc: \
${CLANG_SRCS}/include/clang/Basic/arm_sve.td
${CLANG_TBLGEN} -gen-arm-sve-sema-rangechecks \
@@ -1021,6 +1194,13 @@ clang/Basic/arm_sve_sema_rangechecks.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
TGHDRS+= clang/Basic/arm_sve_sema_rangechecks.inc
+clang/Basic/arm_sve_streaming_attrs.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
+ ${CLANG_TBLGEN} -gen-arm-sve-streaming-attrs \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
+TGHDRS+= clang/Basic/arm_sve_streaming_attrs.inc
+
clang/Basic/arm_sve_typeflags.inc: \
${CLANG_SRCS}/include/clang/Basic/arm_sve.td
${CLANG_TBLGEN} -gen-arm-sve-typeflags \
@@ -1028,12 +1208,26 @@ clang/Basic/arm_sve_typeflags.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/arm_sve.td
TGHDRS+= clang/Basic/arm_sve_typeflags.inc
-clang/Basic/riscv_vector_builtins.inc: \
- ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
- ${CLANG_TBLGEN} -gen-riscv-vector-builtins \
+clang/Basic/riscv_sifive_vector_builtin_cg.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/riscv_sifive_vector.td
+ ${CLANG_TBLGEN} -gen-riscv-sifive-vector-builtin-codegen \
-I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
- -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
-TGHDRS+= clang/Basic/riscv_vector_builtins.inc
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_sifive_vector.td
+TGHDRS+= clang/Basic/riscv_sifive_vector_builtin_cg.inc
+
+clang/Basic/riscv_sifive_vector_builtin_sema.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/riscv_sifive_vector.td
+ ${CLANG_TBLGEN} -gen-riscv-sifive-vector-builtin-sema \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_sifive_vector.td
+TGHDRS+= clang/Basic/riscv_sifive_vector_builtin_sema.inc
+
+clang/Basic/riscv_sifive_vector_builtins.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/riscv_sifive_vector.td
+ ${CLANG_TBLGEN} -gen-riscv-sifive-vector-builtins \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_sifive_vector.td
+TGHDRS+= clang/Basic/riscv_sifive_vector_builtins.inc
clang/Basic/riscv_vector_builtin_cg.inc: \
${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
@@ -1049,6 +1243,13 @@ clang/Basic/riscv_vector_builtin_sema.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
TGHDRS+= clang/Basic/riscv_vector_builtin_sema.inc
+clang/Basic/riscv_vector_builtins.inc: \
+ ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
+ ${CLANG_TBLGEN} -gen-riscv-vector-builtins \
+ -I ${CLANG_SRCS}/include/clang/Basic -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
+TGHDRS+= clang/Basic/riscv_vector_builtins.inc
+
clang/Driver/Options.inc: ${CLANG_SRCS}/include/clang/Driver/Options.td
${LLVM_TBLGEN} -gen-opt-parser-defs \
-I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
@@ -1139,6 +1340,4 @@ CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
.include "../clang.build.mk"
-INTERNALLIB=
-
.include <bsd.lib.mk>
diff --git a/lib/clang/libclangminimal/Makefile b/lib/clang/libclangminimal/Makefile
index 744e1a835f90..c55dae8896ac 100644
--- a/lib/clang/libclangminimal/Makefile
+++ b/lib/clang/libclangminimal/Makefile
@@ -1,4 +1,4 @@
-
+.include <bsd.init.mk>
.include "../clang.pre.mk"
LIB= clangminimal
diff --git a/lib/clang/liblldb/LLDBWrapLua.cpp b/lib/clang/liblldb/LLDBWrapLua.cpp
index 73bd6373845b..823354827790 100644
--- a/lib/clang/liblldb/LLDBWrapLua.cpp
+++ b/lib/clang/liblldb/LLDBWrapLua.cpp
@@ -1,13 +1,13 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (https://www.swig.org).
- * Version 4.1.1
+ * Version 4.2.1
*
* Do not make changes to this file unless you know what you are doing - modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
-#define SWIG_VERSION 0x040101
+#define SWIG_VERSION 0x040201
#define SWIGLUA
#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA
#define SWIG_LUA_MODULE_GLOBAL
@@ -136,6 +136,36 @@
# pragma warning disable 592
#endif
+#if defined(__cplusplus) && __cplusplus >=201103L
+# define SWIG_NULLPTR nullptr
+#else
+# define SWIG_NULLPTR NULL
+#endif
+
+/* -----------------------------------------------------------------------------
+ * swigcompat.swg
+ *
+ * Macros to provide support compatibility with older C and C++ standards.
+ * ----------------------------------------------------------------------------- */
+
+/* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF
+ * if you're missing it.
+ */
+#if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
+ (defined __cplusplus && __cplusplus >= 201103L) || \
+ defined SWIG_HAVE_SNPRINTF) && \
+ !defined SWIG_NO_SNPRINTF
+# define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A)
+# define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B)
+#else
+/* Fallback versions ignore the buffer size, but most of our uses either have a
+ * fixed maximum possible size or dynamically allocate a buffer that's large
+ * enough.
+ */
+# define SWIG_snprintf(O,S,F,A) sprintf(O,F,A)
+# define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B)
+#endif
+
/* -----------------------------------------------------------------------------
* swigrun.swg
*
@@ -283,7 +313,7 @@
#define SWIG_CASTRANKLIMIT (1 << 8)
/* The NewMask denotes the object was created (using new/malloc) */
#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
-/* The TmpMask is for in/out typemaps that use temporal objects */
+/* The TmpMask is for in/out typemaps that use temporary objects */
#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
/* Simple returning values */
#define SWIG_BADOBJ (SWIG_ERROR)
@@ -885,6 +915,20 @@ typedef struct swig_elua_entry {
# define lua_rawlen lua_objlen
#endif
+/* lua_tolstring() was added in Lua 5.1. It should be a little more
+ efficient than making two separate calls and it avoids problems with order
+ of evaluation so SWIG calls lua_tolstring() when it wants the length and
+ we provide a compatibility implementation for Lua 5.0. */
+#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501
+static const char *(lua_tolstring)(lua_State *L, int idx, size_t *len) {
+ /* Call lua_tostring() first as it may convert the value from number to
+ string. */
+ const char *result = lua_tostring(L, idx);
+ if (len) *len = lua_strlen(L, idx);
+ return result;
+}
+#endif
+
/* lua_pushglobaltable is the recommended "future-proof" way to get
the global table for Lua 5.2 and later. Here we define
@@ -1555,6 +1599,7 @@ SWIGINTERN int SWIG_Lua_class_do_get_item(lua_State *L, swig_type_info *type, i
int bases_search_result;
int substack_start = lua_gettop(L)-2;
assert(first_arg == substack_start+1);
+ (void)first_arg;
lua_checkstack(L,5);
assert(lua_isuserdata(L,-2)); /* just in case */
lua_getmetatable(L,-2); /* get the meta table */
@@ -1593,6 +1638,7 @@ SWIGINTERN int SWIG_Lua_class_do_get(lua_State *L, swig_type_info *type, int SW
int bases_search_result;
int substack_start = lua_gettop(L)-2;
assert(first_arg == substack_start+1);
+ (void)first_arg;
lua_checkstack(L,5);
assert(lua_isuserdata(L,-2)); /* just in case */
lua_getmetatable(L,-2); /* get the meta table */
@@ -2692,240 +2738,260 @@ SWIG_Lua_dostring(lua_State *L, const char *str) {
#define SWIGTYPE_p_double swig_types[1]
#define SWIGTYPE_p_f_p_q_const__char_p_void__void swig_types[2]
#define SWIGTYPE_p_f_p_void__p_void swig_types[3]
-#define SWIGTYPE_p_f_p_void_p_q_const__void_size_t__void swig_types[4]
-#define SWIGTYPE_p_int swig_types[5]
-#define SWIGTYPE_p_lldb__ConnectionStatus swig_types[6]
-#define SWIGTYPE_p_lldb__SBAddress swig_types[7]
-#define SWIGTYPE_p_lldb__SBAttachInfo swig_types[8]
-#define SWIGTYPE_p_lldb__SBBlock swig_types[9]
-#define SWIGTYPE_p_lldb__SBBreakpoint swig_types[10]
-#define SWIGTYPE_p_lldb__SBBreakpointList swig_types[11]
-#define SWIGTYPE_p_lldb__SBBreakpointLocation swig_types[12]
-#define SWIGTYPE_p_lldb__SBBreakpointName swig_types[13]
-#define SWIGTYPE_p_lldb__SBBroadcaster swig_types[14]
-#define SWIGTYPE_p_lldb__SBCommandInterpreter swig_types[15]
-#define SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions swig_types[16]
-#define SWIGTYPE_p_lldb__SBCommandReturnObject swig_types[17]
-#define SWIGTYPE_p_lldb__SBCommunication swig_types[18]
-#define SWIGTYPE_p_lldb__SBCompileUnit swig_types[19]
-#define SWIGTYPE_p_lldb__SBData swig_types[20]
-#define SWIGTYPE_p_lldb__SBDebugger swig_types[21]
-#define SWIGTYPE_p_lldb__SBDeclaration swig_types[22]
-#define SWIGTYPE_p_lldb__SBEnvironment swig_types[23]
-#define SWIGTYPE_p_lldb__SBError swig_types[24]
-#define SWIGTYPE_p_lldb__SBEvent swig_types[25]
-#define SWIGTYPE_p_lldb__SBExecutionContext swig_types[26]
-#define SWIGTYPE_p_lldb__SBExpressionOptions swig_types[27]
-#define SWIGTYPE_p_lldb__SBFile swig_types[28]
-#define SWIGTYPE_p_lldb__SBFileSpec swig_types[29]
-#define SWIGTYPE_p_lldb__SBFileSpecList swig_types[30]
-#define SWIGTYPE_p_lldb__SBFrame swig_types[31]
-#define SWIGTYPE_p_lldb__SBFunction swig_types[32]
-#define SWIGTYPE_p_lldb__SBHostOS swig_types[33]
-#define SWIGTYPE_p_lldb__SBInstruction swig_types[34]
-#define SWIGTYPE_p_lldb__SBInstructionList swig_types[35]
-#define SWIGTYPE_p_lldb__SBLanguageRuntime swig_types[36]
-#define SWIGTYPE_p_lldb__SBLaunchInfo swig_types[37]
-#define SWIGTYPE_p_lldb__SBLineEntry swig_types[38]
-#define SWIGTYPE_p_lldb__SBListener swig_types[39]
-#define SWIGTYPE_p_lldb__SBMemoryRegionInfo swig_types[40]
-#define SWIGTYPE_p_lldb__SBMemoryRegionInfoList swig_types[41]
-#define SWIGTYPE_p_lldb__SBModule swig_types[42]
-#define SWIGTYPE_p_lldb__SBModuleSpec swig_types[43]
-#define SWIGTYPE_p_lldb__SBModuleSpecList swig_types[44]
-#define SWIGTYPE_p_lldb__SBPlatform swig_types[45]
-#define SWIGTYPE_p_lldb__SBPlatformConnectOptions swig_types[46]
-#define SWIGTYPE_p_lldb__SBPlatformShellCommand swig_types[47]
-#define SWIGTYPE_p_lldb__SBProcess swig_types[48]
-#define SWIGTYPE_p_lldb__SBProcessInfo swig_types[49]
-#define SWIGTYPE_p_lldb__SBQueue swig_types[50]
-#define SWIGTYPE_p_lldb__SBQueueItem swig_types[51]
-#define SWIGTYPE_p_lldb__SBReproducer swig_types[52]
-#define SWIGTYPE_p_lldb__SBSection swig_types[53]
-#define SWIGTYPE_p_lldb__SBSourceManager swig_types[54]
-#define SWIGTYPE_p_lldb__SBStream swig_types[55]
-#define SWIGTYPE_p_lldb__SBStringList swig_types[56]
-#define SWIGTYPE_p_lldb__SBStructuredData swig_types[57]
-#define SWIGTYPE_p_lldb__SBSymbol swig_types[58]
-#define SWIGTYPE_p_lldb__SBSymbolContext swig_types[59]
-#define SWIGTYPE_p_lldb__SBSymbolContextList swig_types[60]
-#define SWIGTYPE_p_lldb__SBTarget swig_types[61]
-#define SWIGTYPE_p_lldb__SBThread swig_types[62]
-#define SWIGTYPE_p_lldb__SBThreadCollection swig_types[63]
-#define SWIGTYPE_p_lldb__SBThreadPlan swig_types[64]
-#define SWIGTYPE_p_lldb__SBTrace swig_types[65]
-#define SWIGTYPE_p_lldb__SBTraceCursor swig_types[66]
-#define SWIGTYPE_p_lldb__SBType swig_types[67]
-#define SWIGTYPE_p_lldb__SBTypeCategory swig_types[68]
-#define SWIGTYPE_p_lldb__SBTypeEnumMember swig_types[69]
-#define SWIGTYPE_p_lldb__SBTypeEnumMemberList swig_types[70]
-#define SWIGTYPE_p_lldb__SBTypeFilter swig_types[71]
-#define SWIGTYPE_p_lldb__SBTypeFormat swig_types[72]
-#define SWIGTYPE_p_lldb__SBTypeList swig_types[73]
-#define SWIGTYPE_p_lldb__SBTypeMember swig_types[74]
-#define SWIGTYPE_p_lldb__SBTypeMemberFunction swig_types[75]
-#define SWIGTYPE_p_lldb__SBTypeNameSpecifier swig_types[76]
-#define SWIGTYPE_p_lldb__SBTypeSummary swig_types[77]
-#define SWIGTYPE_p_lldb__SBTypeSummaryOptions swig_types[78]
-#define SWIGTYPE_p_lldb__SBTypeSynthetic swig_types[79]
-#define SWIGTYPE_p_lldb__SBUnixSignals swig_types[80]
-#define SWIGTYPE_p_lldb__SBValue swig_types[81]
-#define SWIGTYPE_p_lldb__SBValueList swig_types[82]
-#define SWIGTYPE_p_lldb__SBVariablesOptions swig_types[83]
-#define SWIGTYPE_p_lldb__SBWatchpoint swig_types[84]
-#define SWIGTYPE_p_long_double swig_types[85]
-#define SWIGTYPE_p_long_long swig_types[86]
-#define SWIGTYPE_p_p_void swig_types[87]
-#define SWIGTYPE_p_pthread_rwlock_t swig_types[88]
-#define SWIGTYPE_p_pthread_t swig_types[89]
-#define SWIGTYPE_p_short swig_types[90]
-#define SWIGTYPE_p_signed_char swig_types[91]
-#define SWIGTYPE_p_size_t swig_types[92]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ABI_t swig_types[93]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Baton_t swig_types[94]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Block_t swig_types[95]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointLocation_t swig_types[96]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointPrecondition_t swig_types[97]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointResolver_t swig_types[98]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointSite_t swig_types[99]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Breakpoint_t swig_types[100]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BroadcasterManager_t swig_types[101]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Broadcaster_t swig_types[102]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CommandObject_t swig_types[103]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CompileUnit_t swig_types[104]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Connection_t swig_types[105]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataBuffer_t swig_types[106]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataExtractor_t swig_types[107]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Debugger_t swig_types[108]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Disassembler_t swig_types[109]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventDataStructuredData_t swig_types[110]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventData_t swig_types[111]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t swig_types[112]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExecutionContextRef_t swig_types[113]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExpressionVariable_t swig_types[114]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__File_t swig_types[115]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FuncUnwinders_t swig_types[116]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Function_t swig_types[117]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOHandler_t swig_types[118]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOObject_t swig_types[119]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IRExecutionUnit_t swig_types[120]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InlineFunctionInfo_t swig_types[121]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Instruction_t swig_types[122]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InstrumentationRuntime_t swig_types[123]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__JITLoader_t swig_types[124]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__LanguageRuntime_t swig_types[125]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Listener_t swig_types[126]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryHistory_t swig_types[127]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t swig_types[128]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Module_t swig_types[129]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectContainer_t swig_types[130]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[131]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectFile_t swig_types[132]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__OptionValueProperties_t swig_types[133]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__OptionValue_t swig_types[134]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Platform_t swig_types[135]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ProcessAttachInfo_t swig_types[136]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ProcessLaunchInfo_t swig_types[137]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Process_t swig_types[138]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t swig_types[139]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Queue_t swig_types[140]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__REPL_t swig_types[141]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t swig_types[142]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t swig_types[143]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegisterContext_t swig_types[144]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegularExpression_t swig_types[145]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptInterpreter_t swig_types[146]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t swig_types[147]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t swig_types[148]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t swig_types[149]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SearchFilter_t swig_types[150]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SectionLoadList_t swig_types[151]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Section_t swig_types[152]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StackFrameList_t swig_types[153]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StackFrameRecognizer_t swig_types[154]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StackFrame_t swig_types[155]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StopInfo_t swig_types[156]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StreamFile_t swig_types[157]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Stream_t swig_types[158]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StringSummaryFormat_t swig_types[159]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t swig_types[160]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t swig_types[161]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SymbolFileType_t swig_types[162]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t swig_types[163]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SyntheticChildren_t swig_types[164]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Target_t swig_types[165]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadCollection_t swig_types[166]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlanTracer_t swig_types[167]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlan_t swig_types[168]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPostMortemTrace_t swig_types[169]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Thread_t swig_types[170]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TraceCursor_t swig_types[171]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Trace_t swig_types[172]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeCategoryImpl_t swig_types[173]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeEnumMemberImpl_t swig_types[174]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeFilterImpl_t swig_types[175]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeFormatImpl_t swig_types[176]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeImpl_t swig_types[177]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeMemberFunctionImpl_t swig_types[178]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeNameSpecifierImpl_t swig_types[179]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSummaryImpl_t swig_types[180]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSummaryOptions_t swig_types[181]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSystemClang_t swig_types[182]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSystem_t swig_types[183]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Type_t swig_types[184]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UnixSignals_t swig_types[185]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UnwindAssembly_t swig_types[186]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UnwindPlan_t swig_types[187]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UserExpression_t swig_types[188]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ValueObjectList_t swig_types[189]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ValueObject_t swig_types[190]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Value_t swig_types[191]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__VariableList_t swig_types[192]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Variable_t swig_types[193]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Watchpoint_t swig_types[194]
-#define SWIGTYPE_p_std__shared_ptrT_lldb_private__WritableDataBuffer_t swig_types[195]
-#define SWIGTYPE_p_std__string swig_types[196]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t swig_types[197]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicLoader_t swig_types[198]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__File_t swig_types[199]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__JITLoaderList_t swig_types[200]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__MemoryRegionInfo_t swig_types[201]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__OperatingSystem_t swig_types[202]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__ScriptedPlatformInterface_t swig_types[203]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__ScriptedProcessInterface_t swig_types[204]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SectionList_t swig_types[205]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SourceManager_t swig_types[206]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StackFrameRecognizerManager_t swig_types[207]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StructuredDataImpl_t swig_types[208]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SymbolVendor_t swig_types[209]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SystemRuntime_t swig_types[210]
-#define SWIGTYPE_p_std__unique_ptrT_lldb_private__TraceExporter_t swig_types[211]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BreakpointLocation_t swig_types[212]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Breakpoint_t swig_types[213]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BroadcasterManager_t swig_types[214]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Debugger_t swig_types[215]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Listener_t swig_types[216]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Module_t swig_types[217]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[218]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__OptionValue_t swig_types[219]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Process_t swig_types[220]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Queue_t swig_types[221]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Section_t swig_types[222]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StackFrame_t swig_types[223]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StructuredDataPlugin_t swig_types[224]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Target_t swig_types[225]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ThreadPlan_t swig_types[226]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Thread_t swig_types[227]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__TypeSystem_t swig_types[228]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Type_t swig_types[229]
-#define SWIGTYPE_p_std__weak_ptrT_lldb_private__UnixSignals_t swig_types[230]
-#define SWIGTYPE_p_unsigned_char swig_types[231]
-#define SWIGTYPE_p_unsigned_int swig_types[232]
-#define SWIGTYPE_p_unsigned_long_long swig_types[233]
-#define SWIGTYPE_p_unsigned_short swig_types[234]
-#define SWIGTYPE_p_void swig_types[235]
-static swig_type_info *swig_types[237];
-static swig_module_info swig_module = {swig_types, 236, 0, 0, 0, 0};
+#define SWIGTYPE_p_f_p_void_p_p_q_const__char__bool swig_types[4]
+#define SWIGTYPE_p_f_p_void_p_q_const__void_size_t__void swig_types[5]
+#define SWIGTYPE_p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError swig_types[6]
+#define SWIGTYPE_p_f_unsigned_long_long_p_void__void swig_types[7]
+#define SWIGTYPE_p_int swig_types[8]
+#define SWIGTYPE_p_lldb__ConnectionStatus swig_types[9]
+#define SWIGTYPE_p_lldb__SBAddress swig_types[10]
+#define SWIGTYPE_p_lldb__SBAddressRange swig_types[11]
+#define SWIGTYPE_p_lldb__SBAddressRangeList swig_types[12]
+#define SWIGTYPE_p_lldb__SBAttachInfo swig_types[13]
+#define SWIGTYPE_p_lldb__SBBlock swig_types[14]
+#define SWIGTYPE_p_lldb__SBBreakpoint swig_types[15]
+#define SWIGTYPE_p_lldb__SBBreakpointList swig_types[16]
+#define SWIGTYPE_p_lldb__SBBreakpointLocation swig_types[17]
+#define SWIGTYPE_p_lldb__SBBreakpointName swig_types[18]
+#define SWIGTYPE_p_lldb__SBBroadcaster swig_types[19]
+#define SWIGTYPE_p_lldb__SBCommandInterpreter swig_types[20]
+#define SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions swig_types[21]
+#define SWIGTYPE_p_lldb__SBCommandReturnObject swig_types[22]
+#define SWIGTYPE_p_lldb__SBCommunication swig_types[23]
+#define SWIGTYPE_p_lldb__SBCompileUnit swig_types[24]
+#define SWIGTYPE_p_lldb__SBData swig_types[25]
+#define SWIGTYPE_p_lldb__SBDebugger swig_types[26]
+#define SWIGTYPE_p_lldb__SBDeclaration swig_types[27]
+#define SWIGTYPE_p_lldb__SBEnvironment swig_types[28]
+#define SWIGTYPE_p_lldb__SBError swig_types[29]
+#define SWIGTYPE_p_lldb__SBEvent swig_types[30]
+#define SWIGTYPE_p_lldb__SBExecutionContext swig_types[31]
+#define SWIGTYPE_p_lldb__SBExpressionOptions swig_types[32]
+#define SWIGTYPE_p_lldb__SBFile swig_types[33]
+#define SWIGTYPE_p_lldb__SBFileSpec swig_types[34]
+#define SWIGTYPE_p_lldb__SBFileSpecList swig_types[35]
+#define SWIGTYPE_p_lldb__SBFormat swig_types[36]
+#define SWIGTYPE_p_lldb__SBFrame swig_types[37]
+#define SWIGTYPE_p_lldb__SBFunction swig_types[38]
+#define SWIGTYPE_p_lldb__SBHostOS swig_types[39]
+#define SWIGTYPE_p_lldb__SBInstruction swig_types[40]
+#define SWIGTYPE_p_lldb__SBInstructionList swig_types[41]
+#define SWIGTYPE_p_lldb__SBLanguageRuntime swig_types[42]
+#define SWIGTYPE_p_lldb__SBLaunchInfo swig_types[43]
+#define SWIGTYPE_p_lldb__SBLineEntry swig_types[44]
+#define SWIGTYPE_p_lldb__SBListener swig_types[45]
+#define SWIGTYPE_p_lldb__SBMemoryRegionInfo swig_types[46]
+#define SWIGTYPE_p_lldb__SBMemoryRegionInfoList swig_types[47]
+#define SWIGTYPE_p_lldb__SBModule swig_types[48]
+#define SWIGTYPE_p_lldb__SBModuleSpec swig_types[49]
+#define SWIGTYPE_p_lldb__SBModuleSpecList swig_types[50]
+#define SWIGTYPE_p_lldb__SBPlatform swig_types[51]
+#define SWIGTYPE_p_lldb__SBPlatformConnectOptions swig_types[52]
+#define SWIGTYPE_p_lldb__SBPlatformShellCommand swig_types[53]
+#define SWIGTYPE_p_lldb__SBProcess swig_types[54]
+#define SWIGTYPE_p_lldb__SBProcessInfo swig_types[55]
+#define SWIGTYPE_p_lldb__SBProcessInfoList swig_types[56]
+#define SWIGTYPE_p_lldb__SBQueue swig_types[57]
+#define SWIGTYPE_p_lldb__SBQueueItem swig_types[58]
+#define SWIGTYPE_p_lldb__SBReproducer swig_types[59]
+#define SWIGTYPE_p_lldb__SBSaveCoreOptions swig_types[60]
+#define SWIGTYPE_p_lldb__SBScriptObject swig_types[61]
+#define SWIGTYPE_p_lldb__SBSection swig_types[62]
+#define SWIGTYPE_p_lldb__SBSourceManager swig_types[63]
+#define SWIGTYPE_p_lldb__SBStatisticsOptions swig_types[64]
+#define SWIGTYPE_p_lldb__SBStream swig_types[65]
+#define SWIGTYPE_p_lldb__SBStringList swig_types[66]
+#define SWIGTYPE_p_lldb__SBStructuredData swig_types[67]
+#define SWIGTYPE_p_lldb__SBSymbol swig_types[68]
+#define SWIGTYPE_p_lldb__SBSymbolContext swig_types[69]
+#define SWIGTYPE_p_lldb__SBSymbolContextList swig_types[70]
+#define SWIGTYPE_p_lldb__SBTarget swig_types[71]
+#define SWIGTYPE_p_lldb__SBThread swig_types[72]
+#define SWIGTYPE_p_lldb__SBThreadCollection swig_types[73]
+#define SWIGTYPE_p_lldb__SBThreadPlan swig_types[74]
+#define SWIGTYPE_p_lldb__SBTrace swig_types[75]
+#define SWIGTYPE_p_lldb__SBTraceCursor swig_types[76]
+#define SWIGTYPE_p_lldb__SBType swig_types[77]
+#define SWIGTYPE_p_lldb__SBTypeCategory swig_types[78]
+#define SWIGTYPE_p_lldb__SBTypeEnumMember swig_types[79]
+#define SWIGTYPE_p_lldb__SBTypeEnumMemberList swig_types[80]
+#define SWIGTYPE_p_lldb__SBTypeFilter swig_types[81]
+#define SWIGTYPE_p_lldb__SBTypeFormat swig_types[82]
+#define SWIGTYPE_p_lldb__SBTypeList swig_types[83]
+#define SWIGTYPE_p_lldb__SBTypeMember swig_types[84]
+#define SWIGTYPE_p_lldb__SBTypeMemberFunction swig_types[85]
+#define SWIGTYPE_p_lldb__SBTypeNameSpecifier swig_types[86]
+#define SWIGTYPE_p_lldb__SBTypeStaticField swig_types[87]
+#define SWIGTYPE_p_lldb__SBTypeSummary swig_types[88]
+#define SWIGTYPE_p_lldb__SBTypeSummaryOptions swig_types[89]
+#define SWIGTYPE_p_lldb__SBTypeSynthetic swig_types[90]
+#define SWIGTYPE_p_lldb__SBUnixSignals swig_types[91]
+#define SWIGTYPE_p_lldb__SBValue swig_types[92]
+#define SWIGTYPE_p_lldb__SBValueList swig_types[93]
+#define SWIGTYPE_p_lldb__SBVariablesOptions swig_types[94]
+#define SWIGTYPE_p_lldb__SBWatchpoint swig_types[95]
+#define SWIGTYPE_p_lldb__SBWatchpointOptions swig_types[96]
+#define SWIGTYPE_p_long_double swig_types[97]
+#define SWIGTYPE_p_long_long swig_types[98]
+#define SWIGTYPE_p_p_void swig_types[99]
+#define SWIGTYPE_p_pthread_rwlock_t swig_types[100]
+#define SWIGTYPE_p_pthread_t swig_types[101]
+#define SWIGTYPE_p_short swig_types[102]
+#define SWIGTYPE_p_signed_char swig_types[103]
+#define SWIGTYPE_p_size_t swig_types[104]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ABI_t swig_types[105]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Baton_t swig_types[106]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Block_t swig_types[107]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointLocation_t swig_types[108]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointPrecondition_t swig_types[109]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointResolver_t swig_types[110]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BreakpointSite_t swig_types[111]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Breakpoint_t swig_types[112]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__BroadcasterManager_t swig_types[113]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Broadcaster_t swig_types[114]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CommandObject_t swig_types[115]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__CompileUnit_t swig_types[116]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Connection_t swig_types[117]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataBuffer_t swig_types[118]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__DataExtractor_t swig_types[119]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Debugger_t swig_types[120]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Disassembler_t swig_types[121]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventDataStructuredData_t swig_types[122]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__EventData_t swig_types[123]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t swig_types[124]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExecutionContextRef_t swig_types[125]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ExpressionVariable_t swig_types[126]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__File_t swig_types[127]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t swig_types[128]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__FuncUnwinders_t swig_types[129]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Function_t swig_types[130]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOHandler_t swig_types[131]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IOObject_t swig_types[132]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__IRExecutionUnit_t swig_types[133]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InlineFunctionInfo_t swig_types[134]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Instruction_t swig_types[135]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__InstrumentationRuntime_t swig_types[136]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__JITLoader_t swig_types[137]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__LanguageRuntime_t swig_types[138]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Listener_t swig_types[139]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryHistory_t swig_types[140]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__MemoryRegionInfo_t swig_types[141]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Module_t swig_types[142]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectContainer_t swig_types[143]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[144]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ObjectFile_t swig_types[145]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t swig_types[146]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__OptionValueProperties_t swig_types[147]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__OptionValue_t swig_types[148]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Platform_t swig_types[149]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ProcessAttachInfo_t swig_types[150]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ProcessLaunchInfo_t swig_types[151]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Process_t swig_types[152]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t swig_types[153]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Queue_t swig_types[154]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__REPL_t swig_types[155]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t swig_types[156]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t swig_types[157]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegisterContext_t swig_types[158]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t swig_types[159]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__RegularExpression_t swig_types[160]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptInterpreter_t swig_types[161]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t swig_types[162]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptedMetadata_t swig_types[163]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t swig_types[164]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t swig_types[165]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t swig_types[166]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SearchFilter_t swig_types[167]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SectionLoadList_t swig_types[168]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Section_t swig_types[169]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StackFrameList_t swig_types[170]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StackFrameRecognizer_t swig_types[171]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StackFrame_t swig_types[172]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StopInfo_t swig_types[173]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StreamFile_t swig_types[174]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Stream_t swig_types[175]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StringSummaryFormat_t swig_types[176]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t swig_types[177]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SupportFile_t swig_types[178]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t swig_types[179]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SymbolFileType_t swig_types[180]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t swig_types[181]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__SyntheticChildren_t swig_types[182]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Target_t swig_types[183]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadCollection_t swig_types[184]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlanTracer_t swig_types[185]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlan_t swig_types[186]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPostMortemTrace_t swig_types[187]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Thread_t swig_types[188]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TraceCursor_t swig_types[189]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Trace_t swig_types[190]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeCategoryImpl_t swig_types[191]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeEnumMemberImpl_t swig_types[192]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeFilterImpl_t swig_types[193]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeFormatImpl_t swig_types[194]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeImpl_t swig_types[195]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeMemberFunctionImpl_t swig_types[196]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeNameSpecifierImpl_t swig_types[197]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSummaryImpl_t swig_types[198]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSummaryOptions_t swig_types[199]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSystemClang_t swig_types[200]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__TypeSystem_t swig_types[201]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Type_t swig_types[202]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UnixSignals_t swig_types[203]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UnwindAssembly_t swig_types[204]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UnwindPlan_t swig_types[205]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__UserExpression_t swig_types[206]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ValueObjectList_t swig_types[207]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__ValueObject_t swig_types[208]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Value_t swig_types[209]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__VariableList_t swig_types[210]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Variable_t swig_types[211]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__WatchpointResource_t swig_types[212]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__Watchpoint_t swig_types[213]
+#define SWIGTYPE_p_std__shared_ptrT_lldb_private__WritableDataBuffer_t swig_types[214]
+#define SWIGTYPE_p_std__string swig_types[215]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__AddressRange_t swig_types[216]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t swig_types[217]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__DynamicLoader_t swig_types[218]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__File_t swig_types[219]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__JITLoaderList_t swig_types[220]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__MemoryRegionInfo_t swig_types[221]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__OperatingSystem_t swig_types[222]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__ScriptedPlatformInterface_t swig_types[223]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__ScriptedProcessInterface_t swig_types[224]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SectionList_t swig_types[225]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SourceManager_t swig_types[226]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StackFrameRecognizerManager_t swig_types[227]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__StructuredDataImpl_t swig_types[228]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SymbolVendor_t swig_types[229]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__SystemRuntime_t swig_types[230]
+#define SWIGTYPE_p_std__unique_ptrT_lldb_private__TraceExporter_t swig_types[231]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BreakpointLocation_t swig_types[232]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Breakpoint_t swig_types[233]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__BroadcasterManager_t swig_types[234]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Debugger_t swig_types[235]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Listener_t swig_types[236]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Module_t swig_types[237]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ObjectFileJITDelegate_t swig_types[238]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__OptionValue_t swig_types[239]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Process_t swig_types[240]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Queue_t swig_types[241]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Section_t swig_types[242]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StackFrame_t swig_types[243]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__StructuredDataPlugin_t swig_types[244]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Target_t swig_types[245]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__ThreadPlan_t swig_types[246]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Thread_t swig_types[247]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__TypeSystem_t swig_types[248]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__Type_t swig_types[249]
+#define SWIGTYPE_p_std__weak_ptrT_lldb_private__UnixSignals_t swig_types[250]
+#define SWIGTYPE_p_unsigned_char swig_types[251]
+#define SWIGTYPE_p_unsigned_int swig_types[252]
+#define SWIGTYPE_p_unsigned_long_long swig_types[253]
+#define SWIGTYPE_p_unsigned_short swig_types[254]
+#define SWIGTYPE_p_void swig_types[255]
+static swig_type_info *swig_types[257];
+static swig_module_info swig_module = {swig_types, 256, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -3164,6 +3230,8 @@ SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_typ
#include "lldb/lldb-public.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAddressRange.h"
+#include "lldb/API/SBAddressRangeList.h"
#include "lldb/API/SBAttachInfo.h"
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBBreakpoint.h"
@@ -3175,6 +3243,7 @@ SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_typ
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBCommunication.h"
#include "lldb/API/SBCompileUnit.h"
+#include "lldb/API/SBSaveCoreOptions.h"
#include "lldb/API/SBData.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDeclaration.h"
@@ -3186,11 +3255,13 @@ SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_typ
#include "lldb/API/SBFile.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFileSpecList.h"
+#include "lldb/API/SBFormat.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBFunction.h"
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBInstructionList.h"
+#include "lldb/API/SBLanguages.h"
#include "lldb/API/SBLanguageRuntime.h"
#include "lldb/API/SBLaunchInfo.h"
#include "lldb/API/SBLineEntry.h"
@@ -3202,11 +3273,14 @@ SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_typ
#include "lldb/API/SBPlatform.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBProcessInfo.h"
+#include "lldb/API/SBProcessInfoList.h"
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBQueueItem.h"
#include "lldb/API/SBReproducer.h"
+#include "lldb/API/SBScriptObject.h"
#include "lldb/API/SBSection.h"
#include "lldb/API/SBSourceManager.h"
+#include "lldb/API/SBStatisticsOptions.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
#include "lldb/API/SBStructuredData.h"
@@ -3218,6 +3292,7 @@ SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_typ
#include "lldb/API/SBThreadCollection.h"
#include "lldb/API/SBThreadPlan.h"
#include "lldb/API/SBTrace.h"
+#include "lldb/API/SBTraceCursor.h"
#include "lldb/API/SBType.h"
#include "lldb/API/SBTypeCategory.h"
#include "lldb/API/SBTypeEnumMember.h"
@@ -3231,6 +3306,7 @@ SWIGINTERN void SWIG_write_ptr_array(lua_State* L,void **array,int size,swig_typ
#include "lldb/API/SBValueList.h"
#include "lldb/API/SBVariablesOptions.h"
#include "lldb/API/SBWatchpoint.h"
+#include "lldb/API/SBWatchpointOptions.h"
#include "llvm/Support/Error.h"
@@ -3308,14 +3384,14 @@ SWIGINTERN std::string lldb_SBCommandReturnObject___repr__(lldb::SBCommandReturn
return std::string(desc, desc_len);
}
SWIGINTERN void lldb_SBCommandReturnObject_SetImmediateOutputFile__SWIG_2(lldb::SBCommandReturnObject *self,lldb::FileSP BORROWED,bool transfer_ownership){
- self->SetImmediateOutputFile(BORROWED);
- }
+ self->SetImmediateOutputFile(BORROWED);
+ }
SWIGINTERN void lldb_SBCommandReturnObject_SetImmediateErrorFile__SWIG_2(lldb::SBCommandReturnObject *self,lldb::FileSP BORROWED,bool transfer_ownership){
- self->SetImmediateErrorFile(BORROWED);
- }
+ self->SetImmediateErrorFile(BORROWED);
+ }
SWIGINTERN void lldb_SBCommandReturnObject_Print(lldb::SBCommandReturnObject *self,char const *str){
- self->Printf("%s", str);
- }
+ self->Printf("%s", str);
+ }
SWIGINTERN std::string lldb_SBCompileUnit___repr__(lldb::SBCompileUnit *self){
lldb::SBStream stream;
self->GetDescription (stream);
@@ -3336,15 +3412,6 @@ SWIGINTERN std::string lldb_SBData___repr__(lldb::SBData *self){
}
return std::string(desc, desc_len);
}
-SWIGINTERN lldb::FileSP lldb_SBDebugger_GetInputFileHandle(lldb::SBDebugger *self){
- return self->GetInputFile().GetFile();
- }
-SWIGINTERN lldb::FileSP lldb_SBDebugger_GetOutputFileHandle(lldb::SBDebugger *self){
- return self->GetOutputFile().GetFile();
- }
-SWIGINTERN lldb::FileSP lldb_SBDebugger_GetErrorFileHandle(lldb::SBDebugger *self){
- return self->GetErrorFile().GetFile();
- }
SWIGINTERN std::string lldb_SBDebugger___repr__(lldb::SBDebugger *self){
lldb::SBStream stream;
self->GetDescription (stream);
@@ -3355,6 +3422,15 @@ SWIGINTERN std::string lldb_SBDebugger___repr__(lldb::SBDebugger *self){
}
return std::string(desc, desc_len);
}
+SWIGINTERN lldb::FileSP lldb_SBDebugger_GetInputFileHandle(lldb::SBDebugger *self){
+ return self->GetInputFile().GetFile();
+ }
+SWIGINTERN lldb::FileSP lldb_SBDebugger_GetOutputFileHandle(lldb::SBDebugger *self){
+ return self->GetOutputFile().GetFile();
+ }
+SWIGINTERN lldb::FileSP lldb_SBDebugger_GetErrorFileHandle(lldb::SBDebugger *self){
+ return self->GetErrorFile().GetFile();
+ }
SWIGINTERN std::string lldb_SBDeclaration___repr__(lldb::SBDeclaration *self){
lldb::SBStream stream;
self->GetDescription (stream);
@@ -3376,14 +3452,14 @@ SWIGINTERN std::string lldb_SBError___repr__(lldb::SBError *self){
return std::string(desc, desc_len);
}
SWIGINTERN lldb::SBFile lldb_SBFile_MakeBorrowed(lldb::FileSP BORROWED){
- return lldb::SBFile(BORROWED);
- }
+ return lldb::SBFile(BORROWED);
+ }
SWIGINTERN lldb::SBFile lldb_SBFile_MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS){
- return lldb::SBFile(FORCE_IO_METHODS);
- }
+ return lldb::SBFile(FORCE_IO_METHODS);
+ }
SWIGINTERN lldb::SBFile lldb_SBFile_MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS){
- return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
- }
+ return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
+ }
SWIGINTERN std::string lldb_SBFileSpec___repr__(lldb::SBFileSpec *self){
lldb::SBStream stream;
self->GetDescription (stream);
@@ -3394,6 +3470,16 @@ SWIGINTERN std::string lldb_SBFileSpec___repr__(lldb::SBFileSpec *self){
}
return std::string(desc, desc_len);
}
+SWIGINTERN std::string lldb_SBFileSpecList___repr__(lldb::SBFileSpecList *self){
+ lldb::SBStream stream;
+ self->GetDescription (stream);
+ const char *desc = stream.GetData();
+ size_t desc_len = stream.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) {
+ --desc_len;
+ }
+ return std::string(desc, desc_len);
+ }
SWIGINTERN std::string lldb_SBFrame___repr__(lldb::SBFrame *self){
lldb::SBStream stream;
self->GetDescription (stream);
@@ -3505,8 +3591,18 @@ SWIGINTERN std::string lldb_SBSection___repr__(lldb::SBSection *self){
return std::string(desc, desc_len);
}
SWIGINTERN void lldb_SBStream_RedirectToFileHandle(lldb::SBStream *self,lldb::FileSP file,bool transfer_fh_ownership){
- self->RedirectToFile(file);
- }
+ self->RedirectToFile(file);
+ }
+SWIGINTERN std::string lldb_SBStructuredData___repr__(lldb::SBStructuredData *self){
+ lldb::SBStream stream;
+ self->GetDescription (stream);
+ const char *desc = stream.GetData();
+ size_t desc_len = stream.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) {
+ --desc_len;
+ }
+ return std::string(desc, desc_len);
+ }
SWIGINTERN std::string lldb_SBSymbol___repr__(lldb::SBSymbol *self){
lldb::SBStream stream;
self->GetDescription (stream);
@@ -3700,7 +3796,8 @@ SWIGINTERN std::string lldb_SBWatchpoint___repr__(lldb::SBWatchpoint *self){
template <typename T> void PushSBClass(lua_State * L, T * obj);
// This function is called from Lua::CallBreakpointCallback
-llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction(
+llvm::Expected<bool>
+lldb_private::lua::SWIGBridge::LLDBSwigLuaBreakpointCallbackFunction(
lua_State * L, lldb::StackFrameSP stop_frame_sp,
lldb::BreakpointLocationSP bp_loc_sp,
const StructuredDataImpl &extra_args_impl) {
@@ -3738,7 +3835,8 @@ llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction(
}
// This function is called from Lua::CallWatchpointCallback
-llvm::Expected<bool> lldb_private::LLDBSwigLuaWatchpointCallbackFunction(
+llvm::Expected<bool>
+lldb_private::lua::SWIGBridge::LLDBSwigLuaWatchpointCallbackFunction(
lua_State * L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) {
lldb::SBFrame sb_frame(stop_frame_sp);
lldb::SBWatchpoint sb_wp(wp_sp);
@@ -4321,6 +4419,41 @@ static int _wrap_SBAddress_GetLoadAddress(lua_State* L) {
}
+static int _wrap_SBAddress_SetAddress(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddress *arg1 = (lldb::SBAddress *) 0 ;
+ lldb::SBSection arg2 ;
+ lldb::addr_t arg3 ;
+ lldb::SBSection *argp2 ;
+
+ SWIG_check_num_args("lldb::SBAddress::SetAddress",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::SetAddress",1,"lldb::SBAddress *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddress::SetAddress",2,"lldb::SBSection");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBAddress::SetAddress",3,"lldb::addr_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBAddress_SetAddress",1,SWIGTYPE_p_lldb__SBAddress);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBSection,0))){
+ SWIG_fail_ptr("SBAddress_SetAddress",2,SWIGTYPE_p_lldb__SBSection);
+ }
+ arg2 = *argp2;
+
+ arg3 = (lldb::addr_t)lua_tointeger(L, 3);
+ (arg1)->SetAddress(arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBAddress_SetLoadAddress(lua_State* L) {
{
int SWIG_arg = 0;
@@ -4412,48 +4545,27 @@ static int _wrap_SBAddress_GetDescription(lua_State* L) {
}
-static int _wrap_SBAddress_GetSection(lua_State* L) {
+static int _wrap_SBAddress_GetSymbolContext(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBAddress *arg1 = (lldb::SBAddress *) 0 ;
- lldb::SBSection result;
+ uint32_t arg2 ;
+ lldb::SBSymbolContext result;
- SWIG_check_num_args("lldb::SBAddress::GetSection",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::GetSection",1,"lldb::SBAddress *");
+ SWIG_check_num_args("lldb::SBAddress::GetSymbolContext",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::GetSymbolContext",1,"lldb::SBAddress *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBAddress::GetSymbolContext",2,"uint32_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddress,0))){
- SWIG_fail_ptr("SBAddress_GetSection",1,SWIGTYPE_p_lldb__SBAddress);
+ SWIG_fail_ptr("SBAddress_GetSymbolContext",1,SWIGTYPE_p_lldb__SBAddress);
}
- result = (arg1)->GetSection();
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ result = (arg1)->GetSymbolContext(arg2);
{
- lldb::SBSection * resultptr = new lldb::SBSection(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBSection,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBAddress_GetOffset(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBAddress *arg1 = (lldb::SBAddress *) 0 ;
- lldb::addr_t result;
-
- SWIG_check_num_args("lldb::SBAddress::GetOffset",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::GetOffset",1,"lldb::SBAddress *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddress,0))){
- SWIG_fail_ptr("SBAddress_GetOffset",1,SWIGTYPE_p_lldb__SBAddress);
+ lldb::SBSymbolContext * resultptr = new lldb::SBSymbolContext(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBSymbolContext,1); SWIG_arg++;
}
-
- result = (lldb::addr_t)(arg1)->GetOffset();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -4463,32 +4575,24 @@ static int _wrap_SBAddress_GetOffset(lua_State* L) {
}
-static int _wrap_SBAddress_SetAddress(lua_State* L) {
+static int _wrap_SBAddress_GetSection(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBAddress *arg1 = (lldb::SBAddress *) 0 ;
- lldb::SBSection arg2 ;
- lldb::addr_t arg3 ;
- lldb::SBSection *argp2 ;
+ lldb::SBSection result;
- SWIG_check_num_args("lldb::SBAddress::SetAddress",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::SetAddress",1,"lldb::SBAddress *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddress::SetAddress",2,"lldb::SBSection");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBAddress::SetAddress",3,"lldb::addr_t");
+ SWIG_check_num_args("lldb::SBAddress::GetSection",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::GetSection",1,"lldb::SBAddress *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddress,0))){
- SWIG_fail_ptr("SBAddress_SetAddress",1,SWIGTYPE_p_lldb__SBAddress);
+ SWIG_fail_ptr("SBAddress_GetSection",1,SWIGTYPE_p_lldb__SBAddress);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBSection,0))){
- SWIG_fail_ptr("SBAddress_SetAddress",2,SWIGTYPE_p_lldb__SBSection);
+ result = (arg1)->GetSection();
+ {
+ lldb::SBSection * resultptr = new lldb::SBSection(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBSection,1); SWIG_arg++;
}
- arg2 = *argp2;
-
- arg3 = (lldb::addr_t)lua_tointeger(L, 3);
- (arg1)->SetAddress(arg2,arg3);
-
return SWIG_arg;
fail: SWIGUNUSED;
@@ -4498,27 +4602,21 @@ static int _wrap_SBAddress_SetAddress(lua_State* L) {
}
-static int _wrap_SBAddress_GetSymbolContext(lua_State* L) {
+static int _wrap_SBAddress_GetOffset(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBAddress *arg1 = (lldb::SBAddress *) 0 ;
- uint32_t arg2 ;
- lldb::SBSymbolContext result;
+ lldb::addr_t result;
- SWIG_check_num_args("lldb::SBAddress::GetSymbolContext",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::GetSymbolContext",1,"lldb::SBAddress *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBAddress::GetSymbolContext",2,"uint32_t");
+ SWIG_check_num_args("lldb::SBAddress::GetOffset",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddress::GetOffset",1,"lldb::SBAddress *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddress,0))){
- SWIG_fail_ptr("SBAddress_GetSymbolContext",1,SWIGTYPE_p_lldb__SBAddress);
+ SWIG_fail_ptr("SBAddress_GetOffset",1,SWIGTYPE_p_lldb__SBAddress);
}
- arg2 = (uint32_t)lua_tointeger(L, 2);
- result = (arg1)->GetSymbolContext(arg2);
- {
- lldb::SBSymbolContext * resultptr = new lldb::SBSymbolContext(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBSymbolContext,1); SWIG_arg++;
- }
+ result = (lldb::addr_t)(arg1)->GetOffset();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -4734,13 +4832,13 @@ static swig_lua_method swig_SBAddress_methods[]= {
{ "Clear", _wrap_SBAddress_Clear},
{ "GetFileAddress", _wrap_SBAddress_GetFileAddress},
{ "GetLoadAddress", _wrap_SBAddress_GetLoadAddress},
+ { "SetAddress", _wrap_SBAddress_SetAddress},
{ "SetLoadAddress", _wrap_SBAddress_SetLoadAddress},
{ "OffsetAddress", _wrap_SBAddress_OffsetAddress},
{ "GetDescription", _wrap_SBAddress_GetDescription},
+ { "GetSymbolContext", _wrap_SBAddress_GetSymbolContext},
{ "GetSection", _wrap_SBAddress_GetSection},
{ "GetOffset", _wrap_SBAddress_GetOffset},
- { "SetAddress", _wrap_SBAddress_SetAddress},
- { "GetSymbolContext", _wrap_SBAddress_GetSymbolContext},
{ "GetModule", _wrap_SBAddress_GetModule},
{ "GetCompileUnit", _wrap_SBAddress_GetCompileUnit},
{ "GetFunction", _wrap_SBAddress_GetFunction},
@@ -4780,6 +4878,717 @@ static swig_lua_class *swig_SBAddress_bases[] = {0};
static const char *swig_SBAddress_base_names[] = {0};
static swig_lua_class _wrap_class_SBAddress = { "SBAddress", "SBAddress", &SWIGTYPE_p_lldb__SBAddress,_proxy__wrap_new_SBAddress, swig_delete_SBAddress, swig_SBAddress_methods, swig_SBAddress_attributes, &swig_SBAddress_Sf_SwigStatic, swig_SBAddress_meta, swig_SBAddress_bases, swig_SBAddress_base_names };
+static int _wrap_new_SBAddressRange__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRange::SBAddressRange",0,0)
+ result = (lldb::SBAddressRange *)new lldb::SBAddressRange();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBAddressRange,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBAddressRange__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = 0 ;
+ lldb::SBAddressRange *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRange::SBAddressRange",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBAddressRange::SBAddressRange",1,"lldb::SBAddressRange const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("new_SBAddressRange",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ result = (lldb::SBAddressRange *)new lldb::SBAddressRange((lldb::SBAddressRange const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBAddressRange,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBAddressRange__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddress arg1 ;
+ lldb::addr_t arg2 ;
+ lldb::SBAddress *argp1 ;
+ lldb::SBAddressRange *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRange::SBAddressRange",2,2)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBAddressRange::SBAddressRange",1,"lldb::SBAddress");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBAddressRange::SBAddressRange",2,"lldb::addr_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&argp1,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("new_SBAddressRange",1,SWIGTYPE_p_lldb__SBAddress);
+ }
+ arg1 = *argp1;
+
+ arg2 = (lldb::addr_t)lua_tointeger(L, 2);
+ result = (lldb::SBAddressRange *)new lldb::SBAddressRange(arg1,arg2);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBAddressRange,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBAddressRange(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBAddressRange__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBAddressRange, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBAddressRange__SWIG_1(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_new_SBAddressRange__SWIG_2(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBAddressRange'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBAddressRange::SBAddressRange()\n"
+ " lldb::SBAddressRange::SBAddressRange(lldb::SBAddressRange const &)\n"
+ " lldb::SBAddressRange::SBAddressRange(lldb::SBAddress,lldb::addr_t)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBAddressRange_Clear(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRange::Clear",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRange::Clear",1,"lldb::SBAddressRange *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange_Clear",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ (arg1)->Clear();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRange_IsValid(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBAddressRange::IsValid",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRange::IsValid",1,"lldb::SBAddressRange const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange_IsValid",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ result = (bool)((lldb::SBAddressRange const *)arg1)->IsValid();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRange_GetBaseAddress(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) 0 ;
+ lldb::SBAddress result;
+
+ SWIG_check_num_args("lldb::SBAddressRange::GetBaseAddress",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRange::GetBaseAddress",1,"lldb::SBAddressRange const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange_GetBaseAddress",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ result = ((lldb::SBAddressRange const *)arg1)->GetBaseAddress();
+ {
+ lldb::SBAddress * resultptr = new lldb::SBAddress(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddress,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRange_GetByteSize(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) 0 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBAddressRange::GetByteSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRange::GetByteSize",1,"lldb::SBAddressRange const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange_GetByteSize",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ result = (lldb::addr_t)((lldb::SBAddressRange const *)arg1)->GetByteSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRange___eq(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) 0 ;
+ lldb::SBAddressRange *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBAddressRange::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRange::operator ==",1,"lldb::SBAddressRange *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddressRange::operator ==",2,"lldb::SBAddressRange const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange___eq",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange___eq",2,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ result = (bool)(arg1)->operator ==((lldb::SBAddressRange const &)*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRange_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::SBTarget arg3 ;
+ lldb::SBTarget *argp3 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBAddressRange::GetDescription",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRange::GetDescription",1,"lldb::SBAddressRange *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddressRange::GetDescription",2,"lldb::SBStream &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBAddressRange::GetDescription",3,"lldb::SBTarget const");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRange_GetDescription",1,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBAddressRange_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBAddressRange_GetDescription",3,SWIGTYPE_p_lldb__SBTarget);
+ }
+ arg3 = *argp3;
+
+ result = (bool)(arg1)->GetDescription(*arg2,arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBAddressRange(void *obj) {
+lldb::SBAddressRange *arg1 = (lldb::SBAddressRange *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBAddressRange(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBAddressRange);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBAddressRange_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBAddressRange_methods[]= {
+ { "Clear", _wrap_SBAddressRange_Clear},
+ { "IsValid", _wrap_SBAddressRange_IsValid},
+ { "GetBaseAddress", _wrap_SBAddressRange_GetBaseAddress},
+ { "GetByteSize", _wrap_SBAddressRange_GetByteSize},
+ { "__eq", _wrap_SBAddressRange___eq},
+ { "GetDescription", _wrap_SBAddressRange_GetDescription},
+ {0,0}
+};
+static swig_lua_method swig_SBAddressRange_meta[] = {
+ { "__eq", _wrap_SBAddressRange___eq},
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBAddressRange_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBAddressRange_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBAddressRange_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBAddressRange_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBAddressRange_Sf_SwigStatic = {
+ "SBAddressRange",
+ swig_SBAddressRange_Sf_SwigStatic_methods,
+ swig_SBAddressRange_Sf_SwigStatic_attributes,
+ swig_SBAddressRange_Sf_SwigStatic_constants,
+ swig_SBAddressRange_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBAddressRange_bases[] = {0};
+static const char *swig_SBAddressRange_base_names[] = {0};
+static swig_lua_class _wrap_class_SBAddressRange = { "SBAddressRange", "SBAddressRange", &SWIGTYPE_p_lldb__SBAddressRange,_proxy__wrap_new_SBAddressRange, swig_delete_SBAddressRange, swig_SBAddressRange_methods, swig_SBAddressRange_attributes, &swig_SBAddressRange_Sf_SwigStatic, swig_SBAddressRange_meta, swig_SBAddressRange_bases, swig_SBAddressRange_base_names };
+
+static int _wrap_new_SBAddressRangeList__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::SBAddressRangeList",0,0)
+ result = (lldb::SBAddressRangeList *)new lldb::SBAddressRangeList();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBAddressRangeList,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBAddressRangeList__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = 0 ;
+ lldb::SBAddressRangeList *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::SBAddressRangeList",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::SBAddressRangeList",1,"lldb::SBAddressRangeList const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("new_SBAddressRangeList",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+ result = (lldb::SBAddressRangeList *)new lldb::SBAddressRangeList((lldb::SBAddressRangeList const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBAddressRangeList,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBAddressRangeList(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBAddressRangeList__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBAddressRangeList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBAddressRangeList__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBAddressRangeList'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBAddressRangeList::SBAddressRangeList()\n"
+ " lldb::SBAddressRangeList::SBAddressRangeList(lldb::SBAddressRangeList const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_GetSize(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) 0 ;
+ uint32_t result;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::GetSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::GetSize",1,"lldb::SBAddressRangeList const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_GetSize",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+ result = (uint32_t)((lldb::SBAddressRangeList const *)arg1)->GetSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_Clear(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::Clear",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::Clear",1,"lldb::SBAddressRangeList *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_Clear",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+ (arg1)->Clear();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_GetAddressRangeAtIndex(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) 0 ;
+ uint64_t arg2 ;
+ lldb::SBAddressRange result;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::GetAddressRangeAtIndex",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::GetAddressRangeAtIndex",1,"lldb::SBAddressRangeList *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBAddressRangeList::GetAddressRangeAtIndex",2,"uint64_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_GetAddressRangeAtIndex",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+ arg2 = (uint64_t)lua_tointeger(L, 2);
+ result = (arg1)->GetAddressRangeAtIndex(arg2);
+ {
+ lldb::SBAddressRange * resultptr = new lldb::SBAddressRange(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddressRange,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_Append__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) 0 ;
+ lldb::SBAddressRange *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::Append",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::Append",1,"lldb::SBAddressRangeList *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddressRangeList::Append",2,"lldb::SBAddressRange const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_Append",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBAddressRangeList_Append",2,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ (arg1)->Append((lldb::SBAddressRange const &)*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_Append__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) 0 ;
+ lldb::SBAddressRangeList *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::Append",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::Append",1,"lldb::SBAddressRangeList *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddressRangeList::Append",2,"lldb::SBAddressRangeList const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_Append",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_Append",2,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+ (arg1)->Append((lldb::SBAddressRangeList const &)*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_Append(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBAddressRangeList, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddressRange, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBAddressRangeList_Append__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBAddressRangeList, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddressRangeList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBAddressRangeList_Append__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBAddressRangeList_Append'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBAddressRangeList::Append(lldb::SBAddressRange const &)\n"
+ " lldb::SBAddressRangeList::Append(lldb::SBAddressRangeList const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBAddressRangeList_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::SBTarget *arg3 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBAddressRangeList::GetDescription",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAddressRangeList::GetDescription",1,"lldb::SBAddressRangeList *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAddressRangeList::GetDescription",2,"lldb::SBStream &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBAddressRangeList::GetDescription",3,"lldb::SBTarget const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBAddressRangeList_GetDescription",1,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBAddressRangeList_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBAddressRangeList_GetDescription",3,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2,(lldb::SBTarget const &)*arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBAddressRangeList(void *obj) {
+lldb::SBAddressRangeList *arg1 = (lldb::SBAddressRangeList *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBAddressRangeList(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBAddressRangeList);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBAddressRangeList_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBAddressRangeList_methods[]= {
+ { "GetSize", _wrap_SBAddressRangeList_GetSize},
+ { "Clear", _wrap_SBAddressRangeList_Clear},
+ { "GetAddressRangeAtIndex", _wrap_SBAddressRangeList_GetAddressRangeAtIndex},
+ { "Append", _wrap_SBAddressRangeList_Append},
+ { "GetDescription", _wrap_SBAddressRangeList_GetDescription},
+ {0,0}
+};
+static swig_lua_method swig_SBAddressRangeList_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBAddressRangeList_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBAddressRangeList_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBAddressRangeList_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBAddressRangeList_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBAddressRangeList_Sf_SwigStatic = {
+ "SBAddressRangeList",
+ swig_SBAddressRangeList_Sf_SwigStatic_methods,
+ swig_SBAddressRangeList_Sf_SwigStatic_attributes,
+ swig_SBAddressRangeList_Sf_SwigStatic_constants,
+ swig_SBAddressRangeList_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBAddressRangeList_bases[] = {0};
+static const char *swig_SBAddressRangeList_base_names[] = {0};
+static swig_lua_class _wrap_class_SBAddressRangeList = { "SBAddressRangeList", "SBAddressRangeList", &SWIGTYPE_p_lldb__SBAddressRangeList,_proxy__wrap_new_SBAddressRangeList, swig_delete_SBAddressRangeList, swig_SBAddressRangeList_methods, swig_SBAddressRangeList_attributes, &swig_SBAddressRangeList_Sf_SwigStatic, swig_SBAddressRangeList_meta, swig_SBAddressRangeList_bases, swig_SBAddressRangeList_base_names };
+
static int _wrap_new_SBAttachInfo__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -5850,6 +6659,172 @@ static int _wrap_SBAttachInfo_SetListener(lua_State* L) {
}
+static int _wrap_SBAttachInfo_GetShadowListener(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) 0 ;
+ lldb::SBListener result;
+
+ SWIG_check_num_args("lldb::SBAttachInfo::GetShadowListener",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAttachInfo::GetShadowListener",1,"lldb::SBAttachInfo *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBAttachInfo_GetShadowListener",1,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+ result = (arg1)->GetShadowListener();
+ {
+ lldb::SBListener * resultptr = new lldb::SBListener(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBListener,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAttachInfo_SetShadowListener(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) 0 ;
+ lldb::SBListener *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBAttachInfo::SetShadowListener",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAttachInfo::SetShadowListener",1,"lldb::SBAttachInfo *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAttachInfo::SetShadowListener",2,"lldb::SBListener &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBAttachInfo_SetShadowListener",1,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBListener,0))){
+ SWIG_fail_ptr("SBAttachInfo_SetShadowListener",2,SWIGTYPE_p_lldb__SBListener);
+ }
+
+ (arg1)->SetShadowListener(*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAttachInfo_GetScriptedProcessClassName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBAttachInfo::GetScriptedProcessClassName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAttachInfo::GetScriptedProcessClassName",1,"lldb::SBAttachInfo const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBAttachInfo_GetScriptedProcessClassName",1,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+ result = (char *)((lldb::SBAttachInfo const *)arg1)->GetScriptedProcessClassName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAttachInfo_SetScriptedProcessClassName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ SWIG_check_num_args("lldb::SBAttachInfo::SetScriptedProcessClassName",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAttachInfo::SetScriptedProcessClassName",1,"lldb::SBAttachInfo *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBAttachInfo::SetScriptedProcessClassName",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBAttachInfo_SetScriptedProcessClassName",1,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ (arg1)->SetScriptedProcessClassName((char const *)arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAttachInfo_GetScriptedProcessDictionary(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) 0 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBAttachInfo::GetScriptedProcessDictionary",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAttachInfo::GetScriptedProcessDictionary",1,"lldb::SBAttachInfo const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBAttachInfo_GetScriptedProcessDictionary",1,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+ result = ((lldb::SBAttachInfo const *)arg1)->GetScriptedProcessDictionary();
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBAttachInfo_SetScriptedProcessDictionary(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) 0 ;
+ lldb::SBStructuredData arg2 ;
+ lldb::SBStructuredData *argp2 ;
+
+ SWIG_check_num_args("lldb::SBAttachInfo::SetScriptedProcessDictionary",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBAttachInfo::SetScriptedProcessDictionary",1,"lldb::SBAttachInfo *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBAttachInfo::SetScriptedProcessDictionary",2,"lldb::SBStructuredData");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBAttachInfo_SetScriptedProcessDictionary",1,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBAttachInfo_SetScriptedProcessDictionary",2,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+ arg2 = *argp2;
+
+ (arg1)->SetScriptedProcessDictionary(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBAttachInfo(void *obj) {
lldb::SBAttachInfo *arg1 = (lldb::SBAttachInfo *) obj;
delete arg1;
@@ -5894,6 +6869,12 @@ static swig_lua_method swig_SBAttachInfo_methods[]= {
{ "ParentProcessIDIsValid", _wrap_SBAttachInfo_ParentProcessIDIsValid},
{ "GetListener", _wrap_SBAttachInfo_GetListener},
{ "SetListener", _wrap_SBAttachInfo_SetListener},
+ { "GetShadowListener", _wrap_SBAttachInfo_GetShadowListener},
+ { "SetShadowListener", _wrap_SBAttachInfo_SetShadowListener},
+ { "GetScriptedProcessClassName", _wrap_SBAttachInfo_GetScriptedProcessClassName},
+ { "SetScriptedProcessClassName", _wrap_SBAttachInfo_SetScriptedProcessClassName},
+ { "GetScriptedProcessDictionary", _wrap_SBAttachInfo_GetScriptedProcessDictionary},
+ { "SetScriptedProcessDictionary", _wrap_SBAttachInfo_SetScriptedProcessDictionary},
{0,0}
};
static swig_lua_method swig_SBAttachInfo_meta[] = {
@@ -6173,33 +7154,6 @@ static int _wrap_SBBlock_GetParent(lua_State* L) {
}
-static int _wrap_SBBlock_GetContainingInlinedBlock(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBBlock *arg1 = (lldb::SBBlock *) 0 ;
- lldb::SBBlock result;
-
- SWIG_check_num_args("lldb::SBBlock::GetContainingInlinedBlock",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetContainingInlinedBlock",1,"lldb::SBBlock *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBlock,0))){
- SWIG_fail_ptr("SBBlock_GetContainingInlinedBlock",1,SWIGTYPE_p_lldb__SBBlock);
- }
-
- result = (arg1)->GetContainingInlinedBlock();
- {
- lldb::SBBlock * resultptr = new lldb::SBBlock(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBlock,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBBlock_GetSibling(lua_State* L) {
{
int SWIG_arg = 0;
@@ -6338,30 +7292,24 @@ static int _wrap_SBBlock_GetRangeEndAddress(lua_State* L) {
}
-static int _wrap_SBBlock_GetRangeIndexForBlockAddress(lua_State* L) {
+static int _wrap_SBBlock_GetRanges(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBBlock *arg1 = (lldb::SBBlock *) 0 ;
- lldb::SBAddress arg2 ;
- lldb::SBAddress *argp2 ;
- uint32_t result;
+ lldb::SBAddressRangeList result;
- SWIG_check_num_args("lldb::SBBlock::GetRangeIndexForBlockAddress",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetRangeIndexForBlockAddress",1,"lldb::SBBlock *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBlock::GetRangeIndexForBlockAddress",2,"lldb::SBAddress");
+ SWIG_check_num_args("lldb::SBBlock::GetRanges",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetRanges",1,"lldb::SBBlock *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBlock,0))){
- SWIG_fail_ptr("SBBlock_GetRangeIndexForBlockAddress",1,SWIGTYPE_p_lldb__SBBlock);
+ SWIG_fail_ptr("SBBlock_GetRanges",1,SWIGTYPE_p_lldb__SBBlock);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBAddress,0))){
- SWIG_fail_ptr("SBBlock_GetRangeIndexForBlockAddress",2,SWIGTYPE_p_lldb__SBAddress);
+ result = (arg1)->GetRanges();
+ {
+ lldb::SBAddressRangeList * resultptr = new lldb::SBAddressRangeList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddressRangeList,1); SWIG_arg++;
}
- arg2 = *argp2;
-
- result = (uint32_t)(arg1)->GetRangeIndexForBlockAddress(arg2);
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -6371,28 +7319,30 @@ static int _wrap_SBBlock_GetRangeIndexForBlockAddress(lua_State* L) {
}
-static int _wrap_SBBlock_GetDescription(lua_State* L) {
+static int _wrap_SBBlock_GetRangeIndexForBlockAddress(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBBlock *arg1 = (lldb::SBBlock *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
+ lldb::SBAddress arg2 ;
+ lldb::SBAddress *argp2 ;
+ uint32_t result;
- SWIG_check_num_args("lldb::SBBlock::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetDescription",1,"lldb::SBBlock *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBlock::GetDescription",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBBlock::GetRangeIndexForBlockAddress",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetRangeIndexForBlockAddress",1,"lldb::SBBlock *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBlock::GetRangeIndexForBlockAddress",2,"lldb::SBAddress");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBlock,0))){
- SWIG_fail_ptr("SBBlock_GetDescription",1,SWIGTYPE_p_lldb__SBBlock);
+ SWIG_fail_ptr("SBBlock_GetRangeIndexForBlockAddress",1,SWIGTYPE_p_lldb__SBBlock);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBBlock_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBBlock_GetRangeIndexForBlockAddress",2,SWIGTYPE_p_lldb__SBAddress);
}
+ arg2 = *argp2;
- result = (bool)(arg1)->GetDescription(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ result = (uint32_t)(arg1)->GetRangeIndexForBlockAddress(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -6590,6 +7540,64 @@ static int _wrap_SBBlock_GetVariables(lua_State* L) {
}
+static int _wrap_SBBlock_GetContainingInlinedBlock(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBBlock *arg1 = (lldb::SBBlock *) 0 ;
+ lldb::SBBlock result;
+
+ SWIG_check_num_args("lldb::SBBlock::GetContainingInlinedBlock",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetContainingInlinedBlock",1,"lldb::SBBlock *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBlock,0))){
+ SWIG_fail_ptr("SBBlock_GetContainingInlinedBlock",1,SWIGTYPE_p_lldb__SBBlock);
+ }
+
+ result = (arg1)->GetContainingInlinedBlock();
+ {
+ lldb::SBBlock * resultptr = new lldb::SBBlock(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBlock,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBBlock_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBBlock *arg1 = (lldb::SBBlock *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBBlock::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBlock::GetDescription",1,"lldb::SBBlock *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBlock::GetDescription",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBlock,0))){
+ SWIG_fail_ptr("SBBlock_GetDescription",1,SWIGTYPE_p_lldb__SBBlock);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBBlock_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBBlock___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -6637,15 +7645,16 @@ static swig_lua_method swig_SBBlock_methods[]= {
{ "GetInlinedCallSiteLine", _wrap_SBBlock_GetInlinedCallSiteLine},
{ "GetInlinedCallSiteColumn", _wrap_SBBlock_GetInlinedCallSiteColumn},
{ "GetParent", _wrap_SBBlock_GetParent},
- { "GetContainingInlinedBlock", _wrap_SBBlock_GetContainingInlinedBlock},
{ "GetSibling", _wrap_SBBlock_GetSibling},
{ "GetFirstChild", _wrap_SBBlock_GetFirstChild},
{ "GetNumRanges", _wrap_SBBlock_GetNumRanges},
{ "GetRangeStartAddress", _wrap_SBBlock_GetRangeStartAddress},
{ "GetRangeEndAddress", _wrap_SBBlock_GetRangeEndAddress},
+ { "GetRanges", _wrap_SBBlock_GetRanges},
{ "GetRangeIndexForBlockAddress", _wrap_SBBlock_GetRangeIndexForBlockAddress},
- { "GetDescription", _wrap_SBBlock_GetDescription},
{ "GetVariables", _wrap_SBBlock_GetVariables},
+ { "GetContainingInlinedBlock", _wrap_SBBlock_GetContainingInlinedBlock},
+ { "GetDescription", _wrap_SBBlock_GetDescription},
{ "__tostring", _wrap_SBBlock___tostring},
{0,0}
};
@@ -7082,13 +8091,13 @@ static int _wrap_SBBreakpoint_IsOneShot(lua_State* L) {
bool result;
SWIG_check_num_args("lldb::SBBreakpoint::IsOneShot",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::IsOneShot",1,"lldb::SBBreakpoint *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::IsOneShot",1,"lldb::SBBreakpoint const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
SWIG_fail_ptr("SBBreakpoint_IsOneShot",1,SWIGTYPE_p_lldb__SBBreakpoint);
}
- result = (bool)(arg1)->IsOneShot();
+ result = (bool)((lldb::SBBreakpoint const *)arg1)->IsOneShot();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -7624,36 +8633,6 @@ static int _wrap_SBBreakpoint_SetScriptCallbackFunction(lua_State* L) {
}
-static int _wrap_SBBreakpoint_SetScriptCallbackBody(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBBreakpoint *arg1 = (lldb::SBBreakpoint *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBError result;
-
- SWIG_check_num_args("lldb::SBBreakpoint::SetScriptCallbackBody",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::SetScriptCallbackBody",1,"lldb::SBBreakpoint *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBBreakpoint::SetScriptCallbackBody",2,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
- SWIG_fail_ptr("SBBreakpoint_SetScriptCallbackBody",1,SWIGTYPE_p_lldb__SBBreakpoint);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->SetScriptCallbackBody((char const *)arg2);
- {
- lldb::SBError * resultptr = new lldb::SBError(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBBreakpoint_SetCommandLineCommands(lua_State* L) {
{
int SWIG_arg = 0;
@@ -7715,6 +8694,36 @@ static int _wrap_SBBreakpoint_GetCommandLineCommands(lua_State* L) {
}
+static int _wrap_SBBreakpoint_SetScriptCallbackBody(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBBreakpoint *arg1 = (lldb::SBBreakpoint *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBBreakpoint::SetScriptCallbackBody",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::SetScriptCallbackBody",1,"lldb::SBBreakpoint *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBBreakpoint::SetScriptCallbackBody",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
+ SWIG_fail_ptr("SBBreakpoint_SetScriptCallbackBody",1,SWIGTYPE_p_lldb__SBBreakpoint);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->SetScriptCallbackBody((char const *)arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBBreakpoint_AddName(lua_State* L) {
{
int SWIG_arg = 0;
@@ -8037,67 +9046,6 @@ static int _wrap_SBBreakpoint_GetDescription(lua_State* L) {
}
-static int _wrap_SBBreakpoint_AddLocation(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBBreakpoint *arg1 = (lldb::SBBreakpoint *) 0 ;
- lldb::SBAddress *arg2 = 0 ;
- lldb::SBError result;
-
- SWIG_check_num_args("lldb::SBBreakpoint::AddLocation",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::AddLocation",1,"lldb::SBBreakpoint *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBreakpoint::AddLocation",2,"lldb::SBAddress &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
- SWIG_fail_ptr("SBBreakpoint_AddLocation",1,SWIGTYPE_p_lldb__SBBreakpoint);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddress,0))){
- SWIG_fail_ptr("SBBreakpoint_AddLocation",2,SWIGTYPE_p_lldb__SBAddress);
- }
-
- result = (arg1)->AddLocation(*arg2);
- {
- lldb::SBError * resultptr = new lldb::SBError(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBBreakpoint_SerializeToStructuredData(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBBreakpoint *arg1 = (lldb::SBBreakpoint *) 0 ;
- lldb::SBStructuredData result;
-
- SWIG_check_num_args("lldb::SBBreakpoint::SerializeToStructuredData",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::SerializeToStructuredData",1,"lldb::SBBreakpoint *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
- SWIG_fail_ptr("SBBreakpoint_SerializeToStructuredData",1,SWIGTYPE_p_lldb__SBBreakpoint);
- }
-
- result = (arg1)->SerializeToStructuredData();
- {
- lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBBreakpoint_EventIsBreakpointEvent(lua_State* L) {
{
int SWIG_arg = 0;
@@ -8234,13 +9182,13 @@ static int _wrap_SBBreakpoint_IsHardware(lua_State* L) {
bool result;
SWIG_check_num_args("lldb::SBBreakpoint::IsHardware",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::IsHardware",1,"lldb::SBBreakpoint *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::IsHardware",1,"lldb::SBBreakpoint const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
SWIG_fail_ptr("SBBreakpoint_IsHardware",1,SWIGTYPE_p_lldb__SBBreakpoint);
}
- result = (bool)(arg1)->IsHardware();
+ result = (bool)((lldb::SBBreakpoint const *)arg1)->IsHardware();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -8251,6 +9199,67 @@ static int _wrap_SBBreakpoint_IsHardware(lua_State* L) {
}
+static int _wrap_SBBreakpoint_AddLocation(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBBreakpoint *arg1 = (lldb::SBBreakpoint *) 0 ;
+ lldb::SBAddress *arg2 = 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBBreakpoint::AddLocation",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::AddLocation",1,"lldb::SBBreakpoint *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBreakpoint::AddLocation",2,"lldb::SBAddress &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
+ SWIG_fail_ptr("SBBreakpoint_AddLocation",1,SWIGTYPE_p_lldb__SBBreakpoint);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBBreakpoint_AddLocation",2,SWIGTYPE_p_lldb__SBAddress);
+ }
+
+ result = (arg1)->AddLocation(*arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBBreakpoint_SerializeToStructuredData(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBBreakpoint *arg1 = (lldb::SBBreakpoint *) 0 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBBreakpoint::SerializeToStructuredData",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpoint::SerializeToStructuredData",1,"lldb::SBBreakpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpoint,0))){
+ SWIG_fail_ptr("SBBreakpoint_SerializeToStructuredData",1,SWIGTYPE_p_lldb__SBBreakpoint);
+ }
+
+ result = (arg1)->SerializeToStructuredData();
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBBreakpoint___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -8321,9 +9330,9 @@ static swig_lua_method swig_SBBreakpoint_methods[]= {
{ "SetQueueName", _wrap_SBBreakpoint_SetQueueName},
{ "GetQueueName", _wrap_SBBreakpoint_GetQueueName},
{ "SetScriptCallbackFunction", _wrap_SBBreakpoint_SetScriptCallbackFunction},
- { "SetScriptCallbackBody", _wrap_SBBreakpoint_SetScriptCallbackBody},
{ "SetCommandLineCommands", _wrap_SBBreakpoint_SetCommandLineCommands},
{ "GetCommandLineCommands", _wrap_SBBreakpoint_GetCommandLineCommands},
+ { "SetScriptCallbackBody", _wrap_SBBreakpoint_SetScriptCallbackBody},
{ "AddName", _wrap_SBBreakpoint_AddName},
{ "AddNameWithErrorHandling", _wrap_SBBreakpoint_AddNameWithErrorHandling},
{ "RemoveName", _wrap_SBBreakpoint_RemoveName},
@@ -8332,9 +9341,9 @@ static swig_lua_method swig_SBBreakpoint_methods[]= {
{ "GetNumResolvedLocations", _wrap_SBBreakpoint_GetNumResolvedLocations},
{ "GetNumLocations", _wrap_SBBreakpoint_GetNumLocations},
{ "GetDescription", _wrap_SBBreakpoint_GetDescription},
+ { "IsHardware", _wrap_SBBreakpoint_IsHardware},
{ "AddLocation", _wrap_SBBreakpoint_AddLocation},
{ "SerializeToStructuredData", _wrap_SBBreakpoint_SerializeToStructuredData},
- { "IsHardware", _wrap_SBBreakpoint_IsHardware},
{ "__tostring", _wrap_SBBreakpoint___tostring},
{0,0}
};
@@ -8993,21 +10002,23 @@ static int _wrap_SBBreakpointLocation_GetCondition(lua_State* L) {
}
-static int _wrap_SBBreakpointLocation_GetAutoContinue(lua_State* L) {
+static int _wrap_SBBreakpointLocation_SetAutoContinue(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBBreakpointLocation *arg1 = (lldb::SBBreakpointLocation *) 0 ;
- bool result;
+ bool arg2 ;
- SWIG_check_num_args("lldb::SBBreakpointLocation::GetAutoContinue",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpointLocation::GetAutoContinue",1,"lldb::SBBreakpointLocation *");
+ SWIG_check_num_args("lldb::SBBreakpointLocation::SetAutoContinue",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpointLocation::SetAutoContinue",1,"lldb::SBBreakpointLocation *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBBreakpointLocation::SetAutoContinue",2,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpointLocation,0))){
- SWIG_fail_ptr("SBBreakpointLocation_GetAutoContinue",1,SWIGTYPE_p_lldb__SBBreakpointLocation);
+ SWIG_fail_ptr("SBBreakpointLocation_SetAutoContinue",1,SWIGTYPE_p_lldb__SBBreakpointLocation);
}
- result = (bool)(arg1)->GetAutoContinue();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetAutoContinue(arg2);
+
return SWIG_arg;
fail: SWIGUNUSED;
@@ -9017,23 +10028,21 @@ static int _wrap_SBBreakpointLocation_GetAutoContinue(lua_State* L) {
}
-static int _wrap_SBBreakpointLocation_SetAutoContinue(lua_State* L) {
+static int _wrap_SBBreakpointLocation_GetAutoContinue(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBBreakpointLocation *arg1 = (lldb::SBBreakpointLocation *) 0 ;
- bool arg2 ;
+ bool result;
- SWIG_check_num_args("lldb::SBBreakpointLocation::SetAutoContinue",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpointLocation::SetAutoContinue",1,"lldb::SBBreakpointLocation *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBBreakpointLocation::SetAutoContinue",2,"bool");
+ SWIG_check_num_args("lldb::SBBreakpointLocation::GetAutoContinue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBreakpointLocation::GetAutoContinue",1,"lldb::SBBreakpointLocation *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBreakpointLocation,0))){
- SWIG_fail_ptr("SBBreakpointLocation_SetAutoContinue",1,SWIGTYPE_p_lldb__SBBreakpointLocation);
+ SWIG_fail_ptr("SBBreakpointLocation_GetAutoContinue",1,SWIGTYPE_p_lldb__SBBreakpointLocation);
}
- arg2 = (lua_toboolean(L, 2)!=0);
- (arg1)->SetAutoContinue(arg2);
-
+ result = (bool)(arg1)->GetAutoContinue();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -9597,8 +10606,8 @@ static swig_lua_method swig_SBBreakpointLocation_methods[]= {
{ "SetIgnoreCount", _wrap_SBBreakpointLocation_SetIgnoreCount},
{ "SetCondition", _wrap_SBBreakpointLocation_SetCondition},
{ "GetCondition", _wrap_SBBreakpointLocation_GetCondition},
- { "GetAutoContinue", _wrap_SBBreakpointLocation_GetAutoContinue},
{ "SetAutoContinue", _wrap_SBBreakpointLocation_SetAutoContinue},
+ { "GetAutoContinue", _wrap_SBBreakpointLocation_GetAutoContinue},
{ "SetScriptCallbackFunction", _wrap_SBBreakpointLocation_SetScriptCallbackFunction},
{ "SetScriptCallbackBody", _wrap_SBBreakpointLocation_SetScriptCallbackBody},
{ "SetCommandLineCommands", _wrap_SBBreakpointLocation_SetCommandLineCommands},
@@ -11581,6 +12590,37 @@ static int _wrap_SBBroadcaster___eq(lua_State* L) {
}
+static int _wrap_SBBroadcaster___lt(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBBroadcaster *arg1 = (lldb::SBBroadcaster *) 0 ;
+ lldb::SBBroadcaster *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBBroadcaster::operator <",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBBroadcaster::operator <",1,"lldb::SBBroadcaster const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBBroadcaster::operator <",2,"lldb::SBBroadcaster const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBBroadcaster,0))){
+ SWIG_fail_ptr("SBBroadcaster___lt",1,SWIGTYPE_p_lldb__SBBroadcaster);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBBroadcaster,0))){
+ SWIG_fail_ptr("SBBroadcaster___lt",2,SWIGTYPE_p_lldb__SBBroadcaster);
+ }
+
+ result = (bool)((lldb::SBBroadcaster const *)arg1)->operator <((lldb::SBBroadcaster const &)*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBBroadcaster(void *obj) {
lldb::SBBroadcaster *arg1 = (lldb::SBBroadcaster *) obj;
delete arg1;
@@ -11607,10 +12647,12 @@ static swig_lua_method swig_SBBroadcaster_methods[]= {
{ "EventTypeHasListeners", _wrap_SBBroadcaster_EventTypeHasListeners},
{ "RemoveListener", _wrap_SBBroadcaster_RemoveListener},
{ "__eq", _wrap_SBBroadcaster___eq},
+ { "__lt", _wrap_SBBroadcaster___lt},
{0,0}
};
static swig_lua_method swig_SBBroadcaster_meta[] = {
{ "__eq", _wrap_SBBroadcaster___eq},
+ { "__lt", _wrap_SBBroadcaster___lt},
{0,0}
};
@@ -11639,7 +12681,24 @@ static swig_lua_class *swig_SBBroadcaster_bases[] = {0};
static const char *swig_SBBroadcaster_base_names[] = {0};
static swig_lua_class _wrap_class_SBBroadcaster = { "SBBroadcaster", "SBBroadcaster", &SWIGTYPE_p_lldb__SBBroadcaster,_proxy__wrap_new_SBBroadcaster, swig_delete_SBBroadcaster, swig_SBBroadcaster_methods, swig_SBBroadcaster_attributes, &swig_SBBroadcaster_Sf_SwigStatic, swig_SBBroadcaster_meta, swig_SBBroadcaster_bases, swig_SBBroadcaster_base_names };
-static int _wrap_new_SBCommandInterpreter(lua_State* L) {
+static int _wrap_new_SBCommandInterpreter__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::SBCommandInterpreter",0,0)
+ result = (lldb::SBCommandInterpreter *)new lldb::SBCommandInterpreter();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBCommandInterpreter,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBCommandInterpreter__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandInterpreter *arg1 = 0 ;
@@ -11663,6 +12722,39 @@ static int _wrap_new_SBCommandInterpreter(lua_State* L) {
}
+static int _wrap_new_SBCommandInterpreter(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBCommandInterpreter__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandInterpreter, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBCommandInterpreter__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBCommandInterpreter'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandInterpreter::SBCommandInterpreter()\n"
+ " lldb::SBCommandInterpreter::SBCommandInterpreter(lldb::SBCommandInterpreter const &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBCommandInterpreter_GetArgumentTypeAsCString(lua_State* L) {
{
int SWIG_arg = 0;
@@ -11751,181 +12843,24 @@ static int _wrap_SBCommandInterpreter_IsValid(lua_State* L) {
}
-static int _wrap_SBCommandInterpreter_GetIOHandlerControlSequence(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
- char arg2 ;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBCommandInterpreter::GetIOHandlerControlSequence",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetIOHandlerControlSequence",1,"lldb::SBCommandInterpreter *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetIOHandlerControlSequence",2,"char");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_GetIOHandlerControlSequence",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
- }
-
- arg2 = (lua_tostring(L, 2))[0];
- result = (char *)(arg1)->GetIOHandlerControlSequence(arg2);
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandInterpreter_GetPromptOnQuit(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBCommandInterpreter::GetPromptOnQuit",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetPromptOnQuit",1,"lldb::SBCommandInterpreter *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_GetPromptOnQuit",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
- }
-
- result = (bool)(arg1)->GetPromptOnQuit();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandInterpreter_SetPromptOnQuit(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
- bool arg2 ;
-
- SWIG_check_num_args("lldb::SBCommandInterpreter::SetPromptOnQuit",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetPromptOnQuit",1,"lldb::SBCommandInterpreter *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetPromptOnQuit",2,"bool");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_SetPromptOnQuit",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
- }
-
- arg2 = (lua_toboolean(L, 2)!=0);
- (arg1)->SetPromptOnQuit(arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandInterpreter_AllowExitCodeOnQuit(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
- bool arg2 ;
-
- SWIG_check_num_args("lldb::SBCommandInterpreter::AllowExitCodeOnQuit",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::AllowExitCodeOnQuit",1,"lldb::SBCommandInterpreter *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::AllowExitCodeOnQuit",2,"bool");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_AllowExitCodeOnQuit",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
- }
-
- arg2 = (lua_toboolean(L, 2)!=0);
- (arg1)->AllowExitCodeOnQuit(arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandInterpreter_HasCustomQuitExitCode(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBCommandInterpreter::HasCustomQuitExitCode",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::HasCustomQuitExitCode",1,"lldb::SBCommandInterpreter *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_HasCustomQuitExitCode",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
- }
-
- result = (bool)(arg1)->HasCustomQuitExitCode();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandInterpreter_GetQuitStatus(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
- int result;
-
- SWIG_check_num_args("lldb::SBCommandInterpreter::GetQuitStatus",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetQuitStatus",1,"lldb::SBCommandInterpreter *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_GetQuitStatus",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
- }
-
- result = (int)(arg1)->GetQuitStatus();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandInterpreter_ResolveCommand(lua_State* L) {
+static int _wrap_SBCommandInterpreter_CommandExists(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
char *arg2 = (char *) 0 ;
- lldb::SBCommandReturnObject *arg3 = 0 ;
+ bool result;
- SWIG_check_num_args("lldb::SBCommandInterpreter::ResolveCommand",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::ResolveCommand",1,"lldb::SBCommandInterpreter *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::ResolveCommand",2,"char const *");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBCommandInterpreter::ResolveCommand",3,"lldb::SBCommandReturnObject &");
+ SWIG_check_num_args("lldb::SBCommandInterpreter::CommandExists",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::CommandExists",1,"lldb::SBCommandInterpreter *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::CommandExists",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_ResolveCommand",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ SWIG_fail_ptr("SBCommandInterpreter_CommandExists",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
}
arg2 = (char *)lua_tostring(L, 2);
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandInterpreter_ResolveCommand",3,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
- (arg1)->ResolveCommand((char const *)arg2,*arg3);
-
+ result = (bool)(arg1)->CommandExists((char const *)arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -11935,23 +12870,23 @@ static int _wrap_SBCommandInterpreter_ResolveCommand(lua_State* L) {
}
-static int _wrap_SBCommandInterpreter_CommandExists(lua_State* L) {
+static int _wrap_SBCommandInterpreter_UserCommandExists(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
char *arg2 = (char *) 0 ;
bool result;
- SWIG_check_num_args("lldb::SBCommandInterpreter::CommandExists",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::CommandExists",1,"lldb::SBCommandInterpreter *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::CommandExists",2,"char const *");
+ SWIG_check_num_args("lldb::SBCommandInterpreter::UserCommandExists",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::UserCommandExists",1,"lldb::SBCommandInterpreter *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::UserCommandExists",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_CommandExists",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ SWIG_fail_ptr("SBCommandInterpreter_UserCommandExists",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
}
arg2 = (char *)lua_tostring(L, 2);
- result = (bool)(arg1)->CommandExists((char const *)arg2);
+ result = (bool)(arg1)->UserCommandExists((char const *)arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -12183,7 +13118,7 @@ static int _wrap_SBCommandInterpreter_GetDebugger(lua_State* L) {
}
-static int _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory(lua_State* L) {
+static int _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
@@ -12213,6 +13148,108 @@ static int _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory(lua_State* L
}
+static int _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ lldb::SBCommandReturnObject *arg2 = 0 ;
+ bool arg3 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory",1,"lldb::SBCommandInterpreter *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory",2,"lldb::SBCommandReturnObject &");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory",3,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_SourceInitFileInHomeDirectory",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_SourceInitFileInHomeDirectory",2,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ arg3 = (lua_toboolean(L, 3)!=0);
+ (arg1)->SourceInitFileInHomeDirectory(*arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandInterpreter, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandInterpreter, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBCommandInterpreter_SourceInitFileInHomeDirectory__SWIG_1(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandInterpreter_SourceInitFileInHomeDirectory'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &)\n"
+ " lldb::SBCommandInterpreter::SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &,bool)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBCommandInterpreter_SourceInitFileInCurrentWorkingDirectory(lua_State* L) {
{
int SWIG_arg = 0;
@@ -12709,6 +13746,91 @@ static int _wrap_SBCommandInterpreter_HandleCompletionWithDescriptions(lua_State
}
+static int _wrap_SBCommandInterpreter_WasInterrupted(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::WasInterrupted",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::WasInterrupted",1,"lldb::SBCommandInterpreter const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_WasInterrupted",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ result = (bool)((lldb::SBCommandInterpreter const *)arg1)->WasInterrupted();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_InterruptCommand(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::InterruptCommand",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::InterruptCommand",1,"lldb::SBCommandInterpreter *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_InterruptCommand",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ result = (bool)(arg1)->InterruptCommand();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_SetCommandOverrideCallback(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::CommandOverrideCallback arg3 = (lldb::CommandOverrideCallback) 0 ;
+ void *arg4 = (void *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::SetCommandOverrideCallback",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetCommandOverrideCallback",1,"lldb::SBCommandInterpreter *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetCommandOverrideCallback",2,"char const *");
+ if(!SWIG_isptrtype(L,3)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetCommandOverrideCallback",3,"lldb::CommandOverrideCallback");
+ if(!SWIG_isptrtype(L,4)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetCommandOverrideCallback",4,"void *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_SetCommandOverrideCallback",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_f_p_void_p_p_q_const__char__bool,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_SetCommandOverrideCallback",3,SWIGTYPE_p_f_p_void_p_p_q_const__char__bool);
+ }
+
+ arg4=(void *)SWIG_MustGetPtr(L,4,0,0,4,"SBCommandInterpreter_SetCommandOverrideCallback");
+ result = (bool)(arg1)->SetCommandOverrideCallback((char const *)arg2,arg3,arg4);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBCommandInterpreter_IsActive(lua_State* L) {
{
int SWIG_arg = 0;
@@ -12733,20 +13855,123 @@ static int _wrap_SBCommandInterpreter_IsActive(lua_State* L) {
}
-static int _wrap_SBCommandInterpreter_WasInterrupted(lua_State* L) {
+static int _wrap_SBCommandInterpreter_GetIOHandlerControlSequence(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ char arg2 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::GetIOHandlerControlSequence",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetIOHandlerControlSequence",1,"lldb::SBCommandInterpreter *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetIOHandlerControlSequence",2,"char");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_GetIOHandlerControlSequence",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ arg2 = (lua_tostring(L, 2))[0];
+ result = (char *)(arg1)->GetIOHandlerControlSequence(arg2);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_GetPromptOnQuit(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
bool result;
- SWIG_check_num_args("lldb::SBCommandInterpreter::WasInterrupted",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::WasInterrupted",1,"lldb::SBCommandInterpreter const *");
+ SWIG_check_num_args("lldb::SBCommandInterpreter::GetPromptOnQuit",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetPromptOnQuit",1,"lldb::SBCommandInterpreter *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
- SWIG_fail_ptr("SBCommandInterpreter_WasInterrupted",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ SWIG_fail_ptr("SBCommandInterpreter_GetPromptOnQuit",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
}
- result = (bool)((lldb::SBCommandInterpreter const *)arg1)->WasInterrupted();
+ result = (bool)(arg1)->GetPromptOnQuit();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_SetPromptOnQuit(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::SetPromptOnQuit",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetPromptOnQuit",1,"lldb::SBCommandInterpreter *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::SetPromptOnQuit",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_SetPromptOnQuit",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetPromptOnQuit(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_AllowExitCodeOnQuit(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::AllowExitCodeOnQuit",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::AllowExitCodeOnQuit",1,"lldb::SBCommandInterpreter *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::AllowExitCodeOnQuit",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_AllowExitCodeOnQuit",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->AllowExitCodeOnQuit(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_HasCustomQuitExitCode(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::HasCustomQuitExitCode",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::HasCustomQuitExitCode",1,"lldb::SBCommandInterpreter *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_HasCustomQuitExitCode",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ result = (bool)(arg1)->HasCustomQuitExitCode();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -12757,6 +13982,117 @@ static int _wrap_SBCommandInterpreter_WasInterrupted(lua_State* L) {
}
+static int _wrap_SBCommandInterpreter_GetQuitStatus(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ int result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::GetQuitStatus",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetQuitStatus",1,"lldb::SBCommandInterpreter *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_GetQuitStatus",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ result = (int)(arg1)->GetQuitStatus();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_ResolveCommand(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBCommandReturnObject *arg3 = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::ResolveCommand",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::ResolveCommand",1,"lldb::SBCommandInterpreter *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreter::ResolveCommand",2,"char const *");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBCommandInterpreter::ResolveCommand",3,"lldb::SBCommandReturnObject &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_ResolveCommand",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_ResolveCommand",3,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ (arg1)->ResolveCommand((char const *)arg2,*arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_GetStatistics(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::GetStatistics",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetStatistics",1,"lldb::SBCommandInterpreter *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_GetStatistics",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ result = (arg1)->GetStatistics();
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreter_GetTranscript(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) 0 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreter::GetTranscript",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreter::GetTranscript",1,"lldb::SBCommandInterpreter *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreter,0))){
+ SWIG_fail_ptr("SBCommandInterpreter_GetTranscript",1,SWIGTYPE_p_lldb__SBCommandInterpreter);
+ }
+
+ result = (arg1)->GetTranscript();
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBCommandInterpreter(void *obj) {
lldb::SBCommandInterpreter *arg1 = (lldb::SBCommandInterpreter *) obj;
delete arg1;
@@ -12774,14 +14110,8 @@ static swig_lua_attribute swig_SBCommandInterpreter_attributes[] = {
};
static swig_lua_method swig_SBCommandInterpreter_methods[]= {
{ "IsValid", _wrap_SBCommandInterpreter_IsValid},
- { "GetIOHandlerControlSequence", _wrap_SBCommandInterpreter_GetIOHandlerControlSequence},
- { "GetPromptOnQuit", _wrap_SBCommandInterpreter_GetPromptOnQuit},
- { "SetPromptOnQuit", _wrap_SBCommandInterpreter_SetPromptOnQuit},
- { "AllowExitCodeOnQuit", _wrap_SBCommandInterpreter_AllowExitCodeOnQuit},
- { "HasCustomQuitExitCode", _wrap_SBCommandInterpreter_HasCustomQuitExitCode},
- { "GetQuitStatus", _wrap_SBCommandInterpreter_GetQuitStatus},
- { "ResolveCommand", _wrap_SBCommandInterpreter_ResolveCommand},
{ "CommandExists", _wrap_SBCommandInterpreter_CommandExists},
+ { "UserCommandExists", _wrap_SBCommandInterpreter_UserCommandExists},
{ "AliasExists", _wrap_SBCommandInterpreter_AliasExists},
{ "GetBroadcaster", _wrap_SBCommandInterpreter_GetBroadcaster},
{ "HasCommands", _wrap_SBCommandInterpreter_HasCommands},
@@ -12796,8 +14126,19 @@ static swig_lua_method swig_SBCommandInterpreter_methods[]= {
{ "HandleCommandsFromFile", _wrap_SBCommandInterpreter_HandleCommandsFromFile},
{ "HandleCompletion", _wrap_SBCommandInterpreter_HandleCompletion},
{ "HandleCompletionWithDescriptions", _wrap_SBCommandInterpreter_HandleCompletionWithDescriptions},
- { "IsActive", _wrap_SBCommandInterpreter_IsActive},
{ "WasInterrupted", _wrap_SBCommandInterpreter_WasInterrupted},
+ { "InterruptCommand", _wrap_SBCommandInterpreter_InterruptCommand},
+ { "SetCommandOverrideCallback", _wrap_SBCommandInterpreter_SetCommandOverrideCallback},
+ { "IsActive", _wrap_SBCommandInterpreter_IsActive},
+ { "GetIOHandlerControlSequence", _wrap_SBCommandInterpreter_GetIOHandlerControlSequence},
+ { "GetPromptOnQuit", _wrap_SBCommandInterpreter_GetPromptOnQuit},
+ { "SetPromptOnQuit", _wrap_SBCommandInterpreter_SetPromptOnQuit},
+ { "AllowExitCodeOnQuit", _wrap_SBCommandInterpreter_AllowExitCodeOnQuit},
+ { "HasCustomQuitExitCode", _wrap_SBCommandInterpreter_HasCustomQuitExitCode},
+ { "GetQuitStatus", _wrap_SBCommandInterpreter_GetQuitStatus},
+ { "ResolveCommand", _wrap_SBCommandInterpreter_ResolveCommand},
+ { "GetStatistics", _wrap_SBCommandInterpreter_GetStatistics},
+ { "GetTranscript", _wrap_SBCommandInterpreter_GetTranscript},
{0,0}
};
static swig_lua_method swig_SBCommandInterpreter_meta[] = {
@@ -12808,11 +14149,11 @@ static swig_lua_attribute swig_SBCommandInterpreter_Sf_SwigStatic_attributes[] =
{0,0,0}
};
static swig_lua_const_info swig_SBCommandInterpreter_Sf_SwigStatic_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadShouldExit", lldb::SBCommandInterpreter::eBroadcastBitThreadShouldExit)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitResetPrompt", lldb::SBCommandInterpreter::eBroadcastBitResetPrompt)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitQuitCommandReceived", lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitAsynchronousOutputData", lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitAsynchronousErrorData", lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData)},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadShouldExit", (lldb::SBCommandInterpreter::eBroadcastBitThreadShouldExit))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitResetPrompt", (lldb::SBCommandInterpreter::eBroadcastBitResetPrompt))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitQuitCommandReceived", (lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitAsynchronousOutputData", (lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitAsynchronousErrorData", (lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBCommandInterpreter_Sf_SwigStatic_methods[]= {
@@ -12838,7 +14179,7 @@ static swig_lua_class *swig_SBCommandInterpreter_bases[] = {0};
static const char *swig_SBCommandInterpreter_base_names[] = {0};
static swig_lua_class _wrap_class_SBCommandInterpreter = { "SBCommandInterpreter", "SBCommandInterpreter", &SWIGTYPE_p_lldb__SBCommandInterpreter,_proxy__wrap_new_SBCommandInterpreter, swig_delete_SBCommandInterpreter, swig_SBCommandInterpreter_methods, swig_SBCommandInterpreter_attributes, &swig_SBCommandInterpreter_Sf_SwigStatic, swig_SBCommandInterpreter_meta, swig_SBCommandInterpreter_bases, swig_SBCommandInterpreter_base_names };
-static int _wrap_new_SBCommandInterpreterRunOptions(lua_State* L) {
+static int _wrap_new_SBCommandInterpreterRunOptions__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandInterpreterRunOptions *result = 0 ;
@@ -12855,6 +14196,63 @@ static int _wrap_new_SBCommandInterpreterRunOptions(lua_State* L) {
}
+static int _wrap_new_SBCommandInterpreterRunOptions__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = 0 ;
+ lldb::SBCommandInterpreterRunOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions",1,"lldb::SBCommandInterpreterRunOptions const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("new_SBCommandInterpreterRunOptions",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ result = (lldb::SBCommandInterpreterRunOptions *)new lldb::SBCommandInterpreterRunOptions((lldb::SBCommandInterpreterRunOptions const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBCommandInterpreterRunOptions(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBCommandInterpreterRunOptions__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBCommandInterpreterRunOptions__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBCommandInterpreterRunOptions'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions()\n"
+ " lldb::SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions(lldb::SBCommandInterpreterRunOptions const &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBCommandInterpreterRunOptions_GetStopOnContinue(lua_State* L) {
{
int SWIG_arg = 0;
@@ -13055,6 +14453,56 @@ static int _wrap_SBCommandInterpreterRunOptions_SetEchoCommands(lua_State* L) {
}
+static int _wrap_SBCommandInterpreterRunOptions_GetEchoCommentCommands(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::GetEchoCommentCommands",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::GetEchoCommentCommands",1,"lldb::SBCommandInterpreterRunOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_GetEchoCommentCommands",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ result = (bool)((lldb::SBCommandInterpreterRunOptions const *)arg1)->GetEchoCommentCommands();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreterRunOptions_SetEchoCommentCommands(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::SetEchoCommentCommands",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetEchoCommentCommands",1,"lldb::SBCommandInterpreterRunOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetEchoCommentCommands",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_SetEchoCommentCommands",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetEchoCommentCommands(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBCommandInterpreterRunOptions_GetPrintResults(lua_State* L) {
{
int SWIG_arg = 0;
@@ -13205,6 +14653,156 @@ static int _wrap_SBCommandInterpreterRunOptions_SetAddToHistory(lua_State* L) {
}
+static int _wrap_SBCommandInterpreterRunOptions_GetAutoHandleEvents(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::GetAutoHandleEvents",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::GetAutoHandleEvents",1,"lldb::SBCommandInterpreterRunOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_GetAutoHandleEvents",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ result = (bool)((lldb::SBCommandInterpreterRunOptions const *)arg1)->GetAutoHandleEvents();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreterRunOptions_SetAutoHandleEvents(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::SetAutoHandleEvents",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetAutoHandleEvents",1,"lldb::SBCommandInterpreterRunOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetAutoHandleEvents",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_SetAutoHandleEvents",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetAutoHandleEvents(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreterRunOptions_GetSpawnThread(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::GetSpawnThread",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::GetSpawnThread",1,"lldb::SBCommandInterpreterRunOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_GetSpawnThread",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ result = (bool)((lldb::SBCommandInterpreterRunOptions const *)arg1)->GetSpawnThread();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreterRunOptions_SetSpawnThread(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::SetSpawnThread",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetSpawnThread",1,"lldb::SBCommandInterpreterRunOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetSpawnThread",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_SetSpawnThread",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetSpawnThread(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreterRunOptions_GetAllowRepeats(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::GetAllowRepeats",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::GetAllowRepeats",1,"lldb::SBCommandInterpreterRunOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_GetAllowRepeats",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ result = (bool)((lldb::SBCommandInterpreterRunOptions const *)arg1)->GetAllowRepeats();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandInterpreterRunOptions_SetAllowRepeats(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBCommandInterpreterRunOptions::SetAllowRepeats",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetAllowRepeats",1,"lldb::SBCommandInterpreterRunOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandInterpreterRunOptions::SetAllowRepeats",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions,0))){
+ SWIG_fail_ptr("SBCommandInterpreterRunOptions_SetAllowRepeats",1,SWIGTYPE_p_lldb__SBCommandInterpreterRunOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetAllowRepeats(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBCommandInterpreterRunOptions(void *obj) {
lldb::SBCommandInterpreterRunOptions *arg1 = (lldb::SBCommandInterpreterRunOptions *) obj;
delete arg1;
@@ -13229,12 +14827,20 @@ static swig_lua_method swig_SBCommandInterpreterRunOptions_methods[]= {
{ "SetStopOnCrash", _wrap_SBCommandInterpreterRunOptions_SetStopOnCrash},
{ "GetEchoCommands", _wrap_SBCommandInterpreterRunOptions_GetEchoCommands},
{ "SetEchoCommands", _wrap_SBCommandInterpreterRunOptions_SetEchoCommands},
+ { "GetEchoCommentCommands", _wrap_SBCommandInterpreterRunOptions_GetEchoCommentCommands},
+ { "SetEchoCommentCommands", _wrap_SBCommandInterpreterRunOptions_SetEchoCommentCommands},
{ "GetPrintResults", _wrap_SBCommandInterpreterRunOptions_GetPrintResults},
{ "SetPrintResults", _wrap_SBCommandInterpreterRunOptions_SetPrintResults},
{ "GetPrintErrors", _wrap_SBCommandInterpreterRunOptions_GetPrintErrors},
{ "SetPrintErrors", _wrap_SBCommandInterpreterRunOptions_SetPrintErrors},
{ "GetAddToHistory", _wrap_SBCommandInterpreterRunOptions_GetAddToHistory},
{ "SetAddToHistory", _wrap_SBCommandInterpreterRunOptions_SetAddToHistory},
+ { "GetAutoHandleEvents", _wrap_SBCommandInterpreterRunOptions_GetAutoHandleEvents},
+ { "SetAutoHandleEvents", _wrap_SBCommandInterpreterRunOptions_SetAutoHandleEvents},
+ { "GetSpawnThread", _wrap_SBCommandInterpreterRunOptions_GetSpawnThread},
+ { "SetSpawnThread", _wrap_SBCommandInterpreterRunOptions_SetSpawnThread},
+ { "GetAllowRepeats", _wrap_SBCommandInterpreterRunOptions_GetAllowRepeats},
+ { "SetAllowRepeats", _wrap_SBCommandInterpreterRunOptions_SetAllowRepeats},
{0,0}
};
static swig_lua_method swig_SBCommandInterpreterRunOptions_meta[] = {
@@ -13412,44 +15018,29 @@ static int _wrap_SBCommandReturnObject_GetError__SWIG_0(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_GetOutputSize(lua_State* L) {
+static int _wrap_SBCommandReturnObject_PutOutput__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ lldb::SBFile arg2 ;
+ lldb::SBFile *argp2 ;
size_t result;
- SWIG_check_num_args("lldb::SBCommandReturnObject::GetOutputSize",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetOutputSize",1,"lldb::SBCommandReturnObject *");
+ SWIG_check_num_args("lldb::SBCommandReturnObject::PutOutput",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutOutput",1,"lldb::SBCommandReturnObject *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutOutput",2,"lldb::SBFile");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_GetOutputSize",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ SWIG_fail_ptr("SBCommandReturnObject_PutOutput",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
}
- result = (arg1)->GetOutputSize();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_GetErrorSize(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- size_t result;
-
- SWIG_check_num_args("lldb::SBCommandReturnObject::GetErrorSize",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetErrorSize",1,"lldb::SBCommandReturnObject *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_GetErrorSize",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBFile,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_PutOutput",2,SWIGTYPE_p_lldb__SBFile);
}
+ arg2 = *argp2;
- result = (arg1)->GetErrorSize();
+ result = (arg1)->PutOutput(arg2);
lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
@@ -13460,24 +15051,30 @@ static int _wrap_SBCommandReturnObject_GetErrorSize(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_GetOutput__SWIG_1(lua_State* L) {
+static int _wrap_SBCommandReturnObject_PutOutput__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- bool arg2 ;
- char *result = 0 ;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg2 ;
+ size_t result;
- SWIG_check_num_args("lldb::SBCommandReturnObject::GetOutput",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetOutput",1,"lldb::SBCommandReturnObject *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetOutput",2,"bool");
+ SWIG_check_num_args("lldb::SBCommandReturnObject::PutOutput",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutOutput",1,"lldb::SBCommandReturnObject *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_GetOutput",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ SWIG_fail_ptr("SBCommandReturnObject_PutOutput",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
}
- arg2 = (lua_toboolean(L, 2)!=0);
- result = (char *)(arg1)->GetOutput(arg2);
- lua_pushstring(L,(const char *)result); SWIG_arg++;
+ {
+ luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 2, LUA_FILEHANDLE);
+ lldb::FileSP file_sp;
+ file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
+ if (!file_sp->IsValid())
+ return luaL_error(L, "Invalid file");
+ arg2 = file_sp;
+ }
+ result = (arg1)->PutOutput(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -13487,14 +15084,14 @@ static int _wrap_SBCommandReturnObject_GetOutput__SWIG_1(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_GetOutput(lua_State* L) {
+static int _wrap_SBCommandReturnObject_PutOutput(lua_State* L) {
int argc;
int argv[3]={
1,2,3
};
argc = lua_gettop(L);
- if (argc == 1) {
+ if (argc == 2) {
int _v = 0;
{
void *ptr;
@@ -13505,7 +15102,17 @@ static int _wrap_SBCommandReturnObject_GetOutput(lua_State* L) {
}
}
if (_v) {
- return _wrap_SBCommandReturnObject_GetOutput__SWIG_0(L);
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBFile, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_PutOutput__SWIG_0(L);
+ }
}
}
if (argc == 2) {
@@ -13520,40 +15127,38 @@ static int _wrap_SBCommandReturnObject_GetOutput(lua_State* L) {
}
if (_v) {
{
- _v = lua_isboolean(L,argv[1]);
+ _v = (lua_isuserdata(L, argv[1])) &&
+ (luaL_testudata(L, argv[1], LUA_FILEHANDLE) != nullptr);
}
if (_v) {
- return _wrap_SBCommandReturnObject_GetOutput__SWIG_1(L);
+ return _wrap_SBCommandReturnObject_PutOutput__SWIG_1(L);
}
}
}
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_GetOutput'\n"
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_PutOutput'\n"
" Possible C/C++ prototypes are:\n"
- " lldb::SBCommandReturnObject::GetOutput()\n"
- " lldb::SBCommandReturnObject::GetOutput(bool)\n");
+ " lldb::SBCommandReturnObject::PutOutput(lldb::SBFile)\n"
+ " lldb::SBCommandReturnObject::PutOutput(lldb::FileSP)\n");
lua_error(L);return 0;
}
-static int _wrap_SBCommandReturnObject_GetError__SWIG_1(lua_State* L) {
+static int _wrap_SBCommandReturnObject_GetOutputSize(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- bool arg2 ;
- char *result = 0 ;
+ size_t result;
- SWIG_check_num_args("lldb::SBCommandReturnObject::GetError",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetError",1,"lldb::SBCommandReturnObject *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetError",2,"bool");
+ SWIG_check_num_args("lldb::SBCommandReturnObject::GetOutputSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetOutputSize",1,"lldb::SBCommandReturnObject *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_GetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ SWIG_fail_ptr("SBCommandReturnObject_GetOutputSize",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
}
- arg2 = (lua_toboolean(L, 2)!=0);
- result = (char *)(arg1)->GetError(arg2);
- lua_pushstring(L,(const char *)result); SWIG_arg++;
+ result = (arg1)->GetOutputSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -13563,78 +15168,20 @@ static int _wrap_SBCommandReturnObject_GetError__SWIG_1(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_GetError(lua_State* L) {
- int argc;
- int argv[3]={
- 1,2,3
- };
-
- argc = lua_gettop(L);
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_GetError__SWIG_0(L);
- }
- }
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = lua_isboolean(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_GetError__SWIG_1(L);
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_GetError'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBCommandReturnObject::GetError()\n"
- " lldb::SBCommandReturnObject::GetError(bool)\n");
- lua_error(L);return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_PutOutput__SWIG_0(lua_State* L) {
+static int _wrap_SBCommandReturnObject_GetErrorSize(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- lldb::SBFile arg2 ;
- lldb::SBFile *argp2 ;
size_t result;
- SWIG_check_num_args("lldb::SBCommandReturnObject::PutOutput",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutOutput",1,"lldb::SBCommandReturnObject *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutOutput",2,"lldb::SBFile");
+ SWIG_check_num_args("lldb::SBCommandReturnObject::GetErrorSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetErrorSize",1,"lldb::SBCommandReturnObject *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_PutOutput",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBFile,0))){
- SWIG_fail_ptr("SBCommandReturnObject_PutOutput",2,SWIGTYPE_p_lldb__SBFile);
+ SWIG_fail_ptr("SBCommandReturnObject_GetErrorSize",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
}
- arg2 = *argp2;
- result = (arg1)->PutOutput(arg2);
+ result = (arg1)->GetErrorSize();
lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
@@ -13678,99 +15225,6 @@ static int _wrap_SBCommandReturnObject_PutError__SWIG_0(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_PutOutput__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg2 ;
- size_t result;
-
- SWIG_check_num_args("lldb::SBCommandReturnObject::PutOutput",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutOutput",1,"lldb::SBCommandReturnObject *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_PutOutput",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
- {
- luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 2, LUA_FILEHANDLE);
- lldb::FileSP file_sp;
- file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
- if (!file_sp->IsValid())
- return luaL_error(L, "Invalid file");
- arg2 = file_sp;
- }
- result = (arg1)->PutOutput(arg2);
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_PutOutput(lua_State* L) {
- int argc;
- int argv[3]={
- 1,2,3
- };
-
- argc = lua_gettop(L);
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- void *ptr;
- if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBFile, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_PutOutput__SWIG_0(L);
- }
- }
- }
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = (lua_isuserdata(L, argv[1])) &&
- (luaL_testudata(L, argv[1], LUA_FILEHANDLE) != nullptr);
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_PutOutput__SWIG_1(L);
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_PutOutput'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBCommandReturnObject::PutOutput(lldb::SBFile)\n"
- " lldb::SBCommandReturnObject::PutOutput(lldb::FileSP)\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBCommandReturnObject_PutError__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
@@ -13887,86 +15341,21 @@ static int _wrap_SBCommandReturnObject_Clear(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_SetStatus(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- lldb::ReturnStatus arg2 ;
-
- SWIG_check_num_args("lldb::SBCommandReturnObject::SetStatus",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetStatus",1,"lldb::SBCommandReturnObject *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetStatus",2,"lldb::ReturnStatus");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_SetStatus",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
- arg2 = (lldb::ReturnStatus)lua_tointeger(L, 2);
- (arg1)->SetStatus(arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_SetError__SWIG_0(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- lldb::SBError *arg2 = 0 ;
- char *arg3 = (char *) 0 ;
-
- SWIG_check_num_args("lldb::SBCommandReturnObject::SetError",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",1,"lldb::SBCommandReturnObject *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",2,"lldb::SBError &");
- if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",3,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_SetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBCommandReturnObject_SetError",2,SWIGTYPE_p_lldb__SBError);
- }
-
- arg3 = (char *)lua_tostring(L, 3);
- (arg1)->SetError(*arg2,(char const *)arg3);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_SetError__SWIG_1(lua_State* L) {
+static int _wrap_SBCommandReturnObject_GetStatus(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- lldb::SBError *arg2 = 0 ;
+ lldb::ReturnStatus result;
- SWIG_check_num_args("lldb::SBCommandReturnObject::SetError",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",1,"lldb::SBCommandReturnObject *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",2,"lldb::SBError &");
+ SWIG_check_num_args("lldb::SBCommandReturnObject::GetStatus",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetStatus",1,"lldb::SBCommandReturnObject *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_SetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBCommandReturnObject_SetError",2,SWIGTYPE_p_lldb__SBError);
+ SWIG_fail_ptr("SBCommandReturnObject_GetStatus",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
}
- (arg1)->SetError(*arg2);
-
+ result = (lldb::ReturnStatus)(arg1)->GetStatus();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -13976,136 +15365,23 @@ static int _wrap_SBCommandReturnObject_SetError__SWIG_1(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_SetError__SWIG_2(lua_State* L) {
+static int _wrap_SBCommandReturnObject_SetStatus(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- char *arg2 = (char *) 0 ;
+ lldb::ReturnStatus arg2 ;
- SWIG_check_num_args("lldb::SBCommandReturnObject::SetError",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",1,"lldb::SBCommandReturnObject *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",2,"char const *");
+ SWIG_check_num_args("lldb::SBCommandReturnObject::SetStatus",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetStatus",1,"lldb::SBCommandReturnObject *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetStatus",2,"lldb::ReturnStatus");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_SetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- (arg1)->SetError((char const *)arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_SetError(lua_State* L) {
- int argc;
- int argv[4]={
- 1,2,3,4
- };
-
- argc = lua_gettop(L);
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- void *ptr;
- if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_SetError__SWIG_1(L);
- }
- }
- }
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = SWIG_lua_isnilstring(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_SetError__SWIG_2(L);
- }
- }
- }
- if (argc == 3) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- void *ptr;
- if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = SWIG_lua_isnilstring(L,argv[2]);
- }
- if (_v) {
- return _wrap_SBCommandReturnObject_SetError__SWIG_0(L);
- }
- }
+ SWIG_fail_ptr("SBCommandReturnObject_SetStatus",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
}
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_SetError'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBCommandReturnObject::SetError(lldb::SBError &,char const *)\n"
- " lldb::SBCommandReturnObject::SetError(lldb::SBError &)\n"
- " lldb::SBCommandReturnObject::SetError(char const *)\n");
- lua_error(L);return 0;
-}
-
-
-static int _wrap_SBCommandReturnObject_GetStatus(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- lldb::ReturnStatus result;
- SWIG_check_num_args("lldb::SBCommandReturnObject::GetStatus",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetStatus",1,"lldb::SBCommandReturnObject *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_GetStatus",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
+ arg2 = (lldb::ReturnStatus)lua_tointeger(L, 2);
+ (arg1)->SetStatus(arg2);
- result = (lldb::ReturnStatus)(arg1)->GetStatus();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -14374,6 +15650,457 @@ static int _wrap_SBCommandReturnObject_SetImmediateErrorFile__SWIG_1(lua_State*
}
+static int _wrap_SBCommandReturnObject_PutCString__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ char *arg2 = (char *) 0 ;
+ int arg3 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::PutCString",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutCString",1,"lldb::SBCommandReturnObject *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_PutCString",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ {
+ if (lua_isnil(L, 2)) {
+ arg2 = NULL;
+ arg3 = 0;
+ } else {
+ arg2 = (char *)luaL_checklstring(L, 2, (size_t *)&arg3);
+ }
+ }
+ (arg1)->PutCString((char const *)arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_PutCString__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::PutCString",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutCString",1,"lldb::SBCommandReturnObject *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutCString",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_PutCString",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ (arg1)->PutCString((char const *)arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_PutCString(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ if (argc <= 2) {
+ return _wrap_SBCommandReturnObject_PutCString__SWIG_0(L);
+ }
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_PutCString__SWIG_0(L);
+ }
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_PutCString__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_PutCString'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandReturnObject::PutCString(char const *,int)\n"
+ " lldb::SBCommandReturnObject::PutCString(char const *)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_GetOutput__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ bool arg2 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::GetOutput",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetOutput",1,"lldb::SBCommandReturnObject *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetOutput",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_GetOutput",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ result = (char *)(arg1)->GetOutput(arg2);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_GetOutput(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_GetOutput__SWIG_0(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_GetOutput__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_GetOutput'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandReturnObject::GetOutput()\n"
+ " lldb::SBCommandReturnObject::GetOutput(bool)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_GetError__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ bool arg2 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::GetError",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetError",1,"lldb::SBCommandReturnObject *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::GetError",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_GetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ result = (char *)(arg1)->GetError(arg2);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_GetError(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_GetError__SWIG_0(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_GetError__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_GetError'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandReturnObject::GetError()\n"
+ " lldb::SBCommandReturnObject::GetError(bool)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_SetError__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ lldb::SBError *arg2 = 0 ;
+ char *arg3 = (char *) 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::SetError",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",1,"lldb::SBCommandReturnObject *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",2,"lldb::SBError &");
+ if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",3,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_SetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_SetError",2,SWIGTYPE_p_lldb__SBError);
+ }
+
+ arg3 = (char *)lua_tostring(L, 3);
+ (arg1)->SetError(*arg2,(char const *)arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_SetError__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ lldb::SBError *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::SetError",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",1,"lldb::SBCommandReturnObject *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",2,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_SetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_SetError",2,SWIGTYPE_p_lldb__SBError);
+ }
+
+ (arg1)->SetError(*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_SetError__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ SWIG_check_num_args("lldb::SBCommandReturnObject::SetError",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",1,"lldb::SBCommandReturnObject *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBCommandReturnObject::SetError",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
+ SWIG_fail_ptr("SBCommandReturnObject_SetError",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ (arg1)->SetError((char const *)arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBCommandReturnObject_SetError(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_SetError__SWIG_1(L);
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_SetError__SWIG_2(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBCommandReturnObject, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBCommandReturnObject_SetError__SWIG_0(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBCommandReturnObject_SetError'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBCommandReturnObject::SetError(lldb::SBError &,char const *)\n"
+ " lldb::SBCommandReturnObject::SetError(lldb::SBError &)\n"
+ " lldb::SBCommandReturnObject::SetError(char const *)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBCommandReturnObject___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -14640,39 +16367,6 @@ static int _wrap_SBCommandReturnObject_SetImmediateErrorFile(lua_State* L) {
}
-static int _wrap_SBCommandReturnObject_PutCString(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBCommandReturnObject *arg1 = (lldb::SBCommandReturnObject *) 0 ;
- char *arg2 = (char *) 0 ;
- int arg3 ;
-
- SWIG_check_num_args("lldb::SBCommandReturnObject::PutCString",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCommandReturnObject::PutCString",1,"lldb::SBCommandReturnObject *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCommandReturnObject,0))){
- SWIG_fail_ptr("SBCommandReturnObject_PutCString",1,SWIGTYPE_p_lldb__SBCommandReturnObject);
- }
-
- {
- if (lua_isnil(L, 2)) {
- arg2 = NULL;
- arg3 = 0;
- } else {
- arg2 = (char *)luaL_checklstring(L, 2, (size_t *)&arg3);
- }
- }
- (arg1)->PutCString((char const *)arg2,arg3);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBCommandReturnObject_Print(lua_State* L) {
{
int SWIG_arg = 0;
@@ -14716,25 +16410,25 @@ static swig_lua_attribute swig_SBCommandReturnObject_attributes[] = {
};
static swig_lua_method swig_SBCommandReturnObject_methods[]= {
{ "IsValid", _wrap_SBCommandReturnObject_IsValid},
+ { "PutOutput", _wrap_SBCommandReturnObject_PutOutput},
{ "GetOutputSize", _wrap_SBCommandReturnObject_GetOutputSize},
{ "GetErrorSize", _wrap_SBCommandReturnObject_GetErrorSize},
- { "GetOutput", _wrap_SBCommandReturnObject_GetOutput},
- { "GetError", _wrap_SBCommandReturnObject_GetError},
- { "PutOutput", _wrap_SBCommandReturnObject_PutOutput},
{ "PutError", _wrap_SBCommandReturnObject_PutError},
{ "Clear", _wrap_SBCommandReturnObject_Clear},
- { "SetStatus", _wrap_SBCommandReturnObject_SetStatus},
- { "SetError", _wrap_SBCommandReturnObject_SetError},
{ "GetStatus", _wrap_SBCommandReturnObject_GetStatus},
+ { "SetStatus", _wrap_SBCommandReturnObject_SetStatus},
{ "Succeeded", _wrap_SBCommandReturnObject_Succeeded},
{ "HasResult", _wrap_SBCommandReturnObject_HasResult},
{ "AppendMessage", _wrap_SBCommandReturnObject_AppendMessage},
{ "AppendWarning", _wrap_SBCommandReturnObject_AppendWarning},
{ "GetDescription", _wrap_SBCommandReturnObject_GetDescription},
+ { "PutCString", _wrap_SBCommandReturnObject_PutCString},
+ { "GetOutput", _wrap_SBCommandReturnObject_GetOutput},
+ { "GetError", _wrap_SBCommandReturnObject_GetError},
+ { "SetError", _wrap_SBCommandReturnObject_SetError},
{ "__tostring", _wrap_SBCommandReturnObject___tostring},
{ "SetImmediateOutputFile", _wrap_SBCommandReturnObject_SetImmediateOutputFile},
{ "SetImmediateErrorFile", _wrap_SBCommandReturnObject_SetImmediateErrorFile},
- { "PutCString", _wrap_SBCommandReturnObject_PutCString},
{ "Print", _wrap_SBCommandReturnObject_Print},
{0,0}
};
@@ -15279,12 +16973,12 @@ static swig_lua_attribute swig_SBCommunication_Sf_SwigStatic_attributes[] = {
{0,0,0}
};
static swig_lua_const_info swig_SBCommunication_Sf_SwigStatic_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitDisconnected", lldb::SBCommunication::eBroadcastBitDisconnected)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitReadThreadGotBytes", lldb::SBCommunication::eBroadcastBitReadThreadGotBytes)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitReadThreadDidExit", lldb::SBCommunication::eBroadcastBitReadThreadDidExit)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitReadThreadShouldExit", lldb::SBCommunication::eBroadcastBitReadThreadShouldExit)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitPacketAvailable", lldb::SBCommunication::eBroadcastBitPacketAvailable)},
- {SWIG_LUA_CONSTTAB_INT("eAllEventBits", lldb::SBCommunication::eAllEventBits)},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitDisconnected", (lldb::SBCommunication::eBroadcastBitDisconnected))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitReadThreadGotBytes", (lldb::SBCommunication::eBroadcastBitReadThreadGotBytes))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitReadThreadDidExit", (lldb::SBCommunication::eBroadcastBitReadThreadDidExit))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitReadThreadShouldExit", (lldb::SBCommunication::eBroadcastBitReadThreadShouldExit))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitPacketAvailable", (lldb::SBCommunication::eBroadcastBitPacketAvailable))},
+ {SWIG_LUA_CONSTTAB_INT("eAllEventBits", (lldb::SBCommunication::eAllEventBits))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBCommunication_Sf_SwigStatic_methods[]= {
@@ -15993,27 +17687,27 @@ static int _wrap_SBCompileUnit_GetLanguage(lua_State* L) {
}
-static int _wrap_SBCompileUnit_GetDescription(lua_State* L) {
+static int _wrap_SBCompileUnit___eq(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCompileUnit *arg1 = (lldb::SBCompileUnit *) 0 ;
- lldb::SBStream *arg2 = 0 ;
+ lldb::SBCompileUnit *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBCompileUnit::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCompileUnit::GetDescription",1,"lldb::SBCompileUnit *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCompileUnit::GetDescription",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBCompileUnit::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCompileUnit::operator ==",1,"lldb::SBCompileUnit const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCompileUnit::operator ==",2,"lldb::SBCompileUnit const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCompileUnit,0))){
- SWIG_fail_ptr("SBCompileUnit_GetDescription",1,SWIGTYPE_p_lldb__SBCompileUnit);
+ SWIG_fail_ptr("SBCompileUnit___eq",1,SWIGTYPE_p_lldb__SBCompileUnit);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBCompileUnit_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBCompileUnit,0))){
+ SWIG_fail_ptr("SBCompileUnit___eq",2,SWIGTYPE_p_lldb__SBCompileUnit);
}
- result = (bool)(arg1)->GetDescription(*arg2);
+ result = (bool)((lldb::SBCompileUnit const *)arg1)->operator ==((lldb::SBCompileUnit const &)*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -16024,27 +17718,27 @@ static int _wrap_SBCompileUnit_GetDescription(lua_State* L) {
}
-static int _wrap_SBCompileUnit___eq(lua_State* L) {
+static int _wrap_SBCompileUnit_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBCompileUnit *arg1 = (lldb::SBCompileUnit *) 0 ;
- lldb::SBCompileUnit *arg2 = 0 ;
+ lldb::SBStream *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBCompileUnit::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCompileUnit::operator ==",1,"lldb::SBCompileUnit const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCompileUnit::operator ==",2,"lldb::SBCompileUnit const &");
+ SWIG_check_num_args("lldb::SBCompileUnit::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBCompileUnit::GetDescription",1,"lldb::SBCompileUnit *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBCompileUnit::GetDescription",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBCompileUnit,0))){
- SWIG_fail_ptr("SBCompileUnit___eq",1,SWIGTYPE_p_lldb__SBCompileUnit);
+ SWIG_fail_ptr("SBCompileUnit_GetDescription",1,SWIGTYPE_p_lldb__SBCompileUnit);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBCompileUnit,0))){
- SWIG_fail_ptr("SBCompileUnit___eq",2,SWIGTYPE_p_lldb__SBCompileUnit);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBCompileUnit_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
}
- result = (bool)((lldb::SBCompileUnit const *)arg1)->operator ==((lldb::SBCompileUnit const &)*arg2);
+ result = (bool)(arg1)->GetDescription(*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -16105,8 +17799,8 @@ static swig_lua_method swig_SBCompileUnit_methods[]= {
{ "FindSupportFileIndex", _wrap_SBCompileUnit_FindSupportFileIndex},
{ "GetTypes", _wrap_SBCompileUnit_GetTypes},
{ "GetLanguage", _wrap_SBCompileUnit_GetLanguage},
- { "GetDescription", _wrap_SBCompileUnit_GetDescription},
{ "__eq", _wrap_SBCompileUnit___eq},
+ { "GetDescription", _wrap_SBCompileUnit_GetDescription},
{ "__tostring", _wrap_SBCompileUnit___tostring},
{0,0}
};
@@ -16141,6 +17835,320 @@ static swig_lua_class *swig_SBCompileUnit_bases[] = {0};
static const char *swig_SBCompileUnit_base_names[] = {0};
static swig_lua_class _wrap_class_SBCompileUnit = { "SBCompileUnit", "SBCompileUnit", &SWIGTYPE_p_lldb__SBCompileUnit,_proxy__wrap_new_SBCompileUnit, swig_delete_SBCompileUnit, swig_SBCompileUnit_methods, swig_SBCompileUnit_attributes, &swig_SBCompileUnit_Sf_SwigStatic, swig_SBCompileUnit_meta, swig_SBCompileUnit_bases, swig_SBCompileUnit_base_names };
+static int _wrap_new_SBSaveCoreOptions__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::SBSaveCoreOptions",0,0)
+ result = (lldb::SBSaveCoreOptions *)new lldb::SBSaveCoreOptions();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBSaveCoreOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBSaveCoreOptions__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = 0 ;
+ lldb::SBSaveCoreOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::SBSaveCoreOptions",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SBSaveCoreOptions",1,"lldb::SBSaveCoreOptions const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("new_SBSaveCoreOptions",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ result = (lldb::SBSaveCoreOptions *)new lldb::SBSaveCoreOptions((lldb::SBSaveCoreOptions const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBSaveCoreOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBSaveCoreOptions(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBSaveCoreOptions__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBSaveCoreOptions, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBSaveCoreOptions__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBSaveCoreOptions'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBSaveCoreOptions::SBSaveCoreOptions()\n"
+ " lldb::SBSaveCoreOptions::SBSaveCoreOptions(lldb::SBSaveCoreOptions const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_SetPluginName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::SetPluginName",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SetPluginName",1,"lldb::SBSaveCoreOptions *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SetPluginName",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_SetPluginName",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->SetPluginName((char const *)arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_GetPluginName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::GetPluginName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::GetPluginName",1,"lldb::SBSaveCoreOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_GetPluginName",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ result = (char *)((lldb::SBSaveCoreOptions const *)arg1)->GetPluginName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_SetStyle(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+ lldb::SaveCoreStyle arg2 ;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::SetStyle",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SetStyle",1,"lldb::SBSaveCoreOptions *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SetStyle",2,"lldb::SaveCoreStyle");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_SetStyle",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ arg2 = (lldb::SaveCoreStyle)lua_tointeger(L, 2);
+ (arg1)->SetStyle(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_GetStyle(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+ lldb::SaveCoreStyle result;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::GetStyle",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::GetStyle",1,"lldb::SBSaveCoreOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_GetStyle",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ result = (lldb::SaveCoreStyle)((lldb::SBSaveCoreOptions const *)arg1)->GetStyle();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_SetOutputFile(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+ lldb::SBFileSpec arg2 ;
+ lldb::SBFileSpec *argp2 ;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::SetOutputFile",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SetOutputFile",1,"lldb::SBSaveCoreOptions *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSaveCoreOptions::SetOutputFile",2,"lldb::SBFileSpec");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_SetOutputFile",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBFileSpec,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_SetOutputFile",2,SWIGTYPE_p_lldb__SBFileSpec);
+ }
+ arg2 = *argp2;
+
+ (arg1)->SetOutputFile(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_GetOutputFile(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+ lldb::SBFileSpec result;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::GetOutputFile",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::GetOutputFile",1,"lldb::SBSaveCoreOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_GetOutputFile",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ result = ((lldb::SBSaveCoreOptions const *)arg1)->GetOutputFile();
+ {
+ lldb::SBFileSpec * resultptr = new lldb::SBFileSpec(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFileSpec,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBSaveCoreOptions_Clear(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) 0 ;
+
+ SWIG_check_num_args("lldb::SBSaveCoreOptions::Clear",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSaveCoreOptions::Clear",1,"lldb::SBSaveCoreOptions *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBSaveCoreOptions_Clear",1,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ (arg1)->Clear();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBSaveCoreOptions(void *obj) {
+lldb::SBSaveCoreOptions *arg1 = (lldb::SBSaveCoreOptions *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBSaveCoreOptions(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBSaveCoreOptions);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBSaveCoreOptions_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBSaveCoreOptions_methods[]= {
+ { "SetPluginName", _wrap_SBSaveCoreOptions_SetPluginName},
+ { "GetPluginName", _wrap_SBSaveCoreOptions_GetPluginName},
+ { "SetStyle", _wrap_SBSaveCoreOptions_SetStyle},
+ { "GetStyle", _wrap_SBSaveCoreOptions_GetStyle},
+ { "SetOutputFile", _wrap_SBSaveCoreOptions_SetOutputFile},
+ { "GetOutputFile", _wrap_SBSaveCoreOptions_GetOutputFile},
+ { "Clear", _wrap_SBSaveCoreOptions_Clear},
+ {0,0}
+};
+static swig_lua_method swig_SBSaveCoreOptions_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBSaveCoreOptions_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBSaveCoreOptions_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBSaveCoreOptions_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBSaveCoreOptions_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBSaveCoreOptions_Sf_SwigStatic = {
+ "SBSaveCoreOptions",
+ swig_SBSaveCoreOptions_Sf_SwigStatic_methods,
+ swig_SBSaveCoreOptions_Sf_SwigStatic_attributes,
+ swig_SBSaveCoreOptions_Sf_SwigStatic_constants,
+ swig_SBSaveCoreOptions_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBSaveCoreOptions_bases[] = {0};
+static const char *swig_SBSaveCoreOptions_base_names[] = {0};
+static swig_lua_class _wrap_class_SBSaveCoreOptions = { "SBSaveCoreOptions", "SBSaveCoreOptions", &SWIGTYPE_p_lldb__SBSaveCoreOptions,_proxy__wrap_new_SBSaveCoreOptions, swig_delete_SBSaveCoreOptions, swig_SBSaveCoreOptions_methods, swig_SBSaveCoreOptions_attributes, &swig_SBSaveCoreOptions_Sf_SwigStatic, swig_SBSaveCoreOptions_meta, swig_SBSaveCoreOptions_bases, swig_SBSaveCoreOptions_base_names };
+
static int _wrap_new_SBData__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -16831,7 +18839,60 @@ static int _wrap_SBData_GetString(lua_State* L) {
}
-static int _wrap_SBData_GetDescription(lua_State* L) {
+static int _wrap_SBData_ReadRawData(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBData *arg1 = (lldb::SBData *) 0 ;
+ lldb::SBError *arg2 = 0 ;
+ lldb::offset_t arg3 ;
+ void *arg4 = (void *) 0 ;
+ size_t arg5 ;
+ size_t result;
+
+ SWIG_check_num_args("lldb::SBData::ReadRawData",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBData::ReadRawData",1,"lldb::SBData *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBData::ReadRawData",2,"lldb::SBError &");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBData::ReadRawData",3,"lldb::offset_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBData,0))){
+ SWIG_fail_ptr("SBData_ReadRawData",1,SWIGTYPE_p_lldb__SBData);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBData_ReadRawData",2,SWIGTYPE_p_lldb__SBError);
+ }
+
+ arg3 = (lldb::offset_t)lua_tointeger(L, 3);
+ {
+ arg5 = luaL_checkinteger(L, 4);
+ if (arg5 <= 0) {
+ return luaL_error(L, "Positive integer expected");
+ }
+ arg4 = (char *)malloc(arg5);
+ }
+ result = (arg1)->ReadRawData(*arg2,arg3,arg4,arg5);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ {
+ lua_pop(L, 1); // Blow away the previous result
+ if (result == 0) {
+ lua_pushliteral(L, "");
+ } else {
+ lua_pushlstring(L, (const char *)arg4, result);
+ }
+ free(arg4);
+ // SWIG_arg was already incremented
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBData_GetDescription__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBData *arg1 = (lldb::SBData *) 0 ;
@@ -16865,56 +18926,103 @@ static int _wrap_SBData_GetDescription(lua_State* L) {
}
-static int _wrap_SBData_ReadRawData(lua_State* L) {
+static int _wrap_SBData_GetDescription__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBData *arg1 = (lldb::SBData *) 0 ;
- lldb::SBError *arg2 = 0 ;
- lldb::offset_t arg3 ;
- void *arg4 = (void *) 0 ;
- size_t arg5 ;
- size_t result;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
- SWIG_check_num_args("lldb::SBData::ReadRawData",4,4)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBData::ReadRawData",1,"lldb::SBData *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBData::ReadRawData",2,"lldb::SBError &");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBData::ReadRawData",3,"lldb::offset_t");
+ SWIG_check_num_args("lldb::SBData::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBData::GetDescription",1,"lldb::SBData *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBData::GetDescription",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBData,0))){
- SWIG_fail_ptr("SBData_ReadRawData",1,SWIGTYPE_p_lldb__SBData);
+ SWIG_fail_ptr("SBData_GetDescription",1,SWIGTYPE_p_lldb__SBData);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBData_ReadRawData",2,SWIGTYPE_p_lldb__SBError);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBData_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
}
- arg3 = (lldb::offset_t)lua_tointeger(L, 3);
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBData_GetDescription(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
{
- arg5 = luaL_checkinteger(L, 4);
- if (arg5 <= 0) {
- return luaL_error(L, "Positive integer expected");
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
}
- arg4 = (char *)malloc(arg5);
}
- result = (arg1)->ReadRawData(*arg2,arg3,arg4,arg5);
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStream, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBData_GetDescription__SWIG_1(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
{
- lua_pop(L, 1); // Blow away the previous result
- if (result == 0) {
- lua_pushliteral(L, "");
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBData, 0)) {
+ _v = 0;
} else {
- lua_pushlstring(L, (const char *)arg4, result);
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStream, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBData_GetDescription__SWIG_0(L);
+ }
}
- free(arg4);
- // SWIG_arg was already incremented
}
- return SWIG_arg;
-
- fail: SWIGUNUSED;
}
- lua_error(L);
- return 0;
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBData_GetDescription'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBData::GetDescription(lldb::SBStream &,lldb::addr_t)\n"
+ " lldb::SBData::GetDescription(lldb::SBStream &)\n");
+ lua_error(L);return 0;
}
@@ -17727,8 +19835,8 @@ static swig_lua_method swig_SBData_methods[]= {
{ "GetSignedInt32", _wrap_SBData_GetSignedInt32},
{ "GetSignedInt64", _wrap_SBData_GetSignedInt64},
{ "GetString", _wrap_SBData_GetString},
- { "GetDescription", _wrap_SBData_GetDescription},
{ "ReadRawData", _wrap_SBData_ReadRawData},
+ { "GetDescription", _wrap_SBData_GetDescription},
{ "SetData", _wrap_SBData_SetData},
{ "SetDataWithOwnership", _wrap_SBData_SetDataWithOwnership},
{ "Append", _wrap_SBData_Append},
@@ -17777,6 +19885,144 @@ static swig_lua_class *swig_SBData_bases[] = {0};
static const char *swig_SBData_base_names[] = {0};
static swig_lua_class _wrap_class_SBData = { "SBData", "SBData", &SWIGTYPE_p_lldb__SBData,_proxy__wrap_new_SBData, swig_delete_SBData, swig_SBData_methods, swig_SBData_attributes, &swig_SBData_Sf_SwigStatic, swig_SBData_meta, swig_SBData_bases, swig_SBData_base_names };
+static int _wrap_new_SBDebugger__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::SBDebugger",0,0)
+ result = (lldb::SBDebugger *)new lldb::SBDebugger();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBDebugger,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBDebugger__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = 0 ;
+ lldb::SBDebugger *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::SBDebugger",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBDebugger::SBDebugger",1,"lldb::SBDebugger const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("new_SBDebugger",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = (lldb::SBDebugger *)new lldb::SBDebugger((lldb::SBDebugger const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBDebugger,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBDebugger(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBDebugger__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBDebugger__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBDebugger'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBDebugger::SBDebugger()\n"
+ " lldb::SBDebugger::SBDebugger(lldb::SBDebugger const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBDebugger_GetBroadcasterClass(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetBroadcasterClass",0,0)
+ result = (char *)lldb::SBDebugger::GetBroadcasterClass();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_SupportsLanguage(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBDebugger::SupportsLanguage",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBDebugger::SupportsLanguage",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (bool)lldb::SBDebugger::SupportsLanguage(arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_GetBroadcaster(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::SBBroadcaster result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetBroadcaster",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetBroadcaster",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetBroadcaster",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = (arg1)->GetBroadcaster();
+ {
+ lldb::SBBroadcaster * resultptr = new lldb::SBBroadcaster(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBroadcaster,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_GetProgressFromEvent(lua_State* L) {
{
int SWIG_arg = 0;
@@ -17817,20 +20063,20 @@ static int _wrap_SBDebugger_GetProgressFromEvent(lua_State* L) {
}
-static int _wrap_SBDebugger_GetDiagnosticFromEvent(lua_State* L) {
+static int _wrap_SBDebugger_GetProgressDataFromEvent(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBEvent *arg1 = 0 ;
lldb::SBStructuredData result;
- SWIG_check_num_args("lldb::SBDebugger::GetDiagnosticFromEvent",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetDiagnosticFromEvent",1,"lldb::SBEvent const &");
+ SWIG_check_num_args("lldb::SBDebugger::GetProgressDataFromEvent",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetProgressDataFromEvent",1,"lldb::SBEvent const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
- SWIG_fail_ptr("SBDebugger_GetDiagnosticFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
+ SWIG_fail_ptr("SBDebugger_GetProgressDataFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
}
- result = lldb::SBDebugger::GetDiagnosticFromEvent((lldb::SBEvent const &)*arg1);
+ result = lldb::SBDebugger::GetProgressDataFromEvent((lldb::SBEvent const &)*arg1);
{
lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
@@ -17844,23 +20090,23 @@ static int _wrap_SBDebugger_GetDiagnosticFromEvent(lua_State* L) {
}
-static int _wrap_SBDebugger_GetBroadcaster(lua_State* L) {
+static int _wrap_SBDebugger_GetDiagnosticFromEvent(lua_State* L) {
{
int SWIG_arg = 0;
- lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- lldb::SBBroadcaster result;
+ lldb::SBEvent *arg1 = 0 ;
+ lldb::SBStructuredData result;
- SWIG_check_num_args("lldb::SBDebugger::GetBroadcaster",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetBroadcaster",1,"lldb::SBDebugger *");
+ SWIG_check_num_args("lldb::SBDebugger::GetDiagnosticFromEvent",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetDiagnosticFromEvent",1,"lldb::SBEvent const &");
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetBroadcaster",1,SWIGTYPE_p_lldb__SBDebugger);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
+ SWIG_fail_ptr("SBDebugger_GetDiagnosticFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
}
- result = (arg1)->GetBroadcaster();
+ result = lldb::SBDebugger::GetDiagnosticFromEvent((lldb::SBEvent const &)*arg1);
{
- lldb::SBBroadcaster * resultptr = new lldb::SBBroadcaster(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBroadcaster,1); SWIG_arg++;
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
}
return SWIG_arg;
@@ -17923,6 +20169,22 @@ static int _wrap_SBDebugger_PrintStackTraceOnError(lua_State* L) {
}
+static int _wrap_SBDebugger_PrintDiagnosticsOnError(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+
+ SWIG_check_num_args("lldb::SBDebugger::PrintDiagnosticsOnError",0,0)
+ lldb::SBDebugger::PrintDiagnosticsOnError();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_Terminate(lua_State* L) {
{
int SWIG_arg = 0;
@@ -18118,80 +20380,6 @@ static int _wrap_SBDebugger_MemoryPressureDetected(lua_State* L) {
}
-static int _wrap_new_SBDebugger__SWIG_0(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDebugger *result = 0 ;
-
- SWIG_check_num_args("lldb::SBDebugger::SBDebugger",0,0)
- result = (lldb::SBDebugger *)new lldb::SBDebugger();
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBDebugger,1); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_new_SBDebugger__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDebugger *arg1 = 0 ;
- lldb::SBDebugger *result = 0 ;
-
- SWIG_check_num_args("lldb::SBDebugger::SBDebugger",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBDebugger::SBDebugger",1,"lldb::SBDebugger const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("new_SBDebugger",1,SWIGTYPE_p_lldb__SBDebugger);
- }
-
- result = (lldb::SBDebugger *)new lldb::SBDebugger((lldb::SBDebugger const &)*arg1);
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBDebugger,1); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_new_SBDebugger(lua_State* L) {
- int argc;
- int argv[2]={
- 1,2
- };
-
- argc = lua_gettop(L);
- if (argc == 0) {
- return _wrap_new_SBDebugger__SWIG_0(L);
- }
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_new_SBDebugger__SWIG_1(L);
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBDebugger'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBDebugger::SBDebugger()\n"
- " lldb::SBDebugger::SBDebugger(lldb::SBDebugger const &)\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBDebugger_IsValid(lua_State* L) {
{
int SWIG_arg = 0;
@@ -18239,47 +20427,27 @@ static int _wrap_SBDebugger_Clear(lua_State* L) {
}
-static int _wrap_SBDebugger_SetAsync(lua_State* L) {
+static int _wrap_SBDebugger_GetSetting__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- bool arg2 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBStructuredData result;
- SWIG_check_num_args("lldb::SBDebugger::SetAsync",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SetAsync",1,"lldb::SBDebugger *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBDebugger::SetAsync",2,"bool");
+ SWIG_check_num_args("lldb::SBDebugger::GetSetting",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetSetting",1,"lldb::SBDebugger *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBDebugger::GetSetting",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_SetAsync",1,SWIGTYPE_p_lldb__SBDebugger);
+ SWIG_fail_ptr("SBDebugger_GetSetting",1,SWIGTYPE_p_lldb__SBDebugger);
}
- arg2 = (lua_toboolean(L, 2)!=0);
- (arg1)->SetAsync(arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBDebugger_GetAsync(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBDebugger::GetAsync",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetAsync",1,"lldb::SBDebugger *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetAsync",1,SWIGTYPE_p_lldb__SBDebugger);
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->GetSetting((char const *)arg2);
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
}
-
- result = (bool)(arg1)->GetAsync();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -18289,23 +20457,24 @@ static int _wrap_SBDebugger_GetAsync(lua_State* L) {
}
-static int _wrap_SBDebugger_SkipLLDBInitFiles(lua_State* L) {
+static int _wrap_SBDebugger_GetSetting__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- bool arg2 ;
+ lldb::SBStructuredData result;
- SWIG_check_num_args("lldb::SBDebugger::SkipLLDBInitFiles",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SkipLLDBInitFiles",1,"lldb::SBDebugger *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBDebugger::SkipLLDBInitFiles",2,"bool");
+ SWIG_check_num_args("lldb::SBDebugger::GetSetting",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetSetting",1,"lldb::SBDebugger *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_SkipLLDBInitFiles",1,SWIGTYPE_p_lldb__SBDebugger);
+ SWIG_fail_ptr("SBDebugger_GetSetting",1,SWIGTYPE_p_lldb__SBDebugger);
}
- arg2 = (lua_toboolean(L, 2)!=0);
- (arg1)->SkipLLDBInitFiles(arg2);
-
+ result = (arg1)->GetSetting();
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -18315,63 +20484,72 @@ static int _wrap_SBDebugger_SkipLLDBInitFiles(lua_State* L) {
}
-static int _wrap_SBDebugger_GetInputFileHandle(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
-
- SWIG_check_num_args("lldb::SBDebugger::GetInputFileHandle",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetInputFileHandle",1,"lldb::SBDebugger *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetInputFileHandle",1,SWIGTYPE_p_lldb__SBDebugger);
+static int _wrap_SBDebugger_GetSetting(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
}
-
- result = lldb_SBDebugger_GetInputFileHandle(arg1);
+ if (_v) {
+ return _wrap_SBDebugger_GetSetting__SWIG_1(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
{
- lldb::FileSP sp = result;
- if (sp && sp->IsValid()) {
- luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
- p->closef = &LLDBSwigLuaCloseFileHandle;
- p->f = sp->GetStream();
- luaL_setmetatable(L, LUA_FILEHANDLE);
- SWIG_arg++;
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBDebugger_GetSetting__SWIG_0(L);
}
}
- return SWIG_arg;
-
- fail: SWIGUNUSED;
}
- lua_error(L);
- return 0;
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBDebugger_GetSetting'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBDebugger::GetSetting(char const *)\n"
+ " lldb::SBDebugger::GetSetting()\n");
+ lua_error(L);return 0;
}
-static int _wrap_SBDebugger_GetOutputFileHandle(lua_State* L) {
+static int _wrap_SBDebugger_SetAsync(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
+ bool arg2 ;
- SWIG_check_num_args("lldb::SBDebugger::GetOutputFileHandle",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetOutputFileHandle",1,"lldb::SBDebugger *");
+ SWIG_check_num_args("lldb::SBDebugger::SetAsync",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SetAsync",1,"lldb::SBDebugger *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBDebugger::SetAsync",2,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetOutputFileHandle",1,SWIGTYPE_p_lldb__SBDebugger);
+ SWIG_fail_ptr("SBDebugger_SetAsync",1,SWIGTYPE_p_lldb__SBDebugger);
}
- result = lldb_SBDebugger_GetOutputFileHandle(arg1);
- {
- lldb::FileSP sp = result;
- if (sp && sp->IsValid()) {
- luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
- p->closef = &LLDBSwigLuaCloseFileHandle;
- p->f = sp->GetStream();
- luaL_setmetatable(L, LUA_FILEHANDLE);
- SWIG_arg++;
- }
- }
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetAsync(arg2);
+
return SWIG_arg;
fail: SWIGUNUSED;
@@ -18381,30 +20559,21 @@ static int _wrap_SBDebugger_GetOutputFileHandle(lua_State* L) {
}
-static int _wrap_SBDebugger_GetErrorFileHandle(lua_State* L) {
+static int _wrap_SBDebugger_GetAsync(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
+ bool result;
- SWIG_check_num_args("lldb::SBDebugger::GetErrorFileHandle",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetErrorFileHandle",1,"lldb::SBDebugger *");
+ SWIG_check_num_args("lldb::SBDebugger::GetAsync",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetAsync",1,"lldb::SBDebugger *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetErrorFileHandle",1,SWIGTYPE_p_lldb__SBDebugger);
+ SWIG_fail_ptr("SBDebugger_GetAsync",1,SWIGTYPE_p_lldb__SBDebugger);
}
- result = lldb_SBDebugger_GetErrorFileHandle(arg1);
- {
- lldb::FileSP sp = result;
- if (sp && sp->IsValid()) {
- luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
- p->closef = &LLDBSwigLuaCloseFileHandle;
- p->f = sp->GetStream();
- luaL_setmetatable(L, LUA_FILEHANDLE);
- SWIG_arg++;
- }
- }
+ result = (bool)(arg1)->GetAsync();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -18414,27 +20583,23 @@ static int _wrap_SBDebugger_GetErrorFileHandle(lua_State* L) {
}
-static int _wrap_SBDebugger_GetSetting__SWIG_0(lua_State* L) {
+static int _wrap_SBDebugger_SkipLLDBInitFiles(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBStructuredData result;
+ bool arg2 ;
- SWIG_check_num_args("lldb::SBDebugger::GetSetting",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetSetting",1,"lldb::SBDebugger *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBDebugger::GetSetting",2,"char const *");
+ SWIG_check_num_args("lldb::SBDebugger::SkipLLDBInitFiles",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SkipLLDBInitFiles",1,"lldb::SBDebugger *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBDebugger::SkipLLDBInitFiles",2,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetSetting",1,SWIGTYPE_p_lldb__SBDebugger);
+ SWIG_fail_ptr("SBDebugger_SkipLLDBInitFiles",1,SWIGTYPE_p_lldb__SBDebugger);
}
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->GetSetting((char const *)arg2);
- {
- lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
- }
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SkipLLDBInitFiles(arg2);
+
return SWIG_arg;
fail: SWIGUNUSED;
@@ -18444,24 +20609,23 @@ static int _wrap_SBDebugger_GetSetting__SWIG_0(lua_State* L) {
}
-static int _wrap_SBDebugger_GetSetting__SWIG_1(lua_State* L) {
+static int _wrap_SBDebugger_SkipAppInitFiles(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- lldb::SBStructuredData result;
+ bool arg2 ;
- SWIG_check_num_args("lldb::SBDebugger::GetSetting",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetSetting",1,"lldb::SBDebugger *");
+ SWIG_check_num_args("lldb::SBDebugger::SkipAppInitFiles",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SkipAppInitFiles",1,"lldb::SBDebugger *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBDebugger::SkipAppInitFiles",2,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetSetting",1,SWIGTYPE_p_lldb__SBDebugger);
+ SWIG_fail_ptr("SBDebugger_SkipAppInitFiles",1,SWIGTYPE_p_lldb__SBDebugger);
}
- result = (arg1)->GetSetting();
- {
- lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
- }
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SkipAppInitFiles(arg2);
+
return SWIG_arg;
fail: SWIGUNUSED;
@@ -18471,55 +20635,6 @@ static int _wrap_SBDebugger_GetSetting__SWIG_1(lua_State* L) {
}
-static int _wrap_SBDebugger_GetSetting(lua_State* L) {
- int argc;
- int argv[3]={
- 1,2,3
- };
-
- argc = lua_gettop(L);
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBDebugger_GetSetting__SWIG_1(L);
- }
- }
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = SWIG_lua_isnilstring(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBDebugger_GetSetting__SWIG_0(L);
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBDebugger_GetSetting'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBDebugger::GetSetting(char const *)\n"
- " lldb::SBDebugger::GetSetting()\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBDebugger_SetInputString(lua_State* L) {
{
int SWIG_arg = 0;
@@ -19027,11 +21142,57 @@ static int _wrap_SBDebugger_GetErrorFile(lua_State* L) {
}
+static int _wrap_SBDebugger_SaveInputTerminalState(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::SaveInputTerminalState",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SaveInputTerminalState",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_SaveInputTerminalState",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ (arg1)->SaveInputTerminalState();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_RestoreInputTerminalState(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::RestoreInputTerminalState",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::RestoreInputTerminalState",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_RestoreInputTerminalState",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ (arg1)->RestoreInputTerminalState();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_GetCommandInterpreter(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- SwigValueWrapper< lldb::SBCommandInterpreter > result;
+ lldb::SBCommandInterpreter result;
SWIG_check_num_args("lldb::SBDebugger::GetCommandInterpreter",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetCommandInterpreter",1,"lldb::SBDebugger *");
@@ -19080,6 +21241,76 @@ static int _wrap_SBDebugger_HandleCommand(lua_State* L) {
}
+static int _wrap_SBDebugger_RequestInterrupt(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::RequestInterrupt",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::RequestInterrupt",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_RequestInterrupt",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ (arg1)->RequestInterrupt();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_CancelInterruptRequest(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::CancelInterruptRequest",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::CancelInterruptRequest",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_CancelInterruptRequest",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ (arg1)->CancelInterruptRequest();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_InterruptRequested(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBDebugger::InterruptRequested",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::InterruptRequested",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_InterruptRequested",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = (bool)(arg1)->InterruptRequested();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_GetListener(lua_State* L) {
{
int SWIG_arg = 0;
@@ -20170,6 +22401,57 @@ static int _wrap_SBDebugger_GetUseColor(lua_State* L) {
}
+static int _wrap_SBDebugger_SetUseSourceCache(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ bool arg2 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBDebugger::SetUseSourceCache",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SetUseSourceCache",1,"lldb::SBDebugger *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBDebugger::SetUseSourceCache",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_SetUseSourceCache",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ result = (bool)(arg1)->SetUseSourceCache(arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_GetUseSourceCache(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetUseSourceCache",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetUseSourceCache",1,"lldb::SBDebugger const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetUseSourceCache",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = (bool)((lldb::SBDebugger const *)arg1)->GetUseSourceCache();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_GetDefaultArchitecture(lua_State* L) {
{
int SWIG_arg = 0;
@@ -20240,6 +22522,36 @@ static int _wrap_SBDebugger_GetScriptingLanguage(lua_State* L) {
}
+static int _wrap_SBDebugger_GetScriptInterpreterInfo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::ScriptLanguage arg2 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetScriptInterpreterInfo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetScriptInterpreterInfo",1,"lldb::SBDebugger *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBDebugger::GetScriptInterpreterInfo",2,"lldb::ScriptLanguage");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetScriptInterpreterInfo",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ arg2 = (lldb::ScriptLanguage)lua_tointeger(L, 2);
+ result = (arg1)->GetScriptInterpreterInfo(arg2);
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_GetVersionString(lua_State* L) {
{
int SWIG_arg = 0;
@@ -20430,6 +22742,100 @@ static int _wrap_SBDebugger_SetLoggingCallback(lua_State* L) {
}
+static int _wrap_SBDebugger_SetDestroyCallback(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::SBDebuggerDestroyCallback arg2 = (lldb::SBDebuggerDestroyCallback) 0 ;
+ void *arg3 = (void *) 0 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::SetDestroyCallback",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SetDestroyCallback",1,"lldb::SBDebugger *");
+ if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("lldb::SBDebugger::SetDestroyCallback",2,"lldb::SBDebuggerDestroyCallback");
+ if(!SWIG_isptrtype(L,3)) SWIG_fail_arg("lldb::SBDebugger::SetDestroyCallback",3,"void *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_SetDestroyCallback",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_f_unsigned_long_long_p_void__void,0))){
+ SWIG_fail_ptr("SBDebugger_SetDestroyCallback",2,SWIGTYPE_p_f_unsigned_long_long_p_void__void);
+ }
+
+ arg3=(void *)SWIG_MustGetPtr(L,3,0,0,3,"SBDebugger_SetDestroyCallback");
+ (arg1)->SetDestroyCallback(arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_AddDestroyCallback(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::SBDebuggerDestroyCallback arg2 = (lldb::SBDebuggerDestroyCallback) 0 ;
+ void *arg3 = (void *) 0 ;
+ lldb::callback_token_t result;
+
+ SWIG_check_num_args("lldb::SBDebugger::AddDestroyCallback",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::AddDestroyCallback",1,"lldb::SBDebugger *");
+ if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("lldb::SBDebugger::AddDestroyCallback",2,"lldb::SBDebuggerDestroyCallback");
+ if(!SWIG_isptrtype(L,3)) SWIG_fail_arg("lldb::SBDebugger::AddDestroyCallback",3,"void *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_AddDestroyCallback",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_f_unsigned_long_long_p_void__void,0))){
+ SWIG_fail_ptr("SBDebugger_AddDestroyCallback",2,SWIGTYPE_p_f_unsigned_long_long_p_void__void);
+ }
+
+ arg3=(void *)SWIG_MustGetPtr(L,3,0,0,3,"SBDebugger_AddDestroyCallback");
+ result = (lldb::callback_token_t)(arg1)->AddDestroyCallback(arg2,arg3);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_RemoveDestroyCallback(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::callback_token_t arg2 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBDebugger::RemoveDestroyCallback",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::RemoveDestroyCallback",1,"lldb::SBDebugger *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBDebugger::RemoveDestroyCallback",2,"lldb::callback_token_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_RemoveDestroyCallback",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ arg2 = (lldb::callback_token_t)lua_tointeger(L, 2);
+ result = (bool)(arg1)->RemoveDestroyCallback(arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_DispatchInput(lua_State* L) {
{
int SWIG_arg = 0;
@@ -20835,6 +23241,56 @@ static int _wrap_SBDebugger_SetScriptLanguage(lua_State* L) {
}
+static int _wrap_SBDebugger_GetREPLLanguage(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::LanguageType result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetREPLLanguage",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetREPLLanguage",1,"lldb::SBDebugger const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetREPLLanguage",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = (lldb::LanguageType)((lldb::SBDebugger const *)arg1)->GetREPLLanguage();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_SetREPLLanguage(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ lldb::LanguageType arg2 ;
+
+ SWIG_check_num_args("lldb::SBDebugger::SetREPLLanguage",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::SetREPLLanguage",1,"lldb::SBDebugger *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBDebugger::SetREPLLanguage",2,"lldb::LanguageType");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_SetREPLLanguage",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ arg2 = (lldb::LanguageType)lua_tointeger(L, 2);
+ (arg1)->SetREPLLanguage(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDebugger_GetCloseInputOnEOF(lua_State* L) {
{
int SWIG_arg = 0;
@@ -21281,60 +23737,6 @@ static int _wrap_SBDebugger_GetSyntheticForType(lua_State* L) {
}
-static int _wrap_SBDebugger_GetScriptInterpreterInfo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- lldb::ScriptLanguage arg2 ;
- lldb::SBStructuredData result;
-
- SWIG_check_num_args("lldb::SBDebugger::GetScriptInterpreterInfo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetScriptInterpreterInfo",1,"lldb::SBDebugger *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBDebugger::GetScriptInterpreterInfo",2,"lldb::ScriptLanguage");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger_GetScriptInterpreterInfo",1,SWIGTYPE_p_lldb__SBDebugger);
- }
-
- arg2 = (lldb::ScriptLanguage)lua_tointeger(L, 2);
- result = (arg1)->GetScriptInterpreterInfo(arg2);
- {
- lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBDebugger___tostring(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
- std::string result;
-
- SWIG_check_num_args("lldb::SBDebugger::__repr__",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::__repr__",1,"lldb::SBDebugger *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
- SWIG_fail_ptr("SBDebugger___tostring",1,SWIGTYPE_p_lldb__SBDebugger);
- }
-
- result = lldb_SBDebugger___repr__(arg1);
- lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBDebugger_RunCommandInterpreter(lua_State* L) {
{
int SWIG_arg = 0;
@@ -21463,6 +23865,129 @@ static int _wrap_SBDebugger_LoadTraceFromFile(lua_State* L) {
}
+static int _wrap_SBDebugger___tostring(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ std::string result;
+
+ SWIG_check_num_args("lldb::SBDebugger::__repr__",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::__repr__",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger___tostring",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = lldb_SBDebugger___repr__(arg1);
+ lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_GetInputFileHandle(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetInputFileHandle",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetInputFileHandle",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetInputFileHandle",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = lldb_SBDebugger_GetInputFileHandle(arg1);
+ {
+ lldb::FileSP sp = result;
+ if (sp && sp->IsValid()) {
+ luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
+ p->closef = &LLDBSwigLuaCloseFileHandle;
+ p->f = sp->GetStream();
+ luaL_setmetatable(L, LUA_FILEHANDLE);
+ SWIG_arg++;
+ }
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_GetOutputFileHandle(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetOutputFileHandle",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetOutputFileHandle",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetOutputFileHandle",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = lldb_SBDebugger_GetOutputFileHandle(arg1);
+ {
+ lldb::FileSP sp = result;
+ if (sp && sp->IsValid()) {
+ luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
+ p->closef = &LLDBSwigLuaCloseFileHandle;
+ p->f = sp->GetStream();
+ luaL_setmetatable(L, LUA_FILEHANDLE);
+ SWIG_arg++;
+ }
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBDebugger_GetErrorFileHandle(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = (lldb::SBDebugger *) 0 ;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
+
+ SWIG_check_num_args("lldb::SBDebugger::GetErrorFileHandle",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDebugger::GetErrorFileHandle",1,"lldb::SBDebugger *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBDebugger_GetErrorFileHandle",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = lldb_SBDebugger_GetErrorFileHandle(arg1);
+ {
+ lldb::FileSP sp = result;
+ if (sp && sp->IsValid()) {
+ luaL_Stream *p = (luaL_Stream *)lua_newuserdata(L, sizeof(luaL_Stream));
+ p->closef = &LLDBSwigLuaCloseFileHandle;
+ p->f = sp->GetStream();
+ luaL_setmetatable(L, LUA_FILEHANDLE);
+ SWIG_arg++;
+ }
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBDebugger(void *obj) {
lldb::SBDebugger *arg1 = (lldb::SBDebugger *) obj;
delete arg1;
@@ -21482,13 +24007,11 @@ static swig_lua_method swig_SBDebugger_methods[]= {
{ "GetBroadcaster", _wrap_SBDebugger_GetBroadcaster},
{ "IsValid", _wrap_SBDebugger_IsValid},
{ "Clear", _wrap_SBDebugger_Clear},
+ { "GetSetting", _wrap_SBDebugger_GetSetting},
{ "SetAsync", _wrap_SBDebugger_SetAsync},
{ "GetAsync", _wrap_SBDebugger_GetAsync},
{ "SkipLLDBInitFiles", _wrap_SBDebugger_SkipLLDBInitFiles},
- { "GetInputFileHandle", _wrap_SBDebugger_GetInputFileHandle},
- { "GetOutputFileHandle", _wrap_SBDebugger_GetOutputFileHandle},
- { "GetErrorFileHandle", _wrap_SBDebugger_GetErrorFileHandle},
- { "GetSetting", _wrap_SBDebugger_GetSetting},
+ { "SkipAppInitFiles", _wrap_SBDebugger_SkipAppInitFiles},
{ "SetInputString", _wrap_SBDebugger_SetInputString},
{ "SetInputFile", _wrap_SBDebugger_SetInputFile},
{ "SetOutputFile", _wrap_SBDebugger_SetOutputFile},
@@ -21496,8 +24019,13 @@ static swig_lua_method swig_SBDebugger_methods[]= {
{ "GetInputFile", _wrap_SBDebugger_GetInputFile},
{ "GetOutputFile", _wrap_SBDebugger_GetOutputFile},
{ "GetErrorFile", _wrap_SBDebugger_GetErrorFile},
+ { "SaveInputTerminalState", _wrap_SBDebugger_SaveInputTerminalState},
+ { "RestoreInputTerminalState", _wrap_SBDebugger_RestoreInputTerminalState},
{ "GetCommandInterpreter", _wrap_SBDebugger_GetCommandInterpreter},
{ "HandleCommand", _wrap_SBDebugger_HandleCommand},
+ { "RequestInterrupt", _wrap_SBDebugger_RequestInterrupt},
+ { "CancelInterruptRequest", _wrap_SBDebugger_CancelInterruptRequest},
+ { "InterruptRequested", _wrap_SBDebugger_InterruptRequested},
{ "GetListener", _wrap_SBDebugger_GetListener},
{ "HandleProcessEvent", _wrap_SBDebugger_HandleProcessEvent},
{ "CreateTargetWithFileAndTargetTriple", _wrap_SBDebugger_CreateTargetWithFileAndTargetTriple},
@@ -21525,9 +24053,15 @@ static swig_lua_method swig_SBDebugger_methods[]= {
{ "GetUseExternalEditor", _wrap_SBDebugger_GetUseExternalEditor},
{ "SetUseColor", _wrap_SBDebugger_SetUseColor},
{ "GetUseColor", _wrap_SBDebugger_GetUseColor},
+ { "SetUseSourceCache", _wrap_SBDebugger_SetUseSourceCache},
+ { "GetUseSourceCache", _wrap_SBDebugger_GetUseSourceCache},
{ "GetScriptingLanguage", _wrap_SBDebugger_GetScriptingLanguage},
+ { "GetScriptInterpreterInfo", _wrap_SBDebugger_GetScriptInterpreterInfo},
{ "EnableLog", _wrap_SBDebugger_EnableLog},
{ "SetLoggingCallback", _wrap_SBDebugger_SetLoggingCallback},
+ { "SetDestroyCallback", _wrap_SBDebugger_SetDestroyCallback},
+ { "AddDestroyCallback", _wrap_SBDebugger_AddDestroyCallback},
+ { "RemoveDestroyCallback", _wrap_SBDebugger_RemoveDestroyCallback},
{ "DispatchInput", _wrap_SBDebugger_DispatchInput},
{ "DispatchInputInterrupt", _wrap_SBDebugger_DispatchInputInterrupt},
{ "DispatchInputEndOfFile", _wrap_SBDebugger_DispatchInputEndOfFile},
@@ -21541,6 +24075,8 @@ static swig_lua_method swig_SBDebugger_methods[]= {
{ "GetReproducerPath", _wrap_SBDebugger_GetReproducerPath},
{ "GetScriptLanguage", _wrap_SBDebugger_GetScriptLanguage},
{ "SetScriptLanguage", _wrap_SBDebugger_SetScriptLanguage},
+ { "GetREPLLanguage", _wrap_SBDebugger_GetREPLLanguage},
+ { "SetREPLLanguage", _wrap_SBDebugger_SetREPLLanguage},
{ "GetCloseInputOnEOF", _wrap_SBDebugger_GetCloseInputOnEOF},
{ "SetCloseInputOnEOF", _wrap_SBDebugger_SetCloseInputOnEOF},
{ "GetCategory", _wrap_SBDebugger_GetCategory},
@@ -21553,11 +24089,13 @@ static swig_lua_method swig_SBDebugger_methods[]= {
{ "GetSummaryForType", _wrap_SBDebugger_GetSummaryForType},
{ "GetFilterForType", _wrap_SBDebugger_GetFilterForType},
{ "GetSyntheticForType", _wrap_SBDebugger_GetSyntheticForType},
- { "GetScriptInterpreterInfo", _wrap_SBDebugger_GetScriptInterpreterInfo},
- { "__tostring", _wrap_SBDebugger___tostring},
{ "RunCommandInterpreter", _wrap_SBDebugger_RunCommandInterpreter},
{ "RunREPL", _wrap_SBDebugger_RunREPL},
{ "LoadTraceFromFile", _wrap_SBDebugger_LoadTraceFromFile},
+ { "__tostring", _wrap_SBDebugger___tostring},
+ { "GetInputFileHandle", _wrap_SBDebugger_GetInputFileHandle},
+ { "GetOutputFileHandle", _wrap_SBDebugger_GetOutputFileHandle},
+ { "GetErrorFileHandle", _wrap_SBDebugger_GetErrorFileHandle},
{0,0}
};
static swig_lua_method swig_SBDebugger_meta[] = {
@@ -21569,17 +24107,22 @@ static swig_lua_attribute swig_SBDebugger_Sf_SwigStatic_attributes[] = {
{0,0,0}
};
static swig_lua_const_info swig_SBDebugger_Sf_SwigStatic_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProgress", lldb::SBDebugger::eBroadcastBitProgress)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitWarning", lldb::SBDebugger::eBroadcastBitWarning)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitError", lldb::SBDebugger::eBroadcastBitError)},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProgress", (lldb::SBDebugger::eBroadcastBitProgress))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitWarning", (lldb::SBDebugger::eBroadcastBitWarning))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitError", (lldb::SBDebugger::eBroadcastBitError))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProgressCategory", (lldb::SBDebugger::eBroadcastBitProgressCategory))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBDebugger_Sf_SwigStatic_methods[]= {
+ { "GetBroadcasterClass", _wrap_SBDebugger_GetBroadcasterClass},
+ { "SupportsLanguage", _wrap_SBDebugger_SupportsLanguage},
{ "GetProgressFromEvent", _wrap_SBDebugger_GetProgressFromEvent},
+ { "GetProgressDataFromEvent", _wrap_SBDebugger_GetProgressDataFromEvent},
{ "GetDiagnosticFromEvent", _wrap_SBDebugger_GetDiagnosticFromEvent},
{ "Initialize", _wrap_SBDebugger_Initialize},
{ "InitializeWithErrorHandling", _wrap_SBDebugger_InitializeWithErrorHandling},
{ "PrintStackTraceOnError", _wrap_SBDebugger_PrintStackTraceOnError},
+ { "PrintDiagnosticsOnError", _wrap_SBDebugger_PrintDiagnosticsOnError},
{ "Terminate", _wrap_SBDebugger_Terminate},
{ "Create", _wrap_SBDebugger_Create},
{ "Destroy", _wrap_SBDebugger_Destroy},
@@ -21785,37 +24328,6 @@ static int _wrap_SBDeclaration_GetColumn(lua_State* L) {
}
-static int _wrap_SBDeclaration_GetDescription(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBDeclaration *arg1 = (lldb::SBDeclaration *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBDeclaration::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDeclaration::GetDescription",1,"lldb::SBDeclaration *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBDeclaration::GetDescription",2,"lldb::SBStream &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDeclaration,0))){
- SWIG_fail_ptr("SBDeclaration_GetDescription",1,SWIGTYPE_p_lldb__SBDeclaration);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBDeclaration_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- result = (bool)(arg1)->GetDescription(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBDeclaration_SetFileSpec(lua_State* L) {
{
int SWIG_arg = 0;
@@ -21931,6 +24443,37 @@ static int _wrap_SBDeclaration___eq(lua_State* L) {
}
+static int _wrap_SBDeclaration_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDeclaration *arg1 = (lldb::SBDeclaration *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBDeclaration::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBDeclaration::GetDescription",1,"lldb::SBDeclaration *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBDeclaration::GetDescription",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDeclaration,0))){
+ SWIG_fail_ptr("SBDeclaration_GetDescription",1,SWIGTYPE_p_lldb__SBDeclaration);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBDeclaration_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBDeclaration___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -21975,11 +24518,11 @@ static swig_lua_method swig_SBDeclaration_methods[]= {
{ "GetFileSpec", _wrap_SBDeclaration_GetFileSpec},
{ "GetLine", _wrap_SBDeclaration_GetLine},
{ "GetColumn", _wrap_SBDeclaration_GetColumn},
- { "GetDescription", _wrap_SBDeclaration_GetDescription},
{ "SetFileSpec", _wrap_SBDeclaration_SetFileSpec},
{ "SetLine", _wrap_SBDeclaration_SetLine},
{ "SetColumn", _wrap_SBDeclaration_SetColumn},
{ "__eq", _wrap_SBDeclaration___eq},
+ { "GetDescription", _wrap_SBDeclaration_GetDescription},
{ "__tostring", _wrap_SBDeclaration___tostring},
{0,0}
};
@@ -22055,6 +24598,26 @@ static int _wrap_new_SBError__SWIG_1(lua_State* L) {
}
+static int _wrap_new_SBError__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *arg1 = (char *) 0 ;
+ lldb::SBError *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBError::SBError",1,1)
+ if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("lldb::SBError::SBError",1,"char const *");
+ arg1 = (char *)lua_tostring(L, 1);
+ result = (lldb::SBError *)new lldb::SBError((char const *)arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_new_SBError(lua_State* L) {
int argc;
int argv[2]={
@@ -22079,11 +24642,21 @@ static int _wrap_new_SBError(lua_State* L) {
return _wrap_new_SBError__SWIG_1(L);
}
}
+ if (argc == 1) {
+ int _v = 0;
+ {
+ _v = SWIG_lua_isnilstring(L,argv[0]);
+ }
+ if (_v) {
+ return _wrap_new_SBError__SWIG_2(L);
+ }
+ }
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBError'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBError::SBError()\n"
- " lldb::SBError::SBError(lldb::SBError const &)\n");
+ " lldb::SBError::SBError(lldb::SBError const &)\n"
+ " lldb::SBError::SBError(char const *)\n");
lua_error(L);return 0;
}
@@ -22797,21 +25370,24 @@ static int _wrap_new_SBEnvironment(lua_State* L) {
}
-static int _wrap_SBEnvironment_GetNumValues(lua_State* L) {
+static int _wrap_SBEnvironment_Get(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBEnvironment *arg1 = (lldb::SBEnvironment *) 0 ;
- size_t result;
+ char *arg2 = (char *) 0 ;
+ char *result = 0 ;
- SWIG_check_num_args("lldb::SBEnvironment::GetNumValues",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBEnvironment::GetNumValues",1,"lldb::SBEnvironment *");
+ SWIG_check_num_args("lldb::SBEnvironment::Get",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBEnvironment::Get",1,"lldb::SBEnvironment *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBEnvironment::Get",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEnvironment,0))){
- SWIG_fail_ptr("SBEnvironment_GetNumValues",1,SWIGTYPE_p_lldb__SBEnvironment);
+ SWIG_fail_ptr("SBEnvironment_Get",1,SWIGTYPE_p_lldb__SBEnvironment);
}
- result = (arg1)->GetNumValues();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (char *)(arg1)->Get((char const *)arg2);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -22821,24 +25397,21 @@ static int _wrap_SBEnvironment_GetNumValues(lua_State* L) {
}
-static int _wrap_SBEnvironment_Get(lua_State* L) {
+static int _wrap_SBEnvironment_GetNumValues(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBEnvironment *arg1 = (lldb::SBEnvironment *) 0 ;
- char *arg2 = (char *) 0 ;
- char *result = 0 ;
+ size_t result;
- SWIG_check_num_args("lldb::SBEnvironment::Get",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBEnvironment::Get",1,"lldb::SBEnvironment *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBEnvironment::Get",2,"char const *");
+ SWIG_check_num_args("lldb::SBEnvironment::GetNumValues",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBEnvironment::GetNumValues",1,"lldb::SBEnvironment *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEnvironment,0))){
- SWIG_fail_ptr("SBEnvironment_Get",1,SWIGTYPE_p_lldb__SBEnvironment);
+ SWIG_fail_ptr("SBEnvironment_GetNumValues",1,SWIGTYPE_p_lldb__SBEnvironment);
}
- arg2 = (char *)lua_tostring(L, 2);
- result = (char *)(arg1)->Get((char const *)arg2);
- lua_pushstring(L,(const char *)result); SWIG_arg++;
+ result = (arg1)->GetNumValues();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -23087,8 +25660,8 @@ static swig_lua_attribute swig_SBEnvironment_attributes[] = {
{0,0,0}
};
static swig_lua_method swig_SBEnvironment_methods[]= {
- { "GetNumValues", _wrap_SBEnvironment_GetNumValues},
{ "Get", _wrap_SBEnvironment_Get},
+ { "GetNumValues", _wrap_SBEnvironment_GetNumValues},
{ "GetNameAtIndex", _wrap_SBEnvironment_GetNameAtIndex},
{ "GetValueAtIndex", _wrap_SBEnvironment_GetValueAtIndex},
{ "GetEntries", _wrap_SBEnvironment_GetEntries},
@@ -23451,7 +26024,38 @@ static int _wrap_SBEvent_GetCStringFromEvent(lua_State* L) {
}
-static int _wrap_SBEvent_GetDescription(lua_State* L) {
+static int _wrap_SBEvent_GetDescription__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBEvent *arg1 = (lldb::SBEvent *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBEvent::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBEvent::GetDescription",1,"lldb::SBEvent *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBEvent::GetDescription",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
+ SWIG_fail_ptr("SBEvent_GetDescription",1,SWIGTYPE_p_lldb__SBEvent);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBEvent_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBEvent_GetDescription__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBEvent *arg1 = (lldb::SBEvent *) 0 ;
@@ -23482,6 +26086,70 @@ static int _wrap_SBEvent_GetDescription(lua_State* L) {
}
+static int _wrap_SBEvent_GetDescription(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBEvent, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStream, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBEvent_GetDescription__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBEvent, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStream, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBEvent_GetDescription__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBEvent_GetDescription'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBEvent::GetDescription(lldb::SBStream &)\n"
+ " lldb::SBEvent::GetDescription(lldb::SBStream &) const\n");
+ lua_error(L);return 0;
+}
+
+
static void swig_delete_SBEvent(void *obj) {
lldb::SBEvent *arg1 = (lldb::SBEvent *) obj;
delete arg1;
@@ -25101,7 +27769,7 @@ static int _wrap_SBExpressionOptions_SetTrapExceptions(lua_State* L) {
}
-static int _wrap_SBExpressionOptions_SetLanguage(lua_State* L) {
+static int _wrap_SBExpressionOptions_SetLanguage__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBExpressionOptions *arg1 = (lldb::SBExpressionOptions *) 0 ;
@@ -25127,6 +27795,94 @@ static int _wrap_SBExpressionOptions_SetLanguage(lua_State* L) {
}
+static int _wrap_SBExpressionOptions_SetLanguage__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBExpressionOptions *arg1 = (lldb::SBExpressionOptions *) 0 ;
+ lldb::SBSourceLanguageName arg2 ;
+ uint32_t arg3 ;
+
+ SWIG_check_num_args("lldb::SBExpressionOptions::SetLanguage",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBExpressionOptions::SetLanguage",1,"lldb::SBExpressionOptions *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBExpressionOptions::SetLanguage",2,"lldb::SBSourceLanguageName");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBExpressionOptions::SetLanguage",3,"uint32_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBExpressionOptions,0))){
+ SWIG_fail_ptr("SBExpressionOptions_SetLanguage",1,SWIGTYPE_p_lldb__SBExpressionOptions);
+ }
+
+ arg2 = (lldb::SBSourceLanguageName)lua_tointeger(L, 2);
+ arg3 = (uint32_t)lua_tointeger(L, 3);
+ (arg1)->SetLanguage(arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBExpressionOptions_SetLanguage(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBExpressionOptions, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBExpressionOptions_SetLanguage__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBExpressionOptions, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBExpressionOptions_SetLanguage__SWIG_1(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBExpressionOptions_SetLanguage'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBExpressionOptions::SetLanguage(lldb::LanguageType)\n"
+ " lldb::SBExpressionOptions::SetLanguage(lldb::SBSourceLanguageName,uint32_t)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBExpressionOptions_GetGenerateDebugInfo(lua_State* L) {
{
int SWIG_arg = 0;
@@ -25865,19 +28621,19 @@ static int _wrap_new_SBFile__SWIG_0(lua_State* L) {
static int _wrap_new_SBFile__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
- int arg1 ;
- char *arg2 = (char *) 0 ;
- bool arg3 ;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
lldb::SBFile *result = 0 ;
- SWIG_check_num_args("lldb::SBFile::SBFile",3,3)
- if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBFile::SBFile",1,"int");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFile::SBFile",2,"char const *");
- if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBFile::SBFile",3,"bool");
- arg1 = (int)lua_tointeger(L, 1);
- arg2 = (char *)lua_tostring(L, 2);
- arg3 = (lua_toboolean(L, 3)!=0);
- result = (lldb::SBFile *)new lldb::SBFile(arg1,(char const *)arg2,arg3);
+ SWIG_check_num_args("lldb::SBFile::SBFile",1,1)
+ {
+ luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
+ lldb::FileSP file_sp;
+ file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
+ if (!file_sp->IsValid())
+ return luaL_error(L, "Invalid file");
+ arg1 = file_sp;
+ }
+ result = (lldb::SBFile *)new lldb::SBFile(arg1);
SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
return SWIG_arg;
@@ -25891,19 +28647,19 @@ static int _wrap_new_SBFile__SWIG_1(lua_State* L) {
static int _wrap_new_SBFile__SWIG_2(lua_State* L) {
{
int SWIG_arg = 0;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
+ int arg1 ;
+ char *arg2 = (char *) 0 ;
+ bool arg3 ;
lldb::SBFile *result = 0 ;
- SWIG_check_num_args("lldb::SBFile::SBFile",1,1)
- {
- luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
- lldb::FileSP file_sp;
- file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
- if (!file_sp->IsValid())
- return luaL_error(L, "Invalid file");
- arg1 = file_sp;
- }
- result = (lldb::SBFile *)new lldb::SBFile(arg1);
+ SWIG_check_num_args("lldb::SBFile::SBFile",3,3)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBFile::SBFile",1,"int");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFile::SBFile",2,"char const *");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBFile::SBFile",3,"bool");
+ arg1 = (int)lua_tointeger(L, 1);
+ arg2 = (char *)lua_tostring(L, 2);
+ arg3 = (lua_toboolean(L, 3)!=0);
+ result = (lldb::SBFile *)new lldb::SBFile(arg1,(char const *)arg2,arg3);
SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
return SWIG_arg;
@@ -25931,7 +28687,7 @@ static int _wrap_new_SBFile(lua_State* L) {
(luaL_testudata(L, argv[0], LUA_FILEHANDLE) != nullptr);
}
if (_v) {
- return _wrap_new_SBFile__SWIG_2(L);
+ return _wrap_new_SBFile__SWIG_1(L);
}
}
if (argc == 3) {
@@ -25948,7 +28704,7 @@ static int _wrap_new_SBFile(lua_State* L) {
_v = lua_isboolean(L,argv[2]);
}
if (_v) {
- return _wrap_new_SBFile__SWIG_1(L);
+ return _wrap_new_SBFile__SWIG_2(L);
}
}
}
@@ -25957,99 +28713,12 @@ static int _wrap_new_SBFile(lua_State* L) {
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBFile'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBFile::SBFile()\n"
- " lldb::SBFile::SBFile(int,char const *,bool)\n"
- " lldb::SBFile::SBFile(lldb::FileSP)\n");
+ " lldb::SBFile::SBFile(lldb::FileSP)\n"
+ " lldb::SBFile::SBFile(int,char const *,bool)\n");
lua_error(L);return 0;
}
-static int _wrap_SBFile_MakeBorrowed(lua_State* L) {
- {
- int SWIG_arg = 0;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
- lldb::SBFile result;
-
- SWIG_check_num_args("lldb::SBFile::lldb_SBFile_MakeBorrowed",1,1)
- {
- luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
- lldb::FileSP file_sp;
- file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
- if (!file_sp->IsValid())
- return luaL_error(L, "Invalid file");
- arg1 = file_sp;
- }
- result = lldb_SBFile_MakeBorrowed(SWIG_STD_MOVE(arg1));
- {
- lldb::SBFile * resultptr = new lldb::SBFile(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBFile_MakeForcingIOMethods(lua_State* L) {
- {
- int SWIG_arg = 0;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
- lldb::SBFile result;
-
- SWIG_check_num_args("lldb::SBFile::lldb_SBFile_MakeForcingIOMethods",1,1)
- {
- luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
- lldb::FileSP file_sp;
- file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
- if (!file_sp->IsValid())
- return luaL_error(L, "Invalid file");
- arg1 = file_sp;
- }
- result = lldb_SBFile_MakeForcingIOMethods(SWIG_STD_MOVE(arg1));
- {
- lldb::SBFile * resultptr = new lldb::SBFile(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBFile_MakeBorrowedForcingIOMethods(lua_State* L) {
- {
- int SWIG_arg = 0;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
- lldb::SBFile result;
-
- SWIG_check_num_args("lldb::SBFile::lldb_SBFile_MakeBorrowedForcingIOMethods",1,1)
- {
- luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
- lldb::FileSP file_sp;
- file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
- if (!file_sp->IsValid())
- return luaL_error(L, "Invalid file");
- arg1 = file_sp;
- }
- result = lldb_SBFile_MakeBorrowedForcingIOMethods(SWIG_STD_MOVE(arg1));
- {
- lldb::SBFile * resultptr = new lldb::SBFile(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBFile_Read(lua_State* L) {
{
int SWIG_arg = 0;
@@ -26142,6 +28811,7 @@ static int _wrap_SBFile_Flush(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBFile *arg1 = (lldb::SBFile *) 0 ;
+ lldb::SBError result;
SWIG_check_num_args("lldb::SBFile::Flush",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFile::Flush",1,"lldb::SBFile *");
@@ -26150,8 +28820,11 @@ static int _wrap_SBFile_Flush(lua_State* L) {
SWIG_fail_ptr("SBFile_Flush",1,SWIGTYPE_p_lldb__SBFile);
}
- (arg1)->Flush();
-
+ result = (arg1)->Flush();
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -26219,13 +28892,13 @@ static int _wrap_SBFile_GetFile(lua_State* L) {
SwigValueWrapper< std::shared_ptr< lldb_private::File > > result;
SWIG_check_num_args("lldb::SBFile::GetFile",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFile::GetFile",1,"lldb::SBFile *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFile::GetFile",1,"lldb::SBFile const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFile,0))){
SWIG_fail_ptr("SBFile_GetFile",1,SWIGTYPE_p_lldb__SBFile);
}
- result = (arg1)->GetFile();
+ result = ((lldb::SBFile const *)arg1)->GetFile();
{
lldb::FileSP sp = result;
if (sp && sp->IsValid()) {
@@ -26245,6 +28918,93 @@ static int _wrap_SBFile_GetFile(lua_State* L) {
}
+static int _wrap_SBFile_MakeBorrowed(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
+ lldb::SBFile result;
+
+ SWIG_check_num_args("lldb::SBFile::lldb_SBFile_MakeBorrowed",1,1)
+ {
+ luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
+ lldb::FileSP file_sp;
+ file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
+ if (!file_sp->IsValid())
+ return luaL_error(L, "Invalid file");
+ arg1 = file_sp;
+ }
+ result = lldb_SBFile_MakeBorrowed(SWIG_STD_MOVE(arg1));
+ {
+ lldb::SBFile * resultptr = new lldb::SBFile(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBFile_MakeForcingIOMethods(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
+ lldb::SBFile result;
+
+ SWIG_check_num_args("lldb::SBFile::lldb_SBFile_MakeForcingIOMethods",1,1)
+ {
+ luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
+ lldb::FileSP file_sp;
+ file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
+ if (!file_sp->IsValid())
+ return luaL_error(L, "Invalid file");
+ arg1 = file_sp;
+ }
+ result = lldb_SBFile_MakeForcingIOMethods(SWIG_STD_MOVE(arg1));
+ {
+ lldb::SBFile * resultptr = new lldb::SBFile(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBFile_MakeBorrowedForcingIOMethods(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg1 ;
+ lldb::SBFile result;
+
+ SWIG_check_num_args("lldb::SBFile::lldb_SBFile_MakeBorrowedForcingIOMethods",1,1)
+ {
+ luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE);
+ lldb::FileSP file_sp;
+ file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
+ if (!file_sp->IsValid())
+ return luaL_error(L, "Invalid file");
+ arg1 = file_sp;
+ }
+ result = lldb_SBFile_MakeBorrowedForcingIOMethods(SWIG_STD_MOVE(arg1));
+ {
+ lldb::SBFile * resultptr = new lldb::SBFile(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFile,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBFile(void *obj) {
lldb::SBFile *arg1 = (lldb::SBFile *) obj;
delete arg1;
@@ -27125,6 +29885,30 @@ static int _wrap_SBFileSpecList_GetFileSpecAtIndex(lua_State* L) {
}
+static int _wrap_SBFileSpecList___tostring(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBFileSpecList *arg1 = (lldb::SBFileSpecList *) 0 ;
+ std::string result;
+
+ SWIG_check_num_args("lldb::SBFileSpecList::__repr__",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFileSpecList::__repr__",1,"lldb::SBFileSpecList *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFileSpecList,0))){
+ SWIG_fail_ptr("SBFileSpecList___tostring",1,SWIGTYPE_p_lldb__SBFileSpecList);
+ }
+
+ result = lldb_SBFileSpecList___repr__(arg1);
+ lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBFileSpecList(void *obj) {
lldb::SBFileSpecList *arg1 = (lldb::SBFileSpecList *) obj;
delete arg1;
@@ -27148,9 +29932,11 @@ static swig_lua_method swig_SBFileSpecList_methods[]= {
{ "Clear", _wrap_SBFileSpecList_Clear},
{ "FindFileIndex", _wrap_SBFileSpecList_FindFileIndex},
{ "GetFileSpecAtIndex", _wrap_SBFileSpecList_GetFileSpecAtIndex},
+ { "__tostring", _wrap_SBFileSpecList___tostring},
{0,0}
};
static swig_lua_method swig_SBFileSpecList_meta[] = {
+ { "__tostring", _wrap_SBFileSpecList___tostring},
{0,0}
};
@@ -27179,6 +29965,174 @@ static swig_lua_class *swig_SBFileSpecList_bases[] = {0};
static const char *swig_SBFileSpecList_base_names[] = {0};
static swig_lua_class _wrap_class_SBFileSpecList = { "SBFileSpecList", "SBFileSpecList", &SWIGTYPE_p_lldb__SBFileSpecList,_proxy__wrap_new_SBFileSpecList, swig_delete_SBFileSpecList, swig_SBFileSpecList_methods, swig_SBFileSpecList_attributes, &swig_SBFileSpecList_Sf_SwigStatic, swig_SBFileSpecList_meta, swig_SBFileSpecList_bases, swig_SBFileSpecList_base_names };
+static int _wrap_new_SBFormat__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBFormat *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBFormat::SBFormat",0,0)
+ result = (lldb::SBFormat *)new lldb::SBFormat();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBFormat,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBFormat__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *arg1 = (char *) 0 ;
+ lldb::SBError *arg2 = 0 ;
+ lldb::SBFormat *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBFormat::SBFormat",2,2)
+ if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("lldb::SBFormat::SBFormat",1,"char const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBFormat::SBFormat",2,"lldb::SBError &");
+ arg1 = (char *)lua_tostring(L, 1);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("new_SBFormat",2,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (lldb::SBFormat *)new lldb::SBFormat((char const *)arg1,*arg2);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBFormat,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBFormat__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBFormat *arg1 = 0 ;
+ lldb::SBFormat *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBFormat::SBFormat",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBFormat::SBFormat",1,"lldb::SBFormat const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFormat,0))){
+ SWIG_fail_ptr("new_SBFormat",1,SWIGTYPE_p_lldb__SBFormat);
+ }
+
+ result = (lldb::SBFormat *)new lldb::SBFormat((lldb::SBFormat const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBFormat,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBFormat(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBFormat__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBFormat, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBFormat__SWIG_2(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ _v = SWIG_lua_isnilstring(L,argv[0]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBFormat__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBFormat'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBFormat::SBFormat()\n"
+ " lldb::SBFormat::SBFormat(char const *,lldb::SBError &)\n"
+ " lldb::SBFormat::SBFormat(lldb::SBFormat const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static void swig_delete_SBFormat(void *obj) {
+lldb::SBFormat *arg1 = (lldb::SBFormat *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBFormat(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBFormat);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBFormat_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBFormat_methods[]= {
+ {0,0}
+};
+static swig_lua_method swig_SBFormat_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBFormat_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBFormat_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBFormat_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBFormat_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBFormat_Sf_SwigStatic = {
+ "SBFormat",
+ swig_SBFormat_Sf_SwigStatic_methods,
+ swig_SBFormat_Sf_SwigStatic_attributes,
+ swig_SBFormat_Sf_SwigStatic_constants,
+ swig_SBFormat_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBFormat_bases[] = {0};
+static const char *swig_SBFormat_base_names[] = {0};
+static swig_lua_class _wrap_class_SBFormat = { "SBFormat", "SBFormat", &SWIGTYPE_p_lldb__SBFormat,_proxy__wrap_new_SBFormat, swig_delete_SBFormat, swig_SBFormat_methods, swig_SBFormat_attributes, &swig_SBFormat_Sf_SwigStatic, swig_SBFormat_meta, swig_SBFormat_bases, swig_SBFormat_base_names };
+
static int _wrap_new_SBFrame__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -28081,7 +31035,7 @@ static int _wrap_SBFrame_EvaluateExpression__SWIG_3(lua_State* L) {
SWIG_check_num_args("lldb::SBFrame::EvaluateExpression",3,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFrame::EvaluateExpression",1,"lldb::SBFrame *");
if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFrame::EvaluateExpression",2,"char const *");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBFrame::EvaluateExpression",3,"lldb::SBExpressionOptions &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBFrame::EvaluateExpression",3,"lldb::SBExpressionOptions const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFrame,0))){
SWIG_fail_ptr("SBFrame_EvaluateExpression",1,SWIGTYPE_p_lldb__SBFrame);
@@ -28093,7 +31047,7 @@ static int _wrap_SBFrame_EvaluateExpression__SWIG_3(lua_State* L) {
SWIG_fail_ptr("SBFrame_EvaluateExpression",3,SWIGTYPE_p_lldb__SBExpressionOptions);
}
- result = (arg1)->EvaluateExpression((char const *)arg2,*arg3);
+ result = (arg1)->EvaluateExpression((char const *)arg2,(lldb::SBExpressionOptions const &)*arg3);
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -28221,7 +31175,7 @@ static int _wrap_SBFrame_EvaluateExpression(lua_State* L) {
" lldb::SBFrame::EvaluateExpression(char const *)\n"
" lldb::SBFrame::EvaluateExpression(char const *,lldb::DynamicValueType)\n"
" lldb::SBFrame::EvaluateExpression(char const *,lldb::DynamicValueType,bool)\n"
- " lldb::SBFrame::EvaluateExpression(char const *,lldb::SBExpressionOptions &)\n");
+ " lldb::SBFrame::EvaluateExpression(char const *,lldb::SBExpressionOptions const &)\n");
lua_error(L);return 0;
}
@@ -28641,6 +31595,36 @@ static int _wrap_SBFrame_GetRegisters(lua_State* L) {
}
+static int _wrap_SBFrame_FindRegister(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBFrame *arg1 = (lldb::SBFrame *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBValue result;
+
+ SWIG_check_num_args("lldb::SBFrame::FindRegister",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFrame::FindRegister",1,"lldb::SBFrame *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFrame::FindRegister",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFrame,0))){
+ SWIG_fail_ptr("SBFrame_FindRegister",1,SWIGTYPE_p_lldb__SBFrame);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->FindRegister((char const *)arg2);
+ {
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBFrame_FindVariable__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -28763,53 +31747,26 @@ static int _wrap_SBFrame_FindVariable(lua_State* L) {
}
-static int _wrap_SBFrame_FindRegister(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBFrame *arg1 = (lldb::SBFrame *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBValue result;
-
- SWIG_check_num_args("lldb::SBFrame::FindRegister",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFrame::FindRegister",1,"lldb::SBFrame *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFrame::FindRegister",2,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFrame,0))){
- SWIG_fail_ptr("SBFrame_FindRegister",1,SWIGTYPE_p_lldb__SBFrame);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->FindRegister((char const *)arg2);
- {
- lldb::SBValue * resultptr = new lldb::SBValue(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBFrame_GetValueForVariablePath__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBFrame *arg1 = (lldb::SBFrame *) 0 ;
char *arg2 = (char *) 0 ;
+ lldb::DynamicValueType arg3 ;
lldb::SBValue result;
- SWIG_check_num_args("lldb::SBFrame::GetValueForVariablePath",2,2)
+ SWIG_check_num_args("lldb::SBFrame::GetValueForVariablePath",3,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFrame::GetValueForVariablePath",1,"lldb::SBFrame *");
if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFrame::GetValueForVariablePath",2,"char const *");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBFrame::GetValueForVariablePath",3,"lldb::DynamicValueType");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFrame,0))){
SWIG_fail_ptr("SBFrame_GetValueForVariablePath",1,SWIGTYPE_p_lldb__SBFrame);
}
arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->GetValueForVariablePath((char const *)arg2);
+ arg3 = (lldb::DynamicValueType)lua_tointeger(L, 3);
+ result = (arg1)->GetValueForVariablePath((char const *)arg2,arg3);
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -28828,21 +31785,18 @@ static int _wrap_SBFrame_GetValueForVariablePath__SWIG_1(lua_State* L) {
int SWIG_arg = 0;
lldb::SBFrame *arg1 = (lldb::SBFrame *) 0 ;
char *arg2 = (char *) 0 ;
- lldb::DynamicValueType arg3 ;
lldb::SBValue result;
- SWIG_check_num_args("lldb::SBFrame::GetValueForVariablePath",3,3)
+ SWIG_check_num_args("lldb::SBFrame::GetValueForVariablePath",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFrame::GetValueForVariablePath",1,"lldb::SBFrame *");
if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBFrame::GetValueForVariablePath",2,"char const *");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBFrame::GetValueForVariablePath",3,"lldb::DynamicValueType");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFrame,0))){
SWIG_fail_ptr("SBFrame_GetValueForVariablePath",1,SWIGTYPE_p_lldb__SBFrame);
}
arg2 = (char *)lua_tostring(L, 2);
- arg3 = (lldb::DynamicValueType)lua_tointeger(L, 3);
- result = (arg1)->GetValueForVariablePath((char const *)arg2,arg3);
+ result = (arg1)->GetValueForVariablePath((char const *)arg2);
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -28878,7 +31832,7 @@ static int _wrap_SBFrame_GetValueForVariablePath(lua_State* L) {
_v = SWIG_lua_isnilstring(L,argv[1]);
}
if (_v) {
- return _wrap_SBFrame_GetValueForVariablePath__SWIG_0(L);
+ return _wrap_SBFrame_GetValueForVariablePath__SWIG_1(L);
}
}
}
@@ -28901,7 +31855,7 @@ static int _wrap_SBFrame_GetValueForVariablePath(lua_State* L) {
_v = lua_isnumber(L,argv[2]);
}
if (_v) {
- return _wrap_SBFrame_GetValueForVariablePath__SWIG_1(L);
+ return _wrap_SBFrame_GetValueForVariablePath__SWIG_0(L);
}
}
}
@@ -28909,8 +31863,8 @@ static int _wrap_SBFrame_GetValueForVariablePath(lua_State* L) {
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBFrame_GetValueForVariablePath'\n"
" Possible C/C++ prototypes are:\n"
- " lldb::SBFrame::GetValueForVariablePath(char const *)\n"
- " lldb::SBFrame::GetValueForVariablePath(char const *,lldb::DynamicValueType)\n");
+ " lldb::SBFrame::GetValueForVariablePath(char const *,lldb::DynamicValueType)\n"
+ " lldb::SBFrame::GetValueForVariablePath(char const *)\n");
lua_error(L);return 0;
}
@@ -29084,6 +32038,47 @@ static int _wrap_SBFrame_GetDescription(lua_State* L) {
}
+static int _wrap_SBFrame_GetDescriptionWithFormat(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBFrame *arg1 = (lldb::SBFrame *) 0 ;
+ lldb::SBFormat *arg2 = 0 ;
+ lldb::SBStream *arg3 = 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBFrame::GetDescriptionWithFormat",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFrame::GetDescriptionWithFormat",1,"lldb::SBFrame *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBFrame::GetDescriptionWithFormat",2,"lldb::SBFormat const &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBFrame::GetDescriptionWithFormat",3,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFrame,0))){
+ SWIG_fail_ptr("SBFrame_GetDescriptionWithFormat",1,SWIGTYPE_p_lldb__SBFrame);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFormat,0))){
+ SWIG_fail_ptr("SBFrame_GetDescriptionWithFormat",2,SWIGTYPE_p_lldb__SBFormat);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBFrame_GetDescriptionWithFormat",3,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (arg1)->GetDescriptionWithFormat((lldb::SBFormat const &)*arg2,*arg3);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBFrame___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -29153,11 +32148,12 @@ static swig_lua_method swig_SBFrame_methods[]= {
{ "__eq", _wrap_SBFrame___eq},
{ "GetVariables", _wrap_SBFrame_GetVariables},
{ "GetRegisters", _wrap_SBFrame_GetRegisters},
- { "FindVariable", _wrap_SBFrame_FindVariable},
{ "FindRegister", _wrap_SBFrame_FindRegister},
+ { "FindVariable", _wrap_SBFrame_FindVariable},
{ "GetValueForVariablePath", _wrap_SBFrame_GetValueForVariablePath},
{ "FindValue", _wrap_SBFrame_FindValue},
{ "GetDescription", _wrap_SBFrame_GetDescription},
+ { "GetDescriptionWithFormat", _wrap_SBFrame_GetDescriptionWithFormat},
{ "__tostring", _wrap_SBFrame___tostring},
{0,0}
};
@@ -29560,6 +32556,33 @@ static int _wrap_SBFunction_GetEndAddress(lua_State* L) {
}
+static int _wrap_SBFunction_GetRanges(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBFunction *arg1 = (lldb::SBFunction *) 0 ;
+ lldb::SBAddressRangeList result;
+
+ SWIG_check_num_args("lldb::SBFunction::GetRanges",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFunction::GetRanges",1,"lldb::SBFunction *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFunction,0))){
+ SWIG_fail_ptr("SBFunction_GetRanges",1,SWIGTYPE_p_lldb__SBFunction);
+ }
+
+ result = (arg1)->GetRanges();
+ {
+ lldb::SBAddressRangeList * resultptr = new lldb::SBAddressRangeList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddressRangeList,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBFunction_GetArgumentName(lua_State* L) {
{
int SWIG_arg = 0;
@@ -29713,27 +32736,27 @@ static int _wrap_SBFunction_GetIsOptimized(lua_State* L) {
}
-static int _wrap_SBFunction_GetDescription(lua_State* L) {
+static int _wrap_SBFunction___eq(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBFunction *arg1 = (lldb::SBFunction *) 0 ;
- lldb::SBStream *arg2 = 0 ;
+ lldb::SBFunction *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBFunction::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFunction::GetDescription",1,"lldb::SBFunction *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBFunction::GetDescription",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBFunction::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFunction::operator ==",1,"lldb::SBFunction const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBFunction::operator ==",2,"lldb::SBFunction const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFunction,0))){
- SWIG_fail_ptr("SBFunction_GetDescription",1,SWIGTYPE_p_lldb__SBFunction);
+ SWIG_fail_ptr("SBFunction___eq",1,SWIGTYPE_p_lldb__SBFunction);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBFunction_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFunction,0))){
+ SWIG_fail_ptr("SBFunction___eq",2,SWIGTYPE_p_lldb__SBFunction);
}
- result = (bool)(arg1)->GetDescription(*arg2);
+ result = (bool)((lldb::SBFunction const *)arg1)->operator ==((lldb::SBFunction const &)*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -29744,27 +32767,27 @@ static int _wrap_SBFunction_GetDescription(lua_State* L) {
}
-static int _wrap_SBFunction___eq(lua_State* L) {
+static int _wrap_SBFunction_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBFunction *arg1 = (lldb::SBFunction *) 0 ;
- lldb::SBFunction *arg2 = 0 ;
+ lldb::SBStream *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBFunction::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFunction::operator ==",1,"lldb::SBFunction const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBFunction::operator ==",2,"lldb::SBFunction const &");
+ SWIG_check_num_args("lldb::SBFunction::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBFunction::GetDescription",1,"lldb::SBFunction *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBFunction::GetDescription",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBFunction,0))){
- SWIG_fail_ptr("SBFunction___eq",1,SWIGTYPE_p_lldb__SBFunction);
+ SWIG_fail_ptr("SBFunction_GetDescription",1,SWIGTYPE_p_lldb__SBFunction);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFunction,0))){
- SWIG_fail_ptr("SBFunction___eq",2,SWIGTYPE_p_lldb__SBFunction);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBFunction_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
}
- result = (bool)((lldb::SBFunction const *)arg1)->operator ==((lldb::SBFunction const &)*arg2);
+ result = (bool)(arg1)->GetDescription(*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -29822,14 +32845,15 @@ static swig_lua_method swig_SBFunction_methods[]= {
{ "GetInstructions", _wrap_SBFunction_GetInstructions},
{ "GetStartAddress", _wrap_SBFunction_GetStartAddress},
{ "GetEndAddress", _wrap_SBFunction_GetEndAddress},
+ { "GetRanges", _wrap_SBFunction_GetRanges},
{ "GetArgumentName", _wrap_SBFunction_GetArgumentName},
{ "GetPrologueByteSize", _wrap_SBFunction_GetPrologueByteSize},
{ "GetType", _wrap_SBFunction_GetType},
{ "GetBlock", _wrap_SBFunction_GetBlock},
{ "GetLanguage", _wrap_SBFunction_GetLanguage},
{ "GetIsOptimized", _wrap_SBFunction_GetIsOptimized},
- { "GetDescription", _wrap_SBFunction_GetDescription},
{ "__eq", _wrap_SBFunction___eq},
+ { "GetDescription", _wrap_SBFunction_GetDescription},
{ "__tostring", _wrap_SBFunction___tostring},
{0,0}
};
@@ -31065,7 +34089,7 @@ static int _wrap_SBInstructionList_GetInstructionAtIndex(lua_State* L) {
}
-static int _wrap_SBInstructionList_GetInstructionsCount(lua_State* L) {
+static int _wrap_SBInstructionList_GetInstructionsCount__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBInstructionList *arg1 = (lldb::SBInstructionList *) 0 ;
@@ -31106,6 +34130,133 @@ static int _wrap_SBInstructionList_GetInstructionsCount(lua_State* L) {
}
+static int _wrap_SBInstructionList_GetInstructionsCount__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBInstructionList *arg1 = (lldb::SBInstructionList *) 0 ;
+ lldb::SBAddress *arg2 = 0 ;
+ lldb::SBAddress *arg3 = 0 ;
+ size_t result;
+
+ SWIG_check_num_args("lldb::SBInstructionList::GetInstructionsCount",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBInstructionList::GetInstructionsCount",1,"lldb::SBInstructionList *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBInstructionList::GetInstructionsCount",2,"lldb::SBAddress const &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBInstructionList::GetInstructionsCount",3,"lldb::SBAddress const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBInstructionList,0))){
+ SWIG_fail_ptr("SBInstructionList_GetInstructionsCount",1,SWIGTYPE_p_lldb__SBInstructionList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBInstructionList_GetInstructionsCount",2,SWIGTYPE_p_lldb__SBAddress);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBInstructionList_GetInstructionsCount",3,SWIGTYPE_p_lldb__SBAddress);
+ }
+
+ result = (arg1)->GetInstructionsCount((lldb::SBAddress const &)*arg2,(lldb::SBAddress const &)*arg3);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBInstructionList_GetInstructionsCount(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBInstructionList, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBInstructionList_GetInstructionsCount__SWIG_1(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBInstructionList, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_SBInstructionList_GetInstructionsCount__SWIG_0(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBInstructionList_GetInstructionsCount'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBInstructionList::GetInstructionsCount(lldb::SBAddress const &,lldb::SBAddress const &,bool)\n"
+ " lldb::SBInstructionList::GetInstructionsCount(lldb::SBAddress const &,lldb::SBAddress const &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBInstructionList_Clear(lua_State* L) {
{
int SWIG_arg = 0;
@@ -31465,6 +34616,146 @@ static int _wrap_SBLanguageRuntime_GetNameForLanguageType(lua_State* L) {
}
+static int _wrap_SBLanguageRuntime_LanguageIsCPlusPlus(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::LanguageIsCPlusPlus",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::LanguageIsCPlusPlus",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (bool)lldb::SBLanguageRuntime::LanguageIsCPlusPlus(arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLanguageRuntime_LanguageIsObjC(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::LanguageIsObjC",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::LanguageIsObjC",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (bool)lldb::SBLanguageRuntime::LanguageIsObjC(arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLanguageRuntime_LanguageIsCFamily(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::LanguageIsCFamily",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::LanguageIsCFamily",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (bool)lldb::SBLanguageRuntime::LanguageIsCFamily(arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLanguageRuntime_SupportsExceptionBreakpointsOnThrow(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnThrow",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnThrow",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (bool)lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnThrow(arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLanguageRuntime_SupportsExceptionBreakpointsOnCatch(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (bool)lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch(arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLanguageRuntime_GetThrowKeywordForLanguage(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::GetThrowKeywordForLanguage",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::GetThrowKeywordForLanguage",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (char *)lldb::SBLanguageRuntime::GetThrowKeywordForLanguage(arg1);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLanguageRuntime_GetCatchKeywordForLanguage(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::LanguageType arg1 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBLanguageRuntime::GetCatchKeywordForLanguage",1,1)
+ if(!lua_isinteger(L,1)) SWIG_fail_arg("lldb::SBLanguageRuntime::GetCatchKeywordForLanguage",1,"lldb::LanguageType");
+ arg1 = (lldb::LanguageType)lua_tointeger(L, 1);
+ result = (char *)lldb::SBLanguageRuntime::GetCatchKeywordForLanguage(arg1);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_new_SBLanguageRuntime(lua_State* L) {
{
int SWIG_arg = 0;
@@ -31513,6 +34804,13 @@ static swig_lua_const_info swig_SBLanguageRuntime_Sf_SwigStatic_constants[]= {
static swig_lua_method swig_SBLanguageRuntime_Sf_SwigStatic_methods[]= {
{ "GetLanguageTypeFromString", _wrap_SBLanguageRuntime_GetLanguageTypeFromString},
{ "GetNameForLanguageType", _wrap_SBLanguageRuntime_GetNameForLanguageType},
+ { "LanguageIsCPlusPlus", _wrap_SBLanguageRuntime_LanguageIsCPlusPlus},
+ { "LanguageIsObjC", _wrap_SBLanguageRuntime_LanguageIsObjC},
+ { "LanguageIsCFamily", _wrap_SBLanguageRuntime_LanguageIsCFamily},
+ { "SupportsExceptionBreakpointsOnThrow", _wrap_SBLanguageRuntime_SupportsExceptionBreakpointsOnThrow},
+ { "SupportsExceptionBreakpointsOnCatch", _wrap_SBLanguageRuntime_SupportsExceptionBreakpointsOnCatch},
+ { "GetThrowKeywordForLanguage", _wrap_SBLanguageRuntime_GetThrowKeywordForLanguage},
+ { "GetCatchKeywordForLanguage", _wrap_SBLanguageRuntime_GetCatchKeywordForLanguage},
{0,0}
};
static swig_lua_class* swig_SBLanguageRuntime_Sf_SwigStatic_classes[]= {
@@ -31869,6 +35167,63 @@ static int _wrap_SBLaunchInfo_SetListener(lua_State* L) {
}
+static int _wrap_SBLaunchInfo_GetShadowListener(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBLaunchInfo *arg1 = (lldb::SBLaunchInfo *) 0 ;
+ lldb::SBListener result;
+
+ SWIG_check_num_args("lldb::SBLaunchInfo::GetShadowListener",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBLaunchInfo::GetShadowListener",1,"lldb::SBLaunchInfo *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBLaunchInfo,0))){
+ SWIG_fail_ptr("SBLaunchInfo_GetShadowListener",1,SWIGTYPE_p_lldb__SBLaunchInfo);
+ }
+
+ result = (arg1)->GetShadowListener();
+ {
+ lldb::SBListener * resultptr = new lldb::SBListener(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBListener,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBLaunchInfo_SetShadowListener(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBLaunchInfo *arg1 = (lldb::SBLaunchInfo *) 0 ;
+ lldb::SBListener *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBLaunchInfo::SetShadowListener",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBLaunchInfo::SetShadowListener",1,"lldb::SBLaunchInfo *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBLaunchInfo::SetShadowListener",2,"lldb::SBListener &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBLaunchInfo,0))){
+ SWIG_fail_ptr("SBLaunchInfo_SetShadowListener",1,SWIGTYPE_p_lldb__SBLaunchInfo);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBListener,0))){
+ SWIG_fail_ptr("SBLaunchInfo_SetShadowListener",2,SWIGTYPE_p_lldb__SBListener);
+ }
+
+ (arg1)->SetShadowListener(*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBLaunchInfo_GetNumArguments(lua_State* L) {
{
int SWIG_arg = 0;
@@ -32828,6 +36183,8 @@ static swig_lua_method swig_SBLaunchInfo_methods[]= {
{ "SetExecutableFile", _wrap_SBLaunchInfo_SetExecutableFile},
{ "GetListener", _wrap_SBLaunchInfo_GetListener},
{ "SetListener", _wrap_SBLaunchInfo_SetListener},
+ { "GetShadowListener", _wrap_SBLaunchInfo_GetShadowListener},
+ { "SetShadowListener", _wrap_SBLaunchInfo_SetShadowListener},
{ "GetNumArguments", _wrap_SBLaunchInfo_GetNumArguments},
{ "GetArgumentAtIndex", _wrap_SBLaunchInfo_GetArgumentAtIndex},
{ "SetArguments", _wrap_SBLaunchInfo_SetArguments},
@@ -33020,6 +36377,36 @@ static int _wrap_SBLineEntry_GetEndAddress(lua_State* L) {
}
+static int _wrap_SBLineEntry_GetSameLineContiguousAddressRangeEnd(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBLineEntry *arg1 = (lldb::SBLineEntry *) 0 ;
+ bool arg2 ;
+ lldb::SBAddress result;
+
+ SWIG_check_num_args("lldb::SBLineEntry::GetSameLineContiguousAddressRangeEnd",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBLineEntry::GetSameLineContiguousAddressRangeEnd",1,"lldb::SBLineEntry const *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBLineEntry::GetSameLineContiguousAddressRangeEnd",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBLineEntry,0))){
+ SWIG_fail_ptr("SBLineEntry_GetSameLineContiguousAddressRangeEnd",1,SWIGTYPE_p_lldb__SBLineEntry);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ result = ((lldb::SBLineEntry const *)arg1)->GetSameLineContiguousAddressRangeEnd(arg2);
+ {
+ lldb::SBAddress * resultptr = new lldb::SBAddress(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddress,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBLineEntry_IsValid(lua_State* L) {
{
int SWIG_arg = 0;
@@ -33119,37 +36506,6 @@ static int _wrap_SBLineEntry_GetColumn(lua_State* L) {
}
-static int _wrap_SBLineEntry_GetDescription(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBLineEntry *arg1 = (lldb::SBLineEntry *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBLineEntry::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBLineEntry::GetDescription",1,"lldb::SBLineEntry *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBLineEntry::GetDescription",2,"lldb::SBStream &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBLineEntry,0))){
- SWIG_fail_ptr("SBLineEntry_GetDescription",1,SWIGTYPE_p_lldb__SBLineEntry);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBLineEntry_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- result = (bool)(arg1)->GetDescription(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBLineEntry_SetFileSpec(lua_State* L) {
{
int SWIG_arg = 0;
@@ -33265,6 +36621,37 @@ static int _wrap_SBLineEntry___eq(lua_State* L) {
}
+static int _wrap_SBLineEntry_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBLineEntry *arg1 = (lldb::SBLineEntry *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBLineEntry::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBLineEntry::GetDescription",1,"lldb::SBLineEntry *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBLineEntry::GetDescription",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBLineEntry,0))){
+ SWIG_fail_ptr("SBLineEntry_GetDescription",1,SWIGTYPE_p_lldb__SBLineEntry);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBLineEntry_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBLineEntry___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -33307,15 +36694,16 @@ static swig_lua_attribute swig_SBLineEntry_attributes[] = {
static swig_lua_method swig_SBLineEntry_methods[]= {
{ "GetStartAddress", _wrap_SBLineEntry_GetStartAddress},
{ "GetEndAddress", _wrap_SBLineEntry_GetEndAddress},
+ { "GetSameLineContiguousAddressRangeEnd", _wrap_SBLineEntry_GetSameLineContiguousAddressRangeEnd},
{ "IsValid", _wrap_SBLineEntry_IsValid},
{ "GetFileSpec", _wrap_SBLineEntry_GetFileSpec},
{ "GetLine", _wrap_SBLineEntry_GetLine},
{ "GetColumn", _wrap_SBLineEntry_GetColumn},
- { "GetDescription", _wrap_SBLineEntry_GetDescription},
{ "SetFileSpec", _wrap_SBLineEntry_SetFileSpec},
{ "SetLine", _wrap_SBLineEntry_SetLine},
{ "SetColumn", _wrap_SBLineEntry_SetColumn},
{ "__eq", _wrap_SBLineEntry___eq},
+ { "GetDescription", _wrap_SBLineEntry_GetDescription},
{ "__tostring", _wrap_SBLineEntry___tostring},
{0,0}
};
@@ -33575,7 +36963,7 @@ static int _wrap_SBListener_StopListeningForEventClass(lua_State* L) {
lldb::SBDebugger *arg2 = 0 ;
char *arg3 = (char *) 0 ;
uint32_t arg4 ;
- uint32_t result;
+ bool result;
SWIG_check_num_args("lldb::SBListener::StopListeningForEventClass",4,4)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBListener::StopListeningForEventClass",1,"lldb::SBListener *");
@@ -33594,8 +36982,8 @@ static int _wrap_SBListener_StopListeningForEventClass(lua_State* L) {
arg3 = (char *)lua_tostring(L, 3);
arg4 = (uint32_t)lua_tointeger(L, 4);
- result = (uint32_t)(arg1)->StopListeningForEventClass(*arg2,(char const *)arg3,arg4);
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ result = (bool)(arg1)->StopListeningForEventClass(*arg2,(char const *)arg3,arg4);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -34183,6 +37571,38 @@ static int _wrap_new_SBMemoryRegionInfo__SWIG_2(lua_State* L) {
}
+static int _wrap_new_SBMemoryRegionInfo__SWIG_3(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *arg1 = (char *) 0 ;
+ lldb::addr_t arg2 ;
+ lldb::addr_t arg3 ;
+ uint32_t arg4 ;
+ bool arg5 ;
+ lldb::SBMemoryRegionInfo *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBMemoryRegionInfo::SBMemoryRegionInfo",5,5)
+ if(!SWIG_lua_isnilstring(L,1)) SWIG_fail_arg("lldb::SBMemoryRegionInfo::SBMemoryRegionInfo",1,"char const *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBMemoryRegionInfo::SBMemoryRegionInfo",2,"lldb::addr_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBMemoryRegionInfo::SBMemoryRegionInfo",3,"lldb::addr_t");
+ if(!lua_isinteger(L,4)) SWIG_fail_arg("lldb::SBMemoryRegionInfo::SBMemoryRegionInfo",4,"uint32_t");
+ if(!lua_isboolean(L,5)) SWIG_fail_arg("lldb::SBMemoryRegionInfo::SBMemoryRegionInfo",5,"bool");
+ arg1 = (char *)lua_tostring(L, 1);
+ arg2 = (lldb::addr_t)lua_tointeger(L, 2);
+ arg3 = (lldb::addr_t)lua_tointeger(L, 3);
+ arg4 = (uint32_t)lua_tointeger(L, 4);
+ arg5 = (lua_toboolean(L, 5)!=0);
+ result = (lldb::SBMemoryRegionInfo *)new lldb::SBMemoryRegionInfo((char const *)arg1,arg2,arg3,arg4,arg5);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBMemoryRegionInfo,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_new_SBMemoryRegionInfo(lua_State* L) {
int argc;
int argv[7]={
@@ -34207,6 +37627,35 @@ static int _wrap_new_SBMemoryRegionInfo(lua_State* L) {
return _wrap_new_SBMemoryRegionInfo__SWIG_1(L);
}
}
+ if (argc == 5) {
+ int _v = 0;
+ {
+ _v = SWIG_lua_isnilstring(L,argv[0]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[4]);
+ }
+ if (_v) {
+ return _wrap_new_SBMemoryRegionInfo__SWIG_3(L);
+ }
+ }
+ }
+ }
+ }
+ }
if (argc == 6) {
int _v = 0;
{
@@ -34246,7 +37695,8 @@ static int _wrap_new_SBMemoryRegionInfo(lua_State* L) {
" Possible C/C++ prototypes are:\n"
" lldb::SBMemoryRegionInfo::SBMemoryRegionInfo()\n"
" lldb::SBMemoryRegionInfo::SBMemoryRegionInfo(lldb::SBMemoryRegionInfo const &)\n"
- " lldb::SBMemoryRegionInfo::SBMemoryRegionInfo(char const *,lldb::addr_t,lldb::addr_t,uint32_t,bool,bool)\n");
+ " lldb::SBMemoryRegionInfo::SBMemoryRegionInfo(char const *,lldb::addr_t,lldb::addr_t,uint32_t,bool,bool)\n"
+ " lldb::SBMemoryRegionInfo::SBMemoryRegionInfo(char const *,lldb::addr_t,lldb::addr_t,uint32_t,bool)\n");
lua_error(L);return 0;
}
@@ -35430,6 +38880,102 @@ static int _wrap_SBModule_SetRemoteInstallFileSpec(lua_State* L) {
}
+static int _wrap_SBModule_GetByteOrder(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
+ lldb::ByteOrder result;
+
+ SWIG_check_num_args("lldb::SBModule::GetByteOrder",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetByteOrder",1,"lldb::SBModule *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBModule_GetByteOrder",1,SWIGTYPE_p_lldb__SBModule);
+ }
+
+ result = (lldb::ByteOrder)(arg1)->GetByteOrder();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModule_GetAddressByteSize(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
+ uint32_t result;
+
+ SWIG_check_num_args("lldb::SBModule::GetAddressByteSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetAddressByteSize",1,"lldb::SBModule *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBModule_GetAddressByteSize",1,SWIGTYPE_p_lldb__SBModule);
+ }
+
+ result = (uint32_t)(arg1)->GetAddressByteSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModule_GetTriple(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBModule::GetTriple",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetTriple",1,"lldb::SBModule *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBModule_GetTriple",1,SWIGTYPE_p_lldb__SBModule);
+ }
+
+ result = (char *)(arg1)->GetTriple();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModule_GetUUIDBytes(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
+ uint8_t *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBModule::GetUUIDBytes",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetUUIDBytes",1,"lldb::SBModule const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBModule_GetUUIDBytes",1,SWIGTYPE_p_lldb__SBModule);
+ }
+
+ result = (uint8_t *)((lldb::SBModule const *)arg1)->GetUUIDBytes();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_unsigned_char,0); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBModule_GetUUIDString(lua_State* L) {
{
int SWIG_arg = 0;
@@ -36175,6 +39721,83 @@ static int _wrap_SBModule_FindFunctions(lua_State* L) {
}
+static int _wrap_SBModule_FindGlobalVariables(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
+ lldb::SBTarget *arg2 = 0 ;
+ char *arg3 = (char *) 0 ;
+ uint32_t arg4 ;
+ lldb::SBValueList result;
+
+ SWIG_check_num_args("lldb::SBModule::FindGlobalVariables",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",1,"lldb::SBModule *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",2,"lldb::SBTarget &");
+ if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",3,"char const *");
+ if(!lua_isinteger(L,4)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",4,"uint32_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBModule_FindGlobalVariables",1,SWIGTYPE_p_lldb__SBModule);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBModule_FindGlobalVariables",2,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg3 = (char *)lua_tostring(L, 3);
+ arg4 = (uint32_t)lua_tointeger(L, 4);
+ result = (arg1)->FindGlobalVariables(*arg2,(char const *)arg3,arg4);
+ {
+ lldb::SBValueList * resultptr = new lldb::SBValueList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValueList,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModule_FindFirstGlobalVariable(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
+ lldb::SBTarget *arg2 = 0 ;
+ char *arg3 = (char *) 0 ;
+ lldb::SBValue result;
+
+ SWIG_check_num_args("lldb::SBModule::FindFirstGlobalVariable",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::FindFirstGlobalVariable",1,"lldb::SBModule *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBModule::FindFirstGlobalVariable",2,"lldb::SBTarget &");
+ if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("lldb::SBModule::FindFirstGlobalVariable",3,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBModule_FindFirstGlobalVariable",1,SWIGTYPE_p_lldb__SBModule);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBModule_FindFirstGlobalVariable",2,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg3 = (char *)lua_tostring(L, 3);
+ result = (arg1)->FindFirstGlobalVariable(*arg2,(char const *)arg3);
+ {
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBModule_FindFirstType(lua_State* L) {
{
int SWIG_arg = 0;
@@ -36401,155 +40024,6 @@ static int _wrap_SBModule_GetTypes(lua_State* L) {
}
-static int _wrap_SBModule_FindGlobalVariables(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
- lldb::SBTarget *arg2 = 0 ;
- char *arg3 = (char *) 0 ;
- uint32_t arg4 ;
- lldb::SBValueList result;
-
- SWIG_check_num_args("lldb::SBModule::FindGlobalVariables",4,4)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",1,"lldb::SBModule *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",2,"lldb::SBTarget &");
- if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",3,"char const *");
- if(!lua_isinteger(L,4)) SWIG_fail_arg("lldb::SBModule::FindGlobalVariables",4,"uint32_t");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
- SWIG_fail_ptr("SBModule_FindGlobalVariables",1,SWIGTYPE_p_lldb__SBModule);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBModule_FindGlobalVariables",2,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg3 = (char *)lua_tostring(L, 3);
- arg4 = (uint32_t)lua_tointeger(L, 4);
- result = (arg1)->FindGlobalVariables(*arg2,(char const *)arg3,arg4);
- {
- lldb::SBValueList * resultptr = new lldb::SBValueList(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValueList,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBModule_FindFirstGlobalVariable(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
- lldb::SBTarget *arg2 = 0 ;
- char *arg3 = (char *) 0 ;
- lldb::SBValue result;
-
- SWIG_check_num_args("lldb::SBModule::FindFirstGlobalVariable",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::FindFirstGlobalVariable",1,"lldb::SBModule *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBModule::FindFirstGlobalVariable",2,"lldb::SBTarget &");
- if(!SWIG_lua_isnilstring(L,3)) SWIG_fail_arg("lldb::SBModule::FindFirstGlobalVariable",3,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
- SWIG_fail_ptr("SBModule_FindFirstGlobalVariable",1,SWIGTYPE_p_lldb__SBModule);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBModule_FindFirstGlobalVariable",2,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg3 = (char *)lua_tostring(L, 3);
- result = (arg1)->FindFirstGlobalVariable(*arg2,(char const *)arg3);
- {
- lldb::SBValue * resultptr = new lldb::SBValue(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBModule_GetByteOrder(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
- lldb::ByteOrder result;
-
- SWIG_check_num_args("lldb::SBModule::GetByteOrder",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetByteOrder",1,"lldb::SBModule *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
- SWIG_fail_ptr("SBModule_GetByteOrder",1,SWIGTYPE_p_lldb__SBModule);
- }
-
- result = (lldb::ByteOrder)(arg1)->GetByteOrder();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBModule_GetAddressByteSize(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
- uint32_t result;
-
- SWIG_check_num_args("lldb::SBModule::GetAddressByteSize",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetAddressByteSize",1,"lldb::SBModule *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
- SWIG_fail_ptr("SBModule_GetAddressByteSize",1,SWIGTYPE_p_lldb__SBModule);
- }
-
- result = (uint32_t)(arg1)->GetAddressByteSize();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBModule_GetTriple(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBModule *arg1 = (lldb::SBModule *) 0 ;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBModule::GetTriple",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModule::GetTriple",1,"lldb::SBModule *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModule,0))){
- SWIG_fail_ptr("SBModule_GetTriple",1,SWIGTYPE_p_lldb__SBModule);
- }
-
- result = (char *)(arg1)->GetTriple();
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBModule_GetVersion(lua_State* L) {
{
int SWIG_arg = 0;
@@ -36755,6 +40229,10 @@ static swig_lua_method swig_SBModule_methods[]= {
{ "SetPlatformFileSpec", _wrap_SBModule_SetPlatformFileSpec},
{ "GetRemoteInstallFileSpec", _wrap_SBModule_GetRemoteInstallFileSpec},
{ "SetRemoteInstallFileSpec", _wrap_SBModule_SetRemoteInstallFileSpec},
+ { "GetByteOrder", _wrap_SBModule_GetByteOrder},
+ { "GetAddressByteSize", _wrap_SBModule_GetAddressByteSize},
+ { "GetTriple", _wrap_SBModule_GetTriple},
+ { "GetUUIDBytes", _wrap_SBModule_GetUUIDBytes},
{ "GetUUIDString", _wrap_SBModule_GetUUIDString},
{ "__eq", _wrap_SBModule___eq},
{ "FindSection", _wrap_SBModule_FindSection},
@@ -36771,16 +40249,13 @@ static swig_lua_method swig_SBModule_methods[]= {
{ "GetNumSections", _wrap_SBModule_GetNumSections},
{ "GetSectionAtIndex", _wrap_SBModule_GetSectionAtIndex},
{ "FindFunctions", _wrap_SBModule_FindFunctions},
+ { "FindGlobalVariables", _wrap_SBModule_FindGlobalVariables},
+ { "FindFirstGlobalVariable", _wrap_SBModule_FindFirstGlobalVariable},
{ "FindFirstType", _wrap_SBModule_FindFirstType},
{ "FindTypes", _wrap_SBModule_FindTypes},
{ "GetTypeByID", _wrap_SBModule_GetTypeByID},
{ "GetBasicType", _wrap_SBModule_GetBasicType},
{ "GetTypes", _wrap_SBModule_GetTypes},
- { "FindGlobalVariables", _wrap_SBModule_FindGlobalVariables},
- { "FindFirstGlobalVariable", _wrap_SBModule_FindFirstGlobalVariable},
- { "GetByteOrder", _wrap_SBModule_GetByteOrder},
- { "GetAddressByteSize", _wrap_SBModule_GetAddressByteSize},
- { "GetTriple", _wrap_SBModule_GetTriple},
{ "GetVersion", _wrap_SBModule_GetVersion},
{ "GetSymbolFileSpec", _wrap_SBModule_GetSymbolFileSpec},
{ "GetObjectFileHeaderAddress", _wrap_SBModule_GetObjectFileHeaderAddress},
@@ -37295,6 +40770,106 @@ static int _wrap_SBModuleSpec_SetUUIDBytes(lua_State* L) {
}
+static int _wrap_SBModuleSpec_GetObjectOffset(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModuleSpec *arg1 = (lldb::SBModuleSpec *) 0 ;
+ uint64_t result;
+
+ SWIG_check_num_args("lldb::SBModuleSpec::GetObjectOffset",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModuleSpec::GetObjectOffset",1,"lldb::SBModuleSpec *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModuleSpec,0))){
+ SWIG_fail_ptr("SBModuleSpec_GetObjectOffset",1,SWIGTYPE_p_lldb__SBModuleSpec);
+ }
+
+ result = (uint64_t)(arg1)->GetObjectOffset();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModuleSpec_SetObjectOffset(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModuleSpec *arg1 = (lldb::SBModuleSpec *) 0 ;
+ uint64_t arg2 ;
+
+ SWIG_check_num_args("lldb::SBModuleSpec::SetObjectOffset",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModuleSpec::SetObjectOffset",1,"lldb::SBModuleSpec *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBModuleSpec::SetObjectOffset",2,"uint64_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModuleSpec,0))){
+ SWIG_fail_ptr("SBModuleSpec_SetObjectOffset",1,SWIGTYPE_p_lldb__SBModuleSpec);
+ }
+
+ arg2 = (uint64_t)lua_tointeger(L, 2);
+ (arg1)->SetObjectOffset(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModuleSpec_GetObjectSize(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModuleSpec *arg1 = (lldb::SBModuleSpec *) 0 ;
+ uint64_t result;
+
+ SWIG_check_num_args("lldb::SBModuleSpec::GetObjectSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModuleSpec::GetObjectSize",1,"lldb::SBModuleSpec *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModuleSpec,0))){
+ SWIG_fail_ptr("SBModuleSpec_GetObjectSize",1,SWIGTYPE_p_lldb__SBModuleSpec);
+ }
+
+ result = (uint64_t)(arg1)->GetObjectSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBModuleSpec_SetObjectSize(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBModuleSpec *arg1 = (lldb::SBModuleSpec *) 0 ;
+ uint64_t arg2 ;
+
+ SWIG_check_num_args("lldb::SBModuleSpec::SetObjectSize",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBModuleSpec::SetObjectSize",1,"lldb::SBModuleSpec *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBModuleSpec::SetObjectSize",2,"uint64_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBModuleSpec,0))){
+ SWIG_fail_ptr("SBModuleSpec_SetObjectSize",1,SWIGTYPE_p_lldb__SBModuleSpec);
+ }
+
+ arg2 = (uint64_t)lua_tointeger(L, 2);
+ (arg1)->SetObjectSize(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBModuleSpec_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
@@ -37381,6 +40956,10 @@ static swig_lua_method swig_SBModuleSpec_methods[]= {
{ "GetUUIDBytes", _wrap_SBModuleSpec_GetUUIDBytes},
{ "GetUUIDLength", _wrap_SBModuleSpec_GetUUIDLength},
{ "SetUUIDBytes", _wrap_SBModuleSpec_SetUUIDBytes},
+ { "GetObjectOffset", _wrap_SBModuleSpec_GetObjectOffset},
+ { "SetObjectOffset", _wrap_SBModuleSpec_SetObjectOffset},
+ { "GetObjectSize", _wrap_SBModuleSpec_GetObjectSize},
+ { "SetObjectSize", _wrap_SBModuleSpec_SetObjectSize},
{ "GetDescription", _wrap_SBModuleSpec_GetDescription},
{ "__tostring", _wrap_SBModuleSpec___tostring},
{0,0}
@@ -38697,6 +42276,30 @@ static int _wrap_new_SBPlatform__SWIG_1(lua_State* L) {
}
+static int _wrap_new_SBPlatform__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBPlatform *arg1 = 0 ;
+ lldb::SBPlatform *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBPlatform::SBPlatform",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBPlatform::SBPlatform",1,"lldb::SBPlatform const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
+ SWIG_fail_ptr("new_SBPlatform",1,SWIGTYPE_p_lldb__SBPlatform);
+ }
+
+ result = (lldb::SBPlatform *)new lldb::SBPlatform((lldb::SBPlatform const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBPlatform,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_new_SBPlatform(lua_State* L) {
int argc;
int argv[2]={
@@ -38710,6 +42313,20 @@ static int _wrap_new_SBPlatform(lua_State* L) {
if (argc == 1) {
int _v = 0;
{
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBPlatform, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBPlatform__SWIG_2(L);
+ }
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
_v = SWIG_lua_isnilstring(L,argv[0]);
}
if (_v) {
@@ -38720,7 +42337,8 @@ static int _wrap_new_SBPlatform(lua_State* L) {
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBPlatform'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBPlatform::SBPlatform()\n"
- " lldb::SBPlatform::SBPlatform(char const *)\n");
+ " lldb::SBPlatform::SBPlatform(char const *)\n"
+ " lldb::SBPlatform::SBPlatform(lldb::SBPlatform const &)\n");
lua_error(L);return 0;
}
@@ -39142,7 +42760,7 @@ static int _wrap_SBPlatform_SetSDKRoot(lua_State* L) {
}
-static int _wrap_SBPlatform_Get(lua_State* L) {
+static int _wrap_SBPlatform_Put(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBPlatform *arg1 = (lldb::SBPlatform *) 0 ;
@@ -39150,26 +42768,26 @@ static int _wrap_SBPlatform_Get(lua_State* L) {
lldb::SBFileSpec *arg3 = 0 ;
lldb::SBError result;
- SWIG_check_num_args("lldb::SBPlatform::Get",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::Get",1,"lldb::SBPlatform *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBPlatform::Get",2,"lldb::SBFileSpec &");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBPlatform::Get",3,"lldb::SBFileSpec &");
+ SWIG_check_num_args("lldb::SBPlatform::Put",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::Put",1,"lldb::SBPlatform *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBPlatform::Put",2,"lldb::SBFileSpec &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBPlatform::Put",3,"lldb::SBFileSpec &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
- SWIG_fail_ptr("SBPlatform_Get",1,SWIGTYPE_p_lldb__SBPlatform);
+ SWIG_fail_ptr("SBPlatform_Put",1,SWIGTYPE_p_lldb__SBPlatform);
}
if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFileSpec,0))){
- SWIG_fail_ptr("SBPlatform_Get",2,SWIGTYPE_p_lldb__SBFileSpec);
+ SWIG_fail_ptr("SBPlatform_Put",2,SWIGTYPE_p_lldb__SBFileSpec);
}
if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBFileSpec,0))){
- SWIG_fail_ptr("SBPlatform_Get",3,SWIGTYPE_p_lldb__SBFileSpec);
+ SWIG_fail_ptr("SBPlatform_Put",3,SWIGTYPE_p_lldb__SBFileSpec);
}
- result = (arg1)->Get(*arg2,*arg3);
+ result = (arg1)->Put(*arg2,*arg3);
{
lldb::SBError * resultptr = new lldb::SBError(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
@@ -39183,7 +42801,7 @@ static int _wrap_SBPlatform_Get(lua_State* L) {
}
-static int _wrap_SBPlatform_Put(lua_State* L) {
+static int _wrap_SBPlatform_Get(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBPlatform *arg1 = (lldb::SBPlatform *) 0 ;
@@ -39191,26 +42809,26 @@ static int _wrap_SBPlatform_Put(lua_State* L) {
lldb::SBFileSpec *arg3 = 0 ;
lldb::SBError result;
- SWIG_check_num_args("lldb::SBPlatform::Put",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::Put",1,"lldb::SBPlatform *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBPlatform::Put",2,"lldb::SBFileSpec &");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBPlatform::Put",3,"lldb::SBFileSpec &");
+ SWIG_check_num_args("lldb::SBPlatform::Get",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::Get",1,"lldb::SBPlatform *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBPlatform::Get",2,"lldb::SBFileSpec &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBPlatform::Get",3,"lldb::SBFileSpec &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
- SWIG_fail_ptr("SBPlatform_Put",1,SWIGTYPE_p_lldb__SBPlatform);
+ SWIG_fail_ptr("SBPlatform_Get",1,SWIGTYPE_p_lldb__SBPlatform);
}
if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFileSpec,0))){
- SWIG_fail_ptr("SBPlatform_Put",2,SWIGTYPE_p_lldb__SBFileSpec);
+ SWIG_fail_ptr("SBPlatform_Get",2,SWIGTYPE_p_lldb__SBFileSpec);
}
if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBFileSpec,0))){
- SWIG_fail_ptr("SBPlatform_Put",3,SWIGTYPE_p_lldb__SBFileSpec);
+ SWIG_fail_ptr("SBPlatform_Get",3,SWIGTYPE_p_lldb__SBFileSpec);
}
- result = (arg1)->Put(*arg2,*arg3);
+ result = (arg1)->Get(*arg2,*arg3);
{
lldb::SBError * resultptr = new lldb::SBError(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
@@ -39333,6 +42951,95 @@ static int _wrap_SBPlatform_Launch(lua_State* L) {
}
+static int _wrap_SBPlatform_Attach(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBPlatform *arg1 = (lldb::SBPlatform *) 0 ;
+ lldb::SBAttachInfo *arg2 = 0 ;
+ lldb::SBDebugger *arg3 = 0 ;
+ lldb::SBTarget *arg4 = 0 ;
+ lldb::SBError *arg5 = 0 ;
+ lldb::SBProcess result;
+
+ SWIG_check_num_args("lldb::SBPlatform::Attach",5,5)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::Attach",1,"lldb::SBPlatform *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBPlatform::Attach",2,"lldb::SBAttachInfo &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBPlatform::Attach",3,"lldb::SBDebugger const &");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBPlatform::Attach",4,"lldb::SBTarget &");
+ if(!lua_isuserdata(L,5)) SWIG_fail_arg("lldb::SBPlatform::Attach",5,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
+ SWIG_fail_ptr("SBPlatform_Attach",1,SWIGTYPE_p_lldb__SBPlatform);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAttachInfo,0))){
+ SWIG_fail_ptr("SBPlatform_Attach",2,SWIGTYPE_p_lldb__SBAttachInfo);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBPlatform_Attach",3,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBPlatform_Attach",4,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBPlatform_Attach",5,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->Attach(*arg2,(lldb::SBDebugger const &)*arg3,*arg4,*arg5);
+ {
+ lldb::SBProcess * resultptr = new lldb::SBProcess(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBPlatform_GetAllProcesses(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBPlatform *arg1 = (lldb::SBPlatform *) 0 ;
+ lldb::SBError *arg2 = 0 ;
+ lldb::SBProcessInfoList result;
+
+ SWIG_check_num_args("lldb::SBPlatform::GetAllProcesses",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::GetAllProcesses",1,"lldb::SBPlatform *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBPlatform::GetAllProcesses",2,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
+ SWIG_fail_ptr("SBPlatform_GetAllProcesses",1,SWIGTYPE_p_lldb__SBPlatform);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBPlatform_GetAllProcesses",2,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->GetAllProcesses(*arg2);
+ {
+ lldb::SBProcessInfoList * resultptr = new lldb::SBProcessInfoList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcessInfoList,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBPlatform_Kill(lua_State* L) {
{
int SWIG_arg = 0;
@@ -39552,13 +43259,13 @@ static int _wrap_SBPlatform_GetUnixSignals(lua_State* L) {
lldb::SBUnixSignals result;
SWIG_check_num_args("lldb::SBPlatform::GetUnixSignals",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::GetUnixSignals",1,"lldb::SBPlatform *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::GetUnixSignals",1,"lldb::SBPlatform const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
SWIG_fail_ptr("SBPlatform_GetUnixSignals",1,SWIGTYPE_p_lldb__SBPlatform);
}
- result = (arg1)->GetUnixSignals();
+ result = ((lldb::SBPlatform const *)arg1)->GetUnixSignals();
{
lldb::SBUnixSignals * resultptr = new lldb::SBUnixSignals(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBUnixSignals,1); SWIG_arg++;
@@ -39599,6 +43306,43 @@ static int _wrap_SBPlatform_GetEnvironment(lua_State* L) {
}
+static int _wrap_SBPlatform_SetLocateModuleCallback(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBPlatform *arg1 = (lldb::SBPlatform *) 0 ;
+ lldb::SBPlatformLocateModuleCallback arg2 = (lldb::SBPlatformLocateModuleCallback) 0 ;
+ void *arg3 = (void *) 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBPlatform::SetLocateModuleCallback",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBPlatform::SetLocateModuleCallback",1,"lldb::SBPlatform *");
+ if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("lldb::SBPlatform::SetLocateModuleCallback",2,"lldb::SBPlatformLocateModuleCallback");
+ if(!SWIG_isptrtype(L,3)) SWIG_fail_arg("lldb::SBPlatform::SetLocateModuleCallback",3,"void *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBPlatform,0))){
+ SWIG_fail_ptr("SBPlatform_SetLocateModuleCallback",1,SWIGTYPE_p_lldb__SBPlatform);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError,0))){
+ SWIG_fail_ptr("SBPlatform_SetLocateModuleCallback",2,SWIGTYPE_p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError);
+ }
+
+ arg3=(void *)SWIG_MustGetPtr(L,3,0,0,3,"SBPlatform_SetLocateModuleCallback");
+ result = (arg1)->SetLocateModuleCallback(arg2,arg3);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBPlatform(void *obj) {
lldb::SBPlatform *arg1 = (lldb::SBPlatform *) obj;
delete arg1;
@@ -39631,17 +43375,20 @@ static swig_lua_method swig_SBPlatform_methods[]= {
{ "GetOSMinorVersion", _wrap_SBPlatform_GetOSMinorVersion},
{ "GetOSUpdateVersion", _wrap_SBPlatform_GetOSUpdateVersion},
{ "SetSDKRoot", _wrap_SBPlatform_SetSDKRoot},
- { "Get", _wrap_SBPlatform_Get},
{ "Put", _wrap_SBPlatform_Put},
+ { "Get", _wrap_SBPlatform_Get},
{ "Install", _wrap_SBPlatform_Install},
{ "Run", _wrap_SBPlatform_Run},
{ "Launch", _wrap_SBPlatform_Launch},
+ { "Attach", _wrap_SBPlatform_Attach},
+ { "GetAllProcesses", _wrap_SBPlatform_GetAllProcesses},
{ "Kill", _wrap_SBPlatform_Kill},
{ "MakeDirectory", _wrap_SBPlatform_MakeDirectory},
{ "GetFilePermissions", _wrap_SBPlatform_GetFilePermissions},
{ "SetFilePermissions", _wrap_SBPlatform_SetFilePermissions},
{ "GetUnixSignals", _wrap_SBPlatform_GetUnixSignals},
{ "GetEnvironment", _wrap_SBPlatform_GetEnvironment},
+ { "SetLocateModuleCallback", _wrap_SBPlatform_SetLocateModuleCallback},
{0,0}
};
static swig_lua_method swig_SBPlatform_meta[] = {
@@ -40694,18 +44441,18 @@ static int _wrap_SBProcess_GetQueueAtIndex(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
- uint32_t arg2 ;
+ size_t arg2 ;
lldb::SBQueue result;
SWIG_check_num_args("lldb::SBProcess::GetQueueAtIndex",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetQueueAtIndex",1,"lldb::SBProcess *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::GetQueueAtIndex",2,"uint32_t");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::GetQueueAtIndex",2,"size_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
SWIG_fail_ptr("SBProcess_GetQueueAtIndex",1,SWIGTYPE_p_lldb__SBProcess);
}
- arg2 = (uint32_t)lua_tointeger(L, 2);
+ arg2 = (size_t)lua_tointeger(L, 2);
result = (arg1)->GetQueueAtIndex(arg2);
{
lldb::SBQueue * resultptr = new lldb::SBQueue(result);
@@ -40972,7 +44719,7 @@ static int _wrap_SBProcess_Kill(lua_State* L) {
}
-static int _wrap_SBProcess_Detach(lua_State* L) {
+static int _wrap_SBProcess_Detach__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
@@ -40999,6 +44746,85 @@ static int _wrap_SBProcess_Detach(lua_State* L) {
}
+static int _wrap_SBProcess_Detach__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ bool arg2 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBProcess::Detach",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::Detach",1,"lldb::SBProcess *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBProcess::Detach",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_Detach",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ result = (arg1)->Detach(arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_Detach(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBProcess_Detach__SWIG_0(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_Detach__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_Detach'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcess::Detach()\n"
+ " lldb::SBProcess::Detach(bool)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBProcess_Signal(lua_State* L) {
{
int SWIG_arg = 0;
@@ -41056,6 +44882,29 @@ static int _wrap_SBProcess_GetUnixSignals(lua_State* L) {
}
+static int _wrap_SBProcess_SendAsyncInterrupt(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+
+ SWIG_check_num_args("lldb::SBProcess::SendAsyncInterrupt",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SendAsyncInterrupt",1,"lldb::SBProcess *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_SendAsyncInterrupt",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ (arg1)->SendAsyncInterrupt();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBProcess_GetStopID__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -41156,19 +45005,52 @@ static int _wrap_SBProcess_GetStopID(lua_State* L) {
}
-static int _wrap_SBProcess_SendAsyncInterrupt(lua_State* L) {
+static int _wrap_SBProcess_GetStopEventForStopID(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ uint32_t arg2 ;
+ lldb::SBEvent result;
- SWIG_check_num_args("lldb::SBProcess::SendAsyncInterrupt",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SendAsyncInterrupt",1,"lldb::SBProcess *");
+ SWIG_check_num_args("lldb::SBProcess::GetStopEventForStopID",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetStopEventForStopID",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::GetStopEventForStopID",2,"uint32_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
- SWIG_fail_ptr("SBProcess_SendAsyncInterrupt",1,SWIGTYPE_p_lldb__SBProcess);
+ SWIG_fail_ptr("SBProcess_GetStopEventForStopID",1,SWIGTYPE_p_lldb__SBProcess);
}
- (arg1)->SendAsyncInterrupt();
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ result = (arg1)->GetStopEventForStopID(arg2);
+ {
+ lldb::SBEvent * resultptr = new lldb::SBEvent(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBEvent,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_ForceScriptedState(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::StateType arg2 ;
+
+ SWIG_check_num_args("lldb::SBProcess::ForceScriptedState",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::ForceScriptedState",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::ForceScriptedState",2,"lldb::StateType");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_ForceScriptedState",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::StateType)lua_tointeger(L, 2);
+ (arg1)->ForceScriptedState(arg2);
return SWIG_arg;
@@ -41395,6 +45277,106 @@ static int _wrap_SBProcess_ReadPointerFromMemory(lua_State* L) {
}
+static int _wrap_SBProcess_FindRangesInMemory(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ void *arg2 = (void *) 0 ;
+ uint64_t arg3 ;
+ lldb::SBAddressRangeList *arg4 = 0 ;
+ uint32_t arg5 ;
+ uint32_t arg6 ;
+ lldb::SBError *arg7 = 0 ;
+ lldb::SBAddressRangeList result;
+
+ SWIG_check_num_args("lldb::SBProcess::FindRangesInMemory",7,7)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",1,"lldb::SBProcess *");
+ if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",2,"void const *");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",3,"uint64_t");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",4,"lldb::SBAddressRangeList const &");
+ if(!lua_isinteger(L,5)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",5,"uint32_t");
+ if(!lua_isinteger(L,6)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",6,"uint32_t");
+ if(!lua_isuserdata(L,7)) SWIG_fail_arg("lldb::SBProcess::FindRangesInMemory",7,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_FindRangesInMemory",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"SBProcess_FindRangesInMemory");
+ arg3 = (uint64_t)lua_tointeger(L, 3);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBAddressRangeList,0))){
+ SWIG_fail_ptr("SBProcess_FindRangesInMemory",4,SWIGTYPE_p_lldb__SBAddressRangeList);
+ }
+
+ arg5 = (uint32_t)lua_tointeger(L, 5);
+ arg6 = (uint32_t)lua_tointeger(L, 6);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,7,(void**)&arg7,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBProcess_FindRangesInMemory",7,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->FindRangesInMemory((void const *)arg2,arg3,(lldb::SBAddressRangeList const &)*arg4,arg5,arg6,*arg7);
+ {
+ lldb::SBAddressRangeList * resultptr = new lldb::SBAddressRangeList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddressRangeList,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_FindInMemory(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ void *arg2 = (void *) 0 ;
+ uint64_t arg3 ;
+ lldb::SBAddressRange *arg4 = 0 ;
+ uint32_t arg5 ;
+ lldb::SBError *arg6 = 0 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBProcess::FindInMemory",6,6)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::FindInMemory",1,"lldb::SBProcess *");
+ if(!SWIG_isptrtype(L,2)) SWIG_fail_arg("lldb::SBProcess::FindInMemory",2,"void const *");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::FindInMemory",3,"uint64_t");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBProcess::FindInMemory",4,"lldb::SBAddressRange const &");
+ if(!lua_isinteger(L,5)) SWIG_fail_arg("lldb::SBProcess::FindInMemory",5,"uint32_t");
+ if(!lua_isuserdata(L,6)) SWIG_fail_arg("lldb::SBProcess::FindInMemory",6,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_FindInMemory",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2=(void *)SWIG_MustGetPtr(L,2,0,0,2,"SBProcess_FindInMemory");
+ arg3 = (uint64_t)lua_tointeger(L, 3);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBAddressRange,0))){
+ SWIG_fail_ptr("SBProcess_FindInMemory",4,SWIGTYPE_p_lldb__SBAddressRange);
+ }
+
+ arg5 = (uint32_t)lua_tointeger(L, 5);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,6,(void**)&arg6,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBProcess_FindInMemory",6,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (lldb::addr_t)(arg1)->FindInMemory((void const *)arg2,arg3,(lldb::SBAddressRange const &)*arg4,arg5,*arg6);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBProcess_GetStateFromEvent(lua_State* L) {
{
int SWIG_arg = 0;
@@ -41647,6 +45629,23 @@ static int _wrap_SBProcess_GetBroadcaster(lua_State* L) {
}
+static int _wrap_SBProcess_GetBroadcasterClass(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBProcess::GetBroadcasterClass",0,0)
+ result = (char *)lldb::SBProcess::GetBroadcasterClass();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBProcess_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
@@ -41736,7 +45735,7 @@ static int _wrap_SBProcess_GetNumSupportedHardwareWatchpoints(lua_State* L) {
}
-static int _wrap_SBProcess_LoadImage(lua_State* L) {
+static int _wrap_SBProcess_LoadImage__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
@@ -41774,6 +45773,145 @@ static int _wrap_SBProcess_LoadImage(lua_State* L) {
}
+static int _wrap_SBProcess_LoadImage__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::SBFileSpec *arg2 = 0 ;
+ lldb::SBFileSpec *arg3 = 0 ;
+ lldb::SBError *arg4 = 0 ;
+ uint32_t result;
+
+ SWIG_check_num_args("lldb::SBProcess::LoadImage",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::LoadImage",1,"lldb::SBProcess *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBProcess::LoadImage",2,"lldb::SBFileSpec const &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBProcess::LoadImage",3,"lldb::SBFileSpec const &");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBProcess::LoadImage",4,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_LoadImage",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFileSpec,0))){
+ SWIG_fail_ptr("SBProcess_LoadImage",2,SWIGTYPE_p_lldb__SBFileSpec);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBFileSpec,0))){
+ SWIG_fail_ptr("SBProcess_LoadImage",3,SWIGTYPE_p_lldb__SBFileSpec);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBProcess_LoadImage",4,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (uint32_t)(arg1)->LoadImage((lldb::SBFileSpec const &)*arg2,(lldb::SBFileSpec const &)*arg3,*arg4);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_LoadImage(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpec, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBProcess_LoadImage__SWIG_0(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpec, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpec, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[3])==0 || SWIG_ConvertPtr(L,argv[3], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBProcess_LoadImage__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_LoadImage'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcess::LoadImage(lldb::SBFileSpec &,lldb::SBError &)\n"
+ " lldb::SBProcess::LoadImage(lldb::SBFileSpec const &,lldb::SBFileSpec const &,lldb::SBError &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBProcess_LoadImageUsingPaths(lua_State* L) {
{
int SWIG_arg = 0;
@@ -42060,6 +46198,40 @@ static int _wrap_SBProcess_SaveCore__SWIG_1(lua_State* L) {
}
+static int _wrap_SBProcess_SaveCore__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::SBSaveCoreOptions *arg2 = 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBProcess::SaveCore",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SaveCore",1,"lldb::SBProcess *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBProcess::SaveCore",2,"lldb::SBSaveCoreOptions &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_SaveCore",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBSaveCoreOptions,0))){
+ SWIG_fail_ptr("SBProcess_SaveCore",2,SWIGTYPE_p_lldb__SBSaveCoreOptions);
+ }
+
+ result = (arg1)->SaveCore(*arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBProcess_SaveCore(lua_State* L) {
int argc;
int argv[5]={
@@ -42079,6 +46251,30 @@ static int _wrap_SBProcess_SaveCore(lua_State* L) {
}
if (_v) {
{
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBSaveCoreOptions, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBProcess_SaveCore__SWIG_2(L);
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
_v = SWIG_lua_isnilstring(L,argv[1]);
}
if (_v) {
@@ -42119,7 +46315,8 @@ static int _wrap_SBProcess_SaveCore(lua_State* L) {
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_SaveCore'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBProcess::SaveCore(char const *,char const *,lldb::SaveCoreStyle)\n"
- " lldb::SBProcess::SaveCore(char const *)\n");
+ " lldb::SBProcess::SaveCore(char const *)\n"
+ " lldb::SBProcess::SaveCore(lldb::SBSaveCoreOptions &)\n");
lua_error(L);return 0;
}
@@ -42215,6 +46412,525 @@ static int _wrap_SBProcess_GetProcessInfo(lua_State* L) {
}
+static int _wrap_SBProcess_GetCoreFile(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::SBFileSpec result;
+
+ SWIG_check_num_args("lldb::SBProcess::GetCoreFile",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetCoreFile",1,"lldb::SBProcess *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_GetCoreFile",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ result = (arg1)->GetCoreFile();
+ {
+ lldb::SBFileSpec * resultptr = new lldb::SBFileSpec(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFileSpec,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_GetAddressMask__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::AddressMaskType arg2 ;
+ lldb::AddressMaskRange arg3 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBProcess::GetAddressMask",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetAddressMask",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::GetAddressMask",2,"lldb::AddressMaskType");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::GetAddressMask",3,"lldb::AddressMaskRange");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_GetAddressMask",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::AddressMaskType)lua_tointeger(L, 2);
+ arg3 = (lldb::AddressMaskRange)lua_tointeger(L, 3);
+ result = (lldb::addr_t)(arg1)->GetAddressMask(arg2,arg3);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_GetAddressMask__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::AddressMaskType arg2 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBProcess::GetAddressMask",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetAddressMask",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::GetAddressMask",2,"lldb::AddressMaskType");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_GetAddressMask",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::AddressMaskType)lua_tointeger(L, 2);
+ result = (lldb::addr_t)(arg1)->GetAddressMask(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_GetAddressMask(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_GetAddressMask__SWIG_1(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_GetAddressMask__SWIG_0(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_GetAddressMask'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcess::GetAddressMask(lldb::AddressMaskType,lldb::AddressMaskRange)\n"
+ " lldb::SBProcess::GetAddressMask(lldb::AddressMaskType)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBProcess_SetAddressMask__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::AddressMaskType arg2 ;
+ lldb::addr_t arg3 ;
+ lldb::AddressMaskRange arg4 ;
+
+ SWIG_check_num_args("lldb::SBProcess::SetAddressMask",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",2,"lldb::AddressMaskType");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",3,"lldb::addr_t");
+ if(!lua_isinteger(L,4)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",4,"lldb::AddressMaskRange");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_SetAddressMask",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::AddressMaskType)lua_tointeger(L, 2);
+ arg3 = (lldb::addr_t)lua_tointeger(L, 3);
+ arg4 = (lldb::AddressMaskRange)lua_tointeger(L, 4);
+ (arg1)->SetAddressMask(arg2,arg3,arg4);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_SetAddressMask__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::AddressMaskType arg2 ;
+ lldb::addr_t arg3 ;
+
+ SWIG_check_num_args("lldb::SBProcess::SetAddressMask",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",2,"lldb::AddressMaskType");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::SetAddressMask",3,"lldb::addr_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_SetAddressMask",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::AddressMaskType)lua_tointeger(L, 2);
+ arg3 = (lldb::addr_t)lua_tointeger(L, 3);
+ (arg1)->SetAddressMask(arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_SetAddressMask(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_SetAddressMask__SWIG_1(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_SetAddressMask__SWIG_0(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_SetAddressMask'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcess::SetAddressMask(lldb::AddressMaskType,lldb::addr_t,lldb::AddressMaskRange)\n"
+ " lldb::SBProcess::SetAddressMask(lldb::AddressMaskType,lldb::addr_t)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBProcess_SetAddressableBits__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::AddressMaskType arg2 ;
+ uint32_t arg3 ;
+ lldb::AddressMaskRange arg4 ;
+
+ SWIG_check_num_args("lldb::SBProcess::SetAddressableBits",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",2,"lldb::AddressMaskType");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",3,"uint32_t");
+ if(!lua_isinteger(L,4)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",4,"lldb::AddressMaskRange");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_SetAddressableBits",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::AddressMaskType)lua_tointeger(L, 2);
+ arg3 = (uint32_t)lua_tointeger(L, 3);
+ arg4 = (lldb::AddressMaskRange)lua_tointeger(L, 4);
+ (arg1)->SetAddressableBits(arg2,arg3,arg4);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_SetAddressableBits__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::AddressMaskType arg2 ;
+ uint32_t arg3 ;
+
+ SWIG_check_num_args("lldb::SBProcess::SetAddressableBits",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",2,"lldb::AddressMaskType");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::SetAddressableBits",3,"uint32_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_SetAddressableBits",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::AddressMaskType)lua_tointeger(L, 2);
+ arg3 = (uint32_t)lua_tointeger(L, 3);
+ (arg1)->SetAddressableBits(arg2,arg3);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_SetAddressableBits(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_SetAddressableBits__SWIG_1(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_SetAddressableBits__SWIG_0(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_SetAddressableBits'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcess::SetAddressableBits(lldb::AddressMaskType,uint32_t,lldb::AddressMaskRange)\n"
+ " lldb::SBProcess::SetAddressableBits(lldb::AddressMaskType,uint32_t)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBProcess_FixAddress__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::addr_t arg2 ;
+ lldb::AddressMaskType arg3 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBProcess::FixAddress",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::FixAddress",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::FixAddress",2,"lldb::addr_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBProcess::FixAddress",3,"lldb::AddressMaskType");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_FixAddress",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::addr_t)lua_tointeger(L, 2);
+ arg3 = (lldb::AddressMaskType)lua_tointeger(L, 3);
+ result = (lldb::addr_t)(arg1)->FixAddress(arg2,arg3);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_FixAddress__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::addr_t arg2 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBProcess::FixAddress",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::FixAddress",1,"lldb::SBProcess *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcess::FixAddress",2,"lldb::addr_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_FixAddress",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ arg2 = (lldb::addr_t)lua_tointeger(L, 2);
+ result = (lldb::addr_t)(arg1)->FixAddress(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_FixAddress(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_FixAddress__SWIG_1(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcess, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBProcess_FixAddress__SWIG_0(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBProcess_FixAddress'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcess::FixAddress(lldb::addr_t,lldb::AddressMaskType)\n"
+ " lldb::SBProcess::FixAddress(lldb::addr_t)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBProcess_AllocateMemory(lua_State* L) {
{
int SWIG_arg = 0;
@@ -42282,6 +46998,63 @@ static int _wrap_SBProcess_DeallocateMemory(lua_State* L) {
}
+static int _wrap_SBProcess_GetScriptedImplementation(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ SwigValueWrapper< lldb::SBScriptObject > result;
+
+ SWIG_check_num_args("lldb::SBProcess::GetScriptedImplementation",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetScriptedImplementation",1,"lldb::SBProcess *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_GetScriptedImplementation",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+ result = (arg1)->GetScriptedImplementation();
+ {
+ lldb::SBScriptObject * resultptr = new lldb::SBScriptObject(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBScriptObject,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcess_GetStatus(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcess *arg1 = (lldb::SBProcess *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBProcess::GetStatus",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcess::GetStatus",1,"lldb::SBProcess *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBProcess::GetStatus",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcess,0))){
+ SWIG_fail_ptr("SBProcess_GetStatus",1,SWIGTYPE_p_lldb__SBProcess);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBProcess_GetStatus",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ (arg1)->GetStatus(*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBProcess___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -42360,13 +47133,17 @@ static swig_lua_method swig_SBProcess_methods[]= {
{ "Detach", _wrap_SBProcess_Detach},
{ "Signal", _wrap_SBProcess_Signal},
{ "GetUnixSignals", _wrap_SBProcess_GetUnixSignals},
- { "GetStopID", _wrap_SBProcess_GetStopID},
{ "SendAsyncInterrupt", _wrap_SBProcess_SendAsyncInterrupt},
+ { "GetStopID", _wrap_SBProcess_GetStopID},
+ { "GetStopEventForStopID", _wrap_SBProcess_GetStopEventForStopID},
+ { "ForceScriptedState", _wrap_SBProcess_ForceScriptedState},
{ "ReadMemory", _wrap_SBProcess_ReadMemory},
{ "WriteMemory", _wrap_SBProcess_WriteMemory},
{ "ReadCStringFromMemory", _wrap_SBProcess_ReadCStringFromMemory},
{ "ReadUnsignedFromMemory", _wrap_SBProcess_ReadUnsignedFromMemory},
{ "ReadPointerFromMemory", _wrap_SBProcess_ReadPointerFromMemory},
+ { "FindRangesInMemory", _wrap_SBProcess_FindRangesInMemory},
+ { "FindInMemory", _wrap_SBProcess_FindInMemory},
{ "GetBroadcaster", _wrap_SBProcess_GetBroadcaster},
{ "GetDescription", _wrap_SBProcess_GetDescription},
{ "GetExtendedCrashInformation", _wrap_SBProcess_GetExtendedCrashInformation},
@@ -42383,8 +47160,15 @@ static swig_lua_method swig_SBProcess_methods[]= {
{ "GetMemoryRegionInfo", _wrap_SBProcess_GetMemoryRegionInfo},
{ "GetMemoryRegions", _wrap_SBProcess_GetMemoryRegions},
{ "GetProcessInfo", _wrap_SBProcess_GetProcessInfo},
+ { "GetCoreFile", _wrap_SBProcess_GetCoreFile},
+ { "GetAddressMask", _wrap_SBProcess_GetAddressMask},
+ { "SetAddressMask", _wrap_SBProcess_SetAddressMask},
+ { "SetAddressableBits", _wrap_SBProcess_SetAddressableBits},
+ { "FixAddress", _wrap_SBProcess_FixAddress},
{ "AllocateMemory", _wrap_SBProcess_AllocateMemory},
{ "DeallocateMemory", _wrap_SBProcess_DeallocateMemory},
+ { "GetScriptedImplementation", _wrap_SBProcess_GetScriptedImplementation},
+ { "GetStatus", _wrap_SBProcess_GetStatus},
{ "__tostring", _wrap_SBProcess___tostring},
{0,0}
};
@@ -42397,12 +47181,12 @@ static swig_lua_attribute swig_SBProcess_Sf_SwigStatic_attributes[] = {
{0,0,0}
};
static swig_lua_const_info swig_SBProcess_Sf_SwigStatic_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitStateChanged", lldb::SBProcess::eBroadcastBitStateChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitInterrupt", lldb::SBProcess::eBroadcastBitInterrupt)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSTDOUT", lldb::SBProcess::eBroadcastBitSTDOUT)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSTDERR", lldb::SBProcess::eBroadcastBitSTDERR)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProfileData", lldb::SBProcess::eBroadcastBitProfileData)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitStructuredData", lldb::SBProcess::eBroadcastBitStructuredData)},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitStateChanged", (lldb::SBProcess::eBroadcastBitStateChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitInterrupt", (lldb::SBProcess::eBroadcastBitInterrupt))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSTDOUT", (lldb::SBProcess::eBroadcastBitSTDOUT))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSTDERR", (lldb::SBProcess::eBroadcastBitSTDERR))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProfileData", (lldb::SBProcess::eBroadcastBitProfileData))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitStructuredData", (lldb::SBProcess::eBroadcastBitStructuredData))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBProcess_Sf_SwigStatic_methods[]= {
@@ -42416,6 +47200,7 @@ static swig_lua_method swig_SBProcess_Sf_SwigStatic_methods[]= {
{ "GetStructuredDataFromEvent", _wrap_SBProcess_GetStructuredDataFromEvent},
{ "EventIsProcessEvent", _wrap_SBProcess_EventIsProcessEvent},
{ "EventIsStructuredDataEvent", _wrap_SBProcess_EventIsStructuredDataEvent},
+ { "GetBroadcasterClass", _wrap_SBProcess_GetBroadcasterClass},
{0,0}
};
static swig_lua_class* swig_SBProcess_Sf_SwigStatic_classes[]= {
@@ -42515,13 +47300,13 @@ static int _wrap_SBProcessInfo_IsValid(lua_State* L) {
bool result;
SWIG_check_num_args("lldb::SBProcessInfo::IsValid",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcessInfo::IsValid",1,"lldb::SBProcessInfo *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcessInfo::IsValid",1,"lldb::SBProcessInfo const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcessInfo,0))){
SWIG_fail_ptr("SBProcessInfo_IsValid",1,SWIGTYPE_p_lldb__SBProcessInfo);
}
- result = (bool)(arg1)->IsValid();
+ result = (bool)((lldb::SBProcessInfo const *)arg1)->IsValid();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -42908,6 +47693,211 @@ static swig_lua_class *swig_SBProcessInfo_bases[] = {0};
static const char *swig_SBProcessInfo_base_names[] = {0};
static swig_lua_class _wrap_class_SBProcessInfo = { "SBProcessInfo", "SBProcessInfo", &SWIGTYPE_p_lldb__SBProcessInfo,_proxy__wrap_new_SBProcessInfo, swig_delete_SBProcessInfo, swig_SBProcessInfo_methods, swig_SBProcessInfo_attributes, &swig_SBProcessInfo_Sf_SwigStatic, swig_SBProcessInfo_meta, swig_SBProcessInfo_bases, swig_SBProcessInfo_base_names };
+static int _wrap_new_SBProcessInfoList__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcessInfoList *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBProcessInfoList::SBProcessInfoList",0,0)
+ result = (lldb::SBProcessInfoList *)new lldb::SBProcessInfoList();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBProcessInfoList,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBProcessInfoList__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcessInfoList *arg1 = 0 ;
+ lldb::SBProcessInfoList *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBProcessInfoList::SBProcessInfoList",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBProcessInfoList::SBProcessInfoList",1,"lldb::SBProcessInfoList const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcessInfoList,0))){
+ SWIG_fail_ptr("new_SBProcessInfoList",1,SWIGTYPE_p_lldb__SBProcessInfoList);
+ }
+
+ result = (lldb::SBProcessInfoList *)new lldb::SBProcessInfoList((lldb::SBProcessInfoList const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBProcessInfoList,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBProcessInfoList(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBProcessInfoList__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBProcessInfoList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBProcessInfoList__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBProcessInfoList'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBProcessInfoList::SBProcessInfoList()\n"
+ " lldb::SBProcessInfoList::SBProcessInfoList(lldb::SBProcessInfoList const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBProcessInfoList_GetSize(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcessInfoList *arg1 = (lldb::SBProcessInfoList *) 0 ;
+ uint32_t result;
+
+ SWIG_check_num_args("lldb::SBProcessInfoList::GetSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcessInfoList::GetSize",1,"lldb::SBProcessInfoList const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcessInfoList,0))){
+ SWIG_fail_ptr("SBProcessInfoList_GetSize",1,SWIGTYPE_p_lldb__SBProcessInfoList);
+ }
+
+ result = (uint32_t)((lldb::SBProcessInfoList const *)arg1)->GetSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcessInfoList_GetProcessInfoAtIndex(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcessInfoList *arg1 = (lldb::SBProcessInfoList *) 0 ;
+ uint32_t arg2 ;
+ lldb::SBProcessInfo *arg3 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBProcessInfoList::GetProcessInfoAtIndex",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcessInfoList::GetProcessInfoAtIndex",1,"lldb::SBProcessInfoList *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBProcessInfoList::GetProcessInfoAtIndex",2,"uint32_t");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBProcessInfoList::GetProcessInfoAtIndex",3,"lldb::SBProcessInfo &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcessInfoList,0))){
+ SWIG_fail_ptr("SBProcessInfoList_GetProcessInfoAtIndex",1,SWIGTYPE_p_lldb__SBProcessInfoList);
+ }
+
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBProcessInfo,0))){
+ SWIG_fail_ptr("SBProcessInfoList_GetProcessInfoAtIndex",3,SWIGTYPE_p_lldb__SBProcessInfo);
+ }
+
+ result = (bool)(arg1)->GetProcessInfoAtIndex(arg2,*arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBProcessInfoList_Clear(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBProcessInfoList *arg1 = (lldb::SBProcessInfoList *) 0 ;
+
+ SWIG_check_num_args("lldb::SBProcessInfoList::Clear",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBProcessInfoList::Clear",1,"lldb::SBProcessInfoList *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBProcessInfoList,0))){
+ SWIG_fail_ptr("SBProcessInfoList_Clear",1,SWIGTYPE_p_lldb__SBProcessInfoList);
+ }
+
+ (arg1)->Clear();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBProcessInfoList(void *obj) {
+lldb::SBProcessInfoList *arg1 = (lldb::SBProcessInfoList *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBProcessInfoList(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBProcessInfoList);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBProcessInfoList_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBProcessInfoList_methods[]= {
+ { "GetSize", _wrap_SBProcessInfoList_GetSize},
+ { "GetProcessInfoAtIndex", _wrap_SBProcessInfoList_GetProcessInfoAtIndex},
+ { "Clear", _wrap_SBProcessInfoList_Clear},
+ {0,0}
+};
+static swig_lua_method swig_SBProcessInfoList_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBProcessInfoList_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBProcessInfoList_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBProcessInfoList_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBProcessInfoList_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBProcessInfoList_Sf_SwigStatic = {
+ "SBProcessInfoList",
+ swig_SBProcessInfoList_Sf_SwigStatic_methods,
+ swig_SBProcessInfoList_Sf_SwigStatic_attributes,
+ swig_SBProcessInfoList_Sf_SwigStatic_constants,
+ swig_SBProcessInfoList_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBProcessInfoList_bases[] = {0};
+static const char *swig_SBProcessInfoList_base_names[] = {0};
+static swig_lua_class _wrap_class_SBProcessInfoList = { "SBProcessInfoList", "SBProcessInfoList", &SWIGTYPE_p_lldb__SBProcessInfoList,_proxy__wrap_new_SBProcessInfoList, swig_delete_SBProcessInfoList, swig_SBProcessInfoList_methods, swig_SBProcessInfoList_attributes, &swig_SBProcessInfoList_Sf_SwigStatic, swig_SBProcessInfoList_meta, swig_SBProcessInfoList_bases, swig_SBProcessInfoList_base_names };
+
static int _wrap_new_SBQueue__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -42928,17 +47918,17 @@ static int _wrap_new_SBQueue__SWIG_0(lua_State* L) {
static int _wrap_new_SBQueue__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
- lldb::QueueSP *arg1 = 0 ;
+ lldb::SBQueue *arg1 = 0 ;
lldb::SBQueue *result = 0 ;
SWIG_check_num_args("lldb::SBQueue::SBQueue",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBQueue::SBQueue",1,"lldb::QueueSP const &");
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBQueue::SBQueue",1,"lldb::SBQueue const &");
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_std__shared_ptrT_lldb_private__Queue_t,0))){
- SWIG_fail_ptr("new_SBQueue",1,SWIGTYPE_p_std__shared_ptrT_lldb_private__Queue_t);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBQueue,0))){
+ SWIG_fail_ptr("new_SBQueue",1,SWIGTYPE_p_lldb__SBQueue);
}
- result = (lldb::SBQueue *)new lldb::SBQueue((lldb::QueueSP const &)*arg1);
+ result = (lldb::SBQueue *)new lldb::SBQueue((lldb::SBQueue const &)*arg1);
SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBQueue,1); SWIG_arg++;
return SWIG_arg;
@@ -42963,7 +47953,7 @@ static int _wrap_new_SBQueue(lua_State* L) {
int _v = 0;
{
void *ptr;
- if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_std__shared_ptrT_lldb_private__Queue_t, SWIG_POINTER_NO_NULL)) {
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBQueue, SWIG_POINTER_NO_NULL)) {
_v = 0;
} else {
_v = 1;
@@ -42977,7 +47967,7 @@ static int _wrap_new_SBQueue(lua_State* L) {
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBQueue'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBQueue::SBQueue()\n"
- " lldb::SBQueue::SBQueue(lldb::QueueSP const &)\n");
+ " lldb::SBQueue::SBQueue(lldb::SBQueue const &)\n");
lua_error(L);return 0;
}
@@ -43104,30 +48094,6 @@ static int _wrap_SBQueue_GetName(lua_State* L) {
}
-static int _wrap_SBQueue_GetKind(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBQueue *arg1 = (lldb::SBQueue *) 0 ;
- lldb::QueueKind result;
-
- SWIG_check_num_args("lldb::SBQueue::GetKind",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBQueue::GetKind",1,"lldb::SBQueue *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBQueue,0))){
- SWIG_fail_ptr("SBQueue_GetKind",1,SWIGTYPE_p_lldb__SBQueue);
- }
-
- result = (lldb::QueueKind)(arg1)->GetKind();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBQueue_GetIndexID(lua_State* L) {
{
int SWIG_arg = 0;
@@ -43284,6 +48250,30 @@ static int _wrap_SBQueue_GetNumRunningItems(lua_State* L) {
}
+static int _wrap_SBQueue_GetKind(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBQueue *arg1 = (lldb::SBQueue *) 0 ;
+ lldb::QueueKind result;
+
+ SWIG_check_num_args("lldb::SBQueue::GetKind",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBQueue::GetKind",1,"lldb::SBQueue *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBQueue,0))){
+ SWIG_fail_ptr("SBQueue_GetKind",1,SWIGTYPE_p_lldb__SBQueue);
+ }
+
+ result = (lldb::QueueKind)(arg1)->GetKind();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBQueue(void *obj) {
lldb::SBQueue *arg1 = (lldb::SBQueue *) obj;
delete arg1;
@@ -43305,13 +48295,13 @@ static swig_lua_method swig_SBQueue_methods[]= {
{ "GetProcess", _wrap_SBQueue_GetProcess},
{ "GetQueueID", _wrap_SBQueue_GetQueueID},
{ "GetName", _wrap_SBQueue_GetName},
- { "GetKind", _wrap_SBQueue_GetKind},
{ "GetIndexID", _wrap_SBQueue_GetIndexID},
{ "GetNumThreads", _wrap_SBQueue_GetNumThreads},
{ "GetThreadAtIndex", _wrap_SBQueue_GetThreadAtIndex},
{ "GetNumPendingItems", _wrap_SBQueue_GetNumPendingItems},
{ "GetPendingItemAtIndex", _wrap_SBQueue_GetPendingItemAtIndex},
{ "GetNumRunningItems", _wrap_SBQueue_GetNumRunningItems},
+ { "GetKind", _wrap_SBQueue_GetKind},
{0,0}
};
static swig_lua_method swig_SBQueue_meta[] = {
@@ -43343,7 +48333,7 @@ static swig_lua_class *swig_SBQueue_bases[] = {0};
static const char *swig_SBQueue_base_names[] = {0};
static swig_lua_class _wrap_class_SBQueue = { "SBQueue", "SBQueue", &SWIGTYPE_p_lldb__SBQueue,_proxy__wrap_new_SBQueue, swig_delete_SBQueue, swig_SBQueue_methods, swig_SBQueue_attributes, &swig_SBQueue_Sf_SwigStatic, swig_SBQueue_meta, swig_SBQueue_bases, swig_SBQueue_base_names };
-static int _wrap_new_SBQueueItem__SWIG_0(lua_State* L) {
+static int _wrap_new_SBQueueItem(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBQueueItem *result = 0 ;
@@ -43360,63 +48350,6 @@ static int _wrap_new_SBQueueItem__SWIG_0(lua_State* L) {
}
-static int _wrap_new_SBQueueItem__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::QueueItemSP *arg1 = 0 ;
- lldb::SBQueueItem *result = 0 ;
-
- SWIG_check_num_args("lldb::SBQueueItem::SBQueueItem",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBQueueItem::SBQueueItem",1,"lldb::QueueItemSP const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t,0))){
- SWIG_fail_ptr("new_SBQueueItem",1,SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t);
- }
-
- result = (lldb::SBQueueItem *)new lldb::SBQueueItem((lldb::QueueItemSP const &)*arg1);
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBQueueItem,1); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_new_SBQueueItem(lua_State* L) {
- int argc;
- int argv[2]={
- 1,2
- };
-
- argc = lua_gettop(L);
- if (argc == 0) {
- return _wrap_new_SBQueueItem__SWIG_0(L);
- }
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_new_SBQueueItem__SWIG_1(L);
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBQueueItem'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBQueueItem::SBQueueItem()\n"
- " lldb::SBQueueItem::SBQueueItem(lldb::QueueItemSP const &)\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBQueueItem_IsValid(lua_State* L) {
{
int SWIG_arg = 0;
@@ -43573,36 +48506,6 @@ static int _wrap_SBQueueItem_SetAddress(lua_State* L) {
}
-static int _wrap_SBQueueItem_SetQueueItem(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBQueueItem *arg1 = (lldb::SBQueueItem *) 0 ;
- lldb::QueueItemSP *arg2 = 0 ;
-
- SWIG_check_num_args("lldb::SBQueueItem::SetQueueItem",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBQueueItem::SetQueueItem",1,"lldb::SBQueueItem *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBQueueItem::SetQueueItem",2,"lldb::QueueItemSP const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBQueueItem,0))){
- SWIG_fail_ptr("SBQueueItem_SetQueueItem",1,SWIGTYPE_p_lldb__SBQueueItem);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t,0))){
- SWIG_fail_ptr("SBQueueItem_SetQueueItem",2,SWIGTYPE_p_std__shared_ptrT_lldb_private__QueueItem_t);
- }
-
- (arg1)->SetQueueItem((lldb::QueueItemSP const &)*arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBQueueItem_GetExtendedBacktraceThread(lua_State* L) {
{
int SWIG_arg = 0;
@@ -43655,7 +48558,6 @@ static swig_lua_method swig_SBQueueItem_methods[]= {
{ "SetKind", _wrap_SBQueueItem_SetKind},
{ "GetAddress", _wrap_SBQueueItem_GetAddress},
{ "SetAddress", _wrap_SBQueueItem_SetAddress},
- { "SetQueueItem", _wrap_SBQueueItem_SetQueueItem},
{ "GetExtendedBacktraceThread", _wrap_SBQueueItem_GetExtendedBacktraceThread},
{0,0}
};
@@ -43835,6 +48737,224 @@ static swig_lua_class *swig_SBReproducer_bases[] = {0};
static const char *swig_SBReproducer_base_names[] = {0};
static swig_lua_class _wrap_class_SBReproducer = { "SBReproducer", "SBReproducer", &SWIGTYPE_p_lldb__SBReproducer,_proxy__wrap_new_SBReproducer, swig_delete_SBReproducer, swig_SBReproducer_methods, swig_SBReproducer_attributes, &swig_SBReproducer_Sf_SwigStatic, swig_SBReproducer_meta, swig_SBReproducer_bases, swig_SBReproducer_base_names };
+static int _wrap_new_SBScriptObject__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::ScriptObjectPtr arg1 = (lldb::ScriptObjectPtr) (lldb::ScriptObjectPtr)0 ;
+ lldb::ScriptLanguage arg2 ;
+ lldb::SBScriptObject *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBScriptObject::SBScriptObject",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBScriptObject::SBScriptObject",1,"lldb::ScriptObjectPtr const");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBScriptObject::SBScriptObject",2,"lldb::ScriptLanguage");
+ arg1=(lldb::ScriptObjectPtr)SWIG_MustGetPtr(L,1,0,0,1,"new_SBScriptObject");
+ arg2 = (lldb::ScriptLanguage)lua_tointeger(L, 2);
+ result = (lldb::SBScriptObject *)new lldb::SBScriptObject(arg1,arg2);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBScriptObject,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBScriptObject__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBScriptObject *arg1 = 0 ;
+ lldb::SBScriptObject *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBScriptObject::SBScriptObject",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBScriptObject::SBScriptObject",1,"lldb::SBScriptObject const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBScriptObject,0))){
+ SWIG_fail_ptr("new_SBScriptObject",1,SWIGTYPE_p_lldb__SBScriptObject);
+ }
+
+ result = (lldb::SBScriptObject *)new lldb::SBScriptObject((lldb::SBScriptObject const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBScriptObject,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBScriptObject(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBScriptObject, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBScriptObject__SWIG_1(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, 0, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_new_SBScriptObject__SWIG_0(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBScriptObject'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBScriptObject::SBScriptObject(lldb::ScriptObjectPtr const,lldb::ScriptLanguage)\n"
+ " lldb::SBScriptObject::SBScriptObject(lldb::SBScriptObject const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBScriptObject_IsValid(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBScriptObject *arg1 = (lldb::SBScriptObject *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBScriptObject::IsValid",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBScriptObject::IsValid",1,"lldb::SBScriptObject const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBScriptObject,0))){
+ SWIG_fail_ptr("SBScriptObject_IsValid",1,SWIGTYPE_p_lldb__SBScriptObject);
+ }
+
+ result = (bool)((lldb::SBScriptObject const *)arg1)->IsValid();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBScriptObject_GetPointer(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBScriptObject *arg1 = (lldb::SBScriptObject *) 0 ;
+ lldb::ScriptObjectPtr result;
+
+ SWIG_check_num_args("lldb::SBScriptObject::GetPointer",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBScriptObject::GetPointer",1,"lldb::SBScriptObject const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBScriptObject,0))){
+ SWIG_fail_ptr("SBScriptObject_GetPointer",1,SWIGTYPE_p_lldb__SBScriptObject);
+ }
+
+ result = (lldb::ScriptObjectPtr)((lldb::SBScriptObject const *)arg1)->GetPointer();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBScriptObject_GetLanguage(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBScriptObject *arg1 = (lldb::SBScriptObject *) 0 ;
+ lldb::ScriptLanguage result;
+
+ SWIG_check_num_args("lldb::SBScriptObject::GetLanguage",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBScriptObject::GetLanguage",1,"lldb::SBScriptObject const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBScriptObject,0))){
+ SWIG_fail_ptr("SBScriptObject_GetLanguage",1,SWIGTYPE_p_lldb__SBScriptObject);
+ }
+
+ result = (lldb::ScriptLanguage)((lldb::SBScriptObject const *)arg1)->GetLanguage();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBScriptObject(void *obj) {
+lldb::SBScriptObject *arg1 = (lldb::SBScriptObject *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBScriptObject(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBScriptObject);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBScriptObject_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBScriptObject_methods[]= {
+ { "IsValid", _wrap_SBScriptObject_IsValid},
+ { "GetPointer", _wrap_SBScriptObject_GetPointer},
+ { "GetLanguage", _wrap_SBScriptObject_GetLanguage},
+ {0,0}
+};
+static swig_lua_method swig_SBScriptObject_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBScriptObject_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBScriptObject_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBScriptObject_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBScriptObject_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBScriptObject_Sf_SwigStatic = {
+ "SBScriptObject",
+ swig_SBScriptObject_Sf_SwigStatic_methods,
+ swig_SBScriptObject_Sf_SwigStatic_attributes,
+ swig_SBScriptObject_Sf_SwigStatic_constants,
+ swig_SBScriptObject_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBScriptObject_bases[] = {0};
+static const char *swig_SBScriptObject_base_names[] = {0};
+static swig_lua_class _wrap_class_SBScriptObject = { "SBScriptObject", "SBScriptObject", &SWIGTYPE_p_lldb__SBScriptObject,_proxy__wrap_new_SBScriptObject, swig_delete_SBScriptObject, swig_SBScriptObject_methods, swig_SBScriptObject_attributes, &swig_SBScriptObject_Sf_SwigStatic, swig_SBScriptObject_meta, swig_SBScriptObject_bases, swig_SBScriptObject_base_names };
+
static int _wrap_new_SBSection__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -44405,27 +49525,27 @@ static int _wrap_SBSection_GetAlignment(lua_State* L) {
}
-static int _wrap_SBSection_GetDescription(lua_State* L) {
+static int _wrap_SBSection___eq(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSection *arg1 = (lldb::SBSection *) 0 ;
- lldb::SBStream *arg2 = 0 ;
+ lldb::SBSection *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBSection::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSection::GetDescription",1,"lldb::SBSection *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSection::GetDescription",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBSection::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSection::operator ==",1,"lldb::SBSection *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSection::operator ==",2,"lldb::SBSection const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSection,0))){
- SWIG_fail_ptr("SBSection_GetDescription",1,SWIGTYPE_p_lldb__SBSection);
+ SWIG_fail_ptr("SBSection___eq",1,SWIGTYPE_p_lldb__SBSection);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBSection_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBSection,0))){
+ SWIG_fail_ptr("SBSection___eq",2,SWIGTYPE_p_lldb__SBSection);
}
- result = (bool)(arg1)->GetDescription(*arg2);
+ result = (bool)(arg1)->operator ==((lldb::SBSection const &)*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -44436,27 +49556,27 @@ static int _wrap_SBSection_GetDescription(lua_State* L) {
}
-static int _wrap_SBSection___eq(lua_State* L) {
+static int _wrap_SBSection_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSection *arg1 = (lldb::SBSection *) 0 ;
- lldb::SBSection *arg2 = 0 ;
+ lldb::SBStream *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBSection::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSection::operator ==",1,"lldb::SBSection *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSection::operator ==",2,"lldb::SBSection const &");
+ SWIG_check_num_args("lldb::SBSection::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSection::GetDescription",1,"lldb::SBSection *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSection::GetDescription",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSection,0))){
- SWIG_fail_ptr("SBSection___eq",1,SWIGTYPE_p_lldb__SBSection);
+ SWIG_fail_ptr("SBSection_GetDescription",1,SWIGTYPE_p_lldb__SBSection);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBSection,0))){
- SWIG_fail_ptr("SBSection___eq",2,SWIGTYPE_p_lldb__SBSection);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBSection_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
}
- result = (bool)(arg1)->operator ==((lldb::SBSection const &)*arg2);
+ result = (bool)(arg1)->GetDescription(*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -44523,8 +49643,8 @@ static swig_lua_method swig_SBSection_methods[]= {
{ "GetPermissions", _wrap_SBSection_GetPermissions},
{ "GetTargetByteSize", _wrap_SBSection_GetTargetByteSize},
{ "GetAlignment", _wrap_SBSection_GetAlignment},
- { "GetDescription", _wrap_SBSection_GetDescription},
{ "__eq", _wrap_SBSection___eq},
+ { "GetDescription", _wrap_SBSection_GetDescription},
{ "__tostring", _wrap_SBSection___tostring},
{0,0}
};
@@ -44559,7 +49679,55 @@ static swig_lua_class *swig_SBSection_bases[] = {0};
static const char *swig_SBSection_base_names[] = {0};
static swig_lua_class _wrap_class_SBSection = { "SBSection", "SBSection", &SWIGTYPE_p_lldb__SBSection,_proxy__wrap_new_SBSection, swig_delete_SBSection, swig_SBSection_methods, swig_SBSection_attributes, &swig_SBSection_Sf_SwigStatic, swig_SBSection_meta, swig_SBSection_bases, swig_SBSection_base_names };
-static int _wrap_new_SBSourceManager(lua_State* L) {
+static int _wrap_new_SBSourceManager__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBDebugger *arg1 = 0 ;
+ lldb::SBSourceManager *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBSourceManager::SBSourceManager",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBSourceManager::SBSourceManager",1,"lldb::SBDebugger const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("new_SBSourceManager",1,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+ result = (lldb::SBSourceManager *)new lldb::SBSourceManager((lldb::SBDebugger const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBSourceManager,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBSourceManager__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = 0 ;
+ lldb::SBSourceManager *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBSourceManager::SBSourceManager",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBSourceManager::SBSourceManager",1,"lldb::SBTarget const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("new_SBSourceManager",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (lldb::SBSourceManager *)new lldb::SBSourceManager((lldb::SBTarget const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBSourceManager,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBSourceManager__SWIG_2(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSourceManager *arg1 = 0 ;
@@ -44583,6 +49751,65 @@ static int _wrap_new_SBSourceManager(lua_State* L) {
}
+static int _wrap_new_SBSourceManager(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBSourceManager__SWIG_0(L);
+ }
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBSourceManager__SWIG_1(L);
+ }
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBSourceManager, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBSourceManager__SWIG_2(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBSourceManager'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBSourceManager::SBSourceManager(lldb::SBDebugger const &)\n"
+ " lldb::SBSourceManager::SBSourceManager(lldb::SBTarget const &)\n"
+ " lldb::SBSourceManager::SBSourceManager(lldb::SBSourceManager const &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBSourceManager_DisplaySourceLinesWithLineNumbers(lua_State* L) {
{
int SWIG_arg = 0;
@@ -44735,6 +49962,387 @@ static swig_lua_class *swig_SBSourceManager_bases[] = {0};
static const char *swig_SBSourceManager_base_names[] = {0};
static swig_lua_class _wrap_class_SBSourceManager = { "SBSourceManager", "SBSourceManager", &SWIGTYPE_p_lldb__SBSourceManager,_proxy__wrap_new_SBSourceManager, swig_delete_SBSourceManager, swig_SBSourceManager_methods, swig_SBSourceManager_attributes, &swig_SBSourceManager_Sf_SwigStatic, swig_SBSourceManager_meta, swig_SBSourceManager_bases, swig_SBSourceManager_base_names };
+static int _wrap_new_SBStatisticsOptions__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SBStatisticsOptions",0,0)
+ result = (lldb::SBStatisticsOptions *)new lldb::SBStatisticsOptions();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBStatisticsOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBStatisticsOptions__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = 0 ;
+ lldb::SBStatisticsOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SBStatisticsOptions",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::SBStatisticsOptions",1,"lldb::SBStatisticsOptions const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("new_SBStatisticsOptions",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ result = (lldb::SBStatisticsOptions *)new lldb::SBStatisticsOptions((lldb::SBStatisticsOptions const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBStatisticsOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBStatisticsOptions(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBStatisticsOptions__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStatisticsOptions, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBStatisticsOptions__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBStatisticsOptions'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBStatisticsOptions::SBStatisticsOptions()\n"
+ " lldb::SBStatisticsOptions::SBStatisticsOptions(lldb::SBStatisticsOptions const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_SetSummaryOnly(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SetSummaryOnly",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetSummaryOnly",1,"lldb::SBStatisticsOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetSummaryOnly",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_SetSummaryOnly",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetSummaryOnly(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_GetSummaryOnly(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::GetSummaryOnly",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::GetSummaryOnly",1,"lldb::SBStatisticsOptions *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_GetSummaryOnly",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ result = (bool)(arg1)->GetSummaryOnly();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_SetIncludeTargets(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SetIncludeTargets",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetIncludeTargets",1,"lldb::SBStatisticsOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetIncludeTargets",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_SetIncludeTargets",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetIncludeTargets(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_GetIncludeTargets(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::GetIncludeTargets",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::GetIncludeTargets",1,"lldb::SBStatisticsOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_GetIncludeTargets",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ result = (bool)((lldb::SBStatisticsOptions const *)arg1)->GetIncludeTargets();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_SetIncludeModules(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SetIncludeModules",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetIncludeModules",1,"lldb::SBStatisticsOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetIncludeModules",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_SetIncludeModules",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetIncludeModules(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_GetIncludeModules(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::GetIncludeModules",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::GetIncludeModules",1,"lldb::SBStatisticsOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_GetIncludeModules",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ result = (bool)((lldb::SBStatisticsOptions const *)arg1)->GetIncludeModules();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_SetIncludeTranscript(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SetIncludeTranscript",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetIncludeTranscript",1,"lldb::SBStatisticsOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetIncludeTranscript",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_SetIncludeTranscript",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetIncludeTranscript(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_GetIncludeTranscript(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::GetIncludeTranscript",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::GetIncludeTranscript",1,"lldb::SBStatisticsOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_GetIncludeTranscript",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ result = (bool)((lldb::SBStatisticsOptions const *)arg1)->GetIncludeTranscript();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_SetReportAllAvailableDebugInfo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo",1,"lldb::SBStatisticsOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBStatisticsOptions::SetReportAllAvailableDebugInfo",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_SetReportAllAvailableDebugInfo",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetReportAllAvailableDebugInfo(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStatisticsOptions_GetReportAllAvailableDebugInfo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStatisticsOptions::GetReportAllAvailableDebugInfo",1,"lldb::SBStatisticsOptions *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBStatisticsOptions_GetReportAllAvailableDebugInfo",1,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+
+ result = (bool)(arg1)->GetReportAllAvailableDebugInfo();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBStatisticsOptions(void *obj) {
+lldb::SBStatisticsOptions *arg1 = (lldb::SBStatisticsOptions *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBStatisticsOptions(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBStatisticsOptions);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBStatisticsOptions_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBStatisticsOptions_methods[]= {
+ { "SetSummaryOnly", _wrap_SBStatisticsOptions_SetSummaryOnly},
+ { "GetSummaryOnly", _wrap_SBStatisticsOptions_GetSummaryOnly},
+ { "SetIncludeTargets", _wrap_SBStatisticsOptions_SetIncludeTargets},
+ { "GetIncludeTargets", _wrap_SBStatisticsOptions_GetIncludeTargets},
+ { "SetIncludeModules", _wrap_SBStatisticsOptions_SetIncludeModules},
+ { "GetIncludeModules", _wrap_SBStatisticsOptions_GetIncludeModules},
+ { "SetIncludeTranscript", _wrap_SBStatisticsOptions_SetIncludeTranscript},
+ { "GetIncludeTranscript", _wrap_SBStatisticsOptions_GetIncludeTranscript},
+ { "SetReportAllAvailableDebugInfo", _wrap_SBStatisticsOptions_SetReportAllAvailableDebugInfo},
+ { "GetReportAllAvailableDebugInfo", _wrap_SBStatisticsOptions_GetReportAllAvailableDebugInfo},
+ {0,0}
+};
+static swig_lua_method swig_SBStatisticsOptions_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBStatisticsOptions_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBStatisticsOptions_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBStatisticsOptions_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBStatisticsOptions_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBStatisticsOptions_Sf_SwigStatic = {
+ "SBStatisticsOptions",
+ swig_SBStatisticsOptions_Sf_SwigStatic_methods,
+ swig_SBStatisticsOptions_Sf_SwigStatic_attributes,
+ swig_SBStatisticsOptions_Sf_SwigStatic_constants,
+ swig_SBStatisticsOptions_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBStatisticsOptions_bases[] = {0};
+static const char *swig_SBStatisticsOptions_base_names[] = {0};
+static swig_lua_class _wrap_class_SBStatisticsOptions = { "SBStatisticsOptions", "SBStatisticsOptions", &SWIGTYPE_p_lldb__SBStatisticsOptions,_proxy__wrap_new_SBStatisticsOptions, swig_delete_SBStatisticsOptions, swig_SBStatisticsOptions_methods, swig_SBStatisticsOptions_attributes, &swig_SBStatisticsOptions_Sf_SwigStatic, swig_SBStatisticsOptions_meta, swig_SBStatisticsOptions_bases, swig_SBStatisticsOptions_base_names };
+
static int _wrap_new_SBStream(lua_State* L) {
{
int SWIG_arg = 0;
@@ -45028,31 +50636,25 @@ static int _wrap_SBStream_RedirectToFile(lua_State* L) {
}
-static int _wrap_SBStream_RedirectToFileHandle(lua_State* L) {
+static int _wrap_SBStream_RedirectToFileDescriptor(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBStream *arg1 = (lldb::SBStream *) 0 ;
- SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg2 ;
+ int arg2 ;
bool arg3 ;
- SWIG_check_num_args("lldb::SBStream::RedirectToFileHandle",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStream::RedirectToFileHandle",1,"lldb::SBStream *");
- if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBStream::RedirectToFileHandle",3,"bool");
+ SWIG_check_num_args("lldb::SBStream::RedirectToFileDescriptor",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStream::RedirectToFileDescriptor",1,"lldb::SBStream *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBStream::RedirectToFileDescriptor",2,"int");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBStream::RedirectToFileDescriptor",3,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBStream_RedirectToFileHandle",1,SWIGTYPE_p_lldb__SBStream);
+ SWIG_fail_ptr("SBStream_RedirectToFileDescriptor",1,SWIGTYPE_p_lldb__SBStream);
}
- {
- luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 2, LUA_FILEHANDLE);
- lldb::FileSP file_sp;
- file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
- if (!file_sp->IsValid())
- return luaL_error(L, "Invalid file");
- arg2 = file_sp;
- }
+ arg2 = (int)lua_tointeger(L, 2);
arg3 = (lua_toboolean(L, 3)!=0);
- lldb_SBStream_RedirectToFileHandle(arg1,SWIG_STD_MOVE(arg2),arg3);
+ (arg1)->RedirectToFileDescriptor(arg2,arg3);
return SWIG_arg;
@@ -45063,25 +50665,19 @@ static int _wrap_SBStream_RedirectToFileHandle(lua_State* L) {
}
-static int _wrap_SBStream_RedirectToFileDescriptor(lua_State* L) {
+static int _wrap_SBStream_Clear(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBStream *arg1 = (lldb::SBStream *) 0 ;
- int arg2 ;
- bool arg3 ;
- SWIG_check_num_args("lldb::SBStream::RedirectToFileDescriptor",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStream::RedirectToFileDescriptor",1,"lldb::SBStream *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBStream::RedirectToFileDescriptor",2,"int");
- if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBStream::RedirectToFileDescriptor",3,"bool");
+ SWIG_check_num_args("lldb::SBStream::Clear",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStream::Clear",1,"lldb::SBStream *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBStream_RedirectToFileDescriptor",1,SWIGTYPE_p_lldb__SBStream);
+ SWIG_fail_ptr("SBStream_Clear",1,SWIGTYPE_p_lldb__SBStream);
}
- arg2 = (int)lua_tointeger(L, 2);
- arg3 = (lua_toboolean(L, 3)!=0);
- (arg1)->RedirectToFileDescriptor(arg2,arg3);
+ (arg1)->Clear();
return SWIG_arg;
@@ -45092,19 +50688,31 @@ static int _wrap_SBStream_RedirectToFileDescriptor(lua_State* L) {
}
-static int _wrap_SBStream_Clear(lua_State* L) {
+static int _wrap_SBStream_RedirectToFileHandle(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBStream *arg1 = (lldb::SBStream *) 0 ;
+ SwigValueWrapper< std::shared_ptr< lldb_private::File > > arg2 ;
+ bool arg3 ;
- SWIG_check_num_args("lldb::SBStream::Clear",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStream::Clear",1,"lldb::SBStream *");
+ SWIG_check_num_args("lldb::SBStream::RedirectToFileHandle",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStream::RedirectToFileHandle",1,"lldb::SBStream *");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBStream::RedirectToFileHandle",3,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBStream_Clear",1,SWIGTYPE_p_lldb__SBStream);
+ SWIG_fail_ptr("SBStream_RedirectToFileHandle",1,SWIGTYPE_p_lldb__SBStream);
}
- (arg1)->Clear();
+ {
+ luaL_Stream *p = (luaL_Stream *)luaL_checkudata(L, 2, LUA_FILEHANDLE);
+ lldb::FileSP file_sp;
+ file_sp = std::make_shared<lldb_private::NativeFile>(p->f, false);
+ if (!file_sp->IsValid())
+ return luaL_error(L, "Invalid file");
+ arg2 = file_sp;
+ }
+ arg3 = (lua_toboolean(L, 3)!=0);
+ lldb_SBStream_RedirectToFileHandle(arg1,SWIG_STD_MOVE(arg2),arg3);
return SWIG_arg;
@@ -45136,9 +50744,9 @@ static swig_lua_method swig_SBStream_methods[]= {
{ "GetSize", _wrap_SBStream_GetSize},
{ "Print", _wrap_SBStream_Print},
{ "RedirectToFile", _wrap_SBStream_RedirectToFile},
- { "RedirectToFileHandle", _wrap_SBStream_RedirectToFileHandle},
{ "RedirectToFileDescriptor", _wrap_SBStream_RedirectToFileDescriptor},
{ "Clear", _wrap_SBStream_Clear},
+ { "RedirectToFileHandle", _wrap_SBStream_RedirectToFileHandle},
{0,0}
};
static swig_lua_method swig_SBStream_meta[] = {
@@ -45468,7 +51076,7 @@ static int _wrap_SBStringList_GetSize(lua_State* L) {
}
-static int _wrap_SBStringList_GetStringAtIndex(lua_State* L) {
+static int _wrap_SBStringList_GetStringAtIndex__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBStringList *arg1 = (lldb::SBStringList *) 0 ;
@@ -45495,6 +51103,87 @@ static int _wrap_SBStringList_GetStringAtIndex(lua_State* L) {
}
+static int _wrap_SBStringList_GetStringAtIndex__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStringList *arg1 = (lldb::SBStringList *) 0 ;
+ size_t arg2 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBStringList::GetStringAtIndex",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStringList::GetStringAtIndex",1,"lldb::SBStringList const *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBStringList::GetStringAtIndex",2,"size_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStringList,0))){
+ SWIG_fail_ptr("SBStringList_GetStringAtIndex",1,SWIGTYPE_p_lldb__SBStringList);
+ }
+
+ arg2 = (size_t)lua_tointeger(L, 2);
+ result = (char *)((lldb::SBStringList const *)arg1)->GetStringAtIndex(arg2);
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStringList_GetStringAtIndex(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStringList, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBStringList_GetStringAtIndex__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStringList, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBStringList_GetStringAtIndex__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBStringList_GetStringAtIndex'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBStringList::GetStringAtIndex(size_t)\n"
+ " lldb::SBStringList::GetStringAtIndex(size_t) const\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBStringList_Clear(lua_State* L) {
{
int SWIG_arg = 0;
@@ -45615,17 +51304,26 @@ static int _wrap_new_SBStructuredData__SWIG_1(lua_State* L) {
static int _wrap_new_SBStructuredData__SWIG_2(lua_State* L) {
{
int SWIG_arg = 0;
- lldb::EventSP *arg1 = 0 ;
+ SwigValueWrapper< lldb::SBScriptObject > arg1 ;
+ lldb::SBDebugger *arg2 = 0 ;
+ lldb::SBScriptObject *argp1 ;
lldb::SBStructuredData *result = 0 ;
- SWIG_check_num_args("lldb::SBStructuredData::SBStructuredData",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBStructuredData::SBStructuredData",1,"lldb::EventSP const &");
+ SWIG_check_num_args("lldb::SBStructuredData::SBStructuredData",2,2)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBStructuredData::SBStructuredData",1,"lldb::SBScriptObject const");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::SBStructuredData",2,"lldb::SBDebugger const &");
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t,0))){
- SWIG_fail_ptr("new_SBStructuredData",1,SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&argp1,SWIGTYPE_p_lldb__SBScriptObject,0))){
+ SWIG_fail_ptr("new_SBStructuredData",1,SWIGTYPE_p_lldb__SBScriptObject);
+ }
+ arg1 = *argp1;
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("new_SBStructuredData",2,SWIGTYPE_p_lldb__SBDebugger);
}
- result = (lldb::SBStructuredData *)new lldb::SBStructuredData((lldb::EventSP const &)*arg1);
+ result = (lldb::SBStructuredData *)new lldb::SBStructuredData(arg1,(lldb::SBDebugger const &)*arg2);
SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
return SWIG_arg;
@@ -45638,8 +51336,8 @@ static int _wrap_new_SBStructuredData__SWIG_2(lua_State* L) {
static int _wrap_new_SBStructuredData(lua_State* L) {
int argc;
- int argv[2]={
- 1,2
+ int argv[3]={
+ 1,2,3
};
argc = lua_gettop(L);
@@ -45660,18 +51358,28 @@ static int _wrap_new_SBStructuredData(lua_State* L) {
return _wrap_new_SBStructuredData__SWIG_1(L);
}
}
- if (argc == 1) {
+ if (argc == 2) {
int _v = 0;
{
void *ptr;
- if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_std__shared_ptrT_lldb_private__Event_t, SWIG_POINTER_NO_NULL)) {
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBScriptObject, SWIG_POINTER_NO_NULL)) {
_v = 0;
} else {
_v = 1;
}
}
if (_v) {
- return _wrap_new_SBStructuredData__SWIG_2(L);
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBDebugger, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBStructuredData__SWIG_2(L);
+ }
}
}
@@ -45679,7 +51387,7 @@ static int _wrap_new_SBStructuredData(lua_State* L) {
" Possible C/C++ prototypes are:\n"
" lldb::SBStructuredData::SBStructuredData()\n"
" lldb::SBStructuredData::SBStructuredData(lldb::SBStructuredData const &)\n"
- " lldb::SBStructuredData::SBStructuredData(lldb::EventSP const &)\n");
+ " lldb::SBStructuredData::SBStructuredData(lldb::SBScriptObject const,lldb::SBDebugger const &)\n");
lua_error(L);return 0;
}
@@ -45708,6 +51416,129 @@ static int _wrap_SBStructuredData_IsValid(lua_State* L) {
}
+static int _wrap_SBStructuredData_SetFromJSON__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::SetFromJSON",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",1,"lldb::SBStructuredData *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_SetFromJSON",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBStructuredData_SetFromJSON",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (arg1)->SetFromJSON(*arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_SetFromJSON__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::SetFromJSON",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",1,"lldb::SBStructuredData *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_SetFromJSON",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->SetFromJSON((char const *)arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_SetFromJSON(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStream, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBStructuredData_SetFromJSON__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBStructuredData_SetFromJSON__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBStructuredData_SetFromJSON'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBStructuredData::SetFromJSON(lldb::SBStream &)\n"
+ " lldb::SBStructuredData::SetFromJSON(char const *)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBStructuredData_Clear(lua_State* L) {
{
int SWIG_arg = 0;
@@ -45731,6 +51562,74 @@ static int _wrap_SBStructuredData_Clear(lua_State* L) {
}
+static int _wrap_SBStructuredData_GetAsJSON(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::GetAsJSON",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetAsJSON",1,"lldb::SBStructuredData const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::GetAsJSON",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_GetAsJSON",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBStructuredData_GetAsJSON",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = ((lldb::SBStructuredData const *)arg1)->GetAsJSON(*arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetDescription",1,"lldb::SBStructuredData const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::GetDescription",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_GetDescription",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBStructuredData_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = ((lldb::SBStructuredData const *)arg1)->GetDescription(*arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBStructuredData_GetType(lua_State* L) {
{
int SWIG_arg = 0;
@@ -45870,6 +51769,206 @@ static int _wrap_SBStructuredData_GetItemAtIndex(lua_State* L) {
}
+static int _wrap_SBStructuredData_GetUnsignedIntegerValue__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ uint64_t arg2 ;
+ uint64_t result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::GetUnsignedIntegerValue",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetUnsignedIntegerValue",1,"lldb::SBStructuredData const *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBStructuredData::GetUnsignedIntegerValue",2,"uint64_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_GetUnsignedIntegerValue",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+ arg2 = (uint64_t)lua_tointeger(L, 2);
+ result = (uint64_t)((lldb::SBStructuredData const *)arg1)->GetUnsignedIntegerValue(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_GetUnsignedIntegerValue__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ uint64_t result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::GetUnsignedIntegerValue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetUnsignedIntegerValue",1,"lldb::SBStructuredData const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_GetUnsignedIntegerValue",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+ result = (uint64_t)((lldb::SBStructuredData const *)arg1)->GetUnsignedIntegerValue();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_GetUnsignedIntegerValue(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBStructuredData_GetUnsignedIntegerValue__SWIG_1(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBStructuredData_GetUnsignedIntegerValue__SWIG_0(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBStructuredData_GetUnsignedIntegerValue'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBStructuredData::GetUnsignedIntegerValue(uint64_t) const\n"
+ " lldb::SBStructuredData::GetUnsignedIntegerValue() const\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBStructuredData_GetSignedIntegerValue__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ int64_t arg2 ;
+ int64_t result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::GetSignedIntegerValue",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetSignedIntegerValue",1,"lldb::SBStructuredData const *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBStructuredData::GetSignedIntegerValue",2,"int64_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_GetSignedIntegerValue",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+ arg2 = (int64_t)lua_tointeger(L, 2);
+ result = (int64_t)((lldb::SBStructuredData const *)arg1)->GetSignedIntegerValue(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_GetSignedIntegerValue__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
+ int64_t result;
+
+ SWIG_check_num_args("lldb::SBStructuredData::GetSignedIntegerValue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetSignedIntegerValue",1,"lldb::SBStructuredData const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("SBStructuredData_GetSignedIntegerValue",1,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+ result = (int64_t)((lldb::SBStructuredData const *)arg1)->GetSignedIntegerValue();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBStructuredData_GetSignedIntegerValue(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBStructuredData_GetSignedIntegerValue__SWIG_1(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBStructuredData_GetSignedIntegerValue__SWIG_0(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBStructuredData_GetSignedIntegerValue'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBStructuredData::GetSignedIntegerValue(int64_t) const\n"
+ " lldb::SBStructuredData::GetSignedIntegerValue() const\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBStructuredData_GetIntegerValue__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -46213,98 +52312,23 @@ static int _wrap_SBStructuredData_GetStringValue(lua_State* L) {
}
-static int _wrap_SBStructuredData_GetAsJSON(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- lldb::SBError result;
-
- SWIG_check_num_args("lldb::SBStructuredData::GetAsJSON",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetAsJSON",1,"lldb::SBStructuredData const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::GetAsJSON",2,"lldb::SBStream &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
- SWIG_fail_ptr("SBStructuredData_GetAsJSON",1,SWIGTYPE_p_lldb__SBStructuredData);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBStructuredData_GetAsJSON",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- result = ((lldb::SBStructuredData const *)arg1)->GetAsJSON(*arg2);
- {
- lldb::SBError * resultptr = new lldb::SBError(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBStructuredData_GetDescription(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- lldb::SBError result;
-
- SWIG_check_num_args("lldb::SBStructuredData::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetDescription",1,"lldb::SBStructuredData const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::GetDescription",2,"lldb::SBStream &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
- SWIG_fail_ptr("SBStructuredData_GetDescription",1,SWIGTYPE_p_lldb__SBStructuredData);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBStructuredData_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- result = ((lldb::SBStructuredData const *)arg1)->GetDescription(*arg2);
- {
- lldb::SBError * resultptr = new lldb::SBError(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBStructuredData_SetFromJSON__SWIG_0(lua_State* L) {
+static int _wrap_SBStructuredData_GetGenericValue(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- lldb::SBError result;
+ SwigValueWrapper< lldb::SBScriptObject > result;
- SWIG_check_num_args("lldb::SBStructuredData::SetFromJSON",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",1,"lldb::SBStructuredData *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBStructuredData::GetGenericValue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::GetGenericValue",1,"lldb::SBStructuredData const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
- SWIG_fail_ptr("SBStructuredData_SetFromJSON",1,SWIGTYPE_p_lldb__SBStructuredData);
+ SWIG_fail_ptr("SBStructuredData_GetGenericValue",1,SWIGTYPE_p_lldb__SBStructuredData);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBStructuredData_SetFromJSON",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- result = (arg1)->SetFromJSON(*arg2);
+ result = ((lldb::SBStructuredData const *)arg1)->GetGenericValue();
{
- lldb::SBError * resultptr = new lldb::SBError(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ lldb::SBScriptObject * resultptr = new lldb::SBScriptObject(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBScriptObject,1); SWIG_arg++;
}
return SWIG_arg;
@@ -46315,27 +52339,21 @@ static int _wrap_SBStructuredData_SetFromJSON__SWIG_0(lua_State* L) {
}
-static int _wrap_SBStructuredData_SetFromJSON__SWIG_1(lua_State* L) {
+static int _wrap_SBStructuredData___tostring(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBError result;
+ std::string result;
- SWIG_check_num_args("lldb::SBStructuredData::SetFromJSON",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",1,"lldb::SBStructuredData *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBStructuredData::SetFromJSON",2,"char const *");
+ SWIG_check_num_args("lldb::SBStructuredData::__repr__",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBStructuredData::__repr__",1,"lldb::SBStructuredData *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBStructuredData,0))){
- SWIG_fail_ptr("SBStructuredData_SetFromJSON",1,SWIGTYPE_p_lldb__SBStructuredData);
+ SWIG_fail_ptr("SBStructuredData___tostring",1,SWIGTYPE_p_lldb__SBStructuredData);
}
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->SetFromJSON((char const *)arg2);
- {
- lldb::SBError * resultptr = new lldb::SBError(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
- }
+ result = lldb_SBStructuredData___repr__(arg1);
+ lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -46345,65 +52363,6 @@ static int _wrap_SBStructuredData_SetFromJSON__SWIG_1(lua_State* L) {
}
-static int _wrap_SBStructuredData_SetFromJSON(lua_State* L) {
- int argc;
- int argv[3]={
- 1,2,3
- };
-
- argc = lua_gettop(L);
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- void *ptr;
- if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStream, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBStructuredData_SetFromJSON__SWIG_0(L);
- }
- }
- }
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = SWIG_lua_isnilstring(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBStructuredData_SetFromJSON__SWIG_1(L);
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBStructuredData_SetFromJSON'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBStructuredData::SetFromJSON(lldb::SBStream &)\n"
- " lldb::SBStructuredData::SetFromJSON(char const *)\n");
- lua_error(L);return 0;
-}
-
-
static void swig_delete_SBStructuredData(void *obj) {
lldb::SBStructuredData *arg1 = (lldb::SBStructuredData *) obj;
delete arg1;
@@ -46421,22 +52380,27 @@ static swig_lua_attribute swig_SBStructuredData_attributes[] = {
};
static swig_lua_method swig_SBStructuredData_methods[]= {
{ "IsValid", _wrap_SBStructuredData_IsValid},
+ { "SetFromJSON", _wrap_SBStructuredData_SetFromJSON},
{ "Clear", _wrap_SBStructuredData_Clear},
+ { "GetAsJSON", _wrap_SBStructuredData_GetAsJSON},
+ { "GetDescription", _wrap_SBStructuredData_GetDescription},
{ "GetType", _wrap_SBStructuredData_GetType},
{ "GetSize", _wrap_SBStructuredData_GetSize},
{ "GetKeys", _wrap_SBStructuredData_GetKeys},
{ "GetValueForKey", _wrap_SBStructuredData_GetValueForKey},
{ "GetItemAtIndex", _wrap_SBStructuredData_GetItemAtIndex},
+ { "GetUnsignedIntegerValue", _wrap_SBStructuredData_GetUnsignedIntegerValue},
+ { "GetSignedIntegerValue", _wrap_SBStructuredData_GetSignedIntegerValue},
{ "GetIntegerValue", _wrap_SBStructuredData_GetIntegerValue},
{ "GetFloatValue", _wrap_SBStructuredData_GetFloatValue},
{ "GetBooleanValue", _wrap_SBStructuredData_GetBooleanValue},
{ "GetStringValue", _wrap_SBStructuredData_GetStringValue},
- { "GetAsJSON", _wrap_SBStructuredData_GetAsJSON},
- { "GetDescription", _wrap_SBStructuredData_GetDescription},
- { "SetFromJSON", _wrap_SBStructuredData_SetFromJSON},
+ { "GetGenericValue", _wrap_SBStructuredData_GetGenericValue},
+ { "__tostring", _wrap_SBStructuredData___tostring},
{0,0}
};
static swig_lua_method swig_SBStructuredData_meta[] = {
+ { "__tostring", _wrap_SBStructuredData___tostring},
{0,0}
};
@@ -46929,27 +52893,27 @@ static int _wrap_SBSymbol_GetType(lua_State* L) {
}
-static int _wrap_SBSymbol_GetDescription(lua_State* L) {
+static int _wrap_SBSymbol___eq(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSymbol *arg1 = (lldb::SBSymbol *) 0 ;
- lldb::SBStream *arg2 = 0 ;
+ lldb::SBSymbol *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBSymbol::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::GetDescription",1,"lldb::SBSymbol *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSymbol::GetDescription",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBSymbol::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::operator ==",1,"lldb::SBSymbol const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSymbol::operator ==",2,"lldb::SBSymbol const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSymbol,0))){
- SWIG_fail_ptr("SBSymbol_GetDescription",1,SWIGTYPE_p_lldb__SBSymbol);
+ SWIG_fail_ptr("SBSymbol___eq",1,SWIGTYPE_p_lldb__SBSymbol);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBSymbol_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBSymbol,0))){
+ SWIG_fail_ptr("SBSymbol___eq",2,SWIGTYPE_p_lldb__SBSymbol);
}
- result = (bool)(arg1)->GetDescription(*arg2);
+ result = (bool)((lldb::SBSymbol const *)arg1)->operator ==((lldb::SBSymbol const &)*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -46960,20 +52924,27 @@ static int _wrap_SBSymbol_GetDescription(lua_State* L) {
}
-static int _wrap_SBSymbol_IsExternal(lua_State* L) {
+static int _wrap_SBSymbol_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSymbol *arg1 = (lldb::SBSymbol *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBSymbol::IsExternal",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::IsExternal",1,"lldb::SBSymbol *");
+ SWIG_check_num_args("lldb::SBSymbol::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::GetDescription",1,"lldb::SBSymbol *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSymbol::GetDescription",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSymbol,0))){
- SWIG_fail_ptr("SBSymbol_IsExternal",1,SWIGTYPE_p_lldb__SBSymbol);
+ SWIG_fail_ptr("SBSymbol_GetDescription",1,SWIGTYPE_p_lldb__SBSymbol);
}
- result = (bool)(arg1)->IsExternal();
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBSymbol_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -46984,20 +52955,20 @@ static int _wrap_SBSymbol_IsExternal(lua_State* L) {
}
-static int _wrap_SBSymbol_IsSynthetic(lua_State* L) {
+static int _wrap_SBSymbol_IsExternal(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSymbol *arg1 = (lldb::SBSymbol *) 0 ;
bool result;
- SWIG_check_num_args("lldb::SBSymbol::IsSynthetic",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::IsSynthetic",1,"lldb::SBSymbol *");
+ SWIG_check_num_args("lldb::SBSymbol::IsExternal",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::IsExternal",1,"lldb::SBSymbol *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSymbol,0))){
- SWIG_fail_ptr("SBSymbol_IsSynthetic",1,SWIGTYPE_p_lldb__SBSymbol);
+ SWIG_fail_ptr("SBSymbol_IsExternal",1,SWIGTYPE_p_lldb__SBSymbol);
}
- result = (bool)(arg1)->IsSynthetic();
+ result = (bool)(arg1)->IsExternal();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -47008,27 +52979,20 @@ static int _wrap_SBSymbol_IsSynthetic(lua_State* L) {
}
-static int _wrap_SBSymbol___eq(lua_State* L) {
+static int _wrap_SBSymbol_IsSynthetic(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBSymbol *arg1 = (lldb::SBSymbol *) 0 ;
- lldb::SBSymbol *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBSymbol::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::operator ==",1,"lldb::SBSymbol const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSymbol::operator ==",2,"lldb::SBSymbol const &");
+ SWIG_check_num_args("lldb::SBSymbol::IsSynthetic",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbol::IsSynthetic",1,"lldb::SBSymbol *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSymbol,0))){
- SWIG_fail_ptr("SBSymbol___eq",1,SWIGTYPE_p_lldb__SBSymbol);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBSymbol,0))){
- SWIG_fail_ptr("SBSymbol___eq",2,SWIGTYPE_p_lldb__SBSymbol);
+ SWIG_fail_ptr("SBSymbol_IsSynthetic",1,SWIGTYPE_p_lldb__SBSymbol);
}
- result = (bool)((lldb::SBSymbol const *)arg1)->operator ==((lldb::SBSymbol const &)*arg2);
+ result = (bool)(arg1)->IsSynthetic();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -47090,10 +53054,10 @@ static swig_lua_method swig_SBSymbol_methods[]= {
{ "GetSize", _wrap_SBSymbol_GetSize},
{ "GetPrologueByteSize", _wrap_SBSymbol_GetPrologueByteSize},
{ "GetType", _wrap_SBSymbol_GetType},
+ { "__eq", _wrap_SBSymbol___eq},
{ "GetDescription", _wrap_SBSymbol_GetDescription},
{ "IsExternal", _wrap_SBSymbol_IsExternal},
{ "IsSynthetic", _wrap_SBSymbol_IsSynthetic},
- { "__eq", _wrap_SBSymbol___eq},
{ "__tostring", _wrap_SBSymbol___tostring},
{0,0}
};
@@ -47892,6 +53856,37 @@ static int _wrap_SBSymbolContextList_GetContextAtIndex(lua_State* L) {
}
+static int _wrap_SBSymbolContextList_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBSymbolContextList *arg1 = (lldb::SBSymbolContextList *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBSymbolContextList::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbolContextList::GetDescription",1,"lldb::SBSymbolContextList *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSymbolContextList::GetDescription",2,"lldb::SBStream &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSymbolContextList,0))){
+ SWIG_fail_ptr("SBSymbolContextList_GetDescription",1,SWIGTYPE_p_lldb__SBSymbolContextList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBSymbolContextList_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBSymbolContextList_Append__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48016,37 +54011,6 @@ static int _wrap_SBSymbolContextList_Append(lua_State* L) {
}
-static int _wrap_SBSymbolContextList_GetDescription(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBSymbolContextList *arg1 = (lldb::SBSymbolContextList *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBSymbolContextList::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBSymbolContextList::GetDescription",1,"lldb::SBSymbolContextList *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBSymbolContextList::GetDescription",2,"lldb::SBStream &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBSymbolContextList,0))){
- SWIG_fail_ptr("SBSymbolContextList_GetDescription",1,SWIGTYPE_p_lldb__SBSymbolContextList);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBSymbolContextList_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- result = (bool)(arg1)->GetDescription(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBSymbolContextList_Clear(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48113,8 +54077,8 @@ static swig_lua_method swig_SBSymbolContextList_methods[]= {
{ "IsValid", _wrap_SBSymbolContextList_IsValid},
{ "GetSize", _wrap_SBSymbolContextList_GetSize},
{ "GetContextAtIndex", _wrap_SBSymbolContextList_GetContextAtIndex},
- { "Append", _wrap_SBSymbolContextList_Append},
{ "GetDescription", _wrap_SBSymbolContextList_GetDescription},
+ { "Append", _wrap_SBSymbolContextList_Append},
{ "Clear", _wrap_SBSymbolContextList_Clear},
{ "__tostring", _wrap_SBSymbolContextList___tostring},
{0,0}
@@ -48223,23 +54187,6 @@ static int _wrap_new_SBTarget(lua_State* L) {
}
-static int _wrap_SBTarget_GetBroadcasterClassName(lua_State* L) {
- {
- int SWIG_arg = 0;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBTarget::GetBroadcasterClassName",0,0)
- result = (char *)lldb::SBTarget::GetBroadcasterClassName();
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTarget_IsValid(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48369,6 +54316,23 @@ static int _wrap_SBTarget_GetModuleAtIndexFromEvent(lua_State* L) {
}
+static int _wrap_SBTarget_GetBroadcasterClassName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTarget::GetBroadcasterClassName",0,0)
+ result = (char *)lldb::SBTarget::GetBroadcasterClassName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_GetProcess(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48396,6 +54360,173 @@ static int _wrap_SBTarget_GetProcess(lua_State* L) {
}
+static int _wrap_SBTarget_SetCollectingStats(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBTarget::SetCollectingStats",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::SetCollectingStats",1,"lldb::SBTarget *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBTarget::SetCollectingStats",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_SetCollectingStats",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetCollectingStats(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetCollectingStats(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetCollectingStats",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetCollectingStats",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetCollectingStats",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (bool)(arg1)->GetCollectingStats();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetStatistics__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetStatistics",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetStatistics",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetStatistics",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (arg1)->GetStatistics();
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetStatistics__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBStatisticsOptions arg2 ;
+ lldb::SBStatisticsOptions *argp2 ;
+ lldb::SBStructuredData result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetStatistics",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetStatistics",1,"lldb::SBTarget *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::GetStatistics",2,"lldb::SBStatisticsOptions");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetStatistics",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBStatisticsOptions,0))){
+ SWIG_fail_ptr("SBTarget_GetStatistics",2,SWIGTYPE_p_lldb__SBStatisticsOptions);
+ }
+ arg2 = *argp2;
+
+ result = (arg1)->GetStatistics(arg2);
+ {
+ lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetStatistics(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBTarget_GetStatistics__SWIG_0(L);
+ }
+ }
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBStatisticsOptions, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBTarget_GetStatistics__SWIG_1(L);
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBTarget_GetStatistics'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBTarget::GetStatistics()\n"
+ " lldb::SBTarget::GetStatistics(lldb::SBStatisticsOptions)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBTarget_GetPlatform(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48423,6 +54554,33 @@ static int _wrap_SBTarget_GetPlatform(lua_State* L) {
}
+static int _wrap_SBTarget_GetEnvironment(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBEnvironment result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetEnvironment",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetEnvironment",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetEnvironment",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (arg1)->GetEnvironment();
+ {
+ lldb::SBEnvironment * resultptr = new lldb::SBEnvironment(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBEnvironment,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_Install(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48569,6 +54727,137 @@ static int _wrap_SBTarget_Launch__SWIG_0(lua_State* L) {
}
+static int _wrap_SBTarget_LoadCore__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBProcess result;
+
+ SWIG_check_num_args("lldb::SBTarget::LoadCore",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::LoadCore",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::LoadCore",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_LoadCore",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->LoadCore((char const *)arg2);
+ {
+ lldb::SBProcess * resultptr = new lldb::SBProcess(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_LoadCore__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBError *arg3 = 0 ;
+ lldb::SBProcess result;
+
+ SWIG_check_num_args("lldb::SBTarget::LoadCore",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::LoadCore",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::LoadCore",2,"char const *");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::LoadCore",3,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_LoadCore",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBTarget_LoadCore",3,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->LoadCore((char const *)arg2,*arg3);
+ {
+ lldb::SBProcess * resultptr = new lldb::SBProcess(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_LoadCore(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBTarget_LoadCore__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBTarget_LoadCore__SWIG_1(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBTarget_LoadCore'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBTarget::LoadCore(char const *)\n"
+ " lldb::SBTarget::LoadCore(char const *,lldb::SBError &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBTarget_LaunchSimple(lua_State* L) {
{
int SWIG_arg = 0;
@@ -48824,137 +55113,6 @@ static int _wrap_SBTarget_Launch(lua_State* L) {
}
-static int _wrap_SBTarget_LoadCore__SWIG_0(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBProcess result;
-
- SWIG_check_num_args("lldb::SBTarget::LoadCore",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::LoadCore",1,"lldb::SBTarget *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::LoadCore",2,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_LoadCore",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->LoadCore((char const *)arg2);
- {
- lldb::SBProcess * resultptr = new lldb::SBProcess(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_LoadCore__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBError *arg3 = 0 ;
- lldb::SBProcess result;
-
- SWIG_check_num_args("lldb::SBTarget::LoadCore",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::LoadCore",1,"lldb::SBTarget *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::LoadCore",2,"char const *");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::LoadCore",3,"lldb::SBError &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_LoadCore",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBTarget_LoadCore",3,SWIGTYPE_p_lldb__SBError);
- }
-
- result = (arg1)->LoadCore((char const *)arg2,*arg3);
- {
- lldb::SBProcess * resultptr = new lldb::SBProcess(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_LoadCore(lua_State* L) {
- int argc;
- int argv[4]={
- 1,2,3,4
- };
-
- argc = lua_gettop(L);
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = SWIG_lua_isnilstring(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBTarget_LoadCore__SWIG_0(L);
- }
- }
- }
- if (argc == 3) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = SWIG_lua_isnilstring(L,argv[1]);
- }
- if (_v) {
- {
- void *ptr;
- if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBTarget_LoadCore__SWIG_1(L);
- }
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBTarget_LoadCore'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBTarget::LoadCore(char const *)\n"
- " lldb::SBTarget::LoadCore(char const *,lldb::SBError &)\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBTarget_Attach(lua_State* L) {
{
int SWIG_arg = 0;
@@ -49744,6 +55902,60 @@ static int _wrap_SBTarget_GetABIName(lua_State* L) {
}
+static int _wrap_SBTarget_GetLabel(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTarget::GetLabel",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetLabel",1,"lldb::SBTarget const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetLabel",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (char *)((lldb::SBTarget const *)arg1)->GetLabel();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_SetLabel(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBError result;
+
+ SWIG_check_num_args("lldb::SBTarget::SetLabel",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::SetLabel",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::SetLabel",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_SetLabel",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->SetLabel((char const *)arg2);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_GetDataByteSize(lua_State* L) {
{
int SWIG_arg = 0;
@@ -49896,14 +56108,14 @@ static int _wrap_SBTarget_SetModuleLoadAddress(lua_State* L) {
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
lldb::SBModule arg2 ;
- int64_t arg3 ;
+ uint64_t arg3 ;
lldb::SBModule *argp2 ;
lldb::SBError result;
SWIG_check_num_args("lldb::SBTarget::SetModuleLoadAddress",3,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::SetModuleLoadAddress",1,"lldb::SBTarget *");
if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::SetModuleLoadAddress",2,"lldb::SBModule");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::SetModuleLoadAddress",3,"int64_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::SetModuleLoadAddress",3,"uint64_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
SWIG_fail_ptr("SBTarget_SetModuleLoadAddress",1,SWIGTYPE_p_lldb__SBTarget);
@@ -49915,7 +56127,7 @@ static int _wrap_SBTarget_SetModuleLoadAddress(lua_State* L) {
}
arg2 = *argp2;
- arg3 = (int64_t)lua_tointeger(L, 3);
+ arg3 = (uint64_t)lua_tointeger(L, 3);
result = (arg1)->SetModuleLoadAddress(arg2,arg3);
{
lldb::SBError * resultptr = new lldb::SBError(result);
@@ -50088,123 +56300,6 @@ static int _wrap_SBTarget_FindFunctions(lua_State* L) {
}
-static int _wrap_SBTarget_FindFirstType(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBType result;
-
- SWIG_check_num_args("lldb::SBTarget::FindFirstType",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindFirstType",1,"lldb::SBTarget *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::FindFirstType",2,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_FindFirstType",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->FindFirstType((char const *)arg2);
- {
- lldb::SBType * resultptr = new lldb::SBType(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_FindTypes(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBTypeList result;
-
- SWIG_check_num_args("lldb::SBTarget::FindTypes",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindTypes",1,"lldb::SBTarget *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::FindTypes",2,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_FindTypes",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->FindTypes((char const *)arg2);
- {
- lldb::SBTypeList * resultptr = new lldb::SBTypeList(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTypeList,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetBasicType(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::BasicType arg2 ;
- lldb::SBType result;
-
- SWIG_check_num_args("lldb::SBTarget::GetBasicType",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBasicType",1,"lldb::SBTarget *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::GetBasicType",2,"lldb::BasicType");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetBasicType",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (lldb::BasicType)lua_tointeger(L, 2);
- result = (arg1)->GetBasicType(arg2);
- {
- lldb::SBType * resultptr = new lldb::SBType(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetSourceManager(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- SwigValueWrapper< lldb::SBSourceManager > result;
-
- SWIG_check_num_args("lldb::SBTarget::GetSourceManager",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetSourceManager",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetSourceManager",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (arg1)->GetSourceManager();
- {
- lldb::SBSourceManager * resultptr = new lldb::SBSourceManager(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBSourceManager,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTarget_FindGlobalVariables__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -51203,6 +57298,50 @@ static int _wrap_SBTarget_BreakpointCreateByName__SWIG_2(lua_State* L) {
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
char *arg2 = (char *) 0 ;
+ lldb::SBFileSpecList *arg3 = 0 ;
+ lldb::SBFileSpecList *arg4 = 0 ;
+ lldb::SBBreakpoint result;
+
+ SWIG_check_num_args("lldb::SBTarget::BreakpointCreateByName",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByName",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByName",2,"char const *");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByName",3,"lldb::SBFileSpecList const &");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByName",4,"lldb::SBFileSpecList const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointCreateByName",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBFileSpecList,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointCreateByName",3,SWIGTYPE_p_lldb__SBFileSpecList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBFileSpecList,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointCreateByName",4,SWIGTYPE_p_lldb__SBFileSpecList);
+ }
+
+ result = (arg1)->BreakpointCreateByName((char const *)arg2,(lldb::SBFileSpecList const &)*arg3,(lldb::SBFileSpecList const &)*arg4);
+ {
+ lldb::SBBreakpoint * resultptr = new lldb::SBBreakpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBreakpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_BreakpointCreateByName__SWIG_3(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
uint32_t arg3 ;
lldb::SBFileSpecList *arg4 = 0 ;
lldb::SBFileSpecList *arg5 = 0 ;
@@ -51245,7 +57384,7 @@ static int _wrap_SBTarget_BreakpointCreateByName__SWIG_2(lua_State* L) {
}
-static int _wrap_SBTarget_BreakpointCreateByName__SWIG_3(lua_State* L) {
+static int _wrap_SBTarget_BreakpointCreateByName__SWIG_4(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
@@ -51345,6 +57484,45 @@ static int _wrap_SBTarget_BreakpointCreateByName(lua_State* L) {
}
}
}
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpecList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[3])==0 || SWIG_ConvertPtr(L,argv[3], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpecList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBTarget_BreakpointCreateByName__SWIG_2(L);
+ }
+ }
+ }
+ }
+ }
if (argc == 5) {
int _v = 0;
{
@@ -51382,7 +57560,7 @@ static int _wrap_SBTarget_BreakpointCreateByName(lua_State* L) {
}
}
if (_v) {
- return _wrap_SBTarget_BreakpointCreateByName__SWIG_2(L);
+ return _wrap_SBTarget_BreakpointCreateByName__SWIG_3(L);
}
}
}
@@ -51430,7 +57608,7 @@ static int _wrap_SBTarget_BreakpointCreateByName(lua_State* L) {
}
}
if (_v) {
- return _wrap_SBTarget_BreakpointCreateByName__SWIG_3(L);
+ return _wrap_SBTarget_BreakpointCreateByName__SWIG_4(L);
}
}
}
@@ -51443,6 +57621,7 @@ static int _wrap_SBTarget_BreakpointCreateByName(lua_State* L) {
" Possible C/C++ prototypes are:\n"
" lldb::SBTarget::BreakpointCreateByName(char const *,char const *)\n"
" lldb::SBTarget::BreakpointCreateByName(char const *)\n"
+ " lldb::SBTarget::BreakpointCreateByName(char const *,lldb::SBFileSpecList const &,lldb::SBFileSpecList const &)\n"
" lldb::SBTarget::BreakpointCreateByName(char const *,uint32_t,lldb::SBFileSpecList const &,lldb::SBFileSpecList const &)\n"
" lldb::SBTarget::BreakpointCreateByName(char const *,uint32_t,lldb::LanguageType,lldb::SBFileSpecList const &,lldb::SBFileSpecList const &)\n");
lua_error(L);return 0;
@@ -51936,6 +58115,50 @@ static int _wrap_SBTarget_BreakpointCreateByRegex__SWIG_2(lua_State* L) {
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
char *arg2 = (char *) 0 ;
+ lldb::SBFileSpecList *arg3 = 0 ;
+ lldb::SBFileSpecList *arg4 = 0 ;
+ lldb::SBBreakpoint result;
+
+ SWIG_check_num_args("lldb::SBTarget::BreakpointCreateByRegex",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByRegex",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByRegex",2,"char const *");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByRegex",3,"lldb::SBFileSpecList const &");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBTarget::BreakpointCreateByRegex",4,"lldb::SBFileSpecList const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointCreateByRegex",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBFileSpecList,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointCreateByRegex",3,SWIGTYPE_p_lldb__SBFileSpecList);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBFileSpecList,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointCreateByRegex",4,SWIGTYPE_p_lldb__SBFileSpecList);
+ }
+
+ result = (arg1)->BreakpointCreateByRegex((char const *)arg2,(lldb::SBFileSpecList const &)*arg3,(lldb::SBFileSpecList const &)*arg4);
+ {
+ lldb::SBBreakpoint * resultptr = new lldb::SBBreakpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBreakpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_BreakpointCreateByRegex__SWIG_3(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
lldb::LanguageType arg3 ;
lldb::SBFileSpecList *arg4 = 0 ;
lldb::SBFileSpecList *arg5 = 0 ;
@@ -52028,6 +58251,45 @@ static int _wrap_SBTarget_BreakpointCreateByRegex(lua_State* L) {
}
}
}
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpecList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[3])==0 || SWIG_ConvertPtr(L,argv[3], (void **) &ptr, SWIGTYPE_p_lldb__SBFileSpecList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBTarget_BreakpointCreateByRegex__SWIG_2(L);
+ }
+ }
+ }
+ }
+ }
if (argc == 5) {
int _v = 0;
{
@@ -52065,7 +58327,7 @@ static int _wrap_SBTarget_BreakpointCreateByRegex(lua_State* L) {
}
}
if (_v) {
- return _wrap_SBTarget_BreakpointCreateByRegex__SWIG_2(L);
+ return _wrap_SBTarget_BreakpointCreateByRegex__SWIG_3(L);
}
}
}
@@ -52077,6 +58339,7 @@ static int _wrap_SBTarget_BreakpointCreateByRegex(lua_State* L) {
" Possible C/C++ prototypes are:\n"
" lldb::SBTarget::BreakpointCreateByRegex(char const *,char const *)\n"
" lldb::SBTarget::BreakpointCreateByRegex(char const *)\n"
+ " lldb::SBTarget::BreakpointCreateByRegex(char const *,lldb::SBFileSpecList const &,lldb::SBFileSpecList const &)\n"
" lldb::SBTarget::BreakpointCreateByRegex(char const *,lldb::LanguageType,lldb::SBFileSpecList const &,lldb::SBFileSpecList const &)\n");
lua_error(L);return 0;
}
@@ -52489,33 +58752,6 @@ static int _wrap_SBTarget_BreakpointCreateByAddress(lua_State* L) {
}
-static int _wrap_SBTarget_GetEnvironment(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBEnvironment result;
-
- SWIG_check_num_args("lldb::SBTarget::GetEnvironment",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetEnvironment",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetEnvironment",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (arg1)->GetEnvironment();
- {
- lldb::SBEnvironment * resultptr = new lldb::SBEnvironment(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBEnvironment,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTarget_BreakpointCreateBySBAddress(lua_State* L) {
{
int SWIG_arg = 0;
@@ -52774,279 +59010,6 @@ static int _wrap_SBTarget_BreakpointCreateFromScript(lua_State* L) {
}
-static int _wrap_SBTarget_GetNumBreakpoints(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- uint32_t result;
-
- SWIG_check_num_args("lldb::SBTarget::GetNumBreakpoints",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetNumBreakpoints",1,"lldb::SBTarget const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetNumBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (uint32_t)((lldb::SBTarget const *)arg1)->GetNumBreakpoints();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetBreakpointAtIndex(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- uint32_t arg2 ;
- lldb::SBBreakpoint result;
-
- SWIG_check_num_args("lldb::SBTarget::GetBreakpointAtIndex",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointAtIndex",1,"lldb::SBTarget const *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointAtIndex",2,"uint32_t");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetBreakpointAtIndex",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (uint32_t)lua_tointeger(L, 2);
- result = ((lldb::SBTarget const *)arg1)->GetBreakpointAtIndex(arg2);
- {
- lldb::SBBreakpoint * resultptr = new lldb::SBBreakpoint(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBreakpoint,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_BreakpointDelete(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::break_id_t arg2 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::BreakpointDelete",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::BreakpointDelete",1,"lldb::SBTarget *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::BreakpointDelete",2,"lldb::break_id_t");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_BreakpointDelete",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (lldb::break_id_t)lua_tointeger(L, 2);
- result = (bool)(arg1)->BreakpointDelete(arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_FindBreakpointByID(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::break_id_t arg2 ;
- lldb::SBBreakpoint result;
-
- SWIG_check_num_args("lldb::SBTarget::FindBreakpointByID",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointByID",1,"lldb::SBTarget *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointByID",2,"lldb::break_id_t");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_FindBreakpointByID",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (lldb::break_id_t)lua_tointeger(L, 2);
- result = (arg1)->FindBreakpointByID(arg2);
- {
- lldb::SBBreakpoint * resultptr = new lldb::SBBreakpoint(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBreakpoint,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_FindBreakpointsByName(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- char *arg2 = (char *) 0 ;
- lldb::SBBreakpointList *arg3 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::FindBreakpointsByName",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointsByName",1,"lldb::SBTarget *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointsByName",2,"char const *");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointsByName",3,"lldb::SBBreakpointList &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_FindBreakpointsByName",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBBreakpointList,0))){
- SWIG_fail_ptr("SBTarget_FindBreakpointsByName",3,SWIGTYPE_p_lldb__SBBreakpointList);
- }
-
- result = (bool)(arg1)->FindBreakpointsByName((char const *)arg2,*arg3);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_DeleteBreakpointName(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- char *arg2 = (char *) 0 ;
-
- SWIG_check_num_args("lldb::SBTarget::DeleteBreakpointName",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::DeleteBreakpointName",1,"lldb::SBTarget *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::DeleteBreakpointName",2,"char const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_DeleteBreakpointName",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- arg2 = (char *)lua_tostring(L, 2);
- (arg1)->DeleteBreakpointName((char const *)arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetBreakpointNames(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBStringList *arg2 = 0 ;
-
- SWIG_check_num_args("lldb::SBTarget::GetBreakpointNames",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointNames",1,"lldb::SBTarget *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointNames",2,"lldb::SBStringList &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetBreakpointNames",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStringList,0))){
- SWIG_fail_ptr("SBTarget_GetBreakpointNames",2,SWIGTYPE_p_lldb__SBStringList);
- }
-
- (arg1)->GetBreakpointNames(*arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_EnableAllBreakpoints(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::EnableAllBreakpoints",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::EnableAllBreakpoints",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_EnableAllBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (bool)(arg1)->EnableAllBreakpoints();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_DisableAllBreakpoints(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::DisableAllBreakpoints",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::DisableAllBreakpoints",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_DisableAllBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (bool)(arg1)->DisableAllBreakpoints();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_DeleteAllBreakpoints(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::DeleteAllBreakpoints",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::DeleteAllBreakpoints",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_DeleteAllBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (bool)(arg1)->DeleteAllBreakpoints();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTarget_BreakpointsCreateFromFile__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -53463,6 +59426,279 @@ static int _wrap_SBTarget_BreakpointsWriteToFile(lua_State* L) {
}
+static int _wrap_SBTarget_GetNumBreakpoints(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ uint32_t result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetNumBreakpoints",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetNumBreakpoints",1,"lldb::SBTarget const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetNumBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (uint32_t)((lldb::SBTarget const *)arg1)->GetNumBreakpoints();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetBreakpointAtIndex(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ uint32_t arg2 ;
+ lldb::SBBreakpoint result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetBreakpointAtIndex",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointAtIndex",1,"lldb::SBTarget const *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointAtIndex",2,"uint32_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetBreakpointAtIndex",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ result = ((lldb::SBTarget const *)arg1)->GetBreakpointAtIndex(arg2);
+ {
+ lldb::SBBreakpoint * resultptr = new lldb::SBBreakpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBreakpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_BreakpointDelete(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::break_id_t arg2 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::BreakpointDelete",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::BreakpointDelete",1,"lldb::SBTarget *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::BreakpointDelete",2,"lldb::break_id_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_BreakpointDelete",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (lldb::break_id_t)lua_tointeger(L, 2);
+ result = (bool)(arg1)->BreakpointDelete(arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_FindBreakpointByID(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::break_id_t arg2 ;
+ lldb::SBBreakpoint result;
+
+ SWIG_check_num_args("lldb::SBTarget::FindBreakpointByID",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointByID",1,"lldb::SBTarget *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointByID",2,"lldb::break_id_t");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_FindBreakpointByID",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (lldb::break_id_t)lua_tointeger(L, 2);
+ result = (arg1)->FindBreakpointByID(arg2);
+ {
+ lldb::SBBreakpoint * resultptr = new lldb::SBBreakpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBreakpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_FindBreakpointsByName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBBreakpointList *arg3 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::FindBreakpointsByName",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointsByName",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointsByName",2,"char const *");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::FindBreakpointsByName",3,"lldb::SBBreakpointList &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_FindBreakpointsByName",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBBreakpointList,0))){
+ SWIG_fail_ptr("SBTarget_FindBreakpointsByName",3,SWIGTYPE_p_lldb__SBBreakpointList);
+ }
+
+ result = (bool)(arg1)->FindBreakpointsByName((char const *)arg2,*arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetBreakpointNames(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBStringList *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBTarget::GetBreakpointNames",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointNames",1,"lldb::SBTarget *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::GetBreakpointNames",2,"lldb::SBStringList &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetBreakpointNames",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStringList,0))){
+ SWIG_fail_ptr("SBTarget_GetBreakpointNames",2,SWIGTYPE_p_lldb__SBStringList);
+ }
+
+ (arg1)->GetBreakpointNames(*arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_DeleteBreakpointName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
+
+ SWIG_check_num_args("lldb::SBTarget::DeleteBreakpointName",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::DeleteBreakpointName",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::DeleteBreakpointName",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_DeleteBreakpointName",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ (arg1)->DeleteBreakpointName((char const *)arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_EnableAllBreakpoints(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::EnableAllBreakpoints",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::EnableAllBreakpoints",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_EnableAllBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (bool)(arg1)->EnableAllBreakpoints();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_DisableAllBreakpoints(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::DisableAllBreakpoints",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::DisableAllBreakpoints",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_DisableAllBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (bool)(arg1)->DisableAllBreakpoints();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_DeleteAllBreakpoints(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::DeleteAllBreakpoints",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::DeleteAllBreakpoints",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_DeleteAllBreakpoints",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (bool)(arg1)->DeleteAllBreakpoints();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_GetNumWatchpoints(lua_State* L) {
{
int SWIG_arg = 0;
@@ -53574,6 +59810,101 @@ static int _wrap_SBTarget_FindWatchpointByID(lua_State* L) {
}
+static int _wrap_SBTarget_WatchAddress(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::addr_t arg2 ;
+ size_t arg3 ;
+ bool arg4 ;
+ bool arg5 ;
+ lldb::SBError *arg6 = 0 ;
+ lldb::SBWatchpoint result;
+
+ SWIG_check_num_args("lldb::SBTarget::WatchAddress",6,6)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",1,"lldb::SBTarget *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",2,"lldb::addr_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",3,"size_t");
+ if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",4,"bool");
+ if(!lua_isboolean(L,5)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",5,"bool");
+ if(!lua_isuserdata(L,6)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",6,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_WatchAddress",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (lldb::addr_t)lua_tointeger(L, 2);
+ arg3 = (size_t)lua_tointeger(L, 3);
+ arg4 = (lua_toboolean(L, 4)!=0);
+ arg5 = (lua_toboolean(L, 5)!=0);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,6,(void**)&arg6,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBTarget_WatchAddress",6,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->WatchAddress(arg2,arg3,arg4,arg5,*arg6);
+ {
+ lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_WatchpointCreateByAddress(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::addr_t arg2 ;
+ size_t arg3 ;
+ lldb::SBWatchpointOptions arg4 ;
+ lldb::SBError *arg5 = 0 ;
+ lldb::SBWatchpointOptions *argp4 ;
+ lldb::SBWatchpoint result;
+
+ SWIG_check_num_args("lldb::SBTarget::WatchpointCreateByAddress",5,5)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::WatchpointCreateByAddress",1,"lldb::SBTarget *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::WatchpointCreateByAddress",2,"lldb::addr_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::WatchpointCreateByAddress",3,"size_t");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBTarget::WatchpointCreateByAddress",4,"lldb::SBWatchpointOptions");
+ if(!lua_isuserdata(L,5)) SWIG_fail_arg("lldb::SBTarget::WatchpointCreateByAddress",5,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_WatchpointCreateByAddress",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (lldb::addr_t)lua_tointeger(L, 2);
+ arg3 = (size_t)lua_tointeger(L, 3);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&argp4,SWIGTYPE_p_lldb__SBWatchpointOptions,0))){
+ SWIG_fail_ptr("SBTarget_WatchpointCreateByAddress",4,SWIGTYPE_p_lldb__SBWatchpointOptions);
+ }
+ arg4 = *argp4;
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBTarget_WatchpointCreateByAddress",5,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->WatchpointCreateByAddress(arg2,arg3,arg4,*arg5);
+ {
+ lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_EnableAllWatchpoints(lua_State* L) {
{
int SWIG_arg = 0;
@@ -53646,42 +59977,53 @@ static int _wrap_SBTarget_DeleteAllWatchpoints(lua_State* L) {
}
-static int _wrap_SBTarget_WatchAddress(lua_State* L) {
+static int _wrap_SBTarget_GetBroadcaster(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::addr_t arg2 ;
- size_t arg3 ;
- bool arg4 ;
- bool arg5 ;
- lldb::SBError *arg6 = 0 ;
- lldb::SBWatchpoint result;
+ lldb::SBBroadcaster result;
- SWIG_check_num_args("lldb::SBTarget::WatchAddress",6,6)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",1,"lldb::SBTarget *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",2,"lldb::addr_t");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",3,"size_t");
- if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",4,"bool");
- if(!lua_isboolean(L,5)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",5,"bool");
- if(!lua_isuserdata(L,6)) SWIG_fail_arg("lldb::SBTarget::WatchAddress",6,"lldb::SBError &");
+ SWIG_check_num_args("lldb::SBTarget::GetBroadcaster",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBroadcaster",1,"lldb::SBTarget const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_WatchAddress",1,SWIGTYPE_p_lldb__SBTarget);
+ SWIG_fail_ptr("SBTarget_GetBroadcaster",1,SWIGTYPE_p_lldb__SBTarget);
}
- arg2 = (lldb::addr_t)lua_tointeger(L, 2);
- arg3 = (size_t)lua_tointeger(L, 3);
- arg4 = (lua_toboolean(L, 4)!=0);
- arg5 = (lua_toboolean(L, 5)!=0);
+ result = ((lldb::SBTarget const *)arg1)->GetBroadcaster();
+ {
+ lldb::SBBroadcaster * resultptr = new lldb::SBBroadcaster(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBroadcaster,1); SWIG_arg++;
+ }
+ return SWIG_arg;
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,6,(void**)&arg6,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBTarget_WatchAddress",6,SWIGTYPE_p_lldb__SBError);
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_FindFirstType(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBType result;
+
+ SWIG_check_num_args("lldb::SBTarget::FindFirstType",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindFirstType",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::FindFirstType",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_FindFirstType",1,SWIGTYPE_p_lldb__SBTarget);
}
- result = (arg1)->WatchAddress(arg2,arg3,arg4,arg5,*arg6);
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->FindFirstType((char const *)arg2);
{
- lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ lldb::SBType * resultptr = new lldb::SBType(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
}
return SWIG_arg;
@@ -53692,23 +60034,56 @@ static int _wrap_SBTarget_WatchAddress(lua_State* L) {
}
-static int _wrap_SBTarget_GetBroadcaster(lua_State* L) {
+static int _wrap_SBTarget_FindTypes(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBBroadcaster result;
+ char *arg2 = (char *) 0 ;
+ lldb::SBTypeList result;
- SWIG_check_num_args("lldb::SBTarget::GetBroadcaster",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBroadcaster",1,"lldb::SBTarget const *");
+ SWIG_check_num_args("lldb::SBTarget::FindTypes",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::FindTypes",1,"lldb::SBTarget *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBTarget::FindTypes",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetBroadcaster",1,SWIGTYPE_p_lldb__SBTarget);
+ SWIG_fail_ptr("SBTarget_FindTypes",1,SWIGTYPE_p_lldb__SBTarget);
}
- result = ((lldb::SBTarget const *)arg1)->GetBroadcaster();
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->FindTypes((char const *)arg2);
{
- lldb::SBBroadcaster * resultptr = new lldb::SBBroadcaster(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBBroadcaster,1); SWIG_arg++;
+ lldb::SBTypeList * resultptr = new lldb::SBTypeList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTypeList,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetBasicType(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::BasicType arg2 ;
+ lldb::SBType result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetBasicType",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetBasicType",1,"lldb::SBTarget *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBTarget::GetBasicType",2,"lldb::BasicType");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetBasicType",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ arg2 = (lldb::BasicType)lua_tointeger(L, 2);
+ result = (arg1)->GetBasicType(arg2);
+ {
+ lldb::SBType * resultptr = new lldb::SBType(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
}
return SWIG_arg;
@@ -53848,6 +60223,33 @@ static int _wrap_SBTarget_CreateValueFromExpression(lua_State* L) {
}
+static int _wrap_SBTarget_GetSourceManager(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ SwigValueWrapper< lldb::SBSourceManager > result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetSourceManager",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetSourceManager",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetSourceManager",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = (arg1)->GetSourceManager();
+ {
+ lldb::SBSourceManager * resultptr = new lldb::SBSourceManager(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBSourceManager,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_ReadInstructions__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -53929,6 +60331,54 @@ static int _wrap_SBTarget_ReadInstructions__SWIG_1(lua_State* L) {
}
+static int _wrap_SBTarget_ReadInstructions__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBAddress arg2 ;
+ lldb::SBAddress arg3 ;
+ char *arg4 = (char *) 0 ;
+ lldb::SBAddress *argp2 ;
+ lldb::SBAddress *argp3 ;
+ lldb::SBInstructionList result;
+
+ SWIG_check_num_args("lldb::SBTarget::ReadInstructions",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::ReadInstructions",1,"lldb::SBTarget *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::ReadInstructions",2,"lldb::SBAddress");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTarget::ReadInstructions",3,"lldb::SBAddress");
+ if(!SWIG_lua_isnilstring(L,4)) SWIG_fail_arg("lldb::SBTarget::ReadInstructions",4,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_ReadInstructions",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBTarget_ReadInstructions",2,SWIGTYPE_p_lldb__SBAddress);
+ }
+ arg2 = *argp2;
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBTarget_ReadInstructions",3,SWIGTYPE_p_lldb__SBAddress);
+ }
+ arg3 = *argp3;
+
+ arg4 = (char *)lua_tostring(L, 4);
+ result = (arg1)->ReadInstructions(arg2,arg3,(char const *)arg4);
+ {
+ lldb::SBInstructionList * resultptr = new lldb::SBInstructionList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBInstructionList,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTarget_ReadInstructions(lua_State* L) {
int argc;
int argv[5]={
@@ -53986,6 +60436,45 @@ static int _wrap_SBTarget_ReadInstructions(lua_State* L) {
}
if (_v) {
{
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = SWIG_lua_isnilstring(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_SBTarget_ReadInstructions__SWIG_2(L);
+ }
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTarget, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
_v = lua_isnumber(L,argv[2]);
}
if (_v) {
@@ -54003,7 +60492,8 @@ static int _wrap_SBTarget_ReadInstructions(lua_State* L) {
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBTarget_ReadInstructions'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBTarget::ReadInstructions(lldb::SBAddress,uint32_t)\n"
- " lldb::SBTarget::ReadInstructions(lldb::SBAddress,uint32_t,char const *)\n");
+ " lldb::SBTarget::ReadInstructions(lldb::SBAddress,uint32_t,char const *)\n"
+ " lldb::SBTarget::ReadInstructions(lldb::SBAddress,lldb::SBAddress,char const *)\n");
lua_error(L);return 0;
}
@@ -54215,192 +60705,27 @@ static int _wrap_SBTarget_FindSymbols(lua_State* L) {
}
-static int _wrap_SBTarget_GetDescription(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- lldb::DescriptionLevel arg3 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::GetDescription",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetDescription",1,"lldb::SBTarget *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::GetDescription",2,"lldb::SBStream &");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::GetDescription",3,"lldb::DescriptionLevel");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetDescription",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBTarget_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
- }
-
- arg3 = (lldb::DescriptionLevel)lua_tointeger(L, 3);
- result = (bool)(arg1)->GetDescription(*arg2,arg3);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetStackRedZoneSize(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::addr_t result;
-
- SWIG_check_num_args("lldb::SBTarget::GetStackRedZoneSize",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetStackRedZoneSize",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetStackRedZoneSize",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (lldb::addr_t)(arg1)->GetStackRedZoneSize();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_IsLoaded(lua_State* L) {
+static int _wrap_SBTarget___eq(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBModule *arg2 = 0 ;
+ lldb::SBTarget *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBTarget::IsLoaded",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::IsLoaded",1,"lldb::SBTarget const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::IsLoaded",2,"lldb::SBModule const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_IsLoaded",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBModule,0))){
- SWIG_fail_ptr("SBTarget_IsLoaded",2,SWIGTYPE_p_lldb__SBModule);
- }
-
- result = (bool)((lldb::SBTarget const *)arg1)->IsLoaded((lldb::SBModule const &)*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetLaunchInfo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- SwigValueWrapper< lldb::SBLaunchInfo > result;
-
- SWIG_check_num_args("lldb::SBTarget::GetLaunchInfo",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetLaunchInfo",1,"lldb::SBTarget const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetLaunchInfo",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = ((lldb::SBTarget const *)arg1)->GetLaunchInfo();
- {
- lldb::SBLaunchInfo * resultptr = new lldb::SBLaunchInfo(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBLaunchInfo,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_SetLaunchInfo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBLaunchInfo *arg2 = 0 ;
-
- SWIG_check_num_args("lldb::SBTarget::SetLaunchInfo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::SetLaunchInfo",1,"lldb::SBTarget *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::SetLaunchInfo",2,"lldb::SBLaunchInfo const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_SetLaunchInfo",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBLaunchInfo,0))){
- SWIG_fail_ptr("SBTarget_SetLaunchInfo",2,SWIGTYPE_p_lldb__SBLaunchInfo);
- }
-
- (arg1)->SetLaunchInfo((lldb::SBLaunchInfo const &)*arg2);
-
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_SetCollectingStats(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- bool arg2 ;
-
- SWIG_check_num_args("lldb::SBTarget::SetCollectingStats",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::SetCollectingStats",1,"lldb::SBTarget *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBTarget::SetCollectingStats",2,"bool");
+ SWIG_check_num_args("lldb::SBTarget::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::operator ==",1,"lldb::SBTarget const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::operator ==",2,"lldb::SBTarget const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_SetCollectingStats",1,SWIGTYPE_p_lldb__SBTarget);
+ SWIG_fail_ptr("SBTarget___eq",1,SWIGTYPE_p_lldb__SBTarget);
}
- arg2 = (lua_toboolean(L, 2)!=0);
- (arg1)->SetCollectingStats(arg2);
-
- return SWIG_arg;
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget_GetCollectingStats(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTarget::GetCollectingStats",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetCollectingStats",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetCollectingStats",1,SWIGTYPE_p_lldb__SBTarget);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget___eq",2,SWIGTYPE_p_lldb__SBTarget);
}
- result = (bool)(arg1)->GetCollectingStats();
+ result = (bool)((lldb::SBTarget const *)arg1)->operator ==((lldb::SBTarget const &)*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -54411,54 +60736,30 @@ static int _wrap_SBTarget_GetCollectingStats(lua_State* L) {
}
-static int _wrap_SBTarget_GetStatistics(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBStructuredData result;
-
- SWIG_check_num_args("lldb::SBTarget::GetStatistics",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetStatistics",1,"lldb::SBTarget *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget_GetStatistics",1,SWIGTYPE_p_lldb__SBTarget);
- }
-
- result = (arg1)->GetStatistics();
- {
- lldb::SBStructuredData * resultptr = new lldb::SBStructuredData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBStructuredData,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBTarget___eq(lua_State* L) {
+static int _wrap_SBTarget_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- lldb::SBTarget *arg2 = 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::DescriptionLevel arg3 ;
bool result;
- SWIG_check_num_args("lldb::SBTarget::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::operator ==",1,"lldb::SBTarget const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::operator ==",2,"lldb::SBTarget const &");
+ SWIG_check_num_args("lldb::SBTarget::GetDescription",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetDescription",1,"lldb::SBTarget *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::GetDescription",2,"lldb::SBStream &");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTarget::GetDescription",3,"lldb::DescriptionLevel");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget___eq",1,SWIGTYPE_p_lldb__SBTarget);
+ SWIG_fail_ptr("SBTarget_GetDescription",1,SWIGTYPE_p_lldb__SBTarget);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget___eq",2,SWIGTYPE_p_lldb__SBTarget);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBTarget_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
}
- result = (bool)((lldb::SBTarget const *)arg1)->operator ==((lldb::SBTarget const &)*arg2);
+ arg3 = (lldb::DescriptionLevel)lua_tointeger(L, 3);
+ result = (bool)(arg1)->GetDescription(*arg2,arg3);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -54600,21 +60901,109 @@ static int _wrap_SBTarget_EvaluateExpression(lua_State* L) {
}
-static int _wrap_SBTarget___tostring(lua_State* L) {
+static int _wrap_SBTarget_GetStackRedZoneSize(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
- std::string result;
+ lldb::addr_t result;
- SWIG_check_num_args("lldb::SBTarget::__repr__",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::__repr__",1,"lldb::SBTarget *");
+ SWIG_check_num_args("lldb::SBTarget::GetStackRedZoneSize",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetStackRedZoneSize",1,"lldb::SBTarget *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
- SWIG_fail_ptr("SBTarget___tostring",1,SWIGTYPE_p_lldb__SBTarget);
+ SWIG_fail_ptr("SBTarget_GetStackRedZoneSize",1,SWIGTYPE_p_lldb__SBTarget);
}
- result = lldb_SBTarget___repr__(arg1);
- lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++;
+ result = (lldb::addr_t)(arg1)->GetStackRedZoneSize();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_IsLoaded(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBModule *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTarget::IsLoaded",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::IsLoaded",1,"lldb::SBTarget const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::IsLoaded",2,"lldb::SBModule const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_IsLoaded",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBModule,0))){
+ SWIG_fail_ptr("SBTarget_IsLoaded",2,SWIGTYPE_p_lldb__SBModule);
+ }
+
+ result = (bool)((lldb::SBTarget const *)arg1)->IsLoaded((lldb::SBModule const &)*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_GetLaunchInfo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ SwigValueWrapper< lldb::SBLaunchInfo > result;
+
+ SWIG_check_num_args("lldb::SBTarget::GetLaunchInfo",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::GetLaunchInfo",1,"lldb::SBTarget const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_GetLaunchInfo",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = ((lldb::SBTarget const *)arg1)->GetLaunchInfo();
+ {
+ lldb::SBLaunchInfo * resultptr = new lldb::SBLaunchInfo(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBLaunchInfo,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTarget_SetLaunchInfo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ lldb::SBLaunchInfo *arg2 = 0 ;
+
+ SWIG_check_num_args("lldb::SBTarget::SetLaunchInfo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::SetLaunchInfo",1,"lldb::SBTarget *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTarget::SetLaunchInfo",2,"lldb::SBLaunchInfo const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget_SetLaunchInfo",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBLaunchInfo,0))){
+ SWIG_fail_ptr("SBTarget_SetLaunchInfo",2,SWIGTYPE_p_lldb__SBLaunchInfo);
+ }
+
+ (arg1)->SetLaunchInfo((lldb::SBLaunchInfo const &)*arg2);
+
return SWIG_arg;
fail: SWIGUNUSED;
@@ -54685,6 +61074,30 @@ static int _wrap_SBTarget_CreateTrace(lua_State* L) {
}
+static int _wrap_SBTarget___tostring(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTarget *arg1 = (lldb::SBTarget *) 0 ;
+ std::string result;
+
+ SWIG_check_num_args("lldb::SBTarget::__repr__",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTarget::__repr__",1,"lldb::SBTarget *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTarget___tostring",1,SWIGTYPE_p_lldb__SBTarget);
+ }
+
+ result = lldb_SBTarget___repr__(arg1);
+ lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static void swig_delete_SBTarget(void *obj) {
lldb::SBTarget *arg1 = (lldb::SBTarget *) obj;
delete arg1;
@@ -54703,11 +61116,15 @@ static swig_lua_attribute swig_SBTarget_attributes[] = {
static swig_lua_method swig_SBTarget_methods[]= {
{ "IsValid", _wrap_SBTarget_IsValid},
{ "GetProcess", _wrap_SBTarget_GetProcess},
+ { "SetCollectingStats", _wrap_SBTarget_SetCollectingStats},
+ { "GetCollectingStats", _wrap_SBTarget_GetCollectingStats},
+ { "GetStatistics", _wrap_SBTarget_GetStatistics},
{ "GetPlatform", _wrap_SBTarget_GetPlatform},
+ { "GetEnvironment", _wrap_SBTarget_GetEnvironment},
{ "Install", _wrap_SBTarget_Install},
+ { "LoadCore", _wrap_SBTarget_LoadCore},
{ "LaunchSimple", _wrap_SBTarget_LaunchSimple},
{ "Launch", _wrap_SBTarget_Launch},
- { "LoadCore", _wrap_SBTarget_LoadCore},
{ "Attach", _wrap_SBTarget_Attach},
{ "AttachToProcessWithID", _wrap_SBTarget_AttachToProcessWithID},
{ "AttachToProcessWithName", _wrap_SBTarget_AttachToProcessWithName},
@@ -54725,6 +61142,8 @@ static swig_lua_method swig_SBTarget_methods[]= {
{ "GetAddressByteSize", _wrap_SBTarget_GetAddressByteSize},
{ "GetTriple", _wrap_SBTarget_GetTriple},
{ "GetABIName", _wrap_SBTarget_GetABIName},
+ { "GetLabel", _wrap_SBTarget_GetLabel},
+ { "SetLabel", _wrap_SBTarget_SetLabel},
{ "GetDataByteSize", _wrap_SBTarget_GetDataByteSize},
{ "GetCodeByteSize", _wrap_SBTarget_GetCodeByteSize},
{ "GetMaximumNumberOfChildrenToDisplay", _wrap_SBTarget_GetMaximumNumberOfChildrenToDisplay},
@@ -54733,10 +61152,6 @@ static swig_lua_method swig_SBTarget_methods[]= {
{ "SetModuleLoadAddress", _wrap_SBTarget_SetModuleLoadAddress},
{ "ClearModuleLoadAddress", _wrap_SBTarget_ClearModuleLoadAddress},
{ "FindFunctions", _wrap_SBTarget_FindFunctions},
- { "FindFirstType", _wrap_SBTarget_FindFirstType},
- { "FindTypes", _wrap_SBTarget_FindTypes},
- { "GetBasicType", _wrap_SBTarget_GetBasicType},
- { "GetSourceManager", _wrap_SBTarget_GetSourceManager},
{ "FindFirstGlobalVariable", _wrap_SBTarget_FindFirstGlobalVariable},
{ "FindGlobalVariables", _wrap_SBTarget_FindGlobalVariables},
{ "FindGlobalFunctions", _wrap_SBTarget_FindGlobalFunctions},
@@ -54753,50 +61168,51 @@ static swig_lua_method swig_SBTarget_methods[]= {
{ "BreakpointCreateBySourceRegex", _wrap_SBTarget_BreakpointCreateBySourceRegex},
{ "BreakpointCreateForException", _wrap_SBTarget_BreakpointCreateForException},
{ "BreakpointCreateByAddress", _wrap_SBTarget_BreakpointCreateByAddress},
- { "GetEnvironment", _wrap_SBTarget_GetEnvironment},
{ "BreakpointCreateBySBAddress", _wrap_SBTarget_BreakpointCreateBySBAddress},
{ "BreakpointCreateFromScript", _wrap_SBTarget_BreakpointCreateFromScript},
+ { "BreakpointsCreateFromFile", _wrap_SBTarget_BreakpointsCreateFromFile},
+ { "BreakpointsWriteToFile", _wrap_SBTarget_BreakpointsWriteToFile},
{ "GetNumBreakpoints", _wrap_SBTarget_GetNumBreakpoints},
{ "GetBreakpointAtIndex", _wrap_SBTarget_GetBreakpointAtIndex},
{ "BreakpointDelete", _wrap_SBTarget_BreakpointDelete},
{ "FindBreakpointByID", _wrap_SBTarget_FindBreakpointByID},
{ "FindBreakpointsByName", _wrap_SBTarget_FindBreakpointsByName},
- { "DeleteBreakpointName", _wrap_SBTarget_DeleteBreakpointName},
{ "GetBreakpointNames", _wrap_SBTarget_GetBreakpointNames},
+ { "DeleteBreakpointName", _wrap_SBTarget_DeleteBreakpointName},
{ "EnableAllBreakpoints", _wrap_SBTarget_EnableAllBreakpoints},
{ "DisableAllBreakpoints", _wrap_SBTarget_DisableAllBreakpoints},
{ "DeleteAllBreakpoints", _wrap_SBTarget_DeleteAllBreakpoints},
- { "BreakpointsCreateFromFile", _wrap_SBTarget_BreakpointsCreateFromFile},
- { "BreakpointsWriteToFile", _wrap_SBTarget_BreakpointsWriteToFile},
{ "GetNumWatchpoints", _wrap_SBTarget_GetNumWatchpoints},
{ "GetWatchpointAtIndex", _wrap_SBTarget_GetWatchpointAtIndex},
{ "DeleteWatchpoint", _wrap_SBTarget_DeleteWatchpoint},
{ "FindWatchpointByID", _wrap_SBTarget_FindWatchpointByID},
+ { "WatchAddress", _wrap_SBTarget_WatchAddress},
+ { "WatchpointCreateByAddress", _wrap_SBTarget_WatchpointCreateByAddress},
{ "EnableAllWatchpoints", _wrap_SBTarget_EnableAllWatchpoints},
{ "DisableAllWatchpoints", _wrap_SBTarget_DisableAllWatchpoints},
{ "DeleteAllWatchpoints", _wrap_SBTarget_DeleteAllWatchpoints},
- { "WatchAddress", _wrap_SBTarget_WatchAddress},
{ "GetBroadcaster", _wrap_SBTarget_GetBroadcaster},
+ { "FindFirstType", _wrap_SBTarget_FindFirstType},
+ { "FindTypes", _wrap_SBTarget_FindTypes},
+ { "GetBasicType", _wrap_SBTarget_GetBasicType},
{ "CreateValueFromAddress", _wrap_SBTarget_CreateValueFromAddress},
{ "CreateValueFromData", _wrap_SBTarget_CreateValueFromData},
{ "CreateValueFromExpression", _wrap_SBTarget_CreateValueFromExpression},
+ { "GetSourceManager", _wrap_SBTarget_GetSourceManager},
{ "ReadInstructions", _wrap_SBTarget_ReadInstructions},
{ "GetInstructions", _wrap_SBTarget_GetInstructions},
{ "GetInstructionsWithFlavor", _wrap_SBTarget_GetInstructionsWithFlavor},
{ "FindSymbols", _wrap_SBTarget_FindSymbols},
+ { "__eq", _wrap_SBTarget___eq},
{ "GetDescription", _wrap_SBTarget_GetDescription},
+ { "EvaluateExpression", _wrap_SBTarget_EvaluateExpression},
{ "GetStackRedZoneSize", _wrap_SBTarget_GetStackRedZoneSize},
{ "IsLoaded", _wrap_SBTarget_IsLoaded},
{ "GetLaunchInfo", _wrap_SBTarget_GetLaunchInfo},
{ "SetLaunchInfo", _wrap_SBTarget_SetLaunchInfo},
- { "SetCollectingStats", _wrap_SBTarget_SetCollectingStats},
- { "GetCollectingStats", _wrap_SBTarget_GetCollectingStats},
- { "GetStatistics", _wrap_SBTarget_GetStatistics},
- { "__eq", _wrap_SBTarget___eq},
- { "EvaluateExpression", _wrap_SBTarget_EvaluateExpression},
- { "__tostring", _wrap_SBTarget___tostring},
{ "GetTrace", _wrap_SBTarget_GetTrace},
{ "CreateTrace", _wrap_SBTarget_CreateTrace},
+ { "__tostring", _wrap_SBTarget___tostring},
{0,0}
};
static swig_lua_method swig_SBTarget_meta[] = {
@@ -54809,19 +61225,20 @@ static swig_lua_attribute swig_SBTarget_Sf_SwigStatic_attributes[] = {
{0,0,0}
};
static swig_lua_const_info swig_SBTarget_Sf_SwigStatic_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitBreakpointChanged", lldb::SBTarget::eBroadcastBitBreakpointChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitModulesLoaded", lldb::SBTarget::eBroadcastBitModulesLoaded)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitModulesUnloaded", lldb::SBTarget::eBroadcastBitModulesUnloaded)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitWatchpointChanged", lldb::SBTarget::eBroadcastBitWatchpointChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSymbolsLoaded", lldb::SBTarget::eBroadcastBitSymbolsLoaded)},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitBreakpointChanged", (lldb::SBTarget::eBroadcastBitBreakpointChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitModulesLoaded", (lldb::SBTarget::eBroadcastBitModulesLoaded))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitModulesUnloaded", (lldb::SBTarget::eBroadcastBitModulesUnloaded))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitWatchpointChanged", (lldb::SBTarget::eBroadcastBitWatchpointChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSymbolsLoaded", (lldb::SBTarget::eBroadcastBitSymbolsLoaded))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSymbolsChanged", (lldb::SBTarget::eBroadcastBitSymbolsChanged))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBTarget_Sf_SwigStatic_methods[]= {
- { "GetBroadcasterClassName", _wrap_SBTarget_GetBroadcasterClassName},
{ "EventIsTargetEvent", _wrap_SBTarget_EventIsTargetEvent},
{ "GetTargetFromEvent", _wrap_SBTarget_GetTargetFromEvent},
{ "GetNumModulesFromEvent", _wrap_SBTarget_GetNumModulesFromEvent},
{ "GetModuleAtIndexFromEvent", _wrap_SBTarget_GetModuleAtIndexFromEvent},
+ { "GetBroadcasterClassName", _wrap_SBTarget_GetBroadcasterClassName},
{0,0}
};
static swig_lua_class* swig_SBTarget_Sf_SwigStatic_classes[]= {
@@ -54840,6 +61257,23 @@ static swig_lua_class *swig_SBTarget_bases[] = {0};
static const char *swig_SBTarget_base_names[] = {0};
static swig_lua_class _wrap_class_SBTarget = { "SBTarget", "SBTarget", &SWIGTYPE_p_lldb__SBTarget,_proxy__wrap_new_SBTarget, swig_delete_SBTarget, swig_SBTarget_methods, swig_SBTarget_attributes, &swig_SBTarget_Sf_SwigStatic, swig_SBTarget_meta, swig_SBTarget_bases, swig_SBTarget_base_names };
+static int _wrap_SBThread_GetBroadcasterClassName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBThread::GetBroadcasterClassName",0,0)
+ result = (char *)lldb::SBThread::GetBroadcasterClassName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_new_SBThread__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -54914,91 +61348,23 @@ static int _wrap_new_SBThread(lua_State* L) {
}
-static int _wrap_SBThread_GetBroadcasterClassName(lua_State* L) {
- {
- int SWIG_arg = 0;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBThread::GetBroadcasterClassName",0,0)
- result = (char *)lldb::SBThread::GetBroadcasterClassName();
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBThread_EventIsThreadEvent(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBEvent *arg1 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBThread::EventIsThreadEvent",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThread::EventIsThreadEvent",1,"lldb::SBEvent const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
- SWIG_fail_ptr("SBThread_EventIsThreadEvent",1,SWIGTYPE_p_lldb__SBEvent);
- }
-
- result = (bool)lldb::SBThread::EventIsThreadEvent((lldb::SBEvent const &)*arg1);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBThread_GetStackFrameFromEvent(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBEvent *arg1 = 0 ;
- lldb::SBFrame result;
-
- SWIG_check_num_args("lldb::SBThread::GetStackFrameFromEvent",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThread::GetStackFrameFromEvent",1,"lldb::SBEvent const &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
- SWIG_fail_ptr("SBThread_GetStackFrameFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
- }
-
- result = lldb::SBThread::GetStackFrameFromEvent((lldb::SBEvent const &)*arg1);
- {
- lldb::SBFrame * resultptr = new lldb::SBFrame(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFrame,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBThread_GetThreadFromEvent(lua_State* L) {
+static int _wrap_SBThread_GetQueue(lua_State* L) {
{
int SWIG_arg = 0;
- lldb::SBEvent *arg1 = 0 ;
- lldb::SBThread result;
+ lldb::SBThread *arg1 = (lldb::SBThread *) 0 ;
+ lldb::SBQueue result;
- SWIG_check_num_args("lldb::SBThread::GetThreadFromEvent",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThread::GetThreadFromEvent",1,"lldb::SBEvent const &");
+ SWIG_check_num_args("lldb::SBThread::GetQueue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::GetQueue",1,"lldb::SBThread const *");
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
- SWIG_fail_ptr("SBThread_GetThreadFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
+ SWIG_fail_ptr("SBThread_GetQueue",1,SWIGTYPE_p_lldb__SBThread);
}
- result = lldb::SBThread::GetThreadFromEvent((lldb::SBEvent const &)*arg1);
+ result = ((lldb::SBThread const *)arg1)->GetQueue();
{
- lldb::SBThread * resultptr = new lldb::SBThread(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThread,1); SWIG_arg++;
+ lldb::SBQueue * resultptr = new lldb::SBQueue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBQueue,1); SWIG_arg++;
}
return SWIG_arg;
@@ -55412,33 +61778,6 @@ static int _wrap_SBThread_GetInfoItemByPathAsString(lua_State* L) {
}
-static int _wrap_SBThread_GetQueue(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBThread *arg1 = (lldb::SBThread *) 0 ;
- lldb::SBQueue result;
-
- SWIG_check_num_args("lldb::SBThread::GetQueue",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::GetQueue",1,"lldb::SBThread const *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
- SWIG_fail_ptr("SBThread_GetQueue",1,SWIGTYPE_p_lldb__SBThread);
- }
-
- result = ((lldb::SBThread const *)arg1)->GetQueue();
- {
- lldb::SBQueue * resultptr = new lldb::SBQueue(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBQueue,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBThread_StepOver__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -57165,6 +63504,84 @@ static int _wrap_SBThread_SetSelectedFrame(lua_State* L) {
}
+static int _wrap_SBThread_EventIsThreadEvent(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBEvent *arg1 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBThread::EventIsThreadEvent",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThread::EventIsThreadEvent",1,"lldb::SBEvent const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
+ SWIG_fail_ptr("SBThread_EventIsThreadEvent",1,SWIGTYPE_p_lldb__SBEvent);
+ }
+
+ result = (bool)lldb::SBThread::EventIsThreadEvent((lldb::SBEvent const &)*arg1);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBThread_GetStackFrameFromEvent(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBEvent *arg1 = 0 ;
+ lldb::SBFrame result;
+
+ SWIG_check_num_args("lldb::SBThread::GetStackFrameFromEvent",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThread::GetStackFrameFromEvent",1,"lldb::SBEvent const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
+ SWIG_fail_ptr("SBThread_GetStackFrameFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
+ }
+
+ result = lldb::SBThread::GetStackFrameFromEvent((lldb::SBEvent const &)*arg1);
+ {
+ lldb::SBFrame * resultptr = new lldb::SBFrame(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFrame,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBThread_GetThreadFromEvent(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBEvent *arg1 = 0 ;
+ lldb::SBThread result;
+
+ SWIG_check_num_args("lldb::SBThread::GetThreadFromEvent",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThread::GetThreadFromEvent",1,"lldb::SBEvent const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBEvent,0))){
+ SWIG_fail_ptr("SBThread_GetThreadFromEvent",1,SWIGTYPE_p_lldb__SBEvent);
+ }
+
+ result = lldb::SBThread::GetThreadFromEvent((lldb::SBEvent const &)*arg1);
+ {
+ lldb::SBThread * resultptr = new lldb::SBThread(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThread,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBThread_GetProcess(lua_State* L) {
{
int SWIG_arg = 0;
@@ -57192,6 +63609,37 @@ static int _wrap_SBThread_GetProcess(lua_State* L) {
}
+static int _wrap_SBThread___eq(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBThread *arg1 = (lldb::SBThread *) 0 ;
+ lldb::SBThread *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBThread::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::operator ==",1,"lldb::SBThread const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThread::operator ==",2,"lldb::SBThread const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
+ SWIG_fail_ptr("SBThread___eq",1,SWIGTYPE_p_lldb__SBThread);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBThread,0))){
+ SWIG_fail_ptr("SBThread___eq",2,SWIGTYPE_p_lldb__SBThread);
+ }
+
+ result = (bool)((lldb::SBThread const *)arg1)->operator ==((lldb::SBThread const &)*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBThread_GetDescription__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -57326,28 +63774,38 @@ static int _wrap_SBThread_GetDescription(lua_State* L) {
}
-static int _wrap_SBThread_GetStatus(lua_State* L) {
+static int _wrap_SBThread_GetDescriptionWithFormat(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBThread *arg1 = (lldb::SBThread *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
+ lldb::SBFormat *arg2 = 0 ;
+ lldb::SBStream *arg3 = 0 ;
+ lldb::SBError result;
- SWIG_check_num_args("lldb::SBThread::GetStatus",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::GetStatus",1,"lldb::SBThread const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThread::GetStatus",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBThread::GetDescriptionWithFormat",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::GetDescriptionWithFormat",1,"lldb::SBThread *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThread::GetDescriptionWithFormat",2,"lldb::SBFormat const &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBThread::GetDescriptionWithFormat",3,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
- SWIG_fail_ptr("SBThread_GetStatus",1,SWIGTYPE_p_lldb__SBThread);
+ SWIG_fail_ptr("SBThread_GetDescriptionWithFormat",1,SWIGTYPE_p_lldb__SBThread);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBThread_GetStatus",2,SWIGTYPE_p_lldb__SBStream);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBFormat,0))){
+ SWIG_fail_ptr("SBThread_GetDescriptionWithFormat",2,SWIGTYPE_p_lldb__SBFormat);
}
- result = (bool)((lldb::SBThread const *)arg1)->GetStatus(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBThread_GetDescriptionWithFormat",3,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ result = (arg1)->GetDescriptionWithFormat((lldb::SBFormat const &)*arg2,*arg3);
+ {
+ lldb::SBError * resultptr = new lldb::SBError(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBError,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -57357,27 +63815,27 @@ static int _wrap_SBThread_GetStatus(lua_State* L) {
}
-static int _wrap_SBThread___eq(lua_State* L) {
+static int _wrap_SBThread_GetStatus(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBThread *arg1 = (lldb::SBThread *) 0 ;
- lldb::SBThread *arg2 = 0 ;
+ lldb::SBStream *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBThread::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::operator ==",1,"lldb::SBThread const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThread::operator ==",2,"lldb::SBThread const &");
+ SWIG_check_num_args("lldb::SBThread::GetStatus",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThread::GetStatus",1,"lldb::SBThread const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThread::GetStatus",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
- SWIG_fail_ptr("SBThread___eq",1,SWIGTYPE_p_lldb__SBThread);
+ SWIG_fail_ptr("SBThread_GetStatus",1,SWIGTYPE_p_lldb__SBThread);
}
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBThread,0))){
- SWIG_fail_ptr("SBThread___eq",2,SWIGTYPE_p_lldb__SBThread);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBThread_GetStatus",2,SWIGTYPE_p_lldb__SBStream);
}
- result = (bool)((lldb::SBThread const *)arg1)->operator ==((lldb::SBThread const &)*arg2);
+ result = (bool)((lldb::SBThread const *)arg1)->GetStatus(*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -57587,6 +64045,7 @@ static swig_lua_attribute swig_SBThread_attributes[] = {
{0,0,0}
};
static swig_lua_method swig_SBThread_methods[]= {
+ { "GetQueue", _wrap_SBThread_GetQueue},
{ "IsValid", _wrap_SBThread_IsValid},
{ "Clear", _wrap_SBThread_Clear},
{ "GetStopReason", _wrap_SBThread_GetStopReason},
@@ -57602,7 +64061,6 @@ static swig_lua_method swig_SBThread_methods[]= {
{ "GetQueueName", _wrap_SBThread_GetQueueName},
{ "GetQueueID", _wrap_SBThread_GetQueueID},
{ "GetInfoItemByPathAsString", _wrap_SBThread_GetInfoItemByPathAsString},
- { "GetQueue", _wrap_SBThread_GetQueue},
{ "StepOver", _wrap_SBThread_StepOver},
{ "StepInto", _wrap_SBThread_StepInto},
{ "StepOut", _wrap_SBThread_StepOut},
@@ -57623,9 +64081,10 @@ static swig_lua_method swig_SBThread_methods[]= {
{ "GetSelectedFrame", _wrap_SBThread_GetSelectedFrame},
{ "SetSelectedFrame", _wrap_SBThread_SetSelectedFrame},
{ "GetProcess", _wrap_SBThread_GetProcess},
+ { "__eq", _wrap_SBThread___eq},
{ "GetDescription", _wrap_SBThread_GetDescription},
+ { "GetDescriptionWithFormat", _wrap_SBThread_GetDescriptionWithFormat},
{ "GetStatus", _wrap_SBThread_GetStatus},
- { "__eq", _wrap_SBThread___eq},
{ "GetExtendedBacktraceThread", _wrap_SBThread_GetExtendedBacktraceThread},
{ "GetExtendedBacktraceOriginatingIndexID", _wrap_SBThread_GetExtendedBacktraceOriginatingIndexID},
{ "GetCurrentException", _wrap_SBThread_GetCurrentException},
@@ -57645,11 +64104,11 @@ static swig_lua_attribute swig_SBThread_Sf_SwigStatic_attributes[] = {
{0,0,0}
};
static swig_lua_const_info swig_SBThread_Sf_SwigStatic_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitStackChanged", lldb::SBThread::eBroadcastBitStackChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadSuspended", lldb::SBThread::eBroadcastBitThreadSuspended)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadResumed", lldb::SBThread::eBroadcastBitThreadResumed)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSelectedFrameChanged", lldb::SBThread::eBroadcastBitSelectedFrameChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadSelected", lldb::SBThread::eBroadcastBitThreadSelected)},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitStackChanged", (lldb::SBThread::eBroadcastBitStackChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadSuspended", (lldb::SBThread::eBroadcastBitThreadSuspended))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadResumed", (lldb::SBThread::eBroadcastBitThreadResumed))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitSelectedFrameChanged", (lldb::SBThread::eBroadcastBitSelectedFrameChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitThreadSelected", (lldb::SBThread::eBroadcastBitThreadSelected))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBThread_Sf_SwigStatic_methods[]= {
@@ -57921,17 +64380,20 @@ static int _wrap_new_SBThreadPlan__SWIG_1(lua_State* L) {
static int _wrap_new_SBThreadPlan__SWIG_2(lua_State* L) {
{
int SWIG_arg = 0;
- lldb::ThreadPlanSP *arg1 = 0 ;
+ lldb::SBThread *arg1 = 0 ;
+ char *arg2 = (char *) 0 ;
lldb::SBThreadPlan *result = 0 ;
- SWIG_check_num_args("lldb::SBThreadPlan::SBThreadPlan",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::SBThreadPlan",1,"lldb::ThreadPlanSP const &");
+ SWIG_check_num_args("lldb::SBThreadPlan::SBThreadPlan",2,2)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::SBThreadPlan",1,"lldb::SBThread &");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBThreadPlan::SBThreadPlan",2,"char const *");
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlan_t,0))){
- SWIG_fail_ptr("new_SBThreadPlan",1,SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlan_t);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
+ SWIG_fail_ptr("new_SBThreadPlan",1,SWIGTYPE_p_lldb__SBThread);
}
- result = (lldb::SBThreadPlan *)new lldb::SBThreadPlan((lldb::ThreadPlanSP const &)*arg1);
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (lldb::SBThreadPlan *)new lldb::SBThreadPlan(*arg1,(char const *)arg2);
SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBThreadPlan,1); SWIG_arg++;
return SWIG_arg;
@@ -57947,18 +64409,25 @@ static int _wrap_new_SBThreadPlan__SWIG_3(lua_State* L) {
int SWIG_arg = 0;
lldb::SBThread *arg1 = 0 ;
char *arg2 = (char *) 0 ;
+ lldb::SBStructuredData *arg3 = 0 ;
lldb::SBThreadPlan *result = 0 ;
- SWIG_check_num_args("lldb::SBThreadPlan::SBThreadPlan",2,2)
+ SWIG_check_num_args("lldb::SBThreadPlan::SBThreadPlan",3,3)
if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::SBThreadPlan",1,"lldb::SBThread &");
if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBThreadPlan::SBThreadPlan",2,"char const *");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBThreadPlan::SBThreadPlan",3,"lldb::SBStructuredData &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThread,0))){
SWIG_fail_ptr("new_SBThreadPlan",1,SWIGTYPE_p_lldb__SBThread);
}
arg2 = (char *)lua_tostring(L, 2);
- result = (lldb::SBThreadPlan *)new lldb::SBThreadPlan(*arg1,(char const *)arg2);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBStructuredData,0))){
+ SWIG_fail_ptr("new_SBThreadPlan",3,SWIGTYPE_p_lldb__SBStructuredData);
+ }
+
+ result = (lldb::SBThreadPlan *)new lldb::SBThreadPlan(*arg1,(char const *)arg2,*arg3);
SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBThreadPlan,1); SWIG_arg++;
return SWIG_arg;
@@ -57971,8 +64440,8 @@ static int _wrap_new_SBThreadPlan__SWIG_3(lua_State* L) {
static int _wrap_new_SBThreadPlan(lua_State* L) {
int argc;
- int argv[3]={
- 1,2,3
+ int argv[4]={
+ 1,2,3,4
};
argc = lua_gettop(L);
@@ -57993,21 +64462,26 @@ static int _wrap_new_SBThreadPlan(lua_State* L) {
return _wrap_new_SBThreadPlan__SWIG_1(L);
}
}
- if (argc == 1) {
+ if (argc == 2) {
int _v = 0;
{
void *ptr;
- if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_std__shared_ptrT_lldb_private__ThreadPlan_t, SWIG_POINTER_NO_NULL)) {
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThread, SWIG_POINTER_NO_NULL)) {
_v = 0;
} else {
_v = 1;
}
}
if (_v) {
- return _wrap_new_SBThreadPlan__SWIG_2(L);
+ {
+ _v = SWIG_lua_isnilstring(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_new_SBThreadPlan__SWIG_2(L);
+ }
}
}
- if (argc == 2) {
+ if (argc == 3) {
int _v = 0;
{
void *ptr;
@@ -58022,7 +64496,17 @@ static int _wrap_new_SBThreadPlan(lua_State* L) {
_v = SWIG_lua_isnilstring(L,argv[1]);
}
if (_v) {
- return _wrap_new_SBThreadPlan__SWIG_3(L);
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBStructuredData, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBThreadPlan__SWIG_3(L);
+ }
}
}
}
@@ -58031,8 +64515,8 @@ static int _wrap_new_SBThreadPlan(lua_State* L) {
" Possible C/C++ prototypes are:\n"
" lldb::SBThreadPlan::SBThreadPlan()\n"
" lldb::SBThreadPlan::SBThreadPlan(lldb::SBThreadPlan const &)\n"
- " lldb::SBThreadPlan::SBThreadPlan(lldb::ThreadPlanSP const &)\n"
- " lldb::SBThreadPlan::SBThreadPlan(lldb::SBThread &,char const *)\n");
+ " lldb::SBThreadPlan::SBThreadPlan(lldb::SBThread &,char const *)\n"
+ " lldb::SBThreadPlan::SBThreadPlan(lldb::SBThread &,char const *,lldb::SBStructuredData &)\n");
lua_error(L);return 0;
}
@@ -58044,30 +64528,6 @@ static int _wrap_SBThreadPlan_IsValid__SWIG_0(lua_State* L) {
bool result;
SWIG_check_num_args("lldb::SBThreadPlan::IsValid",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::IsValid",1,"lldb::SBThreadPlan *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
- SWIG_fail_ptr("SBThreadPlan_IsValid",1,SWIGTYPE_p_lldb__SBThreadPlan);
- }
-
- result = (bool)(arg1)->IsValid();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBThreadPlan_IsValid__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBThreadPlan::IsValid",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::IsValid",1,"lldb::SBThreadPlan const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
@@ -58085,50 +64545,6 @@ static int _wrap_SBThreadPlan_IsValid__SWIG_1(lua_State* L) {
}
-static int _wrap_SBThreadPlan_IsValid(lua_State* L) {
- int argc;
- int argv[2]={
- 1,2
- };
-
- argc = lua_gettop(L);
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBThreadPlan_IsValid__SWIG_0(L);
- }
- }
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBThreadPlan_IsValid__SWIG_1(L);
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBThreadPlan_IsValid'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBThreadPlan::IsValid()\n"
- " lldb::SBThreadPlan::IsValid() const\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBThreadPlan_Clear(lua_State* L) {
{
int SWIG_arg = 0;
@@ -58359,6 +64775,74 @@ static int _wrap_SBThreadPlan_IsPlanStale(lua_State* L) {
}
+static int _wrap_SBThreadPlan_IsValid__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBThreadPlan::IsValid",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::IsValid",1,"lldb::SBThreadPlan *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
+ SWIG_fail_ptr("SBThreadPlan_IsValid",1,SWIGTYPE_p_lldb__SBThreadPlan);
+ }
+
+ result = (bool)(arg1)->IsValid();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBThreadPlan_IsValid(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_IsValid__SWIG_1(L);
+ }
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_IsValid__SWIG_0(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBThreadPlan_IsValid'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBThreadPlan::IsValid() const\n"
+ " lldb::SBThreadPlan::IsValid()\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBThreadPlan_GetStopOthers(lua_State* L) {
{
int SWIG_arg = 0;
@@ -58409,7 +64893,7 @@ static int _wrap_SBThreadPlan_SetStopOthers(lua_State* L) {
}
-static int _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange(lua_State* L) {
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
@@ -58446,7 +64930,135 @@ static int _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange(lua_State* L) {
}
-static int _wrap_SBThreadPlan_QueueThreadPlanForStepInRange(lua_State* L) {
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
+ lldb::SBAddress *arg2 = 0 ;
+ lldb::addr_t arg3 ;
+ lldb::SBError *arg4 = 0 ;
+ lldb::SBThreadPlan result;
+
+ SWIG_check_num_args("lldb::SBThreadPlan::QueueThreadPlanForStepOverRange",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOverRange",1,"lldb::SBThreadPlan *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOverRange",2,"lldb::SBAddress &");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOverRange",3,"lldb::addr_t");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOverRange",4,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepOverRange",1,SWIGTYPE_p_lldb__SBThreadPlan);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepOverRange",2,SWIGTYPE_p_lldb__SBAddress);
+ }
+
+ arg3 = (lldb::addr_t)lua_tointeger(L, 3);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepOverRange",4,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->QueueThreadPlanForStepOverRange(*arg2,arg3,*arg4);
+ {
+ lldb::SBThreadPlan * resultptr = new lldb::SBThreadPlan(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThreadPlan,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange__SWIG_0(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[3])==0 || SWIG_ConvertPtr(L,argv[3], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBThreadPlan_QueueThreadPlanForStepOverRange'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForStepOverRange(lldb::SBAddress &,lldb::addr_t)\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForStepOverRange(lldb::SBAddress &,lldb::addr_t,lldb::SBError &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepInRange__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
@@ -58483,6 +65095,134 @@ static int _wrap_SBThreadPlan_QueueThreadPlanForStepInRange(lua_State* L) {
}
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepInRange__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
+ lldb::SBAddress *arg2 = 0 ;
+ lldb::addr_t arg3 ;
+ lldb::SBError *arg4 = 0 ;
+ lldb::SBThreadPlan result;
+
+ SWIG_check_num_args("lldb::SBThreadPlan::QueueThreadPlanForStepInRange",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepInRange",1,"lldb::SBThreadPlan *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepInRange",2,"lldb::SBAddress &");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepInRange",3,"lldb::addr_t");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepInRange",4,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepInRange",1,SWIGTYPE_p_lldb__SBThreadPlan);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepInRange",2,SWIGTYPE_p_lldb__SBAddress);
+ }
+
+ arg3 = (lldb::addr_t)lua_tointeger(L, 3);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepInRange",4,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->QueueThreadPlanForStepInRange(*arg2,arg3,*arg4);
+ {
+ lldb::SBThreadPlan * resultptr = new lldb::SBThreadPlan(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThreadPlan,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepInRange(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForStepInRange__SWIG_0(L);
+ }
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[3])==0 || SWIG_ConvertPtr(L,argv[3], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForStepInRange__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBThreadPlan_QueueThreadPlanForStepInRange'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForStepInRange(lldb::SBAddress &,lldb::addr_t)\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForStepInRange(lldb::SBAddress &,lldb::addr_t,lldb::SBError &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBThreadPlan_QueueThreadPlanForStepOut__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -58546,10 +65286,50 @@ static int _wrap_SBThreadPlan_QueueThreadPlanForStepOut__SWIG_1(lua_State* L) {
}
+static int _wrap_SBThreadPlan_QueueThreadPlanForStepOut__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
+ uint32_t arg2 ;
+ bool arg3 ;
+ lldb::SBError *arg4 = 0 ;
+ lldb::SBThreadPlan result;
+
+ SWIG_check_num_args("lldb::SBThreadPlan::QueueThreadPlanForStepOut",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOut",1,"lldb::SBThreadPlan *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOut",2,"uint32_t");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOut",3,"bool");
+ if(!lua_isuserdata(L,4)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForStepOut",4,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepOut",1,SWIGTYPE_p_lldb__SBThreadPlan);
+ }
+
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ arg3 = (lua_toboolean(L, 3)!=0);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&arg4,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForStepOut",4,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->QueueThreadPlanForStepOut(arg2,arg3,*arg4);
+ {
+ lldb::SBThreadPlan * resultptr = new lldb::SBThreadPlan(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThreadPlan,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBThreadPlan_QueueThreadPlanForStepOut(lua_State* L) {
int argc;
- int argv[4]={
- 1,2,3,4
+ int argv[5]={
+ 1,2,3,4,5
};
argc = lua_gettop(L);
@@ -58596,16 +65376,51 @@ static int _wrap_SBThreadPlan_QueueThreadPlanForStepOut(lua_State* L) {
}
}
}
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[2]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[3])==0 || SWIG_ConvertPtr(L,argv[3], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForStepOut__SWIG_2(L);
+ }
+ }
+ }
+ }
+ }
SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBThreadPlan_QueueThreadPlanForStepOut'\n"
" Possible C/C++ prototypes are:\n"
" lldb::SBThreadPlan::QueueThreadPlanForStepOut(uint32_t,bool)\n"
- " lldb::SBThreadPlan::QueueThreadPlanForStepOut(uint32_t)\n");
+ " lldb::SBThreadPlan::QueueThreadPlanForStepOut(uint32_t)\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForStepOut(uint32_t,bool,lldb::SBError &)\n");
lua_error(L);return 0;
}
-static int _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress(lua_State* L) {
+static int _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
@@ -58641,6 +65456,123 @@ static int _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress(lua_State* L) {
}
+static int _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBThreadPlan *arg1 = (lldb::SBThreadPlan *) 0 ;
+ lldb::SBAddress arg2 ;
+ lldb::SBError *arg3 = 0 ;
+ lldb::SBAddress *argp2 ;
+ lldb::SBThreadPlan result;
+
+ SWIG_check_num_args("lldb::SBThreadPlan::QueueThreadPlanForRunToAddress",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForRunToAddress",1,"lldb::SBThreadPlan *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForRunToAddress",2,"lldb::SBAddress");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBThreadPlan::QueueThreadPlanForRunToAddress",3,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBThreadPlan,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForRunToAddress",1,SWIGTYPE_p_lldb__SBThreadPlan);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBAddress,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForRunToAddress",2,SWIGTYPE_p_lldb__SBAddress);
+ }
+ arg2 = *argp2;
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBThreadPlan_QueueThreadPlanForRunToAddress",3,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->QueueThreadPlanForRunToAddress(arg2,*arg3);
+ {
+ lldb::SBThreadPlan * resultptr = new lldb::SBThreadPlan(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThreadPlan,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress(lua_State* L) {
+ int argc;
+ int argv[4]={
+ 1,2,3,4
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBThreadPlan, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[1])==0 || SWIG_ConvertPtr(L,argv[1], (void **) &ptr, SWIGTYPE_p_lldb__SBAddress, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[2])==0 || SWIG_ConvertPtr(L,argv[2], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBThreadPlan_QueueThreadPlanForRunToAddress__SWIG_1(L);
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBThreadPlan_QueueThreadPlanForRunToAddress'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForRunToAddress(lldb::SBAddress)\n"
+ " lldb::SBThreadPlan::QueueThreadPlanForRunToAddress(lldb::SBAddress,lldb::SBError &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBThreadPlan_QueueThreadPlanForStepScripted__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -58872,7 +65804,6 @@ static swig_lua_attribute swig_SBThreadPlan_attributes[] = {
{0,0,0}
};
static swig_lua_method swig_SBThreadPlan_methods[]= {
- { "IsValid", _wrap_SBThreadPlan_IsValid},
{ "Clear", _wrap_SBThreadPlan_Clear},
{ "GetStopReason", _wrap_SBThreadPlan_GetStopReason},
{ "GetStopReasonDataCount", _wrap_SBThreadPlan_GetStopReasonDataCount},
@@ -58882,6 +65813,7 @@ static swig_lua_method swig_SBThreadPlan_methods[]= {
{ "SetPlanComplete", _wrap_SBThreadPlan_SetPlanComplete},
{ "IsPlanComplete", _wrap_SBThreadPlan_IsPlanComplete},
{ "IsPlanStale", _wrap_SBThreadPlan_IsPlanStale},
+ { "IsValid", _wrap_SBThreadPlan_IsValid},
{ "GetStopOthers", _wrap_SBThreadPlan_GetStopOthers},
{ "SetStopOthers", _wrap_SBThreadPlan_SetStopOthers},
{ "QueueThreadPlanForStepOverRange", _wrap_SBThreadPlan_QueueThreadPlanForStepOverRange},
@@ -58937,6 +65869,47 @@ static int _wrap_new_SBTrace(lua_State* L) {
}
+static int _wrap_SBTrace_LoadTraceFromFile(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBError *arg1 = 0 ;
+ lldb::SBDebugger *arg2 = 0 ;
+ lldb::SBFileSpec *arg3 = 0 ;
+ lldb::SBTrace result;
+
+ SWIG_check_num_args("lldb::SBTrace::LoadTraceFromFile",3,3)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBTrace::LoadTraceFromFile",1,"lldb::SBError &");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTrace::LoadTraceFromFile",2,"lldb::SBDebugger &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBTrace::LoadTraceFromFile",3,"lldb::SBFileSpec const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBTrace_LoadTraceFromFile",1,SWIGTYPE_p_lldb__SBError);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBDebugger,0))){
+ SWIG_fail_ptr("SBTrace_LoadTraceFromFile",2,SWIGTYPE_p_lldb__SBDebugger);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBFileSpec,0))){
+ SWIG_fail_ptr("SBTrace_LoadTraceFromFile",3,SWIGTYPE_p_lldb__SBFileSpec);
+ }
+
+ result = lldb::SBTrace::LoadTraceFromFile(*arg1,*arg2,(lldb::SBFileSpec const &)*arg3);
+ {
+ lldb::SBTrace * resultptr = new lldb::SBTrace(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTrace,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTrace_CreateNewCursor(lua_State* L) {
{
int SWIG_arg = 0;
@@ -58978,30 +65951,6 @@ static int _wrap_SBTrace_CreateNewCursor(lua_State* L) {
}
-static int _wrap_SBTrace_GetStartConfigurationHelp(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTrace *arg1 = (lldb::SBTrace *) 0 ;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBTrace::GetStartConfigurationHelp",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTrace::GetStartConfigurationHelp",1,"lldb::SBTrace *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTrace,0))){
- SWIG_fail_ptr("SBTrace_GetStartConfigurationHelp",1,SWIGTYPE_p_lldb__SBTrace);
- }
-
- result = (char *)(arg1)->GetStartConfigurationHelp();
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTrace_SaveToDisk__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -59176,6 +66125,30 @@ static int _wrap_SBTrace_SaveToDisk(lua_State* L) {
}
+static int _wrap_SBTrace_GetStartConfigurationHelp(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTrace *arg1 = (lldb::SBTrace *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTrace::GetStartConfigurationHelp",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTrace::GetStartConfigurationHelp",1,"lldb::SBTrace *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTrace,0))){
+ SWIG_fail_ptr("SBTrace_GetStartConfigurationHelp",1,SWIGTYPE_p_lldb__SBTrace);
+ }
+
+ result = (char *)(arg1)->GetStartConfigurationHelp();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTrace_Start__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -59481,8 +66454,8 @@ static swig_lua_attribute swig_SBTrace_attributes[] = {
};
static swig_lua_method swig_SBTrace_methods[]= {
{ "CreateNewCursor", _wrap_SBTrace_CreateNewCursor},
- { "GetStartConfigurationHelp", _wrap_SBTrace_GetStartConfigurationHelp},
{ "SaveToDisk", _wrap_SBTrace_SaveToDisk},
+ { "GetStartConfigurationHelp", _wrap_SBTrace_GetStartConfigurationHelp},
{ "Start", _wrap_SBTrace_Start},
{ "Stop", _wrap_SBTrace_Stop},
{ "IsValid", _wrap_SBTrace_IsValid},
@@ -59499,6 +66472,7 @@ static swig_lua_const_info swig_SBTrace_Sf_SwigStatic_constants[]= {
{0,0,0,0,0,0}
};
static swig_lua_method swig_SBTrace_Sf_SwigStatic_methods[]= {
+ { "LoadTraceFromFile", _wrap_SBTrace_LoadTraceFromFile},
{0,0}
};
static swig_lua_class* swig_SBTrace_Sf_SwigStatic_classes[]= {
@@ -59517,7 +66491,7 @@ static swig_lua_class *swig_SBTrace_bases[] = {0};
static const char *swig_SBTrace_base_names[] = {0};
static swig_lua_class _wrap_class_SBTrace = { "SBTrace", "SBTrace", &SWIGTYPE_p_lldb__SBTrace,_proxy__wrap_new_SBTrace, swig_delete_SBTrace, swig_SBTrace_methods, swig_SBTrace_attributes, &swig_SBTrace_Sf_SwigStatic, swig_SBTrace_meta, swig_SBTrace_bases, swig_SBTrace_base_names };
-static int _wrap_new_SBTraceCursor__SWIG_0(lua_State* L) {
+static int _wrap_new_SBTraceCursor(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTraceCursor *result = 0 ;
@@ -59534,65 +66508,6 @@ static int _wrap_new_SBTraceCursor__SWIG_0(lua_State* L) {
}
-static int _wrap_new_SBTraceCursor__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- SwigValueWrapper< std::shared_ptr< lldb_private::TraceCursor > > arg1 ;
- lldb::TraceCursorSP *argp1 ;
- lldb::SBTraceCursor *result = 0 ;
-
- SWIG_check_num_args("lldb::SBTraceCursor::SBTraceCursor",1,1)
- if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBTraceCursor::SBTraceCursor",1,"lldb::TraceCursorSP");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&argp1,SWIGTYPE_p_std__shared_ptrT_lldb_private__TraceCursor_t,0))){
- SWIG_fail_ptr("new_SBTraceCursor",1,SWIGTYPE_p_std__shared_ptrT_lldb_private__TraceCursor_t);
- }
- arg1 = *argp1;
-
- result = (lldb::SBTraceCursor *)new lldb::SBTraceCursor(arg1);
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBTraceCursor,1); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_new_SBTraceCursor(lua_State* L) {
- int argc;
- int argv[2]={
- 1,2
- };
-
- argc = lua_gettop(L);
- if (argc == 0) {
- return _wrap_new_SBTraceCursor__SWIG_0(L);
- }
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_std__shared_ptrT_lldb_private__TraceCursor_t, SWIG_POINTER_NO_NULL)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_new_SBTraceCursor__SWIG_1(L);
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBTraceCursor'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBTraceCursor::SBTraceCursor()\n"
- " lldb::SBTraceCursor::SBTraceCursor(lldb::TraceCursorSP)\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBTraceCursor_SetForwards(lua_State* L) {
{
int SWIG_arg = 0;
@@ -59673,13 +66588,13 @@ static int _wrap_SBTraceCursor_HasValue(lua_State* L) {
bool result;
SWIG_check_num_args("lldb::SBTraceCursor::HasValue",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTraceCursor::HasValue",1,"lldb::SBTraceCursor *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTraceCursor::HasValue",1,"lldb::SBTraceCursor const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTraceCursor,0))){
SWIG_fail_ptr("SBTraceCursor_HasValue",1,SWIGTYPE_p_lldb__SBTraceCursor);
}
- result = (bool)(arg1)->HasValue();
+ result = (bool)((lldb::SBTraceCursor const *)arg1)->HasValue();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -60348,6 +67263,40 @@ static int _wrap_SBTypeMember_GetBitfieldSizeInBits(lua_State* L) {
}
+static int _wrap_SBTypeMember_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeMember *arg1 = (lldb::SBTypeMember *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::DescriptionLevel arg3 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeMember::GetDescription",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeMember::GetDescription",1,"lldb::SBTypeMember *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeMember::GetDescription",2,"lldb::SBStream &");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBTypeMember::GetDescription",3,"lldb::DescriptionLevel");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeMember,0))){
+ SWIG_fail_ptr("SBTypeMember_GetDescription",1,SWIGTYPE_p_lldb__SBTypeMember);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBTypeMember_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ arg3 = (lldb::DescriptionLevel)lua_tointeger(L, 3);
+ result = (bool)(arg1)->GetDescription(*arg2,arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeMember___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -60395,6 +67344,7 @@ static swig_lua_method swig_SBTypeMember_methods[]= {
{ "GetOffsetInBits", _wrap_SBTypeMember_GetOffsetInBits},
{ "IsBitfield", _wrap_SBTypeMember_IsBitfield},
{ "GetBitfieldSizeInBits", _wrap_SBTypeMember_GetBitfieldSizeInBits},
+ { "GetDescription", _wrap_SBTypeMember_GetDescription},
{ "__tostring", _wrap_SBTypeMember___tostring},
{0,0}
};
@@ -60847,6 +67797,267 @@ static swig_lua_class *swig_SBTypeMemberFunction_bases[] = {0};
static const char *swig_SBTypeMemberFunction_base_names[] = {0};
static swig_lua_class _wrap_class_SBTypeMemberFunction = { "SBTypeMemberFunction", "SBTypeMemberFunction", &SWIGTYPE_p_lldb__SBTypeMemberFunction,_proxy__wrap_new_SBTypeMemberFunction, swig_delete_SBTypeMemberFunction, swig_SBTypeMemberFunction_methods, swig_SBTypeMemberFunction_attributes, &swig_SBTypeMemberFunction_Sf_SwigStatic, swig_SBTypeMemberFunction_meta, swig_SBTypeMemberFunction_bases, swig_SBTypeMemberFunction_base_names };
+static int _wrap_new_SBTypeStaticField__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::SBTypeStaticField",0,0)
+ result = (lldb::SBTypeStaticField *)new lldb::SBTypeStaticField();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBTypeStaticField,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBTypeStaticField__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *arg1 = 0 ;
+ lldb::SBTypeStaticField *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::SBTypeStaticField",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBTypeStaticField::SBTypeStaticField",1,"lldb::SBTypeStaticField const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeStaticField,0))){
+ SWIG_fail_ptr("new_SBTypeStaticField",1,SWIGTYPE_p_lldb__SBTypeStaticField);
+ }
+
+ result = (lldb::SBTypeStaticField *)new lldb::SBTypeStaticField((lldb::SBTypeStaticField const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBTypeStaticField,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBTypeStaticField(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBTypeStaticField__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTypeStaticField, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBTypeStaticField__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBTypeStaticField'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBTypeStaticField::SBTypeStaticField()\n"
+ " lldb::SBTypeStaticField::SBTypeStaticField(lldb::SBTypeStaticField const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBTypeStaticField_IsValid(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *arg1 = (lldb::SBTypeStaticField *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::IsValid",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeStaticField::IsValid",1,"lldb::SBTypeStaticField const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeStaticField,0))){
+ SWIG_fail_ptr("SBTypeStaticField_IsValid",1,SWIGTYPE_p_lldb__SBTypeStaticField);
+ }
+
+ result = (bool)((lldb::SBTypeStaticField const *)arg1)->IsValid();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTypeStaticField_GetName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *arg1 = (lldb::SBTypeStaticField *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::GetName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeStaticField::GetName",1,"lldb::SBTypeStaticField *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeStaticField,0))){
+ SWIG_fail_ptr("SBTypeStaticField_GetName",1,SWIGTYPE_p_lldb__SBTypeStaticField);
+ }
+
+ result = (char *)(arg1)->GetName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTypeStaticField_GetMangledName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *arg1 = (lldb::SBTypeStaticField *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::GetMangledName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeStaticField::GetMangledName",1,"lldb::SBTypeStaticField *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeStaticField,0))){
+ SWIG_fail_ptr("SBTypeStaticField_GetMangledName",1,SWIGTYPE_p_lldb__SBTypeStaticField);
+ }
+
+ result = (char *)(arg1)->GetMangledName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTypeStaticField_GetType(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *arg1 = (lldb::SBTypeStaticField *) 0 ;
+ lldb::SBType result;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::GetType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeStaticField::GetType",1,"lldb::SBTypeStaticField *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeStaticField,0))){
+ SWIG_fail_ptr("SBTypeStaticField_GetType",1,SWIGTYPE_p_lldb__SBTypeStaticField);
+ }
+
+ result = (arg1)->GetType();
+ {
+ lldb::SBType * resultptr = new lldb::SBType(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTypeStaticField_GetConstantValue(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeStaticField *arg1 = (lldb::SBTypeStaticField *) 0 ;
+ lldb::SBTarget arg2 ;
+ lldb::SBTarget *argp2 ;
+ lldb::SBValue result;
+
+ SWIG_check_num_args("lldb::SBTypeStaticField::GetConstantValue",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeStaticField::GetConstantValue",1,"lldb::SBTypeStaticField *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeStaticField::GetConstantValue",2,"lldb::SBTarget");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeStaticField,0))){
+ SWIG_fail_ptr("SBTypeStaticField_GetConstantValue",1,SWIGTYPE_p_lldb__SBTypeStaticField);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBTarget,0))){
+ SWIG_fail_ptr("SBTypeStaticField_GetConstantValue",2,SWIGTYPE_p_lldb__SBTarget);
+ }
+ arg2 = *argp2;
+
+ result = (arg1)->GetConstantValue(arg2);
+ {
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBTypeStaticField(void *obj) {
+lldb::SBTypeStaticField *arg1 = (lldb::SBTypeStaticField *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBTypeStaticField(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBTypeStaticField);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBTypeStaticField_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBTypeStaticField_methods[]= {
+ { "IsValid", _wrap_SBTypeStaticField_IsValid},
+ { "GetName", _wrap_SBTypeStaticField_GetName},
+ { "GetMangledName", _wrap_SBTypeStaticField_GetMangledName},
+ { "GetType", _wrap_SBTypeStaticField_GetType},
+ { "GetConstantValue", _wrap_SBTypeStaticField_GetConstantValue},
+ {0,0}
+};
+static swig_lua_method swig_SBTypeStaticField_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBTypeStaticField_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBTypeStaticField_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBTypeStaticField_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBTypeStaticField_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBTypeStaticField_Sf_SwigStatic = {
+ "SBTypeStaticField",
+ swig_SBTypeStaticField_Sf_SwigStatic_methods,
+ swig_SBTypeStaticField_Sf_SwigStatic_attributes,
+ swig_SBTypeStaticField_Sf_SwigStatic_constants,
+ swig_SBTypeStaticField_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBTypeStaticField_bases[] = {0};
+static const char *swig_SBTypeStaticField_base_names[] = {0};
+static swig_lua_class _wrap_class_SBTypeStaticField = { "SBTypeStaticField", "SBTypeStaticField", &SWIGTYPE_p_lldb__SBTypeStaticField,_proxy__wrap_new_SBTypeStaticField, swig_delete_SBTypeStaticField, swig_SBTypeStaticField_methods, swig_SBTypeStaticField_attributes, &swig_SBTypeStaticField_Sf_SwigStatic, swig_SBTypeStaticField_meta, swig_SBTypeStaticField_bases, swig_SBTypeStaticField_base_names };
+
static int _wrap_new_SBType__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
@@ -60928,13 +68139,13 @@ static int _wrap_SBType_IsValid(lua_State* L) {
bool result;
SWIG_check_num_args("lldb::SBType::IsValid",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::IsValid",1,"lldb::SBType *");
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::IsValid",1,"lldb::SBType const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
SWIG_fail_ptr("SBType_IsValid",1,SWIGTYPE_p_lldb__SBType);
}
- result = (bool)(arg1)->IsValid();
+ result = (bool)((lldb::SBType const *)arg1)->IsValid();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -60969,6 +68180,30 @@ static int _wrap_SBType_GetByteSize(lua_State* L) {
}
+static int _wrap_SBType_GetByteAlign(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ uint64_t result;
+
+ SWIG_check_num_args("lldb::SBType::GetByteAlign",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetByteAlign",1,"lldb::SBType *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_GetByteAlign",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+ result = (uint64_t)(arg1)->GetByteAlign();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBType_IsPointerType(lua_State* L) {
{
int SWIG_arg = 0;
@@ -61371,20 +68606,20 @@ static int _wrap_SBType_GetUnqualifiedType(lua_State* L) {
}
-static int _wrap_SBType_GetCanonicalType(lua_State* L) {
+static int _wrap_SBType_GetArrayElementType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
lldb::SBType result;
- SWIG_check_num_args("lldb::SBType::GetCanonicalType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetCanonicalType",1,"lldb::SBType *");
+ SWIG_check_num_args("lldb::SBType::GetArrayElementType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetArrayElementType",1,"lldb::SBType *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetCanonicalType",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetArrayElementType",1,SWIGTYPE_p_lldb__SBType);
}
- result = (arg1)->GetCanonicalType();
+ result = (arg1)->GetArrayElementType();
{
lldb::SBType * resultptr = new lldb::SBType(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
@@ -61398,20 +68633,23 @@ static int _wrap_SBType_GetCanonicalType(lua_State* L) {
}
-static int _wrap_SBType_GetEnumerationIntegerType(lua_State* L) {
+static int _wrap_SBType_GetArrayType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ uint64_t arg2 ;
lldb::SBType result;
- SWIG_check_num_args("lldb::SBType::GetEnumerationIntegerType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetEnumerationIntegerType",1,"lldb::SBType *");
+ SWIG_check_num_args("lldb::SBType::GetArrayType",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetArrayType",1,"lldb::SBType *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBType::GetArrayType",2,"uint64_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetEnumerationIntegerType",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetArrayType",1,SWIGTYPE_p_lldb__SBType);
}
- result = (arg1)->GetEnumerationIntegerType();
+ arg2 = (uint64_t)lua_tointeger(L, 2);
+ result = (arg1)->GetArrayType(arg2);
{
lldb::SBType * resultptr = new lldb::SBType(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
@@ -61425,20 +68663,20 @@ static int _wrap_SBType_GetEnumerationIntegerType(lua_State* L) {
}
-static int _wrap_SBType_GetArrayElementType(lua_State* L) {
+static int _wrap_SBType_GetVectorElementType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
lldb::SBType result;
- SWIG_check_num_args("lldb::SBType::GetArrayElementType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetArrayElementType",1,"lldb::SBType *");
+ SWIG_check_num_args("lldb::SBType::GetVectorElementType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetVectorElementType",1,"lldb::SBType *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetArrayElementType",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetVectorElementType",1,SWIGTYPE_p_lldb__SBType);
}
- result = (arg1)->GetArrayElementType();
+ result = (arg1)->GetVectorElementType();
{
lldb::SBType * resultptr = new lldb::SBType(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
@@ -61452,23 +68690,20 @@ static int _wrap_SBType_GetArrayElementType(lua_State* L) {
}
-static int _wrap_SBType_GetArrayType(lua_State* L) {
+static int _wrap_SBType_GetCanonicalType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
- uint64_t arg2 ;
lldb::SBType result;
- SWIG_check_num_args("lldb::SBType::GetArrayType",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetArrayType",1,"lldb::SBType *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBType::GetArrayType",2,"uint64_t");
+ SWIG_check_num_args("lldb::SBType::GetCanonicalType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetCanonicalType",1,"lldb::SBType *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetArrayType",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetCanonicalType",1,SWIGTYPE_p_lldb__SBType);
}
- arg2 = (uint64_t)lua_tointeger(L, 2);
- result = (arg1)->GetArrayType(arg2);
+ result = (arg1)->GetCanonicalType();
{
lldb::SBType * resultptr = new lldb::SBType(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
@@ -61482,20 +68717,20 @@ static int _wrap_SBType_GetArrayType(lua_State* L) {
}
-static int _wrap_SBType_GetVectorElementType(lua_State* L) {
+static int _wrap_SBType_GetEnumerationIntegerType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
lldb::SBType result;
- SWIG_check_num_args("lldb::SBType::GetVectorElementType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetVectorElementType",1,"lldb::SBType *");
+ SWIG_check_num_args("lldb::SBType::GetEnumerationIntegerType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetEnumerationIntegerType",1,"lldb::SBType *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetVectorElementType",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetEnumerationIntegerType",1,SWIGTYPE_p_lldb__SBType);
}
- result = (arg1)->GetVectorElementType();
+ result = (arg1)->GetEnumerationIntegerType();
{
lldb::SBType * resultptr = new lldb::SBType(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
@@ -61774,23 +69009,26 @@ static int _wrap_SBType_GetVirtualBaseClassAtIndex(lua_State* L) {
}
-static int _wrap_SBType_GetEnumMembers(lua_State* L) {
+static int _wrap_SBType_GetStaticFieldWithName(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
- lldb::SBTypeEnumMemberList result;
+ char *arg2 = (char *) 0 ;
+ lldb::SBTypeStaticField result;
- SWIG_check_num_args("lldb::SBType::GetEnumMembers",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetEnumMembers",1,"lldb::SBType *");
+ SWIG_check_num_args("lldb::SBType::GetStaticFieldWithName",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetStaticFieldWithName",1,"lldb::SBType *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBType::GetStaticFieldWithName",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetEnumMembers",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetStaticFieldWithName",1,SWIGTYPE_p_lldb__SBType);
}
- result = (arg1)->GetEnumMembers();
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->GetStaticFieldWithName((char const *)arg2);
{
- lldb::SBTypeEnumMemberList * resultptr = new lldb::SBTypeEnumMemberList(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTypeEnumMemberList,1); SWIG_arg++;
+ lldb::SBTypeStaticField * resultptr = new lldb::SBTypeStaticField(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTypeStaticField,1); SWIG_arg++;
}
return SWIG_arg;
@@ -61801,96 +69039,24 @@ static int _wrap_SBType_GetEnumMembers(lua_State* L) {
}
-static int _wrap_SBType_GetModule(lua_State* L) {
+static int _wrap_SBType_GetEnumMembers(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBType *arg1 = (lldb::SBType *) 0 ;
- lldb::SBModule result;
+ lldb::SBTypeEnumMemberList result;
- SWIG_check_num_args("lldb::SBType::GetModule",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetModule",1,"lldb::SBType *");
+ SWIG_check_num_args("lldb::SBType::GetEnumMembers",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetEnumMembers",1,"lldb::SBType *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetModule",1,SWIGTYPE_p_lldb__SBType);
+ SWIG_fail_ptr("SBType_GetEnumMembers",1,SWIGTYPE_p_lldb__SBType);
}
- result = (arg1)->GetModule();
+ result = (arg1)->GetEnumMembers();
{
- lldb::SBModule * resultptr = new lldb::SBModule(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBModule,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBType_GetName(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBType *arg1 = (lldb::SBType *) 0 ;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBType::GetName",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetName",1,"lldb::SBType *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetName",1,SWIGTYPE_p_lldb__SBType);
- }
-
- result = (char *)(arg1)->GetName();
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBType_GetDisplayTypeName(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBType *arg1 = (lldb::SBType *) 0 ;
- char *result = 0 ;
-
- SWIG_check_num_args("lldb::SBType::GetDisplayTypeName",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetDisplayTypeName",1,"lldb::SBType *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetDisplayTypeName",1,SWIGTYPE_p_lldb__SBType);
- }
-
- result = (char *)(arg1)->GetDisplayTypeName();
- lua_pushstring(L,(const char *)result); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBType_GetTypeClass(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBType *arg1 = (lldb::SBType *) 0 ;
- lldb::TypeClass result;
-
- SWIG_check_num_args("lldb::SBType::GetTypeClass",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetTypeClass",1,"lldb::SBType *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
- SWIG_fail_ptr("SBType_GetTypeClass",1,SWIGTYPE_p_lldb__SBType);
+ lldb::SBTypeEnumMemberList * resultptr = new lldb::SBTypeEnumMemberList(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTypeEnumMemberList,1); SWIG_arg++;
}
-
- result = (lldb::TypeClass)(arg1)->GetTypeClass();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -62089,6 +69255,105 @@ static int _wrap_SBType_GetMemberFunctionAtIndex(lua_State* L) {
}
+static int _wrap_SBType_GetModule(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ lldb::SBModule result;
+
+ SWIG_check_num_args("lldb::SBType::GetModule",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetModule",1,"lldb::SBType *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_GetModule",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+ result = (arg1)->GetModule();
+ {
+ lldb::SBModule * resultptr = new lldb::SBModule(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBModule,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBType_GetName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBType::GetName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetName",1,"lldb::SBType *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_GetName",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+ result = (char *)(arg1)->GetName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBType_GetDisplayTypeName(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBType::GetDisplayTypeName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetDisplayTypeName",1,"lldb::SBType *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_GetDisplayTypeName",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+ result = (char *)(arg1)->GetDisplayTypeName();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBType_GetTypeClass(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ lldb::TypeClass result;
+
+ SWIG_check_num_args("lldb::SBType::GetTypeClass",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetTypeClass",1,"lldb::SBType *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_GetTypeClass",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+ result = (lldb::TypeClass)(arg1)->GetTypeClass();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBType_IsTypeComplete(lua_State* L) {
{
int SWIG_arg = 0;
@@ -62137,6 +69402,70 @@ static int _wrap_SBType_GetTypeFlags(lua_State* L) {
}
+static int _wrap_SBType_GetDescription(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ lldb::SBStream *arg2 = 0 ;
+ lldb::DescriptionLevel arg3 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBType::GetDescription",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::GetDescription",1,"lldb::SBType *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBType::GetDescription",2,"lldb::SBStream &");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBType::GetDescription",3,"lldb::DescriptionLevel");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_GetDescription",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBType_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ }
+
+ arg3 = (lldb::DescriptionLevel)lua_tointeger(L, 3);
+ result = (bool)(arg1)->GetDescription(*arg2,arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBType_FindDirectNestedType(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBType *arg1 = (lldb::SBType *) 0 ;
+ char *arg2 = (char *) 0 ;
+ lldb::SBType result;
+
+ SWIG_check_num_args("lldb::SBType::FindDirectNestedType",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBType::FindDirectNestedType",1,"lldb::SBType *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBType::FindDirectNestedType",2,"char const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBType,0))){
+ SWIG_fail_ptr("SBType_FindDirectNestedType",1,SWIGTYPE_p_lldb__SBType);
+ }
+
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->FindDirectNestedType((char const *)arg2);
+ {
+ lldb::SBType * resultptr = new lldb::SBType(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBType___eq(lua_State* L) {
{
int SWIG_arg = 0;
@@ -62210,6 +69539,7 @@ static swig_lua_attribute swig_SBType_attributes[] = {
static swig_lua_method swig_SBType_methods[]= {
{ "IsValid", _wrap_SBType_IsValid},
{ "GetByteSize", _wrap_SBType_GetByteSize},
+ { "GetByteAlign", _wrap_SBType_GetByteAlign},
{ "IsPointerType", _wrap_SBType_IsPointerType},
{ "IsReferenceType", _wrap_SBType_IsReferenceType},
{ "IsFunctionType", _wrap_SBType_IsFunctionType},
@@ -62226,11 +69556,11 @@ static swig_lua_method swig_SBType_methods[]= {
{ "GetTypedefedType", _wrap_SBType_GetTypedefedType},
{ "GetDereferencedType", _wrap_SBType_GetDereferencedType},
{ "GetUnqualifiedType", _wrap_SBType_GetUnqualifiedType},
- { "GetCanonicalType", _wrap_SBType_GetCanonicalType},
- { "GetEnumerationIntegerType", _wrap_SBType_GetEnumerationIntegerType},
{ "GetArrayElementType", _wrap_SBType_GetArrayElementType},
{ "GetArrayType", _wrap_SBType_GetArrayType},
{ "GetVectorElementType", _wrap_SBType_GetVectorElementType},
+ { "GetCanonicalType", _wrap_SBType_GetCanonicalType},
+ { "GetEnumerationIntegerType", _wrap_SBType_GetEnumerationIntegerType},
{ "GetBasicType", _wrap_SBType_GetBasicType},
{ "GetNumberOfFields", _wrap_SBType_GetNumberOfFields},
{ "GetNumberOfDirectBaseClasses", _wrap_SBType_GetNumberOfDirectBaseClasses},
@@ -62238,11 +69568,8 @@ static swig_lua_method swig_SBType_methods[]= {
{ "GetFieldAtIndex", _wrap_SBType_GetFieldAtIndex},
{ "GetDirectBaseClassAtIndex", _wrap_SBType_GetDirectBaseClassAtIndex},
{ "GetVirtualBaseClassAtIndex", _wrap_SBType_GetVirtualBaseClassAtIndex},
+ { "GetStaticFieldWithName", _wrap_SBType_GetStaticFieldWithName},
{ "GetEnumMembers", _wrap_SBType_GetEnumMembers},
- { "GetModule", _wrap_SBType_GetModule},
- { "GetName", _wrap_SBType_GetName},
- { "GetDisplayTypeName", _wrap_SBType_GetDisplayTypeName},
- { "GetTypeClass", _wrap_SBType_GetTypeClass},
{ "GetNumberOfTemplateArguments", _wrap_SBType_GetNumberOfTemplateArguments},
{ "GetTemplateArgumentType", _wrap_SBType_GetTemplateArgumentType},
{ "GetTemplateArgumentKind", _wrap_SBType_GetTemplateArgumentKind},
@@ -62250,8 +69577,14 @@ static swig_lua_method swig_SBType_methods[]= {
{ "GetFunctionArgumentTypes", _wrap_SBType_GetFunctionArgumentTypes},
{ "GetNumberOfMemberFunctions", _wrap_SBType_GetNumberOfMemberFunctions},
{ "GetMemberFunctionAtIndex", _wrap_SBType_GetMemberFunctionAtIndex},
+ { "GetModule", _wrap_SBType_GetModule},
+ { "GetName", _wrap_SBType_GetName},
+ { "GetDisplayTypeName", _wrap_SBType_GetDisplayTypeName},
+ { "GetTypeClass", _wrap_SBType_GetTypeClass},
{ "IsTypeComplete", _wrap_SBType_IsTypeComplete},
{ "GetTypeFlags", _wrap_SBType_GetTypeFlags},
+ { "GetDescription", _wrap_SBType_GetDescription},
+ { "FindDirectNestedType", _wrap_SBType_FindDirectNestedType},
{ "__eq", _wrap_SBType___eq},
{ "__tostring", _wrap_SBType___tostring},
{0,0}
@@ -62287,7 +69620,7 @@ static swig_lua_class *swig_SBType_bases[] = {0};
static const char *swig_SBType_base_names[] = {0};
static swig_lua_class _wrap_class_SBType = { "SBType", "SBType", &SWIGTYPE_p_lldb__SBType,_proxy__wrap_new_SBType, swig_delete_SBType, swig_SBType_methods, swig_SBType_attributes, &swig_SBType_Sf_SwigStatic, swig_SBType_meta, swig_SBType_bases, swig_SBType_base_names };
-static int _wrap_new_SBTypeList(lua_State* L) {
+static int _wrap_new_SBTypeList__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTypeList *result = 0 ;
@@ -62304,6 +69637,63 @@ static int _wrap_new_SBTypeList(lua_State* L) {
}
+static int _wrap_new_SBTypeList__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeList *arg1 = 0 ;
+ lldb::SBTypeList *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBTypeList::SBTypeList",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBTypeList::SBTypeList",1,"lldb::SBTypeList const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeList,0))){
+ SWIG_fail_ptr("new_SBTypeList",1,SWIGTYPE_p_lldb__SBTypeList);
+ }
+
+ result = (lldb::SBTypeList *)new lldb::SBTypeList((lldb::SBTypeList const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBTypeList,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBTypeList(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBTypeList__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBTypeList, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBTypeList__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBTypeList'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBTypeList::SBTypeList()\n"
+ " lldb::SBTypeList::SBTypeList(lldb::SBTypeList const &)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBTypeList_IsValid(lua_State* L) {
{
int SWIG_arg = 0;
@@ -63528,6 +70918,37 @@ static int _wrap_SBTypeCategory_DeleteTypeSynthetic(lua_State* L) {
}
+static int _wrap_SBTypeCategory___eq(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeCategory *arg1 = (lldb::SBTypeCategory *) 0 ;
+ lldb::SBTypeCategory *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeCategory::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeCategory::operator ==",1,"lldb::SBTypeCategory *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeCategory::operator ==",2,"lldb::SBTypeCategory &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeCategory,0))){
+ SWIG_fail_ptr("SBTypeCategory___eq",1,SWIGTYPE_p_lldb__SBTypeCategory);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeCategory,0))){
+ SWIG_fail_ptr("SBTypeCategory___eq",2,SWIGTYPE_p_lldb__SBTypeCategory);
+ }
+
+ result = (bool)(arg1)->operator ==(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeCategory___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -63600,10 +71021,12 @@ static swig_lua_method swig_SBTypeCategory_methods[]= {
{ "DeleteTypeFilter", _wrap_SBTypeCategory_DeleteTypeFilter},
{ "AddTypeSynthetic", _wrap_SBTypeCategory_AddTypeSynthetic},
{ "DeleteTypeSynthetic", _wrap_SBTypeCategory_DeleteTypeSynthetic},
+ { "__eq", _wrap_SBTypeCategory___eq},
{ "__tostring", _wrap_SBTypeCategory___tostring},
{0,0}
};
static swig_lua_method swig_SBTypeCategory_meta[] = {
+ { "__eq", _wrap_SBTypeCategory___eq},
{ "__tostring", _wrap_SBTypeCategory___tostring},
{0,0}
};
@@ -64306,37 +71729,6 @@ static int _wrap_SBTypeFilter_IsValid(lua_State* L) {
}
-static int _wrap_SBTypeFilter_IsEqualTo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTypeFilter *arg1 = (lldb::SBTypeFilter *) 0 ;
- lldb::SBTypeFilter *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTypeFilter::IsEqualTo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeFilter::IsEqualTo",1,"lldb::SBTypeFilter *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeFilter::IsEqualTo",2,"lldb::SBTypeFilter &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeFilter,0))){
- SWIG_fail_ptr("SBTypeFilter_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeFilter);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeFilter,0))){
- SWIG_fail_ptr("SBTypeFilter_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeFilter);
- }
-
- result = (bool)(arg1)->IsEqualTo(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTypeFilter_GetNumberOfExpressionPaths(lua_State* L) {
{
int SWIG_arg = 0;
@@ -64551,6 +71943,37 @@ static int _wrap_SBTypeFilter_GetDescription(lua_State* L) {
}
+static int _wrap_SBTypeFilter_IsEqualTo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeFilter *arg1 = (lldb::SBTypeFilter *) 0 ;
+ lldb::SBTypeFilter *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeFilter::IsEqualTo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeFilter::IsEqualTo",1,"lldb::SBTypeFilter *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeFilter::IsEqualTo",2,"lldb::SBTypeFilter &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeFilter,0))){
+ SWIG_fail_ptr("SBTypeFilter_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeFilter);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeFilter,0))){
+ SWIG_fail_ptr("SBTypeFilter_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeFilter);
+ }
+
+ result = (bool)(arg1)->IsEqualTo(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeFilter___eq(lua_State* L) {
{
int SWIG_arg = 0;
@@ -64623,7 +72046,6 @@ static swig_lua_attribute swig_SBTypeFilter_attributes[] = {
};
static swig_lua_method swig_SBTypeFilter_methods[]= {
{ "IsValid", _wrap_SBTypeFilter_IsValid},
- { "IsEqualTo", _wrap_SBTypeFilter_IsEqualTo},
{ "GetNumberOfExpressionPaths", _wrap_SBTypeFilter_GetNumberOfExpressionPaths},
{ "GetExpressionPathAtIndex", _wrap_SBTypeFilter_GetExpressionPathAtIndex},
{ "ReplaceExpressionPathAtIndex", _wrap_SBTypeFilter_ReplaceExpressionPathAtIndex},
@@ -64632,6 +72054,7 @@ static swig_lua_method swig_SBTypeFilter_methods[]= {
{ "GetOptions", _wrap_SBTypeFilter_GetOptions},
{ "SetOptions", _wrap_SBTypeFilter_SetOptions},
{ "GetDescription", _wrap_SBTypeFilter_GetDescription},
+ { "IsEqualTo", _wrap_SBTypeFilter_IsEqualTo},
{ "__eq", _wrap_SBTypeFilter___eq},
{ "__tostring", _wrap_SBTypeFilter___tostring},
{0,0}
@@ -64901,37 +72324,6 @@ static int _wrap_SBTypeFormat_IsValid(lua_State* L) {
}
-static int _wrap_SBTypeFormat_IsEqualTo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTypeFormat *arg1 = (lldb::SBTypeFormat *) 0 ;
- lldb::SBTypeFormat *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTypeFormat::IsEqualTo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeFormat::IsEqualTo",1,"lldb::SBTypeFormat *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeFormat::IsEqualTo",2,"lldb::SBTypeFormat &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeFormat,0))){
- SWIG_fail_ptr("SBTypeFormat_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeFormat);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeFormat,0))){
- SWIG_fail_ptr("SBTypeFormat_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeFormat);
- }
-
- result = (bool)(arg1)->IsEqualTo(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTypeFormat_GetFormat(lua_State* L) {
{
int SWIG_arg = 0;
@@ -65116,6 +72508,37 @@ static int _wrap_SBTypeFormat_GetDescription(lua_State* L) {
}
+static int _wrap_SBTypeFormat_IsEqualTo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeFormat *arg1 = (lldb::SBTypeFormat *) 0 ;
+ lldb::SBTypeFormat *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeFormat::IsEqualTo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeFormat::IsEqualTo",1,"lldb::SBTypeFormat *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeFormat::IsEqualTo",2,"lldb::SBTypeFormat &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeFormat,0))){
+ SWIG_fail_ptr("SBTypeFormat_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeFormat);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeFormat,0))){
+ SWIG_fail_ptr("SBTypeFormat_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeFormat);
+ }
+
+ result = (bool)(arg1)->IsEqualTo(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeFormat___eq(lua_State* L) {
{
int SWIG_arg = 0;
@@ -65188,7 +72611,6 @@ static swig_lua_attribute swig_SBTypeFormat_attributes[] = {
};
static swig_lua_method swig_SBTypeFormat_methods[]= {
{ "IsValid", _wrap_SBTypeFormat_IsValid},
- { "IsEqualTo", _wrap_SBTypeFormat_IsEqualTo},
{ "GetFormat", _wrap_SBTypeFormat_GetFormat},
{ "GetTypeName", _wrap_SBTypeFormat_GetTypeName},
{ "GetOptions", _wrap_SBTypeFormat_GetOptions},
@@ -65196,6 +72618,7 @@ static swig_lua_method swig_SBTypeFormat_methods[]= {
{ "SetTypeName", _wrap_SBTypeFormat_SetTypeName},
{ "SetOptions", _wrap_SBTypeFormat_SetOptions},
{ "GetDescription", _wrap_SBTypeFormat_GetDescription},
+ { "IsEqualTo", _wrap_SBTypeFormat_IsEqualTo},
{ "__eq", _wrap_SBTypeFormat___eq},
{ "__tostring", _wrap_SBTypeFormat___tostring},
{0,0}
@@ -65476,37 +72899,6 @@ static int _wrap_SBTypeNameSpecifier_IsValid(lua_State* L) {
}
-static int _wrap_SBTypeNameSpecifier_IsEqualTo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTypeNameSpecifier *arg1 = (lldb::SBTypeNameSpecifier *) 0 ;
- lldb::SBTypeNameSpecifier *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTypeNameSpecifier::IsEqualTo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeNameSpecifier::IsEqualTo",1,"lldb::SBTypeNameSpecifier *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeNameSpecifier::IsEqualTo",2,"lldb::SBTypeNameSpecifier &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeNameSpecifier,0))){
- SWIG_fail_ptr("SBTypeNameSpecifier_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeNameSpecifier);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeNameSpecifier,0))){
- SWIG_fail_ptr("SBTypeNameSpecifier_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeNameSpecifier);
- }
-
- result = (bool)(arg1)->IsEqualTo(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTypeNameSpecifier_GetName(lua_State* L) {
{
int SWIG_arg = 0;
@@ -65640,6 +73032,37 @@ static int _wrap_SBTypeNameSpecifier_GetDescription(lua_State* L) {
}
+static int _wrap_SBTypeNameSpecifier_IsEqualTo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeNameSpecifier *arg1 = (lldb::SBTypeNameSpecifier *) 0 ;
+ lldb::SBTypeNameSpecifier *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeNameSpecifier::IsEqualTo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeNameSpecifier::IsEqualTo",1,"lldb::SBTypeNameSpecifier *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeNameSpecifier::IsEqualTo",2,"lldb::SBTypeNameSpecifier &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeNameSpecifier,0))){
+ SWIG_fail_ptr("SBTypeNameSpecifier_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeNameSpecifier);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeNameSpecifier,0))){
+ SWIG_fail_ptr("SBTypeNameSpecifier_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeNameSpecifier);
+ }
+
+ result = (bool)(arg1)->IsEqualTo(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeNameSpecifier___eq(lua_State* L) {
{
int SWIG_arg = 0;
@@ -65712,12 +73135,12 @@ static swig_lua_attribute swig_SBTypeNameSpecifier_attributes[] = {
};
static swig_lua_method swig_SBTypeNameSpecifier_methods[]= {
{ "IsValid", _wrap_SBTypeNameSpecifier_IsValid},
- { "IsEqualTo", _wrap_SBTypeNameSpecifier_IsEqualTo},
{ "GetName", _wrap_SBTypeNameSpecifier_GetName},
{ "GetType", _wrap_SBTypeNameSpecifier_GetType},
{ "GetMatchType", _wrap_SBTypeNameSpecifier_GetMatchType},
{ "IsRegex", _wrap_SBTypeNameSpecifier_IsRegex},
{ "GetDescription", _wrap_SBTypeNameSpecifier_GetDescription},
+ { "IsEqualTo", _wrap_SBTypeNameSpecifier_IsEqualTo},
{ "__eq", _wrap_SBTypeNameSpecifier___eq},
{ "__tostring", _wrap_SBTypeNameSpecifier___tostring},
{0,0}
@@ -66365,37 +73788,6 @@ static int _wrap_SBTypeSummary_IsValid(lua_State* L) {
}
-static int _wrap_SBTypeSummary_IsEqualTo(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBTypeSummary *arg1 = (lldb::SBTypeSummary *) 0 ;
- lldb::SBTypeSummary *arg2 = 0 ;
- bool result;
-
- SWIG_check_num_args("lldb::SBTypeSummary::IsEqualTo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSummary::IsEqualTo",1,"lldb::SBTypeSummary *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeSummary::IsEqualTo",2,"lldb::SBTypeSummary &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeSummary,0))){
- SWIG_fail_ptr("SBTypeSummary_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeSummary);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeSummary,0))){
- SWIG_fail_ptr("SBTypeSummary_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeSummary);
- }
-
- result = (bool)(arg1)->IsEqualTo(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
static int _wrap_SBTypeSummary_IsFunctionCode(lua_State* L) {
{
int SWIG_arg = 0;
@@ -66654,6 +74046,70 @@ static int _wrap_SBTypeSummary_GetDescription(lua_State* L) {
}
+static int _wrap_SBTypeSummary_DoesPrintValue(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeSummary *arg1 = (lldb::SBTypeSummary *) 0 ;
+ lldb::SBValue arg2 ;
+ lldb::SBValue *argp2 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeSummary::DoesPrintValue",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSummary::DoesPrintValue",1,"lldb::SBTypeSummary *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeSummary::DoesPrintValue",2,"lldb::SBValue");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeSummary,0))){
+ SWIG_fail_ptr("SBTypeSummary_DoesPrintValue",1,SWIGTYPE_p_lldb__SBTypeSummary);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBTypeSummary_DoesPrintValue",2,SWIGTYPE_p_lldb__SBValue);
+ }
+ arg2 = *argp2;
+
+ result = (bool)(arg1)->DoesPrintValue(arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBTypeSummary_IsEqualTo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeSummary *arg1 = (lldb::SBTypeSummary *) 0 ;
+ lldb::SBTypeSummary *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeSummary::IsEqualTo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSummary::IsEqualTo",1,"lldb::SBTypeSummary *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeSummary::IsEqualTo",2,"lldb::SBTypeSummary &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeSummary,0))){
+ SWIG_fail_ptr("SBTypeSummary_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeSummary);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeSummary,0))){
+ SWIG_fail_ptr("SBTypeSummary_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeSummary);
+ }
+
+ result = (bool)(arg1)->IsEqualTo(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeSummary___eq(lua_State* L) {
{
int SWIG_arg = 0;
@@ -66726,7 +74182,6 @@ static swig_lua_attribute swig_SBTypeSummary_attributes[] = {
};
static swig_lua_method swig_SBTypeSummary_methods[]= {
{ "IsValid", _wrap_SBTypeSummary_IsValid},
- { "IsEqualTo", _wrap_SBTypeSummary_IsEqualTo},
{ "IsFunctionCode", _wrap_SBTypeSummary_IsFunctionCode},
{ "IsFunctionName", _wrap_SBTypeSummary_IsFunctionName},
{ "IsSummaryString", _wrap_SBTypeSummary_IsSummaryString},
@@ -66737,6 +74192,8 @@ static swig_lua_method swig_SBTypeSummary_methods[]= {
{ "GetOptions", _wrap_SBTypeSummary_GetOptions},
{ "SetOptions", _wrap_SBTypeSummary_SetOptions},
{ "GetDescription", _wrap_SBTypeSummary_GetDescription},
+ { "DoesPrintValue", _wrap_SBTypeSummary_DoesPrintValue},
+ { "IsEqualTo", _wrap_SBTypeSummary_IsEqualTo},
{ "__eq", _wrap_SBTypeSummary___eq},
{ "__tostring", _wrap_SBTypeSummary___tostring},
{0,0}
@@ -67049,27 +74506,20 @@ static int _wrap_SBTypeSynthetic_IsValid(lua_State* L) {
}
-static int _wrap_SBTypeSynthetic_IsEqualTo(lua_State* L) {
+static int _wrap_SBTypeSynthetic_IsClassCode(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTypeSynthetic *arg1 = (lldb::SBTypeSynthetic *) 0 ;
- lldb::SBTypeSynthetic *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBTypeSynthetic::IsEqualTo",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsEqualTo",1,"lldb::SBTypeSynthetic *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsEqualTo",2,"lldb::SBTypeSynthetic &");
+ SWIG_check_num_args("lldb::SBTypeSynthetic::IsClassCode",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsClassCode",1,"lldb::SBTypeSynthetic *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeSynthetic,0))){
- SWIG_fail_ptr("SBTypeSynthetic_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeSynthetic);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeSynthetic,0))){
- SWIG_fail_ptr("SBTypeSynthetic_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeSynthetic);
+ SWIG_fail_ptr("SBTypeSynthetic_IsClassCode",1,SWIGTYPE_p_lldb__SBTypeSynthetic);
}
- result = (bool)(arg1)->IsEqualTo(*arg2);
+ result = (bool)(arg1)->IsClassCode();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -67080,20 +74530,20 @@ static int _wrap_SBTypeSynthetic_IsEqualTo(lua_State* L) {
}
-static int _wrap_SBTypeSynthetic_IsClassCode(lua_State* L) {
+static int _wrap_SBTypeSynthetic_IsClassName(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBTypeSynthetic *arg1 = (lldb::SBTypeSynthetic *) 0 ;
bool result;
- SWIG_check_num_args("lldb::SBTypeSynthetic::IsClassCode",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsClassCode",1,"lldb::SBTypeSynthetic *");
+ SWIG_check_num_args("lldb::SBTypeSynthetic::IsClassName",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsClassName",1,"lldb::SBTypeSynthetic *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeSynthetic,0))){
- SWIG_fail_ptr("SBTypeSynthetic_IsClassCode",1,SWIGTYPE_p_lldb__SBTypeSynthetic);
+ SWIG_fail_ptr("SBTypeSynthetic_IsClassName",1,SWIGTYPE_p_lldb__SBTypeSynthetic);
}
- result = (bool)(arg1)->IsClassCode();
+ result = (bool)(arg1)->IsClassName();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -67264,6 +74714,37 @@ static int _wrap_SBTypeSynthetic_GetDescription(lua_State* L) {
}
+static int _wrap_SBTypeSynthetic_IsEqualTo(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBTypeSynthetic *arg1 = (lldb::SBTypeSynthetic *) 0 ;
+ lldb::SBTypeSynthetic *arg2 = 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBTypeSynthetic::IsEqualTo",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsEqualTo",1,"lldb::SBTypeSynthetic *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBTypeSynthetic::IsEqualTo",2,"lldb::SBTypeSynthetic &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBTypeSynthetic,0))){
+ SWIG_fail_ptr("SBTypeSynthetic_IsEqualTo",1,SWIGTYPE_p_lldb__SBTypeSynthetic);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBTypeSynthetic,0))){
+ SWIG_fail_ptr("SBTypeSynthetic_IsEqualTo",2,SWIGTYPE_p_lldb__SBTypeSynthetic);
+ }
+
+ result = (bool)(arg1)->IsEqualTo(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBTypeSynthetic___eq(lua_State* L) {
{
int SWIG_arg = 0;
@@ -67336,14 +74817,15 @@ static swig_lua_attribute swig_SBTypeSynthetic_attributes[] = {
};
static swig_lua_method swig_SBTypeSynthetic_methods[]= {
{ "IsValid", _wrap_SBTypeSynthetic_IsValid},
- { "IsEqualTo", _wrap_SBTypeSynthetic_IsEqualTo},
{ "IsClassCode", _wrap_SBTypeSynthetic_IsClassCode},
+ { "IsClassName", _wrap_SBTypeSynthetic_IsClassName},
{ "GetData", _wrap_SBTypeSynthetic_GetData},
{ "SetClassName", _wrap_SBTypeSynthetic_SetClassName},
{ "SetClassCode", _wrap_SBTypeSynthetic_SetClassCode},
{ "GetOptions", _wrap_SBTypeSynthetic_GetOptions},
{ "SetOptions", _wrap_SBTypeSynthetic_SetOptions},
{ "GetDescription", _wrap_SBTypeSynthetic_GetDescription},
+ { "IsEqualTo", _wrap_SBTypeSynthetic_IsEqualTo},
{ "__eq", _wrap_SBTypeSynthetic___eq},
{ "__tostring", _wrap_SBTypeSynthetic___tostring},
{0,0}
@@ -68643,6 +76125,30 @@ static int _wrap_SBValue_GetValueAsUnsigned(lua_State* L) {
}
+static int _wrap_SBValue_GetValueAsAddress(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ lldb::addr_t result;
+
+ SWIG_check_num_args("lldb::SBValue::GetValueAsAddress",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetValueAsAddress",1,"lldb::SBValue *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_GetValueAsAddress",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ result = (lldb::addr_t)(arg1)->GetValueAsAddress();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBValue_GetValueType(lua_State* L) {
{
int SWIG_arg = 0;
@@ -68925,6 +76431,33 @@ static int _wrap_SBValue_GetNonSyntheticValue(lua_State* L) {
}
+static int _wrap_SBValue_GetSyntheticValue(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ lldb::SBValue result;
+
+ SWIG_check_num_args("lldb::SBValue::GetSyntheticValue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetSyntheticValue",1,"lldb::SBValue *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_GetSyntheticValue",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ result = (arg1)->GetSyntheticValue();
+ {
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBValue_GetPreferDynamicValue(lua_State* L) {
{
int SWIG_arg = 0;
@@ -69410,106 +76943,6 @@ static int _wrap_SBValue_GetChildAtIndex__SWIG_0(lua_State* L) {
}
-static int _wrap_SBValue_GetChildAtIndex__SWIG_1(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- uint32_t arg2 ;
- lldb::DynamicValueType arg3 ;
- bool arg4 ;
- lldb::SBValue result;
-
- SWIG_check_num_args("lldb::SBValue::GetChildAtIndex",4,4)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",1,"lldb::SBValue *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",2,"uint32_t");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",3,"lldb::DynamicValueType");
- if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",4,"bool");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetChildAtIndex",1,SWIGTYPE_p_lldb__SBValue);
- }
-
- arg2 = (uint32_t)lua_tointeger(L, 2);
- arg3 = (lldb::DynamicValueType)lua_tointeger(L, 3);
- arg4 = (lua_toboolean(L, 4)!=0);
- result = (arg1)->GetChildAtIndex(arg2,arg3,arg4);
- {
- lldb::SBValue * resultptr = new lldb::SBValue(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
- }
- return SWIG_arg;
-
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBValue_GetChildAtIndex(lua_State* L) {
- int argc;
- int argv[5]={
- 1,2,3,4,5
- };
-
- argc = lua_gettop(L);
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = lua_isnumber(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBValue_GetChildAtIndex__SWIG_0(L);
- }
- }
- }
- if (argc == 4) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = lua_isnumber(L,argv[1]);
- }
- if (_v) {
- {
- _v = lua_isnumber(L,argv[2]);
- }
- if (_v) {
- {
- _v = lua_isboolean(L,argv[3]);
- }
- if (_v) {
- return _wrap_SBValue_GetChildAtIndex__SWIG_1(L);
- }
- }
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_GetChildAtIndex'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBValue::GetChildAtIndex(uint32_t)\n"
- " lldb::SBValue::GetChildAtIndex(uint32_t,lldb::DynamicValueType,bool)\n");
- lua_error(L);return 0;
-}
-
-
static int _wrap_SBValue_CreateChildAtOffset(lua_State* L) {
{
int SWIG_arg = 0;
@@ -69825,23 +77258,32 @@ static int _wrap_SBValue_CreateValueFromData(lua_State* L) {
}
-static int _wrap_SBValue_GetType(lua_State* L) {
+static int _wrap_SBValue_GetChildAtIndex__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBType result;
+ uint32_t arg2 ;
+ lldb::DynamicValueType arg3 ;
+ bool arg4 ;
+ lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValue::GetType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetType",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetChildAtIndex",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",1,"lldb::SBValue *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",2,"uint32_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",3,"lldb::DynamicValueType");
+ if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::GetChildAtIndex",4,"bool");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetType",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetChildAtIndex",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetType();
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ arg3 = (lldb::DynamicValueType)lua_tointeger(L, 3);
+ arg4 = (lua_toboolean(L, 4)!=0);
+ result = (arg1)->GetChildAtIndex(arg2,arg3,arg4);
{
- lldb::SBType * resultptr = new lldb::SBType(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
}
return SWIG_arg;
@@ -69852,6 +77294,70 @@ static int _wrap_SBValue_GetType(lua_State* L) {
}
+static int _wrap_SBValue_GetChildAtIndex(lua_State* L) {
+ int argc;
+ int argv[5]={
+ 1,2,3,4,5
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 2) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBValue_GetChildAtIndex__SWIG_0(L);
+ }
+ }
+ }
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_SBValue_GetChildAtIndex__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_GetChildAtIndex'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBValue::GetChildAtIndex(uint32_t)\n"
+ " lldb::SBValue::GetChildAtIndex(uint32_t,lldb::DynamicValueType,bool)\n");
+ lua_error(L);return 0;
+}
+
+
static int _wrap_SBValue_GetIndexOfChildWithName(lua_State* L) {
{
int SWIG_arg = 0;
@@ -70031,23 +77537,23 @@ static int _wrap_SBValue_GetValueForExpressionPath(lua_State* L) {
}
-static int _wrap_SBValue_GetDeclaration(lua_State* L) {
+static int _wrap_SBValue_AddressOf(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBDeclaration result;
+ lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValue::GetDeclaration",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetDeclaration",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::AddressOf",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::AddressOf",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetDeclaration",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_AddressOf",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetDeclaration();
+ result = (arg1)->AddressOf();
{
- lldb::SBDeclaration * resultptr = new lldb::SBDeclaration(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBDeclaration,1); SWIG_arg++;
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
}
return SWIG_arg;
@@ -70058,21 +77564,21 @@ static int _wrap_SBValue_GetDeclaration(lua_State* L) {
}
-static int _wrap_SBValue_MightHaveChildren(lua_State* L) {
+static int _wrap_SBValue_GetLoadAddress(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- bool result;
+ lldb::addr_t result;
- SWIG_check_num_args("lldb::SBValue::MightHaveChildren",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::MightHaveChildren",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetLoadAddress",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetLoadAddress",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_MightHaveChildren",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetLoadAddress",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (bool)(arg1)->MightHaveChildren();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ result = (lldb::addr_t)(arg1)->GetLoadAddress();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70082,21 +77588,24 @@ static int _wrap_SBValue_MightHaveChildren(lua_State* L) {
}
-static int _wrap_SBValue_IsRuntimeSupportValue(lua_State* L) {
+static int _wrap_SBValue_GetAddress(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- bool result;
+ lldb::SBAddress result;
- SWIG_check_num_args("lldb::SBValue::IsRuntimeSupportValue",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::IsRuntimeSupportValue",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetAddress",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetAddress",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_IsRuntimeSupportValue",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetAddress",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (bool)(arg1)->IsRuntimeSupportValue();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ result = (arg1)->GetAddress();
+ {
+ lldb::SBAddress * resultptr = new lldb::SBAddress(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddress,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70106,21 +77615,30 @@ static int _wrap_SBValue_IsRuntimeSupportValue(lua_State* L) {
}
-static int _wrap_SBValue_GetNumChildren__SWIG_0(lua_State* L) {
+static int _wrap_SBValue_GetPointeeData__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- uint32_t result;
+ uint32_t arg2 ;
+ uint32_t arg3 ;
+ lldb::SBData result;
- SWIG_check_num_args("lldb::SBValue::GetNumChildren",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetNumChildren",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetPointeeData",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",1,"lldb::SBValue *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",2,"uint32_t");
+ if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",3,"uint32_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetNumChildren",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetPointeeData",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (uint32_t)(arg1)->GetNumChildren();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ arg3 = (uint32_t)lua_tointeger(L, 3);
+ result = (arg1)->GetPointeeData(arg2,arg3);
+ {
+ lldb::SBData * resultptr = new lldb::SBData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70130,24 +77648,27 @@ static int _wrap_SBValue_GetNumChildren__SWIG_0(lua_State* L) {
}
-static int _wrap_SBValue_GetNumChildren__SWIG_1(lua_State* L) {
+static int _wrap_SBValue_GetPointeeData__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
uint32_t arg2 ;
- uint32_t result;
+ lldb::SBData result;
- SWIG_check_num_args("lldb::SBValue::GetNumChildren",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetNumChildren",1,"lldb::SBValue *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetNumChildren",2,"uint32_t");
+ SWIG_check_num_args("lldb::SBValue::GetPointeeData",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",1,"lldb::SBValue *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",2,"uint32_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetNumChildren",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetPointeeData",1,SWIGTYPE_p_lldb__SBValue);
}
arg2 = (uint32_t)lua_tointeger(L, 2);
- result = (uint32_t)(arg1)->GetNumChildren(arg2);
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ result = (arg1)->GetPointeeData(arg2);
+ {
+ lldb::SBData * resultptr = new lldb::SBData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70157,10 +77678,37 @@ static int _wrap_SBValue_GetNumChildren__SWIG_1(lua_State* L) {
}
-static int _wrap_SBValue_GetNumChildren(lua_State* L) {
+static int _wrap_SBValue_GetPointeeData__SWIG_2(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ lldb::SBData result;
+
+ SWIG_check_num_args("lldb::SBValue::GetPointeeData",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",1,"lldb::SBValue *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_GetPointeeData",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ result = (arg1)->GetPointeeData();
+ {
+ lldb::SBData * resultptr = new lldb::SBData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBValue_GetPointeeData(lua_State* L) {
int argc;
- int argv[3]={
- 1,2,3
+ int argv[4]={
+ 1,2,3,4
};
argc = lua_gettop(L);
@@ -70175,7 +77723,7 @@ static int _wrap_SBValue_GetNumChildren(lua_State* L) {
}
}
if (_v) {
- return _wrap_SBValue_GetNumChildren__SWIG_0(L);
+ return _wrap_SBValue_GetPointeeData__SWIG_2(L);
}
}
if (argc == 2) {
@@ -70193,34 +77741,62 @@ static int _wrap_SBValue_GetNumChildren(lua_State* L) {
_v = lua_isnumber(L,argv[1]);
}
if (_v) {
- return _wrap_SBValue_GetNumChildren__SWIG_1(L);
+ return _wrap_SBValue_GetPointeeData__SWIG_1(L);
+ }
+ }
+ }
+ if (argc == 3) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[2]);
+ }
+ if (_v) {
+ return _wrap_SBValue_GetPointeeData__SWIG_0(L);
+ }
}
}
}
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_GetNumChildren'\n"
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_GetPointeeData'\n"
" Possible C/C++ prototypes are:\n"
- " lldb::SBValue::GetNumChildren()\n"
- " lldb::SBValue::GetNumChildren(uint32_t)\n");
+ " lldb::SBValue::GetPointeeData(uint32_t,uint32_t)\n"
+ " lldb::SBValue::GetPointeeData(uint32_t)\n"
+ " lldb::SBValue::GetPointeeData()\n");
lua_error(L);return 0;
}
-static int _wrap_SBValue_GetOpaqueType(lua_State* L) {
+static int _wrap_SBValue_GetData(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- void *result = 0 ;
+ lldb::SBData result;
- SWIG_check_num_args("lldb::SBValue::GetOpaqueType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetOpaqueType",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetData",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetData",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetOpaqueType",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetData",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (void *)(arg1)->GetOpaqueType();
- SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++;
+ result = (arg1)->GetData();
+ {
+ lldb::SBData * resultptr = new lldb::SBData(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70230,24 +77806,35 @@ static int _wrap_SBValue_GetOpaqueType(lua_State* L) {
}
-static int _wrap_SBValue_Dereference(lua_State* L) {
+static int _wrap_SBValue_SetData(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBValue result;
+ lldb::SBData *arg2 = 0 ;
+ lldb::SBError *arg3 = 0 ;
+ bool result;
- SWIG_check_num_args("lldb::SBValue::Dereference",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Dereference",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::SetData",3,3)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::SetData",1,"lldb::SBValue *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBValue::SetData",2,"lldb::SBData &");
+ if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBValue::SetData",3,"lldb::SBError &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_Dereference",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_SetData",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->Dereference();
- {
- lldb::SBValue * resultptr = new lldb::SBValue(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBData,0))){
+ SWIG_fail_ptr("SBValue_SetData",2,SWIGTYPE_p_lldb__SBData);
+ }
+
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBValue_SetData",3,SWIGTYPE_p_lldb__SBError);
}
+
+ result = (bool)(arg1)->SetData(*arg2,*arg3);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70257,20 +77844,23 @@ static int _wrap_SBValue_Dereference(lua_State* L) {
}
-static int _wrap_SBValue_AddressOf(lua_State* L) {
+static int _wrap_SBValue_Clone(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ char *arg2 = (char *) 0 ;
lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValue::AddressOf",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::AddressOf",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::Clone",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Clone",1,"lldb::SBValue *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBValue::Clone",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_AddressOf",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_Clone",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->AddressOf();
+ arg2 = (char *)lua_tostring(L, 2);
+ result = (arg1)->Clone((char const *)arg2);
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -70284,21 +77874,24 @@ static int _wrap_SBValue_AddressOf(lua_State* L) {
}
-static int _wrap_SBValue_TypeIsPointerType(lua_State* L) {
+static int _wrap_SBValue_GetDeclaration(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- bool result;
+ lldb::SBDeclaration result;
- SWIG_check_num_args("lldb::SBValue::TypeIsPointerType",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::TypeIsPointerType",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetDeclaration",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetDeclaration",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_TypeIsPointerType",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetDeclaration",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (bool)(arg1)->TypeIsPointerType();
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ result = (arg1)->GetDeclaration();
+ {
+ lldb::SBDeclaration * resultptr = new lldb::SBDeclaration(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBDeclaration,1); SWIG_arg++;
+ }
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70308,24 +77901,21 @@ static int _wrap_SBValue_TypeIsPointerType(lua_State* L) {
}
-static int _wrap_SBValue_GetTarget(lua_State* L) {
+static int _wrap_SBValue_MightHaveChildren(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBTarget result;
+ bool result;
- SWIG_check_num_args("lldb::SBValue::GetTarget",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetTarget",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::MightHaveChildren",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::MightHaveChildren",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetTarget",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_MightHaveChildren",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetTarget();
- {
- lldb::SBTarget * resultptr = new lldb::SBTarget(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTarget,1); SWIG_arg++;
- }
+ result = (bool)(arg1)->MightHaveChildren();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70335,24 +77925,21 @@ static int _wrap_SBValue_GetTarget(lua_State* L) {
}
-static int _wrap_SBValue_GetProcess(lua_State* L) {
+static int _wrap_SBValue_IsRuntimeSupportValue(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBProcess result;
+ bool result;
- SWIG_check_num_args("lldb::SBValue::GetProcess",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetProcess",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::IsRuntimeSupportValue",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::IsRuntimeSupportValue",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetProcess",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_IsRuntimeSupportValue",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetProcess();
- {
- lldb::SBProcess * resultptr = new lldb::SBProcess(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
- }
+ result = (bool)(arg1)->IsRuntimeSupportValue();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70362,24 +77949,21 @@ static int _wrap_SBValue_GetProcess(lua_State* L) {
}
-static int _wrap_SBValue_GetThread(lua_State* L) {
+static int _wrap_SBValue_GetNumChildren__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBThread result;
+ uint32_t result;
- SWIG_check_num_args("lldb::SBValue::GetThread",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetThread",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetNumChildren",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetNumChildren",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetThread",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetNumChildren",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetThread();
- {
- lldb::SBThread * resultptr = new lldb::SBThread(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThread,1); SWIG_arg++;
- }
+ result = (uint32_t)(arg1)->GetNumChildren();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70389,24 +77973,24 @@ static int _wrap_SBValue_GetThread(lua_State* L) {
}
-static int _wrap_SBValue_GetFrame(lua_State* L) {
+static int _wrap_SBValue_GetNumChildren__SWIG_1(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBFrame result;
+ uint32_t arg2 ;
+ uint32_t result;
- SWIG_check_num_args("lldb::SBValue::GetFrame",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetFrame",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetNumChildren",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetNumChildren",1,"lldb::SBValue *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetNumChildren",2,"uint32_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetFrame",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetNumChildren",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetFrame();
- {
- lldb::SBFrame * resultptr = new lldb::SBFrame(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFrame,1); SWIG_arg++;
- }
+ arg2 = (uint32_t)lua_tointeger(L, 2);
+ result = (uint32_t)(arg1)->GetNumChildren(arg2);
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70416,83 +78000,70 @@ static int _wrap_SBValue_GetFrame(lua_State* L) {
}
-static int _wrap_SBValue_Watch(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- bool arg2 ;
- bool arg3 ;
- bool arg4 ;
- lldb::SBError *arg5 = 0 ;
- lldb::SBWatchpoint result;
-
- SWIG_check_num_args("lldb::SBValue::Watch",5,5)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Watch",1,"lldb::SBValue *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBValue::Watch",2,"bool");
- if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBValue::Watch",3,"bool");
- if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::Watch",4,"bool");
- if(!lua_isuserdata(L,5)) SWIG_fail_arg("lldb::SBValue::Watch",5,"lldb::SBError &");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_Watch",1,SWIGTYPE_p_lldb__SBValue);
+static int _wrap_SBValue_GetNumChildren(lua_State* L) {
+ int argc;
+ int argv[3]={
+ 1,2,3
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
}
-
- arg2 = (lua_toboolean(L, 2)!=0);
- arg3 = (lua_toboolean(L, 3)!=0);
- arg4 = (lua_toboolean(L, 4)!=0);
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBValue_Watch",5,SWIGTYPE_p_lldb__SBError);
+ if (_v) {
+ return _wrap_SBValue_GetNumChildren__SWIG_0(L);
}
-
- result = (arg1)->Watch(arg2,arg3,arg4,*arg5);
+ }
+ if (argc == 2) {
+ int _v = 0;
{
- lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isnumber(L,argv[1]);
+ }
+ if (_v) {
+ return _wrap_SBValue_GetNumChildren__SWIG_1(L);
+ }
}
- return SWIG_arg;
-
- fail: SWIGUNUSED;
}
- lua_error(L);
- return 0;
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_GetNumChildren'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBValue::GetNumChildren()\n"
+ " lldb::SBValue::GetNumChildren(uint32_t)\n");
+ lua_error(L);return 0;
}
-static int _wrap_SBValue_WatchPointee(lua_State* L) {
+static int _wrap_SBValue_GetOpaqueType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- bool arg2 ;
- bool arg3 ;
- bool arg4 ;
- lldb::SBError *arg5 = 0 ;
- lldb::SBWatchpoint result;
+ void *result = 0 ;
- SWIG_check_num_args("lldb::SBValue::WatchPointee",5,5)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::WatchPointee",1,"lldb::SBValue *");
- if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBValue::WatchPointee",2,"bool");
- if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBValue::WatchPointee",3,"bool");
- if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::WatchPointee",4,"bool");
- if(!lua_isuserdata(L,5)) SWIG_fail_arg("lldb::SBValue::WatchPointee",5,"lldb::SBError &");
+ SWIG_check_num_args("lldb::SBValue::GetOpaqueType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetOpaqueType",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_WatchPointee",1,SWIGTYPE_p_lldb__SBValue);
- }
-
- arg2 = (lua_toboolean(L, 2)!=0);
- arg3 = (lua_toboolean(L, 3)!=0);
- arg4 = (lua_toboolean(L, 4)!=0);
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBValue_WatchPointee",5,SWIGTYPE_p_lldb__SBError);
+ SWIG_fail_ptr("SBValue_GetOpaqueType",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->WatchPointee(arg2,arg3,arg4,*arg5);
- {
- lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
- }
+ result = (void *)(arg1)->GetOpaqueType();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_void,0); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70502,28 +78073,24 @@ static int _wrap_SBValue_WatchPointee(lua_State* L) {
}
-static int _wrap_SBValue_GetDescription(lua_State* L) {
+static int _wrap_SBValue_GetTarget(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
+ lldb::SBTarget result;
- SWIG_check_num_args("lldb::SBValue::GetDescription",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetDescription",1,"lldb::SBValue *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBValue::GetDescription",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBValue::GetTarget",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetTarget",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetDescription",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetTarget",1,SWIGTYPE_p_lldb__SBValue);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBValue_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
+ result = (arg1)->GetTarget();
+ {
+ lldb::SBTarget * resultptr = new lldb::SBTarget(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBTarget,1); SWIG_arg++;
}
-
- result = (bool)(arg1)->GetDescription(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70533,28 +78100,24 @@ static int _wrap_SBValue_GetDescription(lua_State* L) {
}
-static int _wrap_SBValue_GetExpressionPath__SWIG_0(lua_State* L) {
+static int _wrap_SBValue_GetProcess(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBStream *arg2 = 0 ;
- bool result;
+ lldb::SBProcess result;
- SWIG_check_num_args("lldb::SBValue::GetExpressionPath",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetExpressionPath",1,"lldb::SBValue *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBValue::GetExpressionPath",2,"lldb::SBStream &");
+ SWIG_check_num_args("lldb::SBValue::GetProcess",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetProcess",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetExpressionPath",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetProcess",1,SWIGTYPE_p_lldb__SBValue);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
- SWIG_fail_ptr("SBValue_GetExpressionPath",2,SWIGTYPE_p_lldb__SBStream);
+ result = (arg1)->GetProcess();
+ {
+ lldb::SBProcess * resultptr = new lldb::SBProcess(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBProcess,1); SWIG_arg++;
}
-
- result = (bool)(arg1)->GetExpressionPath(*arg2);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70564,29 +78127,23 @@ static int _wrap_SBValue_GetExpressionPath__SWIG_0(lua_State* L) {
}
-static int _wrap_SBValue_GetPointeeData__SWIG_0(lua_State* L) {
+static int _wrap_SBValue_GetThread(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- uint32_t arg2 ;
- uint32_t arg3 ;
- lldb::SBData result;
+ lldb::SBThread result;
- SWIG_check_num_args("lldb::SBValue::GetPointeeData",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",1,"lldb::SBValue *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",2,"uint32_t");
- if(!lua_isinteger(L,3)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",3,"uint32_t");
+ SWIG_check_num_args("lldb::SBValue::GetThread",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetThread",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetPointeeData",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetThread",1,SWIGTYPE_p_lldb__SBValue);
}
- arg2 = (uint32_t)lua_tointeger(L, 2);
- arg3 = (uint32_t)lua_tointeger(L, 3);
- result = (arg1)->GetPointeeData(arg2,arg3);
+ result = (arg1)->GetThread();
{
- lldb::SBData * resultptr = new lldb::SBData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ lldb::SBThread * resultptr = new lldb::SBThread(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBThread,1); SWIG_arg++;
}
return SWIG_arg;
@@ -70597,26 +78154,23 @@ static int _wrap_SBValue_GetPointeeData__SWIG_0(lua_State* L) {
}
-static int _wrap_SBValue_GetPointeeData__SWIG_1(lua_State* L) {
+static int _wrap_SBValue_GetFrame(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- uint32_t arg2 ;
- lldb::SBData result;
+ lldb::SBFrame result;
- SWIG_check_num_args("lldb::SBValue::GetPointeeData",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",1,"lldb::SBValue *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",2,"uint32_t");
+ SWIG_check_num_args("lldb::SBValue::GetFrame",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetFrame",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetPointeeData",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetFrame",1,SWIGTYPE_p_lldb__SBValue);
}
- arg2 = (uint32_t)lua_tointeger(L, 2);
- result = (arg1)->GetPointeeData(arg2);
+ result = (arg1)->GetFrame();
{
- lldb::SBData * resultptr = new lldb::SBData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ lldb::SBFrame * resultptr = new lldb::SBFrame(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBFrame,1); SWIG_arg++;
}
return SWIG_arg;
@@ -70627,23 +78181,23 @@ static int _wrap_SBValue_GetPointeeData__SWIG_1(lua_State* L) {
}
-static int _wrap_SBValue_GetPointeeData__SWIG_2(lua_State* L) {
+static int _wrap_SBValue_Dereference(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBData result;
+ lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValue::GetPointeeData",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetPointeeData",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::Dereference",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Dereference",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetPointeeData",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_Dereference",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetPointeeData();
+ result = (arg1)->Dereference();
{
- lldb::SBData * resultptr = new lldb::SBData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
}
return SWIG_arg;
@@ -70654,98 +78208,21 @@ static int _wrap_SBValue_GetPointeeData__SWIG_2(lua_State* L) {
}
-static int _wrap_SBValue_GetPointeeData(lua_State* L) {
- int argc;
- int argv[4]={
- 1,2,3,4
- };
-
- argc = lua_gettop(L);
- if (argc == 1) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- return _wrap_SBValue_GetPointeeData__SWIG_2(L);
- }
- }
- if (argc == 2) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = lua_isnumber(L,argv[1]);
- }
- if (_v) {
- return _wrap_SBValue_GetPointeeData__SWIG_1(L);
- }
- }
- }
- if (argc == 3) {
- int _v = 0;
- {
- void *ptr;
- if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
- _v = 0;
- } else {
- _v = 1;
- }
- }
- if (_v) {
- {
- _v = lua_isnumber(L,argv[1]);
- }
- if (_v) {
- {
- _v = lua_isnumber(L,argv[2]);
- }
- if (_v) {
- return _wrap_SBValue_GetPointeeData__SWIG_0(L);
- }
- }
- }
- }
-
- SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_GetPointeeData'\n"
- " Possible C/C++ prototypes are:\n"
- " lldb::SBValue::GetPointeeData(uint32_t,uint32_t)\n"
- " lldb::SBValue::GetPointeeData(uint32_t)\n"
- " lldb::SBValue::GetPointeeData()\n");
- lua_error(L);return 0;
-}
-
-
-static int _wrap_SBValue_GetData(lua_State* L) {
+static int _wrap_SBValue_TypeIsPointerType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBData result;
+ bool result;
- SWIG_check_num_args("lldb::SBValue::GetData",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetData",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::TypeIsPointerType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::TypeIsPointerType",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetData",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_TypeIsPointerType",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->GetData();
- {
- lldb::SBData * resultptr = new lldb::SBData(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBData,1); SWIG_arg++;
- }
+ result = (bool)(arg1)->TypeIsPointerType();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70755,35 +78232,24 @@ static int _wrap_SBValue_GetData(lua_State* L) {
}
-static int _wrap_SBValue_SetData(lua_State* L) {
+static int _wrap_SBValue_GetType(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBData *arg2 = 0 ;
- lldb::SBError *arg3 = 0 ;
- bool result;
+ lldb::SBType result;
- SWIG_check_num_args("lldb::SBValue::SetData",3,3)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::SetData",1,"lldb::SBValue *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBValue::SetData",2,"lldb::SBData &");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("lldb::SBValue::SetData",3,"lldb::SBError &");
+ SWIG_check_num_args("lldb::SBValue::GetType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetType",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_SetData",1,SWIGTYPE_p_lldb__SBValue);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBData,0))){
- SWIG_fail_ptr("SBValue_SetData",2,SWIGTYPE_p_lldb__SBData);
+ SWIG_fail_ptr("SBValue_GetType",1,SWIGTYPE_p_lldb__SBValue);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&arg3,SWIGTYPE_p_lldb__SBError,0))){
- SWIG_fail_ptr("SBValue_SetData",3,SWIGTYPE_p_lldb__SBError);
+ result = (arg1)->GetType();
+ {
+ lldb::SBType * resultptr = new lldb::SBType(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
}
-
- result = (bool)(arg1)->SetData(*arg2,*arg3);
- lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70793,23 +78259,20 @@ static int _wrap_SBValue_SetData(lua_State* L) {
}
-static int _wrap_SBValue_Clone(lua_State* L) {
+static int _wrap_SBValue_Persist(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- char *arg2 = (char *) 0 ;
lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValue::Clone",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Clone",1,"lldb::SBValue *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBValue::Clone",2,"char const *");
+ SWIG_check_num_args("lldb::SBValue::Persist",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Persist",1,"lldb::SBValue *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_Clone",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_Persist",1,SWIGTYPE_p_lldb__SBValue);
}
- arg2 = (char *)lua_tostring(L, 2);
- result = (arg1)->Clone((char const *)arg2);
+ result = (arg1)->Persist();
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -70823,48 +78286,28 @@ static int _wrap_SBValue_Clone(lua_State* L) {
}
-static int _wrap_SBValue_GetLoadAddress(lua_State* L) {
+static int _wrap_SBValue_GetDescription(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::addr_t result;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
- SWIG_check_num_args("lldb::SBValue::GetLoadAddress",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetLoadAddress",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetDescription",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetDescription",1,"lldb::SBValue *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBValue::GetDescription",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetLoadAddress",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetDescription",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (lldb::addr_t)(arg1)->GetLoadAddress();
- lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
- return SWIG_arg;
- fail: SWIGUNUSED;
- }
- lua_error(L);
- return 0;
-}
-
-
-static int _wrap_SBValue_GetAddress(lua_State* L) {
- {
- int SWIG_arg = 0;
- lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBAddress result;
-
- SWIG_check_num_args("lldb::SBValue::GetAddress",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetAddress",1,"lldb::SBValue *");
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_GetAddress",1,SWIGTYPE_p_lldb__SBValue);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBValue_GetDescription",2,SWIGTYPE_p_lldb__SBStream);
}
- result = (arg1)->GetAddress();
- {
- lldb::SBAddress * resultptr = new lldb::SBAddress(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBAddress,1); SWIG_arg++;
- }
+ result = (bool)(arg1)->GetDescription(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -70874,24 +78317,28 @@ static int _wrap_SBValue_GetAddress(lua_State* L) {
}
-static int _wrap_SBValue_Persist(lua_State* L) {
+static int _wrap_SBValue_GetExpressionPath__SWIG_0(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
- lldb::SBValue result;
+ lldb::SBStream *arg2 = 0 ;
+ bool result;
- SWIG_check_num_args("lldb::SBValue::Persist",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Persist",1,"lldb::SBValue *");
+ SWIG_check_num_args("lldb::SBValue::GetExpressionPath",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetExpressionPath",1,"lldb::SBValue *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBValue::GetExpressionPath",2,"lldb::SBStream &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
- SWIG_fail_ptr("SBValue_Persist",1,SWIGTYPE_p_lldb__SBValue);
+ SWIG_fail_ptr("SBValue_GetExpressionPath",1,SWIGTYPE_p_lldb__SBValue);
}
- result = (arg1)->Persist();
- {
- lldb::SBValue * resultptr = new lldb::SBValue(result);
- SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBStream,0))){
+ SWIG_fail_ptr("SBValue_GetExpressionPath",2,SWIGTYPE_p_lldb__SBStream);
}
+
+ result = (bool)(arg1)->GetExpressionPath(*arg2);
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
fail: SWIGUNUSED;
@@ -71210,6 +78657,239 @@ static int _wrap_SBValue_EvaluateExpression(lua_State* L) {
}
+static int _wrap_SBValue_Watch__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ bool arg2 ;
+ bool arg3 ;
+ bool arg4 ;
+ lldb::SBError *arg5 = 0 ;
+ lldb::SBWatchpoint result;
+
+ SWIG_check_num_args("lldb::SBValue::Watch",5,5)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Watch",1,"lldb::SBValue *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBValue::Watch",2,"bool");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBValue::Watch",3,"bool");
+ if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::Watch",4,"bool");
+ if(!lua_isuserdata(L,5)) SWIG_fail_arg("lldb::SBValue::Watch",5,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_Watch",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ arg3 = (lua_toboolean(L, 3)!=0);
+ arg4 = (lua_toboolean(L, 4)!=0);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBValue_Watch",5,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->Watch(arg2,arg3,arg4,*arg5);
+ {
+ lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBValue_Watch__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ bool arg2 ;
+ bool arg3 ;
+ bool arg4 ;
+ lldb::SBWatchpoint result;
+
+ SWIG_check_num_args("lldb::SBValue::Watch",4,4)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::Watch",1,"lldb::SBValue *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBValue::Watch",2,"bool");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBValue::Watch",3,"bool");
+ if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::Watch",4,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_Watch",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ arg3 = (lua_toboolean(L, 3)!=0);
+ arg4 = (lua_toboolean(L, 4)!=0);
+ result = (arg1)->Watch(arg2,arg3,arg4);
+ {
+ lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBValue_Watch(lua_State* L) {
+ int argc;
+ int argv[6]={
+ 1,2,3,4,5,6
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 4) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[3]);
+ }
+ if (_v) {
+ return _wrap_SBValue_Watch__SWIG_1(L);
+ }
+ }
+ }
+ }
+ }
+ if (argc == 5) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBValue, 0)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[1]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[2]);
+ }
+ if (_v) {
+ {
+ _v = lua_isboolean(L,argv[3]);
+ }
+ if (_v) {
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[4])==0 || SWIG_ConvertPtr(L,argv[4], (void **) &ptr, SWIGTYPE_p_lldb__SBError, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_SBValue_Watch__SWIG_0(L);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'SBValue_Watch'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBValue::Watch(bool,bool,bool,lldb::SBError &)\n"
+ " lldb::SBValue::Watch(bool,bool,bool)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBValue_WatchPointee(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ bool arg2 ;
+ bool arg3 ;
+ bool arg4 ;
+ lldb::SBError *arg5 = 0 ;
+ lldb::SBWatchpoint result;
+
+ SWIG_check_num_args("lldb::SBValue::WatchPointee",5,5)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::WatchPointee",1,"lldb::SBValue *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBValue::WatchPointee",2,"bool");
+ if(!lua_isboolean(L,3)) SWIG_fail_arg("lldb::SBValue::WatchPointee",3,"bool");
+ if(!lua_isboolean(L,4)) SWIG_fail_arg("lldb::SBValue::WatchPointee",4,"bool");
+ if(!lua_isuserdata(L,5)) SWIG_fail_arg("lldb::SBValue::WatchPointee",5,"lldb::SBError &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_WatchPointee",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ arg3 = (lua_toboolean(L, 3)!=0);
+ arg4 = (lua_toboolean(L, 4)!=0);
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,5,(void**)&arg5,SWIGTYPE_p_lldb__SBError,0))){
+ SWIG_fail_ptr("SBValue_WatchPointee",5,SWIGTYPE_p_lldb__SBError);
+ }
+
+ result = (arg1)->WatchPointee(arg2,arg3,arg4,*arg5);
+ {
+ lldb::SBWatchpoint * resultptr = new lldb::SBWatchpoint(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBWatchpoint,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBValue_GetVTable(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBValue *arg1 = (lldb::SBValue *) 0 ;
+ lldb::SBValue result;
+
+ SWIG_check_num_args("lldb::SBValue::GetVTable",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValue::GetVTable",1,"lldb::SBValue *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValue,0))){
+ SWIG_fail_ptr("SBValue_GetVTable",1,SWIGTYPE_p_lldb__SBValue);
+ }
+
+ result = (arg1)->GetVTable();
+ {
+ lldb::SBValue * resultptr = new lldb::SBValue(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBValue___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -71264,6 +78944,7 @@ static swig_lua_method swig_SBValue_methods[]= {
{ "GetValue", _wrap_SBValue_GetValue},
{ "GetValueAsSigned", _wrap_SBValue_GetValueAsSigned},
{ "GetValueAsUnsigned", _wrap_SBValue_GetValueAsUnsigned},
+ { "GetValueAsAddress", _wrap_SBValue_GetValueAsAddress},
{ "GetValueType", _wrap_SBValue_GetValueType},
{ "GetValueDidChange", _wrap_SBValue_GetValueDidChange},
{ "GetSummary", _wrap_SBValue_GetSummary},
@@ -71271,6 +78952,7 @@ static swig_lua_method swig_SBValue_methods[]= {
{ "GetDynamicValue", _wrap_SBValue_GetDynamicValue},
{ "GetStaticValue", _wrap_SBValue_GetStaticValue},
{ "GetNonSyntheticValue", _wrap_SBValue_GetNonSyntheticValue},
+ { "GetSyntheticValue", _wrap_SBValue_GetSyntheticValue},
{ "GetPreferDynamicValue", _wrap_SBValue_GetPreferDynamicValue},
{ "SetPreferDynamicValue", _wrap_SBValue_SetPreferDynamicValue},
{ "GetPreferSyntheticValue", _wrap_SBValue_GetPreferSyntheticValue},
@@ -71285,40 +78967,41 @@ static swig_lua_method swig_SBValue_methods[]= {
{ "GetTypeSummary", _wrap_SBValue_GetTypeSummary},
{ "GetTypeFilter", _wrap_SBValue_GetTypeFilter},
{ "GetTypeSynthetic", _wrap_SBValue_GetTypeSynthetic},
- { "GetChildAtIndex", _wrap_SBValue_GetChildAtIndex},
{ "CreateChildAtOffset", _wrap_SBValue_CreateChildAtOffset},
{ "Cast", _wrap_SBValue_Cast},
{ "CreateValueFromExpression", _wrap_SBValue_CreateValueFromExpression},
{ "CreateValueFromAddress", _wrap_SBValue_CreateValueFromAddress},
{ "CreateValueFromData", _wrap_SBValue_CreateValueFromData},
- { "GetType", _wrap_SBValue_GetType},
+ { "GetChildAtIndex", _wrap_SBValue_GetChildAtIndex},
{ "GetIndexOfChildWithName", _wrap_SBValue_GetIndexOfChildWithName},
{ "GetChildMemberWithName", _wrap_SBValue_GetChildMemberWithName},
{ "GetValueForExpressionPath", _wrap_SBValue_GetValueForExpressionPath},
+ { "AddressOf", _wrap_SBValue_AddressOf},
+ { "GetLoadAddress", _wrap_SBValue_GetLoadAddress},
+ { "GetAddress", _wrap_SBValue_GetAddress},
+ { "GetPointeeData", _wrap_SBValue_GetPointeeData},
+ { "GetData", _wrap_SBValue_GetData},
+ { "SetData", _wrap_SBValue_SetData},
+ { "Clone", _wrap_SBValue_Clone},
{ "GetDeclaration", _wrap_SBValue_GetDeclaration},
{ "MightHaveChildren", _wrap_SBValue_MightHaveChildren},
{ "IsRuntimeSupportValue", _wrap_SBValue_IsRuntimeSupportValue},
{ "GetNumChildren", _wrap_SBValue_GetNumChildren},
{ "GetOpaqueType", _wrap_SBValue_GetOpaqueType},
- { "Dereference", _wrap_SBValue_Dereference},
- { "AddressOf", _wrap_SBValue_AddressOf},
- { "TypeIsPointerType", _wrap_SBValue_TypeIsPointerType},
{ "GetTarget", _wrap_SBValue_GetTarget},
{ "GetProcess", _wrap_SBValue_GetProcess},
{ "GetThread", _wrap_SBValue_GetThread},
{ "GetFrame", _wrap_SBValue_GetFrame},
- { "Watch", _wrap_SBValue_Watch},
- { "WatchPointee", _wrap_SBValue_WatchPointee},
- { "GetDescription", _wrap_SBValue_GetDescription},
- { "GetPointeeData", _wrap_SBValue_GetPointeeData},
- { "GetData", _wrap_SBValue_GetData},
- { "SetData", _wrap_SBValue_SetData},
- { "Clone", _wrap_SBValue_Clone},
- { "GetLoadAddress", _wrap_SBValue_GetLoadAddress},
- { "GetAddress", _wrap_SBValue_GetAddress},
+ { "Dereference", _wrap_SBValue_Dereference},
+ { "TypeIsPointerType", _wrap_SBValue_TypeIsPointerType},
+ { "GetType", _wrap_SBValue_GetType},
{ "Persist", _wrap_SBValue_Persist},
+ { "GetDescription", _wrap_SBValue_GetDescription},
{ "GetExpressionPath", _wrap_SBValue_GetExpressionPath},
{ "EvaluateExpression", _wrap_SBValue_EvaluateExpression},
+ { "Watch", _wrap_SBValue_Watch},
+ { "WatchPointee", _wrap_SBValue_WatchPointee},
+ { "GetVTable", _wrap_SBValue_GetVTable},
{ "__tostring", _wrap_SBValue___tostring},
{0,0}
};
@@ -71651,23 +79334,23 @@ static int _wrap_SBValueList_GetValueAtIndex(lua_State* L) {
}
-static int _wrap_SBValueList_FindValueObjectByUID(lua_State* L) {
+static int _wrap_SBValueList_GetFirstValueByName(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValueList *arg1 = (lldb::SBValueList *) 0 ;
- lldb::user_id_t arg2 ;
+ char *arg2 = (char *) 0 ;
lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValueList::FindValueObjectByUID",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValueList::FindValueObjectByUID",1,"lldb::SBValueList *");
- if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValueList::FindValueObjectByUID",2,"lldb::user_id_t");
+ SWIG_check_num_args("lldb::SBValueList::GetFirstValueByName",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValueList::GetFirstValueByName",1,"lldb::SBValueList const *");
+ if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBValueList::GetFirstValueByName",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValueList,0))){
- SWIG_fail_ptr("SBValueList_FindValueObjectByUID",1,SWIGTYPE_p_lldb__SBValueList);
+ SWIG_fail_ptr("SBValueList_GetFirstValueByName",1,SWIGTYPE_p_lldb__SBValueList);
}
- arg2 = (lldb::user_id_t)lua_tointeger(L, 2);
- result = (arg1)->FindValueObjectByUID(arg2);
+ arg2 = (char *)lua_tostring(L, 2);
+ result = ((lldb::SBValueList const *)arg1)->GetFirstValueByName((char const *)arg2);
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -71681,23 +79364,23 @@ static int _wrap_SBValueList_FindValueObjectByUID(lua_State* L) {
}
-static int _wrap_SBValueList_GetFirstValueByName(lua_State* L) {
+static int _wrap_SBValueList_FindValueObjectByUID(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBValueList *arg1 = (lldb::SBValueList *) 0 ;
- char *arg2 = (char *) 0 ;
+ lldb::user_id_t arg2 ;
lldb::SBValue result;
- SWIG_check_num_args("lldb::SBValueList::GetFirstValueByName",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValueList::GetFirstValueByName",1,"lldb::SBValueList const *");
- if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("lldb::SBValueList::GetFirstValueByName",2,"char const *");
+ SWIG_check_num_args("lldb::SBValueList::FindValueObjectByUID",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBValueList::FindValueObjectByUID",1,"lldb::SBValueList *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBValueList::FindValueObjectByUID",2,"lldb::user_id_t");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBValueList,0))){
- SWIG_fail_ptr("SBValueList_GetFirstValueByName",1,SWIGTYPE_p_lldb__SBValueList);
+ SWIG_fail_ptr("SBValueList_FindValueObjectByUID",1,SWIGTYPE_p_lldb__SBValueList);
}
- arg2 = (char *)lua_tostring(L, 2);
- result = ((lldb::SBValueList const *)arg1)->GetFirstValueByName((char const *)arg2);
+ arg2 = (lldb::user_id_t)lua_tointeger(L, 2);
+ result = (arg1)->FindValueObjectByUID(arg2);
{
lldb::SBValue * resultptr = new lldb::SBValue(result);
SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBValue,1); SWIG_arg++;
@@ -71783,8 +79466,8 @@ static swig_lua_method swig_SBValueList_methods[]= {
{ "Append", _wrap_SBValueList_Append},
{ "GetSize", _wrap_SBValueList_GetSize},
{ "GetValueAtIndex", _wrap_SBValueList_GetValueAtIndex},
- { "FindValueObjectByUID", _wrap_SBValueList_FindValueObjectByUID},
{ "GetFirstValueByName", _wrap_SBValueList_GetFirstValueByName},
+ { "FindValueObjectByUID", _wrap_SBValueList_FindValueObjectByUID},
{ "GetError", _wrap_SBValueList_GetError},
{ "__tostring", _wrap_SBValueList___tostring},
{0,0}
@@ -72410,20 +80093,27 @@ static int _wrap_new_SBWatchpoint(lua_State* L) {
}
-static int _wrap_SBWatchpoint_IsValid(lua_State* L) {
+static int _wrap_SBWatchpoint___eq(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+ lldb::SBWatchpoint *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBWatchpoint::IsValid",1,1)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::IsValid",1,"lldb::SBWatchpoint *");
+ SWIG_check_num_args("lldb::SBWatchpoint::operator ==",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::operator ==",1,"lldb::SBWatchpoint const *");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBWatchpoint::operator ==",2,"lldb::SBWatchpoint const &");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
- SWIG_fail_ptr("SBWatchpoint_IsValid",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ SWIG_fail_ptr("SBWatchpoint___eq",1,SWIGTYPE_p_lldb__SBWatchpoint);
}
- result = (bool)(arg1)->IsValid();
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint___eq",2,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ result = (bool)((lldb::SBWatchpoint const *)arg1)->operator ==((lldb::SBWatchpoint const &)*arg2);
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -72434,27 +80124,20 @@ static int _wrap_SBWatchpoint_IsValid(lua_State* L) {
}
-static int _wrap_SBWatchpoint___eq(lua_State* L) {
+static int _wrap_SBWatchpoint_IsValid(lua_State* L) {
{
int SWIG_arg = 0;
lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
- lldb::SBWatchpoint *arg2 = 0 ;
bool result;
- SWIG_check_num_args("lldb::SBWatchpoint::operator ==",2,2)
- if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::operator ==",1,"lldb::SBWatchpoint const *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("lldb::SBWatchpoint::operator ==",2,"lldb::SBWatchpoint const &");
+ SWIG_check_num_args("lldb::SBWatchpoint::IsValid",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::IsValid",1,"lldb::SBWatchpoint const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
- SWIG_fail_ptr("SBWatchpoint___eq",1,SWIGTYPE_p_lldb__SBWatchpoint);
- }
-
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&arg2,SWIGTYPE_p_lldb__SBWatchpoint,0))){
- SWIG_fail_ptr("SBWatchpoint___eq",2,SWIGTYPE_p_lldb__SBWatchpoint);
+ SWIG_fail_ptr("SBWatchpoint_IsValid",1,SWIGTYPE_p_lldb__SBWatchpoint);
}
- result = (bool)((lldb::SBWatchpoint const *)arg1)->operator ==((lldb::SBWatchpoint const &)*arg2);
+ result = (bool)((lldb::SBWatchpoint const *)arg1)->IsValid();
lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
return SWIG_arg;
@@ -72796,6 +80479,29 @@ static int _wrap_SBWatchpoint_GetDescription(lua_State* L) {
}
+static int _wrap_SBWatchpoint_Clear(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+
+ SWIG_check_num_args("lldb::SBWatchpoint::Clear",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::Clear",1,"lldb::SBWatchpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint_Clear",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ (arg1)->Clear();
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBWatchpoint_EventIsWatchpointEvent(lua_State* L) {
{
int SWIG_arg = 0;
@@ -72871,6 +80577,129 @@ static int _wrap_SBWatchpoint_GetWatchpointFromEvent(lua_State* L) {
}
+static int _wrap_SBWatchpoint_GetType(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+ lldb::SBType result;
+
+ SWIG_check_num_args("lldb::SBWatchpoint::GetType",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::GetType",1,"lldb::SBWatchpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint_GetType",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ result = (arg1)->GetType();
+ {
+ lldb::SBType * resultptr = new lldb::SBType(result);
+ SWIG_NewPointerObj(L,(void *) resultptr,SWIGTYPE_p_lldb__SBType,1); SWIG_arg++;
+ }
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpoint_GetWatchValueKind(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+ lldb::WatchpointValueKind result;
+
+ SWIG_check_num_args("lldb::SBWatchpoint::GetWatchValueKind",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::GetWatchValueKind",1,"lldb::SBWatchpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint_GetWatchValueKind",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ result = (lldb::WatchpointValueKind)(arg1)->GetWatchValueKind();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpoint_GetWatchSpec(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+ char *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBWatchpoint::GetWatchSpec",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::GetWatchSpec",1,"lldb::SBWatchpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint_GetWatchSpec",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ result = (char *)(arg1)->GetWatchSpec();
+ lua_pushstring(L,(const char *)result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpoint_IsWatchingReads(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBWatchpoint::IsWatchingReads",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::IsWatchingReads",1,"lldb::SBWatchpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint_IsWatchingReads",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ result = (bool)(arg1)->IsWatchingReads();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpoint_IsWatchingWrites(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpoint *arg1 = (lldb::SBWatchpoint *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBWatchpoint::IsWatchingWrites",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpoint::IsWatchingWrites",1,"lldb::SBWatchpoint *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpoint,0))){
+ SWIG_fail_ptr("SBWatchpoint_IsWatchingWrites",1,SWIGTYPE_p_lldb__SBWatchpoint);
+ }
+
+ result = (bool)(arg1)->IsWatchingWrites();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
static int _wrap_SBWatchpoint___tostring(lua_State* L) {
{
int SWIG_arg = 0;
@@ -72911,8 +80740,8 @@ static swig_lua_attribute swig_SBWatchpoint_attributes[] = {
{0,0,0}
};
static swig_lua_method swig_SBWatchpoint_methods[]= {
- { "IsValid", _wrap_SBWatchpoint_IsValid},
{ "__eq", _wrap_SBWatchpoint___eq},
+ { "IsValid", _wrap_SBWatchpoint_IsValid},
{ "GetError", _wrap_SBWatchpoint_GetError},
{ "GetID", _wrap_SBWatchpoint_GetID},
{ "GetHardwareIndex", _wrap_SBWatchpoint_GetHardwareIndex},
@@ -72926,6 +80755,12 @@ static swig_lua_method swig_SBWatchpoint_methods[]= {
{ "GetCondition", _wrap_SBWatchpoint_GetCondition},
{ "SetCondition", _wrap_SBWatchpoint_SetCondition},
{ "GetDescription", _wrap_SBWatchpoint_GetDescription},
+ { "Clear", _wrap_SBWatchpoint_Clear},
+ { "GetType", _wrap_SBWatchpoint_GetType},
+ { "GetWatchValueKind", _wrap_SBWatchpoint_GetWatchValueKind},
+ { "GetWatchSpec", _wrap_SBWatchpoint_GetWatchSpec},
+ { "IsWatchingReads", _wrap_SBWatchpoint_IsWatchingReads},
+ { "IsWatchingWrites", _wrap_SBWatchpoint_IsWatchingWrites},
{ "__tostring", _wrap_SBWatchpoint___tostring},
{0,0}
};
@@ -72963,782 +80798,1137 @@ static swig_lua_class *swig_SBWatchpoint_bases[] = {0};
static const char *swig_SBWatchpoint_base_names[] = {0};
static swig_lua_class _wrap_class_SBWatchpoint = { "SBWatchpoint", "SBWatchpoint", &SWIGTYPE_p_lldb__SBWatchpoint,_proxy__wrap_new_SBWatchpoint, swig_delete_SBWatchpoint, swig_SBWatchpoint_methods, swig_SBWatchpoint_attributes, &swig_SBWatchpoint_Sf_SwigStatic, swig_SBWatchpoint_meta, swig_SBWatchpoint_bases, swig_SBWatchpoint_base_names };
+static int _wrap_new_SBWatchpointOptions__SWIG_0(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpointOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBWatchpointOptions::SBWatchpointOptions",0,0)
+ result = (lldb::SBWatchpointOptions *)new lldb::SBWatchpointOptions();
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBWatchpointOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBWatchpointOptions__SWIG_1(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpointOptions *arg1 = 0 ;
+ lldb::SBWatchpointOptions *result = 0 ;
+
+ SWIG_check_num_args("lldb::SBWatchpointOptions::SBWatchpointOptions",1,1)
+ if(!lua_isuserdata(L,1)) SWIG_fail_arg("lldb::SBWatchpointOptions::SBWatchpointOptions",1,"lldb::SBWatchpointOptions const &");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpointOptions,0))){
+ SWIG_fail_ptr("new_SBWatchpointOptions",1,SWIGTYPE_p_lldb__SBWatchpointOptions);
+ }
+
+ result = (lldb::SBWatchpointOptions *)new lldb::SBWatchpointOptions((lldb::SBWatchpointOptions const &)*arg1);
+ SWIG_NewPointerObj(L,result,SWIGTYPE_p_lldb__SBWatchpointOptions,1); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_new_SBWatchpointOptions(lua_State* L) {
+ int argc;
+ int argv[2]={
+ 1,2
+ };
+
+ argc = lua_gettop(L);
+ if (argc == 0) {
+ return _wrap_new_SBWatchpointOptions__SWIG_0(L);
+ }
+ if (argc == 1) {
+ int _v = 0;
+ {
+ void *ptr;
+ if (lua_isuserdata(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_lldb__SBWatchpointOptions, SWIG_POINTER_NO_NULL)) {
+ _v = 0;
+ } else {
+ _v = 1;
+ }
+ }
+ if (_v) {
+ return _wrap_new_SBWatchpointOptions__SWIG_1(L);
+ }
+ }
+
+ SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_SBWatchpointOptions'\n"
+ " Possible C/C++ prototypes are:\n"
+ " lldb::SBWatchpointOptions::SBWatchpointOptions()\n"
+ " lldb::SBWatchpointOptions::SBWatchpointOptions(lldb::SBWatchpointOptions const &)\n");
+ lua_error(L);return 0;
+}
+
+
+static int _wrap_SBWatchpointOptions_SetWatchpointTypeRead(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpointOptions *arg1 = (lldb::SBWatchpointOptions *) 0 ;
+ bool arg2 ;
+
+ SWIG_check_num_args("lldb::SBWatchpointOptions::SetWatchpointTypeRead",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpointOptions::SetWatchpointTypeRead",1,"lldb::SBWatchpointOptions *");
+ if(!lua_isboolean(L,2)) SWIG_fail_arg("lldb::SBWatchpointOptions::SetWatchpointTypeRead",2,"bool");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpointOptions,0))){
+ SWIG_fail_ptr("SBWatchpointOptions_SetWatchpointTypeRead",1,SWIGTYPE_p_lldb__SBWatchpointOptions);
+ }
+
+ arg2 = (lua_toboolean(L, 2)!=0);
+ (arg1)->SetWatchpointTypeRead(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpointOptions_GetWatchpointTypeRead(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpointOptions *arg1 = (lldb::SBWatchpointOptions *) 0 ;
+ bool result;
+
+ SWIG_check_num_args("lldb::SBWatchpointOptions::GetWatchpointTypeRead",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpointOptions::GetWatchpointTypeRead",1,"lldb::SBWatchpointOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpointOptions,0))){
+ SWIG_fail_ptr("SBWatchpointOptions_GetWatchpointTypeRead",1,SWIGTYPE_p_lldb__SBWatchpointOptions);
+ }
+
+ result = (bool)((lldb::SBWatchpointOptions const *)arg1)->GetWatchpointTypeRead();
+ lua_pushboolean(L,(int)(result!=0)); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpointOptions_SetWatchpointTypeWrite(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpointOptions *arg1 = (lldb::SBWatchpointOptions *) 0 ;
+ lldb::WatchpointWriteType arg2 ;
+
+ SWIG_check_num_args("lldb::SBWatchpointOptions::SetWatchpointTypeWrite",2,2)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpointOptions::SetWatchpointTypeWrite",1,"lldb::SBWatchpointOptions *");
+ if(!lua_isinteger(L,2)) SWIG_fail_arg("lldb::SBWatchpointOptions::SetWatchpointTypeWrite",2,"lldb::WatchpointWriteType");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpointOptions,0))){
+ SWIG_fail_ptr("SBWatchpointOptions_SetWatchpointTypeWrite",1,SWIGTYPE_p_lldb__SBWatchpointOptions);
+ }
+
+ arg2 = (lldb::WatchpointWriteType)lua_tointeger(L, 2);
+ (arg1)->SetWatchpointTypeWrite(arg2);
+
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static int _wrap_SBWatchpointOptions_GetWatchpointTypeWrite(lua_State* L) {
+ {
+ int SWIG_arg = 0;
+ lldb::SBWatchpointOptions *arg1 = (lldb::SBWatchpointOptions *) 0 ;
+ lldb::WatchpointWriteType result;
+
+ SWIG_check_num_args("lldb::SBWatchpointOptions::GetWatchpointTypeWrite",1,1)
+ if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("lldb::SBWatchpointOptions::GetWatchpointTypeWrite",1,"lldb::SBWatchpointOptions const *");
+
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_lldb__SBWatchpointOptions,0))){
+ SWIG_fail_ptr("SBWatchpointOptions_GetWatchpointTypeWrite",1,SWIGTYPE_p_lldb__SBWatchpointOptions);
+ }
+
+ result = (lldb::WatchpointWriteType)((lldb::SBWatchpointOptions const *)arg1)->GetWatchpointTypeWrite();
+ lua_pushinteger(L, (lua_Integer) result); SWIG_arg++;
+ return SWIG_arg;
+
+ fail: SWIGUNUSED;
+ }
+ lua_error(L);
+ return 0;
+}
+
+
+static void swig_delete_SBWatchpointOptions(void *obj) {
+lldb::SBWatchpointOptions *arg1 = (lldb::SBWatchpointOptions *) obj;
+delete arg1;
+}
+static int _proxy__wrap_new_SBWatchpointOptions(lua_State *L) {
+ assert(lua_istable(L,1));
+ lua_pushcfunction(L,_wrap_new_SBWatchpointOptions);
+ assert(!lua_isnil(L,-1));
+ lua_replace(L,1); /* replace our table with real constructor */
+ lua_call(L,lua_gettop(L)-1,1);
+ return 1;
+}
+static swig_lua_attribute swig_SBWatchpointOptions_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_method swig_SBWatchpointOptions_methods[]= {
+ { "SetWatchpointTypeRead", _wrap_SBWatchpointOptions_SetWatchpointTypeRead},
+ { "GetWatchpointTypeRead", _wrap_SBWatchpointOptions_GetWatchpointTypeRead},
+ { "SetWatchpointTypeWrite", _wrap_SBWatchpointOptions_SetWatchpointTypeWrite},
+ { "GetWatchpointTypeWrite", _wrap_SBWatchpointOptions_GetWatchpointTypeWrite},
+ {0,0}
+};
+static swig_lua_method swig_SBWatchpointOptions_meta[] = {
+ {0,0}
+};
+
+static swig_lua_attribute swig_SBWatchpointOptions_Sf_SwigStatic_attributes[] = {
+ {0,0,0}
+};
+static swig_lua_const_info swig_SBWatchpointOptions_Sf_SwigStatic_constants[]= {
+ {0,0,0,0,0,0}
+};
+static swig_lua_method swig_SBWatchpointOptions_Sf_SwigStatic_methods[]= {
+ {0,0}
+};
+static swig_lua_class* swig_SBWatchpointOptions_Sf_SwigStatic_classes[]= {
+ 0
+};
+
+static swig_lua_namespace swig_SBWatchpointOptions_Sf_SwigStatic = {
+ "SBWatchpointOptions",
+ swig_SBWatchpointOptions_Sf_SwigStatic_methods,
+ swig_SBWatchpointOptions_Sf_SwigStatic_attributes,
+ swig_SBWatchpointOptions_Sf_SwigStatic_constants,
+ swig_SBWatchpointOptions_Sf_SwigStatic_classes,
+ 0
+};
+static swig_lua_class *swig_SBWatchpointOptions_bases[] = {0};
+static const char *swig_SBWatchpointOptions_base_names[] = {0};
+static swig_lua_class _wrap_class_SBWatchpointOptions = { "SBWatchpointOptions", "SBWatchpointOptions", &SWIGTYPE_p_lldb__SBWatchpointOptions,_proxy__wrap_new_SBWatchpointOptions, swig_delete_SBWatchpointOptions, swig_SBWatchpointOptions_methods, swig_SBWatchpointOptions_attributes, &swig_SBWatchpointOptions_Sf_SwigStatic, swig_SBWatchpointOptions_meta, swig_SBWatchpointOptions_bases, swig_SBWatchpointOptions_base_names };
+
static swig_lua_attribute swig_SwigModule_attributes[] = {
{0,0,0}
};
static swig_lua_const_info swig_SwigModule_constants[]= {
- {SWIG_LUA_CONSTTAB_INT("INT32_MAX", 2147483647)},
- {SWIG_LUA_CONSTTAB_INT("UINT32_MAX", 4294967295U)},
+ {SWIG_LUA_CONSTTAB_INT("INT32_MAX", (2147483647))},
+ {SWIG_LUA_CONSTTAB_INT("UINT32_MAX", (4294967295U))},
{SWIG_LUA_CONSTTAB_STRING("UINT64_MAX", "18446744073709551615ULL")},
- {SWIG_LUA_CONSTTAB_INT("LLDB_GENERIC_ERROR", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_BREAK_ID", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_DEFAULT_BREAK_SIZE", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_WATCH_ID", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_WATCH_TYPE_READ", (1u << 0))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_WATCH_TYPE_WRITE", (1u << 1))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_PC", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_SP", 1)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_FP", 2)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_RA", 3)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_FLAGS", 4)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG1", 5)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG2", 6)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG3", 7)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG4", 8)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG5", 9)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG6", 10)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG7", 11)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG8", 12)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_STOP_ID", 0)},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_GENERIC_ERROR", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_BREAK_ID", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_DEFAULT_BREAK_SIZE", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_WATCH_ID", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_WATCH_TYPE_READ", ((1u << 0)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_WATCH_TYPE_WRITE", ((1u << 1)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_WATCH_TYPE_MODIFY", ((1u << 2)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_SITE_ID", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_PC", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_SP", (1))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_FP", (2))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_RA", (3))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_FLAGS", (4))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG1", (5))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG2", (6))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG3", (7))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG4", (8))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG5", (9))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG6", (10))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG7", (11))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_ARG8", (12))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_REGNUM_GENERIC_TP", (13))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_STOP_ID", (0))},
{SWIG_LUA_CONSTTAB_STRING("LLDB_INVALID_ADDRESS", "18446744073709551615ULL")},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_INDEX32", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_IVAR_OFFSET", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_IMAGE_TOKEN", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_MODULE_VERSION", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_REGNUM", 4294967295U)},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_INDEX32", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_IVAR_OFFSET", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_IMAGE_TOKEN", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_MODULE_VERSION", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_REGNUM", (4294967295U))},
{SWIG_LUA_CONSTTAB_STRING("LLDB_INVALID_UID", "18446744073709551615ULL")},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_PROCESS_ID", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_THREAD_ID", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_FRAME_ID", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_SIGNAL_NUMBER", 2147483647)},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_PROCESS_ID", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_THREAD_ID", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_FRAME_ID", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_SIGNAL_NUMBER", (2147483647))},
{SWIG_LUA_CONSTTAB_STRING("LLDB_INVALID_OFFSET", "18446744073709551615ULL")},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_LINE_NUMBER", 4294967295U)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_COLUMN_NUMBER", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_QUEUE_ID", 0)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_CPU_ID", 4294967295U)},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_LINE_NUMBER", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_COLUMN_NUMBER", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_QUEUE_ID", (0))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_CPU_ID", (4294967295U))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_WATCHPOINT_RESOURCE_ID", (4294967295U))},
{SWIG_LUA_CONSTTAB_STRING("LLDB_ARCH_DEFAULT", "systemArch")},
{SWIG_LUA_CONSTTAB_STRING("LLDB_ARCH_DEFAULT_32BIT", "systemArch32")},
{SWIG_LUA_CONSTTAB_STRING("LLDB_ARCH_DEFAULT_64BIT", "systemArch64")},
- {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_CPUTYPE", (0xFFFFFFFEu))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_MAX_NUM_OPTION_SETS", 32)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_ALL", 0xFFFFFFFFU)},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_1", (1U << 0))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_2", (1U << 1))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_3", (1U << 2))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_4", (1U << 3))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_5", (1U << 4))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_6", (1U << 5))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_7", (1U << 6))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_8", (1U << 7))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_9", (1U << 8))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_10", (1U << 9))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_11", (1U << 10))},
- {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_12", (1U << 11))},
- {SWIG_LUA_CONSTTAB_INT("eStateInvalid", lldb::eStateInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eStateUnloaded", lldb::eStateUnloaded)},
- {SWIG_LUA_CONSTTAB_INT("eStateConnected", lldb::eStateConnected)},
- {SWIG_LUA_CONSTTAB_INT("eStateAttaching", lldb::eStateAttaching)},
- {SWIG_LUA_CONSTTAB_INT("eStateLaunching", lldb::eStateLaunching)},
- {SWIG_LUA_CONSTTAB_INT("eStateStopped", lldb::eStateStopped)},
- {SWIG_LUA_CONSTTAB_INT("eStateRunning", lldb::eStateRunning)},
- {SWIG_LUA_CONSTTAB_INT("eStateStepping", lldb::eStateStepping)},
- {SWIG_LUA_CONSTTAB_INT("eStateCrashed", lldb::eStateCrashed)},
- {SWIG_LUA_CONSTTAB_INT("eStateDetached", lldb::eStateDetached)},
- {SWIG_LUA_CONSTTAB_INT("eStateExited", lldb::eStateExited)},
- {SWIG_LUA_CONSTTAB_INT("eStateSuspended", lldb::eStateSuspended)},
- {SWIG_LUA_CONSTTAB_INT("kLastStateType", lldb::kLastStateType)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagNone", lldb::eLaunchFlagNone)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagExec", lldb::eLaunchFlagExec)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDebug", lldb::eLaunchFlagDebug)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagStopAtEntry", lldb::eLaunchFlagStopAtEntry)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDisableASLR", lldb::eLaunchFlagDisableASLR)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDisableSTDIO", lldb::eLaunchFlagDisableSTDIO)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagLaunchInTTY", lldb::eLaunchFlagLaunchInTTY)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagLaunchInShell", lldb::eLaunchFlagLaunchInShell)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagLaunchInSeparateProcessGroup", lldb::eLaunchFlagLaunchInSeparateProcessGroup)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDontSetExitStatus", lldb::eLaunchFlagDontSetExitStatus)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDetachOnError", lldb::eLaunchFlagDetachOnError)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagShellExpandArguments", lldb::eLaunchFlagShellExpandArguments)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagCloseTTYOnExit", lldb::eLaunchFlagCloseTTYOnExit)},
- {SWIG_LUA_CONSTTAB_INT("eLaunchFlagInheritTCCFromParent", lldb::eLaunchFlagInheritTCCFromParent)},
- {SWIG_LUA_CONSTTAB_INT("eOnlyThisThread", lldb::eOnlyThisThread)},
- {SWIG_LUA_CONSTTAB_INT("eAllThreads", lldb::eAllThreads)},
- {SWIG_LUA_CONSTTAB_INT("eOnlyDuringStepping", lldb::eOnlyDuringStepping)},
- {SWIG_LUA_CONSTTAB_INT("eByteOrderInvalid", lldb::eByteOrderInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eByteOrderBig", lldb::eByteOrderBig)},
- {SWIG_LUA_CONSTTAB_INT("eByteOrderPDP", lldb::eByteOrderPDP)},
- {SWIG_LUA_CONSTTAB_INT("eByteOrderLittle", lldb::eByteOrderLittle)},
- {SWIG_LUA_CONSTTAB_INT("eEncodingInvalid", lldb::eEncodingInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eEncodingUint", lldb::eEncodingUint)},
- {SWIG_LUA_CONSTTAB_INT("eEncodingSint", lldb::eEncodingSint)},
- {SWIG_LUA_CONSTTAB_INT("eEncodingIEEE754", lldb::eEncodingIEEE754)},
- {SWIG_LUA_CONSTTAB_INT("eEncodingVector", lldb::eEncodingVector)},
- {SWIG_LUA_CONSTTAB_INT("eFormatDefault", lldb::eFormatDefault)},
- {SWIG_LUA_CONSTTAB_INT("eFormatInvalid", lldb::eFormatInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eFormatBoolean", lldb::eFormatBoolean)},
- {SWIG_LUA_CONSTTAB_INT("eFormatBinary", lldb::eFormatBinary)},
- {SWIG_LUA_CONSTTAB_INT("eFormatBytes", lldb::eFormatBytes)},
- {SWIG_LUA_CONSTTAB_INT("eFormatBytesWithASCII", lldb::eFormatBytesWithASCII)},
- {SWIG_LUA_CONSTTAB_INT("eFormatChar", lldb::eFormatChar)},
- {SWIG_LUA_CONSTTAB_INT("eFormatCharPrintable", lldb::eFormatCharPrintable)},
- {SWIG_LUA_CONSTTAB_INT("eFormatComplex", lldb::eFormatComplex)},
- {SWIG_LUA_CONSTTAB_INT("eFormatComplexFloat", lldb::eFormatComplexFloat)},
- {SWIG_LUA_CONSTTAB_INT("eFormatCString", lldb::eFormatCString)},
- {SWIG_LUA_CONSTTAB_INT("eFormatDecimal", lldb::eFormatDecimal)},
- {SWIG_LUA_CONSTTAB_INT("eFormatEnum", lldb::eFormatEnum)},
- {SWIG_LUA_CONSTTAB_INT("eFormatHex", lldb::eFormatHex)},
- {SWIG_LUA_CONSTTAB_INT("eFormatHexUppercase", lldb::eFormatHexUppercase)},
- {SWIG_LUA_CONSTTAB_INT("eFormatFloat", lldb::eFormatFloat)},
- {SWIG_LUA_CONSTTAB_INT("eFormatOctal", lldb::eFormatOctal)},
- {SWIG_LUA_CONSTTAB_INT("eFormatOSType", lldb::eFormatOSType)},
- {SWIG_LUA_CONSTTAB_INT("eFormatUnicode16", lldb::eFormatUnicode16)},
- {SWIG_LUA_CONSTTAB_INT("eFormatUnicode32", lldb::eFormatUnicode32)},
- {SWIG_LUA_CONSTTAB_INT("eFormatUnsigned", lldb::eFormatUnsigned)},
- {SWIG_LUA_CONSTTAB_INT("eFormatPointer", lldb::eFormatPointer)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfChar", lldb::eFormatVectorOfChar)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt8", lldb::eFormatVectorOfSInt8)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt8", lldb::eFormatVectorOfUInt8)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt16", lldb::eFormatVectorOfSInt16)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt16", lldb::eFormatVectorOfUInt16)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt32", lldb::eFormatVectorOfSInt32)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt32", lldb::eFormatVectorOfUInt32)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt64", lldb::eFormatVectorOfSInt64)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt64", lldb::eFormatVectorOfUInt64)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfFloat16", lldb::eFormatVectorOfFloat16)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfFloat32", lldb::eFormatVectorOfFloat32)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfFloat64", lldb::eFormatVectorOfFloat64)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt128", lldb::eFormatVectorOfUInt128)},
- {SWIG_LUA_CONSTTAB_INT("eFormatComplexInteger", lldb::eFormatComplexInteger)},
- {SWIG_LUA_CONSTTAB_INT("eFormatCharArray", lldb::eFormatCharArray)},
- {SWIG_LUA_CONSTTAB_INT("eFormatAddressInfo", lldb::eFormatAddressInfo)},
- {SWIG_LUA_CONSTTAB_INT("eFormatHexFloat", lldb::eFormatHexFloat)},
- {SWIG_LUA_CONSTTAB_INT("eFormatInstruction", lldb::eFormatInstruction)},
- {SWIG_LUA_CONSTTAB_INT("eFormatVoid", lldb::eFormatVoid)},
- {SWIG_LUA_CONSTTAB_INT("eFormatUnicode8", lldb::eFormatUnicode8)},
- {SWIG_LUA_CONSTTAB_INT("kNumFormats", lldb::kNumFormats)},
- {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelBrief", lldb::eDescriptionLevelBrief)},
- {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelFull", lldb::eDescriptionLevelFull)},
- {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelVerbose", lldb::eDescriptionLevelVerbose)},
- {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelInitial", lldb::eDescriptionLevelInitial)},
- {SWIG_LUA_CONSTTAB_INT("kNumDescriptionLevels", lldb::kNumDescriptionLevels)},
- {SWIG_LUA_CONSTTAB_INT("eScriptLanguageNone", lldb::eScriptLanguageNone)},
- {SWIG_LUA_CONSTTAB_INT("eScriptLanguagePython", lldb::eScriptLanguagePython)},
- {SWIG_LUA_CONSTTAB_INT("eScriptLanguageLua", lldb::eScriptLanguageLua)},
- {SWIG_LUA_CONSTTAB_INT("eScriptLanguageUnknown", lldb::eScriptLanguageUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eScriptLanguageDefault", lldb::eScriptLanguageDefault)},
- {SWIG_LUA_CONSTTAB_INT("eRegisterKindEHFrame", lldb::eRegisterKindEHFrame)},
- {SWIG_LUA_CONSTTAB_INT("eRegisterKindDWARF", lldb::eRegisterKindDWARF)},
- {SWIG_LUA_CONSTTAB_INT("eRegisterKindGeneric", lldb::eRegisterKindGeneric)},
- {SWIG_LUA_CONSTTAB_INT("eRegisterKindProcessPlugin", lldb::eRegisterKindProcessPlugin)},
- {SWIG_LUA_CONSTTAB_INT("eRegisterKindLLDB", lldb::eRegisterKindLLDB)},
- {SWIG_LUA_CONSTTAB_INT("kNumRegisterKinds", lldb::kNumRegisterKinds)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonInvalid", lldb::eStopReasonInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonNone", lldb::eStopReasonNone)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonTrace", lldb::eStopReasonTrace)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonBreakpoint", lldb::eStopReasonBreakpoint)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonWatchpoint", lldb::eStopReasonWatchpoint)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonSignal", lldb::eStopReasonSignal)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonException", lldb::eStopReasonException)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonExec", lldb::eStopReasonExec)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonPlanComplete", lldb::eStopReasonPlanComplete)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonThreadExiting", lldb::eStopReasonThreadExiting)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonInstrumentation", lldb::eStopReasonInstrumentation)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonProcessorTrace", lldb::eStopReasonProcessorTrace)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonFork", lldb::eStopReasonFork)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonVFork", lldb::eStopReasonVFork)},
- {SWIG_LUA_CONSTTAB_INT("eStopReasonVForkDone", lldb::eStopReasonVForkDone)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusInvalid", lldb::eReturnStatusInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessFinishNoResult", lldb::eReturnStatusSuccessFinishNoResult)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessFinishResult", lldb::eReturnStatusSuccessFinishResult)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessContinuingNoResult", lldb::eReturnStatusSuccessContinuingNoResult)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessContinuingResult", lldb::eReturnStatusSuccessContinuingResult)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusStarted", lldb::eReturnStatusStarted)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusFailed", lldb::eReturnStatusFailed)},
- {SWIG_LUA_CONSTTAB_INT("eReturnStatusQuit", lldb::eReturnStatusQuit)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionCompleted", lldb::eExpressionCompleted)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionSetupError", lldb::eExpressionSetupError)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionParseError", lldb::eExpressionParseError)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionDiscarded", lldb::eExpressionDiscarded)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionInterrupted", lldb::eExpressionInterrupted)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionHitBreakpoint", lldb::eExpressionHitBreakpoint)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionTimedOut", lldb::eExpressionTimedOut)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionResultUnavailable", lldb::eExpressionResultUnavailable)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionStoppedForDebug", lldb::eExpressionStoppedForDebug)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionThreadVanished", lldb::eExpressionThreadVanished)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthInvalid", lldb::eSearchDepthInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthTarget", lldb::eSearchDepthTarget)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthModule", lldb::eSearchDepthModule)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthCompUnit", lldb::eSearchDepthCompUnit)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthFunction", lldb::eSearchDepthFunction)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthBlock", lldb::eSearchDepthBlock)},
- {SWIG_LUA_CONSTTAB_INT("eSearchDepthAddress", lldb::eSearchDepthAddress)},
- {SWIG_LUA_CONSTTAB_INT("kLastSearchDepthKind", lldb::kLastSearchDepthKind)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusSuccess", lldb::eConnectionStatusSuccess)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusEndOfFile", lldb::eConnectionStatusEndOfFile)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusError", lldb::eConnectionStatusError)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusTimedOut", lldb::eConnectionStatusTimedOut)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusNoConnection", lldb::eConnectionStatusNoConnection)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusLostConnection", lldb::eConnectionStatusLostConnection)},
- {SWIG_LUA_CONSTTAB_INT("eConnectionStatusInterrupted", lldb::eConnectionStatusInterrupted)},
- {SWIG_LUA_CONSTTAB_INT("eErrorTypeInvalid", lldb::eErrorTypeInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eErrorTypeGeneric", lldb::eErrorTypeGeneric)},
- {SWIG_LUA_CONSTTAB_INT("eErrorTypeMachKernel", lldb::eErrorTypeMachKernel)},
- {SWIG_LUA_CONSTTAB_INT("eErrorTypePOSIX", lldb::eErrorTypePOSIX)},
- {SWIG_LUA_CONSTTAB_INT("eErrorTypeExpression", lldb::eErrorTypeExpression)},
- {SWIG_LUA_CONSTTAB_INT("eErrorTypeWin32", lldb::eErrorTypeWin32)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeInvalid", lldb::eValueTypeInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableGlobal", lldb::eValueTypeVariableGlobal)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableStatic", lldb::eValueTypeVariableStatic)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableArgument", lldb::eValueTypeVariableArgument)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableLocal", lldb::eValueTypeVariableLocal)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeRegister", lldb::eValueTypeRegister)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeRegisterSet", lldb::eValueTypeRegisterSet)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeConstResult", lldb::eValueTypeConstResult)},
- {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableThreadLocal", lldb::eValueTypeVariableThreadLocal)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityInvalid", lldb::eInputReaderGranularityInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityByte", lldb::eInputReaderGranularityByte)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityWord", lldb::eInputReaderGranularityWord)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityLine", lldb::eInputReaderGranularityLine)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityAll", lldb::eInputReaderGranularityAll)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextTarget", lldb::eSymbolContextTarget)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextModule", lldb::eSymbolContextModule)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextCompUnit", lldb::eSymbolContextCompUnit)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextFunction", lldb::eSymbolContextFunction)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextBlock", lldb::eSymbolContextBlock)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextLineEntry", lldb::eSymbolContextLineEntry)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextSymbol", lldb::eSymbolContextSymbol)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextEverything", lldb::eSymbolContextEverything)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextVariable", lldb::eSymbolContextVariable)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolContextLastItem", lldb::eSymbolContextLastItem)},
- {SWIG_LUA_CONSTTAB_INT("ePermissionsWritable", lldb::ePermissionsWritable)},
- {SWIG_LUA_CONSTTAB_INT("ePermissionsReadable", lldb::ePermissionsReadable)},
- {SWIG_LUA_CONSTTAB_INT("ePermissionsExecutable", lldb::ePermissionsExecutable)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderActivate", lldb::eInputReaderActivate)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderAsynchronousOutputWritten", lldb::eInputReaderAsynchronousOutputWritten)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderReactivate", lldb::eInputReaderReactivate)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderDeactivate", lldb::eInputReaderDeactivate)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderGotToken", lldb::eInputReaderGotToken)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderInterrupt", lldb::eInputReaderInterrupt)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderEndOfFile", lldb::eInputReaderEndOfFile)},
- {SWIG_LUA_CONSTTAB_INT("eInputReaderDone", lldb::eInputReaderDone)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeInvalidType", lldb::eBreakpointEventTypeInvalidType)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeAdded", lldb::eBreakpointEventTypeAdded)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeRemoved", lldb::eBreakpointEventTypeRemoved)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeLocationsAdded", lldb::eBreakpointEventTypeLocationsAdded)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeLocationsRemoved", lldb::eBreakpointEventTypeLocationsRemoved)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeLocationsResolved", lldb::eBreakpointEventTypeLocationsResolved)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeEnabled", lldb::eBreakpointEventTypeEnabled)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeDisabled", lldb::eBreakpointEventTypeDisabled)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeCommandChanged", lldb::eBreakpointEventTypeCommandChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeConditionChanged", lldb::eBreakpointEventTypeConditionChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeIgnoreChanged", lldb::eBreakpointEventTypeIgnoreChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeThreadChanged", lldb::eBreakpointEventTypeThreadChanged)},
- {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeAutoContinueChanged", lldb::eBreakpointEventTypeAutoContinueChanged)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeInvalidType", lldb::eWatchpointEventTypeInvalidType)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeAdded", lldb::eWatchpointEventTypeAdded)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeRemoved", lldb::eWatchpointEventTypeRemoved)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeEnabled", lldb::eWatchpointEventTypeEnabled)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeDisabled", lldb::eWatchpointEventTypeDisabled)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeCommandChanged", lldb::eWatchpointEventTypeCommandChanged)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeConditionChanged", lldb::eWatchpointEventTypeConditionChanged)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeIgnoreChanged", lldb::eWatchpointEventTypeIgnoreChanged)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeThreadChanged", lldb::eWatchpointEventTypeThreadChanged)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeTypeChanged", lldb::eWatchpointEventTypeTypeChanged)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeUnknown", lldb::eLanguageTypeUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC89", lldb::eLanguageTypeC89)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC", lldb::eLanguageTypeC)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAda83", lldb::eLanguageTypeAda83)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus", lldb::eLanguageTypeC_plus_plus)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeCobol74", lldb::eLanguageTypeCobol74)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeCobol85", lldb::eLanguageTypeCobol85)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran77", lldb::eLanguageTypeFortran77)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran90", lldb::eLanguageTypeFortran90)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypePascal83", lldb::eLanguageTypePascal83)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeModula2", lldb::eLanguageTypeModula2)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeJava", lldb::eLanguageTypeJava)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC99", lldb::eLanguageTypeC99)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAda95", lldb::eLanguageTypeAda95)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran95", lldb::eLanguageTypeFortran95)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypePLI", lldb::eLanguageTypePLI)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeObjC", lldb::eLanguageTypeObjC)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeObjC_plus_plus", lldb::eLanguageTypeObjC_plus_plus)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeUPC", lldb::eLanguageTypeUPC)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeD", lldb::eLanguageTypeD)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypePython", lldb::eLanguageTypePython)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeOpenCL", lldb::eLanguageTypeOpenCL)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeGo", lldb::eLanguageTypeGo)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeModula3", lldb::eLanguageTypeModula3)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeHaskell", lldb::eLanguageTypeHaskell)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_03", lldb::eLanguageTypeC_plus_plus_03)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_11", lldb::eLanguageTypeC_plus_plus_11)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeOCaml", lldb::eLanguageTypeOCaml)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeRust", lldb::eLanguageTypeRust)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC11", lldb::eLanguageTypeC11)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeSwift", lldb::eLanguageTypeSwift)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeJulia", lldb::eLanguageTypeJulia)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeDylan", lldb::eLanguageTypeDylan)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_14", lldb::eLanguageTypeC_plus_plus_14)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran03", lldb::eLanguageTypeFortran03)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran08", lldb::eLanguageTypeFortran08)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeMipsAssembler", lldb::eLanguageTypeMipsAssembler)},
- {SWIG_LUA_CONSTTAB_INT("eLanguageTypeExtRenderScript", lldb::eLanguageTypeExtRenderScript)},
- {SWIG_LUA_CONSTTAB_INT("eNumLanguageTypes", lldb::eNumLanguageTypes)},
- {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeAddressSanitizer", lldb::eInstrumentationRuntimeTypeAddressSanitizer)},
- {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeThreadSanitizer", lldb::eInstrumentationRuntimeTypeThreadSanitizer)},
- {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer", lldb::eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer)},
- {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeMainThreadChecker", lldb::eInstrumentationRuntimeTypeMainThreadChecker)},
- {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeSwiftRuntimeReporting", lldb::eInstrumentationRuntimeTypeSwiftRuntimeReporting)},
- {SWIG_LUA_CONSTTAB_INT("eNumInstrumentationRuntimeTypes", lldb::eNumInstrumentationRuntimeTypes)},
- {SWIG_LUA_CONSTTAB_INT("eNoDynamicValues", lldb::eNoDynamicValues)},
- {SWIG_LUA_CONSTTAB_INT("eDynamicCanRunTarget", lldb::eDynamicCanRunTarget)},
- {SWIG_LUA_CONSTTAB_INT("eDynamicDontRunTarget", lldb::eDynamicDontRunTarget)},
- {SWIG_LUA_CONSTTAB_INT("eStopShowColumnAnsiOrCaret", lldb::eStopShowColumnAnsiOrCaret)},
- {SWIG_LUA_CONSTTAB_INT("eStopShowColumnAnsi", lldb::eStopShowColumnAnsi)},
- {SWIG_LUA_CONSTTAB_INT("eStopShowColumnCaret", lldb::eStopShowColumnCaret)},
- {SWIG_LUA_CONSTTAB_INT("eStopShowColumnNone", lldb::eStopShowColumnNone)},
- {SWIG_LUA_CONSTTAB_INT("eAccessNone", lldb::eAccessNone)},
- {SWIG_LUA_CONSTTAB_INT("eAccessPublic", lldb::eAccessPublic)},
- {SWIG_LUA_CONSTTAB_INT("eAccessPrivate", lldb::eAccessPrivate)},
- {SWIG_LUA_CONSTTAB_INT("eAccessProtected", lldb::eAccessProtected)},
- {SWIG_LUA_CONSTTAB_INT("eAccessPackage", lldb::eAccessPackage)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeAddress", lldb::eArgTypeAddress)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeAddressOrExpression", lldb::eArgTypeAddressOrExpression)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeAliasName", lldb::eArgTypeAliasName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeAliasOptions", lldb::eArgTypeAliasOptions)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeArchitecture", lldb::eArgTypeArchitecture)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeBoolean", lldb::eArgTypeBoolean)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeBreakpointID", lldb::eArgTypeBreakpointID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeBreakpointIDRange", lldb::eArgTypeBreakpointIDRange)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeBreakpointName", lldb::eArgTypeBreakpointName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeByteSize", lldb::eArgTypeByteSize)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeClassName", lldb::eArgTypeClassName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeCommandName", lldb::eArgTypeCommandName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeCount", lldb::eArgTypeCount)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeDescriptionVerbosity", lldb::eArgTypeDescriptionVerbosity)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeDirectoryName", lldb::eArgTypeDirectoryName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeDisassemblyFlavor", lldb::eArgTypeDisassemblyFlavor)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeEndAddress", lldb::eArgTypeEndAddress)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeExpression", lldb::eArgTypeExpression)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeExpressionPath", lldb::eArgTypeExpressionPath)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeExprFormat", lldb::eArgTypeExprFormat)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFileLineColumn", lldb::eArgTypeFileLineColumn)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFilename", lldb::eArgTypeFilename)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFormat", lldb::eArgTypeFormat)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFrameIndex", lldb::eArgTypeFrameIndex)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFullName", lldb::eArgTypeFullName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFunctionName", lldb::eArgTypeFunctionName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeFunctionOrSymbol", lldb::eArgTypeFunctionOrSymbol)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeGDBFormat", lldb::eArgTypeGDBFormat)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeHelpText", lldb::eArgTypeHelpText)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeIndex", lldb::eArgTypeIndex)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeLanguage", lldb::eArgTypeLanguage)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeLineNum", lldb::eArgTypeLineNum)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeLogCategory", lldb::eArgTypeLogCategory)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeLogChannel", lldb::eArgTypeLogChannel)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeMethod", lldb::eArgTypeMethod)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeName", lldb::eArgTypeName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeNewPathPrefix", lldb::eArgTypeNewPathPrefix)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeNumLines", lldb::eArgTypeNumLines)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeNumberPerLine", lldb::eArgTypeNumberPerLine)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeOffset", lldb::eArgTypeOffset)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeOldPathPrefix", lldb::eArgTypeOldPathPrefix)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeOneLiner", lldb::eArgTypeOneLiner)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePath", lldb::eArgTypePath)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePermissionsNumber", lldb::eArgTypePermissionsNumber)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePermissionsString", lldb::eArgTypePermissionsString)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePid", lldb::eArgTypePid)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePlugin", lldb::eArgTypePlugin)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeProcessName", lldb::eArgTypeProcessName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePythonClass", lldb::eArgTypePythonClass)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePythonFunction", lldb::eArgTypePythonFunction)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePythonScript", lldb::eArgTypePythonScript)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeQueueName", lldb::eArgTypeQueueName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeRegisterName", lldb::eArgTypeRegisterName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeRegularExpression", lldb::eArgTypeRegularExpression)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeRunArgs", lldb::eArgTypeRunArgs)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeRunMode", lldb::eArgTypeRunMode)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeScriptedCommandSynchronicity", lldb::eArgTypeScriptedCommandSynchronicity)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeScriptLang", lldb::eArgTypeScriptLang)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSearchWord", lldb::eArgTypeSearchWord)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSelector", lldb::eArgTypeSelector)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingIndex", lldb::eArgTypeSettingIndex)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingKey", lldb::eArgTypeSettingKey)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingPrefix", lldb::eArgTypeSettingPrefix)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingVariableName", lldb::eArgTypeSettingVariableName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeShlibName", lldb::eArgTypeShlibName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSourceFile", lldb::eArgTypeSourceFile)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSortOrder", lldb::eArgTypeSortOrder)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeStartAddress", lldb::eArgTypeStartAddress)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSummaryString", lldb::eArgTypeSummaryString)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSymbol", lldb::eArgTypeSymbol)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeThreadID", lldb::eArgTypeThreadID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeThreadIndex", lldb::eArgTypeThreadIndex)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeThreadName", lldb::eArgTypeThreadName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeTypeName", lldb::eArgTypeTypeName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeUnsignedInteger", lldb::eArgTypeUnsignedInteger)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeUnixSignal", lldb::eArgTypeUnixSignal)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeVarName", lldb::eArgTypeVarName)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeValue", lldb::eArgTypeValue)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeWidth", lldb::eArgTypeWidth)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeNone", lldb::eArgTypeNone)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypePlatform", lldb::eArgTypePlatform)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeWatchpointID", lldb::eArgTypeWatchpointID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeWatchpointIDRange", lldb::eArgTypeWatchpointIDRange)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeWatchType", lldb::eArgTypeWatchType)},
- {SWIG_LUA_CONSTTAB_INT("eArgRawInput", lldb::eArgRawInput)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeCommand", lldb::eArgTypeCommand)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeColumnNum", lldb::eArgTypeColumnNum)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeModuleUUID", lldb::eArgTypeModuleUUID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSaveCoreStyle", lldb::eArgTypeSaveCoreStyle)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeLogHandler", lldb::eArgTypeLogHandler)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeSEDStylePair", lldb::eArgTypeSEDStylePair)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeRecognizerID", lldb::eArgTypeRecognizerID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeConnectURL", lldb::eArgTypeConnectURL)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeTargetID", lldb::eArgTypeTargetID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeStopHookID", lldb::eArgTypeStopHookID)},
- {SWIG_LUA_CONSTTAB_INT("eArgTypeLastArg", lldb::eArgTypeLastArg)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeAny", lldb::eSymbolTypeAny)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeInvalid", lldb::eSymbolTypeInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeAbsolute", lldb::eSymbolTypeAbsolute)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeCode", lldb::eSymbolTypeCode)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeResolver", lldb::eSymbolTypeResolver)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeData", lldb::eSymbolTypeData)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeTrampoline", lldb::eSymbolTypeTrampoline)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeRuntime", lldb::eSymbolTypeRuntime)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeException", lldb::eSymbolTypeException)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeSourceFile", lldb::eSymbolTypeSourceFile)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeHeaderFile", lldb::eSymbolTypeHeaderFile)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjectFile", lldb::eSymbolTypeObjectFile)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeCommonBlock", lldb::eSymbolTypeCommonBlock)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeBlock", lldb::eSymbolTypeBlock)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeLocal", lldb::eSymbolTypeLocal)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeParam", lldb::eSymbolTypeParam)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeVariable", lldb::eSymbolTypeVariable)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeVariableType", lldb::eSymbolTypeVariableType)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeLineEntry", lldb::eSymbolTypeLineEntry)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeLineHeader", lldb::eSymbolTypeLineHeader)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeScopeBegin", lldb::eSymbolTypeScopeBegin)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeScopeEnd", lldb::eSymbolTypeScopeEnd)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeAdditional", lldb::eSymbolTypeAdditional)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeCompiler", lldb::eSymbolTypeCompiler)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeInstrumentation", lldb::eSymbolTypeInstrumentation)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeUndefined", lldb::eSymbolTypeUndefined)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjCClass", lldb::eSymbolTypeObjCClass)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjCMetaClass", lldb::eSymbolTypeObjCMetaClass)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjCIVar", lldb::eSymbolTypeObjCIVar)},
- {SWIG_LUA_CONSTTAB_INT("eSymbolTypeReExported", lldb::eSymbolTypeReExported)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeInvalid", lldb::eSectionTypeInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeCode", lldb::eSectionTypeCode)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeContainer", lldb::eSectionTypeContainer)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeData", lldb::eSectionTypeData)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataCString", lldb::eSectionTypeDataCString)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataCStringPointers", lldb::eSectionTypeDataCStringPointers)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataSymbolAddress", lldb::eSectionTypeDataSymbolAddress)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeData4", lldb::eSectionTypeData4)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeData8", lldb::eSectionTypeData8)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeData16", lldb::eSectionTypeData16)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataPointers", lldb::eSectionTypeDataPointers)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDebug", lldb::eSectionTypeDebug)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeZeroFill", lldb::eSectionTypeZeroFill)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataObjCMessageRefs", lldb::eSectionTypeDataObjCMessageRefs)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataObjCCFStrings", lldb::eSectionTypeDataObjCCFStrings)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAbbrev", lldb::eSectionTypeDWARFDebugAbbrev)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAddr", lldb::eSectionTypeDWARFDebugAddr)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAranges", lldb::eSectionTypeDWARFDebugAranges)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugCuIndex", lldb::eSectionTypeDWARFDebugCuIndex)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugFrame", lldb::eSectionTypeDWARFDebugFrame)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugInfo", lldb::eSectionTypeDWARFDebugInfo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLine", lldb::eSectionTypeDWARFDebugLine)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLoc", lldb::eSectionTypeDWARFDebugLoc)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugMacInfo", lldb::eSectionTypeDWARFDebugMacInfo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugMacro", lldb::eSectionTypeDWARFDebugMacro)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugPubNames", lldb::eSectionTypeDWARFDebugPubNames)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugPubTypes", lldb::eSectionTypeDWARFDebugPubTypes)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugRanges", lldb::eSectionTypeDWARFDebugRanges)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStr", lldb::eSectionTypeDWARFDebugStr)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStrOffsets", lldb::eSectionTypeDWARFDebugStrOffsets)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleNames", lldb::eSectionTypeDWARFAppleNames)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleTypes", lldb::eSectionTypeDWARFAppleTypes)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleNamespaces", lldb::eSectionTypeDWARFAppleNamespaces)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleObjC", lldb::eSectionTypeDWARFAppleObjC)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFSymbolTable", lldb::eSectionTypeELFSymbolTable)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFDynamicSymbols", lldb::eSectionTypeELFDynamicSymbols)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFRelocationEntries", lldb::eSectionTypeELFRelocationEntries)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFDynamicLinkInfo", lldb::eSectionTypeELFDynamicLinkInfo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeEHFrame", lldb::eSectionTypeEHFrame)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeARMexidx", lldb::eSectionTypeARMexidx)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeARMextab", lldb::eSectionTypeARMextab)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeCompactUnwind", lldb::eSectionTypeCompactUnwind)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeGoSymtab", lldb::eSectionTypeGoSymtab)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeAbsoluteAddress", lldb::eSectionTypeAbsoluteAddress)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFGNUDebugAltLink", lldb::eSectionTypeDWARFGNUDebugAltLink)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugTypes", lldb::eSectionTypeDWARFDebugTypes)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugNames", lldb::eSectionTypeDWARFDebugNames)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeOther", lldb::eSectionTypeOther)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLineStr", lldb::eSectionTypeDWARFDebugLineStr)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugRngLists", lldb::eSectionTypeDWARFDebugRngLists)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLocLists", lldb::eSectionTypeDWARFDebugLocLists)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAbbrevDwo", lldb::eSectionTypeDWARFDebugAbbrevDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugInfoDwo", lldb::eSectionTypeDWARFDebugInfoDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStrDwo", lldb::eSectionTypeDWARFDebugStrDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStrOffsetsDwo", lldb::eSectionTypeDWARFDebugStrOffsetsDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugTypesDwo", lldb::eSectionTypeDWARFDebugTypesDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugRngListsDwo", lldb::eSectionTypeDWARFDebugRngListsDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLocDwo", lldb::eSectionTypeDWARFDebugLocDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLocListsDwo", lldb::eSectionTypeDWARFDebugLocListsDwo)},
- {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugTuIndex", lldb::eSectionTypeDWARFDebugTuIndex)},
- {SWIG_LUA_CONSTTAB_INT("eEmulateInstructionOptionNone", lldb::eEmulateInstructionOptionNone)},
- {SWIG_LUA_CONSTTAB_INT("eEmulateInstructionOptionAutoAdvancePC", lldb::eEmulateInstructionOptionAutoAdvancePC)},
- {SWIG_LUA_CONSTTAB_INT("eEmulateInstructionOptionIgnoreConditions", lldb::eEmulateInstructionOptionIgnoreConditions)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeNone", lldb::eFunctionNameTypeNone)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeAuto", lldb::eFunctionNameTypeAuto)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeFull", lldb::eFunctionNameTypeFull)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeBase", lldb::eFunctionNameTypeBase)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeMethod", lldb::eFunctionNameTypeMethod)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeSelector", lldb::eFunctionNameTypeSelector)},
- {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeAny", lldb::eFunctionNameTypeAny)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeInvalid", lldb::eBasicTypeInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeVoid", lldb::eBasicTypeVoid)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar", lldb::eBasicTypeChar)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeSignedChar", lldb::eBasicTypeSignedChar)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedChar", lldb::eBasicTypeUnsignedChar)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeWChar", lldb::eBasicTypeWChar)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeSignedWChar", lldb::eBasicTypeSignedWChar)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedWChar", lldb::eBasicTypeUnsignedWChar)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar16", lldb::eBasicTypeChar16)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar32", lldb::eBasicTypeChar32)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar8", lldb::eBasicTypeChar8)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeShort", lldb::eBasicTypeShort)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedShort", lldb::eBasicTypeUnsignedShort)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeInt", lldb::eBasicTypeInt)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedInt", lldb::eBasicTypeUnsignedInt)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeLong", lldb::eBasicTypeLong)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedLong", lldb::eBasicTypeUnsignedLong)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeLongLong", lldb::eBasicTypeLongLong)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedLongLong", lldb::eBasicTypeUnsignedLongLong)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeInt128", lldb::eBasicTypeInt128)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedInt128", lldb::eBasicTypeUnsignedInt128)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeBool", lldb::eBasicTypeBool)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeHalf", lldb::eBasicTypeHalf)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeFloat", lldb::eBasicTypeFloat)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeDouble", lldb::eBasicTypeDouble)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeLongDouble", lldb::eBasicTypeLongDouble)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeFloatComplex", lldb::eBasicTypeFloatComplex)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeDoubleComplex", lldb::eBasicTypeDoubleComplex)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeLongDoubleComplex", lldb::eBasicTypeLongDoubleComplex)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeObjCID", lldb::eBasicTypeObjCID)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeObjCClass", lldb::eBasicTypeObjCClass)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeObjCSel", lldb::eBasicTypeObjCSel)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeNullPtr", lldb::eBasicTypeNullPtr)},
- {SWIG_LUA_CONSTTAB_INT("eBasicTypeOther", lldb::eBasicTypeOther)},
- {SWIG_LUA_CONSTTAB_INT("eTraceTypeNone", lldb::eTraceTypeNone)},
- {SWIG_LUA_CONSTTAB_INT("eTraceTypeProcessorTrace", lldb::eTraceTypeProcessorTrace)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeInvalid", lldb::eStructuredDataTypeInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeNull", lldb::eStructuredDataTypeNull)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeGeneric", lldb::eStructuredDataTypeGeneric)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeArray", lldb::eStructuredDataTypeArray)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeInteger", lldb::eStructuredDataTypeInteger)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeFloat", lldb::eStructuredDataTypeFloat)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeBoolean", lldb::eStructuredDataTypeBoolean)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeString", lldb::eStructuredDataTypeString)},
- {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeDictionary", lldb::eStructuredDataTypeDictionary)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassInvalid", lldb::eTypeClassInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassArray", lldb::eTypeClassArray)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassBlockPointer", lldb::eTypeClassBlockPointer)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassBuiltin", lldb::eTypeClassBuiltin)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassClass", lldb::eTypeClassClass)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassComplexFloat", lldb::eTypeClassComplexFloat)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassComplexInteger", lldb::eTypeClassComplexInteger)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassEnumeration", lldb::eTypeClassEnumeration)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassFunction", lldb::eTypeClassFunction)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassMemberPointer", lldb::eTypeClassMemberPointer)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassObjCObject", lldb::eTypeClassObjCObject)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassObjCInterface", lldb::eTypeClassObjCInterface)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassObjCObjectPointer", lldb::eTypeClassObjCObjectPointer)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassPointer", lldb::eTypeClassPointer)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassReference", lldb::eTypeClassReference)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassStruct", lldb::eTypeClassStruct)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassTypedef", lldb::eTypeClassTypedef)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassUnion", lldb::eTypeClassUnion)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassVector", lldb::eTypeClassVector)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassOther", lldb::eTypeClassOther)},
- {SWIG_LUA_CONSTTAB_INT("eTypeClassAny", lldb::eTypeClassAny)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindNull", lldb::eTemplateArgumentKindNull)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindType", lldb::eTemplateArgumentKindType)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindDeclaration", lldb::eTemplateArgumentKindDeclaration)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindIntegral", lldb::eTemplateArgumentKindIntegral)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindTemplate", lldb::eTemplateArgumentKindTemplate)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindTemplateExpansion", lldb::eTemplateArgumentKindTemplateExpansion)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindExpression", lldb::eTemplateArgumentKindExpression)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindPack", lldb::eTemplateArgumentKindPack)},
- {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindNullPtr", lldb::eTemplateArgumentKindNullPtr)},
- {SWIG_LUA_CONSTTAB_INT("eFormatterMatchExact", lldb::eFormatterMatchExact)},
- {SWIG_LUA_CONSTTAB_INT("eFormatterMatchRegex", lldb::eFormatterMatchRegex)},
- {SWIG_LUA_CONSTTAB_INT("eFormatterMatchCallback", lldb::eFormatterMatchCallback)},
- {SWIG_LUA_CONSTTAB_INT("eLastFormatterMatchType", lldb::eLastFormatterMatchType)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionNone", lldb::eTypeOptionNone)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionCascade", lldb::eTypeOptionCascade)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionSkipPointers", lldb::eTypeOptionSkipPointers)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionSkipReferences", lldb::eTypeOptionSkipReferences)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideChildren", lldb::eTypeOptionHideChildren)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideValue", lldb::eTypeOptionHideValue)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionShowOneLiner", lldb::eTypeOptionShowOneLiner)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideNames", lldb::eTypeOptionHideNames)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionNonCacheable", lldb::eTypeOptionNonCacheable)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideEmptyAggregates", lldb::eTypeOptionHideEmptyAggregates)},
- {SWIG_LUA_CONSTTAB_INT("eTypeOptionFrontEndWantsDereference", lldb::eTypeOptionFrontEndWantsDereference)},
- {SWIG_LUA_CONSTTAB_INT("eFrameCompareInvalid", lldb::eFrameCompareInvalid)},
- {SWIG_LUA_CONSTTAB_INT("eFrameCompareUnknown", lldb::eFrameCompareUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eFrameCompareEqual", lldb::eFrameCompareEqual)},
- {SWIG_LUA_CONSTTAB_INT("eFrameCompareSameParent", lldb::eFrameCompareSameParent)},
- {SWIG_LUA_CONSTTAB_INT("eFrameCompareYounger", lldb::eFrameCompareYounger)},
- {SWIG_LUA_CONSTTAB_INT("eFrameCompareOlder", lldb::eFrameCompareOlder)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserRead", lldb::eFilePermissionsUserRead)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserWrite", lldb::eFilePermissionsUserWrite)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserExecute", lldb::eFilePermissionsUserExecute)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRead", lldb::eFilePermissionsGroupRead)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupWrite", lldb::eFilePermissionsGroupWrite)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupExecute", lldb::eFilePermissionsGroupExecute)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRead", lldb::eFilePermissionsWorldRead)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldWrite", lldb::eFilePermissionsWorldWrite)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldExecute", lldb::eFilePermissionsWorldExecute)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserRW", lldb::eFilePermissionsUserRW)},
- {SWIG_LUA_CONSTTAB_INT("eFileFilePermissionsUserRX", lldb::eFileFilePermissionsUserRX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserRWX", lldb::eFilePermissionsUserRWX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRW", lldb::eFilePermissionsGroupRW)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRX", lldb::eFilePermissionsGroupRX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRWX", lldb::eFilePermissionsGroupRWX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRW", lldb::eFilePermissionsWorldRW)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRX", lldb::eFilePermissionsWorldRX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRWX", lldb::eFilePermissionsWorldRWX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneR", lldb::eFilePermissionsEveryoneR)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneW", lldb::eFilePermissionsEveryoneW)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneX", lldb::eFilePermissionsEveryoneX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneRW", lldb::eFilePermissionsEveryoneRW)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneRX", lldb::eFilePermissionsEveryoneRX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneRWX", lldb::eFilePermissionsEveryoneRWX)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsFileDefault", lldb::eFilePermissionsFileDefault)},
- {SWIG_LUA_CONSTTAB_INT("eFilePermissionsDirectoryDefault", lldb::eFilePermissionsDirectoryDefault)},
- {SWIG_LUA_CONSTTAB_INT("eQueueItemKindUnknown", lldb::eQueueItemKindUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eQueueItemKindFunction", lldb::eQueueItemKindFunction)},
- {SWIG_LUA_CONSTTAB_INT("eQueueItemKindBlock", lldb::eQueueItemKindBlock)},
- {SWIG_LUA_CONSTTAB_INT("eQueueKindUnknown", lldb::eQueueKindUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eQueueKindSerial", lldb::eQueueKindSerial)},
- {SWIG_LUA_CONSTTAB_INT("eQueueKindConcurrent", lldb::eQueueKindConcurrent)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationParse", lldb::eExpressionEvaluationParse)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationIRGen", lldb::eExpressionEvaluationIRGen)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationExecution", lldb::eExpressionEvaluationExecution)},
- {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationComplete", lldb::eExpressionEvaluationComplete)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindUnknown", lldb::eInstructionControlFlowKindUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindOther", lldb::eInstructionControlFlowKindOther)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindCall", lldb::eInstructionControlFlowKindCall)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindReturn", lldb::eInstructionControlFlowKindReturn)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindJump", lldb::eInstructionControlFlowKindJump)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindCondJump", lldb::eInstructionControlFlowKindCondJump)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindFarCall", lldb::eInstructionControlFlowKindFarCall)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindFarReturn", lldb::eInstructionControlFlowKindFarReturn)},
- {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindFarJump", lldb::eInstructionControlFlowKindFarJump)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointKindWrite", lldb::eWatchpointKindWrite)},
- {SWIG_LUA_CONSTTAB_INT("eWatchpointKindRead", lldb::eWatchpointKindRead)},
- {SWIG_LUA_CONSTTAB_INT("eGdbSignalBadAccess", lldb::eGdbSignalBadAccess)},
- {SWIG_LUA_CONSTTAB_INT("eGdbSignalBadInstruction", lldb::eGdbSignalBadInstruction)},
- {SWIG_LUA_CONSTTAB_INT("eGdbSignalArithmetic", lldb::eGdbSignalArithmetic)},
- {SWIG_LUA_CONSTTAB_INT("eGdbSignalEmulation", lldb::eGdbSignalEmulation)},
- {SWIG_LUA_CONSTTAB_INT("eGdbSignalSoftware", lldb::eGdbSignalSoftware)},
- {SWIG_LUA_CONSTTAB_INT("eGdbSignalBreakpoint", lldb::eGdbSignalBreakpoint)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBShlibDir", lldb::ePathTypeLLDBShlibDir)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeSupportExecutableDir", lldb::ePathTypeSupportExecutableDir)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeHeaderDir", lldb::ePathTypeHeaderDir)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypePythonDir", lldb::ePathTypePythonDir)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBSystemPlugins", lldb::ePathTypeLLDBSystemPlugins)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBUserPlugins", lldb::ePathTypeLLDBUserPlugins)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBTempSystemDir", lldb::ePathTypeLLDBTempSystemDir)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeGlobalLLDBTempSystemDir", lldb::ePathTypeGlobalLLDBTempSystemDir)},
- {SWIG_LUA_CONSTTAB_INT("ePathTypeClangDir", lldb::ePathTypeClangDir)},
- {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindUnknown", lldb::eMemberFunctionKindUnknown)},
- {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindConstructor", lldb::eMemberFunctionKindConstructor)},
- {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindDestructor", lldb::eMemberFunctionKindDestructor)},
- {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindInstanceMethod", lldb::eMemberFunctionKindInstanceMethod)},
- {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindStaticMethod", lldb::eMemberFunctionKindStaticMethod)},
- {SWIG_LUA_CONSTTAB_INT("eMatchTypeNormal", lldb::eMatchTypeNormal)},
- {SWIG_LUA_CONSTTAB_INT("eMatchTypeRegex", lldb::eMatchTypeRegex)},
- {SWIG_LUA_CONSTTAB_INT("eMatchTypeStartsWith", lldb::eMatchTypeStartsWith)},
- {SWIG_LUA_CONSTTAB_INT("eTypeHasChildren", lldb::eTypeHasChildren)},
- {SWIG_LUA_CONSTTAB_INT("eTypeHasValue", lldb::eTypeHasValue)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsArray", lldb::eTypeIsArray)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsBlock", lldb::eTypeIsBlock)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsBuiltIn", lldb::eTypeIsBuiltIn)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsClass", lldb::eTypeIsClass)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsCPlusPlus", lldb::eTypeIsCPlusPlus)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsEnumeration", lldb::eTypeIsEnumeration)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsFuncPrototype", lldb::eTypeIsFuncPrototype)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsMember", lldb::eTypeIsMember)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsObjC", lldb::eTypeIsObjC)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsPointer", lldb::eTypeIsPointer)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsReference", lldb::eTypeIsReference)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsStructUnion", lldb::eTypeIsStructUnion)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsTemplate", lldb::eTypeIsTemplate)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsTypedef", lldb::eTypeIsTypedef)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsVector", lldb::eTypeIsVector)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsScalar", lldb::eTypeIsScalar)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsInteger", lldb::eTypeIsInteger)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsFloat", lldb::eTypeIsFloat)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsComplex", lldb::eTypeIsComplex)},
- {SWIG_LUA_CONSTTAB_INT("eTypeIsSigned", lldb::eTypeIsSigned)},
- {SWIG_LUA_CONSTTAB_INT("eTypeInstanceIsPointer", lldb::eTypeInstanceIsPointer)},
- {SWIG_LUA_CONSTTAB_INT("eCommandRequiresTarget", lldb::eCommandRequiresTarget)},
- {SWIG_LUA_CONSTTAB_INT("eCommandRequiresProcess", lldb::eCommandRequiresProcess)},
- {SWIG_LUA_CONSTTAB_INT("eCommandRequiresThread", lldb::eCommandRequiresThread)},
- {SWIG_LUA_CONSTTAB_INT("eCommandRequiresFrame", lldb::eCommandRequiresFrame)},
- {SWIG_LUA_CONSTTAB_INT("eCommandRequiresRegContext", lldb::eCommandRequiresRegContext)},
- {SWIG_LUA_CONSTTAB_INT("eCommandTryTargetAPILock", lldb::eCommandTryTargetAPILock)},
- {SWIG_LUA_CONSTTAB_INT("eCommandProcessMustBeLaunched", lldb::eCommandProcessMustBeLaunched)},
- {SWIG_LUA_CONSTTAB_INT("eCommandProcessMustBePaused", lldb::eCommandProcessMustBePaused)},
- {SWIG_LUA_CONSTTAB_INT("eCommandProcessMustBeTraced", lldb::eCommandProcessMustBeTraced)},
- {SWIG_LUA_CONSTTAB_INT("eTypeSummaryCapped", lldb::eTypeSummaryCapped)},
- {SWIG_LUA_CONSTTAB_INT("eTypeSummaryUncapped", lldb::eTypeSummaryUncapped)},
- {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultSuccess", lldb::eCommandInterpreterResultSuccess)},
- {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultInferiorCrash", lldb::eCommandInterpreterResultInferiorCrash)},
- {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultCommandError", lldb::eCommandInterpreterResultCommandError)},
- {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultQuitRequested", lldb::eCommandInterpreterResultQuitRequested)},
- {SWIG_LUA_CONSTTAB_INT("eSaveCoreUnspecified", lldb::eSaveCoreUnspecified)},
- {SWIG_LUA_CONSTTAB_INT("eSaveCoreFull", lldb::eSaveCoreFull)},
- {SWIG_LUA_CONSTTAB_INT("eSaveCoreDirtyOnly", lldb::eSaveCoreDirtyOnly)},
- {SWIG_LUA_CONSTTAB_INT("eSaveCoreStackOnly", lldb::eSaveCoreStackOnly)},
- {SWIG_LUA_CONSTTAB_INT("eTraceEventDisabledSW", lldb::eTraceEventDisabledSW)},
- {SWIG_LUA_CONSTTAB_INT("eTraceEventDisabledHW", lldb::eTraceEventDisabledHW)},
- {SWIG_LUA_CONSTTAB_INT("eTraceEventCPUChanged", lldb::eTraceEventCPUChanged)},
- {SWIG_LUA_CONSTTAB_INT("eTraceEventHWClockTick", lldb::eTraceEventHWClockTick)},
- {SWIG_LUA_CONSTTAB_INT("eTraceEventSyncPoint", lldb::eTraceEventSyncPoint)},
- {SWIG_LUA_CONSTTAB_INT("eTraceItemKindError", lldb::eTraceItemKindError)},
- {SWIG_LUA_CONSTTAB_INT("eTraceItemKindEvent", lldb::eTraceItemKindEvent)},
- {SWIG_LUA_CONSTTAB_INT("eTraceItemKindInstruction", lldb::eTraceItemKindInstruction)},
- {SWIG_LUA_CONSTTAB_INT("eTraceCursorSeekTypeBeginning", lldb::eTraceCursorSeekTypeBeginning)},
- {SWIG_LUA_CONSTTAB_INT("eTraceCursorSeekTypeCurrent", lldb::eTraceCursorSeekTypeCurrent)},
- {SWIG_LUA_CONSTTAB_INT("eTraceCursorSeekTypeEnd", lldb::eTraceCursorSeekTypeEnd)},
- {SWIG_LUA_CONSTTAB_INT("eDWIMPrintVerbosityNone", lldb::eDWIMPrintVerbosityNone)},
- {SWIG_LUA_CONSTTAB_INT("eDWIMPrintVerbosityExpression", lldb::eDWIMPrintVerbosityExpression)},
- {SWIG_LUA_CONSTTAB_INT("eDWIMPrintVerbosityFull", lldb::eDWIMPrintVerbosityFull)},
- {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitThreadShouldExit", lldb::SBCommandInterpreter::eBroadcastBitThreadShouldExit)},
- {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitResetPrompt", lldb::SBCommandInterpreter::eBroadcastBitResetPrompt)},
- {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitQuitCommandReceived", lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived)},
- {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitAsynchronousOutputData", lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData)},
- {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitAsynchronousErrorData", lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData)},
- {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitDisconnected", lldb::SBCommunication::eBroadcastBitDisconnected)},
- {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitReadThreadGotBytes", lldb::SBCommunication::eBroadcastBitReadThreadGotBytes)},
- {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitReadThreadDidExit", lldb::SBCommunication::eBroadcastBitReadThreadDidExit)},
- {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitReadThreadShouldExit", lldb::SBCommunication::eBroadcastBitReadThreadShouldExit)},
- {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitPacketAvailable", lldb::SBCommunication::eBroadcastBitPacketAvailable)},
- {SWIG_LUA_CONSTTAB_INT("SBCommunication_eAllEventBits", lldb::SBCommunication::eAllEventBits)},
- {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitProgress", lldb::SBDebugger::eBroadcastBitProgress)},
- {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitWarning", lldb::SBDebugger::eBroadcastBitWarning)},
- {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitError", lldb::SBDebugger::eBroadcastBitError)},
- {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitStateChanged", lldb::SBProcess::eBroadcastBitStateChanged)},
- {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitInterrupt", lldb::SBProcess::eBroadcastBitInterrupt)},
- {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitSTDOUT", lldb::SBProcess::eBroadcastBitSTDOUT)},
- {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitSTDERR", lldb::SBProcess::eBroadcastBitSTDERR)},
- {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitProfileData", lldb::SBProcess::eBroadcastBitProfileData)},
- {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitStructuredData", lldb::SBProcess::eBroadcastBitStructuredData)},
- {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitBreakpointChanged", lldb::SBTarget::eBroadcastBitBreakpointChanged)},
- {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitModulesLoaded", lldb::SBTarget::eBroadcastBitModulesLoaded)},
- {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitModulesUnloaded", lldb::SBTarget::eBroadcastBitModulesUnloaded)},
- {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitWatchpointChanged", lldb::SBTarget::eBroadcastBitWatchpointChanged)},
- {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitSymbolsLoaded", lldb::SBTarget::eBroadcastBitSymbolsLoaded)},
- {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitStackChanged", lldb::SBThread::eBroadcastBitStackChanged)},
- {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitThreadSuspended", lldb::SBThread::eBroadcastBitThreadSuspended)},
- {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitThreadResumed", lldb::SBThread::eBroadcastBitThreadResumed)},
- {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitSelectedFrameChanged", lldb::SBThread::eBroadcastBitSelectedFrameChanged)},
- {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitThreadSelected", lldb::SBThread::eBroadcastBitThreadSelected)},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_INVALID_CPUTYPE", ((0xFFFFFFFEu)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_MAX_NUM_OPTION_SETS", (32))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_ALL", (0xFFFFFFFFU))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_1", ((1U << 0)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_2", ((1U << 1)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_3", ((1U << 2)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_4", ((1U << 3)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_5", ((1U << 4)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_6", ((1U << 5)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_7", ((1U << 6)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_8", ((1U << 7)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_9", ((1U << 8)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_10", ((1U << 9)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_11", ((1U << 10)))},
+ {SWIG_LUA_CONSTTAB_INT("LLDB_OPT_SET_12", ((1U << 11)))},
+ {SWIG_LUA_CONSTTAB_STRING("LLDB_INVALID_ADDRESS_MASK", "18446744073709551615ULL")},
+ {SWIG_LUA_CONSTTAB_INT("eStateInvalid", (lldb::eStateInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eStateUnloaded", (lldb::eStateUnloaded))},
+ {SWIG_LUA_CONSTTAB_INT("eStateConnected", (lldb::eStateConnected))},
+ {SWIG_LUA_CONSTTAB_INT("eStateAttaching", (lldb::eStateAttaching))},
+ {SWIG_LUA_CONSTTAB_INT("eStateLaunching", (lldb::eStateLaunching))},
+ {SWIG_LUA_CONSTTAB_INT("eStateStopped", (lldb::eStateStopped))},
+ {SWIG_LUA_CONSTTAB_INT("eStateRunning", (lldb::eStateRunning))},
+ {SWIG_LUA_CONSTTAB_INT("eStateStepping", (lldb::eStateStepping))},
+ {SWIG_LUA_CONSTTAB_INT("eStateCrashed", (lldb::eStateCrashed))},
+ {SWIG_LUA_CONSTTAB_INT("eStateDetached", (lldb::eStateDetached))},
+ {SWIG_LUA_CONSTTAB_INT("eStateExited", (lldb::eStateExited))},
+ {SWIG_LUA_CONSTTAB_INT("eStateSuspended", (lldb::eStateSuspended))},
+ {SWIG_LUA_CONSTTAB_INT("kLastStateType", (lldb::kLastStateType))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagNone", (lldb::eLaunchFlagNone))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagExec", (lldb::eLaunchFlagExec))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDebug", (lldb::eLaunchFlagDebug))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagStopAtEntry", (lldb::eLaunchFlagStopAtEntry))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDisableASLR", (lldb::eLaunchFlagDisableASLR))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDisableSTDIO", (lldb::eLaunchFlagDisableSTDIO))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagLaunchInTTY", (lldb::eLaunchFlagLaunchInTTY))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagLaunchInShell", (lldb::eLaunchFlagLaunchInShell))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagLaunchInSeparateProcessGroup", (lldb::eLaunchFlagLaunchInSeparateProcessGroup))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDontSetExitStatus", (lldb::eLaunchFlagDontSetExitStatus))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagDetachOnError", (lldb::eLaunchFlagDetachOnError))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagShellExpandArguments", (lldb::eLaunchFlagShellExpandArguments))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagCloseTTYOnExit", (lldb::eLaunchFlagCloseTTYOnExit))},
+ {SWIG_LUA_CONSTTAB_INT("eLaunchFlagInheritTCCFromParent", (lldb::eLaunchFlagInheritTCCFromParent))},
+ {SWIG_LUA_CONSTTAB_INT("eOnlyThisThread", (lldb::eOnlyThisThread))},
+ {SWIG_LUA_CONSTTAB_INT("eAllThreads", (lldb::eAllThreads))},
+ {SWIG_LUA_CONSTTAB_INT("eOnlyDuringStepping", (lldb::eOnlyDuringStepping))},
+ {SWIG_LUA_CONSTTAB_INT("eByteOrderInvalid", (lldb::eByteOrderInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eByteOrderBig", (lldb::eByteOrderBig))},
+ {SWIG_LUA_CONSTTAB_INT("eByteOrderPDP", (lldb::eByteOrderPDP))},
+ {SWIG_LUA_CONSTTAB_INT("eByteOrderLittle", (lldb::eByteOrderLittle))},
+ {SWIG_LUA_CONSTTAB_INT("eEncodingInvalid", (lldb::eEncodingInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eEncodingUint", (lldb::eEncodingUint))},
+ {SWIG_LUA_CONSTTAB_INT("eEncodingSint", (lldb::eEncodingSint))},
+ {SWIG_LUA_CONSTTAB_INT("eEncodingIEEE754", (lldb::eEncodingIEEE754))},
+ {SWIG_LUA_CONSTTAB_INT("eEncodingVector", (lldb::eEncodingVector))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatDefault", (lldb::eFormatDefault))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatInvalid", (lldb::eFormatInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatBoolean", (lldb::eFormatBoolean))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatBinary", (lldb::eFormatBinary))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatBytes", (lldb::eFormatBytes))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatBytesWithASCII", (lldb::eFormatBytesWithASCII))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatChar", (lldb::eFormatChar))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatCharPrintable", (lldb::eFormatCharPrintable))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatComplex", (lldb::eFormatComplex))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatComplexFloat", (lldb::eFormatComplexFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatCString", (lldb::eFormatCString))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatDecimal", (lldb::eFormatDecimal))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatEnum", (lldb::eFormatEnum))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatHex", (lldb::eFormatHex))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatHexUppercase", (lldb::eFormatHexUppercase))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatFloat", (lldb::eFormatFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatOctal", (lldb::eFormatOctal))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatOSType", (lldb::eFormatOSType))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatUnicode16", (lldb::eFormatUnicode16))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatUnicode32", (lldb::eFormatUnicode32))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatUnsigned", (lldb::eFormatUnsigned))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatPointer", (lldb::eFormatPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfChar", (lldb::eFormatVectorOfChar))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt8", (lldb::eFormatVectorOfSInt8))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt8", (lldb::eFormatVectorOfUInt8))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt16", (lldb::eFormatVectorOfSInt16))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt16", (lldb::eFormatVectorOfUInt16))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt32", (lldb::eFormatVectorOfSInt32))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt32", (lldb::eFormatVectorOfUInt32))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfSInt64", (lldb::eFormatVectorOfSInt64))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt64", (lldb::eFormatVectorOfUInt64))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfFloat16", (lldb::eFormatVectorOfFloat16))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfFloat32", (lldb::eFormatVectorOfFloat32))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfFloat64", (lldb::eFormatVectorOfFloat64))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVectorOfUInt128", (lldb::eFormatVectorOfUInt128))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatComplexInteger", (lldb::eFormatComplexInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatCharArray", (lldb::eFormatCharArray))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatAddressInfo", (lldb::eFormatAddressInfo))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatHexFloat", (lldb::eFormatHexFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatInstruction", (lldb::eFormatInstruction))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatVoid", (lldb::eFormatVoid))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatUnicode8", (lldb::eFormatUnicode8))},
+ {SWIG_LUA_CONSTTAB_INT("kNumFormats", (lldb::kNumFormats))},
+ {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelBrief", (lldb::eDescriptionLevelBrief))},
+ {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelFull", (lldb::eDescriptionLevelFull))},
+ {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelVerbose", (lldb::eDescriptionLevelVerbose))},
+ {SWIG_LUA_CONSTTAB_INT("eDescriptionLevelInitial", (lldb::eDescriptionLevelInitial))},
+ {SWIG_LUA_CONSTTAB_INT("kNumDescriptionLevels", (lldb::kNumDescriptionLevels))},
+ {SWIG_LUA_CONSTTAB_INT("eScriptLanguageNone", (lldb::eScriptLanguageNone))},
+ {SWIG_LUA_CONSTTAB_INT("eScriptLanguagePython", (lldb::eScriptLanguagePython))},
+ {SWIG_LUA_CONSTTAB_INT("eScriptLanguageLua", (lldb::eScriptLanguageLua))},
+ {SWIG_LUA_CONSTTAB_INT("eScriptLanguageUnknown", (lldb::eScriptLanguageUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eScriptLanguageDefault", (lldb::eScriptLanguageDefault))},
+ {SWIG_LUA_CONSTTAB_INT("eRegisterKindEHFrame", (lldb::eRegisterKindEHFrame))},
+ {SWIG_LUA_CONSTTAB_INT("eRegisterKindDWARF", (lldb::eRegisterKindDWARF))},
+ {SWIG_LUA_CONSTTAB_INT("eRegisterKindGeneric", (lldb::eRegisterKindGeneric))},
+ {SWIG_LUA_CONSTTAB_INT("eRegisterKindProcessPlugin", (lldb::eRegisterKindProcessPlugin))},
+ {SWIG_LUA_CONSTTAB_INT("eRegisterKindLLDB", (lldb::eRegisterKindLLDB))},
+ {SWIG_LUA_CONSTTAB_INT("kNumRegisterKinds", (lldb::kNumRegisterKinds))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonInvalid", (lldb::eStopReasonInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonNone", (lldb::eStopReasonNone))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonTrace", (lldb::eStopReasonTrace))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonBreakpoint", (lldb::eStopReasonBreakpoint))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonWatchpoint", (lldb::eStopReasonWatchpoint))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonSignal", (lldb::eStopReasonSignal))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonException", (lldb::eStopReasonException))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonExec", (lldb::eStopReasonExec))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonPlanComplete", (lldb::eStopReasonPlanComplete))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonThreadExiting", (lldb::eStopReasonThreadExiting))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonInstrumentation", (lldb::eStopReasonInstrumentation))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonProcessorTrace", (lldb::eStopReasonProcessorTrace))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonFork", (lldb::eStopReasonFork))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonVFork", (lldb::eStopReasonVFork))},
+ {SWIG_LUA_CONSTTAB_INT("eStopReasonVForkDone", (lldb::eStopReasonVForkDone))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusInvalid", (lldb::eReturnStatusInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessFinishNoResult", (lldb::eReturnStatusSuccessFinishNoResult))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessFinishResult", (lldb::eReturnStatusSuccessFinishResult))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessContinuingNoResult", (lldb::eReturnStatusSuccessContinuingNoResult))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusSuccessContinuingResult", (lldb::eReturnStatusSuccessContinuingResult))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusStarted", (lldb::eReturnStatusStarted))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusFailed", (lldb::eReturnStatusFailed))},
+ {SWIG_LUA_CONSTTAB_INT("eReturnStatusQuit", (lldb::eReturnStatusQuit))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionCompleted", (lldb::eExpressionCompleted))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionSetupError", (lldb::eExpressionSetupError))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionParseError", (lldb::eExpressionParseError))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionDiscarded", (lldb::eExpressionDiscarded))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionInterrupted", (lldb::eExpressionInterrupted))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionHitBreakpoint", (lldb::eExpressionHitBreakpoint))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionTimedOut", (lldb::eExpressionTimedOut))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionResultUnavailable", (lldb::eExpressionResultUnavailable))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionStoppedForDebug", (lldb::eExpressionStoppedForDebug))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionThreadVanished", (lldb::eExpressionThreadVanished))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthInvalid", (lldb::eSearchDepthInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthTarget", (lldb::eSearchDepthTarget))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthModule", (lldb::eSearchDepthModule))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthCompUnit", (lldb::eSearchDepthCompUnit))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthFunction", (lldb::eSearchDepthFunction))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthBlock", (lldb::eSearchDepthBlock))},
+ {SWIG_LUA_CONSTTAB_INT("eSearchDepthAddress", (lldb::eSearchDepthAddress))},
+ {SWIG_LUA_CONSTTAB_INT("kLastSearchDepthKind", (lldb::kLastSearchDepthKind))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusSuccess", (lldb::eConnectionStatusSuccess))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusEndOfFile", (lldb::eConnectionStatusEndOfFile))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusError", (lldb::eConnectionStatusError))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusTimedOut", (lldb::eConnectionStatusTimedOut))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusNoConnection", (lldb::eConnectionStatusNoConnection))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusLostConnection", (lldb::eConnectionStatusLostConnection))},
+ {SWIG_LUA_CONSTTAB_INT("eConnectionStatusInterrupted", (lldb::eConnectionStatusInterrupted))},
+ {SWIG_LUA_CONSTTAB_INT("eErrorTypeInvalid", (lldb::eErrorTypeInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eErrorTypeGeneric", (lldb::eErrorTypeGeneric))},
+ {SWIG_LUA_CONSTTAB_INT("eErrorTypeMachKernel", (lldb::eErrorTypeMachKernel))},
+ {SWIG_LUA_CONSTTAB_INT("eErrorTypePOSIX", (lldb::eErrorTypePOSIX))},
+ {SWIG_LUA_CONSTTAB_INT("eErrorTypeExpression", (lldb::eErrorTypeExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eErrorTypeWin32", (lldb::eErrorTypeWin32))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeInvalid", (lldb::eValueTypeInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableGlobal", (lldb::eValueTypeVariableGlobal))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableStatic", (lldb::eValueTypeVariableStatic))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableArgument", (lldb::eValueTypeVariableArgument))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableLocal", (lldb::eValueTypeVariableLocal))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeRegister", (lldb::eValueTypeRegister))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeRegisterSet", (lldb::eValueTypeRegisterSet))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeConstResult", (lldb::eValueTypeConstResult))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVariableThreadLocal", (lldb::eValueTypeVariableThreadLocal))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVTable", (lldb::eValueTypeVTable))},
+ {SWIG_LUA_CONSTTAB_INT("eValueTypeVTableEntry", (lldb::eValueTypeVTableEntry))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityInvalid", (lldb::eInputReaderGranularityInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityByte", (lldb::eInputReaderGranularityByte))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityWord", (lldb::eInputReaderGranularityWord))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityLine", (lldb::eInputReaderGranularityLine))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderGranularityAll", (lldb::eInputReaderGranularityAll))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextTarget", (lldb::eSymbolContextTarget))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextModule", (lldb::eSymbolContextModule))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextCompUnit", (lldb::eSymbolContextCompUnit))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextFunction", (lldb::eSymbolContextFunction))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextBlock", (lldb::eSymbolContextBlock))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextLineEntry", (lldb::eSymbolContextLineEntry))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextSymbol", (lldb::eSymbolContextSymbol))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextEverything", (lldb::eSymbolContextEverything))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextVariable", (lldb::eSymbolContextVariable))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolContextLastItem", (lldb::eSymbolContextLastItem))},
+ {SWIG_LUA_CONSTTAB_INT("ePermissionsWritable", (lldb::ePermissionsWritable))},
+ {SWIG_LUA_CONSTTAB_INT("ePermissionsReadable", (lldb::ePermissionsReadable))},
+ {SWIG_LUA_CONSTTAB_INT("ePermissionsExecutable", (lldb::ePermissionsExecutable))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderActivate", (lldb::eInputReaderActivate))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderAsynchronousOutputWritten", (lldb::eInputReaderAsynchronousOutputWritten))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderReactivate", (lldb::eInputReaderReactivate))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderDeactivate", (lldb::eInputReaderDeactivate))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderGotToken", (lldb::eInputReaderGotToken))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderInterrupt", (lldb::eInputReaderInterrupt))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderEndOfFile", (lldb::eInputReaderEndOfFile))},
+ {SWIG_LUA_CONSTTAB_INT("eInputReaderDone", (lldb::eInputReaderDone))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeInvalidType", (lldb::eBreakpointEventTypeInvalidType))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeAdded", (lldb::eBreakpointEventTypeAdded))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeRemoved", (lldb::eBreakpointEventTypeRemoved))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeLocationsAdded", (lldb::eBreakpointEventTypeLocationsAdded))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeLocationsRemoved", (lldb::eBreakpointEventTypeLocationsRemoved))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeLocationsResolved", (lldb::eBreakpointEventTypeLocationsResolved))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeEnabled", (lldb::eBreakpointEventTypeEnabled))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeDisabled", (lldb::eBreakpointEventTypeDisabled))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeCommandChanged", (lldb::eBreakpointEventTypeCommandChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeConditionChanged", (lldb::eBreakpointEventTypeConditionChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeIgnoreChanged", (lldb::eBreakpointEventTypeIgnoreChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeThreadChanged", (lldb::eBreakpointEventTypeThreadChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointEventTypeAutoContinueChanged", (lldb::eBreakpointEventTypeAutoContinueChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeInvalidType", (lldb::eWatchpointEventTypeInvalidType))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeAdded", (lldb::eWatchpointEventTypeAdded))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeRemoved", (lldb::eWatchpointEventTypeRemoved))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeEnabled", (lldb::eWatchpointEventTypeEnabled))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeDisabled", (lldb::eWatchpointEventTypeDisabled))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeCommandChanged", (lldb::eWatchpointEventTypeCommandChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeConditionChanged", (lldb::eWatchpointEventTypeConditionChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeIgnoreChanged", (lldb::eWatchpointEventTypeIgnoreChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeThreadChanged", (lldb::eWatchpointEventTypeThreadChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointEventTypeTypeChanged", (lldb::eWatchpointEventTypeTypeChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointWriteTypeDisabled", (lldb::eWatchpointWriteTypeDisabled))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointWriteTypeAlways", (lldb::eWatchpointWriteTypeAlways))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointWriteTypeOnModify", (lldb::eWatchpointWriteTypeOnModify))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeUnknown", (lldb::eLanguageTypeUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC89", (lldb::eLanguageTypeC89))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC", (lldb::eLanguageTypeC))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAda83", (lldb::eLanguageTypeAda83))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus", (lldb::eLanguageTypeC_plus_plus))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeCobol74", (lldb::eLanguageTypeCobol74))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeCobol85", (lldb::eLanguageTypeCobol85))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran77", (lldb::eLanguageTypeFortran77))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran90", (lldb::eLanguageTypeFortran90))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypePascal83", (lldb::eLanguageTypePascal83))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeModula2", (lldb::eLanguageTypeModula2))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeJava", (lldb::eLanguageTypeJava))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC99", (lldb::eLanguageTypeC99))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAda95", (lldb::eLanguageTypeAda95))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran95", (lldb::eLanguageTypeFortran95))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypePLI", (lldb::eLanguageTypePLI))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeObjC", (lldb::eLanguageTypeObjC))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeObjC_plus_plus", (lldb::eLanguageTypeObjC_plus_plus))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeUPC", (lldb::eLanguageTypeUPC))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeD", (lldb::eLanguageTypeD))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypePython", (lldb::eLanguageTypePython))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeOpenCL", (lldb::eLanguageTypeOpenCL))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeGo", (lldb::eLanguageTypeGo))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeModula3", (lldb::eLanguageTypeModula3))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeHaskell", (lldb::eLanguageTypeHaskell))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_03", (lldb::eLanguageTypeC_plus_plus_03))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_11", (lldb::eLanguageTypeC_plus_plus_11))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeOCaml", (lldb::eLanguageTypeOCaml))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeRust", (lldb::eLanguageTypeRust))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC11", (lldb::eLanguageTypeC11))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeSwift", (lldb::eLanguageTypeSwift))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeJulia", (lldb::eLanguageTypeJulia))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeDylan", (lldb::eLanguageTypeDylan))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_14", (lldb::eLanguageTypeC_plus_plus_14))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran03", (lldb::eLanguageTypeFortran03))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran08", (lldb::eLanguageTypeFortran08))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeRenderScript", (lldb::eLanguageTypeRenderScript))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeBLISS", (lldb::eLanguageTypeBLISS))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeKotlin", (lldb::eLanguageTypeKotlin))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeZig", (lldb::eLanguageTypeZig))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeCrystal", (lldb::eLanguageTypeCrystal))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_17", (lldb::eLanguageTypeC_plus_plus_17))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_plus_plus_20", (lldb::eLanguageTypeC_plus_plus_20))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC17", (lldb::eLanguageTypeC17))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeFortran18", (lldb::eLanguageTypeFortran18))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAda2005", (lldb::eLanguageTypeAda2005))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAda2012", (lldb::eLanguageTypeAda2012))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeHIP", (lldb::eLanguageTypeHIP))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeAssembly", (lldb::eLanguageTypeAssembly))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeC_sharp", (lldb::eLanguageTypeC_sharp))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeMojo", (lldb::eLanguageTypeMojo))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageTypeMipsAssembler", (lldb::eLanguageTypeMipsAssembler))},
+ {SWIG_LUA_CONSTTAB_INT("eNumLanguageTypes", (lldb::eNumLanguageTypes))},
+ {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeAddressSanitizer", (lldb::eInstrumentationRuntimeTypeAddressSanitizer))},
+ {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeThreadSanitizer", (lldb::eInstrumentationRuntimeTypeThreadSanitizer))},
+ {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer", (lldb::eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer))},
+ {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeMainThreadChecker", (lldb::eInstrumentationRuntimeTypeMainThreadChecker))},
+ {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeSwiftRuntimeReporting", (lldb::eInstrumentationRuntimeTypeSwiftRuntimeReporting))},
+ {SWIG_LUA_CONSTTAB_INT("eInstrumentationRuntimeTypeLibsanitizersAsan", (lldb::eInstrumentationRuntimeTypeLibsanitizersAsan))},
+ {SWIG_LUA_CONSTTAB_INT("eNumInstrumentationRuntimeTypes", (lldb::eNumInstrumentationRuntimeTypes))},
+ {SWIG_LUA_CONSTTAB_INT("eNoDynamicValues", (lldb::eNoDynamicValues))},
+ {SWIG_LUA_CONSTTAB_INT("eDynamicCanRunTarget", (lldb::eDynamicCanRunTarget))},
+ {SWIG_LUA_CONSTTAB_INT("eDynamicDontRunTarget", (lldb::eDynamicDontRunTarget))},
+ {SWIG_LUA_CONSTTAB_INT("eStopShowColumnAnsiOrCaret", (lldb::eStopShowColumnAnsiOrCaret))},
+ {SWIG_LUA_CONSTTAB_INT("eStopShowColumnAnsi", (lldb::eStopShowColumnAnsi))},
+ {SWIG_LUA_CONSTTAB_INT("eStopShowColumnCaret", (lldb::eStopShowColumnCaret))},
+ {SWIG_LUA_CONSTTAB_INT("eStopShowColumnNone", (lldb::eStopShowColumnNone))},
+ {SWIG_LUA_CONSTTAB_INT("eAccessNone", (lldb::eAccessNone))},
+ {SWIG_LUA_CONSTTAB_INT("eAccessPublic", (lldb::eAccessPublic))},
+ {SWIG_LUA_CONSTTAB_INT("eAccessPrivate", (lldb::eAccessPrivate))},
+ {SWIG_LUA_CONSTTAB_INT("eAccessProtected", (lldb::eAccessProtected))},
+ {SWIG_LUA_CONSTTAB_INT("eAccessPackage", (lldb::eAccessPackage))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeAddress", (lldb::eArgTypeAddress))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeAddressOrExpression", (lldb::eArgTypeAddressOrExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeAliasName", (lldb::eArgTypeAliasName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeAliasOptions", (lldb::eArgTypeAliasOptions))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeArchitecture", (lldb::eArgTypeArchitecture))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeBoolean", (lldb::eArgTypeBoolean))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeBreakpointID", (lldb::eArgTypeBreakpointID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeBreakpointIDRange", (lldb::eArgTypeBreakpointIDRange))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeBreakpointName", (lldb::eArgTypeBreakpointName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeByteSize", (lldb::eArgTypeByteSize))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeClassName", (lldb::eArgTypeClassName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeCommandName", (lldb::eArgTypeCommandName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeCount", (lldb::eArgTypeCount))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeDescriptionVerbosity", (lldb::eArgTypeDescriptionVerbosity))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeDirectoryName", (lldb::eArgTypeDirectoryName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeDisassemblyFlavor", (lldb::eArgTypeDisassemblyFlavor))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeEndAddress", (lldb::eArgTypeEndAddress))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeExpression", (lldb::eArgTypeExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeExpressionPath", (lldb::eArgTypeExpressionPath))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeExprFormat", (lldb::eArgTypeExprFormat))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFileLineColumn", (lldb::eArgTypeFileLineColumn))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFilename", (lldb::eArgTypeFilename))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFormat", (lldb::eArgTypeFormat))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFrameIndex", (lldb::eArgTypeFrameIndex))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFullName", (lldb::eArgTypeFullName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFunctionName", (lldb::eArgTypeFunctionName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeFunctionOrSymbol", (lldb::eArgTypeFunctionOrSymbol))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeGDBFormat", (lldb::eArgTypeGDBFormat))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeHelpText", (lldb::eArgTypeHelpText))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeIndex", (lldb::eArgTypeIndex))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeLanguage", (lldb::eArgTypeLanguage))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeLineNum", (lldb::eArgTypeLineNum))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeLogCategory", (lldb::eArgTypeLogCategory))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeLogChannel", (lldb::eArgTypeLogChannel))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeMethod", (lldb::eArgTypeMethod))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeName", (lldb::eArgTypeName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeNewPathPrefix", (lldb::eArgTypeNewPathPrefix))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeNumLines", (lldb::eArgTypeNumLines))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeNumberPerLine", (lldb::eArgTypeNumberPerLine))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeOffset", (lldb::eArgTypeOffset))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeOldPathPrefix", (lldb::eArgTypeOldPathPrefix))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeOneLiner", (lldb::eArgTypeOneLiner))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePath", (lldb::eArgTypePath))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePermissionsNumber", (lldb::eArgTypePermissionsNumber))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePermissionsString", (lldb::eArgTypePermissionsString))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePid", (lldb::eArgTypePid))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePlugin", (lldb::eArgTypePlugin))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeProcessName", (lldb::eArgTypeProcessName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePythonClass", (lldb::eArgTypePythonClass))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePythonFunction", (lldb::eArgTypePythonFunction))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePythonScript", (lldb::eArgTypePythonScript))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeQueueName", (lldb::eArgTypeQueueName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRegisterName", (lldb::eArgTypeRegisterName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRegularExpression", (lldb::eArgTypeRegularExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRunArgs", (lldb::eArgTypeRunArgs))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRunMode", (lldb::eArgTypeRunMode))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeScriptedCommandSynchronicity", (lldb::eArgTypeScriptedCommandSynchronicity))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeScriptLang", (lldb::eArgTypeScriptLang))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSearchWord", (lldb::eArgTypeSearchWord))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSelector", (lldb::eArgTypeSelector))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingIndex", (lldb::eArgTypeSettingIndex))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingKey", (lldb::eArgTypeSettingKey))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingPrefix", (lldb::eArgTypeSettingPrefix))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSettingVariableName", (lldb::eArgTypeSettingVariableName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeShlibName", (lldb::eArgTypeShlibName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSourceFile", (lldb::eArgTypeSourceFile))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSortOrder", (lldb::eArgTypeSortOrder))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeStartAddress", (lldb::eArgTypeStartAddress))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSummaryString", (lldb::eArgTypeSummaryString))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSymbol", (lldb::eArgTypeSymbol))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeThreadID", (lldb::eArgTypeThreadID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeThreadIndex", (lldb::eArgTypeThreadIndex))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeThreadName", (lldb::eArgTypeThreadName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeTypeName", (lldb::eArgTypeTypeName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeUnsignedInteger", (lldb::eArgTypeUnsignedInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeUnixSignal", (lldb::eArgTypeUnixSignal))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeVarName", (lldb::eArgTypeVarName))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeValue", (lldb::eArgTypeValue))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeWidth", (lldb::eArgTypeWidth))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeNone", (lldb::eArgTypeNone))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypePlatform", (lldb::eArgTypePlatform))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeWatchpointID", (lldb::eArgTypeWatchpointID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeWatchpointIDRange", (lldb::eArgTypeWatchpointIDRange))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeWatchType", (lldb::eArgTypeWatchType))},
+ {SWIG_LUA_CONSTTAB_INT("eArgRawInput", (lldb::eArgRawInput))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeCommand", (lldb::eArgTypeCommand))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeColumnNum", (lldb::eArgTypeColumnNum))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeModuleUUID", (lldb::eArgTypeModuleUUID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSaveCoreStyle", (lldb::eArgTypeSaveCoreStyle))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeLogHandler", (lldb::eArgTypeLogHandler))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeSEDStylePair", (lldb::eArgTypeSEDStylePair))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRecognizerID", (lldb::eArgTypeRecognizerID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeConnectURL", (lldb::eArgTypeConnectURL))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeTargetID", (lldb::eArgTypeTargetID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeStopHookID", (lldb::eArgTypeStopHookID))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeCompletionType", (lldb::eArgTypeCompletionType))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRemotePath", (lldb::eArgTypeRemotePath))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeRemoteFilename", (lldb::eArgTypeRemoteFilename))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeModule", (lldb::eArgTypeModule))},
+ {SWIG_LUA_CONSTTAB_INT("eArgTypeLastArg", (lldb::eArgTypeLastArg))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeAny", (lldb::eSymbolTypeAny))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeInvalid", (lldb::eSymbolTypeInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeAbsolute", (lldb::eSymbolTypeAbsolute))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeCode", (lldb::eSymbolTypeCode))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeResolver", (lldb::eSymbolTypeResolver))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeData", (lldb::eSymbolTypeData))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeTrampoline", (lldb::eSymbolTypeTrampoline))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeRuntime", (lldb::eSymbolTypeRuntime))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeException", (lldb::eSymbolTypeException))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeSourceFile", (lldb::eSymbolTypeSourceFile))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeHeaderFile", (lldb::eSymbolTypeHeaderFile))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjectFile", (lldb::eSymbolTypeObjectFile))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeCommonBlock", (lldb::eSymbolTypeCommonBlock))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeBlock", (lldb::eSymbolTypeBlock))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeLocal", (lldb::eSymbolTypeLocal))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeParam", (lldb::eSymbolTypeParam))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeVariable", (lldb::eSymbolTypeVariable))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeVariableType", (lldb::eSymbolTypeVariableType))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeLineEntry", (lldb::eSymbolTypeLineEntry))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeLineHeader", (lldb::eSymbolTypeLineHeader))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeScopeBegin", (lldb::eSymbolTypeScopeBegin))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeScopeEnd", (lldb::eSymbolTypeScopeEnd))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeAdditional", (lldb::eSymbolTypeAdditional))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeCompiler", (lldb::eSymbolTypeCompiler))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeInstrumentation", (lldb::eSymbolTypeInstrumentation))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeUndefined", (lldb::eSymbolTypeUndefined))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjCClass", (lldb::eSymbolTypeObjCClass))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjCMetaClass", (lldb::eSymbolTypeObjCMetaClass))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeObjCIVar", (lldb::eSymbolTypeObjCIVar))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolTypeReExported", (lldb::eSymbolTypeReExported))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeInvalid", (lldb::eSectionTypeInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeCode", (lldb::eSectionTypeCode))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeContainer", (lldb::eSectionTypeContainer))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeData", (lldb::eSectionTypeData))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataCString", (lldb::eSectionTypeDataCString))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataCStringPointers", (lldb::eSectionTypeDataCStringPointers))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataSymbolAddress", (lldb::eSectionTypeDataSymbolAddress))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeData4", (lldb::eSectionTypeData4))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeData8", (lldb::eSectionTypeData8))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeData16", (lldb::eSectionTypeData16))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataPointers", (lldb::eSectionTypeDataPointers))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDebug", (lldb::eSectionTypeDebug))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeZeroFill", (lldb::eSectionTypeZeroFill))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataObjCMessageRefs", (lldb::eSectionTypeDataObjCMessageRefs))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDataObjCCFStrings", (lldb::eSectionTypeDataObjCCFStrings))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAbbrev", (lldb::eSectionTypeDWARFDebugAbbrev))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAddr", (lldb::eSectionTypeDWARFDebugAddr))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAranges", (lldb::eSectionTypeDWARFDebugAranges))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugCuIndex", (lldb::eSectionTypeDWARFDebugCuIndex))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugFrame", (lldb::eSectionTypeDWARFDebugFrame))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugInfo", (lldb::eSectionTypeDWARFDebugInfo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLine", (lldb::eSectionTypeDWARFDebugLine))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLoc", (lldb::eSectionTypeDWARFDebugLoc))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugMacInfo", (lldb::eSectionTypeDWARFDebugMacInfo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugMacro", (lldb::eSectionTypeDWARFDebugMacro))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugPubNames", (lldb::eSectionTypeDWARFDebugPubNames))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugPubTypes", (lldb::eSectionTypeDWARFDebugPubTypes))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugRanges", (lldb::eSectionTypeDWARFDebugRanges))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStr", (lldb::eSectionTypeDWARFDebugStr))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStrOffsets", (lldb::eSectionTypeDWARFDebugStrOffsets))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleNames", (lldb::eSectionTypeDWARFAppleNames))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleTypes", (lldb::eSectionTypeDWARFAppleTypes))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleNamespaces", (lldb::eSectionTypeDWARFAppleNamespaces))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFAppleObjC", (lldb::eSectionTypeDWARFAppleObjC))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFSymbolTable", (lldb::eSectionTypeELFSymbolTable))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFDynamicSymbols", (lldb::eSectionTypeELFDynamicSymbols))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFRelocationEntries", (lldb::eSectionTypeELFRelocationEntries))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeELFDynamicLinkInfo", (lldb::eSectionTypeELFDynamicLinkInfo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeEHFrame", (lldb::eSectionTypeEHFrame))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeARMexidx", (lldb::eSectionTypeARMexidx))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeARMextab", (lldb::eSectionTypeARMextab))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeCompactUnwind", (lldb::eSectionTypeCompactUnwind))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeGoSymtab", (lldb::eSectionTypeGoSymtab))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeAbsoluteAddress", (lldb::eSectionTypeAbsoluteAddress))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFGNUDebugAltLink", (lldb::eSectionTypeDWARFGNUDebugAltLink))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugTypes", (lldb::eSectionTypeDWARFDebugTypes))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugNames", (lldb::eSectionTypeDWARFDebugNames))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeOther", (lldb::eSectionTypeOther))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLineStr", (lldb::eSectionTypeDWARFDebugLineStr))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugRngLists", (lldb::eSectionTypeDWARFDebugRngLists))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLocLists", (lldb::eSectionTypeDWARFDebugLocLists))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugAbbrevDwo", (lldb::eSectionTypeDWARFDebugAbbrevDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugInfoDwo", (lldb::eSectionTypeDWARFDebugInfoDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStrDwo", (lldb::eSectionTypeDWARFDebugStrDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugStrOffsetsDwo", (lldb::eSectionTypeDWARFDebugStrOffsetsDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugTypesDwo", (lldb::eSectionTypeDWARFDebugTypesDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugRngListsDwo", (lldb::eSectionTypeDWARFDebugRngListsDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLocDwo", (lldb::eSectionTypeDWARFDebugLocDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugLocListsDwo", (lldb::eSectionTypeDWARFDebugLocListsDwo))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeDWARFDebugTuIndex", (lldb::eSectionTypeDWARFDebugTuIndex))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeCTF", (lldb::eSectionTypeCTF))},
+ {SWIG_LUA_CONSTTAB_INT("eSectionTypeSwiftModules", (lldb::eSectionTypeSwiftModules))},
+ {SWIG_LUA_CONSTTAB_INT("eEmulateInstructionOptionNone", (lldb::eEmulateInstructionOptionNone))},
+ {SWIG_LUA_CONSTTAB_INT("eEmulateInstructionOptionAutoAdvancePC", (lldb::eEmulateInstructionOptionAutoAdvancePC))},
+ {SWIG_LUA_CONSTTAB_INT("eEmulateInstructionOptionIgnoreConditions", (lldb::eEmulateInstructionOptionIgnoreConditions))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeNone", (lldb::eFunctionNameTypeNone))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeAuto", (lldb::eFunctionNameTypeAuto))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeFull", (lldb::eFunctionNameTypeFull))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeBase", (lldb::eFunctionNameTypeBase))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeMethod", (lldb::eFunctionNameTypeMethod))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeSelector", (lldb::eFunctionNameTypeSelector))},
+ {SWIG_LUA_CONSTTAB_INT("eFunctionNameTypeAny", (lldb::eFunctionNameTypeAny))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeInvalid", (lldb::eBasicTypeInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeVoid", (lldb::eBasicTypeVoid))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar", (lldb::eBasicTypeChar))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeSignedChar", (lldb::eBasicTypeSignedChar))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedChar", (lldb::eBasicTypeUnsignedChar))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeWChar", (lldb::eBasicTypeWChar))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeSignedWChar", (lldb::eBasicTypeSignedWChar))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedWChar", (lldb::eBasicTypeUnsignedWChar))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar16", (lldb::eBasicTypeChar16))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar32", (lldb::eBasicTypeChar32))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeChar8", (lldb::eBasicTypeChar8))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeShort", (lldb::eBasicTypeShort))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedShort", (lldb::eBasicTypeUnsignedShort))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeInt", (lldb::eBasicTypeInt))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedInt", (lldb::eBasicTypeUnsignedInt))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeLong", (lldb::eBasicTypeLong))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedLong", (lldb::eBasicTypeUnsignedLong))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeLongLong", (lldb::eBasicTypeLongLong))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedLongLong", (lldb::eBasicTypeUnsignedLongLong))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeInt128", (lldb::eBasicTypeInt128))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeUnsignedInt128", (lldb::eBasicTypeUnsignedInt128))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeBool", (lldb::eBasicTypeBool))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeHalf", (lldb::eBasicTypeHalf))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeFloat", (lldb::eBasicTypeFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeDouble", (lldb::eBasicTypeDouble))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeLongDouble", (lldb::eBasicTypeLongDouble))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeFloatComplex", (lldb::eBasicTypeFloatComplex))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeDoubleComplex", (lldb::eBasicTypeDoubleComplex))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeLongDoubleComplex", (lldb::eBasicTypeLongDoubleComplex))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeObjCID", (lldb::eBasicTypeObjCID))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeObjCClass", (lldb::eBasicTypeObjCClass))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeObjCSel", (lldb::eBasicTypeObjCSel))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeNullPtr", (lldb::eBasicTypeNullPtr))},
+ {SWIG_LUA_CONSTTAB_INT("eBasicTypeOther", (lldb::eBasicTypeOther))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceTypeNone", (lldb::eTraceTypeNone))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceTypeProcessorTrace", (lldb::eTraceTypeProcessorTrace))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeInvalid", (lldb::eStructuredDataTypeInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeNull", (lldb::eStructuredDataTypeNull))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeGeneric", (lldb::eStructuredDataTypeGeneric))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeArray", (lldb::eStructuredDataTypeArray))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeInteger", (lldb::eStructuredDataTypeInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeFloat", (lldb::eStructuredDataTypeFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeBoolean", (lldb::eStructuredDataTypeBoolean))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeString", (lldb::eStructuredDataTypeString))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeDictionary", (lldb::eStructuredDataTypeDictionary))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeSignedInteger", (lldb::eStructuredDataTypeSignedInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eStructuredDataTypeUnsignedInteger", (lldb::eStructuredDataTypeUnsignedInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassInvalid", (lldb::eTypeClassInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassArray", (lldb::eTypeClassArray))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassBlockPointer", (lldb::eTypeClassBlockPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassBuiltin", (lldb::eTypeClassBuiltin))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassClass", (lldb::eTypeClassClass))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassComplexFloat", (lldb::eTypeClassComplexFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassComplexInteger", (lldb::eTypeClassComplexInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassEnumeration", (lldb::eTypeClassEnumeration))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassFunction", (lldb::eTypeClassFunction))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassMemberPointer", (lldb::eTypeClassMemberPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassObjCObject", (lldb::eTypeClassObjCObject))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassObjCInterface", (lldb::eTypeClassObjCInterface))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassObjCObjectPointer", (lldb::eTypeClassObjCObjectPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassPointer", (lldb::eTypeClassPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassReference", (lldb::eTypeClassReference))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassStruct", (lldb::eTypeClassStruct))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassTypedef", (lldb::eTypeClassTypedef))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassUnion", (lldb::eTypeClassUnion))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassVector", (lldb::eTypeClassVector))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassOther", (lldb::eTypeClassOther))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeClassAny", (lldb::eTypeClassAny))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindNull", (lldb::eTemplateArgumentKindNull))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindType", (lldb::eTemplateArgumentKindType))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindDeclaration", (lldb::eTemplateArgumentKindDeclaration))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindIntegral", (lldb::eTemplateArgumentKindIntegral))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindTemplate", (lldb::eTemplateArgumentKindTemplate))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindTemplateExpansion", (lldb::eTemplateArgumentKindTemplateExpansion))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindExpression", (lldb::eTemplateArgumentKindExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindPack", (lldb::eTemplateArgumentKindPack))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindNullPtr", (lldb::eTemplateArgumentKindNullPtr))},
+ {SWIG_LUA_CONSTTAB_INT("eTemplateArgumentKindStructuralValue", (lldb::eTemplateArgumentKindStructuralValue))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatterMatchExact", (lldb::eFormatterMatchExact))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatterMatchRegex", (lldb::eFormatterMatchRegex))},
+ {SWIG_LUA_CONSTTAB_INT("eFormatterMatchCallback", (lldb::eFormatterMatchCallback))},
+ {SWIG_LUA_CONSTTAB_INT("eLastFormatterMatchType", (lldb::eLastFormatterMatchType))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionNone", (lldb::eTypeOptionNone))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionCascade", (lldb::eTypeOptionCascade))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionSkipPointers", (lldb::eTypeOptionSkipPointers))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionSkipReferences", (lldb::eTypeOptionSkipReferences))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideChildren", (lldb::eTypeOptionHideChildren))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideValue", (lldb::eTypeOptionHideValue))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionShowOneLiner", (lldb::eTypeOptionShowOneLiner))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideNames", (lldb::eTypeOptionHideNames))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionNonCacheable", (lldb::eTypeOptionNonCacheable))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionHideEmptyAggregates", (lldb::eTypeOptionHideEmptyAggregates))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeOptionFrontEndWantsDereference", (lldb::eTypeOptionFrontEndWantsDereference))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameCompareInvalid", (lldb::eFrameCompareInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameCompareUnknown", (lldb::eFrameCompareUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameCompareEqual", (lldb::eFrameCompareEqual))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameCompareSameParent", (lldb::eFrameCompareSameParent))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameCompareYounger", (lldb::eFrameCompareYounger))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameCompareOlder", (lldb::eFrameCompareOlder))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserRead", (lldb::eFilePermissionsUserRead))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserWrite", (lldb::eFilePermissionsUserWrite))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserExecute", (lldb::eFilePermissionsUserExecute))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRead", (lldb::eFilePermissionsGroupRead))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupWrite", (lldb::eFilePermissionsGroupWrite))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupExecute", (lldb::eFilePermissionsGroupExecute))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRead", (lldb::eFilePermissionsWorldRead))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldWrite", (lldb::eFilePermissionsWorldWrite))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldExecute", (lldb::eFilePermissionsWorldExecute))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserRW", (lldb::eFilePermissionsUserRW))},
+ {SWIG_LUA_CONSTTAB_INT("eFileFilePermissionsUserRX", (lldb::eFileFilePermissionsUserRX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsUserRWX", (lldb::eFilePermissionsUserRWX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRW", (lldb::eFilePermissionsGroupRW))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRX", (lldb::eFilePermissionsGroupRX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsGroupRWX", (lldb::eFilePermissionsGroupRWX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRW", (lldb::eFilePermissionsWorldRW))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRX", (lldb::eFilePermissionsWorldRX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsWorldRWX", (lldb::eFilePermissionsWorldRWX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneR", (lldb::eFilePermissionsEveryoneR))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneW", (lldb::eFilePermissionsEveryoneW))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneX", (lldb::eFilePermissionsEveryoneX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneRW", (lldb::eFilePermissionsEveryoneRW))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneRX", (lldb::eFilePermissionsEveryoneRX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsEveryoneRWX", (lldb::eFilePermissionsEveryoneRWX))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsFileDefault", (lldb::eFilePermissionsFileDefault))},
+ {SWIG_LUA_CONSTTAB_INT("eFilePermissionsDirectoryDefault", (lldb::eFilePermissionsDirectoryDefault))},
+ {SWIG_LUA_CONSTTAB_INT("eQueueItemKindUnknown", (lldb::eQueueItemKindUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eQueueItemKindFunction", (lldb::eQueueItemKindFunction))},
+ {SWIG_LUA_CONSTTAB_INT("eQueueItemKindBlock", (lldb::eQueueItemKindBlock))},
+ {SWIG_LUA_CONSTTAB_INT("eQueueKindUnknown", (lldb::eQueueKindUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eQueueKindSerial", (lldb::eQueueKindSerial))},
+ {SWIG_LUA_CONSTTAB_INT("eQueueKindConcurrent", (lldb::eQueueKindConcurrent))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationParse", (lldb::eExpressionEvaluationParse))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationIRGen", (lldb::eExpressionEvaluationIRGen))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationExecution", (lldb::eExpressionEvaluationExecution))},
+ {SWIG_LUA_CONSTTAB_INT("eExpressionEvaluationComplete", (lldb::eExpressionEvaluationComplete))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindUnknown", (lldb::eInstructionControlFlowKindUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindOther", (lldb::eInstructionControlFlowKindOther))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindCall", (lldb::eInstructionControlFlowKindCall))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindReturn", (lldb::eInstructionControlFlowKindReturn))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindJump", (lldb::eInstructionControlFlowKindJump))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindCondJump", (lldb::eInstructionControlFlowKindCondJump))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindFarCall", (lldb::eInstructionControlFlowKindFarCall))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindFarReturn", (lldb::eInstructionControlFlowKindFarReturn))},
+ {SWIG_LUA_CONSTTAB_INT("eInstructionControlFlowKindFarJump", (lldb::eInstructionControlFlowKindFarJump))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointKindWrite", (lldb::eWatchpointKindWrite))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointKindRead", (lldb::eWatchpointKindRead))},
+ {SWIG_LUA_CONSTTAB_INT("eGdbSignalBadAccess", (lldb::eGdbSignalBadAccess))},
+ {SWIG_LUA_CONSTTAB_INT("eGdbSignalBadInstruction", (lldb::eGdbSignalBadInstruction))},
+ {SWIG_LUA_CONSTTAB_INT("eGdbSignalArithmetic", (lldb::eGdbSignalArithmetic))},
+ {SWIG_LUA_CONSTTAB_INT("eGdbSignalEmulation", (lldb::eGdbSignalEmulation))},
+ {SWIG_LUA_CONSTTAB_INT("eGdbSignalSoftware", (lldb::eGdbSignalSoftware))},
+ {SWIG_LUA_CONSTTAB_INT("eGdbSignalBreakpoint", (lldb::eGdbSignalBreakpoint))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBShlibDir", (lldb::ePathTypeLLDBShlibDir))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeSupportExecutableDir", (lldb::ePathTypeSupportExecutableDir))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeHeaderDir", (lldb::ePathTypeHeaderDir))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypePythonDir", (lldb::ePathTypePythonDir))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBSystemPlugins", (lldb::ePathTypeLLDBSystemPlugins))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBUserPlugins", (lldb::ePathTypeLLDBUserPlugins))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeLLDBTempSystemDir", (lldb::ePathTypeLLDBTempSystemDir))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeGlobalLLDBTempSystemDir", (lldb::ePathTypeGlobalLLDBTempSystemDir))},
+ {SWIG_LUA_CONSTTAB_INT("ePathTypeClangDir", (lldb::ePathTypeClangDir))},
+ {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindUnknown", (lldb::eMemberFunctionKindUnknown))},
+ {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindConstructor", (lldb::eMemberFunctionKindConstructor))},
+ {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindDestructor", (lldb::eMemberFunctionKindDestructor))},
+ {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindInstanceMethod", (lldb::eMemberFunctionKindInstanceMethod))},
+ {SWIG_LUA_CONSTTAB_INT("eMemberFunctionKindStaticMethod", (lldb::eMemberFunctionKindStaticMethod))},
+ {SWIG_LUA_CONSTTAB_INT("eMatchTypeNormal", (lldb::eMatchTypeNormal))},
+ {SWIG_LUA_CONSTTAB_INT("eMatchTypeRegex", (lldb::eMatchTypeRegex))},
+ {SWIG_LUA_CONSTTAB_INT("eMatchTypeStartsWith", (lldb::eMatchTypeStartsWith))},
+ {SWIG_LUA_CONSTTAB_INT("eMatchTypeRegexInsensitive", (lldb::eMatchTypeRegexInsensitive))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeHasChildren", (lldb::eTypeHasChildren))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeHasValue", (lldb::eTypeHasValue))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsArray", (lldb::eTypeIsArray))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsBlock", (lldb::eTypeIsBlock))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsBuiltIn", (lldb::eTypeIsBuiltIn))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsClass", (lldb::eTypeIsClass))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsCPlusPlus", (lldb::eTypeIsCPlusPlus))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsEnumeration", (lldb::eTypeIsEnumeration))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsFuncPrototype", (lldb::eTypeIsFuncPrototype))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsMember", (lldb::eTypeIsMember))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsObjC", (lldb::eTypeIsObjC))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsPointer", (lldb::eTypeIsPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsReference", (lldb::eTypeIsReference))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsStructUnion", (lldb::eTypeIsStructUnion))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsTemplate", (lldb::eTypeIsTemplate))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsTypedef", (lldb::eTypeIsTypedef))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsVector", (lldb::eTypeIsVector))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsScalar", (lldb::eTypeIsScalar))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsInteger", (lldb::eTypeIsInteger))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsFloat", (lldb::eTypeIsFloat))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsComplex", (lldb::eTypeIsComplex))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeIsSigned", (lldb::eTypeIsSigned))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeInstanceIsPointer", (lldb::eTypeInstanceIsPointer))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandRequiresTarget", (lldb::eCommandRequiresTarget))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandRequiresProcess", (lldb::eCommandRequiresProcess))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandRequiresThread", (lldb::eCommandRequiresThread))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandRequiresFrame", (lldb::eCommandRequiresFrame))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandRequiresRegContext", (lldb::eCommandRequiresRegContext))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandTryTargetAPILock", (lldb::eCommandTryTargetAPILock))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandProcessMustBeLaunched", (lldb::eCommandProcessMustBeLaunched))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandProcessMustBePaused", (lldb::eCommandProcessMustBePaused))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandProcessMustBeTraced", (lldb::eCommandProcessMustBeTraced))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeSummaryCapped", (lldb::eTypeSummaryCapped))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeSummaryUncapped", (lldb::eTypeSummaryUncapped))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultSuccess", (lldb::eCommandInterpreterResultSuccess))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultInferiorCrash", (lldb::eCommandInterpreterResultInferiorCrash))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultCommandError", (lldb::eCommandInterpreterResultCommandError))},
+ {SWIG_LUA_CONSTTAB_INT("eCommandInterpreterResultQuitRequested", (lldb::eCommandInterpreterResultQuitRequested))},
+ {SWIG_LUA_CONSTTAB_INT("eSaveCoreUnspecified", (lldb::eSaveCoreUnspecified))},
+ {SWIG_LUA_CONSTTAB_INT("eSaveCoreFull", (lldb::eSaveCoreFull))},
+ {SWIG_LUA_CONSTTAB_INT("eSaveCoreDirtyOnly", (lldb::eSaveCoreDirtyOnly))},
+ {SWIG_LUA_CONSTTAB_INT("eSaveCoreStackOnly", (lldb::eSaveCoreStackOnly))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceEventDisabledSW", (lldb::eTraceEventDisabledSW))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceEventDisabledHW", (lldb::eTraceEventDisabledHW))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceEventCPUChanged", (lldb::eTraceEventCPUChanged))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceEventHWClockTick", (lldb::eTraceEventHWClockTick))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceEventSyncPoint", (lldb::eTraceEventSyncPoint))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceItemKindError", (lldb::eTraceItemKindError))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceItemKindEvent", (lldb::eTraceItemKindEvent))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceItemKindInstruction", (lldb::eTraceItemKindInstruction))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceCursorSeekTypeBeginning", (lldb::eTraceCursorSeekTypeBeginning))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceCursorSeekTypeCurrent", (lldb::eTraceCursorSeekTypeCurrent))},
+ {SWIG_LUA_CONSTTAB_INT("eTraceCursorSeekTypeEnd", (lldb::eTraceCursorSeekTypeEnd))},
+ {SWIG_LUA_CONSTTAB_INT("eDWIMPrintVerbosityNone", (lldb::eDWIMPrintVerbosityNone))},
+ {SWIG_LUA_CONSTTAB_INT("eDWIMPrintVerbosityExpression", (lldb::eDWIMPrintVerbosityExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eDWIMPrintVerbosityFull", (lldb::eDWIMPrintVerbosityFull))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchPointValueKindInvalid", (lldb::eWatchPointValueKindInvalid))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchPointValueKindVariable", (lldb::eWatchPointValueKindVariable))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchPointValueKindExpression", (lldb::eWatchPointValueKindExpression))},
+ {SWIG_LUA_CONSTTAB_INT("eNoCompletion", (lldb::eNoCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eSourceFileCompletion", (lldb::eSourceFileCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eDiskFileCompletion", (lldb::eDiskFileCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eDiskDirectoryCompletion", (lldb::eDiskDirectoryCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolCompletion", (lldb::eSymbolCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eModuleCompletion", (lldb::eModuleCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eSettingsNameCompletion", (lldb::eSettingsNameCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("ePlatformPluginCompletion", (lldb::ePlatformPluginCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eArchitectureCompletion", (lldb::eArchitectureCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eVariablePathCompletion", (lldb::eVariablePathCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eRegisterCompletion", (lldb::eRegisterCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointCompletion", (lldb::eBreakpointCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eProcessPluginCompletion", (lldb::eProcessPluginCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eDisassemblyFlavorCompletion", (lldb::eDisassemblyFlavorCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeLanguageCompletion", (lldb::eTypeLanguageCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eFrameIndexCompletion", (lldb::eFrameIndexCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eModuleUUIDCompletion", (lldb::eModuleUUIDCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eStopHookIDCompletion", (lldb::eStopHookIDCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eThreadIndexCompletion", (lldb::eThreadIndexCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eWatchpointIDCompletion", (lldb::eWatchpointIDCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eBreakpointNameCompletion", (lldb::eBreakpointNameCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eProcessIDCompletion", (lldb::eProcessIDCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eProcessNameCompletion", (lldb::eProcessNameCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eRemoteDiskFileCompletion", (lldb::eRemoteDiskFileCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eRemoteDiskDirectoryCompletion", (lldb::eRemoteDiskDirectoryCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eTypeCategoryNameCompletion", (lldb::eTypeCategoryNameCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eCustomCompletion", (lldb::eCustomCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eThreadIDCompletion", (lldb::eThreadIDCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eTerminatorCompletion", (lldb::eTerminatorCompletion))},
+ {SWIG_LUA_CONSTTAB_INT("eRefetch", (lldb::eRefetch))},
+ {SWIG_LUA_CONSTTAB_INT("eReuse", (lldb::eReuse))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolDownloadOff", (lldb::eSymbolDownloadOff))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolDownloadBackground", (lldb::eSymbolDownloadBackground))},
+ {SWIG_LUA_CONSTTAB_INT("eSymbolDownloadForeground", (lldb::eSymbolDownloadForeground))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskTypeCode", (lldb::eAddressMaskTypeCode))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskTypeData", (lldb::eAddressMaskTypeData))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskTypeAny", (lldb::eAddressMaskTypeAny))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskTypeAll", (lldb::eAddressMaskTypeAll))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskRangeLow", (lldb::eAddressMaskRangeLow))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskRangeHigh", (lldb::eAddressMaskRangeHigh))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskRangeAny", (lldb::eAddressMaskRangeAny))},
+ {SWIG_LUA_CONSTTAB_INT("eAddressMaskRangeAll", (lldb::eAddressMaskRangeAll))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProgress", (lldb::eBroadcastBitProgress))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitWarning", (lldb::eBroadcastBitWarning))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitError", (lldb::eBroadcastBitError))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastSymbolChange", (lldb::eBroadcastSymbolChange))},
+ {SWIG_LUA_CONSTTAB_INT("eBroadcastBitProgressCategory", (lldb::eBroadcastBitProgressCategory))},
+ {SWIG_LUA_CONSTTAB_INT("eSeverityError", (lldb::eSeverityError))},
+ {SWIG_LUA_CONSTTAB_INT("eSeverityWarning", (lldb::eSeverityWarning))},
+ {SWIG_LUA_CONSTTAB_INT("eSeverityInfo", (lldb::eSeverityInfo))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitThreadShouldExit", (lldb::SBCommandInterpreter::eBroadcastBitThreadShouldExit))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitResetPrompt", (lldb::SBCommandInterpreter::eBroadcastBitResetPrompt))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitQuitCommandReceived", (lldb::SBCommandInterpreter::eBroadcastBitQuitCommandReceived))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitAsynchronousOutputData", (lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommandInterpreter_eBroadcastBitAsynchronousErrorData", (lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitDisconnected", (lldb::SBCommunication::eBroadcastBitDisconnected))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitReadThreadGotBytes", (lldb::SBCommunication::eBroadcastBitReadThreadGotBytes))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitReadThreadDidExit", (lldb::SBCommunication::eBroadcastBitReadThreadDidExit))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitReadThreadShouldExit", (lldb::SBCommunication::eBroadcastBitReadThreadShouldExit))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommunication_eBroadcastBitPacketAvailable", (lldb::SBCommunication::eBroadcastBitPacketAvailable))},
+ {SWIG_LUA_CONSTTAB_INT("SBCommunication_eAllEventBits", (lldb::SBCommunication::eAllEventBits))},
+ {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitProgress", (lldb::SBDebugger::eBroadcastBitProgress))},
+ {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitWarning", (lldb::SBDebugger::eBroadcastBitWarning))},
+ {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitError", (lldb::SBDebugger::eBroadcastBitError))},
+ {SWIG_LUA_CONSTTAB_INT("SBDebugger_eBroadcastBitProgressCategory", (lldb::SBDebugger::eBroadcastBitProgressCategory))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameAda", (lldb::eLanguageNameAda))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameBLISS", (lldb::eLanguageNameBLISS))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameC", (lldb::eLanguageNameC))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameC_plus_plus", (lldb::eLanguageNameC_plus_plus))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameCobol", (lldb::eLanguageNameCobol))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameCrystal", (lldb::eLanguageNameCrystal))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameD", (lldb::eLanguageNameD))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameDylan", (lldb::eLanguageNameDylan))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameFortran", (lldb::eLanguageNameFortran))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameGo", (lldb::eLanguageNameGo))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameHaskell", (lldb::eLanguageNameHaskell))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameJava", (lldb::eLanguageNameJava))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameJulia", (lldb::eLanguageNameJulia))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameKotlin", (lldb::eLanguageNameKotlin))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameModula2", (lldb::eLanguageNameModula2))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameModula3", (lldb::eLanguageNameModula3))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameObjC", (lldb::eLanguageNameObjC))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameObjC_plus_plus", (lldb::eLanguageNameObjC_plus_plus))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameOCaml", (lldb::eLanguageNameOCaml))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameOpenCL_C", (lldb::eLanguageNameOpenCL_C))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNamePascal", (lldb::eLanguageNamePascal))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNamePLI", (lldb::eLanguageNamePLI))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNamePython", (lldb::eLanguageNamePython))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameRenderScript", (lldb::eLanguageNameRenderScript))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameRust", (lldb::eLanguageNameRust))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameSwift", (lldb::eLanguageNameSwift))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameUPC", (lldb::eLanguageNameUPC))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameZig", (lldb::eLanguageNameZig))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameAssembly", (lldb::eLanguageNameAssembly))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameC_sharp", (lldb::eLanguageNameC_sharp))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameMojo", (lldb::eLanguageNameMojo))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameGLSL", (lldb::eLanguageNameGLSL))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameGLSL_ES", (lldb::eLanguageNameGLSL_ES))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameHLSL", (lldb::eLanguageNameHLSL))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameOpenCL_CPP", (lldb::eLanguageNameOpenCL_CPP))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameCPP_for_OpenCL", (lldb::eLanguageNameCPP_for_OpenCL))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameSYCL", (lldb::eLanguageNameSYCL))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameRuby", (lldb::eLanguageNameRuby))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameMove", (lldb::eLanguageNameMove))},
+ {SWIG_LUA_CONSTTAB_INT("eLanguageNameHylo", (lldb::eLanguageNameHylo))},
+ {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitStateChanged", (lldb::SBProcess::eBroadcastBitStateChanged))},
+ {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitInterrupt", (lldb::SBProcess::eBroadcastBitInterrupt))},
+ {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitSTDOUT", (lldb::SBProcess::eBroadcastBitSTDOUT))},
+ {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitSTDERR", (lldb::SBProcess::eBroadcastBitSTDERR))},
+ {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitProfileData", (lldb::SBProcess::eBroadcastBitProfileData))},
+ {SWIG_LUA_CONSTTAB_INT("SBProcess_eBroadcastBitStructuredData", (lldb::SBProcess::eBroadcastBitStructuredData))},
+ {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitBreakpointChanged", (lldb::SBTarget::eBroadcastBitBreakpointChanged))},
+ {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitModulesLoaded", (lldb::SBTarget::eBroadcastBitModulesLoaded))},
+ {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitModulesUnloaded", (lldb::SBTarget::eBroadcastBitModulesUnloaded))},
+ {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitWatchpointChanged", (lldb::SBTarget::eBroadcastBitWatchpointChanged))},
+ {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitSymbolsLoaded", (lldb::SBTarget::eBroadcastBitSymbolsLoaded))},
+ {SWIG_LUA_CONSTTAB_INT("SBTarget_eBroadcastBitSymbolsChanged", (lldb::SBTarget::eBroadcastBitSymbolsChanged))},
+ {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitStackChanged", (lldb::SBThread::eBroadcastBitStackChanged))},
+ {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitThreadSuspended", (lldb::SBThread::eBroadcastBitThreadSuspended))},
+ {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitThreadResumed", (lldb::SBThread::eBroadcastBitThreadResumed))},
+ {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitSelectedFrameChanged", (lldb::SBThread::eBroadcastBitSelectedFrameChanged))},
+ {SWIG_LUA_CONSTTAB_INT("SBThread_eBroadcastBitThreadSelected", (lldb::SBThread::eBroadcastBitThreadSelected))},
{0,0,0,0,0,0}
};
static swig_lua_method swig_SwigModule_methods[]= {
@@ -73758,11 +81948,15 @@ static swig_lua_method swig_SwigModule_methods[]= {
{ "SBData_CreateDataFromSInt64Array", _wrap_SBData_CreateDataFromSInt64Array},
{ "SBData_CreateDataFromSInt32Array", _wrap_SBData_CreateDataFromSInt32Array},
{ "SBData_CreateDataFromDoubleArray", _wrap_SBData_CreateDataFromDoubleArray},
+ { "SBDebugger_GetBroadcasterClass", _wrap_SBDebugger_GetBroadcasterClass},
+ { "SBDebugger_SupportsLanguage", _wrap_SBDebugger_SupportsLanguage},
{ "SBDebugger_GetProgressFromEvent", _wrap_SBDebugger_GetProgressFromEvent},
+ { "SBDebugger_GetProgressDataFromEvent", _wrap_SBDebugger_GetProgressDataFromEvent},
{ "SBDebugger_GetDiagnosticFromEvent", _wrap_SBDebugger_GetDiagnosticFromEvent},
{ "SBDebugger_Initialize", _wrap_SBDebugger_Initialize},
{ "SBDebugger_InitializeWithErrorHandling", _wrap_SBDebugger_InitializeWithErrorHandling},
{ "SBDebugger_PrintStackTraceOnError", _wrap_SBDebugger_PrintStackTraceOnError},
+ { "SBDebugger_PrintDiagnosticsOnError", _wrap_SBDebugger_PrintDiagnosticsOnError},
{ "SBDebugger_Terminate", _wrap_SBDebugger_Terminate},
{ "SBDebugger_Create", _wrap_SBDebugger_Create},
{ "SBDebugger_Destroy", _wrap_SBDebugger_Destroy},
@@ -73793,6 +81987,13 @@ static swig_lua_method swig_SwigModule_methods[]= {
{ "SBHostOS_ThreadJoin", _wrap_SBHostOS_ThreadJoin},
{ "SBLanguageRuntime_GetLanguageTypeFromString", _wrap_SBLanguageRuntime_GetLanguageTypeFromString},
{ "SBLanguageRuntime_GetNameForLanguageType", _wrap_SBLanguageRuntime_GetNameForLanguageType},
+ { "SBLanguageRuntime_LanguageIsCPlusPlus", _wrap_SBLanguageRuntime_LanguageIsCPlusPlus},
+ { "SBLanguageRuntime_LanguageIsObjC", _wrap_SBLanguageRuntime_LanguageIsObjC},
+ { "SBLanguageRuntime_LanguageIsCFamily", _wrap_SBLanguageRuntime_LanguageIsCFamily},
+ { "SBLanguageRuntime_SupportsExceptionBreakpointsOnThrow", _wrap_SBLanguageRuntime_SupportsExceptionBreakpointsOnThrow},
+ { "SBLanguageRuntime_SupportsExceptionBreakpointsOnCatch", _wrap_SBLanguageRuntime_SupportsExceptionBreakpointsOnCatch},
+ { "SBLanguageRuntime_GetThrowKeywordForLanguage", _wrap_SBLanguageRuntime_GetThrowKeywordForLanguage},
+ { "SBLanguageRuntime_GetCatchKeywordForLanguage", _wrap_SBLanguageRuntime_GetCatchKeywordForLanguage},
{ "SBModule_GetNumberAllocatedModules", _wrap_SBModule_GetNumberAllocatedModules},
{ "SBModule_GarbageCollectAllocatedModules", _wrap_SBModule_GarbageCollectAllocatedModules},
{ "SBModuleSpecList_GetModuleSpecifications", _wrap_SBModuleSpecList_GetModuleSpecifications},
@@ -73807,19 +82008,21 @@ static swig_lua_method swig_SwigModule_methods[]= {
{ "SBProcess_GetStructuredDataFromEvent", _wrap_SBProcess_GetStructuredDataFromEvent},
{ "SBProcess_EventIsProcessEvent", _wrap_SBProcess_EventIsProcessEvent},
{ "SBProcess_EventIsStructuredDataEvent", _wrap_SBProcess_EventIsStructuredDataEvent},
+ { "SBProcess_GetBroadcasterClass", _wrap_SBProcess_GetBroadcasterClass},
{ "SBReproducer_Capture", _wrap_SBReproducer_Capture},
{ "SBReproducer_PassiveReplay", _wrap_SBReproducer_PassiveReplay},
{ "SBReproducer_SetAutoGenerate", _wrap_SBReproducer_SetAutoGenerate},
{ "SBReproducer_SetWorkingDirectory", _wrap_SBReproducer_SetWorkingDirectory},
- { "SBTarget_GetBroadcasterClassName", _wrap_SBTarget_GetBroadcasterClassName},
{ "SBTarget_EventIsTargetEvent", _wrap_SBTarget_EventIsTargetEvent},
{ "SBTarget_GetTargetFromEvent", _wrap_SBTarget_GetTargetFromEvent},
{ "SBTarget_GetNumModulesFromEvent", _wrap_SBTarget_GetNumModulesFromEvent},
{ "SBTarget_GetModuleAtIndexFromEvent", _wrap_SBTarget_GetModuleAtIndexFromEvent},
+ { "SBTarget_GetBroadcasterClassName", _wrap_SBTarget_GetBroadcasterClassName},
{ "SBThread_GetBroadcasterClassName", _wrap_SBThread_GetBroadcasterClassName},
{ "SBThread_EventIsThreadEvent", _wrap_SBThread_EventIsThreadEvent},
{ "SBThread_GetStackFrameFromEvent", _wrap_SBThread_GetStackFrameFromEvent},
{ "SBThread_GetThreadFromEvent", _wrap_SBThread_GetThreadFromEvent},
+ { "SBTrace_LoadTraceFromFile", _wrap_SBTrace_LoadTraceFromFile},
{ "SBTypeSummary_CreateWithSummaryString", _wrap_SBTypeSummary_CreateWithSummaryString},
{ "SBTypeSummary_CreateWithFunctionName", _wrap_SBTypeSummary_CreateWithFunctionName},
{ "SBTypeSummary_CreateWithScriptCode", _wrap_SBTypeSummary_CreateWithScriptCode},
@@ -73833,6 +82036,8 @@ static swig_lua_method swig_SwigModule_methods[]= {
static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_string,
&_wrap_class_SBAddress,
+&_wrap_class_SBAddressRange,
+&_wrap_class_SBAddressRangeList,
&_wrap_class_SBAttachInfo,
&_wrap_class_SBBlock,
&_wrap_class_SBBreakpoint,
@@ -73845,6 +82050,7 @@ static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_SBCommandReturnObject,
&_wrap_class_SBCommunication,
&_wrap_class_SBCompileUnit,
+&_wrap_class_SBSaveCoreOptions,
&_wrap_class_SBData,
&_wrap_class_SBDebugger,
&_wrap_class_SBDeclaration,
@@ -73856,6 +82062,7 @@ static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_SBFile,
&_wrap_class_SBFileSpec,
&_wrap_class_SBFileSpecList,
+&_wrap_class_SBFormat,
&_wrap_class_SBFrame,
&_wrap_class_SBFunction,
&_wrap_class_SBHostOS,
@@ -73875,11 +82082,14 @@ static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_SBPlatform,
&_wrap_class_SBProcess,
&_wrap_class_SBProcessInfo,
+&_wrap_class_SBProcessInfoList,
&_wrap_class_SBQueue,
&_wrap_class_SBQueueItem,
&_wrap_class_SBReproducer,
+&_wrap_class_SBScriptObject,
&_wrap_class_SBSection,
&_wrap_class_SBSourceManager,
+&_wrap_class_SBStatisticsOptions,
&_wrap_class_SBStream,
&_wrap_class_SBStringList,
&_wrap_class_SBStructuredData,
@@ -73894,6 +82104,7 @@ static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_SBTraceCursor,
&_wrap_class_SBTypeMember,
&_wrap_class_SBTypeMemberFunction,
+&_wrap_class_SBTypeStaticField,
&_wrap_class_SBType,
&_wrap_class_SBTypeList,
&_wrap_class_SBTypeCategory,
@@ -73910,6 +82121,7 @@ static swig_lua_class* swig_SwigModule_classes[]= {
&_wrap_class_SBValueList,
&_wrap_class_SBVariablesOptions,
&_wrap_class_SBWatchpoint,
+&_wrap_class_SBWatchpointOptions,
0
};
static swig_lua_namespace* swig_SwigModule_namespaces[] = {
@@ -73934,10 +82146,15 @@ static swig_type_info _swigt__p_bool = {"_p_bool", "bool *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_f_p_q_const__char_p_void__void = {"_p_f_p_q_const__char_p_void__void", "lldb::LogOutputCallback|void (*)(char const *,void *)", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_f_p_void__p_void = {"_p_f_p_void__p_void", "lldb::thread_func_t|void *(*)(void *)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_p_void_p_p_q_const__char__bool = {"_p_f_p_void_p_p_q_const__char__bool", "lldb::CommandOverrideCallback|bool (*)(void *,char const **)", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_f_p_void_p_q_const__void_size_t__void = {"_p_f_p_void_p_q_const__void_size_t__void", "lldb::SBCommunication::ReadThreadBytesReceived|void (*)(void *,void const *,size_t)", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "int32_t *|int_fast16_t *|int_fast32_t *|int_least32_t *|intptr_t *|lldb::break_id_t *|lldb::file_t *|lldb::pipe_t *|lldb::socket_t *|lldb::watch_id_t *|int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError = {"_p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError", "lldb::SBPlatformLocateModuleCallback|lldb::SBError (*)(void *,lldb::SBModuleSpec const &,lldb::SBFileSpec &,lldb::SBFileSpec &)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_f_unsigned_long_long_p_void__void = {"_p_f_unsigned_long_long_p_void__void", "lldb::SBDebuggerDestroyCallback|void (*)(unsigned long long,void *)", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "int32_t *|int_fast16_t *|int_fast32_t *|int_least32_t *|intptr_t *|lldb::break_id_t *|lldb::callback_token_t *|lldb::file_t *|lldb::pipe_t *|lldb::socket_t *|lldb::watch_id_t *|int *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_lldb__ConnectionStatus = {"_p_lldb__ConnectionStatus", "lldb::ConnectionStatus *|enum lldb::ConnectionStatus *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_lldb__SBAddress = {"_p_lldb__SBAddress", "lldb::SBAddress *", 0, 0, (void*)&_wrap_class_SBAddress, 0};
+static swig_type_info _swigt__p_lldb__SBAddressRange = {"_p_lldb__SBAddressRange", "lldb::SBAddressRange *", 0, 0, (void*)&_wrap_class_SBAddressRange, 0};
+static swig_type_info _swigt__p_lldb__SBAddressRangeList = {"_p_lldb__SBAddressRangeList", "lldb::SBAddressRangeList *", 0, 0, (void*)&_wrap_class_SBAddressRangeList, 0};
static swig_type_info _swigt__p_lldb__SBAttachInfo = {"_p_lldb__SBAttachInfo", "lldb::SBAttachInfo *", 0, 0, (void*)&_wrap_class_SBAttachInfo, 0};
static swig_type_info _swigt__p_lldb__SBBlock = {"_p_lldb__SBBlock", "lldb::SBBlock *", 0, 0, (void*)&_wrap_class_SBBlock, 0};
static swig_type_info _swigt__p_lldb__SBBreakpoint = {"_p_lldb__SBBreakpoint", "lldb::SBBreakpoint *", 0, 0, (void*)&_wrap_class_SBBreakpoint, 0};
@@ -73961,6 +82178,7 @@ static swig_type_info _swigt__p_lldb__SBExpressionOptions = {"_p_lldb__SBExpress
static swig_type_info _swigt__p_lldb__SBFile = {"_p_lldb__SBFile", "lldb::SBFile *", 0, 0, (void*)&_wrap_class_SBFile, 0};
static swig_type_info _swigt__p_lldb__SBFileSpec = {"_p_lldb__SBFileSpec", "lldb::SBFileSpec *", 0, 0, (void*)&_wrap_class_SBFileSpec, 0};
static swig_type_info _swigt__p_lldb__SBFileSpecList = {"_p_lldb__SBFileSpecList", "lldb::SBFileSpecList *", 0, 0, (void*)&_wrap_class_SBFileSpecList, 0};
+static swig_type_info _swigt__p_lldb__SBFormat = {"_p_lldb__SBFormat", "lldb::SBFormat *", 0, 0, (void*)&_wrap_class_SBFormat, 0};
static swig_type_info _swigt__p_lldb__SBFrame = {"_p_lldb__SBFrame", "lldb::SBFrame *", 0, 0, (void*)&_wrap_class_SBFrame, 0};
static swig_type_info _swigt__p_lldb__SBFunction = {"_p_lldb__SBFunction", "lldb::SBFunction *", 0, 0, (void*)&_wrap_class_SBFunction, 0};
static swig_type_info _swigt__p_lldb__SBHostOS = {"_p_lldb__SBHostOS", "lldb::SBHostOS *", 0, 0, (void*)&_wrap_class_SBHostOS, 0};
@@ -73980,11 +82198,15 @@ static swig_type_info _swigt__p_lldb__SBPlatformConnectOptions = {"_p_lldb__SBPl
static swig_type_info _swigt__p_lldb__SBPlatformShellCommand = {"_p_lldb__SBPlatformShellCommand", "lldb::SBPlatformShellCommand *", 0, 0, (void*)&_wrap_class_SBPlatformShellCommand, 0};
static swig_type_info _swigt__p_lldb__SBProcess = {"_p_lldb__SBProcess", "lldb::SBProcess *", 0, 0, (void*)&_wrap_class_SBProcess, 0};
static swig_type_info _swigt__p_lldb__SBProcessInfo = {"_p_lldb__SBProcessInfo", "lldb::SBProcessInfo *", 0, 0, (void*)&_wrap_class_SBProcessInfo, 0};
+static swig_type_info _swigt__p_lldb__SBProcessInfoList = {"_p_lldb__SBProcessInfoList", "lldb::SBProcessInfoList *", 0, 0, (void*)&_wrap_class_SBProcessInfoList, 0};
static swig_type_info _swigt__p_lldb__SBQueue = {"_p_lldb__SBQueue", "lldb::SBQueue *", 0, 0, (void*)&_wrap_class_SBQueue, 0};
static swig_type_info _swigt__p_lldb__SBQueueItem = {"_p_lldb__SBQueueItem", "lldb::SBQueueItem *", 0, 0, (void*)&_wrap_class_SBQueueItem, 0};
static swig_type_info _swigt__p_lldb__SBReproducer = {"_p_lldb__SBReproducer", "lldb::SBReproducer *", 0, 0, (void*)&_wrap_class_SBReproducer, 0};
+static swig_type_info _swigt__p_lldb__SBSaveCoreOptions = {"_p_lldb__SBSaveCoreOptions", "lldb::SBSaveCoreOptions *", 0, 0, (void*)&_wrap_class_SBSaveCoreOptions, 0};
+static swig_type_info _swigt__p_lldb__SBScriptObject = {"_p_lldb__SBScriptObject", "lldb::SBScriptObject *", 0, 0, (void*)&_wrap_class_SBScriptObject, 0};
static swig_type_info _swigt__p_lldb__SBSection = {"_p_lldb__SBSection", "lldb::SBSection *", 0, 0, (void*)&_wrap_class_SBSection, 0};
static swig_type_info _swigt__p_lldb__SBSourceManager = {"_p_lldb__SBSourceManager", "lldb::SBSourceManager *", 0, 0, (void*)&_wrap_class_SBSourceManager, 0};
+static swig_type_info _swigt__p_lldb__SBStatisticsOptions = {"_p_lldb__SBStatisticsOptions", "lldb::SBStatisticsOptions *", 0, 0, (void*)&_wrap_class_SBStatisticsOptions, 0};
static swig_type_info _swigt__p_lldb__SBStream = {"_p_lldb__SBStream", "lldb::SBStream *", 0, 0, (void*)&_wrap_class_SBStream, 0};
static swig_type_info _swigt__p_lldb__SBStringList = {"_p_lldb__SBStringList", "lldb::SBStringList *", 0, 0, (void*)&_wrap_class_SBStringList, 0};
static swig_type_info _swigt__p_lldb__SBStructuredData = {"_p_lldb__SBStructuredData", "lldb::SBStructuredData *", 0, 0, (void*)&_wrap_class_SBStructuredData, 0};
@@ -74007,6 +82229,7 @@ static swig_type_info _swigt__p_lldb__SBTypeList = {"_p_lldb__SBTypeList", "lldb
static swig_type_info _swigt__p_lldb__SBTypeMember = {"_p_lldb__SBTypeMember", "lldb::SBTypeMember *", 0, 0, (void*)&_wrap_class_SBTypeMember, 0};
static swig_type_info _swigt__p_lldb__SBTypeMemberFunction = {"_p_lldb__SBTypeMemberFunction", "lldb::SBTypeMemberFunction *", 0, 0, (void*)&_wrap_class_SBTypeMemberFunction, 0};
static swig_type_info _swigt__p_lldb__SBTypeNameSpecifier = {"_p_lldb__SBTypeNameSpecifier", "lldb::SBTypeNameSpecifier *", 0, 0, (void*)&_wrap_class_SBTypeNameSpecifier, 0};
+static swig_type_info _swigt__p_lldb__SBTypeStaticField = {"_p_lldb__SBTypeStaticField", "lldb::SBTypeStaticField *", 0, 0, (void*)&_wrap_class_SBTypeStaticField, 0};
static swig_type_info _swigt__p_lldb__SBTypeSummary = {"_p_lldb__SBTypeSummary", "lldb::SBTypeSummary *", 0, 0, (void*)&_wrap_class_SBTypeSummary, 0};
static swig_type_info _swigt__p_lldb__SBTypeSummaryOptions = {"_p_lldb__SBTypeSummaryOptions", "lldb::SBTypeSummaryOptions *", 0, 0, (void*)&_wrap_class_SBTypeSummaryOptions, 0};
static swig_type_info _swigt__p_lldb__SBTypeSynthetic = {"_p_lldb__SBTypeSynthetic", "lldb::SBTypeSynthetic *", 0, 0, (void*)&_wrap_class_SBTypeSynthetic, 0};
@@ -74015,6 +82238,7 @@ static swig_type_info _swigt__p_lldb__SBValue = {"_p_lldb__SBValue", "lldb::SBVa
static swig_type_info _swigt__p_lldb__SBValueList = {"_p_lldb__SBValueList", "lldb::SBValueList *", 0, 0, (void*)&_wrap_class_SBValueList, 0};
static swig_type_info _swigt__p_lldb__SBVariablesOptions = {"_p_lldb__SBVariablesOptions", "lldb::SBVariablesOptions *", 0, 0, (void*)&_wrap_class_SBVariablesOptions, 0};
static swig_type_info _swigt__p_lldb__SBWatchpoint = {"_p_lldb__SBWatchpoint", "lldb::SBWatchpoint *", 0, 0, (void*)&_wrap_class_SBWatchpoint, 0};
+static swig_type_info _swigt__p_lldb__SBWatchpointOptions = {"_p_lldb__SBWatchpointOptions", "lldb::SBWatchpointOptions *", 0, 0, (void*)&_wrap_class_SBWatchpointOptions, 0};
static swig_type_info _swigt__p_long_double = {"_p_long_double", "long double *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_long_long = {"_p_long_long", "int64_t *|int_fast64_t *|int_least64_t *|intmax_t *|long long *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_void = {"_p_p_void", "lldb::thread_result_t *|void **", 0, 0, (void*)0, 0};
@@ -74046,6 +82270,7 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Event_t = {"_p_st
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ExecutionContextRef_t = {"_p_std__shared_ptrT_lldb_private__ExecutionContextRef_t", "lldb::ExecutionContextRefSP *|std::shared_ptr< lldb_private::ExecutionContextRef > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ExpressionVariable_t = {"_p_std__shared_ptrT_lldb_private__ExpressionVariable_t", "lldb::ExpressionVariableSP *|std::shared_ptr< lldb_private::ExpressionVariable > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__File_t = {"_p_std__shared_ptrT_lldb_private__File_t", "lldb::FileSP *|std::shared_ptr< lldb_private::File > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t = {"_p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t", "lldb::FormatEntrySP *|std::shared_ptr< lldb_private::FormatEntity::Entry > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__FuncUnwinders_t = {"_p_std__shared_ptrT_lldb_private__FuncUnwinders_t", "lldb::FuncUnwindersSP *|std::shared_ptr< lldb_private::FuncUnwinders > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Function_t = {"_p_std__shared_ptrT_lldb_private__Function_t", "lldb::FunctionSP *|std::shared_ptr< lldb_private::Function > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__IOHandler_t = {"_p_std__shared_ptrT_lldb_private__IOHandler_t", "lldb::IOHandlerSP *|std::shared_ptr< lldb_private::IOHandler > *", 0, 0, (void*)0, 0};
@@ -74063,6 +82288,7 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Module_t = {"_p_s
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ObjectContainer_t = {"_p_std__shared_ptrT_lldb_private__ObjectContainer_t", "lldb::ObjectContainerSP *|std::shared_ptr< lldb_private::ObjectContainer > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t = {"_p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t", "lldb::ObjectFileJITDelegateSP *|std::shared_ptr< lldb_private::ObjectFileJITDelegate > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ObjectFile_t = {"_p_std__shared_ptrT_lldb_private__ObjectFile_t", "lldb::ObjectFileSP *|std::shared_ptr< lldb_private::ObjectFile > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t = {"_p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t", "lldb::OperatingSystemInterfaceSP *|std::shared_ptr< lldb_private::OperatingSystemInterface > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__OptionValueProperties_t = {"_p_std__shared_ptrT_lldb_private__OptionValueProperties_t", "lldb::OptionValuePropertiesSP *|std::shared_ptr< lldb_private::OptionValueProperties > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__OptionValue_t = {"_p_std__shared_ptrT_lldb_private__OptionValue_t", "lldb::OptionValueSP *|std::shared_ptr< lldb_private::OptionValue > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Platform_t = {"_p_std__shared_ptrT_lldb_private__Platform_t", "lldb::PlatformSP *|std::shared_ptr< lldb_private::Platform > *", 0, 0, (void*)0, 0};
@@ -74075,11 +82301,14 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__REPL_t = {"_p_std
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t = {"_p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t", "lldb::RecognizedStackFrameSP *|std::shared_ptr< lldb_private::RecognizedStackFrame > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t = {"_p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t", "lldb::RegisterCheckpointSP *|std::shared_ptr< lldb_private::RegisterCheckpoint > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__RegisterContext_t = {"_p_std__shared_ptrT_lldb_private__RegisterContext_t", "lldb::RegisterContextSP *|std::shared_ptr< lldb_private::RegisterContext > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t = {"_p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t", "lldb::RegisterTypeBuilderSP *|std::shared_ptr< lldb_private::RegisterTypeBuilder > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__RegularExpression_t = {"_p_std__shared_ptrT_lldb_private__RegularExpression_t", "lldb::RegularExpressionSP *|std::shared_ptr< lldb_private::RegularExpression > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ScriptInterpreter_t = {"_p_std__shared_ptrT_lldb_private__ScriptInterpreter_t", "lldb::ScriptInterpreterSP *|std::shared_ptr< lldb_private::ScriptInterpreter > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t = {"_p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t", "lldb::ScriptSummaryFormatSP *|std::shared_ptr< lldb_private::ScriptSummaryFormat > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ScriptedMetadata_t = {"_p_std__shared_ptrT_lldb_private__ScriptedMetadata_t", "lldb::ScriptedMetadataSP *|std::shared_ptr< lldb_private::ScriptedMetadata > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t = {"_p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t", "lldb::ScriptedSyntheticChildrenSP *|std::shared_ptr< lldb_private::ScriptedSyntheticChildren > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t = {"_p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t", "lldb::ScriptedThreadInterfaceSP *|std::shared_ptr< lldb_private::ScriptedThreadInterface > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t = {"_p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t", "lldb::ScriptedThreadPlanInterfaceSP *|std::shared_ptr< lldb_private::ScriptedThreadPlanInterface > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__SearchFilter_t = {"_p_std__shared_ptrT_lldb_private__SearchFilter_t", "lldb::SearchFilterSP *|std::shared_ptr< lldb_private::SearchFilter > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__SectionLoadList_t = {"_p_std__shared_ptrT_lldb_private__SectionLoadList_t", "lldb::SectionLoadListSP *|std::shared_ptr< lldb_private::SectionLoadList > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Section_t = {"_p_std__shared_ptrT_lldb_private__Section_t", "lldb::SectionSP *|std::shared_ptr< lldb_private::Section > *", 0, 0, (void*)0, 0};
@@ -74091,6 +82320,7 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__StreamFile_t = {"
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Stream_t = {"_p_std__shared_ptrT_lldb_private__Stream_t", "lldb::StreamSP *|std::shared_ptr< lldb_private::Stream > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__StringSummaryFormat_t = {"_p_std__shared_ptrT_lldb_private__StringSummaryFormat_t", "lldb::StringTypeSummaryImplSP *|std::shared_ptr< lldb_private::StringSummaryFormat > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t = {"_p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t", "lldb::StructuredDataPluginSP *|std::shared_ptr< lldb_private::StructuredDataPlugin > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__SupportFile_t = {"_p_std__shared_ptrT_lldb_private__SupportFile_t", "lldb::SupportFileSP *|std::shared_ptr< lldb_private::SupportFile > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t = {"_p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t", "lldb::SymbolContextSpecifierSP *|std::shared_ptr< lldb_private::SymbolContextSpecifier > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__SymbolFileType_t = {"_p_std__shared_ptrT_lldb_private__SymbolFileType_t", "lldb::SymbolFileTypeSP *|std::shared_ptr< lldb_private::SymbolFileType > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t = {"_p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t", "lldb::SyntheticChildrenFrontEndSP *|std::shared_ptr< lldb_private::SyntheticChildrenFrontEnd > *", 0, 0, (void*)0, 0};
@@ -74124,9 +82354,11 @@ static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__ValueObject_t = {
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Value_t = {"_p_std__shared_ptrT_lldb_private__Value_t", "lldb::ValueSP *|std::shared_ptr< lldb_private::Value > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__VariableList_t = {"_p_std__shared_ptrT_lldb_private__VariableList_t", "lldb::VariableListSP *|std::shared_ptr< lldb_private::VariableList > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Variable_t = {"_p_std__shared_ptrT_lldb_private__Variable_t", "lldb::VariableSP *|std::shared_ptr< lldb_private::Variable > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__WatchpointResource_t = {"_p_std__shared_ptrT_lldb_private__WatchpointResource_t", "lldb::WatchpointResourceSP *|std::shared_ptr< lldb_private::WatchpointResource > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__Watchpoint_t = {"_p_std__shared_ptrT_lldb_private__Watchpoint_t", "lldb::WatchpointSP *|std::shared_ptr< lldb_private::Watchpoint > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t = {"_p_std__shared_ptrT_lldb_private__WritableDataBuffer_t", "lldb::WritableDataBufferSP *|std::shared_ptr< lldb_private::WritableDataBuffer > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)&_wrap_class_string, 0};
+static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__AddressRange_t = {"_p_std__unique_ptrT_lldb_private__AddressRange_t", "lldb::AddressRangeUP *|std::unique_ptr< lldb_private::AddressRange > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t = {"_p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t", "lldb::DynamicCheckerFunctionsUP *|std::unique_ptr< lldb_private::DynamicCheckerFunctions > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__DynamicLoader_t = {"_p_std__unique_ptrT_lldb_private__DynamicLoader_t", "lldb::DynamicLoaderUP *|std::unique_ptr< lldb_private::DynamicLoader > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__unique_ptrT_lldb_private__File_t = {"_p_std__unique_ptrT_lldb_private__File_t", "lldb::FileUP *|std::unique_ptr< lldb_private::File > *", 0, 0, (void*)0, 0};
@@ -74162,20 +82394,25 @@ static swig_type_info _swigt__p_std__weak_ptrT_lldb_private__TypeSystem_t = {"_p
static swig_type_info _swigt__p_std__weak_ptrT_lldb_private__Type_t = {"_p_std__weak_ptrT_lldb_private__Type_t", "lldb::TypeWP *|std::weak_ptr< lldb_private::Type > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_std__weak_ptrT_lldb_private__UnixSignals_t = {"_p_std__weak_ptrT_lldb_private__UnixSignals_t", "lldb::UnixSignalsWP *|std::weak_ptr< lldb_private::UnixSignals > *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "uint8_t *|uint_fast8_t *|uint_least8_t *|unsigned char *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "lldb::cpu_id_t *|uint32_t *|uint_fast16_t *|uint_fast32_t *|uint_least32_t *|uintptr_t *|unsigned int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "lldb::cpu_id_t *|lldb::wp_resource_id_t *|uint32_t *|uint_fast16_t *|uint_fast32_t *|uint_least32_t *|uintptr_t *|unsigned int *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "lldb::addr_t *|lldb::offset_t *|lldb::pid_t *|lldb::process_t *|lldb::queue_id_t *|lldb::tid_t *|lldb::user_id_t *|uint64_t *|uint_fast64_t *|uint_least64_t *|uintmax_t *|unsigned long long *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "uint16_t *|uint_least16_t *|unsigned short *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_void = {"_p_void", "lldb::ScriptObjectPtr|void *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = {
&_swigt__p_bool,
&_swigt__p_double,
&_swigt__p_f_p_q_const__char_p_void__void,
&_swigt__p_f_p_void__p_void,
+ &_swigt__p_f_p_void_p_p_q_const__char__bool,
&_swigt__p_f_p_void_p_q_const__void_size_t__void,
+ &_swigt__p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError,
+ &_swigt__p_f_unsigned_long_long_p_void__void,
&_swigt__p_int,
&_swigt__p_lldb__ConnectionStatus,
&_swigt__p_lldb__SBAddress,
+ &_swigt__p_lldb__SBAddressRange,
+ &_swigt__p_lldb__SBAddressRangeList,
&_swigt__p_lldb__SBAttachInfo,
&_swigt__p_lldb__SBBlock,
&_swigt__p_lldb__SBBreakpoint,
@@ -74199,6 +82436,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_lldb__SBFile,
&_swigt__p_lldb__SBFileSpec,
&_swigt__p_lldb__SBFileSpecList,
+ &_swigt__p_lldb__SBFormat,
&_swigt__p_lldb__SBFrame,
&_swigt__p_lldb__SBFunction,
&_swigt__p_lldb__SBHostOS,
@@ -74218,11 +82456,15 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_lldb__SBPlatformShellCommand,
&_swigt__p_lldb__SBProcess,
&_swigt__p_lldb__SBProcessInfo,
+ &_swigt__p_lldb__SBProcessInfoList,
&_swigt__p_lldb__SBQueue,
&_swigt__p_lldb__SBQueueItem,
&_swigt__p_lldb__SBReproducer,
+ &_swigt__p_lldb__SBSaveCoreOptions,
+ &_swigt__p_lldb__SBScriptObject,
&_swigt__p_lldb__SBSection,
&_swigt__p_lldb__SBSourceManager,
+ &_swigt__p_lldb__SBStatisticsOptions,
&_swigt__p_lldb__SBStream,
&_swigt__p_lldb__SBStringList,
&_swigt__p_lldb__SBStructuredData,
@@ -74245,6 +82487,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_lldb__SBTypeMember,
&_swigt__p_lldb__SBTypeMemberFunction,
&_swigt__p_lldb__SBTypeNameSpecifier,
+ &_swigt__p_lldb__SBTypeStaticField,
&_swigt__p_lldb__SBTypeSummary,
&_swigt__p_lldb__SBTypeSummaryOptions,
&_swigt__p_lldb__SBTypeSynthetic,
@@ -74253,6 +82496,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_lldb__SBValueList,
&_swigt__p_lldb__SBVariablesOptions,
&_swigt__p_lldb__SBWatchpoint,
+ &_swigt__p_lldb__SBWatchpointOptions,
&_swigt__p_long_double,
&_swigt__p_long_long,
&_swigt__p_p_void,
@@ -74284,6 +82528,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_std__shared_ptrT_lldb_private__ExecutionContextRef_t,
&_swigt__p_std__shared_ptrT_lldb_private__ExpressionVariable_t,
&_swigt__p_std__shared_ptrT_lldb_private__File_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t,
&_swigt__p_std__shared_ptrT_lldb_private__FuncUnwinders_t,
&_swigt__p_std__shared_ptrT_lldb_private__Function_t,
&_swigt__p_std__shared_ptrT_lldb_private__IOHandler_t,
@@ -74301,6 +82546,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_std__shared_ptrT_lldb_private__ObjectContainer_t,
&_swigt__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t,
&_swigt__p_std__shared_ptrT_lldb_private__ObjectFile_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t,
&_swigt__p_std__shared_ptrT_lldb_private__OptionValueProperties_t,
&_swigt__p_std__shared_ptrT_lldb_private__OptionValue_t,
&_swigt__p_std__shared_ptrT_lldb_private__Platform_t,
@@ -74313,11 +82559,14 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t,
&_swigt__p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t,
&_swigt__p_std__shared_ptrT_lldb_private__RegisterContext_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t,
&_swigt__p_std__shared_ptrT_lldb_private__RegularExpression_t,
&_swigt__p_std__shared_ptrT_lldb_private__ScriptInterpreter_t,
&_swigt__p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__ScriptedMetadata_t,
&_swigt__p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t,
&_swigt__p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t,
&_swigt__p_std__shared_ptrT_lldb_private__SearchFilter_t,
&_swigt__p_std__shared_ptrT_lldb_private__SectionLoadList_t,
&_swigt__p_std__shared_ptrT_lldb_private__Section_t,
@@ -74329,6 +82578,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_std__shared_ptrT_lldb_private__Stream_t,
&_swigt__p_std__shared_ptrT_lldb_private__StringSummaryFormat_t,
&_swigt__p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__SupportFile_t,
&_swigt__p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t,
&_swigt__p_std__shared_ptrT_lldb_private__SymbolFileType_t,
&_swigt__p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t,
@@ -74362,9 +82612,11 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_std__shared_ptrT_lldb_private__Value_t,
&_swigt__p_std__shared_ptrT_lldb_private__VariableList_t,
&_swigt__p_std__shared_ptrT_lldb_private__Variable_t,
+ &_swigt__p_std__shared_ptrT_lldb_private__WatchpointResource_t,
&_swigt__p_std__shared_ptrT_lldb_private__Watchpoint_t,
&_swigt__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t,
&_swigt__p_std__string,
+ &_swigt__p_std__unique_ptrT_lldb_private__AddressRange_t,
&_swigt__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t,
&_swigt__p_std__unique_ptrT_lldb_private__DynamicLoader_t,
&_swigt__p_std__unique_ptrT_lldb_private__File_t,
@@ -74410,10 +82662,15 @@ static swig_cast_info _swigc__p_bool[] = { {&_swigt__p_bool, 0, 0, 0},{0, 0, 0,
static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_f_p_q_const__char_p_void__void[] = { {&_swigt__p_f_p_q_const__char_p_void__void, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_f_p_void__p_void[] = { {&_swigt__p_f_p_void__p_void, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_p_void_p_p_q_const__char__bool[] = { {&_swigt__p_f_p_void_p_p_q_const__char__bool, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_f_p_void_p_q_const__void_size_t__void[] = { {&_swigt__p_f_p_void_p_q_const__void_size_t__void, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError[] = { {&_swigt__p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_f_unsigned_long_long_p_void__void[] = { {&_swigt__p_f_unsigned_long_long_p_void__void, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__ConnectionStatus[] = { {&_swigt__p_lldb__ConnectionStatus, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBAddress[] = { {&_swigt__p_lldb__SBAddress, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBAddressRange[] = { {&_swigt__p_lldb__SBAddressRange, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBAddressRangeList[] = { {&_swigt__p_lldb__SBAddressRangeList, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBAttachInfo[] = { {&_swigt__p_lldb__SBAttachInfo, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBBlock[] = { {&_swigt__p_lldb__SBBlock, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBBreakpoint[] = { {&_swigt__p_lldb__SBBreakpoint, 0, 0, 0},{0, 0, 0, 0}};
@@ -74437,6 +82694,7 @@ static swig_cast_info _swigc__p_lldb__SBExpressionOptions[] = { {&_swigt__p_lld
static swig_cast_info _swigc__p_lldb__SBFile[] = { {&_swigt__p_lldb__SBFile, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBFileSpec[] = { {&_swigt__p_lldb__SBFileSpec, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBFileSpecList[] = { {&_swigt__p_lldb__SBFileSpecList, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBFormat[] = { {&_swigt__p_lldb__SBFormat, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBFrame[] = { {&_swigt__p_lldb__SBFrame, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBFunction[] = { {&_swigt__p_lldb__SBFunction, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBHostOS[] = { {&_swigt__p_lldb__SBHostOS, 0, 0, 0},{0, 0, 0, 0}};
@@ -74456,11 +82714,15 @@ static swig_cast_info _swigc__p_lldb__SBPlatformConnectOptions[] = { {&_swigt__
static swig_cast_info _swigc__p_lldb__SBPlatformShellCommand[] = { {&_swigt__p_lldb__SBPlatformShellCommand, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBProcess[] = { {&_swigt__p_lldb__SBProcess, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBProcessInfo[] = { {&_swigt__p_lldb__SBProcessInfo, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBProcessInfoList[] = { {&_swigt__p_lldb__SBProcessInfoList, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBQueue[] = { {&_swigt__p_lldb__SBQueue, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBQueueItem[] = { {&_swigt__p_lldb__SBQueueItem, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBReproducer[] = { {&_swigt__p_lldb__SBReproducer, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBSaveCoreOptions[] = { {&_swigt__p_lldb__SBSaveCoreOptions, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBScriptObject[] = { {&_swigt__p_lldb__SBScriptObject, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBSection[] = { {&_swigt__p_lldb__SBSection, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBSourceManager[] = { {&_swigt__p_lldb__SBSourceManager, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBStatisticsOptions[] = { {&_swigt__p_lldb__SBStatisticsOptions, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBStream[] = { {&_swigt__p_lldb__SBStream, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBStringList[] = { {&_swigt__p_lldb__SBStringList, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBStructuredData[] = { {&_swigt__p_lldb__SBStructuredData, 0, 0, 0},{0, 0, 0, 0}};
@@ -74483,6 +82745,7 @@ static swig_cast_info _swigc__p_lldb__SBTypeList[] = { {&_swigt__p_lldb__SBType
static swig_cast_info _swigc__p_lldb__SBTypeMember[] = { {&_swigt__p_lldb__SBTypeMember, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBTypeMemberFunction[] = { {&_swigt__p_lldb__SBTypeMemberFunction, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBTypeNameSpecifier[] = { {&_swigt__p_lldb__SBTypeNameSpecifier, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBTypeStaticField[] = { {&_swigt__p_lldb__SBTypeStaticField, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBTypeSummary[] = { {&_swigt__p_lldb__SBTypeSummary, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBTypeSummaryOptions[] = { {&_swigt__p_lldb__SBTypeSummaryOptions, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBTypeSynthetic[] = { {&_swigt__p_lldb__SBTypeSynthetic, 0, 0, 0},{0, 0, 0, 0}};
@@ -74491,6 +82754,7 @@ static swig_cast_info _swigc__p_lldb__SBValue[] = { {&_swigt__p_lldb__SBValue,
static swig_cast_info _swigc__p_lldb__SBValueList[] = { {&_swigt__p_lldb__SBValueList, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBVariablesOptions[] = { {&_swigt__p_lldb__SBVariablesOptions, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_lldb__SBWatchpoint[] = { {&_swigt__p_lldb__SBWatchpoint, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_lldb__SBWatchpointOptions[] = { {&_swigt__p_lldb__SBWatchpointOptions, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_long_double[] = { {&_swigt__p_long_double, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -74522,6 +82786,7 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Event_t[] = { {&
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ExecutionContextRef_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ExecutionContextRef_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ExpressionVariable_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ExpressionVariable_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__File_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__File_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__FuncUnwinders_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__FuncUnwinders_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Function_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Function_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__IOHandler_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__IOHandler_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -74539,6 +82804,7 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Module_t[] = { {
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ObjectContainer_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ObjectContainer_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ObjectFile_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ObjectFile_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__OptionValueProperties_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__OptionValueProperties_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__OptionValue_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__OptionValue_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Platform_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Platform_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -74551,11 +82817,14 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__REPL_t[] = { {&_
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__RegisterContext_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__RegisterContext_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__RegularExpression_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__RegularExpression_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ScriptInterpreter_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ScriptInterpreter_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ScriptedMetadata_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ScriptedMetadata_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__SearchFilter_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__SearchFilter_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__SectionLoadList_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__SectionLoadList_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Section_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Section_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -74567,6 +82836,7 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__StreamFile_t[] =
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Stream_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Stream_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__StringSummaryFormat_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__StringSummaryFormat_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__SupportFile_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__SupportFile_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__SymbolFileType_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__SymbolFileType_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -74600,9 +82870,11 @@ static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__ValueObject_t[] =
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Value_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Value_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__VariableList_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__VariableList_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Variable_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Variable_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__WatchpointResource_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__WatchpointResource_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__Watchpoint_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__Watchpoint_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t[] = { {&_swigt__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__AddressRange_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__AddressRange_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__DynamicLoader_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__DynamicLoader_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_std__unique_ptrT_lldb_private__File_t[] = { {&_swigt__p_std__unique_ptrT_lldb_private__File_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -74648,10 +82920,15 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_double,
_swigc__p_f_p_q_const__char_p_void__void,
_swigc__p_f_p_void__p_void,
+ _swigc__p_f_p_void_p_p_q_const__char__bool,
_swigc__p_f_p_void_p_q_const__void_size_t__void,
+ _swigc__p_f_p_void_r_q_const__lldb__SBModuleSpec_r_lldb__SBFileSpec_r_lldb__SBFileSpec__lldb__SBError,
+ _swigc__p_f_unsigned_long_long_p_void__void,
_swigc__p_int,
_swigc__p_lldb__ConnectionStatus,
_swigc__p_lldb__SBAddress,
+ _swigc__p_lldb__SBAddressRange,
+ _swigc__p_lldb__SBAddressRangeList,
_swigc__p_lldb__SBAttachInfo,
_swigc__p_lldb__SBBlock,
_swigc__p_lldb__SBBreakpoint,
@@ -74675,6 +82952,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_lldb__SBFile,
_swigc__p_lldb__SBFileSpec,
_swigc__p_lldb__SBFileSpecList,
+ _swigc__p_lldb__SBFormat,
_swigc__p_lldb__SBFrame,
_swigc__p_lldb__SBFunction,
_swigc__p_lldb__SBHostOS,
@@ -74694,11 +82972,15 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_lldb__SBPlatformShellCommand,
_swigc__p_lldb__SBProcess,
_swigc__p_lldb__SBProcessInfo,
+ _swigc__p_lldb__SBProcessInfoList,
_swigc__p_lldb__SBQueue,
_swigc__p_lldb__SBQueueItem,
_swigc__p_lldb__SBReproducer,
+ _swigc__p_lldb__SBSaveCoreOptions,
+ _swigc__p_lldb__SBScriptObject,
_swigc__p_lldb__SBSection,
_swigc__p_lldb__SBSourceManager,
+ _swigc__p_lldb__SBStatisticsOptions,
_swigc__p_lldb__SBStream,
_swigc__p_lldb__SBStringList,
_swigc__p_lldb__SBStructuredData,
@@ -74721,6 +83003,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_lldb__SBTypeMember,
_swigc__p_lldb__SBTypeMemberFunction,
_swigc__p_lldb__SBTypeNameSpecifier,
+ _swigc__p_lldb__SBTypeStaticField,
_swigc__p_lldb__SBTypeSummary,
_swigc__p_lldb__SBTypeSummaryOptions,
_swigc__p_lldb__SBTypeSynthetic,
@@ -74729,6 +83012,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_lldb__SBValueList,
_swigc__p_lldb__SBVariablesOptions,
_swigc__p_lldb__SBWatchpoint,
+ _swigc__p_lldb__SBWatchpointOptions,
_swigc__p_long_double,
_swigc__p_long_long,
_swigc__p_p_void,
@@ -74760,6 +83044,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_std__shared_ptrT_lldb_private__ExecutionContextRef_t,
_swigc__p_std__shared_ptrT_lldb_private__ExpressionVariable_t,
_swigc__p_std__shared_ptrT_lldb_private__File_t,
+ _swigc__p_std__shared_ptrT_lldb_private__FormatEntity__Entry_t,
_swigc__p_std__shared_ptrT_lldb_private__FuncUnwinders_t,
_swigc__p_std__shared_ptrT_lldb_private__Function_t,
_swigc__p_std__shared_ptrT_lldb_private__IOHandler_t,
@@ -74777,6 +83062,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_std__shared_ptrT_lldb_private__ObjectContainer_t,
_swigc__p_std__shared_ptrT_lldb_private__ObjectFileJITDelegate_t,
_swigc__p_std__shared_ptrT_lldb_private__ObjectFile_t,
+ _swigc__p_std__shared_ptrT_lldb_private__OperatingSystemInterface_t,
_swigc__p_std__shared_ptrT_lldb_private__OptionValueProperties_t,
_swigc__p_std__shared_ptrT_lldb_private__OptionValue_t,
_swigc__p_std__shared_ptrT_lldb_private__Platform_t,
@@ -74789,11 +83075,14 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_std__shared_ptrT_lldb_private__RecognizedStackFrame_t,
_swigc__p_std__shared_ptrT_lldb_private__RegisterCheckpoint_t,
_swigc__p_std__shared_ptrT_lldb_private__RegisterContext_t,
+ _swigc__p_std__shared_ptrT_lldb_private__RegisterTypeBuilder_t,
_swigc__p_std__shared_ptrT_lldb_private__RegularExpression_t,
_swigc__p_std__shared_ptrT_lldb_private__ScriptInterpreter_t,
_swigc__p_std__shared_ptrT_lldb_private__ScriptSummaryFormat_t,
+ _swigc__p_std__shared_ptrT_lldb_private__ScriptedMetadata_t,
_swigc__p_std__shared_ptrT_lldb_private__ScriptedSyntheticChildren_t,
_swigc__p_std__shared_ptrT_lldb_private__ScriptedThreadInterface_t,
+ _swigc__p_std__shared_ptrT_lldb_private__ScriptedThreadPlanInterface_t,
_swigc__p_std__shared_ptrT_lldb_private__SearchFilter_t,
_swigc__p_std__shared_ptrT_lldb_private__SectionLoadList_t,
_swigc__p_std__shared_ptrT_lldb_private__Section_t,
@@ -74805,6 +83094,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_std__shared_ptrT_lldb_private__Stream_t,
_swigc__p_std__shared_ptrT_lldb_private__StringSummaryFormat_t,
_swigc__p_std__shared_ptrT_lldb_private__StructuredDataPlugin_t,
+ _swigc__p_std__shared_ptrT_lldb_private__SupportFile_t,
_swigc__p_std__shared_ptrT_lldb_private__SymbolContextSpecifier_t,
_swigc__p_std__shared_ptrT_lldb_private__SymbolFileType_t,
_swigc__p_std__shared_ptrT_lldb_private__SyntheticChildrenFrontEnd_t,
@@ -74838,9 +83128,11 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_std__shared_ptrT_lldb_private__Value_t,
_swigc__p_std__shared_ptrT_lldb_private__VariableList_t,
_swigc__p_std__shared_ptrT_lldb_private__Variable_t,
+ _swigc__p_std__shared_ptrT_lldb_private__WatchpointResource_t,
_swigc__p_std__shared_ptrT_lldb_private__Watchpoint_t,
_swigc__p_std__shared_ptrT_lldb_private__WritableDataBuffer_t,
_swigc__p_std__string,
+ _swigc__p_std__unique_ptrT_lldb_private__AddressRange_t,
_swigc__p_std__unique_ptrT_lldb_private__DynamicCheckerFunctions_t,
_swigc__p_std__unique_ptrT_lldb_private__DynamicLoader_t,
_swigc__p_std__unique_ptrT_lldb_private__File_t,
diff --git a/lib/clang/liblldb/Makefile b/lib/clang/liblldb/Makefile
index 3d5f41c8589a..a3ff8e367864 100644
--- a/lib/clang/liblldb/Makefile
+++ b/lib/clang/liblldb/Makefile
@@ -1,7 +1,13 @@
-
+.include <bsd.init.mk>
.include "../lldb.pre.mk"
-LIB= lldb
+PACKAGE= lldb
+SHLIB_CXX= lldb
+SHLIB_MAJOR= 19
+PRIVATELIB=
+
+SHARED_CXXFLAGS+= -UPIC # To avoid compile errors
+
SRCDIR= lldb/source
CFLAGS+= -I${LLDB_SRCS}/include
@@ -16,6 +22,8 @@ CFLAGS+= -I${SRCTOP}/contrib/lua/src
CFLAGS+= -I${SRCTOP}/lib/liblua
SRCS+= API/SBAddress.cpp
+SRCS+= API/SBAddressRange.cpp
+SRCS+= API/SBAddressRangeList.cpp
SRCS+= API/SBAttachInfo.cpp
SRCS+= API/SBBlock.cpp
SRCS+= API/SBBreakpoint.cpp
@@ -39,6 +47,7 @@ SRCS+= API/SBExpressionOptions.cpp
SRCS+= API/SBFile.cpp
SRCS+= API/SBFileSpec.cpp
SRCS+= API/SBFileSpecList.cpp
+SRCS+= API/SBFormat.cpp
SRCS+= API/SBFrame.cpp
SRCS+= API/SBFunction.cpp
SRCS+= API/SBHostOS.cpp
@@ -55,11 +64,15 @@ SRCS+= API/SBModuleSpec.cpp
SRCS+= API/SBPlatform.cpp
SRCS+= API/SBProcess.cpp
SRCS+= API/SBProcessInfo.cpp
+SRCS+= API/SBProcessInfoList.cpp
SRCS+= API/SBQueue.cpp
SRCS+= API/SBQueueItem.cpp
SRCS+= API/SBReproducer.cpp
+SRCS+= API/SBSaveCoreOptions.cpp
+SRCS+= API/SBScriptObject.cpp
SRCS+= API/SBSection.cpp
SRCS+= API/SBSourceManager.cpp
+SRCS+= API/SBStatisticsOptions.cpp
SRCS+= API/SBStream.cpp
SRCS+= API/SBStringList.cpp
SRCS+= API/SBStructuredData.cpp
@@ -85,6 +98,7 @@ SRCS+= API/SBValue.cpp
SRCS+= API/SBValueList.cpp
SRCS+= API/SBVariablesOptions.cpp
SRCS+= API/SBWatchpoint.cpp
+SRCS+= API/SBWatchpointOptions.cpp
SRCS+= API/SystemInitializerFull.cpp
SRCS+= Breakpoint/Breakpoint.cpp
SRCS+= Breakpoint/BreakpointID.cpp
@@ -102,13 +116,15 @@ SRCS+= Breakpoint/BreakpointResolverFileRegex.cpp
SRCS+= Breakpoint/BreakpointResolverName.cpp
SRCS+= Breakpoint/BreakpointResolverScripted.cpp
SRCS+= Breakpoint/BreakpointSite.cpp
-SRCS+= Breakpoint/BreakpointSiteList.cpp
+SRCS+= Breakpoint/StopPointSiteList.cpp
SRCS+= Breakpoint/Stoppoint.cpp
SRCS+= Breakpoint/StoppointCallbackContext.cpp
SRCS+= Breakpoint/StoppointSite.cpp
SRCS+= Breakpoint/Watchpoint.cpp
+SRCS+= Breakpoint/WatchpointAlgorithms.cpp
SRCS+= Breakpoint/WatchpointList.cpp
SRCS+= Breakpoint/WatchpointOptions.cpp
+SRCS+= Breakpoint/WatchpointResource.cpp
SRCS+= Commands/CommandCompletions.cpp
SRCS+= Commands/CommandObjectApropos.cpp
SRCS+= Commands/CommandObjectBreakpoint.cpp
@@ -132,7 +148,7 @@ SRCS+= Commands/CommandObjectProcess.cpp
SRCS+= Commands/CommandObjectQuit.cpp
SRCS+= Commands/CommandObjectRegexCommand.cpp
SRCS+= Commands/CommandObjectRegister.cpp
-SRCS+= Commands/CommandObjectScript.cpp
+SRCS+= Commands/CommandObjectScripting.cpp
SRCS+= Commands/CommandObjectSession.cpp
SRCS+= Commands/CommandObjectSettings.cpp
SRCS+= Commands/CommandObjectSource.cpp
@@ -146,9 +162,11 @@ SRCS+= Commands/CommandObjectVersion.cpp
SRCS+= Commands/CommandObjectWatchpoint.cpp
SRCS+= Commands/CommandObjectWatchpointCommand.cpp
SRCS+= Commands/CommandOptionArgumentTable.cpp
+SRCS+= Commands/CommandOptionsProcessAttach.cpp
SRCS+= Commands/CommandOptionsProcessLaunch.cpp
SRCS+= Core/Address.cpp
SRCS+= Core/AddressRange.cpp
+SRCS+= Core/AddressRangeListImpl.cpp
SRCS+= Core/AddressResolver.cpp
SRCS+= Core/AddressResolverFileLine.cpp
SRCS+= Core/Communication.cpp
@@ -158,11 +176,11 @@ SRCS+= Core/DebuggerEvents.cpp
SRCS+= Core/Declaration.cpp
SRCS+= Core/Disassembler.cpp
SRCS+= Core/DumpDataExtractor.cpp
+SRCS+= Core/DumpRegisterInfo.cpp
SRCS+= Core/DumpRegisterValue.cpp
SRCS+= Core/DynamicLoader.cpp
SRCS+= Core/EmulateInstruction.cpp
SRCS+= Core/FileLineResolver.cpp
-SRCS+= Core/FileSpecList.cpp
SRCS+= Core/FormatEntity.cpp
SRCS+= Core/Highlighter.cpp
SRCS+= Core/IOHandler.cpp
@@ -180,7 +198,6 @@ SRCS+= Core/Section.cpp
SRCS+= Core/SourceLocationSpec.cpp
SRCS+= Core/SourceManager.cpp
SRCS+= Core/StreamAsynchronousIO.cpp
-SRCS+= Core/StreamFile.cpp
SRCS+= Core/ThreadedCommunication.cpp
SRCS+= Core/UserSettingsController.cpp
SRCS+= Core/Value.cpp
@@ -197,6 +214,7 @@ SRCS+= Core/ValueObjectMemory.cpp
SRCS+= Core/ValueObjectRegister.cpp
SRCS+= Core/ValueObjectSyntheticFilter.cpp
SRCS+= Core/ValueObjectUpdater.cpp
+SRCS+= Core/ValueObjectVTable.cpp
SRCS+= Core/ValueObjectVariable.cpp
SRCS+= DataFormatters/CXXFunctionPointer.cpp
SRCS+= DataFormatters/DataVisualization.cpp
@@ -218,6 +236,8 @@ SRCS+= Expression/DWARFExpression.cpp
SRCS+= Expression/DWARFExpressionList.cpp
SRCS+= Expression/DiagnosticManager.cpp
SRCS+= Expression/Expression.cpp
+SRCS+= Expression/ExpressionParser.cpp
+SRCS+= Expression/ExpressionTypeSystemHelper.cpp
SRCS+= Expression/ExpressionVariable.cpp
SRCS+= Expression/FunctionCaller.cpp
SRCS+= Expression/IRExecutionUnit.cpp
@@ -225,9 +245,11 @@ SRCS+= Expression/IRInterpreter.cpp
SRCS+= Expression/IRMemoryMap.cpp
SRCS+= Expression/LLVMUserExpression.cpp
SRCS+= Expression/Materializer.cpp
+SRCS+= Expression/ObjectFileJIT.cpp
SRCS+= Expression/REPL.cpp
SRCS+= Expression/UserExpression.cpp
SRCS+= Expression/UtilityFunction.cpp
+SRCS+= Host/common/Alarm.cpp
SRCS+= Host/common/Editline.cpp
SRCS+= Host/common/File.cpp
SRCS+= Host/common/FileAction.cpp
@@ -253,6 +275,7 @@ SRCS+= Host/common/ProcessRunLock.cpp
SRCS+= Host/common/PseudoTerminal.cpp
SRCS+= Host/common/Socket.cpp
SRCS+= Host/common/SocketAddress.cpp
+SRCS+= Host/common/StreamFile.cpp
SRCS+= Host/common/TCPSocket.cpp
SRCS+= Host/common/Terminal.cpp
SRCS+= Host/common/ThreadLauncher.cpp
@@ -329,6 +352,7 @@ SRCS+= Plugins/ABI/Mips/ABISysV_mips64.cpp
SRCS+= Plugins/ABI/PowerPC/ABIPowerPC.cpp
SRCS+= Plugins/ABI/PowerPC/ABISysV_ppc.cpp
SRCS+= Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
+SRCS+= Plugins/ABI/RISCV/ABISysV_riscv.cpp
SRCS+= Plugins/ABI/X86/ABISysV_i386.cpp
SRCS+= Plugins/ABI/X86/ABISysV_x86_64.cpp
SRCS+= Plugins/ABI/X86/ABIX86.cpp
@@ -338,6 +362,7 @@ SRCS+= Plugins/Architecture/Arm/ArchitectureArm.cpp
SRCS+= Plugins/Architecture/Mips/ArchitectureMips.cpp
SRCS+= Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
SRCS+= Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+SRCS+= Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
SRCS+= Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
SRCS+= Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
SRCS+= Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -349,6 +374,7 @@ SRCS+= Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
SRCS+= Plugins/ExpressionParser/Clang/ClangASTSource.cpp
SRCS+= Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
SRCS+= Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+SRCS+= Plugins/ExpressionParser/Clang/ClangExpressionHelper.cpp
SRCS+= Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
SRCS+= Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
SRCS+= Plugins/ExpressionParser/Clang/ClangExpressionUtil.cpp
@@ -374,9 +400,11 @@ SRCS+= Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
SRCS+= Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
SRCS+= Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
SRCS+= Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
+SRCS+= Plugins/InstrumentationRuntime/ASanLibsanitizers/InstrumentationRuntimeASanLibsanitizers.cpp
SRCS+= Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
SRCS+= Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
SRCS+= Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
+SRCS+= Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp
SRCS+= Plugins/JITLoader/GDB/JITLoaderGDB.cpp
SRCS+= Plugins/Language/CPlusPlus/BlockPointer.cpp
SRCS+= Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -390,11 +418,14 @@ SRCS+= Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxList.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxMap.cpp
+SRCS+= Plugins/Language/CPlusPlus/LibCxxProxyArray.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxQueue.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp
+SRCS+= Plugins/Language/CPlusPlus/LibCxxSliceArray.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxSpan.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxTuple.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+SRCS+= Plugins/Language/CPlusPlus/LibCxxValarray.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxVariant.cpp
SRCS+= Plugins/Language/CPlusPlus/LibCxxVector.cpp
SRCS+= Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -416,22 +447,24 @@ SRCS+= Plugins/Language/ObjC/NSString.cpp
SRCS+= Plugins/Language/ObjC/ObjCLanguage.cpp
SRCS+= Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
SRCS+= Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
SRCS+= Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
SRCS+= Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
-SRCS+= Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
-SRCS+= Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
-SRCS+= Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
SRCS+= Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
SRCS+= Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
SRCS+= Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
SRCS+= Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
SRCS+= Plugins/ObjectFile/ELF/ELFHeader.cpp
SRCS+= Plugins/ObjectFile/ELF/ObjectFileELF.cpp
-SRCS+= Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
SRCS+= Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
SRCS+= Plugins/Platform/POSIX/PlatformPOSIX.cpp
+SRCS+= Plugins/Platform/QemuUser/PlatformQemuUser.cpp
SRCS+= Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
SRCS+= Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
SRCS+= Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.cpp
@@ -456,7 +489,6 @@ SRCS+= Plugins/Process/Utility/HistoryThread.cpp
SRCS+= Plugins/Process/Utility/HistoryUnwind.cpp
SRCS+= Plugins/Process/Utility/InferiorCallPOSIX.cpp
SRCS+= Plugins/Process/Utility/LinuxSignals.cpp
-SRCS+= Plugins/Process/Utility/MipsLinuxSignals.cpp
SRCS+= Plugins/Process/Utility/MemoryTagManagerAArch64MTE.cpp
SRCS+= Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp
SRCS+= Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp
@@ -483,21 +515,26 @@ SRCS+= Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
SRCS+= Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
SRCS+= Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
SRCS+= Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
+SRCS+= Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
SRCS+= Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
SRCS+= Plugins/Process/Utility/RegisterContextThreadMemory.cpp
SRCS+= Plugins/Process/Utility/RegisterContext_x86.cpp
+SRCS+= Plugins/Process/Utility/RegisterFlagsDetector_arm64.cpp
SRCS+= Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
SRCS+= Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
SRCS+= Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
SRCS+= Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp
+SRCS+= Plugins/Process/Utility/RegisterInfos_x86_64_with_base_shared.cpp
SRCS+= Plugins/Process/Utility/StopInfoMachException.cpp
SRCS+= Plugins/Process/Utility/ThreadMemory.cpp
SRCS+= Plugins/Process/elf-core/ProcessElfCore.cpp
+SRCS+= Plugins/Process/elf-core/RegisterContextLinuxCore_x86_64.cpp
SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
+SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
SRCS+= Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
SRCS+= Plugins/Process/elf-core/RegisterUtilities.cpp
SRCS+= Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -524,14 +561,12 @@ SRCS+= Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
SRCS+= Plugins/SymbolFile/DWARF/DIERef.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
-SRCS+= Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFContext.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFDIE.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
-SRCS+= Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -545,7 +580,6 @@ SRCS+= Plugins/SymbolFile/DWARF/DWARFIndex.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
SRCS+= Plugins/SymbolFile/DWARF/DWARFUnit.cpp
SRCS+= Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
-SRCS+= Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
SRCS+= Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
SRCS+= Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
SRCS+= Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -554,6 +588,8 @@ SRCS+= Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
SRCS+= Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
SRCS+= Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
SRCS+= Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+SRCS+= Plugins/SymbolLocator/Default/SymbolLocatorDefault.cpp
+SRCS+= Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod.cpp
SRCS+= Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
SRCS+= Plugins/TypeSystem/Clang/TypeSystemClang.cpp
SRCS+= Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -573,14 +609,15 @@ SRCS+= Symbol/FuncUnwinders.cpp
SRCS+= Symbol/Function.cpp
SRCS+= Symbol/LineEntry.cpp
SRCS+= Symbol/LineTable.cpp
-SRCS+= Symbol/LocateSymbolFile.cpp
SRCS+= Symbol/ObjectContainer.cpp
SRCS+= Symbol/ObjectFile.cpp
SRCS+= Symbol/PostfixExpression.cpp
+SRCS+= Symbol/SaveCoreOptions.cpp
SRCS+= Symbol/Symbol.cpp
SRCS+= Symbol/SymbolContext.cpp
SRCS+= Symbol/SymbolFile.cpp
SRCS+= Symbol/SymbolFileOnDemand.cpp
+SRCS+= Symbol/SymbolLocator.cpp
SRCS+= Symbol/SymbolVendor.cpp
SRCS+= Symbol/Symtab.cpp
SRCS+= Symbol/Type.cpp
@@ -616,6 +653,7 @@ SRCS+= Target/QueueItem.cpp
SRCS+= Target/QueueList.cpp
SRCS+= Target/RegisterContext.cpp
SRCS+= Target/RegisterContextUnwind.cpp
+SRCS+= Target/RegisterFlags.cpp
SRCS+= Target/RegisterNumber.cpp
SRCS+= Target/RemoteAwarePlatform.cpp
SRCS+= Target/SectionLoadHistory.cpp
@@ -657,10 +695,13 @@ SRCS+= Target/TraceDumper.cpp
SRCS+= Target/UnixSignals.cpp
SRCS+= Target/UnwindAssembly.cpp
SRCS+= Target/UnwindLLDB.cpp
+SRCS+= Target/VerboseTrapFrameRecognizer.cpp
+SRCS+= Utility/AddressableBits.cpp
SRCS+= Utility/ArchSpec.cpp
SRCS+= Utility/Args.cpp
SRCS+= Utility/Baton.cpp
SRCS+= Utility/Broadcaster.cpp
+SRCS+= Utility/Checksum.cpp
SRCS+= Utility/CompletionRequest.cpp
SRCS+= Utility/Connection.cpp
SRCS+= Utility/ConstString.cpp
@@ -670,8 +711,10 @@ SRCS+= Utility/DataEncoder.cpp
SRCS+= Utility/DataExtractor.cpp
SRCS+= Utility/Diagnostics.cpp
SRCS+= Utility/Environment.cpp
+SRCS+= Utility/ErrorMessages.cpp
SRCS+= Utility/Event.cpp
SRCS+= Utility/FileSpec.cpp
+SRCS+= Utility/FileSpecList.cpp
SRCS+= Utility/GDBRemote.cpp
SRCS+= Utility/IOObject.cpp
SRCS+= Utility/Instrumentation.cpp
@@ -707,6 +750,19 @@ SRCS+= Utility/VMRange.cpp
SRCS+= Utility/XcodeSDK.cpp
SRCS+= Version/Version.cpp
+LIBDEPS+= clang
+LIBDEPS+= llvm
+
+LIBPRIV= private
+LIBEXT= so
+
+.for lib in ${LIBDEPS}
+DPADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT}
+LDADD+= ${OBJTOP}/lib/clang/lib${lib}/lib${LIBPRIV}${lib}.${LIBEXT}
+.endfor
+
+LIBADD+= kvm
+
LLDB_TBLGEN?= lldb-tblgen
CommandOptions.inc: ${LLDB_SRCS}/source/Commands/Options.td
@@ -719,8 +775,10 @@ TGHDRS+= CommandOptions.inc
Core/Core \
Interpreter/Interpreter \
Plugins/JITLoader/GDB/JITLoaderGDB \
+ Plugins/Platform/QemuUser/PlatformQemuUser \
Plugins/Process/gdb-remote/ProcessGDBRemote \
Plugins/SymbolFile/DWARF/SymbolFileDWARF \
+ Plugins/SymbolLocator/Debuginfod/SymbolLocatorDebuginfod \
Target/Target
${path:T}Properties.inc: ${LLDB_SRCS}/source/${path}Properties.td
${LLDB_TBLGEN} -gen-lldb-property-defs \
@@ -740,8 +798,6 @@ CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
.include "../clang.build.mk"
-INTERNALLIB=
-
# Building lldb's bindings requires swig, but we do not want to include it in
# the FreeBSD base system (as a build tool) because it has non-trivial
# dependencies. As a workaround we commit the generated file. Requires the
diff --git a/lib/clang/liblldb/Makefile.depend b/lib/clang/liblldb/Makefile.depend
index b411ca49268d..3b2fbcc7b889 100644
--- a/lib/clang/liblldb/Makefile.depend
+++ b/lib/clang/liblldb/Makefile.depend
@@ -9,9 +9,13 @@ DIRDEPS = \
lib/libc++ \
lib/libedit \
lib/libexecinfo \
+ lib/libkvm \
+ lib/liblzma \
+ lib/libz \
lib/msun \
- lib/ncurses/ncursesw \
- lib/ncurses/panelw \
+ lib/ncurses/panel \
+ lib/ncurses/tinfo \
+ usr.bin/clang/lldb-tblgen.host \
.include <dirdeps.mk>
diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile
index 7cbf56401d5b..e634a72b4f90 100644
--- a/lib/clang/libllvm/Makefile
+++ b/lib/clang/libllvm/Makefile
@@ -1,9 +1,22 @@
-
-.include <src.opts.mk>
+.include <bsd.init.mk>
.include "../llvm.pre.mk"
+.if defined(TOOLS_PREFIX)
+# Build static library during cross-tools stage
LIB= llvm
INTERNALLIB=
+.else
+PACKAGE= clang
+SHLIB_CXX= llvm
+SHLIB_MAJOR= 19
+PRIVATELIB=
+.if ${MACHINE} == "powerpc"
+# Work around "relocation R_PPC_GOT16 out of range" errors
+PICFLAG= -fPIC
+.endif
+.endif
+
+SHARED_CXXFLAGS+= -UPIC # To avoid compile errors
CFLAGS+= -I${.OBJDIR}
CFLAGS+= -I${SRCTOP}/sys/contrib/zstd/lib
@@ -47,10 +60,10 @@ SRCDIR= llvm/lib
# SRCS_XDB: required for MK_CLANG_EXTRAS and MK_LLDB
# SRCS_XDL: required for MK_CLANG_EXTRAS, MK_LLD and MK_LLDB
# SRCS_XDW: required for MK_CLANG_EXTRAS and MK_LLDB in world stage
+# SRCS_COV: required for MK_LLVM_COV
SRCS_MIN+= Analysis/AliasAnalysis.cpp
SRCS_MIN+= Analysis/AliasAnalysisEvaluator.cpp
-SRCS_MIN+= Analysis/AliasAnalysisSummary.cpp
SRCS_MIN+= Analysis/AliasSetTracker.cpp
SRCS_EXT+= Analysis/Analysis.cpp
SRCS_MIN+= Analysis/AssumeBundleQueries.cpp
@@ -79,11 +92,10 @@ SRCS_MIN+= Analysis/Delinearization.cpp
SRCS_MIN+= Analysis/DemandedBits.cpp
SRCS_MIN+= Analysis/DependenceAnalysis.cpp
SRCS_MIN+= Analysis/DependenceGraphBuilder.cpp
-SRCS_MIN+= Analysis/DivergenceAnalysis.cpp
+SRCS_MIN+= Analysis/DomConditionCache.cpp
SRCS_MIN+= Analysis/DomPrinter.cpp
SRCS_MIN+= Analysis/DomTreeUpdater.cpp
SRCS_MIN+= Analysis/DominanceFrontier.cpp
-SRCS_MIN+= Analysis/EHPersonalities.cpp
SRCS_MIN+= Analysis/FunctionPropertiesAnalysis.cpp
SRCS_MIN+= Analysis/GlobalsModRef.cpp
SRCS_MIN+= Analysis/GuardUtils.cpp
@@ -100,13 +112,11 @@ SRCS_MIN+= Analysis/InlineSizeEstimatorAnalysis.cpp
SRCS_MIN+= Analysis/InstCount.cpp
SRCS_MIN+= Analysis/InstructionPrecedenceTracking.cpp
SRCS_MIN+= Analysis/InstructionSimplify.cpp
-SRCS_MIN+= Analysis/Interval.cpp
-SRCS_MIN+= Analysis/IntervalPartition.cpp
+SRCS_MIN+= Analysis/InteractiveModelRunner.cpp
SRCS_MIN+= Analysis/LazyBlockFrequencyInfo.cpp
SRCS_MIN+= Analysis/LazyBranchProbabilityInfo.cpp
SRCS_MIN+= Analysis/LazyCallGraph.cpp
SRCS_MIN+= Analysis/LazyValueInfo.cpp
-SRCS_MIN+= Analysis/LegacyDivergenceAnalysis.cpp
SRCS_MIN+= Analysis/Lint.cpp
SRCS_MIN+= Analysis/Loads.cpp
SRCS_MIN+= Analysis/Local.cpp
@@ -117,7 +127,7 @@ SRCS_MIN+= Analysis/LoopInfo.cpp
SRCS_MIN+= Analysis/LoopNestAnalysis.cpp
SRCS_MIN+= Analysis/LoopPass.cpp
SRCS_MIN+= Analysis/LoopUnrollAnalyzer.cpp
-SRCS_MIN+= Analysis/MemDepPrinter.cpp
+SRCS_MIN+= Analysis/MLInlineAdvisor.cpp
SRCS_MIN+= Analysis/MemDerefPrinter.cpp
SRCS_MIN+= Analysis/MemoryBuiltins.cpp
SRCS_MIN+= Analysis/MemoryDependenceAnalysis.cpp
@@ -143,22 +153,21 @@ SRCS_MIN+= Analysis/RegionPass.cpp
SRCS_MIN+= Analysis/RegionPrinter.cpp
SRCS_MIN+= Analysis/ReplayInlineAdvisor.cpp
SRCS_MIN+= Analysis/ScalarEvolution.cpp
-SRCS_MIN+= Analysis/ScalarEvolution.cpp
SRCS_MIN+= Analysis/ScalarEvolutionAliasAnalysis.cpp
SRCS_MIN+= Analysis/ScalarEvolutionDivision.cpp
SRCS_MIN+= Analysis/ScalarEvolutionNormalization.cpp
SRCS_MIN+= Analysis/ScopedNoAliasAA.cpp
SRCS_MIN+= Analysis/StackLifetime.cpp
SRCS_MIN+= Analysis/StackSafetyAnalysis.cpp
-SRCS_MIN+= Analysis/SyncDependenceAnalysis.cpp
+SRCS_MIN+= Analysis/StructuralHash.cpp
SRCS_MIN+= Analysis/SyntheticCountsUtils.cpp
SRCS_MIN+= Analysis/TargetLibraryInfo.cpp
SRCS_MIN+= Analysis/TargetTransformInfo.cpp
SRCS_MIN+= Analysis/TensorSpec.cpp
+SRCS_MIN+= Analysis/TrainingLogger.cpp
SRCS_MIN+= Analysis/TypeBasedAliasAnalysis.cpp
SRCS_MIN+= Analysis/TypeMetadataUtils.cpp
SRCS_MIN+= Analysis/UniformityAnalysis.cpp
-SRCS_MIN+= Analysis/VFABIDemangling.cpp
SRCS_MIN+= Analysis/ValueLattice.cpp
SRCS_MIN+= Analysis/ValueLatticeUtils.cpp
SRCS_MIN+= Analysis/ValueTracking.cpp
@@ -169,8 +178,9 @@ SRCS_MIN+= AsmParser/Parser.cpp
SRCS_MIN+= BinaryFormat/AMDGPUMetadataVerifier.cpp
SRCS_MIN+= BinaryFormat/COFF.cpp
SRCS_MIN+= BinaryFormat/Dwarf.cpp
-SRCS_MIN+= BinaryFormat/Magic.cpp
+SRCS_XDB+= BinaryFormat/ELF.cpp
SRCS_MIN+= BinaryFormat/MachO.cpp
+SRCS_MIN+= BinaryFormat/Magic.cpp
SRCS_MIN+= BinaryFormat/MsgPackDocument.cpp
SRCS_MIN+= BinaryFormat/MsgPackDocumentYAML.cpp
SRCS_MIN+= BinaryFormat/MsgPackReader.cpp
@@ -218,6 +228,7 @@ SRCS_MIN+= CodeGen/AsmPrinter/WinCFGuard.cpp
SRCS_MIN+= CodeGen/AsmPrinter/WinException.cpp
SRCS_MIN+= CodeGen/AssignmentTrackingAnalysis.cpp
SRCS_MIN+= CodeGen/AtomicExpandPass.cpp
+SRCS_MIN+= CodeGen/BasicBlockPathCloning.cpp
SRCS_MIN+= CodeGen/BasicBlockSections.cpp
SRCS_MIN+= CodeGen/BasicBlockSectionsProfileReader.cpp
SRCS_MIN+= CodeGen/BasicTargetTransformInfo.cpp
@@ -228,6 +239,7 @@ SRCS_MIN+= CodeGen/CFGuardLongjmp.cpp
SRCS_MIN+= CodeGen/CFIFixup.cpp
SRCS_MIN+= CodeGen/CFIInstrInserter.cpp
SRCS_MIN+= CodeGen/CalcSpillWeights.cpp
+SRCS_MIN+= CodeGen/CallBrPrepare.cpp
SRCS_MIN+= CodeGen/CallingConvLower.cpp
SRCS_MIN+= CodeGen/CodeGen.cpp
SRCS_MIN+= CodeGen/CodeGenCommonISel.cpp
@@ -254,14 +266,17 @@ SRCS_MIN+= CodeGen/FaultMaps.cpp
SRCS_MIN+= CodeGen/FinalizeISel.cpp
SRCS_MIN+= CodeGen/FixupStatepointCallerSaved.cpp
SRCS_MIN+= CodeGen/FuncletLayout.cpp
+SRCS_MIN+= CodeGen/GCEmptyBasicBlocks.cpp
SRCS_MIN+= CodeGen/GCMetadata.cpp
SRCS_MIN+= CodeGen/GCMetadataPrinter.cpp
SRCS_MIN+= CodeGen/GCRootLowering.cpp
SRCS_MIN+= CodeGen/GlobalISel/CSEInfo.cpp
SRCS_MIN+= CodeGen/GlobalISel/CSEMIRBuilder.cpp
+SRCS_MIN+= CodeGen/GlobalISel/CallLowering.cpp
SRCS_MIN+= CodeGen/GlobalISel/Combiner.cpp
SRCS_MIN+= CodeGen/GlobalISel/CombinerHelper.cpp
-SRCS_MIN+= CodeGen/GlobalISel/CallLowering.cpp
+SRCS_MIN+= CodeGen/GlobalISel/CombinerHelperVectorOps.cpp
+SRCS_MIN+= CodeGen/GlobalISel/GIMatchTableExecutor.cpp
SRCS_MIN+= CodeGen/GlobalISel/GISelChangeObserver.cpp
SRCS_MIN+= CodeGen/GlobalISel/GISelKnownBits.cpp
SRCS_MIN+= CodeGen/GlobalISel/GlobalISel.cpp
@@ -286,12 +301,14 @@ SRCS_MIN+= CodeGen/HardwareLoops.cpp
SRCS_MIN+= CodeGen/IfConversion.cpp
SRCS_MIN+= CodeGen/ImplicitNullChecks.cpp
SRCS_MIN+= CodeGen/IndirectBrExpandPass.cpp
+SRCS_MIN+= CodeGen/InitUndef.cpp
SRCS_MIN+= CodeGen/InlineSpiller.cpp
SRCS_MIN+= CodeGen/InterferenceCache.cpp
SRCS_MIN+= CodeGen/InterleavedAccessPass.cpp
SRCS_MIN+= CodeGen/InterleavedLoadCombinePass.cpp
SRCS_MIN+= CodeGen/IntrinsicLowering.cpp
SRCS_MIN+= CodeGen/JMCInstrumenter.cpp
+SRCS_MIN+= CodeGen/KCFI.cpp
SRCS_MIN+= CodeGen/LLVMTargetMachine.cpp
SRCS_MIN+= CodeGen/LatencyPriorityQueue.cpp
SRCS_MIN+= CodeGen/LazyMachineBlockFrequencyInfo.cpp
@@ -314,7 +331,7 @@ SRCS_MIN+= CodeGen/LiveStacks.cpp
SRCS_MIN+= CodeGen/LiveVariables.cpp
SRCS_MIN+= CodeGen/LocalStackSlotAllocation.cpp
SRCS_MIN+= CodeGen/LoopTraversal.cpp
-SRCS_MIN+= CodeGen/LowLevelType.cpp
+SRCS_MIN+= CodeGen/LowLevelTypeUtils.cpp
SRCS_MIN+= CodeGen/LowerEmuTLS.cpp
SRCS_MIN+= CodeGen/MBFIWrapper.cpp
SRCS_MIN+= CodeGen/MIRCanonicalizerPass.cpp
@@ -327,7 +344,8 @@ SRCS_MIN+= CodeGen/MIRPrinter.cpp
SRCS_MIN+= CodeGen/MIRPrintingPass.cpp
SRCS_MIN+= CodeGen/MIRSampleProfile.cpp
SRCS_MIN+= CodeGen/MIRVRegNamerUtils.cpp
-SRCS_MIN+= CodeGen/MLRegallocEvictAdvisor.cpp
+SRCS_MIN+= CodeGen/MLRegAllocEvictAdvisor.cpp
+SRCS_MIN+= CodeGen/MLRegAllocPriorityAdvisor.cpp
SRCS_MIN+= CodeGen/MachineBasicBlock.cpp
SRCS_MIN+= CodeGen/MachineBlockFrequencyInfo.cpp
SRCS_MIN+= CodeGen/MachineBlockPlacement.cpp
@@ -336,6 +354,7 @@ SRCS_MIN+= CodeGen/MachineCFGPrinter.cpp
SRCS_MIN+= CodeGen/MachineCSE.cpp
SRCS_MIN+= CodeGen/MachineCheckDebugify.cpp
SRCS_MIN+= CodeGen/MachineCombiner.cpp
+SRCS_MIN+= CodeGen/MachineConvergenceVerifier.cpp
SRCS_MIN+= CodeGen/MachineCopyPropagation.cpp
SRCS_MIN+= CodeGen/MachineCycleAnalysis.cpp
SRCS_MIN+= CodeGen/MachineDebugify.cpp
@@ -343,6 +362,7 @@ SRCS_MIN+= CodeGen/MachineDominanceFrontier.cpp
SRCS_MIN+= CodeGen/MachineDominators.cpp
SRCS_MIN+= CodeGen/MachineFrameInfo.cpp
SRCS_MIN+= CodeGen/MachineFunction.cpp
+SRCS_MIN+= CodeGen/MachineFunctionAnalysis.cpp
SRCS_MIN+= CodeGen/MachineFunctionPass.cpp
SRCS_MIN+= CodeGen/MachineFunctionPrinterPass.cpp
SRCS_MIN+= CodeGen/MachineFunctionSplitter.cpp
@@ -358,6 +378,7 @@ SRCS_MIN+= CodeGen/MachineModuleSlotTracker.cpp
SRCS_MIN+= CodeGen/MachineOperand.cpp
SRCS_MIN+= CodeGen/MachineOptimizationRemarkEmitter.cpp
SRCS_MIN+= CodeGen/MachineOutliner.cpp
+SRCS_MIN+= CodeGen/MachinePassManager.cpp
SRCS_MIN+= CodeGen/MachinePipeliner.cpp
SRCS_MIN+= CodeGen/MachinePostDominators.cpp
SRCS_MIN+= CodeGen/MachineRegionInfo.cpp
@@ -379,7 +400,6 @@ SRCS_EXT+= CodeGen/NonRelocatableStringpool.cpp
SRCS_MIN+= CodeGen/OptimizePHIs.cpp
SRCS_MIN+= CodeGen/PHIElimination.cpp
SRCS_MIN+= CodeGen/PHIEliminationUtils.cpp
-SRCS_MIN+= CodeGen/ParallelCG.cpp
SRCS_MIN+= CodeGen/PatchableFunction.cpp
SRCS_MIN+= CodeGen/PeepholeOptimizer.cpp
SRCS_MIN+= CodeGen/PostRAHazardRecognizer.cpp
@@ -389,11 +409,10 @@ SRCS_MIN+= CodeGen/ProcessImplicitDefs.cpp
SRCS_MIN+= CodeGen/PrologEpilogInserter.cpp
SRCS_MIN+= CodeGen/PseudoProbeInserter.cpp
SRCS_MIN+= CodeGen/PseudoSourceValue.cpp
-SRCS_MIN+= CodeGen/ReachingDefAnalysis.cpp
-SRCS_MIN+= CodeGen/ReplaceWithVeclib.cpp
SRCS_MIN+= CodeGen/RDFGraph.cpp
SRCS_MIN+= CodeGen/RDFLiveness.cpp
SRCS_MIN+= CodeGen/RDFRegisters.cpp
+SRCS_MIN+= CodeGen/ReachingDefAnalysis.cpp
SRCS_MIN+= CodeGen/RegAllocBase.cpp
SRCS_MIN+= CodeGen/RegAllocBasic.cpp
SRCS_MIN+= CodeGen/RegAllocEvictionAdvisor.cpp
@@ -412,6 +431,7 @@ SRCS_MIN+= CodeGen/RegisterScavenging.cpp
SRCS_MIN+= CodeGen/RegisterUsageInfo.cpp
SRCS_MIN+= CodeGen/RemoveRedundantDebugValues.cpp
SRCS_MIN+= CodeGen/RenameIndependentSubregs.cpp
+SRCS_MIN+= CodeGen/ReplaceWithVeclib.cpp
SRCS_MIN+= CodeGen/ResetMachineFunctionPass.cpp
SRCS_MIN+= CodeGen/SafeStack.cpp
SRCS_MIN+= CodeGen/SafeStackLayout.cpp
@@ -478,31 +498,48 @@ SRCS_MIN+= CodeGen/ValueTypes.cpp
SRCS_MIN+= CodeGen/VirtRegMap.cpp
SRCS_MIN+= CodeGen/WasmEHPrepare.cpp
SRCS_MIN+= CodeGen/WinEHPrepare.cpp
+SRCS_MIN+= CodeGen/WindowScheduler.cpp
SRCS_MIN+= CodeGen/XRayInstrumentation.cpp
-SRCS_EXT+= DWARFLinker/DWARFLinker.cpp
-SRCS_EXT+= DWARFLinker/DWARFLinkerCompileUnit.cpp
-SRCS_EXT+= DWARFLinker/DWARFLinkerDeclContext.cpp
-SRCS_EXT+= DWARFLinker/DWARFStreamer.cpp
+SRCS_MIN+= CodeGenTypes/LowLevelType.cpp
+SRCS_EXT+= DWARFLinker/Classic/DWARFLinker.cpp
+SRCS_EXT+= DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp
+SRCS_EXT+= DWARFLinker/Classic/DWARFLinkerDeclContext.cpp
+SRCS_EXT+= DWARFLinker/Classic/DWARFStreamer.cpp
+SRCS_EXT+= DWARFLinker/DWARFLinkerBase.cpp
+SRCS_EXT+= DWARFLinker/Parallel/AcceleratorRecordsSaver.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DIEAttributeCloner.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DWARFEmitterImpl.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DWARFLinker.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DWARFLinkerImpl.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DWARFLinkerTypeUnit.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DWARFLinkerUnit.cpp
+SRCS_EXT+= DWARFLinker/Parallel/DependencyTracker.cpp
+SRCS_EXT+= DWARFLinker/Parallel/OutputSections.cpp
+SRCS_EXT+= DWARFLinker/Parallel/SyntheticTypeNameBuilder.cpp
+SRCS_EXT+= DWARFLinker/Utils.cpp
SRCS_EXT+= DWP/DWP.cpp
SRCS_EXT+= DWP/DWPError.cpp
-SRCS_EXT+= DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
+SRCS_MIW+= DebugInfo/BTF/BTFContext.cpp
+SRCS_MIW+= DebugInfo/BTF/BTFParser.cpp
+SRCS_MIN+= DebugInfo/CodeView/AppendingTypeTableBuilder.cpp
SRCS_MIN+= DebugInfo/CodeView/CVSymbolVisitor.cpp
SRCS_MIN+= DebugInfo/CodeView/CVTypeVisitor.cpp
SRCS_MIN+= DebugInfo/CodeView/CodeViewError.cpp
SRCS_MIN+= DebugInfo/CodeView/CodeViewRecordIO.cpp
SRCS_MIN+= DebugInfo/CodeView/ContinuationRecordBuilder.cpp
SRCS_MIN+= DebugInfo/CodeView/DebugChecksumsSubsection.cpp
-SRCS_EXT+= DebugInfo/CodeView/DebugCrossExSubsection.cpp
-SRCS_EXT+= DebugInfo/CodeView/DebugCrossImpSubsection.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugCrossExSubsection.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugCrossImpSubsection.cpp
SRCS_MIN+= DebugInfo/CodeView/DebugFrameDataSubsection.cpp
SRCS_MIN+= DebugInfo/CodeView/DebugInlineeLinesSubsection.cpp
SRCS_MIN+= DebugInfo/CodeView/DebugLinesSubsection.cpp
SRCS_MIN+= DebugInfo/CodeView/DebugStringTableSubsection.cpp
-SRCS_MIW+= DebugInfo/CodeView/DebugSubsection.cpp
-SRCS_EXT+= DebugInfo/CodeView/DebugSubsectionRecord.cpp
-SRCS_EXT+= DebugInfo/CodeView/DebugSubsectionVisitor.cpp
-SRCS_EXT+= DebugInfo/CodeView/DebugSymbolRVASubsection.cpp
-SRCS_EXT+= DebugInfo/CodeView/DebugSymbolsSubsection.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugSubsection.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugSubsectionRecord.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugSubsectionVisitor.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugSymbolRVASubsection.cpp
+SRCS_MIN+= DebugInfo/CodeView/DebugSymbolsSubsection.cpp
SRCS_MIN+= DebugInfo/CodeView/EnumTables.cpp
SRCS_MIN+= DebugInfo/CodeView/Formatters.cpp
SRCS_MIN+= DebugInfo/CodeView/GlobalTypeTableBuilder.cpp
@@ -516,7 +553,7 @@ SRCS_EXT+= DebugInfo/CodeView/StringsAndChecksums.cpp
SRCS_MIN+= DebugInfo/CodeView/SymbolDumper.cpp
SRCS_MIN+= DebugInfo/CodeView/SymbolRecordHelpers.cpp
SRCS_MIN+= DebugInfo/CodeView/SymbolRecordMapping.cpp
-SRCS_EXT+= DebugInfo/CodeView/SymbolSerializer.cpp
+SRCS_MIN+= DebugInfo/CodeView/SymbolSerializer.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeDumpVisitor.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeHashing.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeIndex.cpp
@@ -525,37 +562,37 @@ SRCS_EXT+= DebugInfo/CodeView/TypeRecordHelpers.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeRecordMapping.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeStreamMerger.cpp
SRCS_MIN+= DebugInfo/CodeView/TypeTableCollection.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFAcceleratorTable.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFAddressRange.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFCompileUnit.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFContext.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDataExtractor.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugAbbrev.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugAddr.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugArangeSet.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugAranges.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugFrame.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugLine.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugLoc.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugMacro.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugPubTable.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugRangeList.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDebugRnglists.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFDie.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFAddressRange.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFCompileUnit.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFContext.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDataExtractor.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugAbbrev.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugAddr.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugArangeSet.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugAranges.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugFrame.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugLine.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugLoc.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugMacro.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugPubTable.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugRangeList.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDebugRnglists.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFDie.cpp
SRCS_MIN+= DebugInfo/DWARF/DWARFExpression.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFFormValue.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFGdbIndex.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFListTable.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFTypePrinter.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFTypeUnit.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFUnit.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFUnitIndex.cpp
-SRCS_MIW+= DebugInfo/DWARF/DWARFVerifier.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFFormValue.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFGdbIndex.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFListTable.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFTypePrinter.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFTypeUnit.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFUnit.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFUnitIndex.cpp
+SRCS_MIN+= DebugInfo/DWARF/DWARFVerifier.cpp
SRCS_MIN+= DebugInfo/MSF/MSFBuilder.cpp
SRCS_MIN+= DebugInfo/MSF/MSFCommon.cpp
-SRCS_EXT+= DebugInfo/MSF/MSFError.cpp
+SRCS_MIN+= DebugInfo/MSF/MSFError.cpp
SRCS_MIN+= DebugInfo/MSF/MappedBlockStream.cpp
SRCS_EXT+= DebugInfo/PDB/GenericError.cpp
SRCS_EXT+= DebugInfo/PDB/IPDBSourceFile.cpp
@@ -658,6 +695,7 @@ SRCS_MIW+= DebugInfo/Symbolize/Symbolize.cpp
SRCS_MIW+= Debuginfod/BuildIDFetcher.cpp
SRCS_MIW+= Debuginfod/Debuginfod.cpp
SRCS_MIW+= Debuginfod/HTTPClient.cpp
+SRCS_MIW+= Debuginfod/HTTPServer.cpp
SRCS_MIN+= Demangle/DLangDemangle.cpp
SRCS_MIN+= Demangle/Demangle.cpp
SRCS_MIN+= Demangle/ItaniumDemangle.cpp
@@ -671,18 +709,20 @@ SRCS_XDB+= ExecutionEngine/Interpreter/Execution.cpp
SRCS_XDB+= ExecutionEngine/Interpreter/ExternalFunctions.cpp
SRCS_XDB+= ExecutionEngine/Interpreter/Interpreter.cpp
SRCS_EXT+= ExecutionEngine/JITLink/COFF.cpp
-SRCS_EXT+= ExecutionEngine/JITLink/COFF_x86_64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/COFFDirectiveParser.cpp
SRCS_EXT+= ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+SRCS_EXT+= ExecutionEngine/JITLink/COFF_x86_64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/DWARFRecordSectionSplitter.cpp
SRCS_EXT+= ExecutionEngine/JITLink/EHFrameSupport.cpp
SRCS_EXT+= ExecutionEngine/JITLink/ELF.cpp
+SRCS_EXT+= ExecutionEngine/JITLink/ELFLinkGraphBuilder.cpp
+SRCS_EXT+= ExecutionEngine/JITLink/ELF_aarch32.cpp
SRCS_EXT+= ExecutionEngine/JITLink/ELF_aarch64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/ELF_i386.cpp
SRCS_EXT+= ExecutionEngine/JITLink/ELF_loongarch.cpp
+SRCS_EXT+= ExecutionEngine/JITLink/ELF_ppc64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/ELF_riscv.cpp
SRCS_EXT+= ExecutionEngine/JITLink/ELF_x86_64.cpp
-SRCS_EXT+= ExecutionEngine/JITLink/ELFLinkGraphBuilder.cpp
SRCS_EXT+= ExecutionEngine/JITLink/JITLink.cpp
SRCS_EXT+= ExecutionEngine/JITLink/JITLinkGeneric.cpp
SRCS_EXT+= ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
@@ -690,19 +730,26 @@ SRCS_EXT+= ExecutionEngine/JITLink/MachO.cpp
SRCS_EXT+= ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
SRCS_EXT+= ExecutionEngine/JITLink/MachO_arm64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/MachO_x86_64.cpp
+SRCS_EXT+= ExecutionEngine/JITLink/aarch32.cpp
SRCS_EXT+= ExecutionEngine/JITLink/aarch64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/i386.cpp
SRCS_EXT+= ExecutionEngine/JITLink/loongarch.cpp
+SRCS_EXT+= ExecutionEngine/JITLink/ppc64.cpp
SRCS_EXT+= ExecutionEngine/JITLink/riscv.cpp
SRCS_EXT+= ExecutionEngine/JITLink/x86_64.cpp
SRCS_XDB+= ExecutionEngine/MCJIT/MCJIT.cpp
+SRCS_EXT+= ExecutionEngine/Orc/COFFPlatform.cpp
+SRCS_EXT+= ExecutionEngine/Orc/COFFVCRuntimeSupport.cpp
SRCS_EXT+= ExecutionEngine/Orc/CompileOnDemandLayer.cpp
SRCS_EXT+= ExecutionEngine/Orc/CompileUtils.cpp
SRCS_EXT+= ExecutionEngine/Orc/Core.cpp
SRCS_EXT+= ExecutionEngine/Orc/DebugObjectManagerPlugin.cpp
SRCS_EXT+= ExecutionEngine/Orc/DebugUtils.cpp
+SRCS_EXT+= ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp
+SRCS_EXT+= ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.cpp
SRCS_EXT+= ExecutionEngine/Orc/ELFNixPlatform.cpp
SRCS_EXT+= ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
+SRCS_EXT+= ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.cpp
SRCS_EXT+= ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp
SRCS_EXT+= ExecutionEngine/Orc/EPCGenericDylibManager.cpp
SRCS_EXT+= ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
@@ -725,6 +772,7 @@ SRCS_EXT+= ExecutionEngine/Orc/ObjectTransformLayer.cpp
SRCS_EXT+= ExecutionEngine/Orc/OrcABISupport.cpp
SRCS_EXT+= ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
SRCS_EXT+= ExecutionEngine/Orc/Shared/AllocationActions.cpp
+SRCS_EXT+= ExecutionEngine/Orc/Shared/ObjectFormats.cpp
SRCS_EXT+= ExecutionEngine/Orc/Shared/OrcError.cpp
SRCS_EXT+= ExecutionEngine/Orc/Shared/OrcRTBridge.cpp
SRCS_EXT+= ExecutionEngine/Orc/Shared/SimpleRemoteEPCUtils.cpp
@@ -745,7 +793,10 @@ SRCS_XDB+= ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
SRCS_XDB+= ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldELFMips.cpp
SRCS_XDB+= ExecutionEngine/SectionMemoryManager.cpp
SRCS_XDB+= ExecutionEngine/TargetSelect.cpp
+SRCS_MIN+= Frontend/Driver/CodeGenOptions.cpp
SRCS_MIN+= Frontend/HLSL/HLSLResource.cpp
+SRCS_MIN+= Frontend/Offloading/OffloadWrapper.cpp
+SRCS_MIN+= Frontend/Offloading/Utility.cpp
SRCS_MIN+= Frontend/OpenMP/OMP.cpp
SRCS_MIN+= Frontend/OpenMP/OMPContext.cpp
SRCS_MIN+= Frontend/OpenMP/OMPIRBuilder.cpp
@@ -759,17 +810,23 @@ SRCS_MIN+= IR/BuiltinGCs.cpp
SRCS_MIN+= IR/Comdat.cpp
SRCS_MIN+= IR/ConstantFold.cpp
SRCS_MIN+= IR/ConstantRange.cpp
+SRCS_MIN+= IR/ConstantRangeList.cpp
SRCS_MIN+= IR/Constants.cpp
+SRCS_MIN+= IR/ConvergenceVerifier.cpp
SRCS_MIN+= IR/Core.cpp
+SRCS_MIN+= IR/CycleInfo.cpp
SRCS_MIN+= IR/DIBuilder.cpp
+SRCS_MIN+= IR/DIExpressionOptimizer.cpp
SRCS_MIN+= IR/DataLayout.cpp
SRCS_MIN+= IR/DebugInfo.cpp
SRCS_MIN+= IR/DebugInfoMetadata.cpp
SRCS_MIN+= IR/DebugLoc.cpp
+SRCS_MIN+= IR/DebugProgramInstruction.cpp
SRCS_MIN+= IR/DiagnosticHandler.cpp
SRCS_MIN+= IR/DiagnosticInfo.cpp
SRCS_MIN+= IR/DiagnosticPrinter.cpp
SRCS_MIN+= IR/Dominators.cpp
+SRCS_MIN+= IR/EHPersonalities.cpp
SRCS_MIN+= IR/FPEnv.cpp
SRCS_MIN+= IR/Function.cpp
SRCS_MIN+= IR/GCStrategy.cpp
@@ -787,6 +844,7 @@ SRCS_MIN+= IR/LLVMRemarkStreamer.cpp
SRCS_MIN+= IR/LegacyPassManager.cpp
SRCS_MIN+= IR/MDBuilder.cpp
SRCS_MIN+= IR/Mangler.cpp
+SRCS_MIN+= IR/MemoryModelRelaxationAnnotations.cpp
SRCS_MIN+= IR/Metadata.cpp
SRCS_MIN+= IR/Module.cpp
SRCS_MIN+= IR/ModuleSummaryIndex.cpp
@@ -802,31 +860,36 @@ SRCS_MIN+= IR/ProfDataUtils.cpp
SRCS_MIN+= IR/ProfileSummary.cpp
SRCS_MIN+= IR/PseudoProbe.cpp
SRCS_MIN+= IR/ReplaceConstant.cpp
+SRCS_MIN+= IR/RuntimeLibcalls.cpp
SRCS_MIN+= IR/SSAContext.cpp
SRCS_MIN+= IR/SafepointIRVerifier.cpp
SRCS_MIN+= IR/Statepoint.cpp
+SRCS_MIN+= IR/StructuralHash.cpp
SRCS_MIN+= IR/Type.cpp
SRCS_MIN+= IR/TypeFinder.cpp
SRCS_MIN+= IR/Use.cpp
SRCS_MIN+= IR/User.cpp
+SRCS_MIN+= IR/VFABIDemangler.cpp
SRCS_MIN+= IR/Value.cpp
SRCS_MIN+= IR/ValueSymbolTable.cpp
+SRCS_MIN+= IR/VectorBuilder.cpp
SRCS_MIN+= IR/Verifier.cpp
-SRCS_MIN+= IRReader/IRReader.cpp
SRCS_MIN+= IRPrinter/IRPrintingPasses.cpp
+SRCS_MIN+= IRReader/IRReader.cpp
SRCS_MIN+= LTO/LTO.cpp
SRCS_MIN+= LTO/LTOBackend.cpp
SRCS_EXL+= LTO/LTOCodeGenerator.cpp
SRCS_EXL+= LTO/LTOModule.cpp
-SRCS_EXL+= LTO/SummaryBasedOptimizations.cpp
+SRCS_MIN+= LTO/SummaryBasedOptimizations.cpp
SRCS_EXL+= LTO/ThinLTOCodeGenerator.cpp
SRCS_MIN+= LTO/UpdateCompilerUsed.cpp
+SRCS_MIN+= Linker/IRMover.cpp
# Only needed for clangd/clang-query, uncomment once we build those.
# SRCS_XDW+= LineEditor/LineEditor.cpp
-SRCS_MIN+= Linker/IRMover.cpp
SRCS_MIN+= Linker/LinkModules.cpp
SRCS_MIN+= MC/ConstantPools.cpp
SRCS_MIN+= MC/ELFObjectWriter.cpp
+SRCS_MIN+= MC/GOFFObjectWriter.cpp
SRCS_MIN+= MC/MCAsmBackend.cpp
SRCS_MIN+= MC/MCAsmInfo.cpp
SRCS_MIN+= MC/MCAsmInfoCOFF.cpp
@@ -842,7 +905,7 @@ SRCS_MIN+= MC/MCContext.cpp
SRCS_MIN+= MC/MCDXContainerStreamer.cpp
SRCS_MIN+= MC/MCDXContainerWriter.cpp
SRCS_XDL+= MC/MCDisassembler/Disassembler.cpp
-SRCS_XDW+= MC/MCDisassembler/MCDisassembler.cpp
+SRCS_MIN+= MC/MCDisassembler/MCDisassembler.cpp
SRCS_XDW+= MC/MCDisassembler/MCExternalSymbolizer.cpp
SRCS_MIN+= MC/MCDisassembler/MCRelocationInfo.cpp
SRCS_XDW+= MC/MCDisassembler/MCSymbolizer.cpp
@@ -851,6 +914,7 @@ SRCS_MIN+= MC/MCELFObjectTargetWriter.cpp
SRCS_MIN+= MC/MCELFStreamer.cpp
SRCS_MIN+= MC/MCExpr.cpp
SRCS_MIN+= MC/MCFragment.cpp
+SRCS_MIN+= MC/MCGOFFStreamer.cpp
SRCS_MIN+= MC/MCInst.cpp
SRCS_MIN+= MC/MCInstPrinter.cpp
SRCS_MIN+= MC/MCInstrAnalysis.cpp
@@ -898,12 +962,11 @@ SRCS_MIN+= MC/MCWasmStreamer.cpp
SRCS_MIN+= MC/MCWin64EH.cpp
SRCS_MIN+= MC/MCWinCOFFStreamer.cpp
SRCS_MIN+= MC/MCWinEH.cpp
-SRCS_MIN+= MC/MCXCOFFStreamer.cpp
SRCS_MIN+= MC/MCXCOFFObjectTargetWriter.cpp
+SRCS_MIN+= MC/MCXCOFFStreamer.cpp
SRCS_MIN+= MC/MachObjectWriter.cpp
SRCS_MIN+= MC/SPIRVObjectWriter.cpp
SRCS_MIN+= MC/StringTableBuilder.cpp
-SRCS_MIN+= MC/SubtargetFeature.cpp
SRCS_MIN+= MC/TargetRegistry.cpp
SRCS_MIN+= MC/WasmObjectWriter.cpp
SRCS_MIN+= MC/WinCOFFObjectWriter.cpp
@@ -956,9 +1019,9 @@ SRCS_MIW+= ObjCopy/wasm/WasmWriter.cpp
SRCS_MIN+= Object/Archive.cpp
SRCS_MIN+= Object/ArchiveWriter.cpp
SRCS_MIN+= Object/Binary.cpp
-SRCS_MIW+= Object/BuildID.cpp
+SRCS_MIN+= Object/BuildID.cpp
SRCS_MIN+= Object/COFFImportFile.cpp
-SRCS_MIW+= Object/COFFModuleDefinition.cpp
+SRCS_MIN+= Object/COFFModuleDefinition.cpp
SRCS_MIN+= Object/COFFObjectFile.cpp
SRCS_MIN+= Object/Decompressor.cpp
SRCS_MIN+= Object/ELF.cpp
@@ -968,31 +1031,34 @@ SRCS_MIW+= Object/FaultMapParser.cpp
SRCS_MIN+= Object/IRObjectFile.cpp
SRCS_MIN+= Object/IRSymtab.cpp
SRCS_MIN+= Object/MachOObjectFile.cpp
-SRCS_MIW+= Object/MachOUniversal.cpp
+SRCS_MIN+= Object/MachOUniversal.cpp
SRCS_MIW+= Object/MachOUniversalWriter.cpp
-SRCS_MIW+= Object/Minidump.cpp
+SRCS_MIN+= Object/Minidump.cpp
SRCS_MIN+= Object/ModuleSymbolTable.cpp
SRCS_EXT+= Object/Object.cpp
SRCS_MIN+= Object/ObjectFile.cpp
-SRCS_MIW+= Object/OffloadBinary.cpp
+SRCS_MIN+= Object/OffloadBinary.cpp
SRCS_MIN+= Object/RecordStreamer.cpp
-SRCS_MIW+= Object/RelocationResolver.cpp
+SRCS_MIN+= Object/RelocationResolver.cpp
SRCS_MIW+= Object/SymbolSize.cpp
SRCS_MIN+= Object/SymbolicFile.cpp
-SRCS_MIW+= Object/TapiFile.cpp
-SRCS_MIW+= Object/TapiUniversal.cpp
+SRCS_MIN+= Object/TapiFile.cpp
+SRCS_MIN+= Object/TapiUniversal.cpp
SRCS_MIN+= Object/WasmObjectFile.cpp
SRCS_MIW+= Object/WindowsMachineFlag.cpp
SRCS_MIN+= Object/WindowsResource.cpp
SRCS_MIN+= Object/XCOFFObjectFile.cpp
SRCS_MIN+= ObjectYAML/COFFYAML.cpp
-SRCS_EXT+= ObjectYAML/CodeViewYAMLDebugSections.cpp
-SRCS_EXT+= ObjectYAML/CodeViewYAMLSymbols.cpp
-SRCS_EXT+= ObjectYAML/CodeViewYAMLTypes.cpp
+SRCS_MIN+= ObjectYAML/CodeViewYAMLDebugSections.cpp
+SRCS_MIN+= ObjectYAML/CodeViewYAMLSymbols.cpp
+SRCS_MIN+= ObjectYAML/CodeViewYAMLTypeHashing.cpp
+SRCS_MIN+= ObjectYAML/CodeViewYAMLTypes.cpp
+SRCS_MIN+= ObjectYAML/DWARFEmitter.cpp
SRCS_MIN+= ObjectYAML/DWARFYAML.cpp
+SRCS_MIN+= ObjectYAML/ELFEmitter.cpp
SRCS_MIN+= ObjectYAML/ELFYAML.cpp
SRCS_MIN+= ObjectYAML/MachOYAML.cpp
-SRCS_EXT+= ObjectYAML/YAML.cpp
+SRCS_MIN+= ObjectYAML/YAML.cpp
SRCS_MIN+= Option/Arg.cpp
SRCS_MIN+= Option/ArgList.cpp
SRCS_MIN+= Option/OptTable.cpp
@@ -1010,12 +1076,14 @@ SRCS_MIN+= ProfileData/InstrProf.cpp
SRCS_MIN+= ProfileData/InstrProfCorrelator.cpp
SRCS_MIN+= ProfileData/InstrProfReader.cpp
SRCS_MIN+= ProfileData/InstrProfWriter.cpp
+SRCS_MIN+= ProfileData/ItaniumManglingCanonicalizer.cpp
SRCS_MIN+= ProfileData/MemProf.cpp
+SRCS_COV+= ProfileData/MemProfReader.cpp
SRCS_MIN+= ProfileData/ProfileSummaryBuilder.cpp
-SRCS_MIW+= ProfileData/RawMemProfReader.cpp
SRCS_MIN+= ProfileData/SampleProf.cpp
SRCS_MIN+= ProfileData/SampleProfReader.cpp
SRCS_MIN+= ProfileData/SampleProfWriter.cpp
+SRCS_MIN+= ProfileData/SymbolRemappingReader.cpp
SRCS_MIN+= Remarks/BitstreamRemarkParser.cpp
SRCS_MIN+= Remarks/BitstreamRemarkSerializer.cpp
SRCS_MIN+= Remarks/RemarkFormat.cpp
@@ -1033,20 +1101,22 @@ SRCS_MIN+= Support/APSInt.cpp
SRCS_MIN+= Support/ARMAttributeParser.cpp
SRCS_MIN+= Support/ARMBuildAttrs.cpp
SRCS_MIN+= Support/ARMWinEH.cpp
-SRCS_EXT+= Support/AddressRanges.cpp
SRCS_MIN+= Support/Allocator.cpp
SRCS_MIN+= Support/BLAKE3/blake3.c
+.if ${TARGET_ARCH} == "amd64"
+SRCS_MIN+= Support/BLAKE3/blake3_avx2_x86-64_unix.S
+SRCS_MIN+= Support/BLAKE3/blake3_avx512_x86-64_unix.S
+.endif
SRCS_MIN+= Support/BLAKE3/blake3_dispatch.c
.if ${TARGET_ARCH} == "aarch64"
SRCS_MIN+= Support/BLAKE3/blake3_neon.c
.endif
SRCS_MIN+= Support/BLAKE3/blake3_portable.c
.if ${TARGET_ARCH} == "amd64"
-SRCS_MIN+= Support/BLAKE3/blake3_avx2_x86-64_unix.S
SRCS_MIN+= Support/BLAKE3/blake3_sse2_x86-64_unix.S
SRCS_MIN+= Support/BLAKE3/blake3_sse41_x86-64_unix.S
-SRCS_MIN+= Support/BLAKE3/blake3_avx512_x86-64_unix.S
.endif
+SRCS_COV+= Support/BalancedPartitioning.cpp
SRCS_MIN+= Support/BinaryStreamError.cpp
SRCS_MIN+= Support/BinaryStreamReader.cpp
SRCS_MIN+= Support/BinaryStreamRef.cpp
@@ -1078,40 +1148,42 @@ SRCS_MIN+= Support/ELFAttributes.cpp
SRCS_MIN+= Support/Errno.cpp
SRCS_MIN+= Support/Error.cpp
SRCS_MIN+= Support/ErrorHandling.cpp
+SRCS_MIN+= Support/ExponentialBackoff.cpp
SRCS_MIN+= Support/ExtensibleRTTI.cpp
SRCS_MIN+= Support/FileCollector.cpp
-SRCS_MIW+= Support/FileOutputBuffer.cpp
+SRCS_MIN+= Support/FileOutputBuffer.cpp
SRCS_MIN+= Support/FileUtilities.cpp
+SRCS_MIN+= Support/FloatingPointMode.cpp
SRCS_MIN+= Support/FoldingSet.cpp
SRCS_MIN+= Support/FormatVariadic.cpp
SRCS_MIN+= Support/FormattedStream.cpp
SRCS_MIN+= Support/GlobPattern.cpp
SRCS_MIN+= Support/GraphWriter.cpp
-SRCS_MIN+= Support/Hashing.cpp
+SRCS_MIN+= Support/HexagonAttributeParser.cpp
+SRCS_MIN+= Support/HexagonAttributes.cpp
SRCS_MIN+= Support/InitLLVM.cpp
SRCS_MIN+= Support/InstructionCost.cpp
SRCS_MIN+= Support/IntEqClasses.cpp
SRCS_MIN+= Support/IntervalMap.cpp
-SRCS_MIN+= Support/ItaniumManglingCanonicalizer.cpp
SRCS_MIN+= Support/JSON.cpp
SRCS_MIN+= Support/KnownBits.cpp
SRCS_MIN+= Support/LEB128.cpp
SRCS_MIN+= Support/LineIterator.cpp
SRCS_MIN+= Support/Locale.cpp
SRCS_MIN+= Support/LockFileManager.cpp
-SRCS_MIN+= Support/LowLevelType.cpp
SRCS_MIN+= Support/MD5.cpp
SRCS_MIW+= Support/MSP430AttributeParser.cpp
SRCS_MIW+= Support/MSP430Attributes.cpp
SRCS_MIN+= Support/ManagedStatic.cpp
SRCS_MIN+= Support/MathExtras.cpp
SRCS_MIN+= Support/MemAlloc.cpp
-SRCS_MIW+= Support/Memory.cpp
+SRCS_MIN+= Support/Memory.cpp
SRCS_MIN+= Support/MemoryBuffer.cpp
SRCS_MIN+= Support/MemoryBufferRef.cpp
SRCS_MIN+= Support/NativeFormatting.cpp
SRCS_MIN+= Support/OptimizedStructLayout.cpp
SRCS_MIN+= Support/Optional.cpp
+SRCS_MIN+= Support/PGOOptions.cpp
SRCS_EXL+= Support/Parallel.cpp
SRCS_MIN+= Support/Path.cpp
SRCS_MIN+= Support/PluginLoader.cpp
@@ -1120,7 +1192,7 @@ SRCS_MIN+= Support/Process.cpp
SRCS_MIN+= Support/Program.cpp
SRCS_MIN+= Support/RISCVAttributeParser.cpp
SRCS_MIN+= Support/RISCVAttributes.cpp
-SRCS_MIN+= Support/RISCVISAInfo.cpp
+SRCS_MIN+= Support/RISCVISAUtils.cpp
SRCS_MIN+= Support/RWMutex.cpp
SRCS_MIN+= Support/RandomNumberGenerator.cpp
SRCS_MIN+= Support/Regex.cpp
@@ -1130,6 +1202,7 @@ SRCS_MIN+= Support/ScaledNumber.cpp
SRCS_MIN+= Support/ScopedPrinter.cpp
SRCS_MIN+= Support/Signals.cpp
SRCS_MIN+= Support/Signposts.cpp
+SRCS_MIN+= Support/SipHash.cpp
SRCS_MIN+= Support/SmallPtrSet.cpp
SRCS_MIN+= Support/SmallVector.cpp
SRCS_MIN+= Support/SourceMgr.cpp
@@ -1140,15 +1213,14 @@ SRCS_MIN+= Support/StringMap.cpp
SRCS_MIN+= Support/StringRef.cpp
SRCS_MIN+= Support/StringSaver.cpp
SRCS_MIN+= Support/SuffixTree.cpp
-SRCS_MIN+= Support/SymbolRemappingReader.cpp
+SRCS_MIN+= Support/SuffixTreeNode.cpp
SRCS_EXT+= Support/SystemUtils.cpp
SRCS_LLD+= Support/TarWriter.cpp
-SRCS_MIW+= Support/ThreadPool.cpp
+SRCS_MIN+= Support/ThreadPool.cpp
SRCS_MIN+= Support/Threading.cpp
SRCS_MIN+= Support/TimeProfiler.cpp
SRCS_MIN+= Support/Timer.cpp
SRCS_MIN+= Support/ToolOutputFile.cpp
-SRCS_MIN+= Support/TrigramIndex.cpp
SRCS_MIN+= Support/Twine.cpp
SRCS_MIN+= Support/TypeSize.cpp
SRCS_MIN+= Support/Unicode.cpp
@@ -1156,8 +1228,8 @@ SRCS_MIN+= Support/UnicodeCaseFold.cpp
SRCS_MIN+= Support/UnicodeNameToCodepoint.cpp
SRCS_MIN+= Support/UnicodeNameToCodepointGenerated.cpp
SRCS_MIN+= Support/Valgrind.cpp
-SRCS_MIN+= Support/VirtualFileSystem.cpp
SRCS_MIN+= Support/VersionTuple.cpp
+SRCS_MIN+= Support/VirtualFileSystem.cpp
SRCS_MIN+= Support/Watchdog.cpp
SRCS_MIN+= Support/WithColor.cpp
SRCS_MIN+= Support/YAMLParser.cpp
@@ -1166,6 +1238,7 @@ SRCS_FUL+= Support/Z3Solver.cpp
SRCS_MIN+= Support/circular_raw_ostream.cpp
SRCS_MIN+= Support/raw_os_ostream.cpp
SRCS_MIN+= Support/raw_ostream.cpp
+SRCS_MIN+= Support/raw_socket_stream.cpp
SRCS_MIN+= Support/regcomp.c
SRCS_MIN+= Support/regerror.c
SRCS_MIN+= Support/regexec.c
@@ -1186,6 +1259,7 @@ SRCS_MIN+= TableGen/TableGenBackend.cpp
SRCS_MIN+= Target/AArch64/AArch64A53Fix835769.cpp
SRCS_MIN+= Target/AArch64/AArch64A57FPLoadBalancing.cpp
SRCS_MIN+= Target/AArch64/AArch64AdvSIMDScalarPass.cpp
+SRCS_MIN+= Target/AArch64/AArch64Arm64ECCallLowering.cpp
SRCS_MIN+= Target/AArch64/AArch64AsmPrinter.cpp
SRCS_MIN+= Target/AArch64/AArch64BranchTargets.cpp
SRCS_MIN+= Target/AArch64/AArch64CallingConvention.cpp
@@ -1201,10 +1275,10 @@ SRCS_MIN+= Target/AArch64/AArch64ExpandPseudoInsts.cpp
SRCS_MIN+= Target/AArch64/AArch64FalkorHWPFFix.cpp
SRCS_MIN+= Target/AArch64/AArch64FastISel.cpp
SRCS_MIN+= Target/AArch64/AArch64FrameLowering.cpp
+SRCS_MIN+= Target/AArch64/AArch64GlobalsTagging.cpp
SRCS_MIN+= Target/AArch64/AArch64ISelDAGToDAG.cpp
SRCS_MIN+= Target/AArch64/AArch64ISelLowering.cpp
SRCS_MIN+= Target/AArch64/AArch64InstrInfo.cpp
-SRCS_MIN+= Target/AArch64/AArch64KCFI.cpp
SRCS_MIN+= Target/AArch64/AArch64LoadStoreOptimizer.cpp
SRCS_MIN+= Target/AArch64/AArch64LowerHomogeneousPrologEpilog.cpp
SRCS_MIN+= Target/AArch64/AArch64MCInstLower.cpp
@@ -1213,6 +1287,8 @@ SRCS_MIN+= Target/AArch64/AArch64MachineFunctionInfo.cpp
SRCS_MIN+= Target/AArch64/AArch64MachineScheduler.cpp
SRCS_MIN+= Target/AArch64/AArch64MacroFusion.cpp
SRCS_MIN+= Target/AArch64/AArch64PBQPRegAlloc.cpp
+SRCS_MIN+= Target/AArch64/AArch64PointerAuth.cpp
+SRCS_MIN+= Target/AArch64/AArch64PostCoalescerPass.cpp
SRCS_MIN+= Target/AArch64/AArch64PromoteConstant.cpp
SRCS_MIN+= Target/AArch64/AArch64RedundantCopyElimination.cpp
SRCS_MIN+= Target/AArch64/AArch64RegisterInfo.cpp
@@ -1235,10 +1311,10 @@ SRCS_MIN+= Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64InstructionSelector.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64LegalizerInfo.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64O0PreLegalizerCombiner.cpp
-SRCS_MIN+= Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64PostSelectOptimize.cpp
+SRCS_MIN+= Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp
SRCS_MIN+= Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
SRCS_MIN+= Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
SRCS_MIN+= Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp
@@ -1328,6 +1404,7 @@ SRCS_MIN+= Target/ARM/Utils/ARMBaseInfo.cpp
.endif # MK_LLVM_TARGET_ARM
.if ${MK_LLVM_TARGET_BPF} != "no"
SRCS_MIN+= Target/BPF/AsmParser/BPFAsmParser.cpp
+SRCS_MIN+= Target/BPF/BPFASpaceCastSimplifyPass.cpp
SRCS_MIN+= Target/BPF/BPFAbstractMemberAccess.cpp
SRCS_MIN+= Target/BPF/BPFAdjustOpt.cpp
SRCS_MIN+= Target/BPF/BPFAsmPrinter.cpp
@@ -1342,12 +1419,17 @@ SRCS_MIN+= Target/BPF/BPFMIChecking.cpp
SRCS_MIN+= Target/BPF/BPFMIPeephole.cpp
SRCS_MIN+= Target/BPF/BPFMISimplifyPatchable.cpp
SRCS_MIN+= Target/BPF/BPFPreserveDIType.cpp
+SRCS_MIN+= Target/BPF/BPFPreserveStaticOffset.cpp
SRCS_MIN+= Target/BPF/BPFRegisterInfo.cpp
SRCS_MIN+= Target/BPF/BPFSelectionDAGInfo.cpp
SRCS_MIN+= Target/BPF/BPFSubtarget.cpp
SRCS_MIN+= Target/BPF/BPFTargetMachine.cpp
SRCS_MIN+= Target/BPF/BTFDebug.cpp
SRCS_MIN+= Target/BPF/Disassembler/BPFDisassembler.cpp
+SRCS_MIN+= Target/BPF/GISel/BPFCallLowering.cpp
+SRCS_MIN+= Target/BPF/GISel/BPFInstructionSelector.cpp
+SRCS_MIN+= Target/BPF/GISel/BPFLegalizerInfo.cpp
+SRCS_MIN+= Target/BPF/GISel/BPFRegisterBankInfo.cpp
SRCS_MIN+= Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
SRCS_MIN+= Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp
SRCS_MIN+= Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
@@ -1400,8 +1482,8 @@ SRCS_MIN+= Target/Mips/MipsModuleISelDAGToDAG.cpp
SRCS_MIN+= Target/Mips/MipsMulMulBugPass.cpp
SRCS_MIN+= Target/Mips/MipsOptimizePICCall.cpp
SRCS_MIN+= Target/Mips/MipsOs16.cpp
-SRCS_MIN+= Target/Mips/MipsPreLegalizerCombiner.cpp
SRCS_MIN+= Target/Mips/MipsPostLegalizerCombiner.cpp
+SRCS_MIN+= Target/Mips/MipsPreLegalizerCombiner.cpp
SRCS_MIN+= Target/Mips/MipsRegisterBankInfo.cpp
SRCS_MIN+= Target/Mips/MipsRegisterInfo.cpp
SRCS_MIN+= Target/Mips/MipsSEFrameLowering.cpp
@@ -1453,11 +1535,12 @@ SRCS_MIN+= Target/PowerPC/PPCISelLowering.cpp
SRCS_MIN+= Target/PowerPC/PPCInstrInfo.cpp
SRCS_MIN+= Target/PowerPC/PPCLoopInstrFormPrep.cpp
SRCS_MIN+= Target/PowerPC/PPCLowerMASSVEntries.cpp
-SRCS_MIN+= Target/PowerPC/PPCMacroFusion.cpp
SRCS_MIN+= Target/PowerPC/PPCMCInstLower.cpp
SRCS_MIN+= Target/PowerPC/PPCMIPeephole.cpp
SRCS_MIN+= Target/PowerPC/PPCMachineFunctionInfo.cpp
SRCS_MIN+= Target/PowerPC/PPCMachineScheduler.cpp
+SRCS_MIN+= Target/PowerPC/PPCMacroFusion.cpp
+SRCS_MIN+= Target/PowerPC/PPCMergeStringPool.cpp
SRCS_MIN+= Target/PowerPC/PPCPreEmitPeephole.cpp
SRCS_MIN+= Target/PowerPC/PPCReduceCRLogicals.cpp
SRCS_MIN+= Target/PowerPC/PPCRegisterInfo.cpp
@@ -1478,6 +1561,9 @@ SRCS_MIN+= Target/RISCV/Disassembler/RISCVDisassembler.cpp
SRCS_MIN+= Target/RISCV/GISel/RISCVCallLowering.cpp
SRCS_MIN+= Target/RISCV/GISel/RISCVInstructionSelector.cpp
SRCS_MIN+= Target/RISCV/GISel/RISCVLegalizerInfo.cpp
+SRCS_MIN+= Target/RISCV/GISel/RISCVO0PreLegalizerCombiner.cpp
+SRCS_MIN+= Target/RISCV/GISel/RISCVPostLegalizerCombiner.cpp
+SRCS_MIN+= Target/RISCV/GISel/RISCVPreLegalizerCombiner.cpp
SRCS_MIN+= Target/RISCV/GISel/RISCVRegisterBankInfo.cpp
SRCS_EXT+= Target/RISCV/MCA/RISCVCustomBehaviour.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -1485,36 +1571,40 @@ SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
-SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMCObjectFileInfo.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
+SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
SRCS_MIN+= Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
SRCS_MIN+= Target/RISCV/RISCVAsmPrinter.cpp
SRCS_MIN+= Target/RISCV/RISCVCodeGenPrepare.cpp
+SRCS_MIN+= Target/RISCV/RISCVDeadRegisterDefinitions.cpp
SRCS_MIN+= Target/RISCV/RISCVExpandAtomicPseudoInsts.cpp
SRCS_MIN+= Target/RISCV/RISCVExpandPseudoInsts.cpp
SRCS_MIN+= Target/RISCV/RISCVFrameLowering.cpp
SRCS_MIN+= Target/RISCV/RISCVGatherScatterLowering.cpp
-SRCS_MIN+= Target/RISCV/RISCVInsertVSETVLI.cpp
-SRCS_MIN+= Target/RISCV/RISCVInstrInfo.cpp
SRCS_MIN+= Target/RISCV/RISCVISelDAGToDAG.cpp
SRCS_MIN+= Target/RISCV/RISCVISelLowering.cpp
-SRCS_MIN+= Target/RISCV/RISCVMCInstLower.cpp
+SRCS_MIN+= Target/RISCV/RISCVInsertReadWriteCSR.cpp
+SRCS_MIN+= Target/RISCV/RISCVInsertVSETVLI.cpp
+SRCS_MIN+= Target/RISCV/RISCVInsertWriteVXRM.cpp
+SRCS_MIN+= Target/RISCV/RISCVInstrInfo.cpp
SRCS_MIN+= Target/RISCV/RISCVMachineFunctionInfo.cpp
-SRCS_MIN+= Target/RISCV/RISCVMacroFusion.cpp
SRCS_MIN+= Target/RISCV/RISCVMakeCompressible.cpp
SRCS_MIN+= Target/RISCV/RISCVMergeBaseOffset.cpp
+SRCS_MIN+= Target/RISCV/RISCVMoveMerger.cpp
+SRCS_MIN+= Target/RISCV/RISCVOptWInstrs.cpp
+SRCS_MIN+= Target/RISCV/RISCVPostRAExpandPseudoInsts.cpp
+SRCS_MIN+= Target/RISCV/RISCVPushPopOptimizer.cpp
SRCS_MIN+= Target/RISCV/RISCVRedundantCopyElimination.cpp
SRCS_MIN+= Target/RISCV/RISCVRegisterInfo.cpp
-SRCS_MIN+= Target/RISCV/RISCVSExtWRemoval.cpp
-SRCS_MIN+= Target/RISCV/RISCVStripWSuffix.cpp
SRCS_MIN+= Target/RISCV/RISCVSubtarget.cpp
SRCS_MIN+= Target/RISCV/RISCVTargetMachine.cpp
SRCS_MIN+= Target/RISCV/RISCVTargetObjectFile.cpp
SRCS_MIN+= Target/RISCV/RISCVTargetTransformInfo.cpp
+SRCS_MIN+= Target/RISCV/RISCVVectorPeephole.cpp
SRCS_MIN+= Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
.endif # MK_LLVM_TARGET_RISCV
SRCS_MIN+= Target/Target.cpp
@@ -1524,13 +1614,17 @@ SRCS_MIN+= Target/TargetMachineC.cpp
.if ${MK_LLVM_TARGET_X86} != "no"
SRCS_MIN+= Target/X86/AsmParser/X86AsmParser.cpp
SRCS_XDW+= Target/X86/Disassembler/X86Disassembler.cpp
+SRCS_MIN+= Target/X86/GISel/X86CallLowering.cpp
+SRCS_MIN+= Target/X86/GISel/X86InstructionSelector.cpp
+SRCS_MIN+= Target/X86/GISel/X86LegalizerInfo.cpp
+SRCS_MIN+= Target/X86/GISel/X86RegisterBankInfo.cpp
SRCS_EXT+= Target/X86/MCA/X86CustomBehaviour.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86ATTInstPrinter.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86AsmBackend.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
+SRCS_MIN+= Target/X86/MCTargetDesc/X86EncodingOptimization.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86InstComments.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86InstPrinterCommon.cpp
-SRCS_MIN+= Target/X86/MCTargetDesc/X86InstrRelaxTables.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86IntelInstPrinter.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
@@ -1542,29 +1636,33 @@ SRCS_MIN+= Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86WinCOFFStreamer.cpp
SRCS_MIN+= Target/X86/MCTargetDesc/X86WinCOFFTargetStreamer.cpp
SRCS_MIN+= Target/X86/TargetInfo/X86TargetInfo.cpp
+SRCS_MIN+= Target/X86/X86ArgumentStackSlotRebase.cpp
SRCS_MIN+= Target/X86/X86AsmPrinter.cpp
SRCS_MIN+= Target/X86/X86AvoidStoreForwardingBlocks.cpp
SRCS_MIN+= Target/X86/X86AvoidTrailingCall.cpp
SRCS_MIN+= Target/X86/X86CallFrameOptimization.cpp
-SRCS_MIN+= Target/X86/X86CallLowering.cpp
SRCS_MIN+= Target/X86/X86CallingConv.cpp
SRCS_MIN+= Target/X86/X86CmovConversion.cpp
+SRCS_MIN+= Target/X86/X86CodeGenPassBuilder.cpp
+SRCS_MIN+= Target/X86/X86CompressEVEX.cpp
SRCS_MIN+= Target/X86/X86DiscriminateMemOps.cpp
SRCS_MIN+= Target/X86/X86DomainReassignment.cpp
SRCS_MIN+= Target/X86/X86DynAllocaExpander.cpp
-SRCS_MIN+= Target/X86/X86EvexToVex.cpp
SRCS_MIN+= Target/X86/X86ExpandPseudo.cpp
SRCS_MIN+= Target/X86/X86FastISel.cpp
SRCS_MIN+= Target/X86/X86FastPreTileConfig.cpp
SRCS_MIN+= Target/X86/X86FastTileConfig.cpp
SRCS_MIN+= Target/X86/X86FixupBWInsts.cpp
+SRCS_MIN+= Target/X86/X86FixupInstTuning.cpp
SRCS_MIN+= Target/X86/X86FixupLEAs.cpp
SRCS_MIN+= Target/X86/X86FixupSetCC.cpp
+SRCS_MIN+= Target/X86/X86FixupVectorConstants.cpp
SRCS_MIN+= Target/X86/X86FlagsCopyLowering.cpp
SRCS_MIN+= Target/X86/X86FloatingPoint.cpp
SRCS_MIN+= Target/X86/X86FrameLowering.cpp
SRCS_MIN+= Target/X86/X86ISelDAGToDAG.cpp
SRCS_MIN+= Target/X86/X86ISelLowering.cpp
+SRCS_MIN+= Target/X86/X86ISelLoweringCall.cpp
SRCS_MIN+= Target/X86/X86IndirectBranchTracking.cpp
SRCS_MIN+= Target/X86/X86IndirectThunks.cpp
SRCS_MIN+= Target/X86/X86InsertPrefetch.cpp
@@ -1573,10 +1671,7 @@ SRCS_MIN+= Target/X86/X86InstCombineIntrinsic.cpp
SRCS_MIN+= Target/X86/X86InstrFMA3Info.cpp
SRCS_MIN+= Target/X86/X86InstrFoldTables.cpp
SRCS_MIN+= Target/X86/X86InstrInfo.cpp
-SRCS_MIN+= Target/X86/X86InstructionSelector.cpp
SRCS_MIN+= Target/X86/X86InterleavedAccess.cpp
-SRCS_MIN+= Target/X86/X86KCFI.cpp
-SRCS_MIN+= Target/X86/X86LegalizerInfo.cpp
SRCS_MIN+= Target/X86/X86LoadValueInjectionLoadHardening.cpp
SRCS_MIN+= Target/X86/X86LoadValueInjectionRetHardening.cpp
SRCS_MIN+= Target/X86/X86LowerAMXIntrinsics.cpp
@@ -1588,9 +1683,7 @@ SRCS_MIN+= Target/X86/X86MacroFusion.cpp
SRCS_MIN+= Target/X86/X86OptimizeLEAs.cpp
SRCS_MIN+= Target/X86/X86PadShortFunction.cpp
SRCS_MIN+= Target/X86/X86PartialReduction.cpp
-SRCS_MIN+= Target/X86/X86PreAMXConfig.cpp
SRCS_MIN+= Target/X86/X86PreTileConfig.cpp
-SRCS_MIN+= Target/X86/X86RegisterBankInfo.cpp
SRCS_MIN+= Target/X86/X86RegisterInfo.cpp
SRCS_MIN+= Target/X86/X86ReturnThunks.cpp
SRCS_MIN+= Target/X86/X86SelectionDAGInfo.cpp
@@ -1604,6 +1697,7 @@ SRCS_MIN+= Target/X86/X86TargetTransformInfo.cpp
SRCS_MIN+= Target/X86/X86TileConfig.cpp
SRCS_MIN+= Target/X86/X86VZeroUpper.cpp
SRCS_MIN+= Target/X86/X86WinEHState.cpp
+SRCS_MIN+= Target/X86/X86WinFixupBufferSecurityCheck.cpp
.endif # MK_LLVM_TARGET_X86
SRCS_MIN+= TargetParser/AArch64TargetParser.cpp
SRCS_MIN+= TargetParser/ARMTargetParser.cpp
@@ -1611,18 +1705,28 @@ SRCS_MIN+= TargetParser/ARMTargetParserCommon.cpp
SRCS_MIN+= TargetParser/CSKYTargetParser.cpp
SRCS_MIN+= TargetParser/Host.cpp
SRCS_MIN+= TargetParser/LoongArchTargetParser.cpp
+SRCS_MIN+= TargetParser/RISCVISAInfo.cpp
SRCS_MIN+= TargetParser/RISCVTargetParser.cpp
+SRCS_MIN+= TargetParser/SubtargetFeature.cpp
SRCS_MIN+= TargetParser/TargetParser.cpp
SRCS_MIN+= TargetParser/Triple.cpp
SRCS_MIN+= TargetParser/X86TargetParser.cpp
-SRCS_MIW+= TextAPI/Architecture.cpp
-SRCS_MIW+= TextAPI/ArchitectureSet.cpp
-SRCS_MIW+= TextAPI/InterfaceFile.cpp
-SRCS_MIW+= TextAPI/PackedVersion.cpp
-SRCS_MIW+= TextAPI/Platform.cpp
-SRCS_MIW+= TextAPI/Target.cpp
-SRCS_MIW+= TextAPI/TextStub.cpp
-SRCS_MIW+= TextAPI/TextStubCommon.cpp
+SRCS_MIN+= TextAPI/Architecture.cpp
+SRCS_MIN+= TextAPI/ArchitectureSet.cpp
+SRCS_MIW+= TextAPI/BinaryReader/DylibReader.cpp
+SRCS_MIN+= TextAPI/InterfaceFile.cpp
+SRCS_MIN+= TextAPI/PackedVersion.cpp
+SRCS_MIN+= TextAPI/Platform.cpp
+SRCS_MIW+= TextAPI/RecordVisitor.cpp
+SRCS_MIW+= TextAPI/RecordsSlice.cpp
+SRCS_MIN+= TextAPI/Symbol.cpp
+SRCS_MIN+= TextAPI/SymbolSet.cpp
+SRCS_MIN+= TextAPI/Target.cpp
+SRCS_MIN+= TextAPI/TextAPIError.cpp
+SRCS_MIN+= TextAPI/TextStub.cpp
+SRCS_MIN+= TextAPI/TextStubCommon.cpp
+SRCS_MIN+= TextAPI/TextStubV5.cpp
+SRCS_MIN+= TextAPI/Utils.cpp
SRCS_MIN+= ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
SRCS_MIW+= ToolDrivers/llvm-lib/LibDriver.cpp
SRCS_MIN+= Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -1635,6 +1739,7 @@ SRCS_MIN+= Transforms/Coroutines/CoroElide.cpp
SRCS_MIN+= Transforms/Coroutines/CoroFrame.cpp
SRCS_MIN+= Transforms/Coroutines/CoroSplit.cpp
SRCS_MIN+= Transforms/Coroutines/Coroutines.cpp
+SRCS_MIN+= Transforms/HipStdPar/HipStdPar.cpp
SRCS_MIN+= Transforms/IPO/AlwaysInliner.cpp
SRCS_MIN+= Transforms/IPO/Annotation2Metadata.cpp
SRCS_MIN+= Transforms/IPO/ArgumentPromotion.cpp
@@ -1647,6 +1752,8 @@ SRCS_MIN+= Transforms/IPO/ConstantMerge.cpp
SRCS_MIN+= Transforms/IPO/CrossDSOCFI.cpp
SRCS_MIN+= Transforms/IPO/DeadArgumentElimination.cpp
SRCS_MIN+= Transforms/IPO/ElimAvailExtern.cpp
+SRCS_MIN+= Transforms/IPO/EmbedBitcodePass.cpp
+SRCS_MIN+= Transforms/IPO/ExpandVariadics.cpp
SRCS_MIN+= Transforms/IPO/ExtractGV.cpp
SRCS_MIN+= Transforms/IPO/ForceFunctionAttrs.cpp
SRCS_MIN+= Transforms/IPO/FunctionAttrs.cpp
@@ -1659,19 +1766,19 @@ SRCS_MIN+= Transforms/IPO/HotColdSplitting.cpp
SRCS_EXT+= Transforms/IPO/IPO.cpp
SRCS_MIN+= Transforms/IPO/IROutliner.cpp
SRCS_MIN+= Transforms/IPO/InferFunctionAttrs.cpp
-SRCS_MIN+= Transforms/IPO/InlineSimple.cpp
SRCS_MIN+= Transforms/IPO/Inliner.cpp
SRCS_MIN+= Transforms/IPO/Internalize.cpp
SRCS_MIN+= Transforms/IPO/LoopExtractor.cpp
SRCS_MIN+= Transforms/IPO/LowerTypeTests.cpp
+SRCS_MIN+= Transforms/IPO/MemProfContextDisambiguation.cpp
SRCS_MIN+= Transforms/IPO/MergeFunctions.cpp
SRCS_MIN+= Transforms/IPO/ModuleInliner.cpp
SRCS_MIN+= Transforms/IPO/OpenMPOpt.cpp
SRCS_MIN+= Transforms/IPO/PartialInlining.cpp
-SRCS_MIN+= Transforms/IPO/PassManagerBuilder.cpp
SRCS_MIN+= Transforms/IPO/SCCP.cpp
SRCS_MIN+= Transforms/IPO/SampleContextTracker.cpp
SRCS_MIN+= Transforms/IPO/SampleProfile.cpp
+SRCS_MIN+= Transforms/IPO/SampleProfileMatcher.cpp
SRCS_MIN+= Transforms/IPO/SampleProfileProbe.cpp
SRCS_MIN+= Transforms/IPO/StripDeadPrototypes.cpp
SRCS_MIN+= Transforms/IPO/StripSymbols.cpp
@@ -1694,6 +1801,7 @@ SRCS_MIN+= Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
SRCS_MIN+= Transforms/InstCombine/InstCombineVectorOps.cpp
SRCS_MIN+= Transforms/InstCombine/InstructionCombining.cpp
SRCS_MIN+= Transforms/Instrumentation/AddressSanitizer.cpp
+SRCS_MIN+= Transforms/Instrumentation/BlockCoverageInference.cpp
SRCS_MIN+= Transforms/Instrumentation/BoundsChecking.cpp
SRCS_MIN+= Transforms/Instrumentation/CGProfile.cpp
SRCS_MIN+= Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -1705,13 +1813,17 @@ SRCS_MIN+= Transforms/Instrumentation/InstrOrderFile.cpp
SRCS_MIN+= Transforms/Instrumentation/InstrProfiling.cpp
SRCS_MIN+= Transforms/Instrumentation/Instrumentation.cpp
SRCS_MIN+= Transforms/Instrumentation/KCFI.cpp
+SRCS_MIN+= Transforms/Instrumentation/LowerAllowCheckPass.cpp
SRCS_MIN+= Transforms/Instrumentation/MemProfiler.cpp
SRCS_MIN+= Transforms/Instrumentation/MemorySanitizer.cpp
+SRCS_MIN+= Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+SRCS_MIN+= Transforms/Instrumentation/PGOCtxProfLowering.cpp
+SRCS_MIN+= Transforms/Instrumentation/PGOForceFunctionAttrs.cpp
SRCS_MIN+= Transforms/Instrumentation/PGOInstrumentation.cpp
SRCS_MIN+= Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
SRCS_MIN+= Transforms/Instrumentation/PoisonChecking.cpp
-SRCS_MIN+= Transforms/Instrumentation/SanitizerCoverage.cpp
SRCS_MIN+= Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
+SRCS_MIN+= Transforms/Instrumentation/SanitizerCoverage.cpp
SRCS_MIN+= Transforms/Instrumentation/ThreadSanitizer.cpp
SRCS_MIN+= Transforms/Instrumentation/ValueProfileCollector.cpp
SRCS_MIN+= Transforms/ObjCARC/DependencyAnalysis.cpp
@@ -1746,7 +1858,9 @@ SRCS_MIN+= Transforms/Scalar/IVUsersPrinter.cpp
SRCS_MIN+= Transforms/Scalar/IndVarSimplify.cpp
SRCS_MIN+= Transforms/Scalar/InductiveRangeCheckElimination.cpp
SRCS_MIN+= Transforms/Scalar/InferAddressSpaces.cpp
+SRCS_MIN+= Transforms/Scalar/InferAlignment.cpp
SRCS_MIN+= Transforms/Scalar/InstSimplifyPass.cpp
+SRCS_MIN+= Transforms/Scalar/JumpTableToSwitch.cpp
SRCS_MIN+= Transforms/Scalar/JumpThreading.cpp
SRCS_MIN+= Transforms/Scalar/LICM.cpp
SRCS_MIN+= Transforms/Scalar/LoopAccessAnalysisPrinter.cpp
@@ -1762,13 +1876,12 @@ SRCS_MIN+= Transforms/Scalar/LoopInterchange.cpp
SRCS_MIN+= Transforms/Scalar/LoopLoadElimination.cpp
SRCS_MIN+= Transforms/Scalar/LoopPassManager.cpp
SRCS_MIN+= Transforms/Scalar/LoopPredication.cpp
-SRCS_MIN+= Transforms/Scalar/LoopRerollPass.cpp
SRCS_MIN+= Transforms/Scalar/LoopRotation.cpp
SRCS_MIN+= Transforms/Scalar/LoopSimplifyCFG.cpp
SRCS_MIN+= Transforms/Scalar/LoopSink.cpp
SRCS_MIN+= Transforms/Scalar/LoopStrengthReduce.cpp
-SRCS_MIN+= Transforms/Scalar/LoopUnrollPass.cpp
SRCS_MIN+= Transforms/Scalar/LoopUnrollAndJamPass.cpp
+SRCS_MIN+= Transforms/Scalar/LoopUnrollPass.cpp
SRCS_MIN+= Transforms/Scalar/LoopVersioningLICM.cpp
SRCS_MIN+= Transforms/Scalar/LowerAtomicPass.cpp
SRCS_MIN+= Transforms/Scalar/LowerConstantIntrinsics.cpp
@@ -1819,7 +1932,9 @@ SRCS_MIN+= Transforms/Utils/CloneModule.cpp
SRCS_MIN+= Transforms/Utils/CodeExtractor.cpp
SRCS_MIN+= Transforms/Utils/CodeLayout.cpp
SRCS_MIN+= Transforms/Utils/CodeMoverUtils.cpp
+SRCS_MIN+= Transforms/Utils/CountVisits.cpp
SRCS_MIN+= Transforms/Utils/CtorUtils.cpp
+SRCS_MIN+= Transforms/Utils/DXILUpgrade.cpp
SRCS_MIN+= Transforms/Utils/Debugify.cpp
SRCS_MIN+= Transforms/Utils/DemoteRegToStack.cpp
SRCS_MIN+= Transforms/Utils/EntryExitInstrumenter.cpp
@@ -1839,9 +1954,10 @@ SRCS_MIN+= Transforms/Utils/IntegerDivision.cpp
SRCS_MIN+= Transforms/Utils/LCSSA.cpp
SRCS_MIN+= Transforms/Utils/LibCallsShrinkWrap.cpp
SRCS_MIN+= Transforms/Utils/Local.cpp
+SRCS_MIN+= Transforms/Utils/LoopConstrainer.cpp
SRCS_MIN+= Transforms/Utils/LoopPeel.cpp
-SRCS_MIN+= Transforms/Utils/LoopSimplify.cpp
SRCS_MIN+= Transforms/Utils/LoopRotationUtils.cpp
+SRCS_MIN+= Transforms/Utils/LoopSimplify.cpp
SRCS_MIN+= Transforms/Utils/LoopUnroll.cpp
SRCS_MIN+= Transforms/Utils/LoopUnrollAndJam.cpp
SRCS_MIN+= Transforms/Utils/LoopUnrollRuntime.cpp
@@ -1851,14 +1967,16 @@ SRCS_MIN+= Transforms/Utils/LowerAtomic.cpp
SRCS_MIN+= Transforms/Utils/LowerGlobalDtors.cpp
SRCS_MIN+= Transforms/Utils/LowerIFunc.cpp
SRCS_MIN+= Transforms/Utils/LowerInvoke.cpp
+SRCS_MIN+= Transforms/Utils/LowerMemIntrinsics.cpp
SRCS_MIN+= Transforms/Utils/LowerSwitch.cpp
SRCS_MIN+= Transforms/Utils/MatrixUtils.cpp
SRCS_MIN+= Transforms/Utils/Mem2Reg.cpp
-SRCS_MIN+= Transforms/Utils/MetaRenamer.cpp
SRCS_MIN+= Transforms/Utils/MemoryOpRemark.cpp
SRCS_MIN+= Transforms/Utils/MemoryTaggingSupport.cpp
+SRCS_MIN+= Transforms/Utils/MetaRenamer.cpp
SRCS_MIN+= Transforms/Utils/MisExpect.cpp
SRCS_MIN+= Transforms/Utils/ModuleUtils.cpp
+SRCS_MIN+= Transforms/Utils/MoveAutoInit.cpp
SRCS_MIN+= Transforms/Utils/NameAnonGlobals.cpp
SRCS_MIN+= Transforms/Utils/PredicateInfo.cpp
SRCS_MIN+= Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -1866,10 +1984,10 @@ SRCS_MIN+= Transforms/Utils/RelLookupTableConverter.cpp
SRCS_MIN+= Transforms/Utils/SCCPSolver.cpp
SRCS_MIN+= Transforms/Utils/SSAUpdater.cpp
SRCS_MIN+= Transforms/Utils/SSAUpdaterBulk.cpp
-SRCS_MIN+= Transforms/Utils/SanitizerStats.cpp
-SRCS_MIN+= Transforms/Utils/ScalarEvolutionExpander.cpp
SRCS_MIN+= Transforms/Utils/SampleProfileInference.cpp
SRCS_MIN+= Transforms/Utils/SampleProfileLoaderBaseUtil.cpp
+SRCS_MIN+= Transforms/Utils/SanitizerStats.cpp
+SRCS_MIN+= Transforms/Utils/ScalarEvolutionExpander.cpp
SRCS_MIN+= Transforms/Utils/SimplifyCFG.cpp
SRCS_MIN+= Transforms/Utils/SimplifyIndVar.cpp
SRCS_MIN+= Transforms/Utils/SimplifyLibCalls.cpp
@@ -1884,10 +2002,12 @@ SRCS_EXT+= Transforms/Utils/Utils.cpp
SRCS_MIN+= Transforms/Utils/VNCoercion.cpp
SRCS_MIN+= Transforms/Utils/ValueMapper.cpp
SRCS_MIN+= Transforms/Vectorize/LoadStoreVectorizer.cpp
+SRCS_MIN+= Transforms/Vectorize/LoopIdiomVectorize.cpp
SRCS_MIN+= Transforms/Vectorize/LoopVectorizationLegality.cpp
SRCS_MIN+= Transforms/Vectorize/LoopVectorize.cpp
SRCS_MIN+= Transforms/Vectorize/SLPVectorizer.cpp
SRCS_MIN+= Transforms/Vectorize/VPlan.cpp
+SRCS_MIN+= Transforms/Vectorize/VPlanAnalysis.cpp
SRCS_MIN+= Transforms/Vectorize/VPlanHCFGBuilder.cpp
SRCS_MIN+= Transforms/Vectorize/VPlanRecipes.cpp
SRCS_MIN+= Transforms/Vectorize/VPlanTransforms.cpp
@@ -1934,9 +2054,18 @@ SRCS_ALL+= ${SRCS_XDL}
.if ${MK_CLANG_EXTRAS} != "no" || ${MK_LLDB} != "no" || !defined(TOOLS_PREFIX)
SRCS_ALL+= ${SRCS_XDW}
.endif
+.if ${MK_LLVM_COV} != "no"
+SRCS_ALL+= ${SRCS_COV}
+.endif
SRCS+= ${GENSRCS}
SRCS+= ${SRCS_ALL:O}
+llvm/CodeGen/GenVT.inc: ${LLVM_SRCS}/include/llvm/CodeGen/ValueTypes.td
+ ${LLVM_MIN_TBLGEN} -gen-vt \
+ -I ${LLVM_SRCS}/include -d ${.TARGET}.d -o ${.TARGET} \
+ ${LLVM_SRCS}/include/llvm/CodeGen/ValueTypes.td
+TGHDRS+= llvm/CodeGen/GenVT.inc
+
llvm/Frontend/OpenMP/OMP.h.inc: ${LLVM_SRCS}/include/llvm/Frontend/OpenMP/OMP.td
${LLVM_TBLGEN} --gen-directive-decl \
-I ${LLVM_SRCS}/include -d ${.TARGET}.d -o ${.TARGET} \
@@ -1949,12 +2078,6 @@ llvm/Frontend/OpenMP/OMP.inc: ${LLVM_SRCS}/include/llvm/Frontend/OpenMP/OMP.td
${LLVM_SRCS}/include/llvm/Frontend/OpenMP/OMP.td
TGHDRS+= llvm/Frontend/OpenMP/OMP.inc
-OMP.cpp: ${LLVM_SRCS}/include/llvm/Frontend/OpenMP/OMP.td
- ${LLVM_TBLGEN} --gen-directive-impl \
- -I ${LLVM_SRCS}/include -d ${.TARGET}.d -o ${.TARGET} \
- ${LLVM_SRCS}/include/llvm/Frontend/OpenMP/OMP.td
-GENSRCS+= OMP.cpp
-
llvm/IR/Attributes.inc: ${LLVM_SRCS}/include/llvm/IR/Attributes.td
${LLVM_TBLGEN} -gen-attrs \
-I ${LLVM_SRCS}/include -d ${.TARGET}.d -o ${.TARGET} \
@@ -1976,8 +2099,8 @@ TGHDRS+= llvm/IR/IntrinsicImpl.inc
.for arch in \
AArch64/aarch64 AMDGPU/amdgcn ARM/arm BPF/bpf DirectX/dx \
Hexagon/hexagon LoongArch/loongarch Mips/mips NVPTX/nvvm PowerPC/ppc \
- R600/r600 RISCV/riscv S390/s390 VE/ve WebAssembly/wasm X86/x86 \
- XCore/xcore
+ R600/r600 RISCV/riscv S390/s390 SPIRV/spv VE/ve WebAssembly/wasm \
+ X86/x86 XCore/xcore
llvm/IR/Intrinsics${arch:H}.h: ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
${LLVM_TBLGEN} -gen-intrinsic-enums -intrinsic-prefix=${arch:T} \
-I ${LLVM_SRCS}/include -d ${.TARGET}.d -o ${.TARGET} \
@@ -1985,11 +2108,13 @@ llvm/IR/Intrinsics${arch:H}.h: ${LLVM_SRCS}/include/llvm/IR/Intrinsics.td
TGHDRS+= llvm/IR/Intrinsics${arch:H}.h
.endfor
-llvm/TargetParser/RISCVTargetParserDef.inc: ${LLVM_SRCS}/lib/Target/RISCV/RISCV.td
- ${LLVM_TBLGEN} -gen-riscv-target-def \
- -I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target/RISCV \
- -d ${.TARGET}.d -o ${.TARGET} ${LLVM_SRCS}/lib/Target/RISCV/RISCV.td
-TGHDRS+= llvm/TargetParser/RISCVTargetParserDef.inc
+.for arch in AArch64/arm ARM/arm RISCV/riscv
+llvm/TargetParser/${arch:H}TargetParserDef.inc: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:H}.td
+ ${LLVM_TBLGEN} -gen-${arch:T}-target-def \
+ -I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target/${arch:H} \
+ -d ${.TARGET}.d -o ${.TARGET} ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:H}.td
+TGHDRS+= llvm/TargetParser/${arch:H}TargetParserDef.inc
+.endfor
llvm-lib/Options.inc: ${LLVM_SRCS}/lib/ToolDrivers/llvm-lib/Options.td
${LLVM_TBLGEN} -gen-opt-parser-defs \
@@ -2036,28 +2161,35 @@ beforebuild:
CompressInstEmitter/-gen-compress-inst-emitter \
DAGISel/-gen-dag-isel \
DisassemblerTables/-gen-disassembler \
- EVEX2VEXTables/-gen-x86-EVEX2VEX-tables \
FastISel/-gen-fast-isel \
+ FoldTables/-gen-x86-fold-tables,-asmwriternum=1 \
GlobalISel/-gen-global-isel \
InstrInfo/-gen-instr-info${arch:MX86/X86:C/X86\/X86/,-instr-info-expand-mi-operand-info=0/} \
+ InstrMapping/-gen-x86-instr-mapping \
MCCodeEmitter/-gen-emitter \
MCPseudoLowering/-gen-pseudo-lowering \
+ MacroFusion/-gen-macro-fusion-pred \
MnemonicTables/-gen-x86-mnemonic-tables,-asmwriternum=1 \
- O0PreLegalizeGICombiner/-gen-global-isel-combiner,-combiners=${arch:H}O0PreLegalizerCombinerHelper \
- PostLegalizeGICombiner/-gen-global-isel-combiner,-combiners=${arch:H}PostLegalizerCombinerHelper \
- PostLegalizeGILowering/-gen-global-isel-combiner,-combiners=${arch:H}PostLegalizerLoweringHelper \
- PreLegalizeGICombiner/-gen-global-isel-combiner,-combiners=${arch:H}PreLegalizerCombinerHelper \
+ O0PreLegalizeGICombiner/-gen-global-isel-combiner,-combiners=${arch:H}O0PreLegalizerCombiner \
+ PostLegalizeGICombiner/-gen-global-isel-combiner,-combiners=${arch:H}PostLegalizerCombiner \
+ PostLegalizeGILowering/-gen-global-isel-combiner,-combiners=${arch:H}PostLegalizerLowering \
+ PreLegalizeGICombiner/-gen-global-isel-combiner,-combiners=${arch:H}PreLegalizerCombiner \
RegisterBank/-gen-register-bank \
RegisterInfo/-gen-register-info \
SearchableTables/-gen-searchable-tables \
SubtargetInfo/-gen-subtarget \
SystemOperands/-gen-searchable-tables \
SystemRegister/-gen-searchable-tables
-${arch:T}Gen${hdr:H}.inc: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
+. if "${arch:T}" == "RISCV" && "${hdr:T:C/(-gen-global-isel).*/\1/}" == "-gen-global-isel"
+tdfile_${arch:T}_${hdr:H}= ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}GISel.td
+. else
+tdfile_${arch:T}_${hdr:H}= ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
+.endif
+${arch:T}Gen${hdr:H}.inc: ${tdfile_${arch:T}_${hdr:H}}
${LLVM_TBLGEN} ${hdr:T:C/,/ /g} \
-I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target/${arch:H} \
-d ${.TARGET}.d -o ${.TARGET} \
- ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td
+ ${tdfile_${arch:T}_${hdr:H}}
. endfor
.endfor
.if ${MK_LLVM_TARGET_AARCH64} != "no"
@@ -2103,8 +2235,10 @@ TGHDRS+= BPFGenAsmWriter.inc
TGHDRS+= BPFGenCallingConv.inc
TGHDRS+= BPFGenDAGISel.inc
TGHDRS+= BPFGenDisassemblerTables.inc
+TGHDRS+= BPFGenGlobalISel.inc
TGHDRS+= BPFGenInstrInfo.inc
TGHDRS+= BPFGenMCCodeEmitter.inc
+TGHDRS+= BPFGenRegisterBank.inc
TGHDRS+= BPFGenRegisterInfo.inc
TGHDRS+= BPFGenSubtargetInfo.inc
.endif # MK_LLVM_TARGET_BPF
@@ -2144,12 +2278,16 @@ TGHDRS+= RISCVGenAsmWriter.inc
TGHDRS+= RISCVGenCallingConv.inc
TGHDRS+= RISCVGenCompressInstEmitter.inc
TGHDRS+= RISCVGenDAGISel.inc
-TGHDRS+= RISCVGenDisassemblerTables.inc
TGHDRS+= RISCVGenDAGISel.inc
+TGHDRS+= RISCVGenDisassemblerTables.inc
TGHDRS+= RISCVGenGlobalISel.inc
TGHDRS+= RISCVGenInstrInfo.inc
TGHDRS+= RISCVGenMCCodeEmitter.inc
TGHDRS+= RISCVGenMCPseudoLowering.inc
+TGHDRS+= RISCVGenMacroFusion.inc
+TGHDRS+= RISCVGenO0PreLegalizeGICombiner.inc
+TGHDRS+= RISCVGenPostLegalizeGICombiner.inc
+TGHDRS+= RISCVGenPreLegalizeGICombiner.inc
TGHDRS+= RISCVGenRegisterBank.inc
TGHDRS+= RISCVGenRegisterInfo.inc
TGHDRS+= RISCVGenSearchableTables.inc
@@ -2163,10 +2301,11 @@ TGHDRS+= X86GenAsmWriter1.inc
TGHDRS+= X86GenCallingConv.inc
TGHDRS+= X86GenDAGISel.inc
TGHDRS+= X86GenDisassemblerTables.inc
-TGHDRS+= X86GenEVEX2VEXTables.inc
TGHDRS+= X86GenFastISel.inc
+TGHDRS+= X86GenFoldTables.inc
TGHDRS+= X86GenGlobalISel.inc
TGHDRS+= X86GenInstrInfo.inc
+TGHDRS+= X86GenInstrMapping.inc
TGHDRS+= X86GenMnemonicTables.inc
TGHDRS+= X86GenRegisterBank.inc
TGHDRS+= X86GenRegisterInfo.inc
diff --git a/lib/clang/libllvm/Makefile.depend b/lib/clang/libllvm/Makefile.depend
index df413109f8f9..e3399cc28b1c 100644
--- a/lib/clang/libllvm/Makefile.depend
+++ b/lib/clang/libllvm/Makefile.depend
@@ -4,10 +4,10 @@ DIRDEPS = \
include \
include/xlocale \
lib/libc++ \
- lib/libedit \
lib/libexecinfo \
lib/libz \
lib/msun \
+ usr.bin/clang/llvm-min-tblgen.host \
usr.bin/clang/llvm-tblgen.host \
diff --git a/lib/clang/libllvmminimal/Makefile b/lib/clang/libllvmminimal/Makefile
index 5f75b78e8575..583328d60b50 100644
--- a/lib/clang/libllvmminimal/Makefile
+++ b/lib/clang/libllvmminimal/Makefile
@@ -1,4 +1,4 @@
-
+.include <bsd.init.mk>
.include "../llvm.pre.mk"
LIB= llvmminimal
@@ -20,26 +20,26 @@ SRCS+= Support/DebugCounter.cpp
SRCS+= Support/Errno.cpp
SRCS+= Support/Error.cpp
SRCS+= Support/ErrorHandling.cpp
+SRCS+= Support/ExtensibleRTTI.cpp
SRCS+= Support/FoldingSet.cpp
SRCS+= Support/FormatVariadic.cpp
SRCS+= Support/FormattedStream.cpp
SRCS+= Support/GraphWriter.cpp
-SRCS+= Support/Hashing.cpp
SRCS+= Support/InitLLVM.cpp
SRCS+= Support/IntEqClasses.cpp
SRCS+= Support/JSON.cpp
SRCS+= Support/Locale.cpp
-SRCS+= Support/LowLevelType.cpp
SRCS+= Support/MD5.cpp
SRCS+= Support/ManagedStatic.cpp
SRCS+= Support/MemAlloc.cpp
SRCS+= Support/MemoryBuffer.cpp
SRCS+= Support/NativeFormatting.cpp
+SRCS+= Support/Optional.cpp
SRCS+= Support/Path.cpp
SRCS+= Support/PrettyStackTrace.cpp
SRCS+= Support/Process.cpp
SRCS+= Support/Program.cpp
-SRCS+= Support/RISCVISAInfo.cpp
+SRCS+= Support/RISCVISAUtils.cpp
SRCS+= Support/RandomNumberGenerator.cpp
SRCS+= Support/Regex.cpp
SRCS+= Support/Signals.cpp
@@ -65,11 +65,13 @@ SRCS+= Support/WithColor.cpp
SRCS+= Support/YAMLParser.cpp
SRCS+= Support/circular_raw_ostream.cpp
SRCS+= Support/raw_ostream.cpp
+SRCS+= Support/raw_socket_stream.cpp
SRCS+= Support/regcomp.c
SRCS+= Support/regerror.c
SRCS+= Support/regexec.c
SRCS+= Support/regfree.c
SRCS+= Support/regstrlcpy.c
+SRCS+= Support/xxhash.cpp
SRCS+= TableGen/DetailedRecordsBackend.cpp
SRCS+= TableGen/Error.cpp
SRCS+= TableGen/JSONBackend.cpp
diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk
index 7b16f4485340..e88b2ff1033e 100644
--- a/lib/clang/llvm.build.mk
+++ b/lib/clang/llvm.build.mk
@@ -109,9 +109,17 @@ CFLAGS+= -fdata-sections
LDFLAGS+= -Wl,-dead_strip
.else
LDFLAGS+= -Wl,--gc-sections
+# XXX: --gc-sections strips the ELF brand note and on RISC-V the OS/ABI ends up
+# as NONE, so for statically-linked binaries, i.e. lacking an interpreter,
+# get_brandinfo finds nothing and (f)execve fails with ENOEXEC. Work around
+# this by manually setting the OS/ABI field via the emulation.
+.if ${MACHINE_ARCH:Mriscv64*} != "" && ${NO_SHARED:Uno:tl} != "no" && \
+ (${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING))
+LDFLAGS+= -Wl,-m,elf64lriscv_fbsd
+.endif
.endif
-CXXSTD?= c++17
+CXXSTD= c++17
CXXFLAGS+= -fno-exceptions
CXXFLAGS+= -fno-rtti
.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
diff --git a/lib/clang/llvm.pre.mk b/lib/clang/llvm.pre.mk
index 56e454f94381..064e19f69b58 100644
--- a/lib/clang/llvm.pre.mk
+++ b/lib/clang/llvm.pre.mk
@@ -2,4 +2,5 @@
LLVM_BASE= ${SRCTOP}/contrib/llvm-project
LLVM_SRCS= ${LLVM_BASE}/llvm
-LLVM_TBLGEN?= llvm-tblgen
+LLVM_MIN_TBLGEN?= llvm-min-tblgen
+LLVM_TBLGEN?= llvm-tblgen
diff --git a/lib/csu/Makefile b/lib/csu/Makefile
index 1f8a403eb2c5..1e7a17bd35e9 100644
--- a/lib/csu/Makefile
+++ b/lib/csu/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
.if exists(${.CURDIR}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc
index faf01b293b92..c4a1f90b173f 100644
--- a/lib/csu/Makefile.inc
+++ b/lib/csu/Makefile.inc
@@ -1,3 +1,4 @@
+PACKAGE?= clibs-dev
NO_WMISSING_VARIABLE_DECLARATIONS=
# Can't instrument these files since that breaks non-sanitized programs.
@@ -21,7 +22,8 @@ ACFLAGS+= -DLOCORE
CFLAGS+= -DSTRIP_FBSDID
CFLAGS+= -fno-omit-frame-pointer
CFLAGS+= -I${.CURDIR:H}/common \
- -I${SRCTOP}/lib/libc/include
+ -I${SRCTOP}/lib/libc/include \
+ -I${SRCTOP}/lib/libsys \
CFLAGS_CRTS= -DSHARED ${PICFLAG}
@@ -54,6 +56,9 @@ Scrt1_c.o: ${CRT1SRC}
Scrt1.o: Scrt1_c.o ${CRT1OBJS} ${CRT1OBJ}
${LD} ${_LDFLAGS} -o ${.TARGET} -r ${.ALLSRC:M*.o}
+# __FreeBSD_version is recorded in crt1.o et al via crtbrand.
+crtbrand.o: ${SRCTOP}/sys/sys/param.h
+
crtbegin.o: crtbegin.c
crtbeginS.o: crtbegin.c
crtbeginT.o: crtbegin.c
diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile
index 0ea681ced6b4..24abd0b47585 100644
--- a/lib/csu/aarch64/Makefile
+++ b/lib/csu/aarch64/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
CFLAGS+= -I${.CURDIR}
diff --git a/lib/libprocstat/zfs/Makefile.depend b/lib/csu/aarch64/Makefile.depend
index 993ab0638f4a..993ab0638f4a 100644
--- a/lib/libprocstat/zfs/Makefile.depend
+++ b/lib/csu/aarch64/Makefile.depend
diff --git a/lib/csu/aarch64/crt1_s.S b/lib/csu/aarch64/crt1_s.S
index 97b4bff35a0b..1fb60f756a7a 100644
--- a/lib/csu/aarch64/crt1_s.S
+++ b/lib/csu/aarch64/crt1_s.S
@@ -30,6 +30,8 @@
*/
#include <machine/asm.h>
+#include <sys/elf_common.h>
+
/*
* The program entry point
* void _start(char **ap, void (*cleanup)(void)) __dead2
@@ -42,8 +44,8 @@ ENTRY(_start)
add x2, x1, x0, lsl #3 /* env is after argv */
add x2, x2, #8 /* argv is null terminated */
#ifdef PIC
- adrp x4, main
- add x4, x4, :lo12:main
+ adrp x4, :got:main
+ ldr x4, [x4, :got_lo12:main]
#else
ldr x4, =main
#endif
@@ -62,3 +64,5 @@ eprol:
END(_start)
.section .note.GNU-stack,"",@progbits
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/csu/aarch64/crti.S b/lib/csu/aarch64/crti.S
index 0a20f4c5e314..8bd2dfac1494 100644
--- a/lib/csu/aarch64/crti.S
+++ b/lib/csu/aarch64/crti.S
@@ -28,11 +28,14 @@
*/
#include <machine/asm.h>
+#include <sys/elf_common.h>
+
.section .init,"ax",@progbits
.align 4
.globl _init
.type _init,@function
_init:
+ PAC_LR_SIGN
stp x29, x30, [sp, #-16]!
mov x29, sp
@@ -41,6 +44,8 @@ _init:
.globl _fini
.type _fini,@function
_fini:
+ PAC_LR_SIGN
stp x29, x30, [sp, #-16]!
mov x29, sp
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/csu/aarch64/crtn.S b/lib/csu/aarch64/crtn.S
index 924aa36aa045..441411f0ab83 100644
--- a/lib/csu/aarch64/crtn.S
+++ b/lib/csu/aarch64/crtn.S
@@ -28,13 +28,19 @@
*/
#include <machine/asm.h>
+#include <sys/elf_common.h>
+
.section .init,"ax",@progbits
ldp x29, x30, [sp], #16
+ PAC_LR_AUTH
ret
.section .fini,"ax",@progbits
ldp x29, x30, [sp], #16
+ PAC_LR_AUTH
ret
.section .note.GNU-stack,"",%progbits
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile
index 8dd4084f8633..80ae5484d662 100644
--- a/lib/csu/amd64/Makefile
+++ b/lib/csu/amd64/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
CFLAGS+= -I${.CURDIR}
diff --git a/lib/csu/amd64/crt1_s.S b/lib/csu/amd64/crt1_s.S
index f7ea076d94f1..3ceea9289330 100644
--- a/lib/csu/amd64/crt1_s.S
+++ b/lib/csu/amd64/crt1_s.S
@@ -49,15 +49,12 @@ _start:
#ifdef GCRT
subq $16, %rsp
#endif
- movq %rsi, %rcx
- movq %rdi, %rsi /* argv = ap */
- addq $8, %rsi /* argv += 1 */
- movq %rdi, %rdx /* env = ap */
- addq $16, %rdx /* env += 2 */
- movslq (%rdi), %rax
- movl %eax, %edi /* argc = *(long *)(void *)ap */
- shlq $3, %rax
- addq %rax, %rdx /* env += argc */
+ movq %rsi, %rcx /* cleanup */
+ movslq (%rdi), %rax /* long *ap; tmpargc = *ap */
+ leaq 0x8(%rdi), %rsi /* argv = ap + 1 */
+ leaq 0x10(%rdi, %rax, 8), %rdx /* env = ap + 2 + tmpargc */
+ movl %eax, %edi /* argc = tmpargc */
+
#ifdef PIC
/*
* XXX. %rip relative addressing is not intended for use in the
diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile
index 96b361b0656c..5f5de9f9c61a 100644
--- a/lib/csu/arm/Makefile
+++ b/lib/csu/arm/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
CRT1OBJS+= crt1_s.o
diff --git a/lib/csu/arm/crt1_c.c b/lib/csu/arm/crt1_c.c
index 7de2d333a598..bb40f262f5c2 100644
--- a/lib/csu/arm/crt1_c.c
+++ b/lib/csu/arm/crt1_c.c
@@ -41,7 +41,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/elf_common.h>
diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c
index ddeec986a431..8ef9b8923c21 100644
--- a/lib/csu/common/crtbegin.c
+++ b/lib/csu/common/crtbegin.c
@@ -21,7 +21,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include "crt.h"
@@ -67,19 +66,27 @@ static crt_func __DTOR_LIST__[] __section(".dtors") __used = {
(crt_func)-1
};
+extern const char startof_dtors[] __asm(".startof..dtors")
+ __weak_symbol __hidden;
+extern const char sizeof_dtors[] __asm(".sizeof..dtors")
+ __weak_symbol __hidden;
+
static void
__do_global_dtors_aux(void)
{
crt_func fn;
+ uintptr_t dtors_end;
int n;
#ifdef SHARED
run_cxa_finalize();
#endif
+ dtors_end = (uintptr_t)&startof_dtors + (uintptr_t)&sizeof_dtors;
for (n = 1;; n++) {
fn = __DTOR_LIST__[n];
- if (fn == (crt_func)0 || fn == (crt_func)-1)
+ if (fn == (crt_func)0 || fn == (crt_func)-1 || (dtors_end > 0 &&
+ (uintptr_t)&__DTOR_LIST__[n] >= dtors_end))
break;
fn();
}
@@ -91,36 +98,3 @@ asm (
".popsection \n"
);
#endif
-
-/*
- * Handler for gcj. These provide a _Jv_RegisterClasses function and fill
- * out the .jcr section. We just need to call this function with a pointer
- * to the appropriate section.
- */
-extern void _Jv_RegisterClasses(void *) __weak_symbol;
-static void register_classes(void) __used;
-
-static crt_func __JCR_LIST__[] __section(".jcr") __used = { };
-
-#ifndef CTORS_CONSTRUCTORS
-__attribute__((constructor))
-#endif
-static void
-register_classes(void)
-{
-
- if (_Jv_RegisterClasses != NULL && __JCR_LIST__[0] != 0)
- _Jv_RegisterClasses(__JCR_LIST__);
-}
-
-/*
- * We can't use constructors when they use the .ctors section as they may be
- * placed before __CTOR_LIST__.
- */
-#ifdef CTORS_CONSTRUCTORS
-asm (
- ".pushsection .init \n"
- "\t" INIT_CALL_SEQ(register_classes) "\n"
- ".popsection \n"
-);
-#endif
diff --git a/lib/csu/common/crtbrand.S b/lib/csu/common/crtbrand.S
index 0ed86bfba2b2..a06f72daa99d 100644
--- a/lib/csu/common/crtbrand.S
+++ b/lib/csu/common/crtbrand.S
@@ -36,7 +36,7 @@
* for more information.
*/
- .section .note.tag,"aG",%note,.freebsd.noteG,comdat
+ .section .note.tag,"aGR",%note,.freebsd.noteG,comdat
.p2align 2
.4byte 2f-1f
.4byte 4f-3f
@@ -47,3 +47,8 @@
4:
.section .note.GNU-stack,"",%progbits
+
+#ifdef __aarch64__
+/* This is needed in all objects for BTI to be used in the linked elf file */
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
+#endif
diff --git a/lib/csu/common/crtend.c b/lib/csu/common/crtend.c
index d9259729bb0e..9eb75de2ef60 100644
--- a/lib/csu/common/crtend.c
+++ b/lib/csu/common/crtend.c
@@ -21,15 +21,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#include <sys/types.h>
#include "crt.h"
typedef void (*crt_func)(void);
-static crt_func __JCR_END__[] __section(".jcr") __used = {
- (crt_func)0
-};
-
#ifdef HAVE_CTORS
/*
@@ -45,15 +41,22 @@ static crt_func __DTOR_END__[] __section(".dtors") __used = {
(crt_func)0
};
+extern const char startof_ctors[] __asm(".startof..ctors")
+ __weak_symbol __hidden;
+
static void
__do_global_ctors_aux(void)
{
crt_func fn;
+ uintptr_t ctors_start;
int n;
+ ctors_start = (uintptr_t)&startof_ctors;
for (n = 1;; n++) {
fn = __CTOR_END__[-n];
- if (fn == (crt_func)0 || fn == (crt_func)-1)
+ if (fn == (crt_func)0 || fn == (crt_func)-1 ||
+ (ctors_start > 0 &&
+ (uintptr_t)&__CTOR_END__[-n] < ctors_start))
break;
fn();
}
diff --git a/lib/csu/common/feature_note.S b/lib/csu/common/feature_note.S
index 343d2a9262e2..fb9f6141699e 100644
--- a/lib/csu/common/feature_note.S
+++ b/lib/csu/common/feature_note.S
@@ -29,7 +29,7 @@
#include <sys/elf_common.h>
#include "notes.h"
- .section .note.tag,"a",%note
+ .section .note.tag,"aR",%note
.p2align 2
.4byte 2f-1f
.4byte 4f-3f
@@ -40,3 +40,8 @@
4:
.section .note.GNU-stack,"",%progbits
+
+#ifdef __aarch64__
+/* This is needed in all objects for BTI to be used in the linked elf file */
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
+#endif
diff --git a/lib/csu/common/ignore_init_note.S b/lib/csu/common/ignore_init_note.S
index fa37a8990538..d78be61f17a9 100644
--- a/lib/csu/common/ignore_init_note.S
+++ b/lib/csu/common/ignore_init_note.S
@@ -30,7 +30,7 @@
#include "notes.h"
- .section .note.tag,"a",%note
+ .section .note.tag,"aR",%note
.p2align 2
.4byte 2f-1f
.4byte 4f-3f
@@ -41,3 +41,8 @@
4:
.section .note.GNU-stack,"",%progbits
+
+#ifdef __aarch64__
+/* This is needed in all objects for BTI to be used in the linked elf file */
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
+#endif
diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile
index 0ea681ced6b4..24abd0b47585 100644
--- a/lib/csu/i386/Makefile
+++ b/lib/csu/i386/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
CFLAGS+= -I${.CURDIR}
diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile
index 5e0cc7ff6ed5..b6928446d005 100644
--- a/lib/csu/powerpc/Makefile
+++ b/lib/csu/powerpc/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
OBJS+= crtsavres.o
diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile
index 763cebbaa483..97df3f389115 100644
--- a/lib/csu/powerpc64/Makefile
+++ b/lib/csu/powerpc64/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
OBJS+= crtsavres.o
diff --git a/lib/csu/riscv/Makefile b/lib/csu/riscv/Makefile
index 96b361b0656c..5f5de9f9c61a 100644
--- a/lib/csu/riscv/Makefile
+++ b/lib/csu/riscv/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/common
CRT1OBJS+= crt1_s.o
diff --git a/lib/csu/riscv/Makefile.depend b/lib/csu/riscv/Makefile.depend
new file mode 100644
index 000000000000..993ab0638f4a
--- /dev/null
+++ b/lib/csu/riscv/Makefile.depend
@@ -0,0 +1,11 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/csu/tests/Makefile b/lib/csu/tests/Makefile
index 3f95193420ea..b76ef590c88f 100644
--- a/lib/csu/tests/Makefile
+++ b/lib/csu/tests/Makefile
@@ -1,8 +1,10 @@
+PACKAGE= tests
SUBDIR= dso
TESTS_SUBDIRS= dynamic
TESTS_SUBDIRS+= dynamiclib
TESTS_SUBDIRS+= dynamicpie
+TESTS_SUBDIRS+= errno
TESTS_SUBDIRS+= static
SUBDIR_DEPEND_dynamiclib=dso
diff --git a/lib/csu/tests/Makefile.inc b/lib/csu/tests/Makefile.inc
index 9904a82f1baf..2cb85b8d5d43 100644
--- a/lib/csu/tests/Makefile.inc
+++ b/lib/csu/tests/Makefile.inc
@@ -1,2 +1 @@
-
TESTSDIR:= ${TESTSBASE}/${RELDIR:C/csu\/tests/csu/}
diff --git a/lib/csu/tests/Makefile.tests b/lib/csu/tests/Makefile.tests
index 12926d5e38a6..52179057b2a3 100644
--- a/lib/csu/tests/Makefile.tests
+++ b/lib/csu/tests/Makefile.tests
@@ -1,4 +1,3 @@
-
ATF_TESTS_C+= init_test
ATF_TESTS_C+= fini_test
ATF_TESTS_CXX+= cxx_constructors
diff --git a/lib/csu/tests/cxx_constructors.cc b/lib/csu/tests/cxx_constructors.cc
index 3568c4528c36..3c04053884d2 100644
--- a/lib/csu/tests/cxx_constructors.cc
+++ b/lib/csu/tests/cxx_constructors.cc
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/lib/csu/tests/dso/Makefile b/lib/csu/tests/dso/Makefile
index 6975e64c5dfe..431168de0328 100644
--- a/lib/csu/tests/dso/Makefile
+++ b/lib/csu/tests/dso/Makefile
@@ -1,5 +1,6 @@
-
.PATH: ${.CURDIR:H}
+
+PACKAGE= tests
SHLIB= h_csu
SHLIB_NAME= libh_csu.so
SHLIB_MAJOR= 1
@@ -19,6 +20,6 @@ SRCS+= ${src}.c
SRCS+= ${src}.cc
.endfor
-LIBDIR= ${TESTSBASE}/lib/csu/dynamiclib/
+LIBDIR= ${TESTSBASE}/lib/csu/dynamiclib
.include <bsd.lib.mk>
diff --git a/lib/csu/tests/dynamic/Makefile b/lib/csu/tests/dynamic/Makefile
index 1ceeb385b5e9..e9e57201cb9a 100644
--- a/lib/csu/tests/dynamic/Makefile
+++ b/lib/csu/tests/dynamic/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}
.include <src.opts.mk>
diff --git a/lib/csu/tests/dynamiclib/Makefile b/lib/csu/tests/dynamiclib/Makefile
index ced5bbb4e935..13a9b837684e 100644
--- a/lib/csu/tests/dynamiclib/Makefile
+++ b/lib/csu/tests/dynamiclib/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}
CFLAGS+= -DDSO_BASE
DPADD+= ${.OBJDIR:H}/dso/libh_csu.so
diff --git a/lib/csu/tests/dynamicpie/Makefile b/lib/csu/tests/dynamicpie/Makefile
index b5c0356001db..204bef0c7d10 100644
--- a/lib/csu/tests/dynamicpie/Makefile
+++ b/lib/csu/tests/dynamicpie/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}
.include <src.opts.mk>
diff --git a/lib/csu/tests/errno/Makefile b/lib/csu/tests/errno/Makefile
new file mode 100644
index 000000000000..eae54a936294
--- /dev/null
+++ b/lib/csu/tests/errno/Makefile
@@ -0,0 +1,18 @@
+PLAIN_TESTS_C= errno_test \
+ errno_static_test \
+ errno_thr_test \
+ errno_thr_static_test
+
+SRCS.errno_static_test= errno_test.c
+LDFLAGS.errno_static_test= -static
+
+SRCS.errno_thr_test= errno_test.c
+LIBADD.errno_thr_test= pthread
+
+SRCS.errno_thr_static_test= errno_test.c
+LDFLAGS.errno_thr_static_test= -static
+LIBADD.errno_thr_static_test= pthread
+
+MK_PIE:= no
+
+.include <bsd.test.mk>
diff --git a/lib/csu/tests/errno/errno_test.c b/lib/csu/tests/errno/errno_test.c
new file mode 100644
index 000000000000..d190c7fd2959
--- /dev/null
+++ b/lib/csu/tests/errno/errno_test.c
@@ -0,0 +1,23 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Mark Johnston <markj@FreeBSD.org>
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+
+static void __attribute__((constructor))
+f(void)
+{
+ errno = 42;
+}
+
+int
+main(void)
+{
+ /* errno must be zero upon program startup. */
+ if (errno != 0)
+ exit(1);
+ exit(0);
+}
diff --git a/lib/csu/tests/fini_test.c b/lib/csu/tests/fini_test.c
index 9475b40f4271..79dbceb8a37c 100644
--- a/lib/csu/tests/fini_test.c
+++ b/lib/csu/tests/fini_test.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/lib/csu/tests/init_test.c b/lib/csu/tests/init_test.c
index 47bd9b7e64d7..2d4484735f76 100644
--- a/lib/csu/tests/init_test.c
+++ b/lib/csu/tests/init_test.c
@@ -38,9 +38,6 @@
typedef void (*func_ptr)(void);
-extern volatile int jcr_run;
-extern const func_ptr *jcr_ptr;
-extern const void *jcr_func_ptr;
extern volatile int ctors_run;
extern volatile int preinit_array_run;
extern volatile int preinit_array_state;
@@ -48,37 +45,11 @@ extern volatile int init_array_run;
extern volatile int init_array_state;
#ifndef DSO_BASE
-volatile int jcr_run;
-const func_ptr *jcr_ptr;
volatile int ctors_run;
volatile int preinit_array_run;
volatile int preinit_array_state = -1;
volatile int init_array_run;
volatile int init_array_state = -1;
-
-void _Jv_RegisterClasses(const func_ptr *);
-
-__section(".jcr") __used static func_ptr jcr_func = (func_ptr)1;
-const void *jcr_func_ptr = &jcr_func;
-
-void
-_Jv_RegisterClasses(const func_ptr *jcr)
-{
-
- jcr_run = 1;
- jcr_ptr = jcr;
-}
-#endif
-
-#ifndef DSO_LIB
-ATF_TC_WITHOUT_HEAD(jcr_test);
-ATF_TC_BODY(jcr_test, tc)
-{
-
- ATF_REQUIRE_MSG(jcr_run == 1, ".jcr not run");
- ATF_REQUIRE_MSG(jcr_ptr == jcr_func_ptr,
- "Incorrect pointer passed to _Jv_RegisterClasses");
-}
#endif
#ifndef DSO_BASE
@@ -160,7 +131,6 @@ ATF_TC_BODY(init_array_test, tc)
ATF_TP_ADD_TCS(tp)
{
- ATF_TP_ADD_TC(tp, jcr_test);
ATF_TP_ADD_TC(tp, ctors_test);
ATF_TP_ADD_TC(tp, preinit_array_test);
ATF_TP_ADD_TC(tp, init_array_test);
diff --git a/lib/csu/tests/static/Makefile b/lib/csu/tests/static/Makefile
index c3f87641c8ef..e76c49c93a1a 100644
--- a/lib/csu/tests/static/Makefile
+++ b/lib/csu/tests/static/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}
NO_SHARED=
diff --git a/lib/flua/Makefile b/lib/flua/Makefile
deleted file mode 100644
index eb148c2125fd..000000000000
--- a/lib/flua/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-
-SUBDIR= libjail
-
-.include <bsd.subdir.mk>
diff --git a/lib/flua/libjail/Makefile b/lib/flua/libjail/Makefile
deleted file mode 100644
index c7649c724c0a..000000000000
--- a/lib/flua/libjail/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-
-SHLIB_NAME= jail.so
-SHLIBDIR= ${LIBDIR}/flua
-
-SRCS+= lua_jail.c
-
-CFLAGS+= \
- -I${SRCTOP}/contrib/lua/src \
- -I${SRCTOP}/lib/liblua \
-
-LIBADD+= jail
-
-MAN= jail.3lua
-
-.include <bsd.lib.mk>
diff --git a/lib/flua/libjail/jail.3lua b/lib/flua/libjail/jail.3lua
deleted file mode 100644
index 59cbd2dc228c..000000000000
--- a/lib/flua/libjail/jail.3lua
+++ /dev/null
@@ -1,277 +0,0 @@
-.\"
-.\" SPDX-License-Identifier: BSD-2-Clause
-.\"
-.\" Copyright (c) 2020, Ryan Moeller <freqlabs@FreeBSD.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.
-.\"
-.\" 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.
-.\"
-.Dd October 24, 2020
-.Dt JAIL 3lua
-.Os
-.Sh NAME
-.Nm attach ,
-.Nm getid ,
-.Nm getname ,
-.Nm list ,
-.Nm allparams ,
-.Nm getparams ,
-.Nm remove ,
-.Nm setparams ,
-.Nm CREATE ,
-.Nm UPDATE ,
-.Nm ATTACH ,
-.Nm DYING
-.Nd Lua binding to
-.Xr jail 3
-.Sh SYNOPSIS
-.Bd -literal
-local jail = require('jail')
-.Ed
-.Pp
-.Bl -tag -width XXXX -compact
-.It Dv ok, err = jail.attach(jid|name)
-.It Dv jid, err = jail.getid(name)
-.It Dv name, err = jail.getname(jid)
-.It Dv params, err = jail.allparams()
-.It Dv iter, jail_obj = jail.list([params])
-.It Dv jid, res = jail.getparams(jid|name, params [, flags ] )
-.It Dv ok, err = jail.remove(jid|name)
-.It Dv jid, err = jail.setparams(jid|name, params, flags )
-.It Dv jail.CREATE
-.It Dv jail.UPDATE
-.It Dv jail.ATTACH
-.It Dv jail.DYING
-.El
-.Sh DESCRIPTION
-The
-.Nm jail
-module is a binding to the
-.Xr jail 3
-library.
-It provides a string-oriented interface for the
-.Xr jail_get 2
-and
-.Xr jail_set 2
-system calls.
-.Bl -tag -width XXXX
-.It Dv ok, err = jail.attach(jid|name)
-Attach to the given jail, identified by an integer
-.Fa jid
-or the
-.Fa name .
-.It Dv jid, err = jail.getid(name)
-Get the jail identifier
-.Pq jid
-as an integer.
-.Fa name
-is the name of a jail or a jid in the form of a string.
-.It Dv name, err = jail.getname(jid)
-Get the name of a jail as a string for the given
-.Fa jid
-.Pq an integer .
-.It Dv iter, jail_obj = jail.list([params])
-Returns an iterator over running jails on the system.
-.Dv params
-is a list of parameters to fetch for each jail as we iterate.
-.Dv jid
-and
-.Dv name
-will always be returned, and may be omitted from
-.Dv params .
-Additionally,
-.Dv params
-may be omitted or an empty table, but not nil.
-.Pp
-See
-.Sx EXAMPLES .
-.It Dv params, err = jail.allparams()
-Get a list of all supported parameter names
-.Pq as strings .
-See
-.Xr jail 8
-for descriptions of the core jail parameters.
-.It Dv jid, res = jail.getparams(jid|name, params [, flags ] )
-Get a table of the requested parameters for the given jail.
-.Nm jid|name
-can either be the jid as an integer or the jid or name as a string.
-.Nm params
-is a list of parameter names.
-.Nm flags
-is an optional integer representing the flag bits to apply for the operation.
-See the list of flags below.
-Only the
-.Dv DYING
-flag is valid to set.
-.It Dv ok, err = jail.remove(jid|name)
-Remove the given jail, identified by an integer
-.Fa jid
-or the
-.Fa name .
-.It Dv jid, err = jail.setparams(jid|name, params [, flags ] )
-Set parameters for a given jail.
-This is used to create, update, attach to, or destroy a jail.
-.Nm jid|name
-can either be the jid as an integer or the jid or name as a string.
-.Nm params
-is a table of parameters to apply to the jail, where each key in the table
-is a parameter name as a string and each value is a string that will be
-converted to the internal value type by
-.Xr jailparam_import 3 .
-.Nm flags
-is an optional integer representing the flag bits to apply for the operation.
-See the list of flags below.
-.El
-.Pp
-The
-.Nm flags
-arguments are an integer bitwise-or combination of one or more of the following
-flags:
-.Bl -tag -width XXXX
-.It Dv jail.CREATE
-Used with
-.Fn setparams
-to create a new jail.
-The jail must not already exist, unless combined with
-.Dv UPDATE .
-.It Dv jail.UPDATE
-Used with
-.Fn setparams
-to modify an existing jail.
-The jail must already exist, unless combined with
-.Dv CREATE .
-.It Dv jail.ATTACH
-Used with
-.Fn setparams
-in combination with
-.Dv CREATE
-or
-.Dv UPDATE
-to attach the current process to a jail.
-.It Dv jail.DYING
-Allow operating on a jail that is in the process of being removed.
-.El
-.Sh RETURN VALUES
-The
-.Fn getid
-and
-.Fn setparams
-functions return a jail identifier integer on success, or
-.Dv nil
-and an error message string if an error occurred.
-.Pp
-The
-.Fn getname
-function returns a jail name string on success, or
-.Dv nil
-and an error message string if an error occurred.
-.Pp
-The
-.Fn allparams
-function returns a list of parameter name strings on success, or
-.Dv nil
-and an error message string if an error occurred.
-.Pp
-The
-.Fn getparams
-function returns a jail identifier integer and a table of jail parameters
-with parameter name strings as keys and strings for values on success, or
-.Dv nil
-and an error message string if an error occurred.
-.Pp
-The
-.Fn list
-function returns an iterator over the list of running jails.
-.Pp
-The
-.Fn attach
-and
-.Fn remove
-functions return true on success, or
-.Dv nil
-and an error message string if an error occurred.
-.Sh EXAMPLES
-Set the hostname of jail
-.Dq foo
-to
-.Dq foo.bar :
-.Bd -literal -offset indent
-local jail = require('jail')
-
-jid, err = jail.setparams("foo", {["host.hostname"]="foo.bar"},
- jail.UPDATE)
-if not jid then
- error(err)
-end
-.Ed
-.Pp
-Retrieve the hostname of jail
-.Dq foo :
-.Bd -literal -offset indent
-local jail = require('jail')
-
-jid, res = jail.getparams("foo", {"host.hostname"})
-if not jid then
- error(res)
-end
-print(res["host.hostname"])
-.Ed
-.Pp
-Iterate over jails on the system:
-.Bd -literal -offset indent
-local jail = require('jail')
-
--- Recommended: just loop over it
-for jparams in jail.list() do
- print(jparams["jid"] .. " = " .. jparams["name"])
-end
-
--- Request path and hostname, too
-for jparams in jail.list({"path", "host.hostname"}) do
- print(jparams["host.hostname"] .. " mounted at " .. jparams["path"])
-end
-
--- Raw iteration protocol
-local iter, jail_obj = jail.list()
-
--- Request the first params
-local jparams = jail_obj:next()
-while jparams do
- print(jparams["jid"] .. " = " .. jparams["name"])
- -- Subsequent calls may return nil
- jparams = jail_obj:next()
-end
-.Ed
-.Sh SEE ALSO
-.Xr jail 2 ,
-.Xr jail 3 ,
-.Xr jail 8
-.Sh HISTORY
-The
-.Nm jail
-Lua module for flua first appeared in
-.Fx 13.0 .
-.Sh AUTHORS
-.An Ryan Moeller ,
-with inspiration from
-.Nx
-gpio(3lua), by
-.An Mark Balmer .
diff --git a/lib/flua/libjail/lua_jail.c b/lib/flua/libjail/lua_jail.c
deleted file mode 100644
index b463f5c894ee..000000000000
--- a/lib/flua/libjail/lua_jail.c
+++ /dev/null
@@ -1,711 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020, Ryan Moeller <freqlabs@FreeBSD.org>
- * Copyright (c) 2020, Kyle Evans <kevans@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/jail.h>
-#include <errno.h>
-#include <jail.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <lua.h>
-#include <lauxlib.h>
-#include <lualib.h>
-
-#define JAIL_METATABLE "jail iterator metatable"
-
-/*
- * Taken from RhodiumToad's lspawn implementation, let static analyzers make
- * better decisions about the behavior after we raise an error.
- */
-#if defined(LUA_VERSION_NUM) && defined(LUA_API)
-LUA_API int (lua_error) (lua_State *L) __dead2;
-#endif
-#if defined(LUA_ERRFILE) && defined(LUALIB_API)
-LUALIB_API int (luaL_argerror) (lua_State *L, int arg, const char *extramsg) __dead2;
-LUALIB_API int (luaL_typeerror) (lua_State *L, int arg, const char *tname) __dead2;
-LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...) __dead2;
-#endif
-
-int luaopen_jail(lua_State *);
-
-typedef bool (*getparam_filter)(const char *, void *);
-
-static void getparam_table(lua_State *L, int paramindex,
- struct jailparam *params, size_t paramoff, size_t *params_countp,
- getparam_filter keyfilt, void *udata);
-
-struct l_jail_iter {
- struct jailparam *params;
- size_t params_count;
- int jid;
-};
-
-static bool
-l_jail_filter(const char *param_name, void *data __unused)
-{
-
- /*
- * Allowing lastjid will mess up our iteration over all jails on the
- * system, as this is a special parameter that indicates where the search
- * starts from. We'll always add jid and name, so just silently remove
- * these.
- */
- return (strcmp(param_name, "lastjid") != 0 &&
- strcmp(param_name, "jid") != 0 &&
- strcmp(param_name, "name") != 0);
-}
-
-static int
-l_jail_iter_next(lua_State *L)
-{
- struct l_jail_iter *iter, **iterp;
- struct jailparam *jp;
- int serrno;
-
- iterp = (struct l_jail_iter **)luaL_checkudata(L, 1, JAIL_METATABLE);
- iter = *iterp;
- luaL_argcheck(L, iter != NULL, 1, "closed jail iterator");
-
- jp = iter->params;
- /* Populate lastjid; we must keep it in params[0] for our sake. */
- if (jailparam_import_raw(&jp[0], &iter->jid, sizeof(iter->jid))) {
- jailparam_free(jp, iter->params_count);
- free(jp);
- free(iter);
- *iterp = NULL;
- return (luaL_error(L, "jailparam_import_raw: %s", jail_errmsg));
- }
-
- /* The list of requested params was populated back in l_list(). */
- iter->jid = jailparam_get(jp, iter->params_count, 0);
- if (iter->jid == -1) {
- /*
- * We probably got an ENOENT to signify the end of the jail
- * listing, but just in case we didn't; stash it off and start
- * cleaning up. We'll handle non-ENOENT errors later.
- */
- serrno = errno;
- jailparam_free(jp, iter->params_count);
- free(iter->params);
- free(iter);
- *iterp = NULL;
- if (serrno != ENOENT)
- return (luaL_error(L, "jailparam_get: %s",
- strerror(serrno)));
- return (0);
- }
-
- /*
- * Finally, we'll fill in the return table with whatever parameters the
- * user requested, in addition to the ones we forced with exception to
- * lastjid.
- */
- lua_newtable(L);
- for (size_t i = 0; i < iter->params_count; ++i) {
- char *value;
-
- jp = &iter->params[i];
- if (strcmp(jp->jp_name, "lastjid") == 0)
- continue;
- value = jailparam_export(jp);
- lua_pushstring(L, value);
- lua_setfield(L, -2, jp->jp_name);
- free(value);
- }
-
- return (1);
-}
-
-static int
-l_jail_iter_close(lua_State *L)
-{
- struct l_jail_iter *iter, **iterp;
-
- /*
- * Since we're using this as the __gc method as well, there's a good
- * chance that it's already been cleaned up by iterating to the end of
- * the list.
- */
- iterp = (struct l_jail_iter **)lua_touserdata(L, 1);
- iter = *iterp;
- if (iter == NULL)
- return (0);
-
- jailparam_free(iter->params, iter->params_count);
- free(iter->params);
- free(iter);
- *iterp = NULL;
- return (0);
-}
-
-static int
-l_list(lua_State *L)
-{
- struct l_jail_iter *iter;
- int nargs;
-
- nargs = lua_gettop(L);
- if (nargs >= 1)
- luaL_checktype(L, 1, LUA_TTABLE);
-
- iter = malloc(sizeof(*iter));
- if (iter == NULL)
- return (luaL_error(L, "malloc: %s", strerror(errno)));
-
- /*
- * lastjid, jid, name + length of the table. This may be too much if
- * we have duplicated one of those fixed parameters.
- */
- iter->params_count = 3 + (nargs != 0 ? lua_rawlen(L, 1) : 0);
- iter->params = malloc(iter->params_count * sizeof(*iter->params));
- if (iter->params == NULL) {
- free(iter);
- return (luaL_error(L, "malloc params: %s", strerror(errno)));
- }
-
- /* The :next() method will populate lastjid before jail_getparam(). */
- if (jailparam_init(&iter->params[0], "lastjid") == -1) {
- free(iter->params);
- free(iter);
- return (luaL_error(L, "jailparam_init: %s", jail_errmsg));
- }
- /* These two will get populated by jail_getparam(). */
- if (jailparam_init(&iter->params[1], "jid") == -1) {
- jailparam_free(iter->params, 1);
- free(iter->params);
- free(iter);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
- if (jailparam_init(&iter->params[2], "name") == -1) {
- jailparam_free(iter->params, 2);
- free(iter->params);
- free(iter);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
-
- /*
- * We only need to process additional arguments if we were given any.
- * That is, we don't descend into getparam_table if we're passed nothing
- * or an empty table.
- */
- iter->jid = 0;
- if (iter->params_count != 3)
- getparam_table(L, 1, iter->params, 2, &iter->params_count,
- l_jail_filter, NULL);
-
- /*
- * Part of the iterator magic. We give it an iterator function with a
- * metatable defining next() and close() that can be used for manual
- * iteration. iter->jid is how we track which jail we last iterated, to
- * be supplied as "lastjid".
- */
- lua_pushcfunction(L, l_jail_iter_next);
- *(struct l_jail_iter **)lua_newuserdata(L,
- sizeof(struct l_jail_iter **)) = iter;
- luaL_getmetatable(L, JAIL_METATABLE);
- lua_setmetatable(L, -2);
- return (2);
-}
-
-static void
-register_jail_metatable(lua_State *L)
-{
- luaL_newmetatable(L, JAIL_METATABLE);
- lua_newtable(L);
- lua_pushcfunction(L, l_jail_iter_next);
- lua_setfield(L, -2, "next");
- lua_pushcfunction(L, l_jail_iter_close);
- lua_setfield(L, -2, "close");
-
- lua_setfield(L, -2, "__index");
-
- lua_pushcfunction(L, l_jail_iter_close);
- lua_setfield(L, -2, "__gc");
-
- lua_pop(L, 1);
-}
-
-static int
-l_getid(lua_State *L)
-{
- const char *name;
- int jid;
-
- name = luaL_checkstring(L, 1);
- jid = jail_getid(name);
- if (jid == -1) {
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- lua_pushinteger(L, jid);
- return (1);
-}
-
-static int
-l_getname(lua_State *L)
-{
- char *name;
- int jid;
-
- jid = luaL_checkinteger(L, 1);
- name = jail_getname(jid);
- if (name == NULL) {
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- lua_pushstring(L, name);
- free(name);
- return (1);
-}
-
-static int
-l_allparams(lua_State *L)
-{
- struct jailparam *params;
- int params_count;
-
- params_count = jailparam_all(&params);
- if (params_count == -1) {
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- lua_newtable(L);
- for (int i = 0; i < params_count; ++i) {
- lua_pushstring(L, params[i].jp_name);
- lua_rawseti(L, -2, i + 1);
- }
- jailparam_free(params, params_count);
- free(params);
- return (1);
-}
-
-static void
-getparam_table(lua_State *L, int paramindex, struct jailparam *params,
- size_t params_off, size_t *params_countp, getparam_filter keyfilt,
- void *udata)
-{
- size_t params_count;
- int skipped;
-
- params_count = *params_countp;
- skipped = 0;
- for (size_t i = 1 + params_off; i < params_count; ++i) {
- const char *param_name;
-
- lua_rawgeti(L, -1, i - params_off);
- param_name = lua_tostring(L, -1);
- if (param_name == NULL) {
- jailparam_free(params, i - skipped);
- free(params);
- luaL_argerror(L, paramindex,
- "param names must be strings");
- }
- lua_pop(L, 1);
- if (keyfilt != NULL && !keyfilt(param_name, udata)) {
- ++skipped;
- continue;
- }
- if (jailparam_init(&params[i - skipped], param_name) == -1) {
- jailparam_free(params, i - skipped);
- free(params);
- luaL_error(L, "jailparam_init: %s", jail_errmsg);
- }
- }
- *params_countp -= skipped;
-}
-
-struct getparams_filter_args {
- int filter_type;
-};
-
-static bool
-l_getparams_filter(const char *param_name, void *udata)
-{
- struct getparams_filter_args *gpa;
-
- gpa = udata;
-
- /* Skip name or jid, whichever was given. */
- if (gpa->filter_type == LUA_TSTRING) {
- if (strcmp(param_name, "name") == 0)
- return (false);
- } else /* type == LUA_TNUMBER */ {
- if (strcmp(param_name, "jid") == 0)
- return (false);
- }
-
- return (true);
-}
-
-static int
-l_getparams(lua_State *L)
-{
- const char *name;
- struct jailparam *params;
- size_t params_count;
- struct getparams_filter_args gpa;
- int flags, jid, type;
-
- type = lua_type(L, 1);
- luaL_argcheck(L, type == LUA_TSTRING || type == LUA_TNUMBER, 1,
- "expected a jail name (string) or id (integer)");
- luaL_checktype(L, 2, LUA_TTABLE);
- params_count = 1 + lua_rawlen(L, 2);
- flags = luaL_optinteger(L, 3, 0);
-
- params = malloc(params_count * sizeof(struct jailparam));
- if (params == NULL)
- return (luaL_error(L, "malloc: %s", strerror(errno)));
-
- /*
- * Set the jail name or id param as determined by the first arg.
- */
-
- if (type == LUA_TSTRING) {
- if (jailparam_init(&params[0], "name") == -1) {
- free(params);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
- name = lua_tostring(L, 1);
- if (jailparam_import(&params[0], name) == -1) {
- jailparam_free(params, 1);
- free(params);
- return (luaL_error(L, "jailparam_import: %s",
- jail_errmsg));
- }
- } else /* type == LUA_TNUMBER */ {
- if (jailparam_init(&params[0], "jid") == -1) {
- free(params);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
- jid = lua_tointeger(L, 1);
- if (jailparam_import_raw(&params[0], &jid, sizeof(jid)) == -1) {
- jailparam_free(params, 1);
- free(params);
- return (luaL_error(L, "jailparam_import_raw: %s",
- jail_errmsg));
- }
- }
-
- /*
- * Set the remaining param names being requested.
- */
- gpa.filter_type = type;
- getparam_table(L, 2, params, 0, &params_count, l_getparams_filter, &gpa);
-
- /*
- * Get the values and convert to a table.
- */
-
- jid = jailparam_get(params, params_count, flags);
- if (jid == -1) {
- jailparam_free(params, params_count);
- free(params);
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- lua_pushinteger(L, jid);
-
- lua_newtable(L);
- for (size_t i = 0; i < params_count; ++i) {
- char *value;
-
- value = jailparam_export(&params[i]);
- lua_pushstring(L, value);
- free(value);
- lua_setfield(L, -2, params[i].jp_name);
- }
-
- jailparam_free(params, params_count);
- free(params);
-
- return (2);
-}
-
-static int
-l_setparams(lua_State *L)
-{
- const char *name;
- struct jailparam *params;
- size_t params_count;
- int flags, jid, type;
-
- type = lua_type(L, 1);
- luaL_argcheck(L, type == LUA_TSTRING || type == LUA_TNUMBER, 1,
- "expected a jail name (string) or id (integer)");
- luaL_checktype(L, 2, LUA_TTABLE);
-
- lua_pushnil(L);
- for (params_count = 1; lua_next(L, 2) != 0; ++params_count)
- lua_pop(L, 1);
-
- flags = luaL_optinteger(L, 3, 0);
-
- params = malloc(params_count * sizeof(struct jailparam));
- if (params == NULL)
- return (luaL_error(L, "malloc: %s", strerror(errno)));
-
- /*
- * Set the jail name or id param as determined by the first arg.
- */
-
- if (type == LUA_TSTRING) {
- if (jailparam_init(&params[0], "name") == -1) {
- free(params);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
- name = lua_tostring(L, 1);
- if (jailparam_import(&params[0], name) == -1) {
- jailparam_free(params, 1);
- free(params);
- return (luaL_error(L, "jailparam_import: %s",
- jail_errmsg));
- }
- } else /* type == LUA_TNUMBER */ {
- if (jailparam_init(&params[0], "jid") == -1) {
- free(params);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
- jid = lua_tointeger(L, 1);
- if (jailparam_import_raw(&params[0], &jid, sizeof(jid)) == -1) {
- jailparam_free(params, 1);
- free(params);
- return (luaL_error(L, "jailparam_import_raw: %s",
- jail_errmsg));
- }
- }
-
- /*
- * Set the rest of the provided params.
- */
-
- lua_pushnil(L);
- for (size_t i = 1; i < params_count && lua_next(L, 2) != 0; ++i) {
- const char *value;
-
- name = lua_tostring(L, -2);
- if (name == NULL) {
- jailparam_free(params, i);
- free(params);
- return (luaL_argerror(L, 2,
- "param names must be strings"));
- }
- if (jailparam_init(&params[i], name) == -1) {
- jailparam_free(params, i);
- free(params);
- return (luaL_error(L, "jailparam_init: %s",
- jail_errmsg));
- }
-
- value = lua_tostring(L, -1);
- if (value == NULL) {
- jailparam_free(params, i + 1);
- free(params);
- return (luaL_argerror(L, 2,
- "param values must be strings"));
- }
- if (jailparam_import(&params[i], value) == -1) {
- jailparam_free(params, i + 1);
- free(params);
- return (luaL_error(L, "jailparam_import: %s",
- jail_errmsg));
- }
-
- lua_pop(L, 1);
- }
-
- /*
- * Attempt to set the params.
- */
-
- jid = jailparam_set(params, params_count, flags);
- if (jid == -1) {
- jailparam_free(params, params_count);
- free(params);
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- lua_pushinteger(L, jid);
-
- jailparam_free(params, params_count);
- free(params);
- return (1);
-}
-
-static int
-l_attach(lua_State *L)
-{
- int jid, type;
-
- type = lua_type(L, 1);
- luaL_argcheck(L, type == LUA_TSTRING || type == LUA_TNUMBER, 1,
- "expected a jail name (string) or id (integer)");
-
- if (lua_isstring(L, 1)) {
- /* Resolve it to a jid. */
- jid = jail_getid(lua_tostring(L, 1));
- if (jid == -1) {
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- } else {
- jid = lua_tointeger(L, 1);
- }
-
- if (jail_attach(jid) == -1) {
- lua_pushnil(L);
- lua_pushstring(L, strerror(errno));
- return (2);
- }
-
- lua_pushboolean(L, 1);
- return (1);
-}
-
-static int
-l_remove(lua_State *L)
-{
- int jid, type;
-
- type = lua_type(L, 1);
- luaL_argcheck(L, type == LUA_TSTRING || type == LUA_TNUMBER, 1,
- "expected a jail name (string) or id (integer)");
-
- if (lua_isstring(L, 1)) {
- /* Resolve it to a jid. */
- jid = jail_getid(lua_tostring(L, 1));
- if (jid == -1) {
- lua_pushnil(L);
- lua_pushstring(L, jail_errmsg);
- return (2);
- }
- } else {
- jid = lua_tointeger(L, 1);
- }
-
- if (jail_remove(jid) == -1) {
- lua_pushnil(L);
- lua_pushstring(L, strerror(errno));
- return (2);
- }
-
- lua_pushboolean(L, 1);
- return (1);
-}
-
-static const struct luaL_Reg l_jail[] = {
- /** Get id of a jail by name.
- * @param name jail name (string)
- * @return jail id (integer)
- * or nil, error (string) on error
- */
- {"getid", l_getid},
- /** Get name of a jail by id.
- * @param jid jail id (integer)
- * @return jail name (string)
- * or nil, error (string) on error
- */
- {"getname", l_getname},
- /** Get a list of all known jail parameters.
- * @return list of jail parameter names (table of strings)
- * or nil, error (string) on error
- */
- {"allparams", l_allparams},
- /** Get the listed params for a given jail.
- * @param jail jail name (string) or id (integer)
- * @param params list of parameter names (table of strings)
- * @param flags optional flags (integer)
- * @return jid (integer), params (table of [string] = string)
- * or nil, error (string) on error
- */
- {"getparams", l_getparams},
- /** Set params for a given jail.
- * @param jail jail name (string) or id (integer)
- * @param params params and values (table of [string] = string)
- * @param flags optional flags (integer)
- * @return jid (integer)
- * or nil, error (string) on error
- */
- {"setparams", l_setparams},
- /** Get a list of jail parameters for running jails on the system.
- * @param params optional list of parameter names (table of
- * strings)
- * @return iterator (function), jail_obj (object) with next and
- * close methods
- */
- {"list", l_list},
- /** Attach to a running jail.
- * @param jail jail name (string) or id (integer)
- * @return true (boolean)
- * or nil, error (string) on error
- */
- {"attach", l_attach},
- /** Remove a running jail.
- * @param jail jail name (string) or id (integer)
- * @return true (boolean)
- * or nil, error (string) on error
- */
- {"remove", l_remove},
- {NULL, NULL}
-};
-
-int
-luaopen_jail(lua_State *L)
-{
- lua_newtable(L);
-
- luaL_setfuncs(L, l_jail, 0);
-
- lua_pushinteger(L, JAIL_CREATE);
- lua_setfield(L, -2, "CREATE");
- lua_pushinteger(L, JAIL_UPDATE);
- lua_setfield(L, -2, "UPDATE");
- lua_pushinteger(L, JAIL_ATTACH);
- lua_setfield(L, -2, "ATTACH");
- lua_pushinteger(L, JAIL_DYING);
- lua_setfield(L, -2, "DYING");
-
- register_jail_metatable(L);
-
- return (1);
-}
diff --git a/lib/geom/Makefile b/lib/geom/Makefile
index 8352b4f2c5ab..a6274d43e7e1 100644
--- a/lib/geom/Makefile
+++ b/lib/geom/Makefile
@@ -1,4 +1,3 @@
-
SUBDIR=${GEOM_CLASSES}
.include "Makefile.inc"
diff --git a/lib/geom/Makefile.classes b/lib/geom/Makefile.classes
index a924bf71c297..1852e35be15f 100644
--- a/lib/geom/Makefile.classes
+++ b/lib/geom/Makefile.classes
@@ -1,4 +1,3 @@
-
.if !defined(COMPAT_libcompat)
GEOM_CLASS_DIR?=/lib/geom
.else
diff --git a/lib/geom/Makefile.inc b/lib/geom/Makefile.inc
index 3f2e2b541050..35163127538d 100644
--- a/lib/geom/Makefile.inc
+++ b/lib/geom/Makefile.inc
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
SHLIBDIR=${GEOM_CLASS_DIR}
diff --git a/lib/geom/cache/Makefile b/lib/geom/cache/Makefile
index db3f667a0977..e307351c1de5 100644
--- a/lib/geom/cache/Makefile
+++ b/lib/geom/cache/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= cache
diff --git a/lib/geom/concat/Makefile b/lib/geom/concat/Makefile
index f8801db9c61c..c9f9d0e38c75 100644
--- a/lib/geom/concat/Makefile
+++ b/lib/geom/concat/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= concat
diff --git a/lib/geom/concat/gconcat.8 b/lib/geom/concat/gconcat.8
index 55c05b469d4a..165f809ffba8 100644
--- a/lib/geom/concat/gconcat.8
+++ b/lib/geom/concat/gconcat.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 14, 2021
+.Dd January 23, 2025
.Dt GCONCAT 8
.Os
.Sh NAME
@@ -216,7 +216,6 @@ growfs /dev/concat/data
.Xr loader.conf 5 ,
.Xr geom 8 ,
.Xr growfs 8 ,
-.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr sysctl 8 ,
diff --git a/lib/geom/concat/geom_concat.c b/lib/geom/concat/geom_concat.c
index df05b0994d79..424f60ce0179 100644
--- a/lib/geom/concat/geom_concat.c
+++ b/lib/geom/concat/geom_concat.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/eli/Makefile b/lib/geom/eli/Makefile
index 1bc31a5f66b2..a22eacb9d7e8 100644
--- a/lib/geom/eli/Makefile
+++ b/lib/geom/eli/Makefile
@@ -1,14 +1,11 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc ${SRCTOP}/sys/geom/eli ${SRCTOP}/sys/crypto/sha2
+.PATH: ${SRCTOP}/sys/geom/eli
GEOM_CLASS= eli
SRCS= g_eli_crypto.c
SRCS+= g_eli_hmac.c
SRCS+= g_eli_key.c
SRCS+= pkcs5v2.c
-SRCS+= sha256c.c
-SRCS+= sha512c.c
LIBADD= md crypto
diff --git a/lib/geom/eli/geli.8 b/lib/geom/eli/geli.8
index c378c591290c..876caf67ab40 100644
--- a/lib/geom/eli/geli.8
+++ b/lib/geom/eli/geli.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 18, 2022
+.Dd April 24, 2024
.Dt GELI 8
.Os
.Sh NAME
@@ -851,6 +851,15 @@ This variable should be set in
Specifies how many times the Master Key is overwritten
with random values when it is destroyed.
After this operation it is filled with zeros.
+.It Va kern.geom.eli.use_uma_bytes
+.Nm
+must allocate a buffer for every write operation, used when performing
+encryption.
+This sysctl reports the maximum size in bytes for which geli will perform the
+allocation using
+.Xr uma 9 ,
+as opposed to
+.Xr malloc 9 .
.It Va kern.geom.eli.visible_passphrase : No 0
If set to 1, the passphrase entered on boot will be visible.
This alternative should be used with caution as the entered
@@ -863,11 +872,14 @@ Specifies how many kernel threads should be used for doing software
cryptography.
Its purpose is to increase performance on SMP systems.
If set to 0, a CPU-pinned thread will be started for every active CPU.
+Note that this variable must be set prior to attaching
+.Nm
+to a disk.
.It Va kern.geom.eli.batch : No 0
When set to 1, can speed-up crypto operations by using batching.
Batching reduces the number of interrupts by responding to a group of
crypto requests with one interrupt.
-The crypto card and the driver has to support this feature.
+The crypto card and the driver have to support this feature.
.It Va kern.geom.eli.key_cache_limit : No 8192
Specifies how many Data Keys to cache.
The default limit
@@ -884,13 +896,41 @@ Reports how many times we were looking up a Data Key and it was not in cache.
This sysctl is not updated for providers that need fewer Data Keys than the limit
specified in
.Va kern.geom.eli.key_cache_limit .
-.Va kern.geom.eli.unmapped_io
+.It Va kern.geom.eli.unmapped_io
Enable support for unmapped I/O buffers, currently implemented only on 64-bit
platforms.
This is an optimization which reduces the overhead of I/O processing.
This variable is intended for debugging purposes and must be set in
.Pa /boot/loader.conf .
.El
+.Sh PERFORMANCE CONSIDERATIONS
+The default value of
+.Va kern.geom.eli.threads
+is usually good for a system with one SSD.
+However, it may need to be lowered on systems with many disks,
+so as to avoid creating too much thread-switching overhead.
+On systems with more disks than CPUs, it's best to set this variable
+to 1.
+.Pp
+.Nm
+internally uses
+.Xr malloc 9
+to allocate memory for operations larger than
+.Va kern.geom.eli.use_uma_bytes ,
+but malloc is slow for allocations larger than
+.Va vm.kmem_zmax .
+So it's best to avoid writing more than
+.Ms MAX(kern.geom.eli.use_uma_bytes, vm.kmem_zmax)
+in a single write operation.
+On systems that format
+.Xr zfs 4
+on top of
+.Nm ,
+the maximum write size can be controlled by
+.Va vfs.zfs.vdev.aggregation_limit
+and
+.Va vfs.zfs.vdev.aggregation_limit_non_rotating
+for HDDs and SSDs, respectively.
.Sh EXIT STATUS
Exit status is 0 on success, and 1 if the command fails.
.Sh EXAMPLES
@@ -1202,10 +1242,8 @@ after the first time a provider is attached and before it is
initialized in this way.
.Sh SEE ALSO
.Xr crypto 4 ,
-.Xr gbde 4 ,
.Xr geom 4 ,
.Xr loader.conf 5 ,
-.Xr gbde 8 ,
.Xr geom 8 ,
.Xr crypto 9
.Sh HISTORY
diff --git a/lib/geom/eli/geom_eli.c b/lib/geom/eli/geom_eli.c
index 1efb760830c4..4dd1c5dea35d 100644
--- a/lib/geom/eli/geom_eli.c
+++ b/lib/geom/eli/geom_eli.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/sysctl.h>
diff --git a/lib/geom/journal/Makefile b/lib/geom/journal/Makefile
index b3e23df91768..b87e8283225b 100644
--- a/lib/geom/journal/Makefile
+++ b/lib/geom/journal/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= journal
SRCS+= geom_journal_ufs.c
diff --git a/lib/geom/journal/geom_journal.c b/lib/geom/journal/geom_journal.c
index 0f252a3aa26e..85eb6f88ae84 100644
--- a/lib/geom/journal/geom_journal.c
+++ b/lib/geom/journal/geom_journal.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/journal/geom_journal_ufs.c b/lib/geom/journal/geom_journal_ufs.c
index c01bf71da126..fc81663ec96a 100644
--- a/lib/geom/journal/geom_journal_ufs.c
+++ b/lib/geom/journal/geom_journal_ufs.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/mount.h>
diff --git a/lib/geom/journal/gjournal.8 b/lib/geom/journal/gjournal.8
index 80f987679b10..f9959ffa0f3f 100644
--- a/lib/geom/journal/gjournal.8
+++ b/lib/geom/journal/gjournal.8
@@ -61,7 +61,7 @@
The
.Nm
utility is used for journal configuration on the given GEOM provider.
-The Journal and data may be stored on the same provider or on two separate
+The journal and data may be stored on the same provider or on two separate
providers.
This is block level journaling, not file system level journaling, which means
everything gets logged, e.g.\& for file systems, it journals both data and
diff --git a/lib/geom/label/Makefile b/lib/geom/label/Makefile
index d281b3c40e76..823d5816be64 100644
--- a/lib/geom/label/Makefile
+++ b/lib/geom/label/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= label
diff --git a/lib/geom/label/geom_label.c b/lib/geom/label/geom_label.c
index a8ec9b45628a..1daf3df1c5c2 100644
--- a/lib/geom/label/geom_label.c
+++ b/lib/geom/label/geom_label.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
diff --git a/lib/geom/label/glabel.8 b/lib/geom/label/glabel.8
index 5283a604e45b..da958b52befd 100644
--- a/lib/geom/label/glabel.8
+++ b/lib/geom/label/glabel.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 12, 2017
+.Dd April 19, 2024
.Dt GLABEL 8
.Os
.Sh NAME
@@ -113,11 +113,11 @@ CD ISO9660 (directory
EXT2FS (directory
.Pa /dev/ext2fs/ ) .
.It
-REISERFS (directory
-.Pa /dev/reiserfs/ ) .
-.It
NTFS (directory
.Pa /dev/ntfs/ ) .
+.It
+Swap Linux (directory
+.Pa /dev/swaplinux/ ) .
.El
.Pp
Support for partition metadata is implemented for:
@@ -137,14 +137,35 @@ e.g.
.Pa /dev/diskid/DISK-6QG3Z026 .
.Pp
Generic labels created and managed solely by
-.Xr glabel 8
+.Nm
are created in the
.Pa /dev/label/
directory.
+Note that generic, automatic labels occupy some space on the device
+and thus should not be added to a device already containing a file system.
+In particular,
+.Nm
+reserves the last sector of the device to store the label information.
+If the device already contains a file system,
+.Nm
+will overwrite the last sector, possibly damaging the file system, and the
+file system may later overwrite the label sector.
+Instead, create a label before initializing the file system, and initialize
+that file system on the device created by
+.Nm
+under the
+.Pa /dev/label/
+directory.
+Then the file system will correctly account for the space occupied by the
+generic label,
+since the
+.Nm
+device will be one sector smaller than the device from which it was created.
.Pp
Note that for all label types, nested GEOM classes will cause additional
device nodes to be created, with context-specific data appended to their
-names. E.g. for every node like
+names.
+E.g. for every node like
.Pa /dev/label/bigdisk
there will be additional entries for any partitions which the device
contains, like
@@ -152,6 +173,17 @@ contains, like
and
.Pa /dev/label/bigdiskp1a .
.Pp
+.Nm
+requires write access to a device to create, modify, and destroy
+"automatic" labels.
+It will fail to persist changes if they are applied while a file
+system on the device is currently mounted.
+To ensure that modifications are stored across a reboot, the file system
+needs to be unmounted first.
+If the device holds the system's root file system, entering into
+single user mode and mounting in read-only mode is required to persist
+the change.
+.Pp
The first argument to
.Nm
indicates an action to be performed:
@@ -232,12 +264,13 @@ Most
.Nm LABEL
providers implement a
.Xr sysctl 8
-flag and a tunable variable named in the above format. This flag
-controls if the label provider will be active, tasting devices
+flag and a tunable variable named in the above format.
+This flag controls if the label provider will be active, tasting devices
and creating label nodes in the
-.Xr devfs 5
-tree. It is sometimes desirable to disable certain label types if
-they conflict with other classes in complex GEOM topologies.
+.Xr devfs 4
+tree.
+It is sometimes desirable to disable certain label types if they
+conflict with other classes in complex GEOM topologies.
.El
.Sh EXIT STATUS
Exit status is 0 on success, and 1 if the command fails.
diff --git a/lib/geom/mirror/Makefile b/lib/geom/mirror/Makefile
index fd7608accc9e..cf0174ee0766 100644
--- a/lib/geom/mirror/Makefile
+++ b/lib/geom/mirror/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= mirror
diff --git a/lib/geom/mirror/geom_mirror.c b/lib/geom/mirror/geom_mirror.c
index bdd9391e3315..8b47592803d9 100644
--- a/lib/geom/mirror/geom_mirror.c
+++ b/lib/geom/mirror/geom_mirror.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <err.h>
#include <errno.h>
diff --git a/lib/geom/mirror/gmirror.8 b/lib/geom/mirror/gmirror.8
index 0d1bb4566d58..aeffb2d948b1 100644
--- a/lib/geom/mirror/gmirror.8
+++ b/lib/geom/mirror/gmirror.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 5, 2022
+.Dd January 23, 2025
.Dt GMIRROR 8
.Os
.Sh NAME
@@ -436,7 +436,6 @@ there.
.Xr geom 4 ,
.Xr dumpon 8 ,
.Xr geom 8 ,
-.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr savecore 8 ,
diff --git a/lib/geom/mountver/Makefile b/lib/geom/mountver/Makefile
index 24caa75636e3..6ea3705261c2 100644
--- a/lib/geom/mountver/Makefile
+++ b/lib/geom/mountver/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= mountver
diff --git a/lib/geom/multipath/Makefile b/lib/geom/multipath/Makefile
index 550d1969ee45..1c7341145017 100644
--- a/lib/geom/multipath/Makefile
+++ b/lib/geom/multipath/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= multipath
diff --git a/lib/geom/multipath/geom_multipath.c b/lib/geom/multipath/geom_multipath.c
index 4a9ddfc2cd1c..e4cb123594c3 100644
--- a/lib/geom/multipath/geom_multipath.c
+++ b/lib/geom/multipath/geom_multipath.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/nop/Makefile b/lib/geom/nop/Makefile
index 939f56e9567e..294eeb4e7002 100644
--- a/lib/geom/nop/Makefile
+++ b/lib/geom/nop/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= nop
diff --git a/lib/geom/part/Makefile b/lib/geom/part/Makefile
index 00840df1da23..58390e299d6f 100644
--- a/lib/geom/part/Makefile
+++ b/lib/geom/part/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= part
diff --git a/lib/geom/part/gpart.8 b/lib/geom/part/gpart.8
index fa0b247c6174..f76c1d9d5d6c 100644
--- a/lib/geom/part/gpart.8
+++ b/lib/geom/part/gpart.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 26, 2023
+.Dd February 11, 2025
.Dt GPART 8
.Os
.Sh NAME
@@ -681,15 +681,6 @@ The scheme-specific types are
for APM, and
.Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b"
for GPT.
-.It Cm freebsd-vinum
-A
-.Fx
-partition that contains a Vinum volume.
-The scheme-specific types are
-.Qq Li "!FreeBSD-Vinum"
-for APM, and
-.Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b"
-for GPT.
.It Cm freebsd-zfs
A
.Fx
@@ -1008,6 +999,11 @@ A illumos/Solaris partition dedicated to reserved space.
The scheme-specific type is
.Qq Li "!6a945a3b-1dd2-11b2-99a6-080020736631"
for GPT.
+.It Cm u-boot-env
+A raw partition dedicated to U-Boot for storing its environment.
+The scheme-specific type is
+.Qq Li "!3de21764-95bd-54bd-a5c3-4abe786f38a8"
+for GPT.
.It Cm vmware-vmfs
A partition that contains a VMware File System (VMFS).
The scheme-specific types are
diff --git a/lib/geom/raid/Makefile b/lib/geom/raid/Makefile
index 9d804fd437a2..b84121126ca1 100644
--- a/lib/geom/raid/Makefile
+++ b/lib/geom/raid/Makefile
@@ -1,9 +1,5 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= raid
-LIBADD= md
-
.include <bsd.lib.mk>
diff --git a/lib/geom/raid/geom_raid.c b/lib/geom/raid/geom_raid.c
index cec3506f5757..f73b42e91e85 100644
--- a/lib/geom/raid/geom_raid.c
+++ b/lib/geom/raid/geom_raid.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/raid/graid.8 b/lib/geom/raid/graid.8
index 50c0116ba22e..4ef0cd22e703 100644
--- a/lib/geom/raid/graid.8
+++ b/lib/geom/raid/graid.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 4, 2013
+.Dd January 23, 2025
.Dt GRAID 8
.Os
.Sh NAME
@@ -275,7 +275,7 @@ NVIDIA metadata format does not support volumes above 2TiB.
.Sh SYSCTL VARIABLES
The following
.Xr sysctl 8
-variable can be used to control the behavior of the
+variables can be used to control the behavior of the
.Nm RAID
GEOM class.
.Bl -tag -width indent
@@ -307,8 +307,7 @@ Enable taste for specific metadata or transformation module.
Exit status is 0 on success, and non-zero if the command fails.
.Sh SEE ALSO
.Xr geom 4 ,
-.Xr geom 8 ,
-.Xr gvinum 8
+.Xr geom 8
.Sh HISTORY
The
.Nm
diff --git a/lib/geom/raid3/Makefile b/lib/geom/raid3/Makefile
index b4843bd50345..f2d9a9233c16 100644
--- a/lib/geom/raid3/Makefile
+++ b/lib/geom/raid3/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= raid3
diff --git a/lib/geom/raid3/geom_raid3.c b/lib/geom/raid3/geom_raid3.c
index c4b0d0227c67..4967cec75448 100644
--- a/lib/geom/raid3/geom_raid3.c
+++ b/lib/geom/raid3/geom_raid3.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/raid3/graid3.8 b/lib/geom/raid3/graid3.8
index 0e8eebc2bd81..e1bcdac17f99 100644
--- a/lib/geom/raid3/graid3.8
+++ b/lib/geom/raid3/graid3.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 15, 2012
+.Dd January 23, 2025
.Dt GRAID3 8
.Os
.Sh NAME
@@ -236,7 +236,6 @@ graid3 insert -n 0 data da5
.Sh SEE ALSO
.Xr geom 4 ,
.Xr geom 8 ,
-.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr umount 8
diff --git a/lib/geom/shsec/Makefile b/lib/geom/shsec/Makefile
index b67b9c8b6b6f..493ea5d15acd 100644
--- a/lib/geom/shsec/Makefile
+++ b/lib/geom/shsec/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= shsec
diff --git a/lib/geom/shsec/geom_shsec.c b/lib/geom/shsec/geom_shsec.c
index 8a41b18def20..227bdcf39b7d 100644
--- a/lib/geom/shsec/geom_shsec.c
+++ b/lib/geom/shsec/geom_shsec.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/shsec/gshsec.8 b/lib/geom/shsec/gshsec.8
index 9430fde13c52..d4477de3a71e 100644
--- a/lib/geom/shsec/gshsec.8
+++ b/lib/geom/shsec/gshsec.8
@@ -116,7 +116,6 @@ detected and connected, making the secret available via the
device.
.Sh SEE ALSO
.Xr geom 4 ,
-.Xr gbde 8 ,
.Xr geom 8 ,
.Xr newfs 8
.Sh HISTORY
diff --git a/lib/geom/stripe/Makefile b/lib/geom/stripe/Makefile
index 9168ecf30466..762df5f3c872 100644
--- a/lib/geom/stripe/Makefile
+++ b/lib/geom/stripe/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= stripe
diff --git a/lib/geom/stripe/geom_stripe.c b/lib/geom/stripe/geom_stripe.c
index f0acd5fa45e3..da3a726db370 100644
--- a/lib/geom/stripe/geom_stripe.c
+++ b/lib/geom/stripe/geom_stripe.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
diff --git a/lib/geom/stripe/gstripe.8 b/lib/geom/stripe/gstripe.8
index 0282faf58b6d..6fd486355a2e 100644
--- a/lib/geom/stripe/gstripe.8
+++ b/lib/geom/stripe/gstripe.8
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 21, 2004
+.Dd January 23, 2025
.Dt GSTRIPE 8
.Os
.Sh NAME
@@ -227,7 +227,6 @@ for
.Xr loader.conf 5 ,
.Xr ccdconfig 8 ,
.Xr geom 8 ,
-.Xr gvinum 8 ,
.Xr mount 8 ,
.Xr newfs 8 ,
.Xr sysctl 8 ,
diff --git a/lib/geom/union/Makefile b/lib/geom/union/Makefile
index 9f2deca840e8..e2027125c6d1 100644
--- a/lib/geom/union/Makefile
+++ b/lib/geom/union/Makefile
@@ -1,6 +1,4 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc
GEOM_CLASS= union
diff --git a/lib/geom/union/Makefile.depend b/lib/geom/union/Makefile.depend
index d07a313ea118..0dd05cace3c0 100644
--- a/lib/geom/union/Makefile.depend
+++ b/lib/geom/union/Makefile.depend
@@ -1,14 +1,12 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libgeom \
- sbin/geom/core \
.include <dirdeps.mk>
diff --git a/lib/geom/virstor/Makefile b/lib/geom/virstor/Makefile
index c8f728904f24..63ea8e5ad31c 100644
--- a/lib/geom/virstor/Makefile
+++ b/lib/geom/virstor/Makefile
@@ -1,6 +1,5 @@
-
PACKAGE=geom
-.PATH: ${.CURDIR:H:H}/misc ${SRCTOP}/sys/geom/virstor
+.PATH: ${SRCTOP}/sys/geom/virstor
GEOM_CLASS= virstor
diff --git a/lib/geom/virstor/geom_virstor.c b/lib/geom/virstor/geom_virstor.c
index 5b81c43c0acc..5f5087e99213 100644
--- a/lib/geom/virstor/geom_virstor.c
+++ b/lib/geom/virstor/geom_virstor.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <paths.h>
@@ -158,8 +157,7 @@ virstor_label(struct gctl_req *req)
char param[32];
int hardcode, nargs, error;
struct virstor_map_entry *map;
- size_t total_chunks; /* We'll run out of memory if
- this needs to be bigger. */
+ size_t total_chunks, write_max_map_entries;
unsigned int map_chunks; /* Chunks needed by the map (map size). */
size_t map_size; /* In bytes. */
ssize_t written;
@@ -197,27 +195,6 @@ virstor_label(struct gctl_req *req)
return;
}
- if (md.md_chunk_size % MAXPHYS != 0) {
- /* XXX: This is not strictly needed, but it's convenient to
- * impose some limitations on it, so why not MAXPHYS. */
- size_t new_size = rounddown(md.md_chunk_size, MAXPHYS);
- if (new_size < md.md_chunk_size)
- new_size += MAXPHYS;
- fprintf(stderr, "Resizing chunk size to be a multiple of "
- "MAXPHYS (%d kB).\n", MAXPHYS / 1024);
- fprintf(stderr, "New chunk size: %zu kB\n", new_size / 1024);
- md.md_chunk_size = new_size;
- }
-
- if (md.md_virsize % md.md_chunk_size != 0) {
- off_t chunk_count = md.md_virsize / md.md_chunk_size;
- md.md_virsize = chunk_count * md.md_chunk_size;
- fprintf(stderr, "Resizing virtual size to be a multiple of "
- "chunk size.\n");
- fprintf(stderr, "New virtual size: %zu MB\n",
- (size_t)(md.md_virsize/(1024 * 1024)));
- }
-
msize = secsize = 0;
for (i = 1; i < (unsigned)nargs; i++) {
snprintf(param, sizeof(param), "arg%u", i);
@@ -242,11 +219,20 @@ virstor_label(struct gctl_req *req)
}
if (md.md_chunk_size % secsize != 0) {
- fprintf(stderr, "Error: chunk size is not a multiple of sector "
- "size.");
- gctl_error(req, "Chunk size (in bytes) must be multiple of %u.",
- (unsigned int)secsize);
- return;
+ size_t new_size = roundup(md.md_chunk_size, secsize);
+ fprintf(stderr, "Resizing chunk size to be a multiple of "
+ "sector size (%zu bytes).\n", secsize);
+ fprintf(stderr, "New chunk size: %zu kB\n", new_size / 1024);
+ md.md_chunk_size = new_size;
+ }
+
+ if (md.md_virsize % md.md_chunk_size != 0) {
+ off_t chunk_count = md.md_virsize / md.md_chunk_size;
+ md.md_virsize = chunk_count * md.md_chunk_size;
+ fprintf(stderr, "Resizing virtual size to be a multiple of "
+ "chunk size.\n");
+ fprintf(stderr, "New virtual size: %zu MB\n",
+ (size_t)(md.md_virsize / (1024 * 1024)));
}
total_chunks = md.md_virsize / md.md_chunk_size;
@@ -326,28 +312,56 @@ virstor_label(struct gctl_req *req)
sprintf(param, "%s%s", _PATH_DEV, name);
fd = open(param, O_RDWR);
}
- if (fd < 0)
+ if (fd < 0) {
gctl_error(req, "Cannot open provider %s to write map", name);
+ return;
+ }
- /* Do it with calloc because there might be a need to set up chunk flags
- * in the future */
- map = calloc(total_chunks, sizeof(*map));
+ /*
+ * Initialize and write the map. Don't malloc the whole map at once,
+ * in case it's large. Use calloc because there might be a need to set
+ * up chunk flags in the future.
+ */
+ write_max_map_entries = 1024 * 1024 / sizeof(*map);
+ if (write_max_map_entries > total_chunks)
+ write_max_map_entries = total_chunks;
+ map = calloc(write_max_map_entries, sizeof(*map));
if (map == NULL) {
gctl_error(req,
"Out of memory (need %zu bytes for allocation map)",
- map_size);
+ write_max_map_entries * sizeof(*map));
+ close(fd);
+ return;
}
-
- written = pwrite(fd, map, map_size, 0);
- free(map);
- if ((size_t)written != map_size) {
- if (verbose) {
- fprintf(stderr, "\nTried to write %zu, written %zd (%s)\n",
- map_size, written, strerror(errno));
+ for (size_t chunk = 0; chunk < total_chunks;
+ chunk += write_max_map_entries) {
+ size_t bytes_to_write, entries_to_write;
+
+ entries_to_write = total_chunks - chunk;
+ if (entries_to_write > write_max_map_entries)
+ entries_to_write = write_max_map_entries;
+ bytes_to_write = entries_to_write * sizeof(*map);
+ for (size_t off = 0; off < bytes_to_write; off += written) {
+ written = write(fd, ((char *)map) + off,
+ bytes_to_write - off);
+ if (written < 0) {
+ if (verbose) {
+ fprintf(stderr,
+ "\nError writing map at offset "
+ "%zu of %zu: %s\n",
+ chunk * sizeof(*map) + off,
+ map_size, strerror(errno));
+ }
+ gctl_error(req,
+ "Error writing out allocation map!");
+ free(map);
+ close(fd);
+ return;
+ }
}
- gctl_error(req, "Error writing out allocation map!");
- return;
}
+ free(map);
+ map = NULL;
close (fd);
if (verbose)
diff --git a/lib/googletest/Makefile b/lib/googletest/Makefile
index 7b56a6c216d1..2cbc40829d13 100644
--- a/lib/googletest/Makefile
+++ b/lib/googletest/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
SUBDIR+= gtest
diff --git a/lib/googletest/Makefile.inc b/lib/googletest/Makefile.inc
index f40428f77542..231d7545f364 100644
--- a/lib/googletest/Makefile.inc
+++ b/lib/googletest/Makefile.inc
@@ -1,4 +1,3 @@
-
.include <googletest.test.inc.mk>
GTEST_DIR= ${SRCTOP}/contrib/googletest
diff --git a/lib/googletest/gmock/Makefile b/lib/googletest/gmock/Makefile
index b896c789a8bc..b6f8b69e356a 100644
--- a/lib/googletest/gmock/Makefile
+++ b/lib/googletest/gmock/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLEMOCK_SRCROOT}/include ${GOOGLEMOCK_SRCROOT}/src
diff --git a/lib/googletest/gmock/Makefile.inc b/lib/googletest/gmock/Makefile.inc
index 22f1f7384010..f77e46b3451a 100644
--- a/lib/googletest/gmock/Makefile.inc
+++ b/lib/googletest/gmock/Makefile.inc
@@ -1,2 +1 @@
-
include ../Makefile.inc
diff --git a/lib/googletest/gmock_main/Makefile b/lib/googletest/gmock_main/Makefile
index 4978aa7af4a6..34b87a054269 100644
--- a/lib/googletest/gmock_main/Makefile
+++ b/lib/googletest/gmock_main/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLEMOCK_SRCROOT}/include ${GOOGLEMOCK_SRCROOT}/src
diff --git a/lib/googletest/gmock_main/Makefile.inc b/lib/googletest/gmock_main/Makefile.inc
index 22f1f7384010..f77e46b3451a 100644
--- a/lib/googletest/gmock_main/Makefile.inc
+++ b/lib/googletest/gmock_main/Makefile.inc
@@ -1,2 +1 @@
-
include ../Makefile.inc
diff --git a/lib/googletest/gtest/Makefile b/lib/googletest/gtest/Makefile
index fbfcfb5e1b3c..6475fd2e0430 100644
--- a/lib/googletest/gtest/Makefile
+++ b/lib/googletest/gtest/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLETEST_SRCROOT}/include ${GOOGLETEST_SRCROOT}/src
diff --git a/lib/googletest/gtest/Makefile.inc b/lib/googletest/gtest/Makefile.inc
index 22f1f7384010..f77e46b3451a 100644
--- a/lib/googletest/gtest/Makefile.inc
+++ b/lib/googletest/gtest/Makefile.inc
@@ -1,2 +1 @@
-
include ../Makefile.inc
diff --git a/lib/googletest/gtest_main/Makefile b/lib/googletest/gtest_main/Makefile
index 0aea71a41b75..1a4eb5d71393 100644
--- a/lib/googletest/gtest_main/Makefile
+++ b/lib/googletest/gtest_main/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLETEST_SRCROOT}/include ${GOOGLETEST_SRCROOT}/src
diff --git a/lib/googletest/gtest_main/Makefile.inc b/lib/googletest/gtest_main/Makefile.inc
index 22f1f7384010..f77e46b3451a 100644
--- a/lib/googletest/gtest_main/Makefile.inc
+++ b/lib/googletest/gtest_main/Makefile.inc
@@ -1,2 +1 @@
-
include ../Makefile.inc
diff --git a/lib/googletest/tests/Makefile b/lib/googletest/tests/Makefile
index 8e3299029da0..886b1a2fe49d 100644
--- a/lib/googletest/tests/Makefile
+++ b/lib/googletest/tests/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/lib/googletest/tests/Makefile.inc b/lib/googletest/tests/Makefile.inc
index 03ee799eb611..9691aaa93ded 100644
--- a/lib/googletest/tests/Makefile.inc
+++ b/lib/googletest/tests/Makefile.inc
@@ -1,4 +1,3 @@
-
.include "../Makefile.inc"
# Keep the existing tests directory structure (with subdirs per component)
# rather than installing all of them to /usr/tests/lib/googletest
diff --git a/lib/googletest/tests/gmock/Makefile b/lib/googletest/tests/gmock/Makefile
index 5df1f48c0e4a..493567100630 100644
--- a/lib/googletest/tests/gmock/Makefile
+++ b/lib/googletest/tests/gmock/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLEMOCK_SRCROOT}/src ${GOOGLEMOCK_SRCROOT}/test
diff --git a/lib/googletest/tests/gmock_main/Makefile b/lib/googletest/tests/gmock_main/Makefile
index 7523b585ac2c..1b191924fb9d 100644
--- a/lib/googletest/tests/gmock_main/Makefile
+++ b/lib/googletest/tests/gmock_main/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLEMOCK_SRCROOT}/src ${GOOGLEMOCK_SRCROOT}/test
diff --git a/lib/googletest/tests/gtest/Makefile b/lib/googletest/tests/gtest/Makefile
index 0000167dfe70..5834ca788985 100644
--- a/lib/googletest/tests/gtest/Makefile
+++ b/lib/googletest/tests/gtest/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLETEST_SRCROOT}/src ${GOOGLETEST_SRCROOT}/test
diff --git a/lib/googletest/tests/gtest_main/Makefile b/lib/googletest/tests/gtest_main/Makefile
index 3124042f8b95..de9bc2f4a78a 100644
--- a/lib/googletest/tests/gtest_main/Makefile
+++ b/lib/googletest/tests/gtest_main/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${GOOGLETEST_SRCROOT}/src ${GOOGLETEST_SRCROOT}/test
diff --git a/lib/lib80211/Makefile b/lib/lib80211/Makefile
index 0d3cd3619c6d..78819cb9cfac 100644
--- a/lib/lib80211/Makefile
+++ b/lib/lib80211/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
CONFS= regdomain.xml
LIB= 80211
diff --git a/lib/lib80211/lib80211_regdomain.c b/lib/lib80211/lib80211_regdomain.c
index f5ed236467f5..db353a69f4d9 100644
--- a/lib/lib80211/lib80211_regdomain.c
+++ b/lib/lib80211/lib80211_regdomain.c
@@ -22,9 +22,6 @@
* (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 lint
-static const char rcsid[] = "$FreeBSD$";
-#endif /* not lint */
#include <sys/types.h>
#include <sys/errno.h>
@@ -444,7 +441,7 @@ lib80211_regdomain_readconfig(struct regdata *rdp, const void *p, size_t len)
XML_ParserFree(mt->parser);
/* setup the identifer table */
- rdp->ident = calloc(sizeof(struct ident), mt->nident + 1);
+ rdp->ident = calloc(mt->nident + 1, sizeof(struct ident));
if (rdp->ident == NULL)
return ENOMEM;
free(mt);
diff --git a/lib/lib80211/regdomain.xml b/lib/lib80211/regdomain.xml
index 5a432f39ccf6..16b74445f429 100644
--- a/lib/lib80211/regdomain.xml
+++ b/lib/lib80211/regdomain.xml
@@ -494,6 +494,10 @@
<flags>IEEE80211_CHAN_PASSIVE</flags>
<flags>IEEE80211_CHAN_DFS</flags>
</band>
+ <band>
+ <freqband ref="A20_5745_5865"/>
+ <maxpower>13</maxpower>
+ </band>
</netband>
<netband mode="11ng">
<band>
@@ -548,6 +552,14 @@
<flags>IEEE80211_CHAN_PASSIVE</flags>
<flags>IEEE80211_CHAN_DFS</flags>
</band>
+ <band>
+ <freqband ref="NA20_5745_5865"/>
+ <maxpower>13</maxpower>
+ </band>
+ <band>
+ <freqband ref="NA40_5745_5845"/>
+ <maxpower>13</maxpower>
+ </band>
</netband>
<netband mode="11ac">
<!-- 5150-5250/80, 200 mW, indoor -->
@@ -572,6 +584,13 @@
<flags>IEEE80211_CHAN_VHT80</flags>
<flags>INDOOR</flags>
</band>
+ <band>
+ <freqband ref="AC2_5180_5320_160"/>
+ <maxpower>22</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT160</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
<!-- 5250-5350/80, 100 mW, indoor, DFS -->
<band>
@@ -638,7 +657,7 @@
<flags>IEEE80211_CHAN_DFS</flags>
</band>
<band>
- <freqband ref="AC2_5745_5805_40"/>
+ <freqband ref="AC2_5745_5845_40"/>
<maxpower>13</maxpower>
<flags>IEEE80211_CHAN_HT40</flags>
<flags>IEEE80211_CHAN_VHT40</flags>
@@ -1173,6 +1192,202 @@
</netband>
</rd>
+<rd id="taiwan">
+ <name>TAIWAN</name>
+ <netband mode="11b">
+ <band>
+ <freqband ref="F1_2412_2472"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_B</flags>
+ </band>
+ </netband>
+
+ <netband mode="11g">
+ <band>
+ <freqband ref="F1_2412_2472"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_G</flags>
+ </band>
+ </netband>
+
+ <netband mode="11ng">
+ <band>
+ <freqband ref="F1_2412_2472"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_G</flags>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ </band>
+ <band>
+ <freqband ref="H4_2412_2472"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_G</flags>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ </band>
+ </netband>
+
+ <netband mode="11a">
+ <band>
+ <freqband ref="F1_5160_5240"/>
+ <maxpower>23</maxpower>
+ </band>
+ <band>
+ <freqband ref="F1_5260_5340"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="F1_5480_5720"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="F1_5745_5845"/>
+ <maxpower>30</maxpower>
+ </band>
+ </netband>
+
+ <netband mode="11na">
+ <band>
+ <freqband ref="F1_5160_5240"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ </band>
+ <band>
+ <freqband ref="H4_5180_5240"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ </band>
+
+ <band>
+ <freqband ref="F1_5260_5340"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="H4_5260_5320"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+
+ <band>
+ <freqband ref="F1_5480_5720"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="H4_5500_5720"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+
+ <band>
+ <freqband ref="F1_5745_5845"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ </band>
+ <band>
+ <freqband ref="H4_5745_5845"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ </band>
+ </netband>
+
+ <netband mode="11ac">
+ <band>
+ <freqband ref="AC2_5160_5240_20"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ <flags>IEEE80211_CHAN_VHT20</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5180_5240_40"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT40</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5180_5240_80"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT80</flags>
+ </band>
+
+ <band>
+ <freqband ref="AC2_5260_5340_20"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ <flags>IEEE80211_CHAN_VHT20</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5260_5320_40"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT40</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5260_5320_80"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT80</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+
+ <band>
+ <freqband ref="AC2_5480_5700_20"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ <flags>IEEE80211_CHAN_VHT20</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5500_5720_40"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT40</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5500_5720_80"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT80</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5500_5640_160"/>
+ <maxpower>23</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT160</flags>
+ <flags>IEEE80211_CHAN_DFS</flags>
+ </band>
+
+ <band>
+ <freqband ref="AC2_5745_5845_20"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_HT20</flags>
+ <flags>IEEE80211_CHAN_VHT20</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5745_5845_40"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT40</flags>
+ </band>
+ <band>
+ <freqband ref="AC2_5745_5805_80"/>
+ <maxpower>30</maxpower>
+ <flags>IEEE80211_CHAN_HT40</flags>
+ <flags>IEEE80211_CHAN_VHT80</flags>
+ </band>
+ </netband>
+</rd>
+
<!-- Rest Of World -->
<rd id="row">
@@ -1767,7 +1982,7 @@
<isocc>760</isocc> <name>Syria</name> <rd ref="none"/>
</country>
<country id="TW">
- <isocc>158</isocc> <name>Taiwan</name> <rd ref="row"/>
+ <isocc>158</isocc> <name>Taiwan</name> <rd ref="taiwan"/>
</country>
<country id="TH">
<isocc>764</isocc> <name>Thailand</name> <rd ref="none"/>
@@ -1890,6 +2105,11 @@
<flags>IEEE80211_CHAN_A</flags>
</freqband>
<!-- 5150-5250/80 -->
+<freqband id="F1_5160_5240">
+ <freqstart>5120</freqstart> <freqend>5240</freqend>
+ <chanwidth>20</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="AC2_5160_5240_20">
<freqstart>5160</freqstart> <freqend>5240</freqend>
<chanwidth>20</chanwidth> <chansep>20</chansep>
@@ -1905,7 +2125,17 @@
<chanwidth>80</chanwidth> <chansep>20</chansep>
<flags>IEEE80211_CHAN_A</flags>
</freqband>
+<freqband id="AC2_5180_5320_160">
+ <freqstart>5180</freqstart> <freqend>5320</freqend>
+ <chanwidth>160</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<!-- 5250-5350/80 -->
+<freqband id="F1_5260_5340">
+ <freqstart>5260</freqstart> <freqend>5340</freqend>
+ <chanwidth>20</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="AC2_5260_5340_20">
<freqstart>5260</freqstart> <freqend>5340</freqend>
<chanwidth>20</chanwidth> <chansep>20</chansep>
@@ -1922,6 +2152,11 @@
<flags>IEEE80211_CHAN_A</flags>
</freqband>
<!-- 5470-5725/160 -->
+<freqband id="F1_5480_5720">
+ <freqstart>5480</freqstart> <freqend>5720</freqend>
+ <chanwidth>20</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="AC2_5480_5700_20">
<freqstart>5480</freqstart> <freqend>5700</freqend>
<chanwidth>20</chanwidth> <chansep>20</chansep>
@@ -1942,7 +2177,38 @@
<chanwidth>160</chanwidth> <chansep>20</chansep>
<flags>IEEE80211_CHAN_A</flags>
</freqband>
+<!-- 5500-5720/80 -->
+<freqband id="AC2_5500_5720_40">
+ <freqstart>5500</freqstart> <freqend>5720</freqend>
+ <chanwidth>40</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
+<freqband id="AC2_5500_5720_80">
+ <freqstart>5500</freqstart> <freqend>5720</freqend>
+ <chanwidth>80</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<!-- 5725-5875/80 short range -->
+<freqband id="F1_5745_5825">
+ <freqstart>5745</freqstart> <freqend>5825</freqend>
+ <chanwidth>20</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
+<freqband id="F1_5745_5845">
+ <freqstart>5745</freqstart> <freqend>5845</freqend>
+ <chanwidth>20</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
+<freqband id="H4_5745_5845">
+ <freqstart>5745</freqstart> <freqend>5845</freqend>
+ <chanwidth>40</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
+<freqband id="AC2_5745_5845_20">
+ <freqstart>5745</freqstart> <freqend>5845</freqend>
+ <chanwidth>20</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="AC2_5745_5865_20">
<freqstart>5745</freqstart> <freqend>5865</freqend>
<chanwidth>20</chanwidth> <chansep>20</chansep>
@@ -1953,11 +2219,21 @@
<chanwidth>40</chanwidth> <chansep>20</chansep>
<flags>IEEE80211_CHAN_A</flags>
</freqband>
+<freqband id="AC2_5745_5845_40">
+ <freqstart>5745</freqstart> <freqend>5845</freqend>
+ <chanwidth>40</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="AC2_5745_5805_80">
<freqstart>5745</freqstart> <freqend>5805</freqend>
<chanwidth>80</chanwidth> <chansep>20</chansep>
<flags>IEEE80211_CHAN_A</flags>
</freqband>
+<freqband id="AC2_5745_5885_160">
+ <freqstart>5745</freqstart> <freqend>5885</freqend>
+ <chanwidth>160</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="H4_5180_5240">
<freqstart>5180</freqstart> <freqend>5240</freqend>
<chanwidth>40</chanwidth> <chansep>20</chansep>
@@ -2003,6 +2279,11 @@
<chanwidth>20</chanwidth> <chansep>20</chansep>
<flags>IEEE80211_CHAN_A</flags>
</freqband>
+<freqband id="H4_5500_5720">
+ <freqstart>5500</freqstart> <freqend>5720</freqend>
+ <chanwidth>40</chanwidth> <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
<freqband id="H4_5500_5580">
<freqstart>5500</freqstart> <freqend>5580</freqend>
<chanwidth>40</chanwidth> <chansep>20</chansep>
@@ -2028,6 +2309,29 @@
<chanwidth>20</chanwidth> <chansep>20</chansep>
<flags>IEEE80211_CHAN_A</flags>
</freqband>
+<freqband id="A20_5745_5865">
+ <freqstart>5745</freqstart>
+ <freqend>5865</freqend>
+ <chanwidth>20</chanwidth>
+ <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+</freqband>
+<freqband id="NA20_5745_5865">
+ <freqstart>5745</freqstart>
+ <freqend>5865</freqend>
+ <chanwidth>20</chanwidth>
+ <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+ <flags>IEEE80211_CHAN_HT20</flags>
+</freqband>
+<freqband id="NA40_5745_5845">
+ <freqstart>5745</freqstart>
+ <freqend>5845</freqend>
+ <chanwidth>40</chanwidth>
+ <chansep>20</chansep>
+ <flags>IEEE80211_CHAN_A</flags>
+ <flags>IEEE80211_CHAN_HT40</flags>
+</freqband>
<freqband id="F1_5660_5700">
<freqstart>5660</freqstart> <freqend>5700</freqend>
<chanwidth>20</chanwidth> <chansep>20</chansep>
diff --git a/lib/lib9p/Makefile b/lib/lib9p/Makefile
index 349900a9c53a..a8e0c74301e0 100644
--- a/lib/lib9p/Makefile
+++ b/lib/lib9p/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
.PATH: ${.CURDIR}/../../contrib/lib9p
diff --git a/lib/lib9p/Makefile.depend b/lib/lib9p/Makefile.depend
index e69de29bb2d1..b4b434e22ff9 100644
--- a/lib/lib9p/Makefile.depend
+++ b/lib/lib9p/Makefile.depend
@@ -0,0 +1,19 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_grp \
+ lib/libcasper/services/cap_pwd \
+ lib/libcompiler_rt \
+ lib/libsbuf \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libalias/Makefile b/lib/libalias/Makefile
index 02fd37c62a1c..c847f55e8e00 100644
--- a/lib/libalias/Makefile
+++ b/lib/libalias/Makefile
@@ -1,4 +1,3 @@
-
SUBDIR= libalias modules
.include <bsd.subdir.mk>
diff --git a/lib/libalias/Makefile.inc b/lib/libalias/Makefile.inc
index d3b5cbd3a79b..01b5f23410c8 100644
--- a/lib/libalias/Makefile.inc
+++ b/lib/libalias/Makefile.inc
@@ -1,2 +1 @@
-
.include "../Makefile.inc"
diff --git a/lib/libalias/libalias/Makefile b/lib/libalias/libalias/Makefile
index 7a2004ed43fd..e6fed2355d82 100644
--- a/lib/libalias/libalias/Makefile
+++ b/lib/libalias/libalias/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/sys/netinet/libalias
PACKAGE= natd
diff --git a/lib/libalias/modules/Makefile b/lib/libalias/modules/Makefile
index f7d4c3e8e8b4..cf2ce73397c6 100644
--- a/lib/libalias/modules/Makefile
+++ b/lib/libalias/modules/Makefile
@@ -1,4 +1,3 @@
-
.include "${SRCTOP}/sys/modules/libalias/modules/modules.inc"
SUBDIR= ${MODULES}
diff --git a/lib/libalias/modules/Makefile.inc b/lib/libalias/modules/Makefile.inc
index 4be1feb6e745..9d1c9bac3ff0 100644
--- a/lib/libalias/modules/Makefile.inc
+++ b/lib/libalias/modules/Makefile.inc
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/sys/netinet/libalias
SHLIBDIR?= /lib
diff --git a/lib/libalias/modules/dummy/Makefile b/lib/libalias/modules/dummy/Makefile
index 8795962cc42f..4762582b9441 100644
--- a/lib/libalias/modules/dummy/Makefile
+++ b/lib/libalias/modules/dummy/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= dummy
SRCS= alias_dummy.c
diff --git a/lib/libalias/modules/ftp/Makefile b/lib/libalias/modules/ftp/Makefile
index 84dac1758aa2..4e90d1aeea0a 100644
--- a/lib/libalias/modules/ftp/Makefile
+++ b/lib/libalias/modules/ftp/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= ftp
SRCS= alias_ftp.c
diff --git a/lib/libalias/modules/irc/Makefile b/lib/libalias/modules/irc/Makefile
index e954208c256f..0400cbeb53a8 100644
--- a/lib/libalias/modules/irc/Makefile
+++ b/lib/libalias/modules/irc/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= irc
SRCS= alias_irc.c
diff --git a/lib/libalias/modules/nbt/Makefile b/lib/libalias/modules/nbt/Makefile
index 5176d49b7afc..7c8b0487530a 100644
--- a/lib/libalias/modules/nbt/Makefile
+++ b/lib/libalias/modules/nbt/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= nbt
SRCS= alias_nbt.c
diff --git a/lib/libalias/modules/pptp/Makefile b/lib/libalias/modules/pptp/Makefile
index 7db0d8597600..ad32569d0c07 100644
--- a/lib/libalias/modules/pptp/Makefile
+++ b/lib/libalias/modules/pptp/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= pptp
SRCS= alias_pptp.c
diff --git a/lib/libalias/modules/skinny/Makefile b/lib/libalias/modules/skinny/Makefile
index a120ac2f1c78..5d914c6f79aa 100644
--- a/lib/libalias/modules/skinny/Makefile
+++ b/lib/libalias/modules/skinny/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= skinny
SRCS= alias_skinny.c
diff --git a/lib/libalias/modules/smedia/Makefile b/lib/libalias/modules/smedia/Makefile
index 0fbda73b3950..9fa766b7d7d3 100644
--- a/lib/libalias/modules/smedia/Makefile
+++ b/lib/libalias/modules/smedia/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= natd
NAME= smedia
SRCS= alias_smedia.c
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index a68b938ca978..fed73c388318 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -42,11 +42,11 @@ SRCS= archive_acl.c \
archive_entry_stat.c \
archive_entry_strmode.c \
archive_entry_xattr.c \
- archive_getdate.c \
archive_hmac.c \
archive_match.c \
archive_options.c \
archive_pack_dev.c \
+ archive_parse_date.c \
archive_pathmatch.c \
archive_ppmd7.c \
archive_ppmd8.c \
@@ -101,6 +101,7 @@ SRCS= archive_acl.c \
archive_read_support_format_zip.c \
archive_string.c \
archive_string_sprintf.c \
+ archive_time.c \
archive_util.c \
archive_version_details.c \
archive_virtual.c \
diff --git a/lib/libarchive/Makefile.inc b/lib/libarchive/Makefile.inc
index 95d96df24eef..755a39ec01e8 100644
--- a/lib/libarchive/Makefile.inc
+++ b/lib/libarchive/Makefile.inc
@@ -4,7 +4,8 @@
LIBADD= z bz2 lzma bsdxml zstd
CFLAGS+= -DHAVE_BZLIB_H=1 -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 \
- -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 -DHAVE_LIBZSTD_COMPRESSOR=1
+ -DHAVE_ZSTD_H=1 -DHAVE_LIBZSTD=1 -DHAVE_ZSTD_compressStream=1 \
+ -DHAVE_SYSCONF=1
CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\"
.if ${MK_OPENSSL} != "no"
diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h
index a3a0216169bf..1601adddd0de 100644
--- a/lib/libarchive/config_freebsd.h
+++ b/lib/libarchive/config_freebsd.h
@@ -165,7 +165,6 @@
#define HAVE_POSIX_SPAWNP 1
#define HAVE_PTHREAD_H 1
#define HAVE_PWD_H 1
-#define HAVE_READDIR_R 1
#define HAVE_READLINK 1
#define HAVE_READLINKAT 1
#ifndef __linux__
diff --git a/lib/libarchive/tests/Makefile b/lib/libarchive/tests/Makefile
index 2fe9bbcc7c2d..07c5fe24dd30 100644
--- a/lib/libarchive/tests/Makefile
+++ b/lib/libarchive/tests/Makefile
@@ -17,6 +17,7 @@ PROGS+= libarchive_test
CFLAGS+= -I${.CURDIR} -I${.CURDIR:H} -I${.OBJDIR}
CFLAGS+= -I${_LIBARCHIVEDIR}/libarchive -I${_LIBARCHIVEDIR}/libarchive/test
CFLAGS+= -I${_LIBARCHIVEDIR}/test_utils
+CFLAGS+= -I${SRCTOP}/sys/contrib/zstd/lib
CFLAGS.test_utils.c+= -Wno-cast-align
@@ -26,21 +27,24 @@ CFLAGS.test_utils.c+= -Wno-cast-align
.PATH: ${_LIBARCHIVEDIR}/libarchive/test
TESTS_SRCS= \
+ test_7zip_filename_encoding.c \
test_acl_nfs4.c \
test_acl_pax.c \
test_acl_platform_nfs4.c \
test_acl_platform_posix1e.c \
test_acl_posix1e.c \
test_acl_text.c \
+ test_ar_mode.c \
test_archive_api_feature.c \
test_archive_clear_error.c \
test_archive_cmdline.c \
test_archive_digest.c \
- test_archive_getdate.c \
test_archive_match_time.c \
test_archive_match_owner.c \
test_archive_match_path.c \
test_archive_pathmatch.c \
+ test_archive_parse_date.c \
+ test_archive_read.c \
test_archive_read_add_passphrase.c \
test_archive_read_close_twice.c \
test_archive_read_close_twice_open_fd.c \
@@ -69,6 +73,7 @@ TESTS_SRCS= \
test_compat_bzip2.c \
test_compat_cpio.c \
test_compat_gtar.c \
+ test_compat_gtar_large.c \
test_compat_gzip.c \
test_compat_lz4.c \
test_compat_lzip.c \
@@ -108,12 +113,14 @@ TESTS_SRCS= \
test_read_file_nonexistent.c \
test_read_filter_compress.c \
test_read_filter_grzip.c \
+ test_read_filter_gzip_recursive.c \
test_read_filter_lrzip.c \
test_read_filter_lzop.c \
test_read_filter_lzop_multiple_parts.c \
test_read_filter_program.c \
test_read_filter_program_signature.c \
test_read_filter_uudecode.c \
+ test_read_filter_uudecode_raw.c \
test_read_format_7zip.c \
test_read_format_7zip_encryption_data.c \
test_read_format_7zip_encryption_header.c \
@@ -143,8 +150,11 @@ TESTS_SRCS= \
test_read_format_gtar_filename.c \
test_read_format_gtar_gz.c \
test_read_format_gtar_lzma.c \
+ test_read_format_gtar_redundant_L.c \
test_read_format_gtar_sparse.c \
+ test_read_format_gtar_sparse_length.c \
test_read_format_gtar_sparse_skip_entry.c \
+ test_read_format_huge_rpm.c \
test_read_format_iso_Z.c \
test_read_format_iso_multi_extent.c \
test_read_format_iso_xorriso.c \
@@ -166,11 +176,13 @@ TESTS_SRCS= \
test_read_format_pax_bz2.c \
test_read_format_rar.c \
test_read_format_rar5.c \
+ test_read_format_rar_encryption.c \
test_read_format_rar_encryption_data.c \
test_read_format_rar_encryption_header.c \
test_read_format_rar_encryption_partially.c \
test_read_format_rar_filter.c \
test_read_format_rar_invalid1.c \
+ test_read_format_rar_overflow.c \
test_read_format_raw.c \
test_read_format_tar.c \
test_read_format_tar_concatenated.c \
@@ -179,6 +191,10 @@ TESTS_SRCS= \
test_read_format_tar_empty_with_gnulabel.c \
test_read_format_tar_filename.c \
test_read_format_tar_invalid_pax_size.c \
+ test_read_format_tar_mac_metadata.c \
+ test_read_format_tar_pax_g_large.c \
+ test_read_format_tar_pax_large_attr.c \
+ test_read_format_tar_pax_negative_time.c \
test_read_format_tbz.c \
test_read_format_tgz.c \
test_read_format_tlz.c \
@@ -187,6 +203,7 @@ TESTS_SRCS= \
test_read_format_ustar_filename.c \
test_read_format_warc.c \
test_read_format_xar.c \
+ test_read_format_xar_doublelink.c \
test_read_format_zip.c \
test_read_format_zip_7075_utf8_paths.c \
test_read_format_zip_comment_stored.c \
@@ -210,6 +227,7 @@ TESTS_SRCS= \
test_read_format_zip_with_invalid_traditional_eocd.c \
test_read_format_zip_zip64.c \
test_read_large.c \
+ test_read_pax_empty_val_no_nl.c \
test_read_pax_xattr_rht_security_selinux.c \
test_read_pax_xattr_schily.c \
test_read_pax_truncated.c \
@@ -236,6 +254,7 @@ TESTS_SRCS= \
test_write_disk_no_hfs_compression.c \
test_write_disk_perms.c \
test_write_disk_secure.c \
+ test_write_disk_secure_noabsolutepaths.c \
test_write_disk_secure744.c \
test_write_disk_secure745.c \
test_write_disk_secure746.c \
@@ -277,6 +296,7 @@ TESTS_SRCS= \
test_write_format_mtree_classic_indent.c \
test_write_format_mtree_fflags.c \
test_write_format_mtree_no_separator.c \
+ test_write_format_mtree_preset_digests.c \
test_write_format_mtree_quoted_filename.c \
test_write_format_pax.c \
test_write_format_raw.c \
@@ -293,6 +313,9 @@ TESTS_SRCS= \
test_write_format_xar_empty.c \
test_write_format_zip.c \
test_write_format_zip_compression_store.c \
+ test_write_format_zip_compression_zstd.c \
+ test_write_format_zip_compression_bzip2.c \
+ test_write_format_zip_compression_lzmaxz.c \
test_write_format_zip_empty.c \
test_write_format_zip_empty_zip64.c \
test_write_format_zip_entry_size_unset.c \
@@ -300,6 +323,9 @@ TESTS_SRCS= \
test_write_format_zip_file_zip64.c \
test_write_format_zip_large.c \
test_write_format_zip_zip64.c \
+ test_write_format_zip64_stream.c \
+ test_write_format_zip_stream.c \
+ test_write_format_zip_windows_path.c \
test_write_open_memory.c \
test_write_read_format_zip.c \
test_xattr_platform.c \
@@ -322,9 +348,6 @@ ${PACKAGE}FILES+= test_fuzz_1.iso.Z.uu
BROKEN_TESTS+= test_fuzz_rar
.endif
-# https://bugs.freebsd.org/240683
-BROKEN_TESTS+= test_write_filter_zstd
-
# Build the test program.
SRCS.libarchive_test= \
${TESTS_SRCS} \
@@ -370,6 +393,8 @@ ${PACKAGE}FILES+= test_compat_lz4_B7.tar.lz4.uu
${PACKAGE}FILES+= test_compat_lz4_B7BD.tar.lz4.uu
${PACKAGE}FILES+= test_compat_lzip_1.tlz.uu
${PACKAGE}FILES+= test_compat_lzip_2.tlz.uu
+${PACKAGE}FILES+= test_compat_lzip_3.lz.uu
+${PACKAGE}FILES+= test_compat_lzip_4.tlz.uu
${PACKAGE}FILES+= test_compat_lzma_1.tlz.uu
${PACKAGE}FILES+= test_compat_lzma_2.tlz.uu
${PACKAGE}FILES+= test_compat_lzma_3.tlz.uu
@@ -423,15 +448,19 @@ ${PACKAGE}FILES+= test_rar_multivolume_uncompressed_files.part08.rar.uu
${PACKAGE}FILES+= test_rar_multivolume_uncompressed_files.part09.rar.uu
${PACKAGE}FILES+= test_rar_multivolume_uncompressed_files.part10.rar.uu
${PACKAGE}FILES+= test_read_filter_grzip.tar.grz.uu
+${PACKAGE}FILES+= test_read_filter_gzip_recursive.gz.uu
${PACKAGE}FILES+= test_read_filter_lrzip.tar.lrz.uu
${PACKAGE}FILES+= test_read_filter_lzop.tar.lzo.uu
${PACKAGE}FILES+= test_read_filter_lzop_multiple_parts.tar.lzo.uu
+${PACKAGE}FILES+= test_read_filter_uudecode_base64_raw.uu
+${PACKAGE}FILES+= test_read_filter_uudecode_raw.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_bzip2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_copy_1.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_copy_2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_copy_lzma.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_deflate.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_deflate_arm64.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_deflate_powerpc.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_lzma1_1.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_lzma1_2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_bcj2_lzma2_1.7z.uu
@@ -454,22 +483,31 @@ ${PACKAGE}FILES+= test_read_format_7zip_empty_file.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_encryption.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_encryption_header.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_encryption_partially.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_extract_second.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_lzma1.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_lzma1_2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_lzma1_lzma2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_lzma2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_lzma2_arm.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_lzma2_arm64.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_lzma2_powerpc.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_lzma2_riscv.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_lzma2_sparc.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_malformed.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_malformed2.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_packinfo_digests.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_ppmd.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_sfx_elf.elf.uu
+${PACKAGE}FILES+= test_read_format_7zip_sfx_modified_pe.exe.uu
+${PACKAGE}FILES+= test_read_format_7zip_sfx_pe.exe.uu
${PACKAGE}FILES+= test_read_format_7zip_solid_zstd.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_symbolic_name.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_zstd.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_zstd_arm.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_zstd_bcj.7z.uu
${PACKAGE}FILES+= test_read_format_7zip_zstd_nobcj.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_zstd_sparc.7z.uu
+${PACKAGE}FILES+= test_read_format_7zip_win_attrib.7z.uu
${PACKAGE}FILES+= test_read_format_ar.ar.uu
${PACKAGE}FILES+= test_read_format_cab_1.cab.uu
${PACKAGE}FILES+= test_read_format_cab_2.cab.uu
@@ -487,15 +525,19 @@ ${PACKAGE}FILES+= test_read_format_cpio_svr4_gzip_rpm.rpm.uu
${PACKAGE}FILES+= test_read_format_gtar_filename_cp866.tar.Z.uu
${PACKAGE}FILES+= test_read_format_gtar_filename_eucjp.tar.Z.uu
${PACKAGE}FILES+= test_read_format_gtar_filename_koi8r.tar.Z.uu
+${PACKAGE}FILES+= test_read_format_gtar_redundant_L.tar.Z.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_1_13.tar.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_1_17.tar.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_1_17_posix00.tar.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_1_17_posix01.tar.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_1_17_posix10.tar.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu
+${PACKAGE}FILES+= test_read_format_gtar_sparse_length.tar.Z.uu
${PACKAGE}FILES+= test_read_format_gtar_sparse_skip_entry.tar.Z.uu
+${PACKAGE}FILES+= test_read_format_huge_rpm.rpm.uu
${PACKAGE}FILES+= test_read_format_iso.iso.Z.uu
${PACKAGE}FILES+= test_read_format_iso_2.iso.Z.uu
+${PACKAGE}FILES+= test_read_format_iso_3.iso.Z.uu
${PACKAGE}FILES+= test_read_format_iso_joliet.iso.Z.uu
${PACKAGE}FILES+= test_read_format_iso_joliet_by_nero.iso.Z.uu
${PACKAGE}FILES+= test_read_format_iso_joliet_long.iso.Z.uu
@@ -531,6 +573,7 @@ ${PACKAGE}FILES+= test_read_format_rar_compress_normal.rar.uu
${PACKAGE}FILES+= test_read_format_rar_encryption_data.rar.uu
${PACKAGE}FILES+= test_read_format_rar_encryption_header.rar.uu
${PACKAGE}FILES+= test_read_format_rar_encryption_partially.rar.uu
+${PACKAGE}FILES+= test_read_format_rar_endarc_huge.rar.uu
${PACKAGE}FILES+= test_read_format_rar_filter.rar.uu
${PACKAGE}FILES+= test_read_format_rar_invalid1.rar.uu
${PACKAGE}FILES+= test_read_format_rar_multi_lzss_blocks.rar.uu
@@ -538,17 +581,25 @@ ${PACKAGE}FILES+= test_read_format_rar_multivolume.part0001.rar.uu
${PACKAGE}FILES+= test_read_format_rar_multivolume.part0002.rar.uu
${PACKAGE}FILES+= test_read_format_rar_multivolume.part0003.rar.uu
${PACKAGE}FILES+= test_read_format_rar_multivolume.part0004.rar.uu
+${PACKAGE}FILES+= test_read_format_rar_newsub_huge.rar.uu
${PACKAGE}FILES+= test_read_format_rar_noeof.rar.uu
+${PACKAGE}FILES+= test_read_format_rar_overflow.rar.uu
${PACKAGE}FILES+= test_read_format_rar_ppmd_lzss_conversion.rar.uu
${PACKAGE}FILES+= test_read_format_rar_ppmd_use_after_free.rar.uu
${PACKAGE}FILES+= test_read_format_rar_ppmd_use_after_free2.rar.uu
${PACKAGE}FILES+= test_read_format_rar_sfx.exe.uu
${PACKAGE}FILES+= test_read_format_rar_subblock.rar.uu
+${PACKAGE}FILES+= test_read_format_rar_symlink_huge.rar.uu
${PACKAGE}FILES+= test_read_format_rar_unicode.rar.uu
${PACKAGE}FILES+= test_read_format_rar_windows.rar.uu
+${PACKAGE}FILES+= test_read_format_rar4_encrypted.rar.uu
+${PACKAGE}FILES+= test_read_format_rar4_encrypted_filenames.rar.uu
+${PACKAGE}FILES+= test_read_format_rar4_solid_encrypted.rar.uu
+${PACKAGE}FILES+= test_read_format_rar4_solid_encrypted_filenames.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_arm.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_arm_filter_on_window_boundary.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_bad_window_sz_in_mltarc_file.rar.uu
+${PACKAGE}FILES+= test_read_format_rar5_data_ready_pointer_leak.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_blake2.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_block_size_is_too_small.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_compressed.rar.uu
@@ -557,6 +608,10 @@ ${PACKAGE}FILES+= test_read_format_rar5_different_solid_window_size.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_different_window_size.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_different_winsize_on_merge.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_distance_overflow.rar.uu
+${PACKAGE}FILES+= test_read_format_rar5_encrypted.rar.uu
+${PACKAGE}FILES+= test_read_format_rar5_encrypted_filenames.rar.uu
+${PACKAGE}FILES+= test_read_format_rar5_solid_encrypted.rar.uu
+${PACKAGE}FILES+= test_read_format_rar5_solid_encrypted_filenames.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_extra_field_version.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_fileattr.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_hardlink.rar.uu
@@ -586,6 +641,7 @@ ${PACKAGE}FILES+= test_read_format_rar5_stored.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_stored_manyfiles.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_symlink.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_truncated_huff.rar.uu
+${PACKAGE}FILES+= test_read_format_rar5_unicode.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_win32.rar.uu
${PACKAGE}FILES+= test_read_format_rar5_window_buf_and_size_desync.rar.uu
${PACKAGE}FILES+= test_read_format_raw.bufr.uu
@@ -598,10 +654,17 @@ ${PACKAGE}FILES+= test_read_format_tar_empty_with_gnulabel.tar.uu
${PACKAGE}FILES+= test_read_format_tar_empty_pax.tar.Z.uu
${PACKAGE}FILES+= test_read_format_tar_filename_koi8r.tar.Z.uu
${PACKAGE}FILES+= test_read_format_tar_invalid_pax_size.tar.uu
+${PACKAGE}FILES+= test_read_format_tar_mac_metadata_1.tar.uu
+${PACKAGE}FILES+= test_read_format_tar_pax_g_large.tar.uu
+${PACKAGE}FILES+= test_read_format_tar_pax_large_attr.tar.Z.uu
+${PACKAGE}FILES+= test_read_format_tar_pax_negative_time.tar.uu
${PACKAGE}FILES+= test_read_format_ustar_filename_cp866.tar.Z.uu
${PACKAGE}FILES+= test_read_format_ustar_filename_eucjp.tar.Z.uu
${PACKAGE}FILES+= test_read_format_ustar_filename_koi8r.tar.Z.uu
${PACKAGE}FILES+= test_read_format_warc.warc.uu
+${PACKAGE}FILES+= test_read_format_warc_incomplete.warc.uu
+${PACKAGE}FILES+= test_read_format_xar_doublelink.xar.uu
+${PACKAGE}FILES+= test_read_format_xar_duplicate_filename_node.xar.uu
${PACKAGE}FILES+= test_read_format_zip.zip.uu
${PACKAGE}FILES+= test_read_format_zip_7075_utf8_paths.zip.uu
${PACKAGE}FILES+= test_read_format_zip_7z_deflate.zip.uu
@@ -659,6 +722,7 @@ ${PACKAGE}FILES+= test_read_large_splitted_rar_ab.uu
${PACKAGE}FILES+= test_read_large_splitted_rar_ac.uu
${PACKAGE}FILES+= test_read_large_splitted_rar_ad.uu
${PACKAGE}FILES+= test_read_large_splitted_rar_ae.uu
+${PACKAGE}FILES+= test_read_pax_empty_val_no_nl.tar.uu
${PACKAGE}FILES+= test_read_pax_xattr_rht_security_selinux.tar.uu
${PACKAGE}FILES+= test_read_pax_xattr_schily.tar.uu
${PACKAGE}FILES+= test_read_splitted_rar_aa.uu
@@ -670,6 +734,7 @@ ${PACKAGE}FILES+= test_splitted_rar_seek_support_aa.uu
${PACKAGE}FILES+= test_splitted_rar_seek_support_ab.uu
${PACKAGE}FILES+= test_splitted_rar_seek_support_ac.uu
${PACKAGE}FILES+= test_write_disk_appledouble.cpio.gz.uu
+${PACKAGE}FILES+= test_write_disk_appledouble_zip.zip.uu
${PACKAGE}FILES+= test_write_disk_hfs_compression.tgz.uu
${PACKAGE}FILES+= test_write_disk_mac_metadata.tar.gz.uu
${PACKAGE}FILES+= test_write_disk_no_hfs_compression.tgz.uu
diff --git a/lib/libauditd/Makefile b/lib/libauditd/Makefile
index 26da06489d05..76ffb70bbe25 100644
--- a/lib/libauditd/Makefile
+++ b/lib/libauditd/Makefile
@@ -5,6 +5,7 @@ OPENBSMDIR= ${SRCTOP}/contrib/openbsm
_LIBAUDITDDIR= ${OPENBSMDIR}/libauditd
_LIBBSMDIR= ${OPENBSMDIR}/libbsm
+PACKAGE= audit
LIB= auditd
.PATH: ${_LIBAUDITDDIR}
diff --git a/lib/libbe/Makefile b/lib/libbe/Makefile
index 87c032ae3a0c..b04becc38d74 100644
--- a/lib/libbe/Makefile
+++ b/lib/libbe/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -58,10 +57,11 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzfs
+CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include
CFLAGS+= -I${SRCTOP}/sys
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
-CFLAGS+= -DHAVE_ISSETUGID
+CFLAGS+= -DHAVE_ISSETUGID -DHAVE_STRLCAT -DHAVE_STRLCPY
CFLAGS.be.c= -Wno-cast-qual
CFLAGS.be_access.c= -Wno-cast-qual
CFLAGS.be_error.c= -Wno-cast-qual
diff --git a/lib/libbe/be.c b/lib/libbe/be.c
index 38e5e44abb53..613235d5e908 100644
--- a/lib/libbe/be.c
+++ b/lib/libbe/be.c
@@ -1,31 +1,9 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
*
- * 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 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.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/mount.h>
@@ -176,6 +154,9 @@ libbe_init(const char *root)
strcmp(altroot, "-") != 0)
lbh->altroot_len = strlen(altroot);
+ (void) lzbe_get_boot_device(zpool_get_name(lbh->active_phandle),
+ &lbh->bootonce);
+
return (lbh);
err:
if (lbh != NULL) {
@@ -200,6 +181,8 @@ libbe_close(libbe_handle_t *lbh)
if (lbh->active_phandle != NULL)
zpool_close(lbh->active_phandle);
libzfs_fini(lbh->lzh);
+
+ free(lbh->bootonce);
free(lbh);
}
@@ -444,6 +427,12 @@ be_destroy_internal(libbe_handle_t *lbh, const char *name, int options,
return (set_error(lbh, BE_ERR_DESTROYMNT));
}
}
+
+ /* Handle destroying bootonce */
+ if (lbh->bootonce != NULL &&
+ strcmp(path, lbh->bootonce) == 0)
+ (void) lzbe_set_boot_device(
+ zpool_get_name(lbh->active_phandle), lzbe_add, NULL);
} else {
/*
* If we're initially destroying a snapshot, origin options do
@@ -670,8 +659,20 @@ be_deep_clone_prop(int prop, void *cb)
dccb = cb;
/* Skip some properties we don't want to touch */
- if (prop == ZFS_PROP_CANMOUNT)
+ switch (prop) {
+ /*
+ * libzfs insists on these being naturally inherited in the
+ * cloning process.
+ */
+ case ZFS_PROP_KEYFORMAT:
+ case ZFS_PROP_KEYLOCATION:
+ case ZFS_PROP_ENCRYPTION:
+ case ZFS_PROP_PBKDF2_ITERS:
+
+ /* FALLTHROUGH */
+ case ZFS_PROP_CANMOUNT: /* Forced by libbe */
return (ZPROP_CONT);
+ }
/* Don't copy readonly properties */
if (zfs_prop_readonly(prop))
@@ -1022,11 +1023,17 @@ be_rename(libbe_handle_t *lbh, const char *old, const char *new)
.nounmount = 1,
};
err = zfs_rename(zfs_hdl, full_new, flags);
+ if (err != 0)
+ goto error;
+
+ /* handle renaming bootonce */
+ if (lbh->bootonce != NULL &&
+ strcmp(full_old, lbh->bootonce) == 0)
+ err = be_activate(lbh, new, true);
+error:
zfs_close(zfs_hdl);
- if (err != 0)
- return (set_error(lbh, BE_ERR_UNKNOWN));
- return (0);
+ return (set_error(lbh, err));
}
@@ -1151,7 +1158,7 @@ be_create_child_noent(libbe_handle_t *lbh, const char *active,
static int
be_create_child_cloned(libbe_handle_t *lbh, const char *active)
{
- char buf[BE_MAXPATHLEN], tmp[BE_MAXPATHLEN];;
+ char buf[BE_MAXPATHLEN], tmp[BE_MAXPATHLEN];
zfs_handle_t *zfs;
int err;
diff --git a/lib/libbe/be.h b/lib/libbe/be.h
index 0e4486fbb6d2..01ee94fd03ca 100644
--- a/lib/libbe/be.h
+++ b/lib/libbe/be.h
@@ -1,28 +1,7 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
*
- * 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 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.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _LIBBE_H
diff --git a/lib/libbe/be_access.c b/lib/libbe/be_access.c
index 67b30d3fb4fb..a7eb6b703cda 100644
--- a/lib/libbe/be_access.c
+++ b/lib/libbe/be_access.c
@@ -1,30 +1,9 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
* Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
* Copyright (c) 2019 Wes Maag <wes@jwmaag.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.
- *
- * 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.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <sys/cdefs.h>
@@ -33,6 +12,8 @@
#include "be.h"
#include "be_impl.h"
+#define LIBBE_MOUNT_PREFIX "be_mount."
+
struct be_mountcheck_info {
const char *path;
char *name;
@@ -164,7 +145,11 @@ be_umount_iter(zfs_handle_t *zfs_hdl, void *data)
if (!zfs_is_mounted(zfs_hdl, &mountpoint)) {
return (0);
}
- free(mountpoint);
+
+ if (info->depth == 0 && info->mountpoint == NULL)
+ info->mountpoint = mountpoint;
+ else
+ free(mountpoint);
if (zfs_unmount(zfs_hdl, NULL, info->mntflags) != 0) {
switch (errno) {
@@ -255,7 +240,17 @@ be_mount(libbe_handle_t *lbh, const char *bootenv, const char *mountpoint,
/* Create mountpoint if it is not specified */
if (mountpoint == NULL) {
- strlcpy(mnt_temp, "/tmp/be_mount.XXXX", sizeof(mnt_temp));
+ const char *tmpdir;
+
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir == NULL)
+ tmpdir = _PATH_TMP;
+
+ if (snprintf(mnt_temp, sizeof(mnt_temp), "%s%s%sXXXX", tmpdir,
+ tmpdir[strlen(tmpdir) - 1] == '/' ? "" : "/",
+ LIBBE_MOUNT_PREFIX) >= (int)sizeof(mnt_temp))
+ return (set_error(lbh, BE_ERR_PATHLEN));
+
if (mkdtemp(mnt_temp) == NULL)
return (set_error(lbh, BE_ERR_IO));
}
@@ -307,10 +302,32 @@ be_unmount(libbe_handle_t *lbh, const char *bootenv, int flags)
info.depth = 0;
if ((err = be_umount_iter(root_hdl, &info)) != 0) {
+ free(__DECONST(char *, info.mountpoint));
zfs_close(root_hdl);
return (err);
}
+ /*
+ * We'll attempt to remove the directory if we created it on a
+ * best-effort basis. rmdir(2) failure will not be reported.
+ */
+ if (info.mountpoint != NULL) {
+ const char *mdir;
+
+ mdir = strrchr(info.mountpoint, '/');
+ if (mdir == NULL)
+ mdir = info.mountpoint;
+ else
+ mdir++;
+
+ if (strncmp(mdir, LIBBE_MOUNT_PREFIX,
+ sizeof(LIBBE_MOUNT_PREFIX) - 1) == 0) {
+ (void)rmdir(info.mountpoint);
+ }
+ }
+
+ free(__DECONST(char *, info.mountpoint));
+
zfs_close(root_hdl);
return (BE_ERR_SUCCESS);
}
diff --git a/lib/libbe/be_error.c b/lib/libbe/be_error.c
index f515fe136f12..bb1e1ed88c5d 100644
--- a/lib/libbe/be_error.c
+++ b/lib/libbe/be_error.c
@@ -1,28 +1,7 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
*
- * 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 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.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <sys/cdefs.h>
diff --git a/lib/libbe/be_impl.h b/lib/libbe/be_impl.h
index d5fd26c4f072..11d1e0ddca28 100644
--- a/lib/libbe/be_impl.h
+++ b/lib/libbe/be_impl.h
@@ -1,28 +1,7 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
*
- * 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 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.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#ifndef _LIBBE_IMPL_H
@@ -36,6 +15,7 @@ struct libbe_handle {
char root[BE_MAXPATHLEN];
char rootfs[BE_MAXPATHLEN];
char bootfs[BE_MAXPATHLEN];
+ char *bootonce;
size_t altroot_len;
zpool_handle_t *active_phandle;
libzfs_handle_t *lzh;
diff --git a/lib/libbe/be_info.c b/lib/libbe/be_info.c
index 88a9b17bf421..4b0f611ce421 100644
--- a/lib/libbe/be_info.c
+++ b/lib/libbe/be_info.c
@@ -1,29 +1,8 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2017 Kyle J. Kneitinger <kyle@kneit.in>
* Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.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.
- *
- * 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.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <sys/cdefs.h>
@@ -181,8 +160,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p)
dataset = zfs_get_name(zfs_hdl);
nvlist_add_string(props, "dataset", dataset);
- if (data->bootonce != NULL &&
- strcmp(dataset, data->bootonce) == 0)
+ if (data->lbh->bootonce != NULL &&
+ strcmp(dataset, data->lbh->bootonce) == 0)
nvlist_add_boolean_value(props, "bootonce", true);
name = strrchr(dataset, '/') + 1;
@@ -252,9 +231,6 @@ be_proplist_update(prop_data_t *data)
ZFS_TYPE_FILESYSTEM)) == NULL)
return (BE_ERR_ZFSOPEN);
- (void) lzbe_get_boot_device(zpool_get_name(data->lbh->active_phandle),
- &data->bootonce);
-
/* XXX TODO: some error checking here */
zfs_iter_filesystems(root_hdl, prop_list_builder_cb, data);
diff --git a/lib/libbe/libbe.3 b/lib/libbe/libbe.3
index de2c29c65268..3b10711dd0f9 100644
--- a/lib/libbe/libbe.3
+++ b/lib/libbe/libbe.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 18, 2020
+.Dd April 20, 2025
.Dt LIBBE 3
.Os
.Sh NAME
@@ -147,8 +147,8 @@
.Sh DESCRIPTION
.Nm
interfaces with libzfs to provide a set of functions for various operations
-regarding ZFS boot environments including "deep" boot environments in which
-a boot environments has child datasets.
+regarding ZFS boot environments, including "deep" boot environments in which
+a boot environment has child datasets.
.Pp
A context structure is passed to each function, allowing for a small amount
of state to be retained, such as errors from previous operations.
@@ -178,14 +178,22 @@ If a BE root is supplied,
.Nm
will only operate out of that pool and BE root.
An error may occur if:
-.Bl -column
-.It /boot and / are not on the same filesystem and device,
-.It libzfs fails to initialize,
-.It The system has not been properly booted with a ZFS boot
+.Bl -bullet
+.It
+.Pa /boot
+and
+.Pa /
+are not on the same filesystem and device,
+.It
+libzfs fails to initialize,
+.It
+The system has not been properly booted with a ZFS boot
environment,
-.It Nm
+.It
+.Nm
fails to open the zpool the active boot environment resides on, or
-.It Nm
+.It
+.Nm
fails to locate the boot environment that is currently mounted.
.El
.Pp
@@ -226,9 +234,8 @@ function creates a snapshot of
.Fa be_name
named
.Fa snap_name .
-A
+A value of
.Dv NULL
-.Fa snap_name
may be used, indicating that
.Fn be_snaphot
should derive the snapshot name from the current date and time.
@@ -351,6 +358,10 @@ If
is
.Dv NULL ,
a mount point will be generated in
+.Ev TMPDIR
+or, if
+.Ev TMPDIR
+is not set,
.Pa /tmp
using
.Xr mkdtemp 3 .
@@ -385,6 +396,13 @@ This list of properties matches the properties collected by
The
.Fn be_unmount
function will unmount the given boot environment.
+If the mount point looks like it was created by
+.Fn be_mount ,
+then
+.Fn be_unmount
+will attempt to
+.Xr rmdir 2
+the mountpoint after a successful unmount.
Setting the
.Dv BE_MNT_FORCE
flag will pass
@@ -520,7 +538,7 @@ The
function will free the property list.
.Sh DIAGNOSTICS
Upon error, one of the following values will be returned:
-.Bl -dash -offset indent -compact
+.Bl -bullet -offset indent -compact
.It
BE_ERR_SUCCESS
.It
@@ -567,10 +585,16 @@ BE_ERR_INVORIGIN
.Sh SEE ALSO
.Xr bectl 8
.Sh HISTORY
+.Xr bectl 8
+and
.Nm
-and its corresponding command,
-.Xr bectl 8 ,
-were written as a 2017 Google Summer of Code project with Allan Jude serving
-as a mentor.
-Later work was done by
-.An Kyle Evans Aq Mt kevans@FreeBSD.org .
+were written by
+.An Kyle Kneitinger (kneitinger) Aq Mt kyle@kneit.in
+as a 2017 Google Summer of Code project, with
+.An Allan Jude (allanjude) Aq Mt allanjude@freebsd.org
+as mentor.
+.Sh AUTHORS
+Kyle Kneitinger, mentored as above.
+.Pp
+Post-GSoC changes were written by
+.An Kyle Evans (kevans) Aq Mt kevans@freebsd.org .
diff --git a/lib/libbe/tests/Makefile b/lib/libbe/tests/Makefile
index 7a16bc486d70..20a4e1ddfeb7 100644
--- a/lib/libbe/tests/Makefile
+++ b/lib/libbe/tests/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
ATF_TESTS_SH+= be_create
diff --git a/lib/libbe/tests/Makefile.depend b/lib/libbe/tests/Makefile.depend
new file mode 100644
index 000000000000..670634e1722a
--- /dev/null
+++ b/lib/libbe/tests/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ cddl/lib/libnvpair \
+ cddl/lib/libspl \
+ cddl/lib/libzfs \
+ lib/${CSU_DIR} \
+ lib/libbe \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libbearssl/Makefile b/lib/libbearssl/Makefile
index d307dd138a94..2c649bb80e9e 100644
--- a/lib/libbearssl/Makefile
+++ b/lib/libbearssl/Makefile
@@ -1,4 +1,3 @@
-
# This is a reach over build of BearSSL (www.BearSSL.org)
.include <src.opts.mk>
@@ -45,6 +44,7 @@ SRCS+= \
hash/ghash_pwr8.c \
hash/md5.c \
hash/md5sha1.c \
+ hash/mgf1.c
# this one does not compile for amd64
@@ -149,6 +149,11 @@ SRCS+= \
x509/x509_knownkey.c \
x509/x509_minimal_full.c \
+SRCS+= \
+ rand/hmac_drbg.c \
+ mac/hmac.c \
+ mac/hmac_ct.c \
+
INCS= \
inc/bearssl.h \
inc/bearssl_aead.h \
@@ -169,9 +174,6 @@ INCS:= ${INCS:S,^,${BEARSSL}/,}
.if ${MK_BEARSSL_SSL:Uno} == "yes"
SRCS+= \
- mac/hmac.c \
- mac/hmac_ct.c \
- rand/hmac_drbg.c \
ssl/prf.c \
ssl/prf_md5sha1.c \
ssl/prf_sha256.c \
diff --git a/lib/libbearssl/Makefile.inc b/lib/libbearssl/Makefile.inc
index 764984de9067..75365bb98be7 100644
--- a/lib/libbearssl/Makefile.inc
+++ b/lib/libbearssl/Makefile.inc
@@ -1,6 +1,6 @@
-
BEARSSL?= ${SRCTOP}/contrib/bearssl
BEARSSL_SRC= ${BEARSSL}/src
+BEARSSL_TOOLS= ${BEARSSL}/tools
CFLAGS+= -I${BEARSSL}/inc
CFLAGS+= ${NO_WDEPRECATED_NON_PROTOTYPE}
diff --git a/lib/libbearssl/Makefile.libsa.inc b/lib/libbearssl/Makefile.libsa.inc
index c31d3f85975a..827ce82d1304 100644
--- a/lib/libbearssl/Makefile.libsa.inc
+++ b/lib/libbearssl/Makefile.libsa.inc
@@ -1,4 +1,3 @@
-
# This file is included by libsa
# It contains SRCS needed for loader
@@ -83,3 +82,6 @@ SRCS+= \
x509/x509_decoder.c \
x509/x509_minimal.c \
+# We want find_error_name().
+SRCS+= \
+ ${BEARSSL_TOOLS}/errors.c \
diff --git a/lib/libbegemot/Makefile b/lib/libbegemot/Makefile
index a58881ff2ac9..99f61c67f085 100644
--- a/lib/libbegemot/Makefile
+++ b/lib/libbegemot/Makefile
@@ -1,4 +1,3 @@
-
LIBBEGEMOT_DIR=${SRCTOP}/contrib/libbegemot
PACKAGE=lib${LIB}
diff --git a/lib/libblacklist/Makefile b/lib/libblacklist/Makefile
index e8d25ac7f1b8..bfd9edb9614c 100644
--- a/lib/libblacklist/Makefile
+++ b/lib/libblacklist/Makefile
@@ -1,8 +1,8 @@
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
-BLACKLIST_DIR=${SRCTOP}/contrib/blacklist
-
-.PATH: ${BLACKLIST_DIR}/lib ${BLACKLIST_DIR}/include
+.PATH: ${BLOCKLIST_DIR}/lib ${BLOCKLIST_DIR}/include
+PACKAGE= blocklist
LIB= blacklist
SHLIB_MAJOR= 0
@@ -10,7 +10,7 @@ LIBADD+= pthread
CFLAGS.clang+=-Wno-thread-safety-analysis
-CFLAGS+=-I${BLACKLIST_DIR}/include -I${BLACKLIST_DIR}/port \
+CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
-D_REENTRANT -DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
-DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_GETPROGNAME \
-DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRUCT_SOCKADDR_SA_LEN
diff --git a/lib/libblocksruntime/Makefile b/lib/libblocksruntime/Makefile
index 6c7bb3c55144..baadcfd0f95c 100644
--- a/lib/libblocksruntime/Makefile
+++ b/lib/libblocksruntime/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB:tl}
LIB= BlocksRuntime
SHLIB_MAJOR=0
diff --git a/lib/libbsddialog/Makefile b/lib/libbsddialog/Makefile
index ddb7e08f71ba..2ec633b25147 100644
--- a/lib/libbsddialog/Makefile
+++ b/lib/libbsddialog/Makefile
@@ -6,9 +6,8 @@ LIB= bsddialog
PRIVATELIB= yes
SHLIB_MAJOR= 0
SRCS= barbox.c \
- calendarbox.c \
+ datebox.c \
formbox.c \
- infobox.c \
lib_util.c \
lib_util.h \
libbsddialog.c \
@@ -22,7 +21,7 @@ INCS= bsddialog.h \
bsddialog_progressview.h
MAN= bsddialog.3
-LIBADD= ncursesw tinfow formw
+LIBADD= ncursesw tinfow
CFLAGS+= -D_XOPEN_SOURCE_EXTENDED
.include <bsd.lib.mk>
diff --git a/lib/libbsddialog/Makefile.depend b/lib/libbsddialog/Makefile.depend
index e69de29bb2d1..04dbb4f44313 100644
--- a/lib/libbsddialog/Makefile.depend
+++ b/lib/libbsddialog/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/ncurses/ncurses \
+ lib/ncurses/tinfo \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libbsdstat/Makefile b/lib/libbsdstat/Makefile
index 46fa76adb28b..403c11cce586 100644
--- a/lib/libbsdstat/Makefile
+++ b/lib/libbsdstat/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= lib${LIB}
LIB= bsdstat
SHLIB_MAJOR= 1
diff --git a/lib/libbsdstat/bsdstat.h b/lib/libbsdstat/bsdstat.h
index 9dd9eb2cd00b..1b0d1f24e93f 100644
--- a/lib/libbsdstat/bsdstat.h
+++ b/lib/libbsdstat/bsdstat.h
@@ -36,7 +36,7 @@
*/
/*
- * Statistic definition/description. The are defined
+ * Statistic definition/description. These are defined
* for stats that correspond 1-1 w/ a collected stat
* and for stats that are calculated indirectly.
*/
diff --git a/lib/libbsm/Makefile b/lib/libbsm/Makefile
index 54af604eaa8e..67802eef62ac 100644
--- a/lib/libbsm/Makefile
+++ b/lib/libbsm/Makefile
@@ -60,12 +60,6 @@ MAN= libbsm.3 \
# they're not all libbsm parts.
#
MAN+= audit.2 \
- audit.log.5 \
- audit_class.5 \
- audit_control.5 \
- audit_event.5 \
- audit_user.5 \
- audit_warn.5 \
auditctl.2 \
auditon.2 \
getaudit.2 \
diff --git a/lib/libbsnmp/Makefile b/lib/libbsnmp/Makefile
index 5dc4e084dd00..7b25928ba611 100644
--- a/lib/libbsnmp/Makefile
+++ b/lib/libbsnmp/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
SUBDIR= libbsnmp
diff --git a/lib/libbsnmp/Makefile.inc b/lib/libbsnmp/Makefile.inc
index 80478f392410..ed0d6c46bd6c 100644
--- a/lib/libbsnmp/Makefile.inc
+++ b/lib/libbsnmp/Makefile.inc
@@ -1,5 +1,4 @@
-
INCSDIR= ${INCLUDEDIR}/bsnmp
-PACKAGE= bsnmp
+PACKAGE?= bsnmp
.include "../Makefile.inc"
diff --git a/lib/libbsnmp/libbsnmp/Makefile b/lib/libbsnmp/libbsnmp/Makefile
index 6bdb4003fdf4..2e2770b56c4a 100644
--- a/lib/libbsnmp/libbsnmp/Makefile
+++ b/lib/libbsnmp/libbsnmp/Makefile
@@ -7,7 +7,7 @@ CONTRIB= ${SRCTOP}/contrib/bsnmp/lib
.PATH: ${CONTRIB}
LIB= bsnmp
-SHLIB_MAJOR= 6
+SHLIB_MAJOR= 7
LD_FATAL_WARNINGS= no
CFLAGS+= -I${CONTRIB} -DHAVE_ERR_H -DHAVE_GETADDRINFO -DHAVE_STRLCPY
diff --git a/lib/libbsnmp/tests/Makefile b/lib/libbsnmp/tests/Makefile
index 529622104449..7a4a17e893a6 100644
--- a/lib/libbsnmp/tests/Makefile
+++ b/lib/libbsnmp/tests/Makefile
@@ -1,6 +1,7 @@
-
.include <bsd.own.mk>
+PACKAGE= tests
+
ATF_TESTS_C+= bsnmpd_test
SRCS.bsmpd_test= bsnmpd_test.c
diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile
index 832ec15487b8..f7ea21b1a085 100644
--- a/lib/libbz2/Makefile
+++ b/lib/libbz2/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= lib${LIB}
BZ2DIR= ${SRCTOP}/contrib/bzip2
.PATH: ${BZ2DIR}
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index 7b301d45d93e..9c12f419f6f1 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -20,22 +19,28 @@ SRCS+= any.cpp
SRCS+= atomic.cpp
SRCS+= barrier.cpp
SRCS+= bind.cpp
+SRCS+= call_once.cpp
SRCS+= charconv.cpp
SRCS+= chrono.cpp
SRCS+= condition_variable.cpp
SRCS+= condition_variable_destructor.cpp
-SRCS+= debug.cpp
+SRCS+= error_category.cpp
SRCS+= exception.cpp
+SRCS+= expected.cpp
+SRCS+= filesystem/directory_entry.cpp
SRCS+= filesystem/directory_iterator.cpp
+SRCS+= filesystem/filesystem_clock.cpp
+SRCS+= filesystem/filesystem_error.cpp
SRCS+= filesystem/int128_builtins.cpp
SRCS+= filesystem/operations.cpp
+SRCS+= filesystem/path.cpp
+SRCS+= fstream.cpp
SRCS+= functional.cpp
SRCS+= future.cpp
SRCS+= hash.cpp
SRCS+= ios.cpp
SRCS+= ios.instantiations.cpp
SRCS+= iostream.cpp
-SRCS+= legacy_debug_handler.cpp
SRCS+= legacy_pointer_safety.cpp
SRCS+= locale.cpp
SRCS+= memory.cpp
@@ -43,7 +48,11 @@ SRCS+= memory_resource.cpp
SRCS+= mutex.cpp
SRCS+= mutex_destructor.cpp
SRCS+= new.cpp
+SRCS+= new_handler.cpp
+SRCS+= new_helpers.cpp
SRCS+= optional.cpp
+SRCS+= ostream.cpp
+SRCS+= print.cpp
SRCS+= random.cpp
SRCS+= random_shuffle.cpp
SRCS+= regex.cpp
@@ -57,7 +66,6 @@ SRCS+= strstream.cpp
SRCS+= system_error.cpp
SRCS+= thread.cpp
SRCS+= typeinfo.cpp
-SRCS+= utility.cpp
SRCS+= valarray.cpp
SRCS+= variant.cpp
SRCS+= vector.cpp
@@ -81,38 +89,45 @@ cxxrt_${_S}: ${_LIBCXXRTDIR}/${_S} .NOMETA
.endfor
WARNS?= 0
+CFLAGS+= -isystem ${SRCDIR}
CFLAGS+= -isystem ${.CURDIR}
CFLAGS+= -isystem ${HDRDIR}
-CFLAGS+= -isystem ${SRCDIR}
CFLAGS+= -isystem ${_LIBCXXRTDIR}
CFLAGS+= -nostdinc++
CFLAGS+= -nostdlib
CFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
+CFLAGS+= -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
+CFLAGS+= -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
CFLAGS+= -DLIBCXXRT
-CFLAGS+= -ffunction-sections
CFLAGS+= -fdata-sections
+CFLAGS+= -ffunction-sections
+CFLAGS+= -fno-semantic-interposition
+CFLAGS+= -fvisibility-inlines-hidden
+CFLAGS+= -fvisibility=hidden
+
+.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} < 130000
+# NOTE: gcc 12 cannot correctly compile all libc++'s C++23 code. To temporarily
+# support gcc 12, compile libc++ in C++20 mode, but this will leave out any
+# C++23 features.
CXXSTD?= c++20
+.else
+CXXSTD?= c++23
+.endif
LIBADD+= cxxrt
INCSGROUPS+= STD
STDDIR= ${CXXINCLUDEDIR}
STD_HEADERS+= __assert
-STD_HEADERS+= __availability
STD_HEADERS+= __bit_reference
-STD_HEADERS+= __bsd_locale_defaults.h
-STD_HEADERS+= __bsd_locale_fallbacks.h
STD_HEADERS+= __config
-STD_HEADERS+= __debug
-STD_HEADERS+= __errc
STD_HEADERS+= __hash_table
STD_HEADERS+= __locale
STD_HEADERS+= __mbstate_t.h
-STD_HEADERS+= __mutex_base
STD_HEADERS+= __node_handle
STD_HEADERS+= __split_buffer
-STD_HEADERS+= __std_stream
-STD_HEADERS+= __threading_support
+STD_HEADERS+= __std_clang_module
+STD_HEADERS+= __std_mbstate_t.h
STD_HEADERS+= __tree
STD_HEADERS+= __undef_macros
STD_HEADERS+= __verbose_abort
@@ -180,22 +195,23 @@ STD_HEADERS+= iostream
STD_HEADERS+= istream
STD_HEADERS+= iterator
STD_HEADERS+= latch
-STD_HEADERS+= libcxx.imp
STD_HEADERS+= limits
-STD_HEADERS+= limits.h
STD_HEADERS+= list
STD_HEADERS+= locale
STD_HEADERS+= locale.h
STD_HEADERS+= map
STD_HEADERS+= math.h
+STD_HEADERS+= mdspan
STD_HEADERS+= memory
STD_HEADERS+= memory_resource
+STD_HEADERS+= module.modulemap
STD_HEADERS+= mutex
STD_HEADERS+= new
STD_HEADERS+= numbers
STD_HEADERS+= numeric
STD_HEADERS+= optional
STD_HEADERS+= ostream
+STD_HEADERS+= print
STD_HEADERS+= queue
STD_HEADERS+= random
STD_HEADERS+= ranges
@@ -204,7 +220,6 @@ STD_HEADERS+= regex
STD_HEADERS+= scoped_allocator
STD_HEADERS+= semaphore
STD_HEADERS+= set
-STD_HEADERS+= setjmp.h
STD_HEADERS+= shared_mutex
STD_HEADERS+= source_location
STD_HEADERS+= span
@@ -217,11 +232,13 @@ STD_HEADERS+= stdexcept
STD_HEADERS+= stdint.h
STD_HEADERS+= stdio.h
STD_HEADERS+= stdlib.h
+STD_HEADERS+= stop_token
STD_HEADERS+= streambuf
STD_HEADERS+= string
STD_HEADERS+= string.h
STD_HEADERS+= string_view
STD_HEADERS+= strstream
+STD_HEADERS+= syncstream
STD_HEADERS+= system_error
STD_HEADERS+= tgmath.h
STD_HEADERS+= thread
@@ -243,13 +260,14 @@ STD_HEADERS+= wctype.h
STD+= ${HDRDIR}/${hdr}
.endfor
-# Special case for __config_site, which as of libc++ 12.0.0 is generated by
-# CMake, and as of 13.0.0 installed side-by-side with__config.
+# Generated by CMake as of libc++ 18.
+STD+= ${.CURDIR}/__assertion_handler
+
+# Generated by CMake as of libc++ 13.
STD+= ${.CURDIR}/__config_site
-# Special case for module.modulemap, which as of libc++ 15.0.0 is generated by
-# CMake.
-STD+= ${.CURDIR}/module.modulemap
+# Generated by CMake as of libc++ 19.
+STD_HEADERS+= ${.CURDIR}/libcxx.imp
RT_HEADERS+= cxxabi.h
.for hdr in ${RT_HEADERS}
@@ -281,8 +299,11 @@ ALG_HEADERS+= find_end.h
ALG_HEADERS+= find_first_of.h
ALG_HEADERS+= find_if.h
ALG_HEADERS+= find_if_not.h
+ALG_HEADERS+= find_segment_if.h
+ALG_HEADERS+= fold.h
ALG_HEADERS+= for_each.h
ALG_HEADERS+= for_each_n.h
+ALG_HEADERS+= for_each_segment.h
ALG_HEADERS+= generate.h
ALG_HEADERS+= generate_n.h
ALG_HEADERS+= half_positive.h
@@ -303,6 +324,7 @@ ALG_HEADERS+= is_sorted_until.h
ALG_HEADERS+= iter_swap.h
ALG_HEADERS+= iterator_operations.h
ALG_HEADERS+= lexicographical_compare.h
+ALG_HEADERS+= lexicographical_compare_three_way.h
ALG_HEADERS+= lower_bound.h
ALG_HEADERS+= make_heap.h
ALG_HEADERS+= make_projected.h
@@ -327,18 +349,22 @@ ALG_HEADERS+= partition_copy.h
ALG_HEADERS+= partition_point.h
ALG_HEADERS+= pop_heap.h
ALG_HEADERS+= prev_permutation.h
+ALG_HEADERS+= pstl.h
ALG_HEADERS+= push_heap.h
ALG_HEADERS+= ranges_adjacent_find.h
ALG_HEADERS+= ranges_all_of.h
ALG_HEADERS+= ranges_any_of.h
ALG_HEADERS+= ranges_binary_search.h
ALG_HEADERS+= ranges_clamp.h
+ALG_HEADERS+= ranges_contains.h
+ALG_HEADERS+= ranges_contains_subrange.h
ALG_HEADERS+= ranges_copy.h
ALG_HEADERS+= ranges_copy_backward.h
ALG_HEADERS+= ranges_copy_if.h
ALG_HEADERS+= ranges_copy_n.h
ALG_HEADERS+= ranges_count.h
ALG_HEADERS+= ranges_count_if.h
+ALG_HEADERS+= ranges_ends_with.h
ALG_HEADERS+= ranges_equal.h
ALG_HEADERS+= ranges_equal_range.h
ALG_HEADERS+= ranges_fill.h
@@ -348,6 +374,7 @@ ALG_HEADERS+= ranges_find_end.h
ALG_HEADERS+= ranges_find_first_of.h
ALG_HEADERS+= ranges_find_if.h
ALG_HEADERS+= ranges_find_if_not.h
+ALG_HEADERS+= ranges_find_last.h
ALG_HEADERS+= ranges_for_each.h
ALG_HEADERS+= ranges_for_each_n.h
ALG_HEADERS+= ranges_generate.h
@@ -409,6 +436,7 @@ ALG_HEADERS+= ranges_sort.h
ALG_HEADERS+= ranges_sort_heap.h
ALG_HEADERS+= ranges_stable_partition.h
ALG_HEADERS+= ranges_stable_sort.h
+ALG_HEADERS+= ranges_starts_with.h
ALG_HEADERS+= ranges_swap_ranges.h
ALG_HEADERS+= ranges_transform.h
ALG_HEADERS+= ranges_unique.h
@@ -437,11 +465,13 @@ ALG_HEADERS+= shift_left.h
ALG_HEADERS+= shift_right.h
ALG_HEADERS+= shuffle.h
ALG_HEADERS+= sift_down.h
+ALG_HEADERS+= simd_utils.h
ALG_HEADERS+= sort.h
ALG_HEADERS+= sort_heap.h
ALG_HEADERS+= stable_partition.h
ALG_HEADERS+= stable_sort.h
ALG_HEADERS+= swap_ranges.h
+ALG_HEADERS+= three_way_comp_ref_type.h
ALG_HEADERS+= transform.h
ALG_HEADERS+= uniform_random_bit_generator_adaptor.h
ALG_HEADERS+= unique.h
@@ -453,6 +483,28 @@ ALG_HEADERS+= upper_bound.h
ALG+= ${HDRDIR}/__algorithm/${hdr}
.endfor
+INCSGROUPS+= ATM
+ATMDIR= ${CXXINCLUDEDIR}/__atomic
+ATM_HEADERS+= aliases.h
+ATM_HEADERS+= atomic.h
+ATM_HEADERS+= atomic_base.h
+ATM_HEADERS+= atomic_flag.h
+ATM_HEADERS+= atomic_init.h
+ATM_HEADERS+= atomic_lock_free.h
+ATM_HEADERS+= atomic_ref.h
+ATM_HEADERS+= atomic_sync.h
+ATM_HEADERS+= check_memory_order.h
+ATM_HEADERS+= contention_t.h
+ATM_HEADERS+= cxx_atomic_impl.h
+ATM_HEADERS+= fence.h
+ATM_HEADERS+= is_always_lock_free.h
+ATM_HEADERS+= kill_dependency.h
+ATM_HEADERS+= memory_order.h
+ATM_HEADERS+= to_gcc_order.h
+.for hdr in ${ATM_HEADERS}
+ATM+= ${HDRDIR}/__atomic/${hdr}
+.endfor
+
INCSGROUPS+= BIT
BITDIR= ${CXXINCLUDEDIR}/__bit
BIT_HEADERS+= bit_cast.h
@@ -466,6 +518,7 @@ BIT_HEADERS+= countl.h
BIT_HEADERS+= countr.h
BIT_HEADERS+= endian.h
BIT_HEADERS+= has_single_bit.h
+BIT_HEADERS+= invert_if.h
BIT_HEADERS+= popcount.h
BIT_HEADERS+= rotate.h
.for hdr in ${BIT_HEADERS}
@@ -475,10 +528,15 @@ BIT+= ${HDRDIR}/__bit/${hdr}
INCSGROUPS+= CHC
CHCDIR= ${CXXINCLUDEDIR}/__charconv
CHC_HEADERS+= chars_format.h
+CHC_HEADERS+= from_chars_integral.h
CHC_HEADERS+= from_chars_result.h
CHC_HEADERS+= tables.h
+CHC_HEADERS+= to_chars.h
CHC_HEADERS+= to_chars_base_10.h
+CHC_HEADERS+= to_chars_floating_point.h
+CHC_HEADERS+= to_chars_integral.h
CHC_HEADERS+= to_chars_result.h
+CHC_HEADERS+= traits.h
.for hdr in ${CHC_HEADERS}
CHC+= ${HDRDIR}/__charconv/${hdr}
.endfor
@@ -486,15 +544,19 @@ CHC+= ${HDRDIR}/__charconv/${hdr}
INCSGROUPS+= CHR
CHRDIR= ${CXXINCLUDEDIR}/__chrono
CHR_HEADERS+= calendar.h
+CHR_HEADERS+= concepts.h
CHR_HEADERS+= convert_to_timespec.h
CHR_HEADERS+= convert_to_tm.h
CHR_HEADERS+= day.h
CHR_HEADERS+= duration.h
+CHR_HEADERS+= exception.h
CHR_HEADERS+= file_clock.h
CHR_HEADERS+= formatter.h
CHR_HEADERS+= hh_mm_ss.h
CHR_HEADERS+= high_resolution_clock.h
+CHR_HEADERS+= leap_second.h
CHR_HEADERS+= literals.h
+CHR_HEADERS+= local_info.h
CHR_HEADERS+= month.h
CHR_HEADERS+= month_weekday.h
CHR_HEADERS+= monthday.h
@@ -502,13 +564,19 @@ CHR_HEADERS+= ostream.h
CHR_HEADERS+= parser_std_format_spec.h
CHR_HEADERS+= statically_widen.h
CHR_HEADERS+= steady_clock.h
+CHR_HEADERS+= sys_info.h
CHR_HEADERS+= system_clock.h
CHR_HEADERS+= time_point.h
+CHR_HEADERS+= time_zone.h
+CHR_HEADERS+= time_zone_link.h
+CHR_HEADERS+= tzdb.h
+CHR_HEADERS+= tzdb_list.h
CHR_HEADERS+= weekday.h
CHR_HEADERS+= year.h
CHR_HEADERS+= year_month.h
CHR_HEADERS+= year_month_day.h
CHR_HEADERS+= year_month_weekday.h
+CHR_HEADERS+= zoned_time.h
.for hdr in ${CHR_HEADERS}
CHR+= ${HDRDIR}/__chrono/${hdr}
.endfor
@@ -560,6 +628,24 @@ CON_HEADERS+= totally_ordered.h
CON+= ${HDRDIR}/__concepts/${hdr}
.endfor
+INCSGROUPS+= CND
+CNDDIR= ${CXXINCLUDEDIR}/__condition_variable
+CND_HEADERS+= condition_variable.h
+.for hdr in ${CND_HEADERS}
+CND+= ${HDRDIR}/__condition_variable/${hdr}
+.endfor
+
+INCSGROUPS+= CNF
+CNFDIR= ${CXXINCLUDEDIR}/__configuration
+CNF_HEADERS+= abi.h
+CNF_HEADERS+= availability.h
+CNF_HEADERS+= compiler.h
+CNF_HEADERS+= language.h
+CNF_HEADERS+= platform.h
+.for hdr in ${CNF_HEADERS}
+CNF+= ${HDRDIR}/__configuration/${hdr}
+.endfor
+
INCSGROUPS+= COR
CORDIR= ${CXXINCLUDEDIR}/__coroutine
COR_HEADERS+= coroutine_handle.h
@@ -573,18 +659,31 @@ COR+= ${HDRDIR}/__coroutine/${hdr}
INCSGROUPS+= DBG
DBGDIR= ${CXXINCLUDEDIR}/__debug_utils
DBG_HEADERS+= randomize_range.h
+DBG_HEADERS+= sanitizers.h
+DBG_HEADERS+= strict_weak_ordering_check.h
.for hdr in ${DBG_HEADERS}
DBG+= ${HDRDIR}/__debug_utils/${hdr}
.endfor
INCSGROUPS+= EXC
-EXCDIR= ${CXXINCLUDEDIR}/__expected
-EXC_HEADERS+= bad_expected_access.h
-EXC_HEADERS+= expected.h
-EXC_HEADERS+= unexpect.h
-EXC_HEADERS+= unexpected.h
+EXCDIR= ${CXXINCLUDEDIR}/__exception
+EXC_HEADERS+= exception.h
+EXC_HEADERS+= exception_ptr.h
+EXC_HEADERS+= nested_exception.h
+EXC_HEADERS+= operations.h
+EXC_HEADERS+= terminate.h
.for hdr in ${EXC_HEADERS}
-EXC+= ${HDRDIR}/__expected/${hdr}
+EXC+= ${HDRDIR}/__exception/${hdr}
+.endfor
+
+INCSGROUPS+= EXD
+EXDDIR= ${CXXINCLUDEDIR}/__expected
+EXD_HEADERS+= bad_expected_access.h
+EXD_HEADERS+= expected.h
+EXD_HEADERS+= unexpect.h
+EXD_HEADERS+= unexpected.h
+.for hdr in ${EXD_HEADERS}
+EXD+= ${HDRDIR}/__expected/${hdr}
.endfor
INCSGROUPS+= FS
@@ -623,7 +722,6 @@ FMT_HEADERS+= format_args.h
FMT_HEADERS+= format_context.h
FMT_HEADERS+= format_error.h
FMT_HEADERS+= format_functions.h
-FMT_HEADERS+= format_fwd.h
FMT_HEADERS+= format_parse_context.h
FMT_HEADERS+= format_string.h
FMT_HEADERS+= format_to_n_result.h
@@ -637,10 +735,13 @@ FMT_HEADERS+= formatter_output.h
FMT_HEADERS+= formatter_pointer.h
FMT_HEADERS+= formatter_string.h
FMT_HEADERS+= formatter_tuple.h
+FMT_HEADERS+= indic_conjunct_break_table.h
FMT_HEADERS+= parser_std_format_spec.h
FMT_HEADERS+= range_default_formatter.h
FMT_HEADERS+= range_formatter.h
FMT_HEADERS+= unicode.h
+FMT_HEADERS+= width_estimation_table.h
+FMT_HEADERS+= write_escaped.h
.for hdr in ${FMT_HEADERS}
FMT+= ${HDRDIR}/__format/${hdr}
.endfor
@@ -673,7 +774,6 @@ FUN_HEADERS+= ranges_operations.h
FUN_HEADERS+= reference_wrapper.h
FUN_HEADERS+= unary_function.h
FUN_HEADERS+= unary_negate.h
-FUN_HEADERS+= unwrap_ref.h
FUN_HEADERS+= weak_result_type.h
.for hdr in ${FUN_HEADERS}
FUN+= ${HDRDIR}/__functional/${hdr}
@@ -682,15 +782,29 @@ FUN+= ${HDRDIR}/__functional/${hdr}
INCSGROUPS+= FWD
FWDDIR= ${CXXINCLUDEDIR}/__fwd
FWD_HEADERS+= array.h
-FWD_HEADERS+= get.h
-FWD_HEADERS+= hash.h
+FWD_HEADERS+= bit_reference.h
+FWD_HEADERS+= complex.h
+FWD_HEADERS+= deque.h
+FWD_HEADERS+= format.h
+FWD_HEADERS+= fstream.h
+FWD_HEADERS+= functional.h
+FWD_HEADERS+= ios.h
+FWD_HEADERS+= istream.h
+FWD_HEADERS+= mdspan.h
+FWD_HEADERS+= memory.h
FWD_HEADERS+= memory_resource.h
+FWD_HEADERS+= ostream.h
FWD_HEADERS+= pair.h
+FWD_HEADERS+= queue.h
FWD_HEADERS+= span.h
+FWD_HEADERS+= sstream.h
+FWD_HEADERS+= stack.h
+FWD_HEADERS+= streambuf.h
FWD_HEADERS+= string.h
FWD_HEADERS+= string_view.h
FWD_HEADERS+= subrange.h
FWD_HEADERS+= tuple.h
+FWD_HEADERS+= vector.h
.for hdr in ${FWD_HEADERS}
FWD+= ${HDRDIR}/__fwd/${hdr}
.endfor
@@ -706,11 +820,13 @@ INCSGROUPS+= IT
ITDIR= ${CXXINCLUDEDIR}/__iterator
IT_HEADERS+= access.h
IT_HEADERS+= advance.h
+IT_HEADERS+= aliasing_iterator.h
IT_HEADERS+= back_insert_iterator.h
IT_HEADERS+= bounded_iter.h
IT_HEADERS+= common_iterator.h
IT_HEADERS+= concepts.h
IT_HEADERS+= counted_iterator.h
+IT_HEADERS+= cpp17_iterator_concepts.h
IT_HEADERS+= data.h
IT_HEADERS+= default_sentinel.h
IT_HEADERS+= distance.h
@@ -736,6 +852,7 @@ IT_HEADERS+= ostreambuf_iterator.h
IT_HEADERS+= permutable.h
IT_HEADERS+= prev.h
IT_HEADERS+= projected.h
+IT_HEADERS+= ranges_iterator_traits.h
IT_HEADERS+= readable_traits.h
IT_HEADERS+= reverse_access.h
IT_HEADERS+= reverse_iterator.h
@@ -748,10 +865,65 @@ IT_HEADERS+= wrap_iter.h
IT+= ${HDRDIR}/__iterator/${hdr}
.endfor
+INCSGROUPS+= LOC
+LOCDIR= ${CXXINCLUDEDIR}/__locale_dir
+LOC_HEADERS+= locale_base_api.h
+.for hdr in ${LOC_HEADERS}
+LOC+= ${HDRDIR}/__locale_dir/${hdr}
+.endfor
+
+INCSGROUPS+= LBA
+LBADIR= ${CXXINCLUDEDIR}/__locale_dir/locale_base_api
+LBA_HEADERS+= bsd_locale_defaults.h
+LBA_HEADERS+= bsd_locale_fallbacks.h
+LBA_HEADERS+= locale_guard.h
+.for hdr in ${LBA_HEADERS}
+LBA+= ${HDRDIR}/__locale_dir/locale_base_api/${hdr}
+.endfor
+
+INCSGROUPS+= MAT
+MATDIR= ${CXXINCLUDEDIR}/__math
+MAT_HEADERS+= abs.h
+MAT_HEADERS+= copysign.h
+MAT_HEADERS+= error_functions.h
+MAT_HEADERS+= exponential_functions.h
+MAT_HEADERS+= fdim.h
+MAT_HEADERS+= fma.h
+MAT_HEADERS+= gamma.h
+MAT_HEADERS+= hyperbolic_functions.h
+MAT_HEADERS+= hypot.h
+MAT_HEADERS+= inverse_hyperbolic_functions.h
+MAT_HEADERS+= inverse_trigonometric_functions.h
+MAT_HEADERS+= logarithms.h
+MAT_HEADERS+= min_max.h
+MAT_HEADERS+= modulo.h
+MAT_HEADERS+= remainder.h
+MAT_HEADERS+= roots.h
+MAT_HEADERS+= rounding_functions.h
+MAT_HEADERS+= special_functions.h
+MAT_HEADERS+= traits.h
+MAT_HEADERS+= trigonometric_functions.h
+.for hdr in ${MAT_HEADERS}
+MAT+= ${HDRDIR}/__math/${hdr}
+.endfor
+
+INCSGROUPS+= MDS
+MDSDIR= ${CXXINCLUDEDIR}/__mdspan
+MDS_HEADERS+= default_accessor.h
+MDS_HEADERS+= extents.h
+MDS_HEADERS+= layout_left.h
+MDS_HEADERS+= layout_right.h
+MDS_HEADERS+= layout_stride.h
+MDS_HEADERS+= mdspan.h
+.for hdr in ${MDS_HEADERS}
+MDS+= ${HDRDIR}/__mdspan/${hdr}
+.endfor
+
INCSGROUPS+= MEM
MEMDIR= ${CXXINCLUDEDIR}/__memory
MEM_HEADERS+= addressof.h
MEM_HEADERS+= align.h
+MEM_HEADERS+= aligned_alloc.h
MEM_HEADERS+= allocate_at_least.h
MEM_HEADERS+= allocation_guard.h
MEM_HEADERS+= allocator.h
@@ -765,6 +937,8 @@ MEM_HEADERS+= compressed_pair.h
MEM_HEADERS+= concepts.h
MEM_HEADERS+= construct_at.h
MEM_HEADERS+= destruct_n.h
+MEM_HEADERS+= inout_ptr.h
+MEM_HEADERS+= out_ptr.h
MEM_HEADERS+= pointer_traits.h
MEM_HEADERS+= ranges_construct_at.h
MEM_HEADERS+= ranges_uninitialized_algorithms.h
@@ -794,6 +968,17 @@ MER_HEADERS+= unsynchronized_pool_resource.h
MER+= ${HDRDIR}/__memory_resource/${hdr}
.endfor
+INCSGROUPS+= MUT
+MUTDIR= ${CXXINCLUDEDIR}/__mutex
+MUT_HEADERS+= lock_guard.h
+MUT_HEADERS+= mutex.h
+MUT_HEADERS+= once_flag.h
+MUT_HEADERS+= tag_types.h
+MUT_HEADERS+= unique_lock.h
+.for hdr in ${MUT_HEADERS}
+MUT+= ${HDRDIR}/__mutex/${hdr}
+.endfor
+
INCSGROUPS+= NUM
NUMDIR= ${CXXINCLUDEDIR}/__numeric
NUM_HEADERS+= accumulate.h
@@ -805,7 +990,9 @@ NUM_HEADERS+= inner_product.h
NUM_HEADERS+= iota.h
NUM_HEADERS+= midpoint.h
NUM_HEADERS+= partial_sum.h
+NUM_HEADERS+= pstl.h
NUM_HEADERS+= reduce.h
+NUM_HEADERS+= saturation_arithmetic.h
NUM_HEADERS+= transform_exclusive_scan.h
NUM_HEADERS+= transform_inclusive_scan.h
NUM_HEADERS+= transform_reduce.h
@@ -813,6 +1000,49 @@ NUM_HEADERS+= transform_reduce.h
NUM+= ${HDRDIR}/__numeric/${hdr}
.endfor
+INCSGROUPS+= OST
+OSTDIR= ${CXXINCLUDEDIR}/__ostream
+OST_HEADERS+= basic_ostream.h
+OST_HEADERS+= print.h
+.for hdr in ${OST_HEADERS}
+OST+= ${HDRDIR}/__ostream/${hdr}
+.endfor
+
+INCSGROUPS+= PST
+PSTDIR= ${CXXINCLUDEDIR}/__pstl
+PST_HEADERS+= backend.h
+PST_HEADERS+= backend_fwd.h
+PST_HEADERS+= dispatch.h
+PST_HEADERS+= handle_exception.h
+.for hdr in ${PST_HEADERS}
+PST+= ${HDRDIR}/__pstl/${hdr}
+.endfor
+
+INCSGROUPS+= PSB
+PSBDIR= ${CXXINCLUDEDIR}/__pstl/backends
+PSB_HEADERS+= default.h
+PSB_HEADERS+= libdispatch.h
+PSB_HEADERS+= serial.h
+PSB_HEADERS+= std_thread.h
+.for hdr in ${PSB_HEADERS}
+PSB+= ${HDRDIR}/__pstl/backends/${hdr}
+.endfor
+
+INCSGROUPS+= PSC
+PSCDIR= ${CXXINCLUDEDIR}/__pstl/cpu_algos
+PSC_HEADERS+= any_of.h
+PSC_HEADERS+= cpu_traits.h
+PSC_HEADERS+= fill.h
+PSC_HEADERS+= find_if.h
+PSC_HEADERS+= for_each.h
+PSC_HEADERS+= merge.h
+PSC_HEADERS+= stable_sort.h
+PSC_HEADERS+= transform.h
+PSC_HEADERS+= transform_reduce.h
+.for hdr in ${PSC_HEADERS}
+PSC+= ${HDRDIR}/__pstl/cpu_algos/${hdr}
+.endfor
+
INCSGROUPS+= RND
RNDDIR= ${CXXINCLUDEDIR}/__random
RND_HEADERS+= bernoulli_distribution.h
@@ -861,9 +1091,10 @@ RNGDIR= ${CXXINCLUDEDIR}/__ranges
RNG_HEADERS+= access.h
RNG_HEADERS+= all.h
RNG_HEADERS+= as_rvalue_view.h
+RNG_HEADERS+= chunk_by_view.h
RNG_HEADERS+= common_view.h
RNG_HEADERS+= concepts.h
-RNG_HEADERS+= copyable_box.h
+RNG_HEADERS+= container_compatible_range.h
RNG_HEADERS+= counted.h
RNG_HEADERS+= dangling.h
RNG_HEADERS+= data.h
@@ -875,16 +1106,19 @@ RNG_HEADERS+= empty_view.h
RNG_HEADERS+= enable_borrowed_range.h
RNG_HEADERS+= enable_view.h
RNG_HEADERS+= filter_view.h
+RNG_HEADERS+= from_range.h
RNG_HEADERS+= iota_view.h
RNG_HEADERS+= istream_view.h
RNG_HEADERS+= join_view.h
RNG_HEADERS+= lazy_split_view.h
+RNG_HEADERS+= movable_box.h
RNG_HEADERS+= non_propagating_cache.h
RNG_HEADERS+= owning_view.h
RNG_HEADERS+= range_adaptor.h
RNG_HEADERS+= rbegin.h
RNG_HEADERS+= ref_view.h
RNG_HEADERS+= rend.h
+RNG_HEADERS+= repeat_view.h
RNG_HEADERS+= reverse_view.h
RNG_HEADERS+= single_view.h
RNG_HEADERS+= size.h
@@ -892,6 +1126,7 @@ RNG_HEADERS+= split_view.h
RNG_HEADERS+= subrange.h
RNG_HEADERS+= take_view.h
RNG_HEADERS+= take_while_view.h
+RNG_HEADERS+= to.h
RNG_HEADERS+= transform_view.h
RNG_HEADERS+= view_interface.h
RNG_HEADERS+= views.h
@@ -900,36 +1135,78 @@ RNG_HEADERS+= zip_view.h
RNG+= ${HDRDIR}/__ranges/${hdr}
.endfor
+INCSGROUPS+= STT
+STTDIR= ${CXXINCLUDEDIR}/__stop_token
+STT_HEADERS+= atomic_unique_lock.h
+STT_HEADERS+= intrusive_list_view.h
+STT_HEADERS+= intrusive_shared_ptr.h
+STT_HEADERS+= stop_callback.h
+STT_HEADERS+= stop_source.h
+STT_HEADERS+= stop_state.h
+STT_HEADERS+= stop_token.h
+.for hdr in ${STT_HEADERS}
+STT+= ${HDRDIR}/__stop_token/${hdr}
+.endfor
+
INCSGROUPS+= STR
STRDIR= ${CXXINCLUDEDIR}/__string
STR_HEADERS+= char_traits.h
+STR_HEADERS+= constexpr_c_functions.h
STR_HEADERS+= extern_template_lists.h
.for hdr in ${STR_HEADERS}
STR+= ${HDRDIR}/__string/${hdr}
.endfor
+INCSGROUPS+= SER
+SERDIR= ${CXXINCLUDEDIR}/__system_error
+SER_HEADERS+= errc.h
+SER_HEADERS+= error_category.h
+SER_HEADERS+= error_code.h
+SER_HEADERS+= error_condition.h
+SER_HEADERS+= system_error.h
+.for hdr in ${SER_HEADERS}
+SER+= ${HDRDIR}/__system_error/${hdr}
+.endfor
+
INCSGROUPS+= THR
THRDIR= ${CXXINCLUDEDIR}/__thread
+THR_HEADERS+= formatter.h
+THR_HEADERS+= id.h
+THR_HEADERS+= jthread.h
THR_HEADERS+= poll_with_backoff.h
+THR_HEADERS+= support.h
+THR_HEADERS+= this_thread.h
+THR_HEADERS+= thread.h
THR_HEADERS+= timed_backoff_policy.h
.for hdr in ${THR_HEADERS}
THR+= ${HDRDIR}/__thread/${hdr}
.endfor
+INCSGROUPS+= THS
+THSDIR= ${CXXINCLUDEDIR}/__thread/support
+THS_HEADERS+= c11.h
+THS_HEADERS+= external.h
+THS_HEADERS+= pthread.h
+THS_HEADERS+= windows.h
+.for hdr in ${THS_HEADERS}
+THS+= ${HDRDIR}/__thread/support/${hdr}
+.endfor
+
INCSGROUPS+= TUP
-TUPDIR= ${CXXINCLUDEDIR}/__tuple_dir
-TUP_HEADERS+= apply_cv.h
+TUPDIR= ${CXXINCLUDEDIR}/__tuple
+TUP_HEADERS+= find_index.h
+TUP_HEADERS+= ignore.h
TUP_HEADERS+= make_tuple_types.h
-TUP_HEADERS+= pair_like.h
TUP_HEADERS+= sfinae_helpers.h
TUP_HEADERS+= tuple_element.h
TUP_HEADERS+= tuple_indices.h
TUP_HEADERS+= tuple_like.h
TUP_HEADERS+= tuple_like_ext.h
+TUP_HEADERS+= tuple_like_no_subrange.h
TUP_HEADERS+= tuple_size.h
TUP_HEADERS+= tuple_types.h
.for hdr in ${TUP_HEADERS}
-TUP+= ${HDRDIR}/__tuple_dir/${hdr}
+TUP+= ${HDRDIR}/__tuple/${hdr}
.endfor
INCSGROUPS+= TTR
@@ -943,7 +1220,6 @@ TTR_HEADERS+= add_volatile.h
TTR_HEADERS+= aligned_storage.h
TTR_HEADERS+= aligned_union.h
TTR_HEADERS+= alignment_of.h
-TTR_HEADERS+= apply_cv.h
TTR_HEADERS+= can_extract_key.h
TTR_HEADERS+= common_reference.h
TTR_HEADERS+= common_type.h
@@ -951,14 +1227,17 @@ TTR_HEADERS+= conditional.h
TTR_HEADERS+= conjunction.h
TTR_HEADERS+= copy_cv.h
TTR_HEADERS+= copy_cvref.h
+TTR_HEADERS+= datasizeof.h
TTR_HEADERS+= decay.h
TTR_HEADERS+= dependent_type.h
+TTR_HEADERS+= desugars_to.h
TTR_HEADERS+= disjunction.h
TTR_HEADERS+= enable_if.h
TTR_HEADERS+= extent.h
TTR_HEADERS+= has_unique_object_representation.h
TTR_HEADERS+= has_virtual_destructor.h
TTR_HEADERS+= integral_constant.h
+TTR_HEADERS+= invoke.h
TTR_HEADERS+= is_abstract.h
TTR_HEADERS+= is_aggregate.h
TTR_HEADERS+= is_allocator.h
@@ -976,13 +1255,12 @@ TTR_HEADERS+= is_const.h
TTR_HEADERS+= is_constant_evaluated.h
TTR_HEADERS+= is_constructible.h
TTR_HEADERS+= is_convertible.h
-TTR_HEADERS+= is_copy_assignable.h
-TTR_HEADERS+= is_copy_constructible.h
TTR_HEADERS+= is_core_convertible.h
-TTR_HEADERS+= is_default_constructible.h
TTR_HEADERS+= is_destructible.h
TTR_HEADERS+= is_empty.h
TTR_HEADERS+= is_enum.h
+TTR_HEADERS+= is_equality_comparable.h
+TTR_HEADERS+= is_execution_policy.h
TTR_HEADERS+= is_final.h
TTR_HEADERS+= is_floating_point.h
TTR_HEADERS+= is_function.h
@@ -993,17 +1271,10 @@ TTR_HEADERS+= is_literal_type.h
TTR_HEADERS+= is_member_function_pointer.h
TTR_HEADERS+= is_member_object_pointer.h
TTR_HEADERS+= is_member_pointer.h
-TTR_HEADERS+= is_move_assignable.h
-TTR_HEADERS+= is_move_constructible.h
TTR_HEADERS+= is_nothrow_assignable.h
TTR_HEADERS+= is_nothrow_constructible.h
TTR_HEADERS+= is_nothrow_convertible.h
-TTR_HEADERS+= is_nothrow_copy_assignable.h
-TTR_HEADERS+= is_nothrow_copy_constructible.h
-TTR_HEADERS+= is_nothrow_default_constructible.h
TTR_HEADERS+= is_nothrow_destructible.h
-TTR_HEADERS+= is_nothrow_move_assignable.h
-TTR_HEADERS+= is_nothrow_move_constructible.h
TTR_HEADERS+= is_null_pointer.h
TTR_HEADERS+= is_object.h
TTR_HEADERS+= is_pod.h
@@ -1024,13 +1295,10 @@ TTR_HEADERS+= is_swappable.h
TTR_HEADERS+= is_trivial.h
TTR_HEADERS+= is_trivially_assignable.h
TTR_HEADERS+= is_trivially_constructible.h
-TTR_HEADERS+= is_trivially_copy_assignable.h
-TTR_HEADERS+= is_trivially_copy_constructible.h
TTR_HEADERS+= is_trivially_copyable.h
-TTR_HEADERS+= is_trivially_default_constructible.h
TTR_HEADERS+= is_trivially_destructible.h
-TTR_HEADERS+= is_trivially_move_assignable.h
-TTR_HEADERS+= is_trivially_move_constructible.h
+TTR_HEADERS+= is_trivially_lexicographically_comparable.h
+TTR_HEADERS+= is_trivially_relocatable.h
TTR_HEADERS+= is_unbounded_array.h
TTR_HEADERS+= is_union.h
TTR_HEADERS+= is_unsigned.h
@@ -1063,6 +1331,7 @@ TTR_HEADERS+= strip_signature.h
TTR_HEADERS+= type_identity.h
TTR_HEADERS+= type_list.h
TTR_HEADERS+= underlying_type.h
+TTR_HEADERS+= unwrap_ref.h
TTR_HEADERS+= void_t.h
.for hdr in ${TTR_HEADERS}
TTR+= ${HDRDIR}/__type_traits/${hdr}
@@ -1071,21 +1340,28 @@ TTR+= ${HDRDIR}/__type_traits/${hdr}
INCSGROUPS+= UTL
UTLDIR= ${CXXINCLUDEDIR}/__utility
UTL_HEADERS+= as_const.h
+UTL_HEADERS+= as_lvalue.h
UTL_HEADERS+= auto_cast.h
UTL_HEADERS+= cmp.h
UTL_HEADERS+= convert_to_integral.h
UTL_HEADERS+= declval.h
+UTL_HEADERS+= empty.h
UTL_HEADERS+= exception_guard.h
UTL_HEADERS+= exchange.h
UTL_HEADERS+= forward.h
UTL_HEADERS+= forward_like.h
UTL_HEADERS+= in_place.h
UTL_HEADERS+= integer_sequence.h
+UTL_HEADERS+= is_pointer_in_range.h
+UTL_HEADERS+= is_valid_range.h
UTL_HEADERS+= move.h
+UTL_HEADERS+= no_destroy.h
UTL_HEADERS+= pair.h
UTL_HEADERS+= piecewise_construct.h
UTL_HEADERS+= priority_tag.h
+UTL_HEADERS+= private_constructor_tag.h
UTL_HEADERS+= rel_ops.h
+UTL_HEADERS+= small_buffer.h
UTL_HEADERS+= swap.h
UTL_HEADERS+= to_underlying.h
UTL_HEADERS+= unreachable.h
@@ -1103,30 +1379,31 @@ VAR+= ${HDRDIR}/__variant/${hdr}
INCSGROUPS+= EXP
EXPDIR= ${CXXINCLUDEDIR}/experimental
EXP_HEADERS+= __config
-EXP_HEADERS+= __memory
-EXP_HEADERS+= algorithm
-EXP_HEADERS+= coroutine
-EXP_HEADERS+= deque
-EXP_HEADERS+= forward_list
-EXP_HEADERS+= functional
EXP_HEADERS+= iterator
-EXP_HEADERS+= list
-EXP_HEADERS+= map
-EXP_HEADERS+= memory_resource
+EXP_HEADERS+= memory
EXP_HEADERS+= propagate_const
-EXP_HEADERS+= regex
-EXP_HEADERS+= set
EXP_HEADERS+= simd
-EXP_HEADERS+= string
EXP_HEADERS+= type_traits
-EXP_HEADERS+= unordered_map
-EXP_HEADERS+= unordered_set
EXP_HEADERS+= utility
-EXP_HEADERS+= vector
.for hdr in ${EXP_HEADERS}
EXP+= ${HDRDIR}/experimental/${hdr}
.endfor
+INCSGROUPS+= EXS
+EXSDIR= ${CXXINCLUDEDIR}/experimental/__simd
+EXS_HEADERS+= aligned_tag.h
+EXS_HEADERS+= declaration.h
+EXS_HEADERS+= reference.h
+EXS_HEADERS+= scalar.h
+EXS_HEADERS+= simd.h
+EXS_HEADERS+= simd_mask.h
+EXS_HEADERS+= traits.h
+EXS_HEADERS+= utility.h
+EXS_HEADERS+= vec_ext.h
+.for hdr in ${EXS_HEADERS}
+EXS+= ${HDRDIR}/experimental/__simd/${hdr}
+.endfor
+
INCSGROUPS+= EXT
EXTDIR= ${CXXINCLUDEDIR}/ext
EXT_HEADERS+= __hash
diff --git a/lib/libc++/__assertion_handler b/lib/libc++/__assertion_handler
new file mode 100644
index 000000000000..e12ccccdaff3
--- /dev/null
+++ b/lib/libc++/__assertion_handler
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ASSERTION_HANDLER
+#define _LIBCPP___ASSERTION_HANDLER
+
+#include <__config>
+#include <__verbose_abort>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
+
+# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_ABORT("%s", message)
+
+#else
+
+# if __has_builtin(__builtin_verbose_trap)
+// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
+// version before upstream Clang actually got the builtin.
+// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
+# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
+# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
+# else
+# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
+# endif
+# else
+# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
+# endif
+
+#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
+
+#endif // _LIBCPP___ASSERTION_HANDLER
diff --git a/lib/libc++/__config_site b/lib/libc++/__config_site
index c66b451bbdf5..1119b354de46 100644
--- a/lib/libc++/__config_site
+++ b/lib/libc++/__config_site
@@ -19,19 +19,26 @@
/* #undef _LIBCPP_HAS_THREAD_API_PTHREAD */
/* #undef _LIBCPP_HAS_THREAD_API_EXTERNAL */
/* #undef _LIBCPP_HAS_THREAD_API_WIN32 */
-/* #undef _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL */
/* #undef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS */
#define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
/* #undef _LIBCPP_NO_VCRUNTIME */
/* #undef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION */
-/* #undef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY */
-/* #undef _LIBCPP_HAS_PARALLEL_ALGORITHMS */
+/* #undef _LIBCPP_HAS_NO_FILESYSTEM */
/* #undef _LIBCPP_HAS_NO_RANDOM_DEVICE */
/* #undef _LIBCPP_HAS_NO_LOCALIZATION */
-/* #undef _LIBCPP_HAS_NO_FSTREAM */
+/* #undef _LIBCPP_HAS_NO_UNICODE */
/* #undef _LIBCPP_HAS_NO_WIDE_CHARACTERS */
-#define _LIBCPP_ENABLE_ASSERTIONS_DEFAULT 0
-/* #undef _LIBCPP_ENABLE_DEBUG_MODE */
+/* #undef _LIBCPP_HAS_NO_STD_MODULES */
+#define _LIBCPP_HAS_NO_TIME_ZONE_DATABASE
+/* #undef _LIBCPP_INSTRUMENTED_WITH_ASAN */
+
+// PSTL backends
+/* #undef _LIBCPP_PSTL_BACKEND_SERIAL */
+#define _LIBCPP_PSTL_BACKEND_STD_THREAD
+/* #undef _LIBCPP_PSTL_BACKEND_LIBDISPATCH */
+
+// Hardening.
+#define _LIBCPP_HARDENING_MODE_DEFAULT 16
// __USE_MINGW_ANSI_STDIO gets redefined on MinGW
#ifdef __clang__
diff --git a/lib/libc++/libcxx.imp b/lib/libc++/libcxx.imp
new file mode 100644
index 000000000000..73c9d62df329
--- /dev/null
+++ b/lib/libc++/libcxx.imp
@@ -0,0 +1,868 @@
+[
+ { include: [ "<__algorithm/adjacent_find.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/all_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/any_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/binary_search.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/clamp.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/comp.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/comp_ref_type.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/copy_backward.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/copy_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/copy_move_common.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/copy_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/count.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/count_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/equal.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/equal_range.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/fill.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/fill_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/find.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/find_end.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/find_first_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/find_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/find_if_not.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/find_segment_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/fold.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/for_each.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/for_each_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/for_each_segment.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/generate.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/generate_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/half_positive.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/in_found_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/in_fun_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/in_in_out_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/in_in_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/in_out_out_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/in_out_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/includes.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/inplace_merge.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/is_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/is_heap_until.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/is_partitioned.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/is_permutation.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/is_sorted.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/is_sorted_until.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/iter_swap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/iterator_operations.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/lexicographical_compare.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/lexicographical_compare_three_way.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/lower_bound.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/make_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/make_projected.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/max.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/max_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/merge.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/min.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/min_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/min_max_result.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/minmax.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/minmax_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/mismatch.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/move.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/move_backward.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/next_permutation.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/none_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/nth_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/partial_sort.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/partial_sort_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/partition.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/partition_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/partition_point.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/pop_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/prev_permutation.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/pstl.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/push_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_adjacent_find.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_all_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_any_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_binary_search.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_clamp.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_contains.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_contains_subrange.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_copy_backward.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_copy_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_copy_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_count.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_count_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_ends_with.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_equal.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_equal_range.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_fill.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_fill_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_find.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_find_end.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_find_first_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_find_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_find_if_not.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_find_last.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_for_each.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_for_each_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_generate.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_generate_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_includes.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_inplace_merge.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_is_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_is_heap_until.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_is_partitioned.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_is_permutation.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_is_sorted.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_is_sorted_until.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_iterator_concept.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_lexicographical_compare.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_lower_bound.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_make_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_max.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_max_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_merge.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_min.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_min_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_minmax.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_minmax_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_mismatch.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_move.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_move_backward.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_next_permutation.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_none_of.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_nth_element.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_partial_sort.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_partial_sort_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_partition.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_partition_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_partition_point.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_pop_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_prev_permutation.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_push_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_remove.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_remove_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_remove_copy_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_remove_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_replace.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_replace_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_replace_copy_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_replace_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_reverse.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_reverse_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_rotate.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_rotate_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_sample.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_search.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_search_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_set_difference.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_set_intersection.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_set_symmetric_difference.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_set_union.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_shuffle.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_sort.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_sort_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_stable_partition.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_stable_sort.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_starts_with.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_swap_ranges.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_transform.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_unique.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_unique_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/ranges_upper_bound.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/remove.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/remove_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/remove_copy_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/remove_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/replace.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/replace_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/replace_copy_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/replace_if.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/reverse.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/reverse_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/rotate.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/rotate_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/sample.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/search.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/search_n.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/set_difference.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/set_intersection.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/set_symmetric_difference.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/set_union.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/shift_left.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/shift_right.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/shuffle.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/sift_down.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/simd_utils.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/sort.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/sort_heap.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/stable_partition.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/stable_sort.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/swap_ranges.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/three_way_comp_ref_type.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/transform.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/uniform_random_bit_generator_adaptor.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/unique.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/unique_copy.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/unwrap_iter.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/unwrap_range.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__algorithm/upper_bound.h>", "private", "<algorithm>", "public" ] },
+ { include: [ "<__atomic/aliases.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic_base.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic_flag.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic_init.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic_lock_free.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic_ref.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/atomic_sync.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/check_memory_order.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/contention_t.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/cxx_atomic_impl.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/fence.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/is_always_lock_free.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/kill_dependency.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/memory_order.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__atomic/to_gcc_order.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__bit/bit_cast.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/bit_ceil.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/bit_floor.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/bit_log2.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/bit_width.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/blsr.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/byteswap.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/countl.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/countr.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/endian.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/has_single_bit.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/invert_if.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/popcount.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit/rotate.h>", "private", "<bit>", "public" ] },
+ { include: [ "<__bit_reference>", "private", "<bitset>", "public" ] },
+ { include: [ "<__bit_reference>", "private", "<vector>", "public" ] },
+ { include: [ "<__charconv/chars_format.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/from_chars_integral.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/from_chars_result.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/tables.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/to_chars.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/to_chars_base_10.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/to_chars_floating_point.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/to_chars_integral.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/to_chars_result.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__charconv/traits.h>", "private", "<charconv>", "public" ] },
+ { include: [ "<__chrono/calendar.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/concepts.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/convert_to_timespec.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/convert_to_tm.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/day.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/duration.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/exception.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/file_clock.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/formatter.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/hh_mm_ss.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/high_resolution_clock.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/leap_second.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/literals.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/local_info.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/month.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/month_weekday.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/monthday.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/ostream.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/parser_std_format_spec.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/statically_widen.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/steady_clock.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/sys_info.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/system_clock.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/time_point.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/time_zone.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/time_zone_link.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/tzdb.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/tzdb_list.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/weekday.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/year.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/year_month.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/year_month_day.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/year_month_weekday.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__chrono/zoned_time.h>", "private", "<chrono>", "public" ] },
+ { include: [ "<__compare/common_comparison_category.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/compare_partial_order_fallback.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/compare_strong_order_fallback.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/compare_three_way.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/compare_three_way_result.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/compare_weak_order_fallback.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/is_eq.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/ordering.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/partial_order.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/strong_order.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/synth_three_way.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/three_way_comparable.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__compare/weak_order.h>", "private", "<compare>", "public" ] },
+ { include: [ "<__concepts/arithmetic.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/assignable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/boolean_testable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/class_or_enum.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/common_reference_with.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/common_with.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/constructible.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/convertible_to.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/copyable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/derived_from.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/destructible.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/different_from.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/equality_comparable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/invocable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/movable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/predicate.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/regular.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/relation.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/same_as.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/semiregular.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/swappable.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__concepts/totally_ordered.h>", "private", "<concepts>", "public" ] },
+ { include: [ "<__condition_variable/condition_variable.h>", "private", "<condition_variable>", "public" ] },
+ { include: [ "<__config>", "private", "<version>", "public" ] },
+ { include: [ "<__configuration/abi.h>", "private", "<version>", "public" ] },
+ { include: [ "<__configuration/availability.h>", "private", "<version>", "public" ] },
+ { include: [ "<__configuration/compiler.h>", "private", "<version>", "public" ] },
+ { include: [ "<__configuration/language.h>", "private", "<version>", "public" ] },
+ { include: [ "<__configuration/platform.h>", "private", "<version>", "public" ] },
+ { include: [ "<__coroutine/coroutine_handle.h>", "private", "<coroutine>", "public" ] },
+ { include: [ "<__coroutine/coroutine_traits.h>", "private", "<coroutine>", "public" ] },
+ { include: [ "<__coroutine/noop_coroutine_handle.h>", "private", "<coroutine>", "public" ] },
+ { include: [ "<__coroutine/trivial_awaitables.h>", "private", "<coroutine>", "public" ] },
+ { include: [ "<__exception/exception.h>", "private", "<exception>", "public" ] },
+ { include: [ "<__exception/exception_ptr.h>", "private", "<exception>", "public" ] },
+ { include: [ "<__exception/nested_exception.h>", "private", "<exception>", "public" ] },
+ { include: [ "<__exception/operations.h>", "private", "<exception>", "public" ] },
+ { include: [ "<__exception/terminate.h>", "private", "<exception>", "public" ] },
+ { include: [ "<__expected/bad_expected_access.h>", "private", "<expected>", "public" ] },
+ { include: [ "<__expected/expected.h>", "private", "<expected>", "public" ] },
+ { include: [ "<__expected/unexpect.h>", "private", "<expected>", "public" ] },
+ { include: [ "<__expected/unexpected.h>", "private", "<expected>", "public" ] },
+ { include: [ "<__filesystem/copy_options.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/directory_entry.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/directory_iterator.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/directory_options.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/file_status.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/file_time_type.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/file_type.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/filesystem_error.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/operations.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/path.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/path_iterator.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/perm_options.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/perms.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/recursive_directory_iterator.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/space_info.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__filesystem/u8path.h>", "private", "<filesystem>", "public" ] },
+ { include: [ "<__format/buffer.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/concepts.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/container_adaptor.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/enable_insertable.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/escaped_output_table.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/extended_grapheme_cluster_table.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_arg.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_arg_store.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_args.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_context.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_error.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_functions.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_parse_context.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_string.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/format_to_n_result.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_bool.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_char.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_floating_point.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_integer.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_integral.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_output.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_pointer.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_string.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/formatter_tuple.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/indic_conjunct_break_table.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/parser_std_format_spec.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/range_default_formatter.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/range_formatter.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/unicode.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/width_estimation_table.h>", "private", "<format>", "public" ] },
+ { include: [ "<__format/write_escaped.h>", "private", "<format>", "public" ] },
+ { include: [ "<__functional/binary_function.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/binary_negate.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/bind.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/bind_back.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/bind_front.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/binder1st.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/binder2nd.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/boyer_moore_searcher.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/compose.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/default_searcher.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/function.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/hash.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/identity.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/invoke.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/is_transparent.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/mem_fn.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/mem_fun_ref.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/not_fn.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/operations.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/perfect_forward.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/pointer_to_binary_function.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/pointer_to_unary_function.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/ranges_operations.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/reference_wrapper.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/unary_function.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/unary_negate.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__functional/weak_result_type.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__fwd/array.h>", "private", "<array>", "public" ] },
+ { include: [ "<__fwd/bit_reference.h>", "private", "<bitset>", "public" ] },
+ { include: [ "<__fwd/bit_reference.h>", "private", "<vector>", "public" ] },
+ { include: [ "<__fwd/complex.h>", "private", "<complex>", "public" ] },
+ { include: [ "<__fwd/deque.h>", "private", "<deque>", "public" ] },
+ { include: [ "<__fwd/format.h>", "private", "<format>", "public" ] },
+ { include: [ "<__fwd/fstream.h>", "private", "<iosfwd>", "public" ] },
+ { include: [ "<__fwd/functional.h>", "private", "<functional>", "public" ] },
+ { include: [ "<__fwd/ios.h>", "private", "<iosfwd>", "public" ] },
+ { include: [ "<__fwd/istream.h>", "private", "<iosfwd>", "public" ] },
+ { include: [ "<__fwd/mdspan.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__fwd/memory.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__fwd/memory_resource.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__fwd/ostream.h>", "private", "<iosfwd>", "public" ] },
+ { include: [ "<__fwd/pair.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__fwd/queue.h>", "private", "<queue>", "public" ] },
+ { include: [ "<__fwd/span.h>", "private", "<span>", "public" ] },
+ { include: [ "<__fwd/sstream.h>", "private", "<iosfwd>", "public" ] },
+ { include: [ "<__fwd/stack.h>", "private", "<stack>", "public" ] },
+ { include: [ "<__fwd/streambuf.h>", "private", "<iosfwd>", "public" ] },
+ { include: [ "<__fwd/string.h>", "private", "<string>", "public" ] },
+ { include: [ "<__fwd/string_view.h>", "private", "<string_view>", "public" ] },
+ { include: [ "<__fwd/subrange.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__fwd/tuple.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__fwd/vector.h>", "private", "<vector>", "public" ] },
+ { include: [ "<__hash_table>", "private", "<unordered_map>", "public" ] },
+ { include: [ "<__hash_table>", "private", "<unordered_set>", "public" ] },
+ { include: [ "<__ios/fpos.h>", "private", "<ios>", "public" ] },
+ { include: [ "<__iterator/access.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/advance.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/aliasing_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/back_insert_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/bounded_iter.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/common_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/concepts.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/counted_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/cpp17_iterator_concepts.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/data.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/default_sentinel.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/distance.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/empty.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/erase_if_container.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/front_insert_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/incrementable_traits.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/indirectly_comparable.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/insert_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/istream_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/istreambuf_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/iter_move.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/iter_swap.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/iterator_traits.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/iterator_with_data.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/mergeable.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/move_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/move_sentinel.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/next.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/ostream_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/ostreambuf_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/permutable.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/prev.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/projected.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/ranges_iterator_traits.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/readable_traits.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/reverse_access.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/reverse_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/segmented_iterator.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/size.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/sortable.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/unreachable_sentinel.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__iterator/wrap_iter.h>", "private", "<iterator>", "public" ] },
+ { include: [ "<__locale>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/android.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/bsd_locale_defaults.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/bsd_locale_fallbacks.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/fuchsia.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/ibm.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/locale_guard.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/musl.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/newlib.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/openbsd.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__locale_dir/locale_base_api/win32.h>", "private", "<locale>", "public" ] },
+ { include: [ "<__math/abs.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/copysign.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/error_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/exponential_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/fdim.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/fma.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/gamma.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/hyperbolic_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/hypot.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/inverse_hyperbolic_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/inverse_trigonometric_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/logarithms.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/min_max.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/modulo.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/remainder.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/roots.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/rounding_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/special_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/traits.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__math/trigonometric_functions.h>", "private", "<cmath>", "public" ] },
+ { include: [ "<__mdspan/default_accessor.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__mdspan/extents.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__mdspan/layout_left.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__mdspan/layout_right.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__mdspan/layout_stride.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__mdspan/mdspan.h>", "private", "<mdspan>", "public" ] },
+ { include: [ "<__memory/addressof.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/align.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/aligned_alloc.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/allocate_at_least.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/allocation_guard.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/allocator.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/allocator_arg_t.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/allocator_destructor.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/allocator_traits.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/assume_aligned.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/auto_ptr.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/builtin_new_allocator.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/compressed_pair.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/concepts.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/construct_at.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/destruct_n.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/inout_ptr.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/out_ptr.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/pointer_traits.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/ranges_construct_at.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/ranges_uninitialized_algorithms.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/raw_storage_iterator.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/shared_ptr.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/swap_allocator.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/temp_value.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/temporary_buffer.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/uninitialized_algorithms.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/unique_ptr.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/uses_allocator.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/uses_allocator_construction.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory/voidify.h>", "private", "<memory>", "public" ] },
+ { include: [ "<__memory_resource/memory_resource.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__memory_resource/monotonic_buffer_resource.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__memory_resource/polymorphic_allocator.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__memory_resource/pool_options.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__memory_resource/synchronized_pool_resource.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__memory_resource/unsynchronized_pool_resource.h>", "private", "<memory_resource>", "public" ] },
+ { include: [ "<__mutex/lock_guard.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__mutex/mutex.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__mutex/once_flag.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__mutex/tag_types.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__mutex/unique_lock.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<map>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<set>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<unordered_map>", "public" ] },
+ { include: [ "<__node_handle>", "private", "<unordered_set>", "public" ] },
+ { include: [ "<__numeric/accumulate.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/adjacent_difference.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/exclusive_scan.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/gcd_lcm.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/inclusive_scan.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/inner_product.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/iota.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/midpoint.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/partial_sum.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/pstl.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/reduce.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/saturation_arithmetic.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/transform_exclusive_scan.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/transform_inclusive_scan.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__numeric/transform_reduce.h>", "private", "<numeric>", "public" ] },
+ { include: [ "<__ostream/basic_ostream.h>", "private", "<ostream>", "public" ] },
+ { include: [ "<__ostream/print.h>", "private", "<ostream>", "public" ] },
+ { include: [ "<__random/bernoulli_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/binomial_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/cauchy_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/chi_squared_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/clamp_to_integral.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/default_random_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/discard_block_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/discrete_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/exponential_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/extreme_value_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/fisher_f_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/gamma_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/generate_canonical.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/geometric_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/independent_bits_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/is_seed_sequence.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/is_valid.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/knuth_b.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/linear_congruential_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/log2.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/lognormal_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/mersenne_twister_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/negative_binomial_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/normal_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/piecewise_constant_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/piecewise_linear_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/poisson_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/random_device.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/ranlux.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/seed_seq.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/shuffle_order_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/student_t_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/subtract_with_carry_engine.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/uniform_int_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/uniform_random_bit_generator.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/uniform_real_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__random/weibull_distribution.h>", "private", "<random>", "public" ] },
+ { include: [ "<__ranges/access.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/all.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/as_rvalue_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/chunk_by_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/common_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/concepts.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/container_compatible_range.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/counted.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/dangling.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/data.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/drop_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/drop_while_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/elements_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/empty.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/empty_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/enable_borrowed_range.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/enable_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/filter_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/from_range.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/iota_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/istream_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/join_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/lazy_split_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/movable_box.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/non_propagating_cache.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/owning_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/range_adaptor.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/rbegin.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/ref_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/rend.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/repeat_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/reverse_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/single_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/size.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/split_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/subrange.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/take_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/take_while_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/to.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/transform_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/view_interface.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/views.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__ranges/zip_view.h>", "private", "<ranges>", "public" ] },
+ { include: [ "<__split_buffer>", "private", "<deque>", "public" ] },
+ { include: [ "<__split_buffer>", "private", "<vector>", "public" ] },
+ { include: [ "<__stop_token/atomic_unique_lock.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__stop_token/intrusive_list_view.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__stop_token/intrusive_shared_ptr.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__stop_token/stop_callback.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__stop_token/stop_source.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__stop_token/stop_state.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__stop_token/stop_token.h>", "private", "<stop_token>", "public" ] },
+ { include: [ "<__string/char_traits.h>", "private", "<string>", "public" ] },
+ { include: [ "<__string/constexpr_c_functions.h>", "private", "<string>", "public" ] },
+ { include: [ "<__string/extern_template_lists.h>", "private", "<string>", "public" ] },
+ { include: [ "<__system_error/errc.h>", "private", "<system_error>", "public" ] },
+ { include: [ "<__system_error/error_category.h>", "private", "<system_error>", "public" ] },
+ { include: [ "<__system_error/error_code.h>", "private", "<system_error>", "public" ] },
+ { include: [ "<__system_error/error_condition.h>", "private", "<system_error>", "public" ] },
+ { include: [ "<__system_error/system_error.h>", "private", "<system_error>", "public" ] },
+ { include: [ "<__thread/formatter.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/id.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/jthread.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/poll_with_backoff.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/support.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__thread/support.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__thread/support.h>", "private", "<semaphore>", "public" ] },
+ { include: [ "<__thread/support.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/support/c11.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__thread/support/c11.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__thread/support/c11.h>", "private", "<semaphore>", "public" ] },
+ { include: [ "<__thread/support/c11.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/support/external.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__thread/support/external.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__thread/support/external.h>", "private", "<semaphore>", "public" ] },
+ { include: [ "<__thread/support/external.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/support/pthread.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__thread/support/pthread.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__thread/support/pthread.h>", "private", "<semaphore>", "public" ] },
+ { include: [ "<__thread/support/pthread.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/support/windows.h>", "private", "<atomic>", "public" ] },
+ { include: [ "<__thread/support/windows.h>", "private", "<mutex>", "public" ] },
+ { include: [ "<__thread/support/windows.h>", "private", "<semaphore>", "public" ] },
+ { include: [ "<__thread/support/windows.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/this_thread.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/thread.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__thread/timed_backoff_policy.h>", "private", "<thread>", "public" ] },
+ { include: [ "<__tree>", "private", "<map>", "public" ] },
+ { include: [ "<__tree>", "private", "<set>", "public" ] },
+ { include: [ "<__tuple/find_index.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/ignore.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/make_tuple_types.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/sfinae_helpers.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_element.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_indices.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_like.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_like_ext.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_like_no_subrange.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_size.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__tuple/tuple_types.h>", "private", "<tuple>", "public" ] },
+ { include: [ "<__type_traits/add_const.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/add_cv.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/add_lvalue_reference.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/add_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/add_rvalue_reference.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/add_volatile.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/aligned_storage.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/aligned_union.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/alignment_of.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/can_extract_key.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/common_reference.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/common_type.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/conditional.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/conjunction.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/copy_cv.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/copy_cvref.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/datasizeof.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/decay.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/dependent_type.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/desugars_to.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/disjunction.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/enable_if.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/extent.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/has_unique_object_representation.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/has_virtual_destructor.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/integral_constant.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/invoke.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_abstract.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_aggregate.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_allocator.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_always_bitcastable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_arithmetic.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_array.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_assignable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_base_of.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_bounded_array.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_callable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_char_like_type.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_class.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_compound.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_const.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_constant_evaluated.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_constructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_convertible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_core_convertible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_destructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_empty.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_enum.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_equality_comparable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_execution_policy.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_final.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_floating_point.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_function.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_fundamental.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_implicitly_default_constructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_integral.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_literal_type.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_member_function_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_member_object_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_member_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_nothrow_assignable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_nothrow_constructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_nothrow_convertible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_nothrow_destructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_null_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_object.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_pod.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_polymorphic.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_primary_template.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_reference.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_reference_wrapper.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_referenceable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_same.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_scalar.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_scoped_enum.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_signed.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_signed_integer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_specialization.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_standard_layout.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_swappable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivial.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivially_assignable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivially_constructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivially_copyable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivially_destructible.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivially_lexicographically_comparable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_trivially_relocatable.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_unbounded_array.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_union.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_unsigned.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_unsigned_integer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_valid_expansion.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_void.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/is_volatile.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/lazy.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/make_32_64_or_128_bit.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/make_const_lvalue_ref.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/make_signed.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/make_unsigned.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/maybe_const.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/nat.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/negation.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/noexcept_move_assign_container.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/promote.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/rank.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_all_extents.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_const.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_const_ref.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_cv.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_cvref.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_extent.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_pointer.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_reference.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/remove_volatile.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/result_of.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/strip_signature.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/type_identity.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/type_list.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/underlying_type.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/unwrap_ref.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__type_traits/void_t.h>", "private", "<type_traits>", "public" ] },
+ { include: [ "<__utility/as_const.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/as_lvalue.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/auto_cast.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/cmp.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/convert_to_integral.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/declval.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/empty.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/exception_guard.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/exchange.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/forward.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/forward_like.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/in_place.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/integer_sequence.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/is_pointer_in_range.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/is_valid_range.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/move.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/no_destroy.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/pair.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/piecewise_construct.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/priority_tag.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/rel_ops.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/small_buffer.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/swap.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/to_underlying.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__utility/unreachable.h>", "private", "<utility>", "public" ] },
+ { include: [ "<__variant/monostate.h>", "private", "<variant>", "public" ] },
+]
diff --git a/lib/libc++/module.modulemap b/lib/libc++/module.modulemap
deleted file mode 100644
index ac283d8de00c..000000000000
--- a/lib/libc++/module.modulemap
+++ /dev/null
@@ -1,1724 +0,0 @@
-// define the module for __config outside of the top level 'std' module
-// since __config may be included from C headers which may create an
-// include cycle.
-module std_config [system] [extern_c] {
- header "__config"
- export *
-}
-
-module std [system] {
- export std_config
- // FIXME: The standard does not require that each of these submodules
- // re-exports its imported modules. We should provide an alternative form of
- // export that issues a warning if a name from the submodule is used, and
- // use that to provide a 'strict mode' for libc++.
-
- // Deprecated C-compatibility headers. These can all be included from within
- // an 'extern "C"' context.
- module depr [extern_c] {
- // <assert.h> provided by C library.
- module ctype_h {
- header "ctype.h"
- export *
- }
- module errno_h {
- header "errno.h"
- export *
- }
- module fenv_h {
- header "fenv.h"
- export *
- }
- // <float.h> provided by compiler or C library.
- module inttypes_h {
- header "inttypes.h"
- export stdint_h
- export *
- }
- // <iso646.h> provided by compiler.
- // <limits.h> provided by compiler or C library.
- module locale_h {
-
- header "locale.h"
- export *
- }
- module math_h {
- header "math.h"
- export *
- }
- module setjmp_h {
- header "setjmp.h"
- export *
- }
- module stdatomic_h {
-
- requires cplusplus23
- header "stdatomic.h"
- export *
- }
- // FIXME: <stdalign.h> is missing.
- // <signal.h> provided by C library.
- // <stdarg.h> provided by compiler.
- module stdbool_h {
- // <stdbool.h>'s __bool_true_false_are_defined macro requires textual inclusion.
- textual header "stdbool.h"
- }
- module stddef_h {
- // <stddef.h>'s __need_* macros require textual inclusion.
- textual header "stddef.h"
- }
- module stdint_h {
- header "stdint.h"
- export *
- // FIXME: This module only exists on OS X and for some reason the
- // wildcard above doesn't export it.
- export Darwin.C.stdint
- }
- module stdio_h {
- // <stdio.h>'s __need_* macros require textual inclusion.
- textual header "stdio.h"
- export *
- export Darwin.C.stdio
- }
- module stdlib_h {
- // <stdlib.h>'s __need_* macros require textual inclusion.
- textual header "stdlib.h"
- export *
- }
- module string_h {
- header "string.h"
- export *
- }
- module uchar_h {
- header "uchar.h"
- export *
- }
- // <time.h> provided by C library.
- module wchar_h {
-
- // <wchar.h>'s __need_* macros require textual inclusion.
- textual header "wchar.h"
- export *
- }
- module wctype_h {
-
- header "wctype.h"
- export *
- }
- }
-
- // <complex.h> and <tgmath.h> are not C headers in any real sense, do not
- // allow their use in extern "C" contexts.
- module complex_h {
- header "complex.h"
- export ccomplex
- export *
- }
- module tgmath_h {
- header "tgmath.h"
- export ccomplex
- export cmath
- export *
- }
-
- // C compatibility headers.
- module compat {
- module cassert {
- // <cassert>'s use of NDEBUG requires textual inclusion.
- textual header "cassert"
- }
- module ccomplex {
- header "ccomplex"
- export complex
- export *
- }
- module cctype {
- header "cctype"
- export *
- }
- module cerrno {
- header "cerrno"
- export *
- }
- module cfenv {
- header "cfenv"
- export *
- }
- module cfloat {
- header "cfloat"
- export *
- }
- module cinttypes {
- header "cinttypes"
- export cstdint
- export *
- }
- module ciso646 {
- header "ciso646"
- export *
- }
- module climits {
- header "climits"
- export *
- }
- module clocale {
-
- header "clocale"
- export *
- }
- module cmath {
- header "cmath"
- export *
- }
- module csetjmp {
- header "csetjmp"
- export *
- }
- module csignal {
- header "csignal"
- export *
- }
- // FIXME: <cstdalign> is missing.
- module cstdarg {
- header "cstdarg"
- export *
- }
- module cstdbool {
- header "cstdbool"
- export *
- }
- module cstddef {
- header "cstddef"
- export *
- }
- module cstdint {
- header "cstdint"
- export depr.stdint_h
- export *
- }
- module cstdio {
- header "cstdio"
- export *
- }
- module cstdlib {
- header "cstdlib"
- export *
- }
- module cstring {
- header "cstring"
- export *
- }
- module ctgmath {
- header "ctgmath"
- export ccomplex
- export cmath
- export *
- }
- module ctime {
- header "ctime"
- export *
- }
- module cuchar {
- header "cuchar"
- export *
- }
- module cwchar {
-
- header "cwchar"
- export depr.stdio_h
- export *
- }
- module cwctype {
-
- header "cwctype"
- export *
- }
- }
-
- module algorithm {
- header "algorithm"
- export initializer_list
- export *
-
- module __algorithm {
- module adjacent_find { private header "__algorithm/adjacent_find.h" }
- module all_of { private header "__algorithm/all_of.h" }
- module any_of { private header "__algorithm/any_of.h" }
- module binary_search { private header "__algorithm/binary_search.h" }
- module clamp { private header "__algorithm/clamp.h" }
- module comp { private header "__algorithm/comp.h" }
- module comp_ref_type { private header "__algorithm/comp_ref_type.h" }
- module copy { private header "__algorithm/copy.h" }
- module copy_backward { private header "__algorithm/copy_backward.h" }
- module copy_if { private header "__algorithm/copy_if.h" }
- module copy_move_common { private header "__algorithm/copy_move_common.h" }
- module copy_n { private header "__algorithm/copy_n.h" }
- module count { private header "__algorithm/count.h" }
- module count_if { private header "__algorithm/count_if.h" }
- module equal { private header "__algorithm/equal.h" }
- module equal_range { private header "__algorithm/equal_range.h" }
- module fill { private header "__algorithm/fill.h" }
- module fill_n { private header "__algorithm/fill_n.h" }
- module find { private header "__algorithm/find.h" }
- module find_end { private header "__algorithm/find_end.h" }
- module find_first_of { private header "__algorithm/find_first_of.h" }
- module find_if { private header "__algorithm/find_if.h" }
- module find_if_not { private header "__algorithm/find_if_not.h" }
- module for_each { private header "__algorithm/for_each.h" }
- module for_each_n { private header "__algorithm/for_each_n.h" }
- module generate { private header "__algorithm/generate.h" }
- module generate_n { private header "__algorithm/generate_n.h" }
- module half_positive { private header "__algorithm/half_positive.h" }
- module in_found_result { private header "__algorithm/in_found_result.h" }
- module in_fun_result { private header "__algorithm/in_fun_result.h" }
- module in_in_out_result { private header "__algorithm/in_in_out_result.h" }
- module in_in_result { private header "__algorithm/in_in_result.h" }
- module in_out_out_result { private header "__algorithm/in_out_out_result.h" }
- module in_out_result { private header "__algorithm/in_out_result.h" }
- module includes { private header "__algorithm/includes.h" }
- module inplace_merge { private header "__algorithm/inplace_merge.h" }
- module is_heap { private header "__algorithm/is_heap.h" }
- module is_heap_until { private header "__algorithm/is_heap_until.h" }
- module is_partitioned { private header "__algorithm/is_partitioned.h" }
- module is_permutation { private header "__algorithm/is_permutation.h" }
- module is_sorted { private header "__algorithm/is_sorted.h" }
- module is_sorted_until { private header "__algorithm/is_sorted_until.h" }
- module iter_swap { private header "__algorithm/iter_swap.h" }
- module iterator_operations {
- private header "__algorithm/iterator_operations.h"
- export *
- }
- module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" }
- module lower_bound { private header "__algorithm/lower_bound.h" }
- module make_heap { private header "__algorithm/make_heap.h" }
- module make_projected { private header "__algorithm/make_projected.h" }
- module max { private header "__algorithm/max.h" }
- module max_element { private header "__algorithm/max_element.h" }
- module merge { private header "__algorithm/merge.h" }
- module min { private header "__algorithm/min.h" }
- module min_element { private header "__algorithm/min_element.h" }
- module min_max_result { private header "__algorithm/min_max_result.h" }
- module minmax { private header "__algorithm/minmax.h" }
- module minmax_element { private header "__algorithm/minmax_element.h" }
- module mismatch { private header "__algorithm/mismatch.h" }
- module move { private header "__algorithm/move.h" }
- module move_backward { private header "__algorithm/move_backward.h" }
- module next_permutation { private header "__algorithm/next_permutation.h" }
- module none_of { private header "__algorithm/none_of.h" }
- module nth_element { private header "__algorithm/nth_element.h" }
- module partial_sort { private header "__algorithm/partial_sort.h" }
- module partial_sort_copy { private header "__algorithm/partial_sort_copy.h" }
- module partition { private header "__algorithm/partition.h" }
- module partition_copy { private header "__algorithm/partition_copy.h" }
- module partition_point { private header "__algorithm/partition_point.h" }
- module pop_heap { private header "__algorithm/pop_heap.h" }
- module prev_permutation { private header "__algorithm/prev_permutation.h" }
- module push_heap { private header "__algorithm/push_heap.h" }
- module ranges_adjacent_find { private header "__algorithm/ranges_adjacent_find.h" }
- module ranges_all_of { private header "__algorithm/ranges_all_of.h" }
- module ranges_any_of { private header "__algorithm/ranges_any_of.h" }
- module ranges_binary_search {
- private header "__algorithm/ranges_binary_search.h"
- export functional.__functional.ranges_operations
- }
- module ranges_clamp {
- private header "__algorithm/ranges_clamp.h"
- export functional.__functional.ranges_operations
- }
- module ranges_copy {
- private header "__algorithm/ranges_copy.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_copy_backward {
- private header "__algorithm/ranges_copy_backward.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_copy_if {
- private header "__algorithm/ranges_copy_if.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_copy_n {
- private header "__algorithm/ranges_copy_n.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_count { private header "__algorithm/ranges_count.h" }
- module ranges_count_if { private header "__algorithm/ranges_count_if.h" }
- module ranges_equal { private header "__algorithm/ranges_equal.h" }
- module ranges_equal_range {
- private header "__algorithm/ranges_equal_range.h"
- export functional.__functional.ranges_operations
- }
- module ranges_fill { private header "__algorithm/ranges_fill.h" }
- module ranges_fill_n { private header "__algorithm/ranges_fill_n.h" }
- module ranges_find { private header "__algorithm/ranges_find.h" }
- module ranges_find_end { private header "__algorithm/ranges_find_end.h" }
- module ranges_find_first_of { private header "__algorithm/ranges_find_first_of.h" }
- module ranges_find_if { private header "__algorithm/ranges_find_if.h" }
- module ranges_find_if_not { private header "__algorithm/ranges_find_if_not.h" }
- module ranges_for_each {
- private header "__algorithm/ranges_for_each.h"
- export algorithm.__algorithm.in_fun_result
- }
- module ranges_for_each_n {
- private header "__algorithm/ranges_for_each_n.h"
- export algorithm.__algorithm.in_fun_result
- }
- module ranges_generate { private header "__algorithm/ranges_generate.h" }
- module ranges_generate_n { private header "__algorithm/ranges_generate_n.h" }
- module ranges_includes {
- private header "__algorithm/ranges_includes.h"
- export functional.__functional.ranges_operations
- }
- module ranges_inplace_merge {
- private header "__algorithm/ranges_inplace_merge.h"
- export functional.__functional.ranges_operations
- }
- module ranges_is_heap {
- private header "__algorithm/ranges_is_heap.h"
- export functional.__functional.ranges_operations
- }
- module ranges_is_heap_until {
- private header "__algorithm/ranges_is_heap_until.h"
- export functional.__functional.ranges_operations
- }
- module ranges_is_partitioned { private header "__algorithm/ranges_is_partitioned.h" }
- module ranges_is_permutation { private header "__algorithm/ranges_is_permutation.h" }
- module ranges_is_sorted {
- private header "__algorithm/ranges_is_sorted.h"
- export functional.__functional.ranges_operations
- }
- module ranges_is_sorted_until {
- private header "__algorithm/ranges_is_sorted_until.h"
- export functional.__functional.ranges_operations
- }
- module ranges_iterator_concept { private header "__algorithm/ranges_iterator_concept.h" }
- module ranges_lexicographical_compare {
- private header "__algorithm/ranges_lexicographical_compare.h"
- export functional.__functional.ranges_operations
- }
- module ranges_lower_bound {
- private header "__algorithm/ranges_lower_bound.h"
- export functional.__functional.ranges_operations
- }
- module ranges_make_heap {
- private header "__algorithm/ranges_make_heap.h"
- export functional.__functional.ranges_operations
- }
- module ranges_max {
- private header "__algorithm/ranges_max.h"
- export functional.__functional.ranges_operations
- }
- module ranges_max_element {
- private header "__algorithm/ranges_max_element.h"
- export functional.__functional.ranges_operations
- }
- module ranges_merge {
- private header "__algorithm/ranges_merge.h"
- export algorithm.__algorithm.in_in_out_result
- }
- module ranges_min {
- private header "__algorithm/ranges_min.h"
- export functional.__functional.ranges_operations
- }
- module ranges_min_element {
- private header "__algorithm/ranges_min_element.h"
- export functional.__functional.ranges_operations
- }
- module ranges_minmax {
- private header "__algorithm/ranges_minmax.h"
- export functional.__functional.ranges_operations
- export algorithm.__algorithm.min_max_result
- }
- module ranges_minmax_element {
- private header "__algorithm/ranges_minmax_element.h"
- export functional.__functional.ranges_operations
- export algorithm.__algorithm.min_max_result
- }
- module ranges_mismatch {
- private header "__algorithm/ranges_mismatch.h"
- export algorithm.__algorithm.in_in_result
- }
- module ranges_move {
- private header "__algorithm/ranges_move.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_move_backward {
- private header "__algorithm/ranges_move_backward.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_next_permutation {
- private header "__algorithm/ranges_next_permutation.h"
- export algorithm.__algorithm.in_found_result
- export functional.__functional.ranges_operations
- }
- module ranges_none_of { private header "__algorithm/ranges_none_of.h" }
- module ranges_nth_element {
- private header "__algorithm/ranges_nth_element.h"
- export functional.__functional.ranges_operations
- }
- module ranges_partial_sort {
- private header "__algorithm/ranges_partial_sort.h"
- export algorithm.__algorithm.in_out_result
- export functional.__functional.ranges_operations
- }
- module ranges_partial_sort_copy {
- private header "__algorithm/ranges_partial_sort_copy.h"
- export algorithm.__algorithm.in_out_out_result
- export functional.__functional.ranges_operations
- }
- module ranges_partition { private header "__algorithm/ranges_partition.h" }
- module ranges_partition_copy { private header "__algorithm/ranges_partition_copy.h" }
- module ranges_partition_point { private header "__algorithm/ranges_partition_point.h" }
- module ranges_pop_heap {
- private header "__algorithm/ranges_pop_heap.h"
- export functional.__functional.ranges_operations
- }
- module ranges_prev_permutation {
- private header "__algorithm/ranges_prev_permutation.h"
- export algorithm.__algorithm.in_found_result
- export functional.__functional.ranges_operations
- }
- module ranges_push_heap {
- private header "__algorithm/ranges_push_heap.h"
- export functional.__functional.ranges_operations
- }
- module ranges_remove { private header "__algorithm/ranges_remove.h" }
- module ranges_remove_copy {
- private header "__algorithm/ranges_remove_copy.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_remove_copy_if {
- private header "__algorithm/ranges_remove_copy_if.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_remove_if { private header "__algorithm/ranges_remove_if.h" }
- module ranges_replace { private header "__algorithm/ranges_replace.h" }
- module ranges_replace_copy {
- private header "__algorithm/ranges_replace_copy.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_replace_copy_if {
- private header "__algorithm/ranges_replace_copy_if.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_replace_if { private header "__algorithm/ranges_replace_if.h" }
- module ranges_reverse { private header "__algorithm/ranges_reverse.h" }
- module ranges_reverse_copy {
- private header "__algorithm/ranges_reverse_copy.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_rotate { private header "__algorithm/ranges_rotate.h" }
- module ranges_rotate_copy {
- private header "__algorithm/ranges_rotate_copy.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_sample { private header "__algorithm/ranges_sample.h" }
- module ranges_search { private header "__algorithm/ranges_search.h" }
- module ranges_search_n { private header "__algorithm/ranges_search_n.h" }
- module ranges_set_difference {
- private header "__algorithm/ranges_set_difference.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_set_intersection {
- private header "__algorithm/ranges_set_intersection.h"
- export algorithm.__algorithm.in_in_out_result
- }
- module ranges_set_symmetric_difference {
- private header "__algorithm/ranges_set_symmetric_difference.h"
- export algorithm.__algorithm.in_in_out_result
- export functional.__functional.ranges_operations
- }
- module ranges_set_union {
- private header "__algorithm/ranges_set_union.h"
- export algorithm.__algorithm.in_in_out_result
- export functional.__functional.ranges_operations
- }
- module ranges_shuffle { private header "__algorithm/ranges_shuffle.h" }
- module ranges_sort {
- private header "__algorithm/ranges_sort.h"
- export functional.__functional.ranges_operations
- }
- module ranges_sort_heap {
- private header "__algorithm/ranges_sort_heap.h"
- export functional.__functional.ranges_operations
- }
- module ranges_stable_partition { private header "__algorithm/ranges_stable_partition.h" }
- module ranges_stable_sort {
- private header "__algorithm/ranges_stable_sort.h"
- export functional.__functional.ranges_operations
- }
- module ranges_swap_ranges {
- private header "__algorithm/ranges_swap_ranges.h"
- export algorithm.__algorithm.in_in_result
- }
- module ranges_transform {
- private header "__algorithm/ranges_transform.h"
- export algorithm.__algorithm.in_in_out_result
- export algorithm.__algorithm.in_out_result
- }
- module uniform_random_bit_generator_adaptor {
- private header "__algorithm/uniform_random_bit_generator_adaptor.h"
- }
- module ranges_unique { private header "__algorithm/ranges_unique.h" }
- module ranges_unique_copy {
- private header "__algorithm/ranges_unique_copy.h"
- export algorithm.__algorithm.in_out_result
- }
- module ranges_upper_bound {
- private header "__algorithm/ranges_upper_bound.h"
- export functional.__functional.ranges_operations
- }
- module remove { private header "__algorithm/remove.h" }
- module remove_copy { private header "__algorithm/remove_copy.h" }
- module remove_copy_if { private header "__algorithm/remove_copy_if.h" }
- module remove_if { private header "__algorithm/remove_if.h" }
- module replace { private header "__algorithm/replace.h" }
- module replace_copy { private header "__algorithm/replace_copy.h" }
- module replace_copy_if { private header "__algorithm/replace_copy_if.h" }
- module replace_if { private header "__algorithm/replace_if.h" }
- module reverse { private header "__algorithm/reverse.h" }
- module reverse_copy { private header "__algorithm/reverse_copy.h" }
- module rotate { private header "__algorithm/rotate.h" }
- module rotate_copy { private header "__algorithm/rotate_copy.h" }
- module sample { private header "__algorithm/sample.h" }
- module search { private header "__algorithm/search.h" }
- module search_n { private header "__algorithm/search_n.h" }
- module set_difference { private header "__algorithm/set_difference.h" }
- module set_intersection { private header "__algorithm/set_intersection.h" }
- module set_symmetric_difference { private header "__algorithm/set_symmetric_difference.h" }
- module set_union { private header "__algorithm/set_union.h" }
- module shift_left { private header "__algorithm/shift_left.h" }
- module shift_right { private header "__algorithm/shift_right.h" }
- module shuffle { private header "__algorithm/shuffle.h" }
- module sift_down { private header "__algorithm/sift_down.h" }
- module sort { private header "__algorithm/sort.h" }
- module sort_heap { private header "__algorithm/sort_heap.h" }
- module stable_partition { private header "__algorithm/stable_partition.h" }
- module stable_sort { private header "__algorithm/stable_sort.h" }
- module swap_ranges { private header "__algorithm/swap_ranges.h" }
- module transform { private header "__algorithm/transform.h" }
- module unique { private header "__algorithm/unique.h" }
- module unique_copy { private header "__algorithm/unique_copy.h" }
- module unwrap_iter { private header "__algorithm/unwrap_iter.h" }
- module unwrap_range { private header "__algorithm/unwrap_range.h" }
- module upper_bound { private header "__algorithm/upper_bound.h" }
- }
- }
- module any {
- header "any"
- export *
- }
- module array {
- header "array"
- export initializer_list
- export *
-
- module array_fwd { private header "__fwd/array.h" }
- }
- module atomic {
- header "atomic"
- export *
- }
- module barrier {
-
- header "barrier"
- export *
- }
- module bit {
- header "bit"
- export *
-
- module __bit {
- module bit_cast { private header "__bit/bit_cast.h" }
- module bit_ceil { private header "__bit/bit_ceil.h" }
- module bit_floor { private header "__bit/bit_floor.h" }
- module bit_log2 { private header "__bit/bit_log2.h" }
- module bit_width { private header "__bit/bit_width.h" }
- module blsr { private header "__bit/blsr.h" }
- module byteswap { private header "__bit/byteswap.h" }
- module countl { private header "__bit/countl.h" }
- module countr { private header "__bit/countr.h" }
- module endian { private header "__bit/endian.h" }
- module has_single_bit { private header "__bit/has_single_bit.h" }
- module popcount { private header "__bit/popcount.h" }
- module rotate { private header "__bit/rotate.h" }
- }
- }
- module bitset {
- header "bitset"
- export string
- export iosfwd
- export *
- }
- // No submodule for cassert. It fundamentally needs repeated, textual inclusion.
- module charconv {
- header "charconv"
- export *
-
- module __charconv {
- module chars_format { private header "__charconv/chars_format.h" }
- module from_chars_result { private header "__charconv/from_chars_result.h" }
- module tables { private header "__charconv/tables.h" }
- module to_chars_base_10 { private header "__charconv/to_chars_base_10.h" }
- module to_chars_result { private header "__charconv/to_chars_result.h" }
- }
-
- }
- module chrono {
- header "chrono"
- export *
-
- module __chrono {
- module calendar { private header "__chrono/calendar.h" }
- module convert_to_timespec { private header "__chrono/convert_to_timespec.h" }
- module convert_to_tm { private header "__chrono/convert_to_tm.h" }
- module day { private header "__chrono/day.h" }
- module duration { private header "__chrono/duration.h" }
- module file_clock { private header "__chrono/file_clock.h" }
- module formatter {
-
- private header "__chrono/formatter.h"
- }
- module hh_mm_ss { private header "__chrono/hh_mm_ss.h" }
- module high_resolution_clock {
- private header "__chrono/high_resolution_clock.h"
- export steady_clock
- export system_clock
- export time_point
- }
- module literals { private header "__chrono/literals.h" }
- module month { private header "__chrono/month.h" }
- module month_weekday { private header "__chrono/month_weekday.h" }
- module monthday { private header "__chrono/monthday.h" }
- module ostream {
-
- private header "__chrono/ostream.h"
- }
- module parser_std_format_spec {
-
- private header "__chrono/parser_std_format_spec.h"
- }
- module statically_widen { private header "__chrono/statically_widen.h" }
- module steady_clock { private header "__chrono/steady_clock.h" }
- module system_clock { private header "__chrono/system_clock.h" }
- module time_point { private header "__chrono/time_point.h" }
- module weekday { private header "__chrono/weekday.h" }
- module year { private header "__chrono/year.h" }
- module year_month { private header "__chrono/year_month.h" }
- module year_month_day { private header "__chrono/year_month_day.h" }
- module year_month_weekday { private header "__chrono/year_month_weekday.h" }
- }
- }
- module codecvt {
-
- header "codecvt"
- export *
- }
- module compare {
- header "compare"
- export *
-
- module __compare {
- module common_comparison_category { private header "__compare/common_comparison_category.h" }
- module compare_partial_order_fallback { private header "__compare/compare_partial_order_fallback.h" }
- module compare_strong_order_fallback { private header "__compare/compare_strong_order_fallback.h" }
- module compare_three_way { private header "__compare/compare_three_way.h" }
- module compare_three_way_result { private header "__compare/compare_three_way_result.h" }
- module compare_weak_order_fallback { private header "__compare/compare_weak_order_fallback.h" }
- module is_eq { private header "__compare/is_eq.h" }
- module ordering { private header "__compare/ordering.h" }
- module partial_order { private header "__compare/partial_order.h" }
- module strong_order { private header "__compare/strong_order.h" }
- module synth_three_way { private header "__compare/synth_three_way.h" }
- module three_way_comparable { private header "__compare/three_way_comparable.h" }
- module weak_order { private header "__compare/weak_order.h" }
- }
- }
- module complex {
- header "complex"
- export *
- }
- module concepts {
- header "concepts"
- export *
-
- module __concepts {
- module arithmetic { private header "__concepts/arithmetic.h" }
- module assignable { private header "__concepts/assignable.h" }
- module boolean_testable { private header "__concepts/boolean_testable.h" }
- module class_or_enum { private header "__concepts/class_or_enum.h" }
- module common_reference_with { private header "__concepts/common_reference_with.h" }
- module common_with { private header "__concepts/common_with.h" }
- module constructible { private header "__concepts/constructible.h" }
- module convertible_to { private header "__concepts/convertible_to.h" }
- module copyable { private header "__concepts/copyable.h" }
- module derived_from { private header "__concepts/derived_from.h" }
- module destructible { private header "__concepts/destructible.h" }
- module different_from { private header "__concepts/different_from.h" }
- module equality_comparable { private header "__concepts/equality_comparable.h" }
- module invocable { private header "__concepts/invocable.h" }
- module movable { private header "__concepts/movable.h" }
- module predicate { private header "__concepts/predicate.h" }
- module regular { private header "__concepts/regular.h" }
- module relation { private header "__concepts/relation.h" }
- module same_as { private header "__concepts/same_as.h" }
- module semiregular { private header "__concepts/semiregular.h" }
- module swappable { private header "__concepts/swappable.h" }
- module totally_ordered { private header "__concepts/totally_ordered.h" }
- }
- }
- module condition_variable {
- header "condition_variable"
- export *
- }
- module coroutine {
- requires coroutines
- header "coroutine"
- export compare
- export *
-
- module __coroutine {
- module coroutine_handle { private header "__coroutine/coroutine_handle.h" }
- module coroutine_traits { private header "__coroutine/coroutine_traits.h" }
- module noop_coroutine_handle { private header "__coroutine/noop_coroutine_handle.h" }
- module trivial_awaitables { private header "__coroutine/trivial_awaitables.h" }
- }
- }
- module deque {
- header "deque"
- export initializer_list
- export *
- }
- module exception {
- header "exception"
- export *
- }
- module execution {
- header "execution"
- export *
- }
- module expected {
- header "expected"
- export *
-
- module __expected {
- module bad_expected_access { private header "__expected/bad_expected_access.h" }
- module expected { private header "__expected/expected.h" }
- module unexpect { private header "__expected/unexpect.h" }
- module unexpected { private header "__expected/unexpected.h" }
- }
- }
- module filesystem {
-
- header "filesystem"
- export *
-
- module __filesystem {
- module copy_options { private header "__filesystem/copy_options.h" }
- module directory_entry { private header "__filesystem/directory_entry.h" }
- module directory_iterator { private header "__filesystem/directory_iterator.h" }
- module directory_options { private header "__filesystem/directory_options.h" }
- module file_status { private header "__filesystem/file_status.h" }
- module file_time_type { private header "__filesystem/file_time_type.h" }
- module file_type { private header "__filesystem/file_type.h" }
- module filesystem_error { private header "__filesystem/filesystem_error.h" }
- module operations { private header "__filesystem/operations.h" }
- module path { private header "__filesystem/path.h" }
- module path_iterator { private header "__filesystem/path_iterator.h" }
- module perm_options { private header "__filesystem/perm_options.h" }
- module perms { private header "__filesystem/perms.h" }
- module recursive_directory_iterator { private header "__filesystem/recursive_directory_iterator.h" }
- module space_info { private header "__filesystem/space_info.h" }
- module u8path { private header "__filesystem/u8path.h" }
- }
- }
- module format {
- header "format"
- export *
-
- module __format {
- module buffer { private header "__format/buffer.h" }
- module concepts { private header "__format/concepts.h" }
- module container_adaptor { private header "__format/container_adaptor.h" }
- module enable_insertable { private header "__format/enable_insertable.h" }
- module escaped_output_table { private header "__format/escaped_output_table.h" }
- module extended_grapheme_cluster_table { private header "__format/extended_grapheme_cluster_table.h" }
- module format_arg { private header "__format/format_arg.h" }
- module format_arg_store { private header "__format/format_arg_store.h" }
- module format_args { private header "__format/format_args.h" }
- module format_context {
- private header "__format/format_context.h"
- export optional
- export locale
- }
- module format_error { private header "__format/format_error.h" }
- module format_functions { private header "__format/format_functions.h" }
- module format_fwd { private header "__format/format_fwd.h" }
- module format_parse_context { private header "__format/format_parse_context.h" }
- module format_string { private header "__format/format_string.h" }
- module format_to_n_result {
- private header "__format/format_to_n_result.h"
- export iterator.__iterator.incrementable_traits
- }
- module formatter { private header "__format/formatter.h" }
- module formatter_bool { private header "__format/formatter_bool.h" }
- module formatter_char { private header "__format/formatter_char.h" }
- module formatter_floating_point { private header "__format/formatter_floating_point.h" }
- module formatter_integer { private header "__format/formatter_integer.h" }
- module formatter_integral { private header "__format/formatter_integral.h" }
- module formatter_output { private header "__format/formatter_output.h" }
- module formatter_pointer { private header "__format/formatter_pointer.h" }
- module formatter_string { private header "__format/formatter_string.h" }
- module formatter_tuple { private header "__format/formatter_tuple.h" }
- module parser_std_format_spec { private header "__format/parser_std_format_spec.h" }
- module range_default_formatter { private header "__format/range_default_formatter.h" }
- module range_formatter { private header "__format/range_formatter.h" }
- module unicode { private header "__format/unicode.h" }
- }
- }
- module forward_list {
- header "forward_list"
- export initializer_list
- export *
- }
- module fstream {
-
-
- header "fstream"
- export *
- }
- module functional {
- header "functional"
- export *
-
- module __functional {
- module binary_function { private header "__functional/binary_function.h" }
- module binary_negate { private header "__functional/binary_negate.h" }
- module bind { private header "__functional/bind.h" }
- module bind_back { private header "__functional/bind_back.h" }
- module bind_front { private header "__functional/bind_front.h" }
- module binder1st { private header "__functional/binder1st.h" }
- module binder2nd { private header "__functional/binder2nd.h" }
- module boyer_moore_searcher { private header "__functional/boyer_moore_searcher.h" }
- module compose { private header "__functional/compose.h" }
- module default_searcher { private header "__functional/default_searcher.h" }
- module function { private header "__functional/function.h" }
- module hash { private header "__functional/hash.h" }
- module hash_fwd { private header "__fwd/hash.h" }
- module identity { private header "__functional/identity.h" }
- module invoke {
- private header "__functional/invoke.h"
- export type_traits
- }
- module is_transparent { private header "__functional/is_transparent.h" }
- module mem_fn { private header "__functional/mem_fn.h" }
- module mem_fun_ref { private header "__functional/mem_fun_ref.h" }
- module not_fn { private header "__functional/not_fn.h" }
- module operations { private header "__functional/operations.h" }
- module perfect_forward { private header "__functional/perfect_forward.h" }
- module pointer_to_binary_function { private header "__functional/pointer_to_binary_function.h" }
- module pointer_to_unary_function { private header "__functional/pointer_to_unary_function.h" }
- module ranges_operations { private header "__functional/ranges_operations.h" }
- module reference_wrapper { private header "__functional/reference_wrapper.h" }
- module unary_function { private header "__functional/unary_function.h" }
- module unary_negate { private header "__functional/unary_negate.h" }
- module unwrap_ref { private header "__functional/unwrap_ref.h" }
- module weak_result_type { private header "__functional/weak_result_type.h" }
- }
- }
- module future {
-
- header "future"
- export *
- }
- module initializer_list {
- header "initializer_list"
- export *
- }
- module iomanip {
-
- header "iomanip"
- export *
- }
- module ios {
-
- header "ios"
- export iosfwd
- export *
-
- module __ios {
- module fpos { private header "__ios/fpos.h" }
- }
- }
- module iosfwd {
- header "iosfwd"
- export *
- }
- module iostream {
-
- header "iostream"
- export ios
- export streambuf
- export istream
- export ostream
- export *
- }
- module istream {
-
- header "istream"
- // FIXME: should re-export ios, streambuf?
- export *
- }
- module iterator {
- header "iterator"
- export *
-
- module __iterator {
- module access { private header "__iterator/access.h" }
- module advance { private header "__iterator/advance.h" }
- module back_insert_iterator { private header "__iterator/back_insert_iterator.h" }
- module bounded_iter { private header "__iterator/bounded_iter.h" }
- module common_iterator { private header "__iterator/common_iterator.h" }
- module concepts { private header "__iterator/concepts.h" }
- module counted_iterator { private header "__iterator/counted_iterator.h" }
- module data { private header "__iterator/data.h" }
- module default_sentinel { private header "__iterator/default_sentinel.h" }
- module distance { private header "__iterator/distance.h" }
- module empty { private header "__iterator/empty.h" }
- module erase_if_container { private header "__iterator/erase_if_container.h" }
- module front_insert_iterator { private header "__iterator/front_insert_iterator.h" }
- module incrementable_traits { private header "__iterator/incrementable_traits.h" }
- module indirectly_comparable { private header "__iterator/indirectly_comparable.h" }
- module insert_iterator { private header "__iterator/insert_iterator.h" }
- module istream_iterator { private header "__iterator/istream_iterator.h" }
- module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" }
- module iter_move { private header "__iterator/iter_move.h" }
- module iter_swap { private header "__iterator/iter_swap.h" }
- module iterator { private header "__iterator/iterator.h" }
- module iterator_traits { private header "__iterator/iterator_traits.h" }
- module iterator_with_data { private header "__iterator/iterator_with_data.h" }
- module mergeable {
- private header "__iterator/mergeable.h"
- export functional.__functional.ranges_operations
- }
- module move_iterator { private header "__iterator/move_iterator.h" }
- module move_sentinel { private header "__iterator/move_sentinel.h" }
- module next { private header "__iterator/next.h" }
- module ostream_iterator { private header "__iterator/ostream_iterator.h" }
- module ostreambuf_iterator {
- private header "__iterator/ostreambuf_iterator.h"
- export iosfwd
- }
- module permutable { private header "__iterator/permutable.h" }
- module prev { private header "__iterator/prev.h" }
- module projected { private header "__iterator/projected.h" }
- module readable_traits { private header "__iterator/readable_traits.h" }
- module reverse_access { private header "__iterator/reverse_access.h" }
- module reverse_iterator { private header "__iterator/reverse_iterator.h" }
- module segmented_iterator { private header "__iterator/segmented_iterator.h" }
- module size { private header "__iterator/size.h" }
- module sortable {
- private header "__iterator/sortable.h"
- export functional.__functional.ranges_operations
- }
- module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" }
- module wrap_iter { private header "__iterator/wrap_iter.h" }
- }
- }
- module latch {
-
- header "latch"
- export *
- }
-
- module __debug_utils {
- module randomize_range { private header "__debug_utils/randomize_range.h" }
- }
-
- module limits {
- header "limits"
- export *
- }
- module list {
- header "list"
- export initializer_list
- export *
- }
- module locale {
-
- header "locale"
- export *
- }
- module map {
- header "map"
- export initializer_list
- export *
- }
- module memory {
- header "memory"
- export *
-
- module __memory {
- module addressof { private header "__memory/addressof.h" }
- module align { private header "__memory/align.h" }
- module allocate_at_least { private header "__memory/allocate_at_least.h" }
- module allocation_guard { private header "__memory/allocation_guard.h" }
- module allocator { private header "__memory/allocator.h" }
- module allocator_arg_t { private header "__memory/allocator_arg_t.h" }
- module allocator_destructor { private header "__memory/allocator_destructor.h" }
- module allocator_traits { private header "__memory/allocator_traits.h" }
- module assume_aligned { private header "__memory/assume_aligned.h" }
- module auto_ptr { private header "__memory/auto_ptr.h" }
- module builtin_new_allocator { private header "__memory/builtin_new_allocator.h" }
- module compressed_pair { private header "__memory/compressed_pair.h" }
- module concepts { private header "__memory/concepts.h" }
- module construct_at { private header "__memory/construct_at.h" }
- module destruct_n { private header "__memory/destruct_n.h" }
- module pointer_traits { private header "__memory/pointer_traits.h" }
- module ranges_construct_at { private header "__memory/ranges_construct_at.h" }
- module ranges_uninitialized_algorithms {
- private header "__memory/ranges_uninitialized_algorithms.h"
- export algorithm.__algorithm.in_out_result
- }
- module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" }
- module shared_ptr { private header "__memory/shared_ptr.h" }
- module swap_allocator { private header "__memory/swap_allocator.h" }
- module temp_value { private header "__memory/temp_value.h" }
- module temporary_buffer { private header "__memory/temporary_buffer.h" }
- module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" }
- module unique_ptr { private header "__memory/unique_ptr.h" }
- module uses_allocator { private header "__memory/uses_allocator.h" }
- module uses_allocator_construction { private header "__memory/uses_allocator_construction.h" }
- module voidify { private header "__memory/voidify.h" }
- }
- }
- module memory_resource {
- header "memory_resource"
- export *
-
- module __memory_resource {
- module memory_resource { private header "__memory_resource/memory_resource.h" }
- module memory_resource_fwd { private header "__fwd/memory_resource.h" }
- module monotonic_buffer_resource { private header "__memory_resource/monotonic_buffer_resource.h" }
- module polymorphic_allocator { private header "__memory_resource/polymorphic_allocator.h" }
- module pool_options { private header "__memory_resource/pool_options.h" }
- module synchronized_pool_resource { private header "__memory_resource/synchronized_pool_resource.h" }
- module unsynchronized_pool_resource { private header "__memory_resource/unsynchronized_pool_resource.h" }
- }
- }
- module mutex {
-
- header "mutex"
- export *
- }
- module new {
- header "new"
- export *
- }
- module numbers {
- header "numbers"
- export *
- }
- module numeric {
- header "numeric"
- export *
-
- module __numeric {
- module accumulate { private header "__numeric/accumulate.h" }
- module adjacent_difference { private header "__numeric/adjacent_difference.h" }
- module exclusive_scan { private header "__numeric/exclusive_scan.h" }
- module gcd_lcm { private header "__numeric/gcd_lcm.h" }
- module inclusive_scan { private header "__numeric/inclusive_scan.h" }
- module inner_product { private header "__numeric/inner_product.h" }
- module iota { private header "__numeric/iota.h" }
- module midpoint { private header "__numeric/midpoint.h" }
- module partial_sum { private header "__numeric/partial_sum.h" }
- module reduce { private header "__numeric/reduce.h" }
- module transform_exclusive_scan { private header "__numeric/transform_exclusive_scan.h" }
- module transform_inclusive_scan { private header "__numeric/transform_inclusive_scan.h" }
- module transform_reduce { private header "__numeric/transform_reduce.h" }
- }
- }
- module optional {
- header "optional"
- export *
- }
- module ostream {
-
- header "ostream"
- // FIXME: should re-export ios, streambuf?
- export *
- }
- module queue {
- header "queue"
- export initializer_list
- export *
- }
- module random {
- header "random"
- export initializer_list
- export *
-
- module __random {
- module bernoulli_distribution { private header "__random/bernoulli_distribution.h" }
- module binomial_distribution { private header "__random/binomial_distribution.h" }
- module cauchy_distribution { private header "__random/cauchy_distribution.h" }
- module chi_squared_distribution { private header "__random/chi_squared_distribution.h" }
- module clamp_to_integral { private header "__random/clamp_to_integral.h" }
- module default_random_engine { private header "__random/default_random_engine.h" }
- module discard_block_engine { private header "__random/discard_block_engine.h" }
- module discrete_distribution {
- private header "__random/discrete_distribution.h"
- export vector
- }
- module exponential_distribution { private header "__random/exponential_distribution.h" }
- module extreme_value_distribution { private header "__random/extreme_value_distribution.h" }
- module fisher_f_distribution { private header "__random/fisher_f_distribution.h" }
- module gamma_distribution { private header "__random/gamma_distribution.h" }
- module generate_canonical { private header "__random/generate_canonical.h" }
- module geometric_distribution { private header "__random/geometric_distribution.h" }
- module independent_bits_engine { private header "__random/independent_bits_engine.h" }
- module is_seed_sequence { private header "__random/is_seed_sequence.h" }
- module is_valid { private header "__random/is_valid.h" }
- module knuth_b { private header "__random/knuth_b.h" }
- module linear_congruential_engine { private header "__random/linear_congruential_engine.h" }
- module log2 { private header "__random/log2.h" }
- module lognormal_distribution { private header "__random/lognormal_distribution.h" }
- module mersenne_twister_engine { private header "__random/mersenne_twister_engine.h" }
- module negative_binomial_distribution { private header "__random/negative_binomial_distribution.h" }
- module normal_distribution { private header "__random/normal_distribution.h" }
- module piecewise_constant_distribution {
- private header "__random/piecewise_constant_distribution.h"
- export vector
- }
- module piecewise_linear_distribution {
- private header "__random/piecewise_linear_distribution.h"
- export vector
- }
- module poisson_distribution { private header "__random/poisson_distribution.h" }
- module random_device { private header "__random/random_device.h" }
- module ranlux { private header "__random/ranlux.h" }
- module seed_seq { private header "__random/seed_seq.h" }
- module shuffle_order_engine { private header "__random/shuffle_order_engine.h" }
- module student_t_distribution { private header "__random/student_t_distribution.h" }
- module subtract_with_carry_engine { private header "__random/subtract_with_carry_engine.h" }
- module uniform_int_distribution { private header "__random/uniform_int_distribution.h" }
- module uniform_random_bit_generator { private header "__random/uniform_random_bit_generator.h" }
- module uniform_real_distribution { private header "__random/uniform_real_distribution.h" }
- module weibull_distribution { private header "__random/weibull_distribution.h" }
- }
- }
- module ranges {
- header "ranges"
- export compare
- export initializer_list
- export iterator
- export *
-
- module __ranges {
- module access { private header "__ranges/access.h" }
- module all {
- private header "__ranges/all.h"
- export functional.__functional.compose
- export functional.__functional.perfect_forward
- }
- module as_rvalue_view { private header "__ranges/as_rvalue_view.h" }
- module common_view { private header "__ranges/common_view.h" }
- module concepts { private header "__ranges/concepts.h" }
- module copyable_box { private header "__ranges/copyable_box.h" }
- module counted {
- private header "__ranges/counted.h"
- export span
- }
- module dangling { private header "__ranges/dangling.h" }
- module data { private header "__ranges/data.h" }
- module drop_view { private header "__ranges/drop_view.h" }
- module drop_while_view { private header "__ranges/drop_while_view.h" }
- module elements_view { private header "__ranges/elements_view.h" }
- module empty { private header "__ranges/empty.h" }
- module empty_view { private header "__ranges/empty_view.h" }
- module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" }
- module enable_view { private header "__ranges/enable_view.h" }
- module filter_view { private header "__ranges/filter_view.h" }
- module iota_view { private header "__ranges/iota_view.h" }
- module istream_view {
-
- private header "__ranges/istream_view.h"
- }
- module join_view { private header "__ranges/join_view.h" }
- module lazy_split_view { private header "__ranges/lazy_split_view.h" }
- module non_propagating_cache { private header "__ranges/non_propagating_cache.h" }
- module owning_view { private header "__ranges/owning_view.h" }
- module range_adaptor { private header "__ranges/range_adaptor.h" }
- module rbegin { private header "__ranges/rbegin.h" }
- module ref_view { private header "__ranges/ref_view.h" }
- module rend { private header "__ranges/rend.h" }
- module reverse_view { private header "__ranges/reverse_view.h" }
- module single_view { private header "__ranges/single_view.h" }
- module size { private header "__ranges/size.h" }
- module split_view { private header "__ranges/split_view.h" }
- module subrange {
- private header "__ranges/subrange.h"
-
- module subrange_fwd { private header "__fwd/subrange.h" }
- }
- module take_view { private header "__ranges/take_view.h" }
- module take_while_view { private header "__ranges/take_while_view.h" }
- module transform_view {
- private header "__ranges/transform_view.h"
- export functional.__functional.bind_back
- export functional.__functional.perfect_forward
- }
- module view_interface { private header "__ranges/view_interface.h" }
- module views { private header "__ranges/views.h" }
- module zip_view { private header "__ranges/zip_view.h" }
- }
- }
- module ratio {
- header "ratio"
- export *
- }
- module regex {
-
- header "regex"
- export initializer_list
- export *
- }
- module scoped_allocator {
- header "scoped_allocator"
- export *
- }
- module semaphore {
-
- header "semaphore"
- export *
- }
- module set {
- header "set"
- export initializer_list
- export *
- }
- module shared_mutex {
-
- header "shared_mutex"
- export version
- }
- module source_location {
- header "source_location"
- export *
- }
- module span {
- header "span"
- export ranges.__ranges.enable_borrowed_range
- export version
- module span_fwd { private header "__fwd/span.h" }
- }
- module sstream {
-
- header "sstream"
- // FIXME: should re-export istream, ostream, ios, streambuf, string?
- export *
- }
- module stack {
- header "stack"
- export initializer_list
- export *
- }
- module stdexcept {
- header "stdexcept"
- export *
- }
- module streambuf {
-
- header "streambuf"
- export *
- }
- module string {
- header "string"
- export initializer_list
- export string_view
- module __string {
- module char_traits { private header "__string/char_traits.h" }
- module extern_template_lists { private header "__string/extern_template_lists.h" }
- module string_fwd { private header "__fwd/string.h" }
- }
- export *
- }
- module string_view {
- header "string_view"
- export initializer_list
- export *
- module string_view_fwd { private header "__fwd/string_view.h" }
- }
- module strstream {
-
- header "strstream"
- export *
- }
- module system_error {
- header "system_error"
- export *
- }
- module thread {
-
- header "thread"
- export *
-
- module __thread {
- module poll_with_backoff { private header "__thread/poll_with_backoff.h" }
- module timed_backoff_policy { private header "__thread/timed_backoff_policy.h" }
- }
- }
- module tuple {
- header "tuple"
- export *
-
- module apply_cv { private header "__tuple_dir/apply_cv.h" }
- module get_fwd { private header "__fwd/get.h" }
- module make_tuple_types { private header "__tuple_dir/make_tuple_types.h" }
- module pair_like { private header "__tuple_dir/pair_like.h" }
- module sfinae_helpers { private header "__tuple_dir/sfinae_helpers.h" }
- module tuple_element { private header "__tuple_dir/tuple_element.h" }
- module tuple_fwd { private header "__fwd/tuple.h" }
- module tuple_indices { private header "__tuple_dir/tuple_indices.h" }
- module tuple_like { private header "__tuple_dir/tuple_like.h" }
- module tuple_like_ext { private header "__tuple_dir/tuple_like_ext.h" }
- module tuple_size { private header "__tuple_dir/tuple_size.h" }
- module tuple_types { private header "__tuple_dir/tuple_types.h" }
- }
- module type_traits {
- header "type_traits"
- export functional.__functional.unwrap_ref
- export *
-
- module add_const { private header "__type_traits/add_const.h" }
- module add_cv { private header "__type_traits/add_cv.h" }
- module add_lvalue_reference { private header "__type_traits/add_lvalue_reference.h" }
- module add_pointer { private header "__type_traits/add_pointer.h" }
- module add_rvalue_reference { private header "__type_traits/add_rvalue_reference.h" }
- module add_volatile { private header "__type_traits/add_volatile.h" }
- module aligned_storage { private header "__type_traits/aligned_storage.h" }
- module aligned_union { private header "__type_traits/aligned_union.h" }
- module alignment_of { private header "__type_traits/alignment_of.h" }
- module apply_cv { private header "__type_traits/apply_cv.h" }
- module can_extract_key { private header "__type_traits/can_extract_key.h" }
- module common_reference { private header "__type_traits/common_reference.h" }
- module common_type { private header "__type_traits/common_type.h" }
- module conditional { private header "__type_traits/conditional.h" }
- module conjunction { private header "__type_traits/conjunction.h" }
- module copy_cv { private header "__type_traits/copy_cv.h" }
- module copy_cvref { private header "__type_traits/copy_cvref.h" }
- module decay { private header "__type_traits/decay.h" }
- module dependent_type { private header "__type_traits/dependent_type.h" }
- module disjunction { private header "__type_traits/disjunction.h" }
- module enable_if { private header "__type_traits/enable_if.h" }
- module extent { private header "__type_traits/extent.h" }
- module has_unique_object_representation { private header "__type_traits/has_unique_object_representation.h" }
- module has_virtual_destructor { private header "__type_traits/has_virtual_destructor.h" }
- module integral_constant { private header "__type_traits/integral_constant.h" }
- module is_abstract { private header "__type_traits/is_abstract.h" }
- module is_aggregate { private header "__type_traits/is_aggregate.h" }
- module is_allocator { private header "__type_traits/is_allocator.h" }
- module is_always_bitcastable { private header "__type_traits/is_always_bitcastable.h" }
- module is_arithmetic {
- private header "__type_traits/is_arithmetic.h"
- export integral_constant
- }
- module is_array {
- private header "__type_traits/is_array.h"
- export integral_constant
- }
- module is_assignable { private header "__type_traits/is_assignable.h" }
- module is_base_of { private header "__type_traits/is_base_of.h" }
- module is_bounded_array { private header "__type_traits/is_bounded_array.h" }
- module is_callable { private header "__type_traits/is_callable.h" }
- module is_char_like_type { private header "__type_traits/is_char_like_type.h" }
- module is_class { private header "__type_traits/is_class.h" }
- module is_compound { private header "__type_traits/is_compound.h" }
- module is_const { private header "__type_traits/is_const.h" }
- module is_constant_evaluated { private header "__type_traits/is_constant_evaluated.h" }
- module is_constructible { private header "__type_traits/is_constructible.h" }
- module is_convertible { private header "__type_traits/is_convertible.h" }
- module is_copy_assignable { private header "__type_traits/is_copy_assignable.h" }
- module is_copy_constructible { private header "__type_traits/is_copy_constructible.h" }
- module is_core_convertible {
- private header "__type_traits/is_core_convertible.h"
- export integral_constant
- }
- module is_default_constructible { private header "__type_traits/is_default_constructible.h" }
- module is_destructible { private header "__type_traits/is_destructible.h" }
- module is_empty { private header "__type_traits/is_empty.h" }
- module is_enum { private header "__type_traits/is_enum.h" }
- module is_final { private header "__type_traits/is_final.h" }
- module is_floating_point { private header "__type_traits/is_floating_point.h" }
- module is_function { private header "__type_traits/is_function.h" }
- module is_fundamental { private header "__type_traits/is_fundamental.h" }
- module is_implicitly_default_constructible { private header "__type_traits/is_implicitly_default_constructible.h" }
- module is_integral { private header "__type_traits/is_integral.h" }
- module is_literal_type { private header "__type_traits/is_literal_type.h" }
- module is_member_function_pointer { private header "__type_traits/is_member_function_pointer.h" }
- module is_member_object_pointer { private header "__type_traits/is_member_object_pointer.h" }
- module is_member_pointer { private header "__type_traits/is_member_pointer.h" }
- module is_move_assignable { private header "__type_traits/is_move_assignable.h" }
- module is_move_constructible { private header "__type_traits/is_move_constructible.h" }
- module is_nothrow_assignable { private header "__type_traits/is_nothrow_assignable.h" }
- module is_nothrow_constructible { private header "__type_traits/is_nothrow_constructible.h" }
- module is_nothrow_convertible { private header "__type_traits/is_nothrow_convertible.h" }
- module is_nothrow_copy_assignable { private header "__type_traits/is_nothrow_copy_assignable.h" }
- module is_nothrow_copy_constructible { private header "__type_traits/is_nothrow_copy_constructible.h" }
- module is_nothrow_default_constructible { private header "__type_traits/is_nothrow_default_constructible.h" }
- module is_nothrow_destructible { private header "__type_traits/is_nothrow_destructible.h" }
- module is_nothrow_move_assignable { private header "__type_traits/is_nothrow_move_assignable.h" }
- module is_nothrow_move_constructible { private header "__type_traits/is_nothrow_move_constructible.h" }
- module is_null_pointer { private header "__type_traits/is_null_pointer.h" }
- module is_object { private header "__type_traits/is_object.h" }
- module is_pod { private header "__type_traits/is_pod.h" }
- module is_pointer { private header "__type_traits/is_pointer.h" }
- module is_polymorphic { private header "__type_traits/is_polymorphic.h" }
- module is_primary_template { private header "__type_traits/is_primary_template.h" }
- module is_reference { private header "__type_traits/is_reference.h" }
- module is_reference_wrapper { private header "__type_traits/is_reference_wrapper.h" }
- module is_referenceable { private header "__type_traits/is_referenceable.h" }
- module is_same {
- private header "__type_traits/is_same.h"
- export type_traits.integral_constant
- }
- module is_scalar { private header "__type_traits/is_scalar.h" }
- module is_scoped_enum { private header "__type_traits/is_scoped_enum.h" }
- module is_signed { private header "__type_traits/is_signed.h" }
- module is_signed_integer { private header "__type_traits/is_signed_integer.h" }
- module is_specialization { private header "__type_traits/is_specialization.h" }
- module is_standard_layout { private header "__type_traits/is_standard_layout.h" }
- module is_swappable { private header "__type_traits/is_swappable.h" }
- module is_trivial { private header "__type_traits/is_trivial.h" }
- module is_trivially_assignable { private header "__type_traits/is_trivially_assignable.h" }
- module is_trivially_constructible { private header "__type_traits/is_trivially_constructible.h" }
- module is_trivially_copy_assignable { private header "__type_traits/is_trivially_copy_assignable.h" }
- module is_trivially_copy_constructible { private header "__type_traits/is_trivially_copy_constructible.h" }
- module is_trivially_copyable { private header "__type_traits/is_trivially_copyable.h" }
- module is_trivially_default_constructible { private header "__type_traits/is_trivially_default_constructible.h" }
- module is_trivially_destructible { private header "__type_traits/is_trivially_destructible.h" }
- module is_trivially_move_assignable { private header "__type_traits/is_trivially_move_assignable.h" }
- module is_trivially_move_constructible { private header "__type_traits/is_trivially_move_constructible.h" }
- module is_unbounded_array { private header "__type_traits/is_unbounded_array.h" }
- module is_union { private header "__type_traits/is_union.h" }
- module is_unsigned { private header "__type_traits/is_unsigned.h" }
- module is_unsigned_integer { private header "__type_traits/is_unsigned_integer.h" }
- module is_valid_expansion { private header "__type_traits/is_valid_expansion.h" }
- module is_void {
- private header "__type_traits/is_void.h"
- export integral_constant
- }
- module is_volatile { private header "__type_traits/is_volatile.h" }
- module lazy { private header "__type_traits/lazy.h" }
- module make_32_64_or_128_bit { private header "__type_traits/make_32_64_or_128_bit.h" }
- module make_const_lvalue_ref { private header "__type_traits/make_const_lvalue_ref.h" }
- module make_signed { private header "__type_traits/make_signed.h" }
- module make_unsigned { private header "__type_traits/make_unsigned.h" }
- module maybe_const { private header "__type_traits/maybe_const.h" }
- module nat { private header "__type_traits/nat.h" }
- module negation { private header "__type_traits/negation.h" }
- module noexcept_move_assign_container { private header "__type_traits/noexcept_move_assign_container.h" }
- module promote { private header "__type_traits/promote.h" }
- module rank { private header "__type_traits/rank.h" }
- module remove_all_extents { private header "__type_traits/remove_all_extents.h" }
- module remove_const { private header "__type_traits/remove_const.h" }
- module remove_const_ref { private header "__type_traits/remove_const_ref.h" }
- module remove_cv { private header "__type_traits/remove_cv.h" }
- module remove_cvref { private header "__type_traits/remove_cvref.h" }
- module remove_extent { private header "__type_traits/remove_extent.h" }
- module remove_pointer { private header "__type_traits/remove_pointer.h" }
- module remove_reference { private header "__type_traits/remove_reference.h" }
- module remove_volatile { private header "__type_traits/remove_volatile.h" }
- module result_of { private header "__type_traits/result_of.h" }
- module strip_signature { private header "__type_traits/strip_signature.h" }
- module type_identity { private header "__type_traits/type_identity.h" }
- module type_list { private header "__type_traits/type_list.h" }
- module underlying_type { private header "__type_traits/underlying_type.h" }
- module void_t { private header "__type_traits/void_t.h" }
- }
- module typeindex {
- header "typeindex"
- export *
- }
- module typeinfo {
- header "typeinfo"
- export *
- }
- module unordered_map {
- header "unordered_map"
- export initializer_list
- export *
- }
- module unordered_set {
- header "unordered_set"
- export initializer_list
- export *
- }
- module utility {
- header "utility"
- export initializer_list
- export *
-
- module __utility {
- module as_const { private header "__utility/as_const.h" }
- module auto_cast { private header "__utility/auto_cast.h" }
- module cmp { private header "__utility/cmp.h" }
- module convert_to_integral { private header "__utility/convert_to_integral.h" }
- module declval { private header "__utility/declval.h" }
- module exception_guard { private header "__utility/exception_guard.h" }
- module exchange { private header "__utility/exchange.h" }
- module forward { private header "__utility/forward.h" }
- module forward_like { private header "__utility/forward_like.h" }
- module in_place { private header "__utility/in_place.h" }
- module integer_sequence { private header "__utility/integer_sequence.h" }
- module move { private header "__utility/move.h" }
- module pair { private header "__utility/pair.h" }
- module pair_fwd { private header "__fwd/pair.h" }
- module piecewise_construct { private header "__utility/piecewise_construct.h" }
- module priority_tag { private header "__utility/priority_tag.h" }
- module rel_ops { private header "__utility/rel_ops.h" }
- module swap { private header "__utility/swap.h" }
- module to_underlying { private header "__utility/to_underlying.h" }
- module unreachable { private header "__utility/unreachable.h" }
- }
- }
- module valarray {
- header "valarray"
- export initializer_list
- export *
- }
- module variant {
- header "variant"
- export *
-
- module __variant {
- module monostate { private header "__variant/monostate.h" }
- }
- }
- module vector {
- header "vector"
- export initializer_list
- export *
- }
- module version {
- header "version"
- export *
- }
-
- // FIXME: These should be private.
- module __assert { header "__assert" export * }
- module __availability { private header "__availability" export * }
- module __bit_reference { private header "__bit_reference" export * }
- module __debug { header "__debug" export * }
- module __errc { private header "__errc" export * }
- module __hash_table { header "__hash_table" export * }
- module __locale {
-
- private header "__locale" export *
- }
- module __mbstate_t { private header "__mbstate_t.h" export * }
- module __mutex_base { private header "__mutex_base" export * }
- module __node_handle { private header "__node_handle" export * }
- module __split_buffer { private header "__split_buffer" export * }
- module __std_stream {
-
- private header "__std_stream" export *
- }
- module __threading_support { header "__threading_support" export * }
- module __tree { header "__tree" export * }
- module __undef_macros { header "__undef_macros" export * }
- module __verbose_abort { header "__verbose_abort" export * }
-
- module experimental {
- requires cplusplus11
-
- module algorithm {
- header "experimental/algorithm"
- export *
- }
- module coroutine {
- requires coroutines
- header "experimental/coroutine"
- export *
- }
- module deque {
- header "experimental/deque"
- export *
- }
- module forward_list {
- header "experimental/forward_list"
- export *
- }
- module functional {
- header "experimental/functional"
- export *
- }
- module iterator {
- header "experimental/iterator"
- export *
- }
- module list {
- header "experimental/list"
- export *
- }
- module map {
- header "experimental/map"
- export *
- }
- module memory_resource {
- header "experimental/memory_resource"
- export *
- }
- module propagate_const {
- header "experimental/propagate_const"
- export *
- }
- module regex {
-
- header "experimental/regex"
- export *
- }
- module simd {
- header "experimental/simd"
- export *
- }
- module set {
- header "experimental/set"
- export *
- }
- module span {
- header "span"
- export *
- }
- module string {
- header "experimental/string"
- export *
- }
- module type_traits {
- header "experimental/type_traits"
- export *
- }
- module unordered_map {
- header "experimental/unordered_map"
- export *
- }
- module unordered_set {
- header "experimental/unordered_set"
- export *
- }
- module utility {
- header "experimental/utility"
- export *
- }
- module vector {
- header "experimental/vector"
- export *
- }
- // FIXME these should be private
- module __memory {
- header "experimental/__memory"
- export *
- }
- } // end experimental
-}
diff --git a/lib/libc++experimental/Makefile b/lib/libc++experimental/Makefile
index 77adb5c82bae..02551645ca74 100644
--- a/lib/libc++experimental/Makefile
+++ b/lib/libc++experimental/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= clibs
@@ -6,12 +5,10 @@ SRCDIR= ${SRCTOP}/contrib/llvm-project/libcxx
LIB= c++experimental
NO_PIC=
-MK_PROFILE= no
.PATH: ${SRCDIR}/src
-SRCS+= experimental/memory_resource.cpp
-SRCS+= format.cpp
+SRCS+= experimental/keep.cpp
WARNS?= 0
CXXFLAGS+= ${PICFLAG}
diff --git a/lib/libc++experimental/Makefile.depend b/lib/libc++experimental/Makefile.depend
index ecc8fe860f5e..11aba52f82cf 100644
--- a/lib/libc++experimental/Makefile.depend
+++ b/lib/libc++experimental/Makefile.depend
@@ -1,9 +1,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- include \
- include/xlocale \
- lib/msun \
.include <dirdeps.mk>
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index a26215324332..d0c254e33396 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -1,22 +1,25 @@
-# @(#)Makefile 8.2 (Berkeley) 2/3/94
-
PACKAGE= clibs
SHLIBDIR?= /lib
.include <src.opts.mk>
LIBC_SRCTOP?= ${.CURDIR}
-
-# Pick the current architecture directory for libc. In general, this is
-# named MACHINE_CPUARCH, but some ABIs are different enough to require
-# their own libc, so allow a directory named MACHINE_ARCH to override this.
-
-.if exists(${LIBC_SRCTOP}/${MACHINE_ARCH:S/powerpc64le/powerpc64/})
-LIBC_ARCH=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
+LIBSYS_SRCTOP?= ${.CURDIR:H}/libsys
+
+# Pick the current architecture directory for libc. In general, this is named
+# MACHINE_CPUARCH, but some ABIs are different enough to require their own libc,
+# so allow a directory named MACHINE_ARCH to override this (though treat
+# powerpc64le and powerpc64 the same).
+# Note: This is copied to msun/Makefile
+M=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
+.if exists(${LIBC_SRCTOP}/${M})
+LIBC_ARCH=${M}
.else
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
+CFLAGS+=-D_FORTIFY_SOURCE_read=_read
+
# All library objects contain FreeBSD revision strings by default; they may be
# excluded as a space-saving measure. To produce a library that does
# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
@@ -37,6 +40,7 @@ SHLIB_LDSCRIPT_LINKS=libxnet.so
WARNS?= 2
CFLAGS+=-I${LIBC_SRCTOP}/include -I${SRCTOP}/include
CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
+CFLAGS+=-I${LIBSYS_SRCTOP}/${LIBC_ARCH}
.if ${MK_NLS} != "no"
CFLAGS+=-DNLS
.endif
@@ -52,17 +56,21 @@ CFLAGS+=${CANCELPOINTS_CFLAGS}
# Use a more efficient TLS model for libc since we can reasonably assume that
# it will be loaded during program startup.
-.if ${LIBC_ARCH} == "aarch64" || ${LIBC_ARCH} == "amd64" || \
- ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "riscv" || \
- ${LIBC_ARCH:Mpowerpc*} != ""
CFLAGS+= -ftls-model=initial-exec
-.endif
#
# Link with static libcompiler_rt.a.
#
LDFLAGS+= -nodefaultlibs
LIBADD+= compiler_rt
+LIBADD+= sys
+.if defined(COMPAT_libcompat)
+# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
+# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
+LDFLAGS+= -Wl,--rpath=/usr/lib${COMPAT_libcompat}
+.endif
+
+LDFLAGS+=-Wl,--auxiliary,libsys.so.7
.if ${MK_SSP} != "no" && \
(${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
@@ -124,7 +132,6 @@ NOASM=
.include "${LIBC_SRCTOP}/softfloat/Makefile.inc"
.endif
.if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64"
-.include "${LIBC_SRCTOP}/x86/sys/Makefile.inc"
.include "${LIBC_SRCTOP}/x86/gen/Makefile.inc"
.endif
.if ${MK_NIS} != "no"
@@ -149,7 +156,6 @@ STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
VERSION_DEF=${LIBC_SRCTOP}/Versions.def
SYMBOL_MAPS=${SYM_MAPS}
-CFLAGS+= -DSYMBOL_VERSIONING
# If there are no machine dependent sources, append all the
# machine-independent sources:
@@ -214,6 +220,6 @@ GENDIRDEPS_FILTER+= N${RELDIR:H}/msun
# Disable warnings in contributed sources.
CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
# Disable stack protection for SSP symbols.
-SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
+SSP_CFLAGS:= ${.IMPSRC:N*/libc_stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
# Generate stack unwinding tables for cancellation points
CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
diff --git a/lib/libc/Makefile.depend b/lib/libc/Makefile.depend
index 7f0811b3ca91..d2cb630c1bc2 100644
--- a/lib/libc/Makefile.depend
+++ b/lib/libc/Makefile.depend
@@ -6,6 +6,7 @@ DIRDEPS = \
include/rpcsvc \
lib/${CSU_DIR} \
lib/libcompiler_rt \
+ lib/libsys \
usr.bin/yacc.host \
diff --git a/lib/libc/Versions.def b/lib/libc/Versions.def
index a605378654a4..184e107d225a 100644
--- a/lib/libc/Versions.def
+++ b/lib/libc/Versions.def
@@ -38,6 +38,10 @@ FBSD_1.6 {
FBSD_1.7 {
} FBSD_1.6;
+# This version was first added to 15.0-current.
+FBSD_1.8 {
+} FBSD_1.7;
+
# This is our private namespace. Any global interfaces that are
# strictly for use only by other FreeBSD applications and libraries
# are listed here. We use a separate namespace so we can write
@@ -45,4 +49,4 @@ FBSD_1.7 {
#
# Please do NOT increment the version of this namespace.
FBSDprivate_1.0 {
-} FBSD_1.7;
+} FBSD_1.8;
diff --git a/lib/libc/aarch64/SYS.h b/lib/libc/aarch64/SYS.h
deleted file mode 100644
index 059ecd469650..000000000000
--- a/lib/libc/aarch64/SYS.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * Copyright (c) 2014 Andrew Turner
- * Copyright (c) 2015 The FreeBSD Foundation
- *
- * This software was developed by Andrew Turner under
- * sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/syscall.h>
-#include <machine/asm.h>
-
-#define _SYSCALL(name) \
- mov x8, SYS_ ## name; \
- svc 0
-
-#define SYSCALL(name) \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- ret; \
-END(__sys_##name)
-
-/*
- * Conditional jumps can only go up to one megabyte in either
- * direction, and cerror can be located anywhere, so we have
- * to jump around to use more capable unconditional branch
- * instruction.
- */
-#define PSEUDO(name) \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- b.cs 1f; \
- ret; \
-1: b cerror; \
-END(__sys_##name)
-
-#define RSYSCALL(name) \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- b.cs 1f; \
- ret; \
-1: b cerror; \
-END(__sys_##name)
diff --git a/lib/libc/aarch64/Symbol.map b/lib/libc/aarch64/Symbol.map
index 7f5b9ee9b56c..cb4669039942 100644
--- a/lib/libc/aarch64/Symbol.map
+++ b/lib/libc/aarch64/Symbol.map
@@ -1,36 +1,11 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
.mcount;
- _setjmp;
- _longjmp;
- fabs;
__flt_rounds;
fpgetmask;
fpsetmask;
- __infinity;
- __nan;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- vfork;
- makecontext;
-};
-
-FBSDprivate_1.0 {
- __makecontext;
};
diff --git a/lib/libc/aarch64/gen/Makefile.inc b/lib/libc/aarch64/gen/Makefile.inc
index 5e4fccf143e4..1efdb0e9f8be 100644
--- a/lib/libc/aarch64/gen/Makefile.inc
+++ b/lib/libc/aarch64/gen/Makefile.inc
@@ -1,4 +1,3 @@
-
CFLAGS+= -DNO_COMPAT7
SRCS+= _ctx_start.S \
@@ -6,10 +5,10 @@ SRCS+= _ctx_start.S \
flt_rounds.c \
fpgetmask.c \
fpsetmask.c \
+ getcontextx.c \
infinity.c \
ldexp.c \
makecontext.c \
_setjmp.S \
setjmp.S \
- sigsetjmp.S \
- trivial-getcontextx.c
+ sigsetjmp.S
diff --git a/lib/libc/aarch64/gen/_ctx_start.S b/lib/libc/aarch64/gen/_ctx_start.S
index 15edcf21d463..a4049e6c241a 100644
--- a/lib/libc/aarch64/gen/_ctx_start.S
+++ b/lib/libc/aarch64/gen/_ctx_start.S
@@ -27,9 +27,13 @@
*/
#include <machine/asm.h>
+#include <sys/elf_common.h>
+
ENTRY(_ctx_start)
blr x19 /* Call func from makecontext */
mov x0, x20 /* Load ucp saved in makecontext */
bl _C_LABEL(ctx_done)
bl _C_LABEL(abort)
END(_ctx_start)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/aarch64/gen/_setjmp.S b/lib/libc/aarch64/gen/_setjmp.S
index 4fc9ce304893..037eccf1a48a 100644
--- a/lib/libc/aarch64/gen/_setjmp.S
+++ b/lib/libc/aarch64/gen/_setjmp.S
@@ -30,6 +30,7 @@
#include <machine/asm.h>
#include <machine/setjmp.h>
+#include <sys/elf_common.h>
ENTRY(_setjmp)
/* Store the magic value and stack pointer */
@@ -101,3 +102,5 @@ botch:
bl _C_LABEL(abort)
#endif
END(_longjmp)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/aarch64/gen/fabs.S b/lib/libc/aarch64/gen/fabs.S
index 29e4b89d5ee1..91967a10299b 100644
--- a/lib/libc/aarch64/gen/fabs.S
+++ b/lib/libc/aarch64/gen/fabs.S
@@ -24,7 +24,11 @@
*/
#include <machine/asm.h>
+#include <sys/elf_common.h>
+
ENTRY(fabs)
fabs d0, d0
ret
END(fabs)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/aarch64/gen/flt_rounds.c b/lib/libc/aarch64/gen/flt_rounds.c
index 7d5259a1a3bc..b62536aafaf8 100644
--- a/lib/libc/aarch64/gen/flt_rounds.c
+++ b/lib/libc/aarch64/gen/flt_rounds.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <fenv.h>
diff --git a/lib/libc/aarch64/gen/fpgetmask.c b/lib/libc/aarch64/gen/fpgetmask.c
index 7bc56a9d75be..b6f398d202f5 100644
--- a/lib/libc/aarch64/gen/fpgetmask.c
+++ b/lib/libc/aarch64/gen/fpgetmask.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/aarch64/gen/fpsetmask.c b/lib/libc/aarch64/gen/fpsetmask.c
index 1ad3f49d603d..4bc72913a8b9 100644
--- a/lib/libc/aarch64/gen/fpsetmask.c
+++ b/lib/libc/aarch64/gen/fpsetmask.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/aarch64/gen/getcontextx.c b/lib/libc/aarch64/gen/getcontextx.c
new file mode 100644
index 000000000000..9972d3208d08
--- /dev/null
+++ b/lib/libc/aarch64/gen/getcontextx.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+ size_t size;
+
+ size = sizeof(ucontext_t);
+ size += sizeof(struct arm64_reg_context); /* Space for ARM64_CTX_END */
+
+ return (size);
+}
+
+int
+__fillcontextx2(char *ctx)
+{
+ struct arm64_reg_context *reg_ctx;
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ ucp->uc_mcontext.mc_ptr = (uint64_t)(ucp + 1);
+
+ reg_ctx = (struct arm64_reg_context *)ucp->uc_mcontext.mc_ptr;
+ reg_ctx->ctx_id = ARM64_CTX_END;
+ reg_ctx->ctx_size = sizeof(struct arm64_reg_context);
+
+ return (0);
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ if (getcontext(ucp) == -1)
+ return (-1);
+ __fillcontextx2(ctx);
+ return (0);
+}
+
+__weak_reference(__getcontextx, getcontextx);
+
+ucontext_t *
+__getcontextx(void)
+{
+ char *ctx;
+ int error;
+
+ ctx = malloc(__getcontextx_size());
+ if (ctx == NULL)
+ return (NULL);
+ if (__fillcontextx(ctx) == -1) {
+ error = errno;
+ free(ctx);
+ errno = error;
+ return (NULL);
+ }
+ return ((ucontext_t *)ctx);
+}
diff --git a/lib/libc/aarch64/gen/infinity.c b/lib/libc/aarch64/gen/infinity.c
index fca66838fa63..b7688798765f 100644
--- a/lib/libc/aarch64/gen/infinity.c
+++ b/lib/libc/aarch64/gen/infinity.c
@@ -2,7 +2,6 @@
* infinity.c
*/
-#include <sys/cdefs.h>
#include <math.h>
/* bytes for +Infinity on aarch64 */
diff --git a/lib/libc/aarch64/gen/makecontext.c b/lib/libc/aarch64/gen/makecontext.c
index ae23ad87d3a2..8c9b4edd7a15 100644
--- a/lib/libc/aarch64/gen/makecontext.c
+++ b/lib/libc/aarch64/gen/makecontext.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <machine/armreg.h>
@@ -40,16 +39,16 @@ void _ctx_start(void);
void
ctx_done(ucontext_t *ucp)
-{
-
+{
+
if (ucp->uc_link == NULL) {
exit(0);
- } else {
+ } else {
setcontext((const ucontext_t *)ucp->uc_link);
abort();
- }
+ }
}
-
+
__weak_reference(__makecontext, makecontext);
void
diff --git a/lib/libc/aarch64/gen/setjmp.S b/lib/libc/aarch64/gen/setjmp.S
index ecc677de2620..97d98ae2fb52 100644
--- a/lib/libc/aarch64/gen/setjmp.S
+++ b/lib/libc/aarch64/gen/setjmp.S
@@ -30,6 +30,7 @@
#include <machine/asm.h>
#include <machine/setjmp.h>
+#include <sys/elf_common.h>
ENTRY(setjmp)
sub sp, sp, #16
@@ -119,3 +120,5 @@ botch:
bl _C_LABEL(longjmperror)
bl _C_LABEL(abort)
END(longjmp)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/aarch64/gen/sigsetjmp.S b/lib/libc/aarch64/gen/sigsetjmp.S
index cdff7a46c85b..daf3914b6278 100644
--- a/lib/libc/aarch64/gen/sigsetjmp.S
+++ b/lib/libc/aarch64/gen/sigsetjmp.S
@@ -28,6 +28,7 @@
#include <machine/asm.h>
#include <machine/setjmp.h>
+#include <sys/elf_common.h>
ENTRY(sigsetjmp)
cmp x1, #0
@@ -52,3 +53,5 @@ ENTRY(siglongjmp)
.Lmagic:
.quad _JB_MAGIC__SETJMP
END(siglongjmp)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/aarch64/static_tls.h b/lib/libc/aarch64/static_tls.h
deleted file mode 100644
index 2bb717eb75ce..000000000000
--- a/lib/libc/aarch64/static_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_AARCH64_STATIC_TLS_H
-#define _LIBC_AARCH64_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("mrs %x0, tpidr_el0" : "=r" (tlsbase));
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc
index cabc79e4f351..35523fb954be 100644
--- a/lib/libc/aarch64/string/Makefile.inc
+++ b/lib/libc/aarch64/string/Makefile.inc
@@ -4,7 +4,6 @@
#
AARCH64_STRING_FUNCS= \
- memchr \
memcmp \
memcpy \
memmove \
@@ -13,13 +12,30 @@ AARCH64_STRING_FUNCS= \
stpcpy \
strchr \
strchrnul \
- strcmp \
strcpy \
- strlen \
- strncmp \
strnlen \
strrchr
+# SIMD-enhanced routines not derived from Arm's code
+MDSRCS+= \
+ memchr.S \
+ strcmp.S \
+ strspn.S \
+ strcspn.S \
+ strpbrk.c \
+ strsep.c \
+ strcat.c \
+ strlcpy.S \
+ strncmp.S \
+ memccpy.S \
+ strncat.c \
+ strlcat.c \
+ strlen.S \
+ timingsafe_bcmp.S \
+ timingsafe_memcmp.S \
+ bcopy.c \
+ bzero.c
+
#
# Add the above functions. Generate an asm file that includes the needed
# Arm Optimized Routines file defining the function name to the libc name.
@@ -38,3 +54,7 @@ CLEANFILES+= ${FUNC}.S
MDSRCS+= ${FUNC}.S
CFLAGS.${FUNC}.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
.endfor
+
+# memchr.S is a wrapper in the src tree for the implementation from
+# arm-optimized-routines
+CFLAGS.memchr.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
diff --git a/lib/libc/aarch64/string/bcopy.c b/lib/libc/aarch64/string/bcopy.c
new file mode 100644
index 000000000000..0dee529fb9df
--- /dev/null
+++ b/lib/libc/aarch64/string/bcopy.c
@@ -0,0 +1,14 @@
+/*-
+ * Public domain.
+ */
+
+#include <string.h>
+
+#undef bcopy /* _FORTIFY_SOURCE */
+
+void
+bcopy(const void *src, void *dst, size_t len)
+{
+
+ memmove(dst, src, len);
+}
diff --git a/lib/libc/aarch64/string/bzero.c b/lib/libc/aarch64/string/bzero.c
new file mode 100644
index 000000000000..d82f3061865b
--- /dev/null
+++ b/lib/libc/aarch64/string/bzero.c
@@ -0,0 +1,14 @@
+/*-
+ * Public domain.
+ */
+
+#include <string.h>
+
+#undef bzero /* _FORTIFY_SOURCE */
+
+void
+bzero(void *b, size_t len)
+{
+
+ memset(b, 0, len);
+}
diff --git a/lib/libc/aarch64/string/memccpy.S b/lib/libc/aarch64/string/memccpy.S
new file mode 100644
index 000000000000..7d9fdb14b84b
--- /dev/null
+++ b/lib/libc/aarch64/string/memccpy.S
@@ -0,0 +1,271 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+
+ .weak memccpy
+ .set memccpy, __memccpy
+ .text
+
+ENTRY(__memccpy)
+ subs x3, x3, #1
+ b.lo .L0
+
+ dup v0.16b, w2
+
+ mov x9, x0 // stash copy of src pointer
+ bic x10, x1, #0xf // src aligned
+ and x11, x1, #0xf // src offset
+
+ ldr q1, [x10]
+ cmeq v1.16b, v1.16b, v0.16b // bytewise compare against src char
+
+ mov x8, #-1 // prepare a 0xfff..fff register
+ mov x6, #0xf
+
+ lsl x12, x11, #2
+ lsl x8, x8, x12 // mask of bytes in the string
+
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ sub x12, x11, #32
+ adds x12, x12, x3 // distance from alignment boundary - 32
+ b.cc .Lrunt // branch if buffer length is 32 or less
+
+ ands x8, x8, x5
+ b.eq 0f
+
+ /* match in first chunk */
+ rbit x8, x8
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ sub x8, x8, x11 // ... from beginning of the string
+
+ add x0, x0, x8
+ add x4, x9, x8 // dst + cnt
+ add x5, x1, x8 // src + cnt
+ add x0, x0, #1
+
+ b .L0816
+
+0:
+ ldr q3, [x10, #16] // load second string chunk
+ ldr q2, [x1] // load true head
+ cmeq v1.16b, v3.16b, v0.16b // char found in second chunk?
+
+ /* process second chunk */
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ cbz x5, 0f
+
+ /* match in second chunk */
+ rbit x8, x5
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ sub x11, x11, #16
+ sub x8, x8, x11 // adjust for alignment offset
+ add x0, x0, x8 // return value
+ add x0, x0, #1
+
+ add x4, x9, x8
+ add x5, x1, x8
+ b .L1732
+
+0:
+ /* string didn't end in second chunk and neither did buffer */
+ ldr q1, [x10, #32] // load next string chunk
+ str q2, [x0] // deposit head into buffer
+ sub x0, x0, x11 // adjust x0
+ mov x3, x12
+ str q3, [x0, #16] // deposit second chunk
+
+ add x10, x10, #32 // advance src
+ add x0, x0, #32 // advance dst
+ subs x3, x3, #16 // enough left for another round?
+ b.lo 1f
+
+ /* main loop unrolled twice */
+ .p2align 4
+0:
+ cmeq v2.16b, v1.16b, v0.16b // char found in second chunk?
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+
+ cbnz x5, 3f
+
+ str q1, [x0]
+ ldr q1, [x10, #16] // load next chunk
+
+ cmp x3, #16 // more than a full chunk left?
+ b.lo 2f
+
+ add x10, x10, #32 // advance pointers
+ add x0, x0, #32
+
+ cmeq v2.16b, v1.16b, v0.16b // char found in second chunk?
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+ cbnz x5, 4f // process chunk if match
+
+ str q1, [x0, #-16]
+ ldr q1, [x10] // load next chunk
+
+ subs x3, x3, #32
+ b.hs 0b
+
+1:
+ sub x10, x10, #16 // undo second advancement
+ add x3, x3, #16
+ sub x0, x0, #16
+
+ /* 1--16 bytes left in the buffer but string has not ended yet */
+2:
+ cmeq v2.16b, v1.16b, v0.16b // char found in second chunk?
+ shrn v2.8b, v2.8h, #4
+ fmov x4, d2
+
+ lsl x5, x3, #2 // shift 0xf to the limits position
+ lsl x5, x6, x5
+ orr x8, x4, x5 // insert match in mask at limit
+
+ rbit x8, x8 // simulate x86 tzcnt
+ clz x7, x8 // index of mismatch
+ lsr x8, x7, #2
+
+ lsl x5, x6, x7 // simulate x86 bt with shifted 0xf
+
+ add x8, x8, #1
+ add x0, x0, x8
+
+ ldr q1, [x10, x8] // load tail
+ str q1, [x0] // store tail
+
+ add x0, x0, #16
+
+ tst x4, x5 // terminator encountered inside buffer?
+ csel x0, x0, xzr, ne // if yes, return pointer, else NUL
+ ret
+
+4:
+ sub x10, x10, #16 // undo second advancement
+ sub x0, x0, #16 // undo second advancement
+
+3:
+ rbit x8, x5
+ clz x8, x8 // index of mismatch
+ lsr x3, x8, #2
+
+ add x0, x0, x3 // restore dst pointer
+ add x10, x10, x3
+ ldr q1, [x10, #-15]
+ str q1, [x0, #-15]
+ add x0, x0, #1
+ ret
+
+.Lrunt:
+ add x13, x11, x3
+
+ mov x7, x5 // keep a copy of original match mask
+
+ lsl x4, x12, #2 // shift 0xf to the limits position
+ lsl x4, x6, x4
+
+ cmp x13, #16 // dont induce match if limit >=16
+ csel x4, x4, xzr, lo
+ orr x5, x5, x4 // insert match in mask at limit
+
+ ands x8, x8, x5 // if match always fall through
+ b.ne 0f
+
+ ldr q4, [x10, #16] // load second string chunk
+ cmeq v1.16b, v4.16b, v0.16b // char found in second chunk?
+
+ /* process second chunk */
+ shrn v1.8b, v1.8h, #4
+ fmov x8, d1
+ mov x7, x8
+
+ lsl x4, x12, #2
+ lsl x4, x6, x4
+ orr x8, x8, x4 // induce match in upper bytes of mask
+
+ rbit x8, x8
+ clz x4, x8 // index of mismatch
+ lsr x8, x4, #2
+ add x8, x8, #16 // no match in first chunk
+ b 1f
+
+0:
+ rbit x8, x8
+ clz x4, x8 // index of mismatch
+ lsr x8, x4, #2
+1:
+ add x0, x0, x8 // return value if terminator not found
+ sub x0, x0, x11
+ add x0, x0, #1
+
+ /* check if we encountered a match or the limit first */
+ lsl x5, x6, x4
+ ands x7, x7, x5 // was the terminator present?
+ csel x0, xzr, x0, eq // return value based on what we matched
+
+ sub x8, x8, x11
+ add x4, x9, x8 // dst + cnt
+ add x5, x1, x8 // src + cnt
+
+ /* copy 17-32 bytes */
+.L1732:
+ cmp x8, #16
+ b.lo .L0816
+ add x5, x5, #1 // ldp offsets are powers of 2
+ add x4, x4, #1
+ ldp x16, x17, [x1]
+ ldp x12, x13, [x5, #-16]
+ stp x16, x17, [x9]
+ stp x12, x13, [x4, #-16]
+ ret
+
+ /* Copy 8-16 bytes */
+.L0816:
+ tbz x8, #3, .L0407
+ ldr x16, [x1]
+ ldr x17, [x5, #-7]
+ str x16, [x9]
+ str x17, [x4, #-7]
+ ret
+
+ /* Copy 4-7 bytes */
+ .p2align 4
+.L0407:
+ cmp x8, #3
+ b.lo .L0103
+ ldr w16, [x1]
+ ldr w18, [x5, #-3]
+ str w16, [x9]
+ str w18, [x4, #-3]
+ ret
+
+ /* Copy 1-3 bytes */
+ .p2align 4
+.L0103:
+ lsr x14, x8, #1
+ ldrb w16, [x1]
+ ldrb w15, [x5]
+ ldrb w18, [x1, x14]
+ strb w16, [x9]
+ strb w18, [x9, x14]
+ strb w15, [x4]
+ ret
+
+.L0:
+ eor x0, x0, x0
+ ret
+
+END(__memccpy)
diff --git a/lib/libc/aarch64/string/memchr.S b/lib/libc/aarch64/string/memchr.S
new file mode 100644
index 000000000000..6d4330d9115e
--- /dev/null
+++ b/lib/libc/aarch64/string/memchr.S
@@ -0,0 +1,4 @@
+ .weak memchr
+ .set memchr, __memchr_aarch64
+
+#include "aarch64/memchr.S"
diff --git a/lib/libc/aarch64/string/memcpy.S b/lib/libc/aarch64/string/memcpy.S
index ac4fbe8d6175..53e860750eb2 100644
--- a/lib/libc/aarch64/string/memcpy.S
+++ b/lib/libc/aarch64/string/memcpy.S
@@ -1,6 +1,3 @@
-#define __memcpy_aarch64 memcpy
-#define __memmove_aarch64 memmove
-#include "aarch64/memcpy.S"
-
-.weak index
-.equ index, strchr
+#define __memcpy_aarch64_simd memcpy
+#define __memmove_aarch64_simd memmove
+#include "aarch64/memcpy-advsimd.S"
diff --git a/lib/libc/aarch64/string/memmove.S b/lib/libc/aarch64/string/memmove.S
index e2f99790e0da..6ca014b3a565 100644
--- a/lib/libc/aarch64/string/memmove.S
+++ b/lib/libc/aarch64/string/memmove.S
@@ -3,3 +3,7 @@
* as it stops MISRCS from picking up the C implementation and rtld expects
* to copy the memmove object file into its object directory.
*/
+
+#include <machine/asm.h>
+#include <sys/elf_common.h>
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/aarch64/string/strcat.c b/lib/libc/aarch64/string/strcat.c
new file mode 100644
index 000000000000..c70875be1c1a
--- /dev/null
+++ b/lib/libc/aarch64/string/strcat.c
@@ -0,0 +1,20 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <string.h>
+
+#undef strcat /* _FORTIFY_SOURCE */
+
+char *
+strcat(char * __restrict s, const char * __restrict append)
+{
+ char *save = s;
+
+ /* call into SIMD optimized functions */
+ stpcpy(s + strlen(s), append);
+
+ return(save);
+}
diff --git a/lib/libc/aarch64/string/strcmp.S b/lib/libc/aarch64/string/strcmp.S
new file mode 100644
index 000000000000..e8418dfc6763
--- /dev/null
+++ b/lib/libc/aarch64/string/strcmp.S
@@ -0,0 +1,350 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+#include <machine/param.h>
+
+ .weak strcmp
+ .set strcmp, __strcmp
+ .text
+
+ENTRY(__strcmp)
+
+ bic x8, x0, #0xf // x0 aligned to the boundary
+ and x9, x0, #0xf // x9 is the offset
+ bic x10, x1, #0xf // x1 aligned to the boundary
+ and x11, x1, #0xf // x11 is the offset
+
+ mov x13, #-1
+
+ /*
+ * Check if either string is located at end of page to avoid crossing
+ * into unmapped page. If so, we load 16 bytes from the nearest
+ * alignment boundary and shift based on the offset.
+ */
+
+ add x3, x0, #16 // end of head
+ add x4, x1, #16
+ eor x3, x3, x0
+ eor x4, x4, x1 // bits that changed
+ orr x3, x3, x4 // in either str1 or str2
+ tbz w3, #PAGE_SHIFT, .Lbegin
+
+ ldr q0, [x8] // load aligned head
+ ldr q2, [x10]
+
+ lsl x14, x9, #2
+ lsl x15, x11, #2
+ lsl x3, x13, x14 // string head
+ lsl x4, x13, x15
+
+ cmeq v5.16b, v0.16b, #0
+ cmeq v6.16b, v2.16b, #0
+
+ shrn v5.8b, v5.8h, #4
+ shrn v6.8b, v6.8h, #4
+ fmov x5, d5
+ fmov x6, d6
+
+ adrp x2, shift_data
+ add x2, x2, :lo12:shift_data
+
+ /* heads may cross page boundary, avoid unmapped loads */
+ tst x5, x3
+ b.eq 0f
+
+ ldr q4, [x2, x9] // load permutation table
+ tbl v0.16b, {v0.16b}, v4.16b
+
+ b 1f
+ .p2align 4
+0:
+ ldr q0, [x0] // load true head
+1:
+ tst x6, x4
+ b.eq 0f
+
+ ldr q4, [x2, x11]
+ tbl v4.16b, {v2.16b}, v4.16b
+
+ b 1f
+
+ .p2align 4
+.Lbegin:
+ ldr q0, [x0] // load true heads
+0:
+ ldr q4, [x1]
+1:
+
+ cmeq v2.16b, v0.16b, #0 // NUL byte present?
+ cmeq v4.16b, v0.16b, v4.16b // which bytes match?
+
+ orn v2.16b, v2.16b, v4.16b // mismatch or NUL byte?
+
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+
+ cbnz x5, .Lhead_mismatch
+
+ ldr q2, [x8, #16] // load second chunk
+ ldr q3, [x10, #16]
+ subs x9, x9, x11 // is a&0xf >= b&0xf
+ b.lo .Lswapped // if not swap operands
+ sub x12, x10, x9
+ ldr q0, [x12, #16]!
+ sub x10, x10, x8
+ sub x11, x10, x9
+
+ cmeq v1.16b, v3.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+ add x8, x8, #16
+ shrn v1.8b, v1.8h, #4
+ fmov x6, d1
+ shrn v0.8b, v0.8h, #4
+ fmov x5, d0
+ cbnz x6, .Lnulfound
+ mvn x5, x5
+ cbnz x5, .Lmismatch
+ add x8, x8, #16 // advance aligned pointers
+
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * X0: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * X1: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * X1 doesn't end within region 2, then we compare chunk B between the
+ * two strings. As X1 is known not to hold a NUL byte in regions 1
+ * and 2 at this point, this also ensures that x0 has not ended yet.
+ */
+ .p2align 4
+0:
+ ldr q0, [x8, x11]
+ ldr q1, [x8, x10]
+ ldr q2, [x8]
+
+ cmeq v1.16b, v1.16b, #0 // end of string?
+ cmeq v0.16b, v0.16b, v2.16b // do the chunks match?
+
+ shrn v1.8b, v1.8h, #4
+ fmov x6, d1
+ shrn v0.8b, v0.8h, #4
+ fmov x5, d0
+ cbnz x6, .Lnulfound
+ mvn x5, x5 // any mismatches?
+ cbnz x5, .Lmismatch
+
+ add x8, x8, #16
+
+ ldr q0, [x8, x11]
+ ldr q1, [x8, x10]
+ ldr q2, [x8]
+
+ add x8, x8, #16
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ fmov x6, d1
+ shrn v0.8b, v0.8h, #4
+ fmov x5, d0
+ cbnz x6, .Lnulfound2
+ mvn x5, x5
+ cbz x5, 0b
+
+ sub x8, x8, #16 // roll back second increment
+.Lmismatch:
+ rbit x2, x5
+ clz x2, x2 // index of mismatch
+ lsr x2, x2, #2
+ add x11, x8, x11
+
+ ldrb w4, [x8, x2]
+ ldrb w5, [x11, x2]
+ sub w0, w4, w5 // byte difference
+ ret
+
+ .p2align 4
+.Lnulfound2:
+ sub x8, x8, #16
+
+.Lnulfound:
+ mov x7, x9
+ mov x4, x6
+
+ ubfiz x7, x7, #2, #4 // x7 = (x7 & 0xf) << 2
+ lsl x6, x6, x7 // adjust NUL mask to indices
+ orn x5, x6, x5
+ cbnz x5, .Lmismatch
+
+ /*
+ * (x0) == (x1) and NUL is past the string.
+ * Compare (x1) with the corresponding part
+ * of the other string until the NUL byte.
+ */
+ ldr q0, [x8, x9]
+ ldr q1, [x8, x10]
+
+ cmeq v1.16b, v0.16b, v1.16b
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ orn x5, x4, x5
+
+ rbit x2, x5
+ clz x2, x2
+ lsr x5, x2, #2
+
+ add x10, x10, x8 // restore x10 pointer
+ add x8, x8, x9 // point to corresponding chunk
+
+ ldrb w4, [x8, x5]
+ ldrb w5, [x10, x5]
+ sub w0, w4, w5
+ ret
+
+ .p2align 4
+.Lhead_mismatch:
+ rbit x2, x5
+ clz x2, x2 // index of mismatch
+ lsr x2, x2, #2
+ ldrb w4, [x0, x2]
+ ldrb w5, [x1, x2]
+ sub w0, w4, w5
+ ret
+
+ /*
+ * If (a&0xf) < (b&0xf), we do the same thing but with swapped
+ * operands. I found that this performs slightly better than
+ * using conditional moves to do the swap branchless.
+ */
+ .p2align 4
+.Lswapped:
+ add x12, x8, x9
+ ldr q0, [x12, #16]!
+ sub x8, x8, x10
+ add x11, x8, x9
+ neg x9, x9
+
+ cmeq v1.16b, v2.16b, #0
+ cmeq v0.16b, v0.16b, v3.16b
+ add x10, x10, #16
+ shrn v1.8b, v1.8h, #4
+ fmov x6, d1
+ shrn v0.8b, v0.8h, #4
+ fmov x5, d0
+ cbnz x6, .Lnulfounds
+ mvn x5, x5
+ cbnz x5, .Lmismatchs
+ add x10, x10, #16
+
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * X1: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * X0: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * X0 doesn't end within region 2, then we compare chunk B between the
+ * two strings. As X0 is known not to hold a NUL byte in regions 1
+ * and 2 at this point, this also ensures that X1 has not ended yet.
+ */
+ .p2align 4
+0:
+ ldr q0, [x10, x11]
+ ldr q1, [x10, x8]
+ ldr q2, [x10]
+
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ fmov x6, d1
+ shrn v0.8b, v0.8h, #4
+ fmov x5, d0
+ cbnz x6, .Lnulfounds
+ mvn x5, x5
+ cbnz x5, .Lmismatchs
+
+ add x10, x10, #16
+
+ ldr q0, [x10, x11]
+ ldr q1, [x10, x8]
+ ldr q2, [x10]
+
+ add x10, x10, #16
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ fmov x6, d1
+ shrn v0.8b, v0.8h, #4
+ fmov x5, d0
+ cbnz x6, .Lnulfound2s
+ mvn x5, x5
+ cbz x5, 0b
+
+ sub x10, x10, #16
+
+.Lmismatchs:
+ rbit x2, x5
+ clz x2, x2
+ lsr x2, x2, #2
+ add x11, x10, x11
+
+ ldrb w4, [x10, x2]
+ ldrb w5, [x11, x2]
+ sub w0, w5, w4
+ ret
+
+ .p2align 4
+.Lnulfound2s:
+ sub x10, x10, #16
+.Lnulfounds:
+ mov x7, x9
+ mov x4, x6
+
+ ubfiz x7, x7, #2, #4
+ lsl x6, x6, x7
+ orn x5, x6, x5
+ cbnz x5, .Lmismatchs
+
+ ldr q0, [x10, x9]
+ ldr q1, [x10, x8]
+
+ cmeq v1.16b, v0.16b, v1.16b
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ orn x5, x4, x5
+
+ rbit x2, x5
+ clz x2, x2
+ lsr x5, x2, #2
+
+ add x11, x10, x8
+ add x10, x10, x9
+
+ ldrb w4, [x10, x5]
+ ldrb w5, [x11, x5]
+ sub w0, w5, w4
+ ret
+
+END(__strcmp)
+
+ .section .rodata
+ .p2align 4
+shift_data:
+ .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+ .fill 16, 1, -1
+ .size shift_data, .-shift_data
diff --git a/lib/libc/aarch64/string/strcspn.S b/lib/libc/aarch64/string/strcspn.S
new file mode 100644
index 000000000000..8f2d6d20f0f6
--- /dev/null
+++ b/lib/libc/aarch64/string/strcspn.S
@@ -0,0 +1,109 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+
+ .weak strcspn
+ .set strcspn, __strcspn
+ .text
+
+ENTRY(__strcspn)
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+ mov x15, #1 // preload register with 1 for stores
+
+ /* check for special cases */
+ ldrb w4, [x1] // first character in the set
+ cbz w4, .Lstrlen
+
+ movi v0.16b, #0
+
+ ldrb w5, [x1, #1] // second character in the set
+ cbz w5, .Lstrchr
+
+ sub sp, sp, #256 // allocate 256 bytes on the stack
+
+ /* no special case matches -- prepare lookup table */
+ mov w3, #20
+ .p2align 4
+0: add x9, sp, x3, lsl #3
+ stp xzr, xzr, [x9]
+ stp xzr, xzr, [x9, #16]
+ subs w3, w3, #4
+ b.cs 0b
+
+ /* utilize SIMD stores to speed up zeroing the table */
+ stp q0, q0, [sp, #6*32]
+ stp q0, q0, [sp, #7*32]
+
+ add x1, x1, #2
+ strb w15, [sp, x4] // register first chars in the set
+ strb w15, [sp, x5]
+
+ mov x4, x0 // stash a copy of src
+
+ /* process remaining chars in set */
+ .p2align 4
+0: ldrb w5, [x1]
+ strb w15, [sp, x5]
+ cbz w5, 1f // end of set?
+
+ ldrb w5, [x1, #1]
+ strb w15, [sp, x5]
+ cbz w5, 1f
+
+ add x1, x1, #2
+ b 0b
+
+ /* find match */
+ .p2align 4
+1: ldrb w8, [x0]
+ ldrb w9, [sp, x8]
+ cbnz w9, 2f
+
+ ldrb w8, [x0, #1]
+ ldrb w9, [sp, x8]
+ cbnz w9, 3f
+
+ ldrb w8, [x0, #2]
+ ldrb w9, [sp, x8]
+ cbnz w9, 4f
+
+ ldrb w8, [x0, #3]
+ ldrb w9, [sp, x8]
+ add x0, x0, #4
+ cbz w9, 1b
+
+ sub x0, x0, #3 // fix up return value
+4: sub x4, x4, #1
+3: add x0, x0, #1
+2: sub x0, x0, x4
+ mov sp, x29
+ ldp x29, x30, [sp], #16 // restore sp and lr
+ ret
+
+ /* set is empty, degrades to strlen */
+ .p2align 4
+.Lstrlen:
+ mov sp, x29
+ ldp x29, x30, [sp], #16 // restore sp and lr
+ b strlen
+
+ /* just one character in set, degrades to strchrnul */
+ .p2align 4
+.Lstrchr:
+ stp x0, x1, [sp, #-16]!
+ mov x1, x4
+
+ bl strchrnul
+
+ ldp x18, x17, [sp], #16 // restore stashed src
+ sub x0, x0, x18
+
+ ldp x29, x30, [sp], #16 // Restore sp and lr
+ ret
+
+END(__strcspn)
diff --git a/lib/libc/aarch64/string/strlcat.c b/lib/libc/aarch64/string/strlcat.c
new file mode 100644
index 000000000000..fe2e75d091c5
--- /dev/null
+++ b/lib/libc/aarch64/string/strlcat.c
@@ -0,0 +1,27 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Robert Clausecker
+ */
+
+#include <sys/cdefs.h>
+
+#include <string.h>
+
+#undef strlcat /* _FORTIFY_SOURCE */
+
+void *__memchr_aarch64(const void *, int, size_t);
+size_t __strlcpy(char *restrict, const char *restrict, size_t);
+
+size_t
+strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
+{
+ char *loc = __memchr_aarch64(dst, '\0', dstsize);
+
+ if (loc != NULL) {
+ size_t dstlen = (size_t)(loc - dst);
+
+ return (dstlen + __strlcpy(loc, src, dstsize - dstlen));
+ } else
+ return (dstsize + strlen(src));
+}
diff --git a/lib/libc/aarch64/string/strlcpy.S b/lib/libc/aarch64/string/strlcpy.S
new file mode 100644
index 000000000000..3859aaca447b
--- /dev/null
+++ b/lib/libc/aarch64/string/strlcpy.S
@@ -0,0 +1,316 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+
+ .weak strlcpy
+ .set strlcpy, __strlcpy
+ .text
+
+ENTRY(__strlcpy)
+ subs x2, x2, #1
+ b.lo .L0
+
+ mov x9, x0 // stash copy of dst pointer
+ bic x10, x1, #0xf // src aligned
+ and x11, x1, #0xf // src offset
+
+ ldr q1, [x10]
+ cmeq v1.16b, v1.16b, #0 // NUL found in head?
+
+ mov x8, #-1 // fill register with 0xfff..fff
+ lsl x12, x11, #2
+ lsl x8, x8, x12 // mask of bytes in the string
+
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ ands x5, x5, x8
+ b.ne .Lhead_nul
+
+ ldr q3, [x10, #16] // load second string chunk
+ ldr q2, [x1] // load true head
+ mov x8, #32
+ sub x8, x8, x11
+
+ cmeq v1.16b, v3.16b, #0 // NUL found in second chunk?
+
+ subs x2, x2, x8
+ b.ls .Lhead_buf_end
+
+ /* process second chunk */
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+ cbnz x5, .Lsecond_nul
+
+ /* string didn't end in second chunk and neither did buffer */
+ ldr q1, [x10, #32] // load next string chunk
+ str q2, [x0] // deposit head into buffer
+ sub x0, x0, x11 // adjust x0
+ str q3, [x0, #16] // deposit second chunk
+ add x10, x10, #32 // advance src
+ add x0, x0, #32 // advance dst
+ subs x2, x2, #16 // enough left for another round?
+ b.ls 1f
+
+ /* main loop unrolled twice */
+ .p2align 4
+0:
+ cmeq v2.16b, v1.16b, #0 // NUL found in second chunk?
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+
+ cbnz x5, 3f
+
+ str q1, [x0]
+ ldr q1, [x10, #16] // load next chunk
+
+ cmp x2, #16 // more than a full chunk left?
+ b.ls 2f
+
+ add x10, x10, #32 // advance pointers
+ add x0, x0, #32
+
+ cmeq v2.16b, v1.16b, #0 // NUL found in second chunk?
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+ cbnz x5, 4f // process chunk if match
+
+ str q1, [x0, #-16]
+ ldr q1, [x10] // load next chunk
+
+ subs x2, x2, #32
+ b.hi 0b
+
+1:
+ sub x10, x10, #16 // undo second advancement
+ add x2, x2, #16
+ sub x0, x0, #16
+
+ /* 1--16 bytes left in the buffer but string has not ended yet */
+2:
+ cmeq v2.16b, v1.16b, #0 // NUL found in second chunk?
+ shrn v2.8b, v2.8h, #4
+ fmov x4, d2
+
+ mov x6, #0xf
+ mov x7, x4
+
+ lsl x5, x2, #2 // shift 0xf to the limits position
+ lsl x5, x6, x5
+ cmp x2, #16 // dont induce match if limit >=16
+ csel x5, x5, xzr, lo
+ orr x8, x4, x5 // treat limit as if terminator present
+
+ rbit x8, x8 // simulate x86 tzcnt
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ add x0, x0, x8
+
+ ldr q1, [x10, x8] // load tail
+ str q1, [x0] // store tail
+ strb wzr, [x0, #16]
+
+ /* continue to find the end of the string */
+ cbnz x7, 1f
+
+ /* we opt for a simpler strlen than the one in libc as the
+ * cmeq, shrn approach is faster for shorter strings.
+ */
+ .p2align 4
+0:
+ ldr q1, [x10, #32]
+ cmeq v1.16b, v1.16b, #0 // bytewise compare against NUL
+ shrn v1.8b, v1.8h, #4
+ fmov x7, d1
+ cbnz x7, 2f
+
+ ldr q1, [x10, #48]
+ cmeq v1.16b, v1.16b, #0 // bytewise compare against NUL
+ shrn v1.8b, v1.8h, #4
+ fmov x7, d1
+ add x10, x10, #32
+ cbz x7, 0b
+
+1: sub x10, x10, #16
+2: rbit x8, x7
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ sub x10, x10, x1
+ add x0, x10, #32
+ add x0, x0, x8
+
+ ret
+
+4:
+ sub x10, x10, #16 // undo second advancement
+ sub x0, x0, #16 // undo second advancement
+
+ /* string has ended but buffer has not */
+3:
+ rbit x8, x5
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ add x0, x0, x8 // restore dst pointer
+ add x10, x10, x8
+
+ ldr q1, [x10, #-15]
+ str q1, [x0, #-15]
+ add x0, x0, #1
+ sub x0, x10, x1
+
+ ret
+
+.Lhead_buf_end:
+ shrn v1.8b, v1.8h, #4
+ fmov x8, d1
+
+ add x2, x2, #32 // restore limit
+
+ mov x7, x8
+ mov x6, #0xf
+
+ cmp x2, #16 // should we induce a match or not
+ b.lo 0f
+
+ rbit x8, x8
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+ add x8, x8, #16
+
+ cmp x8, x2
+ csel x8, x8, x2, lo // copy min(buflen, srclen) bytes
+ b 1f
+0:
+
+ rbit x8, x8
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ mov x8, x2
+1:
+
+ sub x8, x8, x11
+ strb wzr, [x9, x8]
+
+ /* continue to find the end of the string */
+ cbnz x7, 1f
+
+ /* we opt for a simpler strlen than the one in libc as the
+ * cmeq, shrn approach is faster for shorter strings.
+ */
+ .p2align 4
+0:
+ ldr q1, [x10, #32]
+ cmeq v1.16b, v1.16b, #0 // bytewise compare against NUL
+ shrn v1.8b, v1.8h, #4
+ fmov x7, d1
+ cbnz x7, 2f
+
+ ldr q1, [x10, #48]
+ cmeq v1.16b, v1.16b, #0 // bytewise compare against NUL
+ shrn v1.8b, v1.8h, #4
+ fmov x7, d1
+ add x10, x10, #32
+ cbz x7, 0b
+
+1: sub x10, x10, #16
+2: rbit x6, x7
+ clz x6, x6 // index of mismatch
+ lsr x6, x6, #2
+
+ sub x10, x10, x1
+ add x0, x10, #32
+ add x0, x0, x6
+
+ add x4, x9, x8 // dst + cnt
+ add x5, x1, x8 // src + cnt
+
+ b .L1732
+
+.Lsecond_nul:
+ add x2, x2, x8
+
+ rbit x8, x5
+ clz x8, x8 // index of mismatch
+ lsr x5, x8, #2
+
+ sub x8, x11, #16
+ sub x0, x5, x8 // string length
+
+ cmp x0, x2 // did we match or hit limit first?
+ csel x8, x2, x0, hi
+
+ add x4, x9, x8 // dst + cnt
+ add x5, x1, x8 // src + cnt
+
+ strb wzr, [x4]
+
+ /* copy 17-32 bytes */
+.L1732:
+ cmp x8, #16
+ b.lo .L0816
+ ldp x16, x17, [x1]
+ ldp x12, x1, [x5, #-16]
+ stp x16, x17, [x9]
+ stp x12, x1, [x4, #-16]
+ ret
+
+.Lhead_nul:
+ rbit x8, x5
+ clz x8, x8 // index of mismatch
+ lsr x8, x8, #2
+
+ sub x0, x8, x11
+ cmp x0, x2
+ csel x8, x2, x0, hi
+
+ add x4, x9, x8 // dst + cnt
+ add x5, x1, x8 // src + cnt
+ strb wzr, [x4]
+
+ /* Copy 8-16 bytes */
+.L0816:
+ tbz x8, #3, .L0407
+ ldr x16, [x1]
+ ldr x17, [x5, #-8]
+ str x16, [x9]
+ str x17, [x4, #-8]
+ ret
+
+ /* Copy 4-7 bytes */
+ .p2align 4
+.L0407:
+ cmp x8, #3
+ b.ls .L0203
+ ldr w16, [x1]
+ ldr w18, [x5, #-4]
+ str w16, [x9]
+ str w18, [x4, #-4]
+ ret
+
+.L0203:
+ tbz x8, 1, .L0001
+ ldrh w16, [x1]
+ ldrh w17, [x5, #-2]
+ strh w16, [x9]
+ strh w17, [x4, #-2]
+ ret
+
+.L0001:
+ ldrb w16, [x1]
+ strb w16, [x9]
+ strb wzr, [x4]
+ ret
+
+.L0:
+ mov x0, x1
+ b strlen
+ ret
+END(__strlcpy)
diff --git a/lib/libc/aarch64/string/strlen.S b/lib/libc/aarch64/string/strlen.S
new file mode 100644
index 000000000000..6fefc252eca1
--- /dev/null
+++ b/lib/libc/aarch64/string/strlen.S
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+
+ .weak strlen
+ .set strlen, __strlen
+ .text
+
+ENTRY(__strlen)
+ bic x10, x0, #0xf // aligned src
+ and x9, x0, #0xf
+ ldr q0, [x10]
+ cmeq v0.16b, v0.16b, #0
+ shrn v0.8b, v0.8h, #4
+ fmov x1, d0
+ cbz x9, .Laligned
+ lsl x2, x0, #2 // get the byte offset
+ lsr x1, x1, x2 // shift by offset index
+ cbz x1, .Lloop
+ rbit x1, x1
+ clz x0, x1
+ lsr x0, x0, #2
+ ret
+
+.Laligned:
+ cbnz x1, .Ldone
+
+.Lloop:
+ ldr q0, [x10, #16]!
+ cmeq v0.16b, v0.16b, #0
+ shrn v0.8b, v0.8h, #4 // reduce to fit mask in GPR
+ fmov x1, d0
+ cbz x1, .Lloop
+.Ldone:
+ sub x0, x10, x0
+ rbit x1, x1 // reverse bits as NEON has no ctz
+ clz x3, x1
+ lsr x3, x3, #2
+ add x0, x0, x3
+ ret
+END(__strlen)
diff --git a/lib/libc/aarch64/string/strncat.c b/lib/libc/aarch64/string/strncat.c
new file mode 100644
index 000000000000..2c63ab50b3c3
--- /dev/null
+++ b/lib/libc/aarch64/string/strncat.c
@@ -0,0 +1,31 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Robert Clausecker
+ */
+
+#include <sys/cdefs.h>
+
+#include <string.h>
+
+#undef strncat /* _FORTIFY_SOURCE */
+
+void *__memccpy(void *restrict, const void *restrict, int, size_t);
+
+char *
+strncat(char *dest, const char *src, size_t n)
+{
+ size_t len;
+ char *endptr;
+
+ len = strlen(dest);
+ endptr = __memccpy(dest + len, src, '\0', n);
+
+ /* avoid an extra branch */
+ if (endptr == NULL)
+ endptr = dest + len + n + 1;
+
+ endptr[-1] = '\0';
+
+ return (dest);
+}
diff --git a/lib/libc/aarch64/string/strncmp.S b/lib/libc/aarch64/string/strncmp.S
new file mode 100644
index 000000000000..a7f4156da9e8
--- /dev/null
+++ b/lib/libc/aarch64/string/strncmp.S
@@ -0,0 +1,569 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+#include <machine/param.h>
+
+ .weak strncmp
+ .set strncmp, __strncmp
+ .text
+
+ENTRY(__strncmp)
+
+ bic x8, x0, #0xf // x0 aligned to the boundary
+ and x9, x0, #0xf // x9 is the offset
+ bic x10, x1, #0xf // x1 aligned to the boundary
+ and x11, x1, #0xf // x11 is the offset
+
+ subs x2, x2, #1
+ b.lo .Lempty
+
+ mov x13, #-1 // save constants for later
+ mov x16, #0xf
+
+ /*
+ * Check if either string is located at end of page to avoid crossing
+ * into unmapped page. If so, we load 16 bytes from the nearest
+ * alignment boundary and shift based on the offset.
+ */
+
+ add x3, x0, #16 // end of head
+ add x4, x1, #16
+ eor x3, x3, x0
+ eor x4, x4, x1 // bits that changed
+ orr x3, x3, x4 // in either str1 or str2
+ cmp x2,#16
+ b.lo .Llt16
+ tbz w3, #PAGE_SHIFT, .Lbegin
+
+ ldr q0, [x8] // load aligned head
+ ldr q1, [x10]
+
+ lsl x14, x9, #2
+ lsl x15, x11, #2
+ lsl x3, x13, x14 // string head
+ lsl x4, x13, x15
+
+ cmeq v5.16b, v0.16b, #0
+ cmeq v6.16b, v1.16b, #0
+
+ shrn v5.8b, v5.8h, #4
+ shrn v6.8b, v6.8h, #4
+ fmov x5, d5
+ fmov x6, d6
+
+ adrp x14, shift_data
+ add x14, x14, :lo12:shift_data
+
+ /* heads may cross page boundary, avoid unmapped loads */
+ tst x5, x3
+ b.eq 0f
+
+ ldr q4, [x14, x9] // load permutation table
+ tbl v0.16b, {v0.16b}, v4.16b
+
+ b 1f
+ .p2align 4
+0:
+ ldr q0, [x0] // load true head
+1:
+ tst x6, x4
+ b.eq 0f
+
+ ldr q4, [x14, x11]
+ tbl v4.16b, {v1.16b}, v4.16b
+
+ b 1f
+
+ .p2align 4
+.Lbegin:
+ ldr q0, [x0] // load true heads
+0:
+ ldr q4, [x1]
+1:
+ cmeq v2.16b, v0.16b, #0 // NUL byte present?
+ cmeq v4.16b, v0.16b, v4.16b // which bytes match?
+
+ orn v2.16b, v2.16b, v4.16b // mismatch or NUL byte?
+
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+
+ cbnz x5, .Lhead_mismatch
+ /* load head and second chunk */
+ ldr q2, [x8, #16] // load second chunk
+ ldr q3, [x10, #16]
+
+ add x2, x2, x11
+ sub x2, x2, #16
+
+ subs x9, x9, x11 // is a&0xf >= b&0xf
+ b.lo .Lswapped // if not swap operands
+ b .Lnormal
+
+ .p2align 4
+.Llt16:
+ /*
+ * Check if either string is located at end of page to avoid crossing
+ * into unmapped page. If so, we load 16 bytes from the nearest
+ * alignment boundary and shift based on the offset.
+ */
+ tbz w3, #PAGE_SHIFT, 2f
+
+ ldr q0, [x8] // load aligned head
+ ldr q1, [x10]
+
+ lsl x14, x9, #2
+ lsl x15, x11, #2
+ lsl x3, x13, x14 // string head
+ lsl x4, x13, x15
+
+ /* Introduce a null byte match if the limit is within the aligned chunk */
+ add x14, x2, x9
+ add x15, x2, x11
+ lsl x14, x14, #2
+ lsl x15, x15, #2
+ lsl x14, x16, x14
+ lsl x15, x16, x15
+
+ cmeq v5.16b, v0.16b, #0
+ cmeq v6.16b, v1.16b, #0
+
+ shrn v5.8b, v5.8h, #4
+ shrn v6.8b, v6.8h, #4
+ fmov x5, d5
+ fmov x6, d6
+
+ orr x5, x5, x14 // insert match at limit
+ orr x6, x6, x15
+
+ adrp x14, shift_data
+ add x14, x14, :lo12:shift_data
+
+ /* heads may cross page boundary, avoid unmapped loads */
+ tst x5, x3
+ b.eq 0f
+
+ ldr q4, [x14, x9] // load permutation table
+ tbl v0.16b, {v0.16b}, v4.16b
+
+ b 1f
+ .p2align 4
+0:
+ ldr q0, [x0] // load true head
+1:
+ tst x6, x4
+ b.eq 0f
+
+ ldr q4, [x14, x11]
+ tbl v4.16b, {v1.16b}, v4.16b
+
+ b 1f
+
+ .p2align 4
+2:
+ ldr q0, [x0] // load true heads
+0:
+ ldr q4, [x1]
+1:
+
+ cmeq v2.16b, v0.16b, #0 // NUL byte present?
+ cmeq v4.16b, v0.16b, v4.16b // which bytes match?
+
+ bic v2.16b, v4.16b, v2.16b // match and not NUL byte
+
+ shrn v2.8b, v2.8h, #4
+ fmov x5, d2
+ lsl x4, x2, #2
+ lsl x4, x13, x4
+ orn x5, x4, x5 // mismatch or NUL byte?
+
+.Lhead_mismatch:
+ rbit x3, x5
+ clz x3, x3 // index of mismatch
+ lsr x3, x3, #2
+ ldrb w4, [x0, x3]
+ ldrb w5, [x1, x3]
+ sub w0, w4, w5
+ ret
+
+ .p2align 4
+.Lnormal:
+ sub x12, x10, x9
+ ldr q0, [x12, #16]!
+ sub x10, x10, x8
+ sub x11, x10, x9
+
+ cmeq v1.16b, v3.16b, #0 // NUL present?
+ cmeq v0.16b, v0.16b, v2.16b // Mismatch between chunks?
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+
+ add x8, x8, #32 // advance to next iteration
+
+ lsl x4, x2, #2
+ lsl x4, x13, x4
+ orr x3, x6, x4 // introduce a null byte match
+ cmp x2, #16 // does the buffer end within x2
+ csel x6, x3, x6, lo
+ cbnz x6, .Lnulfound2 // NUL or end of buffer found?
+ mvn x5, x5
+ cbnz x5, .Lmismatch2
+ sub x2, x2, #16
+ cmp x2, #32 // end of buffer?
+ b.lo .Ltail
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * X0: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * X1: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * X1 doesn't end within region 2, then we compare chunk B between the
+ * two strings. As X1 is known not to hold a NUL byte in regions 1
+ * and 2 at this point, this also ensures that x0 has not ended yet.
+ */
+ .p2align 4
+0:
+ ldr q0, [x8, x11]
+ ldr q1, [x8, x10]
+ ldr q2, [x8]
+
+ cmeq v1.16b, v1.16b, #0 // end of string?
+ cmeq v0.16b, v0.16b, v2.16b // do the chunks match?
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+ cbnz x6, .Lnulfound
+ mvn x5, x5 // any mismatches?
+ cbnz x5, .Lmismatch
+
+ add x8, x8, #16
+
+ /* main loop unrolled twice */
+ ldr q0, [x8, x11]
+ ldr q1, [x8, x10]
+ ldr q2, [x8]
+
+ add x8, x8, #16
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+ cbnz x6, .Lnulfound2
+ mvn x5, x5
+ cbnz x5, .Lmismatch2
+ sub x2, x2, #32
+ cmp x2, #32 // end of buffer?
+ b.hs 0b // if yes, process tail
+
+ /* end of buffer will occur in next 32 bytes */
+.Ltail:
+ ldr q0, [x8, x11]
+ ldr q1, [x8, x10]
+ ldr q2, [x8]
+
+ cmeq v1.16b, v1.16b, #0 // end of string?
+ cmeq v0.16b, v0.16b, v2.16b // do the chunks match?
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+
+ /*
+ * If x2 <= 16 then we introduce a NUL byte in the
+ * result from CMEQ to avoid comparing further!
+ */
+
+ lsl x4, x2, #2
+ lsl x4, x13, x4
+ orr x3, x6, x4 // introduce a null byte match
+ cmp x2, #16 // does the buffer end within x2
+ csel x6, x3, x6, lo
+
+ cbnz x6, .Lnulfound // NUL or end of string found
+ mvn x5, x5
+ cbnz x5, .Lmismatch
+
+ add x8, x8, #16
+
+ /* main loop unrolled twice */
+ ldr q0, [x8, x11]
+ ldr q1, [x8, x10]
+ ldr q2, [x8]
+
+ add x8, x8, #16
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+
+ ubfiz x4, x2, #2, #4 // (x2 - 16) << 2
+ lsl x4, x13, x4 // take first half into account
+ orr x6, x6, x4 // introduce a null byte match
+
+.Lnulfound2:
+ sub x8, x8, #16
+
+.Lnulfound:
+ mov x4, x6
+
+ ubfiz x7, x9, #2, #4
+ lsl x6, x6, x7 // adjust NUL mask to indices
+
+ orn x5, x6, x5
+ cbnz x5, .Lmismatch
+
+ /*
+ * (x0) == (x1) and NUL is past the string.
+ * Compare (x1) with the corresponding part
+ * of the other string until the NUL byte.
+ */
+ ldr q0, [x8, x9]
+ ldr q1, [x8, x10]
+
+ cmeq v1.16b, v0.16b, v1.16b
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ orn x5, x4, x5
+
+ rbit x3, x5
+ clz x3, x3
+ lsr x5, x3, #2
+
+ add x10, x10, x8 // restore x10 pointer
+ add x8, x8, x9 // point to corresponding chunk
+
+ ldrb w4, [x8, x5]
+ ldrb w5, [x10, x5]
+ sub w0, w4, w5
+ ret
+
+ .p2align 4
+.Lmismatch2:
+ sub x8, x8, #16 // roll back second increment
+.Lmismatch:
+ rbit x3, x5
+ clz x3, x3 // index of mismatch
+ lsr x3, x3, #2
+ add x11, x8, x11
+
+ ldrb w4, [x8, x3]
+ ldrb w5, [x11, x3]
+ sub w0, w4, w5 // byte difference
+ ret
+
+ /*
+ * If (a&0xf) < (b&0xf), we do the same thing but with swapped
+ * operands. I found that this performs slightly better than
+ * using conditional moves to do the swap branchless.
+ */
+ .p2align 4
+.Lswapped:
+ add x12, x8, x9
+ ldr q0, [x12, #16]!
+ sub x8, x8, x10
+ add x11, x8, x9
+ add x2,x2,x9
+ neg x9, x9
+
+ cmeq v1.16b, v2.16b, #0
+ cmeq v0.16b, v0.16b, v3.16b
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+
+ add x10, x10, #32
+
+ lsl x4, x2, #2
+ lsl x4, x13, x4
+ orr x3,x6,x4 // introduce a null byte match
+ cmp x2,#16
+ csel x6, x3, x6, lo
+ cbnz x6, .Lnulfound2s
+ mvn x5, x5
+ cbnz x5, .Lmismatch2s
+
+ sub x2, x2, #16
+ cmp x2, #32
+ b.lo .Ltails
+
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * X1: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * X0: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * X0 doesn't end within region 2, then we compare chunk B between the
+ * two strings. As X0 is known not to hold a NUL byte in regions 1
+ * and 2 at this point, this also ensures that X1 has not ended yet.
+ */
+ .p2align 4
+0:
+ ldr q0, [x10, x11]
+ ldr q1, [x10, x8]
+ ldr q2, [x10]
+
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+ cbnz x6, .Lnulfounds
+ mvn x5, x5
+ cbnz x5, .Lmismatchs
+
+ add x10, x10, #16
+
+ /* main loop unrolled twice */
+ ldr q0, [x10, x11]
+ ldr q1, [x10, x8]
+ ldr q2, [x10]
+
+ add x10, x10, #16
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+ cbnz x6, .Lnulfound2s
+ mvn x5, x5
+ cbnz x5, .Lmismatch2s
+ sub x2, x2, #32
+ cmp x2, #32
+ b.hs 0b
+
+.Ltails:
+ ldr q0, [x10, x11]
+ ldr q1, [x10, x8]
+ ldr q2, [x10]
+
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+
+ /*
+ * If x2 <= 16 then we introduce a NUL byte in the
+ * result from CMEQ to avoid comparing further!
+ */
+
+ lsl x4, x2, #2
+ lsl x4, x13, x4
+ orr x3, x6, x4 // introduce a null byte match
+ cmp x2, #16
+ csel x6, x3, x6, lo
+
+ cbnz x6, .Lnulfounds
+ mvn x5, x5
+ cbnz x5, .Lmismatchs
+
+ add x10, x10, #16
+
+ ldr q0, [x10, x11]
+ ldr q1, [x10, x8]
+ ldr q2, [x10]
+
+ add x10, x10, #16
+ cmeq v1.16b, v1.16b, #0
+ cmeq v0.16b, v0.16b, v2.16b
+
+ shrn v1.8b, v1.8h, #4
+ shrn v0.8b, v0.8h, #4
+ fmov x6, d1
+ fmov x5, d0
+
+ ubfiz x4, x2, #2, #4
+ lsl x4, x13, x4
+ orr x6, x6, x4 // introduce a null byte match
+
+.Lnulfound2s:
+ sub x10, x10, #16
+.Lnulfounds:
+ mov x4, x6
+
+ ubfiz x7, x9, #2, #4
+ lsl x6, x6, x7
+
+ orn x5, x6, x5
+
+ cbnz x5, .Lmismatchs
+
+ ldr q0, [x10, x9]
+ ldr q1, [x10, x8]
+
+ cmeq v1.16b, v0.16b, v1.16b
+ shrn v1.8b, v1.8h, #4
+ fmov x5, d1
+
+ orn x5, x4, x5
+
+ rbit x3, x5
+ clz x3, x3
+ lsr x5, x3, #2
+
+ add x11, x10, x8
+ add x10, x10, x9
+
+ ldrb w4, [x10, x5]
+ ldrb w5, [x11, x5]
+ sub w0, w5, w4
+ ret
+
+ .p2align 4
+.Lmismatch2s:
+ sub x10, x10, #16
+.Lmismatchs:
+ rbit x3, x5
+ clz x3, x3
+ lsr x3, x3, #2
+ add x11, x10, x11
+
+ ldrb w4, [x10, x3]
+ ldrb w5, [x11, x3]
+ sub w0, w5, w4
+ ret
+
+ .p2align 4
+.Lempty:
+ eor x0, x0, x0
+ ret
+
+END(__strncmp)
+
+ .section .rodata
+ .p2align 4
+shift_data:
+ .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+ .fill 16, 1, -1
+ .size shift_data, .-shift_data
diff --git a/lib/libc/aarch64/string/strpbrk.c b/lib/libc/aarch64/string/strpbrk.c
new file mode 100644
index 000000000000..87f587789991
--- /dev/null
+++ b/lib/libc/aarch64/string/strpbrk.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+
+#include <string.h>
+
+size_t __strcspn(const char *, const char *);
+
+char *
+strpbrk(const char *s, const char *charset)
+{
+ size_t loc;
+
+ loc = __strcspn(s, charset);
+
+ return (s[loc] == '\0' ? NULL : (char *)&s[loc]);
+}
diff --git a/lib/libc/aarch64/string/strsep.c b/lib/libc/aarch64/string/strsep.c
new file mode 100644
index 000000000000..7afd47957aa9
--- /dev/null
+++ b/lib/libc/aarch64/string/strsep.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+size_t __strcspn(const char *, const char *);
+
+/*
+ * We have a fast strcspn() on aarch64. Use it over a direct
+ * implementation of strsep for better performance.
+ */
+char *
+strsep(char **stringp, const char *delim)
+{
+ size_t n;
+ char *s;
+
+ s = *stringp;
+ if (s == NULL)
+ return (NULL);
+
+ n = __strcspn(s, delim);
+ if (s[n] == '\0')
+ *stringp = NULL;
+ else {
+ s[n] = '\0';
+ *stringp = s + n + 1;
+ }
+
+ return (s);
+}
diff --git a/lib/libc/aarch64/string/strspn.S b/lib/libc/aarch64/string/strspn.S
new file mode 100644
index 000000000000..0ef42c2b737e
--- /dev/null
+++ b/lib/libc/aarch64/string/strspn.S
@@ -0,0 +1,111 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Getz Mikalsen <getz@FreeBSD.org>
+*/
+
+#include <machine/asm.h>
+
+ .weak strspn
+ .set strspn, __strspn
+ .text
+
+ENTRY(__strspn)
+
+ /* check for special cases */
+ ldrb w4, [x1] // first character in set
+ cbz w4, .Lzero // empty set always returns 0
+
+ mov x15, #1 // preload register with 1 for stores
+
+ // set is only one character
+ ldrb w5, [x1, #1] // second character in the set
+ cbz w5, .Lsingle
+
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+ sub sp, sp, #256 // allocate 256 bytes on the stack
+
+ /* no special case matches -- prepare lookup table */
+ mov w3, #28
+0: add x9, sp, x3, lsl #3
+ stp xzr, xzr, [x9]
+ stp xzr, xzr, [x9, #16]
+ subs w3, w3, #4
+ b.cs 0b
+
+ strb w15, [sp, x4] // register first character in set
+ add x1, x1, #2
+
+ /* process remaining chars in set */
+ .p2align 4
+
+
+0: ldrb w4, [x1] // next char in set
+ strb w15, [sp, x5] // register previous char
+ cbz w4, 1f // NUL encountered?
+
+ ldrb w5, [x1, #1]
+ add x1, x1, #2
+ strb w15, [sp, x4]
+ cbnz w5, 0b
+
+1: mov x5, x0 // stash a copy of src
+
+ /* find mismatch */
+ .p2align 4
+0: ldrb w8, [x0]
+ ldrb w9, [sp, x8]
+ cbz w9, 2f
+
+ ldrb w8, [x0, #1]
+ ldrb w9, [sp, x8]
+ cbz w9, 3f
+
+ ldrb w8, [x0, #2]
+ ldrb w9, [sp, x8]
+ cbz w9, 4f
+
+ ldrb w8, [x0, #3]
+ add x0, x0, #4
+ ldrb w9, [sp, x8]
+ cbnz w9, 0b
+
+ sub x0, x0, #3
+4: sub x5, x5, #1
+3: add x0, x0, #1
+2: sub x0, x0, x5
+ mov sp, x29
+ ldp x29, x30, [sp], #16
+ ret
+
+.Lzero:
+ mov x0, #0
+ ret
+
+.Lsingle:
+ ldrb w8, [x0, x5]
+ cmp w4, w8
+ b.ne 1f
+
+ add x5, x5, #1
+ ldrb w8, [x0, x5]
+ cmp w4, w8
+ b.ne 1f
+
+ add x5, x5, #1
+ ldrb w8, [x0, x5]
+ cmp w4, w8
+ b.ne 1f
+
+ add x5, x5, #1
+ ldrb w8, [x0, x5]
+ add x5, x5, #1
+ cmp w4, w8
+ b.eq .Lsingle
+
+ sub x5, x5, #1
+1: mov x0, x5
+ ret
+
+END(__strspn)
diff --git a/lib/libc/aarch64/string/timingsafe_bcmp.S b/lib/libc/aarch64/string/timingsafe_bcmp.S
new file mode 100644
index 000000000000..baa5c6f0940c
--- /dev/null
+++ b/lib/libc/aarch64/string/timingsafe_bcmp.S
@@ -0,0 +1,113 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Robert Clausecker
+ */
+
+#include <machine/asm.h>
+
+ENTRY(timingsafe_bcmp)
+ cmp x2, #32 // at least 33 bytes to process?
+ bhi .Lgt32
+
+ cmp x2, #16 // at least 17 bytes to process?
+ bhi .L1732
+
+ cmp x2, #8 // at least 9 bytes to process?
+ bhi .L0916
+
+ cmp x2, #4 // at least 5 bytes to process?
+ bhi .L0508
+
+ cmp x2, #2 // at least 3 bytes to process?
+ bhi .L0304
+
+ cbnz x2, .L0102 // buffer empty?
+
+ mov w0, #0 // empty buffer always matches
+ ret
+
+.L0102: ldrb w3, [x0] // load first bytes
+ ldrb w4, [x1]
+ sub x2, x2, #1
+ ldrb w5, [x0, x2] // load last bytes
+ ldrb w6, [x1, x2]
+ eor w3, w3, w4
+ eor w5, w5, w6
+ orr w0, w3, w5
+ ret
+
+.L0304: ldrh w3, [x0] // load first halfwords
+ ldrh w4, [x1]
+ sub x2, x2, #2
+ ldrh w5, [x0, x2] // load last halfwords
+ ldrh w6, [x1, x2]
+ eor w3, w3, w4
+ eor w5, w5, w6
+ orr w0, w3, w5
+ ret
+
+.L0508: ldr w3, [x0] // load first words
+ ldr w4, [x1]
+ sub x2, x2, #4
+ ldr w5, [x0, x2] // load last words
+ ldr w6, [x1, x2]
+ eor w3, w3, w4
+ eor w5, w5, w6
+ orr w0, w3, w5
+ ret
+
+.L0916: ldr x3, [x0]
+ ldr x4, [x1]
+ sub x2, x2, #8
+ ldr x5, [x0, x2]
+ ldr x6, [x1, x2]
+ eor x3, x3, x4
+ eor x5, x5, x6
+ orr x0, x3, x5
+ orr x0, x0, x0, lsr #32 // ensure low 32 bits are nonzero iff mismatch
+ ret
+
+.L1732: ldr q0, [x0]
+ ldr q1, [x1]
+ sub x2, x2, #16
+ ldr q2, [x0, x2]
+ ldr q3, [x1, x2]
+ eor v0.16b, v0.16b, v1.16b
+ eor v2.16b, v2.16b, v3.16b
+ orr v0.16b, v0.16b, v2.16b
+ umaxv s0, v0.4s // get a nonzero word if any
+ mov w0, v0.s[0]
+ ret
+
+ /* more than 32 bytes: process buffer in a loop */
+.Lgt32: ldp q0, q1, [x0], #32
+ ldp q2, q3, [x1], #32
+ eor v0.16b, v0.16b, v2.16b
+ eor v1.16b, v1.16b, v3.16b
+ orr v4.16b, v0.16b, v1.16b
+ subs x2, x2, #64 // enough left for another iteration?
+ bls .Ltail
+
+0: ldp q0, q1, [x0], #32
+ ldp q2, q3, [x1], #32
+ eor v0.16b, v0.16b, v2.16b
+ eor v1.16b, v1.16b, v3.16b
+ orr v0.16b, v0.16b, v1.16b
+ orr v4.16b, v4.16b, v0.16b
+ subs x2, x2, #32
+ bhi 0b
+
+ /* process last 32 bytes */
+.Ltail: add x0, x0, x2 // point to the last 32 bytes in the buffer
+ add x1, x1, x2
+ ldp q0, q1, [x0]
+ ldp q2, q3, [x1]
+ eor v0.16b, v0.16b, v2.16b
+ eor v1.16b, v1.16b, v3.16b
+ orr v0.16b, v0.16b, v1.16b
+ orr v4.16b, v4.16b, v0.16b
+ umaxv s0, v4.4s // get a nonzero word if any
+ mov w0, v0.s[0]
+ ret
+END(timingsafe_bcmp)
diff --git a/lib/libc/aarch64/string/timingsafe_memcmp.S b/lib/libc/aarch64/string/timingsafe_memcmp.S
new file mode 100644
index 000000000000..28fdd911a387
--- /dev/null
+++ b/lib/libc/aarch64/string/timingsafe_memcmp.S
@@ -0,0 +1,117 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Robert Clausecker
+ */
+
+#include <machine/asm.h>
+
+ENTRY(timingsafe_memcmp)
+ cmp x2, #16 // at least 17 bytes to process?
+ bhi .Lgt16
+
+ cmp x2, #8 // at least 9 bytes to process?
+ bhi .L0916
+
+ cmp x2, #4 // at least 5 bytes to process?
+ bhi .L0508
+
+ cmp x2, #2 // at least 3 bytes to process?
+ bhi .L0304
+
+ cbnz x2, .L0102 // buffer empty?
+
+ mov w0, #0 // empty buffer always matches
+ ret
+
+.L0102: ldrb w3, [x0] // load first bytes
+ ldrb w4, [x1]
+ sub x2, x2, #1
+ ldrb w5, [x0, x2] // load last bytes
+ ldrb w6, [x1, x2]
+ bfi w5, w3, #8, #8 // join bytes in big endian
+ bfi w6, w4, #8, #8
+ sub w0, w5, w6
+ ret
+
+
+.L0304: ldrh w3, [x0] // load first halfwords
+ ldrh w4, [x1]
+ sub x2, x2, #2
+ ldrh w5, [x0, x2] // load last halfwords
+ ldrh w6, [x1, x2]
+ bfi w3, w5, #16, #16 // join halfwords in little endian
+ bfi w4, w6, #16, #16
+ rev w3, w3 // swap word order
+ rev w4, w4
+ cmp w3, w4
+ csetm w0, lo // w0 = w3 >= w4 ? 0 : -1
+ csinc w0, w0, wzr, ls // w0 = w3 <=> w4 ? 1 : 0 : -1
+ ret
+
+.L0508: ldr w3, [x0] // load first words
+ ldr w4, [x1]
+ sub x2, x2, #4
+ ldr w5, [x0, x2] // load last words
+ ldr w6, [x1, x2]
+ bfi x3, x5, #32, #32 // join words in little endian
+ bfi x4, x6, #32, #32
+ rev x3, x3 // swap word order
+ rev x4, x4
+ cmp x3, x4
+ csetm w0, lo // x0 = x3 >= w4 ? 0 : -1
+ csinc w0, w0, wzr, ls // x0 = x3 <=> w4 ? 1 : 0 : -1
+ ret
+
+.L0916: ldr x3, [x0]
+ ldr x4, [x1]
+ sub x2, x2, #8
+ ldr x5, [x0, x2]
+ ldr x6, [x1, x2]
+ cmp x3, x4 // mismatch in first pair?
+ csel x3, x3, x5, ne // use second pair if first pair equal
+ csel x4, x4, x6, ne
+ rev x3, x3
+ rev x4, x4
+ cmp x3, x4
+ csetm w0, lo
+ csinc w0, w0, wzr, ls
+ ret
+
+ /* more than 16 bytes: process buffer in a loop */
+.Lgt16: ldp x3, x4, [x0], #16
+ ldp x5, x6, [x1], #16
+ cmp x3, x5 // mismatch in first pair?
+ csel x3, x3, x4, ne // use second pair if first pair equal
+ csel x5, x5, x6, ne
+ subs x2, x2, #32
+ bls .Ltail
+
+0: ldp x4, x7, [x0], #16
+ ldp x6, x8, [x1], #16
+ cmp x4, x6 // mismatch in first pair?
+ csel x4, x4, x7, ne // if not, try second pair
+ csel x6, x6, x8, ne
+ cmp x3, x5 // was there a mismatch previously?
+ csel x3, x3, x4, ne // apply new pair if there was not
+ csel x5, x5, x6, ne
+ subs x2, x2, #16
+ bhi 0b
+
+.Ltail: add x0, x0, x2
+ add x1, x1, x2
+ ldp x4, x7, [x0]
+ ldp x6, x8, [x1]
+ cmp x4, x6 // mismatch in first pair?
+ csel x4, x4, x7, ne // if not, try second pair
+ csel x6, x6, x8, ne
+ cmp x3, x5 // was there a mismatch previously?
+ csel x3, x3, x4, ne // apply new pair if there was not
+ csel x5, x5, x6, ne
+ rev x3, x3
+ rev x5, x5
+ cmp x3, x5
+ csetm w0, lo
+ csinc w0, w0, wzr, ls
+ ret
+END(timingsafe_bcmp)
diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc
deleted file mode 100644
index eb8b600208b7..000000000000
--- a/lib/libc/aarch64/sys/Makefile.inc
+++ /dev/null
@@ -1,13 +0,0 @@
-
-MIASM:= ${MIASM:Nfreebsd[467]_*}
-
-SRCS+= __vdso_gettc.c \
- sched_getcpu_gen.c
-
-MDASM= cerror.S \
- syscall.S \
- vfork.S
-
-# Don't generate default code for these syscalls:
-NOASM+= sbrk.o \
- vfork.o
diff --git a/lib/libc/aarch64/sys/__vdso_gettc.c b/lib/libc/aarch64/sys/__vdso_gettc.c
deleted file mode 100644
index 52fba0e08566..000000000000
--- a/lib/libc/aarch64/sys/__vdso_gettc.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * Copyright (c) 2015 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/elf.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <machine/cpufunc.h>
-#include <errno.h>
-#include "libc_private.h"
-
-static inline uint64_t
-cp15_cntvct_get(void)
-{
- uint64_t reg;
-
- __asm __volatile("mrs %0, cntvct_el0" : "=r" (reg));
- return (reg);
-}
-
-static inline uint64_t
-cp15_cntpct_get(void)
-{
- uint64_t reg;
-
- __asm __volatile("mrs %0, cntpct_el0" : "=r" (reg));
- return (reg);
-}
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
-
- if (th->th_algo != VDSO_TH_ALGO_ARM_GENTIM)
- return (ENOSYS);
- __asm __volatile("isb" : : : "memory");
- *tc = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
- return (0);
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
-
- return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
-}
diff --git a/lib/libc/aarch64/sys/cerror.S b/lib/libc/aarch64/sys/cerror.S
deleted file mode 100644
index a83514bc2511..000000000000
--- a/lib/libc/aarch64/sys/cerror.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * Copyright (c) 2014 Andrew Turner
- *
- * 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.
- *
- */
-
-#include <machine/asm.h>
-ENTRY(cerror)
- .hidden cerror
- sub sp, sp, #16
- stp x0, lr, [sp]
- bl _C_LABEL(__error)
- ldp x1, lr, [sp]
- str w1, [x0]
- movn x0, #0
- movn x1, #0
- add sp, sp, #16
- ret
-END(cerror)
diff --git a/lib/libc/aarch64/sys/syscall.S b/lib/libc/aarch64/sys/syscall.S
deleted file mode 100644
index 2c7e207f82f7..000000000000
--- a/lib/libc/aarch64/sys/syscall.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright (c) 2014 The FreeBSD Foundation
- *
- * This software was developed by Andrew Turner under
- * sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <machine/asm.h>
-#include "SYS.h"
-
-RSYSCALL(syscall)
diff --git a/lib/libc/aarch64/sys/vfork.S b/lib/libc/aarch64/sys/vfork.S
deleted file mode 100644
index f9489738a3c7..000000000000
--- a/lib/libc/aarch64/sys/vfork.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * Copyright (c) 2014 Andrew Turner
- *
- * 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.
- *
- */
-
-#include <machine/asm.h>
-#include "SYS.h"
-
-ENTRY(__sys_vfork)
- WEAK_REFERENCE(__sys_vfork, vfork)
- WEAK_REFERENCE(__sys_vfork, _vfork)
- mov x2, lr
- _SYSCALL(vfork)
- b.cs cerror
- sub x1, x1, #1
- and x0, x0, x1
- mov lr, x2
- ret
-END(__sys_vfork)
diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h
deleted file mode 100644
index c2c8ef8a56ef..000000000000
--- a/lib/libc/amd64/SYS.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- *
- * @(#)SYS.h 5.5 (Berkeley) 5/7/91
- */
-
-#include <sys/syscall.h>
-#include <machine/asm.h>
-
-#define RSYSCALL(name) ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); ret; \
- END(__sys_##name)
-
-#define PSEUDO(name) ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); ret; \
- END(__sys_##name)
-
-#define KERNCALL movq %rcx, %r10; syscall
diff --git a/lib/libc/amd64/Symbol.map b/lib/libc/amd64/Symbol.map
index 39a913bd5e84..36f54de24fbd 100644
--- a/lib/libc/amd64/Symbol.map
+++ b/lib/libc/amd64/Symbol.map
@@ -1,20 +1,12 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
.mcount;
- _setjmp;
- _longjmp;
- fabs;
__flt_rounds;
+ brk;
fpgetmask;
fpgetprec;
fpgetround;
@@ -22,32 +14,7 @@ FBSD_1.0 {
fpsetmask;
fpsetprec;
fpsetround;
- __infinity;
- __nan;
- makecontext;
- rfork_thread;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- amd64_get_fsbase;
- amd64_get_gsbase;
- amd64_set_fsbase;
- amd64_set_gsbase;
- brk;
sbrk;
- vfork;
-};
-
-FBSD_1.6 {
- x86_pkru_get_perm;
- x86_pkru_set_perm;
- x86_pkru_protect_range;
- x86_pkru_unprotect_range;
};
/*
@@ -56,15 +23,10 @@ FBSD_1.6 {
*
*/
FBSDprivate_1.0 {
- /* PSEUDO syscalls */
- _getlogin;
-
___longjmp;
- __makecontext;
__longjmp;
__signalcontext;
signalcontext;
__siglongjmp;
_brk;
- _vfork;
};
diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc
index 4869973ca254..aaffcb0481f1 100644
--- a/lib/libc/amd64/gen/Makefile.inc
+++ b/lib/libc/amd64/gen/Makefile.inc
@@ -1,6 +1,4 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
-SRCS+= _setjmp.S rfork_thread.S setjmp.S sigsetjmp.S \
+SRCS+= _setjmp.S setjmp.S sigsetjmp.S \
fabs.S \
infinity.c ldexp.c makecontext.c signalcontext.c \
flt_rounds.c fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \
diff --git a/lib/libc/amd64/gen/_setjmp.S b/lib/libc/amd64/gen/_setjmp.S
index 43af2b68b3f2..93b27de49ea0 100644
--- a/lib/libc/amd64/gen/_setjmp.S
+++ b/lib/libc/amd64/gen/_setjmp.S
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)_setjmp.s 5.1 (Berkeley) 4/23/90"
-#endif /* LIBC_SCCS and not lint */
#include <machine/asm.h>
/*
* C library -- _setjmp, _longjmp
diff --git a/lib/libc/amd64/gen/flt_rounds.c b/lib/libc/amd64/gen/flt_rounds.c
index 018ea029ee3f..cd7e501af5af 100644
--- a/lib/libc/amd64/gen/flt_rounds.c
+++ b/lib/libc/amd64/gen/flt_rounds.c
@@ -3,7 +3,6 @@
* Public domain.
*/
-#include <sys/cdefs.h>
#include <float.h>
static const int map[] = {
diff --git a/lib/libc/amd64/gen/infinity.c b/lib/libc/amd64/gen/infinity.c
index b9db2fc84efa..bc05708abd2b 100644
--- a/lib/libc/amd64/gen/infinity.c
+++ b/lib/libc/amd64/gen/infinity.c
@@ -2,7 +2,6 @@
* infinity.c
*/
-#include <sys/cdefs.h>
#include <math.h>
/* bytes for +Infinity on a 387 */
diff --git a/lib/libc/amd64/gen/makecontext.c b/lib/libc/amd64/gen/makecontext.c
index dcc3b8ab9b45..c5767c9d5d75 100644
--- a/lib/libc/amd64/gen/makecontext.c
+++ b/lib/libc/amd64/gen/makecontext.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ucontext.h>
#include <stdarg.h>
diff --git a/lib/libc/amd64/gen/rfork_thread.S b/lib/libc/amd64/gen/rfork_thread.S
deleted file mode 100644
index a3c64fad7994..000000000000
--- a/lib/libc/amd64/gen/rfork_thread.S
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
- * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.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 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.
- */
-
-#include <machine/asm.h>
-/*
- * With thanks to John Dyson for the original version of this.
- */
-
-#include <SYS.h>
-
-/*
- * %edi %rsi %rdx %rcx
- * rfork_thread(flags, stack_addr, start_fnc, start_arg);
- *
- * flags: Flags to rfork system call. See rfork(2).
- * stack_addr: Top of stack for thread.
- * start_fnc: Address of thread function to call in child.
- * start_arg: Argument to pass to the thread function in child.
- */
-
-ENTRY(rfork_thread)
- pushq %rbx
- pushq %r12
- movq %rdx, %rbx
- movq %rcx, %r12
-
- /*
- * Prepare and execute the thread creation syscall
- */
- movq $SYS_rfork, %rax
- KERNCALL
- jb 2f
-
- /*
- * Check to see if we are in the parent or child
- */
- cmpl $0, %edx
- jnz 1f
- popq %r12
- popq %rbx
- ret
-
- /*
- * If we are in the child (new thread), then
- * set-up the call to the internal subroutine. If it
- * returns, then call __exit.
- */
-1:
- movq %rsi, %rsp
- movq %r12, %rdi
- call *%rbx
- movl %eax, %edi
-
- /*
- * Exit system call
- */
- movq $SYS_exit, %rax
- KERNCALL
-
- /*
- * Branch here if the thread creation fails:
- */
-2:
- popq %r12
- popq %rbx
- jmp HIDENAME(cerror)
-END(rfork_thread)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/gen/setjmp.S b/lib/libc/amd64/gen/setjmp.S
index 6f469c4c08e8..54939f123807 100644
--- a/lib/libc/amd64/gen/setjmp.S
+++ b/lib/libc/amd64/gen/setjmp.S
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)setjmp.s 5.1 (Berkeley) 4/23/90"
-#endif /* LIBC_SCCS and not lint */
#include <machine/asm.h>
/*
* C library -- _setjmp, _longjmp
diff --git a/lib/libc/amd64/gen/signalcontext.c b/lib/libc/amd64/gen/signalcontext.c
index cc1c2523c754..a97dd158542a 100644
--- a/lib/libc/amd64/gen/signalcontext.c
+++ b/lib/libc/amd64/gen/signalcontext.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ucontext.h>
#include <signal.h>
diff --git a/lib/libc/amd64/gen/sigsetjmp.S b/lib/libc/amd64/gen/sigsetjmp.S
index 757280159d82..c4775b1c2bea 100644
--- a/lib/libc/amd64/gen/sigsetjmp.S
+++ b/lib/libc/amd64/gen/sigsetjmp.S
@@ -28,8 +28,6 @@
* 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.
- *
- * @(#)setjmp.s 5.1 (Berkeley) 4/23/90"
*/
#if defined(LIBC_SCCS) && !defined(lint)
diff --git a/lib/libc/amd64/static_tls.h b/lib/libc/amd64/static_tls.h
deleted file mode 100644
index 1ee738b231c7..000000000000
--- a/lib/libc/amd64/static_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_AMD64_STATIC_TLS_H
-#define _LIBC_AMD64_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("movq %%fs:0, %0" : "=r" (tlsbase));
- tlsbase -= offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/amd64/stdlib/Makefile.inc b/lib/libc/amd64/stdlib/Makefile.inc
index 8b9af2b3eab1..568f8eb4afa7 100644
--- a/lib/libc/amd64/stdlib/Makefile.inc
+++ b/lib/libc/amd64/stdlib/Makefile.inc
@@ -1,3 +1 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
MDSRCS+=div.S ldiv.S lldiv.S
diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc
index 4df4ff8f1417..d5bb646c5c53 100644
--- a/lib/libc/amd64/string/Makefile.inc
+++ b/lib/libc/amd64/string/Makefile.inc
@@ -1,14 +1,36 @@
-
MDSRCS+= \
amd64_archlevel.c \
bcmp.S \
+ memchr.S \
memcmp.S \
+ memccpy.S \
memcpy.S \
memmove.S \
+ memrchr.S \
memset.S \
stpcpy.S \
+ stpncpy.S \
strcat.S \
strchrnul.S \
strcmp.S \
+ strcpy.c \
+ strcspn.S \
+ strlcat.c \
+ strlcpy.S \
strlen.S \
- strcpy.c
+ strncat.c \
+ strncmp.S \
+ strncpy.c \
+ strnlen.c \
+ strpbrk.c \
+ strrchr.S \
+ strsep.c \
+ strspn.S \
+ timingsafe_bcmp.S \
+ timingsafe_memcmp.S
+
+.if ${MK_ASAN} != "no"
+# Disable ASAN for amd64_archlevel.c since its code is executed before the
+# sanitizer runtime can initialize itself.
+CFLAGS.amd64_archlevel.c+= -fno-sanitize=address
+.endif
diff --git a/lib/libc/amd64/string/bcopy.c b/lib/libc/amd64/string/bcopy.c
index 406b28f0b97a..0dee529fb9df 100644
--- a/lib/libc/amd64/string/bcopy.c
+++ b/lib/libc/amd64/string/bcopy.c
@@ -2,9 +2,10 @@
* Public domain.
*/
-#include <sys/cdefs.h>
#include <string.h>
+#undef bcopy /* _FORTIFY_SOURCE */
+
void
bcopy(const void *src, void *dst, size_t len)
{
diff --git a/lib/libc/amd64/string/bzero.c b/lib/libc/amd64/string/bzero.c
index a4fdb74d6bb4..d82f3061865b 100644
--- a/lib/libc/amd64/string/bzero.c
+++ b/lib/libc/amd64/string/bzero.c
@@ -2,9 +2,10 @@
* Public domain.
*/
-#include <sys/cdefs.h>
#include <string.h>
+#undef bzero /* _FORTIFY_SOURCE */
+
void
bzero(void *b, size_t len)
{
diff --git a/lib/libc/amd64/string/memccpy.S b/lib/libc/amd64/string/memccpy.S
new file mode 100644
index 000000000000..69b650fffc33
--- /dev/null
+++ b/lib/libc/amd64/string/memccpy.S
@@ -0,0 +1,260 @@
+/*
+ * Copyright (c) 2023, 2024 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4, 0x90
+
+ .weak memccpy
+ .set memccpy, __memccpy
+ARCHFUNCS(__memccpy)
+ ARCHFUNC(__memccpy, scalar)
+ ARCHFUNC(__memccpy, baseline)
+ENDARCHFUNCS(__memccpy)
+
+ARCHENTRY(__memccpy, scalar)
+ push %rbp # establish stack frame
+ mov %rsp, %rbp
+ push %rax # dummy push for alignment
+ push %rbx
+ push %rdi
+ push %rsi
+
+ mov %rsi, %rdi
+ mov %edx, %esi
+ mov %rcx, %rdx
+ mov %rcx, %rbx
+ call CNAME(__memchr) # ptr = memchr(src, c, len)
+
+ pop %rsi
+ pop %rdi
+ lea 1(%rax), %rdx
+ sub %rsi, %rdx # size = ptr - src + 1
+ mov %rbx, %rcx
+ lea (%rdi, %rdx, 1), %rbx # res = dest + size
+ test %rax, %rax # if (ptr == NULL)
+ cmovz %rcx, %rdx # size = len
+ cmovz %rax, %rbx # res = NULL
+ call CNAME(memcpy)
+
+ mov %rbx, %rax # return (res)
+ pop %rbx
+ leave
+ ret
+ARCHEND(__memccpy, scalar)
+
+ARCHENTRY(__memccpy, baseline)
+ sub $1, %rcx # RCX refers to last character in buffer
+ jb .L0 # go to special code path if len was 0
+
+ movd %edx, %xmm4
+ mov %rcx, %rdx
+ punpcklbw %xmm4, %xmm4 # c -> cc
+ mov %esi, %ecx
+ punpcklwd %xmm4, %xmm4 # cc -> cccc
+ mov %rsi, %r9 # stash a copy of the source pointer for later
+ pshufd $0, %xmm4, %xmm4 # cccc -> cccccccccccccccc
+ and $~0xf, %rsi
+ movdqa %xmm4, %xmm1
+ pcmpeqb (%rsi), %xmm1 # c found in head?
+ and $0xf, %ecx
+ mov $-1, %eax
+ pmovmskb %xmm1, %r8d
+ lea -32(%rcx), %r11
+ shl %cl, %eax # mask of bytes in the string
+ add %rdx, %r11 # distance from alignment boundary - 32
+ jnc .Lrunt # jump if buffer length is 32 or less
+
+ and %r8d, %eax
+ jz 0f # match (or induced match) found?
+
+ /* match in first chunk */
+ tzcnt %eax, %edx # where is c?
+ sub %ecx, %edx # ... from the beginning of the string?
+ lea 1(%rdi, %rdx, 1), %rax # return value
+ jmp .L0116
+
+0: movdqa 16(%rsi), %xmm3 # load second string chunk
+ movdqu (%r9), %xmm2 # load unaligned string head
+ movdqa %xmm4, %xmm1
+ pcmpeqb %xmm3, %xmm1 # c found in second chunk?
+
+ /* process second chunk */
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jz 0f
+
+ /* match in second chunk */
+ tzcnt %eax, %edx # where is c?
+ sub $16, %ecx
+ sub %ecx, %edx # adjust for alignment offset
+ lea 1(%rdi, %rdx, 1), %rax # return value
+ jmp .L0132
+
+ /* c not found in second chunk: prepare for main loop */
+0: movdqa 32(%rsi), %xmm0 # load next string chunk
+ movdqa %xmm4, %xmm1
+ movdqu %xmm2, (%rdi) # deposit head into buffer
+ sub %rcx, %rdi # adjust RDI to correspond to RSI
+ mov %r11, %rdx
+ movdqu %xmm3, 16(%rdi) # deposit second chunk
+ sub %rsi, %rdi # express RDI as distance from RSI
+ add $32, %rsi # advance RSI past first two chunks
+ sub $16, %rdx # enough left for another round?
+ jb 1f
+
+ /* main loop unrolled twice */
+ ALIGN_TEXT
+0: pcmpeqb %xmm0, %xmm1 # c encountered?
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz 3f
+
+ movdqu %xmm0, (%rsi, %rdi)
+ movdqa 16(%rsi), %xmm0 # load next string chunk
+ movdqa %xmm4, %xmm1
+ cmp $16, %rdx # more than a full chunk left?
+ jb 2f
+
+ add $32, %rsi # advance pointers to next chunk
+ pcmpeqb %xmm0, %xmm1 # c encountered?
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz 4f
+
+ movdqu %xmm0, -16(%rsi, %rdi)
+ movdqa (%rsi), %xmm0 # load next string chunk
+ movdqa %xmm4, %xmm1
+ sub $32, %rdx
+ jae 0b
+
+1: sub $16, %rsi # undo second advancement
+ add $16, %edx
+
+ /* 1--16 bytes left in the buffer but string has not ended yet */
+2: pcmpeqb %xmm1, %xmm0 # c encountered?
+ pmovmskb %xmm0, %r8d
+ mov %r8d, %ecx
+ bts %edx, %r8d # treat end of buffer as end of string
+ tzcnt %r8d, %r8d # find tail length
+ add %rsi, %rdi # restore RDI
+ movdqu 1(%rsi, %r8, 1), %xmm0 # load string tail
+ movdqu %xmm0, 1(%rdi, %r8, 1) # store string tail
+ lea 17(%rdi, %r8, 1), %rsi # return value if terminator encountered
+ xor %eax, %eax # return value if no terminator encountered
+ bt %r8d, %ecx # terminator encountered inside buffer?
+ cmovc %rsi, %rax # if yes, return pointer, else NULL
+ ret
+
+4: sub $16, %rsi # undo second advancement
+
+ /* terminator found and buffer has not ended yet */
+3: tzcnt %eax, %eax # find length of string tail
+ movdqu -15(%rsi, %rax, 1), %xmm0 # load string tail (incl. c)
+ add %rsi, %rdi # restore destination pointer
+ movdqu %xmm0, -15(%rdi, %rax, 1) # store string tail (incl. c)
+ lea 1(%rdi, %rax, 1), %rax # compute return value
+ ret
+
+ /* buffer is 1--32 bytes in size */
+ ALIGN_TEXT
+.Lrunt: add $32, %r11d # undo earlier decrement
+ mov %r8d, %r10d # keep a copy of the original match mask
+ bts %r11d, %r8d # induce match at buffer end
+ and %ax, %r8w # is there a match in the first 16 bytes?
+ jnz 0f # if yes, skip looking at second chunk
+
+ pcmpeqb 16(%rsi), %xmm4 # check for match in second chunk
+ pmovmskb %xmm4, %r8d
+ shl $16, %r8d # place second chunk matches in bits 16--31
+ mov %r8d, %r10d # keep a copy of the original match mask
+ bts %r11d, %r8d # induce a match at buffer end
+
+0: xor %eax, %eax # return value if terminator not found
+ tzcnt %r8d, %edx # find string/buffer length from alignment boundary
+ lea 1(%rdi, %rdx, 1), %r8 # return value if terminator found + rcx
+ sub %rcx, %r8
+ bt %edx, %r10d # was the terminator present?
+ cmovc %r8, %rax # if yes, return pointer, else NULL
+ sub %ecx, %edx # find actual string/buffer length
+
+ ALIGN_TEXT
+.L0132: cmp $16, %rdx # at least 17 bytes to copy?
+ jb .L0116
+
+ /* copy 17--32 bytes */
+ movdqu (%r9), %xmm0 # load first 16 bytes
+ movdqu -15(%r9, %rdx, 1), %xmm1 # load last 16 bytes
+ movdqu %xmm0, (%rdi)
+ movdqu %xmm1, -15(%rdi, %rdx, 1)
+ ret
+
+ /* process strings of 1--16 bytes (rdx: min(buflen, srclen), rax: srclen) */
+ ALIGN_TEXT
+.L0116: cmp $8, %rdx # at least 9 bytes to copy?
+ jae .L0916
+
+ cmp $4, %rdx # at least 5 bytes to copy?
+ jae .L0508
+
+ cmp $2, %rdx # at least 3 bytes to copy?
+ jae .L0304
+
+ /* copy one or two bytes */
+ movzbl (%r9), %ecx # load first byte from src
+ movzbl (%r9, %rdx, 1), %esi # load last byte from src
+ mov %cl, (%rdi) # deposit into destination
+ mov %sil, (%rdi, %rdx, 1)
+ ret
+
+.L0304: movzwl (%r9), %ecx
+ movzwl -1(%r9, %rdx, 1), %esi
+ mov %cx, (%rdi)
+ mov %si, -1(%rdi, %rdx, 1)
+ ret
+
+.L0508: mov (%r9), %ecx
+ mov -3(%r9, %rdx, 1), %esi
+ mov %ecx, (%rdi)
+ mov %esi, -3(%rdi, %rdx, 1)
+ ret
+
+.L0916: mov (%r9), %rcx
+ mov -7(%r9, %rdx, 1), %rsi
+ mov %rcx, (%rdi)
+ mov %rsi, -7(%rdi, %rdx, 1)
+ ret
+
+ /* length zero destination: return null pointer */
+.L0: xor %eax, %eax
+ ret
+ARCHEND(__memccpy, baseline)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/memchr.S b/lib/libc/amd64/string/memchr.S
new file mode 100644
index 000000000000..cfab9b1302de
--- /dev/null
+++ b/lib/libc/amd64/string/memchr.S
@@ -0,0 +1,207 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+ .weak memchr
+ .set memchr, __memchr
+ARCHFUNCS(__memchr)
+ ARCHFUNC(__memchr, scalar)
+ ARCHFUNC(__memchr, baseline)
+ENDARCHFUNCS(__memchr)
+
+ARCHENTRY(__memchr, scalar)
+ test %rdx, %rdx # empty input?
+ je .Lnomatch
+
+ lea (, %rdi, 8), %ecx
+ mov $-1, %rax
+ add %rdi, %rdx # pointer to end of buffer or to end of
+ cmovc %rax, %rdx # address space (whichever comes first)
+ and $~7, %rdi # align to 8 bytes
+ mov (%rdi), %rax # load first word
+ movzbl %sil, %esi # clear stray high bits
+ movabs $0x0101010101010101, %r8
+ imul %r8, %rsi # replicate char 8 times
+
+ /* compute head and tail masks */
+ mov %r8, %r10
+ movabs $0x8080808080808080, %r9
+ shl %cl, %r10 # 0x01 where string head is
+ lea (, %rdx, 8), %ecx
+ xor %r8, %r10 # 0x01 where it is not
+ neg %r8 # negate 01..01 so we can use lea
+ mov %r9, %r11
+ xor %rsi, %rax # str ^ c (0x00 where str[i] == c)
+ neg %ecx
+ or %r10, %rax # except before the string
+ shr %cl, %r11 # 0x80 where string tail is
+
+ add $8, %rdi # advance to next 8 bytes
+ cmp %rdx, %rdi # end of buffer reached during head?
+ jae .Ltail # and go to tail-processing code
+
+ /* main loop, unrolled twice */
+ ALIGN_TEXT
+0: lea (%rax, %r8, 1), %rcx # (str ^ c) - 0x01..01
+ not %rax # ~(str ^ c)
+ and %r9, %rax # ((str^c) - 0x01..01) & ~(str^c)
+ and %rcx, %rax # not including junk bytes
+ jnz .Lmatch
+
+ mov (%rdi), %rax
+ add $8, %rdi
+ xor %rsi, %rax # str ^ c
+ cmp %rdx, %rdi
+ jae .Ltail
+
+ lea (%rax, %r8, 1), %rcx # (str ^ c) - 0x01..01
+ not %rax # ~(str ^ c)
+ and %r9, %rax # ((str^c) - 0x01..01) & ~(str^c)
+ and %rcx, %rax # not including junk bytes
+ jnz .Lmatch
+
+ mov (%rdi), %rax
+ add $8, %rdi
+ xor %rsi, %rax # str ^ c
+ cmp %rdx, %rdi
+ jb 0b
+
+.Ltail: lea (%rax, %r8, 1), %rcx # (str ^ c) - 0x01..01
+ not %rax # ~(str ^ c)
+ and %r11, %rax # ((str^c) - 0x01..01) & ~(str^c)
+ and %rcx, %rax # not including junk bytes or bytes past buffer
+ jz .Lnomatch
+
+.Lmatch:
+ tzcnt %rax, %rax # first match
+ shr $3, %eax # scale from bit to byte index
+ lea -8(%rdi, %rax), %rax # pointer to found c
+ ret
+
+ /* no match found */
+.Lnomatch:
+ xor %eax, %eax # return null pointer
+ ret
+ARCHEND(__memchr, scalar)
+
+ARCHENTRY(__memchr, baseline)
+ test %rdx, %rdx # empty input?
+ je .Lnomatchb
+
+ movd %esi, %xmm2
+ mov %edi, %ecx
+ mov $-1, %r9
+ add %rdi, %rdx # pointer to end of buffer or to end of
+ cmovc %r9, %rdx # address space (whichever comes first)
+ and $~0x1f, %rdi # align to 32 bytes
+ movdqa (%rdi), %xmm0 # load first 32 bytes
+ movdqa 16(%rdi), %xmm1
+
+ punpcklbw %xmm2, %xmm2 # c -> cc
+
+ shl %cl, %r9d # mask with zeroes before the string
+
+ punpcklwd %xmm2, %xmm2 # cc -> cccc
+
+ mov $-1, %r8d
+ xor %ecx, %ecx
+ sub %edx, %ecx # edx = -ecx
+ shr %cl, %r8d # bytes in tail that are part of the buffer
+
+ pshufd $0, %xmm2, %xmm2 # cccc -> cccccccccccccccc
+
+ add $32, %rdi # advance to next 32 bytes
+ mov $-1, %eax
+ cmp %rdx, %rdi # end of buffer reached during head?
+ cmovae %r8d, %eax # if yes, do combined head/tail processing
+ and %r9d, %eax # mask of bytes in head part of string
+
+ /* process head */
+ pcmpeqb %xmm2, %xmm1
+ pcmpeqb %xmm2, %xmm0
+ pmovmskb %xmm1, %esi
+ pmovmskb %xmm0, %ecx
+ shl $16, %esi
+ or %esi, %ecx # locations of matches
+ and %ecx, %eax # any match inside buffer?
+ jnz .Lprecisematchb
+
+ cmp %rdx, %rdi # did the buffer end here?
+ jae .Lnomatchb # if yes we are done
+
+ /* main loop */
+ ALIGN_TEXT
+0: movdqa (%rdi), %xmm0 # load next string chunk
+ movdqa 16(%rdi), %xmm1
+ add $32, %rdi
+ cmp %rdx, %rdi # ready for main loop?
+ jae .Ltailb
+
+ pcmpeqb %xmm2, %xmm0
+ pcmpeqb %xmm2, %xmm1
+ por %xmm1, %xmm0 # match in either half?
+ pmovmskb %xmm0, %eax
+ test %eax, %eax
+ jz 0b
+
+.Lmatchb:
+ pcmpeqb -32(%rdi), %xmm2 # redo comparison of first 16 bytes
+ pmovmskb %xmm1, %ecx
+ pmovmskb %xmm2, %eax
+ shl $16, %ecx
+ or %ecx, %eax # location of matches
+
+.Lprecisematchb:
+ tzcnt %eax, %eax # find location of match
+ lea -32(%rdi, %rax, 1), %rax # point to matching byte
+ ret
+
+.Ltailb:
+ pcmpeqb %xmm2, %xmm1
+ pcmpeqb %xmm2, %xmm0
+ pmovmskb %xmm1, %edx
+ pmovmskb %xmm0, %eax
+ shl $16, %edx
+ or %edx, %eax # location of matches
+ and %r8d, %eax # mask out matches beyond buffer
+ bsf %eax, %edx # location of match
+ lea -32(%rdi, %rdx, 1), %rdx # pointer to match (if any)
+ cmovnz %rdx, %rax # point to match if present,
+ ret # else null pointer
+
+.Lnomatchb:
+ xor %eax, %eax # return null pointer
+ ret
+ARCHEND(__memchr, baseline)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/memcmp.S b/lib/libc/amd64/string/memcmp.S
index d192229677b3..dc8bcff73cb9 100644
--- a/lib/libc/amd64/string/memcmp.S
+++ b/lib/libc/amd64/string/memcmp.S
@@ -328,13 +328,28 @@ ARCHENTRY(memcmp, baseline)
movdqu 16(%rsi, %rdi, 1), %xmm1
pcmpeqb 16(%rdi), %xmm1 # compare second half of this iteration
add %rcx, %rdx # pointer to last byte in buffer
- pcmpeqb %xmm2, %xmm0
+ jc .Loverflow # did this overflow?
+0: pcmpeqb %xmm2, %xmm0
pmovmskb %xmm0, %eax
xor $0xffff, %eax # any mismatch?
jne .Lmismatch_head
add $64, %rdi # advance to next iteration
jmp 1f # and get going with the loop
+ /*
+ * If we got here, a buffer length was passed to memcmp(a, b, len)
+ * such that a + len < a. While this sort of usage is illegal,
+ * it is plausible that a caller tries to do something like
+ * memcmp(a, b, SIZE_MAX) if a and b are known to differ, intending
+ * for memcmp() to stop comparing at the first mismatch. This
+ * behaviour is not guaranteed by any version of ISO/IEC 9899,
+ * but usually works out in practice. Let's try to make this
+ * case work by comparing until the end of the address space.
+ */
+.Loverflow:
+ mov $-1, %rdx # compare until the end of memory
+ jmp 0b
+
/* process buffer 32 bytes at a time */
ALIGN_TEXT
0: movdqu -32(%rsi, %rdi, 1), %xmm0
diff --git a/lib/libc/amd64/string/memrchr.S b/lib/libc/amd64/string/memrchr.S
new file mode 100644
index 000000000000..4f6c5a238daa
--- /dev/null
+++ b/lib/libc/amd64/string/memrchr.S
@@ -0,0 +1,166 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Robert Clausecker
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4, 0x90
+
+ARCHFUNCS(memrchr)
+ ARCHFUNC(memrchr, scalar)
+ ARCHFUNC(memrchr, baseline)
+ENDARCHFUNCS(memrchr)
+
+ARCHENTRY(memrchr, scalar)
+ xor %eax, %eax # prospective return value
+ sub $4, %rdx # 4 bytes left to process?
+ jb 1f
+
+ ALIGN_TEXT
+0: xor %r8, %r8
+ lea 2(%rdi), %r10
+ cmp %sil, 2(%rdi)
+ cmovne %r8, %r10 # point to null if no match
+
+ cmp %sil, (%rdi)
+ cmove %rdi, %r8 # point to first char if match
+
+ lea 1(%rdi), %r9
+ cmp %sil, 1(%rdi)
+ cmovne %r8, %r9 # point to first result if no match in second
+
+ lea 3(%rdi), %r11
+ cmp %sil, 3(%rdi)
+ cmovne %r10, %r11
+
+ test %r11, %r11
+ cmovz %r9, %r11 # take first pair match if none in second
+
+ test %r11, %r11
+ cmovnz %r11, %rax # take match in current set if any
+
+ add $4, %rdi
+ sub $4, %rdx
+ jae 0b
+
+1: cmp $-3, %edx # a least one character left to process?
+ jb 2f
+
+ cmp %sil, (%rdi)
+ cmove %rdi, %rax
+
+ lea 1(%rdi), %rcx
+ cmp $-2, %edx # at least two characters left to process?
+ jb 2f
+
+ cmp %sil, 1(%rdi)
+ cmove %rcx, %rax
+
+ lea 2(%rdi), %rcx
+ cmp $-1, %edx # at least three character left to process?
+ jb 2f
+
+ cmp %sil, 2(%rdi)
+ cmove %rcx, %rax
+
+2: ret
+ARCHEND(memrchr, scalar)
+
+ARCHENTRY(memrchr, baseline)
+ movd %esi, %xmm4
+ test %rdx, %rdx # empty buffer?
+ jz .L0 # if yes, return immediately
+
+ punpcklbw %xmm4, %xmm4 # c -> cc
+ mov %edi, %ecx
+ punpcklwd %xmm4, %xmm4 # cc -> cccc
+ and $~0xf, %rdi # align source pointer
+ pshufd $0, %xmm4, %xmm4 # cccc -> cccccccccccccccc
+ and $0xf, %ecx
+ movdqa %xmm4, %xmm0
+ mov $-1, %r8d
+ pcmpeqb (%rdi), %xmm0 # compare aligned head
+ shl %cl, %r8d # mask of bytes in the head of the buffer
+ pmovmskb %xmm0, %eax
+
+ sub $16, %rcx
+ and %r8d, %eax # match mask
+ add %rcx, %rdx # advance past head
+ cmc
+ jbe .Lrunt # did the string end in the buffer?
+
+ mov %rdi, %rsi # pointer to matching chunk
+ add $16, %rdi
+ sub $16, %rdx # enough left for another round?
+ jbe 1f
+
+ /* main loop unrolled twice */
+ ALIGN_TEXT
+0: movdqa %xmm4, %xmm0
+ pcmpeqb (%rdi), %xmm0
+ pmovmskb %xmm0, %r8d
+
+ cmp $16, %rdx # enough left for second chunk?
+ jbe 2f
+
+ movdqa %xmm4, %xmm0
+ pcmpeqb 16(%rdi), %xmm0
+ pmovmskb %xmm0, %ecx
+
+ lea 16(%rdi), %r9
+ test %ecx, %ecx # match found in second chunk?
+ cmovz %r8d, %ecx # if not, use match data from first chunk
+ cmovz %rdi, %r9
+
+ test %ecx, %ecx # any match found?
+ cmovnz %ecx, %eax # if yes, overwrite previously found match
+ cmovnz %r9, %rsi
+
+ add $32, %rdi # advance to next iteration
+ sub $32, %rdx # advance to next chunks
+ ja 0b
+
+ /* process remaining 1--16 bytes */
+1: pcmpeqb (%rdi), %xmm4
+ mov $0xffff, %r8d
+ xor %ecx, %ecx
+ sub %edx, %ecx # number of bytes to be masked out
+ pmovmskb %xmm4, %r9d
+ shr %cl, %r8d # mask of bytes to be kept in the buffer
+ and %r9d, %r8d
+ cmovnz %r8d, %eax
+ cmovnz %rdi, %rsi
+ bsr %eax, %eax
+ lea (%rsi, %rax, 1), %rsi # pointer to match (or junk)
+ cmovnz %rsi, %rax # if any match was found, return it
+ ret
+
+ /* end of chunk reached within first half iteration */
+2: test %r8d, %r8d # match in previous chunk?
+ cmovnz %r8d, %eax # if yes, overwrite previous chunks
+ cmovnz %rdi, %rsi
+ add $16, %rdi # point to tail
+ sub $16, %edx
+ jmp 1b # handle tail the same otherwise
+
+ /* runt: string ends within head, edx has negated amount of invalid head bytes */
+.Lrunt: mov $0xffff, %r8d
+ xor %ecx, %ecx
+ sub %edx, %ecx
+ shr %cl, %r8d
+ and %r8d, %eax
+ bsr %eax, %eax
+ lea (%rdi, %rax, 1), %rdi
+ cmovnz %rdi, %rax
+ ret
+
+ /* empty buffer: return a null pointer */
+.L0: xor %eax, %eax
+ ret
+ARCHEND(memrchr, baseline)
+
+ .section .note.GNU-stack, "", %progbits
diff --git a/lib/libc/amd64/string/stpncpy.S b/lib/libc/amd64/string/stpncpy.S
new file mode 100644
index 000000000000..5ce0dd093a9e
--- /dev/null
+++ b/lib/libc/amd64/string/stpncpy.S
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4, 0x90
+
+ .weak stpncpy
+ .set stpncpy, __stpncpy
+ARCHFUNCS(__stpncpy)
+ ARCHFUNC(__stpncpy, scalar)
+ ARCHFUNC(__stpncpy, baseline)
+ENDARCHFUNCS(__stpncpy)
+
+ARCHENTRY(__stpncpy, scalar)
+ push %rbp # establish stack frame
+ mov %rsp, %rbp
+
+ push %rdx
+ push %rdi
+ push %rsi
+ push %rax # dummy push for alignment
+
+ mov %rsi, %rdi
+ xor %esi, %esi
+ call CNAME(__memchr) # memchr(src, '\0', len)
+ pop %rcx # dummy pop
+ pop %rsi
+ mov -16(%rbp), %rdi
+
+ test %rax, %rax # NUL found?
+ jz .Lfullcopy
+
+ mov %rax, %rdx
+ sub %rsi, %rdx # copy until the NUL byte
+ add %rdx, -16(%rbp) # advance destination by string length
+ sub %rdx, -8(%rbp) # and shorten buffer size by string length
+ call CNAME(memcpy)
+
+ pop %rdi
+ pop %rdx
+ xor %esi, %esi
+ pop %rbp
+ jmp CNAME(memset) # clear remaining buffer
+
+.Lfullcopy:
+ mov -8(%rbp), %rdx
+ call CNAME(memcpy) # copy whole string
+ add -8(%rbp), %rax # point to dest[n]
+ leave
+ ret
+ARCHEND(__stpncpy, scalar)
+
+ /*
+ * this mask allows us to generate masks of 16-n 0xff bytes
+ * followed by n 0x00 bytes by loading from .Lmask+n.
+ */
+ .section .rodata
+.Lmask: .quad 0xffffffffffffffff
+ .quad 0xffffffffffffffff
+ .quad 0x0000000000000000
+ .quad 0x0000000000000000
+
+/* stpncpy(char *restrict rdi, const char *rsi, size_t rdx) */
+ARCHENTRY(__stpncpy, baseline)
+#define bounce (-3*16-8) /* location of on-stack bounce buffer */
+
+ test %rdx, %rdx # no bytes to copy?
+ jz .L0
+
+ mov %esi, %ecx
+ and $~0xf, %rsi # align source to 16 bytes
+ movdqa (%rsi), %xmm0 # load head
+ and $0xf, %ecx # offset from alignment
+ mov $-1, %r9d
+ lea -32(%rcx), %rax # set up overflow-proof comparison rdx+rcx<=32
+ shl %cl, %r9d # mask of bytes belonging to the string
+ sub %rcx, %rdi # adjust RDI to correspond to RSI
+ pxor %xmm1, %xmm1
+ movdqa %xmm0, bounce(%rsp) # stash copy of head on the stack
+ pcmpeqb %xmm1, %xmm0
+ pmovmskb %xmm0, %r8d
+
+ lea (%rdx, %rcx, 1), %r10 # buffer length from alignment boundary
+ add %rdx, %rax # less than 2 chunks (32 bytes) to play with?
+ jnc .Lrunt # if yes, use special runt processing
+
+ movdqu %xmm1, -16(%rdi, %r10, 1) # clear final bytes of destination
+ and %r9d, %r8d # end of string within head?
+ jnz .Lheadnul
+
+ movdqu (%rsi, %rcx, 1), %xmm2 # load head from source buffer
+ movdqu %xmm2, (%rdi, %rcx, 1) # an deposit
+
+ add $16, %rsi
+ add $16, %rdi
+ sub $32, %r10
+
+ /* main loop unrolled twice */
+ ALIGN_TEXT
+0: movdqa (%rsi), %xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm0, %xmm1 # NUL byte encountered?
+ pmovmskb %xmm1, %r8d
+ test %r8d, %r8d
+ jnz 3f
+
+ movdqu %xmm0, (%rdi)
+ cmp $16, %r10 # more than a full chunk left?
+ jbe 1f
+
+ movdqa 16(%rsi), %xmm0
+ add $32, %rdi # advance pointers to next chunk
+ add $32, %rsi
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm0, %xmm1 # NUL byte encountered?
+ pmovmskb %xmm1, %r8d
+ test %r8d, %r8d
+ jnz 2f
+
+ movdqu %xmm0, -16(%rdi)
+ sub $32, %r10 # more than another full chunk left?
+ ja 0b
+
+ sub $16, %rdi # undo second advancement
+ sub $16, %rsi
+ add $16, %r10d # restore number of remaining bytes
+
+ /* 1--16 bytes left but string has not ended yet */
+1: pxor %xmm1, %xmm1
+ pcmpeqb 16(%rsi), %xmm1 # NUL byte in source tail?
+ pmovmskb %xmm1, %r8d
+ bts %r10d, %r8d # treat end of buffer as NUL
+ tzcnt %r8d, %r8d # where is the NUL byte?
+ movdqu (%rsi, %r8, 1), %xmm0 # load source tail before NUL
+ lea 16(%rdi, %r8, 1), %rax # point return value to NUL byte
+ # or end of buffer
+ movdqu %xmm0, (%rdi, %r8, 1) # store tail into the buffer
+ ret
+
+2: sub $16, %rdi # undo second advancement
+ sub $16, %rsi
+ sub $16, %r10
+
+ /* string has ended and buffer has not */
+3: tzcnt %r8d, %r8d # where did the string end?
+ lea .Lmask+16(%rip), %rcx
+ lea (%rdi, %r8, 1), %rax # where the NUL byte will be
+ neg %r8
+ movdqu (%rcx, %r8, 1), %xmm1 # mask with FF where the string is,
+ # 00 where it is not
+ pand %xmm1, %xmm0 # mask out bytes after the string
+ movdqu %xmm0, (%rdi) # store masked current chunk
+ pxor %xmm1, %xmm1
+ sub $16, %r10 # another full chunk left?
+ jbe 1f
+
+ /* clear remaining destination buffer (tail has been cleared earlier) */
+ ALIGN_TEXT
+0: movdqu %xmm1, 16(%rdi)
+ cmp $16, %r10
+ jbe 1f
+
+ movdqu %xmm1, 32(%rdi)
+ add $32, %rdi
+ sub $32, %r10
+ ja 0b
+
+1: ret
+
+ /* at least two chunks to play with and NUL while processing head */
+.Lheadnul:
+ movdqu bounce(%rsp, %rcx, 1), %xmm0 # load start of source from stack
+ tzcnt %r8d, %r8d # find location of NUL byte
+ movdqu %xmm0, (%rdi, %rcx, 1) # deposit head in the destination
+ movdqu %xmm1, (%rdi, %r8, 1) # clear out following bytes
+ movdqu %xmm1, 16(%rdi) # clear out second chunk
+ lea (%rdi, %r8, 1), %rax # make RAX point to the NUL byte
+
+ add $32, %rdi # advance past first two chunks
+ sub $32+16, %r10 # advance past first three chunks
+ jbe 1f # did we pass the end of the buffer?
+
+ /* clear remaining destination buffer (tail has been cleared earlier) */
+ ALIGN_TEXT
+0: movdqu %xmm1, (%rdi) # clear out buffer chunk
+ cmp $16, %r10
+ jbe 1f
+
+ movdqu %xmm1, 16(%rdi)
+ add $32, %rdi
+ sub $32, %r10
+ ja 0b
+
+1: ret
+
+ /* 1--32 bytes to copy, bounce through the stack */
+.Lrunt: movdqa %xmm1, bounce+16(%rsp) # clear out rest of on-stack copy
+ bts %r10d, %r8d # treat end of buffer as end of string
+ and %r9w, %r8w # end of string within first buffer?
+ jnz 0f # if yes, do not inspect second buffer
+
+ movdqa 16(%rsi), %xmm0 # load second chunk of input
+ movdqa %xmm0, bounce+16(%rsp) # stash copy on stack
+ pcmpeqb %xmm1, %xmm0 # NUL in second chunk?
+ pmovmskb %xmm0, %r9d
+ shl $16, %r9d
+ or %r9d, %r8d # merge found NUL bytes into NUL mask
+
+ /* end of string after one buffer */
+0: tzcnt %r8d, %r8d # location of last char in string
+ movdqu %xmm1, bounce(%rsp, %r8, 1) # clear bytes behind string
+ lea bounce(%rsp, %rcx, 1), %rsi # start of string copy on stack
+ lea (%rdi, %r8, 1), %rax # return pointer to NUL byte
+
+ cmp $16, %edx # at least 16 bytes to transfer?
+ jae .L1631
+
+ mov (%rsi), %r8 # load string head
+ cmp $8, %edx # at least 8 bytes to transfer?
+ jae .L0815
+
+ cmp $4, %edx # at least 4 bytes to transfer?
+ jae .L0407
+
+ movzwl -2(%rsi, %rdx, 1), %esi # load last two bytes of string
+ mov %r8b, (%rdi, %rcx, 1) # store first byte
+
+ cmp $2, %edx # at least 2 bytes to transfer?
+ jb .L1
+
+ mov %si, -2(%rdi, %r10, 1) # store last two bytes of string
+.L1: ret
+
+.L1631: movdqu (%rsi), %xmm0 # load first 16 bytes of string
+ movdqu -16(%rsi, %rdx, 1), %xmm1 # load last 16 bytes of string
+ movdqu %xmm0, (%rdi, %rcx, 1)
+ movdqu %xmm1, -16(%rdi, %r10, 1)
+ ret
+
+.L0815: mov -8(%rsi, %rdx, 1), %rdx # load last 8 bytes of string
+ mov %r8, (%rdi, %rcx, 1)
+ mov %rdx, -8(%rdi, %r10, 1)
+ ret
+
+.L0407: mov -4(%rsi, %rdx, 1), %edx # load last four bytes of string
+ mov %r8d, (%rdi, %rcx, 1)
+ mov %edx, -4(%rdi, %r10, 1)
+ ret
+
+ /* length 0 buffer: just return dest */
+.L0: mov %rdi, %rax
+ ret
+ARCHEND(__stpncpy, baseline)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strcat.S b/lib/libc/amd64/string/strcat.S
index 0834408acfb7..081e98840cee 100644
--- a/lib/libc/amd64/string/strcat.S
+++ b/lib/libc/amd64/string/strcat.S
@@ -1,6 +1,14 @@
-/*
- * Written by J.T. Conklin <jtc@acorntoolworks.com>
- * Public domain.
+/*-
+ * Copyright (c) 2023, The FreeBSD Foundation
+ *
+ * SPDX-License-Expression: BSD-2-Clause
+ *
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * Adapted from NetBSD's common/lib/libc/arch/x86_64/string/strcat.S
+ * written by J.T. Conklin <jtc@acorntoolworks.com>
+ * that was originally dedicated to the public domain
*/
#include <machine/asm.h>
@@ -8,7 +16,14 @@
RCSID("$NetBSD: strcat.S,v 1.4 2004/07/26 18:51:21 drochner Exp $")
#endif
-ENTRY(strcat)
+#include "amd64_archlevel.h"
+
+ARCHFUNCS(strcat)
+ ARCHFUNC(strcat, scalar)
+ ARCHFUNC(strcat, baseline)
+ENDARCHFUNCS(strcat)
+
+ARCHENTRY(strcat, scalar)
movq %rdi,%rax
movabsq $0x0101010101010101,%r8
movabsq $0x8080808080808080,%r9
@@ -161,6 +176,28 @@ ENTRY(strcat)
.Ldone:
ret
-END(strcat)
+ARCHEND(strcat, scalar)
+
+/*
+ * Call into strlen + strcpy if we have any SIMD at all.
+ * The scalar implementation above is better for the scalar
+ * case as it avoids the function call overhead, but pessimal
+ * if we could call SIMD routines instead.
+ */
+ARCHENTRY(strcat, baseline)
+ push %rbp
+ mov %rsp, %rbp
+ push %rsi
+ push %rbx
+ mov %rdi, %rbx # remember destination for later
+ call CNAME(strlen) # strlen(dest)
+ mov -8(%rbp), %rsi
+ lea (%rbx, %rax, 1), %rdi # dest + strlen(dest)
+ call CNAME(__stpcpy) # stpcpy(dest + strlen(dest), src)
+ mov %rbx, %rax # return dest
+ pop %rbx
+ leave
+ ret
+ARCHEND(strcat, baseline)
.section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strcmp.S b/lib/libc/amd64/string/strcmp.S
index 437db7eca43a..eb354bd2af82 100644
--- a/lib/libc/amd64/string/strcmp.S
+++ b/lib/libc/amd64/string/strcmp.S
@@ -1,14 +1,33 @@
-/*
- * Written by J.T. Conklin <jtc@acorntoolworks.com>
- * Public domain.
+/*-
+ * Copyright (c) 2023, The FreeBSD Foundation
+ *
+ * SPDX-License-Expression: BSD-2-Clause
+ *
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * Adapted from NetBSD's common/lib/libc/arch/x86_64/string/strcmp.S
+ * written by J.T. Conklin <jtc@acorntoolworks.com> that was originally
+ * dedicated to the public domain.
*/
#include <machine/asm.h>
+#include <machine/param.h>
+
#if 0
RCSID("$NetBSD: strcmp.S,v 1.3 2004/07/19 20:04:41 drochner Exp $")
#endif
-ENTRY(strcmp)
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4, 0x90
+
+ARCHFUNCS(strcmp)
+ ARCHFUNC(strcmp, scalar)
+ ARCHFUNC(strcmp, baseline)
+ENDARCHFUNCS(strcmp)
+
+ARCHENTRY(strcmp, scalar)
/*
* Align s1 to word boundary.
* Consider unrolling loop?
@@ -39,7 +58,7 @@ ENTRY(strcmp)
movabsq $0x8080808080808080,%r9
subq $8,%rsi
- .align 4
+ ALIGN_TEXT
.Lword_loop:
movq 8(%rdi),%rax
addq $8,%rdi
@@ -53,7 +72,7 @@ ENTRY(strcmp)
testq %r9,%rdx
je .Lword_loop
- .align 4
+ ALIGN_TEXT
.Lbyte_loop:
movb (%rdi),%al
incq %rdi
@@ -69,6 +88,272 @@ ENTRY(strcmp)
movzbq %dl,%rdx
subq %rdx,%rax
ret
-END(strcmp)
+ARCHEND(strcmp, scalar)
+
+ARCHENTRY(strcmp, baseline)
+ /* check if either string crosses a page in the head */
+ lea 15(%rdi), %r8d # end of head
+ lea 15(%rsi), %r9d
+ mov %edi, %eax
+ mov %esi, %edx
+ xor %edi, %r8d # bits that changed between first and last byte
+ xor %esi, %r9d
+ and $~0xf, %rdi # align heads to 16 bytes
+ and $~0xf, %rsi
+ or %r8d, %r9d # in either RSI or RDI
+ and $0xf, %eax # offset from alignment
+ and $0xf, %edx
+ pxor %xmm1, %xmm1
+ test $PAGE_SIZE, %r9d # did the page change?
+ jz 0f # if not, take fast path
+
+ /* heads may cross page boundary, avoid unmapped loads */
+ movdqa (%rdi), %xmm0 # load aligned heads
+ movdqa (%rsi), %xmm2
+ mov $-1, %r8d
+ mov $-1, %r9d
+ mov %eax, %ecx
+ shl %cl, %r8d # string head in XMM0
+ mov %edx, %ecx
+ shl %cl, %r9d # string head in XMM2
+ movdqa %xmm0, -40(%rsp) # stash copies of the heads on the stack
+ movdqa %xmm2, -24(%rsp)
+ pcmpeqb %xmm1, %xmm0
+ pcmpeqb %xmm1, %xmm2
+ pmovmskb %xmm0, %r10d
+ pmovmskb %xmm2, %r11d
+ test %r8d, %r10d # NUL byte present in first string?
+ lea -40(%rsp), %r8
+ cmovz %rdi, %r8
+ test %r9d, %r11d # NUL byte present in second string?
+ lea -24(%rsp), %r9
+ cmovz %rsi, %r9
+ movdqu (%r8, %rax, 1), %xmm0 # load true (or fake) heads
+ movdqu (%r9, %rdx, 1), %xmm4
+ jmp 1f
+
+0: movdqu (%rdi, %rax, 1), %xmm0 # load true heads
+ movdqu (%rsi, %rdx, 1), %xmm4
+1: pxor %xmm2, %xmm2
+ pcmpeqb %xmm0, %xmm2 # NUL byte present?
+ pcmpeqb %xmm0, %xmm4 # which bytes match?
+ pandn %xmm4, %xmm2 # match and not NUL byte?
+ pmovmskb %xmm2, %r9d
+ xor $0xffff, %r9d # mismatch or NUL byte?
+ jnz .Lhead_mismatch
+
+ /* load head and second chunk */
+ movdqa 16(%rdi), %xmm2 # load second chunks
+ movdqa 16(%rsi), %xmm3
+ sub %rdx, %rax # is a&0xf >= b&0xf?
+ jb .Lswapped # if not, proceed with swapped operands
+
+ neg %rax
+ movdqu 16(%rsi, %rax, 1), %xmm0
+ sub %rdi, %rsi # express RSI as distance from RDI
+ lea (%rsi, %rax, 1), %rdx # point RDX to offset in second string
+ neg %rax
+ pcmpeqb %xmm3, %xmm1 # ... corresponding to RDI
+ pcmpeqb %xmm2, %xmm0
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add $16, %rdi
+ test %r8d, %r8d
+ jnz .Lnul_found
+ xor $0xffff, %r9d
+ jnz .Lmismatch
+ add $16, %rdi # advance aligned pointers
+
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * RDI: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * RSI: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * RSI doesn't end within region 2, then we compare chunk B between the
+ * two strings. As RSI is known not to hold a NUL byte in regsions 1
+ * and 2 at this point, this also ensures that RDI has not ended yet.
+ */
+ ALIGN_TEXT
+0: movdqu (%rdi, %rdx, 1), %xmm0 # chunk of 2nd string corresponding to RDI?
+ pxor %xmm1, %xmm1
+ pcmpeqb (%rdi, %rsi, 1), %xmm1 # end of string in RSI?
+ pcmpeqb (%rdi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ test %r8d, %r8d
+ jnz .Lnul_found
+ xor $0xffff, %r9d # any mismatches?
+ jnz .Lmismatch
+
+ /* main loop unrolled twice */
+ movdqu 16(%rdi, %rdx, 1), %xmm0 # chunk of 2nd string corresponding to RDI?
+ pxor %xmm1, %xmm1
+ pcmpeqb 16(%rdi, %rsi, 1), %xmm1 # end of string in RSI?
+ pcmpeqb 16(%rdi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add $32, %rdi
+ test %r8d, %r8d
+ jnz .Lnul_found2
+ xor $0xffff, %r9d # any mismatches?
+ jz 0b
+
+ sub $16, %rdi # roll back second increment
+
+ /* a mismatch has been found between RDX and RSI */
+.Lmismatch:
+ tzcnt %r9d, %r9d # where is the mismatch?
+ add %rdi, %rdx # turn RDX from offset to pointer
+ movzbl (%rdx, %r9, 1), %ecx
+ movzbl (%rdi, %r9, 1), %eax
+ sub %ecx, %eax # difference of the mismatching chars
+ ret
+
+ /* mismatch in true heads */
+.Lhead_mismatch:
+ tzcnt %r9d, %r9d # where is the mismatch?
+ add %rax, %rdi # return to true heads
+ add %rdx, %rsi
+ movzbl (%rdi, %r9, 1), %eax # mismatching characters
+ movzbl (%rsi, %r9, 1), %ecx
+ sub %ecx, %eax
+ ret
+
+.Lnul_found2:
+ sub $16, %rdi # roll back second increment
+
+ /* a NUL has been found in RSI */
+.Lnul_found:
+ mov %eax, %ecx
+ mov %r8d, %r10d
+ shl %cl, %r8w # adjust NUL mask to positions in RDI/RDX
+ xor $0xffff, %r9d # mask of mismatches
+ or %r8d, %r9d # NUL bytes also count as mismatches
+ jnz .Lmismatch
+
+ /*
+ * (RDI) == (RSI) and NUL is past the string.
+ * Compare (RSI) with the corresponding part
+ * of the other string until the NUL byte.
+ */
+ movdqu (%rdi, %rax, 1), %xmm0
+ pcmpeqb (%rdi, %rsi, 1), %xmm0
+ add %rdi, %rsi # restore RSI pointer
+ add %rax, %rdi # point RDI to chunk corresponding to (RSI)
+ pmovmskb %xmm0, %ecx # mask of matches
+ not %ecx # mask of mismatches
+ or %r10d, %ecx # mask of mismatches or NUL bytes
+ tzcnt %ecx, %ecx # location of first mismatch
+ movzbl (%rdi, %rcx, 1), %eax
+ movzbl (%rsi, %rcx, 1), %ecx
+ sub %ecx, %eax
+ ret
+
+ /*
+ * If (a&0xf) < (b&0xf), we do the same thing but with swapped
+ * operands. I found that this performs slightly better than
+ * using conditional moves to do the swap branchless.
+ */
+.Lswapped:
+ movdqu 16(%rdi, %rax, 1), %xmm0
+ sub %rsi, %rdi # express RDI as distance from RSI
+ lea (%rdi, %rax, 1), %rdx # point RDX to offset in RDI corresponding to RSI
+ neg %rax # make difference positive
+ pcmpeqb %xmm2, %xmm1
+ pcmpeqb %xmm3, %xmm0
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add $16, %rsi # advance aligned pointers
+ test %r8d, %r8d
+ jnz .Lnul_founds
+ xor $0xffff, %r9d
+ jnz .Lmismatchs
+ add $16, %rsi
+
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * RDI: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * RSI: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * RSI doesn't end within region 2, then we compare chunk B between the
+ * two strings. As RSI is known not to hold a NUL byte in regsions 1
+ * and 2 at this point, this also ensures that RDI has not ended yet.
+ */
+ ALIGN_TEXT
+0: movdqu (%rsi, %rdx, 1), %xmm0 # chunk of 2nd string corresponding to RDI?
+ pxor %xmm1, %xmm1
+ pcmpeqb (%rsi, %rdi, 1), %xmm1 # end of string in RSI?
+ pcmpeqb (%rsi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ test %r8d, %r8d
+ jnz .Lnul_founds
+ xor $0xffff, %r9d # any mismatches?
+ jnz .Lmismatchs
+
+ /* main loop unrolled twice */
+ movdqu 16(%rsi, %rdx, 1), %xmm0 # chunk of 2nd string corresponding to RDI?
+ pxor %xmm1, %xmm1
+ pcmpeqb 16(%rsi, %rdi, 1), %xmm1 # end of string in RSI?
+ pcmpeqb 16(%rsi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add $32, %rsi
+ test %r8d, %r8d
+ jnz .Lnul_found2s
+ xor $0xffff, %r9d # any mismatches?
+ jz 0b
+
+ sub $16, %rsi # roll back second increment
+
+ /* a mismatch has been found between RDX and RDI */
+.Lmismatchs:
+ tzcnt %r9d, %r9d # where is the mismatch?
+ add %rsi, %rdx # turn RDX from offset to pointer
+ movzbl (%rdx, %r9, 1), %eax
+ movzbl (%rsi, %r9, 1), %ecx
+ sub %ecx, %eax # difference of the mismatching chars
+ ret
+
+.Lnul_found2s:
+ sub $16, %rsi # roll back second increment
+
+ /* a NUL has been found in RSI */
+.Lnul_founds:
+ mov %eax, %ecx
+ mov %r8d, %r10d
+ shl %cl, %r8w # adjust NUL mask to positions in RDI/RDX
+ xor $0xffff, %r9d # mask of mismatches
+ or %r8d, %r9d # NUL bytes also count as mismatches
+ jnz .Lmismatchs
+
+ /*
+ * (RDI) == (RSI) and NUL is past the string.
+ * Compare (RSI) with the corresponding part
+ * of the other string until the NUL byte.
+ */
+ movdqu (%rsi, %rax, 1), %xmm0
+ pcmpeqb (%rsi, %rdi, 1), %xmm0
+ add %rsi, %rdi # restore RDI pointer
+ add %rax, %rsi # point RSI to chunk corresponding to (RDI)
+ pmovmskb %xmm0, %ecx # mask of matches
+ not %ecx # mask of mismatches
+ or %r10d, %ecx # mask of mismatches or NUL bytes
+ tzcnt %ecx, %ecx # location of first mismatch
+ movzbl (%rdi, %rcx, 1), %eax
+ movzbl (%rsi, %rcx, 1), %ecx
+ sub %ecx, %eax
+ ret
+ARCHEND(strcmp, baseline)
.section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strcpy.c b/lib/libc/amd64/string/strcpy.c
index fbc661462ff2..eb93b0defbaa 100644
--- a/lib/libc/amd64/string/strcpy.c
+++ b/lib/libc/amd64/string/strcpy.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
char *__stpcpy(char * __restrict, const char * __restrict);
char *
diff --git a/lib/libc/amd64/string/strcspn.S b/lib/libc/amd64/string/strcspn.S
new file mode 100644
index 000000000000..7ebd7a847d67
--- /dev/null
+++ b/lib/libc/amd64/string/strcspn.S
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+#include <machine/param.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+ .weak strcspn
+ .set strcspn, __strcspn
+ARCHFUNCS(__strcspn)
+ ARCHFUNC(__strcspn, scalar)
+ NOARCHFUNC
+ ARCHFUNC(__strcspn, x86_64_v2)
+ENDARCHFUNCS(__strcspn)
+
+ARCHENTRY(__strcspn, scalar)
+ push %rbp # align stack to enable function call
+ mov %rsp, %rbp
+ sub $256, %rsp # allocate space for lookup table
+
+ /* check for special cases */
+ movzbl (%rsi), %eax # first character in the set
+ test %eax, %eax
+ jz .Lstrlen
+
+ movzbl 1(%rsi), %edx # second character in the set
+ test %edx, %edx
+ jz .Lstrchr
+
+ /* no special case matches -- prepare lookup table */
+ xor %r8d, %r8d
+ mov $28, %ecx
+0: mov %r8, (%rsp, %rcx, 8)
+ mov %r8, 8(%rsp, %rcx, 8)
+ mov %r8, 16(%rsp, %rcx, 8)
+ mov %r8, 24(%rsp, %rcx, 8)
+ sub $4, %ecx
+ jnc 0b
+
+ add $2, %rsi
+ movb $1, (%rsp, %rax, 1) # register first chars in set
+ movb $1, (%rsp, %rdx, 1)
+ mov %rdi, %rax # a copy of the source to iterate over
+
+ /* process remaining chars in set */
+ ALIGN_TEXT
+0: movzbl (%rsi), %ecx
+ movb $1, (%rsp, %rcx, 1)
+ test %ecx, %ecx
+ jz 1f
+
+ movzbl 1(%rsi), %ecx
+ movb $1, (%rsp, %rcx, 1)
+ test %ecx, %ecx
+ jz 1f
+
+ add $2, %rsi
+ jmp 0b
+
+ /* find match */
+ ALIGN_TEXT
+1: movzbl (%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 2f
+
+ movzbl 1(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 3f
+
+ movzbl 2(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 4f
+
+ movzbl 3(%rax), %ecx
+ add $4, %rax
+ cmpb $0, (%rsp, %rcx, 1)
+ je 1b
+
+ sub $3, %rax
+4: dec %rdi
+3: inc %rax
+2: sub %rdi, %rax # number of characters preceding match
+ leave
+ ret
+
+ /* set is empty, degrades to strlen */
+.Lstrlen:
+ leave
+ jmp CNAME(strlen)
+
+ /* just one character in set, degrades to strchr */
+.Lstrchr:
+ mov %rdi, (%rsp) # stash a copy of the string
+ mov %eax, %esi # find the character in the set
+ call CNAME(strchrnul)
+ sub (%rsp), %rax # length of prefix before match
+ leave
+ ret
+ARCHEND(__strcspn, scalar)
+
+ /*
+ * This kernel uses pcmpistri to do the heavy lifting.
+ * We provide five code paths, depending on set size:
+ *
+ * 0: call strlen()
+ * 1: call strchr()
+ * 2--16: one pcmpistri per 16 bytes of input
+ * 17--32: two pcmpistri per 16 bytes of input
+ * >=33: fall back to look up table
+ */
+ARCHENTRY(__strcspn, x86_64_v2)
+ push %rbp
+ mov %rsp, %rbp
+ sub $256, %rsp
+
+ /* check for special cases */
+ movzbl (%rsi), %eax
+ test %eax, %eax # empty string?
+ jz .Lstrlenv2
+
+ cmpb $0, 1(%rsi) # single character string?
+ jz .Lstrchrv2
+
+ /* find set size and copy up to 32 bytes to (%rsp) */
+ mov %esi, %ecx
+ and $~0xf, %rsi # align set pointer
+ movdqa (%rsi), %xmm0
+ pxor %xmm1, %xmm1
+ and $0xf, %ecx # amount of bytes rsi is past alignment
+ xor %edx, %edx
+ pcmpeqb %xmm0, %xmm1 # end of string reached?
+ movdqa %xmm0, 32(%rsp) # transfer head of set to stack
+ pmovmskb %xmm1, %eax
+ shr %cl, %eax # clear out junk before string
+ test %eax, %eax # end of set reached?
+ jnz 0f
+
+ movdqa 16(%rsi), %xmm0 # second chunk of the set
+ mov $16, %edx
+ sub %ecx, %edx # length of set preceding xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm0, %xmm1
+ movdqa %xmm0, 48(%rsp)
+ movdqu 32(%rsp, %rcx, 1), %xmm2 # head of set
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz 1f
+
+ movdqa 32(%rsi), %xmm0 # third chunk
+ add $16, %edx
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm0, %xmm1
+ movdqa %xmm0, 64(%rsp)
+ pmovmskb %xmm1, %eax
+ test %eax, %eax # still not done?
+ jz .Lgt32v2
+
+0: movdqu 32(%rsp, %rcx, 1), %xmm2 # head of set
+1: tzcnt %eax, %eax
+ add %eax, %edx # length of set (excluding NUL byte)
+ cmp $32, %edx # above 32 bytes?
+ ja .Lgt32v2
+
+ /*
+ * At this point we know that we want to use pcmpistri.
+ * one last problem obtains: the head of the string is not
+ * aligned and may cross a cacheline. If this is the case,
+ * we take the part before the page boundary and repeat the
+ * last byte to fill up the xmm register.
+ */
+ mov %rdi, %rax # save original string pointer
+ lea 15(%rdi), %esi # last byte of the head
+ xor %edi, %esi
+ test $PAGE_SIZE, %esi # does the head cross a page?
+ jz 0f
+
+ /* head crosses page: copy to stack to fix up */
+ and $~0xf, %rax # align head pointer temporarily
+ movzbl 15(%rax), %esi # last head byte on the page
+ movdqa (%rax), %xmm0
+ movabs $0x0101010101010101, %r8
+ imul %r8, %rsi # repeated 8 times
+ movdqa %xmm0, (%rsp) # head word on stack
+ mov %rsi, 16(%rsp) # followed by filler (last byte x8)
+ mov %rsi, 24(%rsp)
+ mov %edi, %eax
+ and $0xf, %eax # offset of head from alignment
+ add %rsp, %rax # pointer to fake head
+
+0: movdqu (%rax), %xmm0 # load head (fake or real)
+ lea 16(%rdi), %rax
+ and $~0xf, %rax # second 16 bytes of string (aligned)
+1: cmp $16, %edx # 16--32 bytes?
+ ja .Lgt16v2
+
+
+ /* set is 2--16 bytes in size */
+
+ /* _SIDD_UBYTE_OPS|_SIDD_CMP_EQUAL_ANY|_SIDD_LEAST_SIGNIFICANT */
+ pcmpistri $0, %xmm0, %xmm2 # match in head?
+ jbe .Lheadmatchv2
+
+ ALIGN_TEXT
+0: pcmpistri $0, (%rax), %xmm2
+ jbe 1f # match or end of string?
+ pcmpistri $0, 16(%rax), %xmm2
+ lea 32(%rax), %rax
+ ja 0b # match or end of string?
+
+3: lea -16(%rax), %rax # go back to second half
+1: jc 2f # jump if match found
+ movdqa (%rax), %xmm0 # reload string piece
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm1, %xmm0 # where is the NUL byte?
+ pmovmskb %xmm0, %ecx
+ tzcnt %ecx, %ecx # location of NUL byte in (%rax)
+2: sub %rdi, %rax # offset of %xmm0 from beginning of string
+ add %rcx, %rax # prefix length before match/NUL
+ leave
+ ret
+
+.Lheadmatchv2:
+ jc 2f # jump if match found
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm1, %xmm0
+ pmovmskb %xmm0, %ecx
+ tzcnt %ecx, %ecx # location of NUL byte
+2: mov %ecx, %eax # prefix length before match/NUL
+ leave
+ ret
+
+ /* match in first set half during head */
+.Lheadmatchv2first:
+ mov %ecx, %eax
+ pcmpistri $0, %xmm0, %xmm3 # match in second set half?
+ cmp %ecx, %eax # before the first half match?
+ cmova %ecx, %eax # use the earlier match
+ leave
+ ret
+
+.Lgt16v2:
+ movdqu 48(%rsp, %rcx, 1), %xmm3 # second part of set
+
+ /* set is 17--32 bytes in size */
+ pcmpistri $0, %xmm0, %xmm2 # match in first set half?
+ jb .Lheadmatchv2first
+ pcmpistri $0, %xmm0, %xmm3 # match in second set half or end of string?
+ jbe .Lheadmatchv2
+
+ ALIGN_TEXT
+0: movdqa (%rax), %xmm0
+ pcmpistri $0, %xmm0, %xmm2
+ jb 4f # match in first set half?
+ pcmpistri $0, %xmm0, %xmm3
+ jbe 1f # match in second set half or end of string?
+ movdqa 16(%rax), %xmm0
+ add $32, %rax
+ pcmpistri $0, %xmm0, %xmm2
+ jb 3f # match in first set half?
+ pcmpistri $0, %xmm0, %xmm3
+ ja 0b # neither match in 2nd half nor string end?
+
+ /* match in second half or NUL */
+ lea -16(%rax), %rax # go back to second half
+1: jc 2f # jump if match found
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm1, %xmm0 # where is the NUL byte?
+ pmovmskb %xmm0, %ecx
+ tzcnt %ecx, %ecx # location of NUL byte in (%rax)
+2: sub %rdi, %rax # offset of %xmm0 from beginning of string
+ add %rcx, %rax # prefix length before match/NUL
+ leave
+ ret
+
+ /* match in first half */
+3: sub $16, %rax # go back to second half
+4: sub %rdi, %rax # offset of %xmm0 from beginning of string
+ mov %ecx, %edx
+ pcmpistri $0, %xmm0, %xmm3 # match in second set half?
+ cmp %ecx, %edx # before the first half match?
+ cmova %ecx, %edx # use the earlier match
+ add %rdx, %rax # return full ofset
+ leave
+ ret
+
+ /* set is empty, degrades to strlen */
+.Lstrlenv2:
+ leave
+ jmp CNAME(strlen)
+
+ /* just one character in set, degrades to strchr */
+.Lstrchrv2:
+ mov %rdi, (%rsp) # stash a copy of the string
+ mov %eax, %esi # find this character
+ call CNAME(strchrnul)
+ sub (%rsp), %rax # length of prefix before match
+ leave
+ ret
+
+ /* set is >=33 bytes in size */
+.Lgt32v2:
+ xorps %xmm0, %xmm0
+ mov $256-64, %edx
+
+ /* clear out look up table */
+0: movaps %xmm0, (%rsp, %rdx, 1)
+ movaps %xmm0, 16(%rsp, %rdx, 1)
+ movaps %xmm0, 32(%rsp, %rdx, 1)
+ movaps %xmm0, 48(%rsp, %rdx, 1)
+ sub $64, %edx
+ jnc 0b
+
+ add %rcx, %rsi # restore string pointer
+ mov %rdi, %rax # keep a copy of the string
+
+ /* initialise look up table */
+ ALIGN_TEXT
+0: movzbl (%rsi), %ecx
+ movb $1, (%rsp, %rcx, 1)
+ test %ecx, %ecx
+ jz 1f
+
+ movzbl 1(%rsi), %ecx
+ movb $1, (%rsp, %rcx, 1)
+ test %ecx, %ecx
+ jz 1f
+
+ movzbl 2(%rsi), %ecx
+ movb $1, (%rsp, %rcx, 1)
+ test %ecx, %ecx
+ jz 1f
+
+ movzbl 3(%rsi), %ecx
+ movb $1, (%rsp, %rcx, 1)
+ test %ecx, %ecx
+ jz 1f
+
+ add $4, %rsi
+ jmp 0b
+
+ /* find match */
+ ALIGN_TEXT
+1: movzbl (%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 2f
+
+ movzbl 1(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 3f
+
+ movzbl 2(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 4f
+
+ movzbl 3(%rax), %ecx
+ add $4, %rax
+ cmpb $0, (%rsp, %rcx, 1)
+ je 1b
+
+ sub $3, %rax
+4: dec %rdi
+3: inc %rax
+2: sub %rdi, %rax # number of characters preceding match
+ leave
+ ret
+ARCHEND(__strcspn, x86_64_v2)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strlcat.c b/lib/libc/amd64/string/strlcat.c
new file mode 100644
index 000000000000..94fdc0963dc3
--- /dev/null
+++ b/lib/libc/amd64/string/strlcat.c
@@ -0,0 +1,27 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Robert Clausecker
+ */
+
+#include <sys/cdefs.h>
+
+#include <string.h>
+
+#undef strlcat /* FORTIFY_SOURCE */
+
+void *__memchr(const void *, int, size_t);
+size_t __strlcpy(char *restrict, const char *restrict, size_t);
+
+size_t
+strlcat(char *restrict dst, const char *restrict src, size_t dstsize)
+{
+ char *loc = __memchr(dst, '\0', dstsize);
+
+ if (loc != NULL) {
+ size_t dstlen = (size_t)(loc - dst);
+
+ return (dstlen + __strlcpy(loc, src, dstsize - dstlen));
+ } else
+ return (dstsize + strlen(src));
+}
diff --git a/lib/libc/amd64/string/strlcpy.S b/lib/libc/amd64/string/strlcpy.S
new file mode 100644
index 000000000000..2b32c6c78047
--- /dev/null
+++ b/lib/libc/amd64/string/strlcpy.S
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4, 0x90
+
+ .weak strlcpy
+ .set strlcpy, __strlcpy
+ARCHFUNCS(__strlcpy)
+ ARCHFUNC(__strlcpy, scalar)
+ ARCHFUNC(__strlcpy, baseline)
+ENDARCHFUNCS(__strlcpy)
+
+ARCHENTRY(__strlcpy, scalar)
+ push %rbp # establish stack frame
+ mov %rsp, %rbp
+ push %rsi
+ push %rbx
+ push %rdi
+ push %rdx
+ mov %rsi, %rdi
+ call CNAME(strlen) # strlen(src)
+ pop %rdx
+ pop %rdi
+ mov -8(%rbp), %rsi
+ mov %rax, %rbx # remember string length for return value
+ sub $1, %rdx # do not copy into the final byte of the buffer
+ jc 0f # skip copying altogether if buffer was empty
+ cmp %rax, %rdx # is the buffer longer than the input?
+ cmova %rax, %rdx # if yes, only copy the part that fits
+ movb $0, (%rdi, %rdx, 1) # NUL-terminate output buffer
+ call CNAME(memcpy) # copy string to output
+0: mov %rbx, %rax # restore return value
+ pop %rbx
+ leave
+ ret
+ARCHEND(__strlcpy, scalar)
+
+ARCHENTRY(__strlcpy, baseline)
+ sub $1, %rdx # do not count NUL byte in buffer length
+ jb .L0 # go to special code path if len was 0
+
+ mov %esi, %ecx
+ pxor %xmm1, %xmm1
+ mov %rsi, %r9 # stash a copy of the source pointer for later
+ and $~0xf, %rsi
+ pcmpeqb (%rsi), %xmm1 # NUL found in head?
+ mov $-1, %r8d
+ and $0xf, %ecx
+ shl %cl, %r8d # mask of bytes in the string
+ pmovmskb %xmm1, %eax
+ and %r8d, %eax
+ jnz .Lhead_nul
+
+ movdqa 16(%rsi), %xmm3 # load second string chunk
+ movdqu (%r9), %xmm2 # load unaligned string head
+ mov $32, %r8d
+ sub %ecx, %r8d # head length + length of second chunk
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm3, %xmm1 # NUL found in second chunk?
+
+ sub %r8, %rdx # enough space left for the second chunk?
+ jbe .Lhead_buf_end
+
+ /* process second chunk */
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz .Lsecond_nul
+
+ /* string didn't end in second chunk and neither did buffer -- not a runt! */
+ movdqa 32(%rsi), %xmm0 # load next string chunk
+ pxor %xmm1, %xmm1
+ movdqu %xmm2, (%rdi) # deposit head into buffer
+ sub %rcx, %rdi # adjust RDI to correspond to RSI
+ movdqu %xmm3, 16(%rdi) # deposit second chunk
+ sub %rsi, %rdi # express RDI as distance from RSI
+ add $32, %rsi # advance RSI past first two chunks
+ sub $16, %rdx # enough left for another round?
+ jbe 1f
+
+ /* main loop unrolled twice */
+ ALIGN_TEXT
+0: pcmpeqb %xmm0, %xmm1 # NUL byte encountered?
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz 3f
+
+ movdqu %xmm0, (%rsi, %rdi)
+ movdqa 16(%rsi), %xmm0 # load next string chunk
+ pxor %xmm1, %xmm1
+ cmp $16, %rdx # more than a full chunk left?
+ jbe 2f
+
+ add $32, %rsi # advance pointers to next chunk
+ pcmpeqb %xmm0, %xmm1 # NUL byte encountered?
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz 4f
+
+ movdqu %xmm0, -16(%rsi, %rdi)
+ movdqa (%rsi), %xmm0 # load next string chunk
+ pxor %xmm1, %xmm1
+ sub $32, %rdx
+ ja 0b
+
+1: sub $16, %rsi # undo second advancement
+ add $16, %edx
+
+ /* 1--16 bytes left in the buffer but string has not ended yet */
+2: pcmpeqb %xmm1, %xmm0 # NUL byte encountered?
+ pmovmskb %xmm0, %r8d
+ mov %r8d, %eax
+ bts %edx, %r8d # treat end of buffer as end of string
+ tzcnt %r8d, %r8d # find tail length
+ add %rsi, %rdi # restore RDI
+ movdqu (%rsi, %r8, 1), %xmm0 # load string tail
+ movdqu %xmm0, (%rdi, %r8, 1) # store string tail
+ movb $0, 16(%rdi, %r8, 1) # NUL terminate
+
+ /* continue to find the end of the string */
+ test %eax, %eax # end of string already reached?
+ jnz 1f
+
+ ALIGN_TEXT
+0: pcmpeqb 32(%rsi), %xmm1
+ pmovmskb %xmm1, %eax
+ pxor %xmm1, %xmm1
+ test %eax, %eax
+ jnz 2f
+
+ pcmpeqb 48(%rsi), %xmm1
+ pmovmskb %xmm1, %eax
+ add $32, %rsi
+ pxor %xmm1, %xmm1
+ test %eax, %eax
+ jz 0b
+
+1: sub $16, %rsi # undo second advancement
+2: tzcnt %eax, %eax # where is the NUL byte?
+ sub %r9, %rsi
+ lea 32(%rsi, %rax, 1), %rax # return string length
+ ret
+
+4: sub $16, %rsi # undo second advancement
+ add $16, %rdx # restore number of remaining bytes
+
+ /* string has ended but buffer has not */
+3: tzcnt %eax, %eax # find length of string tail
+ movdqu -15(%rsi, %rax, 1), %xmm0 # load string tail (incl. NUL)
+ add %rsi, %rdi # restore destination pointer
+ movdqu %xmm0, -15(%rdi, %rax, 1) # store string tail (incl. NUL)
+ sub %r9, %rsi # string length to current chunk
+ add %rsi, %rax # plus length of current chunk
+ ret
+
+.Lhead_buf_end:
+ pmovmskb %xmm1, %r8d
+ add $32, %edx # restore edx to (len-1) + ecx
+ mov %r8d, %eax
+ shl $16, %r8d # place 2nd chunk NUL mask into bits 16--31
+ bts %rdx, %r8 # treat end of buffer as end of string
+ tzcnt %r8, %rdx # find string/bufer len from alignment boundary
+ sub %ecx, %edx # find actual string/buffer len
+ movb $0, (%rdi, %rdx, 1) # write NUL terminator
+
+ /* continue to find the end of the string */
+ test %eax, %eax # end of string already reached?
+ jnz 1f
+
+ ALIGN_TEXT
+0: pcmpeqb 32(%rsi), %xmm1
+ pmovmskb %xmm1, %eax
+ pxor %xmm1, %xmm1
+ test %eax, %eax
+ jnz 2f
+
+ pcmpeqb 48(%rsi), %xmm1
+ pmovmskb %xmm1, %eax
+ add $32, %rsi
+ pxor %xmm1, %xmm1
+ test %eax, %eax
+ jz 0b
+
+1: sub $16, %rsi
+2: tzcnt %eax, %eax
+ sub %r9, %rsi
+ lea 32(%rsi, %rax, 1), %rax # return string length
+ jmp .L0031
+
+.Lsecond_nul:
+ add %r8, %rdx # restore buffer length
+ tzcnt %eax, %eax # where is the NUL byte?
+ lea -16(%rcx), %r8d
+ sub %r8d, %eax # string length
+ cmp %rax, %rdx # is the string shorter than the buffer?
+ cmova %rax, %rdx # copy only min(buflen, srclen) bytes
+ movb $0, (%rdi, %rdx, 1) # write NUL terminator
+.L0031: cmp $16, %rdx # at least 16 bytes to copy (not incl NUL)?
+ jb .L0015
+
+ /* copy 16--31 bytes */
+ movdqu (%r9), %xmm0 # load first 16 bytes
+ movdqu -16(%r9, %rdx, 1), %xmm1 # load last 16 bytes
+ movdqu %xmm0, (%rdi)
+ movdqu %xmm1, -16(%rdi, %rdx, 1)
+ ret
+
+.Lhead_nul:
+ tzcnt %eax, %eax # where is the NUL byte?
+ sub %ecx, %eax # ... from the beginning of the string?
+ cmp %rax, %rdx # is the string shorter than the buffer?
+ cmova %rax, %rdx # copy only min(buflen, srclen) bytes
+ movb $0, (%rdi, %rdx, 1) # write NUL terminator
+
+ /* process strings of 0--15 bytes (rdx: min(buflen, srclen), rax: srclen) */
+.L0015: cmp $8, %rdx # at least 8 bytes to copy?
+ jae .L0815
+
+ cmp $4, %rdx # at least 4 bytes to copy?
+ jae .L0407
+
+ cmp $2, %rdx # at least 2 bytes to copy?
+ jae .L0203
+
+ movzbl (%r9), %ecx # load first byte from src
+ mov %cl, (%rdi) # deposit into destination
+ movb $0, (%rdi, %rdx, 1) # add NUL terminator (again)
+ ret
+
+.L0203: movzwl (%r9), %ecx
+ movzwl -2(%r9, %rdx, 1), %esi
+ mov %cx, (%rdi)
+ mov %si, -2(%rdi, %rdx, 1)
+ ret
+
+.L0407: mov (%r9), %ecx
+ mov -4(%r9, %rdx, 1), %esi
+ mov %ecx, (%rdi)
+ mov %esi, -4(%rdi, %rdx, 1)
+ ret
+
+.L0815: mov (%r9), %rcx
+ mov -8(%r9, %rdx, 1), %rsi
+ mov %rcx, (%rdi)
+ mov %rsi, -8(%rdi, %rdx, 1)
+ ret
+
+ /* length zero destination: just return the string length */
+.L0: mov %rsi, %rdi
+ jmp CNAME(strlen)
+ARCHEND(__strlcpy, baseline)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strncat.c b/lib/libc/amd64/string/strncat.c
new file mode 100644
index 000000000000..2c63ab50b3c3
--- /dev/null
+++ b/lib/libc/amd64/string/strncat.c
@@ -0,0 +1,31 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Robert Clausecker
+ */
+
+#include <sys/cdefs.h>
+
+#include <string.h>
+
+#undef strncat /* _FORTIFY_SOURCE */
+
+void *__memccpy(void *restrict, const void *restrict, int, size_t);
+
+char *
+strncat(char *dest, const char *src, size_t n)
+{
+ size_t len;
+ char *endptr;
+
+ len = strlen(dest);
+ endptr = __memccpy(dest + len, src, '\0', n);
+
+ /* avoid an extra branch */
+ if (endptr == NULL)
+ endptr = dest + len + n + 1;
+
+ endptr[-1] = '\0';
+
+ return (dest);
+}
diff --git a/lib/libc/amd64/string/strncmp.S b/lib/libc/amd64/string/strncmp.S
new file mode 100644
index 000000000000..932cf078bdfc
--- /dev/null
+++ b/lib/libc/amd64/string/strncmp.S
@@ -0,0 +1,488 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+#include <machine/param.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4, 0x90
+
+ARCHFUNCS(strncmp)
+ ARCHFUNC(strncmp, scalar)
+ ARCHFUNC(strncmp, baseline)
+ENDARCHFUNCS(strncmp)
+
+/*
+ * This is just the scalar loop unrolled a bunch of times.
+ */
+ARCHENTRY(strncmp, scalar)
+ xor %eax, %eax
+ sub $4, %rdx # 4 chars left to compare?
+ jbe 1f
+
+ ALIGN_TEXT
+0: movzbl (%rdi), %ecx
+ test %ecx, %ecx # NUL char in first string?
+ jz .L0
+ cmpb (%rsi), %cl # mismatch between strings?
+ jnz .L0
+
+ movzbl 1(%rdi), %ecx
+ test %ecx, %ecx
+ jz .L1
+ cmpb 1(%rsi), %cl
+ jnz .L1
+
+ movzbl 2(%rdi), %ecx
+ test %ecx, %ecx
+ jz .L2
+ cmpb 2(%rsi), %cl
+ jnz .L2
+
+ movzbl 3(%rdi), %ecx
+ test %ecx, %ecx
+ jz .L3
+ cmpb 3(%rsi), %cl
+ jnz .L3
+
+ add $4, %rdi # advance to next iteration
+ add $4, %rsi
+ sub $4, %rdx
+ ja 0b
+
+ /* end of string within the next 4 characters */
+1: cmp $-4, %edx # end of string reached immediately?
+ jz .Leq
+ movzbl (%rdi), %ecx
+ test %ecx, %ecx
+ jz .L0
+ cmpb (%rsi), %cl
+ jnz .L0
+
+ cmp $-3, %edx # end of string reached after 1 char?
+ jz .Leq
+ movzbl 1(%rdi), %ecx
+ test %ecx, %ecx
+ jz .L1
+ cmpb 1(%rsi), %cl
+ jnz .L1
+
+ cmp $-2, %edx
+ jz .Leq
+ movzbl 2(%rdi), %ecx
+ test %ecx, %ecx
+ jz .L2
+ cmpb 2(%rsi), %cl
+ jnz .L2
+
+ cmp $-1, %edx # either end of string after 3 chars,
+ jz .Leq # or it boils down to the last char
+
+.L3: inc %eax
+.L2: inc %eax
+.L1: inc %eax
+.L0: movzbl (%rsi, %rax, 1), %ecx
+ movzbl (%rdi, %rax, 1), %eax
+ sub %ecx, %eax
+.Leq: ret
+ARCHEND(strncmp, scalar)
+
+ARCHENTRY(strncmp, baseline)
+ push %rbx
+ sub $1, %rdx # RDX--, so RDX points to the last byte to compare
+ jb .Lempty # where there any bytes to compare at all?
+
+ lea 15(%rdi), %r8d # end of head
+ lea 15(%rsi), %r9d
+ mov %edi, %eax
+ mov %esi, %ebx
+ xor %edi, %r8d # bits that changed between first and last byte
+ xor %esi, %r9d
+ and $~0xf, %rdi # align heads to 16 bytes
+ and $~0xf, %rsi
+ or %r8d, %r9d
+ and $0xf, %eax # offset from alignment
+ and $0xf, %ebx
+ movdqa (%rdi), %xmm0 # load aligned heads
+ movdqa (%rsi), %xmm2
+ pxor %xmm1, %xmm1
+ cmp $16, %rdx # end of buffer within the first 32 bytes?
+ jb .Llt16
+
+ test $PAGE_SIZE, %r9d # did the page change?
+ jz 0f # if not, take fast path
+
+
+ /* heads may cross page boundary, avoid unmapped loads */
+ movdqa %xmm0, -32(%rsp) # stash copies of the heads on the stack
+ movdqa %xmm2, -16(%rsp)
+ mov $-1, %r8d
+ mov $-1, %r9d
+ mov %eax, %ecx
+ shl %cl, %r8d # string head in XMM0
+ mov %ebx, %ecx
+ shl %cl, %r9d # string head in XMM2
+ pcmpeqb %xmm1, %xmm0
+ pcmpeqb %xmm1, %xmm2
+ pmovmskb %xmm0, %r10d
+ pmovmskb %xmm2, %r11d
+ test %r8d, %r10d # NUL byte present in first string?
+ lea -32(%rsp), %r8
+ cmovz %rdi, %r8
+ test %r9d, %r11d # NUL byte present in second string?
+ lea -16(%rsp), %r9
+ cmovz %rsi, %r9
+ movdqu (%r8, %rax, 1), %xmm0 # load true (or fake) heads
+ movdqu (%r9, %rbx, 1), %xmm4
+ jmp 1f
+
+ /* rdx == 0 */
+.Lempty:
+ xor %eax, %eax # zero-length buffers compare equal
+ pop %rbx
+ ret
+
+0: movdqu (%rdi, %rax, 1), %xmm0 # load true heads
+ movdqu (%rsi, %rbx, 1), %xmm4
+1: pxor %xmm2, %xmm2
+ pcmpeqb %xmm0, %xmm2 # NUL byte present?
+ pcmpeqb %xmm0, %xmm4 # which bytes match?
+ pandn %xmm4, %xmm2 # match and not NUL byte?
+ pmovmskb %xmm2, %r9d
+ xor $0xffff, %r9d # mismatch or NUL byte?
+ jnz .Lhead_mismatch
+
+ /* load head and second chunk */
+ movdqa 16(%rdi), %xmm2 # load second chunks
+ movdqa 16(%rsi), %xmm3
+ lea -16(%rdx, %rbx, 1), %rdx # account for length of RSI chunk
+ sub %rbx, %rax # is a&0xf >= b&0xf?
+ jb .Lswapped # if not, proceed with swapped operands
+ jmp .Lnormal
+
+ /* buffer ends within the first 16 bytes */
+.Llt16: test $PAGE_SIZE, %r9d # did the page change?
+ jz 0f # if not, take fast path
+
+ /* heads may cross page boundary */
+ movdqa %xmm0, -32(%rsp) # stash copies of the heads on the stack
+ movdqa %xmm2, -16(%rsp)
+ mov $-1, %r8d
+ mov $-1, %r9d
+ mov %eax, %ecx
+ shl %cl, %r8d # string head in XMM0
+ mov %ebx, %ecx
+ shl %cl, %r9d # string head in XMM2
+ pcmpeqb %xmm1, %xmm0
+ pcmpeqb %xmm1, %xmm2
+ pmovmskb %xmm0, %r10d
+ pmovmskb %xmm2, %r11d
+ lea (%rdx, %rax, 1), %ecx # location of last buffer byte in xmm0
+ bts %ecx, %r10d # treat as if NUL byte present
+ lea (%rdx, %rbx, 1), %ecx
+ bts %ecx, %r11d
+ test %r8w, %r10w # NUL byte present in first string head?
+ lea -32(%rsp), %r8
+ cmovz %rdi, %r8
+ test %r9w, %r11w # NUL byte present in second string head?
+ lea -16(%rsp), %r9
+ cmovz %rsi, %r9
+ movdqu (%r8, %rax, 1), %xmm0 # load true (or fake) heads
+ movdqu (%r9, %rbx, 1), %xmm4
+ jmp 1f
+
+0: movdqu (%rdi, %rax, 1), %xmm0 # load true heads
+ movdqu (%rsi, %rbx, 1), %xmm4
+1: pxor %xmm2, %xmm2
+ pcmpeqb %xmm0, %xmm2 # NUL byte present?
+ pcmpeqb %xmm0, %xmm4 # which bytes match?
+ pandn %xmm4, %xmm2 # match and not NUL byte?
+ pmovmskb %xmm2, %r9d
+ btr %edx, %r9d # induce mismatch in last byte of buffer
+ not %r9d # mismatch or NUL byte?
+
+ /* mismatch in true heads */
+ ALIGN_TEXT
+.Lhead_mismatch:
+ tzcnt %r9d, %r9d # where is the mismatch?
+ add %rax, %rdi # return to true heads
+ add %rbx, %rsi
+ movzbl (%rdi, %r9, 1), %eax # mismatching characters
+ movzbl (%rsi, %r9, 1), %ecx
+ sub %ecx, %eax
+ pop %rbx
+ ret
+
+ /* rax >= 0 */
+ ALIGN_TEXT
+.Lnormal:
+ neg %rax
+ movdqu 16(%rsi, %rax, 1), %xmm0
+ sub %rdi, %rsi # express RSI as distance from RDI
+ lea (%rsi, %rax, 1), %rbx # point RBX to offset in second string
+ neg %rax # ... corresponding to RDI
+ pcmpeqb %xmm3, %xmm1 # NUL present?
+ pcmpeqb %xmm2, %xmm0 # Mismatch between chunks?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ mov $16, %ecx
+ cmp %rcx, %rdx # does the buffer end within (RDI,RSI,1)?
+ cmovb %edx, %ecx # ECX = min(16, RDX)
+ add $32, %rdi # advance to next iteration
+ bts %ecx, %r8d # mark end-of-buffer as if there was a NUL byte
+ test %r8w, %r8w # NUL or end of buffer found?
+ jnz .Lnul_found2
+ xor $0xffff, %r9d
+ jnz .Lmismatch2
+ sub $48, %rdx # end of buffer within first main loop iteration?
+ jb .Ltail # if yes, process tail
+
+ /*
+ * During the main loop, the layout of the two strings is something like:
+ *
+ * v ------1------ v ------2------ v
+ * RDI: AAAAAAAAAAAAABBBBBBBBBBBBBBBB...
+ * RSI: AAAAAAAAAAAAABBBBBBBBBBBBBBBBCCC...
+ *
+ * where v indicates the alignment boundaries and corresponding chunks
+ * of the strings have the same letters. Chunk A has been checked in
+ * the previous iteration. This iteration, we first check that string
+ * RSI doesn't end within region 2, then we compare chunk B between the
+ * two strings. As RSI is known not to hold a NUL byte in regsions 1
+ * and 2 at this point, this also ensures that RDI has not ended yet.
+ */
+ ALIGN_TEXT
+0: movdqu (%rdi, %rbx, 1), %xmm0 # chunk of 2nd string corresponding to RDI
+ pxor %xmm1, %xmm1
+ pcmpeqb (%rdi, %rsi, 1), %xmm1 # end of string in RSI?
+ pcmpeqb (%rdi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ test %r8d, %r8d
+ jnz .Lnul_found
+ xor $0xffff, %r9d # any mismatches?
+ jnz .Lmismatch
+
+ /* main loop unrolled twice */
+ movdqu 16(%rdi, %rbx, 1), %xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb 16(%rdi, %rsi, 1), %xmm1
+ pcmpeqb 16(%rdi), %xmm0
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add $32, %rdi
+ test %r8d, %r8d
+ jnz .Lnul_found2
+ xor $0xffff, %r9d
+ jnz .Lmismatch2
+ sub $32, %rdx # end of buffer within next iteration?
+ jae 0b
+
+ /* end of buffer will occur in next 32 bytes */
+.Ltail: movdqu (%rdi, %rbx, 1), %xmm0 # chunk of 2nd string corresponding to RDI
+ pxor %xmm1, %xmm1
+ pcmpeqb (%rdi, %rsi, 1), %xmm1 # end of string in RSI?
+ pcmpeqb (%rdi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ bts %edx, %r8d # indicate NUL byte at last byte in buffer
+ test %r8w, %r8w # NUL byte in first chunk?
+ jnz .Lnul_found
+ xor $0xffff, %r9d # any mismatches?
+ jnz .Lmismatch
+
+ /* main loop unrolled twice */
+ movdqu 16(%rdi, %rbx, 1), %xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb 16(%rdi, %rsi, 1), %xmm1
+ pcmpeqb 16(%rdi), %xmm0
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ sub $16, %edx # take first half into account
+ bts %edx, %r8d # indicate NUL byte at last byte in buffer
+ add $32, %rdi
+
+.Lnul_found2:
+ sub $16, %rdi
+
+.Lnul_found:
+ mov %eax, %ecx
+ mov %r8d, %r10d
+ shl %cl, %r8d # adjust NUL mask to positions in RDI/RBX
+ not %r9d # mask of mismatches
+ or %r8w, %r9w # NUL bytes als count as mismatches
+ jnz .Lmismatch
+
+ /*
+ * (RDI) == (RSI) and NUL is past the string.
+ * compare (RSI) with the corresponding part
+ * of the other string until the NUL byte.
+ */
+ movdqu (%rdi, %rax, 1), %xmm0
+ pcmpeqb (%rdi, %rsi, 1), %xmm0
+ add %rdi, %rsi # restore RSI pointer
+ add %rax, %rdi # point RDI to chunk corresponding to (RSI)
+ pmovmskb %xmm0, %ecx # mask of matches
+ not %ecx # mask of mismatches
+ or %r10d, %ecx # mask of mismatches or NUL bytes
+ tzcnt %ecx, %ecx # location of first mismatch
+ movzbl (%rdi, %rcx, 1), %eax
+ movzbl (%rsi, %rcx, 1), %ecx
+ sub %ecx, %eax
+ pop %rbx
+ ret
+
+.Lmismatch2:
+ sub $16, %rdi
+
+ /* a mismatch has been found between RBX and RSI */
+.Lmismatch:
+ tzcnt %r9d, %r9d # where is the mismatch?
+ add %rdi, %rbx # turn RBX from offset into pointer
+ movzbl (%rbx, %r9, 1), %ecx
+ movzbl (%rdi, %r9, 1), %eax
+ sub %ecx, %eax
+ pop %rbx
+ ret
+
+ /* rax < 0 */
+ ALIGN_TEXT
+.Lswapped:
+ movdqu 16(%rdi, %rax, 1), %xmm0
+ sub %rsi, %rdi # express RDI as distance from RDI
+ lea (%rdi, %rax, 1), %rbx # point RBX to offset in first string
+ pcmpeqb %xmm2, %xmm1 # NUL present?
+ pcmpeqb %xmm3, %xmm0 # mismatch between chunks?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add %rax, %rdx # RDX points to buffer end in RSI
+ neg %rax # ... corresponding to RSI
+ mov $16, %ecx
+ cmp %rcx, %rdx # does the buffer end within (RSI,RDI,1)?
+ cmovb %edx, %ecx # ECX = min(16, RDX)
+ add $32, %rsi
+ bts %ecx, %r8d # mark end-of-buffer as if there was a NUL byte
+ test %r8w, %r8w # NUL or end of buffer found?
+ jnz .Lnul_found2s
+ xor $0xffff, %r9d
+ jnz .Lmismatch2s
+ sub $48, %rdx # end of buffer within first main loop iteration?
+ jb .Ltails # if yes, process tail
+
+ ALIGN_TEXT
+0: movdqu (%rsi, %rbx, 1), %xmm0 # chunk of 1st string corresponding to RSI
+ pxor %xmm1, %xmm1
+ pcmpeqb (%rsi, %rdi, 1), %xmm1 # end of string in RDI?
+ pcmpeqb (%rsi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ test %r8d, %r8d
+ jnz .Lnul_founds
+ xor $0xffff, %r9d # any mismatches?
+ jnz .Lmismatchs
+
+ /* main loop unrolled twice */
+ movdqu 16(%rsi, %rbx, 1), %xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb 16(%rsi, %rdi, 1), %xmm1
+ pcmpeqb 16(%rsi), %xmm0
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ add $32, %rsi
+ test %r8d, %r8d
+ jnz .Lnul_found2s
+ xor $0xffff, %r9d
+ jnz .Lmismatch2s
+ sub $32, %rdx # end of buffer within next iteration?
+ jae 0b
+
+ /* end of buffer will occur in next 32 bytes */
+.Ltails:
+ movdqu (%rsi, %rbx, 1), %xmm0 # chunk of 1st string corresponding to RSI
+ pxor %xmm1, %xmm1
+ pcmpeqb (%rsi, %rdi, 1), %xmm1 # end of string in RDI?
+ pcmpeqb (%rsi), %xmm0 # where do the chunks match?
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ bts %edx, %r8d # indicate NUL byte at laste byte in buffer
+ test %r8w, %r8w # NUL byte in first chunk?
+ jnz .Lnul_founds
+ xor $0xffff, %r9d # any mismatches?
+ jnz .Lmismatchs
+
+ /* main loop unrolled twice */
+ movdqu 16(%rsi, %rbx, 1), %xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb 16(%rsi, %rdi, 1), %xmm1
+ pcmpeqb 16(%rsi), %xmm0
+ pmovmskb %xmm1, %r8d
+ pmovmskb %xmm0, %r9d
+ sub $16, %edx # take first half into account
+ bts %edx, %r8d # indicate NUL byte at laste byte in buffer
+ add $32, %rsi
+
+.Lnul_found2s:
+ sub $16, %rsi
+
+.Lnul_founds:
+ mov %eax, %ecx
+ mov %r8d, %r10d
+ shl %cl, %r8d # adjust NUL mask to positions in RSI/RBX
+ not %r9d # mask of mismatches
+ or %r8w, %r9w # NUL bytes also count as mismatches
+ jnz .Lmismatchs
+
+ movdqu (%rsi, %rax, 1), %xmm0
+ pcmpeqb (%rsi, %rdi, 1), %xmm0
+ add %rsi, %rdi # restore RDI pointer
+ add %rax, %rsi # point RSI to chunk corresponding to (RDI)
+ pmovmskb %xmm0, %ecx # mask of matches
+ not %ecx # mask of mismatches
+ or %r10d, %ecx # mask of mismatches or NUL bytes
+ tzcnt %ecx, %ecx # location of first mismatch
+ movzbl (%rdi, %rcx, 1), %eax
+ movzbl (%rsi, %rcx, 1), %ecx
+ sub %ecx, %eax
+ pop %rbx
+ ret
+
+.Lmismatch2s:
+ sub $16, %rsi
+
+.Lmismatchs:
+ tzcnt %r9d, %r9d # where is the mismatch?
+ add %rsi, %rbx # turn RBX from offset into pointer
+ movzbl (%rbx, %r9, 1), %eax
+ movzbl (%rsi, %r9, 1), %ecx
+ sub %ecx, %eax
+ pop %rbx
+ ret
+ARCHEND(strncmp, baseline)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strncpy.c b/lib/libc/amd64/string/strncpy.c
new file mode 100644
index 000000000000..0e7a58222aa8
--- /dev/null
+++ b/lib/libc/amd64/string/strncpy.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+#undef strncpy /* _FORTIFY_SOURCE */
+
+char *__stpncpy(char *restrict, const char *restrict, size_t);
+
+char *
+strncpy(char *restrict dst, const char *restrict src, size_t len)
+{
+
+ __stpncpy(dst, src, len);
+
+ return (dst);
+}
diff --git a/lib/libc/amd64/string/strnlen.c b/lib/libc/amd64/string/strnlen.c
new file mode 100644
index 000000000000..74020f1b1c65
--- /dev/null
+++ b/lib/libc/amd64/string/strnlen.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <string.h>
+
+char *__memchr(const void *, int, size_t);
+
+size_t
+strnlen(const char *s, size_t maxlen)
+{
+ const char *loc;
+
+ loc = __memchr(s, '\0', maxlen);
+
+ return (loc == NULL ? maxlen : (size_t)(loc - s));
+}
diff --git a/lib/libc/amd64/string/strpbrk.c b/lib/libc/amd64/string/strpbrk.c
new file mode 100644
index 000000000000..87f587789991
--- /dev/null
+++ b/lib/libc/amd64/string/strpbrk.c
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+
+#include <string.h>
+
+size_t __strcspn(const char *, const char *);
+
+char *
+strpbrk(const char *s, const char *charset)
+{
+ size_t loc;
+
+ loc = __strcspn(s, charset);
+
+ return (s[loc] == '\0' ? NULL : (char *)&s[loc]);
+}
diff --git a/lib/libc/amd64/string/strrchr.S b/lib/libc/amd64/string/strrchr.S
new file mode 100644
index 000000000000..e397bbcd3478
--- /dev/null
+++ b/lib/libc/amd64/string/strrchr.S
@@ -0,0 +1,209 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4,0x90 # 16-byte alignment, nop-filled
+
+ .weak rindex
+ .set rindex, strrchr
+
+ARCHFUNCS(strrchr)
+ ARCHFUNC(strrchr, scalar)
+ ARCHFUNC(strrchr, baseline)
+ENDARCHFUNCS(strrchr)
+
+ARCHENTRY(strrchr, scalar)
+ mov %edi, %ecx
+ and $~7, %rdi # align to 8 byte
+ movzbl %sil, %esi # clear stray high bits
+ movabs $0x0101010101010101, %r8
+ mov (%rdi), %rax # load first word
+ imul %r8, %rsi # replicate char 8 times
+
+ /*
+ * Unaligned input: align to 8 bytes. Then proceed the same
+ * way as with aligned input, but prevent matches before the
+ * beginning of the string. This is achieved by oring 0x01
+ * into each byte of the buffer before the string
+ */
+ shl $3, %ecx
+ mov %r8, %r10
+ shl %cl, %r10 # 0x01 where the string is
+ xor %r8, %r10 # 0x01 where it is not
+ neg %r8 # negate 01..01 so we can use lea
+ movabs $0x8080808080808080, %r9
+
+ mov %rsi, %rcx
+ xor %rax, %rcx # str ^ c
+ or %r10, %rax # ensure str != 0 before string
+ or %r10, %rcx # ensure str^c != 0 before string
+ bswap %rcx # in reverse order, to find last match
+ mov %rdi, %r10 # location of initial mismatch (if any)
+ xor %r11, %r11 # initial mismatch (none)
+ add $8, %rdi # advance to next iteration
+ lea (%rax, %r8, 1), %rdx # str - 0x01..01
+ not %rax # ~str
+ and %rdx, %rax # (str - 0x01..01) & ~str
+ and %r9, %rax # not including junk bits
+ jnz 1f # end of string?
+
+ lea (%rcx, %r8, 1), %rdx # (str ^ c) - 0x01..01
+ not %rcx # ~(str ^ c)
+ and %rdx, %rcx # ((str ^ c - 0x01..01) & ~(str ^ c)
+ and %r9, %rcx # not including junk bits
+ mov %rcx, %r11 # remember mismatch in head
+ jmp 0f
+
+ /* main loop unrolled twice */
+ ALIGN_TEXT
+3: lea (%rcx, %r8, 1), %rdx # (str ^ c) - 0x01..01
+ not %rcx # ~(str ^ c)
+ and %rdx, %rcx # ((str ^ c - 0x01..01) & ~(str ^ c)
+ and %r9, %rcx # not including junk bits
+ lea -8(%rdi), %rdx
+ cmovnz %rdx, %r10 # remember location of current mismatch
+ cmovnz %rcx, %r11
+
+0: mov (%rdi), %rax # str
+ mov %rsi, %rcx
+ xor %rax, %rcx # str ^ c
+ bswap %rcx # in reverse order, to find last match
+ lea (%rax, %r8, 1), %rdx # str - 0x01..01
+ not %rax # ~str
+ and %rdx, %rax # (str - 0x01..01) & ~str
+ and %r9, %rax # not including junk bits
+ jnz 2f # end of string?
+
+ lea (%rcx, %r8, 1), %rdx # (str ^ c) - 0x01..01
+ not %rcx # ~(str ^ c)
+ and %rdx, %rcx # ((str ^ c - 0x01..01) & ~(str ^ c)
+ and %r9, %rcx # not including junk bits
+ cmovnz %rdi, %r10 # remember location of current mismatch
+ cmovnz %rcx, %r11
+
+ mov 8(%rdi), %rax # str
+ add $16, %rdi
+ mov %rsi, %rcx
+ xor %rax, %rcx # str ^ c
+ bswap %rcx
+ lea (%rax, %r8, 1), %rdx # str - 0x01..01
+ not %rax # ~str
+ and %rdx, %rax # (str - 0x01..01) & ~str
+ and %r9, %rax # not including junk bits
+ jz 3b # end of string?
+
+ /* NUL found */
+1: sub $8, %rdi # undo advance past buffer
+2: lea (%rcx, %r8, 1), %rdx # (str ^ c) - 0x01..01
+ not %rcx # ~(str ^ c)
+ and %rdx, %rcx # ((str ^ c - 0x01..01) & ~(str ^ c)
+ and %r9, %rcx # not including junk bits
+ lea -1(%rax), %rdx
+ xor %rdx, %rax # mask of bytes in the string
+ bswap %rdx # in reverse order
+ and %rdx, %rcx # c found in the tail?
+ cmovnz %rdi, %r10
+ cmovnz %rcx, %r11
+ bswap %r11 # unreverse byte order
+ bsr %r11, %rcx # last location of c in (R10)
+ shr $3, %rcx # as byte offset
+ lea (%r10, %rcx, 1), %rax # pointer to match
+ test %r11, %r11 # was there actually a match?
+ cmovz %r11, %rax # if not, return null pointer
+ ret
+ARCHEND(strrchr, scalar)
+
+ARCHENTRY(strrchr, baseline)
+ mov %edi, %ecx
+ and $~0xf, %rdi # align to 16 bytes
+ movdqa (%rdi), %xmm1
+ movd %esi, %xmm0
+ and $0xf, %ecx # offset from alignment
+ pxor %xmm2, %xmm2
+ mov $-1, %edx
+ punpcklbw %xmm0, %xmm0 # c -> cc
+ shl %cl, %edx # bits corresponding to bytes in the string
+ punpcklwd %xmm0, %xmm0 # cc -> cccc
+ xor %r8, %r8 # address of latest match
+ mov $1, %esi # bit mask of latest match
+ mov %rdi, %r9 # candidate location for next match
+ add $16, %rdi # advance to next chunk
+
+ /* check for match in head */
+ pcmpeqb %xmm1, %xmm2 # NUL byte present?
+ pshufd $0, %xmm0, %xmm0 # cccc -> cccccccccccccccc
+ pcmpeqb %xmm0, %xmm1 # c present?
+ pmovmskb %xmm2, %eax
+ pmovmskb %xmm1, %ecx
+ and %edx, %ecx # c present in the string?
+ and %edx, %eax # NUL present in the string?
+ jnz .Lend2
+
+ /* main loop unrolled twice */
+ ALIGN_TEXT
+0: movdqa (%rdi), %xmm1
+ test %ecx, %ecx # was there a match in the last iter.?
+ cmovnz %r9, %r8 # remember match if any
+ cmovnz %ecx, %esi
+ pxor %xmm2, %xmm2
+ pcmpeqb %xmm1, %xmm2 # NUL byte present?
+ pcmpeqb %xmm0, %xmm1 # c present?
+ pmovmskb %xmm2, %eax
+ pmovmskb %xmm1, %ecx
+ test %eax, %eax # end of string in first half?
+ jnz .Lend
+
+ movdqa 16(%rdi), %xmm1
+ test %ecx, %ecx # was there a match in the last iter.?
+ cmovnz %rdi, %r8 # remember match if any
+ cmovnz %ecx, %esi
+ pxor %xmm2, %xmm2
+ pcmpeqb %xmm1, %xmm2 # NUL byte present?
+ pcmpeqb %xmm0, %xmm1 # c present?
+ pmovmskb %xmm2, %eax
+ pmovmskb %xmm1, %ecx
+ lea 16(%rdi), %r9
+ add $32, %rdi
+ test %eax, %eax # end of string in second half?
+ jz 0b
+
+ ALIGN_TEXT
+.Lend2: sub $16, %rdi
+.Lend: lea -1(%rax), %edx
+ xor %edx, %eax # mask of bytes in the string
+ and %eax, %ecx # c found in the tail?
+ cmovnz %rdi, %r8
+ cmovnz %ecx, %esi
+ bsr %esi, %esi # last location of c in (R8)
+ lea (%r8, %rsi, 1), %rax # pointer to match
+ ret
+ARCHEND(strrchr, baseline)
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/strsep.c b/lib/libc/amd64/string/strsep.c
new file mode 100644
index 000000000000..9fda56d7e135
--- /dev/null
+++ b/lib/libc/amd64/string/strsep.c
@@ -0,0 +1,57 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+#include <string.h>
+
+size_t __strcspn(const char *, const char *);
+
+/*
+ * We have a fast strcspn() on amd64. Use it over a direct
+ * implementation of strsep for better performance.
+ */
+char *
+strsep(char **stringp, const char *delim)
+{
+ size_t n;
+ char *s;
+
+ s = *stringp;
+ if (s == NULL)
+ return (NULL);
+
+ n = __strcspn(s, delim);
+ if (s[n] == '\0')
+ *stringp = NULL;
+ else {
+ s[n] = '\0';
+ *stringp = s + n + 1;
+ }
+
+ return (s);
+}
diff --git a/lib/libc/amd64/string/strspn.S b/lib/libc/amd64/string/strspn.S
new file mode 100644
index 000000000000..565330f0c385
--- /dev/null
+++ b/lib/libc/amd64/string/strspn.S
@@ -0,0 +1,358 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+#include <machine/param.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+ARCHFUNCS(strspn)
+ ARCHFUNC(strspn, scalar)
+ NOARCHFUNC
+ ARCHFUNC(strspn, x86_64_v2)
+ENDARCHFUNCS(strspn)
+
+ARCHENTRY(strspn, scalar)
+ push %rbp # align stack to enable function call
+ mov %rsp, %rbp
+ sub $256, %rsp # allocate space for lookup table
+
+ /* check for special cases */
+ movzbl (%rsi), %edx # first character in the set
+ test %edx, %edx
+ jz .Lzero # empty set always returns 0
+
+ movzbl 1(%rsi), %eax # second character in the set
+ test %eax, %eax
+ jz .Lsingle
+
+ /* no special case matches -- prepare lookup table */
+ xor %r8d, %r8d
+ mov $28, %ecx
+0: mov %r8, (%rsp, %rcx, 8)
+ mov %r8, 8(%rsp, %rcx, 8)
+ mov %r8, 16(%rsp, %rcx, 8)
+ mov %r8, 24(%rsp, %rcx, 8)
+ sub $4, %ecx
+ jnc 0b
+
+ movb $1, (%rsp, %rdx, 1) # register first char in set
+ add $2, %rsi
+
+ /* process remaining chars in set */
+ ALIGN_TEXT
+0: movb $1, (%rsp, %rax, 1) # register previous char
+ movzbl (%rsi), %eax # next char in set
+ test %eax, %eax # end of string?
+ jz 1f
+
+ movb $1, (%rsp, %rax, 1)
+ add $2, %rsi
+ movzbl -1(%rsi), %eax
+ test %eax, %eax
+ jnz 0b
+
+1: mov %rdi, %rax # a copy of the source to iterate over
+
+ /* find mismatch */
+ ALIGN_TEXT
+0: movzbl (%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ je 2f
+
+ movzbl 1(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ je 3f
+
+ movzbl 2(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ je 4f
+
+ movzbl 3(%rax), %ecx
+ add $4, %rax
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 0b
+
+ sub $3, %rax
+4: dec %rdi
+3: inc %rax
+2: sub %rdi, %rax # number of characters preceding match
+ leave
+ ret
+
+ /* empty set never matches */
+.Lzero: xor %eax, %eax
+ leave
+ ret
+
+ /* find repeated single character */
+ ALIGN_TEXT
+.Lsingle:
+ cmpb %dl, (%rdi, %rax, 1)
+ jne 1f
+
+ cmpb %dl, 1(%rdi, %rax, 1)
+ jne 2f
+
+ cmpb %dl, 2(%rdi, %rax, 1)
+ jne 3f
+
+ cmpb %dl, 3(%rdi, %rax, 1)
+ lea 4(%rax), %rax
+ je .Lsingle
+
+ sub $3, %rax
+3: inc %rax
+2: inc %rax
+1: leave
+ ret
+ARCHEND(strspn, scalar)
+
+ /*
+ * This kernel uses pcmpistri to do the heavy lifting.
+ * We provide three code paths, depending on set size:
+ *
+ * 0--16: one pcmpistri per 16 bytes of input
+ * 17--32: two pcmpistri per 16 bytes of input
+ * >=33: fall back to look up table
+ */
+ARCHENTRY(strspn, x86_64_v2)
+ push %rbp
+ mov %rsp, %rbp
+ sub $256, %rsp
+
+ /* find set size and copy up to 32 bytes to (%rsp) */
+ mov %esi, %ecx
+ and $~0xf, %rsi # align set pointer
+ movdqa (%rsi), %xmm0
+ pxor %xmm1, %xmm1
+ and $0xf, %ecx # amount of bytes rsi is past alignment
+ xor %edx, %edx
+ pcmpeqb %xmm0, %xmm1 # end of string reached?
+ movdqa %xmm0, 32(%rsp) # transfer head of set to stack
+ pmovmskb %xmm1, %eax
+ shr %cl, %eax # clear out junk before string
+ test %eax, %eax # end of set reached?
+ jnz 0f
+
+ movdqa 16(%rsi), %xmm0 # second chunk of the set
+ mov $16, %edx
+ sub %ecx, %edx # length of set preceding xmm0
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm0, %xmm1
+ movdqa %xmm0, 48(%rsp)
+ movdqu 32(%rsp, %rcx, 1), %xmm2 # head of set
+ pmovmskb %xmm1, %eax
+ test %eax, %eax
+ jnz 1f
+
+ movdqa 32(%rsi), %xmm0 # third chunk
+ add $16, %edx
+ pxor %xmm1, %xmm1
+ pcmpeqb %xmm0, %xmm1
+ movdqa %xmm0, 64(%rsp)
+ pmovmskb %xmm1, %eax
+ test %eax, %eax # still not done?
+ jz .Lgt32v2
+
+0: movdqu 32(%rsp, %rcx, 1), %xmm2 # head of set
+1: tzcnt %eax, %eax
+ add %eax, %edx # length of set (excluding NUL byte)
+ cmp $32, %edx # above 32 bytes?
+ ja .Lgt32v2
+
+ /*
+ * At this point we know that we want to use pcmpistri.
+ * one last problem obtains: the head of the string is not
+ * aligned and may cross a cacheline. If this is the case,
+ * we take the part before the page boundary and repeat the
+ * last byte to fill up the xmm register.
+ */
+ mov %rdi, %rax # save original string pointer
+ lea 15(%rdi), %esi # last byte of the head
+ xor %edi, %esi
+ test $PAGE_SIZE, %esi # does the head cross a page?
+ jz 0f
+
+ /* head crosses page: copy to stack to fix up */
+ and $~0xf, %rax # align head pointer temporarily
+ movzbl 15(%rax), %esi # last head byte on the page
+ movdqa (%rax), %xmm0
+ movabs $0x0101010101010101, %r8
+ imul %r8, %rsi # repeated 8 times
+ movdqa %xmm0, (%rsp) # head word on stack
+ mov %rsi, 16(%rsp) # followed by filler (last byte x8)
+ mov %rsi, 24(%rsp)
+ mov %edi, %eax
+ and $0xf, %eax # offset of head from alignment
+ add %rsp, %rax # pointer to fake head
+
+0: movdqu (%rax), %xmm1 # load head (fake or real)
+ lea 16(%rdi), %rax
+ and $~0xf, %rax # second 16 bytes of string (aligned)
+1: cmp $16, %edx # 16--32 bytes?
+ ja .Lgt16v2
+
+
+ /* set is 2--16 bytes in size */
+
+ /* _SIDD_UBYTE_OPS|_SIDD_CMP_EQUAL_ANY|_SIDD_LEAST_SIGNIFICANT|_SIDD_NEGATIVE_POLARITY */
+ pcmpistri $0x10, %xmm1, %xmm2 # match in head?
+ jc .Lheadmismatchv2
+
+ ALIGN_TEXT
+0: pcmpistri $0x10, (%rax), %xmm2
+ jc 1f # match or end of string?
+ pcmpistri $0x10, 16(%rax), %xmm2
+ lea 32(%rax), %rax
+ jnc 0b # match or end of string?
+
+ sub $16, %rax # go back to second half
+1: sub %rdi, %rax # offset of (%rax) from beginning of string
+ add %rcx, %rax # prefix length before match/NUL
+ leave
+ ret
+
+.Lheadmismatchv2:
+ mov %ecx, %eax # prefix length before mismatch/NUL
+ leave
+ ret
+
+ /* set is 17--32 bytes in size */
+.Lgt16v2:
+ movdqu 48(%rsp, %rcx, 1), %xmm3 # second part of set
+
+ /* _SIDD_UBYTE_OPS|_SIDD_CMP_EQUAL_ANY|_SIDD_BIT_MASK|_SIDD_NEGATIVE_POLARITY */
+ pcmpistrm $0x10, %xmm1, %xmm2 # any mismatch in first half?
+ movdqa %xmm0, %xmm4
+ pcmpistrm $0x10, %xmm1, %xmm3 # any mismatch in the second half?
+ ptest %xmm0, %xmm4 # any entry that doesn't match either?
+ jnz 2f
+
+ ALIGN_TEXT
+0: movdqa (%rax), %xmm1
+ pcmpistrm $0x10, %xmm1, %xmm2
+ movdqa %xmm0, %xmm4
+ pcmpistrm $0x10, %xmm1, %xmm3
+ ptest %xmm0, %xmm4
+ jnz 1f
+ movdqa 16(%rax), %xmm1
+ add $32, %rax
+ pcmpistrm $0x10, %xmm1, %xmm2
+ movdqa %xmm0, %xmm4
+ pcmpistrm $0x10, %xmm1, %xmm3
+ ptest %xmm0, %xmm4
+ jz 0b
+
+ sub $16, %rax
+1: pand %xmm4, %xmm0
+ movd %xmm0, %ecx
+ sub %rdi, %rax # offset of %xmm1 from beginning of string
+ tzcnt %ecx, %ecx
+ add %rcx, %rax # prefix length before match/NUL
+ leave
+ ret
+
+ /* mismatch or string end in head */
+2: pand %xmm4, %xmm0 # bit mask of mismatches (end of string counts)
+ movd %xmm0, %eax
+ tzcnt %eax, %eax # prefix length before mismatch/NUL
+ leave
+ ret
+
+ /* set is >=33 bytes in size */
+.Lgt32v2:
+ xorps %xmm0, %xmm0
+ mov $256-64, %edx
+
+ /* clear out look up table */
+0: movaps %xmm0, (%rsp, %rdx, 1)
+ movaps %xmm0, 16(%rsp, %rdx, 1)
+ movaps %xmm0, 32(%rsp, %rdx, 1)
+ movaps %xmm0, 48(%rsp, %rdx, 1)
+ sub $64, %edx
+ jnc 0b
+
+ add %rcx, %rsi # restore string pointer
+ mov %rdi, %rax # keep a copy of the string
+
+ /* initialise look up table */
+ movzbl (%rsi), %ecx # string is known not to be empty
+
+ ALIGN_TEXT
+0: movb $1, (%rsp, %rcx, 1)
+ movzbl 1(%rsi), %ecx
+ test %ecx, %ecx
+ jz 1f
+
+ movb $1, (%rsp, %rcx, 1)
+ movzbl 2(%rsi), %ecx
+ test %ecx, %ecx
+ jz 1f
+
+ movb $1, (%rsp, %rcx, 1)
+ movzbl 3(%rsi), %ecx
+ add $4, %rsi
+ test %ecx, %ecx
+ jz 1f
+
+ movb $1, (%rsp, %rcx, 1)
+ movzbl (%rsi), %ecx
+ test %ecx, %ecx
+ jnz 0b
+
+ /* find match */
+ ALIGN_TEXT
+1: movzbl (%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ je 2f
+
+ movzbl 1(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ je 3f
+
+ movzbl 2(%rax), %ecx
+ cmpb $0, (%rsp, %rcx, 1)
+ je 4f
+
+ movzbl 3(%rax), %ecx
+ add $4, %rax
+ cmpb $0, (%rsp, %rcx, 1)
+ jne 1b
+
+ sub $3, %rax
+4: dec %rdi
+3: inc %rax
+2: sub %rdi, %rax # number of characters preceding match
+ leave
+ ret
+ARCHEND(strspn, x86_64_v2)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/timingsafe_bcmp.S b/lib/libc/amd64/string/timingsafe_bcmp.S
new file mode 100644
index 000000000000..c003da2ea9a7
--- /dev/null
+++ b/lib/libc/amd64/string/timingsafe_bcmp.S
@@ -0,0 +1,232 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#include "amd64_archlevel.h"
+
+#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+ARCHFUNCS(timingsafe_bcmp)
+ ARCHFUNC(timingsafe_bcmp, scalar)
+ ARCHFUNC(timingsafe_bcmp, baseline)
+ENDARCHFUNCS(timingsafe_bcmp)
+
+ARCHENTRY(timingsafe_bcmp, scalar)
+ cmp $16, %rdx # at least 17 bytes to process?
+ ja .Lgt16
+
+ cmp $8, %edx # at least 9 bytes to process?
+ ja .L0916
+
+ cmp $4, %edx # at least 5 bytes to process?
+ ja .L0508
+
+ cmp $2, %edx # at least 3 bytes to process?
+ ja .L0304
+
+ test %edx, %edx # buffer empty?
+ jnz .L0102
+
+ xor %eax, %eax # empty buffer always matches
+ ret
+
+.L0102: movzbl (%rdi), %eax # load 1--2 bytes from first buffer
+ movzbl -1(%rdi, %rdx, 1), %ecx
+ xor (%rsi), %al # xor in second buffer
+ xor -1(%rsi, %rdx, 1), %cl
+ or %ecx, %eax # mismatch in any of the two?
+ ret
+
+.L0304: movzwl (%rdi), %eax
+ movzwl -2(%rdi, %rdx, 1), %ecx
+ xor (%rsi), %ax
+ xor -2(%rsi, %rdx, 1), %cx
+ or %ecx, %eax
+ ret
+
+.L0508: mov (%rdi), %eax
+ mov -4(%rdi, %rdx, 1), %ecx
+ xor (%rsi), %eax
+ xor -4(%rsi, %rdx, 1), %ecx
+ or %ecx, %eax
+ ret
+
+.L0916: mov (%rdi), %rax
+ mov -8(%rdi, %rdx, 1), %rcx
+ xor (%rsi), %rax
+ xor -8(%rsi, %rdx, 1), %rcx
+ or %rcx, %rax
+ setnz %al # ensure EAX nonzero even if only
+ ret # high bits of RAX were set
+
+ /* more than 16 bytes: process buffer in a loop */
+.Lgt16: mov (%rdi), %rax # process first 16 bytes
+ mov 8(%rdi), %r9
+ mov $32, %ecx
+ xor (%rsi), %rax
+ xor 8(%rsi), %r9
+ or %r9, %rax
+
+ cmp %rdx, %rcx # enough left for a full iteration?
+ jae .Ltail
+
+ /* main loop processing 16 bytes per iteration */
+ ALIGN_TEXT
+0: mov -16(%rdi, %rcx, 1), %r8
+ mov -8(%rdi, %rcx, 1), %r9
+ xor -16(%rsi, %rcx, 1), %r8
+ xor -8(%rsi, %rcx, 1), %r9
+ add $16, %rcx
+ or %r9, %r8
+ or %r8, %rax
+
+ cmp %rdx, %rcx
+ jb 0b
+
+ /* process last 16 bytes */
+.Ltail: mov -16(%rdi, %rdx, 1), %r8
+ mov -8(%rdi, %rdx, 1), %r9
+ xor -16(%rsi, %rdx, 1), %r8
+ xor -8(%rsi, %rdx, 1), %r9
+ or %r9, %r8
+ or %r8, %rax
+ setnz %al
+ ret
+ARCHEND(timingsafe_bcmp, scalar)
+
+ARCHENTRY(timingsafe_bcmp, baseline)
+ cmp $32, %rdx # at least 33 bytes to process?
+ ja .Lgt32b
+
+ cmp $16, %edx # at least 17 bytes to process?
+ ja .L1732b
+
+ cmp $8, %edx # at least 9 bytes to process?
+ ja .L0916b
+
+ cmp $4, %edx # at least 5 bytes to process?
+ ja .L0508b
+
+ cmp $2, %edx # at least 3 bytes to process?
+ ja .L0304b
+
+ test %edx, %edx # buffer empty?
+ jnz .L0102b
+
+ xor %eax, %eax # empty buffer always matches
+ ret
+
+.L0102b:
+ movzbl (%rdi), %eax # load 1--2 bytes from first buffer
+ movzbl -1(%rdi, %rdx, 1), %ecx
+ xor (%rsi), %al # xor in second buffer
+ xor -1(%rsi, %rdx, 1), %cl
+ or %ecx, %eax # mismatch in any of the two?
+ ret
+
+.L0304b:
+ movzwl (%rdi), %eax
+ movzwl -2(%rdi, %rdx, 1), %ecx
+ xor (%rsi), %ax
+ xor -2(%rsi, %rdx, 1), %cx
+ or %ecx, %eax
+ ret
+
+.L0508b:
+ mov (%rdi), %eax
+ mov -4(%rdi, %rdx, 1), %ecx
+ xor (%rsi), %eax
+ xor -4(%rsi, %rdx, 1), %ecx
+ or %ecx, %eax
+ ret
+
+.L0916b:
+ mov (%rdi), %rax
+ mov -8(%rdi, %rdx, 1), %rcx
+ xor (%rsi), %rax
+ xor -8(%rsi, %rdx, 1), %rcx
+ or %rcx, %rax
+ setnz %al # ensure EAX nonzero even if only
+ ret # high bits of RAX were set
+
+.L1732b:
+ movdqu (%rdi), %xmm0
+ movdqu (%rsi), %xmm2
+ movdqu -16(%rdi, %rdx, 1), %xmm1
+ movdqu -16(%rsi, %rdx, 1), %xmm3
+ pcmpeqb %xmm2, %xmm0
+ pcmpeqb %xmm3, %xmm1
+ pand %xmm1, %xmm0
+ pmovmskb %xmm0, %eax # 1 where equal
+ xor $0xffff, %eax # 1 where not equal
+ ret
+
+ /* more than 32 bytes: process buffer in a loop */
+.Lgt32b:
+ movdqu (%rdi), %xmm4
+ movdqu (%rsi), %xmm2
+ movdqu 16(%rdi), %xmm1
+ movdqu 16(%rsi), %xmm3
+ mov $64, %ecx
+ pcmpeqb %xmm2, %xmm4
+ pcmpeqb %xmm3, %xmm1
+ pand %xmm1, %xmm4
+ cmp %rdx, %rcx # enough left for a full iteration?
+ jae .Ltailb
+
+ /* main loop processing 32 bytes per iteration */
+ ALIGN_TEXT
+0: movdqu -32(%rdi, %rcx, 1), %xmm0
+ movdqu -32(%rsi, %rcx, 1), %xmm2
+ movdqu -16(%rdi, %rcx, 1), %xmm1
+ movdqu -16(%rsi, %rcx, 1), %xmm3
+ add $32, %rcx
+ pcmpeqb %xmm2, %xmm0
+ pcmpeqb %xmm3, %xmm1
+ pand %xmm1, %xmm0
+ pand %xmm0, %xmm4
+ cmp %rdx, %rcx
+ jb 0b
+
+ /* process last 32 bytes */
+.Ltailb:
+ movdqu -32(%rdi, %rdx, 1), %xmm0
+ movdqu -32(%rsi, %rdx, 1), %xmm2
+ movdqu -16(%rdi, %rdx, 1), %xmm1
+ movdqu -16(%rsi, %rdx, 1), %xmm3
+ pcmpeqb %xmm2, %xmm0
+ pcmpeqb %xmm3, %xmm1
+ pand %xmm1, %xmm0
+ pand %xmm4, %xmm0
+ pmovmskb %xmm0, %eax
+ xor $0xffff, %eax
+ ret
+ARCHEND(timingsafe_bcmp, baseline)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/timingsafe_memcmp.S b/lib/libc/amd64/string/timingsafe_memcmp.S
new file mode 100644
index 000000000000..3f1eccdbd640
--- /dev/null
+++ b/lib/libc/amd64/string/timingsafe_memcmp.S
@@ -0,0 +1,145 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <machine/asm.h>
+
+#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+/* int timingsafe_memcmp(const void *rdi, const void *rsi, size_t rdx) */
+ENTRY(timingsafe_memcmp)
+ cmp $16, %rdx # at least 17 bytes to process?
+ ja .Lgt16
+
+ cmp $8, %edx # at least 9 bytes to process?
+ ja .L0916
+
+ cmp $4, %edx # at least 5 bytes to process?
+ ja .L0508
+
+ cmp $2, %edx # at least 3 bytes to process?
+ ja .L0304
+
+ test %edx, %edx # buffer empty?
+ jnz .L0102
+
+ xor %eax, %eax # empty buffer always matches
+ ret
+
+.L0102: movzbl -1(%rdi, %rdx, 1), %eax # load 1--2 bytes from first buffer
+ movzbl -1(%rsi, %rdx, 1), %ecx
+ mov (%rdi), %ah # in big endian
+ mov (%rsi), %ch
+ sub %ecx, %eax
+ ret
+
+.L0304: movzwl -2(%rdi, %rdx, 1), %ecx
+ movzwl -2(%rsi, %rdx, 1), %edx
+ movzwl (%rdi), %eax
+ movzwl (%rsi), %esi
+ bswap %ecx # convert to big endian
+ bswap %edx # dito for edx, (e)ax, and (e)si
+ rol $8, %ax # ROLW is used here so the upper two
+ rol $8, %si # bytes stay clear, allowing us to
+ sub %edx, %ecx # save a SBB compared to .L0508
+ sbb %esi, %eax
+ or %eax, %ecx # nonzero if not equal
+ setnz %al
+ ret
+
+.L0508: mov -4(%rdi, %rdx, 1), %ecx
+ mov -4(%rsi, %rdx, 1), %edx
+ mov (%rdi), %edi
+ mov (%rsi), %esi
+ bswap %ecx # compare in big endian
+ bswap %edx
+ bswap %edi
+ bswap %esi
+ sub %edx, %ecx
+ sbb %esi, %edi
+ sbb %eax, %eax # -1 if less, 0 if greater or equal
+ or %edi, %ecx # nonzero if not equal
+ setnz %al # negative if <, 0 if =, 1 if >
+ ret
+
+.L0916: mov -8(%rdi, %rdx, 1), %rcx
+ mov -8(%rsi, %rdx, 1), %rdx
+ mov (%rdi), %rdi
+ mov (%rsi), %rsi
+ bswap %rcx # compare in big endian
+ bswap %rdx
+ bswap %rdi
+ bswap %rsi
+ sub %rdx, %rcx
+ sbb %rsi, %rdi
+ sbb %eax, %eax # -1 if less, 0 if greater or equal
+ or %rdi, %rcx # nonzero if not equal
+ setnz %al # negative if <, 0 if =, 1 if >
+ ret
+
+ /* compare 17+ bytes */
+.Lgt16: mov (%rdi), %r8 # process first 16 bytes
+ mov (%rsi), %r9
+ mov $32, %ecx
+ cmp %r8, %r9 # mismatch in head?
+ cmove 8(%rdi), %r8 # if not, try second pair
+ cmove 8(%rsi), %r9
+ cmp %rdx, %rcx
+ jae .Ltail
+
+ /* main loop processing 16 bytes per iteration */
+ ALIGN_TEXT
+0: mov -16(%rdi, %rcx, 1), %r10
+ mov -16(%rsi, %rcx, 1), %r11
+ cmp %r10, %r11 # mismatch in first pair?
+ cmove -8(%rdi, %rcx, 1), %r10 # if not, try second pair
+ cmove -8(%rsi, %rcx, 1), %r11
+ cmp %r8, %r9 # was there a mismatch previously?
+ cmove %r10, %r8 # apply new pair if there was not
+ cmove %r11, %r9
+ add $16, %rcx
+ cmp %rdx, %rcx
+ jb 0b
+
+.Ltail: mov -8(%rdi, %rdx, 1), %r10
+ mov -8(%rsi, %rdx, 1), %r11
+ cmp %r8, %r9
+ cmove -16(%rdi, %rdx, 1), %r8
+ cmove -16(%rsi, %rdx, 1), %r9
+ bswap %r10 # compare in big endian
+ bswap %r11
+ bswap %r8
+ bswap %r9
+ sub %r11, %r10
+ sbb %r9, %r8
+ sbb %eax, %eax # -1 if less, 0 if greater or equal
+ or %r10, %r8 # nonzero if not equal
+ setnz %al # negative if <, 0 if =, 1 if >
+ ret
+END(timingsafe_memcmp)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc
deleted file mode 100644
index 43af1d2a85a2..000000000000
--- a/lib/libc/amd64/sys/Makefile.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp
-
-SRCS+= \
- amd64_get_fsbase.c \
- amd64_get_gsbase.c \
- amd64_set_fsbase.c \
- amd64_set_gsbase.c
-
-MDASM= vfork.S cerror.S getcontext.S
-
-# Don't generate default code for these syscalls:
-NOASM+= sbrk.o vfork.o
diff --git a/lib/libc/amd64/sys/amd64_get_fsbase.c b/lib/libc/amd64/sys/amd64_get_fsbase.c
deleted file mode 100644
index 4784bb0baf42..000000000000
--- a/lib/libc/amd64/sys/amd64_get_fsbase.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2003 Peter Wemm
- * Copyright (c) 2017, 2018 The FreeBSD Foundation
- * All rights reserved.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#define _WANT_P_OSREL
-#include <sys/param.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/sysarch.h>
-#include <x86/ifunc.h>
-#include "libc_private.h"
-
-static int
-amd64_get_fsbase_cpu(void **addr)
-{
-
- *addr = (void *)rdfsbase();
- return (0);
-}
-
-static int
-amd64_get_fsbase_syscall(void **addr)
-{
-
- return (sysarch(AMD64_GET_FSBASE, addr));
-}
-
-DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **))
-{
-
- if (__getosreldate() >= P_OSREL_WRFSBASE &&
- (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
- return (amd64_get_fsbase_cpu);
- return (amd64_get_fsbase_syscall);
-}
diff --git a/lib/libc/amd64/sys/amd64_get_gsbase.c b/lib/libc/amd64/sys/amd64_get_gsbase.c
deleted file mode 100644
index c81773c4b78c..000000000000
--- a/lib/libc/amd64/sys/amd64_get_gsbase.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2003 Peter Wemm
- * Copyright (c) 2017, 2018 The FreeBSD Foundation
- * All rights reserved.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#define _WANT_P_OSREL
-#include <sys/param.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/sysarch.h>
-#include <x86/ifunc.h>
-#include "libc_private.h"
-
-static int
-amd64_get_gsbase_cpu(void **addr)
-{
-
- *addr = (void *)rdgsbase();
- return (0);
-}
-
-static int
-amd64_get_gsbase_syscall(void **addr)
-{
-
- return (sysarch(AMD64_GET_GSBASE, addr));
-}
-
-DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **))
-{
-
- if (__getosreldate() >= P_OSREL_WRFSBASE &&
- (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
- return (amd64_get_gsbase_cpu);
- return (amd64_get_gsbase_syscall);
-}
diff --git a/lib/libc/amd64/sys/amd64_set_fsbase.c b/lib/libc/amd64/sys/amd64_set_fsbase.c
deleted file mode 100644
index 24dddcad48f8..000000000000
--- a/lib/libc/amd64/sys/amd64_set_fsbase.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2003 Peter Wemm
- * Copyright (c) 2017, 2018 The FreeBSD Foundation
- * All rights reserved.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#define _WANT_P_OSREL
-#include <sys/param.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/sysarch.h>
-#include <x86/ifunc.h>
-#include "libc_private.h"
-
-static int
-amd64_set_fsbase_cpu(void *addr)
-{
-
- wrfsbase((uintptr_t)addr);
- return (0);
-}
-
-static int
-amd64_set_fsbase_syscall(void *addr)
-{
-
- return (sysarch(AMD64_SET_FSBASE, &addr));
-}
-
-DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *))
-{
-
- if (__getosreldate() >= P_OSREL_WRFSBASE &&
- (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
- return (amd64_set_fsbase_cpu);
- return (amd64_set_fsbase_syscall);
-}
diff --git a/lib/libc/amd64/sys/amd64_set_gsbase.c b/lib/libc/amd64/sys/amd64_set_gsbase.c
deleted file mode 100644
index 10004afe8234..000000000000
--- a/lib/libc/amd64/sys/amd64_set_gsbase.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2003 Peter Wemm
- * Copyright (c) 2017, 2018 The FreeBSD Foundation
- * All rights reserved.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#define _WANT_P_OSREL
-#include <sys/param.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/sysarch.h>
-#include <x86/ifunc.h>
-#include "libc_private.h"
-
-static int
-amd64_set_gsbase_cpu(void *addr)
-{
-
- wrgsbase((uintptr_t)addr);
- return (0);
-}
-
-static int
-amd64_set_gsbase_syscall(void *addr)
-{
-
- return (sysarch(AMD64_SET_GSBASE, &addr));
-}
-
-DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *))
-{
-
- if (__getosreldate() >= P_OSREL_WRFSBASE &&
- (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
- return (amd64_set_gsbase_cpu);
- return (amd64_set_gsbase_syscall);
-}
diff --git a/lib/libc/amd64/sys/cerror.S b/lib/libc/amd64/sys/cerror.S
deleted file mode 100644
index d0b11888562e..000000000000
--- a/lib/libc/amd64/sys/cerror.S
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- */
-
-#if defined(SYSLIBC_SCCS) && !defined(lint)
- .asciz "@(#)cerror.s 5.1 (Berkeley) 4/23/90"
-#endif /* SYSLIBC_SCCS and not lint */
-#include <machine/asm.h>
-#include "SYS.h"
-
- .globl HIDENAME(cerror)
- .hidden HIDENAME(cerror)
-
- /*
- * The __error() function is thread aware. For non-threaded
- * programs and the initial thread in threaded programs,
- * it returns a pointer to the global errno variable.
- */
- .globl CNAME(__error)
- .type CNAME(__error),@function
-HIDENAME(cerror):
- pushq %rax
- call PIC_PLT(CNAME(__error))
- popq %rcx
- movl %ecx,(%rax)
- movq $-1,%rax
- movq $-1,%rdx
- ret
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/sys/getcontext.S b/lib/libc/amd64/sys/getcontext.S
deleted file mode 100644
index 6860a3cf9bef..000000000000
--- a/lib/libc/amd64/sys/getcontext.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2003 Peter Wemm <peter@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.
- */
-
-#include <machine/asm.h>
-#include <SYS.h>
-
-/*
- * This has to be magic to handle the multiple returns.
- * Otherwise, the setcontext() syscall will return here and we'll
- * pop off the return address and go to the *setcontext* call.
- */
- WEAK_REFERENCE(__sys_getcontext, _getcontext)
- WEAK_REFERENCE(__sys_getcontext, getcontext)
-ENTRY(__sys_getcontext)
- movq (%rsp),%rsi /* save getcontext return address */
- mov $SYS_getcontext,%rax
- KERNCALL
- jb HIDENAME(cerror)
- addq $8,%rsp /* remove stale (setcontext) return address */
- jmp *%rsi /* restore return address */
-END(__sys_getcontext)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S
deleted file mode 100644
index 11faadc6b310..000000000000
--- a/lib/libc/amd64/sys/vfork.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- */
-
-#if defined(SYSLIBC_SCCS) && !defined(lint)
- .asciz "@(#)Ovfork.s 5.1 (Berkeley) 4/23/90"
-#endif /* SYSLIBC_SCCS and not lint */
-#include <machine/asm.h>
-#include "SYS.h"
-
- WEAK_REFERENCE(__sys_vfork, _vfork)
- WEAK_REFERENCE(__sys_vfork, vfork)
-ENTRY(__sys_vfork)
- popq %rsi /* fetch return address (%rsi preserved) */
- mov $SYS_vfork,%rax
- KERNCALL
- jb 1f
- jmp *%rsi
-1:
- pushq %rsi
- jmp HIDENAME(cerror)
-END(__sys_vfork)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/arm/SYS.h b/lib/libc/arm/SYS.h
deleted file mode 100644
index 97e37d6aca7d..000000000000
--- a/lib/libc/arm/SYS.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */
-
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- *
- * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91
- */
-
-#include <machine/asm.h>
-#include <sys/syscall.h>
-
-#define SYSTRAP(x) \
- mov ip, r7; \
- ldr r7, =SYS_ ## x; \
- swi 0; \
- mov r7, ip
-
-#define CERROR _C_LABEL(cerror)
-#define CURBRK _C_LABEL(curbrk)
-
-#define _SYSCALL_NOERROR(x) \
- ENTRY(__CONCAT(__sys_, x)); \
- .weak _C_LABEL(x); \
- .set _C_LABEL(x), _C_LABEL(__CONCAT(__sys_,x)); \
- .weak _C_LABEL(__CONCAT(_,x)); \
- .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \
- SYSTRAP(x)
-
-#define _SYSCALL(x) \
- _SYSCALL_NOERROR(x); \
- it cs; \
- bcs PIC_SYM(CERROR, PLT)
-
-#define SYSCALL(x) \
- _SYSCALL(x)
-
-#define PSEUDO(x) \
- ENTRY(__CONCAT(__sys_, x)); \
- .weak _C_LABEL(__CONCAT(_,x)); \
- .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \
- SYSTRAP(x); \
- it cs; \
- bcs PIC_SYM(CERROR, PLT); \
- RET
-
-#define RSYSCALL(x) \
- _SYSCALL(x); \
- RET
-
- .globl CERROR
diff --git a/lib/libc/arm/Symbol.map b/lib/libc/arm/Symbol.map
index 7b3d173d72ed..49476d2e176a 100644
--- a/lib/libc/arm/Symbol.map
+++ b/lib/libc/arm/Symbol.map
@@ -1,32 +1,11 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
__mcount;
- _setjmp;
- _longjmp;
alloca;
- fabs;
- __infinity;
- __nan;
- makecontext;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- vfork;
brk;
sbrk;
};
@@ -46,19 +25,13 @@ FBSD_1.6 {
};
FBSDprivate_1.0 {
- /* PSEUDO syscalls */
- _getlogin;
-
+ _brk;
__aeabi_read_tp;
___longjmp;
- __makecontext;
__longjmp;
signalcontext;
- _signalcontext;
+ __signalcontext;
__siglongjmp;
- _vfork;
- _brk;
- _sbrk;
_libc_arm_fpu_present;
};
diff --git a/lib/libc/arm/aeabi/Makefile.inc b/lib/libc/arm/aeabi/Makefile.inc
index 08158f1d8e63..ef9ff746060f 100644
--- a/lib/libc/arm/aeabi/Makefile.inc
+++ b/lib/libc/arm/aeabi/Makefile.inc
@@ -1,4 +1,3 @@
-
.PATH: ${LIBC_SRCTOP}/arm/aeabi
SRCS+= aeabi_atexit.c \
diff --git a/lib/libc/arm/aeabi/Symbol.map b/lib/libc/arm/aeabi/Symbol.map
index 823e4ad0d79d..515794004ba7 100644
--- a/lib/libc/arm/aeabi/Symbol.map
+++ b/lib/libc/arm/aeabi/Symbol.map
@@ -1,7 +1,4 @@
/*
- */
-
-/*
* This only needs to contain AEABI symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
@@ -9,50 +6,6 @@
FBSDprivate_1.0 {
__aeabi_atexit;
- __aeabi_dcmpeq;
- __aeabi_dcmplt;
- __aeabi_dcmple;
- __aeabi_dcmpge;
- __aeabi_dcmpgt;
- __aeabi_dcmpun;
-
- __aeabi_cdcmpeq;
- __aeabi_cdcmple;
- __aeabi_cdrcmple;
-
- __aeabi_d2iz;
- __aeabi_d2f;
-
- __aeabi_dadd;
- __aeabi_ddiv;
- __aeabi_dmul;
- __aeabi_dsub;
-
-
- __aeabi_fcmpeq;
- __aeabi_fcmplt;
- __aeabi_fcmple;
- __aeabi_fcmpge;
- __aeabi_fcmpgt;
- __aeabi_fcmpun;
-
- __aeabi_cfcmpeq;
- __aeabi_cfcmple;
- __aeabi_cfrcmple;
-
- __aeabi_f2iz;
- __aeabi_f2d;
-
- __aeabi_fadd;
- __aeabi_fdiv;
- __aeabi_fmul;
- __aeabi_fsub;
-
-
- __aeabi_i2d;
- __aeabi_i2f;
-
-
__aeabi_memclr;
__aeabi_memclr4;
__aeabi_memclr8;
diff --git a/lib/libc/arm/aeabi/aeabi_atexit.c b/lib/libc/arm/aeabi/aeabi_atexit.c
index 267ddfb223de..d688edf9c4e9 100644
--- a/lib/libc/arm/aeabi/aeabi_atexit.c
+++ b/lib/libc/arm/aeabi/aeabi_atexit.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
int __cxa_atexit(void (*)(void *), void *, void *);
int
diff --git a/lib/libc/arm/aeabi/aeabi_double.c b/lib/libc/arm/aeabi/aeabi_double.c
index 9fb0c61a3467..61f64678e795 100644
--- a/lib/libc/arm/aeabi/aeabi_double.c
+++ b/lib/libc/arm/aeabi/aeabi_double.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include "softfloat-for-gcc.h"
#include "milieu.h"
#include "softfloat.h"
@@ -55,7 +54,7 @@ float64 __aeabi_dsub_vfp(float64, float64);
/*
* Depending on the target these will:
- * On armv6 with a vfp call the above function, or
+ * On armv7 with a vfp call the above function, or
* Call the softfloat function in the 3rd argument.
*/
int AEABI_FUNC2(dcmpeq, float64, float64_eq)
diff --git a/lib/libc/arm/aeabi/aeabi_float.c b/lib/libc/arm/aeabi/aeabi_float.c
index 71b46af836ed..0e465754ecf0 100644
--- a/lib/libc/arm/aeabi/aeabi_float.c
+++ b/lib/libc/arm/aeabi/aeabi_float.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include "softfloat-for-gcc.h"
#include "milieu.h"
#include "softfloat.h"
@@ -55,7 +54,7 @@ float32 __aeabi_fsub_vfp(float32, float32);
/*
* Depending on the target these will:
- * On armv6 with a vfp call the above function, or
+ * On armv7 with a vfp call the above function, or
* Call the softfloat function in the 3rd argument.
*/
int AEABI_FUNC2(fcmpeq, float32, float32_eq)
diff --git a/lib/libc/arm/aeabi/aeabi_int_div.S b/lib/libc/arm/aeabi/aeabi_int_div.S
index 708b478b3881..bb002c2716f7 100644
--- a/lib/libc/arm/aeabi/aeabi_int_div.S
+++ b/lib/libc/arm/aeabi/aeabi_int_div.S
@@ -37,11 +37,13 @@
*/
ENTRY(__aeabi_uidiv_compat)
+ .hidden __aeabi_uidiv_compat
.symver __aeabi_uidiv_compat, __aeabi_uidiv@
b __udivsi3
END(__aeabi_uidiv_compat)
ENTRY(__aeabi_idiv_compat)
+ .hidden __aeabi_idiv_compat
.symver __aeabi_idiv_compat, __aeabi_idiv@
b __divsi3
END(__aeabi_idiv_compat)
diff --git a/lib/libc/arm/aeabi/aeabi_unwind_cpp.c b/lib/libc/arm/aeabi/aeabi_unwind_cpp.c
index f3bee222d529..efcace2c0675 100644
--- a/lib/libc/arm/aeabi/aeabi_unwind_cpp.c
+++ b/lib/libc/arm/aeabi/aeabi_unwind_cpp.c
@@ -34,7 +34,6 @@
* check this.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
void __aeabi_unwind_cpp_pr0(void) __hidden;
diff --git a/lib/libc/arm/aeabi/aeabi_unwind_exidx.c b/lib/libc/arm/aeabi/aeabi_unwind_exidx.c
index e7bff3816ff5..cf61922d4304 100644
--- a/lib/libc/arm/aeabi/aeabi_unwind_exidx.c
+++ b/lib/libc/arm/aeabi/aeabi_unwind_exidx.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/elf.h>
#include <link.h>
diff --git a/lib/libc/arm/aeabi/aeabi_vfp.h b/lib/libc/arm/aeabi/aeabi_vfp.h
index f87f9acfd0a2..4f3bb2ef969b 100644
--- a/lib/libc/arm/aeabi/aeabi_vfp.h
+++ b/lib/libc/arm/aeabi/aeabi_vfp.h
@@ -40,7 +40,9 @@
#define AEABI_ENTRY(x) ENTRY(__aeabi_ ## x ## _vfp)
#define AEABI_END(x) END(__aeabi_ ## x ## _vfp)
#else
-#define AEABI_ENTRY(x) ENTRY(__aeabi_ ## x)
+#define AEABI_ENTRY(x) \
+ ENTRY(__aeabi_ ## x) \
+ .symver __aeabi_##x, __aeabi_##x##@FBSDprivate_1.0;
#define AEABI_END(x) END(__aeabi_ ## x)
#endif
@@ -65,7 +67,7 @@
* C Helper macros
*/
-#if __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(SOFTFLOAT_FOR_GCC)
/*
* Generate a function that will either call into the VFP implementation,
* or the soft float version for a given __aeabi_* helper. The function
diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc
index 01c35f24adb0..dfb83da20a1f 100644
--- a/lib/libc/arm/gen/Makefile.inc
+++ b/lib/libc/arm/gen/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
SRCS+= \
__aeabi_read_tp.S \
_ctx_start.S \
diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S
index 19b8b6b07059..9e655d2e9e2e 100644
--- a/lib/libc/arm/gen/_setjmp.S
+++ b/lib/libc/arm/gen/_setjmp.S
@@ -58,12 +58,12 @@
ENTRY(_setjmp)
ldr r1, .L_setjmp_magic
-#if !defined(_STANDALONE) && __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(_STANDALONE) && !defined(SOFTFLOAT_FOR_GCC)
add r2, r0, #(_JB_REG_D8 * 4)
vstmia r2, {d8-d15}
vmrs r2, fpscr
str r2, [r0, #(_JB_REG_FPSCR * 4)]
-#endif /* !_STANDALONE && __ARM_ARCH >= 6 */
+#endif /* !_STANDALONE && !SOFTFLOAT_FOR_GCC */
str r1, [r0]
@@ -91,12 +91,12 @@ ENTRY(_longjmp)
teq ip, r2 /* magic correct? */
bne botch /* no, botch */
-#if !defined(_STANDALONE) && __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(_STANDALONE) && !defined(SOFTFLOAT_FOR_GCC)
add ip, r0, #(_JB_REG_D8 * 4)
vldmia ip, {d8-d15}
ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
vmsr fpscr, ip
-#endif /* !_STANDALONE && __ARM_ARCH >= 6 */
+#endif /* !_STANDALONE && !SOFTFLOAT_FOR_GCC */
add r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
diff --git a/lib/libc/arm/gen/arm_drain_writebuf.c b/lib/libc/arm/gen/arm_drain_writebuf.c
index d8e4063f27cb..30c93718bfe6 100644
--- a/lib/libc/arm/gen/arm_drain_writebuf.c
+++ b/lib/libc/arm/gen/arm_drain_writebuf.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <machine/sysarch.h>
#include <stddef.h>
diff --git a/lib/libc/arm/gen/arm_initfini.c b/lib/libc/arm/gen/arm_initfini.c
index 00ca41165c29..31756aa852a4 100644
--- a/lib/libc/arm/gen/arm_initfini.c
+++ b/lib/libc/arm/gen/arm_initfini.c
@@ -33,7 +33,6 @@
* $NetBSD: arm_initfini.c,v 1.2 2013/01/31 06:47:55 matt Exp $
*/
-#include <sys/cdefs.h>
/*
* To properly implement setjmp/longjmp for the ARM AAPCS ABI, it has to be
* aware of whether there is a FPU is present or not. Regardless of whether
diff --git a/lib/libc/arm/gen/arm_sync_icache.c b/lib/libc/arm/gen/arm_sync_icache.c
index d89f57cbae18..b5872fb8ef00 100644
--- a/lib/libc/arm/gen/arm_sync_icache.c
+++ b/lib/libc/arm/gen/arm_sync_icache.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/sysarch.h>
#include <stddef.h>
diff --git a/lib/libc/arm/gen/fabs.c b/lib/libc/arm/gen/fabs.c
index b3020b88062d..2e0abbb8a42a 100644
--- a/lib/libc/arm/gen/fabs.c
+++ b/lib/libc/arm/gen/fabs.c
@@ -36,7 +36,6 @@
/*
* fabs(x) returns the absolute value of x.
*/
-#include <sys/cdefs.h>
double
fabs(double x)
{
diff --git a/lib/libc/arm/gen/flt_rounds.c b/lib/libc/arm/gen/flt_rounds.c
index a592dbff38c0..7621262419a4 100644
--- a/lib/libc/arm/gen/flt_rounds.c
+++ b/lib/libc/arm/gen/flt_rounds.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <float.h>
diff --git a/lib/libc/arm/gen/fpgetmask_vfp.c b/lib/libc/arm/gen/fpgetmask_vfp.c
index d70f5caf845b..5e73a274dafa 100644
--- a/lib/libc/arm/gen/fpgetmask_vfp.c
+++ b/lib/libc/arm/gen/fpgetmask_vfp.c
@@ -25,14 +25,9 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
-#ifdef __weak_alias
-__weak_alias(fpgetmask,_fpgetmask)
-#endif
-
#define FP_X_MASK (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP)
fp_except_t
diff --git a/lib/libc/arm/gen/fpgetround_vfp.c b/lib/libc/arm/gen/fpgetround_vfp.c
index 830193b65e65..21debc0b028d 100644
--- a/lib/libc/arm/gen/fpgetround_vfp.c
+++ b/lib/libc/arm/gen/fpgetround_vfp.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/arm/gen/fpgetsticky_vfp.c b/lib/libc/arm/gen/fpgetsticky_vfp.c
index 34ed2f0dd5e0..651610dddf83 100644
--- a/lib/libc/arm/gen/fpgetsticky_vfp.c
+++ b/lib/libc/arm/gen/fpgetsticky_vfp.c
@@ -25,14 +25,9 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
-#ifdef __weak_alias
-__weak_alias(fpgetsticky,_fpgetsticky)
-#endif
-
#define FP_X_MASK (FP_X_INV | FP_X_DZ | FP_X_OFL | FP_X_UFL | FP_X_IMP)
fp_except
diff --git a/lib/libc/arm/gen/fpsetmask_vfp.c b/lib/libc/arm/gen/fpsetmask_vfp.c
index bf9c1c622094..92ad97e6dfa2 100644
--- a/lib/libc/arm/gen/fpsetmask_vfp.c
+++ b/lib/libc/arm/gen/fpsetmask_vfp.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/arm/gen/fpsetround_vfp.c b/lib/libc/arm/gen/fpsetround_vfp.c
index 76b8a9e92269..4e55335f6a3b 100644
--- a/lib/libc/arm/gen/fpsetround_vfp.c
+++ b/lib/libc/arm/gen/fpsetround_vfp.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/arm/gen/fpsetsticky_vfp.c b/lib/libc/arm/gen/fpsetsticky_vfp.c
index e98681e2372c..fb3a59b25178 100644
--- a/lib/libc/arm/gen/fpsetsticky_vfp.c
+++ b/lib/libc/arm/gen/fpsetsticky_vfp.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/arm/gen/getcontextx.c b/lib/libc/arm/gen/getcontextx.c
index 78db8c077152..357d3a2a0416 100644
--- a/lib/libc/arm/gen/getcontextx.c
+++ b/lib/libc/arm/gen/getcontextx.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ucontext.h>
#include <errno.h>
diff --git a/lib/libc/arm/gen/infinity.c b/lib/libc/arm/gen/infinity.c
index fe6c147980ec..1a78a03be2e3 100644
--- a/lib/libc/arm/gen/infinity.c
+++ b/lib/libc/arm/gen/infinity.c
@@ -2,7 +2,6 @@
* infinity.c
*/
-#include <sys/cdefs.h>
#include <math.h>
/* bytes for +Infinity on a 387 */
diff --git a/lib/libc/arm/gen/makecontext.c b/lib/libc/arm/gen/makecontext.c
index bf24e1f741c9..ac338085f2ed 100644
--- a/lib/libc/arm/gen/makecontext.c
+++ b/lib/libc/arm/gen/makecontext.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <stddef.h>
#include <inttypes.h>
@@ -43,15 +42,15 @@ extern void _ctx_start(void);
void
ctx_done(ucontext_t *ucp)
-{
-
+{
+
if (ucp->uc_link == NULL)
exit(0);
- else {
+ else {
setcontext((const ucontext_t *)ucp->uc_link);
abort();
- }
-}
+ }
+}
__weak_reference(__makecontext, makecontext);
diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S
index 5a6c899e2b23..e7f8b788e878 100644
--- a/lib/libc/arm/gen/setjmp.S
+++ b/lib/libc/arm/gen/setjmp.S
@@ -61,7 +61,7 @@ ENTRY(setjmp)
ldr r1, .Lsetjmp_magic
-#if __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(SOFTFLOAT_FOR_GCC)
add r2, r0, #(_JB_REG_D8 * 4)
vstmia r2, {d8-d15}
vmrs r2, fpscr
@@ -102,7 +102,7 @@ ENTRY(__longjmp)
bl PIC_SYM(_C_LABEL(sigprocmask), PLT)
ldmfd sp!, {r0-r2, r14}
-#if __ARM_ARCH >= 6 && !defined(SOFTFLOAT_FOR_GCC)
+#if !defined(SOFTFLOAT_FOR_GCC)
add ip, r0, #(_JB_REG_D8 * 4)
vldmia ip, {d8-d15}
ldr ip, [r0, #(_JB_REG_FPSCR * 4)]
diff --git a/lib/libc/arm/gen/signalcontext.c b/lib/libc/arm/gen/signalcontext.c
index 95fdc1579f84..e66a08928355 100644
--- a/lib/libc/arm/gen/signalcontext.c
+++ b/lib/libc/arm/gen/signalcontext.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/ucontext.h>
diff --git a/lib/libc/arm/static_tls.h b/lib/libc/arm/static_tls.h
deleted file mode 100644
index 557748d75347..000000000000
--- a/lib/libc/arm/static_tls.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_ARM_STATIC_TLS_H
-#define _LIBC_ARM_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("mrc p15, 0, %0, c13, c0, 3" : "=r" (tlsbase));
-
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/arm/string/Makefile.inc b/lib/libc/arm/string/Makefile.inc
index 9f0d10f70c9c..fc886645b0c8 100644
--- a/lib/libc/arm/string/Makefile.inc
+++ b/lib/libc/arm/string/Makefile.inc
@@ -1,4 +1,3 @@
-
MDSRCS+= \
bcopy.S \
bzero.S \
diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc
deleted file mode 100644
index dcc1bdb3ea03..000000000000
--- a/lib/libc/arm/sys/Makefile.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-
-SRCS+= __vdso_gettc.c \
- sched_getcpu_gen.c
-
-MDASM= Ovfork.S cerror.S syscall.S
-
-# Don't generate default code for these syscalls:
-NOASM+= sbrk.o vfork.o
diff --git a/lib/libc/arm/sys/Ovfork.S b/lib/libc/arm/sys/Ovfork.S
deleted file mode 100644
index 0913f0361c4d..000000000000
--- a/lib/libc/arm/sys/Ovfork.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/* $NetBSD: Ovfork.S,v 1.6 2003/08/07 16:42:03 agc Exp $ */
-
-/*-
- * Copyright (c) 1990 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.
- *
- * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90
- */
-
-#include <machine/asm.h>
-#include "SYS.h"
-
-/*
- * pid = vfork();
- *
- * On return from the SWI:
- * r1 == 0 in parent process, r1 == 1 in child process.
- * r0 == pid of child in parent, r0 == pid of parent in child.
- */
- .text
- .align 0
-
-ENTRY(vfork)
- mov r2, r14
- SYSTRAP(vfork)
- bcs PIC_SYM(CERROR, PLT)
- sub r1, r1, #1 /* r1 == 0xffffffff if parent, 0 if child */
- and r0, r0, r1 /* r0 == 0 if child, else unchanged */
- mov r15, r2
-END(vfork)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/arm/sys/__vdso_gettc.c b/lib/libc/arm/sys/__vdso_gettc.c
deleted file mode 100644
index e5987eea2fe4..000000000000
--- a/lib/libc/arm/sys/__vdso_gettc.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2015 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/elf.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <machine/cpufunc.h>
-#include <machine/acle-compat.h>
-#include <errno.h>
-#include "libc_private.h"
-
-#if __ARM_ARCH >= 6
-static inline uint64_t
-cp15_cntvct_get(void)
-{
- uint64_t reg;
-
- __asm __volatile("mrrc\tp15, 1, %Q0, %R0, c14" : "=r" (reg));
- return (reg);
-}
-
-static inline uint64_t
-cp15_cntpct_get(void)
-{
- uint64_t reg;
-
- __asm __volatile("mrrc\tp15, 0, %Q0, %R0, c14" : "=r" (reg));
- return (reg);
-}
-#endif
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
-
- if (th->th_algo != VDSO_TH_ALGO_ARM_GENTIM)
- return (ENOSYS);
-#if __ARM_ARCH >= 6
- /*
- * Userspace gettimeofday() is only enabled on ARMv7 CPUs, but
- * libc is compiled for ARMv6. Due to clang issues, .arch
- * armv7-a directive does not work.
- */
- __asm __volatile(".word\t0xf57ff06f" : : : "memory"); /* isb */
- *tc = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
- return (0);
-#else
- *tc = 0;
- return (ENOSYS);
-#endif
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
-
- return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
-}
diff --git a/lib/libc/arm/sys/cerror.S b/lib/libc/arm/sys/cerror.S
deleted file mode 100644
index 06e51bc649f0..000000000000
--- a/lib/libc/arm/sys/cerror.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: cerror.S,v 1.5 2003/08/07 16:42:04 agc Exp $ */
-
-/*-
- * Copyright (c) 1990 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.
- *
- * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90
- */
-
-#include <machine/asm.h>
-#include "SYS.h"
-
-.globl _C_LABEL(__error)
-.type _C_LABEL(__error),%function
-
-ASENTRY(CERROR)
- stmfd sp!, {r4, lr}
- mov r4, r0
- bl PIC_SYM(_C_LABEL(__error), PLT)
- str r4, [r0]
- mvn r0, #0x00000000
- mvn r1, #0x00000000
- ldmfd sp!, {r4, pc}
-END(CERROR)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/arm/sys/syscall.S b/lib/libc/arm/sys/syscall.S
deleted file mode 100644
index 3199b8fb2f51..000000000000
--- a/lib/libc/arm/sys/syscall.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* $NetBSD: syscall.S,v 1.4 2003/08/07 16:42:05 agc Exp $ */
-
-/*-
- * Copyright (c) 1990 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.
- *
- * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90
- */
-
-#include <machine/asm.h>
-#include "SYS.h"
-
-RSYSCALL(syscall)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/capability/Makefile.inc b/lib/libc/capability/Makefile.inc
index cf214d7f5627..845f8f172bb8 100644
--- a/lib/libc/capability/Makefile.inc
+++ b/lib/libc/capability/Makefile.inc
@@ -1,4 +1,3 @@
-
# capability sources
.PATH: ${SRCTOP}/sys/kern ${LIBC_SRCTOP}/capability
@@ -10,6 +9,7 @@ MAN+= cap_rights_init.3
MLINKS+=cap_rights_init.3 cap_rights_set.3
MLINKS+=cap_rights_init.3 cap_rights_clear.3
+MLINKS+=cap_rights_init.3 cap_rights_is_empty.3
MLINKS+=cap_rights_init.3 cap_rights_is_set.3
MLINKS+=cap_rights_init.3 cap_rights_is_valid.3
MLINKS+=cap_rights_init.3 cap_rights_merge.3
diff --git a/lib/libc/capability/Symbol.map b/lib/libc/capability/Symbol.map
index 65e112348012..8bf11670a5a8 100644
--- a/lib/libc/capability/Symbol.map
+++ b/lib/libc/capability/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.3 {
__cap_rights_clear;
cap_rights_contains;
@@ -11,3 +8,7 @@ FBSD_1.3 {
cap_rights_remove;
__cap_rights_set;
};
+
+FBSD_1.8 {
+ cap_rights_is_empty;
+};
diff --git a/lib/libc/capability/cap_rights_init.3 b/lib/libc/capability/cap_rights_init.3
index 80b522820097..98b50f653f2c 100644
--- a/lib/libc/capability/cap_rights_init.3
+++ b/lib/libc/capability/cap_rights_init.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 5, 2020
+.Dd November 25, 2023
.Dt CAP_RIGHTS_INIT 3
.Os
.Sh NAME
@@ -33,6 +33,7 @@
.Nm cap_rights_set ,
.Nm cap_rights_clear ,
.Nm cap_rights_is_set ,
+.Nm cap_rights_is_empty ,
.Nm cap_rights_is_valid ,
.Nm cap_rights_merge ,
.Nm cap_rights_remove ,
@@ -51,6 +52,8 @@
.Ft bool
.Fn cap_rights_is_set "const cap_rights_t *rights" "..."
.Ft bool
+.Fn cap_rights_is_empty "const cap_rights_t *rights"
+.Ft bool
.Fn cap_rights_is_valid "const cap_rights_t *rights"
.Ft cap_rights_t *
.Fn cap_rights_merge "cap_rights_t *dst" "const cap_rights_t *src"
@@ -118,6 +121,12 @@ function checks if all the given capability rights are set for the given
structure.
.Pp
The
+.Fn cap_rights_is_empty
+function checks if the
+.Fa rights
+structure is empty.
+.Pp
+The
.Fn cap_rights_is_valid
function verifies if the given
.Vt cap_rights_t
@@ -182,6 +191,14 @@ if all the given capability rights are set in the
argument.
.Pp
The
+.Fn cap_rights_is_empty
+function returns
+.Va true
+if none of the capability rights are set in the
+.Fa rights
+structure.
+.Pp
+The
.Fn cap_rights_is_valid
function performs various checks to see if the given
.Vt cap_rights_t
diff --git a/lib/libc/compat-43/Makefile.inc b/lib/libc/compat-43/Makefile.inc
index d6933f0b0c6e..288fb04e5926 100644
--- a/lib/libc/compat-43/Makefile.inc
+++ b/lib/libc/compat-43/Makefile.inc
@@ -1,14 +1,12 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/2/93
-
# compat-43 sources
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/compat-43 ${LIBC_SRCTOP}/compat-43
-SRCS+= creat.c gethostid.c getwd.c killpg.c sethostid.c setpgrp.c \
+SRCS+= gethostid.c getwd.c killpg.c sethostid.c setpgrp.c \
setrgid.c setruid.c sigcompat.c
SYM_MAPS+=${LIBC_SRCTOP}/compat-43/Symbol.map
-MAN+= creat.2 killpg.2 sigpause.2 sigsetmask.2 sigvec.2
+MAN+= killpg.2 sigpause.2 sigsetmask.2 sigvec.2
MAN+= gethostid.3 setruid.3
MLINKS+=gethostid.3 sethostid.3
diff --git a/lib/libc/compat-43/Symbol.map b/lib/libc/compat-43/Symbol.map
index 588a693dabb7..b0ce99f4e416 100644
--- a/lib/libc/compat-43/Symbol.map
+++ b/lib/libc/compat-43/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
creat;
gethostid;
diff --git a/lib/libc/compat-43/creat.2 b/lib/libc/compat-43/creat.2
deleted file mode 100644
index 64ad9f77e353..000000000000
--- a/lib/libc/compat-43/creat.2
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" Copyright (c) 1989, 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.
-.\"
-.\" @(#)creat.2 8.1 (Berkeley) 6/2/93
-.\"
-.Dd September 4, 2019
-.Dt CREAT 2
-.Os
-.Sh NAME
-.Nm creat
-.Nd create a new file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In fcntl.h
-.Ft int
-.Fn creat "const char *path" "mode_t mode"
-.Sh DESCRIPTION
-.Bf -symbolic
-This interface is made obsolete by:
-.Ef
-.Xr open 2 .
-.Pp
-The
-.Fn creat
-function
-is the same as:
-.Bd -literal -offset indent
-open(path, O_CREAT | O_TRUNC | O_WRONLY, mode);
-.Ed
-.Sh SEE ALSO
-.Xr open 2
-.Sh HISTORY
-The
-.Fn creat
-function appeared in
-.At v1 .
diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c
deleted file mode 100644
index f38c673967bd..000000000000
--- a/lib/libc/compat-43/creat.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1989, 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)creat.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <fcntl.h>
-#include "un-namespace.h"
-#include "libc_private.h"
-
-__weak_reference(__creat, creat);
-__weak_reference(__creat, _creat);
-
-int __creat(const char *path, mode_t mode);
-
-#pragma weak creat
-int
-__creat(const char *path, mode_t mode)
-{
-
- return (((int (*)(int, const char *, int, ...))
- __libc_interposing[INTERPOS_openat])(AT_FDCWD, path, O_WRONLY |
- O_CREAT | O_TRUNC, mode));
-}
-
diff --git a/lib/libc/compat-43/gethostid.3 b/lib/libc/compat-43/gethostid.3
index 226e55ccd2bd..ed8d939921c2 100644
--- a/lib/libc/compat-43/gethostid.3
+++ b/lib/libc/compat-43/gethostid.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)gethostid.3 8.1 (Berkeley) 6/2/93
-.\"
.Dd June 2, 1993
.Dt GETHOSTID 3
.Os
diff --git a/lib/libc/compat-43/gethostid.c b/lib/libc/compat-43/gethostid.c
index 2314b9f6df64..bb3670f19670 100644
--- a/lib/libc/compat-43/gethostid.c
+++ b/lib/libc/compat-43/gethostid.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gethostid.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/compat-43/getwd.c b/lib/libc/compat-43/getwd.c
index c5f10440516d..bfc167960f79 100644
--- a/lib/libc/compat-43/getwd.c
+++ b/lib/libc/compat-43/getwd.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getwd.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <unistd.h>
#include <errno.h>
diff --git a/lib/libc/compat-43/killpg.2 b/lib/libc/compat-43/killpg.2
index 3a30e10a7a10..9e94279f8201 100644
--- a/lib/libc/compat-43/killpg.2
+++ b/lib/libc/compat-43/killpg.2
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)killpg.2 8.1 (Berkeley) 6/2/93
-.\"
.Dd March 15, 2012
.Dt KILLPG 2
.Os
diff --git a/lib/libc/compat-43/killpg.c b/lib/libc/compat-43/killpg.c
index 69340598262b..a83a0c426e0b 100644
--- a/lib/libc/compat-43/killpg.c
+++ b/lib/libc/compat-43/killpg.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)killpg.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
diff --git a/lib/libc/compat-43/sethostid.c b/lib/libc/compat-43/sethostid.c
index cc53400a598b..97a239eb4d06 100644
--- a/lib/libc/compat-43/sethostid.c
+++ b/lib/libc/compat-43/sethostid.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)sethostid.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/compat-43/setpgrp.c b/lib/libc/compat-43/setpgrp.c
index 4bf0d23ba73d..8d0b5ea10cf9 100644
--- a/lib/libc/compat-43/setpgrp.c
+++ b/lib/libc/compat-43/setpgrp.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setpgrp.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <unistd.h>
diff --git a/lib/libc/compat-43/setrgid.c b/lib/libc/compat-43/setrgid.c
index 30a7c24cea4d..695270b827b4 100644
--- a/lib/libc/compat-43/setrgid.c
+++ b/lib/libc/compat-43/setrgid.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setrgid.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <unistd.h>
int
diff --git a/lib/libc/compat-43/setruid.3 b/lib/libc/compat-43/setruid.3
index 9c363b1c1794..f9f14c2e4346 100644
--- a/lib/libc/compat-43/setruid.3
+++ b/lib/libc/compat-43/setruid.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)setruid.3 8.1 (Berkeley) 6/2/93
-.\"
.Dd June 2, 1993
.Dt SETRUID 3
.Os
diff --git a/lib/libc/compat-43/setruid.c b/lib/libc/compat-43/setruid.c
index 4dd738a6e68d..1889f3bff746 100644
--- a/lib/libc/compat-43/setruid.c
+++ b/lib/libc/compat-43/setruid.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setruid.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <unistd.h>
int
diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c
index 350f8e77971c..77cfc279a3b3 100644
--- a/lib/libc/compat-43/sigcompat.c
+++ b/lib/libc/compat-43/sigcompat.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)sigcompat.c 8.1 (Berkeley) 6/2/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <errno.h>
diff --git a/lib/libc/compat-43/sigpause.2 b/lib/libc/compat-43/sigpause.2
index 339de2d9a1e0..802c177e9f91 100644
--- a/lib/libc/compat-43/sigpause.2
+++ b/lib/libc/compat-43/sigpause.2
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sigpause.2 8.1 (Berkeley) 6/2/93
-.\"
.\" Part of the content of the man page was derived from
.\" The Open Group Base Specifications Issue 7
.\" IEEE Std 1003.1-2008
diff --git a/lib/libc/compat-43/sigsetmask.2 b/lib/libc/compat-43/sigsetmask.2
index 1d909632066f..4a98fae1f698 100644
--- a/lib/libc/compat-43/sigsetmask.2
+++ b/lib/libc/compat-43/sigsetmask.2
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sigsetmask.2 8.1 (Berkeley) 6/2/93
-.\"
.Dd June 2, 1993
.Dt SIGSETMASK 2
.Os
diff --git a/lib/libc/compat-43/sigvec.2 b/lib/libc/compat-43/sigvec.2
index 4c87656a0665..183db89883d6 100644
--- a/lib/libc/compat-43/sigvec.2
+++ b/lib/libc/compat-43/sigvec.2
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sigvec.2 8.2 (Berkeley) 4/19/94
-.\"
.Dd April 2, 2022
.Dt SIGVEC 2
.Os
diff --git a/lib/libc/csu/aarch64/Makefile.inc b/lib/libc/csu/aarch64/Makefile.inc
index b3420a638164..6c315c5e2624 100644
--- a/lib/libc/csu/aarch64/Makefile.inc
+++ b/lib/libc/csu/aarch64/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_RELA \
- -DINIT_IRELOCS=""
+CFLAGS+= -DCRT_IRELOC_RELA
diff --git a/lib/libc/csu/aarch64/reloc.c b/lib/libc/csu/aarch64/reloc.c
index 7f5dff497fe2..4ba7920bcb07 100644
--- a/lib/libc/csu/aarch64/reloc.c
+++ b/lib/libc/csu/aarch64/reloc.c
@@ -25,6 +25,12 @@
*/
#include <sys/cdefs.h>
+
+static void
+ifunc_init(const Elf_Auxinfo *aux __unused)
+{
+}
+
static void
crt1_handle_rela(const Elf_Rela *r)
{
diff --git a/lib/libc/csu/amd64/Makefile.inc b/lib/libc/csu/amd64/Makefile.inc
index f14033217580..6c315c5e2624 100644
--- a/lib/libc/csu/amd64/Makefile.inc
+++ b/lib/libc/csu/amd64/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_RELA \
- -DINIT_IRELOCS="init_cpu_features()"
+CFLAGS+= -DCRT_IRELOC_RELA
diff --git a/lib/libc/csu/amd64/reloc.c b/lib/libc/csu/amd64/reloc.c
index 654958819271..f1f83db9a391 100644
--- a/lib/libc/csu/amd64/reloc.c
+++ b/lib/libc/csu/amd64/reloc.c
@@ -24,6 +24,7 @@
*/
#include <sys/cdefs.h>
+
#include <machine/specialreg.h>
#include <machine/cpufunc.h>
@@ -31,7 +32,7 @@ static uint32_t cpu_feature, cpu_feature2;
static uint32_t cpu_stdext_feature, cpu_stdext_feature2;
static void
-init_cpu_features(void)
+ifunc_init(const Elf_Auxinfo *aux __unused)
{
u_int p[4];
diff --git a/lib/libc/csu/arm/Makefile.inc b/lib/libc/csu/arm/Makefile.inc
index 2534e6579f38..ddead75f874d 100644
--- a/lib/libc/csu/arm/Makefile.inc
+++ b/lib/libc/csu/arm/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_SUPPRESS \
- -DINIT_IRELOCS=""
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
diff --git a/lib/libc/csu/i386/Makefile.inc b/lib/libc/csu/i386/Makefile.inc
index f3f8c2b176ce..32018000e1f2 100644
--- a/lib/libc/csu/i386/Makefile.inc
+++ b/lib/libc/csu/i386/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_REL \
- -DINIT_IRELOCS="init_cpu_features()"
+CFLAGS+= -DCRT_IRELOC_REL
diff --git a/lib/libc/csu/i386/reloc.c b/lib/libc/csu/i386/reloc.c
index d617f35dc665..7097f58d8f26 100644
--- a/lib/libc/csu/i386/reloc.c
+++ b/lib/libc/csu/i386/reloc.c
@@ -24,6 +24,7 @@
*/
#include <sys/cdefs.h>
+
#include <machine/specialreg.h>
#include <machine/cpufunc.h>
@@ -31,7 +32,7 @@ static uint32_t cpu_feature, cpu_feature2;
static uint32_t cpu_stdext_feature, cpu_stdext_feature2;
static void
-init_cpu_features(void)
+ifunc_init(const Elf_Auxinfo *aux __unused)
{
u_int cpuid_supported, p[4];
diff --git a/lib/libc/csu/libc_start1.c b/lib/libc/csu/libc_start1.c
index f0e708e405ce..5b08ba03ba8c 100644
--- a/lib/libc/csu/libc_start1.c
+++ b/lib/libc/csu/libc_start1.c
@@ -28,6 +28,7 @@
#include <sys/param.h>
#include <sys/elf.h>
#include <sys/elf_common.h>
+#include <errno.h>
#include <stdlib.h>
#include "libc_private.h"
@@ -137,6 +138,24 @@ handle_argv(int argc, char *argv[], char **env)
}
}
+static void
+handle_irelocs(char *env[])
+{
+#ifndef CRT_IRELOC_SUPPRESS
+ const Elf_Auxinfo *aux;
+
+ /* Find the auxiliary vector on the stack. */
+ while (*env++ != 0) /* Skip over environment, and NULL terminator */
+ ;
+ aux = (const Elf_Auxinfo *)env;
+
+ ifunc_init(aux);
+ process_irelocs();
+#else
+ (void)env;
+#endif
+}
+
void
__libc_start1(int argc, char *argv[], char *env[], void (*cleanup)(void),
int (*mainX)(int, char *[], char *[]))
@@ -146,14 +165,18 @@ __libc_start1(int argc, char *argv[], char *env[], void (*cleanup)(void),
if (&_DYNAMIC != NULL) {
atexit(cleanup);
} else {
-#ifndef CRT_IRELOC_SUPPRESS
- INIT_IRELOCS;
- process_irelocs();
-#endif
+ handle_irelocs(env);
_init_tls();
}
handle_static_init(argc, argv, env);
+
+ /*
+ * C17 4.3 paragraph 3:
+ * The value of errno in the initial thread is zero at program
+ * startup.
+ */
+ errno = 0;
exit(mainX(argc, argv, env));
}
@@ -171,10 +194,7 @@ __libc_start1_gcrt(int argc, char *argv[], char *env[],
if (&_DYNAMIC != NULL) {
atexit(cleanup);
} else {
-#ifndef CRT_IRELOC_SUPPRESS
- INIT_IRELOCS;
- process_irelocs();
-#endif
+ handle_irelocs(env);
_init_tls();
}
@@ -182,5 +202,6 @@ __libc_start1_gcrt(int argc, char *argv[], char *env[],
monstartup(eprolp, etextp);
handle_static_init(argc, argv, env);
+ errno = 0;
exit(mainX(argc, argv, env));
}
diff --git a/lib/libc/csu/powerpc/Makefile.inc b/lib/libc/csu/powerpc/Makefile.inc
index 2534e6579f38..ddead75f874d 100644
--- a/lib/libc/csu/powerpc/Makefile.inc
+++ b/lib/libc/csu/powerpc/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_SUPPRESS \
- -DINIT_IRELOCS=""
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
diff --git a/lib/libc/csu/powerpc64/Makefile.inc b/lib/libc/csu/powerpc64/Makefile.inc
index 5d59d40eb393..6c315c5e2624 100644
--- a/lib/libc/csu/powerpc64/Makefile.inc
+++ b/lib/libc/csu/powerpc64/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_RELA \
- -DINIT_IRELOCS="init_cpu_features(env)"
+CFLAGS+= -DCRT_IRELOC_RELA
diff --git a/lib/libc/csu/powerpc64/reloc.c b/lib/libc/csu/powerpc64/reloc.c
index 6201ba0f1fb5..5637e6534197 100644
--- a/lib/libc/csu/powerpc64/reloc.c
+++ b/lib/libc/csu/powerpc64/reloc.c
@@ -20,20 +20,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
static uint32_t cpu_features;
static uint32_t cpu_features2;
static void
-init_cpu_features(char **env)
+ifunc_init(const Elf_Auxinfo *aux)
{
- const Elf_Auxinfo *aux;
-
- /* Find the auxiliary vector on the stack. */
- while (*env++ != 0) /* Skip over environment, and NULL terminator */
- ;
- aux = (const Elf_Auxinfo *)env;
-
/* Digest the auxiliary vector. */
for (; aux->a_type != AT_NULL; aux++) {
switch (aux->a_type) {
diff --git a/lib/libc/csu/powerpcspe/Makefile.inc b/lib/libc/csu/powerpcspe/Makefile.inc
index 2534e6579f38..ddead75f874d 100644
--- a/lib/libc/csu/powerpcspe/Makefile.inc
+++ b/lib/libc/csu/powerpcspe/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_SUPPRESS \
- -DINIT_IRELOCS=""
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
diff --git a/lib/libc/csu/riscv/Makefile.inc b/lib/libc/csu/riscv/Makefile.inc
index 2534e6579f38..6c315c5e2624 100644
--- a/lib/libc/csu/riscv/Makefile.inc
+++ b/lib/libc/csu/riscv/Makefile.inc
@@ -1,4 +1,3 @@
#
-CFLAGS+= -DCRT_IRELOC_SUPPRESS \
- -DINIT_IRELOCS=""
+CFLAGS+= -DCRT_IRELOC_RELA
diff --git a/lib/libc/csu/riscv/reloc.c b/lib/libc/csu/riscv/reloc.c
new file mode 100644
index 000000000000..6ae85085089b
--- /dev/null
+++ b/lib/libc/csu/riscv/reloc.c
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2019 Leandro Lupori
+ * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.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.
+ *
+ * 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.
+ */
+
+static unsigned long elf_hwcap;
+
+static void
+ifunc_init(const Elf_Auxinfo *aux)
+{
+ /* Digest the auxiliary vector. */
+ for (; aux->a_type != AT_NULL; aux++) {
+ switch (aux->a_type) {
+ case AT_HWCAP:
+ elf_hwcap = (uint32_t)aux->a_un.a_val;
+ break;
+ }
+ }
+}
+
+static void
+crt1_handle_rela(const Elf_Rela *r)
+{
+ typedef Elf_Addr (*ifunc_resolver_t)(
+ unsigned long, unsigned long, unsigned long, unsigned long,
+ unsigned long, unsigned long, unsigned long, unsigned long);
+ Elf_Addr *ptr, *where, target;
+
+ switch (ELF_R_TYPE(r->r_info)) {
+ case R_RISCV_IRELATIVE:
+ ptr = (Elf_Addr *)r->r_addend;
+ where = (Elf_Addr *)r->r_offset;
+ target = ((ifunc_resolver_t)ptr)(elf_hwcap,
+ 0, 0, 0, 0, 0, 0, 0);
+ *where = target;
+ break;
+ }
+}
diff --git a/lib/libc/db/Makefile.inc b/lib/libc/db/Makefile.inc
index f5cbae87cb3f..e80128e78956 100644
--- a/lib/libc/db/Makefile.inc
+++ b/lib/libc/db/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.2 (Berkeley) 2/21/94
-#
CFLAGS+=-D__DBINTERFACE_PRIVATE
.include "${LIBC_SRCTOP}/db/btree/Makefile.inc"
diff --git a/lib/libc/db/README b/lib/libc/db/README
index 4a1966de525c..9bcc1e09acbe 100644
--- a/lib/libc/db/README
+++ b/lib/libc/db/README
@@ -1,4 +1,3 @@
-# @(#)README 8.27 (Berkeley) 9/1/94
This is version 1.85 of the Berkeley DB code.
diff --git a/lib/libc/db/Symbol.map b/lib/libc/db/Symbol.map
index cb00d6bd1290..b46fb17e499d 100644
--- a/lib/libc/db/Symbol.map
+++ b/lib/libc/db/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
dbopen;
dbm_open;
@@ -19,7 +16,6 @@ FBSD_1.0 {
mpool_put;
mpool_close;
mpool_sync;
- mpool_stat;
};
FBSD_1.1 {
diff --git a/lib/libc/db/btree/Makefile.inc b/lib/libc/db/btree/Makefile.inc
index 36744af4909d..fb1cf2314677 100644
--- a/lib/libc/db/btree/Makefile.inc
+++ b/lib/libc/db/btree/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.2 (Berkeley) 7/14/94
-
.PATH: ${LIBC_SRCTOP}/db/btree
SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c \
diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c
index 1378e45a77e4..36fc593adb25 100644
--- a/lib/libc/db/btree/bt_close.c
+++ b/lib/libc/db/btree/bt_close.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_close.c 8.7 (Berkeley) 8/17/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
diff --git a/lib/libc/db/btree/bt_conv.c b/lib/libc/db/btree/bt_conv.c
index 5b3f166dff9a..db7516de80f7 100644
--- a/lib/libc/db/btree/bt_conv.c
+++ b/lib/libc/db/btree/bt_conv.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_conv.c 8.5 (Berkeley) 8/17/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
diff --git a/lib/libc/db/btree/bt_debug.c b/lib/libc/db/btree/bt_debug.c
index 50f1294a9603..d8f4599efde5 100644
--- a/lib/libc/db/btree/bt_debug.c
+++ b/lib/libc/db/btree/bt_debug.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_debug.c 8.5 (Berkeley) 8/17/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
diff --git a/lib/libc/db/btree/bt_delete.c b/lib/libc/db/btree/bt_delete.c
index fc122165a335..420617167e4a 100644
--- a/lib/libc/db/btree/bt_delete.c
+++ b/lib/libc/db/btree/bt_delete.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_delete.c 8.13 (Berkeley) 7/28/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/btree/bt_get.c b/lib/libc/db/btree/bt_get.c
index 3a0f9f72d92c..ac4c43ab9f0f 100644
--- a/lib/libc/db/btree/bt_get.c
+++ b/lib/libc/db/btree/bt_get.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_get.c 8.6 (Berkeley) 7/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index fcc3a9a9abb4..92e75120d4a2 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_open.c 8.10 (Berkeley) 8/17/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* Implementation of btree access method for 4.4BSD.
*
diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c
index f2c565789311..0ce85f097af1 100644
--- a/lib/libc/db/btree/bt_overflow.c
+++ b/lib/libc/db/btree/bt_overflow.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_overflow.c 8.5 (Berkeley) 7/16/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c
index aaec36ecfac9..ba5e1cf0d6dd 100644
--- a/lib/libc/db/btree/bt_page.c
+++ b/lib/libc/db/btree/bt_page.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_page.c 8.3 (Berkeley) 7/14/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
diff --git a/lib/libc/db/btree/bt_put.c b/lib/libc/db/btree/bt_put.c
index 9b4ea51f184d..5af8a6dc316f 100644
--- a/lib/libc/db/btree/bt_put.c
+++ b/lib/libc/db/btree/bt_put.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_put.c 8.8 (Berkeley) 7/26/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/btree/bt_search.c b/lib/libc/db/btree/bt_search.c
index bf5245fe1fd0..82489b540b7d 100644
--- a/lib/libc/db/btree/bt_search.c
+++ b/lib/libc/db/btree/bt_search.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_search.c 8.8 (Berkeley) 7/31/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
diff --git a/lib/libc/db/btree/bt_seq.c b/lib/libc/db/btree/bt_seq.c
index c68c7d3717de..2562724faf33 100644
--- a/lib/libc/db/btree/bt_seq.c
+++ b/lib/libc/db/btree/bt_seq.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_seq.c 8.7 (Berkeley) 7/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
@@ -87,7 +83,7 @@ __bt_seq(const DB *dbp, DBT *key, DBT *data, u_int flags)
}
/*
- * If scan unitialized as yet, or starting at a specific record, set
+ * If scan uninitialized as yet, or starting at a specific record, set
* the scan to a specific key. Both __bt_seqset and __bt_seqadv pin
* the page the cursor references if they're successful.
*/
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index cae6ebd81c33..5fbf8c3ac0f3 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_split.c 8.10 (Berkeley) 1/9/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <limits.h>
diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c
index bc78ef871ff0..0594fbad6e9c 100644
--- a/lib/libc/db/btree/bt_utils.c
+++ b/lib/libc/db/btree/bt_utils.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bt_utils.c 8.8 (Berkeley) 7/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
@@ -70,7 +66,7 @@ __bt_ret(BTREE *t, EPG *e, DBT *key, DBT *rkey, DBT *data, DBT *rdata, int copy)
bl = GETBLEAF(e->page, e->index);
/*
- * We must copy big keys/data to make them contigous. Otherwise,
+ * We must copy big keys/data to make them contiguous. Otherwise,
* leave the page pinned and don't copy unless the user specified
* concurrent access.
*/
diff --git a/lib/libc/db/btree/btree.h b/lib/libc/db/btree/btree.h
index 4b167652e37e..9e30f097bc72 100644
--- a/lib/libc/db/btree/btree.h
+++ b/lib/libc/db/btree/btree.h
@@ -30,8 +30,6 @@
* 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.
- *
- * @(#)btree.h 8.11 (Berkeley) 8/17/94
*/
/* Macros to set/clear/test flags. */
diff --git a/lib/libc/db/btree/extern.h b/lib/libc/db/btree/extern.h
index 023d9ffe49bd..4ed2bad9cfc1 100644
--- a/lib/libc/db/btree/extern.h
+++ b/lib/libc/db/btree/extern.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)extern.h 8.10 (Berkeley) 7/20/94
*/
int __bt_close(DB *);
diff --git a/lib/libc/db/db/Makefile.inc b/lib/libc/db/db/Makefile.inc
index 62b196508784..7447ec41ca87 100644
--- a/lib/libc/db/db/Makefile.inc
+++ b/lib/libc/db/db/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
.PATH: ${LIBC_SRCTOP}/db/db
SRCS+= db.c
diff --git a/lib/libc/db/db/db.c b/lib/libc/db/db/db.c
index 0f061ab5b41c..2c748cfe34a5 100644
--- a/lib/libc/db/db/db.c
+++ b/lib/libc/db/db/db.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/docs/hash.usenix.ps b/lib/libc/db/docs/hash.usenix.ps
index e050cdeba59f..98adfdf209b5 100644
--- a/lib/libc/db/docs/hash.usenix.ps
+++ b/lib/libc/db/docs/hash.usenix.ps
@@ -3,7 +3,6 @@
%%Title: stdin (ditroff)
%%CreationDate: Tue Dec 11 15:06:45 1990
%%EndComments
-% @(#)psdit.pro 1.3 4/15/88
% lib/psdit.pro -- prolog for psdit (ditroff) files
% Copyright (c) 1984, 1985 Adobe Systems Incorporated. All Rights Reserved.
% last edit: shore Sat Nov 23 20:28:03 1985
diff --git a/lib/libc/db/docs/libtp.usenix.ps b/lib/libc/db/docs/libtp.usenix.ps
index 57df42730902..2ec31308cb0e 100644
--- a/lib/libc/db/docs/libtp.usenix.ps
+++ b/lib/libc/db/docs/libtp.usenix.ps
@@ -3,7 +3,6 @@
%%Title: stdin (ditroff)
%%CreationDate: Thu Dec 12 15:32:11 1991
%%EndComments
-% @(#)psdit.pro 1.3 4/15/88
% lib/psdit.pro -- prolog for psdit (ditroff) files
% Copyright (c) 1984, 1985 Adobe Systems Incorporated. All Rights Reserved.
% last edit: shore Sat Nov 23 20:28:03 1985
diff --git a/lib/libc/db/hash/Makefile.inc b/lib/libc/db/hash/Makefile.inc
index 0e1fb138fc09..0d58e60796a1 100644
--- a/lib/libc/db/hash/Makefile.inc
+++ b/lib/libc/db/hash/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
.PATH: ${LIBC_SRCTOP}/db/hash
SRCS+= hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c \
diff --git a/lib/libc/db/hash/README b/lib/libc/db/hash/README
index afa0610cedc7..0a5a8142e896 100644
--- a/lib/libc/db/hash/README
+++ b/lib/libc/db/hash/README
@@ -1,4 +1,3 @@
-# @(#)README 8.1 (Berkeley) 6/4/93
This package implements a superset of the hsearch and dbm/ndbm libraries.
diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h
index 181b2b80c8a3..d3850752ad3a 100644
--- a/lib/libc/db/hash/extern.h
+++ b/lib/libc/db/hash/extern.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)extern.h 8.4 (Berkeley) 6/16/94
*/
BUFHEAD *__add_ovflpage(HTAB *, BUFHEAD *);
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index b707ee5ff3ac..88a3ffeab828 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -103,11 +99,6 @@ __hash_open(const char *file, int flags, int mode,
DB *dbp;
int bpages, hdrsize, new_table, nsegs, save_errno;
- if ((flags & O_ACCMODE) == O_WRONLY) {
- errno = EINVAL;
- return (NULL);
- }
-
if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB))))
return (NULL);
hashp->fp = -1;
@@ -119,12 +110,17 @@ __hash_open(const char *file, int flags, int mode,
* we can check accesses.
*/
hashp->flags = flags;
+ if ((flags & O_ACCMODE) == O_WRONLY) {
+ flags &= ~O_WRONLY;
+ flags |= O_RDWR;
+ }
if (file) {
if ((hashp->fp = _open(file, flags | O_CLOEXEC, mode)) == -1)
RETURN_ERROR(errno, error0);
new_table = _fstat(hashp->fp, &statbuf) == 0 &&
- statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY;
+ statbuf.st_size == 0 &&
+ ((flags & O_ACCMODE) != O_RDONLY || (flags & O_CREAT) != 0);
} else
new_table = 1;
@@ -183,7 +179,7 @@ __hash_open(const char *file, int flags, int mode,
__buf_init(hashp, DEF_BUFSIZE);
hashp->new_file = new_table;
- hashp->save_file = file && (hashp->flags & O_RDWR);
+ hashp->save_file = file && (flags & O_RDWR);
hashp->cbucket = -1;
if (!(dbp = (DB *)malloc(sizeof(DB)))) {
save_errno = errno;
@@ -527,6 +523,10 @@ hash_get(const DB *dbp, const DBT *key, DBT *data, u_int32_t flag)
hashp->error = errno = EINVAL;
return (ERROR);
}
+ if ((hashp->flags & O_ACCMODE) == O_WRONLY) {
+ hashp->error = errno = EPERM;
+ return (ERROR);
+ }
return (hash_access(hashp, HASH_GET, (DBT *)key, data));
}
@@ -704,17 +704,19 @@ hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t flag)
u_int16_t *bp, ndx;
hashp = (HTAB *)dbp->internal;
- if (flag && flag != R_FIRST && flag != R_NEXT) {
+ if (flag != R_FIRST && flag != R_NEXT) {
hashp->error = errno = EINVAL;
return (ERROR);
}
#ifdef HASH_STATISTICS
hash_accesses++;
#endif
- if ((hashp->cbucket < 0) || (flag == R_FIRST)) {
+ if (flag == R_FIRST) {
hashp->cbucket = 0;
hashp->cndx = 1;
hashp->cpage = NULL;
+ } else if (hashp->cbucket < 0) { /* R_NEXT */
+ return (ABNORMAL);
}
next_bucket:
for (bp = NULL; !bp || !bp[0]; ) {
diff --git a/lib/libc/db/hash/hash.h b/lib/libc/db/hash/hash.h
index 2e77025c56e1..91d2a459bed2 100644
--- a/lib/libc/db/hash/hash.h
+++ b/lib/libc/db/hash/hash.h
@@ -30,8 +30,6 @@
* 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.
- *
- * @(#)hash.h 8.3 (Berkeley) 5/31/94
*/
/* Operations */
diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c
index 301fc98a1a4a..15fc0899e27e 100644
--- a/lib/libc/db/hash/hash_bigkey.c
+++ b/lib/libc/db/hash/hash_bigkey.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* PACKAGE: hash
* DESCRIPTION:
diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c
index 72c74d38f1b2..94f95c8c0383 100644
--- a/lib/libc/db/hash/hash_buf.c
+++ b/lib/libc/db/hash/hash_buf.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* PACKAGE: hash
*
diff --git a/lib/libc/db/hash/hash_func.c b/lib/libc/db/hash/hash_func.c
index dc7e276b03a9..529180b7698d 100644
--- a/lib/libc/db/hash/hash_func.c
+++ b/lib/libc/db/hash/hash_func.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <db.h>
diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c
index 62c57b3ef1c7..035b073e5d52 100644
--- a/lib/libc/db/hash/hash_log2.c
+++ b/lib/libc/db/hash/hash_log2.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <db.h>
#include "hash.h"
#include "page.h"
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index 2f86db8106c1..2a7b594dc3ea 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* PACKAGE: hashing
*
diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c
index 08e2dc7d3eea..b9d663a2de4c 100644
--- a/lib/libc/db/hash/ndbm.c
+++ b/lib/libc/db/hash/ndbm.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* This package provides a dbm compatible interface to the new hashing
* package described in db(3).
diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h
index 5d9b6fedb6a9..372669a5e6d4 100644
--- a/lib/libc/db/hash/page.h
+++ b/lib/libc/db/hash/page.h
@@ -30,8 +30,6 @@
* 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.
- *
- * @(#)page.h 8.2 (Berkeley) 5/31/94
*/
/*
diff --git a/lib/libc/db/man/Makefile.inc b/lib/libc/db/man/Makefile.inc
index 15021f0ca900..312fd0467078 100644
--- a/lib/libc/db/man/Makefile.inc
+++ b/lib/libc/db/man/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
.PATH: ${LIBC_SRCTOP}/db/man
MAN+= btree.3 dbm.3 dbopen.3 hash.3 mpool.3 recno.3
@@ -7,7 +5,7 @@ MAN+= btree.3 dbm.3 dbopen.3 hash.3 mpool.3 recno.3
MLINKS+= dbm.3 dbm_clearerr.3
MLINKS+= dbm.3 dbm_close.3
MLINKS+= dbm.3 dbm_delete.3
-MLINKS+= dbm.3 dbm_dirnfo.3
+MLINKS+= dbm.3 dbm_dirfno.3
MLINKS+= dbm.3 dbm_error.3
MLINKS+= dbm.3 dbm_fetch.3
MLINKS+= dbm.3 dbm_firstkey.3
diff --git a/lib/libc/db/man/btree.3 b/lib/libc/db/man/btree.3
index 8b8edf11ced8..0ff39e763067 100644
--- a/lib/libc/db/man/btree.3
+++ b/lib/libc/db/man/btree.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)btree.3 8.4 (Berkeley) 8/18/94
-.\"
.Dd August 18, 1994
.Dt BTREE 3
.Os
diff --git a/lib/libc/db/man/dbm.3 b/lib/libc/db/man/dbm.3
index c5a83c7acef4..30787600ad2d 100644
--- a/lib/libc/db/man/dbm.3
+++ b/lib/libc/db/man/dbm.3
@@ -13,7 +13,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 2, 2022
+.Dd July 25, 2025
.Dt DBM 3
.Os
.Sh NAME
@@ -99,9 +99,6 @@ is a typical value for
.Li 0660
is a typical value for
.Fa mode .
-.Dv O_WRONLY
-is not allowed in
-.Fa flags .
The pointer returned by
.Fn dbm_open
identifies the database and is the
diff --git a/lib/libc/db/man/dbopen.3 b/lib/libc/db/man/dbopen.3
index 4af88386c1eb..7fe515f17849 100644
--- a/lib/libc/db/man/dbopen.3
+++ b/lib/libc/db/man/dbopen.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94
-.\"
.Dd September 10, 2010
.Dt DBOPEN 3
.Os
@@ -78,13 +76,10 @@ are as specified to the
.Xr open 2
routine, however, only the
.Dv O_CREAT , O_EXCL , O_EXLOCK , O_NOFOLLOW , O_NONBLOCK ,
-.Dv O_RDONLY , O_RDWR , O_SHLOCK , O_SYNC
+.Dv O_RDONLY , O_RDWR , O_SHLOCK , O_SYNC, O_WRONLY,
and
.Dv O_TRUNC
flags are meaningful.
-(Note, opening a database file
-.Dv O_WRONLY
-is not possible.)
.\"Three additional options may be specified by
.\".Em or Ns 'ing
.\"them into the
diff --git a/lib/libc/db/man/hash.3 b/lib/libc/db/man/hash.3
index 32179abcedb7..2d01ec67f0d1 100644
--- a/lib/libc/db/man/hash.3
+++ b/lib/libc/db/man/hash.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)hash.3 8.6 (Berkeley) 8/18/94
-.\"
.Dd August 18, 1994
.Dt HASH 3
.Os
diff --git a/lib/libc/db/man/mpool.3 b/lib/libc/db/man/mpool.3
index 21877c8f2c9a..3b4613f51fd7 100644
--- a/lib/libc/db/man/mpool.3
+++ b/lib/libc/db/man/mpool.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 17, 2011
.Dt MPOOL 3
.Os
diff --git a/lib/libc/db/man/recno.3 b/lib/libc/db/man/recno.3
index 63811299ea1b..55c15d8fcc0a 100644
--- a/lib/libc/db/man/recno.3
+++ b/lib/libc/db/man/recno.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)recno.3 8.5 (Berkeley) 8/18/94
-.\"
.Dd August 18, 1994
.Dt RECNO 3
.Os
diff --git a/lib/libc/db/mpool/Makefile.inc b/lib/libc/db/mpool/Makefile.inc
index 731ef8871682..e9c9795add3d 100644
--- a/lib/libc/db/mpool/Makefile.inc
+++ b/lib/libc/db/mpool/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
.PATH: ${LIBC_SRCTOP}/db/mpool
SRCS+= mpool.c \
diff --git a/lib/libc/db/mpool/README b/lib/libc/db/mpool/README
index 0f01fbcdb449..1d70e47a09ef 100644
--- a/lib/libc/db/mpool/README
+++ b/lib/libc/db/mpool/README
@@ -1,4 +1,3 @@
-# @(#)README 8.1 (Berkeley) 6/4/93
These are the current memory pool routines.
They aren't ready for prime time, yet, and
diff --git a/lib/libc/db/mpool/mpool-compat.c b/lib/libc/db/mpool/mpool-compat.c
index ef0e340f641e..191b1cf6089b 100644
--- a/lib/libc/db/mpool/mpool-compat.c
+++ b/lib/libc/db/mpool/mpool-compat.c
@@ -26,7 +26,6 @@
*
*/
-#include <sys/cdefs.h>
#include <db.h>
#include <mpool.h>
diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c
index 24dd1b68aaac..9dab032134bc 100644
--- a/lib/libc/db/mpool/mpool.c
+++ b/lib/libc/db/mpool/mpool.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)mpool.c 8.7 (Berkeley) 11/2/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/lib/libc/db/recno/Makefile.inc b/lib/libc/db/recno/Makefile.inc
index a7d9a2f7576d..b3cb3c412f10 100644
--- a/lib/libc/db/recno/Makefile.inc
+++ b/lib/libc/db/recno/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
.PATH: ${LIBC_SRCTOP}/db/recno
SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c rec_search.c \
diff --git a/lib/libc/db/recno/extern.h b/lib/libc/db/recno/extern.h
index 9b61d3c19fec..6c7cf02e666e 100644
--- a/lib/libc/db/recno/extern.h
+++ b/lib/libc/db/recno/extern.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)extern.h 8.3 (Berkeley) 6/4/94
*/
#include "../btree/extern.h"
diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c
index 7264f6dabd1f..32c79eee2cc6 100644
--- a/lib/libc/db/recno/rec_close.c
+++ b/lib/libc/db/recno/rec_close.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_close.c 8.6 (Berkeley) 8/18/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/uio.h>
diff --git a/lib/libc/db/recno/rec_delete.c b/lib/libc/db/recno/rec_delete.c
index 2e3caac31f0d..7c423934ceb3 100644
--- a/lib/libc/db/recno/rec_delete.c
+++ b/lib/libc/db/recno/rec_delete.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_delete.c 8.7 (Berkeley) 7/14/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c
index 5a47871af78c..4d15505adfaf 100644
--- a/lib/libc/db/recno/rec_get.c
+++ b/lib/libc/db/recno/rec_get.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_get.c 8.9 (Berkeley) 8/18/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c
index ca1d58f1526a..e337768e86c7 100644
--- a/lib/libc/db/recno/rec_open.c
+++ b/lib/libc/db/recno/rec_open.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_open.c 8.10 (Berkeley) 9/1/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/mman.h>
diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c
index e3b307e3450b..017eaabfec1d 100644
--- a/lib/libc/db/recno/rec_put.c
+++ b/lib/libc/db/recno/rec_put.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_put.c 8.7 (Berkeley) 8/18/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/recno/rec_search.c b/lib/libc/db/recno/rec_search.c
index c384b9429420..d565b89202f3 100644
--- a/lib/libc/db/recno/rec_search.c
+++ b/lib/libc/db/recno/rec_search.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_search.c 8.4 (Berkeley) 7/14/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/recno/rec_seq.c b/lib/libc/db/recno/rec_seq.c
index bcbf309f6c94..7f1ba88e73df 100644
--- a/lib/libc/db/recno/rec_seq.c
+++ b/lib/libc/db/recno/rec_seq.c
@@ -29,11 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#ifndef lint
-/* XXX use __SCCSID */
-static char sccsid[] __unused = "@(#)rec_seq.c 8.3 (Berkeley) 7/14/94";
-#endif /* not lint */
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/db/recno/rec_utils.c b/lib/libc/db/recno/rec_utils.c
index 48631fd84429..2004179a1904 100644
--- a/lib/libc/db/recno/rec_utils.c
+++ b/lib/libc/db/recno/rec_utils.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rec_utils.c 8.6 (Berkeley) 7/16/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
diff --git a/lib/libc/db/recno/recno.h b/lib/libc/db/recno/recno.h
index a484983c1f81..7589c1d93b44 100644
--- a/lib/libc/db/recno/recno.h
+++ b/lib/libc/db/recno/recno.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)recno.h 8.1 (Berkeley) 6/4/93
*/
enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */
diff --git a/lib/libc/db/test/Makefile b/lib/libc/db/test/Makefile
index 0d1db95c7838..b8930e951e13 100644
--- a/lib/libc/db/test/Makefile
+++ b/lib/libc/db/test/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.15 (Berkeley) 7/28/94
-
PROG= dbtest
OBJS= dbtest.o strerror.o
diff --git a/lib/libc/db/test/README b/lib/libc/db/test/README
index 0c0cd13d8fa0..55eb85ee76fb 100644
--- a/lib/libc/db/test/README
+++ b/lib/libc/db/test/README
@@ -1,4 +1,3 @@
-# @(#)README 8.8 (Berkeley) 7/31/94
To build this portably, try something like:
diff --git a/lib/libc/db/test/btree.tests/main.c b/lib/libc/db/test/btree.tests/main.c
index 50a769fa9441..94727882dc9f 100644
--- a/lib/libc/db/test/btree.tests/main.c
+++ b/lib/libc/db/test/btree.tests/main.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <fcntl.h>
#include <db.h>
diff --git a/lib/libc/db/test/dbtest.c b/lib/libc/db/test/dbtest.c
index 8b47827db996..8ce8239f41b6 100644
--- a/lib/libc/db/test/dbtest.c
+++ b/lib/libc/db/test/dbtest.c
@@ -29,16 +29,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/lib/libc/db/test/hash.tests/driver2.c b/lib/libc/db/test/hash.tests/driver2.c
index 05f2d57a7533..eb05a6da2dab 100644
--- a/lib/libc/db/test/hash.tests/driver2.c
+++ b/lib/libc/db/test/hash.tests/driver2.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)driver2.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* Test driver, to try to tackle the large ugly-split problem.
*/
diff --git a/lib/libc/db/test/hash.tests/makedb.sh b/lib/libc/db/test/hash.tests/makedb.sh
index f28e281fd19c..e4a1a2de1267 100644
--- a/lib/libc/db/test/hash.tests/makedb.sh
+++ b/lib/libc/db/test/hash.tests/makedb.sh
@@ -1,6 +1,4 @@
#!/bin/sh
-#
-# @(#)makedb.sh 8.1 (Berkeley) 6/4/93
awk '{i++; print $0; print i;}' /usr/share/dict/words > WORDS
ls /bin /usr/bin /usr/ucb /etc | egrep '^(...|....|.....|......)$' | \
diff --git a/lib/libc/db/test/hash.tests/tcreat3.c b/lib/libc/db/test/hash.tests/tcreat3.c
index 68be11143c55..163992dd17a6 100644
--- a/lib/libc/db/test/hash.tests/tcreat3.c
+++ b/lib/libc/db/test/hash.tests/tcreat3.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tcreat3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
diff --git a/lib/libc/db/test/hash.tests/tdel.c b/lib/libc/db/test/hash.tests/tdel.c
index 9760e271808c..78a5618995a9 100644
--- a/lib/libc/db/test/hash.tests/tdel.c
+++ b/lib/libc/db/test/hash.tests/tdel.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tdel.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <db.h>
diff --git a/lib/libc/db/test/hash.tests/testit b/lib/libc/db/test/hash.tests/testit
index 039457a9c4e4..57c1f38a62b5 100644
--- a/lib/libc/db/test/hash.tests/testit
+++ b/lib/libc/db/test/hash.tests/testit
@@ -1,7 +1,4 @@
#!/bin/csh -f
-#
-# @(#)testit 8.1 (Berkeley) 6/4/93
-#
echo ""
echo "PAGE FILL "
diff --git a/lib/libc/db/test/hash.tests/thash4.c b/lib/libc/db/test/hash.tests/thash4.c
index 641534a92730..8dfdf003eafe 100644
--- a/lib/libc/db/test/hash.tests/thash4.c
+++ b/lib/libc/db/test/hash.tests/thash4.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)thash4.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/timeb.h>
diff --git a/lib/libc/db/test/hash.tests/tread2.c b/lib/libc/db/test/hash.tests/tread2.c
index 4962d163a24c..eead3b3105f0 100644
--- a/lib/libc/db/test/hash.tests/tread2.c
+++ b/lib/libc/db/test/hash.tests/tread2.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tread2.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
diff --git a/lib/libc/db/test/hash.tests/tseq.c b/lib/libc/db/test/hash.tests/tseq.c
index c9569cbbe6d4..5b27d80881e9 100644
--- a/lib/libc/db/test/hash.tests/tseq.c
+++ b/lib/libc/db/test/hash.tests/tseq.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tseq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
diff --git a/lib/libc/db/test/hash.tests/tverify.c b/lib/libc/db/test/hash.tests/tverify.c
index 2e8209e42117..6a2342c96bd9 100644
--- a/lib/libc/db/test/hash.tests/tverify.c
+++ b/lib/libc/db/test/hash.tests/tverify.c
@@ -32,16 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tverify.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
diff --git a/lib/libc/db/test/run.test b/lib/libc/db/test/run.test
index 52b74c316199..33ef393ce1ce 100644
--- a/lib/libc/db/test/run.test
+++ b/lib/libc/db/test/run.test
@@ -1,7 +1,4 @@
#!/bin/sh -
-#
-# @(#)run.test 8.10 (Berkeley) 7/26/94
-#
# db regression tests
main()
diff --git a/lib/libc/gdtoa/Makefile.inc b/lib/libc/gdtoa/Makefile.inc
index 5a7bc9fab150..ce0ddfc46162 100644
--- a/lib/libc/gdtoa/Makefile.inc
+++ b/lib/libc/gdtoa/Makefile.inc
@@ -1,4 +1,3 @@
-
# netlib gdtoa sources
.PATH: ${LIBC_SRCTOP}/gdtoa
diff --git a/lib/libc/gdtoa/Symbol.map b/lib/libc/gdtoa/Symbol.map
index a3cfd8df6819..55fe12e87c57 100644
--- a/lib/libc/gdtoa/Symbol.map
+++ b/lib/libc/gdtoa/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
/*
* Standard functions from contrib/gdtoa
diff --git a/lib/libc/gdtoa/_hdtoa.c b/lib/libc/gdtoa/_hdtoa.c
index c5f2238d7a7b..8ae739acf0db 100644
--- a/lib/libc/gdtoa/_hdtoa.c
+++ b/lib/libc/gdtoa/_hdtoa.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/lib/libc/gdtoa/_hldtoa.c b/lib/libc/gdtoa/_hldtoa.c
index 698038fd8de4..965d2349d103 100644
--- a/lib/libc/gdtoa/_hldtoa.c
+++ b/lib/libc/gdtoa/_hldtoa.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/lib/libc/gdtoa/_ldtoa.c b/lib/libc/gdtoa/_ldtoa.c
index 3787b7dd653d..81da06013855 100644
--- a/lib/libc/gdtoa/_ldtoa.c
+++ b/lib/libc/gdtoa/_ldtoa.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
diff --git a/lib/libc/gdtoa/machdep_ldisQ.c b/lib/libc/gdtoa/machdep_ldisQ.c
index d39d57e9d292..abd9f4288884 100644
--- a/lib/libc/gdtoa/machdep_ldisQ.c
+++ b/lib/libc/gdtoa/machdep_ldisQ.c
@@ -37,7 +37,6 @@
* uses quad precision, such as aarch64 or riscv.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "gdtoaimp.h"
diff --git a/lib/libc/gdtoa/machdep_ldisd.c b/lib/libc/gdtoa/machdep_ldisd.c
index 79370e05c604..061c67f0bb5a 100644
--- a/lib/libc/gdtoa/machdep_ldisd.c
+++ b/lib/libc/gdtoa/machdep_ldisd.c
@@ -37,7 +37,6 @@
* is the same as a double, such as the Alpha.
*/
-#include <sys/cdefs.h>
#include "gdtoaimp.h"
#undef strtold_l
diff --git a/lib/libc/gdtoa/machdep_ldisx.c b/lib/libc/gdtoa/machdep_ldisx.c
index 7c7c0d9e5d28..e3cd4899452d 100644
--- a/lib/libc/gdtoa/machdep_ldisx.c
+++ b/lib/libc/gdtoa/machdep_ldisx.c
@@ -37,7 +37,6 @@
* is an IEEE extended precision number.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "gdtoaimp.h"
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 655843f03715..4d064d18d36e 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
-
# machine-independent gen sources
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen ${SRCTOP}/etc
@@ -7,7 +5,7 @@ CONFS+= group master.passwd shells
CONFSMODE_master.passwd= 600
CONFSPACKAGE= runtime
-SRCS+= __getosreldate.c \
+SRCS+= \
__pthread_mutex_init_calloc_cb_stub.c \
__xuname.c \
_once_stub.c \
@@ -15,12 +13,13 @@ SRCS+= __getosreldate.c \
_rand48.c \
_spinlock_stub.c \
_thread_init.c \
+ aio_read2.c \
+ aio_write2.c \
alarm.c \
arc4random.c \
arc4random-compat.c \
arc4random_uniform.c \
assert.c \
- auxv.c \
basename.c \
basename_compat.c \
cap_sandboxed.c \
@@ -47,11 +46,11 @@ SRCS+= __getosreldate.c \
erand48.c \
err.c \
errlst.c \
- errno.c \
eventfd.c \
exec.c \
exect.c \
fdevname.c \
+ fdopendir.c \
feature_present.c \
fmtcheck.c \
fmtmsg.c \
@@ -80,8 +79,6 @@ SRCS+= __getosreldate.c \
getmntinfo-compat11.c \
getnetgrent.c \
getosreldate.c \
- getpagesize.c \
- getpagesizes.c \
getpeereid.c \
getprogname.c \
getpwent.c \
@@ -92,6 +89,7 @@ SRCS+= __getosreldate.c \
glob.c \
glob-compat11.c \
initgroups.c \
+ inotify.c \
isatty.c \
isinf.c \
isnan.c \
@@ -99,9 +97,10 @@ SRCS+= __getosreldate.c \
kqueue1.c \
lcong48.c \
libc_dlopen.c \
- lockf.c \
+ libc_interposing_table.c \
lrand48.c \
memalign.c \
+ memfd_create.c \
mrand48.c \
nftw.c \
nftw-compat11.c \
@@ -109,6 +108,7 @@ SRCS+= __getosreldate.c \
nlist.c \
nrand48.c \
opendir.c \
+ opendir2.c \
pause.c \
pmadvise.c \
popen.c \
@@ -120,7 +120,6 @@ SRCS+= __getosreldate.c \
readdir.c \
readdir-compat11.c \
readpassphrase.c \
- recvmmsg.c \
rewinddir.c \
scandir.c \
scandir_b.c \
@@ -130,13 +129,13 @@ SRCS+= __getosreldate.c \
seed48.c \
seekdir.c \
semctl.c \
- sendmmsg.c \
setdomainname.c \
sethostname.c \
setjmperr.c \
setmode.c \
setproctitle.c \
setprogname.c \
+ sig2str.c \
siginterrupt.c \
siglist.c \
signal.c \
@@ -162,6 +161,8 @@ SRCS+= __getosreldate.c \
ttyname.c \
ttyslot.c \
ualarm.c \
+ uexterr_format.c \
+ uexterr_gettext.c \
ulimit.c \
uname.c \
unvis-compat.c \
@@ -169,12 +170,13 @@ SRCS+= __getosreldate.c \
utime.c \
utxdb.c \
valloc.c \
- wait.c \
- wait3.c \
- waitpid.c \
- waitid.c \
wordexp.c
+.if ${COMPILER_FEATURES:Mblocks}
+CFLAGS.fts.c= -fblocks
+CFLAGS.glob.c= -fblocks
+.endif
+
CFLAGS.arc4random.c= -I${SRCTOP}/sys -I${SRCTOP}/sys/crypto/chacha20
CFLAGS.sysconf.c= -I${SRCTOP}/contrib/tzcode
@@ -206,7 +208,6 @@ SYM_MAPS+=${LIBC_SRCTOP}/gen/Symbol.map
MAN+= alarm.3 \
arc4random.3 \
- auxv.3 \
basename.3 \
cap_rights_get.3 \
cap_sandboxed.3 \
@@ -252,8 +253,6 @@ MAN+= alarm.3 \
getmntinfo.3 \
getnetgrent.3 \
getosreldate.3 \
- getpagesize.3 \
- getpagesizes.3 \
getpass.3 \
getpeereid.3 \
getprogname.3 \
@@ -266,7 +265,6 @@ MAN+= alarm.3 \
initgroups.3 \
isgreater.3 \
ldexp.3 \
- lockf.3 \
makecontext.3 \
modf.3 \
nice.3 \
@@ -288,7 +286,7 @@ MAN+= alarm.3 \
raise.3 \
rand48.3 \
readpassphrase.3 \
- rfork_thread.3 \
+ rtld_get_var.3 \
scandir.3 \
sem_destroy.3 \
sem_getvalue.3 \
@@ -303,7 +301,6 @@ MAN+= alarm.3 \
siginterrupt.3 \
signal.3 \
sigsetops.3 \
- sleep.3 \
statvfs.3 \
stringlist.3 \
strtofflags.3 \
@@ -321,15 +318,12 @@ MAN+= alarm.3 \
times.3 \
timespec_get.3 \
timespec_getres.3 \
- timezone.3 \
ttyname.3 \
- tzset.3 \
ualarm.3 \
ucontext.3 \
ulimit.3 \
uname.3 \
unvis.3 \
- usleep.3 \
utime.3 \
valloc.3 \
vis.3 \
@@ -337,7 +331,6 @@ MAN+= alarm.3 \
MLINKS+=arc4random.3 arc4random_buf.3 \
arc4random.3 arc4random_uniform.3
-MLINKS+=auxv.3 elf_aux_info.3
MLINKS+=ctermid.3 ctermid_r.3
MLINKS+=daemon.3 daemonfd.3
MLINKS+=devname.3 devname_r.3
@@ -378,7 +371,8 @@ MLINKS+=exec.3 execl.3 \
exec.3 exect.3 \
exec.3 execv.3 \
exec.3 execvP.3 \
- exec.3 execvp.3
+ exec.3 execvp.3 \
+ exec.3 execvpe.3
MLINKS+=fpclassify.3 finite.3 \
fpclassify.3 finitef.3 \
fpclassify.3 isfinite.3 \
@@ -481,10 +475,17 @@ MLINKS+=posix_spawn.3 posix_spawnp.3 \
posix_spawnattr_getsigdefault.3 posix_spawnattr_setsigdefault.3 \
posix_spawnattr_getsigmask.3 posix_spawnattr_setsigmask.3 \
posix_spawnattr_init.3 posix_spawnattr_destroy.3
-MLINKS+=psignal.3 strsignal.3 \
+MLINKS+=psignal.3 psiginfo.3 \
+ psignal.3 sig2str.3 \
+ psignal.3 str2sig.3 \
+ psignal.3 strsignal.3 \
psignal.3 sys_siglist.3 \
psignal.3 sys_signame.3
-MLINKS+=pwcache.3 group_from_gid.3 \
+MLINKS+=pwcache.3 gid_from_group.3 \
+ pwcache.3 group_from_gid.3 \
+ pwcache.3 pwcache_groupdb.3 \
+ pwcache.3 pwcache_userdb.3 \
+ pwcache.3 uid_from_user.3 \
pwcache.3 user_from_uid.3
MLINKS+=rand48.3 _rand48.3 \
rand48.3 drand48.3 \
@@ -496,16 +497,19 @@ MLINKS+=rand48.3 _rand48.3 \
rand48.3 nrand48.3 \
rand48.3 seed48.3 \
rand48.3 srand48.3
-MLINKS+=recv.2 recvmmsg.2
+MLINKS+=rtld_get_var.3 \
+ rtld_set_var.3
MLINKS+=scandir.3 alphasort.3 \
- scandir.3 scandirat.3 \
+ scandir.3 fdscandir.3 \
+ scandir.3 fdscandir_b.3 \
scandir.3 scandir_b.3 \
+ scandir.3 scandirat.3 \
+ scandir.3 scandirat_b.3 \
scandir.3 versionsort.3
MLINKS+=sem_open.3 sem_close.3 \
sem_open.3 sem_unlink.3
MLINKS+=sem_wait.3 sem_trywait.3
MLINKS+=sem_timedwait.3 sem_clockwait_np.3
-MLINKS+=send.2 sendmmsg.2
MLINKS+=setjmp.3 _longjmp.3 \
setjmp.3 _setjmp.3 \
setjmp.3 longjmp.3 \
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index bdd659197644..26f638568efc 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
__xuname;
pthread_atfork;
@@ -50,6 +47,7 @@ FBSD_1.0 {
pthread_mutexattr_init;
pthread_mutexattr_settype;
pthread_once;
+ pthread_resume_all_np;
pthread_rwlock_destroy;
pthread_rwlock_init;
pthread_rwlock_rdlock;
@@ -62,6 +60,7 @@ FBSD_1.0 {
pthread_setcanceltype;
pthread_setspecific;
pthread_sigmask;
+ pthread_suspend_all_np;
pthread_testcancel;
alarm;
arc4random;
@@ -102,7 +101,6 @@ FBSD_1.0 {
vwarnx;
sys_errlist;
sys_nerr;
- errno;
exect;
execl;
execle;
@@ -110,6 +108,7 @@ FBSD_1.0 {
execv;
execvp;
execvP;
+ fabs;
fmtcheck;
fmtmsg;
fnmatch;
@@ -161,7 +160,6 @@ FBSD_1.0 {
endnetgrent;
innetgr;
getosreldate;
- getpagesize;
getpeereid;
_getprogname;
getprogname;
@@ -184,10 +182,12 @@ FBSD_1.0 {
endusershell;
setusershell;
getvfsbyname;
+ __nan;
__isnan;
isnan;
__isnanf;
isnanf;
+ __infinity;
__isinf;
isinf;
__isinff;
@@ -199,6 +199,7 @@ FBSD_1.0 {
ldexp;
lockf;
lrand48;
+ makecontext;
modf;
mrand48;
nice;
@@ -220,6 +221,12 @@ FBSD_1.0 {
group_from_gid;
setdomainname;
sethostname;
+ _setjmp;
+ _longjmp;
+ setjmp;
+ longjmp;
+ sigsetjmp;
+ siglongjmp;
longjmperror;
getmode;
setmode;
@@ -256,7 +263,6 @@ FBSD_1.0 {
setlogmask;
ttyname_r;
ttyname;
- timezone;
times;
time;
telldir;
@@ -332,7 +338,6 @@ FBSD_1.1 {
FBSD_1.2 {
cfmakesane;
endutxent;
- getpagesizes;
getutxent;
getutxid;
getutxline;
@@ -354,6 +359,7 @@ FBSD_1.2 {
};
FBSD_1.3 {
+ cap_sandboxed;
clock_getcpuclockid;
dirfd;
dup3;
@@ -397,7 +403,6 @@ FBSD_1.5 {
devname;
devname_r;
dirname;
- elf_aux_info;
fts_children;
fts_close;
fts_get_clientptr;
@@ -426,6 +431,7 @@ FBSD_1.6 {
eventfd_write;
getlogin_r;
memalign;
+ memfd_create;
pthread_getname_np;
scandir_b;
sigandset;
@@ -443,16 +449,36 @@ FBSD_1.7 {
scandirat;
sched_getaffinity;
sched_setaffinity;
- sched_getcpu;
versionsort;
__cpuset_alloc;
__cpuset_free;
};
+FBSD_1.8 {
+ aio_read2;
+ aio_write2;
+ execvpe;
+ fdscandir;
+ fdscandir_b;
+ fts_open_b;
+ glob_b;
+ inotify_add_watch;
+ inotify_init;
+ inotify_init1;
+ psiginfo;
+ rtld_get_var;
+ rtld_set_var;
+ scandirat_b;
+ uexterr_gettext;
+ sig2str;
+ str2sig;
+};
+
FBSDprivate_1.0 {
/* needed by thread libraries */
__thr_jtable;
+ _dl_iterate_phdr_locked;
_pthread_atfork;
_pthread_attr_destroy;
_pthread_attr_getdetachstate;
@@ -555,6 +581,8 @@ FBSDprivate_1.0 {
__waitpid;
_waitpid;
+ __libc_interposing_slot;
+
_libc_sem_init_compat;
_libc_sem_destroy_compat;
_libc_sem_open_compat;
@@ -568,10 +596,10 @@ FBSDprivate_1.0 {
__libc_tcdrain;
- __elf_aux_vector;
- __pthread_distribute_static_tls;
__pthread_map_stacks_exec;
__fillcontextx;
__fillcontextx2;
__getcontextx_size;
+ __makecontext;
+ __uexterr_format;
};
diff --git a/lib/libc/gen/__getosreldate.c b/lib/libc/gen/__getosreldate.c
deleted file mode 100644
index 81e7382caac6..000000000000
--- a/lib/libc/gen/__getosreldate.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2007 Peter Wemm
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <errno.h>
-#include <link.h>
-#include "libc_private.h"
-
-/*
- * This is private to libc. It is intended for wrapping syscall stubs in order
- * to avoid having to put SIGSYS signal handlers in place to test for presence
- * of new syscalls. This caches the result in order to be as quick as possible.
- *
- * Use getosreldate(3) for public use as it respects the $OSVERSION environment
- * variable.
- */
-
-int
-__getosreldate(void)
-{
- static int osreldate;
- size_t len;
- int oid[2];
- int error, osrel;
-
- if (osreldate != 0)
- return (osreldate);
-
- error = _elf_aux_info(AT_OSRELDATE, &osreldate, sizeof(osreldate));
- if (error == 0 && osreldate != 0)
- return (osreldate);
-
- oid[0] = CTL_KERN;
- oid[1] = KERN_OSRELDATE;
- osrel = 0;
- len = sizeof(osrel);
- error = sysctl(oid, 2, &osrel, &len, NULL, 0);
- if (error == 0 && osrel > 0 && len == sizeof(osrel))
- osreldate = osrel;
- return (osreldate);
-}
diff --git a/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c b/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
index 1f0a8f7a944d..3a81ace8a0f4 100644
--- a/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
+++ b/lib/libc/gen/__pthread_mutex_init_calloc_cb_stub.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <pthread.h>
#include "libc_private.h"
diff --git a/lib/libc/gen/__xuname.c b/lib/libc/gen/__xuname.c
index f6e1372dc76a..4257c42f9519 100644
--- a/lib/libc/gen/__xuname.c
+++ b/lib/libc/gen/__xuname.c
@@ -27,11 +27,8 @@
* 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.
- *
- * From: @(#)uname.c 8.1 (Berkeley) 1/4/94
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
diff --git a/lib/libc/gen/_once_stub.c b/lib/libc/gen/_once_stub.c
index 27de031108af..518072cbd28f 100644
--- a/lib/libc/gen/_once_stub.c
+++ b/lib/libc/gen/_once_stub.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include "un-namespace.h"
diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c
index 34e420ec11f5..d867ee4db51e 100644
--- a/lib/libc/gen/_pthread_stubs.c
+++ b/lib/libc/gen/_pthread_stubs.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <signal.h>
#include <pthread.h>
#include <stdlib.h>
@@ -51,6 +50,7 @@ struct pthread {
static struct pthread main_thread;
static int stub_main(void);
+static void stub_void(void);
static void *stub_null(void);
static struct pthread *stub_self(void);
static int stub_zero(void);
@@ -63,6 +63,7 @@ static int stub_getname_np(pthread_t, char *, size_t);
#define PJT_DUAL_ENTRY(entry) \
(pthread_func_t)entry, (pthread_func_t)entry
+__attribute__((visibility("protected")))
pthread_func_entry_t __thr_jtable[PJT_MAX] = {
[PJT_ATFORK] = {PJT_DUAL_ENTRY(stub_zero)},
[PJT_ATTR_DESTROY] = {PJT_DUAL_ENTRY(stub_zero)},
@@ -133,6 +134,8 @@ pthread_func_entry_t __thr_jtable[PJT_MAX] = {
[PJT_GETTHREADID_NP] = {PJT_DUAL_ENTRY(stub_zero)},
[PJT_ATTR_GET_NP] = {PJT_DUAL_ENTRY(stub_esrch)},
[PJT_GETNAME_NP] = {PJT_DUAL_ENTRY(stub_getname_np)},
+ [PJT_SUSPEND_ALL_NP] = {PJT_DUAL_ENTRY(stub_void)},
+ [PJT_RESUME_ALL_NP] = {PJT_DUAL_ENTRY(stub_void)},
};
/*
@@ -292,6 +295,8 @@ STUB_FUNC1(_pthread_cancel_enter, PJT_CANCEL_ENTER, void, int)
STUB_FUNC1(_pthread_cancel_leave, PJT_CANCEL_LEAVE, void, int)
STUB_FUNC2(pthread_attr_get_np, PJT_ATTR_GET_NP, int, pthread_t, pthread_attr_t *)
STUB_FUNC3(pthread_getname_np, PJT_GETNAME_NP, int, pthread_t, char *, size_t)
+STUB_FUNC(pthread_suspend_all_np, PJT_SUSPEND_ALL_NP, void);
+STUB_FUNC(pthread_resume_all_np, PJT_RESUME_ALL_NP, void);
static int
stub_zero(void)
@@ -299,6 +304,12 @@ stub_zero(void)
return (0);
}
+static void
+stub_void(void)
+{
+
+}
+
static void *
stub_null(void)
{
diff --git a/lib/libc/gen/_rand48.c b/lib/libc/gen/_rand48.c
index e422781e44d3..990e2c86949b 100644
--- a/lib/libc/gen/_rand48.c
+++ b/lib/libc/gen/_rand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
unsigned short _rand48_seed[3] = {
diff --git a/lib/libc/gen/_spinlock_stub.c b/lib/libc/gen/_spinlock_stub.c
index b220d90ea193..30e5c61f5f74 100644
--- a/lib/libc/gen/_spinlock_stub.c
+++ b/lib/libc/gen/_spinlock_stub.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include "spinlock.h"
diff --git a/lib/libc/gen/_thread_init.c b/lib/libc/gen/_thread_init.c
index b285654cc863..66fa8b8c2e96 100644
--- a/lib/libc/gen/_thread_init.c
+++ b/lib/libc/gen/_thread_init.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
void _thread_init_stub(void);
diff --git a/lib/libc/gen/aio_read2.c b/lib/libc/gen/aio_read2.c
new file mode 100644
index 000000000000..a5186d509b26
--- /dev/null
+++ b/lib/libc/gen/aio_read2.c
@@ -0,0 +1,58 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 The FreeBSD Foundation
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/aio.h>
+#include <errno.h>
+#include <stddef.h>
+
+int
+aio_read2(struct aiocb *iocb, int flags)
+{
+ int error;
+
+ if ((flags & ~(AIO_OP2_FOFFSET | AIO_OP2_VECTORED)) != 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+ iocb->aio_lio_opcode = LIO_READ;
+ if ((flags & AIO_OP2_FOFFSET) != 0)
+ iocb->aio_lio_opcode |= LIO_FOFFSET;
+ if ((flags & AIO_OP2_VECTORED) != 0)
+ iocb->aio_lio_opcode |= LIO_VECTORED;
+
+ error = lio_listio(LIO_NOWAIT, &iocb, 1, NULL);
+ if (error == -1 && errno == EIO) {
+ error = aio_error(iocb);
+ if (error != -1 && error != 0)
+ errno = error;
+ error = -1;
+ }
+ return (error);
+}
diff --git a/lib/libc/gen/aio_write2.c b/lib/libc/gen/aio_write2.c
new file mode 100644
index 000000000000..8f4f6a35fd4d
--- /dev/null
+++ b/lib/libc/gen/aio_write2.c
@@ -0,0 +1,58 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 The FreeBSD Foundation
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/aio.h>
+#include <errno.h>
+#include <stddef.h>
+
+int
+aio_write2(struct aiocb *iocb, int flags)
+{
+ int error;
+
+ if ((flags & ~(AIO_OP2_FOFFSET | AIO_OP2_VECTORED)) != 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+ iocb->aio_lio_opcode = LIO_WRITE;
+ if ((flags & AIO_OP2_FOFFSET) != 0)
+ iocb->aio_lio_opcode |= LIO_FOFFSET;
+ if ((flags & AIO_OP2_VECTORED) != 0)
+ iocb->aio_lio_opcode |= LIO_VECTORED;
+
+ error = lio_listio(LIO_NOWAIT, &iocb, 1, NULL);
+ if (error == -1 && errno == EIO) {
+ error = aio_error(iocb);
+ if (error != -1 && error != 0)
+ errno = error;
+ error = -1;
+ }
+ return (error);
+}
diff --git a/lib/libc/gen/alarm.3 b/lib/libc/gen/alarm.3
index 6e9d13b51dd6..4a24cc6d7216 100644
--- a/lib/libc/gen/alarm.3
+++ b/lib/libc/gen/alarm.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)alarm.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd April 2, 2022
.Dt ALARM 3
.Os
@@ -65,7 +63,7 @@ Due to
.Xr setitimer 2
restriction the maximum number of
.Fa seconds
-allowed is 100000000.
+allowed is 100,000,000.
.Sh RETURN VALUES
The return value of
.Fn alarm
diff --git a/lib/libc/gen/alarm.c b/lib/libc/gen/alarm.c
index 58b9835608d8..043571ff89a1 100644
--- a/lib/libc/gen/alarm.c
+++ b/lib/libc/gen/alarm.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)alarm.c 8.1 (Berkeley) 6/4/93");
/*
* Backwards compatible alarm.
*/
diff --git a/lib/libc/gen/arc4random-compat.c b/lib/libc/gen/arc4random-compat.c
index 014273b1a76d..beeb4d75964a 100644
--- a/lib/libc/gen/arc4random-compat.c
+++ b/lib/libc/gen/arc4random-compat.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdbool.h>
#include <syslog.h>
diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3
index 62b62e883e9c..1b042f15f000 100644
--- a/lib/libc/gen/arc4random.3
+++ b/lib/libc/gen/arc4random.3
@@ -30,7 +30,7 @@
.\"
.\" Manual page, using -mandoc macros
.\"
-.Dd April 13, 2020
+.Dd November 18, 2024
.Dt ARC4RANDOM 3
.Os
.Sh NAME
@@ -129,9 +129,31 @@ functions using
.%O Document ID: 4027b5256e17b9796842e6d0f68b0b5e
.%U http://cr.yp.to/papers.html#chacha
.Re
+.Rs
+.%A Daniel Lemire
+.%T Fast Random Integer Generation in an Interval
+.%D January 2019
+.%J ACM Trans. Model. Comput. Simul.
+.%I Association for Computing Machinery
+.%C New York, NY, USA
+.%V vol. 29
+.%N no. 1
+.%P pp. 1\(en12
+.Re
.Sh HISTORY
These functions first appeared in
.Ox 2.1 .
+.Fn arc4random
+first appeared in
+.Fx 3.0 .
+.Fn arc4random_buf
+and
+.Fn arc4random_uniform
+first appeared in
+.Fx 8.0 .
+.Fn arc4random_stir
+was removed in
+.Fx 12.0 .
.Pp
The original version of this random number generator used the
RC4 (also known as ARC4) algorithm.
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c
index 621af03a57a7..cc65e0131970 100644
--- a/lib/libc/gen/arc4random.c
+++ b/lib/libc/gen/arc4random.c
@@ -23,7 +23,6 @@
* ChaCha based random number generator for OpenBSD.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#if defined(__FreeBSD__)
#include <assert.h>
@@ -36,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -244,7 +244,7 @@ arc4random(void)
}
void
-arc4random_buf(void *buf, size_t n)
+__ssp_real(arc4random_buf)(void *buf, size_t n)
{
_ARC4_LOCK();
_rs_random_buf(buf, n);
diff --git a/lib/libc/gen/arc4random_uniform.c b/lib/libc/gen/arc4random_uniform.c
index 06cd29c6dbe4..23455e545899 100644
--- a/lib/libc/gen/arc4random_uniform.c
+++ b/lib/libc/gen/arc4random_uniform.c
@@ -1,56 +1,47 @@
-/* $OpenBSD: arc4random_uniform.c,v 1.3 2019/01/20 02:59:07 bcook Exp $ */
-
-/*
- * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
+/*-
+ * SPDX-License-Identifier: 0BSD
*
- * 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.
+ * Copyright (c) Robert Clausecker <fuz@FreeBSD.org>
+ * Based on a publication by Daniel Lemire.
+ * Public domain where applicable.
*
- * 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.
+ * Daniel Lemire, "Fast Random Integer Generation in an Interval",
+ * Association for Computing Machinery, ACM Trans. Model. Comput. Simul.,
+ * no. 1, vol. 29, pp. 1--12, New York, NY, USA, January 2019.
*/
#include <stdint.h>
#include <stdlib.h>
-/*
- * Calculate a uniformly distributed random number less than upper_bound
- * avoiding "modulo bias".
- *
- * Uniformity is achieved by generating new random numbers until the one
- * returned is outside the range [0, 2**32 % upper_bound). This
- * guarantees the selected random number will be inside
- * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
- * after reduction modulo upper_bound.
- */
uint32_t
arc4random_uniform(uint32_t upper_bound)
{
- uint32_t r, min;
-
- if (upper_bound < 2)
- return 0;
-
- /* 2**32 % x == (2**32 - x) % x */
- min = -upper_bound % upper_bound;
+ uint64_t product;
/*
- * This could theoretically loop forever but each retry has
- * p > 0.5 (worst case, usually far better) of selecting a
- * number inside the range we need, so it should rarely need
- * to re-roll.
+ * The paper uses these variable names:
+ *
+ * L -- log2(UINT32_MAX+1)
+ * s -- upper_bound
+ * x -- arc4random() return value
+ * m -- product
+ * l -- (uint32_t)product
+ * t -- threshold
*/
- for (;;) {
- r = arc4random();
- if (r >= min)
- break;
+
+ if (upper_bound <= 1)
+ return (0);
+
+ product = upper_bound * (uint64_t)arc4random();
+
+ if ((uint32_t)product < upper_bound) {
+ uint32_t threshold;
+
+ /* threshold = (2**32 - upper_bound) % upper_bound */
+ threshold = -upper_bound % upper_bound;
+ while ((uint32_t)product < threshold)
+ product = upper_bound * (uint64_t)arc4random();
}
- return r % upper_bound;
+ return (product >> 32);
}
diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c
index 06b4261437f3..21e5a44522ec 100644
--- a/lib/libc/gen/assert.c
+++ b/lib/libc/gen/assert.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)assert.c 8.1 (Berkeley) 6/4/93");
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/auxv.3 b/lib/libc/gen/auxv.3
deleted file mode 100644
index 10ec10e8755c..000000000000
--- a/lib/libc/gen/auxv.3
+++ /dev/null
@@ -1,105 +0,0 @@
-.\"
-.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.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.
-.\"
-.\" 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.
-.\"
-.Dd September 16, 2022
-.Dt ELF_AUX_INFO 3
-.Os
-.Sh NAME
-.Nm elf_aux_info
-.Nd extract data from the elf auxiliary vector of the current process
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/auxv.h
-.Ft int
-.Fn elf_aux_info "int aux" "void *buf" "int buflen"
-.Sh DESCRIPTION
-The
-.Fn elf_aux_info
-function retrieves the auxiliary info vector requested in
-.Va aux .
-The information is stored into the provided buffer if it will fit.
-The following values, defined in
-.In sys/elf_common.h
-can be requested (corresponding buffer sizes are specified in parenthesis):
-.Bl -tag -width AT_OSRELDATE
-.It AT_CANARY
-The canary value for SSP (arbitrary sized buffer, as many bytes are
-returned as it fits into it, rest is zeroed).
-.It AT_EXECPATH
-The path of executed program
-.Dv (MAXPATHLEN).
-This may not be present if the process was initialized by
-.Xr fexecve 2
-and the namecache no longer contains the file's name.
-.It AT_HWCAP
-CPU / hardware feature flags
-.Dv (sizeof(u_long)).
-.It AT_HWCAP2
-CPU / hardware feature flags
-.Dv (sizeof(u_long)).
-.It AT_NCPUS
-Number of CPUs
-.Dv (sizeof(int)).
-.It AT_OSRELDATE
-The
-.Dv OSRELDATE
-of the kernel or jail the program is running on
-.Dv (sizeof(int)).
-.It AT_PAGESIZES
-Vector of page sizes (arbitrary sized buffer, as many elements of the
-.Dv pagesizes
-array are returned as it fits).
-.It AT_PAGESZ
-Page size in bytes
-.Dv (sizeof(int)).
-.It AT_TIMEKEEP
-Pointer to VDSO timehands (for library internal use,
-.Dv sizeof(void *)).
-.It AT_USRSTACKBASE
-Top of the user stack for main thread.
-.It AT_USRSTACKLIM
-Limit for grow of the user stack for main thread.
-.El
-.Sh RETURN VALUES
-Returns zero on success, or an error number on failure.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EINVAL
-An unknown item was requested.
-.It Bq Er EINVAL
-The provided buffer was not the right size for the requested item.
-.It Bq Er ENOENT
-The requested item is not available.
-.El
-.Sh HISTORY
-The
-.Fn elf_aux_info
-function appeared in
-.Fx 12.0 .
-.Sh BUGS
-Only a small subset of available auxiliary info vector items are
-accessible with this function.
-Some items require a "right-sized" buffer while others just require a
-"big enough" buffer.
diff --git a/lib/libc/gen/auxv.c b/lib/libc/gen/auxv.c
deleted file mode 100644
index 1b0d886030b2..000000000000
--- a/lib/libc/gen/auxv.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright 2010, 2012 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <elf.h>
-#include <errno.h>
-#include <link.h>
-#include <pthread.h>
-#include <string.h>
-#include <sys/auxv.h>
-#include "un-namespace.h"
-#include "libc_private.h"
-
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-
-void *__elf_aux_vector;
-static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT;
-
-static void
-init_aux_vector_once(void)
-{
- Elf_Addr *sp;
-
- sp = (Elf_Addr *)environ;
- while (*sp++ != 0)
- ;
- __elf_aux_vector = (Elf_Auxinfo *)sp;
-}
-
-void
-__init_elf_aux_vector(void)
-{
-
- if (&_DYNAMIC != NULL)
- return;
- _once(&aux_vector_once, init_aux_vector_once);
-}
-
-static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
-static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags;
-static int hwcap_present, hwcap2_present;
-static char *canary, *pagesizes, *execpath;
-static void *ps_strings, *timekeep;
-static u_long hwcap, hwcap2;
-static void *fxrng_seed_version;
-static u_long usrstackbase, usrstacklim;
-
-#ifdef __powerpc__
-static int powerpc_new_auxv_format = 0;
-static void _init_aux_powerpc_fixup(void);
-int _powerpc_elf_aux_info(int, void *, int);
-#endif
-
-static void
-init_aux(void)
-{
- Elf_Auxinfo *aux;
-
- for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
- switch (aux->a_type) {
- case AT_BSDFLAGS:
- bsdflags = aux->a_un.a_val;
- break;
-
- case AT_CANARY:
- canary = (char *)(aux->a_un.a_ptr);
- break;
-
- case AT_CANARYLEN:
- canary_len = aux->a_un.a_val;
- break;
-
- case AT_EXECPATH:
- execpath = (char *)(aux->a_un.a_ptr);
- break;
-
- case AT_HWCAP:
- hwcap_present = 1;
- hwcap = (u_long)(aux->a_un.a_val);
- break;
-
- case AT_HWCAP2:
- hwcap2_present = 1;
- hwcap2 = (u_long)(aux->a_un.a_val);
- break;
-
- case AT_PAGESIZES:
- pagesizes = (char *)(aux->a_un.a_ptr);
- break;
-
- case AT_PAGESIZESLEN:
- pagesizes_len = aux->a_un.a_val;
- break;
-
- case AT_PAGESZ:
- pagesize = aux->a_un.a_val;
- break;
-
- case AT_OSRELDATE:
- osreldate = aux->a_un.a_val;
- break;
-
- case AT_NCPUS:
- ncpus = aux->a_un.a_val;
- break;
-
- case AT_TIMEKEEP:
- timekeep = aux->a_un.a_ptr;
- break;
-
- case AT_PS_STRINGS:
- ps_strings = aux->a_un.a_ptr;
- break;
-
- case AT_FXRNG:
- fxrng_seed_version = aux->a_un.a_ptr;
- break;
-
- case AT_USRSTACKBASE:
- usrstackbase = aux->a_un.a_val;
- break;
-
- case AT_USRSTACKLIM:
- usrstacklim = aux->a_un.a_val;
- break;
-#ifdef __powerpc__
- /*
- * Since AT_STACKPROT is always set, and the common
- * value 23 is mutually exclusive with the legacy powerpc
- * value 21, the existence of AT_STACKPROT proves we are
- * on the common format.
- */
- case AT_STACKPROT: /* 23 */
- powerpc_new_auxv_format = 1;
- break;
-#endif
- }
- }
-#ifdef __powerpc__
- if (!powerpc_new_auxv_format)
- _init_aux_powerpc_fixup();
-#endif
-}
-
-#ifdef __powerpc__
-static void
-_init_aux_powerpc_fixup(void)
-{
- Elf_Auxinfo *aux;
-
- /*
- * Before 1300070, PowerPC platforms had nonstandard numbering for
- * the aux vector. When running old binaries, the kernel will pass
- * the vector using the old numbering. Reload affected variables.
- */
- for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
- switch (aux->a_type) {
- case AT_OLD_CANARY:
- canary = (char *)(aux->a_un.a_ptr);
- break;
- case AT_OLD_CANARYLEN:
- canary_len = aux->a_un.a_val;
- break;
- case AT_OLD_EXECPATH:
- execpath = (char *)(aux->a_un.a_ptr);
- break;
- case AT_OLD_PAGESIZES:
- pagesizes = (char *)(aux->a_un.a_ptr);
- break;
- case AT_OLD_PAGESIZESLEN:
- pagesizes_len = aux->a_un.a_val;
- break;
- case AT_OLD_OSRELDATE:
- osreldate = aux->a_un.a_val;
- break;
- case AT_OLD_NCPUS:
- ncpus = aux->a_un.a_val;
- break;
- }
- }
-}
-
-int
-_powerpc_elf_aux_info(int aux, void *buf, int buflen)
-{
-
- /*
- * If we are in the old auxv format, we need to translate the aux
- * parameter of elf_aux_info() calls into the common auxv format.
- * Internal libc calls always use the common format, and they
- * directly call _elf_aux_info instead of using the weak symbol.
- */
- if (!powerpc_new_auxv_format) {
- switch (aux) {
- case AT_OLD_EXECPATH:
- aux = AT_EXECPATH;
- break;
- case AT_OLD_CANARY:
- aux = AT_CANARY;
- break;
- case AT_OLD_CANARYLEN:
- aux = AT_CANARYLEN;
- break;
- case AT_OLD_OSRELDATE:
- aux = AT_OSRELDATE;
- break;
- case AT_OLD_NCPUS:
- aux = AT_NCPUS;
- break;
- case AT_OLD_PAGESIZES:
- aux = AT_PAGESIZES;
- break;
- case AT_OLD_PAGESIZESLEN:
- aux = AT_PAGESIZESLEN;
- break;
- case AT_OLD_STACKPROT:
- aux = AT_STACKPROT;
- break;
- }
- }
- return _elf_aux_info(aux, buf, buflen);
-}
-__weak_reference(_powerpc_elf_aux_info, elf_aux_info);
-#else
-__weak_reference(_elf_aux_info, elf_aux_info);
-#endif
-
-int
-_elf_aux_info(int aux, void *buf, int buflen)
-{
- int res;
-
- __init_elf_aux_vector();
- if (__elf_aux_vector == NULL)
- return (ENOSYS);
- _once(&aux_once, init_aux);
-
- if (buflen < 0)
- return (EINVAL);
-
- switch (aux) {
- case AT_CANARY:
- if (canary != NULL && canary_len >= buflen) {
- memcpy(buf, canary, buflen);
- memset(canary, 0, canary_len);
- canary = NULL;
- res = 0;
- } else
- res = ENOENT;
- break;
- case AT_EXECPATH:
- if (execpath == NULL)
- res = ENOENT;
- else if (buf == NULL)
- res = EINVAL;
- else {
- if (strlcpy(buf, execpath, buflen) >=
- (unsigned int)buflen)
- res = EINVAL;
- else
- res = 0;
- }
- break;
- case AT_HWCAP:
- if (hwcap_present && buflen == sizeof(u_long)) {
- *(u_long *)buf = hwcap;
- res = 0;
- } else
- res = ENOENT;
- break;
- case AT_HWCAP2:
- if (hwcap2_present && buflen == sizeof(u_long)) {
- *(u_long *)buf = hwcap2;
- res = 0;
- } else
- res = ENOENT;
- break;
- case AT_PAGESIZES:
- if (pagesizes != NULL && pagesizes_len >= buflen) {
- memcpy(buf, pagesizes, buflen);
- res = 0;
- } else
- res = ENOENT;
- break;
- case AT_PAGESZ:
- if (buflen == sizeof(int)) {
- if (pagesize != 0) {
- *(int *)buf = pagesize;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_OSRELDATE:
- if (buflen == sizeof(int)) {
- if (osreldate != 0) {
- *(int *)buf = osreldate;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_NCPUS:
- if (buflen == sizeof(int)) {
- if (ncpus != 0) {
- *(int *)buf = ncpus;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_TIMEKEEP:
- if (buflen == sizeof(void *)) {
- if (timekeep != NULL) {
- *(void **)buf = timekeep;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_BSDFLAGS:
- if (buflen == sizeof(int)) {
- *(int *)buf = bsdflags;
- res = 0;
- } else
- res = EINVAL;
- break;
- case AT_PS_STRINGS:
- if (buflen == sizeof(void *)) {
- if (ps_strings != NULL) {
- *(void **)buf = ps_strings;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_FXRNG:
- if (buflen == sizeof(void *)) {
- if (fxrng_seed_version != NULL) {
- *(void **)buf = fxrng_seed_version;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_USRSTACKBASE:
- if (buflen == sizeof(u_long)) {
- if (usrstackbase != 0) {
- *(u_long *)buf = usrstackbase;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- case AT_USRSTACKLIM:
- if (buflen == sizeof(u_long)) {
- if (usrstacklim != 0) {
- *(u_long *)buf = usrstacklim;
- res = 0;
- } else
- res = ENOENT;
- } else
- res = EINVAL;
- break;
- default:
- res = ENOENT;
- break;
- }
- return (res);
-}
diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c
index 46fea9a630cf..d0ba1bd9229c 100644
--- a/lib/libc/gen/basename.c
+++ b/lib/libc/gen/basename.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <libgen.h>
#include <string.h>
diff --git a/lib/libc/gen/basename_compat.c b/lib/libc/gen/basename_compat.c
index 217c4582e857..19a4bd6c03eb 100644
--- a/lib/libc/gen/basename_compat.c
+++ b/lib/libc/gen/basename_compat.c
@@ -16,7 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <libgen.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/cap_sandboxed.c b/lib/libc/gen/cap_sandboxed.c
index d01d94735bec..63c2439382a6 100644
--- a/lib/libc/gen/cap_sandboxed.c
+++ b/lib/libc/gen/cap_sandboxed.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/capsicum.h>
#include <assert.h>
diff --git a/lib/libc/gen/check_utility_compat.c b/lib/libc/gen/check_utility_compat.c
index 6b1b487945f2..63a268896daa 100644
--- a/lib/libc/gen/check_utility_compat.c
+++ b/lib/libc/gen/check_utility_compat.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/*
* I din't use "namespace.h" here because none of the relevant utilities
* are threaded, so I'm not concerned about cancellation points or other
diff --git a/lib/libc/gen/clock.3 b/lib/libc/gen/clock.3
index 39a10ffbf15a..77d7ce085d2e 100644
--- a/lib/libc/gen/clock.3
+++ b/lib/libc/gen/clock.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)clock.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt CLOCK 3
.Os
diff --git a/lib/libc/gen/clock.c b/lib/libc/gen/clock.c
index 59a85d393ceb..4d78fff73028 100644
--- a/lib/libc/gen/clock.c
+++ b/lib/libc/gen/clock.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)clock.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/lib/libc/gen/clock_getcpuclockid.c b/lib/libc/gen/clock_getcpuclockid.c
index fdfe3b614d69..77d6c3423301 100644
--- a/lib/libc/gen/clock_getcpuclockid.c
+++ b/lib/libc/gen/clock_getcpuclockid.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index 16f9bff452e4..6015114d6c47 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)closedir.c 8.1 (Berkeley) 6/10/93");
#include "namespace.h"
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/libc/gen/confstr.3 b/lib/libc/gen/confstr.3
index f10856878710..df19339c612a 100644
--- a/lib/libc/gen/confstr.3
+++ b/lib/libc/gen/confstr.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)confstr.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 3, 2006
.Dt CONFSTR 3
.Os
diff --git a/lib/libc/gen/confstr.c b/lib/libc/gen/confstr.c
index c348d4ce1587..491df0cba67a 100644
--- a/lib/libc/gen/confstr.c
+++ b/lib/libc/gen/confstr.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)confstr.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <errno.h>
diff --git a/lib/libc/gen/crypt.c b/lib/libc/gen/crypt.c
index a2deb670f148..ddcd6719775f 100644
--- a/lib/libc/gen/crypt.c
+++ b/lib/libc/gen/crypt.c
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)crypt.c 5.11 (Berkeley) 6/25/91");
#include <stdio.h>
#include <string.h>
#include <unistd.h>
diff --git a/lib/libc/gen/ctermid.3 b/lib/libc/gen/ctermid.3
index d2d0d8e5d815..2a53412f1b29 100644
--- a/lib/libc/gen/ctermid.3
+++ b/lib/libc/gen/ctermid.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ctermid.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 1, 2011
.Dt CTERMID 3
.Os
diff --git a/lib/libc/gen/ctermid.c b/lib/libc/gen/ctermid.c
index 35be197742a7..fb117b3c8ded 100644
--- a/lib/libc/gen/ctermid.c
+++ b/lib/libc/gen/ctermid.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
@@ -35,11 +34,12 @@
#include <paths.h>
#include <stdio.h>
#include <string.h>
+#include <ssp/ssp.h>
#define LEN_PATH_DEV (sizeof(_PATH_DEV) - 1)
char *
-ctermid(char *s)
+__ssp_real(ctermid)(char *s)
{
static char def[sizeof(_PATH_DEV) + SPECNAMELEN];
struct stat sb;
@@ -63,7 +63,7 @@ ctermid(char *s)
}
char *
-ctermid_r(char *s)
+__ssp_real(ctermid_r)(char *s)
{
return (s != NULL ? ctermid(s) : NULL);
diff --git a/lib/libc/gen/daemon.3 b/lib/libc/gen/daemon.3
index 0c6479f65cc5..4619ba3489aa 100644
--- a/lib/libc/gen/daemon.3
+++ b/lib/libc/gen/daemon.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)daemon.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd February 27, 2023
.Dt DAEMON 3
.Os
diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c
index 0ea1e0809d08..525c99761aa3 100644
--- a/lib/libc/gen/daemon.c
+++ b/lib/libc/gen/daemon.c
@@ -30,8 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)daemon.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libc/gen/devname-compat11.c b/lib/libc/gen/devname-compat11.c
index 37886b6c8aaa..b01b0845e261 100644
--- a/lib/libc/gen/devname-compat11.c
+++ b/lib/libc/gen/devname-compat11.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/devname.3 b/lib/libc/gen/devname.3
index 1ab8b5ec98b9..44c1ff951cfa 100644
--- a/lib/libc/gen/devname.3
+++ b/lib/libc/gen/devname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)devname.3 8.2 (Berkeley) 4/29/95
-.\"
.Dd February 22, 2005
.Dt DEVNAME 3
.Os
diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c
index bee5a78060e0..ebb56132c48d 100644
--- a/lib/libc/gen/devname.c
+++ b/lib/libc/gen/devname.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)devname.c 8.2 (Berkeley) 4/29/95");
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 0314ab90ca24..263dfdd6eb95 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd August 1, 2020
.Dt DIRECTORY 3
.Os
diff --git a/lib/libc/gen/dirfd.c b/lib/libc/gen/dirfd.c
index 123d856eba47..85090bd4da6c 100644
--- a/lib/libc/gen/dirfd.c
+++ b/lib/libc/gen/dirfd.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
diff --git a/lib/libc/gen/dirname.c b/lib/libc/gen/dirname.c
index ab36ac66dea1..7157fec23630 100644
--- a/lib/libc/gen/dirname.c
+++ b/lib/libc/gen/dirname.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <libgen.h>
#include <string.h>
diff --git a/lib/libc/gen/dirname_compat.c b/lib/libc/gen/dirname_compat.c
index 6423984b1877..7eca7eb03f83 100644
--- a/lib/libc/gen/dirname_compat.c
+++ b/lib/libc/gen/dirname_compat.c
@@ -16,7 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <libgen.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c
index 8155202b7828..4b3730920529 100644
--- a/lib/libc/gen/disklabel.c
+++ b/lib/libc/gen/disklabel.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)disklabel.c 8.2 (Berkeley) 5/3/95");
#include <sys/param.h>
#define DKTYPENAMES
#define FSTYPENAMES
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
index b6dab041bac3..ae1c8d83df19 100644
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#if !defined(IN_LIBDL) || defined(PIC)
/*
@@ -36,6 +35,7 @@
#include <sys/mman.h>
#include <machine/atomic.h>
#include <dlfcn.h>
+#include <errno.h>
#include <link.h>
#include <stddef.h>
#include <string.h>
@@ -203,9 +203,12 @@ dl_init_phdr_info(void)
}
#endif
-#pragma weak dl_iterate_phdr
+#pragma weak _dl_iterate_phdr_locked
+int _dl_iterate_phdr_locked(int (*callback)(struct dl_phdr_info *,
+ size_t, void *), void *data);
int
-dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
+_dl_iterate_phdr_locked(
+ int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
void *data __unused)
{
#if defined IN_LIBDL
@@ -226,15 +229,30 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
return (1);
_once(&dl_phdr_info_once, dl_init_phdr_info);
ti.ti_module = 1;
- ti.ti_offset = 0;
- mutex_lock(&dl_phdr_info_lock);
+ ti.ti_offset = -TLS_DTV_OFFSET;
phdr_info.dlpi_tls_data = __tls_get_addr(&ti);
ret = callback(&phdr_info, sizeof(phdr_info), data);
- mutex_unlock(&dl_phdr_info_lock);
return (ret);
#endif
}
+#pragma weak dl_iterate_phdr
+int
+dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
+ void *data __unused)
+{
+ int error;
+
+#if !defined(IN_LIBDL) && !defined(PIC)
+ mutex_lock(&dl_phdr_info_lock);
+#endif
+ error = _dl_iterate_phdr_locked(callback, data);
+#if !defined(IN_LIBDL) && !defined(PIC)
+ mutex_unlock(&dl_phdr_info_lock);
+#endif
+ return (error);
+}
+
#pragma weak fdlopen
void *
fdlopen(int fd __unused, int mode __unused)
@@ -338,4 +356,20 @@ _rtld_is_dlopened(void *arg __unused)
return (0);
}
+#pragma weak rtld_get_var
+const char *
+rtld_get_var(const char *name __unused)
+{
+ _rtld_error(sorry);
+ return (NULL);
+}
+
+#pragma weak rtld_set_var
+int
+rtld_set_var(const char *name __unused, const char *val __unused)
+{
+ _rtld_error(sorry);
+ return (EINVAL);
+}
+
#endif /* !defined(IN_LIBDL) || defined(PIC) */
diff --git a/lib/libc/gen/dlopen.3 b/lib/libc/gen/dlopen.3
index 09f37ff2fa93..340545114114 100644
--- a/lib/libc/gen/dlopen.3
+++ b/lib/libc/gen/dlopen.3
@@ -29,9 +29,7 @@
.\"
.\" Copyright (c) 1991 Sun Microsystems, Inc.
.\"
-.\" @(#) dlopen.3 1.6 90/01/31 SMI
-.\"
-.Dd May 14, 2020
+.Dd May 7, 2024
.Dt DLOPEN 3
.Os
.Sh NAME
@@ -201,6 +199,10 @@ The
function can be used by the code that needs to perform
additional checks on the loaded objects, to prevent races with
symlinking or renames.
+Applications sandboxed using
+.Xr capsicum 4
+can also make beneficial use of
+.Fn fdlopen .
.Pp
The
.Fn dlsym
diff --git a/lib/libc/gen/drand48.c b/lib/libc/gen/drand48.c
index e24b974ae84f..cec04a6a2425 100644
--- a/lib/libc/gen/drand48.c
+++ b/lib/libc/gen/drand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
extern unsigned short _rand48_seed[3];
diff --git a/lib/libc/gen/dup3.3 b/lib/libc/gen/dup3.3
index f2798930797b..338a9ae74c64 100644
--- a/lib/libc/gen/dup3.3
+++ b/lib/libc/gen/dup3.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 16, 2013
+.Dd May 17, 2025
.Dt DUP3 3
.Os
.Sh NAME
@@ -47,6 +47,11 @@ The close-on-exec flag on the new file descriptor is determined by the
bit in
.Fa flags .
.Pp
+The close-on-fork flag on the new file descriptor is determined by the
+.Dv O_CLOFORK
+bit in
+.Fa flags .
+.Pp
If
.Fa oldd
\*(Ne
@@ -91,7 +96,9 @@ argument.
The
.Fa flags
argument has bits set other than
-.Dv O_CLOEXEC .
+.Dv O_CLOEXEC
+or
+.Dv O_CLOFORK .
.El
.Sh SEE ALSO
.Xr accept 2 ,
@@ -112,3 +119,7 @@ The
.Fn dup3
function appeared in
.Fx 10.0 .
+The
+.Dv O_CLOFORK
+flag appeared in
+.Fx 15.0 .
diff --git a/lib/libc/gen/dup3.c b/lib/libc/gen/dup3.c
index e0298c821148..1401c1f5b607 100644
--- a/lib/libc/gen/dup3.c
+++ b/lib/libc/gen/dup3.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <unistd.h>
#include <fcntl.h>
@@ -40,21 +39,22 @@ int __dup3(int, int, int);
int
__dup3(int oldfd, int newfd, int flags)
{
- int how;
+ int fdflags;
if (oldfd == newfd) {
errno = EINVAL;
return (-1);
}
- if (flags & ~O_CLOEXEC) {
+ if ((flags & ~(O_CLOEXEC | O_CLOFORK)) != 0) {
errno = EINVAL;
return (-1);
}
- how = (flags & O_CLOEXEC) ? F_DUP2FD_CLOEXEC : F_DUP2FD;
+ fdflags = ((flags & O_CLOEXEC) != 0 ? FD_CLOEXEC : 0) |
+ ((flags & O_CLOFORK) != 0 ? FD_CLOFORK : 0);
- return (_fcntl(oldfd, how, newfd));
+ return (_fcntl(oldfd, F_DUP3FD | (fdflags << F_DUP3FD_SHIFT), newfd));
}
__weak_reference(__dup3, dup3);
diff --git a/lib/libc/gen/elf_utils.c b/lib/libc/gen/elf_utils.c
index 5b87e012d0eb..3714a0dc42b5 100644
--- a/lib/libc/gen/elf_utils.c
+++ b/lib/libc/gen/elf_utils.c
@@ -31,14 +31,16 @@
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
+
+#include <machine/tls.h>
+
#include <link.h>
#include <stddef.h>
#include <string.h>
+
#include "libc_private.h"
-#include "static_tls.h"
void __pthread_map_stacks_exec(void);
-void __pthread_distribute_static_tls(size_t, void *, size_t, size_t);
int
__elf_phdr_match_addr(struct dl_phdr_info *phdr_info, void *addr)
@@ -102,24 +104,3 @@ __pthread_map_stacks_exec(void)
((void (*)(void))__libc_interposing[INTERPOS_map_stacks_exec])();
}
-
-void
-__libc_distribute_static_tls(size_t offset, void *src, size_t len,
- size_t total_len)
-{
- uintptr_t tlsbase;
-
- tlsbase = _libc_get_static_tls_base(offset);
- memcpy((void *)tlsbase, src, len);
- memset((char *)tlsbase + len, 0, total_len - len);
-}
-
-#pragma weak __pthread_distribute_static_tls
-void
-__pthread_distribute_static_tls(size_t offset, void *src, size_t len,
- size_t total_len)
-{
-
- ((void (*)(size_t, void *, size_t, size_t))__libc_interposing[
- INTERPOS_distribute_static_tls])(offset, src, len, total_len);
-}
diff --git a/lib/libc/gen/erand48.c b/lib/libc/gen/erand48.c
index fb0b1aef8cf1..286904c27839 100644
--- a/lib/libc/gen/erand48.c
+++ b/lib/libc/gen/erand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
double
diff --git a/lib/libc/gen/err.3 b/lib/libc/gen/err.3
index eb429f888fae..088ead71239b 100644
--- a/lib/libc/gen/err.3
+++ b/lib/libc/gen/err.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)err.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd March 29, 2012
.Dt ERR 3
.Os
diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c
index 9636ef5b93b5..16cbe27693e7 100644
--- a/lib/libc/gen/err.c
+++ b/lib/libc/gen/err.c
@@ -29,12 +29,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)err.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
+#include <sys/exterrvar.h>
#include <err.h>
#include <errno.h>
+#include <exterr.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -45,6 +46,11 @@ __SCCSID("@(#)err.c 8.1 (Berkeley) 6/4/93");
static FILE *err_file; /* file to use for error output */
static void (*err_exit)(int);
+static void verrci(bool doexterr, int eval, int code, const char *fmt,
+ va_list ap) __printf0like(4, 0) __dead2;
+static void vwarnci(bool doexterr, int code, const char *fmt, va_list ap)
+ __printf0like(3, 0);
+
/*
* This is declared to take a `void *' so that the caller is not required
* to include <stdio.h> first. However, it is really a `FILE *', and the
@@ -72,14 +78,14 @@ _err(int eval, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- verrc(eval, errno, fmt, ap);
+ verrci(true, eval, errno, fmt, ap);
va_end(ap);
}
void
verr(int eval, const char *fmt, va_list ap)
{
- verrc(eval, errno, fmt, ap);
+ verrci(true, eval, errno, fmt, ap);
}
void
@@ -87,13 +93,24 @@ errc(int eval, int code, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- verrc(eval, code, fmt, ap);
+ verrci(false, eval, code, fmt, ap);
va_end(ap);
}
void
verrc(int eval, int code, const char *fmt, va_list ap)
{
+ verrci(false, eval, code, fmt, ap);
+}
+
+static void
+vexterr(bool doexterr, int code, const char *fmt, va_list ap)
+{
+ char exterr[UEXTERROR_MAXLEN]; /* libc knows the buffer size */
+ int extstatus;
+
+ if (doexterr)
+ extstatus = uexterr_gettext(exterr, sizeof(exterr));
if (err_file == NULL)
err_set_file(NULL);
fprintf(err_file, "%s: ", _getprogname());
@@ -101,7 +118,16 @@ verrc(int eval, int code, const char *fmt, va_list ap)
vfprintf(err_file, fmt, ap);
fprintf(err_file, ": ");
}
- fprintf(err_file, "%s\n", strerror(code));
+ fprintf(err_file, "%s", strerror(code));
+ if (doexterr && extstatus == 0 && exterr[0] != '\0')
+ fprintf(err_file, " (extended error %s)", exterr);
+ fprintf(err_file, "\n");
+}
+
+static void
+verrci(bool doexterr, int eval, int code, const char *fmt, va_list ap)
+{
+ vexterr(doexterr, code, fmt, ap);
if (err_exit)
err_exit(eval);
exit(eval);
@@ -159,17 +185,16 @@ warnc(int code, const char *fmt, ...)
void
vwarnc(int code, const char *fmt, va_list ap)
{
+ vwarnci(false, code, fmt, ap);
+}
+
+static void
+vwarnci(bool doexterr, int code, const char *fmt, va_list ap)
+{
int saved_errno;
saved_errno = errno;
- if (err_file == NULL)
- err_set_file(NULL);
- fprintf(err_file, "%s: ", _getprogname());
- if (fmt != NULL) {
- vfprintf(err_file, fmt, ap);
- fprintf(err_file, ": ");
- }
- fprintf(err_file, "%s\n", strerror(code));
+ vexterr(doexterr, code, fmt, ap);
errno = saved_errno;
}
diff --git a/lib/libc/gen/errlst.c b/lib/libc/gen/errlst.c
index 837af5b0c6ae..a73fa06feb5e 100644
--- a/lib/libc/gen/errlst.c
+++ b/lib/libc/gen/errlst.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)errlst.c 8.2 (Berkeley) 11/16/93");
#include <errno.h>
#include <stdio.h>
#include "errlst.h"
diff --git a/lib/libc/gen/errno.c b/lib/libc/gen/errno.c
deleted file mode 100644
index aae8300a34b2..000000000000
--- a/lib/libc/gen/errno.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2002 Peter Wemm <peter@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.
- */
-
-#include <sys/cdefs.h>
-int errno;
diff --git a/lib/libc/gen/eventfd.c b/lib/libc/gen/eventfd.c
index e05218cf90e4..44a33915c2fb 100644
--- a/lib/libc/gen/eventfd.c
+++ b/lib/libc/gen/eventfd.c
@@ -24,7 +24,6 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/eventfd.h>
#include <sys/specialfd.h>
diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3
index ead7ea0f416f..41ab18fa89ef 100644
--- a/lib/libc/gen/exec.3
+++ b/lib/libc/gen/exec.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)exec.3 8.3 (Berkeley) 1/24/94
-.\"
-.Dd March 22, 2020
+.Dd December 11, 2023
.Dt EXEC 3
.Os
.Sh NAME
@@ -37,6 +35,7 @@
.Nm exect ,
.Nm execv ,
.Nm execvp ,
+.Nm execvpe ,
.Nm execvP
.Nd execute a file
.Sh LIBRARY
@@ -50,7 +49,6 @@
.Fn execlp "const char *file" "const char *arg" ... NULL
.Ft int
.Fn execle "const char *path" "const char *arg" ... NULL "char *const envp[]"
-.Fc
.Ft int
.Fn exect "const char *path" "char *const argv[]" "char *const envp[]"
.Ft int
@@ -58,6 +56,8 @@
.Ft int
.Fn execvp "const char *file" "char *const argv[]"
.Ft int
+.Fn execvpe "const char *file" "char *const argv[]" "char *const envp[]"
+.Ft int
.Fn execvP "const char *file" "const char *search_path" "char *const argv[]"
.Sh DESCRIPTION
The
@@ -99,6 +99,7 @@ The
.Fn exect ,
.Fn execv ,
.Fn execvp ,
+.Fn execvpe ,
and
.Fn execvP
functions provide an array of pointers to null-terminated strings that
@@ -112,9 +113,10 @@ be terminated by a
pointer.
.Pp
The
-.Fn execle
+.Fn execle ,
+.Fn exect ,
and
-.Fn exect
+.Fn execvpe
functions also specify the environment of the executed process by following
the
.Dv NULL
@@ -136,6 +138,7 @@ Some of these functions have special semantics.
The functions
.Fn execlp ,
.Fn execvp ,
+.Fn execvpe ,
and
.Fn execvP
will duplicate the actions of the shell in searching for an executable file
@@ -146,6 +149,7 @@ For
.Fn execlp
and
.Fn execvp ,
+.Fn execvpe ,
search path is the path specified in the environment by
.Dq Ev PATH
variable.
@@ -271,7 +275,8 @@ The
.Fn execl ,
.Fn execle ,
.Fn execlp ,
-.Fn execvp
+.Fn execvp ,
+.Fn execvpe ,
and
.Fn execvP
functions
@@ -309,6 +314,9 @@ and
functions
conform to
.St -p1003.1-88 .
+The
+.Fn execvpe
+function is a GNU extension.
.Sh HISTORY
The
.Fn exec
@@ -332,6 +340,10 @@ The
.Fn execvP
function first appeared in
.Fx 5.2 .
+The
+.Fn execvpe
+function first appeared in
+.Fx 14.1 .
.Sh BUGS
The type of the
.Fa argv
@@ -342,6 +354,7 @@ parameters to
.Fn exect ,
.Fn execv ,
.Fn execvp ,
+.Fn execvpe ,
and
.Fn execvP
is a historical accident and no sane implementation should modify the provided
diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c
index 15dc7f0200ac..12020a79f6b4 100644
--- a/lib/libc/gen/exec.c
+++ b/lib/libc/gen/exec.c
@@ -29,13 +29,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)exec.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
+#include <assert.h>
#include <errno.h>
#include <unistd.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -138,29 +138,132 @@ execv(const char *name, char * const *argv)
int
execvp(const char *name, char * const *argv)
{
- return (_execvpe(name, argv, environ));
+ return (__libc_execvpe(name, argv, environ));
+}
+
+/*
+ * Returns 0 if we don't consider this a terminal condition, -1 if we do.
+ */
+static int
+execvPe_prog(const char *path, char * const *argv, char * const *envp)
+{
+ struct stat sb;
+ const char **memp;
+ size_t cnt;
+ int save_errno;
+
+ (void)_execve(path, argv, envp);
+ /* Grouped roughly by never terminal vs. usually terminal conditions */
+ switch (errno) {
+ case ELOOP:
+ case ENAMETOOLONG:
+ case ENOENT:
+ case ENOTDIR:
+ /* Non-terminal: property of the path we're trying */
+ break;
+ case ENOEXEC:
+ /*
+ * Failures here are considered terminal because we must handle
+ * this via the ENOEXEC fallback path; doing any further
+ * searching would be categorically incorrect.
+ */
+
+ for (cnt = 0; argv[cnt] != NULL; ++cnt)
+ ;
+
+ /*
+ * cnt may be 0 above; always allocate at least
+ * 3 entries so that we can at least fit "sh", path, and
+ * the NULL terminator. We can rely on cnt to take into
+ * account the NULL terminator in all other scenarios,
+ * as we drop argv[0].
+ */
+ memp = alloca(MAX(3, cnt + 2) * sizeof(char *));
+ assert(memp != NULL);
+ if (cnt > 0) {
+ memp[0] = argv[0];
+ memp[1] = path;
+ memcpy(&memp[2], &argv[1], cnt * sizeof(char *));
+ } else {
+ memp[0] = "sh";
+ memp[1] = path;
+ memp[2] = NULL;
+ }
+
+ (void)_execve(_PATH_BSHELL, __DECONST(char **, memp), envp);
+ return (-1);
+ case ENOMEM:
+ case E2BIG:
+ /* Terminal: persistent condition */
+ return (-1);
+ case ETXTBSY:
+ /*
+ * Terminal: we used to retry here, but sh(1) doesn't.
+ */
+ return (-1);
+ default:
+ /*
+ * EACCES may be for an inaccessible directory or
+ * a non-executable file. Call stat() to decide
+ * which. This also handles ambiguities for EFAULT
+ * and EIO, and undocumented errors like ESTALE.
+ * We hope that the race for a stat() is unimportant.
+ */
+ save_errno = errno;
+ if (stat(path, &sb) == -1) {
+ /*
+ * We force errno to ENOENT here to disambiguate the
+ * EACCESS case; the results of execve(2) are somewhat
+ * inconclusive because either the file did not exist or
+ * we just don't have search permissions, but the caller
+ * only really wants to see EACCES if the file did exist
+ * but was not accessible.
+ */
+ if (save_errno == EACCES)
+ errno = ENOENT;
+ break;
+ }
+
+ errno = save_errno;
+
+ /*
+ * Non-terminal: the file did exist and we just didn't have
+ * access to it, so we surface the EACCES and let the search
+ * continue for a candidate that we do have access to.
+ */
+ if (errno == EACCES)
+ break;
+
+ /*
+ * All other errors here are terminal, as prescribed by exec(3).
+ */
+ return (-1);
+ }
+
+ return (0);
}
static int
execvPe(const char *name, const char *path, char * const *argv,
char * const *envp)
{
- const char **memp;
- size_t cnt, lp, ln;
- int eacces, save_errno;
char buf[MAXPATHLEN];
- const char *bp, *np, *op, *p;
- struct stat sb;
+ size_t ln, lp;
+ const char *np, *op, *p;
+ bool eacces;
- eacces = 0;
+ eacces = false;
/* If it's an absolute or relative path name, it's easy. */
- if (strchr(name, '/')) {
- bp = name;
- op = NULL;
- goto retry;
+ if (strchr(name, '/') != NULL) {
+ /*
+ * We ignore non-terminal conditions because we don't have any
+ * further paths to try -- we can just bubble up the errno from
+ * execve(2) here.
+ */
+ (void)execvPe_prog(name, argv, envp);
+ return (-1);
}
- bp = buf;
/* If it's an empty path name, fail in the usual POSIX way. */
if (*name == '\0') {
@@ -194,9 +297,13 @@ execvPe(const char *name, const char *path, char * const *argv,
op = np + 1;
/*
- * If the path is too long complain. This is a possible
- * security issue; given a way to make the path too long
- * the user may execute the wrong program.
+ * If the path is too long, then complain. This is a possible
+ * security issue: given a way to make the path too long, the
+ * user may execute the wrong program.
+ *
+ * Remember to exercise caution here with assembling our final
+ * buf and any output, as we may be running in a vfork() context
+ * via posix_spawnp().
*/
if (lp + ln + 2 > sizeof(buf)) {
(void)_write(STDERR_FILENO, execvPe_err_preamble,
@@ -204,82 +311,40 @@ execvPe(const char *name, const char *path, char * const *argv,
(void)_write(STDERR_FILENO, p, lp);
(void)_write(STDERR_FILENO, execvPe_err_trailer,
sizeof(execvPe_err_trailer) - 1);
+
continue;
}
- bcopy(p, buf, lp);
+
+ memcpy(&buf[0], p, lp);
buf[lp] = '/';
- bcopy(name, buf + lp + 1, ln);
+ memcpy(&buf[lp + 1], name, ln);
buf[lp + ln + 1] = '\0';
-retry: (void)_execve(bp, argv, envp);
- switch (errno) {
- case E2BIG:
- goto done;
- case ELOOP:
- case ENAMETOOLONG:
- case ENOENT:
- break;
- case ENOEXEC:
- for (cnt = 0; argv[cnt]; ++cnt)
- ;
-
- /*
- * cnt may be 0 above; always allocate at least
- * 3 entries so that we can at least fit "sh", bp, and
- * the NULL terminator. We can rely on cnt to take into
- * account the NULL terminator in all other scenarios,
- * as we drop argv[0].
- */
- memp = alloca(MAX(3, cnt + 2) * sizeof(char *));
- if (memp == NULL) {
- /* errno = ENOMEM; XXX override ENOEXEC? */
- goto done;
- }
- if (cnt > 0) {
- memp[0] = argv[0];
- memp[1] = bp;
- bcopy(argv + 1, memp + 2, cnt * sizeof(char *));
- } else {
- memp[0] = "sh";
- memp[1] = bp;
- memp[2] = NULL;
- }
- (void)_execve(_PATH_BSHELL,
- __DECONST(char **, memp), envp);
- goto done;
- case ENOMEM:
- goto done;
- case ENOTDIR:
- break;
- case ETXTBSY:
- /*
- * We used to retry here, but sh(1) doesn't.
- */
- goto done;
- default:
- /*
- * EACCES may be for an inaccessible directory or
- * a non-executable file. Call stat() to decide
- * which. This also handles ambiguities for EFAULT
- * and EIO, and undocumented errors like ESTALE.
- * We hope that the race for a stat() is unimportant.
- */
- save_errno = errno;
- if (stat(bp, &sb) != 0)
- break;
- if (save_errno == EACCES) {
- eacces = 1;
- continue;
- }
- errno = save_errno;
- goto done;
- }
+ /*
+ * For terminal conditions we can just return immediately. If
+ * it was non-terminal, we just need to note if we had an
+ * EACCES -- execvPe_prog would do a stat(2) and leave us with
+ * an errno of EACCES only if the file did exist; otherwise it
+ * would coerce it to an ENOENT because we may not know if a
+ * file actually existed there or not.
+ */
+ if (execvPe_prog(buf, argv, envp) == -1)
+ return (-1);
+ if (errno == EACCES)
+ eacces = true;
}
+
+ /*
+ * We don't often preserve errors encountering during the PATH search,
+ * so we override it here. ENOENT would be misleading if we found a
+ * candidate but couldn't access it, but most of the other conditions
+ * are either terminal or indicate that nothing was there.
+ */
if (eacces)
errno = EACCES;
else
errno = ENOENT;
-done:
+
return (-1);
}
@@ -290,7 +355,7 @@ execvP(const char *name, const char *path, char * const argv[])
}
int
-_execvpe(const char *name, char * const argv[], char * const envp[])
+__libc_execvpe(const char *name, char * const argv[], char * const envp[])
{
const char *path;
@@ -300,3 +365,5 @@ _execvpe(const char *name, char * const argv[], char * const envp[])
return (execvPe(name, path, argv, envp));
}
+
+__weak_reference(__libc_execvpe, execvpe);
diff --git a/lib/libc/gen/exect.c b/lib/libc/gen/exect.c
index b40c95c93fe3..e5be7a4d8755 100644
--- a/lib/libc/gen/exect.c
+++ b/lib/libc/gen/exect.c
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/ptrace.h>
#include <errno.h>
diff --git a/lib/libc/gen/fdevname.c b/lib/libc/gen/fdevname.c
index 585724e53fc9..62e71e98af63 100644
--- a/lib/libc/gen/fdevname.c
+++ b/lib/libc/gen/fdevname.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/ioctl.h>
diff --git a/lib/libc/gen/fdopendir.c b/lib/libc/gen/fdopendir.c
new file mode 100644
index 000000000000..9393cbe28f85
--- /dev/null
+++ b/lib/libc/gen/fdopendir.c
@@ -0,0 +1,63 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1983, 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.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include "un-namespace.h"
+
+#include "gen-private.h"
+#include "telldir.h"
+
+/*
+ * Open a directory with existing file descriptor.
+ */
+DIR *
+fdopendir(int fd)
+{
+ int flags, rc;
+
+ flags = _fcntl(fd, F_GETFD, 0);
+ if (flags == -1)
+ return (NULL);
+
+ if ((flags & FD_CLOEXEC) == 0) {
+ rc = _fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
+ if (rc == -1)
+ return (NULL);
+ }
+ return (__opendir_common(fd, DTF_HIDEW | DTF_NODUP, true));
+}
diff --git a/lib/libc/gen/feature_present.c b/lib/libc/gen/feature_present.c
index bbf8fcc2eb47..4c0b41cfb23e 100644
--- a/lib/libc/gen/feature_present.c
+++ b/lib/libc/gen/feature_present.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stdio.h>
diff --git a/lib/libc/gen/fmtcheck.c b/lib/libc/gen/fmtcheck.c
index 8a3ea16b88cf..de889ad3421c 100644
--- a/lib/libc/gen/fmtcheck.c
+++ b/lib/libc/gen/fmtcheck.c
@@ -30,7 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c
index 9a62c90f4d96..9edeee4405ce 100644
--- a/lib/libc/gen/fmtmsg.c
+++ b/lib/libc/gen/fmtmsg.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fmtmsg.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/fnmatch.3 b/lib/libc/gen/fnmatch.3
index 1367f94b8f3e..7f020fec58e3 100644
--- a/lib/libc/gen/fnmatch.3
+++ b/lib/libc/gen/fnmatch.3
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95
-.\"
-.Dd April 2, 2022
+.Dd April 7, 2025
.Dt FNMATCH 3
.Os
.Sh NAME
@@ -131,12 +129,8 @@ otherwise, it returns the value
.Sh STANDARDS
The current implementation of the
.Fn fnmatch
-function
-.Em does not
-conform to
+function is expected to conform to
.St -p1003.2 .
-Collating symbol expressions, equivalence class expressions and
-character class expressions are not supported.
.Sh HISTORY
A predecessor to
.Fn fnmatch ,
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c
index e211f3d535ad..1c583a9d23e2 100644
--- a/lib/libc/gen/fnmatch.c
+++ b/lib/libc/gen/fnmatch.c
@@ -37,8 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)fnmatch.c 8.2 (Berkeley) 4/16/94");
/*
* Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
* Compares a filename or pathname to a pattern.
@@ -69,7 +67,8 @@ __SCCSID("@(#)fnmatch.c 8.2 (Berkeley) 4/16/94");
#define RANGE_NOMATCH 0
#define RANGE_ERROR (-1)
-static int rangematch(const char *, wchar_t, int, char **, mbstate_t *);
+static int rangematch(const char *, wchar_t, const char *, int, char **,
+ char **, mbstate_t *, mbstate_t *);
static int fnmatch1(const char *, const char *, const char *, int, mbstate_t,
mbstate_t);
@@ -87,7 +86,7 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart,
{
const char *bt_pattern, *bt_string;
mbstate_t bt_patmbs, bt_strmbs;
- char *newp;
+ char *newp, *news;
char c;
wchar_t pc, sc;
size_t pclen, sclen;
@@ -153,8 +152,10 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart,
* there is no way having it match more characters
* can help us, given that we are already here.
*/
- bt_pattern = pattern, bt_patmbs = patmbs;
- bt_string = string, bt_strmbs = strmbs;
+ bt_pattern = pattern;
+ bt_patmbs = patmbs;
+ bt_string = string;
+ bt_strmbs = strmbs;
break;
case '[':
if (sc == EOS)
@@ -166,17 +167,17 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart,
((flags & FNM_PATHNAME) && *(string - 1) == '/')))
goto backtrack;
- switch (rangematch(pattern, sc, flags, &newp,
- &patmbs)) {
+ switch (rangematch(pattern, sc, string + sclen, flags,
+ &newp, &news, &patmbs, &strmbs)) {
case RANGE_ERROR:
goto norm;
case RANGE_MATCH:
pattern = newp;
+ string = news;
break;
case RANGE_NOMATCH:
goto backtrack;
}
- string += sclen;
break;
case '\\':
if (!(flags & FNM_NOESCAPE)) {
@@ -220,8 +221,10 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart,
if (sc == '/' && flags & FNM_PATHNAME)
return (FNM_NOMATCH);
bt_string += sclen;
- pattern = bt_pattern, patmbs = bt_patmbs;
- string = bt_string, strmbs = bt_strmbs;
+ pattern = bt_pattern;
+ patmbs = bt_patmbs;
+ string = bt_string;
+ strmbs = bt_strmbs;
}
break;
}
@@ -230,15 +233,20 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart,
}
static int
-rangematch(const char *pattern, wchar_t test, int flags, char **newp,
- mbstate_t *patmbs)
+rangematch(const char *pattern, wchar_t test, const char *string, int flags,
+ char **newp, char **news, mbstate_t *patmbs, mbstate_t *strmbs)
{
int negate, ok;
wchar_t c, c2;
size_t pclen;
const char *origpat;
struct xlocale_collate *table =
- (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE];
+ (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE];
+ wchar_t buf[COLLATE_STR_LEN]; /* STR_LEN defined in collate.h */
+ const char *cp, *savestring;
+ int special;
+ mbstate_t save;
+ size_t sclen, len;
/*
* A bracket expression starting with an unquoted circumflex
@@ -261,20 +269,132 @@ rangematch(const char *pattern, wchar_t test, int flags, char **newp,
ok = 0;
origpat = pattern;
for (;;) {
+ c = 0;
if (*pattern == ']' && pattern > origpat) {
- pattern++;
break;
} else if (*pattern == '\0') {
return (RANGE_ERROR);
} else if (*pattern == '/' && (flags & FNM_PATHNAME)) {
return (RANGE_NOMATCH);
- } else if (*pattern == '\\' && !(flags & FNM_NOESCAPE))
+ } else if (*pattern == '\\' && !(flags & FNM_NOESCAPE)) {
pattern++;
- pclen = mbrtowc(&c, pattern, MB_LEN_MAX, patmbs);
- if (pclen == (size_t)-1 || pclen == (size_t)-2)
- return (RANGE_NOMATCH);
- pattern += pclen;
+ } else if (*pattern == '[' &&
+ ((special = *(pattern + 1)) == '.' ||
+ special == '=' || special == ':')) {
+ cp = (pattern += 2);
+ while ((cp = strchr(cp, special))) {
+ if (*(cp + 1) == ']')
+ break;
+ cp++;
+ }
+ if (!cp)
+ return (RANGE_ERROR);
+ if (special == '.') {
+treat_like_collating_symbol:
+ len = __collate_collating_symbol(buf,
+ COLLATE_STR_LEN, pattern,
+ cp - pattern, patmbs);
+ if (len == (size_t)-1 || len == 0)
+ return (RANGE_ERROR);
+ pattern = cp + 2;
+ if (len > 1) {
+ wchar_t *wp, sc;
+ /*
+ * No multi-character collation
+ * symbols as start of range.
+ */
+ if (*(cp + 2) == '-' &&
+ *(cp + 3) != EOS &&
+ *(cp + 3) != ']')
+ return (RANGE_ERROR);
+ wp = buf;
+ if (test != *wp++)
+ continue;
+ if (len == 1) {
+ ok = 1;
+ break;
+ }
+ memcpy(&save, strmbs, sizeof(save));
+ savestring = string;
+ while (--len > 0) {
+ sclen = mbrtowc(&sc, string,
+ MB_LEN_MAX, strmbs);
+ if (sclen == (size_t)-1 ||
+ sclen == (size_t)-2) {
+ sc = (unsigned char)*string;
+ sclen = 1;
+ memset(&strmbs, 0,
+ sizeof(strmbs));
+ }
+ if (sc != *wp++) {
+ memcpy(strmbs, &save,
+ sizeof(save));
+ string = savestring;
+ break;
+ }
+ string += sclen;
+ }
+ if (len == 0) {
+ ok = 1;
+ break;
+ }
+ continue; /* no match */
+ }
+ c = *buf;
+ } else if (special == '=') {
+ int ec;
+ memcpy(&save, patmbs, sizeof(save));
+ ec = __collate_equiv_class(pattern,
+ cp - pattern, patmbs);
+ if (ec < 0)
+ return (RANGE_ERROR);
+ if (ec == 0) {
+ memcpy(patmbs, &save, sizeof(save));
+ goto treat_like_collating_symbol;
+ }
+ pattern = cp + 2;
+ /* no equivalence classes as start of range */
+ if (*(cp + 2) == '-' && *(cp + 3) != EOS &&
+ *(cp + 3) != ']')
+ return (RANGE_ERROR);
+ len = __collate_equiv_match(ec, NULL, 0, test,
+ string, strlen(string), strmbs, &sclen);
+ if (len < 0)
+ return (RANGE_ERROR);
+ if (len > 0) {
+ ok = 1;
+ string += sclen;
+ break;
+ }
+ continue;
+ } else { /* special == ':' */
+ wctype_t charclass;
+ char name[CHARCLASS_NAME_MAX + 1];
+ /* no character classes as start of range */
+ if (*(cp + 2) == '-' && *(cp + 3) != EOS &&
+ *(cp + 3) != ']')
+ return (RANGE_ERROR);
+ /* assume character class names are ascii */
+ if (cp - pattern > CHARCLASS_NAME_MAX)
+ return (RANGE_ERROR);
+ strlcpy(name, pattern, cp - pattern + 1);
+ pattern = cp + 2;
+ if ((charclass = wctype(name)) == 0)
+ return (RANGE_ERROR);
+ if (iswctype(test, charclass)) {
+ ok = 1;
+ break;
+ }
+ continue;
+ }
+ }
+ if (!c) {
+ pclen = mbrtowc(&c, pattern, MB_LEN_MAX, patmbs);
+ if (pclen == (size_t)-1 || pclen == (size_t)-2)
+ return (RANGE_NOMATCH);
+ pattern += pclen;
+ }
if (flags & FNM_CASEFOLD)
c = towlower(c);
@@ -290,6 +410,37 @@ rangematch(const char *pattern, wchar_t test, int flags, char **newp,
if (c2 == EOS)
return (RANGE_ERROR);
+ if ((c2 == '[' && (special = *pattern) == '.') ||
+ special == '=' || special == ':') {
+
+ /*
+ * No equivalence classes or character
+ * classes as end of range.
+ */
+ if (special == '=' || special == ':')
+ return (RANGE_ERROR);
+ cp = ++pattern;
+ while ((cp = strchr(cp, special))) {
+ if (*(cp + 1) == ']')
+ break;
+ cp++;
+ }
+ if (!cp)
+ return (RANGE_ERROR);
+ len = __collate_collating_symbol(buf,
+ COLLATE_STR_LEN, pattern,
+ cp - pattern, patmbs);
+
+ /*
+ * No multi-character collation symbols
+ * as end of range.
+ */
+ if (len != 1)
+ return (RANGE_ERROR);
+ pattern = cp + 2;
+ c2 = *buf;
+ }
+
if (flags & FNM_CASEFOLD)
c2 = towlower(c2);
@@ -297,12 +448,44 @@ rangematch(const char *pattern, wchar_t test, int flags, char **newp,
c <= test && test <= c2 :
__wcollate_range_cmp(c, test) <= 0
&& __wcollate_range_cmp(test, c2) <= 0
- )
+ ) {
ok = 1;
- } else if (c == test)
+ break;
+ }
+ } else if (c == test) {
ok = 1;
+ break;
+ }
}
- *newp = (char *)pattern;
+ /* go to end of bracket expression */
+ special = 0;
+ while (*pattern != ']') {
+ if (*pattern == 0)
+ return (RANGE_ERROR);
+ if (*pattern == special) {
+ if (*++pattern == ']') {
+ special = 0;
+ pattern++;
+ }
+ continue;
+ }
+ if (!special && *pattern == '[') {
+ special = *++pattern;
+ if (special != '.' && special != '=' && special != ':')
+ special = 0;
+ else
+ pattern++;
+ continue;
+ }
+ pclen = mbrtowc(&c, pattern, MB_LEN_MAX, patmbs);
+ if (pclen == (size_t)-1 || pclen == (size_t)-2)
+ return (RANGE_NOMATCH);
+ pattern += pclen;
+ }
+
+ *newp = (char *)++pattern;
+ *news = (char *)string;
+
return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
}
diff --git a/lib/libc/gen/frexp.3 b/lib/libc/gen/frexp.3
index a1d187ea44c8..1424ac888ad6 100644
--- a/lib/libc/gen/frexp.3
+++ b/lib/libc/gen/frexp.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)frexp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 4, 2005
.Dt FREXP 3
.Os
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index 06aae12ff86a..ae21b4696883 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)fstab.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <sys/param.h>
#include <sys/mount.h>
diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c
index 1465fe5c7e47..04fa5d464fb0 100644
--- a/lib/libc/gen/ftok.c
+++ b/lib/libc/gen/ftok.c
@@ -27,7 +27,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ipc.h>
diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c
index e692e1f9e271..f87cabf085f7 100644
--- a/lib/libc/gen/fts-compat.c
+++ b/lib/libc/gen/fts-compat.c
@@ -27,12 +27,9 @@
* 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.
- *
- * From: @(#)fts.c 8.6 (Berkeley) 8/14/94
* From: $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#define _WANT_FREEBSD11_STATFS
diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h
index f1794fe3264d..d522e3befedb 100644
--- a/lib/libc/gen/fts-compat.h
+++ b/lib/libc/gen/fts-compat.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)fts.h 8.3 (Berkeley) 8/14/94
*/
#ifndef _FTS_H_
diff --git a/lib/libc/gen/fts-compat11.c b/lib/libc/gen/fts-compat11.c
index 2739e10a77de..0351ce5ac690 100644
--- a/lib/libc/gen/fts-compat11.c
+++ b/lib/libc/gen/fts-compat11.c
@@ -25,12 +25,9 @@
* 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.
- *
- * From: @(#)fts.c 8.6 (Berkeley) 8/14/94
* From: $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#define _WANT_FREEBSD11_STATFS
diff --git a/lib/libc/gen/fts-compat11.h b/lib/libc/gen/fts-compat11.h
index ca77b9e491c0..f53e312374c5 100644
--- a/lib/libc/gen/fts-compat11.h
+++ b/lib/libc/gen/fts-compat11.h
@@ -25,8 +25,6 @@
* 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.
- *
- * @(#)fts.h 8.3 (Berkeley) 8/14/94
*/
#ifndef _FTS_COPMAT11_H_
diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3
index 04ff2ee0296a..ee558b892c8c 100644
--- a/lib/libc/gen/fts.3
+++ b/lib/libc/gen/fts.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
-.\"
-.Dd January 12, 2014
+.Dd June 30, 2025
.Dt FTS 3
.Os
.Sh NAME
@@ -39,6 +37,8 @@
.In fts.h
.Ft FTS *
.Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)"
+.Ft FTS *
+.Fn fts_open_b "char * const *path_argv" "int options" "int (^compar)(const FTSENT * const *, const FTSENT * const *)"
.Ft FTSENT *
.Fn fts_read "FTS *ftsp"
.Ft FTSENT *
@@ -61,7 +61,9 @@ functions are provided for traversing
file hierarchies.
A simple overview is that the
.Fn fts_open
-function returns a
+and
+.Fn fts_open_b
+functions return a
.Dq handle
on a file hierarchy, which is then supplied to
the other
@@ -178,6 +180,12 @@ by one of the other
values.
.It Dv FTS_DNR
A directory which cannot be read.
+This immediately follows
+.Dv FTS_D ,
+in place of
+.Dv FTS_DP ,
+when the directory could not be entered, or could be entered but not
+read.
This is an error return, and the
.Fa fts_errno
field will be set to indicate what caused the error.
@@ -188,6 +196,8 @@ or
.Ql ..\&
which was not specified as a file name to
.Fn fts_open
+or
+.Fn fts_open_b
(see
.Dv FTS_SEEDOT ) .
.It Dv FTS_DP
@@ -236,6 +246,8 @@ A path for accessing the file from the current directory.
The path for the file relative to the root of the traversal.
This path contains the path specified to
.Fn fts_open
+or
+.Fn fts_open_b
as a prefix.
.It Fa fts_pathlen
The length of the string referenced by
@@ -382,12 +394,16 @@ must be specified.
The options are selected by
.Em or Ns 'ing
the following values:
-.Bl -tag -width "FTS_PHYSICAL"
+.Bl -tag -width "FTS_COMFOLLOWDIR"
.It Dv FTS_COMFOLLOW
This option causes any symbolic link specified as a root path to be
followed immediately whether or not
.Dv FTS_LOGICAL
is also specified.
+.It Dv FTS_COMFOLLOWDIR
+This option is similar to
+.Dv FTS_COMFOLLOW ,
+but only follows symbolic links to directories.
.It Dv FTS_LOGICAL
This option causes the
.Nm
@@ -443,6 +459,15 @@ field to
and leave the contents of the
.Fa statp
field undefined.
+.It Dv FTS_NOSTAT_TYPE
+This option is similar to
+.Dv FTS_NOSTAT ,
+but attempts to populate
+.Fa fts_info
+based on information from the
+.Fa d_type
+field of
+.Vt struct dirent .
.It Dv FTS_PHYSICAL
This option causes the
.Nm
@@ -520,6 +545,15 @@ the directory traversal order is in the order listed in
.Fa path_argv
for the root paths, and in the order listed in the directory for
everything else.
+.Sh FTS_OPEN_B
+The
+.Fn fts_open_b
+function is identical to
+.Fn fts_open
+except that it takes a block pointer instead of a function pointer.
+The block is copied before
+.Fn fts_open_b
+returns, so the original can safely go out of scope or be released.
.Sh FTS_READ
The
.Fn fts_read
@@ -595,9 +629,13 @@ As a special case, if
has not yet been called for a hierarchy,
.Fn fts_children
will return a pointer to the files in the logical directory specified to
-.Fn fts_open ,
+.Fn fts_open
+or
+.Fn fts_open_b ,
i.e., the arguments specified to
-.Fn fts_open .
+.Fn fts_open
+or
+.Fn fts_open_b .
Otherwise, if the
.Vt FTSENT
structure most recently returned by
@@ -718,6 +756,8 @@ function closes a file hierarchy stream
.Fa ftsp
and restores the current directory to the directory from which
.Fn fts_open
+or
+.Fn fts_open_b
was called to open
.Fa ftsp .
The
@@ -725,29 +765,38 @@ The
function
returns 0 on success, and \-1 if an error occurs.
.Sh ERRORS
-The function
+The
.Fn fts_open
-may fail and set
+and
+.Fn fts_open_b
+functions may fail and set
.Va errno
for any of the errors specified for the library functions
.Xr open 2
and
.Xr malloc 3 .
+The
+.Fn fts_open_b
+function may also fail and set
+.Va errno
+to
+.Dv ENOSYS
+if the blocks runtime is missing.
.Pp
-The function
+The
.Fn fts_close
-may fail and set
+function may fail and set
.Va errno
for any of the errors specified for the library functions
.Xr chdir 2
and
.Xr close 2 .
.Pp
-The functions
+The
.Fn fts_read
and
.Fn fts_children
-may fail and set
+functions may fail and set
.Va errno
for any of the errors specified for the library functions
.Xr chdir 2 ,
@@ -757,12 +806,12 @@ for any of the errors specified for the library functions
and
.Xr stat 2 .
.Pp
-In addition,
+In addition, the
.Fn fts_children ,
-.Fn fts_open
+.Fn fts_open ,
and
.Fn fts_set
-may fail and set
+functions may fail and set
.Va errno
as follows:
.Bl -tag -width Er
@@ -790,6 +839,13 @@ functions were introduced in
principally to provide for alternative interfaces to the
.Nm
functionality using different data structures.
+Blocks support and the
+.Dv FTS_COMFOLLOWDIR
+and
+.Dv FTS_NOSTAT
+options were added in
+.Fx 15.0
+based on similar functionality in macOS.
.Sh BUGS
The
.Fn fts_open
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index ff51d2b224c2..cce959ba836a 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -31,8 +31,6 @@
* $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)fts.c 8.6 (Berkeley) 8/14/94");
#include "namespace.h"
#include <sys/param.h>
#include <sys/mount.h>
@@ -42,6 +40,7 @@ __SCCSID("@(#)fts.c 8.6 (Berkeley) 8/14/94");
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
+#include <stdalign.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -49,6 +48,19 @@ __SCCSID("@(#)fts.c 8.6 (Berkeley) 8/14/94");
#include "gen-private.h"
+#ifdef __BLOCKS__
+#include <Block.h>
+#else
+#include "block_abi.h"
+typedef DECLARE_BLOCK(int, fts_block,
+ const FTSENT * const *, const FTSENT * const *);
+void qsort_b(void *, size_t, size_t, fts_block);
+#endif /* __BLOCKS__ */
+/* only present if linked with blocks runtime */
+void *_Block_copy(const void *) __weak_symbol;
+void _Block_release(const void *) __weak_symbol;
+extern void *_NSConcreteGlobalBlock[] __weak_symbol;
+
static FTSENT *fts_alloc(FTS *, char *, size_t);
static FTSENT *fts_build(FTS *, int);
static void fts_lfree(FTSENT *);
@@ -103,39 +115,21 @@ static const char *ufslike_filesystems[] = {
0
};
-FTS *
-fts_open(char * const *argv, int options,
- int (*compar)(const FTSENT * const *, const FTSENT * const *))
+static FTS *
+__fts_open(FTS *sp, char * const *argv)
{
- struct _fts_private *priv;
- FTS *sp;
FTSENT *p, *root;
FTSENT *parent, *tmp;
size_t len, nitems;
- /* Options check. */
- if (options & ~FTS_OPTIONMASK) {
- errno = EINVAL;
- return (NULL);
- }
-
- /* fts_open() requires at least one path */
- if (*argv == NULL) {
- errno = EINVAL;
- return (NULL);
- }
-
- /* Allocate/initialize the stream. */
- if ((priv = calloc(1, sizeof(*priv))) == NULL)
- return (NULL);
- sp = &priv->ftsp_fts;
- sp->fts_compar = compar;
- sp->fts_options = options;
-
/* Logical walks turn on NOCHDIR; symbolic links are too hard. */
if (ISSET(FTS_LOGICAL))
SET(FTS_NOCHDIR);
+ /* NOSTAT_TYPE implies NOSTAT */
+ if (ISSET(FTS_NOSTAT_TYPE))
+ SET(FTS_NOSTAT);
+
/*
* Start out with 1K of path space, and enough, in any case,
* to hold the user's paths.
@@ -159,7 +153,9 @@ fts_open(char * const *argv, int options,
p->fts_level = FTS_ROOTLEVEL;
p->fts_parent = parent;
p->fts_accpath = p->fts_name;
- p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW), -1);
+ p->fts_info = fts_stat(sp, p,
+ ISSET(FTS_COMFOLLOWDIR) ? -1 : ISSET(FTS_COMFOLLOW),
+ -1);
/* Command-line "." and ".." are real directories. */
if (p->fts_info == FTS_DOT)
@@ -169,7 +165,7 @@ fts_open(char * const *argv, int options,
* If comparison routine supplied, traverse in sorted
* order; otherwise traverse in the order specified.
*/
- if (compar) {
+ if (sp->fts_compar) {
p->fts_link = root;
root = p;
} else {
@@ -182,7 +178,7 @@ fts_open(char * const *argv, int options,
}
}
}
- if (compar && nitems > 1)
+ if (sp->fts_compar && nitems > 1)
root = fts_sort(sp, root, nitems);
/*
@@ -215,6 +211,97 @@ mem1: free(sp);
return (NULL);
}
+FTS *
+fts_open(char * const *argv, int options,
+ int (*compar)(const FTSENT * const *, const FTSENT * const *))
+{
+ struct _fts_private *priv;
+ FTS *sp;
+
+ /* Options check. */
+ if (options & ~FTS_OPTIONMASK) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ /* fts_open() requires at least one path */
+ if (*argv == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ /* Allocate/initialize the stream. */
+ if ((priv = calloc(1, sizeof(*priv))) == NULL)
+ return (NULL);
+ sp = &priv->ftsp_fts;
+ sp->fts_compar = compar;
+ sp->fts_options = options;
+
+ return (__fts_open(sp, argv));
+}
+
+#ifdef __BLOCKS__
+FTS *
+fts_open_b(char * const *argv, int options,
+ int (^compar)(const FTSENT * const *, const FTSENT * const *))
+#else
+FTS *
+fts_open_b(char * const *argv, int options, fts_block compar)
+#endif /* __BLOCKS__ */
+{
+ struct _fts_private *priv;
+ FTS *sp;
+
+ /* No blocks, no problems. */
+ if (compar == NULL)
+ return (fts_open(argv, options, NULL));
+
+ /* Avoid segfault if blocks runtime is missing. */
+ if (_Block_copy == NULL) {
+ errno = ENOSYS;
+ return (NULL);
+ }
+
+ /* Options check. */
+ if (options & ~FTS_OPTIONMASK) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ /* fts_open() requires at least one path */
+ if (*argv == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ /* Allocate/initialize the stream. */
+ if ((priv = calloc(1, sizeof(*priv))) == NULL)
+ return (NULL);
+ sp = &priv->ftsp_fts;
+#ifdef __BLOCKS__
+ compar = Block_copy(compar);
+#else
+ if (compar->isa != &_NSConcreteGlobalBlock)
+ compar = _Block_copy(compar);
+#endif /* __BLOCKS__ */
+ if (compar == NULL) {
+ free(priv);
+ return (NULL);
+ }
+ sp->fts_compar_b = compar;
+ sp->fts_options = options | FTS_COMPAR_B;
+
+ if ((sp = __fts_open(sp, argv)) == NULL) {
+#ifdef __BLOCKS__
+ Block_release(compar);
+#else
+ if (compar->isa != &_NSConcreteGlobalBlock)
+ _Block_release(compar);
+#endif /* __BLOCKS__ */
+ }
+ return (sp);
+}
+
static void
fts_load(FTS *sp, FTSENT *p)
{
@@ -266,6 +353,17 @@ fts_close(FTS *sp)
free(sp->fts_array);
free(sp->fts_path);
+ /* Free up any block pointer. */
+ if (ISSET(FTS_COMPAR_B) && sp->fts_compar_b != NULL) {
+#ifdef __BLOCKS__
+ Block_release(sp->fts_compar_b);
+#else
+ if (((fts_block)(sp->fts_compar_b))->isa !=
+ &_NSConcreteGlobalBlock)
+ _Block_release(sp->fts_compar_b);
+#endif /* __BLOCKS__ */
+ }
+
/* Return to original directory, save errno if necessary. */
if (!ISSET(FTS_NOCHDIR)) {
saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
@@ -651,14 +749,10 @@ fts_build(FTS *sp, int type)
* Open the directory for reading. If this fails, we're done.
* If being called from fts_read, set the fts_info field.
*/
-#ifdef FTS_WHITEOUT
if (ISSET(FTS_WHITEOUT))
oflag = DTF_NODUP;
else
oflag = DTF_HIDEW | DTF_NODUP;
-#else
-#define __opendir2(path, flag) opendir(path)
-#endif
if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) {
if (type == BREAD) {
cur->fts_info = FTS_DNR;
@@ -785,10 +879,8 @@ mem1: saved_errno = errno;
p->fts_parent = sp->fts_cur;
p->fts_pathlen = len + dnamlen;
-#ifdef FTS_WHITEOUT
if (dp->d_type == DT_WHT)
p->fts_flags |= FTS_ISW;
-#endif
if (cderrno) {
if (nlinks) {
@@ -797,12 +889,8 @@ mem1: saved_errno = errno;
} else
p->fts_info = FTS_NSOK;
p->fts_accpath = cur->fts_accpath;
- } else if (nlinks == 0
-#ifdef DT_DIR
- || (nostat &&
- dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)
-#endif
- ) {
+ } else if (nlinks == 0 || (nostat &&
+ dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)) {
p->fts_accpath =
ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name;
p->fts_info = FTS_NSOK;
@@ -822,6 +910,25 @@ mem1: saved_errno = errno;
p->fts_info == FTS_DC || p->fts_info == FTS_DOT))
--nlinks;
}
+ if (p->fts_info == FTS_NSOK && ISSET(FTS_NOSTAT_TYPE)) {
+ switch (dp->d_type) {
+ case DT_FIFO:
+ case DT_CHR:
+ case DT_BLK:
+ case DT_SOCK:
+ p->fts_info = FTS_DEFAULT;
+ break;
+ case DT_REG:
+ p->fts_info = FTS_F;
+ break;
+ case DT_LNK:
+ p->fts_info = FTS_SL;
+ break;
+ case DT_WHT:
+ p->fts_info = FTS_W;
+ break;
+ }
+ }
/* We walk in directory order so "ls -f" doesn't get upset. */
p->fts_link = NULL;
@@ -898,18 +1005,19 @@ fts_stat(FTS *sp, FTSENT *p, int follow, int dfd)
dev_t dev;
ino_t ino;
struct stat *sbp, sb;
- int saved_errno;
+ int ret, saved_errno;
const char *path;
- if (dfd == -1)
- path = p->fts_accpath, dfd = AT_FDCWD;
- else
+ if (dfd == -1) {
+ path = p->fts_accpath;
+ dfd = AT_FDCWD;
+ } else {
path = p->fts_name;
+ }
/* If user needs stat info, stat buffer already allocated. */
sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
-#ifdef FTS_WHITEOUT
/* Check for whiteout. */
if (p->fts_flags & FTS_ISW) {
if (sbp != &sb) {
@@ -918,22 +1026,27 @@ fts_stat(FTS *sp, FTSENT *p, int follow, int dfd)
}
return (FTS_W);
}
-#endif
/*
- * If doing a logical walk, or application requested FTS_FOLLOW, do
- * a stat(2). If that fails, check for a non-existent symlink. If
- * fail, set the errno from the stat call.
+ * If doing a logical walk, or caller requested FTS_COMFOLLOW, do
+ * a full stat(2). If that fails, do an lstat(2) to check for a
+ * non-existent symlink. If that fails, set the errno from the
+ * stat(2) call.
+ *
+ * As a special case, if stat(2) succeeded but the target is not a
+ * directory and follow is negative (indicating FTS_COMFOLLOWDIR
+ * rather than FTS_COMFOLLOW), we also revert to lstat(2).
*/
if (ISSET(FTS_LOGICAL) || follow) {
- if (fstatat(dfd, path, sbp, 0)) {
+ if ((ret = fstatat(dfd, path, sbp, 0)) != 0 ||
+ (follow < 0 && !S_ISDIR(sbp->st_mode))) {
saved_errno = errno;
if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
p->fts_errno = saved_errno;
goto err;
}
errno = 0;
- if (S_ISLNK(sbp->st_mode))
+ if (ret != 0 && S_ISLNK(sbp->st_mode))
return (FTS_SLNONE);
}
} else if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
@@ -978,21 +1091,6 @@ err: memset(sbp, 0, sizeof(struct stat));
return (FTS_DEFAULT);
}
-/*
- * The comparison function takes pointers to pointers to FTSENT structures.
- * Qsort wants a comparison function that takes pointers to void.
- * (Both with appropriate levels of const-poisoning, of course!)
- * Use a trampoline function to deal with the difference.
- */
-static int
-fts_compar(const void *a, const void *b)
-{
- FTS *parent;
-
- parent = (*(const FTSENT * const *)a)->fts_fts;
- return (*parent->fts_compar)(a, b);
-}
-
static FTSENT *
fts_sort(FTS *sp, FTSENT *head, size_t nitems)
{
@@ -1015,7 +1113,18 @@ fts_sort(FTS *sp, FTSENT *head, size_t nitems)
}
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
*ap++ = p;
- qsort(sp->fts_array, nitems, sizeof(FTSENT *), fts_compar);
+ if (ISSET(FTS_COMPAR_B)) {
+#ifdef __BLOCKS__
+ qsort_b(sp->fts_array, nitems, sizeof(FTSENT *),
+ (int (^)(const void *, const void *))sp->fts_compar_b);
+#else
+ qsort_b(sp->fts_array, nitems, sizeof(FTSENT *),
+ sp->fts_compar_b);
+#endif /* __BLOCKS__ */
+ } else {
+ qsort(sp->fts_array, nitems, sizeof(FTSENT *),
+ (int (*)(const void *, const void *))sp->fts_compar);
+ }
for (head = *(ap = sp->fts_array); --nitems; ++ap)
ap[0]->fts_link = ap[1];
ap[0]->fts_link = NULL;
@@ -1028,44 +1137,32 @@ fts_alloc(FTS *sp, char *name, size_t namelen)
FTSENT *p;
size_t len;
- struct ftsent_withstat {
- FTSENT ent;
- struct stat statbuf;
- };
-
/*
* The file name is a variable length array and no stat structure is
* necessary if the user has set the nostat bit. Allocate the FTSENT
* structure, the file name and the stat structure in one chunk, but
* be careful that the stat structure is reasonably aligned.
*/
- if (ISSET(FTS_NOSTAT))
- len = sizeof(FTSENT) + namelen + 1;
- else
- len = sizeof(struct ftsent_withstat) + namelen + 1;
-
- if ((p = malloc(len)) == NULL)
- return (NULL);
-
- if (ISSET(FTS_NOSTAT)) {
- p->fts_name = (char *)(p + 1);
- p->fts_statp = NULL;
+ len = sizeof(FTSENT) + namelen + 1;
+ if (!ISSET(FTS_NOSTAT)) {
+ len = roundup(len, alignof(struct stat));
+ p = calloc(1, len + sizeof(struct stat));
} else {
- p->fts_name = (char *)((struct ftsent_withstat *)p + 1);
- p->fts_statp = &((struct ftsent_withstat *)p)->statbuf;
+ p = calloc(1, len);
}
+ if (p == NULL)
+ return (NULL);
- /* Copy the name and guarantee NUL termination. */
- memcpy(p->fts_name, name, namelen);
- p->fts_name[namelen] = '\0';
- p->fts_namelen = namelen;
+ p->fts_symfd = -1;
p->fts_path = sp->fts_path;
- p->fts_errno = 0;
- p->fts_flags = 0;
+ p->fts_name = (char *)(p + 1);
+ p->fts_namelen = namelen;
p->fts_instr = FTS_NOINSTR;
- p->fts_number = 0;
- p->fts_pointer = NULL;
+ if (!ISSET(FTS_NOSTAT))
+ p->fts_statp = (struct stat *)((char *)p + len);
p->fts_fts = sp;
+ memcpy(p->fts_name, name, namelen);
+
return (p);
}
@@ -1145,6 +1242,7 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
{
int ret, oerrno, newfd;
struct stat sb;
+ struct statfs sf;
newfd = fd;
if (ISSET(FTS_NOCHDIR))
@@ -1157,9 +1255,15 @@ fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
goto bail;
}
if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
- errno = ENOENT; /* disinformation */
- ret = -1;
- goto bail;
+ if (_fstatfs(newfd, &sf) != 0 ||
+ (sf.f_flags & MNT_AUTOMOUNTED) == 0) {
+ errno = ENOENT; /* disinformation */
+ ret = -1;
+ goto bail;
+ }
+ /* autofs might did the mount under us, accept. */
+ p->fts_dev = sb.st_dev;
+ p->fts_ino = sb.st_ino;
}
ret = fchdir(newfd);
bail:
diff --git a/lib/libc/gen/ftw-compat11.c b/lib/libc/gen/ftw-compat11.c
index aa9d9358aa15..28d6398f6fd8 100644
--- a/lib/libc/gen/ftw-compat11.c
+++ b/lib/libc/gen/ftw-compat11.c
@@ -22,7 +22,6 @@
* From: FreeBSD: head/lib/libc/gen/ftw.c 239151 2012-08-09 15:11:38Z jilles
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/lib/libc/gen/ftw.c b/lib/libc/gen/ftw.c
index 80b45ff32f5c..35557d930bf4 100644
--- a/lib/libc/gen/ftw.c
+++ b/lib/libc/gen/ftw.c
@@ -20,7 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/lib/libc/gen/gen-private.h b/lib/libc/gen/gen-private.h
index 3792a61ff942..b6749b3435cd 100644
--- a/lib/libc/gen/gen-private.h
+++ b/lib/libc/gen/gen-private.h
@@ -43,8 +43,8 @@ struct pthread_mutex;
*/
struct _dirdesc {
int dd_fd; /* file descriptor associated with directory */
- long dd_loc; /* offset in current buffer */
- long dd_size; /* amount of data returned by getdirentries */
+ size_t dd_loc; /* offset in current buffer */
+ size_t dd_size; /* amount of data returned by getdirentries */
char *dd_buf; /* data buffer */
int dd_len; /* size of data buffer */
off_t dd_seek; /* magic cookie returned by getdirentries */
diff --git a/lib/libc/gen/getbootfile.3 b/lib/libc/gen/getbootfile.3
index 1fffa9c9df7c..a857b3e8859e 100644
--- a/lib/libc/gen/getbootfile.3
+++ b/lib/libc/gen/getbootfile.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)gethostname.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd September 23, 1994
.Dt GETBOOTFILE 3
.Os
diff --git a/lib/libc/gen/getbootfile.c b/lib/libc/gen/getbootfile.c
index e2c36a96378d..6250e3e2509b 100644
--- a/lib/libc/gen/getbootfile.c
+++ b/lib/libc/gen/getbootfile.c
@@ -27,11 +27,8 @@
* 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.
- *
- * From: @(#)gethostname.c 8.1 (Berkeley) 6/4/93
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/getbsize.3 b/lib/libc/gen/getbsize.3
index 500968ad6db8..1d9d43fdfffb 100644
--- a/lib/libc/gen/getbsize.3
+++ b/lib/libc/gen/getbsize.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 11, 2017
.Dt GETBSIZE 3
.Os
diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c
index 2fbcaf7b6dbd..efcabea663a0 100644
--- a/lib/libc/gen/getbsize.c
+++ b/lib/libc/gen/getbsize.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getbsize.c 8.1 (Berkeley) 6/4/93");
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/getcap.3 b/lib/libc/gen/getcap.3
index f736cfc3c4e9..00c7edd8026f 100644
--- a/lib/libc/gen/getcap.3
+++ b/lib/libc/gen/getcap.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94
-.\"
.Dd March 22, 2002
.Dt GETCAP 3
.Os
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
index 9ba6cda5c280..cfb81ed0d065 100644
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getcap.c 8.3 (Berkeley) 3/25/94");
#include "namespace.h"
#include <sys/types.h>
diff --git a/lib/libc/gen/getcwd.3 b/lib/libc/gen/getcwd.3
index 073838f2bf02..43d7718e92d6 100644
--- a/lib/libc/gen/getcwd.3
+++ b/lib/libc/gen/getcwd.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getcwd.3 8.2 (Berkeley) 12/11/93
-.\"
.Dd April 17, 2010
.Dt GETCWD 3
.Os
diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c
index c0cabacb96ba..18d8ce668274 100644
--- a/lib/libc/gen/getcwd.c
+++ b/lib/libc/gen/getcwd.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getcwd.c 8.5 (Berkeley) 2/7/95");
#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -42,6 +40,7 @@ __SCCSID("@(#)getcwd.c 8.5 (Berkeley) 2/7/95");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include "un-namespace.h"
#include "gen-private.h"
@@ -53,7 +52,7 @@ __SCCSID("@(#)getcwd.c 8.5 (Berkeley) 2/7/95");
extern int __getcwd(char *, size_t);
char *
-getcwd(char *pt, size_t size)
+__ssp_real(getcwd)(char *pt, size_t size)
{
struct dirent *dp;
DIR *dir = NULL;
diff --git a/lib/libc/gen/getdiskbyname.3 b/lib/libc/gen/getdiskbyname.3
index ddf7d39fd821..8de4f3976dd2 100644
--- a/lib/libc/gen/getdiskbyname.3
+++ b/lib/libc/gen/getdiskbyname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getdiskbyname.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt GETDISKBYNAME 3
.Os
diff --git a/lib/libc/gen/getdomainname.3 b/lib/libc/gen/getdomainname.3
index 94bafd6ece70..47fb139ac23c 100644
--- a/lib/libc/gen/getdomainname.3
+++ b/lib/libc/gen/getdomainname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 6, 1994
.Dt GETDOMAINNAME 3
.Os
diff --git a/lib/libc/gen/getdomainname.c b/lib/libc/gen/getdomainname.c
index 70b1e460028f..c0be7465f967 100644
--- a/lib/libc/gen/getdomainname.c
+++ b/lib/libc/gen/getdomainname.c
@@ -29,15 +29,14 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)gethostname.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/sysctl.h>
#include <unistd.h>
+#include <ssp/ssp.h>
int
-getdomainname(char *name, int namelen)
+__ssp_real(getdomainname)(char *name, int namelen)
{
int mib[2];
size_t size;
diff --git a/lib/libc/gen/getentropy.3 b/lib/libc/gen/getentropy.3
index 0a3ba3e25610..5f7ee32ebbfc 100644
--- a/lib/libc/gen/getentropy.3
+++ b/lib/libc/gen/getentropy.3
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd February 24, 2018
+.Dd January 17, 2025
.Dt GETENTROPY 3
.Os
.Sh NAME
@@ -60,8 +60,8 @@ The
.Fa buf
parameter points to an
invalid address.
-.It Bq Er EIO
-Too many bytes requested, or some other fatal error occurred.
+.It Bq Er EINVAL
+Too many bytes requested.
.El
.Sh SEE ALSO
.Xr getrandom 2 ,
@@ -69,10 +69,8 @@ Too many bytes requested, or some other fatal error occurred.
.Xr random 4
.Sh STANDARDS
.Fn getentropy
-is non-standard.
-It is present on
-.Ox
-and Linux.
+conforms to
+.St -p1003.1-2024 .
.Sh HISTORY
The
.Fn getentropy
diff --git a/lib/libc/gen/getentropy.c b/lib/libc/gen/getentropy.c
index 44cb190f0237..6b8ad697b7e0 100644
--- a/lib/libc/gen/getentropy.c
+++ b/lib/libc/gen/getentropy.c
@@ -26,123 +26,44 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/random.h>
-#include <sys/sysctl.h>
#include <errno.h>
+#include <limits.h>
#include <signal.h>
-#include <stdbool.h>
-#include <stdlib.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
-/* First __FreeBSD_version bump after introduction of getrandom(2) (r331279) */
-#define GETRANDOM_FIRST 1200061
-
-extern int __sysctl(int *, u_int, void *, size_t *, void *, size_t);
-
static inline void
_getentropy_fail(void)
{
raise(SIGKILL);
}
-static size_t
-arnd_sysctl(u_char *buf, size_t size)
-{
- int mib[2];
- size_t len, done;
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_ARND;
- done = 0;
-
- do {
- len = size;
- if (__sysctl(mib, 2, buf, &len, NULL, 0) == -1)
- return (done);
- done += len;
- buf += len;
- size -= len;
- } while (size > 0);
-
- return (done);
-}
-
-/*
- * If a newer libc is accidentally installed on an older kernel, provide high
- * quality random data anyway. The sysctl interface is not as fast and does
- * not block by itself, but is provided by even very old kernels.
- */
-static int
-getentropy_fallback(void *buf, size_t buflen)
-{
- /*
- * oldp (buf) == NULL has a special meaning for sysctl that results in
- * no EFAULT. For compatibility with the kernel getrandom(2), detect
- * this case and return the appropriate error.
- */
- if (buf == NULL && buflen > 0) {
- errno = EFAULT;
- return (-1);
- }
- if (arnd_sysctl(buf, buflen) != buflen) {
- if (errno == EFAULT)
- return (-1);
- /*
- * This cannot happen. arnd_sysctl() spins until the random
- * device is seeded and then repeatedly reads until the full
- * request is satisfied. The only way for this to return a zero
- * byte or short read is if sysctl(2) on the kern.arandom MIB
- * fails. In this case, excepting the user-provided-a-bogus-
- * buffer EFAULT, give up (like for arc4random(3)'s arc4_stir).
- */
- _getentropy_fail();
- }
- return (0);
-}
-
int
-getentropy(void *buf, size_t buflen)
+__ssp_real(getentropy)(void *buf, size_t buflen)
{
ssize_t rd;
- bool have_getrandom;
- if (buflen > 256) {
- errno = EIO;
+ if (buflen > GETENTROPY_MAX) {
+ errno = EINVAL;
return (-1);
}
- have_getrandom = (__getosreldate() >= GETRANDOM_FIRST);
-
while (buflen > 0) {
- if (have_getrandom) {
- rd = getrandom(buf, buflen, 0);
- if (rd == -1) {
- switch (errno) {
- case ECAPMODE:
- /*
- * Kernel >= r331280 and < r337999
- * will return ECAPMODE when the
- * caller is already in capability
- * mode, fallback to traditional
- * method in this case.
- */
- have_getrandom = false;
- continue;
- case EINTR:
- continue;
- case EFAULT:
- return (-1);
- default:
- _getentropy_fail();
- }
+ rd = getrandom(buf, buflen, 0);
+ if (rd == -1) {
+ switch (errno) {
+ case EINTR:
+ continue;
+ case EFAULT:
+ return (-1);
+ default:
+ _getentropy_fail();
}
- } else {
- return (getentropy_fallback(buf, buflen));
}
/* This cannot happen. */
diff --git a/lib/libc/gen/getfsent.3 b/lib/libc/gen/getfsent.3
index dd2ea3417e78..4783c7469910 100644
--- a/lib/libc/gen/getfsent.3
+++ b/lib/libc/gen/getfsent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getfsent.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 7, 2003
.Dt GETFSENT 3
.Os
diff --git a/lib/libc/gen/getgrent.3 b/lib/libc/gen/getgrent.3
index 0fba3bcd880d..e4a703f3bfad 100644
--- a/lib/libc/gen/getgrent.3
+++ b/lib/libc/gen/getgrent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd July 31, 2016
.Dt GETGRENT 3
.Os
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index b7fe6021f9fd..508e3d63eb60 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#ifdef YP
diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3
index a7c478a9250c..e9a980f99751 100644
--- a/lib/libc/gen/getgrouplist.3
+++ b/lib/libc/gen/getgrouplist.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd October 26, 2014
.Dt GETGROUPLIST 3
.Os
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index 6dddea5c3847..5bd06bc5121f 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94");
/*
* get credential
*/
@@ -39,11 +37,12 @@ __SCCSID("@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94");
#include <grp.h>
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
extern int __getgroupmembership(const char *, gid_t, gid_t *, int, int *);
int
-getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
+__ssp_real(getgrouplist)(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt)
{
return __getgroupmembership(uname, agroup, groups, *grpcnt, grpcnt);
}
diff --git a/lib/libc/gen/gethostname.3 b/lib/libc/gen/gethostname.3
index d9287f6c861b..99e723fa9595 100644
--- a/lib/libc/gen/gethostname.3
+++ b/lib/libc/gen/gethostname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd July 13, 2020
.Dt GETHOSTNAME 3
.Os
diff --git a/lib/libc/gen/gethostname.c b/lib/libc/gen/gethostname.c
index 9b0400d744e6..66d401fad846 100644
--- a/lib/libc/gen/gethostname.c
+++ b/lib/libc/gen/gethostname.c
@@ -29,16 +29,15 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)gethostname.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/sysctl.h>
#include <errno.h>
#include <unistd.h>
+#include <ssp/ssp.h>
int
-gethostname(char *name, size_t namelen)
+__ssp_real(gethostname)(char *name, size_t namelen)
{
int mib[2];
diff --git a/lib/libc/gen/getloadavg.3 b/lib/libc/gen/getloadavg.3
index 8de0fca20b79..42a9f511c9ef 100644
--- a/lib/libc/gen/getloadavg.3
+++ b/lib/libc/gen/getloadavg.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt GETLOADAVG 3
.Os
diff --git a/lib/libc/gen/getloadavg.c b/lib/libc/gen/getloadavg.c
index 8b4844096015..4f6c23627f0e 100644
--- a/lib/libc/gen/getloadavg.c
+++ b/lib/libc/gen/getloadavg.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getloadavg.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c
index c2c8e24b070e..f8a3fb079067 100644
--- a/lib/libc/gen/getlogin.c
+++ b/lib/libc/gen/getlogin.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getlogin.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <errno.h>
#include <pwd.h>
@@ -39,6 +37,7 @@ __SCCSID("@(#)getlogin.c 8.1 (Berkeley) 6/4/93");
#include <unistd.h>
#include "namespace.h"
#include <pthread.h>
+#include <ssp/ssp.h>
#include "un-namespace.h"
#include "libc_private.h"
@@ -56,7 +55,7 @@ getlogin(void)
}
int
-getlogin_r(char *logname, size_t namelen)
+__ssp_real(getlogin_r)(char *logname, size_t namelen)
{
char tmpname[MAXLOGNAME];
int len;
diff --git a/lib/libc/gen/getmntinfo-compat11.c b/lib/libc/gen/getmntinfo-compat11.c
index 317be508eda2..d5c308b387a0 100644
--- a/lib/libc/gen/getmntinfo-compat11.c
+++ b/lib/libc/gen/getmntinfo-compat11.c
@@ -25,11 +25,8 @@
* 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.
- *
- * From: @(#)getmntinfo.c 8.1 (Berkeley) 6/4/93
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ucred.h>
#define _WANT_FREEBSD11_STATFS
diff --git a/lib/libc/gen/getmntinfo.3 b/lib/libc/gen/getmntinfo.3
index a136bd34175a..2bbe436078d6 100644
--- a/lib/libc/gen/getmntinfo.3
+++ b/lib/libc/gen/getmntinfo.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getmntinfo.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd December 27, 2016
.Dt GETMNTINFO 3
.Os
diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c
index 8b374887f358..3c224ef27d76 100644
--- a/lib/libc/gen/getmntinfo.c
+++ b/lib/libc/gen/getmntinfo.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
diff --git a/lib/libc/gen/getnetgrent.3 b/lib/libc/gen/getnetgrent.3
index 653187d2a401..be2e3cd1cdd5 100644
--- a/lib/libc/gen/getnetgrent.3
+++ b/lib/libc/gen/getnetgrent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getnetgrent.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 5, 2016
.Dt GETNETGRENT 3
.Os
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index baa852076c12..7c92bc2ce9a9 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getnetgrent.c 8.2 (Berkeley) 4/27/95");
#include "namespace.h"
#include <ctype.h>
diff --git a/lib/libc/gen/getosreldate.c b/lib/libc/gen/getosreldate.c
index ce80c099f581..edd978973ade 100644
--- a/lib/libc/gen/getosreldate.c
+++ b/lib/libc/gen/getosreldate.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)gethostid.c 8.1 (Berkeley) 6/2/93");
#include <sys/types.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/getpagesize.3 b/lib/libc/gen/getpagesize.3
deleted file mode 100644
index 5a40c2b2c2a5..000000000000
--- a/lib/libc/gen/getpagesize.3
+++ /dev/null
@@ -1,69 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getpagesize.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd October 17, 2022
-.Dt GETPAGESIZE 3
-.Os
-.Sh NAME
-.Nm getpagesize
-.Nd get system page size
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn getpagesize void
-.Sh DESCRIPTION
-The
-.Fn getpagesize
-function
-returns the number of bytes in a page.
-Page granularity is the granularity of many of the memory
-management calls.
-.Pp
-The page size is a system
-page size and may not be the same as the underlying
-hardware page size.
-.Pp
-.St -p1003.1-2001
-removed
-.Nm .
-Portable applications should use
-.Ql sysconf(_SC_PAGESIZE)
-instead.
-.Sh SEE ALSO
-.Xr pagesize 1 ,
-.Xr sbrk 2 ,
-.Xr getpagesizes 3 ,
-.Xr sysconf 3
-.Sh HISTORY
-The
-.Fn getpagesize
-function appeared in
-.Bx 4.2 .
diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c
deleted file mode 100644
index 94e579c987c9..000000000000
--- a/lib/libc/gen/getpagesize.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1989, 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.
- */
-
-#include <sys/cdefs.h>
-__SCCSID("@(#)getpagesize.c 8.1 (Berkeley) 6/4/93");
-#include <sys/param.h>
-#include <sys/sysctl.h>
-
-#include <errno.h>
-#include <link.h>
-#include <unistd.h>
-
-#include "libc_private.h"
-
-/*
- * This is unlikely to change over the running time of any
- * program, so we cache the result to save some syscalls.
- *
- * NB: This function may be called from malloc(3) at initialization
- * NB: so must not result in a malloc(3) related call!
- */
-
-int
-getpagesize(void)
-{
- int mib[2];
- static int value;
- size_t size;
- int error;
-
- if (value != 0)
- return (value);
-
- error = _elf_aux_info(AT_PAGESZ, &value, sizeof(value));
- if (error == 0 && value != 0)
- return (value);
-
- mib[0] = CTL_HW;
- mib[1] = HW_PAGESIZE;
- size = sizeof value;
- if (sysctl(mib, nitems(mib), &value, &size, NULL, 0) == -1)
- return (PAGE_SIZE);
-
- return (value);
-}
diff --git a/lib/libc/gen/getpagesizes.c b/lib/libc/gen/getpagesizes.c
deleted file mode 100644
index 2cb4ebee0d0e..000000000000
--- a/lib/libc/gen/getpagesizes.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2009 Alan L. Cox <alc@cs.rice.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 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/sysctl.h>
-
-#include <errno.h>
-#include <link.h>
-
-#include "libc_private.h"
-
-/*
- * Retrieves page size information from the system. Specifically, returns the
- * number of distinct page sizes that are supported by the system, if
- * "pagesize" is NULL and "nelem" is 0. Otherwise, assigns up to "nelem" of
- * the system-supported page sizes to consecutive elements of the array
- * referenced by "pagesize", and returns the number of such page sizes that it
- * assigned to the array. These page sizes are expressed in bytes.
- *
- * The implementation of this function does not directly or indirectly call
- * malloc(3) or any other dynamic memory allocator that may itself call this
- * function.
- */
-int
-getpagesizes(size_t pagesize[], int nelem)
-{
- static u_long ps[MAXPAGESIZES];
- static int nops;
- size_t size;
- int error, i;
-
- if (nelem < 0 || (nelem > 0 && pagesize == NULL)) {
- errno = EINVAL;
- return (-1);
- }
- /* Cache the result of the sysctl(2). */
- if (nops == 0) {
- error = _elf_aux_info(AT_PAGESIZES, ps, sizeof(ps));
- size = sizeof(ps);
- if (error != 0 || ps[0] == 0) {
- if (sysctlbyname("hw.pagesizes", ps, &size, NULL, 0)
- == -1)
- return (-1);
- }
- /* Count the number of page sizes that are supported. */
- nops = size / sizeof(ps[0]);
- while (nops > 0 && ps[nops - 1] == 0)
- nops--;
- }
- if (pagesize == NULL)
- return (nops);
- /* Return up to "nelem" page sizes from the cached result. */
- if (nelem > nops)
- nelem = nops;
- for (i = 0; i < nelem; i++)
- pagesize[i] = ps[i];
- return (nelem);
-}
diff --git a/lib/libc/gen/getpass.3 b/lib/libc/gen/getpass.3
index bad4c7f75dea..c88e072e1900 100644
--- a/lib/libc/gen/getpass.3
+++ b/lib/libc/gen/getpass.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getpass.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt GETPASS 3
.Os
diff --git a/lib/libc/gen/getpeereid.3 b/lib/libc/gen/getpeereid.3
index 204dec041d8f..8e3b763f716a 100644
--- a/lib/libc/gen/getpeereid.3
+++ b/lib/libc/gen/getpeereid.3
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 28, 2022
+.Dd November 16, 2023
.Dt GETPEEREID 3
.Os
.Sh NAME
@@ -44,7 +44,7 @@ peer connected to a
socket.
The argument
.Fa s
-must be a
+must be a connected
.Ux Ns -domain
socket
.Pq Xr unix 4
diff --git a/lib/libc/gen/getpeereid.c b/lib/libc/gen/getpeereid.c
index b1934a6c471b..444dd2664cc4 100644
--- a/lib/libc/gen/getpeereid.c
+++ b/lib/libc/gen/getpeereid.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/gen/getprogname.c b/lib/libc/gen/getprogname.c
index 5b563534616b..54e59b6ac412 100644
--- a/lib/libc/gen/getprogname.c
+++ b/lib/libc/gen/getprogname.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdlib.h>
#include "un-namespace.h"
diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3
index 93578dd85ee9..486f0cab2399 100644
--- a/lib/libc/gen/getpwent.3
+++ b/lib/libc/gen/getpwent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93
-.\"
.Dd November 28, 2022
.Dt GETPWENT 3
.Os
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index e3c8098fad0d..1cbf97e7eb52 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#ifdef YP
diff --git a/lib/libc/gen/getttyent.3 b/lib/libc/gen/getttyent.3
index eb1c3d2ef8c5..bf38f417ac58 100644
--- a/lib/libc/gen/getttyent.3
+++ b/lib/libc/gen/getttyent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 17, 1996
.Dt GETTTYENT 3
.Os
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index df19fb18ee81..3c92f603ff06 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)getttyent.c 8.1 (Berkeley) 6/4/93");
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/getusershell.3 b/lib/libc/gen/getusershell.3
index f186d9448163..728e87c9d56a 100644
--- a/lib/libc/gen/getusershell.3
+++ b/lib/libc/gen/getusershell.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getusershell.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd January 16, 1999
.Dt GETUSERSHELL 3
.Os
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index c460cf4d4bd2..26c6e326e94d 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -30,8 +30,8 @@
*/
#include <sys/cdefs.h>
-__SCCSID("@(#)getusershell.c 8.1 (Berkeley) 6/4/93");
__RCSID("$NetBSD: getusershell.c,v 1.17 1999/01/25 01:09:34 lukem Exp $");
+
#include "namespace.h"
#include <sys/param.h>
#include <sys/file.h>
diff --git a/lib/libc/gen/getutxent.c b/lib/libc/gen/getutxent.c
index 94a20592c1bb..d0c307538930 100644
--- a/lib/libc/gen/getutxent.c
+++ b/lib/libc/gen/getutxent.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/endian.h>
#include <sys/param.h>
diff --git a/lib/libc/gen/getvfsbyname.3 b/lib/libc/gen/getvfsbyname.3
index 9365d043a1fc..23036429b27e 100644
--- a/lib/libc/gen/getvfsbyname.3
+++ b/lib/libc/gen/getvfsbyname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_getvfsbyname.3 8.3 (Berkeley) 5/4/95
-.\"
.Dd August 16, 2018
.Dt GETVFSBYNAME 3
.Os
diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c
index 05efe8f8cd5e..18cbf64b9f4a 100644
--- a/lib/libc/gen/getvfsbyname.c
+++ b/lib/libc/gen/getvfsbyname.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95");
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/sysctl.h>
@@ -40,7 +38,7 @@ __SCCSID("@(#)kvm_getvfsbyname.c 8.1 (Berkeley) 4/3/95");
#include <string.h>
/*
- * fusefs(5) file systems may have a "subtype" which gets appended to
+ * fusefs(4) file systems may have a "subtype" which gets appended to
* statfs(2)'s f_fstypename field on a per-mount basis. Allow getvfsbyname to
* match either the full "fusefs.foobar" or the more general "fusefs".
*/
diff --git a/lib/libc/gen/glob-compat11.c b/lib/libc/gen/glob-compat11.c
index 8fb45210b775..cdae52056f61 100644
--- a/lib/libc/gen/glob-compat11.c
+++ b/lib/libc/gen/glob-compat11.c
@@ -33,12 +33,9 @@
* 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.
- *
- * From: @(#)glob.c 8.3 (Berkeley) 10/13/93
* From: FreeBSD: head/lib/libc/gen/glob.c 317913 2017-05-07 19:52:56Z jilles
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#define _WANT_FREEBSD11_STAT
#include <sys/stat.h>
diff --git a/lib/libc/gen/glob-compat11.h b/lib/libc/gen/glob-compat11.h
index 720f3fab36f9..713e1a454b7f 100644
--- a/lib/libc/gen/glob-compat11.h
+++ b/lib/libc/gen/glob-compat11.h
@@ -28,14 +28,11 @@
* 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.
- *
- * @(#)glob.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _GLOB_COMPAT11_H_
#define _GLOB_COMPAT11_H_
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <glob.h>
diff --git a/lib/libc/gen/glob.3 b/lib/libc/gen/glob.3
index ea72558786f0..839d98ce02b5 100644
--- a/lib/libc/gen/glob.3
+++ b/lib/libc/gen/glob.3
@@ -27,13 +27,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)glob.3 8.3 (Berkeley) 4/16/94
-.\"
-.Dd December 20, 2011
+.Dd June 23, 2025
.Dt GLOB 3
.Os
.Sh NAME
.Nm glob ,
+.Nm glob_b ,
.Nm globfree
.Nd generate pathnames matching a pattern
.Sh LIBRARY
@@ -41,7 +40,9 @@
.Sh SYNOPSIS
.In glob.h
.Ft int
-.Fn glob "const char * restrict pattern" "int flags" "int (*errfunc)(const char *, int)" "glob_t * restrict pglob"
+.Fn glob "const char * restrict pattern" "int flags" "int (*errfunc)(const char *epath, int errno)" "glob_t * restrict pglob"
+.Ft int
+.Fn glob_b "const char * restrict pattern" "int flags" "int (^errblk)(const char *epath, int errno)" "glob_t * restrict pglob"
.Ft void
.Fn globfree "glob_t *pglob"
.Sh DESCRIPTION
@@ -274,10 +275,24 @@ is
.Pf non- Dv NULL ,
.Fn glob
calls
-.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) ,
+.Fa \*(lp*errfunc\*(rp Ns ( Fa path , errno ) .
+This may be unintuitive: a pattern like
+.Ql */Makefile
+will try to
+.Xr stat 2
+.Ql foo/Makefile
+even if
+.Ql foo
+is not a directory, resulting in a
+call to
+.Fa errfunc .
+The error routine can suppress this action by testing for
+.Er ENOENT
+and
+.Er ENOTDIR ;
however, the
.Dv GLOB_ERR
-flag will cause an immediate
+flag will still cause an immediate
return when this happens.
.Pp
If
@@ -309,16 +324,27 @@ or
returns zero, the error is ignored.
.Pp
The
+.Fn glob_b
+function is like
+.Fn glob
+except that the error callback is a block pointer instead of a function
+pointer.
+.Pp
+The
.Fn globfree
function frees any space associated with
.Fa pglob
from a previous call(s) to
-.Fn glob .
+.Fn glob
+or
+.Fn glob_b .
.Sh RETURN VALUES
On successful completion,
.Fn glob
-returns zero.
-In addition the fields of
+and
+.Fn glob_b
+return zero.
+In addition, the fields of
.Fa pglob
contain the values described below:
.Bl -tag -width GLOB_NOCHECK
@@ -326,12 +352,16 @@ contain the values described below:
contains the total number of matched pathnames so far.
This includes other matches from previous invocations of
.Fn glob
+or
+.Fn glob_b
if
.Dv GLOB_APPEND
was specified.
.It Fa gl_matchc
contains the number of matched pathnames in the current invocation of
-.Fn glob .
+.Fn glob
+or
+.Fn glob_b .
.It Fa gl_flags
contains a copy of the
.Fa flags
@@ -354,6 +384,8 @@ are undefined.
.Pp
If
.Fn glob
+or
+.Fn glob_b
terminates due to an error, it sets errno and returns one of the
following non-zero constants, which are defined in the include
file
@@ -399,6 +431,14 @@ g.gl_pathv[0] = "ls";
g.gl_pathv[1] = "-l";
execvp("ls", g.gl_pathv);
.Ed
+.Sh CAVEATS
+The
+.Fn glob
+and
+.Fn glob_b
+functions
+will not match filenames that begin with a period
+unless this is specifically requested (e.g., by ".*").
.Sh SEE ALSO
.Xr sh 1 ,
.Xr fnmatch 3 ,
@@ -437,6 +477,10 @@ and
.Fn globfree
functions first appeared in
.Bx 4.4 .
+The
+.Fn glob_b
+function first appeared in
+.Fx 15.0 .
.Sh BUGS
Patterns longer than
.Dv MAXPATHLEN
@@ -444,7 +488,9 @@ may cause unchecked errors.
.Pp
The
.Fn glob
-argument
+and
+.Fn glob_b
+functions
may fail and set errno for any of the errors specified for the
library routines
.Xr stat 2 ,
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
index dbb6389d707e..f7da5f0cda09 100644
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -37,8 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)glob.c 8.3 (Berkeley) 10/13/93");
/*
* glob(3) -- a superset of the one defined in POSIX 1003.2.
*
@@ -90,8 +88,11 @@ __SCCSID("@(#)glob.c 8.3 (Berkeley) 10/13/93");
#include <unistd.h>
#include <wchar.h>
+#include "block_abi.h"
#include "collate.h"
+typedef DECLARE_BLOCK(int, glob_b_block, const char*, int);
+
/*
* glob(3) expansion limits. Stop the expansion if any of these limits
* is reached. This caps the runtime in the face of DoS attacks. See
@@ -106,8 +107,8 @@ __SCCSID("@(#)glob.c 8.3 (Berkeley) 10/13/93");
struct glob_limit {
size_t l_brace_cnt;
size_t l_path_lim;
- size_t l_readdir_cnt;
- size_t l_stat_cnt;
+ size_t l_readdir_cnt;
+ size_t l_stat_cnt;
size_t l_string_cnt;
};
@@ -181,9 +182,8 @@ static int err_aborted(glob_t *, int, char *);
static void qprintf(const char *, Char *);
#endif
-int
-glob(const char * __restrict pattern, int flags,
- int (*errfunc)(const char *, int), glob_t * __restrict pglob)
+static int
+__glob(const char *pattern, glob_t *pglob)
{
struct glob_limit limit = { 0, 0, 0, 0, 0 };
const char *patnext;
@@ -194,25 +194,23 @@ glob(const char * __restrict pattern, int flags,
int too_long;
patnext = pattern;
- if (!(flags & GLOB_APPEND)) {
+ if (!(pglob->gl_flags & GLOB_APPEND)) {
pglob->gl_pathc = 0;
pglob->gl_pathv = NULL;
- if (!(flags & GLOB_DOOFFS))
+ if (!(pglob->gl_flags & GLOB_DOOFFS))
pglob->gl_offs = 0;
}
- if (flags & GLOB_LIMIT) {
+ if (pglob->gl_flags & GLOB_LIMIT) {
limit.l_path_lim = pglob->gl_matchc;
if (limit.l_path_lim == 0)
limit.l_path_lim = GLOB_LIMIT_PATH;
}
- pglob->gl_flags = flags & ~GLOB_MAGCHAR;
- pglob->gl_errfunc = errfunc;
pglob->gl_matchc = 0;
bufnext = patbuf;
bufend = bufnext + MAXPATHLEN - 1;
too_long = 1;
- if (flags & GLOB_NOESCAPE) {
+ if (pglob->gl_flags & GLOB_NOESCAPE) {
memset(&mbs, 0, sizeof(mbs));
while (bufnext <= bufend) {
clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
@@ -252,15 +250,45 @@ glob(const char * __restrict pattern, int flags,
return (err_nomatch(pglob, &limit, pattern));
*bufnext = EOS;
- if (flags & GLOB_BRACE)
+ if (pglob->gl_flags & GLOB_BRACE)
return (globexp0(patbuf, pglob, &limit, pattern));
else
return (glob0(patbuf, pglob, &limit, pattern));
}
+int
+glob(const char * __restrict pattern, int flags,
+ int (*errfunc)(const char *, int), glob_t * __restrict pglob)
+{
+ int rv;
+
+ pglob->gl_flags = flags & ~(GLOB_MAGCHAR | _GLOB_ERR_BLOCK);
+ pglob->gl_errfunc = errfunc;
+ rv = __glob(pattern, pglob);
+ pglob->gl_errfunc = NULL;
+
+ return (rv);
+}
+
+int
+glob_b(const char * __restrict pattern, int flags,
+ glob_b_block block, glob_t * __restrict pglob)
+{
+ int rv;
+
+ pglob->gl_flags = flags & ~GLOB_MAGCHAR;
+ pglob->gl_flags |= _GLOB_ERR_BLOCK;
+ pglob->gl_errblk = block;
+ rv = __glob(pattern, pglob);
+ pglob->gl_errblk = NULL;
+
+ return (rv);
+}
+
static int
globexp0(const Char *pattern, glob_t *pglob, struct glob_limit *limit,
- const char *origpat) {
+ const char *origpat)
+{
int rv;
size_t oldpathc;
@@ -726,7 +754,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
return (GLOB_NOSPACE);
}
*pathend = EOS;
- if (pglob->gl_errfunc != NULL &&
+ if ((pglob->gl_errfunc != NULL || pglob->gl_errblk != NULL) &&
g_Ctoc(pathbuf, buf, sizeof(buf))) {
errno = E2BIG;
return (GLOB_NOSPACE);
@@ -1087,10 +1115,21 @@ err_nomatch(glob_t *pglob, struct glob_limit *limit, const char *origpat) {
}
static int
-err_aborted(glob_t *pglob, int err, char *buf) {
- if ((pglob->gl_errfunc != NULL && pglob->gl_errfunc(buf, err)) ||
- (pglob->gl_flags & GLOB_ERR))
+err_aborted(glob_t *pglob, int err, char *buf)
+{
+ int rv = 0;
+
+ if ((pglob->gl_flags & _GLOB_ERR_BLOCK) != 0) {
+ if (pglob->gl_errblk != NULL)
+ rv = CALL_BLOCK((glob_b_block)pglob->gl_errblk, buf,
+ errno);
+ } else if (pglob->gl_errfunc != NULL) {
+ rv = pglob->gl_errfunc(buf, errno);
+ }
+ /* GLOB_ERR is allowed to override the error callback function. */
+ if (rv != 0 || pglob->gl_flags & GLOB_ERR) {
return (GLOB_ABORTED);
+ }
return (0);
}
diff --git a/lib/libc/gen/initgroups.3 b/lib/libc/gen/initgroups.3
index a44641a63828..03bd07494fc9 100644
--- a/lib/libc/gen/initgroups.3
+++ b/lib/libc/gen/initgroups.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)initgroups.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 26, 2014
.Dt INITGROUPS 3
.Os
diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c
index 6e417d6a62ed..b6697dd7ed8f 100644
--- a/lib/libc/gen/initgroups.c
+++ b/lib/libc/gen/initgroups.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)initgroups.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include "namespace.h"
diff --git a/lib/libc/gen/inotify.c b/lib/libc/gen/inotify.c
new file mode 100644
index 000000000000..7ce53aaccd58
--- /dev/null
+++ b/lib/libc/gen/inotify.c
@@ -0,0 +1,48 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Klara, Inc.
+ */
+
+#include "namespace.h"
+#include <sys/fcntl.h>
+#include <sys/inotify.h>
+#include <sys/specialfd.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+
+/*
+ * Provide compatibility with libinotify, which uses different values for these
+ * flags.
+ */
+#define IN_NONBLOCK_OLD 0x80000
+#define IN_CLOEXEC_OLD 0x00800
+
+int
+inotify_add_watch(int fd, const char *pathname, uint32_t mask)
+{
+ return (inotify_add_watch_at(fd, AT_FDCWD, pathname, mask));
+}
+
+int
+inotify_init1(int flags)
+{
+ struct specialfd_inotify args;
+
+ if ((flags & IN_NONBLOCK_OLD) != 0) {
+ flags &= ~IN_NONBLOCK_OLD;
+ flags |= IN_NONBLOCK;
+ }
+ if ((flags & IN_CLOEXEC_OLD) != 0) {
+ flags &= ~IN_CLOEXEC_OLD;
+ flags |= IN_CLOEXEC;
+ }
+ args.flags = flags;
+ return (__sys___specialfd(SPECIALFD_INOTIFY, &args, sizeof(args)));
+}
+
+int
+inotify_init(void)
+{
+ return (inotify_init1(0));
+}
diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c
index 60e94e0ba524..8844f3121538 100644
--- a/lib/libc/gen/isatty.c
+++ b/lib/libc/gen/isatty.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)isatty.c 8.1 (Berkeley) 6/4/93");
#include <termios.h>
#include <unistd.h>
diff --git a/lib/libc/gen/jrand48.c b/lib/libc/gen/jrand48.c
index 5fdd1778c340..0a9f780a9e5c 100644
--- a/lib/libc/gen/jrand48.c
+++ b/lib/libc/gen/jrand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include <stdint.h>
#include "rand48.h"
diff --git a/lib/libc/gen/lcong48.c b/lib/libc/gen/lcong48.c
index b77278db1750..f13826b3d3f3 100644
--- a/lib/libc/gen/lcong48.c
+++ b/lib/libc/gen/lcong48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
extern unsigned short _rand48_seed[3];
diff --git a/lib/libc/gen/ldexp.3 b/lib/libc/gen/ldexp.3
index 5158911fa99c..d89dea2d16c7 100644
--- a/lib/libc/gen/ldexp.3
+++ b/lib/libc/gen/ldexp.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ldexp.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd March 4, 2005
.Dt LDEXP 3
.Os
diff --git a/lib/libc/gen/ldexp.c b/lib/libc/gen/ldexp.c
index 5055add84ff3..1db62afc609e 100644
--- a/lib/libc/gen/ldexp.c
+++ b/lib/libc/gen/ldexp.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
/*
* ldexp() and scalbn() are defined to be identical, but ldexp() lives in libc
* for backwards compatibility.
diff --git a/lib/libc/gen/libc_dlopen.c b/lib/libc/gen/libc_dlopen.c
index bc7e13ca0043..4e5ec2961ac2 100644
--- a/lib/libc/gen/libc_dlopen.c
+++ b/lib/libc/gen/libc_dlopen.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <dlfcn.h>
#include <stddef.h>
#include <unistd.h>
diff --git a/lib/libc/gen/libc_interposing_table.c b/lib/libc/gen/libc_interposing_table.c
new file mode 100644
index 000000000000..025a67ac3eac
--- /dev/null
+++ b/lib/libc/gen/libc_interposing_table.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <stddef.h>
+#include "libc_private.h"
+
+#define SLOT(a, b) \
+ [INTERPOS_##a] = (interpos_func_t)b
+interpos_func_t __libc_interposing[INTERPOS_MAX] = {
+ SLOT(system, __libc_system),
+ SLOT(tcdrain, __libc_tcdrain),
+ SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub),
+ SLOT(spinlock, __libc_spinlock_stub),
+ SLOT(spinunlock, __libc_spinunlock_stub),
+ SLOT(map_stacks_exec, __libc_map_stacks_exec),
+ SLOT(uexterr_gettext, __libc_uexterr_gettext),
+};
+#undef SLOT
+
+interpos_func_t *
+__libc_interposing_slot(int interposno)
+{
+ if (__libc_interposing[interposno] == NULL)
+ return (__libsys_interposing_slot(interposno));
+ return (&__libc_interposing[interposno]);
+}
diff --git a/lib/libc/gen/lockf.c b/lib/libc/gen/lockf.c
deleted file mode 100644
index 247066706a2b..000000000000
--- a/lib/libc/gen/lockf.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* $NetBSD: lockf.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Klaus Klein.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "un-namespace.h"
-#include "libc_private.h"
-
-int
-lockf(int filedes, int function, off_t size)
-{
- struct flock fl;
- int cmd;
-
- fl.l_start = 0;
- fl.l_len = size;
- fl.l_whence = SEEK_CUR;
-
- switch (function) {
- case F_ULOCK:
- cmd = F_SETLK;
- fl.l_type = F_UNLCK;
- break;
- case F_LOCK:
- cmd = F_SETLKW;
- fl.l_type = F_WRLCK;
- break;
- case F_TLOCK:
- cmd = F_SETLK;
- fl.l_type = F_WRLCK;
- break;
- case F_TEST:
- fl.l_type = F_WRLCK;
- if (((int (*)(int, int, ...))
- __libc_interposing[INTERPOS_fcntl])(filedes, F_GETLK, &fl)
- == -1)
- return (-1);
- if (fl.l_type == F_UNLCK || (fl.l_sysid == 0 &&
- fl.l_pid == getpid()))
- return (0);
- errno = EAGAIN;
- return (-1);
- /* NOTREACHED */
- default:
- errno = EINVAL;
- return (-1);
- /* NOTREACHED */
- }
-
- return (((int (*)(int, int, ...))
- __libc_interposing[INTERPOS_fcntl])(filedes, cmd, &fl));
-}
diff --git a/lib/libc/gen/lrand48.c b/lib/libc/gen/lrand48.c
index d7257febe717..a3d0111cf4d5 100644
--- a/lib/libc/gen/lrand48.c
+++ b/lib/libc/gen/lrand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
extern unsigned short _rand48_seed[3];
diff --git a/lib/libc/gen/makecontext.3 b/lib/libc/gen/makecontext.3
index bcf836979962..198c541d40a6 100644
--- a/lib/libc/gen/makecontext.3
+++ b/lib/libc/gen/makecontext.3
@@ -152,6 +152,7 @@ via
.Fn makecontext ;
portable applications should not rely on the implementation detail that
it may be possible to pass pointer arguments to functions.
+.Ef
.Sh HISTORY
The
.Fn makecontext
diff --git a/lib/libc/gen/memalign.c b/lib/libc/gen/memalign.c
index af64c998dbd4..269a5bc829b1 100644
--- a/lib/libc/gen/memalign.c
+++ b/lib/libc/gen/memalign.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdlib.h>
diff --git a/lib/libc/gen/memfd_create.c b/lib/libc/gen/memfd_create.c
new file mode 100644
index 000000000000..78131f46d7b1
--- /dev/null
+++ b/lib/libc/gen/memfd_create.c
@@ -0,0 +1,121 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/filio.h>
+#include <sys/mman.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libc_private.h"
+
+#define MEMFD_NAME_PREFIX "memfd:"
+
+/*
+ * The path argument is passed to the kernel, but the kernel doesn't currently
+ * do anything with it. Linux exposes it in linprocfs for debugging purposes
+ * only, but our kernel currently will not do the same.
+ */
+int
+memfd_create(const char *name, unsigned int flags)
+{
+ char memfd_name[NAME_MAX + 1];
+ size_t pgs[MAXPAGESIZES];
+ size_t namelen, pgsize;
+ struct shm_largepage_conf slc;
+ int error, fd, npgs, oflags, pgidx, saved_errno, shmflags;
+
+ if (name == NULL) {
+ errno = EBADF;
+ return (-1);
+ }
+ namelen = strlen(name);
+ if (namelen + sizeof(MEMFD_NAME_PREFIX) - 1 > NAME_MAX) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if ((flags & ~(MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB |
+ MFD_HUGE_MASK)) != 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+ /* Size specified but no HUGETLB. */
+ if ((flags & MFD_HUGE_MASK) != 0 && (flags & MFD_HUGETLB) == 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ /* We've already validated that we're sufficiently sized. */
+ snprintf(memfd_name, NAME_MAX + 1, "%s%s", MEMFD_NAME_PREFIX, name);
+ oflags = O_RDWR;
+ shmflags = 0;
+ if ((flags & MFD_CLOEXEC) != 0)
+ oflags |= O_CLOEXEC;
+ if ((flags & MFD_ALLOW_SEALING) != 0)
+ shmflags |= SHM_ALLOW_SEALING;
+ if ((flags & MFD_HUGETLB) != 0)
+ shmflags |= SHM_LARGEPAGE;
+ else
+ shmflags |= SHM_GROW_ON_WRITE;
+ fd = __sys_shm_open2(SHM_ANON, oflags, 0, shmflags, memfd_name);
+ if (fd == -1 || (flags & MFD_HUGETLB) == 0)
+ return (fd);
+
+ npgs = getpagesizes(pgs, nitems(pgs));
+ if (npgs == -1)
+ goto clean;
+ pgsize = (size_t)1 << ((flags & MFD_HUGE_MASK) >> MFD_HUGE_SHIFT);
+ for (pgidx = 0; pgidx < npgs; pgidx++) {
+ if (pgsize == pgs[pgidx])
+ break;
+ }
+ if (pgidx == npgs) {
+ errno = EOPNOTSUPP;
+ goto clean;
+ }
+
+ memset(&slc, 0, sizeof(slc));
+ slc.psind = pgidx;
+ slc.alloc_policy = SHM_LARGEPAGE_ALLOC_DEFAULT;
+ error = ioctl(fd, FIOSSHMLPGCNF, &slc);
+ if (error == -1)
+ goto clean;
+ return (fd);
+
+clean:
+ saved_errno = errno;
+ close(fd);
+ errno = saved_errno;
+ return (-1);
+}
diff --git a/lib/libc/gen/modf.3 b/lib/libc/gen/modf.3
index 6d6ff16e236c..9d698ff62ce6 100644
--- a/lib/libc/gen/modf.3
+++ b/lib/libc/gen/modf.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)modf.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 29, 2008
.Dt MODF 3
.Os
diff --git a/lib/libc/gen/modf.c b/lib/libc/gen/modf.c
index 6853a56d051d..b4093d6e930c 100644
--- a/lib/libc/gen/modf.c
+++ b/lib/libc/gen/modf.c
@@ -1,4 +1,3 @@
-/* @(#)s_modf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* modf(double x, double *iptr)
* return fraction part of x, and return x's integral part in *iptr.
diff --git a/lib/libc/gen/mrand48.c b/lib/libc/gen/mrand48.c
index 6ee078e95c81..15b0bfb1bd6e 100644
--- a/lib/libc/gen/mrand48.c
+++ b/lib/libc/gen/mrand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include <stdint.h>
#include "rand48.h"
diff --git a/lib/libc/gen/nftw-compat11.c b/lib/libc/gen/nftw-compat11.c
index fdd5c9a707a4..36970424bf2a 100644
--- a/lib/libc/gen/nftw-compat11.c
+++ b/lib/libc/gen/nftw-compat11.c
@@ -21,7 +21,6 @@
* From: FreeBSD: head/lib/libc/gen/nftw.c 239160 2012-08-09 22:05:40Z jilles
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c
index 9b5c33e1057c..95cc9947b7c1 100644
--- a/lib/libc/gen/nftw.c
+++ b/lib/libc/gen/nftw.c
@@ -20,7 +20,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3
index ff82610c34ec..011b4c33effc 100644
--- a/lib/libc/gen/nice.3
+++ b/lib/libc/gen/nice.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)nice.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd February 28, 2015
.Dt NICE 3
.Os
diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c
index b71076efdcde..a96d4d06e081 100644
--- a/lib/libc/gen/nice.c
+++ b/lib/libc/gen/nice.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)nice.c 8.1 (Berkeley) 6/4/93");
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/lib/libc/gen/nlist.3 b/lib/libc/gen/nlist.3
index ef5b8d95282e..f4ef59083dab 100644
--- a/lib/libc/gen/nlist.3
+++ b/lib/libc/gen/nlist.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)nlist.3 8.3 (Berkeley) 4/19/94
-.\"
.Dd April 19, 1994
.Dt NLIST 3
.Os
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index 0e00d8d23f99..ebf4ae92641a 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)nlist.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <sys/param.h>
#include <sys/mman.h>
diff --git a/lib/libc/gen/nrand48.c b/lib/libc/gen/nrand48.c
index 12016ed76ec9..6c54065e7e0f 100644
--- a/lib/libc/gen/nrand48.c
+++ b/lib/libc/gen/nrand48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
long
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c
index a3864b0939fc..08d9eb10eaa2 100644
--- a/lib/libc/gen/opendir.c
+++ b/lib/libc/gen/opendir.c
@@ -29,24 +29,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)opendir.c 8.8 (Berkeley) 5/1/95");
#include "namespace.h"
-#include <sys/param.h>
-
#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include "un-namespace.h"
#include "gen-private.h"
#include "telldir.h"
-static DIR * __opendir_common(int, int, bool);
-
/*
* Open a directory.
*/
@@ -54,313 +43,5 @@ DIR *
opendir(const char *name)
{
- return (__opendir2(name, DTF_HIDEW|DTF_NODUP));
-}
-
-/*
- * Open a directory with existing file descriptor.
- */
-DIR *
-fdopendir(int fd)
-{
-
- if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
- return (NULL);
- return (__opendir_common(fd, DTF_HIDEW|DTF_NODUP, true));
-}
-
-DIR *
-__opendir2(const char *name, int flags)
-{
- int fd;
- DIR *dir;
- int saved_errno;
-
- if ((flags & (__DTF_READALL | __DTF_SKIPREAD)) != 0)
- return (NULL);
- if ((fd = _open(name,
- O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC)) == -1)
- return (NULL);
-
- dir = __opendir_common(fd, flags, false);
- if (dir == NULL) {
- saved_errno = errno;
- _close(fd);
- errno = saved_errno;
- }
- return (dir);
-}
-
-static int
-opendir_compar(const void *p1, const void *p2)
-{
-
- return (strcmp((*(const struct dirent * const *)p1)->d_name,
- (*(const struct dirent * const *)p2)->d_name));
-}
-
-/*
- * For a directory at the top of a unionfs stack, the entire directory's
- * contents are read and cached locally until the next call to rewinddir().
- * For the fdopendir() case, the initial seek position must be preserved.
- * For rewinddir(), the full directory should always be re-read from the
- * beginning.
- *
- * If an error occurs, the existing buffer and state of 'dirp' is left
- * unchanged.
- */
-bool
-_filldir(DIR *dirp, bool use_current_pos)
-{
- struct dirent **dpv;
- char *buf, *ddptr, *ddeptr;
- off_t pos;
- int fd2, incr, len, n, saved_errno, space;
-
- len = 0;
- space = 0;
- buf = NULL;
- ddptr = NULL;
-
- /*
- * Use the system page size if that is a multiple of DIRBLKSIZ.
- * Hopefully this can be a big win someday by allowing page
- * trades to user space to be done by _getdirentries().
- */
- incr = getpagesize();
- if ((incr % DIRBLKSIZ) != 0)
- incr = DIRBLKSIZ;
-
- /*
- * The strategy here is to read all the directory
- * entries into a buffer, sort the buffer, and
- * remove duplicate entries by setting the inode
- * number to zero.
- *
- * We reopen the directory because _getdirentries()
- * on a MNT_UNION mount modifies the open directory,
- * making it refer to the lower directory after the
- * upper directory's entries are exhausted.
- * This would otherwise break software that uses
- * the directory descriptor for fchdir or *at
- * functions, such as fts.c.
- */
- if ((fd2 = _openat(dirp->dd_fd, ".", O_RDONLY | O_CLOEXEC)) == -1)
- return (false);
-
- if (use_current_pos) {
- pos = lseek(dirp->dd_fd, 0, SEEK_CUR);
- if (pos == -1 || lseek(fd2, pos, SEEK_SET) == -1) {
- saved_errno = errno;
- _close(fd2);
- errno = saved_errno;
- return (false);
- }
- }
-
- do {
- /*
- * Always make at least DIRBLKSIZ bytes
- * available to _getdirentries
- */
- if (space < DIRBLKSIZ) {
- space += incr;
- len += incr;
- buf = reallocf(buf, len);
- if (buf == NULL) {
- saved_errno = errno;
- _close(fd2);
- errno = saved_errno;
- return (false);
- }
- ddptr = buf + (len - space);
- }
-
- n = _getdirentries(fd2, ddptr, space, &dirp->dd_seek);
- if (n > 0) {
- ddptr += n;
- space -= n;
- }
- if (n < 0) {
- saved_errno = errno;
- _close(fd2);
- errno = saved_errno;
- return (false);
- }
- } while (n > 0);
- _close(fd2);
-
- ddeptr = ddptr;
-
- /*
- * There is now a buffer full of (possibly) duplicate
- * names.
- */
- dirp->dd_buf = buf;
-
- /*
- * Go round this loop twice...
- *
- * Scan through the buffer, counting entries.
- * On the second pass, save pointers to each one.
- * Then sort the pointers and remove duplicate names.
- */
- for (dpv = NULL;;) {
- n = 0;
- ddptr = buf;
- while (ddptr < ddeptr) {
- struct dirent *dp;
-
- dp = (struct dirent *) ddptr;
- if ((long)dp & 03L)
- break;
- if ((dp->d_reclen <= 0) ||
- (dp->d_reclen > (ddeptr + 1 - ddptr)))
- break;
- ddptr += dp->d_reclen;
- if (dp->d_fileno) {
- if (dpv)
- dpv[n] = dp;
- n++;
- }
- }
-
- if (dpv) {
- struct dirent *xp;
-
- /*
- * This sort must be stable.
- */
- mergesort(dpv, n, sizeof(*dpv), opendir_compar);
-
- dpv[n] = NULL;
- xp = NULL;
-
- /*
- * Scan through the buffer in sort order,
- * zapping the inode number of any
- * duplicate names.
- */
- for (n = 0; dpv[n]; n++) {
- struct dirent *dp = dpv[n];
-
- if ((xp == NULL) ||
- strcmp(dp->d_name, xp->d_name)) {
- xp = dp;
- } else {
- dp->d_fileno = 0;
- }
- if (dp->d_type == DT_WHT &&
- (dirp->dd_flags & DTF_HIDEW))
- dp->d_fileno = 0;
- }
-
- free(dpv);
- break;
- } else {
- dpv = malloc((n+1) * sizeof(struct dirent *));
- if (dpv == NULL)
- break;
- }
- }
-
- dirp->dd_len = len;
- dirp->dd_size = ddptr - dirp->dd_buf;
- return (true);
-}
-
-static bool
-is_unionstack(int fd)
-{
- int unionstack;
-
- unionstack = _fcntl(fd, F_ISUNIONSTACK, 0);
- if (unionstack != -1)
- return (unionstack);
-
- /*
- * Should not happen unless running on a kernel without the op,
- * but no use rendering the system useless in such a case.
- */
- return (0);
-}
-
-/*
- * Common routine for opendir(3), __opendir2(3) and fdopendir(3).
- */
-static DIR *
-__opendir_common(int fd, int flags, bool use_current_pos)
-{
- DIR *dirp;
- int incr;
- int saved_errno;
- bool unionstack;
-
- if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
- return (NULL);
-
- dirp->dd_buf = NULL;
- dirp->dd_fd = fd;
- dirp->dd_flags = flags;
- dirp->dd_loc = 0;
- dirp->dd_lock = NULL;
- dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR));
- LIST_INIT(&dirp->dd_td->td_locq);
- dirp->dd_td->td_loccnt = 0;
- dirp->dd_compat_de = NULL;
-
- /*
- * Use the system page size if that is a multiple of DIRBLKSIZ.
- * Hopefully this can be a big win someday by allowing page
- * trades to user space to be done by _getdirentries().
- */
- incr = getpagesize();
- if ((incr % DIRBLKSIZ) != 0)
- incr = DIRBLKSIZ;
-
- /*
- * Determine whether this directory is the top of a union stack.
- */
- unionstack = false;
- if (flags & DTF_NODUP) {
- unionstack = is_unionstack(fd);
- }
-
- if (unionstack) {
- if (!_filldir(dirp, use_current_pos))
- goto fail;
- dirp->dd_flags |= __DTF_READALL;
- } else {
- dirp->dd_len = incr;
- dirp->dd_buf = malloc(dirp->dd_len);
- if (dirp->dd_buf == NULL)
- goto fail;
- if (use_current_pos) {
- /*
- * Read the first batch of directory entries
- * to prime dd_seek. This also checks if the
- * fd passed to fdopendir() is a directory.
- */
- dirp->dd_size = _getdirentries(dirp->dd_fd,
- dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
- if (dirp->dd_size < 0) {
- if (errno == EINVAL)
- errno = ENOTDIR;
- goto fail;
- }
- dirp->dd_flags |= __DTF_SKIPREAD;
- } else {
- dirp->dd_size = 0;
- dirp->dd_seek = 0;
- }
- }
-
- return (dirp);
-
-fail:
- saved_errno = errno;
- free(dirp->dd_buf);
- free(dirp);
- errno = saved_errno;
- return (NULL);
+ return (__opendir2(name, DTF_HIDEW | DTF_NODUP));
}
diff --git a/lib/libc/gen/opendir2.c b/lib/libc/gen/opendir2.c
new file mode 100644
index 000000000000..c5c2e662efd8
--- /dev/null
+++ b/lib/libc/gen/opendir2.c
@@ -0,0 +1,337 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1983, 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.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+
+#include "gen-private.h"
+#include "telldir.h"
+
+DIR *
+__opendir2(const char *name, int flags)
+{
+ int fd;
+ DIR *dir;
+ int saved_errno;
+
+ if ((flags & (__DTF_READALL | __DTF_SKIPREAD)) != 0)
+ return (NULL);
+ if ((fd = _open(name, O_DIRECTORY | O_RDONLY | O_CLOEXEC)) == -1)
+ return (NULL);
+
+ dir = __opendir_common(fd, flags, false);
+ if (dir == NULL) {
+ saved_errno = errno;
+ _close(fd);
+ errno = saved_errno;
+ }
+ return (dir);
+}
+
+static int
+opendir_compar(const void *p1, const void *p2)
+{
+
+ return (strcmp((*(const struct dirent * const *)p1)->d_name,
+ (*(const struct dirent * const *)p2)->d_name));
+}
+
+/*
+ * For a directory at the top of a unionfs stack, the entire directory's
+ * contents are read and cached locally until the next call to rewinddir().
+ * For the fdopendir() case, the initial seek position must be preserved.
+ * For rewinddir(), the full directory should always be re-read from the
+ * beginning.
+ *
+ * If an error occurs, the existing buffer and state of 'dirp' is left
+ * unchanged.
+ */
+bool
+_filldir(DIR *dirp, bool use_current_pos)
+{
+ struct dirent **dpv;
+ char *buf, *ddptr, *ddeptr;
+ off_t pos;
+ int fd2, incr, len, n, saved_errno, space;
+
+ len = 0;
+ space = 0;
+ buf = NULL;
+ ddptr = NULL;
+
+ /*
+ * Use the system page size if that is a multiple of DIRBLKSIZ.
+ * Hopefully this can be a big win someday by allowing page
+ * trades to user space to be done by _getdirentries().
+ */
+ incr = getpagesize();
+ if ((incr % DIRBLKSIZ) != 0)
+ incr = DIRBLKSIZ;
+
+ /*
+ * The strategy here is to read all the directory
+ * entries into a buffer, sort the buffer, and
+ * remove duplicate entries by setting the inode
+ * number to zero.
+ *
+ * We reopen the directory because _getdirentries()
+ * on a MNT_UNION mount modifies the open directory,
+ * making it refer to the lower directory after the
+ * upper directory's entries are exhausted.
+ * This would otherwise break software that uses
+ * the directory descriptor for fchdir or *at
+ * functions, such as fts.c.
+ */
+ if ((fd2 = _openat(dirp->dd_fd, ".", O_RDONLY | O_CLOEXEC)) == -1)
+ return (false);
+
+ if (use_current_pos) {
+ pos = lseek(dirp->dd_fd, 0, SEEK_CUR);
+ if (pos == -1 || lseek(fd2, pos, SEEK_SET) == -1) {
+ saved_errno = errno;
+ _close(fd2);
+ errno = saved_errno;
+ return (false);
+ }
+ }
+
+ do {
+ /*
+ * Always make at least DIRBLKSIZ bytes
+ * available to _getdirentries
+ */
+ if (space < DIRBLKSIZ) {
+ space += incr;
+ len += incr;
+ buf = reallocf(buf, len);
+ if (buf == NULL) {
+ saved_errno = errno;
+ _close(fd2);
+ errno = saved_errno;
+ return (false);
+ }
+ ddptr = buf + (len - space);
+ }
+
+ n = _getdirentries(fd2, ddptr, space, &dirp->dd_seek);
+ if (n > 0) {
+ ddptr += n;
+ space -= n;
+ }
+ if (n < 0) {
+ saved_errno = errno;
+ _close(fd2);
+ errno = saved_errno;
+ return (false);
+ }
+ } while (n > 0);
+ _close(fd2);
+
+ ddeptr = ddptr;
+
+ /*
+ * There is now a buffer full of (possibly) duplicate
+ * names.
+ */
+ dirp->dd_buf = buf;
+
+ /*
+ * Go round this loop twice...
+ *
+ * Scan through the buffer, counting entries.
+ * On the second pass, save pointers to each one.
+ * Then sort the pointers and remove duplicate names.
+ */
+ for (dpv = NULL;;) {
+ n = 0;
+ ddptr = buf;
+ while (ddptr < ddeptr) {
+ struct dirent *dp;
+
+ dp = (struct dirent *) ddptr;
+ if ((long)dp & 03L)
+ break;
+ if ((dp->d_reclen <= 0) ||
+ (dp->d_reclen > (ddeptr + 1 - ddptr)))
+ break;
+ ddptr += dp->d_reclen;
+ if (dp->d_fileno) {
+ if (dpv)
+ dpv[n] = dp;
+ n++;
+ }
+ }
+
+ if (dpv) {
+ struct dirent *xp;
+
+ /*
+ * This sort must be stable.
+ */
+ mergesort(dpv, n, sizeof(*dpv), opendir_compar);
+
+ dpv[n] = NULL;
+ xp = NULL;
+
+ /*
+ * Scan through the buffer in sort order,
+ * zapping the inode number of any
+ * duplicate names.
+ */
+ for (n = 0; dpv[n]; n++) {
+ struct dirent *dp = dpv[n];
+
+ if ((xp == NULL) ||
+ strcmp(dp->d_name, xp->d_name)) {
+ xp = dp;
+ } else {
+ dp->d_fileno = 0;
+ }
+ if (dp->d_type == DT_WHT &&
+ (dirp->dd_flags & DTF_HIDEW))
+ dp->d_fileno = 0;
+ }
+
+ free(dpv);
+ break;
+ } else {
+ dpv = malloc((n+1) * sizeof(struct dirent *));
+ if (dpv == NULL)
+ break;
+ }
+ }
+
+ dirp->dd_len = len;
+ dirp->dd_size = ddptr - dirp->dd_buf;
+ return (true);
+}
+
+/*
+ * Return true if the file descriptor is associated with a file from a
+ * union file system or from a file system mounted with the union flag.
+ */
+static bool
+is_unionstack(int fd)
+{
+ /*
+ * This call shouldn't fail, but if it does, just assume that the
+ * answer is no.
+ */
+ return (_fcntl(fd, F_ISUNIONSTACK, 0) > 0);
+}
+
+/*
+ * Common routine for opendir(3), __opendir2(3) and fdopendir(3).
+ */
+DIR *
+__opendir_common(int fd, int flags, bool use_current_pos)
+{
+ DIR *dirp;
+ ssize_t ret;
+ int incr;
+ int saved_errno;
+ bool unionstack;
+
+ if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
+ return (NULL);
+
+ dirp->dd_buf = NULL;
+ dirp->dd_fd = fd;
+ dirp->dd_flags = flags;
+ dirp->dd_loc = 0;
+ dirp->dd_lock = NULL;
+ dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR));
+ LIST_INIT(&dirp->dd_td->td_locq);
+ dirp->dd_td->td_loccnt = 0;
+ dirp->dd_compat_de = NULL;
+
+ /*
+ * Use the system page size if that is a multiple of DIRBLKSIZ.
+ * Hopefully this can be a big win someday by allowing page
+ * trades to user space to be done by _getdirentries().
+ */
+ incr = getpagesize();
+ if ((incr % DIRBLKSIZ) != 0)
+ incr = DIRBLKSIZ;
+
+ /*
+ * Determine whether this directory is the top of a union stack.
+ */
+ unionstack = false;
+ if (flags & DTF_NODUP) {
+ unionstack = is_unionstack(fd);
+ }
+
+ if (unionstack) {
+ if (!_filldir(dirp, use_current_pos))
+ goto fail;
+ dirp->dd_flags |= __DTF_READALL;
+ } else {
+ dirp->dd_len = incr;
+ dirp->dd_buf = malloc(dirp->dd_len);
+ if (dirp->dd_buf == NULL)
+ goto fail;
+ if (use_current_pos) {
+ /*
+ * Read the first batch of directory entries
+ * to prime dd_seek. This also checks if the
+ * fd passed to fdopendir() is a directory.
+ */
+ ret = _getdirentries(dirp->dd_fd,
+ dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
+ if (ret < 0)
+ goto fail;
+ dirp->dd_size = (size_t)ret;
+ dirp->dd_flags |= __DTF_SKIPREAD;
+ } else {
+ dirp->dd_size = 0;
+ dirp->dd_seek = 0;
+ }
+ }
+
+ return (dirp);
+
+fail:
+ saved_errno = errno;
+ free(dirp->dd_buf);
+ free(dirp);
+ errno = saved_errno;
+ return (NULL);
+}
diff --git a/lib/libc/gen/pause.3 b/lib/libc/gen/pause.3
index 79d2b7455738..6b17ae10777d 100644
--- a/lib/libc/gen/pause.3
+++ b/lib/libc/gen/pause.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pause.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt PAUSE 3
.Os
diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c
index ce255dbba6b2..38aed9da7439 100644
--- a/lib/libc/gen/pause.c
+++ b/lib/libc/gen/pause.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)pause.c 8.1 (Berkeley) 6/4/93");
#include <signal.h>
#include <unistd.h>
diff --git a/lib/libc/gen/pmadvise.c b/lib/libc/gen/pmadvise.c
index ac4f858d09c9..19525c939c26 100644
--- a/lib/libc/gen/pmadvise.c
+++ b/lib/libc/gen/pmadvise.c
@@ -4,7 +4,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/mman.h>
#include <errno.h>
diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3
index 4fdff3172db4..bae37eed14cf 100644
--- a/lib/libc/gen/popen.3
+++ b/lib/libc/gen/popen.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
-.\"
.Dd May 20, 2013
.Dt POPEN 3
.Os
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c
index 1531ca462c24..db6b91d08af6 100644
--- a/lib/libc/gen/popen.c
+++ b/lib/libc/gen/popen.c
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)popen.c 8.3 (Berkeley) 5/3/95");
#include "namespace.h"
#include <sys/param.h>
#include <sys/queue.h>
diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3
index a9ff7b2b21da..278fee88463a 100644
--- a/lib/libc/gen/posix_spawn.3
+++ b/lib/libc/gen/posix_spawn.3
@@ -32,7 +32,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.Dd November 28, 2021
+.Dd March 4, 2024
.Dt POSIX_SPAWN 3
.Os
.Sh NAME
@@ -297,6 +297,15 @@ and the signals being indicated in the spawn-sigdefault attribute
of the object referenced by
.Fa attrp .
.Pp
+The Address Space Layout Randomization for the newly spawned process
+can be disabled by specifying the
+.Dv POSIX_SPAWN_DISABLE_ASLR_NP
+flag in the spawn-flags attribute.
+This setting is inherited by future children of the child as well.
+See
+.Xr procctl 2
+for more details.
+.Pp
If the value of the
.Fa attrp
pointer is NULL, then the default values are used.
@@ -432,16 +441,17 @@ action.
.Xr execve 2 ,
.Xr fcntl 2 ,
.Xr open 2 ,
+.Xr procctl 2 ,
.Xr sched_setparam 2 ,
.Xr sched_setscheduler 2 ,
.Xr setpgid 2 ,
.Xr vfork 2 ,
+.Xr posix_spawn_file_actions_addchdir_np 3 ,
.Xr posix_spawn_file_actions_addclose 3 ,
.Xr posix_spawn_file_actions_addclosefrom_np 3 ,
.Xr posix_spawn_file_actions_adddup2 3 ,
-.Xr posix_spawn_file_actions_addopen 3 ,
-.Xr posix_spawn_file_actions_addchdir_np 3 ,
.Xr posix_spawn_file_actions_addfchdir_np 3 ,
+.Xr posix_spawn_file_actions_addopen 3 ,
.Xr posix_spawn_file_actions_destroy 3 ,
.Xr posix_spawn_file_actions_init 3 ,
.Xr posix_spawnattr_destroy 3 ,
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
index 77f7dd9955cd..a5b732696b8c 100644
--- a/lib/libc/gen/posix_spawn.c
+++ b/lib/libc/gen/posix_spawn.c
@@ -26,9 +26,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
+#include <sys/procctl.h>
#include <sys/queue.h>
#include <sys/wait.h>
@@ -92,7 +92,7 @@ static int
process_spawnattr(const posix_spawnattr_t sa)
{
struct sigaction sigact = { .sa_flags = 0, .sa_handler = SIG_DFL };
- int i;
+ int aslr, i;
/*
* POSIX doesn't really describe in which order everything
@@ -140,6 +140,13 @@ process_spawnattr(const posix_spawnattr_t sa)
}
}
+ /* Disable ASLR. */
+ if ((sa->sa_flags & POSIX_SPAWN_DISABLE_ASLR_NP) != 0) {
+ aslr = PROC_ASLR_FORCE_DISABLE;
+ if (procctl(P_PID, 0, PROC_ASLR_CTL, &aslr) != 0)
+ return (errno);
+ }
+
return (0);
}
@@ -227,7 +234,7 @@ struct posix_spawn_args {
#if defined(__i386__) || defined(__amd64__)
/*
* Below we'll assume that _RFORK_THREAD_STACK_SIZE is appropriately aligned for
- * the posix_spawn() case where we do not end up calling _execvpe and won't ever
+ * the posix_spawn() case where we do not end up calling execvpe and won't ever
* try to allocate space on the stack for argv[].
*/
#define _RFORK_THREAD_STACK_SIZE 4096
@@ -254,7 +261,7 @@ _posix_spawn_thr(void *data)
}
envp = psa->envp != NULL ? psa->envp : environ;
if (psa->use_env_path)
- _execvpe(psa->path, psa->argv, envp);
+ __libc_execvpe(psa->path, psa->argv, envp);
else
_execve(psa->path, psa->argv, envp);
psa->error = errno;
@@ -318,11 +325,16 @@ do_posix_spawn(pid_t *pid, const char *path,
* ideal vfork(2) if we get an EINVAL from rfork -- this should only
* happen with newer libc on older kernel that doesn't accept
* RFSPAWN.
+ *
+ * Combination of vfork() (or its equivalent rfork() form) and
+ * a special property of the libthr rtld locks ensure that
+ * rtld is operational in the child. In particular, libthr
+ * rtld locks do not store owner' tid into the lock word.
*/
#ifdef _RFORK_THREAD_STACK_SIZE
/*
* x86 stores the return address on the stack, so rfork(2) cannot work
- * as-is because the child would clobber the return address om the
+ * as-is because the child would clobber the return address of the
* parent. Because of this, we must use rfork_thread instead while
* almost every other arch stores the return address in a register.
*/
@@ -630,6 +642,11 @@ posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict sa,
int
posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags)
{
+ if ((flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP |
+ POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER |
+ POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK |
+ POSIX_SPAWN_DISABLE_ASLR_NP)) != 0)
+ return (EINVAL);
(*sa)->sa_flags = flags;
return (0);
}
diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3
index ef6348daa4ba..80bc91454471 100644
--- a/lib/libc/gen/posix_spawn_file_actions_addopen.3
+++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3
@@ -270,6 +270,6 @@ The
and
.Fn posix_spawn_file_actions_addclosefrom_np
functions first appeared in
-.Fx 14.0 .
+.Fx 13.1 .
.Sh AUTHORS
.An \&Ed Schouten Aq Mt ed@FreeBSD.org
diff --git a/lib/libc/gen/posix_spawnattr_getflags.3 b/lib/libc/gen/posix_spawnattr_getflags.3
index 9a468cbb8b0f..308bbb386d76 100644
--- a/lib/libc/gen/posix_spawnattr_getflags.3
+++ b/lib/libc/gen/posix_spawnattr_getflags.3
@@ -32,7 +32,7 @@
.\" the referee document. The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
-.Dd March 24, 2008
+.Dd March 4, 2024
.Dt POSIX_SPAWNATTR_GETFLAGS 3
.Os
.Sh NAME
@@ -75,6 +75,7 @@ It is the bitwise-inclusive OR of zero or more of the following flags
.It Dv POSIX_SPAWN_SETSIGMASK
.It Dv POSIX_SPAWN_SETSCHEDPARAM
.It Dv POSIX_SPAWN_SETSCHEDULER
+.It Dv POSIX_SPAWN_DISABLE_ASLR_NP
.El
.Pp
These flags are defined in
@@ -83,9 +84,12 @@ The default value of this attribute is as if no flags were set.
.Sh RETURN VALUES
The
.Fn posix_spawnattr_getflags
-and
+function returns zero.
+The
.Fn posix_spawnattr_setflags
-functions return zero.
+function returns zero on success, and
+.Er EINVAL
+on failure due to invalid flag specified.
.Sh SEE ALSO
.Xr posix_spawn 3 ,
.Xr posix_spawnattr_destroy 3 ,
diff --git a/lib/libc/gen/psignal.3 b/lib/libc/gen/psignal.3
index 0fc63418d3f3..098b7b02a9b9 100644
--- a/lib/libc/gen/psignal.3
+++ b/lib/libc/gen/psignal.3
@@ -25,16 +25,17 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)psignal.3 8.2 (Berkeley) 2/27/95
-.\"
-.Dd May 30, 2016
+.Dd May 10, 2025
.Dt PSIGNAL 3
.Os
.Sh NAME
.Nm psignal ,
+.Nm psiginfo ,
.Nm strsignal ,
.Nm sys_siglist ,
-.Nm sys_signame
+.Nm sys_signame ,
+.Nm sig2str ,
+.Nm str2sig
.Nd system signal messages
.Sh LIBRARY
.Lb libc
@@ -42,11 +43,17 @@
.In signal.h
.Ft void
.Fn psignal "int sig" "const char *s"
+.Ft void
+.Fn psiginfo "const siginfo_t *si" "const char *s"
.Vt extern const char * const sys_siglist[] ;
.Vt extern const char * const sys_signame[] ;
.In string.h
.Ft "char *"
.Fn strsignal "int sig"
+.Ft int
+.Fn sig2str "int signum" "char *str"
+.Ft int
+.Fn str2sig "char *str" "int *pnum"
.Sh DESCRIPTION
The
.Fn psignal
@@ -81,6 +88,16 @@ the string
.Dq "Unknown signal"
is produced.
.Pp
+The
+.Fn psiginfo
+function is similar to
+.Fn psignal ,
+except that the signal number information is taken from the
+.Fa si
+argument which is a
+.Vt siginfo_t
+structure.
+.Pp
The message strings can be accessed directly
through the external array
.Va sys_siglist ,
@@ -97,12 +114,65 @@ contains a count of the strings in
.Va sys_siglist
and
.Va sys_signame .
+.Pp
+The
+.Fn sig2str
+function translates the signal number
+.Fa signum
+to the signal name, without the
+.Dq SIG
+prefix, and stores it at the location specified by
+.Fa str ,
+which should be large enough to hold the name and the terminating
+.Dv NUL
+byte.
+The symbol
+.Dv SIG2STR_MAX
+gives the maximum size in bytes required.
+.Pp
+The
+.Fn str2sig
+function translates the signal name
+.Fa str
+to a signal number and stores it in the location referenced by
+.Fa pnum .
+The name in
+.Fa str
+can be either the name of the signal, with or without the
+.Dq SIG
+prefix, or a decimal number.
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr perror 3 ,
.Xr strerror 3
+.Sh STANDARDS
+The
+.Fn psignal
+and
+.Fn psiginfo
+functions are defined by
+.St -p1003.1-2008
+, while the
+.Fn sig2str
+and
+.Fn str2sig
+functions are defined by
+.St -p1003.1-2024 .
.Sh HISTORY
The
.Fn psignal
function appeared in
.Bx 4.2 .
+The
+.Fn psiginfo
+function appeared in
+.Fx 14.3 ,
+.Nx 6.0 ,
+and
+.Dx 4.1 .
+The
+.Fn sig2str
+and
+.Fn str2sig
+functions appeared in
+.Fx 15.0 .
diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c
index f8caf7621e83..291a6a9337a0 100644
--- a/lib/libc/gen/psignal.c
+++ b/lib/libc/gen/psignal.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)psignal.c 8.1 (Berkeley) 6/4/93");
/*
* Print the name of the signal indicated
* along with the supplied message.
@@ -57,3 +55,9 @@ psignal(int sig, const char *s)
(void)_write(STDERR_FILENO, c, strlen(c));
(void)_write(STDERR_FILENO, "\n", 1);
}
+
+void
+psiginfo(const siginfo_t *si, const char *s)
+{
+ psignal(si->si_signo, s);
+}
diff --git a/lib/libc/gen/pututxline.c b/lib/libc/gen/pututxline.c
index 36f987ee7ae7..15df7b5f6783 100644
--- a/lib/libc/gen/pututxline.c
+++ b/lib/libc/gen/pututxline.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/endian.h>
#include <sys/stat.h>
diff --git a/lib/libc/gen/pw_scan.c b/lib/libc/gen/pw_scan.c
index 01ddc57a0d8c..35072d7c1b59 100644
--- a/lib/libc/gen/pw_scan.c
+++ b/lib/libc/gen/pw_scan.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)pw_scan.c 8.3 (Berkeley) 4/2/94");
/*
* This module is used to "verify" password entries by chpass(1) and
* pwd_mkdb(8).
diff --git a/lib/libc/gen/pw_scan.h b/lib/libc/gen/pw_scan.h
index d3e33454195e..63457a382821 100644
--- a/lib/libc/gen/pw_scan.h
+++ b/lib/libc/gen/pw_scan.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
*/
#define _PWSCAN_MASTER 0x01
diff --git a/lib/libc/gen/raise.3 b/lib/libc/gen/raise.3
index 87319bb30329..c74777e7faa9 100644
--- a/lib/libc/gen/raise.3
+++ b/lib/libc/gen/raise.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)raise.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 7, 2010
.Dt RAISE 3
.Os
diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c
index 4cb596d49bc9..9829de18dcdc 100644
--- a/lib/libc/gen/raise.c
+++ b/lib/libc/gen/raise.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)raise.c 8.1 (Berkeley) 6/4/93");
#include <signal.h>
#include <unistd.h>
diff --git a/lib/libc/gen/rand48.3 b/lib/libc/gen/rand48.3
index d4a14b88ebee..1e47c843058e 100644
--- a/lib/libc/gen/rand48.3
+++ b/lib/libc/gen/rand48.3
@@ -9,8 +9,6 @@
.\" of any kind. I shall in no event be liable for anything that happens
.\" to anyone/anything when using this software.
.\"
-.\" @(#)rand48.3 V1.0 MB 8 Oct 1993
-.\"
.Dd September 4, 2012
.Dt RAND48 3
.Os
diff --git a/lib/libc/gen/readdir-compat11.c b/lib/libc/gen/readdir-compat11.c
index 30cec5acd0e6..606e15bd7b36 100644
--- a/lib/libc/gen/readdir-compat11.c
+++ b/lib/libc/gen/readdir-compat11.c
@@ -25,12 +25,9 @@
* 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.
- *
- * From: @(#)readdir.c 8.3 (Berkeley) 9/29/94
* From: FreeBSD: head/lib/libc/gen/readdir.c 314436 2017-02-28 23:42:47Z imp
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#define _WANT_FREEBSD11_DIRENT
diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c
index d2c8636651ff..94d2b2e8d877 100644
--- a/lib/libc/gen/readdir.c
+++ b/lib/libc/gen/readdir.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)readdir.c 8.3 (Berkeley) 9/29/94");
#include "namespace.h"
#include <sys/param.h>
#include <dirent.h>
@@ -50,8 +48,9 @@ struct dirent *
_readdir_unlocked(DIR *dirp, int flags)
{
struct dirent *dp;
- long initial_seek;
- long initial_loc = 0;
+ off_t initial_seek;
+ size_t initial_loc = 0;
+ ssize_t ret;
for (;;) {
if (dirp->dd_loc >= dirp->dd_size) {
@@ -63,11 +62,13 @@ _readdir_unlocked(DIR *dirp, int flags)
}
if (dirp->dd_loc == 0 &&
!(dirp->dd_flags & (__DTF_READALL | __DTF_SKIPREAD))) {
+ dirp->dd_size = 0;
initial_seek = dirp->dd_seek;
- dirp->dd_size = _getdirentries(dirp->dd_fd,
+ ret = _getdirentries(dirp->dd_fd,
dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
- if (dirp->dd_size <= 0)
+ if (ret <= 0)
return (NULL);
+ dirp->dd_size = (size_t)ret;
_fixtelldir(dirp, initial_seek, initial_loc);
}
dirp->dd_flags &= ~__DTF_SKIPREAD;
@@ -133,3 +134,5 @@ __readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
}
__strong_reference(__readdir_r, readdir_r);
+__warn_references(readdir_r,
+ "warning: this program uses readdir_r(), which is unsafe.");
diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c
index c6eb63f1469c..5319d3e634af 100644
--- a/lib/libc/gen/readpassphrase.c
+++ b/lib/libc/gen/readpassphrase.c
@@ -21,7 +21,6 @@
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ctype.h>
#include <errno.h>
diff --git a/lib/libc/gen/recvmmsg.c b/lib/libc/gen/recvmmsg.c
deleted file mode 100644
index 6fa400f00c22..000000000000
--- a/lib/libc/gen/recvmmsg.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2016 Boris Astardzhiev, Smartcom-Bulgaria AD
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <poll.h>
-#include <stddef.h>
-#include "libc_private.h"
-
-ssize_t
-recvmmsg(int s, struct mmsghdr *__restrict msgvec, size_t vlen, int flags,
- const struct timespec *__restrict timeout)
-{
- struct pollfd pfd[1];
- size_t i, rcvd;
- ssize_t ret;
- int res;
- short ev;
-
- if (timeout != NULL) {
- pfd[0].fd = s;
- pfd[0].revents = 0;
- pfd[0].events = ev = POLLIN | POLLRDNORM | POLLRDBAND |
- POLLPRI;
- res = ppoll(&pfd[0], 1, timeout, NULL);
- if (res == -1 || res == 0)
- return (res);
- if (pfd[0].revents & POLLNVAL) {
- errno = EBADF;
- return (-1);
- }
- if ((pfd[0].revents & ev) == 0) {
- errno = ETIMEDOUT;
- return (-1);
- }
- }
-
- ret = __sys_recvmsg(s, &msgvec[0].msg_hdr, flags);
- if (ret == -1)
- return (ret);
-
- msgvec[0].msg_len = ret;
-
- /*
- * Do non-blocking receive for second and later messages if
- * WAITFORONE is set.
- */
- if (flags & MSG_WAITFORONE)
- flags |= MSG_DONTWAIT;
-
- rcvd = 1;
- for (i = rcvd; i < vlen; i++, rcvd++) {
- ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags);
- if (ret == -1) {
- /* We have received messages. Let caller know
- * about the data received, socket error is
- * returned on next invocation.
- */
- return (rcvd);
- }
-
- /* Save received bytes. */
- msgvec[i].msg_len = ret;
- }
-
- return (rcvd);
-}
diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c
index bc072d2826ea..df829e98d138 100644
--- a/lib/libc/gen/rewinddir.c
+++ b/lib/libc/gen/rewinddir.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)rewinddir.c 8.1 (Berkeley) 6/8/93");
#include "namespace.h"
#include <sys/types.h>
#include <dirent.h>
diff --git a/lib/libc/gen/rtld_get_var.3 b/lib/libc/gen/rtld_get_var.3
new file mode 100644
index 000000000000..092114e86d78
--- /dev/null
+++ b/lib/libc/gen/rtld_get_var.3
@@ -0,0 +1,106 @@
+.\" Copyright (c) 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd October 31, 2024
+.Dt RTLD_GET_VAR 3
+.Os
+.Sh NAME
+.Nm rtld_get_var ,
+.Nm rtld_set_var
+.Nd query or change run-time linker parameters after image activation
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/errno.h
+.In link.h
+.Ft const char *
+.Fn rtld_get_var "const char *name"
+.Ft int
+.Fn rtld_set_var "const char *name" "const char *value"
+.Sh DESCRIPTION
+The dynamic linker
+.Xr rtld 1
+can be configured by setting some environment variables for the process,
+before image activation.
+Sometimes it is desirable to query the current effective settings or
+change them afterward.
+.Pp
+Since the process environment variables are maintained by higher-level
+libraries, the run-time linker cannot access them after the image
+activation.
+The described functions make it possible to operate on rtld settings.
+.Pp
+The
+.Fn rtld_get_var
+function returns the current value of the named parameter.
+.Pp
+The
+.Fn rtld_set_var
+functions changes the value of the parameter to the new
+.Fa value
+value, if possible.
+The
+.Fa name
+argument to both functions is the name of the parameter, which
+is same as the corresponding environment variable
+.Pq see Xr rtld 1
+but without the
+.Ev LD_
+(or
+.Ev LD_32_
+or any other ABI-specific) prefix.
+.Sh RETURN VALUES
+The
+.Fn rtld_get_var
+returns the current value of the named parameter, or
+.Dv NULL
+if the name is invalid.
+.Pp
+The
+.Fn rtld_set_var
+returns 0 on success, or an integer indicating the error condition
+which prevented the operation.
+.Sh ERRORS
+Possible errors returned from
+.Fn rtld_set_var :
+.Bl -tag -width Er
+.It Bq Er EPERM
+The requested change cannot be made at runtime, either because the
+runtime linker can only take this parameter at initialization time,
+or because the current process is executing with elevated privileges.
+.It Bq ENOENT
+The supplied parameter
+.Fa name
+is unknown.
+.El
+.Sh SEE ALSO
+.Xr rtld 1
+.Sh HISTORY
+The
+.Nm
+function first appeared in
+.Fx 14.3 .
diff --git a/lib/libc/gen/scandir-compat11.c b/lib/libc/gen/scandir-compat11.c
index b5c9846c2798..96c9b1052b48 100644
--- a/lib/libc/gen/scandir-compat11.c
+++ b/lib/libc/gen/scandir-compat11.c
@@ -25,12 +25,9 @@
* 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.
- *
- * From: @(#)scandir.c 8.3 (Berkeley) 1/2/94
* From: FreeBSD: head/lib/libc/gen/scandir.c 317372 2017-04-24 14:56:41Z pfg
*/
-#include <sys/cdefs.h>
/*
* Scan the directory dirname calling select to make a list of selected
* directory entries then sort using qsort and compare routine dcomp.
diff --git a/lib/libc/gen/scandir.3 b/lib/libc/gen/scandir.3
index 033042acbb05..3da4500cefb9 100644
--- a/lib/libc/gen/scandir.3
+++ b/lib/libc/gen/scandir.3
@@ -25,15 +25,16 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 31, 2023
+.Dd June 25, 2025
.Dt SCANDIR 3
.Os
.Sh NAME
.Nm scandir ,
+.Nm fdscandir ,
.Nm scandirat ,
.Nm scandir_b ,
+.Nm fdscandir_b ,
+.Nm fdscandirat_b ,
.Nm alphasort ,
.Nm versionsort
.Nd scan a directory
@@ -49,6 +50,13 @@
.Fa "int \*(lp*compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp"
.Fc
.Ft int
+.Fo fdscandir
+.Fa "int dirfd"
+.Fa "struct dirent ***namelist"
+.Fa "int \*(lp*select\*(rp\*(lpconst struct dirent *\*(rp"
+.Fa "int \*(lp*compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp"
+.Fc
+.Ft int
.Fo scandirat
.Fa "int dirfd"
.Fa "const char *dirname"
@@ -64,6 +72,21 @@
.Fa "int \*(lp^compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp"
.Fc
.Ft int
+.Fo fdscandir_b
+.Fa "int dirfd"
+.Fa "struct dirent ***namelist"
+.Fa "int \*(lp^select\*(rp\*(lpconst struct dirent *\*(rp"
+.Fa "int \*(lp^compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp"
+.Fc
+.Ft int
+.Fo scandirat_b
+.Fa "int dirfd"
+.Fa "const char *dirname"
+.Fa "struct dirent ***namelist"
+.Fa "int \*(lp^select\*(rp\*(lpconst struct dirent *\*(rp"
+.Fa "int \*(lp^compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp"
+.Fc
+.Ft int
.Fn alphasort "const struct dirent **d1" "const struct dirent **d2"
.Ft int
.Fn versionsort "const struct dirent **d1" "const struct dirent **d2"
@@ -79,7 +102,8 @@ entries using
It returns the number of entries in the array.
A pointer to the array of directory entries is stored in the location
referenced by
-.Fa namelist .
+.Fa namelist
+(even if no entries were selected).
.Pp
The
.Fa select
@@ -120,6 +144,13 @@ The memory allocated for the array can be deallocated with
by freeing each pointer in the array and then the array itself.
.Pp
The
+.Fn fdscandir
+function is similar to
+.Fn scandir ,
+but takes a file descriptor referencing a directory instead of a path.
+The file descriptor is left open on return, regardless of outcome.
+.Pp
+The
.Fn scandirat
function is similar to
.Fn scandir ,
@@ -153,17 +184,67 @@ See
for additional details.
.Pp
The
-.Fn scandir_b
-function behaves in the same way as
+.Fn scandir_b ,
+.Fn fdscandir_b ,
+and
+.Fn scandirat_b
+functions behave in the same way as
.Fn scandir ,
-but takes blocks as arguments instead of function pointers and calls
+.Fn fdscandir ,
+and
+.Fn scandirat ,
+respectively,
+but take blocks as arguments instead of function pointers and call
.Fn qsort_b
rather than
.Fn qsort .
.Sh DIAGNOSTICS
-Returns \-1 if the directory cannot be opened for reading or if
+The
+.Fn scandir ,
+.Fn fdscandir ,
+.Fn scandirat ,
+.Fn scandir_b ,
+.Fn fdscandir_b ,
+and
+.Fn scandirat_b
+functions return the number of directory entries found on succes.
+If the directory cannot be opened for reading, an error occurs
+while reading the directory, or
.Xr malloc 3
-cannot allocate enough memory to hold all the data structures.
+cannot allocate enough memory to hold all the directory entries,
+they return \-1 and set
+.Va errno
+to an appropriate value.
+.Sh ERRORS
+The
+.Fn scandir ,
+.Fn scandirat ,
+.Fn scandir_b ,
+and
+.Fn scandirat_b
+functions may fail and set
+.Va errno
+for any of the errors specified for the
+.Xr opendir 3 ,
+.Xr malloc 3 ,
+.Xr readdir 3 ,
+and
+.Xr closedir 3
+functions.
+.Pp
+The
+.Fn fdscandir
+and
+.Fn fdscandir_b
+functions may fail and set
+.Va errno
+for any of the errors specified for the
+.Xr fdopendir 3 ,
+.Xr malloc 3 ,
+.Xr readdir 3 ,
+and
+.Xr closedir 3
+functions.
.Sh SEE ALSO
.Xr openat 2 ,
.Xr directory 3 ,
@@ -174,8 +255,25 @@ cannot allocate enough memory to hold all the data structures.
.Xr dir 5
.Sh STANDARDS
The
+.Fn alphasort
+and
+.Fn scandir
+functions are expected to conform to
+.St -p1003.1-2008 .
+The
+.Fn scandirat
+and
.Fn versionsort
-function is a GNU extension and conforms to no standard.
+functions are GNU extensions and conform to no standard.
+The
+.Fn fdscandir ,
+.Fn scandir_b ,
+.Fn fdscandir_b ,
+and
+.Fn scandirat_b
+functions are
+.Fx
+extensions.
.Sh HISTORY
The
.Fn scandir
@@ -184,8 +282,19 @@ and
functions appeared in
.Bx 4.2 .
The
+.Fn scandir_b
+function was added in
+.Fx 11.0 .
+The
.Fn scandirat
and
.Fn versionsort
functions were added in
.Fx 13.2 .
+The
+.Fn fdscandir ,
+.Fn fdscandir_b ,
+and
+.Fn scandirat_b
+functions were added in
+.Fx 15.0 .
diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c
index 28565150a035..fb589f4b36b6 100644
--- a/lib/libc/gen/scandir.c
+++ b/lib/libc/gen/scandir.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)scandir.c 8.3 (Berkeley) 1/2/94");
/*
* Scan the directory dirname calling select to make a list of selected
* directory entries then sort using qsort and compare routine dcomp.
@@ -40,6 +38,7 @@ __SCCSID("@(#)scandir.c 8.3 (Berkeley) 1/2/94");
#include "namespace.h"
#include <dirent.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
@@ -66,71 +65,76 @@ static int scandir_thunk_cmp(const void *p1, const void *p2, void *thunk);
static int
#ifdef I_AM_SCANDIR_B
-scandir_b_dirp(DIR *dirp, struct dirent ***namelist, select_block select,
+scandir_dirp_b(DIR *dirp, struct dirent ***namelist, select_block select,
dcomp_block dcomp)
#else
scandir_dirp(DIR *dirp, struct dirent ***namelist,
- int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **,
- const struct dirent **))
+ int (*select)(const struct dirent *),
+ int (*dcomp)(const struct dirent **, const struct dirent **))
#endif
{
- struct dirent *d, *p, **names = NULL;
- size_t arraysz, numitems;
+ struct dirent *d, *p = NULL, **names = NULL, **names2;
+ size_t arraysz = 32, numitems = 0;
+ int serrno;
- numitems = 0;
- arraysz = 32; /* initial estimate of the array size */
- names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *));
+ names = malloc(arraysz * sizeof(*names));
if (names == NULL)
- goto fail;
+ return (-1);
- while ((d = readdir(dirp)) != NULL) {
+ while (errno = 0, (d = readdir(dirp)) != NULL) {
if (select != NULL && !SELECT(d))
continue; /* just selected names */
/*
* Make a minimum size copy of the data
*/
- p = (struct dirent *)malloc(_GENERIC_DIRSIZ(d));
+ p = malloc(_GENERIC_DIRSIZ(d));
if (p == NULL)
goto fail;
p->d_fileno = d->d_fileno;
p->d_type = d->d_type;
p->d_reclen = d->d_reclen;
p->d_namlen = d->d_namlen;
- bcopy(d->d_name, p->d_name, p->d_namlen + 1);
+ memcpy(p->d_name, d->d_name, p->d_namlen + 1);
/*
* Check to make sure the array has space left and
* realloc the maximum size.
*/
if (numitems >= arraysz) {
- struct dirent **names2;
-
- names2 = reallocarray(names, arraysz,
- 2 * sizeof(struct dirent *));
- if (names2 == NULL) {
- free(p);
+ arraysz = arraysz * 2;
+ names2 = reallocarray(names, arraysz, sizeof(*names));
+ if (names2 == NULL)
goto fail;
- }
names = names2;
- arraysz *= 2;
}
names[numitems++] = p;
}
- closedir(dirp);
- if (numitems && dcomp != NULL)
+ /*
+ * Since we can't simultaneously return both -1 and a count, we
+ * must either suppress the error or discard the partial result.
+ * The latter seems the lesser of two evils.
+ */
+ if (errno != 0)
+ goto fail;
+ if (numitems > 0 && dcomp != NULL) {
#ifdef I_AM_SCANDIR_B
- qsort_b(names, numitems, sizeof(struct dirent *), (void*)dcomp);
+ qsort_b(names, numitems, sizeof(struct dirent *),
+ (void *)dcomp);
#else
qsort_r(names, numitems, sizeof(struct dirent *),
scandir_thunk_cmp, &dcomp);
#endif
+ }
*namelist = names;
return (numitems);
fail:
+ serrno = errno;
+ if (numitems == 0 || names[numitems - 1] != p)
+ free(p);
while (numitems > 0)
free(names[--numitems]);
free(names);
- closedir(dirp);
+ errno = serrno;
return (-1);
}
@@ -140,44 +144,87 @@ scandir_b(const char *dirname, struct dirent ***namelist, select_block select,
dcomp_block dcomp)
#else
scandir(const char *dirname, struct dirent ***namelist,
- int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **,
- const struct dirent **))
+ int (*select)(const struct dirent *),
+ int (*dcomp)(const struct dirent **, const struct dirent **))
#endif
{
DIR *dirp;
+ int ret, serrno;
dirp = opendir(dirname);
if (dirp == NULL)
return (-1);
- return (
+ ret =
#ifdef I_AM_SCANDIR_B
- scandir_b_dirp
+ scandir_dirp_b
#else
scandir_dirp
#endif
- (dirp, namelist, select, dcomp));
+ (dirp, namelist, select, dcomp);
+ serrno = errno;
+ closedir(dirp);
+ errno = serrno;
+ return (ret);
}
-#ifndef I_AM_SCANDIR_B
int
-scandirat(int dirfd, const char *dirname, struct dirent ***namelist,
- int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **,
- const struct dirent **))
+#ifdef I_AM_SCANDIR_B
+fdscandir_b(int dirfd, struct dirent ***namelist, select_block select,
+ dcomp_block dcomp)
+#else
+fdscandir(int dirfd, struct dirent ***namelist,
+ int (*select)(const struct dirent *),
+ int (*dcomp)(const struct dirent **, const struct dirent **))
+#endif
{
DIR *dirp;
- int fd;
+ int ret, serrno;
+
+ dirp = fdopendir(dirfd);
+ if (dirp == NULL)
+ return (-1);
+ ret =
+#ifdef I_AM_SCANDIR_B
+ scandir_dirp_b
+#else
+ scandir_dirp
+#endif
+ (dirp, namelist, select, dcomp);
+ serrno = errno;
+ fdclosedir(dirp);
+ errno = serrno;
+ return (ret);
+}
+
+int
+#ifdef I_AM_SCANDIR_B
+scandirat_b(int dirfd, const char *dirname, struct dirent ***namelist,
+ select_block select, dcomp_block dcomp)
+#else
+scandirat(int dirfd, const char *dirname, struct dirent ***namelist,
+ int (*select)(const struct dirent *),
+ int (*dcomp)(const struct dirent **, const struct dirent **))
+#endif
+{
+ int fd, ret, serrno;
fd = _openat(dirfd, dirname, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
if (fd == -1)
return (-1);
- dirp = fdopendir(fd);
- if (dirp == NULL) {
- _close(fd);
- return (-1);
- }
- return (scandir_dirp(dirp, namelist, select, dcomp));
+ ret =
+#ifdef I_AM_SCANDIR_B
+ fdscandir_b
+#else
+ fdscandir
+#endif
+ (fd, namelist, select, dcomp);
+ serrno = errno;
+ _close(fd);
+ errno = serrno;
+ return (ret);
}
+#ifndef I_AM_SCANDIR_B
/*
* Alphabetic order comparison routine for those who want it.
* POSIX 2008 requires that alphasort() uses strcoll().
diff --git a/lib/libc/gen/seed48.c b/lib/libc/gen/seed48.c
index 230348ff0fa8..258c4bac3c9f 100644
--- a/lib/libc/gen/seed48.c
+++ b/lib/libc/gen/seed48.c
@@ -11,7 +11,6 @@
* to anyone/anything when using this software.
*/
-#include <sys/cdefs.h>
#include "rand48.h"
extern unsigned short _rand48_seed[3];
diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c
index 8c88bdbf4ab5..c796aa7e3550 100644
--- a/lib/libc/gen/seekdir.c
+++ b/lib/libc/gen/seekdir.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)seekdir.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <sys/param.h>
#include <dirent.h>
diff --git a/lib/libc/gen/semctl.c b/lib/libc/gen/semctl.c
index 84df40e4c9af..374f01508236 100644
--- a/lib/libc/gen/semctl.c
+++ b/lib/libc/gen/semctl.c
@@ -28,7 +28,6 @@
*/
-#include <sys/cdefs.h>
#ifndef NO_COMPAT7
#define _WANT_SEMUN_OLD
#endif
diff --git a/lib/libc/gen/sendmmsg.c b/lib/libc/gen/sendmmsg.c
deleted file mode 100644
index 72b551792741..000000000000
--- a/lib/libc/gen/sendmmsg.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2016 Boris Astardzhiev, Smartcom-Bulgaria AD
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "libc_private.h"
-
-ssize_t
-sendmmsg(int s, struct mmsghdr *__restrict msgvec, size_t vlen, int flags)
-{
- size_t i, sent;
- ssize_t ret;
-
- sent = 0;
- for (i = 0; i < vlen; i++, sent++) {
- ret = __sys_sendmsg(s, &msgvec[i].msg_hdr, flags);
- if (ret == -1) {
- if (sent != 0) {
- /*
- * We have sent messages. Let caller
- * know about the data sent, socket
- * error is returned on next
- * invocation.
- */
- return (sent);
- }
- return (ret);
- }
-
- /* Save sent bytes. */
- msgvec[i].msg_len = ret;
- }
-
- return (sent);
-}
diff --git a/lib/libc/gen/setdomainname.c b/lib/libc/gen/setdomainname.c
index b7d96ed8cdef..c40b7a393e3b 100644
--- a/lib/libc/gen/setdomainname.c
+++ b/lib/libc/gen/setdomainname.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)sethostname.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/sethostname.c b/lib/libc/gen/sethostname.c
index b1ba640d3348..eeb3ec5cc6db 100644
--- a/lib/libc/gen/sethostname.c
+++ b/lib/libc/gen/sethostname.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)sethostname.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/setjmp.3 b/lib/libc/gen/setjmp.3
index 70b46f47cb2b..e7c52473dbc9 100644
--- a/lib/libc/gen/setjmp.3
+++ b/lib/libc/gen/setjmp.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 2, 2022
.Dt SETJMP 3
.Os
diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c
index 7532070c9f53..1ba722c30146 100644
--- a/lib/libc/gen/setjmperr.c
+++ b/lib/libc/gen/setjmperr.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)setjmperr.c 8.1 (Berkeley) 6/4/93");
/*
* This routine is called from longjmp() when an error occurs.
* Programs that wish to exit gracefully from this error may
diff --git a/lib/libc/gen/setmode.3 b/lib/libc/gen/setmode.3
index 1a3ce2539ae8..a5dd05a5e7c6 100644
--- a/lib/libc/gen/setmode.3
+++ b/lib/libc/gen/setmode.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
-.\"
.Dd July 18, 2019
.Dt SETMODE 3
.Os
diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c
index 823fcbd182bb..8d7ba905067f 100644
--- a/lib/libc/gen/setmode.c
+++ b/lib/libc/gen/setmode.c
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3
index 15bafa23a982..087cbe4b84e9 100644
--- a/lib/libc/gen/setproctitle.3
+++ b/lib/libc/gen/setproctitle.3
@@ -74,10 +74,10 @@ setproctitle("talking to %s", inet_ntoa(addr));
.Sh SEE ALSO
.Xr ps 1 ,
.Xr w 1 ,
-.Xr setprogname 3 ,
.Xr kvm 3 ,
.Xr kvm_getargv 3 ,
-.Xr printf 3
+.Xr printf 3 ,
+.Xr setprogname 3
.Sh STANDARDS
The
.Fn setproctitle
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c
index 9c73fd77ca42..715951a8c96d 100644
--- a/lib/libc/gen/setproctitle.c
+++ b/lib/libc/gen/setproctitle.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/elf_common.h>
diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c
index 849ff9188d47..853c5f277386 100644
--- a/lib/libc/gen/setprogname.c
+++ b/lib/libc/gen/setprogname.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/gen/sig2str.c b/lib/libc/gen/sig2str.c
new file mode 100644
index 000000000000..869a09ab9db4
--- /dev/null
+++ b/lib/libc/gen/sig2str.c
@@ -0,0 +1,113 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Ricardo Branco <rbranco@suse.de>.
+ *
+ * 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.
+ */
+
+/*
+ * Translate between signal names and numbers
+ */
+#include "namespace.h"
+#include <ctype.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ssp/ssp.h>
+#include "un-namespace.h"
+
+static const char rtmin_str[] = "RTMIN";
+static const char rtmax_str[] = "RTMAX";
+
+int
+__ssp_real(sig2str)(int signum, char *str)
+{
+ if (signum <= 0 || signum > SIGRTMAX)
+ return (-1);
+
+ if (signum < sys_nsig)
+ (void)strlcpy(str, sys_signame[signum], SIG2STR_MAX);
+ else if (signum < SIGRTMIN)
+ (void)snprintf(str, SIG2STR_MAX, "%d", signum);
+ else if (signum == SIGRTMIN)
+ (void)strlcpy(str, rtmin_str, SIG2STR_MAX);
+ else if (signum == SIGRTMAX)
+ (void)strlcpy(str, rtmax_str, SIG2STR_MAX);
+ else if (signum <= (SIGRTMIN + SIGRTMAX) / 2)
+ (void)snprintf(str, SIG2STR_MAX, "%s+%d",
+ rtmin_str, signum - SIGRTMIN);
+ else
+ (void)snprintf(str, SIG2STR_MAX, "%s-%d",
+ rtmax_str, SIGRTMAX - signum);
+
+ return (0);
+}
+
+int
+str2sig(const char * restrict str, int * restrict pnum)
+{
+ const char *errstr;
+ long long n;
+ int sig;
+ int rtend = sizeof(rtmin_str) - 1;
+
+ if (strncasecmp(str, "SIG", 3) == 0)
+ str += 3;
+
+ if (strncasecmp(str, rtmin_str, sizeof(rtmin_str) - 1) == 0 ||
+ strncasecmp(str, rtmax_str, sizeof(rtmax_str) - 1) == 0) {
+ sig = (toupper(str[4]) == 'X') ? SIGRTMAX : SIGRTMIN;
+ n = 0;
+ if (str[rtend] == '+' || str[rtend] == '-') {
+ n = strtonum(str + rtend, INT_MIN, INT_MAX, &errstr);
+ if (n == 0 || errstr != NULL)
+ return (-1);
+ } else if (str[rtend] != '\0') {
+ return (-1);
+ }
+ sig += (int)n;
+ if (sig < SIGRTMIN || sig > SIGRTMAX)
+ return (-1);
+ *pnum = sig;
+ return (0);
+ }
+
+ if (isdigit((unsigned char)str[0])) {
+ n = strtonum(str, 1, SIGRTMAX, &errstr);
+ if (errstr == NULL) {
+ *pnum = (int)n;
+ return (0);
+ }
+ }
+
+ for (sig = 1; sig < sys_nsig; sig++) {
+ if (strcasecmp(sys_signame[sig], str) == 0) {
+ *pnum = sig;
+ return (0);
+ }
+ }
+
+ return (-1);
+}
diff --git a/lib/libc/gen/siginterrupt.3 b/lib/libc/gen/siginterrupt.3
index 74e408c5fef9..4e286f28df7c 100644
--- a/lib/libc/gen/siginterrupt.3
+++ b/lib/libc/gen/siginterrupt.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)siginterrupt.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt SIGINTERRUPT 3
.Os
diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c
index da010ca923fe..0a05e89982dc 100644
--- a/lib/libc/gen/siginterrupt.c
+++ b/lib/libc/gen/siginterrupt.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <signal.h>
#include "un-namespace.h"
diff --git a/lib/libc/gen/siglist.c b/lib/libc/gen/siglist.c
index 7af7e0ef5652..c1d0a8d425e1 100644
--- a/lib/libc/gen/siglist.c
+++ b/lib/libc/gen/siglist.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)siglist.c 8.1 (Berkeley) 6/4/93");
#include <signal.h>
const char *const sys_signame[NSIG] = {
diff --git a/lib/libc/gen/signal.3 b/lib/libc/gen/signal.3
index c71bf00d9e30..56e77325eed8 100644
--- a/lib/libc/gen/signal.3
+++ b/lib/libc/gen/signal.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)signal.3 8.3 (Berkeley) 4/19/94
-.\"
.Dd December 1, 2017
.Dt SIGNAL 3
.Os
diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c
index 17fb057b2ced..dce06bba3678 100644
--- a/lib/libc/gen/signal.c
+++ b/lib/libc/gen/signal.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)signal.c 8.1 (Berkeley) 6/4/93");
/*
* Almost backwards compatible signal.
*/
diff --git a/lib/libc/gen/sigsetops.3 b/lib/libc/gen/sigsetops.3
index 7585cbedff18..109b1d9d4a8c 100644
--- a/lib/libc/gen/sigsetops.3
+++ b/lib/libc/gen/sigsetops.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sigsetops.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 29, 2019
.Dt SIGSETOPS 3
.Os
diff --git a/lib/libc/gen/sigsetops.c b/lib/libc/gen/sigsetops.c
index 7050fa1607c1..3e22b0dba5e9 100644
--- a/lib/libc/gen/sigsetops.c
+++ b/lib/libc/gen/sigsetops.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)sigsetops.c 8.1 (Berkeley) 6/4/93");
#include <errno.h>
#include <signal.h>
diff --git a/lib/libc/gen/sleep.3 b/lib/libc/gen/sleep.3
deleted file mode 100644
index 549cd68257d3..000000000000
--- a/lib/libc/gen/sleep.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1986, 1991, 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.
-.\"
-.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd February 13, 1998
-.Dt SLEEP 3
-.Os
-.Sh NAME
-.Nm sleep
-.Nd suspend thread execution for an interval measured in seconds
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft unsigned int
-.Fn sleep "unsigned int seconds"
-.Sh DESCRIPTION
-The
-.Fn sleep
-function suspends execution of the calling thread until either
-.Fa seconds
-seconds have elapsed or a signal is delivered to the thread and its
-action is to invoke a signal-catching function or to terminate the
-thread or process.
-System activity may lengthen the sleep by an indeterminate amount.
-.Pp
-This function is implemented using
-.Xr nanosleep 2
-by pausing for
-.Fa seconds
-seconds or until a signal occurs.
-Consequently, in this implementation,
-sleeping has no effect on the state of process timers,
-and there is no special handling for SIGALRM.
-.Sh RETURN VALUES
-If the
-.Fn sleep
-function returns because the requested time has elapsed, the value
-returned will be zero.
-If the
-.Fn sleep
-function returns due to the delivery of a signal, the value returned
-will be the unslept amount (the requested time minus the time actually
-slept) in seconds.
-.Sh SEE ALSO
-.Xr nanosleep 2 ,
-.Xr usleep 3
-.Sh STANDARDS
-The
-.Fn sleep
-function conforms to
-.St -p1003.1-90 .
-.Sh HISTORY
-A
-.Fn sleep
-function appeared in
-.At v7 .
diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c
index e73496854736..e32d434d4d33 100644
--- a/lib/libc/gen/sleep.c
+++ b/lib/libc/gen/sleep.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)sleep.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <errno.h>
#include <limits.h>
@@ -57,9 +55,7 @@ __sleep(unsigned int seconds)
time_to_sleep.tv_sec = seconds;
time_to_sleep.tv_nsec = 0;
- if (((int (*)(const struct timespec *, struct timespec *))
- __libc_interposing[INTERPOS_nanosleep])(
- &time_to_sleep, &time_remaining) != -1)
+ if (INTERPOS_SYS(nanosleep, &time_to_sleep, &time_remaining) != -1)
return (0);
if (errno != EINTR)
return (seconds); /* best guess */
diff --git a/lib/libc/gen/statvfs.c b/lib/libc/gen/statvfs.c
index a7190f9a707d..94c61f0cd73d 100644
--- a/lib/libc/gen/statvfs.c
+++ b/lib/libc/gen/statvfs.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/mount.h>
diff --git a/lib/libc/gen/strtofflags.3 b/lib/libc/gen/strtofflags.3
index dfeea2d7e018..0cf996275480 100644
--- a/lib/libc/gen/strtofflags.3
+++ b/lib/libc/gen/strtofflags.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
-.\"
.Dd January 1, 2000
.Dt STRTOFFLAGS 3
.Os
diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c
index 09a811c37a80..73b4db54ccdd 100644
--- a/lib/libc/gen/strtofflags.c
+++ b/lib/libc/gen/strtofflags.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)stat_flags.c 8.1 (Berkeley) 5/31/93");
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3
index 56d4c0bc5aa6..e38357b898a7 100644
--- a/lib/libc/gen/sysconf.3
+++ b/lib/libc/gen/sysconf.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94
-.\"
.Dd April 26, 2013
.Dt SYSCONF 3
.Os
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c
index 54f9526d3955..66562d0e29f0 100644
--- a/lib/libc/gen/sysconf.c
+++ b/lib/libc/gen/sysconf.c
@@ -32,10 +32,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)sysconf.c 8.2 (Berkeley) 3/20/94");
#include "namespace.h"
#include <sys/param.h>
+#include <sys/exterrvar.h>
#include <sys/time.h>
#include <sys/sysctl.h>
#include <sys/resource.h>
@@ -52,7 +51,7 @@ __SCCSID("@(#)sysconf.c 8.2 (Berkeley) 3/20/94");
#include "un-namespace.h"
#include "../stdlib/atexit.h"
-#include "tzfile.h" /* from ../../../contrib/tzcode/stdtime */
+#include "tzdir.h" /* from ../../../contrib/tzcode/stdtime */
#include "libc_private.h"
#define _PATH_ZONEINFO TZDIR /* from tzfile.h */
@@ -288,6 +287,8 @@ do_NAME_MAX:
mib[0] = CTL_P1003_1B;
mib[1] = CTL_P1003_1B_MQ_OPEN_MAX;
goto yesno;
+ case _SC_NSIG:
+ return (_SIG_MAXSIG);
case _SC_PAGESIZE:
return (getpagesize());
case _SC_RTSIG_MAX:
@@ -569,7 +570,7 @@ yesno:
case _SC_IPV6:
#if _POSIX_IPV6 == 0
sverrno = errno;
- value = _socket(PF_INET6, SOCK_DGRAM, 0);
+ value = _socket(PF_INET6, SOCK_CLOEXEC | SOCK_DGRAM, 0);
errno = sverrno;
if (value >= 0) {
_close(value);
@@ -604,6 +605,8 @@ yesno:
return (-1);
return ((long)value);
#endif
+ case _SC_UEXTERR_MAXLEN:
+ return (UEXTERROR_MAXLEN);
default:
errno = EINVAL;
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index c2d43cc4e49c..ef897c653728 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
-.\"
-.Dd March 16, 2023
+.Dd July 31, 2025
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -327,6 +325,7 @@ information.
.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent
.It Sy Second Level Name Ta Sy Type Ta Sy Changeable
.It Dv KERN_ARGMAX Ta integer Ta no
+.It Dv KERN_ARND Ta integer Ta no
.It Dv KERN_BOOTFILE Ta string Ta yes
.It Dv KERN_BOOTTIME Ta struct timeval Ta no
.It Dv KERN_CLOCKRATE Ta struct clockinfo Ta no
@@ -334,9 +333,13 @@ information.
.It Dv KERN_HOSTID Ta integer Ta yes
.It Dv KERN_HOSTUUID Ta string Ta yes
.It Dv KERN_HOSTNAME Ta string Ta yes
+.It Dv KERN_IOV_MAX Ta integer Ta yes
.It Dv KERN_JOB_CONTROL Ta integer Ta no
+.It Dv KERN_LOCKF Ta struct kinfo_lockf Ta no
+.It Dv KERN_LOGSIGEXIT Ta integer Ta yes
.It Dv KERN_MAXFILES Ta integer Ta yes
.It Dv KERN_MAXFILESPERPROC Ta integer Ta yes
+.It Dv KERN_MAXPHYS Ta integer Ta no
.It Dv KERN_MAXPROC Ta integer Ta no
.It Dv KERN_MAXPROCPERUID Ta integer Ta yes
.It Dv KERN_MAXVNODES Ta integer Ta yes
@@ -348,16 +351,28 @@ information.
.It Dv KERN_OSTYPE Ta string Ta no
.It Dv KERN_POSIX1 Ta integer Ta no
.It Dv KERN_PROC Ta node Ta not applicable
-.It Dv KERN_QUANTUM Ta integer Ta yes
+.It Dv KERN_PS_STRINGS Ta integer Ta no
.It Dv KERN_SAVED_IDS Ta integer Ta no
.It Dv KERN_SECURELVL Ta integer Ta raise only
.It Dv KERN_UPDATEINTERVAL Ta integer Ta no
+.It Dv KERN_USRSTACK Ta integer Ta no
.It Dv KERN_VERSION Ta string Ta no
.El
.Bl -tag -width 6n
.It Li KERN_ARGMAX
The maximum bytes of argument to
.Xr execve 2 .
+.It Li KERN_ARND
+.Xr arc4rand 9
+Fills the buffer with random bytes from in-kernel random data generator.
+This is an alternative interface for
+.Xr read 2
+of
+.Xr random 4
+device, which does not depend on accessibility and correct mounting options
+of the
+.Xr devfs 4
+node.
.It Li KERN_BOOTFILE
The full pathname of the file from which the kernel was loaded.
.It Li KERN_BOOTTIME
@@ -382,8 +397,18 @@ Get or set the host ID.
Get or set the host's universally unique identifier (UUID).
.It Li KERN_HOSTNAME
Get or set the hostname.
+.It Li KERN_IOV_MAX
+The maximum accepted number of elements in an input-output vector (iovec),
+see
+.Xr readv 2
+and
+.Xr writev 2 .
.It Li KERN_JOB_CONTROL
Return 1 if job control is available on this system, otherwise 0.
+.It Li KERN_LOCKF
+Returns the list of the file advisory locks currently known to kernel.
+.It Li KERN_LOGSIGEXIT
+Controls logging of process exit due to untrapped signals.
.It Li KERN_MAXFILES
The maximum number of files that may be open in the system.
.It Li KERN_MAXFILESPERPROC
@@ -392,6 +417,10 @@ This limit only applies to processes with an effective uid of nonzero
at the time of the open request.
Files that have already been opened are not affected if the limit
or the effective uid is changed.
+.It Li KERN_MAXPHYS
+Specifies the maximum block I/O size.
+Can be changed by the tunable
+.Ev kern.maxphys .
.It Li KERN_MAXPROC
The maximum number of concurrent processes the system will allow.
.It Li KERN_MAXPROCPERUID
@@ -448,41 +477,140 @@ whose size depends on the current number of such objects in the system.
.It Dv KERN_PROC_ALL Ta None
.It Dv KERN_PROC_PID Ta A process ID
.It Dv KERN_PROC_PGRP Ta A process group
+.It Dv KERN_PROC_SESSION Ta A session
.It Dv KERN_PROC_TTY Ta A tty device
-.It Dv KERN_PROC_UID Ta A user ID
+.It Dv KERN_PROC_UID Ta An effective user ID
.It Dv KERN_PROC_RUID Ta A real user ID
+.It Dv KERN_PROC_GID Ta An effective group ID
+.It Dv KERN_PROC_RGID Ta A real group ID
+.El
+.Pp
+For the following names, the miscellaneous information about the target
+process, which is specified by the fourth level of the oid name,
+is returned.
+A process ID of
+.Li \-1
+specifies the current process.
+.Bl -column "Third Level NameXXXXXX" "TypeXXXXXX" -offset indent
+.It Sy Third Level Name Ta Sy Fourth Level
+.It Dv KERN_PROC_ARGS Ta "Set of strings"
+.It Dv KERN_PROC_PATHNAME Ta "String"
+.It Dv KERN_PROC_KSTACK Ta "struct kinfo_stack []"
+.It Dv KERN_PROC_VMMAP Ta "struct kinfo_vmentry []"
+.It Dv KERN_PROC_FILEDESC Ta "struct kinfo_file []"
+.It Dv KERN_PROC_GROUPS Ta "gid_t []"
+.It Dv KERN_PROC_ENV Ta "Set of strings"
+.It Dv KERN_PROC_AUXV Ta "Elf_Auxinfo []"
+.It Dv KERN_PROC_RLIMIT Ta "Integer"
+.It Dv KERN_PROC_PS_STRINGS Ta "Integer"
+.It Dv KERN_PROC_UMASK Ta "Integer/short"
+.It Dv KERN_PROC_OSREL Ta "Integer"
+.It Dv KERN_PROC_SIGTRAMP Ta "Integer"
+.It Dv KERN_PROC_CWD Ta "String"
+.It Dv KERN_PROC_NFDS Ta "Integer"
+.It Dv KERN_PROC_SIGFASTBLK Ta "Integer"
+.It Dv KERN_PROC_VM_LAYOUT Ta "struct kinfo_vm_layout"
+.It Dv KERN_PROC_RLIMIT_USAGE Ta "rlim_t []"
+.It Dv KERN_PROC_KQUEUE Ta "struct kinfo_knote []"
.El
.Pp
-If the third level name is
-.Dv KERN_PROC_ARGS
-then the command line argument
+.Bl -tag -compact
+.It Dv KERN_PROC_ARGS
+The command line argument
array is returned in a flattened form, i.e., zero-terminated arguments
follow each other.
The total size of array is returned.
It is also possible for a process to set its own process title this way.
-If the third level name is
-.Dv KERN_PROC_PATHNAME ,
-the path of the
-process' text file is stored.
-For
-.Dv KERN_PROC_PATHNAME ,
-a process ID of
+.It Dv KERN_PROC_PATHNAME
+The path of the process' text file is returned.
+.It Dv KERN_PROC_KSTACK
+The in-kernel call stacks for the threads of the specified process.
+.It Dv KERN_PROC_VMMAP
+The description of the map entries for the process.
+Also refer to
+.Xr kinfo_getvmmap 3 .
+.It Dv KERN_PROC_FILEDESC
+The file descriptors for files opened in the specified process.
+Also refer to
+.Xr kinfo_getfile 3 .
+.It Dv KERN_PROC_GROUPS
+Groups associated with the process.
+.It Dv KERN_PROC_ENV
+The set of strings representing the environment of the specified process.
+.Pp
+Note that from the kernel point of view, environment exists only at the
+time of
+.Xr execve 2
+system call.
+This node method tries to reconstruct the environment from the known
+breadcrumbs left in the process address space, but it is not guaranteed
+to succeed or to represent the current value as maintained by the program.
+.It Dv KERN_PROC_AUXV
+The set of ELF auxv entries.
+See the note above about environment, which is also applicable to auxv.
+.It Dv KERN_PROC_RLIMIT
+Additinal OID name element must be supplied, specifiing the resource name
+as in
+.Xr getrlimit 2 .
+The call returns the given resource limit for the process.
+.It Dv KERN_PROC_PS_STRINGS
+Returns the location of the
+.Vt ps_strings
+structure at the time of the last call to
+.Xr execve 2
+in the specified process.
+.It Dv KERN_PROC_UMASK
+The current umask value, see
+.Xr umask 2 .
+.It Dv KERN_PROC_OSREL
+The value of osrel for the process, that is the osrel the currently executed
+image was compiled for.
+Read from the note of the elf executable at
+.Xr execve 2
+time.
+Might be modified by the process.
+.It Dv KERN_PROC_SIGTRAMP
+Address of the signal trampoline in the process address space,
+where, simplifying, the kernel passes control for signal delivery.
+.It Dv KERN_PROC_CWD
+Returns the current working directory for the process.
+.It Dv KERN_PROC_NFDS
+Returns the total number of opened file descriptors for the process.
+.It Dv KERN_PROC_SIGFASTBLK
+Returns the address of the
+.Xr sigfastblock 2
+location, if active.
+.It Dv KERN_PROC_VM_LAYOUT
+Fills a structure describing process virtual address space layout.
+.It Dv KERN_PROC_RLIMIT_USAGE
+Like
+.Dv KERN_PROC_RLIMIT ,
+but instead of the limit, returns the accounted resource usage.
+For resources which do not have a meaningful current value,
.Li \-1
-implies the current process.
-.Bl -column "Third Level NameXXXXXX" "Fourth LevelXXXXXX" -offset indent
-.It Sy Third Level Name Ta Sy Fourth Level
-.It Dv KERN_PROC_ARGS Ta "A process ID"
-.It Dv KERN_PROC_PATHNAME Ta "A process ID"
+is returned.
+.It Dv KERN_PROC_KQUEUE
+Fills an array of structures describing events registered with
+the specified kqueue.
+The next two node's values are the
+.Va pid
+and
+.Va kqfd ,
+the process ID of the process, and the file descriptor of the kqueue
+in that process, to query.
.El
-.It Li KERN_QUANTUM
-The maximum period of time, in microseconds, for which a process is allowed
-to run without being preempted if other processes are in the run queue.
+.It Li KERN_PS_STRINGS
+Reports the location of the process
+.Vt ps_strings
+structure after exec, for the ABI of the querying process.
.It Li KERN_SAVED_IDS
Returns 1 if saved set-group and saved set-user ID is available.
.It Li KERN_SECURELVL
The system security level.
This level may be raised by processes with appropriate privilege.
It may not be lowered.
+.It Li KERN_USRSTACK
+Reports the top of the main thread user stack for the current process.
.It Li KERN_VERSION
The system version string.
.El
@@ -825,6 +953,7 @@ A process without appropriate privilege attempts to set a value.
.El
.Sh SEE ALSO
.Xr confstr 3 ,
+.Xr kinfo_getproc 3 ,
.Xr kvm 3 ,
.Xr sysconf 3 ,
.Xr sysctl 8
diff --git a/lib/libc/gen/sysctl.c b/lib/libc/gen/sysctl.c
index 5586b78b26b9..d6fadd3c3e5c 100644
--- a/lib/libc/gen/sysctl.c
+++ b/lib/libc/gen/sysctl.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)sysctl.c 8.2 (Berkeley) 1/4/94");
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/sysctlbyname.c b/lib/libc/gen/sysctlbyname.c
index 017dba86c11a..8cc9599f7a95 100644
--- a/lib/libc/gen/sysctlbyname.c
+++ b/lib/libc/gen/sysctlbyname.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <string.h>
diff --git a/lib/libc/gen/sysctlnametomib.c b/lib/libc/gen/sysctlnametomib.c
index d2e33f5690ff..e45d23e10714 100644
--- a/lib/libc/gen/sysctlnametomib.c
+++ b/lib/libc/gen/sysctlnametomib.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <string.h>
diff --git a/lib/libc/gen/syslog.3 b/lib/libc/gen/syslog.3
index 017a9092e625..62140554f4f5 100644
--- a/lib/libc/gen/syslog.3
+++ b/lib/libc/gen/syslog.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)syslog.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd July 3, 2023
.Dt SYSLOG 3
.Os
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index a9a87943da8b..a6290ee81a29 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)syslog.c 8.5 (Berkeley) 4/29/95");
#include "namespace.h"
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/gen/tcgetpgrp.3 b/lib/libc/gen/tcgetpgrp.3
index 02a6ac51867c..2c9bd2983e06 100644
--- a/lib/libc/gen/tcgetpgrp.3
+++ b/lib/libc/gen/tcgetpgrp.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tcgetpgrp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 28, 2022
.Dt TCGETPGRP 3
.Os
diff --git a/lib/libc/gen/tcsendbreak.3 b/lib/libc/gen/tcsendbreak.3
index a84148c59319..0eb132e22e8c 100644
--- a/lib/libc/gen/tcsendbreak.3
+++ b/lib/libc/gen/tcsendbreak.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tcsendbreak.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd January 11, 2017
.Dt TCSENDBREAK 3
.Os
diff --git a/lib/libc/gen/tcsetattr.3 b/lib/libc/gen/tcsetattr.3
index 9564d9e9c223..6afa90af556b 100644
--- a/lib/libc/gen/tcsetattr.3
+++ b/lib/libc/gen/tcsetattr.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94
-.\"
.Dd July 15, 2020
.Dt TCSETATTR 3
.Os
diff --git a/lib/libc/gen/tcsetpgrp.3 b/lib/libc/gen/tcsetpgrp.3
index 10af071d2b77..4ae67d4520bf 100644
--- a/lib/libc/gen/tcsetpgrp.3
+++ b/lib/libc/gen/tcsetpgrp.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tcsetpgrp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 28, 2022
.Dt TCSETPGRP 3
.Os
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index 9b60093ac472..1731cc4d7a2c 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)telldir.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <sys/param.h>
#include <sys/queue.h>
@@ -120,7 +118,7 @@ _seekdir(DIR *dirp, long loc)
struct dirent *dp;
union ddloc_packed ddloc;
off_t loc_seek;
- long loc_loc;
+ size_t loc_loc;
ddloc.l = loc;
@@ -173,7 +171,7 @@ _seekdir(DIR *dirp, long loc)
* fetching a new block to fix any such telldir locations.
*/
void
-_fixtelldir(DIR *dirp, long oldseek, long oldloc)
+_fixtelldir(DIR *dirp, off_t oldseek, size_t oldloc)
{
struct ddloc_mem *lp;
diff --git a/lib/libc/gen/telldir.h b/lib/libc/gen/telldir.h
index aafa6ac71b1e..02fd52af9060 100644
--- a/lib/libc/gen/telldir.h
+++ b/lib/libc/gen/telldir.h
@@ -46,9 +46,9 @@
*/
struct ddloc_mem {
LIST_ENTRY(ddloc_mem) loc_lqe; /* entry in list */
- long loc_index; /* key associated with structure */
+ size_t loc_index; /* key associated with structure */
off_t loc_seek; /* magic cookie returned by getdirentries */
- long loc_loc; /* offset of entry in buffer */
+ size_t loc_loc; /* offset of entry in buffer */
};
#ifdef __LP64__
@@ -102,7 +102,8 @@ bool _filldir(DIR *, bool);
struct dirent *_readdir_unlocked(DIR *, int);
void _reclaim_telldir(DIR *);
void _seekdir(DIR *, long);
-void _fixtelldir(DIR *dirp, long oldseek, long oldloc);
+void _fixtelldir(DIR *dirp, off_t oldseek, size_t oldloc);
+DIR *__opendir_common(int, int, bool);
#define RDU_SKIP 0x0001
#define RDU_SHORT 0x0002
diff --git a/lib/libc/gen/termios.c b/lib/libc/gen/termios.c
index 8f3a89188fb0..2178cc7c419d 100644
--- a/lib/libc/gen/termios.c
+++ b/lib/libc/gen/termios.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)termios.c 8.2 (Berkeley) 2/21/94");
#include "namespace.h"
#include <sys/types.h>
#include <sys/fcntl.h>
diff --git a/lib/libc/gen/time.3 b/lib/libc/gen/time.3
index 0499493a2fa0..6df74df2dcb4 100644
--- a/lib/libc/gen/time.3
+++ b/lib/libc/gen/time.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)time.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 14, 2022
.Dt TIME 3
.Os
diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c
index b46d90a11999..3f26c937d15b 100644
--- a/lib/libc/gen/time.c
+++ b/lib/libc/gen/time.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)time.c 8.1 (Berkeley) 6/4/93");
#include <sys/types.h>
#include <sys/time.h>
diff --git a/lib/libc/gen/times.3 b/lib/libc/gen/times.3
index 75b8d1957ba9..71449767b551 100644
--- a/lib/libc/gen/times.3
+++ b/lib/libc/gen/times.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)times.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 1, 2008
.Dt TIMES 3
.Os
diff --git a/lib/libc/gen/times.c b/lib/libc/gen/times.c
index e357162dcb30..b609faedc7a1 100644
--- a/lib/libc/gen/times.c
+++ b/lib/libc/gen/times.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)times.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/time.h>
#include <sys/times.h>
diff --git a/lib/libc/gen/timezone.3 b/lib/libc/gen/timezone.3
deleted file mode 100644
index 34041b93791d..000000000000
--- a/lib/libc/gen/timezone.3
+++ /dev/null
@@ -1,68 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94
-.\"
-.Dd April 19, 1994
-.Dt TIMEZONE 3
-.Os
-.Sh NAME
-.Nm timezone
-.Nd return the timezone abbreviation
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.Ft char *
-.Fn timezone "int zone" "int dst"
-.Sh DESCRIPTION
-.Bf Sy
-This interface is for compatibility only; it is impossible to reliably
-map timezone's arguments to a time zone abbreviation.
-See
-.Xr ctime 3 .
-.Ef
-.Pp
-The
-.Fn timezone
-function returns a pointer to a time zone abbreviation for the specified
-.Fa zone
-and
-.Fa dst
-values.
-The
-.Fa zone
-argument
-is the number of minutes west of GMT and
-.Fa dst
-is non-zero if daylight savings time is in effect.
-.Sh SEE ALSO
-.Xr ctime 3
-.Sh HISTORY
-A
-.Fn timezone
-function appeared in
-.At v7 .
diff --git a/lib/libc/gen/timezone.c b/lib/libc/gen/timezone.c
index e0f7d4a4ae0b..2809067eb8d8 100644
--- a/lib/libc/gen/timezone.c
+++ b/lib/libc/gen/timezone.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)timezone.c 8.1 (Berkeley) 6/4/93");
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
@@ -38,7 +36,7 @@ __SCCSID("@(#)timezone.c 8.1 (Berkeley) 6/4/93");
#include <string.h>
#define TZ_MAX_CHARS 255
-char *_tztab(int, int);
+static char *_tztab(int, int);
/*
* timezone --
@@ -51,7 +49,7 @@ char *_tztab(int, int);
static char czone[TZ_MAX_CHARS]; /* space for zone name */
char *
-timezone(int zone, int dst)
+__timezone_compat(int zone, int dst)
{
char *beg,
*end;
@@ -70,6 +68,7 @@ timezone(int zone, int dst)
}
return(_tztab(zone,dst)); /* default: table or created zone */
}
+__sym_compat(timezone, __timezone_compat, FBSD_1.0);
static struct zone {
int offset;
@@ -101,7 +100,7 @@ static struct zone {
* aren't in place in /etc. DO NOT USE THIS ROUTINE OUTSIDE OF THE
* STANDARD LIBRARY.
*/
-char *
+static char *
_tztab(int zone, int dst)
{
struct zone *zp;
diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c
index c81ef7e9ad0e..b26b13d45589 100644
--- a/lib/libc/gen/tls.c
+++ b/lib/libc/gen/tls.c
@@ -32,7 +32,6 @@
* runtime from ld-elf.so.1.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdlib.h>
#include <string.h>
@@ -81,13 +80,13 @@ static void *libc_tls_init;
void *
__libc_tls_get_addr(void *vti)
{
- uintptr_t *dtv;
+ struct dtv *dtv;
tls_index *ti;
dtv = _tcb_get()->tcb_dtv;
ti = vti;
- return ((char *)(dtv[ti->ti_module + 1] + ti->ti_offset) +
- TLS_DTV_OFFSET);
+ return (dtv->dtv_slots[ti->ti_module - 1].dtvs_tls +
+ (ti->ti_offset + TLS_DTV_OFFSET));
}
#ifdef __i386__
@@ -114,6 +113,8 @@ libc_malloc_aligned(size_t size, size_t align)
align = sizeof(void *);
mem = __je_bootstrap_malloc(size + sizeof(void *) + align - 1);
+ if (mem == NULL)
+ return (NULL);
res = (void *)roundup2((uintptr_t)mem + sizeof(void *), align);
*(void **)((uintptr_t)res - sizeof(void *)) = mem;
return (res);
@@ -150,7 +151,8 @@ libc_free_aligned(void *ptr)
* where TP points (with bias) to TLS and TCB immediately precedes TLS without
* any alignment gap[4]. Only TLS should be aligned. The TCB[0] points to DTV
* vector and DTV values are biased by constant value (TLS_DTV_OFFSET) from
- * real addresses[5].
+ * real addresses. However, like RTLD, we don't actually bias the DTV values,
+ * instead we compensate in __tls_get_addr for ti_offset's bias.
*
* [1] Ulrich Drepper: ELF Handling for Thread-Local Storage
* www.akkadia.org/drepper/tls.pdf
@@ -166,8 +168,6 @@ libc_free_aligned(void *ptr)
* but we must follow this rule due to suboptimal _tcb_set()
* (aka <ARCH>_SET_TP) implementation. This function doesn't expect TP but
* TCB as argument.
- *
- * [5] I'm not able to validate "values are biased" assertions.
*/
/*
@@ -200,11 +200,9 @@ get_tls_block_ptr(void *tcb, size_t tcbsize)
void
__libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused)
{
- Elf_Addr *dtv;
- Elf_Addr **tls;
+ struct dtv *dtv;
- tls = (Elf_Addr **)tcb;
- dtv = tls[0];
+ dtv = ((struct tcb *)tcb)->tcb_dtv;
__je_bootstrap_free(dtv);
libc_free_aligned(get_tls_block_ptr(tcb, tcbsize));
}
@@ -232,7 +230,8 @@ __libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused)
void *
__libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign)
{
- Elf_Addr *dtv, **tcb;
+ struct dtv *dtv;
+ struct tcb *tcb;
char *tls_block, *tls;
size_t extra_size, maxalign, post_size, pre_size, tls_block_size;
@@ -261,7 +260,7 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign)
abort();
}
memset(tls_block, 0, tls_block_size);
- tcb = (Elf_Addr **)(tls_block + pre_size + extra_size);
+ tcb = (struct tcb *)(tls_block + pre_size + extra_size);
tls = (char *)tcb + TLS_TCB_SIZE + post_size;
if (oldtcb != NULL) {
@@ -270,19 +269,20 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign)
libc_free_aligned(oldtcb);
/* Adjust the DTV. */
- dtv = tcb[0];
- dtv[2] = (Elf_Addr)(tls + TLS_DTV_OFFSET);
+ dtv = tcb->tcb_dtv;
+ dtv->dtv_slots[0].dtvs_tls = tls;
} else {
- dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr));
+ dtv = __je_bootstrap_malloc(sizeof(struct dtv) +
+ sizeof(struct dtv_slot));
if (dtv == NULL) {
tls_msg("__libc_allocate_tls: Out of memory.\n");
abort();
}
/* Build the DTV. */
- tcb[0] = dtv;
- dtv[0] = 1; /* Generation. */
- dtv[1] = 1; /* Segments count. */
- dtv[2] = (Elf_Addr)(tls + TLS_DTV_OFFSET);
+ tcb->tcb_dtv = dtv;
+ dtv->dtv_gen = 1; /* Generation. */
+ dtv->dtv_size = 1; /* Segments count. */
+ dtv->dtv_slots[0].dtvs_tls = tls;
if (libc_tls_init_size > 0)
memcpy(tls, libc_tls_init, libc_tls_init_size);
@@ -302,8 +302,8 @@ void
__libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign)
{
size_t size;
- Elf_Addr* dtv;
- Elf_Addr tlsstart, tlsend;
+ struct dtv *dtv;
+ uintptr_t tlsstart, tlsend;
/*
* Figure out the size of the initial TLS block so that we can
@@ -312,8 +312,8 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign)
tcbalign = MAX(tcbalign, libc_tls_init_align);
size = roundup2(libc_tls_static_space, tcbalign);
- dtv = ((Elf_Addr**)tcb)[1];
- tlsend = (Elf_Addr) tcb;
+ dtv = ((struct tcb *)tcb)->tcb_dtv;
+ tlsend = (uintptr_t)tcb;
tlsstart = tlsend - size;
libc_free_aligned((void*)tlsstart);
__je_bootstrap_free(dtv);
@@ -323,61 +323,60 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign)
* Allocate Static TLS using the Variant II method.
*/
void *
-__libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign)
+__libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign)
{
size_t size;
- char *tls;
- Elf_Addr *dtv;
- Elf_Addr segbase, oldsegbase;
+ char *tls_block, *tls;
+ struct dtv *dtv;
+ struct tcb *tcb;
tcbalign = MAX(tcbalign, libc_tls_init_align);
size = roundup2(libc_tls_static_space, tcbalign);
- if (tcbsize < 2 * sizeof(Elf_Addr))
- tcbsize = 2 * sizeof(Elf_Addr);
- tls = libc_malloc_aligned(size + tcbsize, tcbalign);
- if (tls == NULL) {
+ if (tcbsize < 2 * sizeof(uintptr_t))
+ tcbsize = 2 * sizeof(uintptr_t);
+ tls_block = libc_malloc_aligned(size + tcbsize, tcbalign);
+ if (tls_block == NULL) {
tls_msg("__libc_allocate_tls: Out of memory.\n");
abort();
}
- memset(tls, 0, size + tcbsize);
- dtv = __je_bootstrap_malloc(3 * sizeof(Elf_Addr));
+ memset(tls_block, 0, size + tcbsize);
+ dtv = __je_bootstrap_malloc(sizeof(struct dtv) +
+ sizeof(struct dtv_slot));
if (dtv == NULL) {
tls_msg("__libc_allocate_tls: Out of memory.\n");
abort();
}
- segbase = (Elf_Addr)(tls + size);
- ((Elf_Addr*)segbase)[0] = segbase;
- ((Elf_Addr*)segbase)[1] = (Elf_Addr) dtv;
+ tcb = (struct tcb *)(tls_block + size);
+ tls = (char *)tcb - libc_tls_static_space;
+ tcb->tcb_self = tcb;
+ tcb->tcb_dtv = dtv;
- dtv[0] = 1;
- dtv[1] = 1;
- dtv[2] = segbase - libc_tls_static_space;
+ dtv->dtv_gen = 1;
+ dtv->dtv_size = 1;
+ dtv->dtv_slots[0].dtvs_tls = tls;
- if (oldtls) {
+ if (oldtcb != NULL) {
/*
* Copy the static TLS block over whole.
*/
- oldsegbase = (Elf_Addr) oldtls;
- memcpy((void *)(segbase - libc_tls_static_space),
- (const void *)(oldsegbase - libc_tls_static_space),
+ memcpy(tls, (const char *)oldtcb - libc_tls_static_space,
libc_tls_static_space);
/*
* We assume that this block was the one we created with
* allocate_initial_tls().
*/
- _rtld_free_tls(oldtls, 2*sizeof(Elf_Addr), sizeof(Elf_Addr));
+ _rtld_free_tls(oldtcb, 2 * sizeof(uintptr_t),
+ sizeof(uintptr_t));
} else {
- memcpy((void *)(segbase - libc_tls_static_space),
- libc_tls_init, libc_tls_init_size);
- memset((void *)(segbase - libc_tls_static_space +
- libc_tls_init_size), 0,
+ memcpy(tls, libc_tls_init, libc_tls_init_size);
+ memset(tls + libc_tls_init_size, 0,
libc_tls_static_space - libc_tls_init_size);
}
- return (void*) segbase;
+ return (tcb);
}
#endif /* TLS_VARIANT_II */
@@ -385,7 +384,7 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign)
#else
void *
-__libc_allocate_tls(void *oldtls __unused, size_t tcbsize __unused,
+__libc_allocate_tls(void *oldtcb __unused, size_t tcbsize __unused,
size_t tcbalign __unused)
{
return (0);
diff --git a/lib/libc/gen/trivial-getcontextx.c b/lib/libc/gen/trivial-getcontextx.c
index 512e8d17e1c4..b9d4522d96ee 100644
--- a/lib/libc/gen/trivial-getcontextx.c
+++ b/lib/libc/gen/trivial-getcontextx.c
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ucontext.h>
#include <errno.h>
diff --git a/lib/libc/gen/ttyname.3 b/lib/libc/gen/ttyname.3
index 1c672f113c86..741b25946ace 100644
--- a/lib/libc/gen/ttyname.3
+++ b/lib/libc/gen/ttyname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd July 18, 2014
.Dt TTYNAME 3
.Os
diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c
index 95a713c6a0a5..f1e2f401fe5d 100644
--- a/lib/libc/gen/ttyname.c
+++ b/lib/libc/gen/ttyname.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)ttyname.c 8.2 (Berkeley) 1/27/94");
#include "namespace.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -44,6 +42,7 @@ __SCCSID("@(#)ttyname.c 8.2 (Berkeley) 1/27/94");
#include <paths.h>
#include <errno.h>
#include "reentrant.h"
+#include <ssp/ssp.h>
#include "un-namespace.h"
#include "libc_private.h"
@@ -55,7 +54,7 @@ static thread_key_t ttyname_key;
static int ttyname_keycreated = 0;
int
-ttyname_r(int fd, char *buf, size_t len)
+__ssp_real(ttyname_r)(int fd, char *buf, size_t len)
{
size_t used;
diff --git a/lib/libc/gen/ttyslot.c b/lib/libc/gen/ttyslot.c
index 6a1b5960ab86..a57b18dcf030 100644
--- a/lib/libc/gen/ttyslot.c
+++ b/lib/libc/gen/ttyslot.c
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__SCCSID("@(#)ttyslot.c 8.1 (Berkeley) 6/4/93");
+
int __ttyslot(void);
int
diff --git a/lib/libc/gen/tzset.3 b/lib/libc/gen/tzset.3
deleted file mode 100644
index 723ffc55979b..000000000000
--- a/lib/libc/gen/tzset.3
+++ /dev/null
@@ -1,325 +0,0 @@
-.\" Copyright (c) 1989, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Arthur Olson.
-.\"
-.\" 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.
-.\"
-.\" @(#)tzset.3 8.2 (Berkeley) 11/17/93
-.\"
-.Dd March 6, 2023
-.Dt TZSET 3
-.Os
-.Sh NAME
-.Nm tzset
-.Nd initialize time conversion information
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In time.h
-.Ft void
-.Fn tzset void
-.Sh DESCRIPTION
-The
-.Fn tzset
-function
-initializes time conversion information used by the library routine
-.Xr localtime 3 .
-The environment variable
-.Ev TZ
-specifies how this is done.
-.Pp
-If
-.Ev TZ
-does not appear in the environment, the best available approximation to
-local wall clock time, as specified by the
-.Xr tzfile 5 Ns -format
-file
-.Pa /etc/localtime
-is used.
-.Pp
-If
-.Ev TZ
-appears in the environment but its value is a null string, Coordinated
-Universal Time
-.Pq Tn UTC
-is used (without leap second correction).
-.Pp
-If
-.Ev TZ
-appears in the environment and its value begins with a colon
-.Pq Ql \&: ,
-the rest of its value is used as a pathname of a
-.Xr tzfile 5 Ns -format
-file from which to read the time conversion information.
-If the first character of the pathname is a slash
-.Pq Ql /
-it is used as
-an absolute pathname; otherwise, it is used as a pathname relative to
-the system time conversion information directory.
-.Pp
-If its value does not begin with a colon, it is first used as the pathname
-of a file (as described above) from which to read the time conversion
-information.
-If that file cannot be read, the value is then interpreted as a direct
-specification (the format is described below) of the time conversion
-information.
-.Pp
-If the
-.Ev TZ
-environment variable does not specify a
-.Xr tzfile 5 Ns -format
-file and cannot be interpreted as a direct specification,
-.Tn UTC
-is used.
-.Sh SPECIFICATION FORMAT
-When
-.Ev TZ
-is used directly as a specification of the time conversion information,
-it must have the following syntax (spaces inserted for clarity):
-.Bd -ragged -offset indent
-.Em std offset
-.Bo
-.Em dst
-.Bq Em offset
-.Bq , Em rule
-.Bc
-.Ed
-.Pp
-Where:
-.Bl -tag -width std_and_dst -offset indent
-.It Em std No and Em dst
-Three or more bytes that are the designation for the standard
-.Pq Em std
-or summer
-.Pq Em dst
-time zone.
-Only
-.Em std
-is required; if
-.Em dst
-is missing, then summer time does not apply in this locale.
-Upper and lowercase letters are explicitly allowed.
-Any characters
-except a leading colon
-.Pq Ql \&: ,
-digits, comma
-.Pq Ql \&, ,
-minus
-.Pq Ql \- ,
-plus
-.Pq Ql + ,
-and
-.Tn ASCII
-.Dv NUL
-are allowed.
-.It Em offset
-Indicates the value one must add to the local time to arrive at
-Coordinated Universal Time.
-The
-.Em offset
-has the form:
-.Bd -ragged -offset indent
-.Sm off
-.Em hh Bo
-.Em : mm
-.Bq Em : ss
-.Bc
-.Sm on
-.Ed
-.Pp
-The minutes
-.Pq Em mm
-and seconds
-.Pq Em ss
-are optional.
-The hour
-.Pq Em hh
-is required and may be a single digit.
-The
-.Em offset
-following
-.Em std
-is required.
-If no
-.Em offset
-follows
-.Em dst ,
-summer time is assumed to be one hour ahead of standard time.
-One or
-more digits may be used; the value is always interpreted as a decimal
-number.
-The hour must be between zero and 24, and the minutes (and
-seconds) \(em if present \(em between zero and 59.
-If preceded by a
-.Pq Ql \-
-the time zone shall be east of the Prime Meridian; otherwise it shall be
-west (which may be indicated by an optional preceding
-.Pq Ql + ) .
-.It Em rule
-Indicates when to change to and back from summer time.
-The
-.Em rule
-has the form:
-.Bd -ragged -offset indent
-.Em date/time,date/time
-.Ed
-.Pp
-where the first
-.Em date
-describes when the change from standard to summer time occurs and the
-second
-.Em date
-describes when the change back happens.
-Each
-.Em time
-field describes when, in current local time, the change to the other
-time is made.
-.Pp
-The format of
-.Em date
-is one of the following:
-.Bl -tag -width "M.m.n.d"
-.It Sy J Em n
-The Julian day
-.Em n
-(1 \*(Le
-.Em n
-\*(Le 365).
-Leap days are not counted; that is, in all years \(em including leap
-years \(em February 28 is day 59 and March 1 is day 60.
-It is
-impossible to explicitly refer to the occasional February 29.
-.It Em n
-The zero-based Julian day
-(0 \*(Le
-.Em n
-\*(Le 365 ) .
-Leap days are counted, and it is possible to refer to February 29.
-.It Sy M Em m.n.d
-The
-.Em d Ns 'th
-day (0 \*(Le
-.Em d
-\*(Le 6)
-of week
-.Em n
-of month
-.Em m
-of the year
-(1 \*(Le
-.Em n
-\*(Le 5),
-(1 \*(Le
-.Em m
-\*(Le 12),
-where week 5 means
-.Do
-the last
-.Em d
-day in month
-.Em m
-.Dc
-which may occur in either the fourth or the fifth week).
-Week 1 is the
-first week in which the
-.Em d Ns 'th
-day occurs.
-Day zero is Sunday.
-.Pp
-The
-.Em time
-has the same format as
-.Em offset
-except that no leading sign
-.Pq Ql \-
-or
-.Pq Ql +
-is allowed.
-The default, if
-.Em time
-is not given, is
-.Sy 02:00:00 .
-.El
-.Pp
-If no
-.Em rule
-is present in the
-.Ev TZ
-specification, the rules specified
-by the
-.Xr tzfile 5 Ns -format
-file
-.Em posixrules
-in the system time conversion information directory are used, with the
-standard and summer time offsets from
-.Tn UTC
-replaced by those specified by
-the
-.Em offset
-values in
-.Ev TZ .
-.El
-.Pp
-For compatibility with System V Release 3.1, a semicolon
-.Pq Ql \&;
-may be used to separate the
-.Em rule
-from the rest of the specification.
-.Sh FILES
-.Bl -tag -width /usr/share/zoneinfo/posixrules -compact
-.It Pa /etc/localtime
-local time zone file
-.It Pa /usr/share/zoneinfo
-time zone directory
-.It Pa /usr/share/zoneinfo/posixrules
-rules for
-.Tn POSIX Ns -style
-.Tn TZ Ns 's
-.It Pa /usr/share/zoneinfo/Etc/GMT
-for
-.Tn UTC
-leap seconds
-.El
-.Pp
-If the file
-.Pa /usr/share/zoneinfo/UTC
-does not exist,
-.Tn UTC
-leap seconds are loaded from
-.Pa /usr/share/zoneinfo/posixrules .
-.Sh SEE ALSO
-.Xr date 1 ,
-.Xr gettimeofday 2 ,
-.Xr ctime 3 ,
-.Xr getenv 3 ,
-.Xr time 3 ,
-.Xr tzfile 5
-.Sh HISTORY
-The
-.Fn tzset
-function first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/gen/ualarm.3 b/lib/libc/gen/ualarm.3
index d7591fdc68e9..dfd9ddd5f434 100644
--- a/lib/libc/gen/ualarm.3
+++ b/lib/libc/gen/ualarm.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)ualarm.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd April 19, 1994
.Dt UALARM 3
.Os
@@ -72,7 +70,7 @@ restriction the maximum number of
.Fa microseconds
and
.Fa interval
-is limited to 100000000000000
+is limited to 100,000,000,000,000
(in case this value fits in the unsigned integer).
.Sh RETURN VALUES
When the signal has successfully been caught,
diff --git a/lib/libc/gen/ualarm.c b/lib/libc/gen/ualarm.c
index 389e88d73bd1..44e77252202f 100644
--- a/lib/libc/gen/ualarm.c
+++ b/lib/libc/gen/ualarm.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)ualarm.c 8.1 (Berkeley) 6/4/93");
#include <sys/time.h>
#include <unistd.h>
diff --git a/lib/libc/gen/uexterr_format.c b/lib/libc/gen/uexterr_format.c
new file mode 100644
index 000000000000..e8ddfbd578e3
--- /dev/null
+++ b/lib/libc/gen/uexterr_format.c
@@ -0,0 +1,35 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#include <sys/types.h>
+#include <sys/exterrvar.h>
+#include <exterr.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+__uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz)
+{
+ if (bufsz > UEXTERROR_MAXLEN)
+ bufsz = UEXTERROR_MAXLEN;
+ if (ue->error == 0) {
+ strlcpy(buf, "", bufsz);
+ return (0);
+ }
+ if (ue->msg[0] == '\0') {
+ snprintf(buf, bufsz,
+ "errno %d category %u (src line %u) p1 %#jx p2 %#jx",
+ ue->error, ue->cat, ue->src_line,
+ (uintmax_t)ue->p1, (uintmax_t)ue->p2);
+ } else {
+ strlcpy(buf, ue->msg, bufsz);
+ }
+ return (0);
+}
diff --git a/lib/libc/gen/uexterr_gettext.c b/lib/libc/gen/uexterr_gettext.c
new file mode 100644
index 000000000000..5b8a5cd17a48
--- /dev/null
+++ b/lib/libc/gen/uexterr_gettext.c
@@ -0,0 +1,43 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <sys/exterrvar.h>
+#include <exterr.h>
+#include <string.h>
+#include "libc_private.h"
+
+static struct uexterror uexterr = {
+ .ver = UEXTERROR_VER,
+};
+
+int __getosreldate(void);
+
+static void uexterr_ctr(void) __attribute__((constructor));
+static void
+uexterr_ctr(void)
+{
+ if (__getosreldate() >= P_OSREL_EXTERRCTL)
+ exterrctl(EXTERRCTL_ENABLE, 0, &uexterr);
+}
+
+int
+__libc_uexterr_gettext(char *buf, size_t bufsz)
+{
+ return (__uexterr_format(&uexterr, buf, bufsz));
+}
+
+int
+uexterr_gettext(char *buf, size_t bufsz)
+{
+ return (((int (*)(char *, size_t))
+ __libc_interposing[INTERPOS_uexterr_gettext])(buf, bufsz));
+}
diff --git a/lib/libc/gen/uname.3 b/lib/libc/gen/uname.3
index 7b548923104f..ed1596529c4c 100644
--- a/lib/libc/gen/uname.3
+++ b/lib/libc/gen/uname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)uname.3 8.1 (Berkeley) 1/4/94
-.\"
.Dd December 2, 2005
.Dt UNAME 3
.Os
diff --git a/lib/libc/gen/uname.c b/lib/libc/gen/uname.c
index b70b3942813e..3a14ae3fefc1 100644
--- a/lib/libc/gen/uname.c
+++ b/lib/libc/gen/uname.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)uname.c 8.1 (Berkeley) 1/4/94");
#define uname wrapped_uname
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/gen/usleep.3 b/lib/libc/gen/usleep.3
deleted file mode 100644
index ec3492f2c945..000000000000
--- a/lib/libc/gen/usleep.3
+++ /dev/null
@@ -1,79 +0,0 @@
-.\" Copyright (c) 1986, 1991, 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.
-.\"
-.\" @(#)usleep.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd February 11, 2021
-.Dt USLEEP 3
-.Os
-.Sh NAME
-.Nm usleep
-.Nd suspend thread execution for an interval measured in microseconds
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn usleep "useconds_t microseconds"
-.Sh DESCRIPTION
-The
-.Fn usleep
-function suspends execution of the calling thread until either
-.Fa microseconds
-microseconds have elapsed or a signal is delivered to the thread and its
-action is to invoke a signal-catching function or to terminate the
-process.
-System activity may lengthen the sleep by an indeterminate amount.
-.Pp
-This function is implemented using
-.Xr nanosleep 2
-by pausing for
-.Fa microseconds
-microseconds or until a signal occurs.
-Consequently, in this implementation,
-sleeping has no effect on the state of process timers,
-and there is no special handling for SIGALRM.
-.Sh RETURN VALUES
-.Rv -std usleep
-.Sh ERRORS
-The
-.Fn usleep
-function
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINTR
-A signal was delivered to the calling thread and its
-action was to invoke a signal-catching function.
-.El
-.Sh SEE ALSO
-.Xr nanosleep 2 ,
-.Xr sleep 3
-.Sh HISTORY
-The
-.Fn usleep
-function appeared in
-.Bx 4.3 .
diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c
index 7a59c584d417..31d5567d562d 100644
--- a/lib/libc/gen/usleep.c
+++ b/lib/libc/gen/usleep.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)usleep.c 8.1 (Berkeley) 6/4/93");
#include "namespace.h"
#include <time.h>
#include <unistd.h>
@@ -47,8 +45,7 @@ __usleep(useconds_t useconds)
time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
time_to_sleep.tv_sec = useconds / 1000000;
- return (((int (*)(const struct timespec *, struct timespec *))
- __libc_interposing[INTERPOS_nanosleep])(&time_to_sleep, NULL));
+ return (INTERPOS_SYS(nanosleep, &time_to_sleep, NULL));
}
__weak_reference(__usleep, usleep);
diff --git a/lib/libc/gen/utime.3 b/lib/libc/gen/utime.3
index f892154f693b..e17fab908497 100644
--- a/lib/libc/gen/utime.3
+++ b/lib/libc/gen/utime.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)utime.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 9, 2016
.Dt UTIME 3
.Os
diff --git a/lib/libc/gen/utime.c b/lib/libc/gen/utime.c
index 95897b7af8f4..208c6bdae449 100644
--- a/lib/libc/gen/utime.c
+++ b/lib/libc/gen/utime.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)utime.c 8.1 (Berkeley) 6/4/93");
#include <sys/time.h>
#include <utime.h>
diff --git a/lib/libc/gen/utxdb.c b/lib/libc/gen/utxdb.c
index e831f6970295..4c4c73bffea3 100644
--- a/lib/libc/gen/utxdb.c
+++ b/lib/libc/gen/utxdb.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/endian.h>
#include <sys/param.h>
diff --git a/lib/libc/gen/valloc.3 b/lib/libc/gen/valloc.3
index bd0291988e91..063e781e3174 100644
--- a/lib/libc/gen/valloc.3
+++ b/lib/libc/gen/valloc.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)valloc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 30, 2007
.Dt VALLOC 3
.Os
diff --git a/lib/libc/gen/valloc.c b/lib/libc/gen/valloc.c
index a68c1fc0eaf9..6f3fd2d2d10c 100644
--- a/lib/libc/gen/valloc.c
+++ b/lib/libc/gen/valloc.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)valloc.c 8.1 (Berkeley) 6/4/93");
#include <stdlib.h>
#include <unistd.h>
diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c
deleted file mode 100644
index ddb2e5725c11..000000000000
--- a/lib/libc/gen/wait.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1988, 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.
- */
-
-#include <sys/cdefs.h>
-__SCCSID("@(#)wait.c 8.1 (Berkeley) 6/4/93");
-#include "namespace.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/resource.h>
-#include "un-namespace.h"
-
-#include "libc_private.h"
-
-pid_t __wait(int *);
-
-pid_t
-__wait(int *istat)
-{
-
- return (((pid_t (*)(pid_t, int *, int, struct rusage *))
- __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, 0, NULL));
-}
-
-__weak_reference(__wait, wait);
-__weak_reference(__wait, _wait);
diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c
deleted file mode 100644
index 2fdeb720296d..000000000000
--- a/lib/libc/gen/wait3.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1988, 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.
- */
-
-#include <sys/cdefs.h>
-__SCCSID("@(#)wait3.c 8.1 (Berkeley) 6/4/93");
-#include "namespace.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/resource.h>
-#include "un-namespace.h"
-
-#include "libc_private.h"
-
-pid_t __wait3(int *, int, struct rusage *);
-
-pid_t
-__wait3(int *istat, int options, struct rusage *rup)
-{
-
- return (((pid_t (*)(pid_t, int *, int, struct rusage *))
- __libc_interposing[INTERPOS_wait4])(WAIT_ANY, istat, options, rup));
-}
-
-__weak_reference(__wait3, wait3);
diff --git a/lib/libc/gen/waitid.c b/lib/libc/gen/waitid.c
deleted file mode 100644
index 018f2a2c8f94..000000000000
--- a/lib/libc/gen/waitid.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012 Jukka A. Ukkonen
- * All rights reserved.
- *
- * This software was developed by Jukka Ukkonen for FreeBSD.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <stddef.h>
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
-#include "un-namespace.h"
-#include "libc_private.h"
-
-int __waitid(idtype_t, id_t, siginfo_t *, int);
-
-int
-__waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags)
-{
- int status;
- pid_t ret;
-
- ret = ((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *,
- siginfo_t *))__libc_interposing[INTERPOS_wait6])(idtype, id,
- &status, flags, NULL, info);
-
- /*
- * According to SUSv4, waitid() shall not return a PID when a
- * process is found, but only 0. If a process was actually
- * found, siginfo_t fields si_signo and si_pid will be
- * non-zero. In case WNOHANG was set in the flags and no
- * process was found those fields are set to zero using
- * memset() below.
- */
- if (ret == 0 && info != NULL)
- memset(info, 0, sizeof(*info));
- else if (ret > 0)
- ret = 0;
- return (ret);
-}
-
-__weak_reference(__waitid, waitid);
-__weak_reference(__waitid, _waitid);
diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c
deleted file mode 100644
index 196c842c3fa1..000000000000
--- a/lib/libc/gen/waitpid.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1988, 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.
- */
-
-#include <sys/cdefs.h>
-__SCCSID("@(#)waitpid.c 8.1 (Berkeley) 6/4/93");
-#include "namespace.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <sys/resource.h>
-#include "un-namespace.h"
-
-#include "libc_private.h"
-
-pid_t __waitpid(pid_t, int *, int);
-
-pid_t
-__waitpid(pid_t pid, int *istat, int options)
-{
-
- return (((pid_t (*)(pid_t, int *, int, struct rusage *))
- __libc_interposing[INTERPOS_wait4])(pid, istat, options, NULL));
-}
-
-__weak_reference(__waitpid, waitpid);
-__weak_reference(__waitpid, _waitpid);
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index 0902814eb04f..f8080c20d121 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -27,7 +27,6 @@
*/
#include "namespace.h"
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
@@ -266,7 +265,15 @@ cleanup:
errno = serrno;
return (error);
}
- if (wpid < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
+ /*
+ * Check process exit status, but ignore ECHILD as the child may have
+ * been automatically reaped if the process had set SIG_IGN or
+ * SA_NOCLDWAIT for SIGCHLD, and our reason for waitpid was just to
+ * reap our own child on behalf of the calling process.
+ */
+ if (wpid < 0 && errno != ECHILD)
+ return (WRDE_NOSPACE); /* abort for unknown reason */
+ if (wpid >= 0 && (!WIFEXITED(status) || WEXITSTATUS(status) != 0))
return (WRDE_NOSPACE); /* abort for unknown reason */
/*
diff --git a/lib/libc/gmon/Makefile.inc b/lib/libc/gmon/Makefile.inc
index bf7acbe9848b..f70dc5692f8e 100644
--- a/lib/libc/gmon/Makefile.inc
+++ b/lib/libc/gmon/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
# gmon sources
.PATH: ${LIBC_SRCTOP}/gmon
diff --git a/lib/libc/gmon/Symbol.map b/lib/libc/gmon/Symbol.map
index 9d880afd8841..573c20020237 100644
--- a/lib/libc/gmon/Symbol.map
+++ b/lib/libc/gmon/Symbol.map
@@ -1,11 +1,7 @@
-/*
- */
-
FBSD_1.0 {
_mcleanup;
monstartup;
moncontrol;
- mexitcount;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c
index b165ec394bbe..4bc3ca7facbe 100644
--- a/lib/libc/gmon/gmon.c
+++ b/lib/libc/gmon/gmon.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93";
-#endif
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/time.h>
diff --git a/lib/libc/gmon/mcount.c b/lib/libc/gmon/mcount.c
index df87973e27f9..01b1044142f9 100644
--- a/lib/libc/gmon/mcount.c
+++ b/lib/libc/gmon/mcount.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if !defined(_KERNEL) && defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/gmon.h>
#ifdef _KERNEL
diff --git a/lib/libc/gmon/moncontrol.3 b/lib/libc/gmon/moncontrol.3
index 07a18eecd317..8548c20f7172 100644
--- a/lib/libc/gmon/moncontrol.3
+++ b/lib/libc/gmon/moncontrol.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)moncontrol.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 14, 2004
.Dt MONCONTROL 3
.Os
diff --git a/lib/libc/i386/Makefile.inc b/lib/libc/i386/Makefile.inc
index 79ecb7597547..5268afe685f5 100644
--- a/lib/libc/i386/Makefile.inc
+++ b/lib/libc/i386/Makefile.inc
@@ -1,4 +1,3 @@
-
# Long double is 80 bits
GDTOASRCS+=strtorx.c
SRCS+=machdep_ldisx.c
diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h
deleted file mode 100644
index f6966aacf237..000000000000
--- a/lib/libc/i386/SYS.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- *
- * @(#)SYS.h 5.5 (Berkeley) 5/7/91
- */
-
-#include <sys/syscall.h>
-#include <machine/asm.h>
-
-#define SYSCALL(name) ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror)
-
-#define RSYSCALL(name) SYSCALL(name); ret; END(__sys_##name)
-
-#define PSEUDO(name) ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- mov $SYS_##name,%eax; KERNCALL; \
- jb HIDENAME(cerror); ret; \
- END(__sys_##name)
-
-/* gas messes up offset -- although we don't currently need it, do for BCS */
-#define LCALL(x,y) .byte 0x9a ; .long y; .word x
-
-#define KERNCALL int $0x80
diff --git a/lib/libc/i386/Symbol.map b/lib/libc/i386/Symbol.map
index 9d6ea7fff9f3..d7961009417e 100644
--- a/lib/libc/i386/Symbol.map
+++ b/lib/libc/i386/Symbol.map
@@ -1,67 +1,21 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
.mcount;
- _setjmp;
- _longjmp;
- alloca;
- fabs;
- __flt_rounds;
- __nan;
- __infinity;
- makecontext;
- rfork_thread;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- vfork;
brk;
- i386_clr_watch;
- i386_get_fsbase;
- i386_get_gsbase;
- i386_get_ioperm;
- i386_get_ldt;
- i386_set_fsbase;
- i386_set_gsbase;
- i386_set_ioperm;
- i386_set_ldt;
- i386_set_watch;
- i386_vm86;
- sbrk;
+ __flt_rounds;
___tls_get_addr;
-};
-
-FBSD_1.6 {
- x86_pkru_get_perm;
- x86_pkru_set_perm;
- x86_pkru_protect_range;
- x86_pkru_unprotect_range;
+ sbrk;
};
FBSDprivate_1.0 {
- /* PSEUDO syscalls */
- _getlogin;
-
___longjmp;
- __makecontext;
__longjmp;
__signalcontext;
signalcontext;
__siglongjmp;
- _vfork;
_brk;
};
diff --git a/lib/libc/i386/gen/Makefile.inc b/lib/libc/i386/gen/Makefile.inc
index e89127bdae38..e3d36c0a1ade 100644
--- a/lib/libc/i386/gen/Makefile.inc
+++ b/lib/libc/i386/gen/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
SRCS+= _ctx_start.S _setjmp.S fabs.S \
flt_rounds.c infinity.c ldexp.c makecontext.c \
- rfork_thread.S setjmp.S signalcontext.c sigsetjmp.S
+ setjmp.S signalcontext.c sigsetjmp.S
diff --git a/lib/libc/i386/gen/_setjmp.S b/lib/libc/i386/gen/_setjmp.S
index f61183dffbac..0d00bf7a998f 100644
--- a/lib/libc/i386/gen/_setjmp.S
+++ b/lib/libc/i386/gen/_setjmp.S
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)_setjmp.s 5.1 (Berkeley) 4/23/90"
-#endif /* LIBC_SCCS and not lint */
#include <machine/asm.h>
/*
* C library -- _setjmp, _longjmp
diff --git a/lib/libc/i386/gen/fabs.S b/lib/libc/i386/gen/fabs.S
index 15558a0ebede..d19cfd24ccc1 100644
--- a/lib/libc/i386/gen/fabs.S
+++ b/lib/libc/i386/gen/fabs.S
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)fabs.s 5.2 (Berkeley) 12/17/90"
-#endif /* LIBC_SCCS and not lint */
#include <machine/asm.h>
ENTRY(fabs)
fldl 4(%esp)
diff --git a/lib/libc/i386/gen/flt_rounds.c b/lib/libc/i386/gen/flt_rounds.c
index 6212dbf20918..cebd8e1eb098 100644
--- a/lib/libc/i386/gen/flt_rounds.c
+++ b/lib/libc/i386/gen/flt_rounds.c
@@ -3,7 +3,6 @@
* Public domain.
*/
-#include <sys/cdefs.h>
#include <float.h>
static const int map[] = {
diff --git a/lib/libc/i386/gen/infinity.c b/lib/libc/i386/gen/infinity.c
index b9db2fc84efa..bc05708abd2b 100644
--- a/lib/libc/i386/gen/infinity.c
+++ b/lib/libc/i386/gen/infinity.c
@@ -2,7 +2,6 @@
* infinity.c
*/
-#include <sys/cdefs.h>
#include <math.h>
/* bytes for +Infinity on a 387 */
diff --git a/lib/libc/i386/gen/makecontext.c b/lib/libc/i386/gen/makecontext.c
index b710a7136788..7b4845ac6bee 100644
--- a/lib/libc/i386/gen/makecontext.c
+++ b/lib/libc/i386/gen/makecontext.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/ucontext.h>
diff --git a/lib/libc/i386/gen/rfork_thread.S b/lib/libc/i386/gen/rfork_thread.S
deleted file mode 100644
index e4d3b904d523..000000000000
--- a/lib/libc/i386/gen/rfork_thread.S
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * Copyright (c) 2000 Peter Wemm <peter@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.
- */
-
-#include <machine/asm.h>
-/*
- * With thanks to John Dyson for the original version of this.
- */
-
-#include <SYS.h>
-
-/*
- * 8 12 16 20
- * rfork_thread(flags, stack_addr, start_fnc, start_arg);
- *
- * flags: Flags to rfork system call. See rfork(2).
- * stack_addr: Top of stack for thread.
- * start_fnc: Address of thread function to call in child.
- * start_arg: Argument to pass to the thread function in child.
- */
-
-ENTRY(rfork_thread)
- pushl %ebp
- movl %esp, %ebp
- pushl %esi
-
- /*
- * Push thread info onto the new thread's stack
- */
- movl 12(%ebp), %esi # get stack addr
-
- subl $4, %esi
- movl 20(%ebp), %eax # get start argument
- movl %eax, (%esi)
-
- subl $4, %esi
- movl 16(%ebp), %eax # get start thread address
- movl %eax, (%esi)
-
- /*
- * Prepare and execute the thread creation syscall
- */
- pushl 8(%ebp)
- pushl $0
- movl $SYS_rfork, %eax
- KERNCALL
- jb 2f
-
- /*
- * Check to see if we are in the parent or child
- */
- cmpl $0, %edx
- jnz 1f
- addl $8, %esp
- popl %esi
- movl %ebp, %esp
- popl %ebp
- ret
- .p2align 2
-
- /*
- * If we are in the child (new thread), then
- * set-up the call to the internal subroutine. If it
- * returns, then call __exit.
- */
-1:
- movl %esi,%esp
- popl %eax
- call *%eax
- addl $4, %esp
-
- /*
- * Exit system call
- */
- pushl %eax
- pushl $0
- movl $SYS_exit, %eax
- KERNCALL
-
- /*
- * Branch here if the thread creation fails:
- */
-2:
- addl $8, %esp
- popl %esi
- movl %ebp, %esp
- popl %ebp
- jmp HIDENAME(cerror)
-END(rfork_thread)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/i386/gen/setjmp.S b/lib/libc/i386/gen/setjmp.S
index 070bc7e88bcf..e16f01d02f20 100644
--- a/lib/libc/i386/gen/setjmp.S
+++ b/lib/libc/i386/gen/setjmp.S
@@ -30,9 +30,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
- .asciz "@(#)setjmp.s 5.1 (Berkeley) 4/23/90"
-#endif /* LIBC_SCCS and not lint */
#include <machine/asm.h>
/*
* C library -- _setjmp, _longjmp
diff --git a/lib/libc/i386/gen/signalcontext.c b/lib/libc/i386/gen/signalcontext.c
index 1e77ffe1a1a2..38b306501c3c 100644
--- a/lib/libc/i386/gen/signalcontext.c
+++ b/lib/libc/i386/gen/signalcontext.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ucontext.h>
#include <machine/psl.h>
diff --git a/lib/libc/i386/gen/sigsetjmp.S b/lib/libc/i386/gen/sigsetjmp.S
index 8aef3d1d90ee..588788f32e0a 100644
--- a/lib/libc/i386/gen/sigsetjmp.S
+++ b/lib/libc/i386/gen/sigsetjmp.S
@@ -28,8 +28,6 @@
* 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.
- *
- * @(#)setjmp.s 5.1 (Berkeley) 4/23/90"
*/
#if defined(LIBC_SCCS) && !defined(lint)
diff --git a/lib/libc/i386/static_tls.h b/lib/libc/i386/static_tls.h
deleted file mode 100644
index baf9dfc59a5a..000000000000
--- a/lib/libc/i386/static_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_I386_STATIC_TLS_H
-#define _LIBC_I386_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("movl %%gs:0, %0" : "=r" (tlsbase));
- tlsbase -= offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/i386/stdlib/Makefile.inc b/lib/libc/i386/stdlib/Makefile.inc
index 959aedcf85ed..21e1af04fd8d 100644
--- a/lib/libc/i386/stdlib/Makefile.inc
+++ b/lib/libc/i386/stdlib/Makefile.inc
@@ -1,3 +1 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
MDSRCS+=div.S ldiv.S
diff --git a/lib/libc/i386/string/Makefile.inc b/lib/libc/i386/string/Makefile.inc
index 391b81be4d68..bbb4320a5b05 100644
--- a/lib/libc/i386/string/Makefile.inc
+++ b/lib/libc/i386/string/Makefile.inc
@@ -1,4 +1,3 @@
-
MDSRCS+= \
bcmp.S \
bcopy.S \
diff --git a/lib/libc/i386/sys/Makefile.inc b/lib/libc/i386/sys/Makefile.inc
deleted file mode 100644
index f89099385dc9..000000000000
--- a/lib/libc/i386/sys/Makefile.inc
+++ /dev/null
@@ -1,16 +0,0 @@
-# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp
-
-SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \
- i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c \
- i386_clr_watch.c i386_set_watch.c i386_vm86.c
-
-MDASM= Ovfork.S cerror.S getcontext.S syscall.S
-
-NOASM+= sbrk.o vfork.o
-
-MAN+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2
-MAN+= i386_set_watch.3
-
-MLINKS+=i386_get_ioperm.2 i386_set_ioperm.2
-MLINKS+=i386_get_ldt.2 i386_set_ldt.2
-MLINKS+=i386_set_watch.3 i386_clr_watch.3
diff --git a/lib/libc/i386/sys/Ovfork.S b/lib/libc/i386/sys/Ovfork.S
deleted file mode 100644
index 96232222e121..000000000000
--- a/lib/libc/i386/sys/Ovfork.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- */
-
-#if defined(SYSLIBC_SCCS) && !defined(lint)
- .asciz "@(#)Ovfork.s 5.1 (Berkeley) 4/23/90"
-#endif /* SYSLIBC_SCCS and not lint */
-#include <machine/asm.h>
-#include "SYS.h"
-
- WEAK_REFERENCE(__sys_vfork, _vfork)
- WEAK_REFERENCE(__sys_vfork, vfork)
-ENTRY(__sys_vfork)
- popl %ecx /* my rta into ecx */
- mov $SYS_vfork,%eax
- KERNCALL
- jb 1f
- jmp *%ecx
-1:
- pushl %ecx
- jmp HIDENAME(cerror)
-END(__sys_vfork)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/i386/sys/cerror.S b/lib/libc/i386/sys/cerror.S
deleted file mode 100644
index 6570fb3c7c3f..000000000000
--- a/lib/libc/i386/sys/cerror.S
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- */
-
-#if defined(SYSLIBC_SCCS) && !defined(lint)
- .asciz "@(#)cerror.s 5.1 (Berkeley) 4/23/90"
-#endif /* SYSLIBC_SCCS and not lint */
-#include <machine/asm.h>
-#include "SYS.h"
-
- .globl HIDENAME(cerror)
- .hidden HIDENAME(cerror)
-
- /*
- * The __error() function is thread aware. For non-threaded
- * programs and the initial thread in threaded programs,
- * it returns a pointer to the global errno variable.
- */
- .globl CNAME(__error)
- .type CNAME(__error),@function
-HIDENAME(cerror):
-#ifdef PIC
- PIC_PROLOGUE
- pushl %eax
- call PIC_PLT(CNAME(__error))
- popl %ecx
- PIC_EPILOGUE
-#else
- pushl %eax
- call CNAME(__error)
- popl %ecx
-#endif
- movl %ecx,(%eax)
- movl $-1,%eax
- movl $-1,%edx
- ret
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/i386/sys/getcontext.S b/lib/libc/i386/sys/getcontext.S
deleted file mode 100644
index 8baf0caf18fd..000000000000
--- a/lib/libc/i386/sys/getcontext.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2003 Peter Wemm <peter@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.
- */
-
-#include <machine/asm.h>
-#include <SYS.h>
-
-/*
- * This has to be magic to handle the multiple returns.
- * Otherwise, the setcontext() syscall will return here and we'll
- * pop off the return address and go to the *setcontext* call.
- */
- WEAK_REFERENCE(__sys_getcontext, _getcontext)
- WEAK_REFERENCE(__sys_getcontext, getcontext)
-ENTRY(__sys_getcontext)
- movl (%esp),%ecx /* save getcontext return address */
- mov $SYS_getcontext,%eax
- KERNCALL
- jb HIDENAME(cerror)
- addl $4,%esp /* remove stale (setcontext) return address */
- jmp *%ecx /* restore return address */
-END(__sys_getcontext)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/i386/sys/i386_clr_watch.c b/lib/libc/i386/sys/i386_clr_watch.c
deleted file mode 100644
index 07b85795fba4..000000000000
--- a/lib/libc/i386/sys/i386_clr_watch.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright 2000 Brian S. Dean <bsd@bsdhome.com>
- * 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 BRIAN S. DEAN ``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 BRIAN S. DEAN BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <machine/reg.h>
-#include <machine/sysarch.h>
-
-int
-i386_clr_watch(int watchnum, struct dbreg * d)
-{
-
- if (watchnum < 0 || watchnum >= 4)
- return -1;
-
- DBREG_DRX(d,7) = DBREG_DRX(d,7) & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
- DBREG_DRX(d,watchnum) = 0;
-
- return 0;
-}
diff --git a/lib/libc/i386/sys/i386_get_fsbase.c b/lib/libc/i386/sys/i386_get_fsbase.c
deleted file mode 100644
index f12a2383cc3e..000000000000
--- a/lib/libc/i386/sys/i386_get_fsbase.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2005 Peter Wemm
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_get_fsbase(void **addr)
-{
-
- return (sysarch(I386_GET_FSBASE, addr));
-}
diff --git a/lib/libc/i386/sys/i386_get_gsbase.c b/lib/libc/i386/sys/i386_get_gsbase.c
deleted file mode 100644
index efe43d383b4f..000000000000
--- a/lib/libc/i386/sys/i386_get_gsbase.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2005 Peter Wemm
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_get_gsbase(void **addr)
-{
-
- return (sysarch(I386_GET_GSBASE, addr));
-}
diff --git a/lib/libc/i386/sys/i386_get_ioperm.c b/lib/libc/i386/sys/i386_get_ioperm.c
deleted file mode 100644
index 9d8e8d31862b..000000000000
--- a/lib/libc/i386/sys/i386_get_ioperm.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 1998 Jonathan Lemon
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_get_ioperm(unsigned int start, unsigned int *length, int *enable)
-{
- struct i386_ioperm_args p;
- int error;
-
- p.start = start;
- p.length = *length;
- p.enable = *enable;
-
- error = sysarch(I386_GET_IOPERM, &p);
-
- *length = p.length;
- *enable = p.enable;
-
- return (error);
-}
diff --git a/lib/libc/i386/sys/i386_get_ldt.2 b/lib/libc/i386/sys/i386_get_ldt.2
deleted file mode 100644
index c025aa684630..000000000000
--- a/lib/libc/i386/sys/i386_get_ldt.2
+++ /dev/null
@@ -1,138 +0,0 @@
-.\" Copyright (c) 1980, 1991 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.
-.\"
-.\" from: @(#)fork.2 6.5 (Berkeley) 3/10/91
-.\"
-.Dd October 14, 2006
-.Dt I386_GET_LDT 2
-.Os
-.Sh NAME
-.Nm i386_get_ldt ,
-.Nm i386_set_ldt
-.Nd manage i386 per-process Local Descriptor Table entries
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In machine/segments.h
-.In machine/sysarch.h
-.Ft int
-.Fn i386_get_ldt "int start_sel" "union descriptor *descs" "int num_sels"
-.Ft int
-.Fn i386_set_ldt "int start_sel" "union descriptor *descs" "int num_sels"
-.Sh DESCRIPTION
-The
-.Fn i386_get_ldt
-system call
-returns a list of the i386 descriptors in the current process'
-LDT.
-The
-.Fn i386_set_ldt
-system call
-sets a list of i386 descriptors in the current process'
-LDT.
-For both routines,
-.Fa start_sel
-specifies the index of the selector in the LDT at which to begin and
-.Fa descs
-points to an array of
-.Fa num_sels
-descriptors to be set or returned.
-.Pp
-Each entry in the
-.Fa descs
-array can be either a segment_descriptor or gate_descriptor and are defined in
-.In i386/segments.h .
-These structures are defined by the architecture
-as disjoint bit-fields, so care must be taken in constructing them.
-.Pp
-If
-.Fa start_sel
-is
-.Em LDT_AUTO_ALLOC ,
-.Fa num_sels
-is 1 and the descriptor pointed to by
-.Fa descs
-is legal, then
-.Fn i386_set_ldt
-will allocate a descriptor and return its
-selector number.
-.Pp
-If
-.Fa num_descs
-is 1,
-.Fa start_sels
-is valid, and
-.Fa descs
-is NULL, then
-.Fn i386_set_ldt
-will free that descriptor
-(making it available to be reallocated again later).
-.Pp
-If
-.Fa num_descs
-is 0,
-.Fa start_sels
-is 0 and
-.Fa descs
-is NULL then, as a special case,
-.Fn i386_set_ldt
-will free all descriptors.
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn i386_get_ldt
-returns the number of descriptors currently in the LDT.
-The
-.Fn i386_set_ldt
-system call
-returns the first selector set on success.
-If the kernel allocated a descriptor in the LDT,
-the allocated index is returned.
-Otherwise, a value of -1 is returned and the global
-variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn i386_get_ldt
-and
-.Fn i386_set_ldt
-system calls
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-An inappropriate value was used for
-.Fa start_sel
-or
-.Fa num_sels .
-.It Bq Er EACCES
-The caller attempted to use a descriptor that would
-circumvent protection or cause a failure.
-.El
-.Sh SEE ALSO
-i386 Microprocessor Programmer's Reference Manual, Intel
-.Sh WARNING
-You can really hose your process using this.
diff --git a/lib/libc/i386/sys/i386_get_ldt.c b/lib/libc/i386/sys/i386_get_ldt.c
deleted file mode 100644
index 52daefd85de5..000000000000
--- a/lib/libc/i386/sys/i386_get_ldt.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1993 John Brezak
- * 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. 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/cdefs.h>
-#include <machine/segments.h>
-#include <machine/sysarch.h>
-
-int
-i386_get_ldt(int start, union descriptor *descs, int num)
-{
- struct i386_ldt_args p;
-
- p.start = start;
- p.descs = descs;
- p.num = num;
-
- return sysarch(I386_GET_LDT, &p);
-}
diff --git a/lib/libc/i386/sys/i386_set_fsbase.c b/lib/libc/i386/sys/i386_set_fsbase.c
deleted file mode 100644
index 81a4ed761a7e..000000000000
--- a/lib/libc/i386/sys/i386_set_fsbase.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2005 Peter Wemm
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_set_fsbase(void *addr)
-{
-
- return (sysarch(I386_SET_FSBASE, &addr));
-}
diff --git a/lib/libc/i386/sys/i386_set_gsbase.c b/lib/libc/i386/sys/i386_set_gsbase.c
deleted file mode 100644
index 8a584435e4c7..000000000000
--- a/lib/libc/i386/sys/i386_set_gsbase.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2005 Peter Wemm
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_set_gsbase(void *addr)
-{
-
- return (sysarch(I386_SET_GSBASE, &addr));
-}
diff --git a/lib/libc/i386/sys/i386_set_ioperm.c b/lib/libc/i386/sys/i386_set_ioperm.c
deleted file mode 100644
index dead1cae262a..000000000000
--- a/lib/libc/i386/sys/i386_set_ioperm.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 1998 Jonathan Lemon
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_set_ioperm(unsigned int start, unsigned int length, int enable)
-{
- struct i386_ioperm_args p;
-
- p.start = start;
- p.length = length;
- p.enable = enable;
-
- return (sysarch(I386_SET_IOPERM, &p));
-}
diff --git a/lib/libc/i386/sys/i386_set_ldt.c b/lib/libc/i386/sys/i386_set_ldt.c
deleted file mode 100644
index 578b7f4d2f06..000000000000
--- a/lib/libc/i386/sys/i386_set_ldt.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1993 John Brezak
- * 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. 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/cdefs.h>
-#include <machine/segments.h>
-#include <machine/sysarch.h>
-
-int
-i386_set_ldt(int start, union descriptor *descs, int num)
-{
- struct i386_ldt_args p;
-
- p.start = start;
- p.descs = descs;
- p.num = num;
-
- return sysarch(I386_SET_LDT, &p);
-}
diff --git a/lib/libc/i386/sys/i386_set_watch.3 b/lib/libc/i386/sys/i386_set_watch.3
deleted file mode 100644
index 68c46e0ec081..000000000000
--- a/lib/libc/i386/sys/i386_set_watch.3
+++ /dev/null
@@ -1,116 +0,0 @@
-.\" Copyright (c) 2000 Brian S. Dean
-.\" All rights reserved.
-.\"
-.\" This man-page is based on a similar man-page by Jonathan Lemon
-.\" which is copyrighted under the following conditions:
-.\"
-.\" 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.
-.\"
-.Dd August 24, 2000
-.Dt I386_SET_WATCH 3
-.Os
-.Sh NAME
-.Nm i386_clr_watch ,
-.Nm i386_set_watch
-.Nd manage i386 debug register values
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In machine/reg.h
-.In machine/sysarch.h
-.Ft int
-.Fn i386_clr_watch "int watchnum" "struct dbreg *d"
-.Ft int
-.Fn i386_set_watch "int watchnum" "unsigned int watchaddr" "int size" "int access" "struct dbreg *d"
-.Sh DESCRIPTION
-The
-.Fn i386_clr_watch
-function
-will disable the indicated watch point within the specified debug
-register set.
-.Pp
-The
-.Fn i386_set_watch
-function
-will set up the specified debug registers as indicated by the
-arguments.
-The
-.Fa watchnum
-argument specifies which watch register is used, 0, 1, 2, 3, or \-1.
-If
-.Fa watchnum
-is \-1, a free watch register is found and used.
-If there are no free
-watch registers, an error code of \-1 is returned.
-The
-.Fa watchaddr
-argument
-specifies the watch address,
-.Fa size
-specifies the size in bytes of the area to be watched (1, 2, or 4 bytes),
-and
-.Fa access
-specifies the type of watch point:
-.Pp
-.Bd -literal -offset indent -compact
-DBREG_DR7_EXEC An execution breakpoint.
-DBREG_DR7_WRONLY Break only when the watch area is written to.
-DBREG_DR7_RDWR Break when the watch area is read from or written
- to.
-.Ed
-.Pp
-Note that these functions do not actually set or clear breakpoints;
-they manipulate the indicated debug register set.
-You must use
-.Xr ptrace 2
-to retrieve and install the debug register values for a process.
-.Sh RETURN VALUES
-On success, the
-.Fn i386_clr_watch
-function returns 0.
-On error, \-1 returned which indicates that
-.Fa watchnum
-is invalid (not in the range of 0-3).
-If the specified watchnum was already disabled, no error is returned.
-.Pp
-On success, the
-.Fn i386_set_watch
-function returns the
-.Fa watchnum
-argument, or the watchnum actually used in the case where the specified
-.Fa watchnum
-was \-1.
-On error, the
-.Fn i386_set_watch
-function returns \-1 indicating that the watchpoint could not established
-because either no more watchpoints are available, or
-.Fa watchnum ,
-.Fa size ,
-or
-.Fa access
-is invalid.
-.Sh SEE ALSO
-.Xr ptrace 2 ,
-.Xr procfs 5
-.Sh AUTHORS
-This man page was written by
-.An Brian S. Dean .
diff --git a/lib/libc/i386/sys/i386_set_watch.c b/lib/libc/i386/sys/i386_set_watch.c
deleted file mode 100644
index 7b341e099c6b..000000000000
--- a/lib/libc/i386/sys/i386_set_watch.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright 2000 Brian S. Dean <bsd@bsdhome.com>
- * 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 BRIAN S. DEAN ``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 BRIAN S. DEAN BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <machine/reg.h>
-#include <machine/sysarch.h>
-
-int
-i386_set_watch(int watchnum, unsigned int watchaddr, int size,
- int access, struct dbreg * d)
-{
- int i;
- unsigned int mask;
-
- if (watchnum == -1) {
- for (i = 0, mask = 0x3; i < 4; i++, mask <<= 2)
- if ((DBREG_DRX(d,7) & mask) == 0)
- break;
- if (i < 4)
- watchnum = i;
- else
- return -1;
- }
-
- switch (access) {
- case DBREG_DR7_EXEC:
- size = 1; /* size must be 1 for an execution breakpoint */
- /* fall through */
- case DBREG_DR7_WRONLY:
- case DBREG_DR7_RDWR:
- break;
- default : return -1; break;
- }
-
- /*
- * we can watch a 1, 2, or 4 byte sized location
- */
- switch (size) {
- case 1 : mask = 0x00; break;
- case 2 : mask = 0x01 << 2; break;
- case 4 : mask = 0x03 << 2; break;
- default : return -1; break;
- }
-
- mask |= access;
-
- /* clear the bits we are about to affect */
- DBREG_DRX(d,7) &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
-
- /* set drN register to the address, N=watchnum */
- DBREG_DRX(d,watchnum) = watchaddr;
-
- /* enable the watchpoint */
- DBREG_DRX(d,7) |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16));
-
- return watchnum;
-}
diff --git a/lib/libc/i386/sys/i386_vm86.c b/lib/libc/i386/sys/i386_vm86.c
deleted file mode 100644
index e5d942d37131..000000000000
--- a/lib/libc/i386/sys/i386_vm86.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 1998 Jonathan Lemon
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <machine/sysarch.h>
-
-int
-i386_vm86(int fcn, void *data)
-{
- struct i386_vm86_args p;
-
- p.sub_op = fcn;
- p.sub_args = (char *)data;
-
- return (sysarch(I386_VM86, &p));
-}
diff --git a/lib/libc/i386/sys/syscall.S b/lib/libc/i386/sys/syscall.S
deleted file mode 100644
index c6b1d38960a8..000000000000
--- a/lib/libc/i386/sys/syscall.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- */
-
-#if defined(SYSLIBC_SCCS) && !defined(lint)
- .asciz "@(#)syscall.s 5.1 (Berkeley) 4/23/90"
-#endif /* SYSLIBC_SCCS and not lint */
-#include <machine/asm.h>
-#include "SYS.h"
-
-ENTRY(syscall)
- pop %ecx /* rta */
- pop %eax /* syscall number */
- push %ecx
- KERNCALL
- push %ecx /* need to push a word to keep stack frame intact
- upon return; the word must be the return address. */
- jb HIDENAME(cerror)
- ret
-END(syscall)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/iconv/Makefile.inc b/lib/libc/iconv/Makefile.inc
index 1e23f1a6fc94..08c2763c8f0d 100644
--- a/lib/libc/iconv/Makefile.inc
+++ b/lib/libc/iconv/Makefile.inc
@@ -1,4 +1,3 @@
-
# iconv sources
.PATH: ${LIBC_SRCTOP}/iconv
diff --git a/lib/libc/iconv/Symbol.map b/lib/libc/iconv/Symbol.map
index f883fe0d3e87..d36e0733a4f0 100644
--- a/lib/libc/iconv/Symbol.map
+++ b/lib/libc/iconv/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.3 {
__bsd___iconv;
__bsd___iconv_free_list;
@@ -18,15 +15,6 @@ FBSD_1.3 {
FBSDprivate_1.0 {
_citrus_bcs_convert_to_lower;
_citrus_bcs_convert_to_upper;
- _citrus_bcs_isalnum;
- _citrus_bcs_isalpha;
- _citrus_bcs_isblank;
- _citrus_bcs_isdigit;
- _citrus_bcs_iseol;
- _citrus_bcs_islower;
- _citrus_bcs_isspace;
- _citrus_bcs_isupper;
- _citrus_bcs_isxdigit;
_citrus_bcs_skip_nonws;
_citrus_bcs_skip_nonws_len;
_citrus_bcs_skip_ws;
@@ -35,12 +23,8 @@ FBSDprivate_1.0 {
_citrus_bcs_strncasecmp;
_citrus_bcs_strtol;
_citrus_bcs_strtoul;
- _citrus_bcs_tolower;
- _citrus_bcs_toupper;
_citrus_bcs_trunc_rws_len;
- _citrus_bcs_trunc_ws_len;
_citrus_csmapper_open;
- _citrus_csmapper_close;
_citrus_db_factory_add_by_string;
_citrus_db_factory_add_string_by_string;
_citrus_db_factory_add32_by_string;
@@ -62,41 +46,16 @@ FBSDprivate_1.0 {
_citrus_lookup_factory_convert;
_citrus_map_file;
_citrus_mapper_close;
- _citrus_mapper_convert;
_citrus_mapper_create_area;
- _citrus_mapper_get_dst_max;
- _citrus_mapper_get_src_max;
- _citrus_mapper_get_state_size;
- _citrus_mapper_init_state;
_citrus_mapper_open;
_citrus_mapper_open_direct;
_citrus_mapper_set_persistent;
- _citrus_memory_stream_bind;
_citrus_memory_stream_chr;
- _citrus_memory_stream_getc;
_citrus_memory_stream_getln;
- _citrus_memory_stream_getln_region;
- _citrus_memory_stream_getregion;
- _citrus_memory_stream_iseof;
_citrus_memory_stream_matchline;
- _citrus_memory_stream_peek;
- _citrus_memory_stream_remainder;
- _citrus_memory_stream_rewind;
- _citrus_memory_stream_seek;
_citrus_memory_stream_skip_ws;
- _citrus_memory_stream_tell;
- _citrus_memory_stream_ungetc;
_citrus_pivot_factory_convert;
- _citrus_prop_object_init;
- _citrus_prop_object_uninit;
_citrus_prop_parse_variable;
- _citrus_prop_read_bool;
- _citrus_prop_read_character;
- _citrus_prop_read_character_common;
- _citrus_prop_read_element;
- _citrus_prop_read_num;
- _citrus_prop_read_str;
- _citrus_prop_read_symbol;
_citrus_stdenc_close;
_citrus_stdenc_open;
_citrus_unmap_file;
diff --git a/lib/libc/iconv/bsd_iconv.c b/lib/libc/iconv/bsd_iconv.c
index fe2491d665dd..d3da6fd1a271 100644
--- a/lib/libc/iconv/bsd_iconv.c
+++ b/lib/libc/iconv/bsd_iconv.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include <sys/types.h>
diff --git a/lib/libc/iconv/citrus_bcs.c b/lib/libc/iconv/citrus_bcs.c
index 9e7cb8c0749f..8409e1fbac7b 100644
--- a/lib/libc/iconv/citrus_bcs.c
+++ b/lib/libc/iconv/citrus_bcs.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdlib.h>
diff --git a/lib/libc/iconv/citrus_bcs_strtol.c b/lib/libc/iconv/citrus_bcs_strtol.c
index c1273acba344..55d4d1ca565d 100644
--- a/lib/libc/iconv/citrus_bcs_strtol.c
+++ b/lib/libc/iconv/citrus_bcs_strtol.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/iconv/citrus_bcs_strtoul.c b/lib/libc/iconv/citrus_bcs_strtoul.c
index 0ea896d90b0e..280397a72428 100644
--- a/lib/libc/iconv/citrus_bcs_strtoul.c
+++ b/lib/libc/iconv/citrus_bcs_strtoul.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/iconv/citrus_csmapper.c b/lib/libc/iconv/citrus_csmapper.c
index e59ccfb3f02a..642abafbe9a2 100644
--- a/lib/libc/iconv/citrus_csmapper.c
+++ b/lib/libc/iconv/citrus_csmapper.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/endian.h>
#include <sys/types.h>
#include <sys/queue.h>
diff --git a/lib/libc/iconv/citrus_db.c b/lib/libc/iconv/citrus_db.c
index 4a89a9cb86f4..bb74668a2d4c 100644
--- a/lib/libc/iconv/citrus_db.c
+++ b/lib/libc/iconv/citrus_db.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/endian.h>
#include <sys/types.h>
diff --git a/lib/libc/iconv/citrus_db_factory.c b/lib/libc/iconv/citrus_db_factory.c
index 589c1f43a60b..c1753195c767 100644
--- a/lib/libc/iconv/citrus_db_factory.c
+++ b/lib/libc/iconv/citrus_db_factory.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/queue.h>
diff --git a/lib/libc/iconv/citrus_db_hash.c b/lib/libc/iconv/citrus_db_hash.c
index 9e9918e38655..24b7213ee268 100644
--- a/lib/libc/iconv/citrus_db_hash.c
+++ b/lib/libc/iconv/citrus_db_hash.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_esdb.c b/lib/libc/iconv/citrus_esdb.c
index 15c107566101..65b518f838c6 100644
--- a/lib/libc/iconv/citrus_esdb.c
+++ b/lib/libc/iconv/citrus_esdb.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_hash.c b/lib/libc/iconv/citrus_hash.c
index 9dcf86354b3d..3a34efde3044 100644
--- a/lib/libc/iconv/citrus_hash.c
+++ b/lib/libc/iconv/citrus_hash.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_iconv.c b/lib/libc/iconv/citrus_iconv.c
index a2ff7b5177c8..e785e6721968 100644
--- a/lib/libc/iconv/citrus_iconv.c
+++ b/lib/libc/iconv/citrus_iconv.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/queue.h>
diff --git a/lib/libc/iconv/citrus_lookup.c b/lib/libc/iconv/citrus_lookup.c
index 4d66a7d53ef2..ed224001bffb 100644
--- a/lib/libc/iconv/citrus_lookup.c
+++ b/lib/libc/iconv/citrus_lookup.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_lookup_factory.c b/lib/libc/iconv/citrus_lookup_factory.c
index c2afe1d869b8..59b119e24872 100644
--- a/lib/libc/iconv/citrus_lookup_factory.c
+++ b/lib/libc/iconv/citrus_lookup_factory.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <ctype.h>
diff --git a/lib/libc/iconv/citrus_mapper.c b/lib/libc/iconv/citrus_mapper.c
index 5b919a9e9c92..45ea2d65de48 100644
--- a/lib/libc/iconv/citrus_mapper.c
+++ b/lib/libc/iconv/citrus_mapper.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/queue.h>
diff --git a/lib/libc/iconv/citrus_memstream.c b/lib/libc/iconv/citrus_memstream.c
index 25ab088ee413..10918bf2c5e0 100644
--- a/lib/libc/iconv/citrus_memstream.c
+++ b/lib/libc/iconv/citrus_memstream.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdio.h>
diff --git a/lib/libc/iconv/citrus_mmap.c b/lib/libc/iconv/citrus_mmap.c
index b48242d94d38..7686a389edec 100644
--- a/lib/libc/iconv/citrus_mmap.c
+++ b/lib/libc/iconv/citrus_mmap.c
@@ -29,7 +29,6 @@
*/
#include "namespace.h"
-#include <sys/cdefs.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/iconv/citrus_module.c b/lib/libc/iconv/citrus_module.c
index 24ad16246be6..1d862ed6ccad 100644
--- a/lib/libc/iconv/citrus_module.c
+++ b/lib/libc/iconv/citrus_module.c
@@ -89,7 +89,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_none.c b/lib/libc/iconv/citrus_none.c
index 3ae0a236f8f1..194d78853955 100644
--- a/lib/libc/iconv/citrus_none.c
+++ b/lib/libc/iconv/citrus_none.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_pivot_factory.c b/lib/libc/iconv/citrus_pivot_factory.c
index 8441ae3c5cdb..ed5e6863beab 100644
--- a/lib/libc/iconv/citrus_pivot_factory.c
+++ b/lib/libc/iconv/citrus_pivot_factory.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include <assert.h>
diff --git a/lib/libc/iconv/citrus_prop.c b/lib/libc/iconv/citrus_prop.c
index 283200f10073..6dadce92e3eb 100644
--- a/lib/libc/iconv/citrus_prop.c
+++ b/lib/libc/iconv/citrus_prop.c
@@ -29,7 +29,6 @@
*
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/iconv/citrus_stdenc.c b/lib/libc/iconv/citrus_stdenc.c
index afb472507c14..c4778132750b 100644
--- a/lib/libc/iconv/citrus_stdenc.c
+++ b/lib/libc/iconv/citrus_stdenc.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/include/block_abi.h b/lib/libc/include/block_abi.h
index e04998d6148d..cf670c6c079e 100644
--- a/lib/libc/include/block_abi.h
+++ b/lib/libc/include/block_abi.h
@@ -37,7 +37,7 @@
* compilers that support blocks and exposing the ABI in the source for other
* compilers.
*/
-#define CALL_BLOCK(name, ...) name(__VA_ARGS__)
+#define CALL_BLOCK(name, ...) (name)(__VA_ARGS__)
#else // !__BLOCKS__
#define DECLARE_BLOCK(retTy, name, argTys, ...)\
struct {\
diff --git a/lib/libc/include/compat.h b/lib/libc/include/compat.h
index fe940701e356..70fb8dcd97f3 100644
--- a/lib/libc/include/compat.h
+++ b/lib/libc/include/compat.h
@@ -74,8 +74,6 @@ __sym_compat(swapoff, freebsd13_swapoff, FBSD_1.0);
#define __weak_reference(sym,alias) \
.weak alias;.equ alias,sym
-__weak_reference(__sys_fcntl, __fcntl_compat)
-
#undef __weak_reference
#endif /* __LIBC_COMPAT_H__ */
diff --git a/lib/libc/include/errlst.h b/lib/libc/include/errlst.h
index d43b14789b86..b71d547bda81 100644
--- a/lib/libc/include/errlst.h
+++ b/lib/libc/include/errlst.h
@@ -29,7 +29,6 @@
#ifndef __ERRLST_H__
#define __ERRLST_H__
-#include <sys/cdefs.h>
#ifdef PIC
/* If the main executable imports these, do not use its copy from libc.so. */
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index a9ad2ef21b0b..db4cbc32be35 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -37,6 +37,8 @@
#include <sys/_types.h>
#include <sys/_pthreadtypes.h>
+#include <libsys.h>
+
extern char **environ;
/*
@@ -185,10 +187,12 @@ typedef enum {
PJT_GETTHREADID_NP,
PJT_ATTR_GET_NP,
PJT_GETNAME_NP,
+ PJT_SUSPEND_ALL_NP,
+ PJT_RESUME_ALL_NP,
PJT_MAX
} pjt_index_t;
-typedef int (*pthread_func_t)(void);
+typedef void (*pthread_func_t)(void);
typedef pthread_func_t pthread_func_entry_t[2];
extern pthread_func_entry_t __thr_jtable[];
@@ -197,9 +201,10 @@ void __set_error_selector(int *(*arg)(void));
int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
void *(calloc_cb)(__size_t, __size_t));
-typedef int (*interpos_func_t)(void);
+typedef void (*interpos_func_t)(void);
interpos_func_t *__libc_interposing_slot(int interposno);
extern interpos_func_t __libc_interposing[] __hidden;
+interpos_func_t *__libsys_interposing_slot(int interposno);
enum {
INTERPOS_accept,
@@ -244,11 +249,18 @@ enum {
INTERPOS_map_stacks_exec,
INTERPOS_fdatasync,
INTERPOS_clock_nanosleep,
- INTERPOS_distribute_static_tls,
+ INTERPOS__reserved0, /* was distribute_static_tls */
INTERPOS_pdfork,
+ INTERPOS_uexterr_gettext,
INTERPOS_MAX
};
+#define _INTERPOS_SYS(type, idx, ...) \
+ ((type *)*(__libc_interposing_slot(idx)))(__VA_ARGS__)
+#define INTERPOS_SYS(syscall, ...) \
+ _INTERPOS_SYS(__sys_## syscall ##_t, INTERPOS_## syscall \
+ __VA_OPT__(,) __VA_ARGS__)
+
/*
* yplib internal interfaces
*/
@@ -333,105 +345,22 @@ struct __siginfo;
struct __ucontext;
struct __wrusage;
enum idtype;
-int __sys_aio_suspend(const struct aiocb * const[], int,
- const struct timespec *);
-int __sys_accept(int, struct sockaddr *, __socklen_t *);
-int __sys_accept4(int, struct sockaddr *, __socklen_t *, int);
-int __sys_clock_gettime(__clockid_t, struct timespec *ts);
-int __sys_clock_nanosleep(__clockid_t, int,
- const struct timespec *, struct timespec *);
-int __sys_close(int);
-int __sys_close_range(unsigned, unsigned, int);
-int __sys_connect(int, const struct sockaddr *, __socklen_t);
-int __sys_fcntl(int, int, ...);
-int __sys_fdatasync(int);
-int __sys_fstat(int fd, struct stat *);
-int __sys_fstatfs(int fd, struct statfs *);
-int __sys_fstatat(int, const char *, struct stat *, int);
-int __sys_fsync(int);
-__pid_t __sys_fork(void);
-int __sys_ftruncate(int, __off_t);
-__ssize_t __sys_getdirentries(int, char *, __size_t, __off_t *);
-int __sys_getfsstat(struct statfs *, long, int);
-int __sys_gettimeofday(struct timeval *, struct timezone *);
-int __sys_kevent(int, const struct kevent *, int, struct kevent *,
- int, const struct timespec *);
-__off_t __sys_lseek(int, __off_t, int);
-void *__sys_mmap(void *, __size_t, int, int, int, __off_t);
-int __sys_msync(void *, __size_t, int);
-int __sys_nanosleep(const struct timespec *, struct timespec *);
-int __sys_open(const char *, int, ...);
-int __sys_openat(int, const char *, int, ...);
-int __sys_pdfork(int *, int);
-int __sys_pselect(int, struct fd_set *, struct fd_set *,
- struct fd_set *, const struct timespec *,
- const __sigset_t *);
-int __sys_ptrace(int, __pid_t, char *, int);
-int __sys_poll(struct pollfd *, unsigned, int);
-int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *,
- const __sigset_t *);
-__ssize_t __sys_pread(int, void *, __size_t, __off_t);
-__ssize_t __sys_pwrite(int, const void *, __size_t, __off_t);
-__ssize_t __sys_read(int, void *, __size_t);
-__ssize_t __sys_readv(int, const struct iovec *, int);
-__ssize_t __sys_recv(int, void *, __size_t, int);
-__ssize_t __sys_recvfrom(int, void *, __size_t, int, struct sockaddr *,
- __socklen_t *);
-__ssize_t __sys_recvmsg(int, struct msghdr *, int);
-int __sys_sched_getcpu(void);
-int __sys_select(int, struct fd_set *, struct fd_set *,
- struct fd_set *, struct timeval *);
-__ssize_t __sys_sendmsg(int, const struct msghdr *, int);
-__ssize_t __sys_sendto(int, const void *, __size_t, int,
- const struct sockaddr *, __socklen_t);
-int __sys_setcontext(const struct __ucontext *);
-int __sys_sigaction(int, const struct sigaction *,
- struct sigaction *);
-int __sys_sigprocmask(int, const __sigset_t *, __sigset_t *);
-int __sys_sigsuspend(const __sigset_t *);
-int __sys_sigtimedwait(const __sigset_t *, struct __siginfo *,
- const struct timespec *);
-int __sys_sigwait(const __sigset_t *, int *);
-int __sys_sigwaitinfo(const __sigset_t *, struct __siginfo *);
-int __sys___specialfd(int, const void *, __size_t);
-int __sys_statfs(const char *, struct statfs *);
-int __sys_swapcontext(struct __ucontext *,
- const struct __ucontext *);
-int __sys_thr_kill(long, int);
-int __sys_thr_self(long *);
-int __sys_truncate(const char *, __off_t);
-__pid_t __sys_wait4(__pid_t, int *, int, struct rusage *);
-__pid_t __sys_wait6(enum idtype, __id_t, int *, int,
- struct __wrusage *, struct __siginfo *);
-__ssize_t __sys_write(int, const void *, __size_t);
-__ssize_t __sys_writev(int, const struct iovec *, int);
-int __sys_shm_open2(const char *, int, __mode_t, int, const char *);
+int __libc_execvpe(const char *, char * const *, char * const *);
int __libc_sigaction(int, const struct sigaction *,
struct sigaction *) __hidden;
int __libc_sigprocmask(int, const __sigset_t *, __sigset_t *)
__hidden;
int __libc_sigsuspend(const __sigset_t *) __hidden;
-int __libc_sigwait(const __sigset_t * __restrict,
- int * restrict sig);
+int __libsys_sigwait(const __sigset_t *, int *) __hidden;
int __libc_system(const char *);
int __libc_tcdrain(int);
-int __fcntl_compat(int fd, int cmd, ...);
-
-int __sys_futimens(int fd, const struct timespec *times) __hidden;
-int __sys_utimensat(int fd, const char *path,
- const struct timespec *times, int flag) __hidden;
-
-/* execve() with PATH processing to implement posix_spawnp() */
-int _execvpe(const char *, char * const *, char * const *);
int _elf_aux_info(int aux, void *buf, int buflen);
struct dl_phdr_info;
int __elf_phdr_match_addr(struct dl_phdr_info *, void *);
void __init_elf_aux_vector(void);
void __libc_map_stacks_exec(void);
-void __libc_distribute_static_tls(__size_t, void *, __size_t, __size_t);
-__uintptr_t __libc_static_tls_base(__size_t);
void _pthread_cancel_enter(int);
void _pthread_cancel_leave(int);
@@ -447,5 +376,11 @@ struct __nl_cat_d;
struct _xlocale;
struct __nl_cat_d *__catopen_l(const char *name, int type,
struct _xlocale *locale);
+int __strerror_rl(int errnum, char *strerrbuf, size_t buflen,
+ struct _xlocale *locale);
+
+struct uexterror;
+int __uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz);
+int __libc_uexterr_gettext(char *buf, size_t bufsz);
#endif /* _LIBC_PRIVATE_H_ */
diff --git a/lib/libc/include/spinlock.h b/lib/libc/include/spinlock.h
index 113dfef81c3b..5dcb961a035f 100644
--- a/lib/libc/include/spinlock.h
+++ b/lib/libc/include/spinlock.h
@@ -34,7 +34,6 @@
#ifndef _SPINLOCK_H_
#define _SPINLOCK_H_
-#include <sys/cdefs.h>
#include <sys/types.h>
/*
diff --git a/lib/libc/inet/Makefile.inc b/lib/libc/inet/Makefile.inc
index 9cc1b6547261..8175bfef6772 100644
--- a/lib/libc/inet/Makefile.inc
+++ b/lib/libc/inet/Makefile.inc
@@ -1,4 +1,3 @@
-
# inet sources
.PATH: ${LIBC_SRCTOP}/inet
diff --git a/lib/libc/inet/Symbol.map b/lib/libc/inet/Symbol.map
index e26556cd5fe4..11e22a1f6945 100644
--- a/lib/libc/inet/Symbol.map
+++ b/lib/libc/inet/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
__inet_addr;
__inet_aton;
diff --git a/lib/libc/inet/inet_addr.c b/lib/libc/inet/inet_addr.c
index 69199a3adf61..7a07b4ff85b5 100644
--- a/lib/libc/inet/inet_addr.c
+++ b/lib/libc/inet/inet_addr.c
@@ -66,11 +66,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
-static const char rcsid[] = "$Id: inet_addr.c,v 1.5 2005/04/27 04:56:19 sra Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/inet/inet_cidr_ntop.c b/lib/libc/inet/inet_cidr_ntop.c
index 45f441a163ab..e75d7ba7a49a 100644
--- a/lib/libc/inet/inet_cidr_ntop.c
+++ b/lib/libc/inet/inet_cidr_ntop.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.7 2006/10/11 02:18:18 marka Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/inet/inet_cidr_pton.c b/lib/libc/inet/inet_cidr_pton.c
index 62fada390fed..e24efcedc935 100644
--- a/lib/libc/inet/inet_cidr_pton.c
+++ b/lib/libc/inet/inet_cidr_pton.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.6 2005/04/27 04:56:19 sra Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/inet/inet_lnaof.c b/lib/libc/inet/inet_lnaof.c
index b9cc926327fb..fb384872154b 100644
--- a/lib/libc/inet/inet_lnaof.c
+++ b/lib/libc/inet/inet_lnaof.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/inet/inet_makeaddr.c b/lib/libc/inet/inet_makeaddr.c
index 95bb7c6d4628..1ac3b30886c9 100644
--- a/lib/libc/inet/inet_makeaddr.c
+++ b/lib/libc/inet/inet_makeaddr.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/inet/inet_net_ntop.c b/lib/libc/inet/inet_net_ntop.c
index f523e460e8bb..9d98dbb5ca99 100644
--- a/lib/libc/inet/inet_net_ntop.c
+++ b/lib/libc/inet/inet_net_ntop.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.5 2006/06/20 02:50:14 marka Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/inet/inet_net_pton.c b/lib/libc/inet/inet_net_pton.c
index 9fe41702738d..d566a0e1d3c3 100644
--- a/lib/libc/inet/inet_net_pton.c
+++ b/lib/libc/inet/inet_net_pton.c
@@ -17,10 +17,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_pton.c,v 1.10 2008/11/14 02:36:51 marka Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
@@ -142,7 +138,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) {
goto enoent;
}
- /* Firey death and destruction unless we prefetched EOS. */
+ /* Fiery death and destruction unless we prefetched EOS. */
if (ch != '\0')
goto enoent;
diff --git a/lib/libc/inet/inet_neta.c b/lib/libc/inet/inet_neta.c
index 19facd2047de..2cf40ef3505d 100644
--- a/lib/libc/inet/inet_neta.c
+++ b/lib/libc/inet/inet_neta.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_neta.c,v 1.3 2005/04/27 04:56:20 sra Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/inet/inet_netof.c b/lib/libc/inet/inet_netof.c
index 0322c6427f3b..74648ae87d9d 100644
--- a/lib/libc/inet/inet_netof.c
+++ b/lib/libc/inet/inet_netof.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/inet/inet_network.c b/lib/libc/inet/inet_network.c
index 98f7e379a82c..29bd708b8c92 100644
--- a/lib/libc/inet/inet_network.c
+++ b/lib/libc/inet/inet_network.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/inet/inet_ntoa.c b/lib/libc/inet/inet_ntoa.c
index abe160ca3ab8..52380d8623d1 100644
--- a/lib/libc/inet/inet_ntoa.c
+++ b/lib/libc/inet/inet_ntoa.c
@@ -29,11 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: inet_ntoa.c,v 1.2 2005/04/27 04:56:21 sra Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/inet/inet_ntop.c b/lib/libc/inet/inet_ntop.c
index bc73761d6728..3227a855fd85 100644
--- a/lib/libc/inet/inet_ntop.c
+++ b/lib/libc/inet/inet_ntop.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/inet/inet_pton.c b/lib/libc/inet/inet_pton.c
index 53776f15e92e..6524125ac5be 100644
--- a/lib/libc/inet/inet_pton.c
+++ b/lib/libc/inet/inet_pton.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_pton.c,v 1.5 2005/07/28 06:51:47 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/inet/nsap_addr.c b/lib/libc/inet/nsap_addr.c
index c3f0a4362277..de0ee80b209c 100644
--- a/lib/libc/inet/nsap_addr.c
+++ b/lib/libc/inet/nsap_addr.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: nsap_addr.c,v 1.5 2005/07/28 06:51:48 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/isc/Makefile.inc b/lib/libc/isc/Makefile.inc
index 11b3da0a1b45..30729e96ef16 100644
--- a/lib/libc/isc/Makefile.inc
+++ b/lib/libc/isc/Makefile.inc
@@ -1,4 +1,3 @@
-
# isc sources
.PATH: ${LIBC_SRCTOP}/isc
diff --git a/lib/libc/isc/ev_streams.c b/lib/libc/isc/ev_streams.c
index 254005738226..aebf757a9755 100644
--- a/lib/libc/isc/ev_streams.c
+++ b/lib/libc/isc/ev_streams.c
@@ -21,10 +21,6 @@
* vix 04mar96 [initial]
*/
-#if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_streams.c,v 1.5 2005/04/27 04:56:36 sra Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#ifndef _LIBC
#include "fd_setsize.h"
diff --git a/lib/libc/isc/ev_timers.c b/lib/libc/isc/ev_timers.c
index 4dcc8f05bc3a..07cd2e1d624c 100644
--- a/lib/libc/isc/ev_timers.c
+++ b/lib/libc/isc/ev_timers.c
@@ -21,10 +21,6 @@
* vix 09sep95 [initial]
*/
-#if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_timers.c,v 1.6 2005/04/27 04:56:36 sra Exp $";
-#endif
-#include <sys/cdefs.h>
/* Import. */
#include "port_before.h"
diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc
index e3d073e74a7e..33caafc5c10a 100644
--- a/lib/libc/locale/Makefile.inc
+++ b/lib/libc/locale/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
# locale sources
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/locale ${LIBC_SRCTOP}/locale
diff --git a/lib/libc/locale/Symbol.map b/lib/libc/locale/Symbol.map
index f29e6226855b..dc9bb56d7870 100644
--- a/lib/libc/locale/Symbol.map
+++ b/lib/libc/locale/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
btowc;
digittoint;
@@ -211,6 +208,5 @@ FBSD_1.3 {
FBSDprivate_1.0 {
_PathLocale;
__detect_path_locale;
- __collate_load_error;
__collate_range_cmp;
};
diff --git a/lib/libc/locale/ascii.c b/lib/libc/locale/ascii.c
index 55761626d67b..2afbcea9cab9 100644
--- a/lib/libc/locale/ascii.c
+++ b/lib/libc/locale/ascii.c
@@ -38,7 +38,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <runetype.h>
diff --git a/lib/libc/locale/big5.c b/lib/libc/locale/big5.c
index 77c19e9d7c0e..f67ea97af91c 100644
--- a/lib/libc/locale/big5.c
+++ b/lib/libc/locale/big5.c
@@ -38,10 +38,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <runetype.h>
diff --git a/lib/libc/locale/btowc.c b/lib/libc/locale/btowc.c
index e5e4951fedd8..a5bf7182298d 100644
--- a/lib/libc/locale/btowc.c
+++ b/lib/libc/locale/btowc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/c16rtomb.c b/lib/libc/locale/c16rtomb.c
index de6ada6521c6..7814da308fc9 100644
--- a/lib/libc/locale/c16rtomb.c
+++ b/lib/libc/locale/c16rtomb.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <uchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/c32rtomb.c b/lib/libc/locale/c32rtomb.c
index f60d137556b2..1addb222e588 100644
--- a/lib/libc/locale/c32rtomb.c
+++ b/lib/libc/locale/c32rtomb.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <uchar.h>
#include <wchar.h>
diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h
index cca2c1f160d4..f75126df3c14 100644
--- a/lib/libc/locale/cXXrtomb_iconv.h
+++ b/lib/libc/locale/cXXrtomb_iconv.h
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include <assert.h>
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index 60c14a7de552..c0fc4c91481d 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -36,7 +36,6 @@
* Adapted to xlocale by John Marino <draco@marino.st>
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
@@ -44,6 +43,7 @@
#include <sys/mman.h>
#include <assert.h>
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -733,3 +733,261 @@ __collate_equiv_value(locale_t locale, const wchar_t *str, size_t len)
}
return (0);
}
+
+/*
+ * __collate_collating_symbol takes the multibyte string specified by
+ * src and slen, and using ps, converts that to a wide character. Then
+ * it is checked to verify it is a collating symbol, and then copies
+ * it to the wide character string specified by dst and dlen (the
+ * results are not null terminated). The length of the wide characters
+ * copied to dst is returned if successful. Zero is returned if no such
+ * collating symbol exists. (size_t)-1 is returned if there are wide-character
+ * conversion errors, if the length of the converted string is greater that
+ * COLLATE_STR_LEN or if dlen is too small. It is up to the calling routine to
+ * preserve the mbstate_t structure as needed.
+ */
+size_t
+__collate_collating_symbol(wchar_t *dst, size_t dlen, const char *src,
+ size_t slen, mbstate_t *ps)
+{
+ wchar_t wname[COLLATE_STR_LEN];
+ wchar_t w, *wp;
+ struct xlocale_collate *table;
+ size_t len, l;
+
+ table =
+ (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE];
+ /* POSIX locale */
+ if (table->__collate_load_error) {
+ if (dlen < 1)
+ return ((size_t)-1);
+ if (slen != 1 || !isascii(*src))
+ return (0);
+ *dst = *src;
+ return (1);
+ }
+ for (wp = wname, len = 0; slen > 0; len++) {
+ l = mbrtowc(&w, src, slen, ps);
+ if (l == (size_t)-1 || l == (size_t)-2)
+ return ((size_t)-1);
+ if (l == 0)
+ break;
+ if (len >= COLLATE_STR_LEN)
+ return ((size_t)-1);
+ *wp++ = w;
+ src += l;
+ slen -= l;
+ }
+ if (len == 0 || len > dlen)
+ return ((size_t)-1);
+ if (len == 1) {
+ if (*wname <= UCHAR_MAX) {
+ if (table->char_pri_table[*wname].pri[0] >= 0) {
+ if (dlen > 0)
+ *dst = *wname;
+ return (1);
+ }
+ return (0);
+ } else if (table->info->large_count > 0) {
+ collate_large_t *match;
+ match = largesearch(table, *wname);
+ if (match && match->pri.pri[0] >= 0) {
+ if (dlen > 0)
+ *dst = *wname;
+ return (1);
+ }
+ }
+ return (0);
+ }
+ *wp = 0;
+ if (table->info->chain_count > 0) {
+ collate_chain_t *match;
+ int ll;
+ match = chainsearch(table, wname, &ll);
+ if (match) {
+ if (ll < dlen)
+ dlen = ll;
+ wcsncpy(dst, wname, dlen);
+ return (dlen);
+ }
+ }
+ return (0);
+}
+
+/*
+ * __collate_equiv_class returns the equivalence class number for the symbol
+ * specified by src and slen, using ps to convert from multi-byte to wide
+ * character. Zero is returned if the symbol is not in an equivalence
+ * class. -1 is returned if there are wide character conversion errors,
+ * if there are any greater-than-8-bit characters or if a multi-byte symbol
+ * is greater or equal to COLLATE_STR_LEN in length. It is up to the calling
+ * routine to preserve the mbstate_t structure as needed.
+ */
+int
+__collate_equiv_class(const char *src, size_t slen, mbstate_t *ps)
+{
+ wchar_t wname[COLLATE_STR_LEN];
+ wchar_t w, *wp;
+ struct xlocale_collate *table;
+ size_t len, l;
+ int e;
+
+ table =
+ (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE];
+ /* POSIX locale */
+ if (table->__collate_load_error)
+ return (0);
+ for (wp = wname, len = 0; slen > 0; len++) {
+ l = mbrtowc(&w, src, slen, ps);
+ if (l == (size_t)-1 || l == (size_t)-2)
+ return (-1);
+ if (l == 0)
+ break;
+ if (len >= COLLATE_STR_LEN)
+ return (-1);
+ *wp++ = w;
+ src += l;
+ slen -= l;
+ }
+ if (len == 0)
+ return (-1);
+ if (len == 1) {
+ e = -1;
+ if (*wname <= UCHAR_MAX)
+ e = table->char_pri_table[*wname].pri[0];
+ else if (table->info->large_count > 0) {
+ collate_large_t *match;
+ match = largesearch(table, *wname);
+ if (match)
+ e = match->pri.pri[0];
+ }
+ if (e == 0)
+ return (IGNORE_EQUIV_CLASS);
+ return (e > 0 ? e : 0);
+ }
+ *wp = 0;
+ if (table->info->chain_count > 0) {
+ collate_chain_t *match;
+ int ll;
+ match = chainsearch(table, wname, &ll);
+ if (match) {
+ e = match->pri[0];
+ if (e == 0)
+ return (IGNORE_EQUIV_CLASS);
+ return (e < 0 ? -e : e);
+ }
+ }
+ return (0);
+}
+
+
+/*
+ * __collate_equiv_match tries to match any single or multi-character symbol
+ * in equivalence class equiv_class in the multi-byte string specified by src
+ * and slen. If start is non-zero, it is taken to be the first (pre-converted)
+ * wide character. Subsequence wide characters, if needed, will use ps in
+ * the conversion. On a successful match, the length of the matched string
+ * is returned (including the start character). If dst is non-NULL, the
+ * matched wide-character string is copied to dst, a wide character array of
+ * length dlen (the results are not zero-terminated). If rlen is non-NULL,
+ * the number of character in src actually used is returned. Zero is
+ * returned by __collate_equiv_match if there is no match. (size_t)-1 is
+ * returned on error: if there were conversion errors or if dlen is too small
+ * to accept the results. On no match or error, ps is restored to its incoming
+ * state.
+ */
+size_t
+__collate_equiv_match(int equiv_class, wchar_t *dst, size_t dlen, wchar_t start,
+ const char *src, size_t slen, mbstate_t *ps, size_t *rlen)
+{
+ wchar_t w;
+ size_t len, l, clen;
+ int i;
+ wchar_t buf[COLLATE_STR_LEN], *wp;
+ mbstate_t save;
+ const char *s = src;
+ struct xlocale_collate *table;
+ size_t sl = slen;
+ collate_chain_t *ch = NULL;
+
+ table =
+ (struct xlocale_collate *)__get_locale()->components[XLC_COLLATE];
+ /* POSIX locale */
+ if (table->__collate_load_error)
+ return ((size_t)-1);
+ if (equiv_class == IGNORE_EQUIV_CLASS)
+ equiv_class = 0;
+ if (ps)
+ save = *ps;
+ wp = buf;
+ len = clen = 0;
+ if (start) {
+ *wp++ = start;
+ len = 1;
+ }
+ /* convert up to the max chain length */
+ while (sl > 0 && len < table->info->chain_max_len) {
+ l = mbrtowc(&w, s, sl, ps);
+ if (l == (size_t)-1 || l == (size_t)-2 || l == 0)
+ break;
+ *wp++ = w;
+ s += l;
+ clen += l;
+ sl -= l;
+ len++;
+ }
+ *wp = 0;
+ if (len > 1 && (ch = chainsearch(table, buf, &i)) != NULL) {
+ int e = ch->pri[0];
+ if (e < 0)
+ e = -e;
+ if (e == equiv_class)
+ goto found;
+ }
+ /* try single character */
+ i = 1;
+ if (*buf <= UCHAR_MAX) {
+ if (equiv_class == table->char_pri_table[*buf].pri[0])
+ goto found;
+ } else if (table->info->large_count > 0) {
+ collate_large_t *match;
+ match = largesearch(table, *buf);
+ if (match && equiv_class == match->pri.pri[0])
+ goto found;
+ }
+ /* no match */
+ if (ps)
+ *ps = save;
+ return (0);
+found:
+ /*
+ * If we converted more than we used, restore to initial
+ * and reconvert up to what did match.
+ */
+ if (i < len) {
+ len = i;
+ if (ps)
+ *ps = save;
+ if (start)
+ i--;
+ clen = 0;
+ while (i-- > 0) {
+ l = mbrtowc(&w, src, slen, ps);
+ src += l;
+ clen += l;
+ slen -= l;
+ }
+ }
+ if (dst) {
+ if (dlen < len) {
+ if (ps)
+ *ps = save;
+ return ((size_t)-1);
+ }
+ for (wp = buf; len > 0; len--)
+ *dst++ = *wp++;
+ }
+ if (rlen)
+ *rlen = clen;
+ return (len);
+}
diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h
index 2d3723b49f5b..64e0e6f2337d 100644
--- a/lib/libc/locale/collate.h
+++ b/lib/libc/locale/collate.h
@@ -36,9 +36,9 @@
#ifndef _COLLATE_H_
#define _COLLATE_H_
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <limits.h>
+#include <wchar.h>
#include "xlocale_private.h"
/*
@@ -66,6 +66,8 @@
#define DIRECTIVE_DIRECTION_MASK (DIRECTIVE_FORWARD | DIRECTIVE_BACKWARD)
+#define IGNORE_EQUIV_CLASS 1
+
/*
* The collate file format is as follows:
*
@@ -86,6 +88,7 @@
typedef struct collate_info {
uint8_t directive_count;
uint8_t directive[COLL_WEIGHTS_MAX];
+ uint8_t chain_max_len; /* In padding */
int32_t pri_count[COLL_WEIGHTS_MAX];
int32_t flags;
int32_t chain_count;
@@ -127,8 +130,13 @@ struct xlocale_collate {
};
__BEGIN_DECLS
-int __collate_load_tables(const char *);
+size_t __collate_collating_symbol(wchar_t *, size_t, const char *, size_t,
+ mbstate_t *);
+int __collate_equiv_class(const char *, size_t, mbstate_t *);
int __collate_equiv_value(locale_t, const wchar_t *, size_t);
+size_t __collate_equiv_match(int, wchar_t *, size_t, wchar_t, const char *,
+ size_t, mbstate_t *, size_t *);
+int __collate_load_tables(const char *);
void _collate_lookup(struct xlocale_collate *,const wchar_t *, int *, int *,
int, const int **);
int __collate_range_cmp(char, char);
diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c
index 7b2d6723411b..855f84d884da 100644
--- a/lib/libc/locale/collcmp.c
+++ b/lib/libc/locale/collcmp.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <string.h>
#include <wchar.h>
#include "collate.h"
diff --git a/lib/libc/locale/ctype.3 b/lib/libc/locale/ctype.3
index d3b76aa27737..25568d6f062c 100644
--- a/lib/libc/locale/ctype.3
+++ b/lib/libc/locale/ctype.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ctype.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt CTYPE 3
.Os
diff --git a/lib/libc/locale/digittoint.3 b/lib/libc/locale/digittoint.3
index 8fc97d930881..363b736bf442 100644
--- a/lib/libc/locale/digittoint.3
+++ b/lib/libc/locale/digittoint.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)digittoint.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt DIGITTOINT 3
.Os
diff --git a/lib/libc/locale/euc.5 b/lib/libc/locale/euc.5
index 1aba92f0dfc6..23eab67c0737 100644
--- a/lib/libc/locale/euc.5
+++ b/lib/libc/locale/euc.5
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)euc.4 8.1 (Berkeley) 6/4/93
-.\"
.Dd September 9, 2019
.Dt EUC 5
.Os
diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c
index 823928ff745b..c110fc61b375 100644
--- a/lib/libc/locale/euc.c
+++ b/lib/libc/locale/euc.c
@@ -40,9 +40,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <errno.h>
#include <limits.h>
@@ -429,7 +426,7 @@ _EUC_wcrtomb_impl(char * __restrict s, wchar_t wc,
/* This first check excludes CS1, which is implicitly valid. */
if ((wc < 0xa100) || (wc > 0xffff)) {
/* Check for valid CS2 or CS3 */
- nm = (wc >> ((len - 1) * 8));
+ nm = (wc >> ((len - 1) * 8)) & 0xff;
if (nm == cs2) {
if (len != cs2width) {
errno = EILSEQ;
diff --git a/lib/libc/locale/fix_grouping.c b/lib/libc/locale/fix_grouping.c
index 19b32a378b95..2ae165661d84 100644
--- a/lib/libc/locale/fix_grouping.c
+++ b/lib/libc/locale/fix_grouping.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <limits.h>
#include <stddef.h>
diff --git a/lib/libc/locale/gbk.c b/lib/libc/locale/gbk.c
index 045e0645b1b5..c64a9d534701 100644
--- a/lib/libc/locale/gbk.c
+++ b/lib/libc/locale/gbk.c
@@ -40,7 +40,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <runetype.h>
diff --git a/lib/libc/locale/isalnum.3 b/lib/libc/locale/isalnum.3
index 9bf24a9c3c18..ab79ba79fd5b 100644
--- a/lib/libc/locale/isalnum.3
+++ b/lib/libc/locale/isalnum.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isalnum.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISALNUM 3
.Os
diff --git a/lib/libc/locale/isalpha.3 b/lib/libc/locale/isalpha.3
index 032970fc380f..fe695b70f7b6 100644
--- a/lib/libc/locale/isalpha.3
+++ b/lib/libc/locale/isalpha.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isalpha.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISALPHA 3
.Os
diff --git a/lib/libc/locale/isascii.3 b/lib/libc/locale/isascii.3
index 8f6f69cb75ce..d395dd232d00 100644
--- a/lib/libc/locale/isascii.3
+++ b/lib/libc/locale/isascii.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isascii.3 8.2 (Berkeley) 12/11/93
-.\"
.Dd April 2, 2022
.Dt ISASCII 3
.Os
diff --git a/lib/libc/locale/isblank.3 b/lib/libc/locale/isblank.3
index 410d82552eeb..e28bd8294d43 100644
--- a/lib/libc/locale/isblank.3
+++ b/lib/libc/locale/isblank.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isblank.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISBLANK 3
.Os
diff --git a/lib/libc/locale/iscntrl.3 b/lib/libc/locale/iscntrl.3
index 3507726f200a..9df266ba9780 100644
--- a/lib/libc/locale/iscntrl.3
+++ b/lib/libc/locale/iscntrl.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)iscntrl.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISCNTRL 3
.Os
diff --git a/lib/libc/locale/isctype.c b/lib/libc/locale/isctype.c
index 45dc86c260f6..c6bea890d154 100644
--- a/lib/libc/locale/isctype.c
+++ b/lib/libc/locale/isctype.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)isctype.c 8.3 (Berkeley) 2/24/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <ctype.h>
#undef digittoint
diff --git a/lib/libc/locale/isdigit.3 b/lib/libc/locale/isdigit.3
index facb0da942ff..eac334ef40d1 100644
--- a/lib/libc/locale/isdigit.3
+++ b/lib/libc/locale/isdigit.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isdigit.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISDIGIT 3
.Os
diff --git a/lib/libc/locale/isgraph.3 b/lib/libc/locale/isgraph.3
index 0212b1305c0e..a9b727987e59 100644
--- a/lib/libc/locale/isgraph.3
+++ b/lib/libc/locale/isgraph.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isgraph.3 8.2 (Berkeley) 12/11/93
-.\"
.Dd December 19, 2022
.Dt ISGRAPH 3
.Os
diff --git a/lib/libc/locale/islower.3 b/lib/libc/locale/islower.3
index c07887a5b752..78503eed93b9 100644
--- a/lib/libc/locale/islower.3
+++ b/lib/libc/locale/islower.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)islower.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISLOWER 3
.Os
diff --git a/lib/libc/locale/isprint.3 b/lib/libc/locale/isprint.3
index 43a33498974a..c54e122cc621 100644
--- a/lib/libc/locale/isprint.3
+++ b/lib/libc/locale/isprint.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isprint.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISPRINT 3
.Os
diff --git a/lib/libc/locale/ispunct.3 b/lib/libc/locale/ispunct.3
index 3609ad8b4490..23fec2b17528 100644
--- a/lib/libc/locale/ispunct.3
+++ b/lib/libc/locale/ispunct.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ispunct.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISPUNCT 3
.Os
diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3
index a8d30c0ea804..e52d2bebe76c 100644
--- a/lib/libc/locale/isspace.3
+++ b/lib/libc/locale/isspace.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isspace.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISSPACE 3
.Os
diff --git a/lib/libc/locale/isupper.3 b/lib/libc/locale/isupper.3
index e88b22f48395..212ab1d93625 100644
--- a/lib/libc/locale/isupper.3
+++ b/lib/libc/locale/isupper.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isupper.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISUPPER 3
.Os
diff --git a/lib/libc/locale/iswalnum.3 b/lib/libc/locale/iswalnum.3
index eb81ef44be8c..5425ceeb7e5f 100644
--- a/lib/libc/locale/iswalnum.3
+++ b/lib/libc/locale/iswalnum.3
@@ -31,8 +31,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isalnum.3 5.2 (Berkeley) 6/29/91
-.\"
.Dd October 3, 2002
.Dt ISWALNUM 3
.Os
diff --git a/lib/libc/locale/iswctype.c b/lib/libc/locale/iswctype.c
index 8e5879b0b72c..0693da602116 100644
--- a/lib/libc/locale/iswctype.c
+++ b/lib/libc/locale/iswctype.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wctype.h>
#undef iswalnum
diff --git a/lib/libc/locale/isxdigit.3 b/lib/libc/locale/isxdigit.3
index 18f414dbf931..f6c4a47b4971 100644
--- a/lib/libc/locale/isxdigit.3
+++ b/lib/libc/locale/isxdigit.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)isxdigit.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt ISXDIGIT 3
.Os
diff --git a/lib/libc/locale/ldpart.c b/lib/libc/locale/ldpart.c
index e77f3e2e2a72..77be5404b199 100644
--- a/lib/libc/locale/ldpart.c
+++ b/lib/libc/locale/ldpart.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/locale/lmessages.c b/lib/libc/locale/lmessages.c
index 90757b131fbb..716dc1ead6ea 100644
--- a/lib/libc/locale/lmessages.c
+++ b/lib/libc/locale/lmessages.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stddef.h>
#include "ldpart.h"
diff --git a/lib/libc/locale/lmonetary.c b/lib/libc/locale/lmonetary.c
index f12d4d258403..75ef6b3d53dc 100644
--- a/lib/libc/locale/lmonetary.c
+++ b/lib/libc/locale/lmonetary.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/lnumeric.c b/lib/libc/locale/lnumeric.c
index 109761a62b1d..8f8443668314 100644
--- a/lib/libc/locale/lnumeric.c
+++ b/lib/libc/locale/lnumeric.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include "ldpart.h"
diff --git a/lib/libc/locale/localeconv.3 b/lib/libc/locale/localeconv.3
index 77138924c6f4..caea8a7529f8 100644
--- a/lib/libc/locale/localeconv.3
+++ b/lib/libc/locale/localeconv.3
@@ -27,8 +27,6 @@
.\" 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.
-.\"
-.\" From @(#)setlocale.3 8.1 (Berkeley) 6/9/93
.\" From FreeBSD: src/lib/libc/locale/setlocale.3,v 1.28 2003/11/15 02:26:04 tjr Exp
.\"
.Dd November 21, 2003
diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c
index d87bd03cad61..2cd629e8210d 100644
--- a/lib/libc/locale/localeconv.c
+++ b/lib/libc/locale/localeconv.c
@@ -35,10 +35,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)localeconv.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <locale.h>
#include "lmonetary.h"
@@ -49,7 +45,7 @@ static char sccsid[] = "@(#)localeconv.c 8.1 (Berkeley) 6/4/93";
* monetary and numeric locales.
*
* Because localeconv() may be called many times (especially by library
- * routines like printf() & strtod()), the approprate members of the
+ * routines like printf() & strtod()), the appropriate members of the
* lconv structure are computed only when the monetary or numeric
* locale has been changed.
*/
diff --git a/lib/libc/locale/mblen.3 b/lib/libc/locale/mblen.3
index e5562a1fa1c3..10404f51f785 100644
--- a/lib/libc/locale/mblen.3
+++ b/lib/libc/locale/mblen.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93
.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
.\"
.Dd April 11, 2004
diff --git a/lib/libc/locale/mblen.c b/lib/libc/locale/mblen.c
index a0ff1660ce5d..f0723b2c05a9 100644
--- a/lib/libc/locale/mblen.c
+++ b/lib/libc/locale/mblen.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/mbrlen.c b/lib/libc/locale/mbrlen.c
index 57237c86141e..e4470070752f 100644
--- a/lib/libc/locale/mbrlen.c
+++ b/lib/libc/locale/mbrlen.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/mbrtoc16.c b/lib/libc/locale/mbrtoc16.c
index 54c3beb16f66..0c0d33e944f6 100644
--- a/lib/libc/locale/mbrtoc16.c
+++ b/lib/libc/locale/mbrtoc16.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <uchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/mbrtoc32.c b/lib/libc/locale/mbrtoc32.c
index 33227adb70b8..29b32abcf4fc 100644
--- a/lib/libc/locale/mbrtoc32.c
+++ b/lib/libc/locale/mbrtoc32.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <uchar.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h
index c3c832149617..35d0fd914b1f 100644
--- a/lib/libc/locale/mbrtocXX_iconv.h
+++ b/lib/libc/locale/mbrtocXX_iconv.h
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include <assert.h>
diff --git a/lib/libc/locale/mbrtowc.c b/lib/libc/locale/mbrtowc.c
index b92968156e0e..ac1afc49a94f 100644
--- a/lib/libc/locale/mbrtowc.c
+++ b/lib/libc/locale/mbrtowc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/mbsinit.c b/lib/libc/locale/mbsinit.c
index c9aece68fe6f..5b964c1b3d58 100644
--- a/lib/libc/locale/mbsinit.c
+++ b/lib/libc/locale/mbsinit.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/mbsnrtowcs.c b/lib/libc/locale/mbsnrtowcs.c
index b667ee710757..9a261a297e73 100644
--- a/lib/libc/locale/mbsnrtowcs.c
+++ b/lib/libc/locale/mbsnrtowcs.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/mbsrtowcs.c b/lib/libc/locale/mbsrtowcs.c
index 718d61c77ea4..0d7157cdd643 100644
--- a/lib/libc/locale/mbsrtowcs.c
+++ b/lib/libc/locale/mbsrtowcs.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/mbstowcs.3 b/lib/libc/locale/mbstowcs.3
index 6347d0f63255..4d8d9907f3e0 100644
--- a/lib/libc/locale/mbstowcs.3
+++ b/lib/libc/locale/mbstowcs.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93
.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
.\"
.Dd April 8, 2004
diff --git a/lib/libc/locale/mbstowcs.c b/lib/libc/locale/mbstowcs.c
index 805a49b3563f..338db46185ad 100644
--- a/lib/libc/locale/mbstowcs.c
+++ b/lib/libc/locale/mbstowcs.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
diff --git a/lib/libc/locale/mbtowc.3 b/lib/libc/locale/mbtowc.3
index 7d0e85ee84bf..597c3acd0f63 100644
--- a/lib/libc/locale/mbtowc.3
+++ b/lib/libc/locale/mbtowc.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93
.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
.\"
.Dd April 11, 2004
diff --git a/lib/libc/locale/mbtowc.c b/lib/libc/locale/mbtowc.c
index 56b9b2ba8afd..c36d1d46f1c0 100644
--- a/lib/libc/locale/mbtowc.c
+++ b/lib/libc/locale/mbtowc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdlib.h>
#include <wchar.h>
diff --git a/lib/libc/locale/mskanji.c b/lib/libc/locale/mskanji.c
index 3b30ed0c6027..f0731443c154 100644
--- a/lib/libc/locale/mskanji.c
+++ b/lib/libc/locale/mskanji.c
@@ -42,10 +42,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <runetype.h>
diff --git a/lib/libc/locale/multibyte.3 b/lib/libc/locale/multibyte.3
index 2c97285779d0..e134579512e3 100644
--- a/lib/libc/locale/multibyte.3
+++ b/lib/libc/locale/multibyte.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)multibyte.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd September 9, 2019
.Dt MULTIBYTE 3
.Os
diff --git a/lib/libc/locale/nextwctype.c b/lib/libc/locale/nextwctype.c
index dd81cd82940e..b0416a9a1138 100644
--- a/lib/libc/locale/nextwctype.c
+++ b/lib/libc/locale/nextwctype.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <runetype.h>
#include <wchar.h>
#include <wctype.h>
diff --git a/lib/libc/locale/nl_langinfo.c b/lib/libc/locale/nl_langinfo.c
index b7055f3eaa62..7cdf2856c5bc 100644
--- a/lib/libc/locale/nl_langinfo.c
+++ b/lib/libc/locale/nl_langinfo.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <langinfo.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/locale/nomacros.c b/lib/libc/locale/nomacros.c
index 2dfdd772cfc9..680682d4447a 100644
--- a/lib/libc/locale/nomacros.c
+++ b/lib/libc/locale/nomacros.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
/*
* Tell <ctype.h> to generate extern versions of all its inline
* functions. The extern versions get called if the system doesn't
diff --git a/lib/libc/locale/none.c b/lib/libc/locale/none.c
index a0110f8590ec..8130a2f9b49e 100644
--- a/lib/libc/locale/none.c
+++ b/lib/libc/locale/none.c
@@ -40,10 +40,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)none.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <runetype.h>
diff --git a/lib/libc/locale/rpmatch.c b/lib/libc/locale/rpmatch.c
index 4826c302b827..fb778876bc30 100644
--- a/lib/libc/locale/rpmatch.c
+++ b/lib/libc/locale/rpmatch.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <langinfo.h>
#include <regex.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c
index 79dc4de18e25..59537c440a39 100644
--- a/lib/libc/locale/rune.c
+++ b/lib/libc/locale/rune.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <arpa/inet.h>
#include <errno.h>
diff --git a/lib/libc/locale/runetype.c b/lib/libc/locale/runetype.c
index 1442c3a77fd5..e26104e97234 100644
--- a/lib/libc/locale/runetype.c
+++ b/lib/libc/locale/runetype.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <stdio.h>
#include <runetype.h>
diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3
index daf28334e582..df64f3178fbe 100644
--- a/lib/libc/locale/setlocale.3
+++ b/lib/libc/locale/setlocale.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd August 7, 2020
.Dt SETLOCALE 3
.Os
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c
index 53b6e635ecb7..00226b2c5f00 100644
--- a/lib/libc/locale/setlocale.c
+++ b/lib/libc/locale/setlocale.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 8c8ef82a1193..bb89812486fa 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#define __RUNETYPE_INTERNAL 1
#include <runetype.h>
diff --git a/lib/libc/locale/table.c b/lib/libc/locale/table.c
index 1c6ecacbbbfa..da600f4a44df 100644
--- a/lib/libc/locale/table.c
+++ b/lib/libc/locale/table.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <ctype.h>
#include <runetype.h>
#include <wchar.h>
diff --git a/lib/libc/locale/toascii.3 b/lib/libc/locale/toascii.3
index 1b91f4e17f5b..960b62b3cb1d 100644
--- a/lib/libc/locale/toascii.3
+++ b/lib/libc/locale/toascii.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)toascii.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt TOASCII 3
.Os
diff --git a/lib/libc/locale/tolower.3 b/lib/libc/locale/tolower.3
index f47afd024761..dddf1f38f75c 100644
--- a/lib/libc/locale/tolower.3
+++ b/lib/libc/locale/tolower.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tolower.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt TOLOWER 3
.Os
diff --git a/lib/libc/locale/tolower.c b/lib/libc/locale/tolower.c
index 59cd24393a22..0401147705c6 100644
--- a/lib/libc/locale/tolower.c
+++ b/lib/libc/locale/tolower.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <stdio.h>
#include <runetype.h>
diff --git a/lib/libc/locale/toupper.3 b/lib/libc/locale/toupper.3
index 2c4935bc0737..e0e6b367e8c7 100644
--- a/lib/libc/locale/toupper.3
+++ b/lib/libc/locale/toupper.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)toupper.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd December 19, 2022
.Dt TOUPPER 3
.Os
diff --git a/lib/libc/locale/toupper.c b/lib/libc/locale/toupper.c
index 6de0c76860bd..bff6c5bf32e3 100644
--- a/lib/libc/locale/toupper.c
+++ b/lib/libc/locale/toupper.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <stdio.h>
#include <runetype.h>
diff --git a/lib/libc/locale/towlower.3 b/lib/libc/locale/towlower.3
index a17cca505ade..bcc78da10689 100644
--- a/lib/libc/locale/towlower.3
+++ b/lib/libc/locale/towlower.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tolower.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 3, 2002
.Dt TOWLOWER 3
.Os
diff --git a/lib/libc/locale/towupper.3 b/lib/libc/locale/towupper.3
index 4b7bee7a08ed..f9e9b115b13e 100644
--- a/lib/libc/locale/towupper.3
+++ b/lib/libc/locale/towupper.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)toupper.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 3, 2002
.Dt TOWUPPER 3
.Os
diff --git a/lib/libc/locale/utf8.5 b/lib/libc/locale/utf8.5
index f08e4c2ddc76..890caee1559c 100644
--- a/lib/libc/locale/utf8.5
+++ b/lib/libc/locale/utf8.5
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 7, 2004
.Dt UTF8 5
.Os
diff --git a/lib/libc/locale/wcrtomb.c b/lib/libc/locale/wcrtomb.c
index 83321e4a41c9..ef7d502486b8 100644
--- a/lib/libc/locale/wcrtomb.c
+++ b/lib/libc/locale/wcrtomb.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/wcsftime.c b/lib/libc/locale/wcsftime.c
index ce67d35846e8..f77b4e9a33f8 100644
--- a/lib/libc/locale/wcsftime.c
+++ b/lib/libc/locale/wcsftime.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/wcsnrtombs.c b/lib/libc/locale/wcsnrtombs.c
index fc47c1c7cce2..b7c7738bd85f 100644
--- a/lib/libc/locale/wcsnrtombs.c
+++ b/lib/libc/locale/wcsnrtombs.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/locale/wcsrtombs.c b/lib/libc/locale/wcsrtombs.c
index 2e472f1a0ff9..f949d9331abb 100644
--- a/lib/libc/locale/wcsrtombs.c
+++ b/lib/libc/locale/wcsrtombs.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/locale/wcstod.c b/lib/libc/locale/wcstod.c
index 570bf4474ff4..94a5ff4612a5 100644
--- a/lib/libc/locale/wcstod.c
+++ b/lib/libc/locale/wcstod.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
diff --git a/lib/libc/locale/wcstof.c b/lib/libc/locale/wcstof.c
index 2d35f0b82f25..0c2c7946e89b 100644
--- a/lib/libc/locale/wcstof.c
+++ b/lib/libc/locale/wcstof.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
diff --git a/lib/libc/locale/wcstoimax.c b/lib/libc/locale/wcstoimax.c
index 5ed949cd0531..29e12f809812 100644
--- a/lib/libc/locale/wcstoimax.c
+++ b/lib/libc/locale/wcstoimax.c
@@ -34,13 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoimax.c,v 1.8 2002/09/06 11:23:59 tjr Exp ");
-#endif
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/wcstol.c b/lib/libc/locale/wcstol.c
index 1678b615ca1c..2b83187347c2 100644
--- a/lib/libc/locale/wcstol.c
+++ b/lib/libc/locale/wcstol.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/locale/wcstold.c b/lib/libc/locale/wcstold.c
index dc15631a22f0..1fe7c26ff79a 100644
--- a/lib/libc/locale/wcstold.c
+++ b/lib/libc/locale/wcstold.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
diff --git a/lib/libc/locale/wcstoll.c b/lib/libc/locale/wcstoll.c
index ef1e6ef58861..01ee701af016 100644
--- a/lib/libc/locale/wcstoll.c
+++ b/lib/libc/locale/wcstoll.c
@@ -34,13 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoll.c,v 1.19 2002/09/06 11:23:59 tjr Exp ");
-#endif
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/wcstombs.3 b/lib/libc/locale/wcstombs.3
index 8a4bc1eb49d0..82476de25427 100644
--- a/lib/libc/locale/wcstombs.3
+++ b/lib/libc/locale/wcstombs.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93
.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
.\"
.Dd April 8, 2004
diff --git a/lib/libc/locale/wcstombs.c b/lib/libc/locale/wcstombs.c
index 0b9303cd79e1..962614bf88f3 100644
--- a/lib/libc/locale/wcstombs.c
+++ b/lib/libc/locale/wcstombs.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdlib.h>
#include <wchar.h>
diff --git a/lib/libc/locale/wcstoul.c b/lib/libc/locale/wcstoul.c
index 2c9c8820b1f6..b4fa4d439e10 100644
--- a/lib/libc/locale/wcstoul.c
+++ b/lib/libc/locale/wcstoul.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/locale/wcstoull.c b/lib/libc/locale/wcstoull.c
index 692eb90eef6b..db77acd2a55d 100644
--- a/lib/libc/locale/wcstoull.c
+++ b/lib/libc/locale/wcstoull.c
@@ -34,13 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoull.c,v 1.18 2002/09/06 11:23:59 tjr Exp ");
-#endif
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/wcstoumax.c b/lib/libc/locale/wcstoumax.c
index c4f2ec3aaf41..6a3861618e3e 100644
--- a/lib/libc/locale/wcstoumax.c
+++ b/lib/libc/locale/wcstoumax.c
@@ -34,13 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoumax.c,v 1.8 2002/09/06 11:23:59 tjr Exp ");
-#endif
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
diff --git a/lib/libc/locale/wctob.c b/lib/libc/locale/wctob.c
index d3c9318cc70d..9ae1aa003331 100644
--- a/lib/libc/locale/wctob.c
+++ b/lib/libc/locale/wctob.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/locale/wctomb.3 b/lib/libc/locale/wctomb.3
index 8863fa17a73b..bd6ea0f36519 100644
--- a/lib/libc/locale/wctomb.3
+++ b/lib/libc/locale/wctomb.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" From @(#)multibyte.3 8.1 (Berkeley) 6/4/93
.\" From FreeBSD: src/lib/libc/locale/multibyte.3,v 1.22 2003/11/08 03:23:11 tjr Exp
.\"
.Dd April 8, 2004
diff --git a/lib/libc/locale/wctomb.c b/lib/libc/locale/wctomb.c
index 72bce6567b76..7138ae7df3a2 100644
--- a/lib/libc/locale/wctomb.c
+++ b/lib/libc/locale/wctomb.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <wchar.h>
#include "mblocal.h"
diff --git a/lib/libc/locale/wctrans.c b/lib/libc/locale/wctrans.c
index 947629a8bad8..9d2371814560 100644
--- a/lib/libc/locale/wctrans.c
+++ b/lib/libc/locale/wctrans.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <string.h>
#include <wctype.h>
diff --git a/lib/libc/locale/wctype.c b/lib/libc/locale/wctype.c
index a738a075f982..1b3ac054bc0b 100644
--- a/lib/libc/locale/wctype.c
+++ b/lib/libc/locale/wctype.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <string.h>
#include <wctype.h>
diff --git a/lib/libc/locale/wcwidth.c b/lib/libc/locale/wcwidth.c
index 4c256033ac47..118680d4f2bd 100644
--- a/lib/libc/locale/wcwidth.c
+++ b/lib/libc/locale/wcwidth.c
@@ -42,7 +42,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include <wctype.h>
#include <xlocale.h>
diff --git a/lib/libc/locale/xlocale.3 b/lib/libc/locale/xlocale.3
index daa754dfc473..3af7a38a76d1 100644
--- a/lib/libc/locale/xlocale.3
+++ b/lib/libc/locale/xlocale.3
@@ -166,10 +166,10 @@ along with the headers that expose them, is provided here:
.Xr vsprintf_l 3 ,
.Xr vsscanf_l 3
.It In stdlib.h
-.Xr atof_l 3 ,
-.Xr atoi_l 3 ,
-.Xr atol_l 3 ,
-.Xr atoll_l 3 ,
+.\".Xr atof_l 3 ,
+.\".Xr atoi_l 3 ,
+.\".Xr atol_l 3 ,
+.\".Xr atoll_l 3 ,
.Xr mblen_l 3 ,
.Xr mbstowcs_l 3 ,
.Xr mbtowc_l 3 ,
diff --git a/lib/libc/md/Makefile.inc b/lib/libc/md/Makefile.inc
index e7bf932c1ffe..82c5f0670485 100644
--- a/lib/libc/md/Makefile.inc
+++ b/lib/libc/md/Makefile.inc
@@ -1,4 +1,3 @@
-
-.PATH: ${SRCTOP}/lib/libmd
+.PATH: ${SRCTOP}/sys/kern
SRCS+= md5c.c
diff --git a/lib/libc/nameser/Makefile.inc b/lib/libc/nameser/Makefile.inc
index f91cccbc1713..c60371e2ca93 100644
--- a/lib/libc/nameser/Makefile.inc
+++ b/lib/libc/nameser/Makefile.inc
@@ -1,4 +1,3 @@
-
# nameser sources
.PATH: ${LIBC_SRCTOP}/nameser
diff --git a/lib/libc/nameser/Symbol.map b/lib/libc/nameser/Symbol.map
index db66ed0951ec..0d328cb0f23c 100644
--- a/lib/libc/nameser/Symbol.map
+++ b/lib/libc/nameser/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
__ns_makecanon;
__ns_msg_getflag;
diff --git a/lib/libc/nameser/ns_name.c b/lib/libc/nameser/ns_name.c
index ffe3b9716ab3..ab6a81ed7b4e 100644
--- a/lib/libc/nameser/ns_name.c
+++ b/lib/libc/nameser/ns_name.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id: ns_name.c,v 1.11 2009/01/23 19:59:16 each Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/nameser/ns_netint.c b/lib/libc/nameser/ns_netint.c
index 02e2d485f3f7..0253ea1aa58e 100644
--- a/lib/libc/nameser/ns_netint.c
+++ b/lib/libc/nameser/ns_netint.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id: ns_netint.c,v 1.3 2005/04/27 04:56:40 sra Exp $";
-#endif
-#include <sys/cdefs.h>
/* Import. */
#include "port_before.h"
diff --git a/lib/libc/nameser/ns_parse.c b/lib/libc/nameser/ns_parse.c
index d475b92cd5fc..40f19d33c2bc 100644
--- a/lib/libc/nameser/ns_parse.c
+++ b/lib/libc/nameser/ns_parse.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp $";
-#endif
-#include <sys/cdefs.h>
/* Import. */
#include "port_before.h"
diff --git a/lib/libc/nameser/ns_print.c b/lib/libc/nameser/ns_print.c
index 84e8873bb62e..bf2cb1d2ce24 100644
--- a/lib/libc/nameser/ns_print.c
+++ b/lib/libc/nameser/ns_print.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id: ns_print.c,v 1.12 2009/03/03 05:29:58 each Exp $";
-#endif
-#include <sys/cdefs.h>
/* Import. */
#include "port_before.h"
diff --git a/lib/libc/nameser/ns_samedomain.c b/lib/libc/nameser/ns_samedomain.c
index 1b7f562d66b5..d80688b9d335 100644
--- a/lib/libc/nameser/ns_samedomain.c
+++ b/lib/libc/nameser/ns_samedomain.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id: ns_samedomain.c,v 1.6 2005/04/27 04:56:40 sra Exp $";
-#endif
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/types.h>
diff --git a/lib/libc/nameser/ns_ttl.c b/lib/libc/nameser/ns_ttl.c
index e6d66379fa3e..2050eb5754be 100644
--- a/lib/libc/nameser/ns_ttl.c
+++ b/lib/libc/nameser/ns_ttl.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifndef lint
-static const char rcsid[] = "$Id: ns_ttl.c,v 1.4 2005/07/28 06:51:49 marka Exp $";
-#endif
-#include <sys/cdefs.h>
/* Import. */
#include "port_before.h"
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc
index ea5ddf875151..7e9e5295c78c 100644
--- a/lib/libc/net/Makefile.inc
+++ b/lib/libc/net/Makefile.inc
@@ -1,9 +1,7 @@
-# from @(#)Makefile.inc 8.2 (Berkeley) 9/5/93
-
# machine-independent net sources
.PATH: ${LIBC_SRCTOP}/net
-CONFS+= net/hosts net/hosts.equiv net/networks net/nsswitch.conf net/protocols
+CONFS+= net/hosts net/hosts.equiv net/networks ${.OBJDIR}/nsswitch.conf net/protocols
SRCS+= base64.c ether_addr.c eui64.c \
gai_strerror.c getaddrinfo.c \
gethostbydns.c gethostbyht.c gethostbynis.c gethostnamadr.c \
@@ -13,7 +11,7 @@ SRCS+= base64.c ether_addr.c eui64.c \
if_indextoname.c if_nameindex.c if_nametoindex.c \
ip6opt.c linkaddr.c map_v4v6.c name6.c ntoh.c \
nsdispatch.c nslexer.l nsparser.y nss_compat.c \
- rcmd.c rcmdsh.c recv.c rthdr.c sctp_sys_calls.c send.c \
+ rcmd.c rcmdsh.c rthdr.c sctp_sys_calls.c \
sockatmark.c sourcefilter.c vars.c
.if ${MK_NS_CACHING} != "no"
@@ -50,41 +48,75 @@ MAN+= byteorder.3 ethers.3 eui64.3 \
sctp_getaddrlen.3 sctp_getassocid.3 sctp_getpaddrs.3 \
sctp_opt_info.3 sctp_recvmsg.3 sctp_send.3 sctp_sendmsg.3 \
-MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \
+MLINKS+=byteorder.3 htonl.3 \
+ byteorder.3 htons.3 \
+ byteorder.3 ntohl.3 \
byteorder.3 ntohs.3
-MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \
- ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3
-MLINKS+=eui64.3 eui64_aton.3 eui64.3 eui64_hostton.3 \
- eui64.3 eui64_ntoa.3 eui64.3 eui64_ntohost.3
-MLINKS+=getaddrinfo.3 freeaddrinfo.3
-MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
- gethostbyname.3 gethostbyaddr_r.3 gethostbyname.3 gethostbyname2.3 \
- gethostbyname.3 gethostbyname2_r.3 gethostbyname.3 gethostbyname_r.3 \
- gethostbyname.3 gethostent.3 gethostbyname.3 herror.3 \
- gethostbyname.3 hstrerror.3 gethostbyname.3 sethostent.3
+MLINKS+=ethers.3 ether_aton.3 \
+ ethers.3 ether_aton_r.3 \
+ ethers.3 ether_hostton.3 \
+ ethers.3 ether_line.3 \
+ ethers.3 ether_ntoa.3 \
+ ethers.3 ether_ntoa_r.3 \
+ ethers.3 ether_ntohost.3
+MLINKS+=eui64.3 eui64_aton.3 \
+ eui64.3 eui64_hostton.3 \
+ eui64.3 eui64_ntoa.3 \
+ eui64.3 eui64_ntohost.3
+MLINKS+=getaddrinfo.3 freeaddrinfo.3
+MLINKS+=gethostbyname.3 endhostent.3 \
+ gethostbyname.3 gethostbyaddr.3 \
+ gethostbyname.3 gethostbyaddr_r.3 \
+ gethostbyname.3 gethostbyname2.3 \
+ gethostbyname.3 gethostbyname2_r.3 \
+ gethostbyname.3 gethostbyname_r.3 \
+ gethostbyname.3 gethostent.3 \
+ gethostbyname.3 herror.3 \
+ gethostbyname.3 hstrerror.3 \
+ gethostbyname.3 sethostent.3
MLINKS+=getifaddrs.3 freeifaddrs.3
MLINKS+=getifmaddrs.3 freeifmaddrs.3
-MLINKS+=getipnodebyname.3 getipnodebyaddr.3 getipnodebyname.3 freehostent.3
-MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \
- getnetent.3 getnetbyaddr_r.3 getnetent.3 getnetbyname.3 \
- getnetent.3 getnetbyname_r.3 getnetent.3 setnetent.3 \
+MLINKS+=getipnodebyname.3 getipnodebyaddr.3 \
+ getipnodebyname.3 freehostent.3
+MLINKS+=getnetent.3 endnetent.3 \
+ getnetent.3 getnetbyaddr.3 \
+ getnetent.3 getnetbyaddr_r.3 \
+ getnetent.3 getnetbyname.3 \
+ getnetent.3 getnetbyname_r.3 \
+ getnetent.3 setnetent.3 \
getnetent.3 getnetent_r.3
-MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \
- getprotoent.3 getprotobynumber.3 getprotoent.3 setprotoent.3
-MLINKS+=getservent.3 endservent.3 getservent.3 getservbyname.3 \
- getservent.3 getservbyport.3 getservent.3 setservent.3
-MLINKS+=if_indextoname.3 if_nametoindex.3 if_indextoname.3 if_nameindex.3 \
+MLINKS+=getprotoent.3 endprotoent.3 \
+ getprotoent.3 getprotobyname.3 \
+ getprotoent.3 getprotobynumber.3 \
+ getprotoent.3 setprotoent.3
+MLINKS+=getservent.3 endservent.3 \
+ getservent.3 getservbyname.3 \
+ getservent.3 getservbyport.3 \
+ getservent.3 setservent.3
+MLINKS+=if_indextoname.3 if_nametoindex.3 \
+ if_indextoname.3 if_nameindex.3 \
if_indextoname.3 if_freenameindex.3
-MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \
- inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \
- inet.3 inet_network.3 inet.3 inet_ntoa.3 inet.3 inet_ntoa_r.3\
- inet.3 inet_ntop.3 inet.3 inet_pton.3 \
- inet.3 network.3 inet.3 ntoa.3
-MLINKS+= sctp_send.3 sctp_sendx.3
-MLINKS+= sctp_sendmsg.3 sctp_sendmsgx.3
-MLINKS+= sctp_freepaddrs.3 sctp_freeladdrs.3
-MLINKS+= sctp_getpaddrs.3 sctp_getladdrs.3
-MLINKS+=inet_net.3 inet_net_ntop.3 inet_net.3 inet_net_pton.3
+MLINKS+=inet.3 addr.3 \
+ inet.3 inet_addr.3 \
+ inet.3 inet_aton.3 \
+ inet.3 inet_lnaof.3 \
+ inet.3 inet_makeaddr.3 \
+ inet.3 inet_netof.3 \
+ inet.3 inet_network.3 \
+ inet.3 inet_ntoa.3 \
+ inet.3 inet_ntoa_r.3 \
+ inet.3 inet_ntop.3 \
+ inet.3 inet_pton.3 \
+ inet.3 network.3 \
+ inet.3 ntoa.3
+MLINKS+=sctp_freepaddrs.3 sctp_freeladdrs.3
+MLINKS+=sctp_getpaddrs.3 sctp_getladdrs.3
+MLINKS+=sctp_recvmsg.3 sctp_recvv.3
+MLINKS+=sctp_sendmsg.3 sctp_sendmsgx.3
+MLINKS+=sctp_send.3 sctp_sendx.3 \
+ sctp_send.3 sctp_sendv.3
+MLINKS+=inet_net.3 inet_net_ntop.3 \
+ inet_net.3 inet_net_pton.3
MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \
inet6_opt_init.3 inet6_opt_find.3 \
inet6_opt_init.3 inet6_opt_finish.3 \
@@ -108,27 +140,50 @@ MLINKS+=inet6_opt_init.3 inet6_opt_append.3 \
inet6_rthdr_space.3 inet6_rthdr_lasthop.3 \
inet6_rthdr_space.3 inet6_rthdr_reverse.3 \
inet6_rthdr_space.3 inet6_rthdr_segments.3
-MLINKS+=linkaddr.3 link_addr.3 linkaddr.3 link_ntoa.3
-MLINKS+=rcmd.3 iruserok.3 rcmd.3 iruserok_sa.3 \
+MLINKS+=linkaddr.3 link_addr.3 \
+ linkaddr.3 link_ntoa.3 \
+ linkaddr.3 link_ntoa_r.3
+MLINKS+=rcmd.3 iruserok.3 \
+ rcmd.3 iruserok_sa.3 \
rcmd.3 rcmd_af.3 \
- rcmd.3 rresvport.3 rcmd.3 rresvport_af.3 \
+ rcmd.3 rresvport.3 \
+ rcmd.3 rresvport_af.3 \
rcmd.3 ruserok.3
-MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \
- resolver.3 res_mkquery.3 resolver.3 res_query.3 \
- resolver.3 res_search.3 resolver.3 res_send.3 resolver.3 dn_skipname.3 \
- resolver.3 ns_get16.3 resolver.3 ns_get32.3 \
- resolver.3 ns_put16.3 resolver.3 ns_put32.3
-MLINKS+=sourcefilter.3 setipv4sourcefilter.3 sourcefilter.3 getipv4sourcefilter.3 \
- sourcefilter.3 setsourcefilter.3 sourcefilter.3 getsourcefilter.3
+MLINKS+=resolver.3 dn_comp.3 \
+ resolver.3 dn_expand.3 \
+ resolver.3 res_init.3 \
+ resolver.3 res_mkquery.3 \
+ resolver.3 res_query.3 \
+ resolver.3 res_search.3 \
+ resolver.3 res_send.3 \
+ resolver.3 dn_skipname.3 \
+ resolver.3 ns_get16.3 \
+ resolver.3 ns_get32.3 \
+ resolver.3 ns_put16.3 \
+ resolver.3 ns_put32.3
+MLINKS+=sourcefilter.3 setipv4sourcefilter.3 \
+ sourcefilter.3 getipv4sourcefilter.3 \
+ sourcefilter.3 setsourcefilter.3 \
+ sourcefilter.3 getsourcefilter.3
.if ${MK_HESIOD} != "no"
-SRCS+= hesiod.c
+SRCS+= hesiod.c
+SYM_MAPS+=${LIBC_SRCTOP}/net/Symbol.hesiod.map
MAN+= hesiod.3
+MLINKS+=hesiod.3 hesiod_init.3 \
+ hesiod.3 hesiod_resolve.3 \
+ hesiod.3 hesiod_free_list.3 \
+ hesiod.3 hesiod_to_bind.3 \
+ hesiod.3 hesiod_end.3
.endif
-afterinstallconfig: modify-nsswitch-conf
-modify-nsswitch-conf: .PHONY
+all: ${.OBJDIR}/nsswitch.conf
+
+# Manually stage nsswitch.conf in the object directory so that we can edit it
+# before installing.
+${.OBJDIR}/nsswitch.conf: ${LIBC_SRCTOP}/net/nsswitch.conf
+ cp -f ${LIBC_SRCTOP}/net/nsswitch.conf ${.TARGET}
.if ${MK_NIS} == "no"
sed -i "" -e 's/.*_compat:/# &/' -e 's/compat$$/files/' \
- ${DESTDIR}/etc/nsswitch.conf
+ ${.TARGET}
.endif
diff --git a/lib/libc/net/Symbol.hesiod.map b/lib/libc/net/Symbol.hesiod.map
new file mode 100644
index 000000000000..bb020c969ee9
--- /dev/null
+++ b/lib/libc/net/Symbol.hesiod.map
@@ -0,0 +1,12 @@
+FBSD_1.0 {
+ hesiod_init;
+ hesiod_end;
+ hesiod_to_bind;
+ hesiod_resolve;
+ hesiod_free_list;
+ hes_init;
+ hes_to_bind;
+ hes_resolve;
+ hes_error;
+ hes_free;
+};
diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map
index b2ecd4f08735..25e79b4e5807 100644
--- a/lib/libc/net/Symbol.map
+++ b/lib/libc/net/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
__b64_ntop;
__b64_pton;
@@ -57,16 +54,10 @@ FBSD_1.0 {
endservent;
getservent;
getservent_r;
- hesiod_init;
- hesiod_end;
- hesiod_to_bind;
- hesiod_resolve;
- hesiod_free_list;
- hes_init;
- hes_to_bind;
- hes_resolve;
- hes_error;
- hes_free;
+ htonl;
+ htons;
+ ntohl;
+ ntohs;
if_indextoname;
if_nameindex;
if_freenameindex;
@@ -91,7 +82,6 @@ FBSD_1.0 {
freehostent;
__nsdefaultsrc;
_nsdbtaddsrc;
- _nsdbtdump;
_nsdbtput;
nsdispatch;
rcmd;
@@ -148,6 +138,10 @@ FBSD_1.3 {
sctp_sendv;
};
+FBSD_1.8 {
+ link_ntoa_r;
+};
+
FBSDprivate_1.0 {
_nsdispatch;
_nsyyerror; /* generated from nslexer.l */
diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c
index 44b2e9bd42f6..f508275e4eb9 100644
--- a/lib/libc/net/base64.c
+++ b/lib/libc/net/base64.c
@@ -40,7 +40,6 @@
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3
index 0a6a3b670cf9..9c28e7b80882 100644
--- a/lib/libc/net/byteorder.3
+++ b/lib/libc/net/byteorder.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 20, 2005
.Dt BYTEORDER 3
.Os
diff --git a/lib/libc/net/ether_addr.c b/lib/libc/net/ether_addr.c
index 3a2e565a7b34..efcd84a53437 100644
--- a/lib/libc/net/ether_addr.c
+++ b/lib/libc/net/ether_addr.c
@@ -39,7 +39,6 @@
* Columbia University, New York City
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/eui64.c b/lib/libc/net/eui64.c
index 349f907b9d0b..274c00186153 100644
--- a/lib/libc/net/eui64.c
+++ b/lib/libc/net/eui64.c
@@ -67,7 +67,6 @@
* Columbia University, New York City
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <paths.h>
#include <sys/param.h>
diff --git a/lib/libc/net/gai_strerror.c b/lib/libc/net/gai_strerror.c
index 4964ca23ae4b..0d4303e76a73 100644
--- a/lib/libc/net/gai_strerror.c
+++ b/lib/libc/net/gai_strerror.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <netdb.h>
#if defined(NLS)
diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3
index 271ef8a0102b..634786a8bd12 100644
--- a/lib/libc/net/getaddrinfo.3
+++ b/lib/libc/net/getaddrinfo.3
@@ -480,7 +480,8 @@ freeaddrinfo(res0);
.Xr hosts 5 ,
.Xr resolv.conf 5 ,
.Xr services 5 ,
-.Xr hostname 7
+.Xr hostname 7 ,
+.Xr ip6addrctl 8
.Rs
.%A R. Gilligan
.%A S. Thomson
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 60d2444026a0..b8af23ebe8da 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -53,7 +53,6 @@
* - FreeBSD supported $GAI. The code does not.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/socket.h>
@@ -2342,9 +2341,14 @@ _dns_getaddrinfo(void *rv, void *cb_data, va_list ap)
if (res_searchN(hostname, &q, res) < 0) {
free(buf);
free(buf2);
- if (res->res_h_errno == NO_DATA)
+ switch (res->res_h_errno) {
+ case NO_DATA:
return (NS_ADDRFAMILY);
- return (NS_NOTFOUND);
+ case TRY_AGAIN:
+ return (NS_TRYAGAIN);
+ default:
+ return (NS_NOTFOUND);
+ }
}
/* prefer IPv6 */
if (q.next) {
@@ -2706,9 +2710,18 @@ res_queryN(const char *name, struct res_target *target, res_state res)
int n;
u_int oflags;
struct res_target *t;
- int rcode;
+ u_int rcode;
int ancount;
+ /*
+ * Extend rcode values in the scope of this function. The DNS header
+ * rcode we use in this function (hp->rcode) is limited by 4 bits, so
+ * anything starting from 16 is safe wrt aliasing. However, nameser.h
+ * already has extended enum __ns_rcode, so for future safety let's use
+ * even larger values.
+ */
+#define RCODE_UNREACH 32
+#define RCODE_TIMEDOUT 33
rcode = NOERROR;
ancount = 0;
@@ -2769,7 +2782,29 @@ again:
printf(";; res_nquery: retry without EDNS0\n");
goto again;
}
- rcode = hp->rcode; /* record most recent error */
+ /*
+ * Historically if a DNS server replied with ICMP port
+ * unreach res_nsend() would signal that with
+ * ECONNREFUSED and the upper layers would convert that
+ * into TRY_AGAIN. See 3a0b3b673936b and deeper.
+ * Also, res_nsend() may set errno to ECONNREFUSED due
+ * to internal failures. This may not be intentional,
+ * but we also treat that as soft failures.
+ *
+ * A more practical case is when a DNS server(s) were
+ * queried and didn't respond anything, which usually
+ * indicates a soft network failure.
+ */
+ switch (errno) {
+ case ECONNREFUSED:
+ rcode = RCODE_UNREACH;
+ break;
+ case ETIMEDOUT:
+ rcode = RCODE_TIMEDOUT;
+ break;
+ default:
+ rcode = hp->rcode;
+ }
#ifdef DEBUG
if (res->options & RES_DEBUG)
printf(";; res_query: send error\n");
@@ -2801,6 +2836,8 @@ again:
case NXDOMAIN:
RES_SET_H_ERRNO(res, HOST_NOT_FOUND);
break;
+ case RCODE_UNREACH:
+ case RCODE_TIMEDOUT:
case SERVFAIL:
RES_SET_H_ERRNO(res, TRY_AGAIN);
break;
@@ -2863,10 +2900,6 @@ res_searchN(const char *name, struct res_target *target, res_state res)
ret = res_querydomainN(name, NULL, target, res);
if (ret > 0 || trailing_dot)
return (ret);
- if (errno == ECONNREFUSED) {
- RES_SET_H_ERRNO(res, TRY_AGAIN);
- return (-1);
- }
switch (res->res_h_errno) {
case NO_DATA:
case HOST_NOT_FOUND:
@@ -2907,7 +2940,6 @@ res_searchN(const char *name, struct res_target *target, res_state res)
ret = res_querydomainN(name, *domain, target, res);
if (ret > 0)
return (ret);
-
/*
* If no server present, give up.
* If name isn't found in this domain,
@@ -2921,11 +2953,6 @@ res_searchN(const char *name, struct res_target *target, res_state res)
* but try the input name below in case it's
* fully-qualified.
*/
- if (errno == ECONNREFUSED) {
- RES_SET_H_ERRNO(res, TRY_AGAIN);
- return (-1);
- }
-
switch (res->res_h_errno) {
case NO_DATA:
got_nodata++;
@@ -2934,8 +2961,8 @@ res_searchN(const char *name, struct res_target *target, res_state res)
/* keep trying */
break;
case TRY_AGAIN:
- got_servfail++;
if (hp->rcode == SERVFAIL) {
+ got_servfail++;
/* try next search element, if any */
break;
}
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index 4fa86acef139..216fc9bcf9a4 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -51,11 +51,6 @@
* --Copyright--
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.23 1998/04/07 04:59:46 vixie Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -79,8 +74,10 @@ static char fromrcsid[] = "From: Id: gethnamaddr.c,v 8.23 1998/04/07 04:59:46 vi
#define SPRINTF(x) ((size_t)sprintf x)
+#ifdef DEBUG
static const char AskedForGot[] =
"gethostby*.gethostanswer: asked for \"%s\", got \"%s\"";
+#endif
#ifdef RESOLVSORT
static void addrsort(char **, int, res_state);
@@ -304,8 +301,10 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
switch (type) {
case T_PTR:
if (strcasecmp(tname, bp) != 0) {
+#ifdef DEBUG
syslog(LOG_NOTICE|LOG_AUTH,
AskedForGot, qname, bp);
+#endif
cp += n;
continue; /* XXX - had_error++ ? */
}
@@ -352,8 +351,10 @@ gethostanswer(const querybuf *answer, int anslen, const char *qname, int qtype,
case T_A:
case T_AAAA:
if (strcasecmp(he->h_name, bp) != 0) {
+#ifdef DEBUG
syslog(LOG_NOTICE|LOG_AUTH,
AskedForGot, he->h_name, bp);
+#endif
cp += n;
continue; /* XXX - had_error++ ? */
}
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c
index ee51b4056d00..ac8585439ccf 100644
--- a/lib/libc/net/gethostbyht.c
+++ b/lib/libc/net/gethostbyht.c
@@ -49,10 +49,6 @@
* --Copyright--
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3
index 4f963847e919..1d817679c028 100644
--- a/lib/libc/net/gethostbyname.3
+++ b/lib/libc/net/gethostbyname.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
-.\"
.Dd June 27, 2022
.Dt GETHOSTBYNAME 3
.Os
diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c
index ea503c9dd4c8..2d6abb49b44f 100644
--- a/lib/libc/net/gethostbynis.c
+++ b/lib/libc/net/gethostbynis.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index 1b60ab0fa00f..b54ca8b2998e 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include "reentrant.h"
#include <sys/param.h>
diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c
index f42093b76ca6..35d31d46af78 100644
--- a/lib/libc/net/getifaddrs.c
+++ b/lib/libc/net/getifaddrs.c
@@ -31,7 +31,6 @@
* try-and-error for region size.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/ioctl.h>
diff --git a/lib/libc/net/getifmaddrs.c b/lib/libc/net/getifmaddrs.c
index d2f41e341568..415c25f11968 100644
--- a/lib/libc/net/getifmaddrs.c
+++ b/lib/libc/net/getifmaddrs.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/net/getipnodebyname.3 b/lib/libc/net/getipnodebyname.3
index cf48aca25ab8..2e5b05edec9c 100644
--- a/lib/libc/net/getipnodebyname.3
+++ b/lib/libc/net/getipnodebyname.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
-.\"
.Dd June 27, 2022
.Dt GETIPNODEBYNAME 3
.Os
diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c
index b299b596e343..01bceaa98fce 100644
--- a/lib/libc/net/getnameinfo.c
+++ b/lib/libc/net/getnameinfo.c
@@ -46,7 +46,6 @@
* beware on merge.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -230,24 +229,44 @@ getnameinfo_inet(const struct afd *afd,
case AF_INET6:
{
const struct sockaddr_in6 *sin6;
+
sin6 = (const struct sockaddr_in6 *)sa;
- switch (sin6->sin6_addr.s6_addr[0]) {
- case 0x00:
- if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- ;
- else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
- ;
- else
- flags |= NI_NUMERICHOST;
- break;
- default:
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- flags |= NI_NUMERICHOST;
- }
- else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- break;
- }
+
+ /*
+ * https://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html
+ * "[IP6] [Option Start] If the socket address structure
+ * contains an IPv4-mapped IPv6 address or an IPv4-compatible
+ * IPv6 address, the implementation shall extract the embedded
+ * IPv4 address and lookup the node name for that IPv4 address.
+ * [Option End]"
+ * => getipnodebyaddr() handles this case for us.
+ * => in case of NI_NUMERICHOST being set, inet_ntop[6] will
+ * handle it too.
+ *
+ * "If the address is the IPv6 unspecified address ( "::" ),
+ * a lookup shall not be performed and the behavior shall be
+ * the same as when the node's name cannot be located."
+ * => getipnodebyaddr() handles this case for us.
+ * => in case of NI_NUMERICHOST being set,
+ * ip6_parsenumeric() -> inet_ntop[6] will handle it too.
+ */
+
+ /*
+ * We used to exclude link-local from lookups.
+ * Even though calles in the resolver chain may not (yet)
+ * properly deal with them, we no longer do as for link-local
+ * there is a path to resolve these. See:
+ * RFC 6303 4.5. IPv6 Link-Local Addresses
+ * RFC 6762 4. Reverse Address Mapping
+ *
+ * XXX For IPv6 MC the only reference found was
+ * https://www.ietf.org/archive/id/draft-michaelson-as112-ipv6-02.html
+ * but there are also no "empty zone"s for x.0.f.f.ip6.arpa
+ * in DNS servers. Keep catching it here for now and
+ * do not attempt name resolution but return the address string.
+ */
+ if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
+ flags |= NI_NUMERICHOST;
}
break;
#endif
diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c
index c2a8310e4172..deca8c58fca5 100644
--- a/lib/libc/net/getnetbydns.c
+++ b/lib/libc/net/getnetbydns.c
@@ -56,10 +56,6 @@
* copyright notice and this permission notice appear in all copies.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/lib/libc/net/getnetbyht.c b/lib/libc/net/getnetbyht.c
index 8fb4ccff9cfb..00bfd61552af 100644
--- a/lib/libc/net/getnetbyht.c
+++ b/lib/libc/net/getnetbyht.c
@@ -39,11 +39,6 @@
* from getnetent.c 1.1 (Coimbra) 93/06/02
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93";
-static char orig_rcsid[] = "From: Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/lib/libc/net/getnetbynis.c b/lib/libc/net/getnetbynis.c
index 266cce2bdac2..a56404a14fe7 100644
--- a/lib/libc/net/getnetbynis.c
+++ b/lib/libc/net/getnetbynis.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/lib/libc/net/getnetent.3 b/lib/libc/net/getnetent.3
index f565a2243c94..bd588bd7551a 100644
--- a/lib/libc/net/getnetent.3
+++ b/lib/libc/net/getnetent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 27, 2022
.Dt GETNETENT 3
.Os
diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c
index d3c44050a1ac..660de3302606 100644
--- a/lib/libc/net/getnetnamadr.c
+++ b/lib/libc/net/getnetnamadr.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include "reentrant.h"
#include <sys/param.h>
diff --git a/lib/libc/net/getproto.c b/lib/libc/net/getproto.c
index 407acf635c7e..62ecb04972c4 100644
--- a/lib/libc/net/getproto.c
+++ b/lib/libc/net/getproto.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <netdb.h>
#include <nsswitch.h>
diff --git a/lib/libc/net/getprotoent.3 b/lib/libc/net/getprotoent.3
index a75bd7ad3c98..eeea57ac9859 100644
--- a/lib/libc/net/getprotoent.3
+++ b/lib/libc/net/getprotoent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt GETPROTOENT 3
.Os
diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c
index 1fb719219c10..9fcbf41530cf 100644
--- a/lib/libc/net/getprotoent.c
+++ b/lib/libc/net/getprotoent.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <errno.h>
diff --git a/lib/libc/net/getprotoname.c b/lib/libc/net/getprotoname.c
index 0ae48e96d3f3..f3654a8955ec 100644
--- a/lib/libc/net/getprotoname.c
+++ b/lib/libc/net/getprotoname.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <netdb.h>
#include <nsswitch.h>
diff --git a/lib/libc/net/getservent.3 b/lib/libc/net/getservent.3
index e340eb799be2..996d1606eb79 100644
--- a/lib/libc/net/getservent.3
+++ b/lib/libc/net/getservent.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)getservent.3 8.3 (Berkeley) 1/12/94
-.\"
.Dd December 7, 2020
.Dt GETSERVENT 3
.Os
diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c
index d4241d49d05a..26f68f24cc78 100644
--- a/lib/libc/net/getservent.c
+++ b/lib/libc/net/getservent.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -941,7 +937,7 @@ fin:
return (res);
}
-int
+static int
serv_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
void *cache_mdata)
{
@@ -1042,7 +1038,7 @@ serv_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
return (NS_SUCCESS);
}
-int
+static int
serv_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list ap,
void *cache_mdata)
{
diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c
index 634f109e616b..18d5c7348c78 100644
--- a/lib/libc/net/hesiod.c
+++ b/lib/libc/net/hesiod.c
@@ -43,12 +43,7 @@
* it uses res_send() and accesses _res.
*/
-#include <sys/cdefs.h>
-#if 0
-static char *orig_rcsid = "$NetBSD: hesiod.c,v 1.9 1999/02/11 06:16:38 simonb Exp $";
-#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
@@ -81,8 +76,7 @@ static void translate_errors(void);
* initialize a hesiod_p.
*/
int
-hesiod_init(context)
- void **context;
+hesiod_init(void **context)
{
struct hesiod_p *ctx;
const char *p, *configname;
@@ -130,8 +124,7 @@ hesiod_init(context)
* Deallocates the hesiod_p.
*/
void
-hesiod_end(context)
- void *context;
+hesiod_end(void *context)
{
struct hesiod_p *ctx = (struct hesiod_p *) context;
@@ -221,10 +214,7 @@ hesiod_to_bind(void *context, const char *name, const char *type)
* by the resolver.
*/
char **
-hesiod_resolve(context, name, type)
- void *context;
- const char *name;
- const char *type;
+hesiod_resolve(void *context, const char *name, const char *type)
{
struct hesiod_p *ctx = (struct hesiod_p *) context;
char *bindname, **retvec;
@@ -243,9 +233,7 @@ hesiod_resolve(context, name, type)
/*ARGSUSED*/
void
-hesiod_free_list(context, list)
- void *context;
- char **list;
+hesiod_free_list(void *context, char **list)
{
char **p;
@@ -263,9 +251,7 @@ hesiod_free_list(context, list)
* or ctx->rhs which need to be freed by the caller.
*/
static int
-read_config_file(ctx, filename)
- struct hesiod_p *ctx;
- const char *filename;
+read_config_file(struct hesiod_p *ctx, const char *filename)
{
char *key, *data, *p, **which;
char buf[MAXDNAME + 7];
@@ -357,9 +343,7 @@ read_config_file(ctx, filename)
* return a list of them.
*/
static char **
-get_txt_records(qclass, name)
- int qclass;
- const char *name;
+get_txt_records(int qclass, const char *name)
{
HEADER *hp;
unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP], *p, *eom, *eor;
@@ -483,16 +467,14 @@ static void *context;
static int errval = HES_ER_UNINIT;
int
-hes_init()
+hes_init(void)
{
init_context();
return errval;
}
char *
-hes_to_bind(name, type)
- const char *name;
- const char *type;
+hes_to_bind(const char *name, const char *type)
{
static char *bindname;
if (init_context() < 0)
@@ -506,9 +488,7 @@ hes_to_bind(name, type)
}
char **
-hes_resolve(name, type)
- const char *name;
- const char *type;
+hes_resolve(const char *name, const char *type)
{
static char **list;
@@ -529,20 +509,19 @@ hes_resolve(name, type)
}
int
-hes_error()
+hes_error(void)
{
return errval;
}
void
-hes_free(hp)
- char **hp;
+hes_free(char **hp)
{
hesiod_free_list(context, hp);
}
static int
-init_context()
+init_context(void)
{
if (!inited) {
inited = 1;
@@ -556,7 +535,7 @@ init_context()
}
static void
-translate_errors()
+translate_errors(void)
{
switch (errno) {
case ENOENT:
diff --git a/lib/libc/net/if_indextoname.c b/lib/libc/net/if_indextoname.c
index ba4bd7ab3794..99620c9cac0d 100644
--- a/lib/libc/net/if_indextoname.c
+++ b/lib/libc/net/if_indextoname.c
@@ -27,7 +27,6 @@
* BSDI Id: if_indextoname.c,v 2.3 2000/04/17 22:38:05 dab Exp
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
diff --git a/lib/libc/net/if_nameindex.c b/lib/libc/net/if_nameindex.c
index ca052e91f7a5..a7c2c92bd8d1 100644
--- a/lib/libc/net/if_nameindex.c
+++ b/lib/libc/net/if_nameindex.c
@@ -27,7 +27,6 @@
* BSDI Id: if_nameindex.c,v 2.3 2000/04/17 22:38:05 dab Exp
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c
index 0042bc8c0f4f..febf33b86667 100644
--- a/lib/libc/net/if_nametoindex.c
+++ b/lib/libc/net/if_nametoindex.c
@@ -27,7 +27,6 @@
* BSDI Id: if_nametoindex.c,v 2.3 2000/04/17 22:38:05 dab Exp
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/inet.3 b/lib/libc/net/inet.3
index 69ccf3df9e77..9b822fd6805a 100644
--- a/lib/libc/net/inet.3
+++ b/lib/libc/net/inet.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)inet.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 9, 2021
.Dt INET 3
.Os
@@ -175,10 +173,15 @@ All Internet addresses are returned in network
order (bytes ordered from left to right).
All network numbers and local address parts are
returned as machine byte order integer values.
-.Sh INTERNET ADDRESSES
-Values specified using the
+.Sh INTERNET ADDRESSES (IP VERSION 4)
+The
+.Fn inet_aton
+and
+.Fn inet_addr
+functions accept IPv4
+values specified using the
.Ql .\&
-notation take one
+notation in one
of the following forms:
.Bd -literal -offset indent
a.b.c.d
@@ -212,6 +215,13 @@ may be decimal, octal, or hexadecimal, as specified
in the C language (i.e., a leading 0x or 0X implies
hexadecimal; otherwise, a leading 0 implies octal;
otherwise, the number is interpreted as decimal).
+.Pp
+Note that
+.Fn inet_pton
+does not accept 1-, 2-, or 3-part dotted addresses; all four parts
+must be specified and are interpreted only as decimal values.
+This is a narrower input set than that accepted by
+.Fn inet_aton .
.Sh DIAGNOSTICS
The constant
.Dv INADDR_NONE
@@ -258,12 +268,6 @@ and
.Fn inet_pton
functions conform to
.St -xns5.2 .
-Note that
-.Fn inet_pton
-does not accept 1-, 2-, or 3-part dotted addresses; all four parts
-must be specified and are interpreted only as decimal values.
-This is a narrower input set than that accepted by
-.Fn inet_aton .
.Sh HISTORY
These
functions appeared in
diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c
index 54bd24939d3c..4f53840299ea 100644
--- a/lib/libc/net/ip6opt.c
+++ b/lib/libc/net/ip6opt.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/linkaddr.3 b/lib/libc/net/linkaddr.3
index 6c2fb6ccfdc3..38ee6a0aedea 100644
--- a/lib/libc/net/linkaddr.3
+++ b/lib/libc/net/linkaddr.3
@@ -28,14 +28,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93
-.\"
-.Dd February 28, 2007
+.Dd May 9, 2025
.Dt LINK_ADDR 3
.Os
.Sh NAME
.Nm link_addr ,
-.Nm link_ntoa
+.Nm link_ntoa ,
+.Nm link_ntoa_r
.Nd elementary address specification routines for link level access
.Sh LIBRARY
.Lb libc
@@ -43,16 +42,29 @@
.In sys/types.h
.In sys/socket.h
.In net/if_dl.h
-.Ft void
+.Ft int
.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
.Ft char *
.Fn link_ntoa "const struct sockaddr_dl *sdl"
+.Ft int
+.Fn link_ntoa_r "const struct sockaddr_dl *sdl" "char *obuf" "size_t *buflen"
.Sh DESCRIPTION
The routine
.Fn link_addr
-interprets character strings representing
-link-level addresses, returning binary information suitable
-for use in system calls.
+parses a character string
+.Fa addr
+representing a link-level address,
+and stores the resulting address in the structure pointed to by
+.Fa sdl .
+A link-level address consists of an optional interface name, followed by
+a colon (which is required in all cases), followed by an address
+consisting of either a string of hexadecimal digits, or a series of
+hexadecimal octets separated by one of the characters
+.Sq "." ,
+.Sq ":" ,
+or
+.Sq - .
+.Pp
The routine
.Fn link_ntoa
takes
@@ -62,9 +74,34 @@ address and returns an
string representing some of the information present,
including the link level address itself, and the interface name
or number, if present.
+The returned string is stored in a static buffer.
This facility is experimental and is
still subject to change.
.Pp
+The routine
+.Fn link_ntoa_r
+behaves like
+.Fn link_ntoa ,
+except the string is placed in the provided buffer instead of a static
+buffer.
+The caller should initialize
+.Fa buflen
+to the number of bytes available in
+.Fa obuf .
+On return,
+.Fa buflen
+is set to the actual number of bytes required for the output buffer,
+including the NUL terminator.
+If
+.Fa obuf
+is NULL, then
+.Fa buflen
+is set as described, but nothing is written.
+This may be used to determine the required length of the buffer before
+calling
+.Fn link_ntoa_r
+a second time.
+.Pp
For
.Fn link_addr ,
the string
@@ -96,12 +133,21 @@ The
.Fn link_ntoa
function
always returns a null terminated string.
+.Pp
+The
+.Fn link_ntoa_r
+function returns 0 on success, or -1 if the provided buffer was not
+large enough; in the latter case, the contents of the buffer are
+indeterminate, but a trailing NUL will always be written if the buffer
+was at least one byte in size.
+.Pp
The
.Fn link_addr
-function
-has no return value.
-(See
-.Sx BUGS . )
+function returns 0 on success.
+If the address did not appear to be a valid link-level address, -1 is
+returned and
+.Va errno
+is set to indicate the error.
.Sh SEE ALSO
.Xr getnameinfo 3
.Sh HISTORY
@@ -111,15 +157,14 @@ and
.Fn link_ntoa
functions appeared in
.Bx 4.3 Reno .
+The
+.Fn link_ntoa_r
+function appeared in
+.Fx 15.0 .
.Sh BUGS
The returned values for link_ntoa
reside in a static memory area.
.Pp
-The function
-.Fn link_addr
-should diagnose improperly formed input, and there should be an unambiguous
-way to recognize this.
-.Pp
If the
.Va sdl_len
field of the link socket address
diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c
index df1b7b94276e..5be4c0a7a43e 100644
--- a/lib/libc/net/linkaddr.c
+++ b/lib/libc/net/linkaddr.c
@@ -29,141 +29,263 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
+
#include <net/if.h>
#include <net/if_dl.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdint.h>
#include <string.h>
-/* States*/
-#define NAMING 0
-#define GOTONE 1
-#define GOTTWO 2
-#define RESET 3
-/* Inputs */
-#define DIGIT (4*0)
-#define END (4*1)
-#define DELIM (4*2)
-#define LETTER (4*3)
-
-void
+int
link_addr(const char *addr, struct sockaddr_dl *sdl)
{
char *cp = sdl->sdl_data;
char *cplim = sdl->sdl_len + (char *)sdl;
- int byte = 0, state = NAMING, new;
+ const char *nptr;
+ size_t newsize;
+ int error = 0;
+ char delim = 0;
+ /* Initialise the sdl to zero, except for sdl_len. */
bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1);
sdl->sdl_family = AF_LINK;
- do {
- state &= ~LETTER;
- if ((*addr >= '0') && (*addr <= '9')) {
- new = *addr - '0';
- } else if ((*addr >= 'a') && (*addr <= 'f')) {
- new = *addr - 'a' + 10;
- } else if ((*addr >= 'A') && (*addr <= 'F')) {
- new = *addr - 'A' + 10;
- } else if (*addr == 0) {
- state |= END;
- } else if (state == NAMING &&
- (((*addr >= 'A') && (*addr <= 'Z')) ||
- ((*addr >= 'a') && (*addr <= 'z'))))
- state |= LETTER;
- else
- state |= DELIM;
- addr++;
- switch (state /* | INPUT */) {
- case NAMING | DIGIT:
- case NAMING | LETTER:
- *cp++ = addr[-1];
- continue;
- case NAMING | DELIM:
- state = RESET;
- sdl->sdl_nlen = cp - sdl->sdl_data;
- continue;
- case GOTTWO | DIGIT:
- *cp++ = byte;
- /* FALLTHROUGH */
- case RESET | DIGIT:
- state = GOTONE;
- byte = new;
- continue;
- case GOTONE | DIGIT:
- state = GOTTWO;
- byte = new + (byte << 4);
- continue;
- default: /* | DELIM */
- state = RESET;
- *cp++ = byte;
- byte = 0;
- continue;
- case GOTONE | END:
- case GOTTWO | END:
- *cp++ = byte;
- /* FALLTHROUGH */
- case RESET | END:
+
+ /*
+ * Everything up to the first ':' is the interface name. Usually the
+ * ':' should always be present even if there's no interface name, but
+ * since this interface was poorly specified in the past, accept a
+ * missing colon as meaning no interface name.
+ */
+ if ((nptr = strchr(addr, ':')) != NULL) {
+ size_t namelen = nptr - addr;
+
+ /* Ensure the sdl is large enough to store the name. */
+ if (namelen > cplim - cp) {
+ errno = ENOSPC;
+ return (-1);
+ }
+
+ memcpy(cp, addr, namelen);
+ cp += namelen;
+ sdl->sdl_nlen = namelen;
+ /* Skip the interface name and the colon. */
+ addr += namelen + 1;
+ }
+
+ /*
+ * The remainder of the string should be hex digits representing the
+ * address, with optional delimiters. Each two hex digits form one
+ * octet, but octet output can be forced using a delimiter, so we accept
+ * a long string of hex digits, or a mix of delimited and undelimited
+ * digits like "1122.3344.5566", or delimited one- or two-digit octets
+ * like "1.22.3".
+ *
+ * If anything fails at this point, exit the loop so we set sdl_alen and
+ * sdl_len based on whatever we did manage to parse. This preserves
+ * compatibility with the 4.3BSD version of link_addr, which had no way
+ * to indicate an error and would just return.
+ */
+#define DIGIT(c) \
+ (((c) >= '0' && (c) <= '9') ? ((c) - '0') \
+ : ((c) >= 'a' && (c) <= 'f') ? ((c) - 'a' + 10) \
+ : ((c) >= 'A' && (c) <= 'F') ? ((c) - 'A' + 10) \
+ : (-1))
+#define ISDELIM(c) (((c) == '.' || (c) == ':' || (c) == '-') && \
+ (delim == 0 || delim == (c)))
+
+ for (;;) {
+ int digit, digit2;
+
+ /*
+ * Treat any leading delimiters as empty bytes. This supports
+ * the (somewhat obsolete) form of Ethernet addresses with empty
+ * octets, e.g. "1::3:4:5:6".
+ */
+ while (ISDELIM(*addr) && cp < cplim) {
+ delim = *addr++;
+ *cp++ = 0;
+ }
+
+ /* Did we reach the end of the string? */
+ if (*addr == '\0')
+ break;
+
+ /*
+ * If not, the next character must be a digit, so make sure we
+ * have room for at least one more octet.
+ */
+
+ if (cp >= cplim) {
+ error = ENOSPC;
+ break;
+ }
+
+ if ((digit = DIGIT(*addr)) == -1) {
+ error = EINVAL;
break;
}
- break;
- } while (cp < cplim);
+
+ ++addr;
+
+ /* If the next character is another digit, consume it. */
+ if ((digit2 = DIGIT(*addr)) != -1) {
+ digit = (digit << 4) | digit2;
+ ++addr;
+ }
+
+ if (ISDELIM(*addr)) {
+ /*
+ * If the digit is followed by a delimiter, write it
+ * and consume the delimiter.
+ */
+ delim = *addr++;
+ *cp++ = digit;
+ } else if (DIGIT(*addr) != -1) {
+ /*
+ * If two digits are followed by a third digit, treat
+ * the two digits we have as a single octet and
+ * continue.
+ */
+ *cp++ = digit;
+ } else if (*addr == '\0') {
+ /* If the digit is followed by EOS, we're done. */
+ *cp++ = digit;
+ break;
+ } else {
+ /* Otherwise, the input was invalid. */
+ error = EINVAL;
+ break;
+ }
+ }
+#undef DIGIT
+#undef ISDELIM
+
+ /* How many bytes did we write to the address? */
sdl->sdl_alen = cp - LLADDR(sdl);
- new = cp - (char *)sdl;
- if (new > sizeof(*sdl))
- sdl->sdl_len = new;
- return;
+
+ /*
+ * The user might have given us an sdl which is larger than sizeof(sdl);
+ * in that case, record the actual size of the new sdl.
+ */
+ newsize = cp - (char *)sdl;
+ if (newsize > sizeof(*sdl))
+ sdl->sdl_len = (u_char)newsize;
+
+ if (error == 0)
+ return (0);
+
+ errno = error;
+ return (-1);
}
-static const char hexlist[] = "0123456789abcdef";
char *
link_ntoa(const struct sockaddr_dl *sdl)
{
static char obuf[64];
+ size_t buflen;
_Static_assert(sizeof(obuf) >= IFNAMSIZ + 20, "obuf is too small");
+
+ /*
+ * Ignoring the return value of link_ntoa_r() is safe here because it
+ * always writes the terminating NUL. This preserves the traditional
+ * behaviour of link_ntoa().
+ */
+ buflen = sizeof(obuf);
+ (void)link_ntoa_r(sdl, obuf, &buflen);
+ return obuf;
+}
+
+int
+link_ntoa_r(const struct sockaddr_dl *sdl, char *obuf, size_t *buflen)
+{
+ static const char hexlist[] = "0123456789abcdef";
char *out;
const u_char *in, *inlim;
int namelen, i, rem;
+ size_t needed;
- namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ;
+ assert(sdl);
+ assert(buflen);
+ /* obuf may be null */
+ needed = 1; /* 1 for the NUL */
out = obuf;
- rem = sizeof(obuf);
+ if (obuf)
+ rem = *buflen;
+ else
+ rem = 0;
+
+/*
+ * Check if at least n bytes are available in the output buffer, plus 1 for the
+ * trailing NUL. If not, set rem = 0 so we stop writing.
+ * Either way, increment needed by the amount we would have written.
+ */
+#define CHECK(n) do { \
+ if ((SIZE_MAX - (n)) >= needed) \
+ needed += (n); \
+ if (rem >= ((n) + 1)) \
+ rem -= (n); \
+ else \
+ rem = 0; \
+ } while (0)
+
+/*
+ * Write the char c to the output buffer, unless the buffer is full.
+ * Note that if obuf is NULL, rem is always zero.
+ */
+#define OUT(c) do { \
+ if (rem > 0) \
+ *out++ = (c); \
+ } while (0)
+
+ namelen = (sdl->sdl_nlen <= IFNAMSIZ) ? sdl->sdl_nlen : IFNAMSIZ;
if (namelen > 0) {
- bcopy(sdl->sdl_data, out, namelen);
- out += namelen;
- rem -= namelen;
+ CHECK(namelen);
+ if (rem > 0) {
+ bcopy(sdl->sdl_data, out, namelen);
+ out += namelen;
+ }
+
if (sdl->sdl_alen > 0) {
- *out++ = ':';
- rem--;
+ CHECK(1);
+ OUT(':');
}
}
- in = (const u_char *)sdl->sdl_data + sdl->sdl_nlen;
+ in = (const u_char *)LLADDR(sdl);
inlim = in + sdl->sdl_alen;
- while (in < inlim && rem > 1) {
- if (in != (const u_char *)sdl->sdl_data + sdl->sdl_nlen) {
- *out++ = '.';
- rem--;
+ while (in < inlim) {
+ if (in != (const u_char *)LLADDR(sdl)) {
+ CHECK(1);
+ OUT('.');
}
i = *in++;
if (i > 0xf) {
- if (rem < 3)
- break;
- *out++ = hexlist[i >> 4];
- *out++ = hexlist[i & 0xf];
- rem -= 2;
+ CHECK(2);
+ OUT(hexlist[i >> 4]);
+ OUT(hexlist[i & 0xf]);
} else {
- if (rem < 2)
- break;
- *out++ = hexlist[i];
- rem--;
+ CHECK(1);
+ OUT(hexlist[i]);
}
}
- *out = 0;
- return (obuf);
+
+#undef CHECK
+#undef OUT
+
+ /*
+ * We always leave enough room for the NUL if possible, but the user
+ * might have passed a NULL or zero-length buffer.
+ */
+ if (out && *buflen)
+ *out = '\0';
+
+ *buflen = needed;
+ return ((rem > 0) ? 0 : -1);
}
diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c
index 7a624df5d552..bb3d580473ec 100644
--- a/lib/libc/net/map_v4v6.c
+++ b/lib/libc/net/map_v4v6.c
@@ -51,10 +51,6 @@
* --Copyright--
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c
index 75a663ab1ca7..ae1a117665cb 100644
--- a/lib/libc/net/name6.c
+++ b/lib/libc/net/name6.c
@@ -85,7 +85,6 @@
* Atsushi Onoe <onoe@sm.sony.co.jp>
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/networks b/lib/libc/net/networks
index 71aeb5b05a53..48e5e38269d2 100644
--- a/lib/libc/net/networks
+++ b/lib/libc/net/networks
@@ -1,5 +1,3 @@
-# @(#)networks 5.1 (Berkeley) 6/30/90
-#
# Your Local Networks Database
#
your-net 127 # your comment
diff --git a/lib/libc/net/nscache.c b/lib/libc/net/nscache.c
index 0814818aa210..3537d77edbbe 100644
--- a/lib/libc/net/nscache.c
+++ b/lib/libc/net/nscache.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#define _NS_PRIVATE
#include <nsswitch.h>
diff --git a/lib/libc/net/nscachedcli.c b/lib/libc/net/nscachedcli.c
index 55b0b97129f5..f57e69bdceb2 100644
--- a/lib/libc/net/nscachedcli.c
+++ b/lib/libc/net/nscachedcli.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c
index 958bd2ed69b0..60baa0014904 100644
--- a/lib/libc/net/nsdispatch.c
+++ b/lib/libc/net/nsdispatch.c
@@ -62,7 +62,6 @@
* SUCH DAMAGE.
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l
index bd3c02dcacf4..ce0f18670e21 100644
--- a/lib/libc/net/nslexer.l
+++ b/lib/libc/net/nslexer.l
@@ -32,12 +32,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid =
- "$FreeBSD$";
-#endif /* LIBC_SCCS and not lint */
-
#include "namespace.h"
#include <ctype.h>
#define _NS_PRIVATE
diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y
index 636ac19ffbc0..ec840d996f90 100644
--- a/lib/libc/net/nsparser.y
+++ b/lib/libc/net/nsparser.y
@@ -32,7 +32,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#define _NS_PRIVATE
#include <nsswitch.h>
diff --git a/lib/libc/net/nss_compat.c b/lib/libc/net/nss_compat.c
index 131e7c398589..fb1956b1e71a 100644
--- a/lib/libc/net/nss_compat.c
+++ b/lib/libc/net/nss_compat.c
@@ -33,7 +33,6 @@
*
* Compatibility shims for the GNU C Library-style nsswitch interface.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <errno.h>
diff --git a/lib/libc/net/ntoh.c b/lib/libc/net/ntoh.c
index 1c309ded5cb8..508a2c81d466 100644
--- a/lib/libc/net/ntoh.c
+++ b/lib/libc/net/ntoh.c
@@ -26,7 +26,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/endian.h>
#define _BYTEORDER_FUNC_DEFINED
#include <arpa/inet.h>
diff --git a/lib/libc/net/protocols b/lib/libc/net/protocols
index 9810356b8973..7581cff17908 100644
--- a/lib/libc/net/protocols
+++ b/lib/libc/net/protocols
@@ -1,8 +1,5 @@
#
# Internet protocols
-#
-# from: @(#)protocols 5.1 (Berkeley) 4/17/89
-#
# See also http://www.iana.org/assignments/protocol-numbers
#
ip 0 IP # internet protocol, pseudo protocol number
diff --git a/lib/libc/net/rcmd.3 b/lib/libc/net/rcmd.3
index aa002812b9e5..b4b80e4385cf 100644
--- a/lib/libc/net/rcmd.3
+++ b/lib/libc/net/rcmd.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)rcmd.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 3, 2000
.Dt RCMD 3
.Os
diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c
index 1a0dd5c48d01..f9f70c7921ca 100644
--- a/lib/libc/net/rcmd.c
+++ b/lib/libc/net/rcmd.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c
index ceedc51731a3..7e400e99cb3b 100644
--- a/lib/libc/net/rcmdsh.c
+++ b/lib/libc/net/rcmdsh.c
@@ -35,7 +35,6 @@
* Chris Siebenmann <cks@utcc.utoronto.ca>.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c
deleted file mode 100644
index bf321f3d522d..000000000000
--- a/lib/libc/net/recv.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1988, 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "libc_private.h"
-
-#include <stddef.h>
-
-ssize_t
-recv(int s, void *buf, size_t len, int flags)
-{
- /*
- * POSIX says recv() shall be a cancellation point, so call the
- * cancellation-enabled recvfrom() and not _recvfrom().
- */
- return (((ssize_t (*)(int, void *, size_t, int,
- struct sockaddr *, socklen_t *))
- __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
- NULL, NULL));
-}
diff --git a/lib/libc/net/res_config.h b/lib/libc/net/res_config.h
index f049d6817b7a..39a1b5f1486f 100644
--- a/lib/libc/net/res_config.h
+++ b/lib/libc/net/res_config.h
@@ -1,5 +1,5 @@
-#define DEBUG 1 /* enable debugging code (needed for dig) */
+//#define DEBUG /* enable debugging code */
#define RESOLVSORT /* allow sorting of addresses in gethostbyname */
-#undef SUNSECURITY /* verify gethostbyaddr() calls - WE DON'T NEED IT */
+//#define SUNSECURITY /* verify gethostbyaddr() calls */
#define MULTI_PTRS_ARE_ALIASES 1 /* fold multiple PTR records into aliases */
diff --git a/lib/libc/net/resolver.3 b/lib/libc/net/resolver.3
index e11159583f55..f1220dcf9b7f 100644
--- a/lib/libc/net/resolver.3
+++ b/lib/libc/net/resolver.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)resolver.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd September 15, 2022
+.Dd January 8, 2024
.Dt RESOLVER 3
.Os
.Sh NAME
@@ -47,9 +45,6 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
-.In netinet/in.h
-.In arpa/nameser.h
.In resolv.h
.Ft int
.Fo res_query
diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c
index 0a2e70cf4914..0698a3f7712e 100644
--- a/lib/libc/net/rthdr.c
+++ b/lib/libc/net/rthdr.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libc/net/sctp_bindx.3 b/lib/libc/net/sctp_bindx.3
index f178d96f3337..93a9857ddc86 100644
--- a/lib/libc/net/sctp_bindx.3
+++ b/lib/libc/net/sctp_bindx.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
-.Dd June 14, 2015
+.Dd February 2, 2024
.Dt SCTP_BINDX 3
.Os
.Sh NAME
@@ -107,3 +105,17 @@ is not a socket.
.Sh SEE ALSO
.Xr bind 2 ,
.Xr sctp 4
+.Rs
+.%A R. Stewart
+.%A M. Tuexen
+.%A K. Poon
+.%A P. Lei
+.%A V. Yasevich
+.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)
+.%R RFC 6458
+.%D December 2011
+.Re
+.Sh STANDARDS
+The
+.Fn sctp_bindx
+function conforms to RFC 6458.
diff --git a/lib/libc/net/sctp_connectx.3 b/lib/libc/net/sctp_connectx.3
index cd903ddd01ce..c6cbca14006d 100644
--- a/lib/libc/net/sctp_connectx.3
+++ b/lib/libc/net/sctp_connectx.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 19, 2007
+.Dd February 2, 2024
.Dt SCTP_CONNECTX 3
.Os
.Sh NAME
@@ -98,3 +98,17 @@ is not a socket.
.Sh SEE ALSO
.Xr connect 2 ,
.Xr sctp 4
+.Rs
+.%A R. Stewart
+.%A M. Tuexen
+.%A K. Poon
+.%A P. Lei
+.%A V. Yasevich
+.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)
+.%R RFC 6458
+.%D December 2011
+.Re
+.Sh STANDARDS
+The
+.Fn sctp_connectx
+function conforms to RFC 6458.
diff --git a/lib/libc/net/sctp_freepaddrs.3 b/lib/libc/net/sctp_freepaddrs.3
index 1cd6f814f359..07d486920125 100644
--- a/lib/libc/net/sctp_freepaddrs.3
+++ b/lib/libc/net/sctp_freepaddrs.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
-.Dd December 15, 2006
+.Dd February 2, 2024
.Dt SCTP_FREEPADDRS 3
.Os
.Sh NAME
@@ -61,3 +59,19 @@ none.
.Xr sctp_getladdrs 3 ,
.Xr sctp_getpaddrs 3 ,
.Xr sctp 4
+.Rs
+.%A R. Stewart
+.%A M. Tuexen
+.%A K. Poon
+.%A P. Lei
+.%A V. Yasevich
+.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)
+.%R RFC 6458
+.%D December 2011
+.Re
+.Sh STANDARDS
+The
+.Fn sctp_freepaddrs
+and
+.Fn sctp_freeladdrs
+functions conform to RFC 6458.
diff --git a/lib/libc/net/sctp_getaddrlen.3 b/lib/libc/net/sctp_getaddrlen.3
index 271d82f5b309..cb755a71d107 100644
--- a/lib/libc/net/sctp_getaddrlen.3
+++ b/lib/libc/net/sctp_getaddrlen.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
.Dd December 15, 2006
.Dt SCTP_GETADDRLEN 3
.Os
diff --git a/lib/libc/net/sctp_getpaddrs.3 b/lib/libc/net/sctp_getpaddrs.3
index 48d17f36ead7..0e80e72bbaf6 100644
--- a/lib/libc/net/sctp_getpaddrs.3
+++ b/lib/libc/net/sctp_getpaddrs.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
-.Dd December 15, 2006
+.Dd February 2, 2024
.Dt SCTP_GETPADDRS 3
.Os
.Sh NAME
@@ -93,3 +91,19 @@ is not a socket.
.Xr sctp_freeladdrs 3 ,
.Xr sctp_freepaddrs 3 ,
.Xr sctp 4
+.Rs
+.%A R. Stewart
+.%A M. Tuexen
+.%A K. Poon
+.%A P. Lei
+.%A V. Yasevich
+.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)
+.%R RFC 6458
+.%D December 2011
+.Re
+.Sh STANDARDS
+The
+.Fn sctp_getpaddrs
+and
+.Fn sctp_getladdrs
+functions conform to RFC 6458.
diff --git a/lib/libc/net/sctp_opt_info.3 b/lib/libc/net/sctp_opt_info.3
index 34ba1b85f160..b8b4c1a832b5 100644
--- a/lib/libc/net/sctp_opt_info.3
+++ b/lib/libc/net/sctp_opt_info.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
.Dd June 18, 2011
.Dt SCTP_OPT_INFO 3
.Os
diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3
index a5f794743f53..7bcdcc74f7a1 100644
--- a/lib/libc/net/sctp_recvmsg.3
+++ b/lib/libc/net/sctp_recvmsg.3
@@ -25,11 +25,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 23, 2015
+.Dd May 2, 2024
.Dt SCTP_RECVMSG 3
.Os
.Sh NAME
-.Nm sctp_recvmsg
+.Nm sctp_recvmsg ,
+.Nm sctp_recvv
.Nd receive a message from an SCTP socket
.Sh LIBRARY
.Lb libc
@@ -39,18 +40,22 @@
.In netinet/sctp.h
.Ft ssize_t
.Fo sctp_recvmsg
-.Fa "int s" "void *msg" "size_t len" "struct sockaddr * restrict from"
-.Fa "socklen_t * restrict fromlen" "struct sctp_sndrcvinfo *sinfo" "int *flags"
+.Fa "int s" "void *msg" "size_t len" "struct sockaddr *from"
+.Fa "socklen_t *fromlen" "struct sctp_sndrcvinfo *sinfo" "int *flags"
+.Fc
+.Ft ssize_t
+.Fo sctp_recvv
+.Fa "int s" "const struct iovec *iov" "int iovlen" "struct sockaddr *from"
+.Fa "socklen_t *fromlen" "void *info" "socklen_t *infolen"
+.Fa "unsigned int *infotype" "int *flags"
.Fc
.Sh DESCRIPTION
The
.Fn sctp_recvmsg
-system call
-is used to receive a message from another SCTP endpoint.
-The
-.Fn sctp_recvmsg
-call is used by one-to-one (SOCK_STREAM) type sockets after a
-successful
+and
+.Fn sctp_recvv
+functions are used to receive a message from another SCTP endpoint.
+They are used by one-to-one (SOCK_STREAM) type sockets after a successful
.Fn connect
call or after the application has performed a
.Fn listen
@@ -58,6 +63,8 @@ followed by a successful
.Fn accept .
For a one-to-many (SOCK_SEQPACKET) type socket, an endpoint may call
.Fn sctp_recvmsg
+or
+.Fn sctp_recvv
after having implicitly started an association via one
of the send calls including
.Fn sctp_sendmsg ,
@@ -231,6 +238,159 @@ The
.Fa sinfo->info_timetolive
field is not used by
.Fn sctp_recvmsg .
+.Pp
+The
+.Fn sctp_recvv
+function works as
+.Fn sctp_recvmsg
+with two differences.
+Firstly, the receive buffer is passed as an array containing
+.Vt iocnt
+objects of type
+.Vt struct iovec ,
+where the received data will be scattered in the same manner as
+.Xr readv 2 .
+Secondly, the
+.Fa sinfo
+argument is replaced by the tuple
+.Fa info ,
+.Fa infolen ,
+and
+.Fa infotype ,
+which allow different information to be received based on the socket options.
+.Pp
+To receive an
+.Vt sctp_rcvinfo
+structure, set the
+.Va SCTP_RECVRCVINFO
+socket option, and pass a pointer to a
+.Vt struct sctp_rcvinfo
+structure in
+.Fa info .
+The
+.Vt sctp_rcvinfo
+structure has the following format:
+.Bd -literal
+struct sctp_rcvinfo {
+ uint16_t rcv_sid; /* Stream arriving on */
+ uint16_t rcv_ssn; /* Stream Sequence Number */
+ uint16_t rcv_flags; /* Flags on the incoming message */
+ uint32_t rcv_ppid; /* The ppid field */
+ uint32_t rcv_tsn; /* The transport sequence number */
+ uint32_t rcv_cumtsn; /* The cumulative TSN */
+ uint32_t rcv_context; /* Opaque context field */
+ sctp_assoc_t rcv_assoc_id; /* Peer association id */
+};
+.Ed
+.Pp
+These fields have the same meaning as the equivalent fields in
+.Vt struct sctp_sndrcvinfo ,
+defined above.
+.Pp
+To receive an
+.Vt sctp_nxtinfo
+structure, set the
+.Va SCTP_RECVNXTINFO
+socket option, and pass a pointer to a
+.Vt struct sctp_nxtinfo
+structure in
+.Fa info .
+The
+.Vt struct sctp_nxtinfo
+structure has the following format:
+.Bd -literal
+struct sctp_nxtinfo {
+ uint16_t nxt_sid; /* Next message's stream number */
+ uint16_t nxt_flags; /* Flags (see below) */
+ uint32_t nxt_ppid; /* The ppid field */
+ uint32_t nxt_length; /* Length of next message */
+ sctp_assoc_t nxt_assoc_id; /* Peer association id */
+};
+.Ed
+.Pp
+The fields
+.Va nxt_sid ,
+.Va nxt_ppid ,
+and
+.Va nxt_assoc_id
+have the same meaning as in
+.Vt struct sctp_rcvinfo ,
+except they refer to the next message rather than the message that was
+received.
+The field
+.Va nxt_length
+contains the length of the part of the next message currently available in
+the socket buffer.
+This may not represent the length of the entire message unless the
+.Va SCTP_COMPLETE
+flag is set in
+.Va nxt_flags .
+.Pp
+The
+.Va nxt_flags
+field is a bitmask which may contain any of the following values:
+.Bl -bullet
+.It
+.Va SCTP_UNORDERED :
+The next message was sent unordered.
+.It
+.Va SCTP_COMPLETE :
+The entirety of the next message has been received in the socket buffer.
+In this case, the
+.Va nxt_length
+field contains the length of the entire message.
+.It
+.Va SCTP_NOTIFICATION :
+The next message is a notification, not a user message.
+.El
+.Pp
+If both the
+.Va SCTP_RECVRCVINFO
+and
+.Va SCTP_RECVNXTINFO
+socket options are set, then pass a pointer to a
+.Vt struct sctp_recvv_rn
+structure in
+.Fa info .
+This struct has the following format:
+.Bd -literal
+struct sctp_recvv_rn {
+ struct sctp_rcvinfo recvv_rcvinfo;
+ struct sctp_nxtinfo recvv_nxtinfo;
+};
+.Ed
+.Pp
+The value pointed to by
+.Fa infolen
+should initially contain the length of the structure to which
+.Fa info
+points.
+When the function returns, it will be set to the length of the
+returned structure.
+Additionally,
+.Fa *infotype
+will be set to one of the following values depending on what type of info
+was returned:
+.Bl -bullet
+.It
+.Va SCTP_RECVV_NOINFO :
+no information was returned.
+.It
+.Va SCTP_RECVV_RCVINFO :
+.Fa *info
+contains an object of type
+.Vt struct sctp_rcvinfo .
+.It
+.Va SCTP_RECVV_NXTINFO :
+.Fa *info
+contains an object of type
+.Vt struct sctp_nxtinfo .
+.It
+.Va SCTP_RECVV_RN :
+.Fa *info
+contains an object of type
+.Vt struct sctp_recvv_rn .
+.El
.Sh RETURN VALUES
The call returns the number of bytes received, or -1
if an error occurred.
@@ -279,6 +439,12 @@ has been set on the socket).
This typically means that the socket
is not connected and is a one-to-one style socket.
.El
+.Sh NOTES
+The
+.Fn sctp_recvmsg
+function is deprecated.
+New applications should use
+.Fn sctp_recvv .
.Sh SEE ALSO
.Xr getsockopt 2 ,
.Xr recv 2 ,
@@ -290,3 +456,15 @@ is not connected and is a one-to-one style socket.
.Xr sctp_send 3 ,
.Xr sctp_sendmsg 3 ,
.Xr sctp 4
+.Rs
+.%A R. Stewart
+.%A M. Tuexen
+.%A K. Poon
+.%A P. Lei
+.%A V. Yasevich
+.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)
+.%R RFC 6458
+.%D December 2011
+.Re
+.Sh STANDARDS
+The functions described in this document conform to RFC 6458.
diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3
index 32319ac8493c..ce34a2554576 100644
--- a/lib/libc/net/sctp_send.3
+++ b/lib/libc/net/sctp_send.3
@@ -25,12 +25,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 15, 2006
+.Dd February 2, 2024
.Dt SCTP_SEND 3
.Os
.Sh NAME
.Nm sctp_send ,
-.Nm sctp_sendx
+.Nm sctp_sendx ,
+.Nm sctp_sendv
.Nd send a message from an SCTP socket
.Sh LIBRARY
.Lb libc
@@ -48,11 +49,27 @@
.Fa "int sd" "const void *msg" "size_t len" "struct sockaddr *addrs"
.Fa "int addrcnt" "const struct sctp_sndrcvinfo *sinfo" "int flags"
.Fc
+.Ft ssize_t
+.Fo sctp_sendv
+.Fa "int sd" "const struct iovec *iov" "int iocnt" "struct sockaddr *addrs"
+.Fa "int addrcnt" "void *info" "socklen_t infolen" "unsigned int infotype"
+.Fa "int flags"
+.Fc
.Sh DESCRIPTION
The
.Fn sctp_send
system call
is used to transmit a message to another SCTP endpoint.
+The
+.Fn sctp_sendx
+function is used to specify multiple peer addresses when creating an implicit
+association, as in
+.Xr sctp_connectx 3 .
+The
+.Fn sctp_sendv
+function is used to transmit a message whose data is gathered from the
+provided I/O buffers.
+.Pp
.Fn sctp_send
may be used to send data to an existing association for both
one-to-many (SOCK_SEQPACKET) and one-to-one (SOCK_STREAM) socket types.
@@ -253,6 +270,7 @@ and
.Fa sinfo->sinfo_cumtsn
are used only when receiving messages and are thus ignored by
.Fn sctp_send .
+.Pp
The function
.Fn sctp_sendx
has the same properties as
@@ -281,6 +299,156 @@ the association in place of the association id.
If both
an address and an association id are specified, the association
id has priority.
+.Pp
+The function
+.Fn sctp_sendv
+works as
+.Fn sctp_sendx ,
+with two differences.
+Firstly, the data to be written is passed as an array containing
+.Vt iocnt
+objects of type
+.Vt struct iovec ,
+which will be gathered for sending in the same manner as
+.Xr writev 2 .
+Secondly, the
+.Fa info
+argument is replaced by the tuple
+.Fa sinfo ,
+.Fa infolen ,
+.Fa infotype ,
+where
+.Fa sinfo
+is a pointer to a struct of size
+.Fa infolen
+whose type is indicated by the
+.Fa infotype
+argument.
+.Pp
+If no information is passed, set
+.Fa infotype
+to
+.Va SCTP_SENDV_NOINFO .
+.Fa sinfo
+may be a null pointer.
+.Pp
+If
+.Fa sinfo
+points to a
+.Vt struct sctp_sndinfo ,
+set
+.Fa infotype
+to
+.Va SCTP_SENDV_SNDINFO .
+The
+.Vt sctp_sndinfo
+structure has the following format:
+.Bd -literal
+struct sctp_sndinfo {
+ uint16_t snd_sid; /* stream identifier */
+ uint16_t snd_flags; /* Flags */
+ uint32_t snd_ppid; /* ppid field */
+ uint32_t snd_context; /* context field */
+ sctp_assoc_t snd_assoc_id; /* association id */
+};
+.Ed
+.Pp
+The meaning of these fields is the same as in
+.Vt struct sctp_sndrcvinfo ,
+described above.
+.Pp
+If
+.Fa sinfo
+points to a
+.Vt struct sctp_authinfo ,
+set
+.Fa infotype
+to
+.Va SCTP_SENDV_AUTHINFO .
+The
+.Vt sctp_authinfo
+struct has the following format:
+.Bd -literal
+struct sctp_authinfo {
+ uint16_t auth_keynumber; /* Shared key identifier */
+};
+.Ed
+.Pp
+The
+.Va auth_keynumber
+field specifies the shared key identifier that will be used for sending the
+message.
+.Pp
+If
+.Fa sinfo
+points to a
+.Vt struct sctp_prinfo ,
+set
+.Fa infotype
+to
+.Va SCTP_SENDV_PRINFO .
+The
+.Vt sctp_prinfo
+structure has the following format:
+.Bd -literal
+struct sctp_prinfo {
+ uint16_t pr_policy; /* PR-SCTP policy */
+ uint32_t pr_value; /* PR-SCTP Policy option */
+};
+.Ed
+.Pp
+The
+.Va pr_policy
+field should be set to either
+.Va SCTP_PR_SCTP_NONE
+to use reliable transmission (in which case the field
+.Va pr_value
+is ignored), or
+.Va SCTP_PR_SCTP_TTL
+to use RFC 3758 timed reliability, in which case the field
+.Va pr_value
+contains the lifetime in milliseconds.
+.Pp
+To pass two or more types in
+.Fa sinfo ,
+set
+.Fa infotype
+to
+.Va SCTP_SENDV_SPA
+and pass a pointer to a
+.Vt struct sctp_sendv_spa
+in
+.Fa sinfo .
+The
+.Ft sctp_sendv_spa
+structure has the following format:
+.Bd -literal
+struct sctp_sendv_spa {
+ uint32_t sendv_flags;
+ struct sctp_sndinfo sendv_sndinfo;
+ struct sctp_prinfo sendv_prinfo;
+ struct sctp_authinfo sendv_authinfo;
+};
+.Ed
+.Pp
+The
+.Va sendv_flags
+member should be set to the bitwise OR of the flags
+.Va SCTP_SEND_SNDINFO_VALID ,
+.Va SCTP_SEND_PRINFO_VALID ,
+and
+.Va SCTP_SEND_AUTHINFO_VALID
+to indicate which fields of the struct contain valid data.
+.Pp
+If
+.Fa infotype
+is set to SCTP_SENDV_NOINFO, the
+.Fa infolen
+argument should be set to zero.
+Otherwise,
+.Fa infolen
+should be set to the length of the data structure pointed to by
+.Fa info .
.Sh RETURN VALUES
The call returns the number of characters sent, or -1
if an error occurred.
@@ -329,6 +497,14 @@ has been set on the socket).
This typically means that the socket
is not connected and is a one-to-one style socket.
.El
+.Sh NOTES
+The functions
+.Fn sctp_send
+and
+.Fn sctp_sendx
+are deprecated.
+New applications should use
+.Fn sctp_sendv .
.Sh SEE ALSO
.Xr getsockopt 2 ,
.Xr recv 2 ,
@@ -340,6 +516,18 @@ is not connected and is a one-to-one style socket.
.Xr sctp_recvmsg 3 ,
.Xr sctp_sendmsg 3 ,
.Xr sctp 4
+.Rs
+.%A R. Stewart
+.%A M. Tuexen
+.%A K. Poon
+.%A P. Lei
+.%A V. Yasevich
+.%T Sockets API Extensions for the Stream Control Transmission Protocol (SCTP)
+.%R RFC 6458
+.%D December 2011
+.Re
+.Sh STANDARDS
+The functions described in this document conform to RFC 6458.
.Sh BUGS
Because
.Fn sctp_send
diff --git a/lib/libc/net/sctp_sendmsg.3 b/lib/libc/net/sctp_sendmsg.3
index 015f6ef60b52..47a7c7db2d8b 100644
--- a/lib/libc/net/sctp_sendmsg.3
+++ b/lib/libc/net/sctp_sendmsg.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
-.Dd December 15, 2006
+.Dd February 2, 2024
.Dt SCTP_SENDMSG 3
.Os
.Sh NAME
@@ -98,13 +96,13 @@ is set to
the message is not transmitted.
.Pp
No indication of failure to deliver is implicit in a
-.Xr sctp_sendmsg 3
+.Fn sctp_sendmsg
call.
Locally detected errors are indicated by a return value of -1.
.Pp
If no space is available at the socket to hold
the message to be transmitted, then
-.Xr sctp_sendmsg 3
+.Fn sctp_sendmsg
normally blocks, unless the socket has been placed in
non-blocking I/O mode.
The
diff --git a/lib/libc/net/sctp_sys_calls.c b/lib/libc/net/sctp_sys_calls.c
index ee0de3b95691..5cb26266c888 100644
--- a/lib/libc/net/sctp_sys_calls.c
+++ b/lib/libc/net/sctp_sys_calls.c
@@ -32,7 +32,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c
deleted file mode 100644
index cb2f72ae8b9f..000000000000
--- a/lib/libc/net/send.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1988, 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "libc_private.h"
-
-#include <stddef.h>
-
-ssize_t
-send(int s, const void *msg, size_t len, int flags)
-{
- /*
- * POSIX says send() shall be a cancellation point, so call the
- * cancellation-enabled sendto() and not _sendto().
- */
- return (((ssize_t (*)(int, const void *, size_t, int,
- const struct sockaddr *, socklen_t))
- __libc_interposing[INTERPOS_sendto])(s, msg, len, flags,
- NULL, 0));
-}
diff --git a/lib/libc/net/sourcefilter.c b/lib/libc/net/sourcefilter.c
index 34dbde6a2577..81fa55741d0c 100644
--- a/lib/libc/net/sourcefilter.c
+++ b/lib/libc/net/sourcefilter.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
diff --git a/lib/libc/net/vars.c b/lib/libc/net/vars.c
index 7df32ca69ed6..1a8824740dec 100644
--- a/lib/libc/net/vars.c
+++ b/lib/libc/net/vars.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <netinet/in.h>
diff --git a/lib/libc/nls/Makefile.inc b/lib/libc/nls/Makefile.inc
index 0d4c245c6911..f26e04c187a5 100644
--- a/lib/libc/nls/Makefile.inc
+++ b/lib/libc/nls/Makefile.inc
@@ -32,6 +32,7 @@ NLS+= no_NO.ISO8859-1
NLS+= pl_PL.ISO8859-2
NLS+= pt_BR.ISO8859-1
NLS+= ru_RU.KOI8-R
+NLS+= ru_RU.UTF-8
NLS+= sk_SK.ISO8859-2
NLS+= sv_SE.ISO8859-1
NLS+= uk_UA.UTF-8
diff --git a/lib/libc/nls/Symbol.map b/lib/libc/nls/Symbol.map
index d8ee248d60f0..0703131b8415 100644
--- a/lib/libc/nls/Symbol.map
+++ b/lib/libc/nls/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
catopen;
catgets;
diff --git a/lib/libc/nls/catopen.3 b/lib/libc/nls/catopen.3
index 6fd50956be1f..6fb2e2522e85 100644
--- a/lib/libc/nls/catopen.3
+++ b/lib/libc/nls/catopen.3
@@ -130,16 +130,17 @@ Otherwise, (nl_catd) -1 is returned and
is set to indicate the error.
.Sh ERRORS
.Bl -tag -width Er
-.It Bq Er EINVAL
-Argument
-.Fa name
-does not point to a valid message catalog, or catalog is corrupt.
.It Bq Er ENAMETOOLONG
An entire path to the message catalog exceeded 1024 characters.
.It Bq Er ENOENT
-The named message catalog does not exists, or the
+Argument
.Fa name
-argument points to an empty string.
+does not point to a valid message catalog name,
+or it points to an empty string.
+.It Bq Er ENOENT
+The named message catalog does not exist.
+.It Bq Er ENOENT
+The named message catalog file is in wrong format.
.It Bq Er ENOMEM
Insufficient memory is available.
.El
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
index 80750dc8cfa1..61c09b65f434 100644
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -31,7 +31,6 @@ up-to-date. Many thanks.
******************************************************************/
-#include <sys/cdefs.h>
#define _NLS_PRIVATE
#include "namespace.h"
@@ -137,7 +136,7 @@ __catopen_l(const char *name, int type, locale_t locale)
/* sanity checking */
if (name == NULL || *name == '\0')
- NLRETERR(EINVAL);
+ NLRETERR(ENOENT);
if (strchr(name, '/') != NULL)
/* have a pathname */
@@ -391,7 +390,7 @@ load_msgcat(const char *path, const char *name, const char *lang)
struct catentry *np;
void *data;
char *copy_path, *copy_name, *copy_lang;
- int fd;
+ int fd, saved_errno;
/* path/name will never be NULL here */
@@ -415,9 +414,17 @@ load_msgcat(const char *path, const char *name, const char *lang)
}
if (_fstat(fd, &st) != 0) {
+ saved_errno = errno;
_close(fd);
- SAVEFAIL(name, lang, EFTYPE);
- NLRETERR(EFTYPE);
+ SAVEFAIL(name, lang, saved_errno);
+ NLRETERR(saved_errno);
+ }
+
+ /* The file is too small to contain a _NLS_MAGIC. */
+ if (st.st_size < sizeof(u_int32_t)) {
+ _close(fd);
+ SAVEFAIL(name, lang, ENOENT);
+ NLRETERR(ENOENT);
}
/*
@@ -427,13 +434,13 @@ load_msgcat(const char *path, const char *name, const char *lang)
*/
if (st.st_size > SIZE_T_MAX) {
_close(fd);
- SAVEFAIL(name, lang, EFBIG);
- NLRETERR(EFBIG);
+ SAVEFAIL(name, lang, ENOENT);
+ NLRETERR(ENOENT);
}
- if ((data = mmap(0, (size_t)st.st_size, PROT_READ,
- MAP_FILE|MAP_SHARED, fd, (off_t)0)) == MAP_FAILED) {
- int saved_errno = errno;
+ data = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (data == MAP_FAILED) {
+ saved_errno = errno;
_close(fd);
SAVEFAIL(name, lang, saved_errno);
NLRETERR(saved_errno);
@@ -443,8 +450,8 @@ load_msgcat(const char *path, const char *name, const char *lang)
if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) !=
_NLS_MAGIC) {
munmap(data, (size_t)st.st_size);
- SAVEFAIL(name, lang, EFTYPE);
- NLRETERR(EFTYPE);
+ SAVEFAIL(name, lang, ENOENT);
+ NLRETERR(ENOENT);
}
copy_name = strdup(name);
diff --git a/lib/libc/nls/ru_RU.KOI8-R.msg b/lib/libc/nls/ru_RU.KOI8-R.msg
index 0fcd0e9b1225..7b5cd288ed60 100644
--- a/lib/libc/nls/ru_RU.KOI8-R.msg
+++ b/lib/libc/nls/ru_RU.KOI8-R.msg
@@ -67,7 +67,6 @@ $ EROFS
$ EMLINK
31 óÌÉÛËÏÍ ÍÎÏÇÏ ÓÓÙÌÏË
$ EPIPE
-$ XXX???
32 ëÁÎÁÌ ÒÁÚÒÕÛÅÎ
$ EDOM
33 îÅÄÏÐÕÓÔÉÍÏÅ ÚÎÁÞÅÎÉÅ ÞÉÓÌÏ×ÏÇÏ ÁÒÇÕÍÅÎÔÁ
@@ -78,7 +77,6 @@ $ EAGAIN, EWOULDBLOCK
$ EINPROGRESS
36 ïÐÅÒÁÃÉÑ × ÐÒÏÃÅÓÓÅ ×ÙÐÏÌÎÅÎÉÑ
$ EALREADY
-$ XXX???
37 ïÐÅÒÁÃÉÑ ÕÖÅ ×ÙÐÏÌÎÑÅÔÓÑ
$ ENOTSOCK
38 ïÐÅÒÁÃÉÑ Ó ÓÏËÅÔÏÍ ÐÒÉÍÅÎÅÎÁ ÎÅ Ë ÓÏËÅÔÕ
diff --git a/lib/libc/nls/ru_RU.UTF-8.msg b/lib/libc/nls/ru_RU.UTF-8.msg
new file mode 100644
index 000000000000..1bd2179dfe81
--- /dev/null
+++ b/lib/libc/nls/ru_RU.UTF-8.msg
@@ -0,0 +1,263 @@
+$
+$ Message catalog for ru_RU.KOI8-R locale
+$
+$ strerror() support catalog
+$
+$set 1
+$ EPERM
+1 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ð½Ðµ разрешена
+$ ENOENT
+2 Ðет такого файла или каталога
+$ ESRCH
+3 Ðет такого процеÑÑа
+$ EINTR
+4 Прерванный ÑиÑтемный вызов
+$ EIO
+5 Ошибка ввода/вывода
+$ ENXIO
+6 УÑтройÑтво не Ñконфигурировано
+$ E2BIG
+7 Слишком длинный ÑпиÑок аргументов
+$ ENOEXEC
+8 Ошибка формата выполнÑемого файла
+$ EBADF
+9 Ðекорректный деÑкриптор файла
+$ ECHILD
+10 Ðет порожденных процеÑÑов
+$ EDEADLK
+11 Предотвращена Ð²Ð·Ð°Ð¸Ð¼Ð½Ð°Ñ Ð±Ð»Ð¾ÐºÐ¸Ñ€Ð¾Ð²ÐºÐ° при доÑтупе к реÑурÑу
+$ ENOMEM
+12 Ðевозможно выделить памÑть
+$ EACCES
+13 ÐедоÑтаточно привилегий
+$ EFAULT
+14 Ðекорректный адреÑ
+$ ENOTBLK
+15 Ðеобходимо указать блочное уÑтройÑтво
+$ EBUSY
+16 УÑтройÑтво занÑто
+$ EEXIST
+17 Файл ÑущеÑтвует
+$ EXDEV
+18 СÑылка на другое уÑтройÑтво
+$ ENODEV
+19 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ð½Ðµ поддерживаетÑÑ ÑƒÑтройÑтвом
+$ ENOTDIR
+20 Указанный файл не ÑвлÑетÑÑ ÐºÐ°Ñ‚Ð°Ð»Ð¾Ð³Ð¾Ð¼
+$ EISDIR
+21 Указанный файл ÑвлÑетÑÑ ÐºÐ°Ñ‚Ð°Ð»Ð¾Ð³Ð¾Ð¼
+$ EINVAL
+22 ÐедопуÑтимый аргумент
+$ ENFILE
+23 Слишком много открытых файлов в ÑиÑтеме
+$ EMFILE
+24 Слишком много открытых файлов
+$ ENOTTY
+25 Вызов ioctl не поддерживаетÑÑ ÑƒÑтройÑтвом
+$ ETXTBSY
+26 ТекÑтовый файл занÑÑ‚
+$ EFBIG
+27 Слишком большой файл
+$ ENOSPC
+28 Ðа уÑтройÑтве не оÑталоÑÑŒ меÑта
+$ ESPIPE
+29 ÐедопуÑтимое Ñмещение
+$ EROFS
+30 Ð¤Ð°Ð¹Ð»Ð¾Ð²Ð°Ñ ÑиÑтема только Ð´Ð»Ñ Ñ‡Ñ‚ÐµÐ½Ð¸Ñ
+$ EMLINK
+31 Слишком много ÑÑылок
+$ EPIPE
+32 Канал разрушен
+$ EDOM
+33 ÐедопуÑтимое значение чиÑлового аргумента
+$ ERANGE
+34 Слишком большой результат
+$ EAGAIN, EWOULDBLOCK
+35 РеÑÑƒÑ€Ñ Ð²Ñ€ÐµÐ¼ÐµÐ½Ð½Ð¾ недоÑтупен
+$ EINPROGRESS
+36 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ð² процеÑÑе выполнениÑ
+$ EALREADY
+37 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ ÑƒÐ¶Ðµ выполнÑетÑÑ
+$ ENOTSOCK
+38 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ñ Ñокетом применена не к Ñокету
+$ EDESTADDRREQ
+39 ТребуетÑÑ Ñ†ÐµÐ»ÐµÐ²Ð¾Ð¹ адреÑ
+$ EMSGSIZE
+40 Слишком длинное Ñообщение
+$ EPROTOTYPE
+41 Ðеверный тип протокола Ð´Ð»Ñ Ñокета
+$ ENOPROTOOPT
+42 Протокол недоÑтупен
+$ EPROTONOSUPPORT
+43 Протокол не поддерживаетÑÑ
+$ ESOCKTNOSUPPORT
+44 Этот тип Ñокета не поддерживаетÑÑ
+$ EOPNOTSUPP
+45 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ð½Ðµ поддерживаетÑÑ
+$ EPFNOSUPPORT
+46 СемейÑтво протоколов не поддерживаетÑÑ
+$ EAFNOSUPPORT
+47 СемейÑтво адреÑов не поддерживаетÑÑ ÑемейÑтвом протоколов
+$ EADDRINUSE
+48 ÐÐ´Ñ€ÐµÑ ÑƒÐ¶Ðµ иÑпользуетÑÑ
+$ EADDRNOTAVAIL
+49 Ðе могу назначить указанный адреÑ
+$ ENETDOWN
+50 Сеть не работает
+$ ENETUNREACH
+51 Сеть недоÑтижима
+$ ENETRESET
+52 Сеть закрыла подключение при ÑброÑе
+$ ECONNABORTED
+53 Программа вызвала аварийное прекращение подключениÑ
+$ ECONNRESET
+54 Подключение Ñброшено противоположной Ñтороной
+$ ENOBUFS
+55 Ðе оÑталоÑÑŒ меÑта под буфер
+$ EISCONN
+56 Сокет уже подключен
+$ ENOTCONN
+57 Сокет не подключен
+$ ESHUTDOWN
+58 Ðе могу поÑлать поÑле Ð·Ð°ÐºÑ€Ñ‹Ñ‚Ð¸Ñ Ñокета
+$ ETOOMANYREFS
+59 Слишком много ÑÑылок: не могу Ñоединить
+$ ETIMEDOUT
+60 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ð¿Ñ€ÐµÐ²Ñ‹Ñила лимит времени
+$ ECONNREFUSED
+61 Подключение отвергнуто
+$ ELOOP
+62 Слишком много уровней Ñимвольных ÑÑылок
+$ ENAMETOOLONG
+63 Слишком длинное Ð¸Ð¼Ñ Ñ„Ð°Ð¹Ð»Ð°
+$ EHOSTDOWN
+64 ХоÑÑ‚ не работает
+$ EHOSTUNREACH
+65 Ðет маршрута к хоÑту
+$ ENOTEMPTY
+66 Каталог не пуÑÑ‚
+$ EPROCLIM
+67 Слишком много процеÑÑов
+$ EUSERS
+68 Слишком много пользователей
+$ EDQUOT
+69 Превзойдена диÑÐºÐ¾Ð²Ð°Ñ ÐºÐ²Ð¾Ñ‚Ð°
+$ ESTALE
+70 УÑтаревший деÑкриптор файла NFS
+$ EREMOTE
+71 Слишком много диÑтанционных переходов в пути
+$ EBADRPC
+72 ÐÐµÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ Ñтруктура RPC
+$ ERPCMISMATCH
+73 ÐÐµÐ²ÐµÑ€Ð½Ð°Ñ Ð²ÐµÑ€ÑÐ¸Ñ RPC
+$ EPROGUNAVAIL
+74 Программа RPC недоÑтупна
+$ EPROGMISMATCH
+75 ÐÐµÐ²ÐµÑ€Ð½Ð°Ñ Ð²ÐµÑ€ÑÐ¸Ñ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ñ‹
+$ EPROCUNAVAIL
+76 ÐÐµÐºÐ¾Ñ€Ñ€ÐµÐºÑ‚Ð½Ð°Ñ Ð¿Ñ€Ð¾Ñ†ÐµÐ´ÑƒÑ€Ð° Ð´Ð»Ñ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ñ‹
+$ ENOLCK
+77 Блокировки недоÑтупны
+$ ENOSYS
+78 Ð¤ÑƒÐ½ÐºÑ†Ð¸Ñ Ð½Ðµ реализована
+$ EFTYPE
+79 ÐеподходÑщий тип или формат файла
+$ EAUTH
+80 Ошибка аутентификации
+$ ENEEDAUTH
+81 Ðеобходимо удоÑтоверение
+$ EIDRM
+82 Идентификатор удален
+$ ENOMSG
+83 Ðет ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ñ‚Ñ€ÐµÐ±ÑƒÐµÐ¼Ð¾Ð³Ð¾ типа
+$ EOVERFLOW
+84 Слишком большое значение Ð´Ð»Ñ Ñ…Ñ€Ð°Ð½ÐµÐ½Ð¸Ñ Ð² указанном типе данных
+$ ECANCELED
+85 ÐžÐ¿ÐµÑ€Ð°Ñ†Ð¸Ñ Ð¾Ñ‚Ð¼ÐµÐ½ÐµÐ½Ð°
+$ EILSEQ
+86 ÐедопуÑÑ‚Ð¸Ð¼Ð°Ñ Ð¿Ð¾ÑледовательноÑть байтов
+$ ENOATTR
+87 Ðтрибут не найден
+$ EDOOFUS
+88 Ошибка программированиÑ
+$ EBADMSG
+89 Плохой формат ÑообщениÑ
+$ EMULTIHOP
+90 Попытка мультихопа
+$ ENOLINK
+91 Канал разорван
+$ EPROTO
+92 Ошибка протокола
+$ ENOTCAPABLE
+93 ÐедоÑтаточно возможноÑтей
+$
+$ strsignal() support catalog
+$
+$set 2
+$ SIGHUP
+$ XXX: Отключение?
+1 Разрыв ÑвÑзи
+$ SIGINT
+2 Прерывание по Ñигналу
+$ SIGQUIT
+3 Выход
+$ SIGILL
+4 ÐедопуÑÑ‚Ð¸Ð¼Ð°Ñ Ð¸Ð½ÑтрукциÑ
+$ SIGTRAP
+5 Ловушка траÑÑировки/точки оÑтанова
+$ SIGABRT
+$ XXX: Ðварийное завершение
+6 Ловушка аварийного прекращениÑ
+$ SIGEMT
+7 Ловушка EMT
+$ SIGFPE
+$ XXX: Ошибка операции Ñ Ð¿Ð»Ð°Ð²Ð°ÑŽÑ‰ÐµÐ¹ точкой?
+8 Ошибка при работе Ñ Ð²ÐµÑ‰ÐµÑтвенным чиÑлом
+$ SIGKILL
+$ XXX: Убит
+9 Принудительно прекращен
+$ SIGBUS
+$ XXX: Ошибка адреÑации на шине
+10 Ошибка шины
+$ SIGSEGV
+11 Ошибка Ñегментации
+$ SIGSYS
+12 ÐедопуÑтимый ÑиÑтемный вызов
+$ SIGPIPE
+13 Канал разрушен
+$ SIGALRM
+14 Сработал таймер
+$ SIGTERM
+15 Завершен
+$ SIGURG
+16 Ðеобходим Ñрочный ввод-вывод
+$ SIGSTOP
+17 ПриоÑтановка (Ñигнал)
+$ SIGTSTP
+18 ПриоÑтановка
+$ SIGCONT
+19 Продолжение работы
+$ SIGCHLD
+20 Завершена работа порожденного процеÑÑа
+$ SIGTTIN
+21 ОÑтановлен (ввод Ñ Ñ‚ÐµÑ€Ð¼Ð¸Ð½Ð°Ð»Ð°)
+$ SIGTTOU
+22 ОÑтановлен (вывод на терминал)
+$ SIGIO
+23 Ввод-вывод возможен
+$ SIGXCPU
+24 Превышено ограничение процеÑÑорного времени
+$ SIGXFSZ
+25 Превышен макÑимальный размер файла
+$ SIGVTALRM
+26 ИÑтек виртуальный таймер
+$ SIGPROF
+27 ИÑтек таймер профилированиÑ
+$ SIGWINCH
+28 Изменение размера окна
+$ SIGINFO
+29 Ð—Ð°Ð¿Ñ€Ð¾Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ð¸
+$ SIGUSR1
+30 ПользовательÑкий Ñигнал 1
+$ SIGUSR2
+31 ПользовательÑкий Ñигнал 2
diff --git a/lib/libc/posix1e/Makefile.inc b/lib/libc/posix1e/Makefile.inc
index 5d3d30ed6dea..934998cdd092 100644
--- a/lib/libc/posix1e/Makefile.inc
+++ b/lib/libc/posix1e/Makefile.inc
@@ -1,4 +1,3 @@
-
.PATH: ${LIBC_SRCTOP}/posix1e
CFLAGS+=-D_ACL_PRIVATE
@@ -95,23 +94,27 @@ MAN+= acl.3 \
posix1e.3
MLINKS+=acl_create_entry.3 acl_create_entry_np.3\
+ acl_cmp_np.3 acl_cmp.3 \
acl_delete.3 acl_delete_def_file.3 \
- acl_delete.3 acl_delete_file_np.3 \
+ acl_delete.3 acl_delete_def_link_np.3 \
acl_delete.3 acl_delete_fd_np.3 \
+ acl_delete.3 acl_delete_file_np.3 \
+ acl_delete.3 acl_delete_link_np.3 \
acl_delete_entry.3 acl_delete_entry_np.3\
acl_extended_file_np.3 acl_extended_file_nofollow_np.3 \
acl_extended_file_np.3 acl_extended_link_np.3 \
- acl_get.3 acl_get_file.3 \
acl_get.3 acl_get_fd.3 \
acl_get.3 acl_get_fd_np.3 \
+ acl_get.3 acl_get_file.3 \
acl_get.3 acl_get_link_np.3 \
- acl_set.3 acl_set_file.3 \
acl_set.3 acl_set_fd.3 \
acl_set.3 acl_set_fd_np.3 \
+ acl_set.3 acl_set_file.3 \
acl_set.3 acl_set_link_np.3 \
acl_to_text.3 acl_to_text_np.3 \
- acl_valid.3 acl_valid_file_np.3 \
acl_valid.3 acl_valid_fd_np.3 \
+ acl_valid.3 acl_valid_file_np.3 \
+ acl_valid.3 acl_valid_link_np.3 \
extattr.3 extattr_namespace_to_string.3 \
extattr.3 extattr_string_to_namespace.3 \
mac_get.3 mac_get_fd.3 \
diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map
index 87e18493d1ec..92a0bf85cfa2 100644
--- a/lib/libc/posix1e/Symbol.map
+++ b/lib/libc/posix1e/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
acl_calc_mask;
acl_copy_entry;
diff --git a/lib/libc/posix1e/acl.3 b/lib/libc/posix1e/acl.3
index c74b92028c6d..4c5f232a2e6a 100644
--- a/lib/libc/posix1e/acl.3
+++ b/lib/libc/posix1e/acl.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 8, 2023
+.Dd September 21, 2023
.Dt ACL 3
.Os
.Sh NAME
@@ -286,11 +286,6 @@ POSIX.2c describes a set of userland utilities for manipulating these
labels.
.Pp
POSIX.1e is described in IEEE POSIX.1e draft 17.
-Discussion of the draft continues on the cross-platform POSIX.1e
-implementation mailing list.
-To join this list, see the
-.Fx
-POSIX.1e implementation page for more information.
.Sh HISTORY
POSIX.1e support was introduced in
.Fx 4.0 ;
diff --git a/lib/libc/posix1e/acl_branding.c b/lib/libc/posix1e/acl_branding.c
index 4cb9feb1d281..85c0d2b86825 100644
--- a/lib/libc/posix1e/acl_branding.c
+++ b/lib/libc/posix1e/acl_branding.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_calc_mask.c b/lib/libc/posix1e/acl_calc_mask.c
index 74a432839c17..3e5c5afd06c2 100644
--- a/lib/libc/posix1e/acl_calc_mask.c
+++ b/lib/libc/posix1e/acl_calc_mask.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_cmp_np.3 b/lib/libc/posix1e/acl_cmp_np.3
index a8dca4959d2e..5e47df833d0d 100644
--- a/lib/libc/posix1e/acl_cmp_np.3
+++ b/lib/libc/posix1e/acl_cmp_np.3
@@ -63,6 +63,7 @@ to the corresponding value:
.Bl -tag -width Er
.It Bq Er EINVAL
Either first or second argument does not point to a valid ACL.
+.El
.Sh SEE ALSO
.Xr acl 3 ,
.Xr posix1e 3
diff --git a/lib/libc/posix1e/acl_cmp_np.c b/lib/libc/posix1e/acl_cmp_np.c
index f1ec108629a5..f7ee9c235a04 100644
--- a/lib/libc/posix1e/acl_cmp_np.c
+++ b/lib/libc/posix1e/acl_cmp_np.c
@@ -29,7 +29,6 @@
* acl_cmp_np: Compare two ACL's.
*/
-#include <sys/cdefs.h>
#include <sys/acl.h>
#include <sys/errno.h>
diff --git a/lib/libc/posix1e/acl_compat.c b/lib/libc/posix1e/acl_compat.c
index f8eb55116d84..836cf3cab500 100644
--- a/lib/libc/posix1e/acl_compat.c
+++ b/lib/libc/posix1e/acl_compat.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/acl.h>
int __oldacl_get_perm_np(acl_permset_t, oldacl_perm_t);
diff --git a/lib/libc/posix1e/acl_copy.c b/lib/libc/posix1e/acl_copy.c
index 96a5ed479641..3f0771b1c257 100644
--- a/lib/libc/posix1e/acl_copy.c
+++ b/lib/libc/posix1e/acl_copy.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_delete.c b/lib/libc/posix1e/acl_delete.c
index b0fb59391ec5..35303fe87e0f 100644
--- a/lib/libc/posix1e/acl_delete.c
+++ b/lib/libc/posix1e/acl_delete.c
@@ -31,7 +31,6 @@
* acl_delete_def_file -- remove a default acl from a file
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_delete_entry.c b/lib/libc/posix1e/acl_delete_entry.c
index 5faa52065fe9..a787609f3853 100644
--- a/lib/libc/posix1e/acl_delete_entry.c
+++ b/lib/libc/posix1e/acl_delete_entry.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_entry.c b/lib/libc/posix1e/acl_entry.c
index eb9103439efe..abba3a0586dc 100644
--- a/lib/libc/posix1e/acl_entry.c
+++ b/lib/libc/posix1e/acl_entry.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_equiv_mode_np.c b/lib/libc/posix1e/acl_equiv_mode_np.c
index 06bd3a3deda3..333b010541ee 100644
--- a/lib/libc/posix1e/acl_equiv_mode_np.c
+++ b/lib/libc/posix1e/acl_equiv_mode_np.c
@@ -29,7 +29,6 @@
* acl_equiv_mode_np: Check if an ACL can be represented as a mode_t.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/errno.h>
@@ -50,7 +49,7 @@ acl_equiv_mode_np(acl_t acl, mode_t *mode_p)
/* Linux returns 0 for ACL returned by acl_init() */
if (_acl_brand(acl) == ACL_BRAND_UNKNOWN && acl->ats_acl.acl_cnt == 0)
- return (0);
+ goto done;
// TODO: Do we want to handle ACL_BRAND_NFS4 in this function? */
if (_acl_brand(acl) != ACL_BRAND_POSIX)
@@ -92,6 +91,7 @@ acl_equiv_mode_np(acl_t acl, mode_t *mode_p)
}
}
+done:
if (mode_p != NULL)
*mode_p = ret_mode;
diff --git a/lib/libc/posix1e/acl_extended_file_np.3 b/lib/libc/posix1e/acl_extended_file_np.3
index 26572be9d2b3..4673e9c3e417 100644
--- a/lib/libc/posix1e/acl_extended_file_np.3
+++ b/lib/libc/posix1e/acl_extended_file_np.3
@@ -75,6 +75,7 @@ to the corresponding value:
.Bl -tag -width Er
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
+.El
.Sh SEE ALSO
.Xr extattr_get_file 2 ,
.Xr posix1e 3
diff --git a/lib/libc/posix1e/acl_extended_file_np.c b/lib/libc/posix1e/acl_extended_file_np.c
index 27b5c9b20776..9c1452e96d93 100644
--- a/lib/libc/posix1e/acl_extended_file_np.c
+++ b/lib/libc/posix1e/acl_extended_file_np.c
@@ -29,7 +29,6 @@
* acl_extended_file_np: Check if the file has extended ACLs set.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_flag.c b/lib/libc/posix1e/acl_flag.c
index 82772bf261f1..eaaaecd9a374 100644
--- a/lib/libc/posix1e/acl_flag.c
+++ b/lib/libc/posix1e/acl_flag.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <errno.h>
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_free.c b/lib/libc/posix1e/acl_free.c
index 1de6d3105047..813ec6a35fb6 100644
--- a/lib/libc/posix1e/acl_free.c
+++ b/lib/libc/posix1e/acl_free.c
@@ -29,7 +29,6 @@
* acl_free -- free ACL objects from user memory
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_from_mode_np.c b/lib/libc/posix1e/acl_from_mode_np.c
index b08cc5b5e6a0..3d4135770917 100644
--- a/lib/libc/posix1e/acl_from_mode_np.c
+++ b/lib/libc/posix1e/acl_from_mode_np.c
@@ -29,7 +29,6 @@
* acl_from_mode_np: Create an ACL from a mode_t.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_from_text.c b/lib/libc/posix1e/acl_from_text.c
index 2a1c21fa7859..765b58290a04 100644
--- a/lib/libc/posix1e/acl_from_text.c
+++ b/lib/libc/posix1e/acl_from_text.c
@@ -29,7 +29,6 @@
* acl_from_text: Convert a text-form ACL from a string to an acl_t.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_from_text_nfs4.c b/lib/libc/posix1e/acl_from_text_nfs4.c
index 41fb96973d91..ed82c1093bc4 100644
--- a/lib/libc/posix1e/acl_from_text_nfs4.c
+++ b/lib/libc/posix1e/acl_from_text_nfs4.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/lib/libc/posix1e/acl_get.3 b/lib/libc/posix1e/acl_get.3
index 1908f0d0d97b..91a3626ada72 100644
--- a/lib/libc/posix1e/acl_get.3
+++ b/lib/libc/posix1e/acl_get.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 25, 2009
+.Dd September 21, 2023
.Dt ACL_GET 3
.Os
.Sh NAME
@@ -151,16 +151,8 @@ The file system does not support ACL retrieval.
.Xr posix1e 3
.Sh STANDARDS
POSIX.1e is described in IEEE POSIX.1e draft 17.
-Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list.
-To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
.Sh HISTORY
POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
+.Fx 4.0 .
.Sh AUTHORS
.An Robert N M Watson
diff --git a/lib/libc/posix1e/acl_get.c b/lib/libc/posix1e/acl_get.c
index f5191d739dcc..a02c2d53085d 100644
--- a/lib/libc/posix1e/acl_get.c
+++ b/lib/libc/posix1e/acl_get.c
@@ -40,7 +40,6 @@
* acl_get_tag_type() returns the tag type for the ACL entry entry_d
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_get_entry.3 b/lib/libc/posix1e/acl_get_entry.3
index 1c6126334fa3..94a95b5412b7 100644
--- a/lib/libc/posix1e/acl_get_entry.3
+++ b/lib/libc/posix1e/acl_get_entry.3
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 13, 2001
+.Dd September 21, 2023
.Dt ACL_GET_ENTRY 3
.Os
.Sh NAME
@@ -42,7 +42,7 @@ The
function
is a POSIX.1e call that retrieves a descriptor for an ACL entry
specified by the argument
-.Fa entry_d
+.Fa entry_id
within the ACL indicated by the argument
.Fa acl .
.Pp
@@ -100,7 +100,7 @@ will be set to indicate the error.
.Sh ERRORS
The
.Fn acl_get_entry
-fails if:
+function fails if:
.Bl -tag -width Er
.It Bq Er EINVAL
Argument
diff --git a/lib/libc/posix1e/acl_id_to_name.c b/lib/libc/posix1e/acl_id_to_name.c
index b5afe7d16613..78e050a8648a 100644
--- a/lib/libc/posix1e/acl_id_to_name.c
+++ b/lib/libc/posix1e/acl_id_to_name.c
@@ -30,7 +30,6 @@
* These calls are intended only to be called within the library.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_init.c b/lib/libc/posix1e/acl_init.c
index eaa554df4fe8..587817388081 100644
--- a/lib/libc/posix1e/acl_init.c
+++ b/lib/libc/posix1e/acl_init.c
@@ -30,7 +30,6 @@
* acl_dup -- duplicate an acl and return the new copy
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_perm.c b/lib/libc/posix1e/acl_perm.c
index f6abf404c4f8..9ad103398646 100644
--- a/lib/libc/posix1e/acl_perm.c
+++ b/lib/libc/posix1e/acl_perm.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_set.c b/lib/libc/posix1e/acl_set.c
index 5edc291b5171..359dda2c1619 100644
--- a/lib/libc/posix1e/acl_set.c
+++ b/lib/libc/posix1e/acl_set.c
@@ -31,7 +31,6 @@
* acl_set_file -- set a file/directory ACL by name
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_strip.c b/lib/libc/posix1e/acl_strip.c
index ac6c94e66f86..9af1ad680036 100644
--- a/lib/libc/posix1e/acl_strip.c
+++ b/lib/libc/posix1e/acl_strip.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdio.h>
#include <assert.h>
diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c
index c4552d9799a2..82abeb0273f9 100644
--- a/lib/libc/posix1e/acl_support.c
+++ b/lib/libc/posix1e/acl_support.c
@@ -30,7 +30,6 @@
* These calls are intended only to be called within the library.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c
index 9062ec31cd43..08647651933b 100644
--- a/lib/libc/posix1e/acl_support_nfs4.c
+++ b/lib/libc/posix1e/acl_support_nfs4.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/posix1e/acl_to_text.c b/lib/libc/posix1e/acl_to_text.c
index 3b2156c61560..c17253e2cec2 100644
--- a/lib/libc/posix1e/acl_to_text.c
+++ b/lib/libc/posix1e/acl_to_text.c
@@ -30,9 +30,8 @@
* in it.
*/
-#include <sys/cdefs.h>
-#include <sys/types.h>
#include "namespace.h"
+#include <sys/param.h>
#include <sys/acl.h>
#include "un-namespace.h"
#include <sys/errno.h>
diff --git a/lib/libc/posix1e/acl_to_text_nfs4.c b/lib/libc/posix1e/acl_to_text_nfs4.c
index 522ebe3d4373..157215c9dd52 100644
--- a/lib/libc/posix1e/acl_to_text_nfs4.c
+++ b/lib/libc/posix1e/acl_to_text_nfs4.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -73,6 +72,7 @@ format_who(char *str, size_t size, const acl_entry_t entry, int numeric)
snprintf(str, size, "user:%d", (unsigned int)*id);
else
snprintf(str, size, "user:%s", pwd->pw_name);
+ acl_free(id);
break;
case ACL_GROUP_OBJ:
@@ -92,6 +92,7 @@ format_who(char *str, size_t size, const acl_entry_t entry, int numeric)
snprintf(str, size, "group:%d", (unsigned int)*id);
else
snprintf(str, size, "group:%s", grp->gr_name);
+ acl_free(id);
break;
case ACL_EVERYONE:
@@ -158,6 +159,7 @@ format_additional_id(char *str, size_t size, const acl_entry_t entry)
if (id == NULL)
return (-1);
snprintf(str, size, ":%d", (unsigned int)*id);
+ acl_free(id);
}
return (0);
diff --git a/lib/libc/posix1e/acl_valid.c b/lib/libc/posix1e/acl_valid.c
index b0468d5a57d8..c804b0840307 100644
--- a/lib/libc/posix1e/acl_valid.c
+++ b/lib/libc/posix1e/acl_valid.c
@@ -31,7 +31,6 @@
* acl_valid -- POSIX.1e ACL check routine
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "namespace.h"
#include <sys/acl.h>
diff --git a/lib/libc/posix1e/extattr.c b/lib/libc/posix1e/extattr.c
index 816b3a6952ad..6938c302b8a4 100644
--- a/lib/libc/posix1e/extattr.c
+++ b/lib/libc/posix1e/extattr.c
@@ -29,7 +29,6 @@
* TrustedBSD: Utility functions for extended attributes.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/extattr.h>
diff --git a/lib/libc/posix1e/mac.c b/lib/libc/posix1e/mac.c
index c1bfcf15969a..8f3a63e40ac5 100644
--- a/lib/libc/posix1e/mac.c
+++ b/lib/libc/posix1e/mac.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/posix1e/mac_exec.c b/lib/libc/posix1e/mac_exec.c
index acd7c1d6e828..3016f21edd0d 100644
--- a/lib/libc/posix1e/mac_exec.c
+++ b/lib/libc/posix1e/mac_exec.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/mac.h>
diff --git a/lib/libc/posix1e/mac_free.3 b/lib/libc/posix1e/mac_free.3
index 987bd9966564..4ed68b70f3a3 100644
--- a/lib/libc/posix1e/mac_free.3
+++ b/lib/libc/posix1e/mac_free.3
@@ -31,7 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 21, 2001
+.Dd September 21, 2023
.Dt MAC_FREE 3
.Os
.Sh NAME
@@ -67,12 +67,6 @@ function.
.Xr mac 9
.Sh STANDARDS
POSIX.1e is described in IEEE POSIX.1e draft 17.
-Discussion of the draft
-continues on the cross-platform POSIX.1e implementation mailing list.
-To join this list, see the
-.Fx
-POSIX.1e implementation page
-for more information.
.Sh HISTORY
Support for Mandatory Access Control was introduced in
.Fx 5.0
diff --git a/lib/libc/posix1e/mac_get.3 b/lib/libc/posix1e/mac_get.3
index 45045977fb32..171f7cd91aaf 100644
--- a/lib/libc/posix1e/mac_get.3
+++ b/lib/libc/posix1e/mac_get.3
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 21, 2001
+.Dd September 21, 2023
.Dt MAC_GET 3
.Os
.Sh NAME
@@ -136,12 +136,6 @@ is not a directory.
.Xr mac 9
.Sh STANDARDS
POSIX.1e is described in IEEE POSIX.1e draft 17.
-Discussion of the draft
-continues on the cross-platform POSIX.1e implementation mailing list.
-To join this list, see the
-.Fx
-POSIX.1e implementation page
-for more information.
.Sh HISTORY
Support for Mandatory Access Control was introduced in
.Fx 5.0
diff --git a/lib/libc/posix1e/mac_get.c b/lib/libc/posix1e/mac_get.c
index 5bf829e9a160..5bfc0a549754 100644
--- a/lib/libc/posix1e/mac_get.c
+++ b/lib/libc/posix1e/mac_get.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/mac.h>
#include <sys/socket.h>
diff --git a/lib/libc/posix1e/mac_prepare.3 b/lib/libc/posix1e/mac_prepare.3
index 58493e988a0b..50dfa1c28d2d 100644
--- a/lib/libc/posix1e/mac_prepare.3
+++ b/lib/libc/posix1e/mac_prepare.3
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 22, 2003
+.Dd September 21, 2023
.Dt MAC_PREPARE 3
.Os
.Sh NAME
@@ -108,12 +108,6 @@ respectively.
.Xr maclabel 7
.Sh STANDARDS
POSIX.1e is described in IEEE POSIX.1e draft 17.
-Discussion of the draft
-continues on the cross-platform POSIX.1e implementation mailing list.
-To join this list, see the
-.Fx
-POSIX.1e implementation page
-for more information.
.Sh HISTORY
Support for Mandatory Access Control was introduced in
.Fx 5.0
diff --git a/lib/libc/posix1e/mac_set.c b/lib/libc/posix1e/mac_set.c
index cded5a7cca70..8197d4354910 100644
--- a/lib/libc/posix1e/mac_set.c
+++ b/lib/libc/posix1e/mac_set.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/mac.h>
diff --git a/lib/libc/posix1e/mac_text.3 b/lib/libc/posix1e/mac_text.3
index 88131f0bf611..29c1aacca485 100644
--- a/lib/libc/posix1e/mac_text.3
+++ b/lib/libc/posix1e/mac_text.3
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 21, 2001
+.Dd September 21, 2023
.Dt MAC_TEXT 3
.Os
.Sh NAME
@@ -101,12 +101,6 @@ to allocate internal storage.
.Xr maclabel 7
.Sh STANDARDS
POSIX.1e is described in IEEE POSIX.1e draft 17.
-Discussion of the draft
-continues on the cross-platform POSIX.1e implementation mailing list.
-To join this list, see the
-.Fx
-POSIX.1e implementation page
-for more information.
.Sh HISTORY
Support for Mandatory Access Control was introduced in
.Fx 5.0
diff --git a/lib/libc/posix1e/posix1e.3 b/lib/libc/posix1e/posix1e.3
index 8eef3bb21724..1dbe12427da1 100644
--- a/lib/libc/posix1e/posix1e.3
+++ b/lib/libc/posix1e/posix1e.3
@@ -46,7 +46,7 @@ its interfaces are widely used.
implements POSIX.1e interface for access control lists, described in
.Xr acl 3 ,
and supports ACLs on the
-.Xr ffs 7
+.Xr ffs 4
file system; ACLs must be administratively enabled using
.Xr tunefs 8 .
.Pp
@@ -95,7 +95,7 @@ for mandatory access control labels.
.Xr libcasper 3 ,
.Xr mac 3 ,
.Xr capsicum 4 ,
-.Xr ffs 7 ,
+.Xr ffs 4 ,
.Xr getfmac 8 ,
.Xr setfmac 8 ,
.Xr tunefs 8 ,
diff --git a/lib/libc/powerpc/Makefile.inc b/lib/libc/powerpc/Makefile.inc
index 80ac23a9947c..1d1fadd21330 100644
--- a/lib/libc/powerpc/Makefile.inc
+++ b/lib/libc/powerpc/Makefile.inc
@@ -1,4 +1,3 @@
-
# Long double is 64-bits
SRCS+=machdep_ldisd.c
SYM_MAPS+=${LIBC_SRCTOP}/powerpc/Symbol.map
diff --git a/lib/libc/powerpc/SYS.h b/lib/libc/powerpc/SYS.h
deleted file mode 100644
index 7fdf7c734310..000000000000
--- a/lib/libc/powerpc/SYS.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 2002 Benno Rice. All rights reserved.
- * Copyright (c) 2002 David E. O'Brien. 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 author nor the names of any contributors
- * may 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 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.
- *
- * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $
- */
-
-#include <sys/syscall.h>
-#include <machine/asm.h>
-
-#define _SYSCALL(name) \
- .text; \
- .align 2; \
- li 0,(SYS_##name); \
- sc
-
-#define SYSCALL(name) \
- .text; \
- .align 2; \
-2: b CNAME(HIDENAME(cerror)); \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bso 2b
-
-#define PSEUDO(name) \
- .text; \
- .align 2; \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bnslr; \
- b CNAME(HIDENAME(cerror)); \
-END(__sys_##name)
-
-#define RSYSCALL(name) \
- .text; \
- .align 2; \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bnslr; \
- b CNAME(HIDENAME(cerror)); \
-END(__sys_##name)
diff --git a/lib/libc/powerpc/Symbol.map b/lib/libc/powerpc/Symbol.map
index fb82bcdb27f0..ccf74c1748e4 100644
--- a/lib/libc/powerpc/Symbol.map
+++ b/lib/libc/powerpc/Symbol.map
@@ -1,39 +1,18 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
_mcount;
- _setjmp;
- _longjmp;
- fabs;
__flt_rounds;
+ brk;
fpgetmask;
fpgetround;
fpgetsticky;
fpsetmask;
fpsetround;
- __infinity;
- __nan;
- makecontext;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- brk;
sbrk;
- vfork;
};
FBSD_1.3 {
@@ -41,11 +20,6 @@ FBSD_1.3 {
};
FBSDprivate_1.0 {
- /* PSEUDO syscalls */
- _getlogin;
-
- _fpgetsticky;
- __makecontext;
__longjmp;
signalcontext;
__signalcontext;
diff --git a/lib/libc/powerpc/gen/Makefile.common b/lib/libc/powerpc/gen/Makefile.common
index d0d78197ca63..70aa9ea5d9c3 100644
--- a/lib/libc/powerpc/gen/Makefile.common
+++ b/lib/libc/powerpc/gen/Makefile.common
@@ -1,4 +1,3 @@
-
.PATH: ${LIBC_SRCTOP}/powerpc/gen
SRCS += _ctx_start.S eabi.S infinity.c ldexp.c makecontext.c \
diff --git a/lib/libc/powerpc/gen/Makefile.inc b/lib/libc/powerpc/gen/Makefile.inc
index efdc778e8999..502f3dc231bf 100644
--- a/lib/libc/powerpc/gen/Makefile.inc
+++ b/lib/libc/powerpc/gen/Makefile.inc
@@ -1,4 +1,3 @@
-
.include "${LIBC_SRCTOP}/powerpc/gen/Makefile.common"
SRCS += fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
diff --git a/lib/libc/powerpc/gen/flt_rounds.c b/lib/libc/powerpc/gen/flt_rounds.c
index 601a42321a16..77e04694dc69 100644
--- a/lib/libc/powerpc/gen/flt_rounds.c
+++ b/lib/libc/powerpc/gen/flt_rounds.c
@@ -33,7 +33,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/float.h>
diff --git a/lib/libc/powerpc/gen/fpgetmask.c b/lib/libc/powerpc/gen/fpgetmask.c
index b4399f23cf72..6817a32bdc65 100644
--- a/lib/libc/powerpc/gen/fpgetmask.c
+++ b/lib/libc/powerpc/gen/fpgetmask.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc/gen/fpgetround.c b/lib/libc/powerpc/gen/fpgetround.c
index f6a98d3ffe1f..b135807b613f 100644
--- a/lib/libc/powerpc/gen/fpgetround.c
+++ b/lib/libc/powerpc/gen/fpgetround.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc/gen/fpgetsticky.c b/lib/libc/powerpc/gen/fpgetsticky.c
index a79f4062c7f9..3512c97f8cf9 100644
--- a/lib/libc/powerpc/gen/fpgetsticky.c
+++ b/lib/libc/powerpc/gen/fpgetsticky.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
@@ -39,10 +38,6 @@
#include <ieeefp.h>
#ifndef _SOFT_FLOAT
-#ifdef __weak_alias
-__weak_alias(fpgetsticky,_fpgetsticky)
-#endif
-
fp_except_t
fpgetsticky()
{
diff --git a/lib/libc/powerpc/gen/fpsetmask.c b/lib/libc/powerpc/gen/fpsetmask.c
index eb5884aa080c..4170b385e9e4 100644
--- a/lib/libc/powerpc/gen/fpsetmask.c
+++ b/lib/libc/powerpc/gen/fpsetmask.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc/gen/fpsetround.c b/lib/libc/powerpc/gen/fpsetround.c
index 82ec0ea354c2..2a70fd781474 100644
--- a/lib/libc/powerpc/gen/fpsetround.c
+++ b/lib/libc/powerpc/gen/fpsetround.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc/gen/makecontext.c b/lib/libc/powerpc/gen/makecontext.c
index eb3cf2bb3d3b..5fbb0a96f05c 100644
--- a/lib/libc/powerpc/gen/makecontext.c
+++ b/lib/libc/powerpc/gen/makecontext.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdarg.h>
diff --git a/lib/libc/powerpc/gen/signalcontext.c b/lib/libc/powerpc/gen/signalcontext.c
index 253f1c8a7626..8cc9c1c94918 100644
--- a/lib/libc/powerpc/gen/signalcontext.c
+++ b/lib/libc/powerpc/gen/signalcontext.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ucontext.h>
#include <signal.h>
diff --git a/lib/libc/powerpc/gen/syncicache.c b/lib/libc/powerpc/gen/syncicache.c
index 5192d1356153..6376cb0e576d 100644
--- a/lib/libc/powerpc/gen/syncicache.c
+++ b/lib/libc/powerpc/gen/syncicache.c
@@ -33,11 +33,6 @@
* $NetBSD: syncicache.c,v 1.2 1999/05/05 12:36:40 tsubai Exp $
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/time.h>
diff --git a/lib/libc/powerpc/static_tls.h b/lib/libc/powerpc/static_tls.h
deleted file mode 100644
index 9ae38c71a515..000000000000
--- a/lib/libc/powerpc/static_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_POWERPC_STATIC_TLS_H
-#define _LIBC_POWERPC_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("mr %0,2" : "=r"(tlsbase));
- tlsbase += offset - 0x7008;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/powerpc/sys/Makefile.inc b/lib/libc/powerpc/sys/Makefile.inc
deleted file mode 100644
index 17b7b3b26111..000000000000
--- a/lib/libc/powerpc/sys/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-
-SRCS+= __vdso_gettc.c \
- sched_getcpu_gen.c
-
-MDASM+= cerror.S
diff --git a/lib/libc/powerpc/sys/__vdso_gettc.c b/lib/libc/powerpc/sys/__vdso_gettc.c
deleted file mode 100644
index 21f0f2dd87ec..000000000000
--- a/lib/libc/powerpc/sys/__vdso_gettc.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Brandon Bergren <bdragon@FreeBSD.org>
- *
- * This software was developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/elf.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-
-#include <machine/cpufunc.h>
-#include <machine/spr.h>
-
-#include <errno.h>
-
-#include "libc_private.h"
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
-
- if (__predict_false(th->th_algo != VDSO_TH_ALGO_PPC_TB))
- return (ENOSYS);
- /*
- * While the timebase is a 64 bit quantity, we are only interested
- * in the lower 32 bits of it.
- */
- *tc = mfspr(TBR_TBL);
-
- return (0);
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
-
- return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
-}
diff --git a/lib/libc/powerpc64/Makefile.inc b/lib/libc/powerpc64/Makefile.inc
index 4aac4e3a6e68..734afe95f243 100644
--- a/lib/libc/powerpc64/Makefile.inc
+++ b/lib/libc/powerpc64/Makefile.inc
@@ -1,4 +1,3 @@
-
# Long double is 64-bits
SRCS+=machdep_ldisd.c
SYM_MAPS+=${LIBC_SRCTOP}/powerpc64/Symbol.map
diff --git a/lib/libc/powerpc64/SYS.h b/lib/libc/powerpc64/SYS.h
deleted file mode 100644
index c364090a5487..000000000000
--- a/lib/libc/powerpc64/SYS.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 2002 Benno Rice. All rights reserved.
- * Copyright (c) 2002 David E. O'Brien. 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 author nor the names of any contributors
- * may 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 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.
- *
- * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $
- */
-
-#include <sys/syscall.h>
-#include <machine/asm.h>
-
-#define _SYSCALL(name) \
- .text; \
- .align 2; \
- li 0,(SYS_##name); \
- sc
-
-#define SYSCALL(name) \
- .text; \
- .align 2; \
-2: mflr %r0; \
- std %r0,16(%r1); \
- stdu %r1,-48(%r1); \
- bl CNAME(HIDENAME(cerror)); \
- nop; \
- addi %r1,%r1,48; \
- ld %r0,16(%r1); \
- mtlr %r0; \
- blr; \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bso 2b
-
-#define PSEUDO(name) \
- .text; \
- .align 2; \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bnslr; \
- mflr %r0; \
- std %r0,16(%r1); \
- stdu %r1,-48(%r1); \
- bl CNAME(HIDENAME(cerror)); \
- nop; \
- addi %r1,%r1,48; \
- ld %r0,16(%r1); \
- mtlr %r0; \
- blr; \
-END(__sys_##name)
-
-#define RSYSCALL(name) \
- .text; \
- .align 2; \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bnslr; \
- \
- mflr %r0; \
- std %r0,16(%r1); \
- stdu %r1,-48(%r1); \
- bl CNAME(HIDENAME(cerror)); \
- nop; \
- addi %r1,%r1,48; \
- ld %r0,16(%r1); \
- mtlr %r0; \
- blr; \
-END(__sys_##name)
diff --git a/lib/libc/powerpc64/Symbol.map b/lib/libc/powerpc64/Symbol.map
index 7d010fda6693..62f20e7f352c 100644
--- a/lib/libc/powerpc64/Symbol.map
+++ b/lib/libc/powerpc64/Symbol.map
@@ -1,49 +1,16 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
_mcount;
- _setjmp;
- _longjmp;
- fabs;
__flt_rounds;
+ brk;
fpgetmask;
fpgetround;
fpgetsticky;
fpsetmask;
fpsetround;
- __infinity;
- __nan;
- makecontext;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- brk;
sbrk;
- vfork;
-};
-
-FBSDprivate_1.0 {
- /* PSEUDO syscalls */
- _getlogin;
-
- _fpgetsticky;
- __makecontext;
- __longjmp;
- signalcontext;
- __signalcontext;
- __syncicache;
};
diff --git a/lib/libc/powerpc64/gen/Makefile.inc b/lib/libc/powerpc64/gen/Makefile.inc
index 26265df5fbd2..c48ff05ae552 100644
--- a/lib/libc/powerpc64/gen/Makefile.inc
+++ b/lib/libc/powerpc64/gen/Makefile.inc
@@ -1,4 +1,3 @@
-
SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
fpgetsticky.c fpsetmask.c fpsetround.c \
infinity.c ldexp.c makecontext.c _setjmp.S \
diff --git a/lib/libc/powerpc64/gen/_ctx_start.S b/lib/libc/powerpc64/gen/_ctx_start.S
index c2f8abfd6486..98225f9c1138 100644
--- a/lib/libc/powerpc64/gen/_ctx_start.S
+++ b/lib/libc/powerpc64/gen/_ctx_start.S
@@ -34,6 +34,16 @@
ld %r2,8(%r14)
ld %r14,0(%r14)
#else
+ /*
+ * The stack frame was already set up in makecontext(),
+ * so we can safely use the guaranteed fields here.
+ *
+ * Note we do step on the allocated stack frame's TOC,
+ * but since we never return from this function (i.e.
+ * never restore the stack frame) this should be safe.
+ */
+ std %r2,24(%r1) /* save TOC */
+
/* Load global entry point */
mr %r12,%r14
#endif
@@ -41,6 +51,10 @@
blrl /* branch to start function */
mr %r3,%r15 /* pass pointer to ucontext as argument */
nop
+#if defined(_CALL_ELF) && _CALL_ELF != 1
+ /* Restore TOC */
+ ld %r2,24(%r1)
+#endif
bl CNAME(_ctx_done) /* branch to ctxt completion func */
/*
* we should never return from the
diff --git a/lib/libc/powerpc64/gen/flt_rounds.c b/lib/libc/powerpc64/gen/flt_rounds.c
index 16ec162fc14b..800ec6944d79 100644
--- a/lib/libc/powerpc64/gen/flt_rounds.c
+++ b/lib/libc/powerpc64/gen/flt_rounds.c
@@ -33,7 +33,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/float.h>
diff --git a/lib/libc/powerpc64/gen/fpgetmask.c b/lib/libc/powerpc64/gen/fpgetmask.c
index b4399f23cf72..6817a32bdc65 100644
--- a/lib/libc/powerpc64/gen/fpgetmask.c
+++ b/lib/libc/powerpc64/gen/fpgetmask.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc64/gen/fpgetround.c b/lib/libc/powerpc64/gen/fpgetround.c
index f6a98d3ffe1f..b135807b613f 100644
--- a/lib/libc/powerpc64/gen/fpgetround.c
+++ b/lib/libc/powerpc64/gen/fpgetround.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc64/gen/fpgetsticky.c b/lib/libc/powerpc64/gen/fpgetsticky.c
index a79f4062c7f9..3512c97f8cf9 100644
--- a/lib/libc/powerpc64/gen/fpgetsticky.c
+++ b/lib/libc/powerpc64/gen/fpgetsticky.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
@@ -39,10 +38,6 @@
#include <ieeefp.h>
#ifndef _SOFT_FLOAT
-#ifdef __weak_alias
-__weak_alias(fpgetsticky,_fpgetsticky)
-#endif
-
fp_except_t
fpgetsticky()
{
diff --git a/lib/libc/powerpc64/gen/fpsetmask.c b/lib/libc/powerpc64/gen/fpsetmask.c
index eb5884aa080c..4170b385e9e4 100644
--- a/lib/libc/powerpc64/gen/fpsetmask.c
+++ b/lib/libc/powerpc64/gen/fpsetmask.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc64/gen/fpsetround.c b/lib/libc/powerpc64/gen/fpsetround.c
index 82ec0ea354c2..2a70fd781474 100644
--- a/lib/libc/powerpc64/gen/fpsetround.c
+++ b/lib/libc/powerpc64/gen/fpsetround.c
@@ -32,7 +32,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpc64/gen/makecontext.c b/lib/libc/powerpc64/gen/makecontext.c
index 34d16fc673a8..9e3a976fa1bd 100644
--- a/lib/libc/powerpc64/gen/makecontext.c
+++ b/lib/libc/powerpc64/gen/makecontext.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdarg.h>
@@ -79,7 +78,7 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
*/
stackargs = (argc > 8) ? argc - 8 : 0;
sp = (char *) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size
- - sizeof(uintptr_t)*(stackargs + 2);
+ - sizeof(uintptr_t)*(stackargs + 6);
sp = (char *)((uintptr_t)sp & ~0x1f);
mc = &ucp->uc_mcontext;
@@ -120,6 +119,7 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
mc->mc_srr0 = *(uintptr_t *)_ctx_start;
#else
mc->mc_srr0 = (uintptr_t) _ctx_start;
+ mc->mc_gpr[12] = (uintptr_t) _ctx_start;/* required for prologue */
#endif
mc->mc_gpr[1] = (uintptr_t) sp; /* new stack pointer */
mc->mc_gpr[14] = (uintptr_t) start; /* r14 <- start */
diff --git a/lib/libc/powerpc64/gen/signalcontext.c b/lib/libc/powerpc64/gen/signalcontext.c
index 5fac663fb15b..de0b2109bba4 100644
--- a/lib/libc/powerpc64/gen/signalcontext.c
+++ b/lib/libc/powerpc64/gen/signalcontext.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ucontext.h>
#include <signal.h>
diff --git a/lib/libc/powerpc64/gen/syncicache.c b/lib/libc/powerpc64/gen/syncicache.c
index d96529bc3833..7885a36bd1d1 100644
--- a/lib/libc/powerpc64/gen/syncicache.c
+++ b/lib/libc/powerpc64/gen/syncicache.c
@@ -33,11 +33,6 @@
* $NetBSD: syncicache.c,v 1.2 1999/05/05 12:36:40 tsubai Exp $
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#if defined(_KERNEL) || defined(_STANDALONE)
#include <sys/time.h>
diff --git a/lib/libc/powerpc64/static_tls.h b/lib/libc/powerpc64/static_tls.h
deleted file mode 100644
index 014b8a931453..000000000000
--- a/lib/libc/powerpc64/static_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_POWERPC64_STATIC_TLS_H
-#define _LIBC_POWERPC64_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("mr %0,13" : "=r"(tlsbase));
- tlsbase += offset - 0x7010;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/powerpc64/string/Makefile.inc b/lib/libc/powerpc64/string/Makefile.inc
index d1918ff027c3..c9d7c9d71676 100644
--- a/lib/libc/powerpc64/string/Makefile.inc
+++ b/lib/libc/powerpc64/string/Makefile.inc
@@ -1,4 +1,3 @@
-
MDSRCS+= \
bcopy.S \
bcopy_vsx.S \
diff --git a/lib/libc/powerpc64/string/bcopy_resolver.c b/lib/libc/powerpc64/string/bcopy_resolver.c
index a551d5d3ca5e..c99c53b2f9b3 100644
--- a/lib/libc/powerpc64/string/bcopy_resolver.c
+++ b/lib/libc/powerpc64/string/bcopy_resolver.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include <machine/cpu.h>
#include <machine/ifunc.h>
diff --git a/lib/libc/powerpc64/string/strcpy.c b/lib/libc/powerpc64/string/strcpy.c
index 23531264d8f4..d0be3ca468a0 100644
--- a/lib/libc/powerpc64/string/strcpy.c
+++ b/lib/libc/powerpc64/string/strcpy.c
@@ -26,6 +26,5 @@
*/
-#include <sys/cdefs.h>
#define WEAK_STRCPY
#include "../../string/strcpy.c"
diff --git a/lib/libc/powerpc64/string/strcpy_resolver.c b/lib/libc/powerpc64/string/strcpy_resolver.c
index 513d33e96e28..7a64ce41c7e4 100644
--- a/lib/libc/powerpc64/string/strcpy_resolver.c
+++ b/lib/libc/powerpc64/string/strcpy_resolver.c
@@ -26,7 +26,6 @@
*/
-#include <sys/cdefs.h>
#include <machine/cpu.h>
#include <machine/ifunc.h>
diff --git a/lib/libc/powerpc64/string/strncpy.c b/lib/libc/powerpc64/string/strncpy.c
index 6879834c5818..aef3fb88724a 100644
--- a/lib/libc/powerpc64/string/strncpy.c
+++ b/lib/libc/powerpc64/string/strncpy.c
@@ -26,6 +26,5 @@
*/
-#include <sys/cdefs.h>
#define WEAK_STRNCPY
#include "../../string/strncpy.c"
diff --git a/lib/libc/powerpc64/string/strncpy_resolver.c b/lib/libc/powerpc64/string/strncpy_resolver.c
index b3b5511c74b5..402b5c5226d0 100644
--- a/lib/libc/powerpc64/string/strncpy_resolver.c
+++ b/lib/libc/powerpc64/string/strncpy_resolver.c
@@ -26,7 +26,6 @@
*/
-#include <sys/cdefs.h>
#include <machine/cpu.h>
#include <machine/ifunc.h>
diff --git a/lib/libc/powerpc64/sys/Makefile.inc b/lib/libc/powerpc64/sys/Makefile.inc
deleted file mode 100644
index 17b7b3b26111..000000000000
--- a/lib/libc/powerpc64/sys/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-
-SRCS+= __vdso_gettc.c \
- sched_getcpu_gen.c
-
-MDASM+= cerror.S
diff --git a/lib/libc/powerpc64/sys/__vdso_gettc.c b/lib/libc/powerpc64/sys/__vdso_gettc.c
deleted file mode 100644
index b9c924e0e542..000000000000
--- a/lib/libc/powerpc64/sys/__vdso_gettc.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Brandon Bergren <bdragon@FreeBSD.org>
- *
- * This software was developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/elf.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-
-#include <machine/cpufunc.h>
-
-#include <errno.h>
-
-#include "libc_private.h"
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
- u_quad_t tb;
-
- if (__predict_false(th->th_algo != VDSO_TH_ALGO_PPC_TB))
- return (ENOSYS);
-
- __asm __volatile ("mftb %0" : "=r"(tb));
- *tc = tb;
- return (0);
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
-
- return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
-}
diff --git a/lib/libc/powerpcspe/Makefile.inc b/lib/libc/powerpcspe/Makefile.inc
index 6962e107ed4d..0b5879574480 100644
--- a/lib/libc/powerpcspe/Makefile.inc
+++ b/lib/libc/powerpcspe/Makefile.inc
@@ -1,4 +1,3 @@
-
CFLAGS+= -I${LIBC_SRCTOP}/powerpc
# Long double is 64-bits
diff --git a/lib/libc/powerpcspe/_fpmath.h b/lib/libc/powerpcspe/_fpmath.h
new file mode 100644
index 000000000000..9bc7450aacaf
--- /dev/null
+++ b/lib/libc/powerpcspe/_fpmath.h
@@ -0,0 +1,56 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 David Schultz <das@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.
+ */
+
+union IEEEl2bits {
+ long double e;
+ struct {
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+ unsigned int manl :32;
+ unsigned int manh :20;
+ unsigned int exp :11;
+ unsigned int sign :1;
+#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
+ unsigned int sign :1;
+ unsigned int exp :11;
+ unsigned int manh :20;
+ unsigned int manl :32;
+#endif
+ } bits;
+};
+
+#define mask_nbit_l(u) ((void)0)
+#define LDBL_IMPLICIT_NBIT
+#define LDBL_NBIT 0
+
+#define LDBL_MANH_SIZE 20
+#define LDBL_MANL_SIZE 32
+
+#define LDBL_TO_ARRAY32(u, a) do { \
+ (a)[0] = (uint32_t)(u).bits.manl; \
+ (a)[1] = (uint32_t)(u).bits.manh; \
+} while(0)
diff --git a/lib/libc/powerpcspe/gen/Makefile.inc b/lib/libc/powerpcspe/gen/Makefile.inc
index efdc778e8999..502f3dc231bf 100644
--- a/lib/libc/powerpcspe/gen/Makefile.inc
+++ b/lib/libc/powerpcspe/gen/Makefile.inc
@@ -1,4 +1,3 @@
-
.include "${LIBC_SRCTOP}/powerpc/gen/Makefile.common"
SRCS += fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
diff --git a/lib/libc/powerpcspe/gen/flt_rounds.c b/lib/libc/powerpcspe/gen/flt_rounds.c
index eec1d3a05693..26dfca0e0e3a 100644
--- a/lib/libc/powerpcspe/gen/flt_rounds.c
+++ b/lib/libc/powerpcspe/gen/flt_rounds.c
@@ -31,7 +31,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/float.h>
#include <machine/spr.h>
diff --git a/lib/libc/powerpcspe/gen/fpgetmask.c b/lib/libc/powerpcspe/gen/fpgetmask.c
index b46a52fae220..f7679be4ca54 100644
--- a/lib/libc/powerpcspe/gen/fpgetmask.c
+++ b/lib/libc/powerpcspe/gen/fpgetmask.c
@@ -30,7 +30,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/spr.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpcspe/gen/fpgetround.c b/lib/libc/powerpcspe/gen/fpgetround.c
index 1021a1ad4cc6..9c01bcbaf327 100644
--- a/lib/libc/powerpcspe/gen/fpgetround.c
+++ b/lib/libc/powerpcspe/gen/fpgetround.c
@@ -30,7 +30,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/spr.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpcspe/gen/fpgetsticky.c b/lib/libc/powerpcspe/gen/fpgetsticky.c
index abe83bb2da31..a97c27296cab 100644
--- a/lib/libc/powerpcspe/gen/fpgetsticky.c
+++ b/lib/libc/powerpcspe/gen/fpgetsticky.c
@@ -29,7 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
@@ -38,10 +37,6 @@
#include <ieeefp.h>
#ifndef _SOFT_FLOAT
-#ifdef __weak_alias
-__weak_alias(fpgetsticky,_fpgetsticky)
-#endif
-
fp_except_t
fpgetsticky()
{
diff --git a/lib/libc/powerpcspe/gen/fpsetmask.c b/lib/libc/powerpcspe/gen/fpsetmask.c
index 0563da982c2e..a7a2569df905 100644
--- a/lib/libc/powerpcspe/gen/fpsetmask.c
+++ b/lib/libc/powerpcspe/gen/fpsetmask.c
@@ -30,7 +30,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/spr.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpcspe/gen/fpsetround.c b/lib/libc/powerpcspe/gen/fpsetround.c
index 85b55087935a..2280e190b2f9 100644
--- a/lib/libc/powerpcspe/gen/fpsetround.c
+++ b/lib/libc/powerpcspe/gen/fpsetround.c
@@ -30,7 +30,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/spr.h>
#include <ieeefp.h>
diff --git a/lib/libc/powerpcspe/sys/Makefile.inc b/lib/libc/powerpcspe/sys/Makefile.inc
deleted file mode 100644
index 8f48df0d6021..000000000000
--- a/lib/libc/powerpcspe/sys/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-
-.PATH: ${LIBC_SRCTOP}/powerpc/sys
-.sinclude "${LIBC_SRCTOP}/powerpc/sys/Makefile.inc"
diff --git a/lib/libc/quad/Makefile.inc b/lib/libc/quad/Makefile.inc
index 5da01fba7678..680b58ab2226 100644
--- a/lib/libc/quad/Makefile.inc
+++ b/lib/libc/quad/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
# Quad support, if needed
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/quad ${LIBC_SRCTOP}/quad
diff --git a/lib/libc/quad/Symbol.map b/lib/libc/quad/Symbol.map
index 2752be26abb4..f7dcdebfc7ae 100644
--- a/lib/libc/quad/Symbol.map
+++ b/lib/libc/quad/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
/*
* These symbols really shouldn't be exported since they should
@@ -8,12 +5,15 @@ FBSD_1.0 {
* broken and they expect to see them in libc. glibc exports
* them, but they do not appear to be exported in Solaris.
*/
+#ifndef __i386__
__adddi3;
__anddi3;
__ashldi3;
__ashrdi3;
+#endif
__cmpdi2;
__divdi3;
+#ifndef __i386__
__fixdfdi;
__fixsfdi;
__fixunsdfdi;
@@ -24,14 +24,21 @@ FBSD_1.0 {
__iordi3;
__lshldi3;
__lshrdi3;
+#endif
__moddi3;
+#ifndef __i386__
__muldi3;
__negdi2;
__one_cmpldi2;
+#endif
__qdivrem;
+#ifndef __i386__
__subdi3;
+#endif
__ucmpdi2;
__udivdi3;
__umoddi3;
+#ifndef __i386__
__xordi3;
+#endif
};
diff --git a/lib/libc/quad/TESTS/Makefile b/lib/libc/quad/TESTS/Makefile
index 5834f21e80d7..9cb440158029 100644
--- a/lib/libc/quad/TESTS/Makefile
+++ b/lib/libc/quad/TESTS/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
all: mul divrem
MUL= mul.c ../muldi3.c
diff --git a/lib/libc/quad/TESTS/divrem.c b/lib/libc/quad/TESTS/divrem.c
index 1fd83e52d13b..728c0786f464 100644
--- a/lib/libc/quad/TESTS/divrem.c
+++ b/lib/libc/quad/TESTS/divrem.c
@@ -33,16 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)divrem.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
main()
diff --git a/lib/libc/quad/TESTS/mul.c b/lib/libc/quad/TESTS/mul.c
index f347e4f1e026..9306284f3faf 100644
--- a/lib/libc/quad/TESTS/mul.c
+++ b/lib/libc/quad/TESTS/mul.c
@@ -33,16 +33,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)mul.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
main()
diff --git a/lib/libc/quad/adddi3.c b/lib/libc/quad/adddi3.c
index 0f3a41ff4e2c..15aa300455a7 100644
--- a/lib/libc/quad/adddi3.c
+++ b/lib/libc/quad/adddi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)adddi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/anddi3.c b/lib/libc/quad/anddi3.c
index ad9ec24c1651..3c4e1a320395 100644
--- a/lib/libc/quad/anddi3.c
+++ b/lib/libc/quad/anddi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)anddi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/ashldi3.c b/lib/libc/quad/ashldi3.c
index b18267c723c1..13607351d302 100644
--- a/lib/libc/quad/ashldi3.c
+++ b/lib/libc/quad/ashldi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ashldi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/ashrdi3.c b/lib/libc/quad/ashrdi3.c
index a5157c0dc958..d704b8e68195 100644
--- a/lib/libc/quad/ashrdi3.c
+++ b/lib/libc/quad/ashrdi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ashrdi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/cmpdi2.c b/lib/libc/quad/cmpdi2.c
index f8aae7f018c6..7bd89af9f2d3 100644
--- a/lib/libc/quad/cmpdi2.c
+++ b/lib/libc/quad/cmpdi2.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)cmpdi2.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/divdi3.c b/lib/libc/quad/divdi3.c
index c913faf4c31c..ec3100cf0992 100644
--- a/lib/libc/quad/divdi3.c
+++ b/lib/libc/quad/divdi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)divdi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/fixdfdi.c b/lib/libc/quad/fixdfdi.c
index 5237a5decfaf..a30028d39d3d 100644
--- a/lib/libc/quad/fixdfdi.c
+++ b/lib/libc/quad/fixdfdi.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fixdfdi.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/fixsfdi.c b/lib/libc/quad/fixsfdi.c
index 2cbb41767890..f800d3b40f93 100644
--- a/lib/libc/quad/fixsfdi.c
+++ b/lib/libc/quad/fixsfdi.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fixsfdi.c 5.1 (Berkeley) 7/7/92";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/fixunsdfdi.c b/lib/libc/quad/fixunsdfdi.c
index 8fb23d60d363..250b476385ed 100644
--- a/lib/libc/quad/fixunsdfdi.c
+++ b/lib/libc/quad/fixunsdfdi.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fixunsdfdi.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
#define ONE_FOURTH (1L << (LONG_BITS - 2))
diff --git a/lib/libc/quad/fixunssfdi.c b/lib/libc/quad/fixunssfdi.c
index a1f03f075d9f..114caa9d32a9 100644
--- a/lib/libc/quad/fixunssfdi.c
+++ b/lib/libc/quad/fixunssfdi.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fixunssfdi.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
#define ONE_FOURTH (1L << (LONG_BITS - 2))
diff --git a/lib/libc/quad/floatdidf.c b/lib/libc/quad/floatdidf.c
index 2c4f79da4e45..d6d155ca3b85 100644
--- a/lib/libc/quad/floatdidf.c
+++ b/lib/libc/quad/floatdidf.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)floatdidf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/floatdisf.c b/lib/libc/quad/floatdisf.c
index 9b0251eaff2e..ff50508a2038 100644
--- a/lib/libc/quad/floatdisf.c
+++ b/lib/libc/quad/floatdisf.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)floatdisf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/floatunsdidf.c b/lib/libc/quad/floatunsdidf.c
index 143b0f7da5a4..1bb122184134 100644
--- a/lib/libc/quad/floatunsdidf.c
+++ b/lib/libc/quad/floatunsdidf.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)floatunsdidf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/iordi3.c b/lib/libc/quad/iordi3.c
index 295c075ed18c..3361e1d8764b 100644
--- a/lib/libc/quad/iordi3.c
+++ b/lib/libc/quad/iordi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)iordi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/lshldi3.c b/lib/libc/quad/lshldi3.c
index 1f86398cb54c..ae8d2698bf4e 100644
--- a/lib/libc/quad/lshldi3.c
+++ b/lib/libc/quad/lshldi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)lshldi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/lshrdi3.c b/lib/libc/quad/lshrdi3.c
index 1af382b16da6..13d55bdf2e08 100644
--- a/lib/libc/quad/lshrdi3.c
+++ b/lib/libc/quad/lshrdi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)lshrdi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/moddi3.c b/lib/libc/quad/moddi3.c
index dacd7f849118..919c83575ff2 100644
--- a/lib/libc/quad/moddi3.c
+++ b/lib/libc/quad/moddi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)moddi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/muldi3.c b/lib/libc/quad/muldi3.c
index 194b7d9dd75c..a39598fdbc97 100644
--- a/lib/libc/quad/muldi3.c
+++ b/lib/libc/quad/muldi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)muldi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/negdi2.c b/lib/libc/quad/negdi2.c
index 6f05db6e966a..ca716149ea93 100644
--- a/lib/libc/quad/negdi2.c
+++ b/lib/libc/quad/negdi2.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)negdi2.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/notdi2.c b/lib/libc/quad/notdi2.c
index 072eed6e4234..522ce4a46a56 100644
--- a/lib/libc/quad/notdi2.c
+++ b/lib/libc/quad/notdi2.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)notdi2.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/qdivrem.c b/lib/libc/quad/qdivrem.c
index d89d02c2bcd9..67a0b510bb53 100644
--- a/lib/libc/quad/qdivrem.c
+++ b/lib/libc/quad/qdivrem.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)qdivrem.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed),
* section 4.3.1, pp. 257--259.
diff --git a/lib/libc/quad/quad.h b/lib/libc/quad/quad.h
index 0bda2b67398b..12c576d3432c 100644
--- a/lib/libc/quad/quad.h
+++ b/lib/libc/quad/quad.h
@@ -31,8 +31,6 @@
* 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.
- *
- * @(#)quad.h 8.1 (Berkeley) 6/4/93
*/
/*
diff --git a/lib/libc/quad/subdi3.c b/lib/libc/quad/subdi3.c
index 149c0d07259a..5953f5fb814a 100644
--- a/lib/libc/quad/subdi3.c
+++ b/lib/libc/quad/subdi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)subdi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/ucmpdi2.c b/lib/libc/quad/ucmpdi2.c
index 796ec7b089db..164005fb6616 100644
--- a/lib/libc/quad/ucmpdi2.c
+++ b/lib/libc/quad/ucmpdi2.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ucmpdi2.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/udivdi3.c b/lib/libc/quad/udivdi3.c
index b36e1ca6558f..456de8509560 100644
--- a/lib/libc/quad/udivdi3.c
+++ b/lib/libc/quad/udivdi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)udivdi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/umoddi3.c b/lib/libc/quad/umoddi3.c
index 719b6fa49243..3f36bd688040 100644
--- a/lib/libc/quad/umoddi3.c
+++ b/lib/libc/quad/umoddi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)umoddi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/quad/xordi3.c b/lib/libc/quad/xordi3.c
index ce958f799137..b765b223218f 100644
--- a/lib/libc/quad/xordi3.c
+++ b/lib/libc/quad/xordi3.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)xordi3.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "quad.h"
/*
diff --git a/lib/libc/regex/COPYRIGHT b/lib/libc/regex/COPYRIGHT
index 574f6bcec6c7..9f3893e48f98 100644
--- a/lib/libc/regex/COPYRIGHT
+++ b/lib/libc/regex/COPYRIGHT
@@ -51,6 +51,4 @@ to the following restrictions:
* 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.
- *
- * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94
*/
diff --git a/lib/libc/regex/Makefile.inc b/lib/libc/regex/Makefile.inc
index 6fcc9dee0370..89468f1317f6 100644
--- a/lib/libc/regex/Makefile.inc
+++ b/lib/libc/regex/Makefile.inc
@@ -1,5 +1,3 @@
-# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
# regex sources
.PATH: ${LIBC_SRCTOP}/regex
diff --git a/lib/libc/regex/Symbol.map b/lib/libc/regex/Symbol.map
index 3b9072571740..436398f639c7 100644
--- a/lib/libc/regex/Symbol.map
+++ b/lib/libc/regex/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
regerror;
regexec;
diff --git a/lib/libc/regex/WHATSNEW b/lib/libc/regex/WHATSNEW
index f4301d300dd3..0bd305c32cb9 100644
--- a/lib/libc/regex/WHATSNEW
+++ b/lib/libc/regex/WHATSNEW
@@ -1,4 +1,3 @@
-# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94
New in alpha3.4: The complex bug alluded to below has been fixed (in a
slightly kludgey temporary way that may hurt efficiency a bit; this is
diff --git a/lib/libc/regex/cname.h b/lib/libc/regex/cname.h
index a50ebbe54cb4..e1b76d36e589 100644
--- a/lib/libc/regex/cname.h
+++ b/lib/libc/regex/cname.h
@@ -31,8 +31,6 @@
* 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.
- *
- * @(#)cname.h 8.3 (Berkeley) 3/20/94
*/
/* character-name table */
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c
index 1efaf9a62f67..9e1935dc4d4a 100644
--- a/lib/libc/regex/engine.c
+++ b/lib/libc/regex/engine.c
@@ -31,11 +31,8 @@
* 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.
- *
- * @(#)engine.c 8.5 (Berkeley) 3/20/94
*/
-#include <sys/cdefs.h>
#include <stdbool.h>
/*
diff --git a/lib/libc/regex/grot/debug.c b/lib/libc/regex/grot/debug.c
index 24e34138007e..f5984366f3c6 100644
--- a/lib/libc/regex/grot/debug.c
+++ b/lib/libc/regex/grot/debug.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
diff --git a/lib/libc/regex/grot/main.c b/lib/libc/regex/grot/main.c
index 248fe0ca438a..e9d57c84e6f4 100644
--- a/lib/libc/regex/grot/main.c
+++ b/lib/libc/regex/grot/main.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <regex.h>
diff --git a/lib/libc/regex/grot/split.c b/lib/libc/regex/grot/split.c
index 89afef0f7cee..37d593e5eb4f 100644
--- a/lib/libc/regex/grot/split.c
+++ b/lib/libc/regex/grot/split.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#include <stdio.h>
#include <string.h>
diff --git a/lib/libc/regex/re_format.7 b/lib/libc/regex/re_format.7
index 23563758ddbd..ed8572b17e62 100644
--- a/lib/libc/regex/re_format.7
+++ b/lib/libc/regex/re_format.7
@@ -33,8 +33,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94
-.\"
.Dd June 30, 2014
.Dt RE_FORMAT 7
.Os
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index 791755ceb14d..f34dc322d0bb 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -36,14 +36,8 @@
* 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.
- *
- * @(#)regcomp.c 8.5 (Berkeley) 3/20/94
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
@@ -327,7 +321,7 @@ regcomp_internal(regex_t * __restrict preg,
computejumps(p, g);
computematchjumps(p, g);
if(g->matchjump == NULL && g->charjump != NULL) {
- free(g->charjump);
+ free(&g->charjump[CHAR_MIN]);
g->charjump = NULL;
}
}
@@ -459,7 +453,9 @@ p_ere_exp(struct parse *p, struct branchc *bc)
case '*':
case '+':
case '?':
+#ifndef NO_STRICT_REGEX
case '{':
+#endif
SETERROR(REG_BADRPT);
break;
case '.':
@@ -542,6 +538,11 @@ p_ere_exp(struct parse *p, struct branchc *bc)
break;
}
break;
+#ifdef NO_STRICT_REGEX
+ case '{': /* okay as ordinary except if digit follows */
+ (void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
+ /* FALLTHROUGH */
+#endif
default:
if (p->error != 0)
return (false);
@@ -555,11 +556,19 @@ p_ere_exp(struct parse *p, struct branchc *bc)
return (false);
c = PEEK();
/* we call { a repetition if followed by a digit */
- if (!( c == '*' || c == '+' || c == '?' || c == '{'))
+ if (!( c == '*' || c == '+' || c == '?' ||
+#ifdef NO_STRICT_REGEX
+ (c == '{' && MORE2() && isdigit((uch)PEEK2()))
+#else
+ c == '{'
+#endif
+ ))
return (false); /* no repetition, we're done */
+#ifndef NO_STRICT_REGEX
else if (c == '{')
(void)REQUIRE(MORE2() && \
(isdigit((uch)PEEK2()) || PEEK2() == ','), REG_BADRPT);
+#endif
NEXT();
(void)REQUIRE(!wascaret, REG_BADRPT);
@@ -828,10 +837,10 @@ p_simp_re(struct parse *p, struct branchc *bc)
handled = false;
assert(MORE()); /* caller should have ensured this */
- c = GETNEXT();
+ c = (uch)GETNEXT();
if (c == '\\') {
(void)REQUIRE(MORE(), REG_EESCAPE);
- cc = GETNEXT();
+ cc = (uch)GETNEXT();
c = BACKSL | cc;
#ifdef LIBREGEX
if (p->gnuext) {
@@ -898,6 +907,9 @@ p_simp_re(struct parse *p, struct branchc *bc)
(void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
break;
case BACKSL|')': /* should not get here -- must be user */
+#ifdef NO_STRICT_REGEX
+ case BACKSL|'}':
+#endif
SETERROR(REG_EPAREN);
break;
case BACKSL|'1':
@@ -992,7 +1004,7 @@ p_count(struct parse *p)
int ndigits = 0;
while (MORE() && isdigit((uch)PEEK()) && count <= DUPMAX) {
- count = count*10 + (GETNEXT() - '0');
+ count = count*10 + ((uch)GETNEXT() - '0');
ndigits++;
}
@@ -1302,7 +1314,7 @@ may_escape(struct parse *p, const wint_t ch)
if ((p->pflags & PFLAG_LEGACY_ESC) != 0)
return (true);
- if (isalpha(ch) || ch == '\'' || ch == '`')
+ if (iswalpha(ch) || ch == '\'' || ch == '`')
return (false);
return (true);
#ifdef NOTYET
@@ -1592,17 +1604,32 @@ singleton(cset *cs)
{
wint_t i, s, n;
+ /* Exclude the complicated cases we don't want to deal with */
+ if (cs->nranges != 0 || cs->ntypes != 0 || cs->icase != 0)
+ return (OUT);
+
+ if (cs->nwides > 1)
+ return (OUT);
+
+ /* Count the number of characters present in the bitmap */
for (i = n = 0; i < NC; i++)
if (CHIN(cs, i)) {
n++;
s = i;
}
- if (n == 1)
- return (s);
- if (cs->nwides == 1 && cs->nranges == 0 && cs->ntypes == 0 &&
- cs->icase == 0)
+
+ if (n > 1)
+ return (OUT);
+
+ if (n == 1) {
+ if (cs->nwides == 0)
+ return (s);
+ else
+ return (OUT);
+ }
+ if (cs->nwides == 1)
return (cs->wides[0]);
- /* Don't bother handling the other cases. */
+
return (OUT);
}
diff --git a/lib/libc/regex/regerror.c b/lib/libc/regex/regerror.c
index 7e9631796a9f..b21e7ac3517b 100644
--- a/lib/libc/regex/regerror.c
+++ b/lib/libc/regex/regerror.c
@@ -31,14 +31,8 @@
* 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.
- *
- * @(#)regerror.c 8.4 (Berkeley) 3/20/94
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
diff --git a/lib/libc/regex/regex.3 b/lib/libc/regex/regex.3
index e72927030c4a..3c9fb4da4185 100644
--- a/lib/libc/regex/regex.3
+++ b/lib/libc/regex/regex.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)regex.3 8.4 (Berkeley) 3/20/94
-.\"
.Dd April 15, 2017
.Dt REGEX 3
.Os
diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h
index 369c0231b677..f5854d916a2c 100644
--- a/lib/libc/regex/regex2.h
+++ b/lib/libc/regex/regex2.h
@@ -31,8 +31,6 @@
* 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.
- *
- * @(#)regex2.h 8.4 (Berkeley) 3/20/94
*/
/*
diff --git a/lib/libc/regex/regexec.c b/lib/libc/regex/regexec.c
index 7c50bcad444a..784e596d5f8a 100644
--- a/lib/libc/regex/regexec.c
+++ b/lib/libc/regex/regexec.c
@@ -31,14 +31,8 @@
* 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.
- *
- * @(#)regexec.c 8.3 (Berkeley) 3/20/94
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* the outer shell of regexec()
*
diff --git a/lib/libc/regex/regfree.c b/lib/libc/regex/regfree.c
index dc73c4b8ef21..e87314772a6c 100644
--- a/lib/libc/regex/regfree.c
+++ b/lib/libc/regex/regfree.c
@@ -31,14 +31,8 @@
* 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.
- *
- * @(#)regfree.c 8.3 (Berkeley) 3/20/94
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/regex/utils.h b/lib/libc/regex/utils.h
index 6a486a9a9b63..611decbb3b38 100644
--- a/lib/libc/regex/utils.h
+++ b/lib/libc/regex/utils.h
@@ -31,8 +31,6 @@
* 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.
- *
- * @(#)utils.h 8.3 (Berkeley) 3/20/94
*/
/* utility definitions */
diff --git a/lib/libc/resolv/Makefile.inc b/lib/libc/resolv/Makefile.inc
index ea5e1927a9c2..be900e942435 100644
--- a/lib/libc/resolv/Makefile.inc
+++ b/lib/libc/resolv/Makefile.inc
@@ -1,4 +1,3 @@
-
# resolv sources
.PATH: ${LIBC_SRCTOP}/resolv
diff --git a/lib/libc/resolv/Symbol.map b/lib/libc/resolv/Symbol.map
index c93d8bea6f15..6b9c43298fb5 100644
--- a/lib/libc/resolv/Symbol.map
+++ b/lib/libc/resolv/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
/* h_nerr; */ /* Why is this not staticized in net/herror.c? */
h_errlist;
diff --git a/lib/libc/resolv/herror.c b/lib/libc/resolv/herror.c
index f222497db0ee..def4057b3c18 100644
--- a/lib/libc/resolv/herror.c
+++ b/lib/libc/resolv/herror.c
@@ -46,11 +46,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: herror.c,v 1.4 2005/04/27 04:56:41 sra Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include "namespace.h"
diff --git a/lib/libc/resolv/mtctxres.c b/lib/libc/resolv/mtctxres.c
index e754ab0c5209..beb2b6b3f5dd 100644
--- a/lib/libc/resolv/mtctxres.c
+++ b/lib/libc/resolv/mtctxres.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#include <port_before.h>
#ifdef DO_PTHREADS
#include <pthread.h>
diff --git a/lib/libc/resolv/res_comp.c b/lib/libc/resolv/res_comp.c
index 0709b7f2eaab..55b71266b4ae 100644
--- a/lib/libc/resolv/res_comp.c
+++ b/lib/libc/resolv/res_comp.c
@@ -66,11 +66,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_comp.c,v 1.5 2005/07/28 06:51:50 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
#include <netinet/in.h>
diff --git a/lib/libc/resolv/res_data.c b/lib/libc/resolv/res_data.c
index 71b4b9279b4c..b6e3008c4e35 100644
--- a/lib/libc/resolv/res_data.c
+++ b/lib/libc/resolv/res_data.c
@@ -17,10 +17,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: res_data.c,v 1.7 2008/12/11 09:59:00 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/resolv/res_debug.c b/lib/libc/resolv/res_debug.c
index 7dd902af1b69..520fe4986c80 100644
--- a/lib/libc/resolv/res_debug.c
+++ b/lib/libc/resolv/res_debug.c
@@ -91,11 +91,6 @@
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_debug.c,v 1.19 2009/02/26 11:20:20 tbox Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/resolv/res_debug.h b/lib/libc/resolv/res_debug.h
index dd048116fb49..ccae03e625aa 100644
--- a/lib/libc/resolv/res_debug.h
+++ b/lib/libc/resolv/res_debug.h
@@ -23,7 +23,7 @@
#ifndef DEBUG
# define Dprint(cond, args) /*empty*/
# define DprintQ(cond, args, query, size) /*empty*/
-# define Aerror(statp, file, string, error, address) /*empty*/
+# define Aerror(statp, file, string, error, address, alen) /*empty*/
# define Perror(statp, file, string, error) /*empty*/
#else
# define Dprint(cond, args) if (cond) {fprintf args;} else {}
diff --git a/lib/libc/resolv/res_findzonecut.c b/lib/libc/resolv/res_findzonecut.c
index f1caaa76505f..a78b08302057 100644
--- a/lib/libc/resolv/res_findzonecut.c
+++ b/lib/libc/resolv/res_findzonecut.c
@@ -1,6 +1,3 @@
-#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_findzonecut.c,v 1.10 2005/10/11 00:10:16 marka Exp $";
-#endif /* not lint */
/*-
* SPDX-License-Identifier: ISC
@@ -21,7 +18,6 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 1.10 2005/10/11 00:10:16 m
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
/* Import. */
#include "port_before.h"
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index aede91e889c1..71ab2dcb7038 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -66,11 +66,6 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include "namespace.h"
@@ -113,12 +108,6 @@ static const char rcsid[] = "$Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Ex
#include "res_private.h"
-/*% Options. Should all be left alone. */
-#define RESOLVSORT
-#ifndef DEBUG
-#define DEBUG
-#endif
-
#ifdef SOLARIS2
#include <sys/systeminfo.h>
#endif
diff --git a/lib/libc/resolv/res_mkquery.c b/lib/libc/resolv/res_mkquery.c
index 40874e8d904b..f6767a92375c 100644
--- a/lib/libc/resolv/res_mkquery.c
+++ b/lib/libc/resolv/res_mkquery.c
@@ -66,11 +66,6 @@
* SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
#include <netinet/in.h>
@@ -81,11 +76,6 @@ static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka
#include <string.h>
#include "port_after.h"
-/* Options. Leave them on. */
-#ifndef DEBUG
-#define DEBUG
-#endif
-
extern const char *_res_opcodes[];
/*%
diff --git a/lib/libc/resolv/res_mkupdate.c b/lib/libc/resolv/res_mkupdate.c
index 41447f60def6..3f595dc4ec08 100644
--- a/lib/libc/resolv/res_mkupdate.c
+++ b/lib/libc/resolv/res_mkupdate.c
@@ -23,10 +23,6 @@
* &lt;viraj_bais@ccm.fm.intel.com>
*/
-#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_mkupdate.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
-#endif /* not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
@@ -52,10 +48,6 @@ static const char rcsid[] = "$Id: res_mkupdate.c,v 1.10 2008/12/11 09:59:00 mark
#include "port_after.h"
-/* Options. Leave them on. */
-#ifndef DEBUG
-#define DEBUG
-#endif
#define MAXPORT 1024
static int getnum_str(u_char **, u_char *);
diff --git a/lib/libc/resolv/res_query.c b/lib/libc/resolv/res_query.c
index 8a134dd86395..f26d59e522b4 100644
--- a/lib/libc/resolv/res_query.c
+++ b/lib/libc/resolv/res_query.c
@@ -66,11 +66,6 @@
* SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_query.c,v 1.11 2008/11/14 02:36:51 marka Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
#include <netinet/in.h>
@@ -86,11 +81,6 @@ static const char rcsid[] = "$Id: res_query.c,v 1.11 2008/11/14 02:36:51 marka E
#include <unistd.h>
#include "port_after.h"
-/* Options. Leave them on. */
-#ifndef DEBUG
-#define DEBUG
-#endif
-
#if PACKETSZ > 1024
#define MAXPACKET PACKETSZ
#else
diff --git a/lib/libc/resolv/res_send.c b/lib/libc/resolv/res_send.c
index 4c228a4dbd5e..08c3aed7f934 100644
--- a/lib/libc/resolv/res_send.c
+++ b/lib/libc/resolv/res_send.c
@@ -66,11 +66,6 @@
* SOFTWARE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.22 2009/01/22 23:49:23 tbox Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*! \file
* \brief
* Send query to name server and wait for reply.
@@ -117,10 +112,6 @@ static const char rcsid[] = "$Id: res_send.c,v 1.22 2009/01/22 23:49:23 tbox Exp
#include "un-namespace.h"
-/* Options. Leave them on. */
-#ifndef DEBUG
-#define DEBUG
-#endif
#include "res_debug.h"
#include "res_private.h"
@@ -143,15 +134,12 @@ static int send_dg(res_state,
const u_char *, int,
u_char *, int, int *, int, int,
int *, int *);
+#ifdef DEBUG
static void Aerror(const res_state, FILE *, const char *, int,
const struct sockaddr *, int);
static void Perror(const res_state, FILE *, const char *, int);
-static int sock_eq(struct sockaddr *, struct sockaddr *);
-#if defined(NEED_PSELECT) && !defined(USE_POLL) && !defined(USE_KQUEUE)
-static int pselect(int, void *, void *, void *,
- struct timespec *,
- const sigset_t *);
#endif
+static int sock_eq(struct sockaddr *, struct sockaddr *);
void res_pquery(const res_state, const u_char *, int, FILE *);
static const int niflags = NI_NUMERICHOST | NI_NUMERICSERV;
@@ -307,7 +295,9 @@ res_nsend(res_state statp,
#ifdef USE_KQUEUE
int kq;
#endif
+#ifdef DEBUG
char abuf[NI_MAXHOST];
+#endif
/* No name servers or res_init() failure */
if (statp->nscount == 0 || EXT(statp).ext == NULL) {
@@ -423,10 +413,10 @@ res_nsend(res_state statp,
*/
for (tries = 0; tries < statp->retry; tries++) {
for (ns = 0; ns < statp->nscount; ns++) {
- struct sockaddr *nsap;
- int nsaplen;
- nsap = get_nsaddr(statp, ns);
- nsaplen = get_salen(nsap);
+ struct sockaddr *nsap = get_nsaddr(statp, ns);
+#ifdef DEBUG
+ int nsaplen = get_salen(nsap);
+#endif
statp->_flags &= ~RES_F_LASTMASK;
statp->_flags |= (ns << RES_F_LASTSHIFT);
same_ns:
@@ -1093,6 +1083,7 @@ send_dg(res_state statp,
return (resplen);
}
+#ifdef DEBUG
static void
Aerror(const res_state statp, FILE *file, const char *string, int error,
const struct sockaddr *address, int alen)
@@ -1124,6 +1115,7 @@ Perror(const res_state statp, FILE *file, const char *string, int error) {
string, strerror(error));
errno = save;
}
+#endif
static int
sock_eq(struct sockaddr *a, struct sockaddr *b) {
@@ -1150,29 +1142,3 @@ sock_eq(struct sockaddr *a, struct sockaddr *b) {
return 0;
}
}
-
-#if defined(NEED_PSELECT) && !defined(USE_POLL) && !defined(USE_KQUEUE)
-/* XXX needs to move to the porting library. */
-static int
-pselect(int nfds, void *rfds, void *wfds, void *efds,
- struct timespec *tsp, const sigset_t *sigmask)
-{
- struct timeval tv, *tvp;
- sigset_t sigs;
- int n;
-
- if (tsp) {
- tvp = &tv;
- tv = evTimeVal(*tsp);
- } else
- tvp = NULL;
- if (sigmask)
- sigprocmask(SIG_SETMASK, sigmask, &sigs);
- n = select(nfds, rfds, wfds, efds, tvp);
- if (sigmask)
- sigprocmask(SIG_SETMASK, &sigs, NULL);
- if (tsp)
- *tsp = evTimeSpec(tv);
- return (n);
-}
-#endif
diff --git a/lib/libc/resolv/res_update.c b/lib/libc/resolv/res_update.c
index 05e9969008b0..f8f13bf495f9 100644
--- a/lib/libc/resolv/res_update.c
+++ b/lib/libc/resolv/res_update.c
@@ -1,6 +1,3 @@
-#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_update.c,v 1.13 2005/04/27 04:56:43 sra Exp $";
-#endif /* not lint */
/*-
* SPDX-License-Identifier: ISC
@@ -27,7 +24,6 @@ static const char rcsid[] = "$Id: res_update.c,v 1.13 2005/04/27 04:56:43 sra Ex
* &lt;viraj_bais@ccm.fm.intel.com>
*/
-#include <sys/cdefs.h>
#include "port_before.h"
#include <sys/param.h>
diff --git a/lib/libc/riscv/SYS.h b/lib/libc/riscv/SYS.h
deleted file mode 100644
index 47f92467c843..000000000000
--- a/lib/libc/riscv/SYS.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Copyright (c) 2014 Andrew Turner
- * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
- * All rights reserved.
- *
- * Portions of this software were developed by SRI International and the
- * University of Cambridge Computer Laboratory under DARPA/AFRL contract
- * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * Portions of this software were developed by the University of Cambridge
- * Computer Laboratory as part of the CTSRD Project, with support from the
- * UK Higher Education Innovation Fund (HEIF).
- *
- * 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.
- */
-
-#include <sys/syscall.h>
-#include <machine/asm.h>
-
-#define _SYSCALL(name) \
- li t0, SYS_ ## name; \
- ecall
-
-#define SYSCALL(name) \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- ret; \
-END(__sys_##name)
-
-#define PSEUDO(name) \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bnez t0, 1f; \
- ret; \
-1: la t1, cerror; \
- jr t1; \
-END(__sys_##name)
-
-#define RSYSCALL(name) \
-ENTRY(__sys_##name); \
- WEAK_REFERENCE(__sys_##name, name); \
- WEAK_REFERENCE(__sys_##name, _##name); \
- _SYSCALL(name); \
- bnez t0, 1f; \
- ret; \
-1: la t1, cerror; \
- jr t1; \
-END(__sys_##name)
diff --git a/lib/libc/riscv/Symbol.map b/lib/libc/riscv/Symbol.map
index c19f7ddf631e..bebcecb879f4 100644
--- a/lib/libc/riscv/Symbol.map
+++ b/lib/libc/riscv/Symbol.map
@@ -1,35 +1,10 @@
/*
- */
-
-/*
* This only needs to contain symbols that are not listed in
* symbol maps from other parts of libc (i.e., not found in
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
*/
FBSD_1.0 {
- /* PSEUDO syscalls */
- _exit;
-
- _setjmp;
- _longjmp;
- fabs;
__flt_rounds;
fpgetmask;
fpsetmask;
- __infinity;
- __nan;
- setjmp;
- longjmp;
- sigsetjmp;
- siglongjmp;
- htonl;
- htons;
- ntohl;
- ntohs;
- vfork;
- makecontext;
-};
-
-FBSDprivate_1.0 {
- __makecontext;
};
diff --git a/lib/libc/riscv/gen/Makefile.inc b/lib/libc/riscv/gen/Makefile.inc
index 71bb6a42bbd1..443e029946bf 100644
--- a/lib/libc/riscv/gen/Makefile.inc
+++ b/lib/libc/riscv/gen/Makefile.inc
@@ -1,4 +1,3 @@
-
SRCS+= _ctx_start.S \
fabs.S \
flt_rounds.c \
diff --git a/lib/libc/riscv/gen/flt_rounds.c b/lib/libc/riscv/gen/flt_rounds.c
index 46e2ab9ca63c..bccd7d8baa44 100644
--- a/lib/libc/riscv/gen/flt_rounds.c
+++ b/lib/libc/riscv/gen/flt_rounds.c
@@ -32,28 +32,17 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <fenv.h>
#include <float.h>
-#ifdef __riscv_float_abi_soft
-#include "softfloat-for-gcc.h"
-#include "milieu.h"
-#include "softfloat.h"
-#endif
-
int
__flt_rounds(void)
{
uint64_t mode;
-#ifdef __riscv_float_abi_soft
- mode = __softfloat_float_rounding_mode;
-#else
__asm __volatile("csrr %0, fcsr" : "=r" (mode));
-#endif
switch (mode & _ROUND_MASK) {
case FE_TOWARDZERO:
diff --git a/lib/libc/riscv/gen/fpgetmask.c b/lib/libc/riscv/gen/fpgetmask.c
index 781709b8bf22..7835a17cff60 100644
--- a/lib/libc/riscv/gen/fpgetmask.c
+++ b/lib/libc/riscv/gen/fpgetmask.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/riscv/gen/fpsetmask.c b/lib/libc/riscv/gen/fpsetmask.c
index bcb42845065c..024f1fd8d8bc 100644
--- a/lib/libc/riscv/gen/fpsetmask.c
+++ b/lib/libc/riscv/gen/fpsetmask.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ieeefp.h>
diff --git a/lib/libc/riscv/gen/infinity.c b/lib/libc/riscv/gen/infinity.c
index 1639ac09d410..ae44d5195a3b 100644
--- a/lib/libc/riscv/gen/infinity.c
+++ b/lib/libc/riscv/gen/infinity.c
@@ -2,7 +2,6 @@
* infinity.c
*/
-#include <sys/cdefs.h>
#include <math.h>
/* bytes for +Infinity on riscv */
diff --git a/lib/libc/riscv/gen/makecontext.c b/lib/libc/riscv/gen/makecontext.c
index aea855544f4d..e5371d082b2c 100644
--- a/lib/libc/riscv/gen/makecontext.c
+++ b/lib/libc/riscv/gen/makecontext.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <machine/riscvreg.h>
diff --git a/lib/libc/riscv/static_tls.h b/lib/libc/riscv/static_tls.h
deleted file mode 100644
index ce9fa23338a6..000000000000
--- a/lib/libc/riscv/static_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _LIBC_RISCV_STATIC_TLS_H
-#define _LIBC_RISCV_STATIC_TLS_H
-
-static __inline uintptr_t
-_libc_get_static_tls_base(size_t offset)
-{
- uintptr_t tlsbase;
-
- __asm __volatile("mv %0, tp" : "=r"(tlsbase));
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libc/riscv/sys/Makefile.inc b/lib/libc/riscv/sys/Makefile.inc
deleted file mode 100644
index e98d2ceeccad..000000000000
--- a/lib/libc/riscv/sys/Makefile.inc
+++ /dev/null
@@ -1,10 +0,0 @@
-
-SRCS+= __vdso_gettc.c \
- sched_getcpu_gen.c
-
-MDASM= cerror.S \
- syscall.S \
- vfork.S
-
-# Don't generate default code for these syscalls:
-NOASM+= sbrk.o vfork.o
diff --git a/lib/libc/riscv/sys/__vdso_gettc.c b/lib/libc/riscv/sys/__vdso_gettc.c
deleted file mode 100644
index 919351511983..000000000000
--- a/lib/libc/riscv/sys/__vdso_gettc.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * Copyright (c) 2021 Jessica Clarke
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/elf.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-
-#include <machine/riscvreg.h>
-
-#include <errno.h>
-
-#include "libc_private.h"
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
- if (th->th_algo != VDSO_TH_ALGO_RISCV_RDTIME)
- return (ENOSYS);
-
- *tc = csr_read(time);
- return (0);
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
- return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
-}
diff --git a/lib/libc/riscv/sys/syscall.S b/lib/libc/riscv/sys/syscall.S
deleted file mode 100644
index 54dbff768f93..000000000000
--- a/lib/libc/riscv/sys/syscall.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
- * All rights reserved.
- *
- * Portions of this software were developed by SRI International and the
- * University of Cambridge Computer Laboratory under DARPA/AFRL contract
- * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * Portions of this software were developed by the University of Cambridge
- * Computer Laboratory as part of the CTSRD Project, with support from the
- * UK Higher Education Innovation Fund (HEIF).
- *
- * 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.
- */
-
-#include <machine/asm.h>
-#include "SYS.h"
-
-RSYSCALL(syscall)
diff --git a/lib/libc/rpc/Makefile.inc b/lib/libc/rpc/Makefile.inc
index 969c775d156a..87963d10eec1 100644
--- a/lib/libc/rpc/Makefile.inc
+++ b/lib/libc/rpc/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile 5.11 (Berkeley) 9/6/90
-
.PATH: ${LIBC_SRCTOP}/rpc ${LIBC_SRCTOP}/.
CONFS+= rpc/netconfig rpc/rpc
SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c clnt_bcast.c \
@@ -10,7 +8,7 @@ SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c clnt_bcast.c \
rpc_callmsg.c rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c \
rpcb_st_xdr.c rpcsec_gss_stub.c svc.c svc_auth.c svc_dg.c \
svc_auth_unix.c svc_generic.c svc_raw.c svc_run.c svc_simple.c \
- svc_vc.c
+ svc_vc.c svc_nl.c
# Secure-RPC
SRCS+= auth_time.c auth_des.c authdes_prot.c des_crypt.c des_soft.c \
@@ -49,7 +47,7 @@ MAN+= bindresvport.3 des_crypt.3 getnetconfig.3 getnetpath.3 getrpcent.3 \
rpc_clnt_create.3 rpc_svc_calls.3 rpc_svc_create.3 rpc_svc_err.3 \
rpc_svc_reg.3 rpc_xdr.3 rpcbind.3 publickey.3 rpc_secure.3 \
rtime.3
-MAN+= publickey.5 rpc.5 netconfig.5
+MAN+= rpc.5 netconfig.5
MLINKS+= bindresvport.3 bindresvport_sa.3 \
des_crypt.3 ecb_crypt.3 \
des_crypt.3 cbc_crypt.3 \
@@ -167,6 +165,7 @@ MLINKS+= bindresvport.3 bindresvport_sa.3 \
rpc_soc.3 svc_fds.3 \
rpc_soc.3 svc_fdset.3 \
rpc_soc.3 svc_getcaller.3 \
+ rpc_soc.3 svc_getreq.3 \
rpc_soc.3 svc_register.3 \
rpc_soc.3 svc_unregister.3 \
rpc_soc.3 svcfd_create.3 \
@@ -175,5 +174,6 @@ MLINKS+= bindresvport.3 bindresvport_sa.3 \
rpc_soc.3 svctcp_create.3 \
rpc_soc.3 svcudp_bufcreate.3 \
rpc_soc.3 svcunix_create.3 \
+ rpc_soc.3 xdr_authunix_parms.3 \
rpc_soc.3 xdr_pmap.3 \
rpc_soc.3 xdr_pmaplist.3
diff --git a/lib/libc/rpc/Symbol.map b/lib/libc/rpc/Symbol.map
index 89b434ce67db..105d6fb6b54e 100644
--- a/lib/libc/rpc/Symbol.map
+++ b/lib/libc/rpc/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
/* From crypt_clnt.c (generated by rpcgen - include/rpcsvc/crypt.x) */
des_crypt_1;
@@ -11,37 +8,6 @@ FBSD_1.0 {
xdr_desargs;
xdr_desresp;
- /* From yp_xdr.c (generated by rpcgen - include/rpcsvc/yp.x) */
- xdr_domainname;
- xdr_keydat;
- xdr_mapname;
- xdr_peername;
- xdr_valdat;
- xdr_ypbind_binding;
- xdr_ypbind_resp;
- xdr_ypbind_resptype;
- xdr_ypbind_setdom;
- xdr_ypmap_parms;
- xdr_ypmaplist;
- xdr_yppush_status;
- xdr_yppushresp_xfr;
- xdr_ypreq_key;
- xdr_ypreq_nokey;
- xdr_ypreq_xfr;
- xdr_ypreqtype;
- xdr_yprequest;
- xdr_ypresp_all;
- xdr_ypresp_key_val;
- xdr_ypresp_maplist;
- xdr_ypresp_master;
- xdr_ypresp_order;
- xdr_ypresp_val;
- xdr_ypresp_xfr;
- xdr_ypresponse;
- xdr_ypresptype;
- xdr_ypstat;
- xdr_ypxfrstat;
-
authdes_seccreate;
authdes_pk_seccreate;
authnone_create;
@@ -233,6 +199,10 @@ FBSD_1.0 {
__rpc_get_local_uid;
};
+FBSD_1.8 {
+ svc_nl_create;
+};
+
FBSDprivate_1.0 {
__des_crypt_LOCAL;
__key_encryptsession_pk_LOCAL;
diff --git a/lib/libc/rpc/auth_des.c b/lib/libc/rpc/auth_des.c
index 1ceabaf8d672..c9b20de25cda 100644
--- a/lib/libc/rpc/auth_des.c
+++ b/lib/libc/rpc/auth_des.c
@@ -41,7 +41,6 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include <sys/cdefs.h>
#include <rpc/des_crypt.h>
#include <syslog.h>
#include <rpc/types.h>
@@ -55,10 +54,6 @@
#include "un-namespace.h"
#include "mt_misc.h"
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)auth_des.c 2.2 88/07/29 4.0 RPCSRC; from 1.9 88/02/08 SMI";
-#endif
-#include <sys/cdefs.h>
#define USEC_PER_SEC 1000000
#define RTIME_TIMEOUT 5 /* seconds to wait for sync */
diff --git a/lib/libc/rpc/auth_none.c b/lib/libc/rpc/auth_none.c
index 5a702976cf14..c116ce242707 100644
--- a/lib/libc/rpc/auth_none.c
+++ b/lib/libc/rpc/auth_none.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* auth_none.c
* Creates a client authentication handle for passing "null"
diff --git a/lib/libc/rpc/auth_time.c b/lib/libc/rpc/auth_time.c
index 8709dea3cfe6..d8ea585c8ee7 100644
--- a/lib/libc/rpc/auth_time.c
+++ b/lib/libc/rpc/auth_time.c
@@ -1,5 +1,3 @@
-/* #pragma ident "@(#)auth_time.c 1.4 92/11/10 SMI" */
-
/*
* auth_time.c
*
@@ -27,7 +25,6 @@
* needed to deal with TCP connections.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <syslog.h>
diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c
index 36b6a5b49e3b..22c65ddfb8f0 100644
--- a/lib/libc/rpc/auth_unix.c
+++ b/lib/libc/rpc/auth_unix.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* auth_unix.c, Implements UNIX style authentication parameters.
*
diff --git a/lib/libc/rpc/authdes_prot.c b/lib/libc/rpc/authdes_prot.c
index 94168a0dbcd0..79a0e5baa084 100644
--- a/lib/libc/rpc/authdes_prot.c
+++ b/lib/libc/rpc/authdes_prot.c
@@ -1,7 +1,3 @@
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)authdes_prot.c 2.1 88/07/29 4.0 RPCSRC; from 1.6 88/02/08 SMI";
-#endif
-#include <sys/cdefs.h>
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c
index 0f2fc8a22f45..777f262f5c33 100644
--- a/lib/libc/rpc/authunix_prot.c
+++ b/lib/libc/rpc/authunix_prot.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* authunix_prot.c
* XDR for UNIX style authentication parameters for RPC
diff --git a/lib/libc/rpc/bindresvport.3 b/lib/libc/rpc/bindresvport.3
index 81e9f6268c80..25483a623e56 100644
--- a/lib/libc/rpc/bindresvport.3
+++ b/lib/libc/rpc/bindresvport.3
@@ -1,4 +1,3 @@
-.\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
.\" $NetBSD: bindresvport.3,v 1.8 2000/07/05 15:45:33 msaitoh Exp $
.\"
.Dd November 22, 1987
diff --git a/lib/libc/rpc/bindresvport.c b/lib/libc/rpc/bindresvport.c
index 53abc2b2b64c..4cdd037afd1a 100644
--- a/lib/libc/rpc/bindresvport.c
+++ b/lib/libc/rpc/bindresvport.c
@@ -30,12 +30,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";
-static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";
-#endif
/* from: $OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp $ */
-#include <sys/cdefs.h>
/*
* Copyright (c) 1987 by Sun Microsystems, Inc.
*
diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c
index 6d39bca2f83f..07e6d0a0fa20 100644
--- a/lib/libc/rpc/clnt_bcast.c
+++ b/lib/libc/rpc/clnt_bcast.c
@@ -33,11 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-#ident "@(#)clnt_bcast.c 1.18 94/05/03 SMI"
-static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* clnt_bcast.c
* Client interface to broadcast service.
diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c
index d6b9698bf4db..78fc5e47d444 100644
--- a/lib/libc/rpc/clnt_dg.c
+++ b/lib/libc/rpc/clnt_dg.c
@@ -33,11 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-#ident "@(#)clnt_dg.c 1.23 94/04/22 SMI"
-static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* Implements a connectionless client side RPC.
*/
@@ -49,13 +44,17 @@ static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
+#include <sys/tree.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <rpc/rpcsec_gss.h>
+#include <assert.h>
#include <errno.h>
+#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <stdbool.h>
#include <unistd.h>
#include <err.h>
#include "un-namespace.h"
@@ -90,28 +89,65 @@ static void clnt_dg_destroy(CLIENT *);
* This machinery implements per-fd locks for MT-safety. It is not
* sufficient to do per-CLIENT handle locks for MT-safety because a
* user may create more than one CLIENT handle with the same fd behind
- * it. Therefore, we allocate an array of flags (dg_fd_locks), protected
- * by the clnt_fd_lock mutex, and an array (dg_cv) of condition variables
- * similarly protected. Dg_fd_lock[fd] == 1 => a call is active on some
- * CLIENT handle created for that fd.
- * The current implementation holds locks across the entire RPC and reply,
- * including retransmissions. Yes, this is silly, and as soon as this
- * code is proven to work, this should be the first thing fixed. One step
- * at a time.
+ * it. Therefore, we allocate an associative array of flags and condition
+ * variables (dg_fd). The flags and the array are protected by the
+ * clnt_fd_lock mutex. dg_fd[fd].lock == 1 => a call is active on some
+ * CLIENT handle created for that fd. The current implementation holds
+ * locks across the entire RPC and reply, including retransmissions. Yes,
+ * this is silly, and as soon as this code is proven to work, this should
+ * be the first thing fixed. One step at a time.
+ */
+struct dg_fd {
+ RB_ENTRY(dg_fd) dg_link;
+ int fd;
+ mutex_t mtx;
+};
+static inline int
+cmp_dg_fd(struct dg_fd *a, struct dg_fd *b)
+{
+ if (a->fd > b->fd) {
+ return (1);
+ } else if (a->fd < b->fd) {
+ return (-1);
+ } else {
+ return (0);
+ }
+}
+RB_HEAD(dg_fd_list, dg_fd);
+RB_PROTOTYPE(dg_fd_list, dg_fd, dg_link, cmp_dg_fd);
+RB_GENERATE(dg_fd_list, dg_fd, dg_link, cmp_dg_fd);
+struct dg_fd_list dg_fd_head = RB_INITIALIZER(&dg_fd_head);
+
+/*
+ * Find the lock structure for the given file descriptor, or initialize it if
+ * it does not already exist. The clnt_fd_lock mutex must be held.
*/
-static int *dg_fd_locks;
-static cond_t *dg_cv;
-#define release_fd_lock(fd, mask) { \
- mutex_lock(&clnt_fd_lock); \
- dg_fd_locks[fd] = 0; \
- mutex_unlock(&clnt_fd_lock); \
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL); \
- cond_signal(&dg_cv[fd]); \
+static struct dg_fd *
+dg_fd_find(int fd)
+{
+ struct dg_fd key, *elem;
+
+ key.fd = fd;
+ elem = RB_FIND(dg_fd_list, &dg_fd_head, &key);
+ if (elem == NULL) {
+ elem = calloc(1, sizeof(*elem));
+ elem->fd = fd;
+ mutex_init(&elem->mtx, NULL);
+ RB_INSERT(dg_fd_list, &dg_fd_head, elem);
+ }
+ return (elem);
+}
+
+static void
+release_fd_lock(struct dg_fd *elem, sigset_t mask)
+{
+ mutex_unlock(&elem->mtx);
+ thr_sigsetmask(SIG_SETMASK, &mask, NULL);
}
static const char mem_err_clnt_dg[] = "clnt_dg_create: out of memory";
-/* VARIABLES PROTECTED BY clnt_fd_lock: dg_fd_locks, dg_cv */
+/* VARIABLES PROTECTED BY clnt_fd_lock: dg_fd */
#define MCALL_MSG_SIZE 24
@@ -169,47 +205,9 @@ clnt_dg_create(int fd, const struct netbuf *svcaddr, rpcprog_t program,
struct cu_data *cu = NULL; /* private data */
struct timeval now;
struct rpc_msg call_msg;
- sigset_t mask;
- sigset_t newmask;
struct __rpc_sockinfo si;
int one = 1;
- sigfillset(&newmask);
- thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
- mutex_lock(&clnt_fd_lock);
- if (dg_fd_locks == (int *) NULL) {
- int cv_allocsz;
- size_t fd_allocsz;
- int dtbsize = __rpc_dtbsize();
-
- fd_allocsz = dtbsize * sizeof (int);
- dg_fd_locks = (int *) mem_alloc(fd_allocsz);
- if (dg_fd_locks == (int *) NULL) {
- mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- goto err1;
- } else
- memset(dg_fd_locks, '\0', fd_allocsz);
-
- cv_allocsz = dtbsize * sizeof (cond_t);
- dg_cv = (cond_t *) mem_alloc(cv_allocsz);
- if (dg_cv == (cond_t *) NULL) {
- mem_free(dg_fd_locks, fd_allocsz);
- dg_fd_locks = (int *) NULL;
- mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- goto err1;
- } else {
- int i;
-
- for (i = 0; i < dtbsize; i++)
- cond_init(&dg_cv[i], 0, (void *) 0);
- }
- }
-
- mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
-
if (svcaddr == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNADDR;
return (NULL);
@@ -330,25 +328,21 @@ clnt_dg_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xargs, void *argsp,
struct timespec ts;
struct kevent kv;
struct sockaddr *sa;
+ struct dg_fd *elem;
sigset_t mask;
sigset_t newmask;
socklen_t salen;
ssize_t recvlen = 0;
- int kin_len, n, rpc_lock_value;
+ int kin_len, n;
u_int32_t xid;
outlen = 0;
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (dg_fd_locks[cu->cu_fd])
- cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock);
- if (__isthreaded)
- rpc_lock_value = 1;
- else
- rpc_lock_value = 0;
- dg_fd_locks[cu->cu_fd] = rpc_lock_value;
+ elem = dg_fd_find(cu->cu_fd);
mutex_unlock(&clnt_fd_lock);
+ mutex_lock(&elem->mtx);
if (cu->cu_total.tv_usec == -1) {
timeout = utimeout; /* use supplied timeout */
} else {
@@ -602,7 +596,7 @@ out:
if (cu->cu_kq >= 0)
_close(cu->cu_kq);
cu->cu_kq = -1;
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (cu->cu_error.re_status);
}
@@ -618,6 +612,7 @@ static bool_t
clnt_dg_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr)
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ struct dg_fd *elem;
XDR *xdrs = &(cu->cu_outxdrs);
bool_t dummy;
sigset_t mask;
@@ -626,13 +621,12 @@ clnt_dg_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr)
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (dg_fd_locks[cu->cu_fd])
- cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock);
+ elem = dg_fd_find(cu->cu_fd);
+ mutex_lock(&elem->mtx);
xdrs->x_op = XDR_FREE;
dummy = (*xdr_res)(xdrs, res_ptr);
mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &mask, NULL);
- cond_signal(&dg_cv[cu->cu_fd]);
+ release_fd_lock(elem, mask);
return (dummy);
}
@@ -647,41 +641,36 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info)
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
struct netbuf *addr;
+ struct dg_fd *elem;
sigset_t mask;
sigset_t newmask;
- int rpc_lock_value;
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (dg_fd_locks[cu->cu_fd])
- cond_wait(&dg_cv[cu->cu_fd], &clnt_fd_lock);
- if (__isthreaded)
- rpc_lock_value = 1;
- else
- rpc_lock_value = 0;
- dg_fd_locks[cu->cu_fd] = rpc_lock_value;
+ elem = dg_fd_find(cu->cu_fd);
mutex_unlock(&clnt_fd_lock);
+ mutex_lock(&elem->mtx);
switch (request) {
case CLSET_FD_CLOSE:
cu->cu_closeit = TRUE;
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (TRUE);
case CLSET_FD_NCLOSE:
cu->cu_closeit = FALSE;
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (TRUE);
}
/* for other requests which use info */
if (info == NULL) {
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
switch (request) {
case CLSET_TIMEOUT:
if (time_not_ok((struct timeval *)info)) {
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
cu->cu_total = *(struct timeval *)info;
@@ -695,7 +684,7 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info)
break;
case CLSET_RETRY_TIMEOUT:
if (time_not_ok((struct timeval *)info)) {
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
cu->cu_wait = *(struct timeval *)info;
@@ -715,7 +704,7 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info)
case CLSET_SVC_ADDR: /* set to new address */
addr = (struct netbuf *)info;
if (addr->len < sizeof cu->cu_raddr) {
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
(void) memcpy(&cu->cu_raddr, addr->buf, addr->len);
@@ -778,10 +767,10 @@ clnt_dg_control(CLIENT *cl, u_int request, void *info)
cu->cu_connect = *(int *)info;
break;
default:
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
- release_fd_lock(cu->cu_fd, mask);
+ release_fd_lock(elem, mask);
return (TRUE);
}
@@ -789,6 +778,7 @@ static void
clnt_dg_destroy(CLIENT *cl)
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
+ struct dg_fd *elem;
int cu_fd = cu->cu_fd;
sigset_t mask;
sigset_t newmask;
@@ -796,8 +786,8 @@ clnt_dg_destroy(CLIENT *cl)
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (dg_fd_locks[cu_fd])
- cond_wait(&dg_cv[cu_fd], &clnt_fd_lock);
+ elem = dg_fd_find(cu_fd);
+ mutex_lock(&elem->mtx);
if (cu->cu_closeit)
(void)_close(cu_fd);
if (cu->cu_kq >= 0)
@@ -810,8 +800,7 @@ clnt_dg_destroy(CLIENT *cl)
mem_free(cl->cl_tp, strlen(cl->cl_tp) +1);
mem_free(cl, sizeof (CLIENT));
mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &mask, NULL);
- cond_signal(&dg_cv[cu_fd]);
+ release_fd_lock(elem, mask);
}
static struct clnt_ops *
diff --git a/lib/libc/rpc/clnt_generic.c b/lib/libc/rpc/clnt_generic.c
index 0233de9a4b59..f55fb9d44c9f 100644
--- a/lib/libc/rpc/clnt_generic.c
+++ b/lib/libc/rpc/clnt_generic.c
@@ -30,13 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/* #ident "@(#)clnt_generic.c 1.40 99/04/21 SMI" */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
-static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* Copyright (c) 1986-1996,1998 by Sun Microsystems, Inc.
* All rights reserved.
diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c
index 878439a11109..83ed2f600452 100644
--- a/lib/libc/rpc/clnt_perror.c
+++ b/lib/libc/rpc/clnt_perror.c
@@ -31,11 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* clnt_perror.c
*
diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c
index d09494c9206f..b355f827140b 100644
--- a/lib/libc/rpc/clnt_raw.c
+++ b/lib/libc/rpc/clnt_raw.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* clnt_raw.c
*
diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c
index 657d0ac399d5..0df3fd8dee09 100644
--- a/lib/libc/rpc/clnt_simple.c
+++ b/lib/libc/rpc/clnt_simple.c
@@ -33,11 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "from: @(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "from: @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* clnt_simple.c
* Simplified front end to client rpc.
diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c
index d3c96945d25a..60e381168ed3 100644
--- a/lib/libc/rpc/clnt_vc.c
+++ b/lib/libc/rpc/clnt_vc.c
@@ -30,12 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
-static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* clnt_tcp.c, Implements a TCP/IP based, client side RPC.
*
@@ -61,6 +55,7 @@ static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#include <sys/poll.h>
#include <sys/syslog.h>
#include <sys/socket.h>
+#include <sys/tree.h>
#include <sys/un.h>
#include <sys/uio.h>
@@ -69,7 +64,9 @@ static char sccsid3[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#include <err.h>
#include <errno.h>
#include <netdb.h>
+#include <pthread.h>
#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -121,22 +118,60 @@ struct ct_data {
* This machinery implements per-fd locks for MT-safety. It is not
* sufficient to do per-CLIENT handle locks for MT-safety because a
* user may create more than one CLIENT handle with the same fd behind
- * it. Therefore, we allocate an array of flags (vc_fd_locks), protected
- * by the clnt_fd_lock mutex, and an array (vc_cv) of condition variables
- * similarly protected. Vc_fd_lock[fd] == 1 => a call is active on some
- * CLIENT handle created for that fd.
- * The current implementation holds locks across the entire RPC and reply.
- * Yes, this is silly, and as soon as this code is proven to work, this
- * should be the first thing fixed. One step at a time.
+ * it. Therefore, we allocate an associative array of flags and condition
+ * variables (vc_fd). The flags and the array are protected by the
+ * clnt_fd_lock mutex. vc_fd_lock[fd] == 1 => a call is active on some
+ * CLIENT handle created for that fd. The current implementation holds
+ * locks across the entire RPC and reply. Yes, this is silly, and as soon
+ * as this code is proven to work, this should be the first thing fixed.
+ * One step at a time.
*/
-static int *vc_fd_locks;
-static cond_t *vc_cv;
-#define release_fd_lock(fd, mask) { \
- mutex_lock(&clnt_fd_lock); \
- vc_fd_locks[fd] = 0; \
- mutex_unlock(&clnt_fd_lock); \
- thr_sigsetmask(SIG_SETMASK, &(mask), (sigset_t *) NULL); \
- cond_signal(&vc_cv[fd]); \
+struct vc_fd {
+ RB_ENTRY(vc_fd) vc_link;
+ int fd;
+ mutex_t mtx;
+};
+static inline int
+cmp_vc_fd(struct vc_fd *a, struct vc_fd *b)
+{
+ if (a->fd > b->fd) {
+ return (1);
+ } else if (a->fd < b->fd) {
+ return (-1);
+ } else {
+ return (0);
+ }
+}
+RB_HEAD(vc_fd_list, vc_fd);
+RB_PROTOTYPE(vc_fd_list, vc_fd, vc_link, cmp_vc_fd);
+RB_GENERATE(vc_fd_list, vc_fd, vc_link, cmp_vc_fd);
+struct vc_fd_list vc_fd_head = RB_INITIALIZER(&vc_fd_head);
+
+/*
+ * Find the lock structure for the given file descriptor, or initialize it if
+ * it does not already exist. The clnt_fd_lock mutex must be held.
+ */
+static struct vc_fd *
+vc_fd_find(int fd)
+{
+ struct vc_fd key, *elem;
+
+ key.fd = fd;
+ elem = RB_FIND(vc_fd_list, &vc_fd_head, &key);
+ if (elem == NULL) {
+ elem = calloc(1, sizeof(*elem));
+ elem->fd = fd;
+ mutex_init(&elem->mtx, NULL);
+ RB_INSERT(vc_fd_list, &vc_fd_head, elem);
+ }
+ return (elem);
+}
+
+static void
+release_fd_lock(struct vc_fd *elem, sigset_t mask)
+{
+ mutex_unlock(&elem->mtx);
+ thr_sigsetmask(SIG_SETMASK, &mask, NULL);
}
static const char clnt_vc_errstr[] = "%s : %s";
@@ -170,8 +205,6 @@ clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog,
struct timeval now;
struct rpc_msg call_msg;
static u_int32_t disrupt;
- sigset_t mask;
- sigset_t newmask;
struct sockaddr_storage ss;
socklen_t slen;
struct __rpc_sockinfo si;
@@ -189,39 +222,6 @@ clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog,
goto err;
}
ct->ct_addr.buf = NULL;
- sigfillset(&newmask);
- thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
- mutex_lock(&clnt_fd_lock);
- if (vc_fd_locks == (int *) NULL) {
- int cv_allocsz, fd_allocsz;
- int dtbsize = __rpc_dtbsize();
-
- fd_allocsz = dtbsize * sizeof (int);
- vc_fd_locks = (int *) mem_alloc(fd_allocsz);
- if (vc_fd_locks == (int *) NULL) {
- mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- goto err;
- } else
- memset(vc_fd_locks, '\0', fd_allocsz);
-
- assert(vc_cv == (cond_t *) NULL);
- cv_allocsz = dtbsize * sizeof (cond_t);
- vc_cv = (cond_t *) mem_alloc(cv_allocsz);
- if (vc_cv == (cond_t *) NULL) {
- mem_free(vc_fd_locks, fd_allocsz);
- vc_fd_locks = (int *) NULL;
- mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- goto err;
- } else {
- int i;
-
- for (i = 0; i < dtbsize; i++)
- cond_init(&vc_cv[i], 0, (void *) 0);
- }
- } else
- assert(vc_cv != (cond_t *) NULL);
/*
* XXX - fvdl connecting while holding a mutex?
@@ -232,19 +232,16 @@ clnt_vc_create(int fd, const struct netbuf *raddr, const rpcprog_t prog,
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
goto err;
}
if (_connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){
rpc_createerr.cf_stat = RPC_SYSTEMERROR;
rpc_createerr.cf_error.re_errno = errno;
mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
goto err;
}
}
mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
if (!__rpc_fd2sockinfo(fd, &si))
goto err;
@@ -319,12 +316,12 @@ clnt_vc_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xdr_args, void *args_ptr,
struct ct_data *ct = (struct ct_data *) cl->cl_private;
XDR *xdrs = &(ct->ct_xdrs);
struct rpc_msg reply_msg;
+ struct vc_fd *elem;
u_int32_t x_id;
u_int32_t *msg_x_id = &ct->ct_u.ct_mcalli; /* yuk */
bool_t shipnow;
int refreshes = 2;
sigset_t mask, newmask;
- int rpc_lock_value;
bool_t reply_stat;
assert(cl != NULL);
@@ -332,14 +329,9 @@ clnt_vc_call(CLIENT *cl, rpcproc_t proc, xdrproc_t xdr_args, void *args_ptr,
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (vc_fd_locks[ct->ct_fd])
- cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
- if (__isthreaded)
- rpc_lock_value = 1;
- else
- rpc_lock_value = 0;
- vc_fd_locks[ct->ct_fd] = rpc_lock_value;
+ elem = vc_fd_find(ct->ct_fd);
mutex_unlock(&clnt_fd_lock);
+ mutex_lock(&elem->mtx);
if (!ct->ct_waitset) {
/* If time is not within limits, we ignore it. */
if (time_not_ok(&timeout) == FALSE)
@@ -363,7 +355,7 @@ call_again:
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTENCODEARGS;
(void)xdrrec_endofrecord(xdrs, TRUE);
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (ct->ct_error.re_status);
}
} else {
@@ -374,23 +366,23 @@ call_again:
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTENCODEARGS;
(void)xdrrec_endofrecord(xdrs, TRUE);
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (ct->ct_error.re_status);
}
}
if (! xdrrec_endofrecord(xdrs, shipnow)) {
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (ct->ct_error.re_status = RPC_CANTSEND);
}
if (! shipnow) {
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (RPC_SUCCESS);
}
/*
* Hack to provide rpc-based message passing
*/
if (timeout.tv_sec == 0 && timeout.tv_usec == 0) {
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return(ct->ct_error.re_status = RPC_TIMEDOUT);
}
@@ -404,14 +396,14 @@ call_again:
reply_msg.acpted_rply.ar_results.where = NULL;
reply_msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
if (! xdrrec_skiprecord(xdrs)) {
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (ct->ct_error.re_status);
}
/* now decode and validate the response header */
if (! xdr_replymsg(xdrs, &reply_msg)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
continue;
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (ct->ct_error.re_status);
}
if (reply_msg.rm_xid == x_id)
@@ -452,7 +444,7 @@ call_again:
if (refreshes-- && AUTH_REFRESH(cl->cl_auth, &reply_msg))
goto call_again;
} /* end of unsuccessful completion */
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (ct->ct_error.re_status);
}
@@ -472,6 +464,7 @@ static bool_t
clnt_vc_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr)
{
struct ct_data *ct;
+ struct vc_fd *elem;
XDR *xdrs;
bool_t dummy;
sigset_t mask;
@@ -485,14 +478,13 @@ clnt_vc_freeres(CLIENT *cl, xdrproc_t xdr_res, void *res_ptr)
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (vc_fd_locks[ct->ct_fd])
- cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
+ elem = vc_fd_find(ct->ct_fd);
+ mutex_lock(&elem->mtx);
xdrs->x_op = XDR_FREE;
dummy = (*xdr_res)(xdrs, res_ptr);
- mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- cond_signal(&vc_cv[ct->ct_fd]);
+ mutex_unlock(&clnt_fd_lock);
+ release_fd_lock(elem, mask);
return dummy;
}
@@ -520,10 +512,10 @@ static bool_t
clnt_vc_control(CLIENT *cl, u_int request, void *info)
{
struct ct_data *ct;
+ struct vc_fd *elem;
void *infop = info;
sigset_t mask;
sigset_t newmask;
- int rpc_lock_value;
assert(cl != NULL);
@@ -532,23 +524,18 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info)
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (vc_fd_locks[ct->ct_fd])
- cond_wait(&vc_cv[ct->ct_fd], &clnt_fd_lock);
- if (__isthreaded)
- rpc_lock_value = 1;
- else
- rpc_lock_value = 0;
- vc_fd_locks[ct->ct_fd] = rpc_lock_value;
+ elem = vc_fd_find(ct->ct_fd);
mutex_unlock(&clnt_fd_lock);
+ mutex_lock(&elem->mtx);
switch (request) {
case CLSET_FD_CLOSE:
ct->ct_closeit = TRUE;
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (TRUE);
case CLSET_FD_NCLOSE:
ct->ct_closeit = FALSE;
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (TRUE);
default:
break;
@@ -556,13 +543,13 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info)
/* for other requests which use info */
if (info == NULL) {
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
switch (request) {
case CLSET_TIMEOUT:
if (time_not_ok((struct timeval *)info)) {
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
ct->ct_wait = *(struct timeval *)infop;
@@ -582,7 +569,7 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info)
*(struct netbuf *)info = ct->ct_addr;
break;
case CLSET_SVC_ADDR: /* set to new address */
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
case CLGET_XID:
/*
@@ -626,10 +613,10 @@ clnt_vc_control(CLIENT *cl, u_int request, void *info)
break;
default:
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (FALSE);
}
- release_fd_lock(ct->ct_fd, mask);
+ release_fd_lock(elem, mask);
return (TRUE);
}
@@ -638,6 +625,7 @@ static void
clnt_vc_destroy(CLIENT *cl)
{
struct ct_data *ct = (struct ct_data *) cl->cl_private;
+ struct vc_fd *elem;
int ct_fd = ct->ct_fd;
sigset_t mask;
sigset_t newmask;
@@ -649,8 +637,8 @@ clnt_vc_destroy(CLIENT *cl)
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
- while (vc_fd_locks[ct_fd])
- cond_wait(&vc_cv[ct_fd], &clnt_fd_lock);
+ elem = vc_fd_find(ct_fd);
+ mutex_lock(&elem->mtx);
if (ct->ct_closeit && ct->ct_fd != -1) {
(void)_close(ct->ct_fd);
}
@@ -663,8 +651,7 @@ clnt_vc_destroy(CLIENT *cl)
mem_free(cl->cl_tp, strlen(cl->cl_tp) +1);
mem_free(cl, sizeof(CLIENT));
mutex_unlock(&clnt_fd_lock);
- thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
- cond_signal(&vc_cv[ct_fd]);
+ release_fd_lock(elem, mask);
}
/*
diff --git a/lib/libc/rpc/crypt_client.c b/lib/libc/rpc/crypt_client.c
index 2fe0facd6505..4173a14811f9 100644
--- a/lib/libc/rpc/crypt_client.c
+++ b/lib/libc/rpc/crypt_client.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <err.h>
#include <sys/types.h>
diff --git a/lib/libc/rpc/des_crypt.3 b/lib/libc/rpc/des_crypt.3
index d2142178a1d1..063e4bf247f0 100644
--- a/lib/libc/rpc/des_crypt.3
+++ b/lib/libc/rpc/des_crypt.3
@@ -1,4 +1,3 @@
-.\" @(#)des_crypt.3 2.1 88/08/11 4.0 RPCSRC; from 1.16 88/03/02 SMI;
.\"
.Dd October 6, 1987
.Dt DES_CRYPT 3
diff --git a/lib/libc/rpc/des_crypt.c b/lib/libc/rpc/des_crypt.c
index 3202aeef3604..beaa11c5fc15 100644
--- a/lib/libc/rpc/des_crypt.c
+++ b/lib/libc/rpc/des_crypt.c
@@ -36,10 +36,6 @@
#include <rpc/des_crypt.h>
#include <rpc/des.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)des_crypt.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
-#endif
-#include <sys/cdefs.h>
static int common_crypt( char *, char *, unsigned, unsigned, struct desparams * );
int (*__des_crypt_LOCAL)(char *, unsigned, struct desparams *) = 0;
extern int _des_crypt_call(char *, int, struct desparams *);
diff --git a/lib/libc/rpc/des_soft.c b/lib/libc/rpc/des_soft.c
index c97a4686b70d..426b0a1bc116 100644
--- a/lib/libc/rpc/des_soft.c
+++ b/lib/libc/rpc/des_soft.c
@@ -28,10 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
-#endif
-#include <sys/cdefs.h>
/*
* Table giving odd parity in the low bit for ASCII characters
*/
diff --git a/lib/libc/rpc/getnetconfig.3 b/lib/libc/rpc/getnetconfig.3
index 8e8a8abb2081..a3b7fd37174f 100644
--- a/lib/libc/rpc/getnetconfig.3
+++ b/lib/libc/rpc/getnetconfig.3
@@ -1,4 +1,3 @@
-.\" @(#)getnetconfig.3n 1.28 93/06/02 SMI; from SVr4
.\" $NetBSD: getnetconfig.3,v 1.1 2000/06/02 23:11:11 fvdl Exp $
.\" Copyright 1989 AT&T
.Dd April 22, 2000
diff --git a/lib/libc/rpc/getnetconfig.c b/lib/libc/rpc/getnetconfig.c
index 100aef435512..03a4497b21ec 100644
--- a/lib/libc/rpc/getnetconfig.c
+++ b/lib/libc/rpc/getnetconfig.c
@@ -30,10 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetconfig.c 1.12 91/12/19 SMI";
-#endif
-#include <sys/cdefs.h>
/*
* Copyright (c) 1989 by Sun Microsystems, Inc.
*/
diff --git a/lib/libc/rpc/getnetpath.3 b/lib/libc/rpc/getnetpath.3
index 961bcd88a4fe..79185c5f50b9 100644
--- a/lib/libc/rpc/getnetpath.3
+++ b/lib/libc/rpc/getnetpath.3
@@ -1,4 +1,3 @@
-.\" @(#)getnetpath.3n 1.26 93/05/07 SMI; from SVr4
.\" $NetBSD: getnetpath.3,v 1.1 2000/06/02 23:11:11 fvdl Exp $
.\" Copyright 1989 AT&T
.Dd April 22, 2000
diff --git a/lib/libc/rpc/getnetpath.c b/lib/libc/rpc/getnetpath.c
index 4ae32a8783e2..06098af87dc1 100644
--- a/lib/libc/rpc/getnetpath.c
+++ b/lib/libc/rpc/getnetpath.c
@@ -30,10 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetpath.c 1.11 91/12/19 SMI";
-#endif
-#include <sys/cdefs.h>
/*
* Copyright (c) 1989 by Sun Microsystems, Inc.
*/
diff --git a/lib/libc/rpc/getpublickey.c b/lib/libc/rpc/getpublickey.c
index 76f8258d45c1..2afd5b8c2a8a 100644
--- a/lib/libc/rpc/getpublickey.c
+++ b/lib/libc/rpc/getpublickey.c
@@ -28,10 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)publickey.c 1.10 91/03/11 Copyr 1986 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* publickey.c
* Copyright (C) 1986, Sun Microsystems, Inc.
diff --git a/lib/libc/rpc/getrpcent.3 b/lib/libc/rpc/getrpcent.3
index 4afbaa615b50..b2a4f71375a6 100644
--- a/lib/libc/rpc/getrpcent.3
+++ b/lib/libc/rpc/getrpcent.3
@@ -1,4 +1,3 @@
-.\" @(#)getrpcent.3n 2.2 88/08/02 4.0 RPCSRC; from 1.11 88/03/14 SMI
.\" $NetBSD: getrpcent.3,v 1.6 1998/02/05 18:49:06 perry Exp $
.\"
.Dd February 26, 2016
diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c
index c980aaee5d83..ee36c11b303f 100644
--- a/lib/libc/rpc/getrpcent.c
+++ b/lib/libc/rpc/getrpcent.c
@@ -30,10 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid = "@(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* Copyright (c) 1984 by Sun Microsystems, Inc.
*/
diff --git a/lib/libc/rpc/getrpcport.3 b/lib/libc/rpc/getrpcport.3
index 5a3a34d8f3d0..c4d5a053626e 100644
--- a/lib/libc/rpc/getrpcport.3
+++ b/lib/libc/rpc/getrpcport.3
@@ -1,4 +1,3 @@
-.\" @(#)getrpcport.3r 2.2 88/08/02 4.0 RPCSRC; from 1.12 88/02/26 SMI
.\"
.Dd October 6, 1987
.Dt GETRPCPORT 3
diff --git a/lib/libc/rpc/getrpcport.c b/lib/libc/rpc/getrpcport.c
index a6143ef0a8ba..5065c37cab7b 100644
--- a/lib/libc/rpc/getrpcport.c
+++ b/lib/libc/rpc/getrpcport.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)getrpcport.c 1.3 87/08/11 SMI";
-static char *sccsid = "@(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
diff --git a/lib/libc/rpc/key_call.c b/lib/libc/rpc/key_call.c
index 4af7ca9609ce..5c87881c815c 100644
--- a/lib/libc/rpc/key_call.c
+++ b/lib/libc/rpc/key_call.c
@@ -31,8 +31,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#ident "@(#)key_call.c 1.25 94/04/24 SMI"
-#include <sys/cdefs.h>
/*
* key_call.c, Interface to keyserver
*
diff --git a/lib/libc/rpc/key_prot_xdr.c b/lib/libc/rpc/key_prot_xdr.c
index b98d1c432e3f..aadde38e39c6 100644
--- a/lib/libc/rpc/key_prot_xdr.c
+++ b/lib/libc/rpc/key_prot_xdr.c
@@ -37,8 +37,6 @@
*/
/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */
-/* #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */
-#include <sys/cdefs.h>
/*
* Compiled from key_prot.x using rpcgen.
* DO NOT EDIT THIS FILE!
diff --git a/lib/libc/rpc/mt_misc.c b/lib/libc/rpc/mt_misc.c
index 93c242953d1b..1f8bcfc0cb5d 100644
--- a/lib/libc/rpc/mt_misc.c
+++ b/lib/libc/rpc/mt_misc.c
@@ -1,7 +1,5 @@
/* $NetBSD: mt_misc.c,v 1.1 2000/06/02 23:11:11 fvdl Exp $ */
-/* #pragma ident "@(#)mt_misc.c 1.24 93/04/29 SMI" */
-#include <sys/cdefs.h>
#include "namespace.h"
#include "reentrant.h"
#include <rpc/rpc.h>
diff --git a/lib/libc/rpc/netname.c b/lib/libc/rpc/netname.c
index bfb925f25335..6ab016ef968a 100644
--- a/lib/libc/rpc/netname.c
+++ b/lib/libc/rpc/netname.c
@@ -28,10 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)netname.c 1.8 91/03/11 Copyr 1986 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* netname utility routines
* convert from unix names to network names and vice-versa
diff --git a/lib/libc/rpc/netnamer.c b/lib/libc/rpc/netnamer.c
index 94b386bcdf63..96ece9cc1885 100644
--- a/lib/libc/rpc/netnamer.c
+++ b/lib/libc/rpc/netnamer.c
@@ -28,10 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)netnamer.c 1.13 91/03/11 Copyr 1986 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* netname utility routines convert from unix names to network names and
* vice-versa This module is operating system dependent! What we define here
diff --git a/lib/libc/rpc/pmap_clnt.c b/lib/libc/rpc/pmap_clnt.c
index 4e33ed21bd2d..ad592b8da3de 100644
--- a/lib/libc/rpc/pmap_clnt.c
+++ b/lib/libc/rpc/pmap_clnt.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* pmap_clnt.c
* Client interface to pmap rpc service.
diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c
index 3ecd51044797..594ea1879ab4 100644
--- a/lib/libc/rpc/pmap_getmaps.c
+++ b/lib/libc/rpc/pmap_getmaps.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* pmap_getmap.c
* Client interface to pmap rpc service.
diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c
index 9610f7625001..065cb73c70c7 100644
--- a/lib/libc/rpc/pmap_getport.c
+++ b/lib/libc/rpc/pmap_getport.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "from: @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "from: @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* pmap_getport.c
* Client interface to pmap rpc service.
diff --git a/lib/libc/rpc/pmap_prot.c b/lib/libc/rpc/pmap_prot.c
index 596b3699ba86..3f4dba89494c 100644
--- a/lib/libc/rpc/pmap_prot.c
+++ b/lib/libc/rpc/pmap_prot.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* pmap_prot.c
* Protocol for the local binder service, or pmap.
diff --git a/lib/libc/rpc/pmap_prot2.c b/lib/libc/rpc/pmap_prot2.c
index 20614c44987d..98be43a15202 100644
--- a/lib/libc/rpc/pmap_prot2.c
+++ b/lib/libc/rpc/pmap_prot2.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* pmap_prot2.c
* Protocol for the local binder service, or pmap.
diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c
index ae5e2483c351..3bf22a676382 100644
--- a/lib/libc/rpc/pmap_rmt.c
+++ b/lib/libc/rpc/pmap_rmt.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* pmap_rmt.c
* Client interface to pmap rpc service.
diff --git a/lib/libc/rpc/publickey.3 b/lib/libc/rpc/publickey.3
index 86fef5f0ed08..450fbd037371 100644
--- a/lib/libc/rpc/publickey.3
+++ b/lib/libc/rpc/publickey.3
@@ -1,4 +1,3 @@
-.\" @(#)publickey.3r 2.1 88/08/07 4.0 RPCSRC
.\"
.Dd October 6, 1987
.Dt PUBLICKEY 3
diff --git a/lib/libc/rpc/publickey.5 b/lib/libc/rpc/publickey.5
index e0a03f7dca45..db95c4617b50 100644
--- a/lib/libc/rpc/publickey.5
+++ b/lib/libc/rpc/publickey.5
@@ -1,4 +1,3 @@
-.\" @(#)publickey.5 2.1 88/08/07 4.0 RPCSRC; from 1.6 88/02/29 SMI;
.Dd October 19, 1987
.Dt PUBLICKEY 5
.Os
diff --git a/lib/libc/rpc/rpc.3 b/lib/libc/rpc/rpc.3
index 01430b8a63f2..12d19df117ad 100644
--- a/lib/libc/rpc/rpc.3
+++ b/lib/libc/rpc/rpc.3
@@ -1,4 +1,3 @@
-.\" @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" $NetBSD: rpc.3,v 1.10 2000/06/02 23:11:12 fvdl Exp $
.Dd May 7, 1993
diff --git a/lib/libc/rpc/rpc.5 b/lib/libc/rpc/rpc.5
index aac312215146..ac8219fc57fc 100644
--- a/lib/libc/rpc/rpc.5
+++ b/lib/libc/rpc/rpc.5
@@ -1,5 +1,4 @@
.\" $NetBSD: rpc.5,v 1.3 2000/06/15 20:05:54 fvdl Exp $
-.\" @(#)rpc.4 1.17 93/08/30 SMI; from SVr4
.\" Copyright 1989 AT&T
.Dd December 10, 1991
.Dt RPC 5
diff --git a/lib/libc/rpc/rpc_callmsg.c b/lib/libc/rpc/rpc_callmsg.c
index d4ad098e7cea..a06010cadc2f 100644
--- a/lib/libc/rpc/rpc_callmsg.c
+++ b/lib/libc/rpc/rpc_callmsg.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* rpc_callmsg.c
*
diff --git a/lib/libc/rpc/rpc_clnt_auth.3 b/lib/libc/rpc/rpc_clnt_auth.3
index 9b50f89b2c56..36aafe85c677 100644
--- a/lib/libc/rpc/rpc_clnt_auth.3
+++ b/lib/libc/rpc/rpc_clnt_auth.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_clnt_auth.3n 1.21 93/05/07 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $NetBSD: rpc_clnt_auth.3,v 1.1 2000/06/03 09:29:50 fvdl Exp $
.Dd May 7, 1993
diff --git a/lib/libc/rpc/rpc_clnt_calls.3 b/lib/libc/rpc/rpc_clnt_calls.3
index 3c7fb9f12f17..894ed8e92cc4 100644
--- a/lib/libc/rpc/rpc_clnt_calls.3
+++ b/lib/libc/rpc/rpc_clnt_calls.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_clnt_calls.3n 1.30 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_clnt_calls 1.4 89/07/20 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.Dd May 7, 1993
.Dt RPC_CLNT_CALLS 3
diff --git a/lib/libc/rpc/rpc_clnt_create.3 b/lib/libc/rpc/rpc_clnt_create.3
index 87e101fd7696..75bc3471faaa 100644
--- a/lib/libc/rpc/rpc_clnt_create.3
+++ b/lib/libc/rpc/rpc_clnt_create.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_clnt_create.3n 1.36 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_clnt_create 1.5 89/07/24 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $NetBSD: rpc_clnt_create.3,v 1.2 2000/06/20 00:53:08 fvdl Exp $
.Dd May 7, 1993
diff --git a/lib/libc/rpc/rpc_com.h b/lib/libc/rpc/rpc_com.h
index 67e47af3f454..e641e2d3e731 100644
--- a/lib/libc/rpc/rpc_com.h
+++ b/lib/libc/rpc/rpc_com.h
@@ -44,9 +44,6 @@
#ifndef _RPC_RPCCOM_H
#define _RPC_RPCCOM_H
-#include <sys/cdefs.h>
-
-/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */
/*
* The max size of the transport, if the size cannot be determined
@@ -60,7 +57,6 @@
__BEGIN_DECLS
extern u_int __rpc_get_a_size(int);
-extern int __rpc_dtbsize(void);
extern struct netconfig * __rpcgettp(int);
extern int __rpc_get_default_domain(char **);
diff --git a/lib/libc/rpc/rpc_commondata.c b/lib/libc/rpc/rpc_commondata.c
index 7d7a537a396d..7b07dff11874 100644
--- a/lib/libc/rpc/rpc_commondata.c
+++ b/lib/libc/rpc/rpc_commondata.c
@@ -30,10 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid = "@(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
#include "namespace.h"
#include <rpc/rpc.h>
#include "un-namespace.h"
diff --git a/lib/libc/rpc/rpc_dtablesize.c b/lib/libc/rpc/rpc_dtablesize.c
index e476914cefcd..c2cffecec24e 100644
--- a/lib/libc/rpc/rpc_dtablesize.c
+++ b/lib/libc/rpc/rpc_dtablesize.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
-static char *sccsid = "@(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
#include "namespace.h"
#include <unistd.h>
#include "un-namespace.h"
diff --git a/lib/libc/rpc/rpc_generic.c b/lib/libc/rpc/rpc_generic.c
index 967fb6e0932c..0e563f6a5996 100644
--- a/lib/libc/rpc/rpc_generic.c
+++ b/lib/libc/rpc/rpc_generic.c
@@ -33,8 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-/* #pragma ident "@(#)rpc_generic.c 1.17 94/04/24 SMI" */
-#include <sys/cdefs.h>
/*
* rpc_generic.c, Miscl routines for RPC.
*
@@ -97,7 +95,8 @@ static const struct netid_af na_cvt[] = {
{ "udp6", AF_INET6, IPPROTO_UDP },
{ "tcp6", AF_INET6, IPPROTO_TCP },
#endif
- { "local", AF_LOCAL, 0 }
+ { "local", AF_LOCAL, 0 },
+ { "netlink", AF_NETLINK, 0 },
};
#if 0
@@ -105,29 +104,6 @@ static char *strlocase(char *);
#endif
static int getnettype(const char *);
-/*
- * Cache the result of getrlimit(), so we don't have to do an
- * expensive call every time.
- */
-int
-__rpc_dtbsize(void)
-{
- static int tbsize;
- struct rlimit rl;
-
- if (tbsize) {
- return (tbsize);
- }
- if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
- return (tbsize = (int)rl.rlim_max);
- }
- /*
- * Something wrong. I'll try to save face by returning a
- * pessimistic number.
- */
- return (32);
-}
-
/*
* Find the appropriate buffer size
diff --git a/lib/libc/rpc/rpc_prot.c b/lib/libc/rpc/rpc_prot.c
index 6cd854efa943..48671462a52e 100644
--- a/lib/libc/rpc/rpc_prot.c
+++ b/lib/libc/rpc/rpc_prot.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* rpc_prot.c
*
diff --git a/lib/libc/rpc/rpc_secure.3 b/lib/libc/rpc/rpc_secure.3
index e5d14b935aa4..ce59bba7115f 100644
--- a/lib/libc/rpc/rpc_secure.3
+++ b/lib/libc/rpc/rpc_secure.3
@@ -1,4 +1,3 @@
-.\" @(#)rpc_secure.3n 2.1 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
.\"
.Dd February 16, 1988
.Dt RPC 3
@@ -267,8 +266,7 @@ Inverse of
.Fn netname2user .
.Sh SEE ALSO
.Xr rpc 3 ,
-.Xr xdr 3 ,
-.Xr keyserv 8
+.Xr xdr 3
.Pp
The following manuals:
.Rs
diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3
index 166a3477b8d4..4abd4b14c475 100644
--- a/lib/libc/rpc/rpc_soc.3
+++ b/lib/libc/rpc/rpc_soc.3
@@ -1,4 +1,3 @@
-.\" @(#)rpc.3n 2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
.\" $NetBSD: rpc_soc.3,v 1.2 2000/06/07 13:39:43 simonb Exp $
.\"
.Dd February 16, 1988
diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c
index 1350da14d42b..c63b89594ce6 100644
--- a/lib/libc/rpc/rpc_soc.c
+++ b/lib/libc/rpc/rpc_soc.c
@@ -30,8 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/* #ident "@(#)rpc_soc.c 1.17 94/04/24 SMI" */
-
/*
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
* In addition, portions of such source code were derived from Berkeley
@@ -39,10 +37,6 @@
* California.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
-#endif
-#include <sys/cdefs.h>
#ifdef PORTMAP
/*
* rpc_soc.c
diff --git a/lib/libc/rpc/rpc_svc_calls.3 b/lib/libc/rpc/rpc_svc_calls.3
index bb4047f4d9ca..503cf6a53b9c 100644
--- a/lib/libc/rpc/rpc_svc_calls.3
+++ b/lib/libc/rpc/rpc_svc_calls.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_svc_calls.3n 1.28 93/05/10 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_svc_calls 1.5 89/07/25 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $NetBSD: rpc_svc_calls.3,v 1.1 2000/06/02 23:11:13 fvdl Exp $
.Dd May 3, 1993
diff --git a/lib/libc/rpc/rpc_svc_create.3 b/lib/libc/rpc/rpc_svc_create.3
index 20281c7294af..4c5dde45aabd 100644
--- a/lib/libc/rpc/rpc_svc_create.3
+++ b/lib/libc/rpc/rpc_svc_create.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_svc_create.3n 1.26 93/08/26 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_svc_create 1.3 89/06/28 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.Dd May 3, 1993
.Dt RPC_SVC_CREATE 3
diff --git a/lib/libc/rpc/rpc_svc_err.3 b/lib/libc/rpc/rpc_svc_err.3
index 9014e71c8d88..c2724cefac5a 100644
--- a/lib/libc/rpc/rpc_svc_err.3
+++ b/lib/libc/rpc/rpc_svc_err.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_svc_err.3n 1.23 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_svc_err 1.4 89/06/28 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $NetBSD: rpc_svc_err.3,v 1.1 2000/06/02 23:11:14 fvdl Exp $
.Dd May 3, 1993
diff --git a/lib/libc/rpc/rpc_svc_reg.3 b/lib/libc/rpc/rpc_svc_reg.3
index 72003cec3cdd..00c8259f6ef4 100644
--- a/lib/libc/rpc/rpc_svc_reg.3
+++ b/lib/libc/rpc/rpc_svc_reg.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_svc_reg.3n 1.32 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_svc_call 1.6 89/07/20 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\" $NetBSD: rpc_svc_reg.3,v 1.1 2000/06/02 23:11:14 fvdl Exp $
.Dd May 3, 1993
diff --git a/lib/libc/rpc/rpc_xdr.3 b/lib/libc/rpc/rpc_xdr.3
index 029d79b65cf7..1918684101c2 100644
--- a/lib/libc/rpc/rpc_xdr.3
+++ b/lib/libc/rpc/rpc_xdr.3
@@ -1,6 +1,4 @@
-.\" @(#)rpc_xdr.3n 1.24 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
-.\" @(#)rpc_xdr.new 1.1 89/04/06 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.Dd May 3, 1993
.Dt RPC_XDR 3
diff --git a/lib/libc/rpc/rpcb_clnt.c b/lib/libc/rpc/rpcb_clnt.c
index 10e7b0cce046..a08cd82b4359 100644
--- a/lib/libc/rpc/rpcb_clnt.c
+++ b/lib/libc/rpc/rpcb_clnt.c
@@ -30,13 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/* #ident "@(#)rpcb_clnt.c 1.27 94/04/24 SMI" */
-
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* rpcb_clnt.c
* interface to rpcbind rpc service.
diff --git a/lib/libc/rpc/rpcb_prot.c b/lib/libc/rpc/rpcb_prot.c
index 088d2493bd80..c6de3465898f 100644
--- a/lib/libc/rpc/rpcb_prot.c
+++ b/lib/libc/rpc/rpcb_prot.c
@@ -33,12 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-/* #ident "@(#)rpcb_prot.c 1.13 94/04/24 SMI" */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rpcb_prot.c 1.9 89/04/21 Copyr 1984 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* rpcb_prot.c
* XDR routines for the rpcbinder version 3.
diff --git a/lib/libc/rpc/rpcb_st_xdr.c b/lib/libc/rpc/rpcb_st_xdr.c
index 5791681b812c..ece2f284a980 100644
--- a/lib/libc/rpc/rpcb_st_xdr.c
+++ b/lib/libc/rpc/rpcb_st_xdr.c
@@ -39,7 +39,6 @@
* routines used with the rpcbind stats facility.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <rpc/rpc.h>
#include <rpc/rpc_com.h>
diff --git a/lib/libc/rpc/rpcbind.3 b/lib/libc/rpc/rpcbind.3
index 31fc7ad9a91d..aa5ffe62af7e 100644
--- a/lib/libc/rpc/rpcbind.3
+++ b/lib/libc/rpc/rpcbind.3
@@ -1,4 +1,3 @@
-.\" @(#)rpcbind.3n 1.25 93/05/07 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" Copyright (c) 1988 Sun Microsystem's, Inc. - All Right's Reserved.
.\" $NetBSD: rpcbind.3,v 1.2 2000/06/03 18:47:28 fvdl Exp $
diff --git a/lib/libc/rpc/rpcdname.c b/lib/libc/rpc/rpcdname.c
index 970588d01430..dff2ca464572 100644
--- a/lib/libc/rpc/rpcdname.c
+++ b/lib/libc/rpc/rpcdname.c
@@ -28,10 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rpcdname.c 1.7 91/03/11 Copyr 1989 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* rpcdname.c
* Gets the default domain name
diff --git a/lib/libc/rpc/rtime.3 b/lib/libc/rpc/rtime.3
index ac26d3045a6a..3c245ab398ac 100644
--- a/lib/libc/rpc/rtime.3
+++ b/lib/libc/rpc/rtime.3
@@ -1,4 +1,3 @@
-.\" @(#)rtime.3n 2.1 88/08/08 4.0 RPCSRC; from 1.5 88/02/08 SMI
.\"
.Dd May 13, 2021
.Dt RTIME 3
diff --git a/lib/libc/rpc/rtime.c b/lib/libc/rpc/rtime.c
index 673751c8a03b..0d4177142bf2 100644
--- a/lib/libc/rpc/rtime.c
+++ b/lib/libc/rpc/rtime.c
@@ -55,10 +55,6 @@
#include <netdb.h>
#include "un-namespace.h"
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rtime.c 2.2 88/08/10 4.0 RPCSRC; from 1.8 88/02/08 SMI";
-#endif
-#include <sys/cdefs.h>
extern int _rpc_dtablesize( void );
#define NYEARS (unsigned long)(1970 - 1900)
diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c
index 4fb69dda9c7a..d3877a95b742 100644
--- a/lib/libc/rpc/svc.c
+++ b/lib/libc/rpc/svc.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* svc.c, Server-side remote procedure call interface.
*
diff --git a/lib/libc/rpc/svc_auth.c b/lib/libc/rpc/svc_auth.c
index 1bfffcc4786f..eb61171733d6 100644
--- a/lib/libc/rpc/svc_auth.c
+++ b/lib/libc/rpc/svc_auth.c
@@ -33,11 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-#ident "@(#)svc_auth.c 1.16 94/04/24 SMI"
-static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* svc_auth.c, Server-side rpc authenticator interface.
*
diff --git a/lib/libc/rpc/svc_auth_des.c b/lib/libc/rpc/svc_auth_des.c
index a2dd0c92e541..d4736cc851e8 100644
--- a/lib/libc/rpc/svc_auth_des.c
+++ b/lib/libc/rpc/svc_auth_des.c
@@ -65,10 +65,6 @@
#include <rpc/svc_auth.h>
#include "libc_private.h"
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)svcauth_des.c 2.3 89/07/11 4.0 RPCSRC; from 1.15 88/02/08 SMI";
-#endif
-#include <sys/cdefs.h>
extern int key_decryptsession_pk(const char *, netobj *, des_block *);
#define debug(msg) printf("svcauth_des: %s\n", msg)
diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c
index b5f783240ad4..2caab6fe9d9e 100644
--- a/lib/libc/rpc/svc_auth_unix.c
+++ b/lib/libc/rpc/svc_auth_unix.c
@@ -28,11 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* svc_auth_unix.c
* Handles UNIX flavor authentication parameters on the service side of rpc.
diff --git a/lib/libc/rpc/svc_dg.c b/lib/libc/rpc/svc_dg.c
index 544b80a65d95..892fe5ceaa53 100644
--- a/lib/libc/rpc/svc_dg.c
+++ b/lib/libc/rpc/svc_dg.c
@@ -34,10 +34,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-#ident "@(#)svc_dg.c 1.17 94/04/24 SMI"
-#endif
-#include <sys/cdefs.h>
/*
* svc_dg.c, Server side for connectionless RPC.
*
diff --git a/lib/libc/rpc/svc_generic.c b/lib/libc/rpc/svc_generic.c
index b0913b42d045..ea08811ba1ae 100644
--- a/lib/libc/rpc/svc_generic.c
+++ b/lib/libc/rpc/svc_generic.c
@@ -34,11 +34,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-#ident "@(#)svc_generic.c 1.19 94/04/24 SMI"
-static char sccsid[] = "@(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* svc_generic.c, Server side for RPC.
*
diff --git a/lib/libc/rpc/svc_nl.c b/lib/libc/rpc/svc_nl.c
new file mode 100644
index 000000000000..cff364063c5c
--- /dev/null
+++ b/lib/libc/rpc/svc_nl.c
@@ -0,0 +1,373 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Gleb Smirnoff <glebius@FreeBSD.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.
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <pthread.h>
+#include <rpc/rpc.h>
+#include <rpc/clnt_nl.h>
+
+#include <netlink/netlink.h>
+#include <netlink/netlink_generic.h>
+#include <netlink/netlink_snl.h>
+#include <netlink/netlink_snl_generic.h>
+
+#include "rpc_com.h"
+#include "libc_private.h"
+
+/*
+ * RPC server to serve a kernel RPC client(s) over netlink(4). See clnt_nl.c
+ * in sys/rpc as the counterpart.
+ *
+ * Upon creation the client will seek for specified multicast group within the
+ * generic netlink family named "rpc". Then it would listen for incoming
+ * messages, process them and send replies over the same netlink socket.
+ * See clnt_nl.c for more transport protocol implementation details.
+ */
+
+static void svc_nl_destroy(SVCXPRT *);
+static bool_t svc_nl_recv(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_nl_reply(SVCXPRT *, struct rpc_msg *);
+static enum xprt_stat svc_nl_stat(SVCXPRT *);
+static bool_t svc_nl_getargs(SVCXPRT *, xdrproc_t, void *);
+static bool_t svc_nl_freeargs(SVCXPRT *, xdrproc_t, void *);
+static bool_t svc_nl_control(SVCXPRT *, const u_int, void *);
+
+static struct xp_ops nl_ops = {
+ .xp_recv = svc_nl_recv,
+ .xp_reply = svc_nl_reply,
+ .xp_stat = svc_nl_stat,
+ .xp_getargs = svc_nl_getargs,
+ .xp_freeargs = svc_nl_freeargs,
+ .xp_destroy = svc_nl_destroy,
+};
+static struct xp_ops2 nl_ops2 = {
+ .xp_control = svc_nl_control,
+};
+
+struct nl_softc {
+ struct snl_state snl;
+ XDR xdrs;
+ struct nlmsghdr *hdr;
+ pthread_key_t xidkey;
+ size_t mlen;
+ enum xprt_stat stat;
+ uint32_t xid;
+ uint32_t group;
+ uint16_t family;
+ u_int errline;
+ int error;
+};
+
+SVCXPRT *
+svc_nl_create(const char *service)
+{
+ static struct sockaddr_nl snl_null = {
+ .nl_len = sizeof(struct sockaddr_nl),
+ .nl_family = PF_NETLINK,
+ };
+ struct nl_softc *sc;
+ SVCXPRT *xprt = NULL;
+ void *buf = NULL;
+ uint16_t family;
+ ssize_t len = 1024;
+
+ if ((sc = calloc(1, sizeof(struct nl_softc))) == NULL)
+ return (NULL);
+ if (!snl_init(&sc->snl, NETLINK_GENERIC) || (sc->group =
+ snl_get_genl_mcast_group(&sc->snl, "rpc", service, &family)) == 0)
+ goto fail;
+ if (setsockopt(sc->snl.fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
+ &sc->group, sizeof(sc->group)) == -1)
+ goto fail;
+ if ((buf = malloc(len)) == NULL)
+ goto fail;
+ if ((xprt = svc_xprt_alloc()) == NULL)
+ goto fail;
+
+ sc->hdr = buf,
+ sc->mlen = len,
+ sc->stat = XPRT_IDLE,
+ sc->family = family;
+
+ if (__isthreaded &&
+ (pthread_key_create(&sc->xidkey, NULL) != 0 ||
+ pthread_setspecific(sc->xidkey, &sc->xid) != 0))
+ goto fail;
+
+ xprt->xp_fd = sc->snl.fd,
+ xprt->xp_p1 = sc,
+ xprt->xp_ops = &nl_ops,
+ xprt->xp_ops2 = &nl_ops2,
+ xprt->xp_rtaddr = (struct netbuf){
+ .maxlen = sizeof(struct sockaddr_nl),
+ .len = sizeof(struct sockaddr_nl),
+ .buf = &snl_null,
+ };
+ xprt_register(xprt);
+
+ return (xprt);
+fail:
+ free(xprt);
+ free(buf);
+ snl_free(&sc->snl);
+ free(sc);
+ return (NULL);
+}
+
+static void
+svc_nl_destroy(SVCXPRT *xprt)
+{
+ struct nl_softc *sc = xprt->xp_p1;
+
+ snl_free(&sc->snl);
+ free(sc->hdr);
+ free(xprt->xp_p1);
+ svc_xprt_free(xprt);
+}
+
+#define DIE(sc) do { \
+ (sc)->stat = XPRT_DIED; \
+ (sc)->errline = __LINE__; \
+ (sc)->error = errno; \
+ return (FALSE); \
+} while (0)
+
+struct nl_request_parsed {
+ uint32_t group;
+ struct nlattr *data;
+};
+static const struct snl_attr_parser rpcnl_attr_parser[] = {
+#define OUT(field) offsetof(struct nl_request_parsed, field)
+ { .type = RPCNL_REQUEST_GROUP, .off = OUT(group),
+ .cb = snl_attr_get_uint32 },
+ { .type = RPCNL_REQUEST_BODY, .off = OUT(data), .cb = snl_attr_get_nla },
+#undef OUT
+};
+SNL_DECLARE_GENL_PARSER(request_parser, rpcnl_attr_parser);
+
+static bool_t
+svc_nl_recv(SVCXPRT *xprt, struct rpc_msg *msg)
+{
+ struct nl_request_parsed req;
+ struct nl_softc *sc = xprt->xp_p1;
+ struct nlmsghdr *hdr = sc->hdr;
+
+ switch (sc->stat) {
+ case XPRT_IDLE:
+ if (recv(xprt->xp_fd, hdr, sizeof(struct nlmsghdr),
+ MSG_PEEK) != sizeof(struct nlmsghdr))
+ DIE(sc);
+ break;
+ case XPRT_MOREREQS:
+ sc->stat = XPRT_IDLE;
+ break;
+ case XPRT_DIED:
+ return (FALSE);
+ }
+
+ if (sc->mlen < hdr->nlmsg_len) {
+ if ((hdr = sc->hdr = realloc(hdr, hdr->nlmsg_len)) == NULL)
+ DIE(sc);
+ else
+ sc->mlen = hdr->nlmsg_len;
+ }
+ if (read(xprt->xp_fd, hdr, hdr->nlmsg_len) != hdr->nlmsg_len)
+ DIE(sc);
+
+ if (hdr->nlmsg_type != sc->family)
+ return (FALSE);
+
+ if (((struct genlmsghdr *)(hdr + 1))->cmd != RPCNL_REQUEST)
+ return (FALSE);
+
+ if (!snl_parse_nlmsg(NULL, hdr, &request_parser, &req))
+ return (FALSE);
+
+ if (req.group != sc->group)
+ return (FALSE);
+
+ xdrmem_create(&sc->xdrs, NLA_DATA(req.data), NLA_DATA_LEN(req.data),
+ XDR_DECODE);
+ if (xdr_callmsg(&sc->xdrs, msg)) {
+ /* XXX: assert that xid == nlmsg_seq? */
+ sc->xid = msg->rm_xid;
+ return (TRUE);
+ } else
+ return (FALSE);
+}
+
+/*
+ * Reenterable reply method. Note that both the softc and xprt are declared
+ * const. The qualifier for xprt is commented out to match the library
+ * prototype. If doing any substantial changes to the function please
+ * temporarily uncomment the const for xprt and check your changes.
+ *
+ * Applications that want to use svc_nl_reply in a spawned thread context
+ * should do the following hacks in self:
+ * 1) - Create xprt with svc_nl_create() with libc in threaded mode, e.g.
+ * at least one pthread_create() shall happen before svc_nl_create().
+ * - After xprt creation query it for the pthread_key_t with the
+ * SVCNL_GET_XIDKEY control and save this key.
+ * 2) In the RPC function body that wants to become multithreaded:
+ * - Make a copy of the arguments and of the xid with help of
+ * pthread_getspecific() using the key.
+ * - pthread_create() the worker function, pointing it at the copy of
+ * arguments and xid.
+ * - return FALSE, so that RPC generated code doesn't do anything.
+ * 3) In the spawned thread:
+ * - Use arguments provided in the copy by the parent.
+ * - Allocate appropriately typed result on stack.
+ * - *** do the actual work ***
+ * - Populate the on-stack result same way as pointed result is populated
+ * in a regular RPC function.
+ * - Point the thread specific storage to the copy of xid provided by the
+ * parent with help of pthread_setspecific().
+ * - Call svc_sendreply() just like the rpcgen(1) generated code does.
+ *
+ * If all done correctly svc_nl_reply() will use thread specific xid for
+ * a call that was processed asynchronously and most recent xid when entered
+ * synchronously. So you can make only some methods of your application
+ * reentrable, keeping others as is.
+ */
+
+static bool_t
+svc_nl_reply(/* const */ SVCXPRT *xprt, struct rpc_msg *msg)
+{
+ const struct nl_softc *sc = xprt->xp_p1;
+ struct snl_state snl;
+ struct snl_writer nw;
+ XDR xdrs;
+ struct nlattr *body;
+ bool_t rv;
+
+ msg->rm_xid = __isthreaded ?
+ *(uint32_t *)pthread_getspecific(sc->xidkey) :
+ sc->xid;
+
+ if (__predict_false(!snl_clone(&snl, &sc->snl)))
+ return (FALSE);
+ snl_init_writer(&snl, &nw);
+ snl_create_genl_msg_request(&nw, sc->family, RPCNL_REPLY);
+ snl_add_msg_attr_u32(&nw, RPCNL_REPLY_GROUP, sc->group);
+ body = snl_reserve_msg_attr_raw(&nw, RPCNL_REPLY_BODY, RPC_MAXDATASIZE);
+
+ xdrmem_create(&xdrs, (char *)(body + 1), RPC_MAXDATASIZE, XDR_ENCODE);
+
+ if (msg->rm_reply.rp_stat == MSG_ACCEPTED &&
+ msg->rm_reply.rp_acpt.ar_stat == SUCCESS) {
+ xdrproc_t xdr_proc;
+ char *xdr_where;
+ u_int pos;
+
+ xdr_proc = msg->acpted_rply.ar_results.proc;
+ xdr_where = msg->acpted_rply.ar_results.where;
+ msg->acpted_rply.ar_results.proc = (xdrproc_t) xdr_void;
+ msg->acpted_rply.ar_results.where = NULL;
+
+ pos = xdr_getpos(&xdrs);
+ if (!xdr_replymsg(&xdrs, msg) ||
+ !SVCAUTH_WRAP(&SVC_AUTH(xprt), &xdrs, xdr_proc,
+ xdr_where)) {
+ xdr_setpos(&xdrs, pos);
+ rv = FALSE;
+ } else
+ rv = TRUE;
+ } else
+ rv = xdr_replymsg(&xdrs, msg);
+
+ if (rv) {
+ /* snl_finalize_msg() really doesn't work for us */
+ body->nla_len = sizeof(struct nlattr) + xdr_getpos(&xdrs);
+ nw.hdr->nlmsg_len = ((char *)body - (char *)nw.hdr) +
+ body->nla_len;
+ nw.hdr->nlmsg_type = sc->family;
+ nw.hdr->nlmsg_flags = NLM_F_REQUEST;
+ nw.hdr->nlmsg_seq = msg->rm_xid;
+ if (write(xprt->xp_fd, nw.hdr, nw.hdr->nlmsg_len) !=
+ nw.hdr->nlmsg_len)
+ DIE(__DECONST(struct nl_softc *, sc));
+ }
+
+ snl_free(&snl);
+
+ return (rv);
+}
+
+static bool_t
+svc_nl_control(SVCXPRT *xprt, const u_int req, void *v)
+{
+ struct nl_softc *sc = xprt->xp_p1;
+
+ switch (req) {
+ case SVCNL_GET_XIDKEY:
+ if (!__isthreaded) {
+ /*
+ * Report to application that it had created xprt not
+ * in threaded mode, but definitly plans to use it with
+ * threads. If it tries so, it would very likely crash.
+ */
+ errno = EDOOFUS;
+ DIE(sc);
+ };
+ *(pthread_key_t *)v = sc->xidkey;
+ return (TRUE);
+ default:
+ return (FALSE);
+ }
+}
+
+static enum xprt_stat
+svc_nl_stat(SVCXPRT *xprt)
+{
+ struct nl_softc *sc = xprt->xp_p1;
+
+ if (sc->stat == XPRT_IDLE &&
+ recv(xprt->xp_fd, sc->hdr, sizeof(struct nlmsghdr),
+ MSG_PEEK | MSG_DONTWAIT) == sizeof(struct nlmsghdr))
+ sc->stat = XPRT_MOREREQS;
+
+ return (sc->stat);
+}
+
+static bool_t
+svc_nl_getargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr)
+{
+ struct nl_softc *sc = xprt->xp_p1;
+
+ return (SVCAUTH_UNWRAP(&SVC_AUTH(xprt), &sc->xdrs, xdr_args, args_ptr));
+}
+
+static bool_t
+svc_nl_freeargs(SVCXPRT *xprt, xdrproc_t xdr_args, void *args_ptr)
+{
+ struct nl_softc *sc = xprt->xp_p1;
+
+ sc->xdrs.x_op = XDR_FREE;
+ return ((*xdr_args)(&sc->xdrs, args_ptr));
+}
diff --git a/lib/libc/rpc/svc_raw.c b/lib/libc/rpc/svc_raw.c
index d734e2c45894..ceedb083eae6 100644
--- a/lib/libc/rpc/svc_raw.c
+++ b/lib/libc/rpc/svc_raw.c
@@ -33,12 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-/* #ident "@(#)svc_raw.c 1.16 94/04/24 SMI" */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)svc_raw.c 1.25 89/01/31 Copyr 1984 Sun Micro";
-#endif
-#include <sys/cdefs.h>
/*
* svc_raw.c, This a toy for simple testing and timing.
* Interface to create an rpc client and server in the same UNIX process.
diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c
index 104be0b5078d..2c71d2bd082c 100644
--- a/lib/libc/rpc/svc_run.c
+++ b/lib/libc/rpc/svc_run.c
@@ -30,11 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
-static char *sccsid = "from: @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* This is the rpc server side idle loop
* Wait for input, call server program.
diff --git a/lib/libc/rpc/svc_simple.c b/lib/libc/rpc/svc_simple.c
index 8a99fce0d7d5..f4ce90f19bb4 100644
--- a/lib/libc/rpc/svc_simple.c
+++ b/lib/libc/rpc/svc_simple.c
@@ -33,8 +33,6 @@
* Copyright (c) 1986-1991 by Sun Microsystems Inc.
*/
-/* #pragma ident "@(#)svc_simple.c 1.18 94/04/24 SMI" */
-#include <sys/cdefs.h>
/*
* svc_simple.c
* Simplified front end to rpc.
diff --git a/lib/libc/rpc/svc_vc.c b/lib/libc/rpc/svc_vc.c
index 1f377b41e41b..e5826fdb6543 100644
--- a/lib/libc/rpc/svc_vc.c
+++ b/lib/libc/rpc/svc_vc.c
@@ -30,16 +30,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* svc_vc.c, Server side for Connection Oriented based RPC.
*
* Actually implements two flavors of transporter -
- * a tcp rendezvouser (a listner and connection establisher)
+ * a tcp rendezvouser (a listener and connection establisher)
* and a record/tcp stream.
*/
diff --git a/lib/libc/secure/Makefile.inc b/lib/libc/secure/Makefile.inc
index 8574c5a05dc5..5ee6f38d8b98 100644
--- a/lib/libc/secure/Makefile.inc
+++ b/lib/libc/secure/Makefile.inc
@@ -3,8 +3,19 @@
.PATH: ${LIBC_SRCTOP}/secure
+# _FORTIFY_SOURCE
+SRCS+= fgets_chk.c memcpy_chk.c memmove_chk.c mempcpy_chk.c memset_chk.c \
+ snprintf_chk.c sprintf_chk.c stpcpy_chk.c stpncpy_chk.c \
+ strcat_chk.c strcpy_chk.c strlcat_chk.c strncat_chk.c strlcpy_chk.c \
+ strncpy_chk.c vsnprintf_chk.c vsprintf_chk.c
+
+CFLAGS.snprintf_chk.c+= -Wno-unused-parameter
+CFLAGS.sprintf_chk.c+= -Wno-unused-parameter
+CFLAGS.vsnprintf_chk.c+= -Wno-unused-parameter
+CFLAGS.vsprintf_chk.c+= -Wno-unused-parameter
+
# Sources common to both syscall interfaces:
-SRCS+= stack_protector.c \
+SRCS+= libc_stack_protector.c \
stack_protector_compat.c
SYM_MAPS+= ${LIBC_SRCTOP}/secure/Symbol.map
diff --git a/lib/libc/secure/Symbol.map b/lib/libc/secure/Symbol.map
index 4f9f34844131..df0a2d1ac93d 100644
--- a/lib/libc/secure/Symbol.map
+++ b/lib/libc/secure/Symbol.map
@@ -1,8 +1,25 @@
-/*
- */
-
FBSD_1.0 {
__chk_fail;
__stack_chk_fail;
__stack_chk_guard;
};
+
+FBSD_1.8 {
+ __fgets_chk;
+ __memcpy_chk;
+ __memmove_chk;
+ __mempcpy_chk;
+ __memset_chk;
+ __snprintf_chk;
+ __sprintf_chk;
+ __stpcpy_chk;
+ __stpncpy_chk;
+ __strcat_chk;
+ __strcpy_chk;
+ __strlcat_chk;
+ __strncat_chk;
+ __strlcpy_chk;
+ __strncpy_chk;
+ __vsnprintf_chk;
+ __vsprintf_chk;
+};
diff --git a/lib/libc/secure/fgets_chk.c b/lib/libc/secure/fgets_chk.c
new file mode 100644
index 000000000000..72aa1d816ce1
--- /dev/null
+++ b/lib/libc/secure/fgets_chk.c
@@ -0,0 +1,54 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: fgets_chk.c,v 1.6 2009/02/05 05:41:51 lukem Exp $");
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <ssp/stdio.h>
+#include <ssp/string.h>
+#undef fgets
+
+char *
+__fgets_chk(char * __restrict buf, int len, size_t slen, FILE *fp)
+{
+ if (slen >= (size_t)INT_MAX)
+ return (fgets(buf, len, fp));
+
+ if (len >= 0 && (size_t)len > slen)
+ __chk_fail();
+
+ return (fgets(buf, len, fp));
+}
diff --git a/lib/libc/secure/libc_stack_protector.c b/lib/libc/secure/libc_stack_protector.c
new file mode 100644
index 000000000000..28673caa3866
--- /dev/null
+++ b/lib/libc/secure/libc_stack_protector.c
@@ -0,0 +1,137 @@
+/* $NetBSD: stack_protector.c,v 1.4 2006/11/22 17:23:25 christos Exp $ */
+/* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */
+/*
+ * Copyright (c) 2002 Hiroaki Etoh, Federico G. Schwindt, and Miodrag Vallat.
+ * 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 AUTHORS ``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 AUTHORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <errno.h>
+#include <link.h>
+#include <signal.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include "libc_private.h"
+
+/*
+ * We give __guard_setup a defined priority early on so that statically linked
+ * applications have a defined priority at which __stack_chk_guard will be
+ * getting initialized. This will not matter to most applications, because
+ * they're either not usually statically linked or they simply don't do things
+ * in constructors that would be adversely affected by their positioning with
+ * respect to this initialization.
+ */
+static void __guard_setup(void)
+ __attribute__((__constructor__ (200), __used__));
+
+extern long __stack_chk_guard[8];
+extern int __sysctl(const int *name, u_int namelen, void *oldp,
+ size_t *oldlenp, void *newp, size_t newlen);
+
+long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+static void __fail(const char *) __dead2;
+void __stack_chk_fail(void) __dead2;
+void __chk_fail(void) __dead2;
+
+/*LINTED used*/
+static void
+__guard_setup(void)
+{
+ static const int mib[2] = { CTL_KERN, KERN_ARND };
+ volatile long tmp_stack_chk_guard[nitems(__stack_chk_guard)];
+ size_t idx, len;
+ int error;
+
+ if (__stack_chk_guard[0] != 0)
+ return;
+ /*
+ * Avoid using functions which might have stack protection
+ * enabled, to update the __stack_chk_guard. First fetch the
+ * data into a temporal array, then do manual volatile copy to
+ * not allow optimizer to call memcpy() behind us.
+ */
+ error = _elf_aux_info(AT_CANARY,
+ __DEQUALIFY(void *, tmp_stack_chk_guard),
+ sizeof(tmp_stack_chk_guard));
+ if (error == 0 && tmp_stack_chk_guard[0] != 0) {
+ for (idx = 0; idx < nitems(__stack_chk_guard); idx++) {
+ __stack_chk_guard[idx] = tmp_stack_chk_guard[idx];
+ tmp_stack_chk_guard[idx] = 0;
+ }
+ return;
+ }
+
+ len = sizeof(__stack_chk_guard);
+ if (__sysctl(mib, nitems(mib), __stack_chk_guard, &len, NULL, 0) ==
+ -1 || len != sizeof(__stack_chk_guard)) {
+ /* If sysctl was unsuccessful, use the "terminator canary". */
+ ((unsigned char *)(void *)__stack_chk_guard)[0] = 0;
+ ((unsigned char *)(void *)__stack_chk_guard)[1] = 0;
+ ((unsigned char *)(void *)__stack_chk_guard)[2] = '\n';
+ ((unsigned char *)(void *)__stack_chk_guard)[3] = 255;
+ }
+}
+
+/*ARGSUSED*/
+static void
+__fail(const char *msg)
+{
+ struct sigaction sa;
+ sigset_t mask;
+
+ /* Immediately block all signal handlers from running code */
+ (void)sigfillset(&mask);
+ (void)sigdelset(&mask, SIGABRT);
+ (void)sigprocmask(SIG_BLOCK, &mask, NULL);
+
+ /* This may fail on a chroot jail... */
+ syslog(LOG_CRIT, "%s", msg);
+
+ (void)memset(&sa, 0, sizeof(sa));
+ (void)sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ (void)sigaction(SIGABRT, &sa, NULL);
+ (void)kill(getpid(), SIGABRT);
+ _exit(127);
+}
+
+void
+__stack_chk_fail(void)
+{
+ __fail("stack overflow detected; terminated");
+}
+
+void
+__chk_fail(void)
+{
+ __fail("buffer overflow detected; terminated");
+}
+
+#ifndef PIC
+__weak_reference(__stack_chk_fail, __stack_chk_fail_local);
+#endif
diff --git a/lib/libc/secure/memcpy_chk.c b/lib/libc/secure/memcpy_chk.c
new file mode 100644
index 000000000000..ac995d00ee8c
--- /dev/null
+++ b/lib/libc/secure/memcpy_chk.c
@@ -0,0 +1,51 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef memcpy
+
+void *
+__memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,
+ size_t slen)
+{
+ if (len > slen)
+ __chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
+ return (memcpy(dst, src, len));
+}
diff --git a/lib/libc/secure/memmove_chk.c b/lib/libc/secure/memmove_chk.c
new file mode 100644
index 000000000000..07f965d608fc
--- /dev/null
+++ b/lib/libc/secure/memmove_chk.c
@@ -0,0 +1,47 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: memmove_chk.c,v 1.6 2020/09/05 13:37:59 mrg Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef memmove
+
+void *
+__memmove_chk(void *dst, const void *src, size_t len,
+ size_t slen)
+{
+ if (len > slen)
+ __chk_fail();
+ return (memmove(dst, src, len));
+}
diff --git a/lib/libc/secure/mempcpy_chk.c b/lib/libc/secure/mempcpy_chk.c
new file mode 100644
index 000000000000..ca4ae150bc94
--- /dev/null
+++ b/lib/libc/secure/mempcpy_chk.c
@@ -0,0 +1,49 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef mempcpy
+
+void *
+__mempcpy_chk(void * __restrict dst, const void * __restrict src, size_t len,
+ size_t slen)
+{
+ if (len > slen)
+ __chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
+ return (mempcpy(dst, src, len));
+}
diff --git a/lib/libc/secure/memset_chk.c b/lib/libc/secure/memset_chk.c
new file mode 100644
index 000000000000..f337be98b46d
--- /dev/null
+++ b/lib/libc/secure/memset_chk.c
@@ -0,0 +1,46 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef memset
+
+void *
+__memset_chk(void * __restrict dst, int val, size_t len, size_t slen)
+{
+ if (len > slen)
+ __chk_fail();
+ return (memset(dst, val, len));
+}
diff --git a/lib/libc/secure/snprintf_chk.c b/lib/libc/secure/snprintf_chk.c
new file mode 100644
index 000000000000..52ef874ede5b
--- /dev/null
+++ b/lib/libc/secure/snprintf_chk.c
@@ -0,0 +1,56 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: snprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $");
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <ssp/stdio.h>
+#undef vsnprintf
+
+int
+__snprintf_chk(char * __restrict buf, size_t len, int flags, size_t slen,
+ const char * __restrict fmt, ...)
+{
+ va_list ap;
+ int rv;
+
+ if (len > slen)
+ __chk_fail();
+
+ va_start(ap, fmt);
+ rv = vsnprintf(buf, len, fmt, ap);
+ va_end(ap);
+
+ return (rv);
+}
diff --git a/lib/libc/secure/sprintf_chk.c b/lib/libc/secure/sprintf_chk.c
new file mode 100644
index 000000000000..d4c42ccba3ce
--- /dev/null
+++ b/lib/libc/secure/sprintf_chk.c
@@ -0,0 +1,61 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: sprintf_chk.c,v 1.6 2009/02/05 05:40:36 lukem Exp $");
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <ssp/stdio.h>
+#undef vsnprintf
+#undef vsprintf
+
+int
+__sprintf_chk(char * __restrict buf, int flags, size_t slen,
+ const char * __restrict fmt, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, fmt);
+ if (slen > (size_t)INT_MAX)
+ rv = vsprintf(buf, fmt, ap);
+ else {
+ if ((rv = vsnprintf(buf, slen, fmt, ap)) >= 0 &&
+ (size_t)rv >= slen)
+ __chk_fail();
+ }
+ va_end(ap);
+
+ return (rv);
+}
diff --git a/lib/libc/secure/stack_protector.c b/lib/libc/secure/stack_protector.c
deleted file mode 100644
index 15c9e7fcc029..000000000000
--- a/lib/libc/secure/stack_protector.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* $NetBSD: stack_protector.c,v 1.4 2006/11/22 17:23:25 christos Exp $ */
-/* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */
-/*
- * Copyright (c) 2002 Hiroaki Etoh, Federico G. Schwindt, and Miodrag Vallat.
- * 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 AUTHORS ``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 AUTHORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <errno.h>
-#include <link.h>
-#include <signal.h>
-#include <string.h>
-#include <syslog.h>
-#include <unistd.h>
-#include "libc_private.h"
-
-/*
- * We give __guard_setup a defined priority early on so that statically linked
- * applications have a defined priority at which __stack_chk_guard will be
- * getting initialized. This will not matter to most applications, because
- * they're either not usually statically linked or they simply don't do things
- * in constructors that would be adversely affected by their positioning with
- * respect to this initialization.
- */
-static void __guard_setup(void)
- __attribute__((__constructor__ (200), __used__));
-
-extern long __stack_chk_guard[8];
-extern int __sysctl(const int *name, u_int namelen, void *oldp,
- size_t *oldlenp, void *newp, size_t newlen);
-
-long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-static void __fail(const char *) __dead2;
-void __stack_chk_fail(void) __dead2;
-void __chk_fail(void) __dead2;
-
-/*LINTED used*/
-static void
-__guard_setup(void)
-{
- static const int mib[2] = { CTL_KERN, KERN_ARND };
- volatile long tmp_stack_chk_guard[nitems(__stack_chk_guard)];
- size_t idx, len;
- int error;
-
- if (__stack_chk_guard[0] != 0)
- return;
- /*
- * Avoid using functions which might have stack protection
- * enabled, to update the __stack_chk_guard. First fetch the
- * data into a temporal array, then do manual volatile copy to
- * not allow optimizer to call memcpy() behind us.
- */
- error = _elf_aux_info(AT_CANARY,
- __DEQUALIFY(void *, tmp_stack_chk_guard),
- sizeof(tmp_stack_chk_guard));
- if (error == 0 && tmp_stack_chk_guard[0] != 0) {
- for (idx = 0; idx < nitems(__stack_chk_guard); idx++) {
- __stack_chk_guard[idx] = tmp_stack_chk_guard[idx];
- tmp_stack_chk_guard[idx] = 0;
- }
- return;
- }
-
- len = sizeof(__stack_chk_guard);
- if (__sysctl(mib, nitems(mib), __stack_chk_guard, &len, NULL, 0) ==
- -1 || len != sizeof(__stack_chk_guard)) {
- /* If sysctl was unsuccessful, use the "terminator canary". */
- ((unsigned char *)(void *)__stack_chk_guard)[0] = 0;
- ((unsigned char *)(void *)__stack_chk_guard)[1] = 0;
- ((unsigned char *)(void *)__stack_chk_guard)[2] = '\n';
- ((unsigned char *)(void *)__stack_chk_guard)[3] = 255;
- }
-}
-
-/*ARGSUSED*/
-static void
-__fail(const char *msg)
-{
- struct sigaction sa;
- sigset_t mask;
-
- /* Immediately block all signal handlers from running code */
- (void)sigfillset(&mask);
- (void)sigdelset(&mask, SIGABRT);
- (void)sigprocmask(SIG_BLOCK, &mask, NULL);
-
- /* This may fail on a chroot jail... */
- syslog(LOG_CRIT, "%s", msg);
-
- (void)memset(&sa, 0, sizeof(sa));
- (void)sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- (void)sigaction(SIGABRT, &sa, NULL);
- (void)kill(getpid(), SIGABRT);
- _exit(127);
-}
-
-void
-__stack_chk_fail(void)
-{
- __fail("stack overflow detected; terminated");
-}
-
-void
-__chk_fail(void)
-{
- __fail("buffer overflow detected; terminated");
-}
-
-#ifndef PIC
-__weak_reference(__stack_chk_fail, __stack_chk_fail_local);
-#endif
diff --git a/lib/libc/secure/stpcpy_chk.c b/lib/libc/secure/stpcpy_chk.c
new file mode 100644
index 000000000000..fd4849099675
--- /dev/null
+++ b/lib/libc/secure/stpcpy_chk.c
@@ -0,0 +1,53 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2013 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: stpcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef memcpy
+
+char *
+__stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen)
+{
+ size_t len = strlen(src);
+
+ if (len >= slen)
+ __chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
+ (void)memcpy(dst, src, len + 1);
+ return (dst + len);
+}
diff --git a/lib/libc/secure/stpncpy_chk.c b/lib/libc/secure/stpncpy_chk.c
new file mode 100644
index 000000000000..d76f0eb62fcd
--- /dev/null
+++ b/lib/libc/secure/stpncpy_chk.c
@@ -0,0 +1,51 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2013 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: stpncpy_chk.c,v 1.3 2015/05/09 15:42:21 christos Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef stpncpy
+
+char *
+__stpncpy_chk(char * __restrict dst, const char * __restrict src, size_t len,
+ size_t slen)
+{
+ if (len > slen)
+ __chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
+ return (stpncpy(dst, src, len));
+}
diff --git a/lib/libc/secure/strcat_chk.c b/lib/libc/secure/strcat_chk.c
new file mode 100644
index 000000000000..202d084fddc9
--- /dev/null
+++ b/lib/libc/secure/strcat_chk.c
@@ -0,0 +1,60 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: strcat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+
+char *
+__strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen)
+{
+ char *d;
+
+ for (d = dst; *d; d++) {
+ if (slen-- == 0)
+ __chk_fail();
+ }
+
+ while (*src) {
+ if (slen-- == 0)
+ __chk_fail();
+ *d++ = *src++;
+ }
+
+ if (slen-- == 0)
+ __chk_fail();
+
+ *d = '\0';
+ return (dst);
+}
diff --git a/lib/libc/secure/strcpy_chk.c b/lib/libc/secure/strcpy_chk.c
new file mode 100644
index 000000000000..14403bd74469
--- /dev/null
+++ b/lib/libc/secure/strcpy_chk.c
@@ -0,0 +1,52 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: strcpy_chk.c,v 1.8 2015/05/09 15:42:21 christos Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef memcpy
+
+char *
+__strcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen)
+{
+ size_t len = strlen(src) + 1;
+
+ if (len > slen)
+ __chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
+ return (memcpy(dst, src, len));
+}
diff --git a/lib/libc/secure/strlcat_chk.c b/lib/libc/secure/strlcat_chk.c
new file mode 100644
index 000000000000..26448bd37af0
--- /dev/null
+++ b/lib/libc/secure/strlcat_chk.c
@@ -0,0 +1,70 @@
+/* $OpenBSD: strlcat.c,v 1.15 2015/03/02 21:41:08 millert Exp $ */
+
+/*
+ * SPDX-License-Identifier: ISC
+ *
+ * Copyright (c) 1998, 2015 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include <ssp/string.h>
+
+/*
+ * Appends src to string dst of size dsize (unlike strncat, dsize is the
+ * full size of dst, not space left). At most dsize-1 characters
+ * will be copied. Always NUL terminates (unless dsize <= strlen(dst)).
+ * Returns strlen(src) + MIN(dsize, strlen(initial dst)).
+ * If retval >= dsize, truncation occurred.
+ */
+size_t
+__strlcat_chk(char * __restrict dst, const char * __restrict src, size_t dsize,
+ size_t dbufsize)
+{
+ const char *odst = dst;
+ const char *osrc = src;
+ size_t n = dsize;
+ size_t dlen;
+
+ if (dsize > dbufsize)
+ __chk_fail();
+
+ /* Find the end of dst and adjust bytes left but don't go past end. */
+ while (n-- != 0 && *dst != '\0') {
+ dst++;
+ }
+
+ dlen = dst - odst;
+ n = dsize - dlen;
+
+ if (n-- == 0)
+ return (dlen + strlen(src));
+ while (*src != '\0') {
+ if (n != 0) {
+ if (dbufsize-- == 0)
+ __chk_fail();
+ *dst++ = *src;
+ n--;
+ }
+
+ src++;
+ }
+
+ if (dbufsize-- == 0)
+ __chk_fail();
+ *dst = '\0';
+ return (dlen + (src - osrc)); /* count does not include NUL */
+}
diff --git a/lib/libc/secure/strlcpy_chk.c b/lib/libc/secure/strlcpy_chk.c
new file mode 100644
index 000000000000..8c11ee3e07eb
--- /dev/null
+++ b/lib/libc/secure/strlcpy_chk.c
@@ -0,0 +1,43 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024, Klara, 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.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+#include <ssp/string.h>
+#undef strlcpy
+
+size_t
+__strlcpy_chk(char * __restrict dst, const char * __restrict src, size_t dsize,
+ size_t dbufsize)
+{
+
+ if (dsize > dbufsize)
+ __chk_fail();
+
+ return (strlcpy(dst, src, dsize));
+}
diff --git a/lib/libc/secure/strncat_chk.c b/lib/libc/secure/strncat_chk.c
new file mode 100644
index 000000000000..94ef34675386
--- /dev/null
+++ b/lib/libc/secure/strncat_chk.c
@@ -0,0 +1,70 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: strncat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $");
+
+#include <stdio.h>
+#include <string.h>
+
+#include <ssp/string.h>
+
+char *
+__strncat_chk(char * __restrict dst, const char * __restrict src, size_t len,
+ size_t slen)
+{
+ char *d;
+
+ if (len == 0)
+ return (dst);
+
+ if (len > slen)
+ __chk_fail();
+
+ for (d = dst; *d; d++) {
+ if (slen-- == 0)
+ __chk_fail();
+ }
+
+ do {
+ if ((*d = *src++) == '\0')
+ break;
+ if (slen-- == 0)
+ __chk_fail();
+ d++;
+ } while (--len != 0);
+
+ if (slen-- == 0)
+ __chk_fail();
+
+ *d = '\0';
+ return (dst);
+}
diff --git a/lib/libc/secure/strncpy_chk.c b/lib/libc/secure/strncpy_chk.c
new file mode 100644
index 000000000000..c8d411638862
--- /dev/null
+++ b/lib/libc/secure/strncpy_chk.c
@@ -0,0 +1,51 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: strncpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $");
+
+#include <string.h>
+
+#include <ssp/string.h>
+#undef strncpy
+
+char *
+__strncpy_chk(char * __restrict dst, const char * __restrict src, size_t len,
+ size_t slen)
+{
+ if (len > slen)
+ __chk_fail();
+
+ if (__ssp_overlap(src, dst, len))
+ __chk_fail();
+
+ return (strncpy(dst, src, len));
+}
diff --git a/lib/libc/secure/vsnprintf_chk.c b/lib/libc/secure/vsnprintf_chk.c
new file mode 100644
index 000000000000..c48e7bf929b1
--- /dev/null
+++ b/lib/libc/secure/vsnprintf_chk.c
@@ -0,0 +1,49 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: vsnprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $");
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <ssp/stdio.h>
+#undef vsnprintf
+
+int
+__vsnprintf_chk(char * __restrict buf, size_t len, int flags, size_t slen,
+ const char * __restrict fmt, va_list ap)
+{
+ if (len > slen)
+ __chk_fail();
+
+ return (vsnprintf(buf, len, fmt, ap));
+}
diff --git a/lib/libc/secure/vsprintf_chk.c b/lib/libc/secure/vsprintf_chk.c
new file mode 100644
index 000000000000..6855feb92f15
--- /dev/null
+++ b/lib/libc/secure/vsprintf_chk.c
@@ -0,0 +1,58 @@
+/*-
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2006 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: vsprintf_chk.c,v 1.6 2009/02/05 05:39:38 lukem Exp $");
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <ssp/stdio.h>
+#undef vsprintf
+#undef vsnprintf
+
+int
+__vsprintf_chk(char * __restrict buf, int flags, size_t slen,
+ const char * __restrict fmt, va_list ap)
+{
+ int rv;
+
+ if (slen > (size_t)INT_MAX)
+ rv = vsprintf(buf, fmt, ap);
+ else {
+ if ((rv = vsnprintf(buf, slen, fmt, ap)) >= 0 &&
+ (size_t)rv >= slen)
+ __chk_fail();
+ }
+
+ return (rv);
+}
diff --git a/lib/libc/softfloat/Symbol.map b/lib/libc/softfloat/Symbol.map
index ee6d1b0eac52..d412eb417765 100644
--- a/lib/libc/softfloat/Symbol.map
+++ b/lib/libc/softfloat/Symbol.map
@@ -1,18 +1,9 @@
-/*
- */
-
FBSD_1.0 {
- _fpgetmask;
fpgetmask;
- _fpgetround;
fpgetround;
- _fpgetsticky;
fpgetsticky;
- _fpsetmask;
fpsetmask;
- _fpsetround;
fpsetround;
- _fpsetsticky;
fpsetsticky;
};
diff --git a/lib/libc/softfloat/bits32/softfloat.c b/lib/libc/softfloat/bits32/softfloat.c
index 2968786133cd..91aa190695af 100644
--- a/lib/libc/softfloat/bits32/softfloat.c
+++ b/lib/libc/softfloat/bits32/softfloat.c
@@ -51,7 +51,6 @@ this code that are retained.
===============================================================================
*/
-#include <sys/cdefs.h>
#ifdef SOFTFLOAT_FOR_GCC
#include "softfloat-for-gcc.h"
#endif
diff --git a/lib/libc/softfloat/bits64/softfloat.c b/lib/libc/softfloat/bits64/softfloat.c
index 6295a787cb6b..b072588b33fb 100644
--- a/lib/libc/softfloat/bits64/softfloat.c
+++ b/lib/libc/softfloat/bits64/softfloat.c
@@ -44,7 +44,6 @@ this code that are retained.
===============================================================================
*/
-#include <sys/cdefs.h>
#ifdef SOFTFLOAT_FOR_GCC
#include "softfloat-for-gcc.h"
#endif
diff --git a/lib/libc/softfloat/eqdf2.c b/lib/libc/softfloat/eqdf2.c
index dc4b2d24f285..e642c467aa4a 100644
--- a/lib/libc/softfloat/eqdf2.c
+++ b/lib/libc/softfloat/eqdf2.c
@@ -4,7 +4,6 @@
* Written by Ben Harris, 2000. This file is in the Public Domain.
*/
-#include <sys/cdefs.h>
#include "softfloat-for-gcc.h"
#include "milieu.h"
#include "softfloat.h"
diff --git a/lib/libc/softfloat/eqsf2.c b/lib/libc/softfloat/eqsf2.c
index bebb4d1f76a6..866db81bc5ab 100644
--- a/lib/libc/softfloat/eqsf2.c
+++ b/lib/libc/softfloat/eqsf2.c
@@ -4,7 +4,6 @@
* Written by Ben Harris, 2000. This file is in the Public Domain.
*/
-#include <sys/cdefs.h>
#include "softfloat-for-gcc.h"
#include "milieu.h"
#include "softfloat.h"
diff --git a/lib/libc/softfloat/eqtf2.c b/lib/libc/softfloat/eqtf2.c
index 8852adafa2ff..b7ae12d265b4 100644
--- a/lib/libc/softfloat/eqtf2.c
+++ b/lib/libc/softfloat/eqtf2.c
@@ -4,7 +4,6 @@
* Written by Matt Thomas, 2011. This file is in the Public Domain.
*/
-#include <sys/cdefs.h>
#include "softfloat-for-gcc.h"
#include "milieu.h"
#include "softfloat.h"
diff --git a/lib/libc/softfloat/fpgetmask.c b/lib/libc/softfloat/fpgetmask.c
index 78177544538e..86cf89020668 100644
--- a/lib/libc/softfloat/fpgetmask.c
+++ b/lib/libc/softfloat/fpgetmask.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ieeefp.h>
@@ -41,13 +40,8 @@
#include "milieu.h"
#include "softfloat.h"
-#ifdef __weak_alias
-__weak_alias(fpgetmask,_fpgetmask)
-#endif
-
fp_except
fpgetmask(void)
{
-
return float_exception_mask;
}
diff --git a/lib/libc/softfloat/fpgetround.c b/lib/libc/softfloat/fpgetround.c
index e098ef46c122..2c060d86f5ae 100644
--- a/lib/libc/softfloat/fpgetround.c
+++ b/lib/libc/softfloat/fpgetround.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ieeefp.h>
diff --git a/lib/libc/softfloat/fpgetsticky.c b/lib/libc/softfloat/fpgetsticky.c
index 0caff5b0578f..f42c348784e1 100644
--- a/lib/libc/softfloat/fpgetsticky.c
+++ b/lib/libc/softfloat/fpgetsticky.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ieeefp.h>
@@ -41,13 +40,8 @@
#include "milieu.h"
#include "softfloat.h"
-#ifdef __weak_alias
-__weak_alias(fpgetsticky,_fpgetsticky)
-#endif
-
fp_except
fpgetsticky(void)
{
-
return float_exception_flags;
}
diff --git a/lib/libc/softfloat/fpsetmask.c b/lib/libc/softfloat/fpsetmask.c
index 90f457563513..b65a1e8de350 100644
--- a/lib/libc/softfloat/fpsetmask.c
+++ b/lib/libc/softfloat/fpsetmask.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ieeefp.h>
diff --git a/lib/libc/softfloat/fpsetround.c b/lib/libc/softfloat/fpsetround.c
index 37fa7064ce84..f48a683bf6d8 100644
--- a/lib/libc/softfloat/fpsetround.c
+++ b/lib/libc/softfloat/fpsetround.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ieeefp.h>
diff --git a/lib/libc/softfloat/fpsetsticky.c b/lib/libc/softfloat/fpsetsticky.c
index 3916161c8e23..2a056c032645 100644
--- a/lib/libc/softfloat/fpsetsticky.c
+++ b/lib/libc/softfloat/fpsetsticky.c
@@ -31,7 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ieeefp.h>
diff --git a/lib/libc/softfloat/gedf2.c b/lib/libc/softfloat/gedf2.c
index 75769823991b..2d82ef394b54 100644
--- a/lib/libc/softfloat/gedf2.c
+++ b/lib/libc/softfloat/gedf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __gedf2(float64, float64);
flag
diff --git a/lib/libc/softfloat/gesf2.c b/lib/libc/softfloat/gesf2.c
index 1ec47ae32ea6..8822ebecd983 100644
--- a/lib/libc/softfloat/gesf2.c
+++ b/lib/libc/softfloat/gesf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __gesf2(float32, float32);
flag
diff --git a/lib/libc/softfloat/getf2.c b/lib/libc/softfloat/getf2.c
index ac4665eedb29..168cd00e2003 100644
--- a/lib/libc/softfloat/getf2.c
+++ b/lib/libc/softfloat/getf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOAT128
flag __getf2(float128, float128);
diff --git a/lib/libc/softfloat/gexf2.c b/lib/libc/softfloat/gexf2.c
index 51f98f2ae03a..291b1d040409 100644
--- a/lib/libc/softfloat/gexf2.c
+++ b/lib/libc/softfloat/gexf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOATX80
flag __gexf2(floatx80, floatx80);
diff --git a/lib/libc/softfloat/gtdf2.c b/lib/libc/softfloat/gtdf2.c
index fc6d2fd06a34..c2a7d5d7264a 100644
--- a/lib/libc/softfloat/gtdf2.c
+++ b/lib/libc/softfloat/gtdf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __gtdf2(float64, float64);
flag
diff --git a/lib/libc/softfloat/gtsf2.c b/lib/libc/softfloat/gtsf2.c
index ae8d7c209106..48988084f753 100644
--- a/lib/libc/softfloat/gtsf2.c
+++ b/lib/libc/softfloat/gtsf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __gtsf2(float32, float32);
flag
diff --git a/lib/libc/softfloat/gttf2.c b/lib/libc/softfloat/gttf2.c
index 76684e013e35..22ebae560aaa 100644
--- a/lib/libc/softfloat/gttf2.c
+++ b/lib/libc/softfloat/gttf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOAT128
flag __gttf2(float128, float128);
diff --git a/lib/libc/softfloat/gtxf2.c b/lib/libc/softfloat/gtxf2.c
index 284526f0c410..ea883d1fb848 100644
--- a/lib/libc/softfloat/gtxf2.c
+++ b/lib/libc/softfloat/gtxf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOATX80
flag __gtxf2(floatx80, floatx80);
diff --git a/lib/libc/softfloat/ledf2.c b/lib/libc/softfloat/ledf2.c
index 689c7d70c1ca..3be7f5e5fa75 100644
--- a/lib/libc/softfloat/ledf2.c
+++ b/lib/libc/softfloat/ledf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __ledf2(float64, float64);
flag
diff --git a/lib/libc/softfloat/lesf2.c b/lib/libc/softfloat/lesf2.c
index 98ba0722525a..e8d60d5733e0 100644
--- a/lib/libc/softfloat/lesf2.c
+++ b/lib/libc/softfloat/lesf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __lesf2(float32, float32);
flag
diff --git a/lib/libc/softfloat/letf2.c b/lib/libc/softfloat/letf2.c
index d5dbd45a106b..a5a25ebe0848 100644
--- a/lib/libc/softfloat/letf2.c
+++ b/lib/libc/softfloat/letf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOAT128
flag __letf2(float128, float128);
diff --git a/lib/libc/softfloat/ltdf2.c b/lib/libc/softfloat/ltdf2.c
index 8c5342a3c6ff..fa58b55f24f5 100644
--- a/lib/libc/softfloat/ltdf2.c
+++ b/lib/libc/softfloat/ltdf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __ltdf2(float64, float64);
flag
diff --git a/lib/libc/softfloat/ltsf2.c b/lib/libc/softfloat/ltsf2.c
index 9eb9e990bc63..e19b2f4328cf 100644
--- a/lib/libc/softfloat/ltsf2.c
+++ b/lib/libc/softfloat/ltsf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __ltsf2(float32, float32);
flag
diff --git a/lib/libc/softfloat/lttf2.c b/lib/libc/softfloat/lttf2.c
index ad8e4830d904..ce99f6cfee34 100644
--- a/lib/libc/softfloat/lttf2.c
+++ b/lib/libc/softfloat/lttf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOAT128
flag __lttf2(float128, float128);
diff --git a/lib/libc/softfloat/nedf2.c b/lib/libc/softfloat/nedf2.c
index 7c1e49643d72..a7af22a9a9e9 100644
--- a/lib/libc/softfloat/nedf2.c
+++ b/lib/libc/softfloat/nedf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __nedf2(float64, float64);
flag
diff --git a/lib/libc/softfloat/negdf2.c b/lib/libc/softfloat/negdf2.c
index 27dfdd5ee688..e42d26d2287b 100644
--- a/lib/libc/softfloat/negdf2.c
+++ b/lib/libc/softfloat/negdf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
float64 __negdf2(float64);
float64
diff --git a/lib/libc/softfloat/negsf2.c b/lib/libc/softfloat/negsf2.c
index 9b4a269132e1..e4f33f3a8422 100644
--- a/lib/libc/softfloat/negsf2.c
+++ b/lib/libc/softfloat/negsf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
float32 __negsf2(float32);
float32
diff --git a/lib/libc/softfloat/negtf2.c b/lib/libc/softfloat/negtf2.c
index d8cb6a0dc4bc..bb757a3d0a3e 100644
--- a/lib/libc/softfloat/negtf2.c
+++ b/lib/libc/softfloat/negtf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOAT128
float128 __negtf2(float128);
diff --git a/lib/libc/softfloat/negxf2.c b/lib/libc/softfloat/negxf2.c
index fd906c830e28..acc59f0755c8 100644
--- a/lib/libc/softfloat/negxf2.c
+++ b/lib/libc/softfloat/negxf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOATX80
floatx80 __negxf2(floatx80);
diff --git a/lib/libc/softfloat/nesf2.c b/lib/libc/softfloat/nesf2.c
index d7c580c2ff8c..8f2d93681b61 100644
--- a/lib/libc/softfloat/nesf2.c
+++ b/lib/libc/softfloat/nesf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __nesf2(float32, float32);
flag
diff --git a/lib/libc/softfloat/netf2.c b/lib/libc/softfloat/netf2.c
index c54b22b8bf22..17b54da01dd9 100644
--- a/lib/libc/softfloat/netf2.c
+++ b/lib/libc/softfloat/netf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOAT128
flag __netf2(float128, float128);
diff --git a/lib/libc/softfloat/nexf2.c b/lib/libc/softfloat/nexf2.c
index 6d75d164d9e2..e48895d3eca2 100644
--- a/lib/libc/softfloat/nexf2.c
+++ b/lib/libc/softfloat/nexf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
#ifdef FLOATX80
flag __nexf2(floatx80, floatx80);
diff --git a/lib/libc/softfloat/timesoftfloat.c b/lib/libc/softfloat/timesoftfloat.c
index 4abff11e13e6..fc6d196f74ab 100644
--- a/lib/libc/softfloat/timesoftfloat.c
+++ b/lib/libc/softfloat/timesoftfloat.c
@@ -30,7 +30,6 @@ this code that are retained.
===============================================================================
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
diff --git a/lib/libc/softfloat/unorddf2.c b/lib/libc/softfloat/unorddf2.c
index 44e03792b3f9..7447b6a83de0 100644
--- a/lib/libc/softfloat/unorddf2.c
+++ b/lib/libc/softfloat/unorddf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __unorddf2(float64, float64);
flag
diff --git a/lib/libc/softfloat/unordsf2.c b/lib/libc/softfloat/unordsf2.c
index 3b73ac20ca80..9cc202f7e009 100644
--- a/lib/libc/softfloat/unordsf2.c
+++ b/lib/libc/softfloat/unordsf2.c
@@ -8,7 +8,6 @@
#include "milieu.h"
#include "softfloat.h"
-#include <sys/cdefs.h>
flag __unordsf2(float32, float32);
flag
diff --git a/lib/libc/stdio/Makefile.inc b/lib/libc/stdio/Makefile.inc
index 0fc0a6bfd68c..a3d76c0ea795 100644
--- a/lib/libc/stdio/Makefile.inc
+++ b/lib/libc/stdio/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.3 (Berkeley) 4/17/94
-
# stdio sources
.PATH: ${LIBC_SRCTOP}/stdio
@@ -42,50 +40,102 @@ MAN+= fclose.3 ferror.3 fflush.3 fgetln.3 fgets.3 fgetwln.3 fgetws.3 \
stdio.3 tmpnam.3 \
ungetc.3 ungetwc.3 wprintf.3 wscanf.3
-MLINKS+=fclose.3 fcloseall.3 fclose.3 fdclose.3
+MLINKS+=fclose.3 fcloseall.3 \
+ fclose.3 fdclose.3
MLINKS+=ferror.3 ferror_unlocked.3 \
- ferror.3 clearerr.3 ferror.3 clearerr_unlocked.3 \
- ferror.3 feof.3 ferror.3 feof_unlocked.3 \
- ferror.3 fileno.3 ferror.3 fileno_unlocked.3
+ ferror.3 clearerr.3 \
+ ferror.3 clearerr_unlocked.3 \
+ ferror.3 feof.3 \
+ ferror.3 feof_unlocked.3 \
+ ferror.3 fileno.3 \
+ ferror.3 fileno_unlocked.3
MLINKS+=fflush.3 fflush_unlocked.3 \
fflush.3 fpurge.3
MLINKS+=fgets.3 gets.3
MLINKS+=fgets.3 gets_s.3
-MLINKS+=flockfile.3 ftrylockfile.3 flockfile.3 funlockfile.3
-MLINKS+=fopen.3 fdopen.3 fopen.3 freopen.3 fopen.3 fmemopen.3
+MLINKS+=flockfile.3 ftrylockfile.3 \
+ flockfile.3 funlockfile.3
+MLINKS+=fopen.3 fdopen.3 \
+ fopen.3 freopen.3 \
+ fopen.3 fmemopen.3
MLINKS+=fputs.3 fputs_unlocked.3 \
fputs.3 puts.3
MLINKS+=fread.3 fread_unlocked.3 \
fread.3 fwrite.3 \
fread.3 fwrite_unlocked.3
-MLINKS+=fseek.3 fgetpos.3 fseek.3 fseeko.3 fseek.3 fsetpos.3 fseek.3 ftell.3 \
- fseek.3 ftello.3 fseek.3 rewind.3
-MLINKS+=funopen.3 fropen.3 funopen.3 fwopen.3
-MLINKS+=getc.3 fgetc.3 getc.3 getc_unlocked.3 getc.3 getchar.3 \
- getc.3 getchar_unlocked.3 getc.3 getw.3
+MLINKS+=fseek.3 fgetpos.3 \
+ fseek.3 fseeko.3 \
+ fseek.3 fsetpos.3 \
+ fseek.3 ftell.3 \
+ fseek.3 ftello.3 \
+ fseek.3 rewind.3
+MLINKS+=funopen.3 fropen.3 \
+ funopen.3 fwopen.3
+MLINKS+=getc.3 fgetc.3 \
+ getc.3 getc_unlocked.3 \
+ getc.3 getchar.3 \
+ getc.3 getchar_unlocked.3 \
+ getc.3 getw.3
MLINKS+=getline.3 getdelim.3
-MLINKS+=getwc.3 fgetwc.3 getwc.3 getwchar.3
-MLINKS+=mktemp.3 mkdtemp.3 mktemp.3 mkstemp.3 mktemp.3 mkstemps.3 \
- mktemp.3 mkostemp.3 mktemp.3 mkostemps.3 mktemp.3 mkostempsat.3
+MLINKS+=getwc.3 fgetwc.3 \
+ getwc.3 getwchar.3
+MLINKS+=mktemp.3 mkdtemp.3 \
+ mktemp.3 mkstemp.3 \
+ mktemp.3 mkstemps.3 \
+ mktemp.3 mkostemp.3 \
+ mktemp.3 mkostemps.3 \
+ mktemp.3 mkostempsat.3
MLINKS+=open_memstream.3 open_wmemstream.3
-MLINKS+=printf.3 asprintf.3 printf.3 dprintf.3 printf.3 fprintf.3 \
- printf.3 snprintf.3 printf.3 sprintf.3 \
- printf.3 vasprintf.3 printf.3 vdprintf.3 \
- printf.3 vfprintf.3 printf.3 vprintf.3 printf.3 vsnprintf.3 \
+MLINKS+=printf.3 asprintf.3 \
+ printf.3 dprintf.3 \
+ printf.3 fprintf.3 \
+ printf.3 snprintf.3 \
+ printf.3 sprintf.3 \
+ printf.3 vasprintf.3 \
+ printf.3 vdprintf.3 \
+ printf.3 vfprintf.3 \
+ printf.3 vprintf.3 \
+ printf.3 vsnprintf.3 \
printf.3 vsprintf.3
-MLINKS+=printf_l.3 asprintf_l.3 printf_l.3 fprintf_l.3 printf_l.3 snprintf_l.3 \
- printf_l.3 sprintf_l.3 printf_l.3 vasprintf_l.3 printf_l.3 vfprintf_l.3 \
- printf_l.3 vprintf_l.3 printf_l.3 vsnprintf_l.3 printf_l.3 vsprintf_l.3
-MLINKS+=putc.3 fputc.3 putc.3 putc_unlocked.3 putc.3 putchar.3 \
- putc.3 putchar_unlocked.3 putc.3 putw.3
-MLINKS+=putwc.3 fputwc.3 putwc.3 putwchar.3
-MLINKS+=scanf.3 fscanf.3 scanf.3 sscanf.3 scanf.3 vfscanf.3 scanf.3 vscanf.3 \
+MLINKS+=printf_l.3 asprintf_l.3 \
+ printf_l.3 fprintf_l.3 \
+ printf_l.3 snprintf_l.3 \
+ printf_l.3 sprintf_l.3 \
+ printf_l.3 vasprintf_l.3 \
+ printf_l.3 vfprintf_l.3 \
+ printf_l.3 vprintf_l.3 \
+ printf_l.3 vsnprintf_l.3 \
+ printf_l.3 vsprintf_l.3
+MLINKS+=putc.3 fputc.3 \
+ putc.3 fputc_unlocked.3 \
+ putc.3 putc_unlocked.3 \
+ putc.3 putchar.3 \
+ putc.3 putchar_unlocked.3 \
+ putc.3 putw.3
+MLINKS+=putwc.3 fputwc.3 \
+ putwc.3 putwchar.3
+MLINKS+=scanf.3 fscanf.3 \
+ scanf.3 sscanf.3 \
+ scanf.3 vfscanf.3 \
+ scanf.3 vscanf.3 \
scanf.3 vsscanf.3
-MLINKS+=scanf_l.3 fscanf_l.3 scanf_l.3 sscanf_l.3 scanf_l.3 vfscanf_l.3 \
- scanf_l.3 vscanf_l.3 scanf_l.3 vsscanf_l.3
-MLINKS+=setbuf.3 setbuffer.3 setbuf.3 setlinebuf.3 setbuf.3 setvbuf.3
-MLINKS+=tmpnam.3 tempnam.3 tmpnam.3 tmpfile.3
-MLINKS+=wprintf.3 fwprintf.3 wprintf.3 swprintf.3 \
- wprintf.3 vwprintf.3 wprintf.3 vfwprintf.3 wprintf.3 vswprintf.3
-MLINKS+=wscanf.3 fwscanf.3 wscanf.3 swscanf.3 wscanf.3 vwscanf.3 \
- wscanf.3 vswscanf.3 wscanf.3 vfwscanf.3
+MLINKS+=scanf_l.3 fscanf_l.3 \
+ scanf_l.3 sscanf_l.3 \
+ scanf_l.3 vfscanf_l.3 \
+ scanf_l.3 vscanf_l.3 \
+ scanf_l.3 vsscanf_l.3
+MLINKS+=setbuf.3 setbuffer.3 \
+ setbuf.3 setlinebuf.3 \
+ setbuf.3 setvbuf.3
+MLINKS+=tmpnam.3 tempnam.3 \
+ tmpnam.3 tmpfile.3
+MLINKS+=wprintf.3 fwprintf.3 \
+ wprintf.3 swprintf.3 \
+ wprintf.3 vwprintf.3 \
+ wprintf.3 vfwprintf.3 \
+ wprintf.3 vswprintf.3
+MLINKS+=wscanf.3 fwscanf.3 \
+ wscanf.3 swscanf.3 \
+ wscanf.3 vwscanf.3 \
+ wscanf.3 vswscanf.3 \
+ wscanf.3 vfwscanf.3
diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map
index 575dc3cd923c..e44ea6554d46 100644
--- a/lib/libc/stdio/Symbol.map
+++ b/lib/libc/stdio/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
flockfile;
ftrylockfile;
@@ -21,7 +18,6 @@ FBSD_1.0 {
fgetwln;
fgetws;
fileno;
- __sF;
__stdinp;
__stdoutp;
__stderrp;
@@ -48,7 +44,6 @@ FBSD_1.0 {
fwscanf;
getc;
getchar;
- gets;
getw;
getwc;
getwchar;
diff --git a/lib/libc/stdio/_flock_stub.c b/lib/libc/stdio/_flock_stub.c
index 674e88c512bd..5f81f29ac232 100644
--- a/lib/libc/stdio/_flock_stub.c
+++ b/lib/libc/stdio/_flock_stub.c
@@ -36,7 +36,6 @@
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c
index 123345490c43..f0e898c92c0c 100644
--- a/lib/libc/stdio/asprintf.c
+++ b/lib/libc/stdio/asprintf.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdarg.h>
#include <xlocale.h>
diff --git a/lib/libc/stdio/clrerr.c b/lib/libc/stdio/clrerr.c
index 780172ef3f6d..01ce88654c09 100644
--- a/lib/libc/stdio/clrerr.c
+++ b/lib/libc/stdio/clrerr.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)clrerr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/dprintf.c b/lib/libc/stdio/dprintf.c
index 07e20f0709ef..9e976b37379f 100644
--- a/lib/libc/stdio/dprintf.c
+++ b/lib/libc/stdio/dprintf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdarg.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/fclose.3 b/lib/libc/stdio/fclose.3
index 1171105598f0..524ff9754bb4 100644
--- a/lib/libc/stdio/fclose.3
+++ b/lib/libc/stdio/fclose.3
@@ -30,9 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fclose.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 4, 2015
+.Dd February 13, 2024
.Dt FCLOSE 3
.Os
.Sh NAME
@@ -71,9 +69,6 @@ If
is not
.Dv NULL ,
the file descriptor will be written to it.
-If the
-.Fa fdp
-argument will be different then NULL the file descriptor will be returned in it,
If the stream does not have an associated file descriptor,
.Fa fdp
will be set to -1.
diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c
index 7a925f1a1661..ba527f6e7108 100644
--- a/lib/libc/stdio/fclose.c
+++ b/lib/libc/stdio/fclose.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fclose.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdbool.h>
diff --git a/lib/libc/stdio/fcloseall.c b/lib/libc/stdio/fcloseall.c
index 83dc8d697bf1..ae6bd151ca9c 100644
--- a/lib/libc/stdio/fcloseall.c
+++ b/lib/libc/stdio/fcloseall.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include "local.h"
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c
index 7512e2d4dbba..49ec97eda39d 100644
--- a/lib/libc/stdio/fdopen.c
+++ b/lib/libc/stdio/fdopen.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fdopen.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <fcntl.h>
@@ -50,7 +46,7 @@ FILE *
fdopen(int fd, const char *mode)
{
FILE *fp;
- int flags, oflags, fdflags, tmp;
+ int flags, oflags, fdflags, rc, tmp;
/*
* File descriptors are a full int, but _file is only a short.
@@ -80,9 +76,19 @@ fdopen(int fd, const char *mode)
if ((fp = __sfp()) == NULL)
return (NULL);
- if ((oflags & O_CLOEXEC) && _fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
- fp->_flags = 0;
- return (NULL);
+ if ((oflags & O_CLOEXEC) != 0) {
+ tmp = _fcntl(fd, F_GETFD, 0);
+ if (tmp == -1) {
+ fp->_flags = 0;
+ return (NULL);
+ }
+ if ((tmp & FD_CLOEXEC) == 0) {
+ rc = _fcntl(fd, F_SETFD, tmp | FD_CLOEXEC);
+ if (rc == -1) {
+ fp->_flags = 0;
+ return (NULL);
+ }
+ }
}
fp->_flags = flags;
diff --git a/lib/libc/stdio/feof.c b/lib/libc/stdio/feof.c
index f224e1d6d6ba..aefffcd36c70 100644
--- a/lib/libc/stdio/feof.c
+++ b/lib/libc/stdio/feof.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)feof.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/ferror.3 b/lib/libc/stdio/ferror.3
index 1529c002fb7f..b921c4280607 100644
--- a/lib/libc/stdio/ferror.3
+++ b/lib/libc/stdio/ferror.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ferror.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd April 2, 2022
.Dt FERROR 3
.Os
@@ -112,9 +110,25 @@ before calling them.
These functions may be used to avoid the overhead of locking the stream
and to prevent races when multiple threads are operating on the same stream.
.Sh ERRORS
-These functions should not fail and do not set the external
-variable
+These functions, except
+.Fn fileno ,
+should not fail and do not set the external variable
.Va errno .
+.Pp
+On error,
+.Fn fileno
+returns \-1 and sets
+.Va errno
+to one of the following values:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The stream is not associated with a file.
+.It Bq Er EBADF
+The file descriptor underlying stream is not a valid file descriptor.
+.Pp
+Note that detection of this condition is not reliable, the error might
+be not reported.
+.El
.Sh SEE ALSO
.Xr open 2 ,
.Xr fdopen 3 ,
diff --git a/lib/libc/stdio/ferror.c b/lib/libc/stdio/ferror.c
index bf3b2deaf299..15f6f5a69e25 100644
--- a/lib/libc/stdio/ferror.c
+++ b/lib/libc/stdio/ferror.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ferror.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/fflush.3 b/lib/libc/stdio/fflush.3
index 9ca57e749d84..c311b7f473c5 100644
--- a/lib/libc/stdio/fflush.3
+++ b/lib/libc/stdio/fflush.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fflush.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 1, 2020
.Dt FFLUSH 3
.Os
diff --git a/lib/libc/stdio/fflush.c b/lib/libc/stdio/fflush.c
index a7f9348def50..84cba7619866 100644
--- a/lib/libc/stdio/fflush.c
+++ b/lib/libc/stdio/fflush.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fflush.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
@@ -103,11 +99,11 @@ __weak_reference(__fflush, fflush_unlocked);
int
__sflush(FILE *fp)
{
- unsigned char *p, *old_p;
- int n, t, old_w;
+ unsigned char *p;
+ int n, f, t;
- t = fp->_flags;
- if ((t & __SWR) == 0)
+ f = fp->_flags;
+ if ((f & __SWR) == 0)
return (0);
if ((p = fp->_bf._base) == NULL)
@@ -119,26 +115,19 @@ __sflush(FILE *fp)
* Set these immediately to avoid problems with longjmp and to allow
* exchange buffering (via setvbuf) in user write function.
*/
- old_p = fp->_p;
fp->_p = p;
- old_w = fp->_w;
- fp->_w = t & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
+ fp->_w = f & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
for (; n > 0; n -= t, p += t) {
t = _swrite(fp, (char *)p, n);
if (t <= 0) {
- /* Reset _p and _w. */
- if (p > fp->_p) {
+ if (p > fp->_p)
/* Some was written. */
memmove(fp->_p, p, n);
- fp->_p += n;
- if ((fp->_flags & (__SLBF | __SNBF)) == 0)
- fp->_w -= n;
- /* conditional to handle setvbuf */
- } else if (p == fp->_p && errno == EINTR) {
- fp->_p = old_p;
- fp->_w = old_w;
- }
+ /* Reset _p and _w. */
+ fp->_p += n;
+ if ((fp->_flags & __SNBF) == 0)
+ fp->_w -= n;
fp->_flags |= __SERR;
return (EOF);
}
diff --git a/lib/libc/stdio/fgetc.c b/lib/libc/stdio/fgetc.c
index 2919fe31b826..d05d9de3cc9f 100644
--- a/lib/libc/stdio/fgetc.c
+++ b/lib/libc/stdio/fgetc.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fgetc.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/fgetln.3 b/lib/libc/stdio/fgetln.3
index 007a73c37213..09fd014cde00 100644
--- a/lib/libc/stdio/fgetln.3
+++ b/lib/libc/stdio/fgetln.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fgetln.3 8.3 (Berkeley) 4/19/94
-.\"
.Dd June 11, 2020
.Dt FGETLN 3
.Os
diff --git a/lib/libc/stdio/fgetln.c b/lib/libc/stdio/fgetln.c
index a66919711050..ad37a2e15c61 100644
--- a/lib/libc/stdio/fgetln.c
+++ b/lib/libc/stdio/fgetln.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fgetln.c 8.2 (Berkeley) 1/2/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/stdio/fgetpos.c b/lib/libc/stdio/fgetpos.c
index 4cbd5e1f6e76..930e26b762f5 100644
--- a/lib/libc/stdio/fgetpos.c
+++ b/lib/libc/stdio/fgetpos.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fgetpos.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
int
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3
index 6533c218a789..1ae5888f5983 100644
--- a/lib/libc/stdio/fgets.3
+++ b/lib/libc/stdio/fgets.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fgets.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd April 2, 2022
+.Dd December 6, 2024
.Dt FGETS 3
.Os
.Sh NAME
@@ -44,6 +42,7 @@
.In stdio.h
.Ft char *
.Fn fgets "char * restrict str" "int size" "FILE * restrict stream"
+.Fd #define __STDC_WANT_LIB_EXT1__ 1
.Ft char *
.Fn gets_s "char *str" "rsize_t size"
.Sh DESCRIPTION
diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c
index adac5dc3d6a0..504338c012a2 100644
--- a/lib/libc/stdio/fgets.c
+++ b/lib/libc/stdio/fgets.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fgets.c 8.2 (Berkeley) 12/22/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
@@ -44,6 +40,8 @@ static char sccsid[] = "@(#)fgets.c 8.2 (Berkeley) 12/22/93";
#include "local.h"
#include "libc_private.h"
+#undef fgets /* _FORTIFY_SOURCE */
+
/*
* Read at most n-1 characters from the given file.
* Stop when a newline has been read, or the count runs out.
diff --git a/lib/libc/stdio/fgetwc.c b/lib/libc/stdio/fgetwc.c
index 949d93f67007..53d1f9564fe2 100644
--- a/lib/libc/stdio/fgetwc.c
+++ b/lib/libc/stdio/fgetwc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/fgetwln.3 b/lib/libc/stdio/fgetwln.3
index d84a2740837f..9e863a1bd460 100644
--- a/lib/libc/stdio/fgetwln.3
+++ b/lib/libc/stdio/fgetwln.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fgetln.3 8.3 (Berkeley) 4/19/94
-.\"
.Dd July 16, 2004
.Dt FGETWLN 3
.Os
diff --git a/lib/libc/stdio/fgetwln.c b/lib/libc/stdio/fgetwln.c
index 8d74f9d8f3da..3a8e12b30c07 100644
--- a/lib/libc/stdio/fgetwln.c
+++ b/lib/libc/stdio/fgetwln.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/fgetws.3 b/lib/libc/stdio/fgetws.3
index 77c0ba4c9e97..5da940525d24 100644
--- a/lib/libc/stdio/fgetws.3
+++ b/lib/libc/stdio/fgetws.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" @(#)fgets.3 8.1 (Berkeley) 6/4/93
.\" FreeBSD: src/lib/libc/stdio/fgets.3,v 1.16 2002/05/31 05:01:17 archie Exp
.\"
.Dd August 6, 2002
diff --git a/lib/libc/stdio/fgetws.c b/lib/libc/stdio/fgetws.c
index 1eaeed708ef1..1aa94e50f186 100644
--- a/lib/libc/stdio/fgetws.c
+++ b/lib/libc/stdio/fgetws.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/fileno.c b/lib/libc/stdio/fileno.c
index 272a46abb74a..0ba242c1aed3 100644
--- a/lib/libc/stdio/fileno.c
+++ b/lib/libc/stdio/fileno.c
@@ -32,11 +32,8 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fileno.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
+#include <errno.h>
#include <stdio.h>
#include "un-namespace.h"
#include "libc_private.h"
@@ -44,14 +41,29 @@ static char sccsid[] = "@(#)fileno.c 8.1 (Berkeley) 6/4/93";
#undef fileno
#undef fileno_unlocked
+static int
+__fileno_impl(FILE *fp)
+{
+ int fd;
+
+ fd = fp->_file;
+ if (fd == -1)
+ errno = EBADF;
+ return (fd);
+}
+
int
fileno(FILE *fp)
{
int fd;
- FLOCKFILE(fp);
- fd = __sfileno(fp);
- FUNLOCKFILE(fp);
+ if (__isthreaded) {
+ FLOCKFILE(fp);
+ fd = __fileno_impl(fp);
+ FUNLOCKFILE(fp);
+ } else {
+ fd = __fileno_impl(fp);
+ }
return (fd);
}
@@ -59,6 +71,5 @@ fileno(FILE *fp)
int
fileno_unlocked(FILE *fp)
{
-
- return (__sfileno(fp));
+ return (__fileno_impl(fp));
}
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c
index cf4eccf8807e..3729adf8d8dc 100644
--- a/lib/libc/stdio/findfp.c
+++ b/lib/libc/stdio/findfp.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)findfp.c 8.2 (Berkeley) 1/4/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <machine/atomic.h>
#include <unistd.h>
diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c
index 04b67f127986..ef7ee38b8e2a 100644
--- a/lib/libc/stdio/flags.c
+++ b/lib/libc/stdio/flags.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)flags.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/floatio.h b/lib/libc/stdio/floatio.h
index 4abf972f5f40..ef8c0fa84528 100644
--- a/lib/libc/stdio/floatio.h
+++ b/lib/libc/stdio/floatio.h
@@ -30,8 +30,6 @@
* 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.
- *
- * @(#)floatio.h 8.1 (Berkeley) 6/4/93
*/
/*
diff --git a/lib/libc/stdio/fmemopen.c b/lib/libc/stdio/fmemopen.c
index 295592ac896f..dc323921d93a 100644
--- a/lib/libc/stdio/fmemopen.c
+++ b/lib/libc/stdio/fmemopen.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdio.h>
@@ -75,10 +74,9 @@ fmemopen(void * __restrict buf, size_t size, const char * __restrict mode)
}
/*
- * There's no point in requiring an automatically allocated buffer
- * in write-only mode.
+ * An automatically allocated buffer is only allowed in read-write mode.
*/
- if (!(flags & O_RDWR) && buf == NULL) {
+ if ((flags & O_ACCMODE) != O_RDWR && buf == NULL) {
errno = EINVAL;
return (NULL);
}
@@ -137,9 +135,10 @@ fmemopen(void * __restrict buf, size_t size, const char * __restrict mode)
break;
}
+ /* Disable read in O_WRONLY mode, and write in O_RDONLY mode. */
f = funopen(ck,
- flags & O_WRONLY ? NULL : fmemopen_read,
- flags & O_RDONLY ? NULL : fmemopen_write,
+ (flags & O_ACCMODE) == O_WRONLY ? NULL : fmemopen_read,
+ (flags & O_ACCMODE) == O_RDONLY ? NULL : fmemopen_write,
fmemopen_seek, fmemopen_close);
if (f == NULL) {
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index 6f03443caf42..3d69dc1fec13 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd September 1, 2023
.Dt FOPEN 3
.Os
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index 2f2de15345c4..f76f0fb09087 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fopen.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/stdio/fopencookie.c b/lib/libc/stdio/fopencookie.c
index 9c295ff7bfed..ef49d3d10f16 100644
--- a/lib/libc/stdio/fopencookie.c
+++ b/lib/libc/stdio/fopencookie.c
@@ -24,7 +24,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/fcntl.h>
#include <errno.h>
diff --git a/lib/libc/stdio/fprintf.c b/lib/libc/stdio/fprintf.c
index c1df55872aa3..9b2cbb0849a7 100644
--- a/lib/libc/stdio/fprintf.c
+++ b/lib/libc/stdio/fprintf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdarg.h>
#include "xlocale_private.h"
diff --git a/lib/libc/stdio/fpurge.c b/lib/libc/stdio/fpurge.c
index 4ca6a5373050..0914b977ad49 100644
--- a/lib/libc/stdio/fpurge.c
+++ b/lib/libc/stdio/fpurge.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fpurge.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c
index 54476b8f2bea..3d8409c465b8 100644
--- a/lib/libc/stdio/fputc.c
+++ b/lib/libc/stdio/fputc.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fputc.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/fputs.3 b/lib/libc/stdio/fputs.3
index c9e0ca3f30ed..dc85113dd791 100644
--- a/lib/libc/stdio/fputs.3
+++ b/lib/libc/stdio/fputs.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fputs.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd January 23, 2020
.Dt FPUTS 3
.Os
diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c
index 1b611d50017b..8bafa23d4131 100644
--- a/lib/libc/stdio/fputs.c
+++ b/lib/libc/stdio/fputs.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fputs.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <limits.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/fputwc.c b/lib/libc/stdio/fputwc.c
index 197c57cc374a..7955a4e811b2 100644
--- a/lib/libc/stdio/fputwc.c
+++ b/lib/libc/stdio/fputwc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/stdio/fputws.3 b/lib/libc/stdio/fputws.3
index cdf01e22f96b..920d0e0cf658 100644
--- a/lib/libc/stdio/fputws.3
+++ b/lib/libc/stdio/fputws.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" @(#)fputs.3 8.1 (Berkeley) 6/4/93
.\" FreeBSD: src/lib/libc/stdio/fputs.3,v 1.8 2001/10/01 16:08:59 ru Exp
.\"
.Dd August 6, 2002
diff --git a/lib/libc/stdio/fputws.c b/lib/libc/stdio/fputws.c
index c77393886e72..105fc426cb9c 100644
--- a/lib/libc/stdio/fputws.c
+++ b/lib/libc/stdio/fputws.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/stdio/fread.3 b/lib/libc/stdio/fread.3
index cc278781acf5..dfa7c8df18a3 100644
--- a/lib/libc/stdio/fread.3
+++ b/lib/libc/stdio/fread.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fread.3 8.2 (Berkeley) 3/8/94
-.\"
.Dd April 2, 2022
.Dt FREAD 3
.Os
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
index 13776382fbb7..65d9ecf94366 100644
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -32,15 +32,12 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fread.c 8.2 (Berkeley) 12/11/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include <ssp/ssp.h>
#include "un-namespace.h"
#include "local.h"
#include "libc_private.h"
@@ -50,7 +47,8 @@ static char sccsid[] = "@(#)fread.c 8.2 (Berkeley) 12/11/93";
*/
size_t
-fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict fp)
+__ssp_real(fread)(void * __restrict buf, size_t size, size_t count,
+ FILE * __restrict fp)
{
size_t ret;
diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c
index 2f3f96c1d92a..048fd30b3193 100644
--- a/lib/libc/stdio/freopen.c
+++ b/lib/libc/stdio/freopen.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)freopen.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -59,7 +55,7 @@ freopen(const char * __restrict file, const char * __restrict mode,
FILE * __restrict fp)
{
int f;
- int dflags, flags, isopen, oflags, sverrno, wantfd;
+ int dflags, fdflags, flags, isopen, oflags, sverrno, wantfd;
if ((flags = __sflags(mode, &oflags)) == 0) {
sverrno = errno;
@@ -117,8 +113,12 @@ freopen(const char * __restrict file, const char * __restrict mode,
(void) ftruncate(fp->_file, (off_t)0);
if (!(oflags & O_APPEND))
(void) _sseek(fp, (fpos_t)0, SEEK_SET);
- if (oflags & O_CLOEXEC)
- (void) _fcntl(fp->_file, F_SETFD, FD_CLOEXEC);
+ if ((oflags & O_CLOEXEC) != 0) {
+ fdflags = _fcntl(fp->_file, F_GETFD, 0);
+ if (fdflags != -1 && (fdflags & FD_CLOEXEC) == 0)
+ (void) _fcntl(fp->_file, F_SETFD,
+ fdflags | FD_CLOEXEC);
+ }
f = fp->_file;
isopen = 0;
wantfd = -1;
diff --git a/lib/libc/stdio/fscanf.c b/lib/libc/stdio/fscanf.c
index f274cb98ef3c..f2dc9cf6e787 100644
--- a/lib/libc/stdio/fscanf.c
+++ b/lib/libc/stdio/fscanf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <stdarg.h>
diff --git a/lib/libc/stdio/fseek.3 b/lib/libc/stdio/fseek.3
index a1be3149a6ca..521ded3a09d7 100644
--- a/lib/libc/stdio/fseek.3
+++ b/lib/libc/stdio/fseek.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)fseek.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 2, 2022
.Dt FSEEK 3
.Os
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index 21f1079b6458..c19d682ec667 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fseek.c 8.3 (Berkeley) 1/2/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/stdio/fsetpos.c b/lib/libc/stdio/fsetpos.c
index 4f985e249a32..caca58dad710 100644
--- a/lib/libc/stdio/fsetpos.c
+++ b/lib/libc/stdio/fsetpos.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fsetpos.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c
index 4cb038df1d76..c74ae03ec7db 100644
--- a/lib/libc/stdio/ftell.c
+++ b/lib/libc/stdio/ftell.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ftell.c 8.2 (Berkeley) 5/4/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libc/stdio/funopen.3 b/lib/libc/stdio/funopen.3
index cbc1500931e3..f3234af229f7 100644
--- a/lib/libc/stdio/funopen.3
+++ b/lib/libc/stdio/funopen.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)funopen.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd May 9, 2016
.Dt FUNOPEN 3
.Os
diff --git a/lib/libc/stdio/funopen.c b/lib/libc/stdio/funopen.c
index 376721d33eb3..87a3179f5908 100644
--- a/lib/libc/stdio/funopen.c
+++ b/lib/libc/stdio/funopen.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)funopen.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <errno.h>
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index 81e7ba89a644..2d5aaf3c5dc8 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -32,11 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -53,7 +48,6 @@ int
__sfvwrite(FILE *fp, struct __suio *uio)
{
size_t len;
- unsigned char *old_p;
char *p;
struct __siov *iov;
int w, s;
@@ -137,12 +131,8 @@ __sfvwrite(FILE *fp, struct __suio *uio)
COPY(w);
/* fp->_w -= w; */ /* unneeded */
fp->_p += w;
- old_p = fp->_p;
- if (__fflush(fp) == EOF) {
- if (old_p == fp->_p && errno == EINTR)
- fp->_p -= w;
+ if (__fflush(fp))
goto err;
- }
} else if (len >= (w = fp->_bf._size)) {
/* write directly */
w = _swrite(fp, p, w);
@@ -181,12 +171,8 @@ __sfvwrite(FILE *fp, struct __suio *uio)
COPY(w);
/* fp->_w -= w; */
fp->_p += w;
- old_p = fp->_p;
- if (__fflush(fp) == EOF) {
- if (old_p == fp->_p && errno == EINTR)
- fp->_p -= w;
+ if (__fflush(fp))
goto err;
- }
} else if (s >= (w = fp->_bf._size)) {
w = _swrite(fp, p, w);
if (w <= 0)
diff --git a/lib/libc/stdio/fvwrite.h b/lib/libc/stdio/fvwrite.h
index f9e89dfd2454..ce6dc67a6ed2 100644
--- a/lib/libc/stdio/fvwrite.h
+++ b/lib/libc/stdio/fvwrite.h
@@ -30,8 +30,6 @@
* 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.
- *
- * @(#)fvwrite.h 8.1 (Berkeley) 6/4/93
*/
/*
diff --git a/lib/libc/stdio/fwalk.c b/lib/libc/stdio/fwalk.c
index 0e2c48234a75..fc93ee075051 100644
--- a/lib/libc/stdio/fwalk.c
+++ b/lib/libc/stdio/fwalk.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fwalk.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
#include "local.h"
diff --git a/lib/libc/stdio/fwide.c b/lib/libc/stdio/fwide.c
index d413d4518d2a..86eb5b5299f8 100644
--- a/lib/libc/stdio/fwide.c
+++ b/lib/libc/stdio/fwide.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/fwprintf.c b/lib/libc/stdio/fwprintf.c
index 7550bb8eb69b..f2a28ad4b08a 100644
--- a/lib/libc/stdio/fwprintf.c
+++ b/lib/libc/stdio/fwprintf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c
index d0663c93a2a2..bbe2afb683c3 100644
--- a/lib/libc/stdio/fwrite.c
+++ b/lib/libc/stdio/fwrite.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fwrite.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdint.h>
diff --git a/lib/libc/stdio/fwscanf.c b/lib/libc/stdio/fwscanf.c
index b0f2d02e748d..833a31a8f1b9 100644
--- a/lib/libc/stdio/fwscanf.c
+++ b/lib/libc/stdio/fwscanf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/getc.3 b/lib/libc/stdio/getc.3
index 86852aea7f21..02f0f2f06f4a 100644
--- a/lib/libc/stdio/getc.3
+++ b/lib/libc/stdio/getc.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 4, 2020
.Dt GETC 3
.Os
diff --git a/lib/libc/stdio/getc.c b/lib/libc/stdio/getc.c
index 61fb4fe88c88..61b184115004 100644
--- a/lib/libc/stdio/getc.c
+++ b/lib/libc/stdio/getc.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getc.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/getchar.c b/lib/libc/stdio/getchar.c
index 197e135f8cbf..02ac4893b5e8 100644
--- a/lib/libc/stdio/getchar.c
+++ b/lib/libc/stdio/getchar.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getchar.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* A subroutine version of the macro getchar.
*/
diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c
index 5a1a3cd3dfb8..7543fefc3a57 100644
--- a/lib/libc/stdio/getdelim.c
+++ b/lib/libc/stdio/getdelim.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <errno.h>
diff --git a/lib/libc/stdio/getline.c b/lib/libc/stdio/getline.c
index 7e62829ecf4c..371341d6ea8e 100644
--- a/lib/libc/stdio/getline.c
+++ b/lib/libc/stdio/getline.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
ssize_t
diff --git a/lib/libc/stdio/gets.c b/lib/libc/stdio/gets.c
index 7f3e165f0bff..b92ce188e2b5 100644
--- a/lib/libc/stdio/gets.c
+++ b/lib/libc/stdio/gets.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gets.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <unistd.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/gets_s.c b/lib/libc/stdio/gets_s.c
index cf839f8abed9..41e379507483 100644
--- a/lib/libc/stdio/gets_s.c
+++ b/lib/libc/stdio/gets_s.c
@@ -34,12 +34,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
+#include <ssp/ssp.h>
#include "un-namespace.h"
#include "libc_private.h"
#include "local.h"
@@ -78,7 +78,7 @@ _gets_s(char *buf, rsize_t n)
/* ISO/IEC 9899:2011 K.3.7.4.1 */
char *
-gets_s(char *buf, rsize_t n)
+__ssp_real(gets_s)(char *buf, rsize_t n)
{
char *ret;
if (buf == NULL) {
diff --git a/lib/libc/stdio/getw.c b/lib/libc/stdio/getw.c
index f48395d7dc7c..2986220461e9 100644
--- a/lib/libc/stdio/getw.c
+++ b/lib/libc/stdio/getw.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getw.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
int
diff --git a/lib/libc/stdio/getwc.3 b/lib/libc/stdio/getwc.3
index 2efa0c4de113..734e5c0b4259 100644
--- a/lib/libc/stdio/getwc.3
+++ b/lib/libc/stdio/getwc.3
@@ -31,8 +31,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 3, 2004
.Dt GETWC 3
.Os
diff --git a/lib/libc/stdio/getwc.c b/lib/libc/stdio/getwc.c
index ccac10db228f..ae56ff7d6dd3 100644
--- a/lib/libc/stdio/getwc.c
+++ b/lib/libc/stdio/getwc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/getwchar.c b/lib/libc/stdio/getwchar.c
index 9294a952357e..335a975ba6e8 100644
--- a/lib/libc/stdio/getwchar.c
+++ b/lib/libc/stdio/getwchar.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/glue.h b/lib/libc/stdio/glue.h
index 3fcb52316133..948ef537e5d6 100644
--- a/lib/libc/stdio/glue.h
+++ b/lib/libc/stdio/glue.h
@@ -30,8 +30,6 @@
* 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.
- *
- * @(#)glue.h 8.1 (Berkeley) 6/4/93
*/
/*
diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h
index a5c465bcdcba..da08fa246833 100644
--- a/lib/libc/stdio/local.h
+++ b/lib/libc/stdio/local.h
@@ -35,8 +35,6 @@
* 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.
- *
- * @(#)local.h 8.3 (Berkeley) 7/3/94
*/
#ifndef _STDIO_LOCAL_H
@@ -80,7 +78,7 @@ extern int __swsetup(FILE *);
extern int __sflags(const char *, int *);
extern int __ungetc(int, FILE *);
extern wint_t __ungetwc(wint_t, FILE *, locale_t);
-extern int __vfprintf(FILE *, locale_t, const char *, __va_list);
+extern int __vfprintf(FILE *, locale_t, int, const char *, __va_list);
extern int __vfscanf(FILE *, const char *, __va_list);
extern int __vfwprintf(FILE *, locale_t, const wchar_t *, __va_list);
extern int __vfwscanf(FILE * __restrict, locale_t, const wchar_t * __restrict,
diff --git a/lib/libc/stdio/makebuf.c b/lib/libc/stdio/makebuf.c
index f499651880ca..036682870cfa 100644
--- a/lib/libc/stdio/makebuf.c
+++ b/lib/libc/stdio/makebuf.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)makebuf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/stdio/mktemp.3 b/lib/libc/stdio/mktemp.3
index cfb6f79be251..8d38dd2cd57e 100644
--- a/lib/libc/stdio/mktemp.3
+++ b/lib/libc/stdio/mktemp.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)mktemp.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 29, 2019
+.Dd July 07, 2025
.Dt MKTEMP 3
.Os
.Sh NAME
@@ -65,7 +63,7 @@ The template may be any file name with some number of
.Ql X Ns s
appended
to it, for example
-.Pa /tmp/temp.XXXXXX .
+.Pa /tmp/temp.XXXXXXXXXX .
The trailing
.Ql X Ns s
are replaced with a
@@ -103,9 +101,10 @@ The permitted flags are
.Dv O_DIRECT ,
.Dv O_SHLOCK ,
.Dv O_EXLOCK ,
-.Dv O_SYNC
+.Dv O_SYNC ,
+.Dv O_CLOEXEC
and
-.Dv O_CLOEXEC .
+.Dv O_CLOFORK .
.Pp
The
.Fn mkstemps
@@ -118,7 +117,7 @@ and
respectively,
except they permit a suffix to exist in the template.
The template should be of the form
-.Pa /tmp/tmpXXXXXXsuffix .
+.Pa /tmp/tmpXXXXXXXXXXsuffix .
The
.Fn mkstemps
and
@@ -245,7 +244,7 @@ compilers were common.
For example, calling
.Fn mkstemp
with an argument of
-.Qq /tmp/tempfile.XXXXXX
+.Qq /tmp/tempfile.XXXXXXXXXX
will result in a core dump due to
.Fn mkstemp
attempting to modify the string constant that was given.
@@ -277,7 +276,10 @@ function is expected to conform to
and is not specified by
.St -p1003.1-2008 .
The
-.Fn mkostemp ,
+.Fn mkostemp
+function conforms to
+.St -p1003.1-2024 .
+The
.Fn mkstemps ,
.Fn mkostemps
and
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index bbefc2b28cfd..a2f80ee7b0dd 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
@@ -125,7 +121,7 @@ _gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
if ((doopen != NULL && domkdir) || slen < 0 ||
(oflags & ~(O_APPEND | O_DIRECT | O_SHLOCK | O_EXLOCK | O_SYNC |
- O_CLOEXEC)) != 0) {
+ O_CLOEXEC | O_CLOFORK)) != 0) {
errno = EINVAL;
return (0);
}
diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c
index 7dabc737db8c..371022adf6b3 100644
--- a/lib/libc/stdio/open_memstream.c
+++ b/lib/libc/stdio/open_memstream.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c
index bc746ebf8073..213d61fcd4dd 100644
--- a/lib/libc/stdio/open_wmemstream.c
+++ b/lib/libc/stdio/open_wmemstream.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c
index a16820f83b26..36052e8a8689 100644
--- a/lib/libc/stdio/perror.c
+++ b/lib/libc/stdio/perror.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)perror.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/uio.h>
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index 534ac9cd4b78..edbd4e379699 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* This is the code responsible for handling positional arguments
* (%m$ and %m$.n$) for vfprintf() and vfwprintf().
diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3
index 110851e2a421..b421a2a0985d 100644
--- a/lib/libc/stdio/printf.3
+++ b/lib/libc/stdio/printf.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)printf.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 21, 2023
+.Dd September 5, 2023
.Dt PRINTF 3
.Os
.Sh NAME
@@ -342,6 +340,8 @@ conversion:
.It Cm ll No (ell ell) Ta Vt "long long" Ta Vt "unsigned long long" Ta Vt "long long *"
.It Cm j Ta Vt intmax_t Ta Vt uintmax_t Ta Vt "intmax_t *"
.It Cm t Ta Vt ptrdiff_t Ta (see note) Ta Vt "ptrdiff_t *"
+.It Cm w Ns Ar N Ta Vt intN_t Ta Vt uintN_t Ta Vt "intN_t *"
+.It Cm wf Ns Ar N Ta Vt int_fastN_t Ta Vt uint_fastN_t Ta Vt "int_fastN_t *"
.It Cm z Ta (see note) Ta Vt size_t Ta (see note)
.It Cm q Em (deprecated) Ta Vt quad_t Ta Vt u_quad_t Ta Vt "quad_t *"
.El
@@ -828,6 +828,12 @@ and
.Fn vdprintf
conform to
.St -p1003.1-2008 .
+The functions
+.Fn asprintf
+and
+.Fn vasprintf
+conform to
+.St -p1003.1-2024 .
.Sh HISTORY
The functions
.Fn asprintf
diff --git a/lib/libc/stdio/printf.c b/lib/libc/stdio/printf.c
index 20e5b7b0e3cd..f67e3d51a398 100644
--- a/lib/libc/stdio/printf.c
+++ b/lib/libc/stdio/printf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)printf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdarg.h>
#include <xlocale.h>
diff --git a/lib/libc/stdio/printflocal.h b/lib/libc/stdio/printflocal.h
index 3594f75d0050..f3d0d3e9e216 100644
--- a/lib/libc/stdio/printflocal.h
+++ b/lib/libc/stdio/printflocal.h
@@ -49,6 +49,7 @@
#define PTRDIFFT 0x800 /* ptrdiff_t */
#define INTMAXT 0x1000 /* intmax_t */
#define CHARINT 0x2000 /* print char using int format */
+#define FASTINT 0x4000 /* int_fastN_t */
/*
* Macros for converting digits to letters and vice versa
diff --git a/lib/libc/stdio/putc.3 b/lib/libc/stdio/putc.3
index a010046f89ef..7bdf87e31769 100644
--- a/lib/libc/stdio/putc.3
+++ b/lib/libc/stdio/putc.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)putc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd January 23, 2020
.Dt PUTC 3
.Os
diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c
index 54735da59527..6942239e0c78 100644
--- a/lib/libc/stdio/putc.c
+++ b/lib/libc/stdio/putc.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)putc.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/putchar.c b/lib/libc/stdio/putchar.c
index dd8ea0271b94..87980ca0d052 100644
--- a/lib/libc/stdio/putchar.c
+++ b/lib/libc/stdio/putchar.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)putchar.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/puts.c b/lib/libc/stdio/puts.c
index b97807fe1255..f0cf58fab5b5 100644
--- a/lib/libc/stdio/puts.c
+++ b/lib/libc/stdio/puts.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)puts.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <string.h>
diff --git a/lib/libc/stdio/putw.c b/lib/libc/stdio/putw.c
index 7e7c87c99ba2..417030f13360 100644
--- a/lib/libc/stdio/putw.c
+++ b/lib/libc/stdio/putw.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)putw.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/putwc.3 b/lib/libc/stdio/putwc.3
index a4add5516175..6d09c575c022 100644
--- a/lib/libc/stdio/putwc.3
+++ b/lib/libc/stdio/putwc.3
@@ -31,8 +31,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)putc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 3, 2004
.Dt PUTWC 3
.Os
diff --git a/lib/libc/stdio/putwc.c b/lib/libc/stdio/putwc.c
index 386023924440..435da69dec6a 100644
--- a/lib/libc/stdio/putwc.c
+++ b/lib/libc/stdio/putwc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/putwchar.c b/lib/libc/stdio/putwchar.c
index 1c5ab256125a..f109a5f6b1dd 100644
--- a/lib/libc/stdio/putwchar.c
+++ b/lib/libc/stdio/putwchar.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/refill.c b/lib/libc/stdio/refill.c
index afc0526441aa..13d85d71af22 100644
--- a/lib/libc/stdio/refill.c
+++ b/lib/libc/stdio/refill.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)refill.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/remove.3 b/lib/libc/stdio/remove.3
index ea1e82bf44a8..65ec58bf8b6d 100644
--- a/lib/libc/stdio/remove.3
+++ b/lib/libc/stdio/remove.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)remove.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt REMOVE 3
.Os
diff --git a/lib/libc/stdio/remove.c b/lib/libc/stdio/remove.c
index 1e9dd98e1841..2c9ef61b12de 100644
--- a/lib/libc/stdio/remove.c
+++ b/lib/libc/stdio/remove.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)remove.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
diff --git a/lib/libc/stdio/rewind.c b/lib/libc/stdio/rewind.c
index 8e6fc877c401..4bbd06976034 100644
--- a/lib/libc/stdio/rewind.c
+++ b/lib/libc/stdio/rewind.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rewind.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/rget.c b/lib/libc/stdio/rget.c
index a25ae3bdcea1..6f57ad4bc0f3 100644
--- a/lib/libc/stdio/rget.c
+++ b/lib/libc/stdio/rget.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rget.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include "local.h"
diff --git a/lib/libc/stdio/scanf.3 b/lib/libc/stdio/scanf.3
index 6cefdb133983..04664c5f2bbd 100644
--- a/lib/libc/stdio/scanf.3
+++ b/lib/libc/stdio/scanf.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
-.\"
-.Dd August 21, 2023
+.Dd September 5, 2023
.Dt SCANF 3
.Os
.Sh NAME
@@ -217,6 +215,34 @@ and the next pointer is a pointer to a
.Vt ptrdiff_t
(rather than
.Vt int ) .
+.It Cm w Ns Ar N
+.Po
+where
+.Ar N
+is 8, 16, 32, or 64
+.Pc
+Indicates that the conversion will be one of
+.Cm bdioux
+or
+.Cm n
+and the next pointer is a pointer to a
+.Vt intN_t
+(rather than
+.Vt int ) .
+.It Cm wf Ns Ar N
+.Po
+where
+.Ar N
+is 8, 16, 32, or 64
+.Pc
+Indicates that the conversion will be one of
+.Cm bdioux
+or
+.Cm n
+and the next pointer is a pointer to a
+.Vt int_fastN_t
+(rather than
+.Vt int ) .
.It Cm z
Indicates that the conversion will be one of
.Cm bdioux
diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c
index 1f84f9ab6542..c0bd4dfe0c01 100644
--- a/lib/libc/stdio/scanf.c
+++ b/lib/libc/stdio/scanf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)scanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <stdarg.h>
diff --git a/lib/libc/stdio/setbuf.3 b/lib/libc/stdio/setbuf.3
index 0f17e52fa36f..027564cadfb4 100644
--- a/lib/libc/stdio/setbuf.3
+++ b/lib/libc/stdio/setbuf.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)setbuf.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 1, 2020
.Dt SETBUF 3
.Os
diff --git a/lib/libc/stdio/setbuf.c b/lib/libc/stdio/setbuf.c
index 71f0ee4ae7dc..ec3c741947d8 100644
--- a/lib/libc/stdio/setbuf.c
+++ b/lib/libc/stdio/setbuf.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setbuf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include "local.h"
diff --git a/lib/libc/stdio/setbuffer.c b/lib/libc/stdio/setbuffer.c
index 96c498f95e73..1838b84c1653 100644
--- a/lib/libc/stdio/setbuffer.c
+++ b/lib/libc/stdio/setbuffer.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setbuffer.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
void
diff --git a/lib/libc/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c
index 9714818bc57f..554d558e73df 100644
--- a/lib/libc/stdio/setvbuf.c
+++ b/lib/libc/stdio/setvbuf.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)setvbuf.c 8.2 (Berkeley) 11/16/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <limits.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c
index 45a9e3d7d622..da5032f10e6a 100644
--- a/lib/libc/stdio/snprintf.c
+++ b/lib/libc/stdio/snprintf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
@@ -49,13 +45,16 @@ static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
#include "local.h"
+#undef snprintf /* _FORTIFY_SOURCE */
+
int
snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...)
{
+ FILE f = FAKE_FILE;
+ va_list ap;
size_t on;
+ int serrno = errno;
int ret;
- va_list ap;
- FILE f = FAKE_FILE;
on = n;
if (n != 0)
@@ -69,7 +68,7 @@ snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...)
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n;
- ret = __vfprintf(&f, __get_locale(), fmt, ap);
+ ret = __vfprintf(&f, __get_locale(), serrno, fmt, ap);
if (on > 0)
*f._p = '\0';
va_end(ap);
@@ -79,10 +78,11 @@ int
snprintf_l(char * __restrict str, size_t n, locale_t locale,
char const * __restrict fmt, ...)
{
+ FILE f = FAKE_FILE;
+ va_list ap;
size_t on;
+ int serrno = errno;
int ret;
- va_list ap;
- FILE f = FAKE_FILE;
FIX_LOCALE(locale);
on = n;
@@ -97,7 +97,7 @@ snprintf_l(char * __restrict str, size_t n, locale_t locale,
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n;
- ret = __vfprintf(&f, locale, fmt, ap);
+ ret = __vfprintf(&f, locale, serrno, fmt, ap);
if (on > 0)
*f._p = '\0';
va_end(ap);
diff --git a/lib/libc/stdio/sprintf.c b/lib/libc/stdio/sprintf.c
index c83efdb3f357..1cac21e98a46 100644
--- a/lib/libc/stdio/sprintf.c
+++ b/lib/libc/stdio/sprintf.c
@@ -37,16 +37,14 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)sprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include "local.h"
#include "xlocale_private.h"
+#undef sprintf /* _FORTIFY_SOURCE */
+
int
sprintf(char * __restrict str, char const * __restrict fmt, ...)
{
diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c
index a06aac85a676..5dc9d2b13697 100644
--- a/lib/libc/stdio/sscanf.c
+++ b/lib/libc/stdio/sscanf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)sscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
diff --git a/lib/libc/stdio/stdio.3 b/lib/libc/stdio/stdio.3
index 4447ca1b2b87..cbb8a49df2c6 100644
--- a/lib/libc/stdio/stdio.3
+++ b/lib/libc/stdio/stdio.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)stdio.3 8.7 (Berkeley) 4/19/94
-.\"
.Dd March 3, 2009
.Dt STDIO 3
.Os
@@ -254,7 +252,7 @@ library conforms to
.It "fgets get a line from a stream"
.It "fgetwc get next wide character from input stream"
.It "fgetws get a line of wide characters from a stream"
-.It "fileno check and reset stream status"
+.It "fileno map a stream pointer to a file descriptor"
.It "fopen stream open functions"
.It "fprintf formatted output conversion"
.It "fpurge flush a stream"
diff --git a/lib/libc/stdio/stdio.c b/lib/libc/stdio/stdio.c
index 40677118bea2..bffd7b1bfc3c 100644
--- a/lib/libc/stdio/stdio.c
+++ b/lib/libc/stdio/stdio.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)stdio.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libc/stdio/swprintf.c b/lib/libc/stdio/swprintf.c
index 4c4db2accb76..278f0e37d117 100644
--- a/lib/libc/stdio/swprintf.c
+++ b/lib/libc/stdio/swprintf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/swscanf.c b/lib/libc/stdio/swscanf.c
index 20bf266dc772..9b91acf56685 100644
--- a/lib/libc/stdio/swscanf.c
+++ b/lib/libc/stdio/swscanf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/tempnam.c b/lib/libc/stdio/tempnam.c
index 06dceec153bf..a3e6c6e3cf01 100644
--- a/lib/libc/stdio/tempnam.c
+++ b/lib/libc/stdio/tempnam.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tempnam.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c
index afe45595eac8..d3331b8c2c2d 100644
--- a/lib/libc/stdio/tmpfile.c
+++ b/lib/libc/stdio/tmpfile.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tmpfile.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <signal.h>
diff --git a/lib/libc/stdio/tmpnam.3 b/lib/libc/stdio/tmpnam.3
index c5269a674278..3b9d93280e72 100644
--- a/lib/libc/stdio/tmpnam.3
+++ b/lib/libc/stdio/tmpnam.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)tmpnam.3 8.2 (Berkeley) 11/17/93
-.\"
.Dd August 7, 2020
.Dt TMPFILE 3
.Os
diff --git a/lib/libc/stdio/tmpnam.c b/lib/libc/stdio/tmpnam.c
index 8fc057dea868..fab4253e2834 100644
--- a/lib/libc/stdio/tmpnam.c
+++ b/lib/libc/stdio/tmpnam.c
@@ -32,14 +32,11 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)tmpnam.c 8.3 (Berkeley) 3/28/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
+#include <ssp/ssp.h>
__warn_references(tmpnam,
"warning: tmpnam() possibly used unsafely; consider using mkstemp()");
@@ -47,7 +44,7 @@ __warn_references(tmpnam,
extern char *_mktemp(char *);
char *
-tmpnam(char *s)
+__ssp_real(tmpnam)(char *s)
{
static u_long tmpcount;
static char buf[L_tmpnam];
diff --git a/lib/libc/stdio/ungetc.3 b/lib/libc/stdio/ungetc.3
index 9ce4712551c0..946eceed9428 100644
--- a/lib/libc/stdio/ungetc.3
+++ b/lib/libc/stdio/ungetc.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ungetc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt UNGETC 3
.Os
diff --git a/lib/libc/stdio/ungetc.c b/lib/libc/stdio/ungetc.c
index d5c91626dfa1..b494d462a19a 100644
--- a/lib/libc/stdio/ungetc.c
+++ b/lib/libc/stdio/ungetc.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ungetc.c 8.2 (Berkeley) 11/3/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/stdio/ungetwc.3 b/lib/libc/stdio/ungetwc.3
index 2b7427e99ccf..e5d5560417a0 100644
--- a/lib/libc/stdio/ungetwc.3
+++ b/lib/libc/stdio/ungetwc.3
@@ -31,8 +31,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ungetc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 3, 2004
.Dt UNGETWC 3
.Os
diff --git a/lib/libc/stdio/ungetwc.c b/lib/libc/stdio/ungetwc.c
index a4c71d012be0..0a72b6ea1705 100644
--- a/lib/libc/stdio/ungetwc.c
+++ b/lib/libc/stdio/ungetwc.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c
index 2e5f8dd4107a..62d8f09fc954 100644
--- a/lib/libc/stdio/vasprintf.c
+++ b/lib/libc/stdio/vasprintf.c
@@ -34,10 +34,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
-#include <errno.h>
#include "xlocale_private.h"
#include "local.h"
@@ -45,6 +44,7 @@ int
vasprintf_l(char **str, locale_t locale, const char *fmt, __va_list ap)
{
FILE f = FAKE_FILE;
+ int serrno = errno;
int ret;
FIX_LOCALE(locale);
@@ -56,7 +56,7 @@ vasprintf_l(char **str, locale_t locale, const char *fmt, __va_list ap)
return (-1);
}
f._bf._size = f._w = 127; /* Leave room for the NUL */
- ret = __vfprintf(&f, locale, fmt, ap);
+ ret = __vfprintf(&f, locale, serrno, fmt, ap);
if (ret < 0) {
free(f._bf._base);
*str = NULL;
diff --git a/lib/libc/stdio/vdprintf.c b/lib/libc/stdio/vdprintf.c
index a84efaa14b4d..39fb55420953 100644
--- a/lib/libc/stdio/vdprintf.c
+++ b/lib/libc/stdio/vdprintf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <limits.h>
@@ -47,6 +46,7 @@ vdprintf(int fd, const char * __restrict fmt, va_list ap)
{
FILE f = FAKE_FILE;
unsigned char buf[BUFSIZ];
+ int serrno = errno;
int ret;
if (fd > SHRT_MAX) {
@@ -63,7 +63,7 @@ vdprintf(int fd, const char * __restrict fmt, va_list ap)
f._bf._base = buf;
f._bf._size = sizeof(buf);
- if ((ret = __vfprintf(&f, __get_locale(), fmt, ap)) < 0)
+ if ((ret = __vfprintf(&f, __get_locale(), serrno, fmt, ap)) < 0)
return (ret);
return (__fflush(&f) ? EOF : ret);
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 5e5a9b5e31c1..2dc8d9022179 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* Actual printf innards.
*
@@ -72,7 +68,8 @@ static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
#include "printflocal.h"
static int __sprint(FILE *, struct __suio *, locale_t);
-static int __sbprintf(FILE *, locale_t, const char *, va_list) __printflike(3, 0)
+static int __sbprintf(FILE *, locale_t, int, const char *, va_list)
+ __printflike(4, 0)
__noinline;
static char *__wcsconv(wchar_t *, int);
@@ -173,7 +170,7 @@ __sprint(FILE *fp, struct __suio *uio, locale_t locale)
* worries about ungetc buffers and so forth.
*/
static int
-__sbprintf(FILE *fp, locale_t locale, const char *fmt, va_list ap)
+__sbprintf(FILE *fp, locale_t locale, int serrno, const char *fmt, va_list ap)
{
int ret;
FILE fake = FAKE_FILE;
@@ -197,7 +194,7 @@ __sbprintf(FILE *fp, locale_t locale, const char *fmt, va_list ap)
fake._lbfsize = 0; /* not actually used, but Just In Case */
/* do the work, then copy any error status */
- ret = __vfprintf(&fake, locale, fmt, ap);
+ ret = __vfprintf(&fake, locale, serrno, fmt, ap);
if (ret >= 0 && __fflush(&fake))
ret = EOF;
if (fake._flags & __SERR)
@@ -269,8 +266,9 @@ __wcsconv(wchar_t *wcsarg, int prec)
*/
int
vfprintf_l(FILE * __restrict fp, locale_t locale, const char * __restrict fmt0,
- va_list ap)
+ va_list ap)
{
+ int serrno = errno;
int ret;
FIX_LOCALE(locale);
@@ -278,9 +276,9 @@ vfprintf_l(FILE * __restrict fp, locale_t locale, const char * __restrict fmt0,
/* optimise fprintf(stderr) (and other unbuffered Unix files) */
if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) &&
fp->_file >= 0)
- ret = __sbprintf(fp, locale, fmt0, ap);
+ ret = __sbprintf(fp, locale, serrno, fmt0, ap);
else
- ret = __vfprintf(fp, locale, fmt0, ap);
+ ret = __vfprintf(fp, locale, serrno, fmt0, ap);
FUNLOCKFILE_CANCELSAFE();
return (ret);
}
@@ -293,19 +291,15 @@ vfprintf(FILE * __restrict fp, const char * __restrict fmt0, va_list ap)
/*
* The size of the buffer we use as scratch space for integer
* conversions, among other things. We need enough space to
- * write a uintmax_t in octal (plus one byte).
+ * write a uintmax_t in binary.
*/
-#if UINTMAX_MAX <= UINT64_MAX
-#define BUF 32
-#else
-#error "BUF must be large enough to format a uintmax_t"
-#endif
+#define BUF (sizeof(uintmax_t) * CHAR_BIT)
/*
* Non-MT-safe version
*/
int
-__vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
+__vfprintf(FILE *fp, locale_t locale, int serrno, const char *fmt0, va_list ap)
{
char *fmt; /* format string */
int ch; /* character from fmt */
@@ -315,7 +309,8 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
int ret; /* return value accumulator */
int width; /* width from format (%8d), or 0 */
int prec; /* precision from format; <0 for N/A */
- int saved_errno;
+ int error;
+ char errnomsg[NL_TEXTMAX];
char sign; /* sign prefix (' ', '+', '-', or \0) */
struct grouping_state gs; /* thousands' grouping info */
@@ -451,8 +446,6 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
val = GETARG (int); \
}
- if (__use_xprintf == 0 && getenv("USE_XPRINTF"))
- __use_xprintf = 1;
if (__use_xprintf > 0)
return (__xvprintf(fp, fmt0, ap));
@@ -465,7 +458,6 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
savserr = fp->_flags & __SERR;
fp->_flags &= ~__SERR;
- saved_errno = errno;
convbuf = NULL;
fmt = (char *)fmt0;
argtable = NULL;
@@ -610,6 +602,49 @@ reswitch: switch (ch) {
case 't':
flags |= PTRDIFFT;
goto rflag;
+ case 'w':
+ /*
+ * Fixed-width integer types. On all platforms we
+ * support, int8_t is equivalent to char, int16_t
+ * is equivalent to short, int32_t is equivalent
+ * to int, int64_t is equivalent to long long int.
+ * Furthermore, int_fast8_t, int_fast16_t and
+ * int_fast32_t are equivalent to int, and
+ * int_fast64_t is equivalent to long long int.
+ */
+ flags &= ~(CHARINT|SHORTINT|LONGINT|LLONGINT|INTMAXT);
+ if (fmt[0] == 'f') {
+ flags |= FASTINT;
+ fmt++;
+ } else {
+ flags &= ~FASTINT;
+ }
+ if (fmt[0] == '8') {
+ if (!(flags & FASTINT))
+ flags |= CHARINT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 1;
+ } else if (fmt[0] == '1' && fmt[1] == '6') {
+ if (!(flags & FASTINT))
+ flags |= SHORTINT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '3' && fmt[1] == '2') {
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '6' && fmt[1] == '4') {
+ flags |= LLONGINT;
+ fmt += 2;
+ } else {
+ if (flags & FASTINT) {
+ flags &= ~FASTINT;
+ fmt--;
+ }
+ goto invalid;
+ }
+ goto rflag;
case 'z':
flags |= SIZET;
goto rflag;
@@ -790,7 +825,9 @@ fp_common:
break;
#endif /* !NO_FLOATING_POINT */
case 'm':
- cp = strerror(saved_errno);
+ error = __strerror_rl(serrno, errnomsg,
+ sizeof(errnomsg), locale);
+ cp = error == 0 ? errnomsg : "<strerror failure>";
size = (prec >= 0) ? strnlen(cp, prec) : strlen(cp);
sign = '\0';
break;
@@ -932,6 +969,7 @@ number: if ((dprec = prec) >= 0)
default: /* "%?" prints ?, unless ? is NUL */
if (ch == '\0')
goto done;
+invalid:
/* pretend it was %c with argument ch */
cp = buf;
*cp = ch;
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 9727c9e70c34..a678710e1ecb 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -39,10 +39,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ctype.h>
#include <inttypes.h>
@@ -75,6 +71,7 @@ static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
#define SUPPRESS 0x08 /* *: suppress assignment */
#define POINTER 0x10 /* p: void * (as hex) */
#define NOSKIP 0x20 /* [ or c: do not skip blanks */
+#define FASTINT 0x200 /* wfN: int_fastN_t */
#define LONGLONG 0x400 /* ll: long long (+ deprecated q: quad) */
#define INTMAXT 0x800 /* j: intmax_t */
#define PTRDIFFT 0x1000 /* t: ptrdiff_t */
@@ -555,6 +552,45 @@ literal:
case 't':
flags |= PTRDIFFT;
goto again;
+ case 'w':
+ /*
+ * Fixed-width integer types. On all platforms we
+ * support, int8_t is equivalent to char, int16_t
+ * is equivalent to short, int32_t is equivalent
+ * to int, int64_t is equivalent to long long int.
+ * Furthermore, int_fast8_t, int_fast16_t and
+ * int_fast32_t are equivalent to int, and
+ * int_fast64_t is equivalent to long long int.
+ */
+ flags &= ~(SHORTSHORT|SHORT|LONG|LONGLONG|SIZET|INTMAXT|PTRDIFFT);
+ if (fmt[0] == 'f') {
+ flags |= FASTINT;
+ fmt++;
+ } else {
+ flags &= ~FASTINT;
+ }
+ if (fmt[0] == '8') {
+ if (!(flags & FASTINT))
+ flags |= SHORTSHORT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 1;
+ } else if (fmt[0] == '1' && fmt[1] == '6') {
+ if (!(flags & FASTINT))
+ flags |= SHORT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '3' && fmt[1] == '2') {
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '6' && fmt[1] == '4') {
+ flags |= LONGLONG;
+ fmt += 2;
+ } else {
+ goto match_failure;
+ }
+ goto again;
case 'z':
flags |= SIZET;
goto again;
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index 259a86467ea7..0d77bd74567e 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -37,12 +37,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#endif
-#include <sys/cdefs.h>
/*
* Actual wprintf innards.
*
@@ -375,13 +369,9 @@ vfwprintf(FILE * __restrict fp, const wchar_t * __restrict fmt0, va_list ap)
/*
* The size of the buffer we use as scratch space for integer
* conversions, among other things. We need enough space to
- * write a uintmax_t in octal (plus one byte).
+ * write a uintmax_t in binary.
*/
-#if UINTMAX_MAX <= UINT64_MAX
-#define BUF 32
-#else
-#error "BUF must be large enough to format a uintmax_t"
-#endif
+#define BUF (sizeof(uintmax_t) * CHAR_BIT)
/*
* Non-MT-safe version
@@ -681,6 +671,49 @@ reswitch: switch (ch) {
case 't':
flags |= PTRDIFFT;
goto rflag;
+ case 'w':
+ /*
+ * Fixed-width integer types. On all platforms we
+ * support, int8_t is equivalent to char, int16_t
+ * is equivalent to short, int32_t is equivalent
+ * to int, int64_t is equivalent to long long int.
+ * Furthermore, int_fast8_t, int_fast16_t and
+ * int_fast32_t are equivalent to int, and
+ * int_fast64_t is equivalent to long long int.
+ */
+ flags &= ~(CHARINT|SHORTINT|LONGINT|LLONGINT|INTMAXT);
+ if (fmt[0] == 'f') {
+ flags |= FASTINT;
+ fmt++;
+ } else {
+ flags &= ~FASTINT;
+ }
+ if (fmt[0] == '8') {
+ if (!(flags & FASTINT))
+ flags |= CHARINT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 1;
+ } else if (fmt[0] == '1' && fmt[1] == '6') {
+ if (!(flags & FASTINT))
+ flags |= SHORTINT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '3' && fmt[1] == '2') {
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '6' && fmt[1] == '4') {
+ flags |= LLONGINT;
+ fmt += 2;
+ } else {
+ if (flags & FASTINT) {
+ flags &= ~FASTINT;
+ fmt--;
+ }
+ goto invalid;
+ }
+ goto rflag;
case 'z':
flags |= SIZET;
goto rflag;
@@ -993,6 +1026,7 @@ number: if ((dprec = prec) >= 0)
default: /* "%?" prints ?, unless ? is NUL */
if (ch == '\0')
goto done;
+invalid:
/* pretend it was %c with argument ch */
cp = buf;
*cp = ch;
diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
index b03c9dba0699..57206a8407d5 100644
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -39,12 +39,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#endif
-#include <sys/cdefs.h>
#include "namespace.h"
#include <ctype.h>
#include <inttypes.h>
@@ -73,6 +67,7 @@ static char sccsid[] = "@(#)vfscanf.c 8.1 (Berkeley) 6/4/93";
#define SUPPRESS 0x08 /* *: suppress assignment */
#define POINTER 0x10 /* p: void * (as hex) */
#define NOSKIP 0x20 /* [ or c: do not skip blanks */
+#define FASTINT 0x200 /* wfN: int_fastN_t */
#define LONGLONG 0x400 /* ll: long long (+ deprecated q: quad) */
#define INTMAXT 0x800 /* j: intmax_t */
#define PTRDIFFT 0x1000 /* t: ptrdiff_t */
@@ -539,6 +534,45 @@ literal:
case 't':
flags |= PTRDIFFT;
goto again;
+ case 'w':
+ /*
+ * Fixed-width integer types. On all platforms we
+ * support, int8_t is equivalent to char, int16_t
+ * is equivalent to short, int32_t is equivalent
+ * to int, int64_t is equivalent to long long int.
+ * Furthermore, int_fast8_t, int_fast16_t and
+ * int_fast32_t are equivalent to int, and
+ * int_fast64_t is equivalent to long long int.
+ */
+ flags &= ~(SHORTSHORT|SHORT|LONG|LONGLONG|SIZET|INTMAXT|PTRDIFFT);
+ if (fmt[0] == 'f') {
+ flags |= FASTINT;
+ fmt++;
+ } else {
+ flags &= ~FASTINT;
+ }
+ if (fmt[0] == '8') {
+ if (!(flags & FASTINT))
+ flags |= SHORTSHORT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 1;
+ } else if (fmt[0] == '1' && fmt[1] == '6') {
+ if (!(flags & FASTINT))
+ flags |= SHORT;
+ else
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '3' && fmt[1] == '2') {
+ /* no flag set = 32 */ ;
+ fmt += 2;
+ } else if (fmt[0] == '6' && fmt[1] == '4') {
+ flags |= LONGLONG;
+ fmt += 2;
+ } else {
+ goto match_failure;
+ }
+ goto again;
case 'z':
flags |= SIZET;
goto again;
diff --git a/lib/libc/stdio/vprintf.c b/lib/libc/stdio/vprintf.c
index 604870b93b1e..f49f3d5daff0 100644
--- a/lib/libc/stdio/vprintf.c
+++ b/lib/libc/stdio/vprintf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <xlocale.h>
diff --git a/lib/libc/stdio/vscanf.c b/lib/libc/stdio/vscanf.c
index 58fd2a455389..9011a44c8e25 100644
--- a/lib/libc/stdio/vscanf.c
+++ b/lib/libc/stdio/vscanf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include "un-namespace.h"
diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c
index 8fc7f9fdf725..45e4fb529be7 100644
--- a/lib/libc/stdio/vsnprintf.c
+++ b/lib/libc/stdio/vsnprintf.c
@@ -37,24 +37,23 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vsnprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include "local.h"
#include "xlocale_private.h"
+#undef vsnprintf /* _FORTIFY_SOURCE */
+
int
vsnprintf_l(char * __restrict str, size_t n, locale_t locale,
- const char * __restrict fmt, __va_list ap)
+ const char * __restrict fmt, __va_list ap)
{
+ FILE f = FAKE_FILE;
size_t on;
+ int serrno = errno;
int ret;
char dummy[2];
- FILE f = FAKE_FILE;
FIX_LOCALE(locale);
on = n;
@@ -75,7 +74,7 @@ vsnprintf_l(char * __restrict str, size_t n, locale_t locale,
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = n;
- ret = __vfprintf(&f, locale, fmt, ap);
+ ret = __vfprintf(&f, locale, serrno, fmt, ap);
if (on > 0)
*f._p = '\0';
return (ret);
diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c
index 68a2f70469f4..23c18264fa50 100644
--- a/lib/libc/stdio/vsprintf.c
+++ b/lib/libc/stdio/vsprintf.c
@@ -37,27 +37,27 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vsprintf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-#include <stdio.h>
+#include <errno.h>
#include <limits.h>
+#include <stdio.h>
#include "local.h"
#include "xlocale_private.h"
+#undef vsprintf /* _FORTIFY_SOURCE */
+
int
vsprintf_l(char * __restrict str, locale_t locale,
- const char * __restrict fmt, __va_list ap)
+ const char * __restrict fmt, __va_list ap)
{
- int ret;
FILE f = FAKE_FILE;
+ int serrno = errno;
+ int ret;
FIX_LOCALE(locale);
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
f._bf._size = f._w = INT_MAX;
- ret = __vfprintf(&f, locale, fmt, ap);
+ ret = __vfprintf(&f, locale, serrno, fmt, ap);
*f._p = 0;
return (ret);
}
diff --git a/lib/libc/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c
index 0751f0e95b0b..f77928725f92 100644
--- a/lib/libc/stdio/vsscanf.c
+++ b/lib/libc/stdio/vsscanf.c
@@ -37,10 +37,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdio.h>
#include <string.h>
#include "local.h"
diff --git a/lib/libc/stdio/vswprintf.c b/lib/libc/stdio/vswprintf.c
index db1b5d30d09d..e90a05c4cc14 100644
--- a/lib/libc/stdio/vswprintf.c
+++ b/lib/libc/stdio/vswprintf.c
@@ -34,10 +34,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-__FBSDID("FreeBSD: src/lib/libc/stdio/vasprintf.c,v 1.16 2002/08/21 16:19:57 mike Exp ");
-#endif
#include <errno.h>
#include <limits.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/vswscanf.c b/lib/libc/stdio/vswscanf.c
index ecdafbefdc75..be21f4a53f7b 100644
--- a/lib/libc/stdio/vswscanf.c
+++ b/lib/libc/stdio/vswscanf.c
@@ -37,13 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)vsscanf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-__FBSDID("FreeBSD: src/lib/libc/stdio/vsscanf.c,v 1.11 2002/08/21 16:19:57 mike Exp ");
-#endif
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
diff --git a/lib/libc/stdio/vwprintf.c b/lib/libc/stdio/vwprintf.c
index b0e9ac26d3c6..0647130f9732 100644
--- a/lib/libc/stdio/vwprintf.c
+++ b/lib/libc/stdio/vwprintf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/vwscanf.c b/lib/libc/stdio/vwscanf.c
index e2e16ac91e53..b4906184e2c0 100644
--- a/lib/libc/stdio/vwscanf.c
+++ b/lib/libc/stdio/vwscanf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c
index acbe379ad90e..7993f3e3d38f 100644
--- a/lib/libc/stdio/wbuf.c
+++ b/lib/libc/stdio/wbuf.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdio.h>
#include "local.h"
@@ -50,7 +46,6 @@ static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93";
int
__swbuf(int c, FILE *fp)
{
- unsigned char *old_p;
int n;
/*
@@ -86,15 +81,8 @@ __swbuf(int c, FILE *fp)
}
fp->_w--;
*fp->_p++ = c;
- old_p = fp->_p;
- if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) {
- if (__fflush(fp) != 0) {
- if (fp->_p == old_p && errno == EINTR) {
- fp->_p--;
- fp->_w++;
- }
+ if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n'))
+ if (__fflush(fp) != 0)
return (EOF);
- }
- }
return (c);
}
diff --git a/lib/libc/stdio/wprintf.3 b/lib/libc/stdio/wprintf.3
index e694a26f1fcf..d1d2bdfaffd4 100644
--- a/lib/libc/stdio/wprintf.3
+++ b/lib/libc/stdio/wprintf.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" @(#)printf.3 8.1 (Berkeley) 6/4/93
.\" FreeBSD: src/lib/libc/stdio/printf.3,v 1.47 2002/09/06 11:23:55 tjr Exp
.\"
.Dd July 5, 2003
diff --git a/lib/libc/stdio/wprintf.c b/lib/libc/stdio/wprintf.c
index c45640021927..0aa33cc78770 100644
--- a/lib/libc/stdio/wprintf.c
+++ b/lib/libc/stdio/wprintf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/wscanf.3 b/lib/libc/stdio/wscanf.3
index d3c8cd8ac1a0..6b428452e6aa 100644
--- a/lib/libc/stdio/wscanf.3
+++ b/lib/libc/stdio/wscanf.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
.\" FreeBSD: src/lib/libc/stdio/scanf.3,v 1.24 2003/06/28 09:03:25 das Exp
.\"
.Dd July 5, 2003
diff --git a/lib/libc/stdio/wscanf.c b/lib/libc/stdio/wscanf.c
index 9527fcd27767..8e2019c2c490 100644
--- a/lib/libc/stdio/wscanf.c
+++ b/lib/libc/stdio/wscanf.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
diff --git a/lib/libc/stdio/wsetup.c b/lib/libc/stdio/wsetup.c
index b0dd89637b75..61797b035b33 100644
--- a/lib/libc/stdio/wsetup.c
+++ b/lib/libc/stdio/wsetup.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)wsetup.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/stdio/xprintf_errno.c b/lib/libc/stdio/xprintf_errno.c
index db897328f0fe..f1e5421f60c8 100644
--- a/lib/libc/stdio/xprintf_errno.c
+++ b/lib/libc/stdio/xprintf_errno.c
@@ -27,6 +27,7 @@
*/
#include <namespace.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -38,7 +39,8 @@
#include "printf.h"
int
-__printf_arginfo_errno(const struct printf_info *pi __unused, size_t n, int *argt)
+__printf_arginfo_errno(const struct printf_info *pi __unused, size_t n,
+ int *argt)
{
assert(n >= 1);
@@ -47,17 +49,18 @@ __printf_arginfo_errno(const struct printf_info *pi __unused, size_t n, int *arg
}
int
-__printf_render_errno(struct __printf_io *io, const struct printf_info *pi __unused, const void *const *arg)
+__printf_render_errno(struct __printf_io *io, const struct printf_info *pi
+ __unused, const void *const *arg)
{
int ret, error;
char buf[64];
- const char *p;
+ char errnomsg[NL_TEXTMAX];
ret = 0;
error = *((const int *)arg[0]);
if (error >= 0 && error < __hidden_sys_nerr) {
- p = strerror(error);
- return (__printf_out(io, pi, p, strlen(p)));
+ strerror_r(error, errnomsg, sizeof(errnomsg));
+ return (__printf_out(io, pi, errnomsg, strlen(errnomsg)));
}
sprintf(buf, "errno=%d/0x%x", error, error);
ret += __printf_out(io, pi, buf, strlen(buf));
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index 413c9421c0ee..ca199a669be1 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -1,10 +1,8 @@
-# from @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
-
# machine-independent stdlib sources
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/stdlib ${LIBC_SRCTOP}/stdlib
MISRCS+=C99_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
- bsearch.c \
+ bsearch.c bsearch_b.c \
cxa_thread_atexit.c cxa_thread_atexit_impl.c \
div.c exit.c getenv.c getopt.c getopt_long.c \
getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \
@@ -33,7 +31,7 @@ SYM_MAPS+= ${LIBC_SRCTOP}/stdlib/Symbol.map
# machine-dependent stdlib sources
.sinclude "${LIBC_SRCTOP}/${LIBC_ARCH}/stdlib/Makefile.inc"
-MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 \
+MAN+= a64l.3 abort.3 abs.3 atexit.3 atof.3 \
atoi.3 atol.3 at_quick_exit.3 bsearch.3 \
div.3 exit.3 getenv.3 getopt.3 getopt_long.3 getsubopt.3 \
hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \
@@ -44,27 +42,51 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 \
strfmon.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 \
tsearch.3
-MLINKS+=a64l.3 l64a.3 a64l.3 l64a_r.3
+MLINKS+=a64l.3 l64a.3 \
+ a64l.3 l64a_r.3
MLINKS+=atol.3 atoll.3
MLINKS+=exit.3 _Exit.3
-MLINKS+=getenv.3 clearenv.3 getenv.3 putenv.3 getenv.3 secure_getenv.3 \
- getenv.3 setenv.3 getenv.3 unsetenv.3
+MLINKS+=getenv.3 clearenv.3 \
+ getenv.3 putenv.3 \
+ getenv.3 secure_getenv.3 \
+ getenv.3 setenv.3 \
+ getenv.3 unsetenv.3
MLINKS+=getopt_long.3 getopt_long_only.3
-MLINKS+=hcreate.3 hdestroy.3 hcreate.3 hsearch.3
-MLINKS+=hcreate.3 hcreate_r.3 hcreate.3 hdestroy_r.3 hcreate.3 hsearch_r.3
+MLINKS+=hcreate.3 hdestroy.3 \
+ hcreate.3 hsearch.3
+MLINKS+=hcreate.3 hcreate_r.3 \
+ hcreate.3 hdestroy_r.3 \
+ hcreate.3 hsearch_r.3
MLINKS+=insque.3 remque.3
MLINKS+=lsearch.3 lfind.3
-MLINKS+=ptsname.3 grantpt.3 ptsname.3 ptsname_r.3 ptsname.3 unlockpt.3
-MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 qsort.3 qsort_r.3 \
+MLINKS+=ptsname.3 grantpt.3 \
+ ptsname.3 ptsname_r.3 \
+ ptsname.3 unlockpt.3
+MLINKS+=qsort.3 heapsort.3 \
+ qsort.3 heapsort_b.3 \
+ qsort.3 mergesort.3 \
+ qsort.3 mergesort_b.3 \
+ qsort.3 qsort_b.3 \
+ qsort.3 qsort_r.3 \
qsort.3 qsort_s.3
-MLINKS+=rand.3 rand_r.3 rand.3 srand.3
-MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3 \
+MLINKS+=rand.3 rand_r.3 \
+ rand.3 srand.3
+MLINKS+=random.3 initstate.3 \
+ random.3 setstate.3 \
+ random.3 srandom.3 \
random.3 srandomdev.3
MLINKS+=radixsort.3 sradixsort.3
MLINKS+=set_constraint_handler_s.3 abort_handler_s.3
MLINKS+=set_constraint_handler_s.3 ignore_handler_s.3
MLINKS+=strfmon.3 strfmon_l.3
-MLINKS+=strtod.3 strtof.3 strtod.3 strtold.3
-MLINKS+=strtol.3 strtoll.3 strtol.3 strtoq.3 strtol.3 strtoimax.3
-MLINKS+=strtoul.3 strtoull.3 strtoul.3 strtouq.3 strtoul.3 strtoumax.3
-MLINKS+=tsearch.3 tdelete.3 tsearch.3 tfind.3 tsearch.3 twalk.3
+MLINKS+=strtod.3 strtof.3 \
+ strtod.3 strtold.3
+MLINKS+=strtol.3 strtoll.3 \
+ strtol.3 strtoq.3 \
+ strtol.3 strtoimax.3
+MLINKS+=strtoul.3 strtoull.3 \
+ strtoul.3 strtouq.3 \
+ strtoul.3 strtoumax.3
+MLINKS+=tsearch.3 tdelete.3 \
+ tsearch.3 tfind.3 \
+ tsearch.3 twalk.3
diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map
index e10789ceab1a..2b79ca2ece8b 100644
--- a/lib/libc/stdlib/Symbol.map
+++ b/lib/libc/stdlib/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
_Exit;
a64l;
@@ -130,6 +127,10 @@ FBSD_1.7 {
secure_getenv;
};
+FBSD_1.8 {
+ getenv_r;
+};
+
FBSDprivate_1.0 {
__system;
_system;
diff --git a/lib/libc/stdlib/abort.3 b/lib/libc/stdlib/abort.3
index 1ded7b9ee21a..2a14eb44c5a7 100644
--- a/lib/libc/stdlib/abort.3
+++ b/lib/libc/stdlib/abort.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)abort.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 28, 2018
.Dt ABORT 3
.Os
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index 5d8c39987b14..02b01cb3db66 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)abort.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <signal.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/abs.3 b/lib/libc/stdlib/abs.3
index 1464975f494a..d47f83ea0f73 100644
--- a/lib/libc/stdlib/abs.3
+++ b/lib/libc/stdlib/abs.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)abs.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt ABS 3
.Os
diff --git a/lib/libc/stdlib/abs.c b/lib/libc/stdlib/abs.c
index c0f402381c02..baed3795bf5e 100644
--- a/lib/libc/stdlib/abs.c
+++ b/lib/libc/stdlib/abs.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)abs.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h>
int
diff --git a/lib/libc/stdlib/alloca.3 b/lib/libc/stdlib/alloca.3
deleted file mode 100644
index 443e48edff89..000000000000
--- a/lib/libc/stdlib/alloca.3
+++ /dev/null
@@ -1,87 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)alloca.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd September 5, 2006
-.Dt ALLOCA 3
-.Os
-.Sh NAME
-.Nm alloca
-.Nd memory allocator
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft void *
-.Fn alloca "size_t size"
-.Sh DESCRIPTION
-The
-.Fn alloca
-function
-allocates
-.Fa size
-bytes of space in the stack frame of the caller.
-This temporary space is automatically freed on
-return.
-.Sh RETURN VALUES
-The
-.Fn alloca
-function returns a pointer to the beginning of the allocated space.
-.Sh SEE ALSO
-.Xr brk 2 ,
-.Xr calloc 3 ,
-.Xr getpagesize 3 ,
-.Xr malloc 3 ,
-.Xr realloc 3
-.Sh HISTORY
-The
-.Fn alloca
-function appeared in
-.At 32v .
-.\" .Bx ?? .
-.\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd
-.\" The first man page (or link to a man page that I can find at the
-.\" moment is 4.3...
-.Sh BUGS
-The
-.Fn alloca
-function
-is machine and compiler dependent;
-its use is discouraged.
-.Pp
-The
-.Fn alloca
-function is slightly unsafe because it cannot ensure that the pointer
-returned points to a valid and usable block of memory.
-The allocation made may exceed the bounds of the stack, or even go
-further into other objects in memory, and
-.Fn alloca
-cannot determine such an error.
-Avoid
-.Fn alloca
-with large unbounded allocations.
diff --git a/lib/libc/stdlib/atexit.3 b/lib/libc/stdlib/atexit.3
index 4b55942daeb6..4ff384813550 100644
--- a/lib/libc/stdlib/atexit.3
+++ b/lib/libc/stdlib/atexit.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)atexit.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd September 6, 2002
.Dt ATEXIT 3
.Os
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c
index 6b63d9e728c4..6e4a12f9e530 100644
--- a/lib/libc/stdlib/atexit.c
+++ b/lib/libc/stdlib/atexit.c
@@ -32,13 +32,10 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)atexit.c 8.2 (Berkeley) 7/3/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <link.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
@@ -60,6 +57,8 @@ _Block_copy(void*);
#define ATEXIT_FN_CXA 2
static pthread_mutex_t atexit_mutex = PTHREAD_MUTEX_INITIALIZER;
+static void *current_finalize_dso = NULL;
+static bool call_finalize_again = false;
#define _MUTEX_LOCK(x) if (__isthreaded) _pthread_mutex_lock(x)
#define _MUTEX_UNLOCK(x) if (__isthreaded) _pthread_mutex_unlock(x)
@@ -119,6 +118,9 @@ atexit_register(struct atexit_fn *fptr)
__atexit = p;
}
p->fns[p->ind++] = *fptr;
+ if (current_finalize_dso != NULL &&
+ current_finalize_dso == fptr->fn_dso)
+ call_finalize_again = true;
_MUTEX_UNLOCK(&atexit_mutex);
return 0;
}
@@ -212,33 +214,38 @@ __cxa_finalize(void *dso)
}
_MUTEX_LOCK(&atexit_mutex);
- for (p = __atexit; p; p = p->next) {
- for (n = p->ind; --n >= 0;) {
- if (p->fns[n].fn_type == ATEXIT_FN_EMPTY)
- continue; /* already been called */
- fn = p->fns[n];
- if (dso != NULL && dso != fn.fn_dso) {
- /* wrong DSO ? */
- if (!has_phdr || global_exit ||
- !__elf_phdr_match_addr(&phdr_info,
- fn.fn_ptr.cxa_func))
- continue;
+ current_finalize_dso = dso;
+ do {
+ call_finalize_again = false;
+ for (p = __atexit; p; p = p->next) {
+ for (n = p->ind; --n >= 0;) {
+ if (p->fns[n].fn_type == ATEXIT_FN_EMPTY)
+ continue; /* already been called */
+ fn = p->fns[n];
+ if (dso != NULL && dso != fn.fn_dso) {
+ /* wrong DSO ? */
+ if (!has_phdr || global_exit ||
+ !__elf_phdr_match_addr(&phdr_info,
+ fn.fn_ptr.cxa_func))
+ continue;
+ }
+ /*
+ Mark entry to indicate that this particular
+ handler has already been called.
+ */
+ p->fns[n].fn_type = ATEXIT_FN_EMPTY;
+ _MUTEX_UNLOCK(&atexit_mutex);
+
+ /* Call the function of correct type. */
+ if (fn.fn_type == ATEXIT_FN_CXA)
+ fn.fn_ptr.cxa_func(fn.fn_arg);
+ else if (fn.fn_type == ATEXIT_FN_STD)
+ fn.fn_ptr.std_func();
+ _MUTEX_LOCK(&atexit_mutex);
}
- /*
- Mark entry to indicate that this particular handler
- has already been called.
- */
- p->fns[n].fn_type = ATEXIT_FN_EMPTY;
- _MUTEX_UNLOCK(&atexit_mutex);
-
- /* Call the function of correct type. */
- if (fn.fn_type == ATEXIT_FN_CXA)
- fn.fn_ptr.cxa_func(fn.fn_arg);
- else if (fn.fn_type == ATEXIT_FN_STD)
- fn.fn_ptr.std_func();
- _MUTEX_LOCK(&atexit_mutex);
}
- }
+ } while (call_finalize_again);
+ current_finalize_dso = NULL;
_MUTEX_UNLOCK(&atexit_mutex);
if (dso == NULL)
_MUTEX_DESTROY(&atexit_mutex);
diff --git a/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h
index 456168325e46..3cfe5d3df36d 100644
--- a/lib/libc/stdlib/atexit.h
+++ b/lib/libc/stdlib/atexit.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)atexit.h 8.2 (Berkeley) 7/3/94
*/
/* must be at least 32 to guarantee ANSI conformance */
diff --git a/lib/libc/stdlib/atof.3 b/lib/libc/stdlib/atof.3
index 7a2a04156b6f..8129d4b77c7f 100644
--- a/lib/libc/stdlib/atof.3
+++ b/lib/libc/stdlib/atof.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)atof.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 1, 2020
.Dt ATOF 3
.Os
diff --git a/lib/libc/stdlib/atof.c b/lib/libc/stdlib/atof.c
index b058f10deb87..2376249dc65f 100644
--- a/lib/libc/stdlib/atof.c
+++ b/lib/libc/stdlib/atof.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)atof.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <xlocale.h>
diff --git a/lib/libc/stdlib/atoi.3 b/lib/libc/stdlib/atoi.3
index ea685f53e41c..da03e91de747 100644
--- a/lib/libc/stdlib/atoi.3
+++ b/lib/libc/stdlib/atoi.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)atoi.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 1, 2020
.Dt ATOI 3
.Os
diff --git a/lib/libc/stdlib/atoi.c b/lib/libc/stdlib/atoi.c
index dfaf659458f5..7dd888d9b6e7 100644
--- a/lib/libc/stdlib/atoi.c
+++ b/lib/libc/stdlib/atoi.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <xlocale.h>
diff --git a/lib/libc/stdlib/atol.3 b/lib/libc/stdlib/atol.3
index b479f5e5ee2c..714c3ac65cfa 100644
--- a/lib/libc/stdlib/atol.3
+++ b/lib/libc/stdlib/atol.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)atol.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 14, 2013
.Dt ATOL 3
.Os
diff --git a/lib/libc/stdlib/atol.c b/lib/libc/stdlib/atol.c
index a36633f04d8c..356efbc99aef 100644
--- a/lib/libc/stdlib/atol.c
+++ b/lib/libc/stdlib/atol.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)atol.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <xlocale.h>
diff --git a/lib/libc/stdlib/atoll.c b/lib/libc/stdlib/atoll.c
index 95efac77eb82..4819c3f56150 100644
--- a/lib/libc/stdlib/atoll.c
+++ b/lib/libc/stdlib/atoll.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <xlocale.h>
diff --git a/lib/libc/stdlib/bsearch.3 b/lib/libc/stdlib/bsearch.3
index fe7aa20ae578..712be0f98381 100644
--- a/lib/libc/stdlib/bsearch.3
+++ b/lib/libc/stdlib/bsearch.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)bsearch.3 8.3 (Berkeley) 4/19/94
-.\"
.Dd July 17, 2019
.Dt BSEARCH 3
.Os
diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c
index 9934716fd196..96c728e1c997 100644
--- a/lib/libc/stdlib/bsearch.c
+++ b/lib/libc/stdlib/bsearch.c
@@ -29,16 +29,13 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bsearch.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stddef.h>
#include <stdlib.h>
#ifdef I_AM_BSEARCH_B
#include "block_abi.h"
#define COMPAR(x,y) CALL_BLOCK(compar, x, y)
+typedef DECLARE_BLOCK(int, compar_block, const void *, const void *);
#else
#define COMPAR(x,y) compar(x, y)
#endif
@@ -62,7 +59,7 @@ static char sccsid[] = "@(#)bsearch.c 8.1 (Berkeley) 6/4/93";
#ifdef I_AM_BSEARCH_B
void *
bsearch_b(const void *key, const void *base0, size_t nmemb, size_t size,
- DECLARE_BLOCK(int, compar, const void *, const void *))
+ compar_block compar)
#else
void *
bsearch(const void *key, const void *base0, size_t nmemb, size_t size,
diff --git a/lib/libc/stdlib/cxa_thread_atexit.c b/lib/libc/stdlib/cxa_thread_atexit.c
index c6eb1278fcd2..1715bc6d125c 100644
--- a/lib/libc/stdlib/cxa_thread_atexit.c
+++ b/lib/libc/stdlib/cxa_thread_atexit.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "libc_private.h"
int
diff --git a/lib/libc/stdlib/cxa_thread_atexit_impl.c b/lib/libc/stdlib/cxa_thread_atexit_impl.c
index 6883f5290829..3123bd12dca8 100644
--- a/lib/libc/stdlib/cxa_thread_atexit_impl.c
+++ b/lib/libc/stdlib/cxa_thread_atexit_impl.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include "namespace.h"
#include <errno.h>
@@ -103,7 +102,7 @@ walk_cb_call(struct cxa_thread_dtor *dtor)
{
struct dl_phdr_info phdr_info;
- if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
+ if (_rtld_addr_phdr(dtor->func, &phdr_info) &&
__elf_phdr_match_addr(&phdr_info, dtor->func))
dtor->func(dtor->obj);
else
diff --git a/lib/libc/stdlib/div.3 b/lib/libc/stdlib/div.3
index e1e54bfe68cb..55c1bd107cb7 100644
--- a/lib/libc/stdlib/div.3
+++ b/lib/libc/stdlib/div.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)div.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 14, 2001
.Dt DIV 3
.Os
diff --git a/lib/libc/stdlib/div.c b/lib/libc/stdlib/div.c
index c7bb8c44aa79..351dca870553 100644
--- a/lib/libc/stdlib/div.c
+++ b/lib/libc/stdlib/div.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)div.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h> /* div_t */
div_t
@@ -45,34 +41,6 @@ div(int num, int denom)
r.quot = num / denom;
r.rem = num % denom;
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
- /*
- * The ANSI standard says that |r.quot| <= |n/d|, where
- * n/d is to be computed in infinite precision. In other
- * words, we should always truncate the quotient towards
- * 0, never -infinity.
- *
- * Machine division and remainer may work either way when
- * one or both of n or d is negative. If only one is
- * negative and r.quot has been truncated towards -inf,
- * r.rem will have the same sign as denom and the opposite
- * sign of num; if both are negative and r.quot has been
- * truncated towards -inf, r.rem will be positive (will
- * have the opposite sign of num). These are considered
- * `wrong'.
- *
- * If both are num and denom are positive, r will always
- * be positive.
- *
- * This all boils down to:
- * if num >= 0, but r.rem < 0, we got the wrong answer.
- * In that case, to get the right answer, add 1 to r.quot and
- * subtract denom from r.rem.
- */
- if (num >= 0 && r.rem < 0) {
- r.quot++;
- r.rem -= denom;
- }
-#endif
+
return (r);
}
diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3
index afdc58ec4831..bfb14c5c9f83 100644
--- a/lib/libc/stdlib/exit.3
+++ b/lib/libc/stdlib/exit.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)exit.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 5, 2021
+.Dd July 24, 2024
.Dt EXIT 3
.Os
.Sh NAME
@@ -80,7 +78,7 @@ The
implementation of the
.Fn _Exit
function does not call destructors registered with
-.Xr __cxa_atexit 3,
+.Xr __cxa_atexit 3 ,
does not flush buffers, and does not close streams.
.Pp
Both functions make the low-order eight bits of the
@@ -104,6 +102,37 @@ values described in
.Xr sysexits 3
may be used to provide more information to the parent process.
.Pp
+The complete
+.Fa status
+value is avaliable as
+.Va si_status
+member of the
+.Vt siginfo_t
+structure, to the
+.Xr wait6 2
+and
+.Xr sigwaitinfo 2
+callers, and
+.Va SIGCHLD
+signal handlers.
+.Pp
+Calls to the
+.Fn exit
+function are serialized.
+All functions registered by
+.Xr atexit 3
+are executed in the first thread that called
+.Nm exit .
+If any other thread of the process calls
+.Nm exit
+before all registered functions have completed or before the process
+terminates, the thread is blocked until the process terminates.
+The exit status of the process is the
+.Fa status
+argument of the first
+.Nm exit
+call which thread proceeds the atexit handlers.
+.Pp
Note that
.Fn exit
does nothing to prevent bottomless recursion should a function registered
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c
index 111b735be0a0..16631fad5b90 100644
--- a/lib/libc/stdlib/exit.c
+++ b/lib/libc/stdlib/exit.c
@@ -29,12 +29,9 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)exit.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdlib.h>
+#include <pthread.h>
#include <unistd.h>
#include "un-namespace.h"
@@ -52,6 +49,20 @@ void (*__cleanup)(void);
*/
int __isthreaded = 0;
+static pthread_mutex_t exit_mutex;
+static pthread_once_t exit_mutex_once = PTHREAD_ONCE_INIT;
+
+static void
+exit_mutex_init_once(void)
+{
+ pthread_mutexattr_t ma;
+
+ _pthread_mutexattr_init(&ma);
+ _pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE);
+ _pthread_mutex_init(&exit_mutex, &ma);
+ _pthread_mutexattr_destroy(&ma);
+}
+
/*
* Exit, flushing stdio buffers if necessary.
*/
@@ -63,6 +74,12 @@ exit(int status)
_thread_autoinit_dummy_decl = 1;
+ /* Make exit(3) thread-safe */
+ if (__isthreaded) {
+ _once(&exit_mutex_once, exit_mutex_init_once);
+ _pthread_mutex_lock(&exit_mutex);
+ }
+
/*
* We're dealing with cleaning up thread_local destructors in the case of
* the process termination through main() exit.
diff --git a/lib/libc/stdlib/getenv.3 b/lib/libc/stdlib/getenv.3
index df5c1e59074a..045a1831dfdc 100644
--- a/lib/libc/stdlib/getenv.3
+++ b/lib/libc/stdlib/getenv.3
@@ -29,14 +29,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getenv.3 8.2 (Berkeley) 12/11/93
-.\"
-.Dd March 14, 2023
+.Dd April 22, 2025
.Dt GETENV 3
.Os
.Sh NAME
.Nm clearenv ,
.Nm getenv ,
+.Nm getenv_r ,
.Nm putenv ,
.Nm secure_getenv ,
.Nm setenv ,
@@ -50,6 +49,8 @@
.Fn clearenv "void"
.Ft char *
.Fn getenv "const char *name"
+.Ft int
+.Fn getenv_r "const char *name" "char *buf" "size_t len"
.Ft char *
.Fn secure_getenv "const char *name"
.Ft int
@@ -73,7 +74,8 @@ and
.Pp
The
.Fn getenv
-function obtains the current value of the environment variable,
+function obtains the current value of the environment variable
+designated by
.Fa name .
The application should not modify the string pointed
to by the
@@ -81,13 +83,23 @@ to by the
function.
.Pp
The
+.Fn getenv_r
+function obtains the current value of the environment variable
+designated by
+.Fa name
+and copies it into the buffer
+.Fa buf
+of length
+.Fa len .
+.Pp
+The
.Fn secure_getenv
returns
.Va NULL
when the environment cannot be trusted, otherwise it acts like
.Fn getenv .
The environment currently is not trusted when
-.Xr issetugid 3
+.Xr issetugid 2
returns a non-zero value, but other conditions may be added
in the future.
.Pp
@@ -159,12 +171,13 @@ function returns
if the process is in "secure execution," otherwise it will call
.Fn getenv .
.Pp
-.Rv -std clearenv setenv putenv unsetenv
+.Rv -std clearenv getenv_r setenv putenv unsetenv
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EINVAL
The function
.Fn getenv ,
+.Fn getenv_r ,
.Fn setenv
or
.Fn unsetenv
@@ -193,6 +206,11 @@ is the first character in
This does not follow the
.Tn POSIX
specification.
+.It Bq Er ENOENT
+The function
+.Fn getenv_r
+failed because the requested variable was not found in the
+environment.
.It Bq Er ENOMEM
The function
.Fn setenv ,
@@ -200,6 +218,11 @@ The function
or
.Fn putenv
failed because they were unable to allocate memory for the environment.
+.It Bq Er ERANGE
+The function
+.Fn getenv_r
+failed because the value of the requested variable was too long to fit
+in the provided buffer.
.El
.Sh SEE ALSO
.Xr csh 1 ,
@@ -220,7 +243,8 @@ functions conforms to
.St -p1003.1-2001 .
The
.Fn secure_getenv
-function is expected to be glibc-compatible.
+function conforms to
+.St -p1003.1-2024 .
.Sh HISTORY
The functions
.Fn setenv
@@ -252,6 +276,13 @@ and
.Fn secure_getenv
functions were added in
.Fx 14 .
+.Pp
+The
+.Fn getenv_r
+function first appeared in
+.Nx 4.0
+and was added in
+.Fx 15 .
.Sh BUGS
Successive calls to
.Fn setenv
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index f7206f3af29b..c1d0b7a559d5 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -26,9 +26,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
+#include <ssp/ssp.h>
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
@@ -445,6 +445,41 @@ getenv(const char *name)
/*
+ * Like getenv(), but copies the value into the provided buffer.
+ */
+int
+__ssp_real(getenv_r)(const char *name, char *buf, size_t len)
+{
+ const char *val;
+ size_t nameLen;
+ int envNdx;
+
+ if (name == NULL || (nameLen = __strleneq(name)) == 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ if (environ == NULL || environ[0] == NULL) {
+ val = NULL;
+ } else if (envVars == NULL || environ != intEnviron) {
+ val = __findenv_environ(name, nameLen);
+ } else {
+ envNdx = envVarsTotal - 1;
+ val = __findenv(name, nameLen, &envNdx, true);
+ }
+ if (val == NULL) {
+ errno = ENOENT;
+ return (-1);
+ }
+ if (strlcpy(buf, val, len) >= len) {
+ errno = ERANGE;
+ return (-1);
+ }
+ return (0);
+}
+
+
+/*
* Runs getenv() unless the current process is tainted by uid or gid changes, in
* which case it will return NULL.
*/
diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3
index 3e26e798ddb4..a5b5bff9d1a7 100644
--- a/lib/libc/stdlib/getopt.3
+++ b/lib/libc/stdlib/getopt.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95
-.\"
.Dd June 5, 2014
.Dt GETOPT 3
.Os
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c
index 5b50d587c92e..2b5e3fa69032 100644
--- a/lib/libc/stdlib/getopt.c
+++ b/lib/libc/stdlib/getopt.c
@@ -31,10 +31,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/getopt_long.3 b/lib/libc/stdlib/getopt_long.3
index 16fadd7733fd..d6998d13822a 100644
--- a/lib/libc/stdlib/getopt_long.3
+++ b/lib/libc/stdlib/getopt_long.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getopt.3 8.5 (Berkeley) 4/27/95
-.\"
.Dd December 24, 2022
.Dt GETOPT_LONG 3
.Os
@@ -219,7 +217,7 @@ an error and return
Specifying
.Ql \&:
in
-.Fa optstr
+.Fa optstring
will cause the error message to be suppressed and
.Ql \&:
to be returned instead.
@@ -231,7 +229,7 @@ a leading
or
.Ql \&-
in
-.Fa optstr
+.Fa optstring
also has special meaning.
If either of these are specified, they must appear before
.Ql \&: .
diff --git a/lib/libc/stdlib/getopt_long.c b/lib/libc/stdlib/getopt_long.c
index 3e6e3fd431bb..5cf6a55649bd 100644
--- a/lib/libc/stdlib/getopt_long.c
+++ b/lib/libc/stdlib/getopt_long.c
@@ -49,12 +49,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: getopt_long.c,v 1.16 2004/02/04 18:17:25 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-#endif
-#include <sys/cdefs.h>
#include <err.h>
#include <errno.h>
#include <getopt.h>
diff --git a/lib/libc/stdlib/getsubopt.3 b/lib/libc/stdlib/getsubopt.3
index 1f9ed58b2ae1..cd2845aefdcb 100644
--- a/lib/libc/stdlib/getsubopt.3
+++ b/lib/libc/stdlib/getsubopt.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd December 25, 2011
.Dt GETSUBOPT 3
.Os
diff --git a/lib/libc/stdlib/getsubopt.c b/lib/libc/stdlib/getsubopt.c
index dfcca7a7209d..8ff0f13655e1 100644
--- a/lib/libc/stdlib/getsubopt.c
+++ b/lib/libc/stdlib/getsubopt.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/stdlib/hcreate.c b/lib/libc/stdlib/hcreate.c
index 969e31bfc461..261f55bfec39 100644
--- a/lib/libc/stdlib/hcreate.c
+++ b/lib/libc/stdlib/hcreate.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <search.h>
#include <stdbool.h>
#include <stddef.h>
diff --git a/lib/libc/stdlib/hcreate_r.c b/lib/libc/stdlib/hcreate_r.c
index 82204b7982be..90eff3318be9 100644
--- a/lib/libc/stdlib/hcreate_r.c
+++ b/lib/libc/stdlib/hcreate_r.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <search.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/hdestroy_r.c b/lib/libc/stdlib/hdestroy_r.c
index 42ad8b1b4e0d..e9435c43bca1 100644
--- a/lib/libc/stdlib/hdestroy_r.c
+++ b/lib/libc/stdlib/hdestroy_r.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <search.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c
index 3a795db70448..7816caf17048 100644
--- a/lib/libc/stdlib/heapsort.c
+++ b/lib/libc/stdlib/heapsort.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)heapsort.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/hsearch_r.c b/lib/libc/stdlib/hsearch_r.c
index e398a1d5b913..15c2c156fbec 100644
--- a/lib/libc/stdlib/hsearch_r.c
+++ b/lib/libc/stdlib/hsearch_r.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <search.h>
diff --git a/lib/libc/stdlib/imaxabs.c b/lib/libc/stdlib/imaxabs.c
index ad7c3fd26e47..08a27ac98da7 100644
--- a/lib/libc/stdlib/imaxabs.c
+++ b/lib/libc/stdlib/imaxabs.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <inttypes.h>
intmax_t
diff --git a/lib/libc/stdlib/imaxdiv.c b/lib/libc/stdlib/imaxdiv.c
index a2ed360fa868..bf9737a3c47a 100644
--- a/lib/libc/stdlib/imaxdiv.c
+++ b/lib/libc/stdlib/imaxdiv.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <inttypes.h>
/* See comments in div.c for implementation details. */
@@ -37,11 +36,6 @@ imaxdiv(intmax_t numer, intmax_t denom)
retval.quot = numer / denom;
retval.rem = numer % denom;
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
- if (numer >= 0 && retval.rem < 0) {
- retval.quot++;
- retval.rem -= denom;
- }
-#endif
+
return (retval);
}
diff --git a/lib/libc/stdlib/insque.c b/lib/libc/stdlib/insque.c
index 46b250893264..3af31eb15554 100644
--- a/lib/libc/stdlib/insque.c
+++ b/lib/libc/stdlib/insque.c
@@ -6,7 +6,6 @@
* As long as the above copyright statement and this notice remain
* unchanged, you can do what ever you want with this file.
*/
-#include <sys/cdefs.h>
#define _SEARCH_PRIVATE
#include <search.h>
#ifdef DEBUG
diff --git a/lib/libc/stdlib/labs.3 b/lib/libc/stdlib/labs.3
index b0bfd64fc586..97f527b7d941 100644
--- a/lib/libc/stdlib/labs.3
+++ b/lib/libc/stdlib/labs.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)labs.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 14, 2001
.Dt LABS 3
.Os
diff --git a/lib/libc/stdlib/labs.c b/lib/libc/stdlib/labs.c
index 8eb58252dd83..23696f1c0f0c 100644
--- a/lib/libc/stdlib/labs.c
+++ b/lib/libc/stdlib/labs.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)labs.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h>
long
diff --git a/lib/libc/stdlib/ldiv.3 b/lib/libc/stdlib/ldiv.3
index a6204393bf90..66abb00d4d6c 100644
--- a/lib/libc/stdlib/ldiv.3
+++ b/lib/libc/stdlib/ldiv.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ldiv.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt LDIV 3
.Os
diff --git a/lib/libc/stdlib/ldiv.c b/lib/libc/stdlib/ldiv.c
index 0d1835a03d0c..4c73bcc14af4 100644
--- a/lib/libc/stdlib/ldiv.c
+++ b/lib/libc/stdlib/ldiv.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ldiv.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stdlib.h> /* ldiv_t */
ldiv_t
@@ -47,11 +43,6 @@ ldiv(long num, long denom)
r.quot = num / denom;
r.rem = num % denom;
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
- if (num >= 0 && r.rem < 0) {
- r.quot++;
- r.rem -= denom;
- }
-#endif
+
return (r);
}
diff --git a/lib/libc/stdlib/llabs.c b/lib/libc/stdlib/llabs.c
index ad7fbdda1660..ac151e3a5036 100644
--- a/lib/libc/stdlib/llabs.c
+++ b/lib/libc/stdlib/llabs.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
long long
diff --git a/lib/libc/stdlib/lldiv.c b/lib/libc/stdlib/lldiv.c
index 91dc062e9e15..6feeb74bacd6 100644
--- a/lib/libc/stdlib/lldiv.c
+++ b/lib/libc/stdlib/lldiv.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
/* See comments in div.c for implementation details. */
@@ -37,11 +36,6 @@ lldiv(long long numer, long long denom)
retval.quot = numer / denom;
retval.rem = numer % denom;
-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
- if (numer >= 0 && retval.rem < 0) {
- retval.quot++;
- retval.rem -= denom;
- }
-#endif
+
return (retval);
}
diff --git a/lib/libc/stdlib/lsearch.c b/lib/libc/stdlib/lsearch.c
index 1ca55cc9002e..e2b83473411e 100644
--- a/lib/libc/stdlib/lsearch.c
+++ b/lib/libc/stdlib/lsearch.c
@@ -7,7 +7,6 @@
* unchanged, you can do what ever you want with this file.
*/
#include <sys/types.h>
-#include <sys/cdefs.h>
#define _SEARCH_PRIVATE
#include <search.h>
#include <stdint.h> /* for uint8_t */
diff --git a/lib/libc/stdlib/malloc/Symbol.map b/lib/libc/stdlib/malloc/Symbol.map
index 4356337d1c37..d3aa7f3f9988 100644
--- a/lib/libc/stdlib/malloc/Symbol.map
+++ b/lib/libc/stdlib/malloc/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
_malloc_options;
_malloc_message;
@@ -26,11 +23,6 @@ FBSD_1.3 {
sallocx;
dallocx;
nallocx;
- allocm;
- rallocm;
- sallocm;
- dallocm;
- nallocm;
__malloc;
__calloc;
__realloc;
@@ -43,11 +35,6 @@ FBSD_1.3 {
__sallocx;
__dallocx;
__nallocx;
- __allocm;
- __rallocm;
- __sallocm;
- __dallocm;
- __nallocm;
};
FBSD_1.4 {
diff --git a/lib/libc/stdlib/malloc/jemalloc/Makefile.inc b/lib/libc/stdlib/malloc/jemalloc/Makefile.inc
index 1ba7725fe8a8..c10d79dbce6c 100644
--- a/lib/libc/stdlib/malloc/jemalloc/Makefile.inc
+++ b/lib/libc/stdlib/malloc/jemalloc/Makefile.inc
@@ -1,10 +1,15 @@
+.PATH: ${LIBC_SRCTOP}/stdlib/malloc/jemalloc
+
JEMALLOCSRCS:= jemalloc.c arena.c background_thread.c base.c bin.c bitmap.c \
ckh.c ctl.c div.c extent.c extent_dss.c extent_mmap.c hash.c hook.c \
large.c log.c malloc_io.c mutex.c mutex_pool.c nstime.c pages.c \
prng.c prof.c rtree.c safety_check.c sc.c stats.c sz.c tcache.c \
test_hooks.c ticker.c tsd.c witness.c
-CFLAGS+=-I${SRCTOP}/contrib/jemalloc/include
+CFLAGS+=-I${SRCTOP}/contrib/jemalloc/include -I${LIBC_SRCTOP}/stdlib/malloc/jemalloc/include
+.if ${MK_JEMALLOC_LG_VADDR_WIDE} != no
+CFLAGS+=-D_USE_LG_VADDR_WIDE
+.endif
.for src in ${JEMALLOCSRCS}
MISRCS+=jemalloc_${src}
@@ -13,10 +18,7 @@ jemalloc_${src}: ${SRCTOP}/contrib/jemalloc/src/${src} .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}
.endfor
-MAN+=jemalloc.3
-CLEANFILES+=jemalloc.3
-jemalloc.3: ${SRCTOP}/contrib/jemalloc/doc/jemalloc.3 .NOMETA
- ln -sf ${.ALLSRC} ${.TARGET}
+MAN+= jemalloc.3
MLINKS+= \
jemalloc.3 malloc.3 \
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
new file mode 100644
index 000000000000..1aedb916976b
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs.h
@@ -0,0 +1,367 @@
+/* include/jemalloc/internal/jemalloc_internal_defs.h. Generated from jemalloc_internal_defs.h.in by configure. */
+#ifndef JEMALLOC_INTERNAL_DEFS_H_
+#define JEMALLOC_INTERNAL_DEFS_H_
+/*
+ * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all
+ * public APIs to be prefixed. This makes it possible, with some care, to use
+ * multiple allocators simultaneously.
+ */
+/* #undef JEMALLOC_PREFIX */
+/* #undef JEMALLOC_CPREFIX */
+
+/*
+ * Define overrides for non-standard allocator-related functions if they are
+ * present on the system.
+ */
+/* #undef JEMALLOC_OVERRIDE___LIBC_CALLOC */
+/* #undef JEMALLOC_OVERRIDE___LIBC_FREE */
+/* #undef JEMALLOC_OVERRIDE___LIBC_MALLOC */
+/* #undef JEMALLOC_OVERRIDE___LIBC_MEMALIGN */
+/* #undef JEMALLOC_OVERRIDE___LIBC_REALLOC */
+/* #undef JEMALLOC_OVERRIDE___LIBC_VALLOC */
+#define JEMALLOC_OVERRIDE___POSIX_MEMALIGN
+
+/*
+ * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
+ * For shared libraries, symbol visibility mechanisms prevent these symbols
+ * from being exported, but for static libraries, naming collisions are a real
+ * possibility.
+ */
+#define JEMALLOC_PRIVATE_NAMESPACE __je_
+
+/*
+ * Hyper-threaded CPUs may need a special instruction inside spin loops in
+ * order to yield to another virtual CPU.
+ */
+#define CPU_SPINWAIT __asm__ volatile("pause")
+/* 1 if CPU_SPINWAIT is defined, 0 otherwise. */
+#define HAVE_CPU_SPINWAIT 1
+
+/*
+ * Number of significant bits in virtual addresses. This may be less than the
+ * total number of bits in a pointer, e.g. on x64, for which the uppermost 16
+ * bits are the same as bit 47.
+ */
+#define LG_VADDR 48
+
+/* Defined if C11 atomics are available. */
+#define JEMALLOC_C11_ATOMICS 1
+
+/* Defined if GCC __atomic atomics are available. */
+#define JEMALLOC_GCC_ATOMIC_ATOMICS 1
+/* and the 8-bit variant support. */
+#define JEMALLOC_GCC_U8_ATOMIC_ATOMICS 1
+
+/* Defined if GCC __sync atomics are available. */
+#define JEMALLOC_GCC_SYNC_ATOMICS 1
+/* and the 8-bit variant support. */
+#define JEMALLOC_GCC_U8_SYNC_ATOMICS 1
+
+/*
+ * Defined if __builtin_clz() and __builtin_clzl() are available.
+ */
+#define JEMALLOC_HAVE_BUILTIN_CLZ
+
+/*
+ * Defined if os_unfair_lock_*() functions are available, as provided by Darwin.
+ */
+/* #undef JEMALLOC_OS_UNFAIR_LOCK */
+
+/* Defined if syscall(2) is usable. */
+#define JEMALLOC_USE_SYSCALL
+
+/*
+ * Defined if secure_getenv(3) is available.
+ */
+/* #undef JEMALLOC_HAVE_SECURE_GETENV */
+
+/*
+ * Defined if issetugid(2) is available.
+ */
+#define JEMALLOC_HAVE_ISSETUGID
+
+/* Defined if pthread_atfork(3) is available. */
+#define JEMALLOC_HAVE_PTHREAD_ATFORK
+
+/* Defined if pthread_setname_np(3) is available. */
+/* #undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP */
+
+/*
+ * Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
+ */
+/* #undef JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE */
+
+/*
+ * Defined if clock_gettime(CLOCK_MONOTONIC, ...) is available.
+ */
+#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1
+
+/*
+ * Defined if mach_absolute_time() is available.
+ */
+/* #undef JEMALLOC_HAVE_MACH_ABSOLUTE_TIME */
+
+/*
+ * Defined if _malloc_thread_cleanup() exists. At least in the case of
+ * FreeBSD, pthread_key_create() allocates, which if used during malloc
+ * bootstrapping will cause recursion into the pthreads library. Therefore, if
+ * _malloc_thread_cleanup() exists, use it as the basis for thread cleanup in
+ * malloc_tsd.
+ */
+#define JEMALLOC_MALLOC_THREAD_CLEANUP
+
+/*
+ * Defined if threaded initialization is known to be safe on this platform.
+ * Among other things, it must be possible to initialize a mutex without
+ * triggering allocation in order for threaded allocation to be safe.
+ */
+/* #undef JEMALLOC_THREADED_INIT */
+
+/*
+ * Defined if the pthreads implementation defines
+ * _pthread_mutex_init_calloc_cb(), in which case the function is used in order
+ * to avoid recursive allocation during mutex initialization.
+ */
+#define JEMALLOC_MUTEX_INIT_CB 1
+
+/* Non-empty if the tls_model attribute is supported. */
+#define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
+
+/*
+ * JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
+ * inline functions.
+ */
+/* #undef JEMALLOC_DEBUG */
+
+/* JEMALLOC_STATS enables statistics calculation. */
+#define JEMALLOC_STATS
+
+/* JEMALLOC_EXPERIMENTAL_SMALLOCX_API enables experimental smallocx API. */
+/* #undef JEMALLOC_EXPERIMENTAL_SMALLOCX_API */
+
+/* JEMALLOC_PROF enables allocation profiling. */
+/* #undef JEMALLOC_PROF */
+
+/* Use libunwind for profile backtracing if defined. */
+/* #undef JEMALLOC_PROF_LIBUNWIND */
+
+/* Use libgcc for profile backtracing if defined. */
+/* #undef JEMALLOC_PROF_LIBGCC */
+
+/* Use gcc intrinsics for profile backtracing if defined. */
+/* #undef JEMALLOC_PROF_GCC */
+
+/*
+ * JEMALLOC_DSS enables use of sbrk(2) to allocate extents from the data storage
+ * segment (DSS).
+ */
+#define JEMALLOC_DSS
+
+/* Support memory filling (junk/zero). */
+#define JEMALLOC_FILL
+
+/* Support utrace(2)-based tracing. */
+#define JEMALLOC_UTRACE
+
+/* Support optional abort() on OOM. */
+#define JEMALLOC_XMALLOC
+
+/* Support lazy locking (avoid locking unless a second thread is launched). */
+#define JEMALLOC_LAZY_LOCK
+
+/*
+ * Minimum allocation alignment is 2^LG_QUANTUM bytes (ignoring tiny size
+ * classes).
+ */
+/* #undef LG_QUANTUM */
+
+/* One page is 2^LG_PAGE bytes. */
+#define LG_PAGE 12
+
+/*
+ * One huge page is 2^LG_HUGEPAGE bytes. Note that this is defined even if the
+ * system does not explicitly support huge pages; system calls that require
+ * explicit huge page support are separately configured.
+ */
+#define LG_HUGEPAGE 21
+
+/*
+ * If defined, adjacent virtual memory mappings with identical attributes
+ * automatically coalesce, and they fragment when changes are made to subranges.
+ * This is the normal order of things for mmap()/munmap(), but on Windows
+ * VirtualAlloc()/VirtualFree() operations must be precisely matched, i.e.
+ * mappings do *not* coalesce/fragment.
+ */
+#define JEMALLOC_MAPS_COALESCE
+
+/*
+ * If defined, retain memory for later reuse by default rather than using e.g.
+ * munmap() to unmap freed extents. This is enabled on 64-bit Linux because
+ * common sequences of mmap()/munmap() calls will cause virtual memory map
+ * holes.
+ */
+/* #undef JEMALLOC_RETAIN */
+
+/* TLS is used to map arenas and magazine caches to threads. */
+#define JEMALLOC_TLS
+
+/*
+ * Used to mark unreachable code to quiet "end of non-void" compiler warnings.
+ * Don't use this directly; instead use unreachable() from util.h
+ */
+#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable
+
+/*
+ * ffs*() functions to use for bitmapping. Don't use these directly; instead,
+ * use ffs_*() from util.h.
+ */
+#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll
+#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl
+#define JEMALLOC_INTERNAL_FFS __builtin_ffs
+
+/*
+ * popcount*() functions to use for bitmapping.
+ */
+#define JEMALLOC_INTERNAL_POPCOUNTL __builtin_popcountl
+#define JEMALLOC_INTERNAL_POPCOUNT __builtin_popcount
+
+/*
+ * If defined, explicitly attempt to more uniformly distribute large allocation
+ * pointer alignments across all cache indices.
+ */
+#define JEMALLOC_CACHE_OBLIVIOUS
+
+/*
+ * If defined, enable logging facilities. We make this a configure option to
+ * avoid taking extra branches everywhere.
+ */
+/* #undef JEMALLOC_LOG */
+
+/*
+ * If defined, use readlinkat() (instead of readlink()) to follow
+ * /etc/malloc_conf.
+ */
+/* #undef JEMALLOC_READLINKAT */
+
+/*
+ * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
+ */
+/* #undef JEMALLOC_ZONE */
+
+/*
+ * Methods for determining whether the OS overcommits.
+ * JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY: Linux's
+ * /proc/sys/vm.overcommit_memory file.
+ * JEMALLOC_SYSCTL_VM_OVERCOMMIT: FreeBSD's vm.overcommit sysctl.
+ */
+#define JEMALLOC_SYSCTL_VM_OVERCOMMIT
+/* #undef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY */
+
+/* Defined if madvise(2) is available. */
+#define JEMALLOC_HAVE_MADVISE
+
+/*
+ * Defined if transparent huge pages are supported via the MADV_[NO]HUGEPAGE
+ * arguments to madvise(2).
+ */
+/* #undef JEMALLOC_HAVE_MADVISE_HUGE */
+
+/*
+ * Methods for purging unused pages differ between operating systems.
+ *
+ * madvise(..., MADV_FREE) : This marks pages as being unused, such that they
+ * will be discarded rather than swapped out.
+ * madvise(..., MADV_DONTNEED) : If JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS is
+ * defined, this immediately discards pages,
+ * such that new pages will be demand-zeroed if
+ * the address region is later touched;
+ * otherwise this behaves similarly to
+ * MADV_FREE, though typically with higher
+ * system overhead.
+ */
+#define JEMALLOC_PURGE_MADVISE_FREE
+#define JEMALLOC_PURGE_MADVISE_DONTNEED
+/* #undef JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS */
+
+/* Defined if madvise(2) is available but MADV_FREE is not (x86 Linux only). */
+/* #undef JEMALLOC_DEFINE_MADVISE_FREE */
+
+/*
+ * Defined if MADV_DO[NT]DUMP is supported as an argument to madvise.
+ */
+/* #undef JEMALLOC_MADVISE_DONTDUMP */
+
+/*
+ * Defined if transparent huge pages (THPs) are supported via the
+ * MADV_[NO]HUGEPAGE arguments to madvise(2), and THP support is enabled.
+ */
+/* #undef JEMALLOC_THP */
+
+/* Define if operating system has alloca.h header. */
+/* #undef JEMALLOC_HAS_ALLOCA_H */
+
+/* C99 restrict keyword supported. */
+#define JEMALLOC_HAS_RESTRICT 1
+
+/* For use by hash code. */
+/* #undef JEMALLOC_BIG_ENDIAN */
+
+/* sizeof(int) == 2^LG_SIZEOF_INT. */
+#define LG_SIZEOF_INT 2
+
+/* sizeof(long) == 2^LG_SIZEOF_LONG. */
+#define LG_SIZEOF_LONG 3
+
+/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */
+#define LG_SIZEOF_LONG_LONG 3
+
+/* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
+#define LG_SIZEOF_INTMAX_T 3
+
+/* glibc malloc hooks (__malloc_hook, __realloc_hook, __free_hook). */
+/* #undef JEMALLOC_GLIBC_MALLOC_HOOK */
+
+/* glibc memalign hook. */
+/* #undef JEMALLOC_GLIBC_MEMALIGN_HOOK */
+
+/* pthread support */
+#define JEMALLOC_HAVE_PTHREAD
+
+/* dlsym() support */
+#define JEMALLOC_HAVE_DLSYM
+
+/* Adaptive mutex support in pthreads. */
+#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
+
+/* GNU specific sched_getcpu support */
+/* #undef JEMALLOC_HAVE_SCHED_GETCPU */
+
+/* GNU specific sched_setaffinity support */
+/* #undef JEMALLOC_HAVE_SCHED_SETAFFINITY */
+
+/*
+ * If defined, all the features necessary for background threads are present.
+ */
+#define JEMALLOC_BACKGROUND_THREAD 1
+
+/*
+ * If defined, jemalloc symbols are not exported (doesn't work when
+ * JEMALLOC_PREFIX is not defined).
+ */
+/* #undef JEMALLOC_EXPORT */
+
+/* config.malloc_conf options string. */
+#define JEMALLOC_CONFIG_MALLOC_CONF "abort_conf:false"
+
+/* If defined, jemalloc takes the malloc/free/etc. symbol names. */
+#define JEMALLOC_IS_MALLOC 1
+
+/*
+ * Defined if strerror_r returns char * if _GNU_SOURCE is defined.
+ */
+/* #undef JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE */
+
+/* Performs additional safety checks when defined. */
+/* #undef JEMALLOC_OPT_SAFETY_CHECKS */
+
+#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs_FreeBSD.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs_FreeBSD.h
new file mode 100644
index 000000000000..0dab1296d849
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_internal_defs_FreeBSD.h
@@ -0,0 +1,9 @@
+#ifndef __clang__
+# undef JEMALLOC_INTERNAL_UNREACHABLE
+# define JEMALLOC_INTERNAL_UNREACHABLE abort
+
+# undef JEMALLOC_C11_ATOMICS
+# undef JEMALLOC_GCC_ATOMIC_ATOMICS
+# undef JEMALLOC_GCC_U8_ATOMIC_ATOMICS
+# undef JEMALLOC_GCC_U8_SYNC_ATOMICS
+#endif
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h
new file mode 100644
index 000000000000..d1dcc50d5a3b
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/jemalloc_preamble.h
@@ -0,0 +1,210 @@
+#ifndef JEMALLOC_PREAMBLE_H
+#define JEMALLOC_PREAMBLE_H
+
+#include "jemalloc_internal_defs.h"
+#include "jemalloc/internal/jemalloc_internal_decls.h"
+
+#ifdef JEMALLOC_UTRACE
+#include <sys/ktrace.h>
+#endif
+
+#include "un-namespace.h"
+#include "libc_private.h"
+
+#define JEMALLOC_NO_DEMANGLE
+#ifdef JEMALLOC_JET
+# undef JEMALLOC_IS_MALLOC
+# define JEMALLOC_N(n) jet_##n
+# include "jemalloc/internal/public_namespace.h"
+# define JEMALLOC_NO_RENAME
+# include "../jemalloc.h"
+# undef JEMALLOC_NO_RENAME
+#else
+# define JEMALLOC_N(n) __je_##n
+# include "../jemalloc.h"
+#endif
+
+#if defined(JEMALLOC_OSATOMIC)
+#include <libkern/OSAtomic.h>
+#endif
+
+#ifdef JEMALLOC_ZONE
+#include <mach/mach_error.h>
+#include <mach/mach_init.h>
+#include <mach/vm_map.h>
+#endif
+
+#include "jemalloc/internal/jemalloc_internal_macros.h"
+
+/*
+ * Note that the ordering matters here; the hook itself is name-mangled. We
+ * want the inclusion of hooks to happen early, so that we hook as much as
+ * possible.
+ */
+#ifndef JEMALLOC_NO_PRIVATE_NAMESPACE
+# ifndef JEMALLOC_JET
+# include "jemalloc/internal/private_namespace.h"
+# else
+# include "jemalloc/internal/private_namespace_jet.h"
+# endif
+#endif
+#include "jemalloc/internal/test_hooks.h"
+
+#ifdef JEMALLOC_DEFINE_MADVISE_FREE
+# define JEMALLOC_MADV_FREE 8
+#endif
+
+static const bool config_debug =
+#ifdef JEMALLOC_DEBUG
+ true
+#else
+ false
+#endif
+ ;
+static const bool have_dss =
+#ifdef JEMALLOC_DSS
+ true
+#else
+ false
+#endif
+ ;
+static const bool have_madvise_huge =
+#ifdef JEMALLOC_HAVE_MADVISE_HUGE
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_fill =
+#ifdef JEMALLOC_FILL
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_lazy_lock = true;
+static const char * const config_malloc_conf = JEMALLOC_CONFIG_MALLOC_CONF;
+static const bool config_prof =
+#ifdef JEMALLOC_PROF
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_prof_libgcc =
+#ifdef JEMALLOC_PROF_LIBGCC
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_prof_libunwind =
+#ifdef JEMALLOC_PROF_LIBUNWIND
+ true
+#else
+ false
+#endif
+ ;
+static const bool maps_coalesce =
+#ifdef JEMALLOC_MAPS_COALESCE
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_stats =
+#ifdef JEMALLOC_STATS
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_tls =
+#ifdef JEMALLOC_TLS
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_utrace =
+#ifdef JEMALLOC_UTRACE
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_xmalloc =
+#ifdef JEMALLOC_XMALLOC
+ true
+#else
+ false
+#endif
+ ;
+static const bool config_cache_oblivious =
+#ifdef JEMALLOC_CACHE_OBLIVIOUS
+ true
+#else
+ false
+#endif
+ ;
+/*
+ * Undocumented, for jemalloc development use only at the moment. See the note
+ * in jemalloc/internal/log.h.
+ */
+static const bool config_log =
+#ifdef JEMALLOC_LOG
+ true
+#else
+ false
+#endif
+ ;
+/*
+ * Are extra safety checks enabled; things like checking the size of sized
+ * deallocations, double-frees, etc.
+ */
+static const bool config_opt_safety_checks =
+#ifdef JEMALLOC_OPT_SAFETY_CHECKS
+ true
+#elif defined(JEMALLOC_DEBUG)
+ /*
+ * This lets us only guard safety checks by one flag instead of two; fast
+ * checks can guard solely by config_opt_safety_checks and run in debug mode
+ * too.
+ */
+ true
+#else
+ false
+#endif
+ ;
+
+#if defined(_WIN32) || defined(JEMALLOC_HAVE_SCHED_GETCPU)
+/* Currently percpu_arena depends on sched_getcpu. */
+#define JEMALLOC_PERCPU_ARENA
+#endif
+static const bool have_percpu_arena =
+#ifdef JEMALLOC_PERCPU_ARENA
+ true
+#else
+ false
+#endif
+ ;
+/*
+ * Undocumented, and not recommended; the application should take full
+ * responsibility for tracking provenance.
+ */
+static const bool force_ivsalloc =
+#ifdef JEMALLOC_FORCE_IVSALLOC
+ true
+#else
+ false
+#endif
+ ;
+static const bool have_background_thread =
+#ifdef JEMALLOC_BACKGROUND_THREAD
+ true
+#else
+ false
+#endif
+ ;
+
+#endif /* JEMALLOC_PREAMBLE_H */
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/private_namespace.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/private_namespace.h
new file mode 100644
index 000000000000..a448ad63fa54
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/private_namespace.h
@@ -0,0 +1,420 @@
+#define a0dalloc JEMALLOC_N(a0dalloc)
+#define a0malloc JEMALLOC_N(a0malloc)
+#define arena_choose_hard JEMALLOC_N(arena_choose_hard)
+#define arena_cleanup JEMALLOC_N(arena_cleanup)
+#define arena_init JEMALLOC_N(arena_init)
+#define arena_migrate JEMALLOC_N(arena_migrate)
+#define arena_set JEMALLOC_N(arena_set)
+#define arena_tdata_get_hard JEMALLOC_N(arena_tdata_get_hard)
+#define arenas JEMALLOC_N(arenas)
+#define arenas_lock JEMALLOC_N(arenas_lock)
+#define arenas_tdata_cleanup JEMALLOC_N(arenas_tdata_cleanup)
+#define bootstrap_calloc JEMALLOC_N(bootstrap_calloc)
+#define bootstrap_free JEMALLOC_N(bootstrap_free)
+#define bootstrap_malloc JEMALLOC_N(bootstrap_malloc)
+#define free_default JEMALLOC_N(free_default)
+#define iarena_cleanup JEMALLOC_N(iarena_cleanup)
+#define je_sdallocx_noflags JEMALLOC_N(je_sdallocx_noflags)
+#define jemalloc_postfork_child JEMALLOC_N(jemalloc_postfork_child)
+#define malloc_default JEMALLOC_N(malloc_default)
+#define malloc_initialized JEMALLOC_N(malloc_initialized)
+#define malloc_slow JEMALLOC_N(malloc_slow)
+#define manual_arena_base JEMALLOC_N(manual_arena_base)
+#define narenas_auto JEMALLOC_N(narenas_auto)
+#define narenas_total_get JEMALLOC_N(narenas_total_get)
+#define ncpus JEMALLOC_N(ncpus)
+#define opt_abort JEMALLOC_N(opt_abort)
+#define opt_abort_conf JEMALLOC_N(opt_abort_conf)
+#define opt_confirm_conf JEMALLOC_N(opt_confirm_conf)
+#define opt_junk JEMALLOC_N(opt_junk)
+#define opt_junk_alloc JEMALLOC_N(opt_junk_alloc)
+#define opt_junk_free JEMALLOC_N(opt_junk_free)
+#define opt_narenas JEMALLOC_N(opt_narenas)
+#define opt_utrace JEMALLOC_N(opt_utrace)
+#define opt_xmalloc JEMALLOC_N(opt_xmalloc)
+#define opt_zero JEMALLOC_N(opt_zero)
+#define sdallocx_default JEMALLOC_N(sdallocx_default)
+#define arena_alloc_junk_small JEMALLOC_N(arena_alloc_junk_small)
+#define arena_basic_stats_merge JEMALLOC_N(arena_basic_stats_merge)
+#define arena_bin_choose_lock JEMALLOC_N(arena_bin_choose_lock)
+#define arena_boot JEMALLOC_N(arena_boot)
+#define arena_choose_huge JEMALLOC_N(arena_choose_huge)
+#define arena_dalloc_bin_junked_locked JEMALLOC_N(arena_dalloc_bin_junked_locked)
+#define arena_dalloc_junk_small JEMALLOC_N(arena_dalloc_junk_small)
+#define arena_dalloc_promoted JEMALLOC_N(arena_dalloc_promoted)
+#define arena_dalloc_small JEMALLOC_N(arena_dalloc_small)
+#define arena_decay JEMALLOC_N(arena_decay)
+#define arena_destroy JEMALLOC_N(arena_destroy)
+#define arena_dirty_decay_ms_default_get JEMALLOC_N(arena_dirty_decay_ms_default_get)
+#define arena_dirty_decay_ms_default_set JEMALLOC_N(arena_dirty_decay_ms_default_set)
+#define arena_dirty_decay_ms_get JEMALLOC_N(arena_dirty_decay_ms_get)
+#define arena_dirty_decay_ms_set JEMALLOC_N(arena_dirty_decay_ms_set)
+#define arena_dss_prec_get JEMALLOC_N(arena_dss_prec_get)
+#define arena_dss_prec_set JEMALLOC_N(arena_dss_prec_set)
+#define arena_extent_alloc_large JEMALLOC_N(arena_extent_alloc_large)
+#define arena_extent_dalloc_large_prep JEMALLOC_N(arena_extent_dalloc_large_prep)
+#define arena_extent_ralloc_large_expand JEMALLOC_N(arena_extent_ralloc_large_expand)
+#define arena_extent_ralloc_large_shrink JEMALLOC_N(arena_extent_ralloc_large_shrink)
+#define arena_extent_sn_next JEMALLOC_N(arena_extent_sn_next)
+#define arena_extents_dirty_dalloc JEMALLOC_N(arena_extents_dirty_dalloc)
+#define arena_init_huge JEMALLOC_N(arena_init_huge)
+#define arena_is_huge JEMALLOC_N(arena_is_huge)
+#define arena_malloc_hard JEMALLOC_N(arena_malloc_hard)
+#define arena_muzzy_decay_ms_default_get JEMALLOC_N(arena_muzzy_decay_ms_default_get)
+#define arena_muzzy_decay_ms_default_set JEMALLOC_N(arena_muzzy_decay_ms_default_set)
+#define arena_muzzy_decay_ms_get JEMALLOC_N(arena_muzzy_decay_ms_get)
+#define arena_muzzy_decay_ms_set JEMALLOC_N(arena_muzzy_decay_ms_set)
+#define arena_new JEMALLOC_N(arena_new)
+#define arena_nthreads_dec JEMALLOC_N(arena_nthreads_dec)
+#define arena_nthreads_get JEMALLOC_N(arena_nthreads_get)
+#define arena_nthreads_inc JEMALLOC_N(arena_nthreads_inc)
+#define arena_palloc JEMALLOC_N(arena_palloc)
+#define arena_postfork_child JEMALLOC_N(arena_postfork_child)
+#define arena_postfork_parent JEMALLOC_N(arena_postfork_parent)
+#define arena_prefork0 JEMALLOC_N(arena_prefork0)
+#define arena_prefork1 JEMALLOC_N(arena_prefork1)
+#define arena_prefork2 JEMALLOC_N(arena_prefork2)
+#define arena_prefork3 JEMALLOC_N(arena_prefork3)
+#define arena_prefork4 JEMALLOC_N(arena_prefork4)
+#define arena_prefork5 JEMALLOC_N(arena_prefork5)
+#define arena_prefork6 JEMALLOC_N(arena_prefork6)
+#define arena_prefork7 JEMALLOC_N(arena_prefork7)
+#define arena_prof_promote JEMALLOC_N(arena_prof_promote)
+#define arena_ralloc JEMALLOC_N(arena_ralloc)
+#define arena_ralloc_no_move JEMALLOC_N(arena_ralloc_no_move)
+#define arena_reset JEMALLOC_N(arena_reset)
+#define arena_retain_grow_limit_get_set JEMALLOC_N(arena_retain_grow_limit_get_set)
+#define arena_stats_merge JEMALLOC_N(arena_stats_merge)
+#define arena_tcache_fill_small JEMALLOC_N(arena_tcache_fill_small)
+#define h_steps JEMALLOC_N(h_steps)
+#define opt_dirty_decay_ms JEMALLOC_N(opt_dirty_decay_ms)
+#define opt_muzzy_decay_ms JEMALLOC_N(opt_muzzy_decay_ms)
+#define opt_oversize_threshold JEMALLOC_N(opt_oversize_threshold)
+#define opt_percpu_arena JEMALLOC_N(opt_percpu_arena)
+#define oversize_threshold JEMALLOC_N(oversize_threshold)
+#define percpu_arena_mode_names JEMALLOC_N(percpu_arena_mode_names)
+#define background_thread_boot0 JEMALLOC_N(background_thread_boot0)
+#define background_thread_boot1 JEMALLOC_N(background_thread_boot1)
+#define background_thread_create JEMALLOC_N(background_thread_create)
+#define background_thread_ctl_init JEMALLOC_N(background_thread_ctl_init)
+#define background_thread_enabled_state JEMALLOC_N(background_thread_enabled_state)
+#define background_thread_info JEMALLOC_N(background_thread_info)
+#define background_thread_interval_check JEMALLOC_N(background_thread_interval_check)
+#define background_thread_lock JEMALLOC_N(background_thread_lock)
+#define background_thread_postfork_child JEMALLOC_N(background_thread_postfork_child)
+#define background_thread_postfork_parent JEMALLOC_N(background_thread_postfork_parent)
+#define background_thread_prefork0 JEMALLOC_N(background_thread_prefork0)
+#define background_thread_prefork1 JEMALLOC_N(background_thread_prefork1)
+#define background_thread_stats_read JEMALLOC_N(background_thread_stats_read)
+#define background_threads_disable JEMALLOC_N(background_threads_disable)
+#define background_threads_enable JEMALLOC_N(background_threads_enable)
+#define max_background_threads JEMALLOC_N(max_background_threads)
+#define n_background_threads JEMALLOC_N(n_background_threads)
+#define opt_background_thread JEMALLOC_N(opt_background_thread)
+#define opt_max_background_threads JEMALLOC_N(opt_max_background_threads)
+#define pthread_create_wrapper JEMALLOC_N(pthread_create_wrapper)
+#define b0get JEMALLOC_N(b0get)
+#define base_alloc JEMALLOC_N(base_alloc)
+#define base_alloc_extent JEMALLOC_N(base_alloc_extent)
+#define base_boot JEMALLOC_N(base_boot)
+#define base_delete JEMALLOC_N(base_delete)
+#define base_extent_hooks_get JEMALLOC_N(base_extent_hooks_get)
+#define base_extent_hooks_set JEMALLOC_N(base_extent_hooks_set)
+#define base_new JEMALLOC_N(base_new)
+#define base_postfork_child JEMALLOC_N(base_postfork_child)
+#define base_postfork_parent JEMALLOC_N(base_postfork_parent)
+#define base_prefork JEMALLOC_N(base_prefork)
+#define base_stats_get JEMALLOC_N(base_stats_get)
+#define metadata_thp_mode_names JEMALLOC_N(metadata_thp_mode_names)
+#define opt_metadata_thp JEMALLOC_N(opt_metadata_thp)
+#define bin_boot JEMALLOC_N(bin_boot)
+#define bin_infos JEMALLOC_N(bin_infos)
+#define bin_init JEMALLOC_N(bin_init)
+#define bin_postfork_child JEMALLOC_N(bin_postfork_child)
+#define bin_postfork_parent JEMALLOC_N(bin_postfork_parent)
+#define bin_prefork JEMALLOC_N(bin_prefork)
+#define bin_shard_sizes_boot JEMALLOC_N(bin_shard_sizes_boot)
+#define bin_update_shard_size JEMALLOC_N(bin_update_shard_size)
+#define bitmap_info_init JEMALLOC_N(bitmap_info_init)
+#define bitmap_init JEMALLOC_N(bitmap_init)
+#define bitmap_size JEMALLOC_N(bitmap_size)
+#define ckh_count JEMALLOC_N(ckh_count)
+#define ckh_delete JEMALLOC_N(ckh_delete)
+#define ckh_insert JEMALLOC_N(ckh_insert)
+#define ckh_iter JEMALLOC_N(ckh_iter)
+#define ckh_new JEMALLOC_N(ckh_new)
+#define ckh_pointer_hash JEMALLOC_N(ckh_pointer_hash)
+#define ckh_pointer_keycomp JEMALLOC_N(ckh_pointer_keycomp)
+#define ckh_remove JEMALLOC_N(ckh_remove)
+#define ckh_search JEMALLOC_N(ckh_search)
+#define ckh_string_hash JEMALLOC_N(ckh_string_hash)
+#define ckh_string_keycomp JEMALLOC_N(ckh_string_keycomp)
+#define ctl_boot JEMALLOC_N(ctl_boot)
+#define ctl_bymib JEMALLOC_N(ctl_bymib)
+#define ctl_byname JEMALLOC_N(ctl_byname)
+#define ctl_nametomib JEMALLOC_N(ctl_nametomib)
+#define ctl_postfork_child JEMALLOC_N(ctl_postfork_child)
+#define ctl_postfork_parent JEMALLOC_N(ctl_postfork_parent)
+#define ctl_prefork JEMALLOC_N(ctl_prefork)
+#define div_init JEMALLOC_N(div_init)
+#define extent_alloc JEMALLOC_N(extent_alloc)
+#define extent_alloc_wrapper JEMALLOC_N(extent_alloc_wrapper)
+#define extent_avail_any JEMALLOC_N(extent_avail_any)
+#define extent_avail_empty JEMALLOC_N(extent_avail_empty)
+#define extent_avail_first JEMALLOC_N(extent_avail_first)
+#define extent_avail_insert JEMALLOC_N(extent_avail_insert)
+#define extent_avail_new JEMALLOC_N(extent_avail_new)
+#define extent_avail_remove JEMALLOC_N(extent_avail_remove)
+#define extent_avail_remove_any JEMALLOC_N(extent_avail_remove_any)
+#define extent_avail_remove_first JEMALLOC_N(extent_avail_remove_first)
+#define extent_boot JEMALLOC_N(extent_boot)
+#define extent_commit_wrapper JEMALLOC_N(extent_commit_wrapper)
+#define extent_dalloc JEMALLOC_N(extent_dalloc)
+#define extent_dalloc_gap JEMALLOC_N(extent_dalloc_gap)
+#define extent_dalloc_wrapper JEMALLOC_N(extent_dalloc_wrapper)
+#define extent_decommit_wrapper JEMALLOC_N(extent_decommit_wrapper)
+#define extent_destroy_wrapper JEMALLOC_N(extent_destroy_wrapper)
+#define extent_heap_any JEMALLOC_N(extent_heap_any)
+#define extent_heap_empty JEMALLOC_N(extent_heap_empty)
+#define extent_heap_first JEMALLOC_N(extent_heap_first)
+#define extent_heap_insert JEMALLOC_N(extent_heap_insert)
+#define extent_heap_new JEMALLOC_N(extent_heap_new)
+#define extent_heap_remove JEMALLOC_N(extent_heap_remove)
+#define extent_heap_remove_any JEMALLOC_N(extent_heap_remove_any)
+#define extent_heap_remove_first JEMALLOC_N(extent_heap_remove_first)
+#define extent_hooks_default JEMALLOC_N(extent_hooks_default)
+#define extent_hooks_get JEMALLOC_N(extent_hooks_get)
+#define extent_hooks_set JEMALLOC_N(extent_hooks_set)
+#define extent_merge_wrapper JEMALLOC_N(extent_merge_wrapper)
+#define extent_mutex_pool JEMALLOC_N(extent_mutex_pool)
+#define extent_purge_forced_wrapper JEMALLOC_N(extent_purge_forced_wrapper)
+#define extent_purge_lazy_wrapper JEMALLOC_N(extent_purge_lazy_wrapper)
+#define extent_split_wrapper JEMALLOC_N(extent_split_wrapper)
+#define extent_util_stats_get JEMALLOC_N(extent_util_stats_get)
+#define extent_util_stats_verbose_get JEMALLOC_N(extent_util_stats_verbose_get)
+#define extents_alloc JEMALLOC_N(extents_alloc)
+#define extents_dalloc JEMALLOC_N(extents_dalloc)
+#define extents_evict JEMALLOC_N(extents_evict)
+#define extents_init JEMALLOC_N(extents_init)
+#define extents_nbytes_get JEMALLOC_N(extents_nbytes_get)
+#define extents_nextents_get JEMALLOC_N(extents_nextents_get)
+#define extents_npages_get JEMALLOC_N(extents_npages_get)
+#define extents_postfork_child JEMALLOC_N(extents_postfork_child)
+#define extents_postfork_parent JEMALLOC_N(extents_postfork_parent)
+#define extents_prefork JEMALLOC_N(extents_prefork)
+#define extents_rtree JEMALLOC_N(extents_rtree)
+#define extents_state_get JEMALLOC_N(extents_state_get)
+#define opt_lg_extent_max_active_fit JEMALLOC_N(opt_lg_extent_max_active_fit)
+#define dss_prec_names JEMALLOC_N(dss_prec_names)
+#define extent_alloc_dss JEMALLOC_N(extent_alloc_dss)
+#define extent_dss_boot JEMALLOC_N(extent_dss_boot)
+#define extent_dss_mergeable JEMALLOC_N(extent_dss_mergeable)
+#define extent_dss_prec_get JEMALLOC_N(extent_dss_prec_get)
+#define extent_dss_prec_set JEMALLOC_N(extent_dss_prec_set)
+#define extent_in_dss JEMALLOC_N(extent_in_dss)
+#define opt_dss JEMALLOC_N(opt_dss)
+#define extent_alloc_mmap JEMALLOC_N(extent_alloc_mmap)
+#define extent_dalloc_mmap JEMALLOC_N(extent_dalloc_mmap)
+#define opt_retain JEMALLOC_N(opt_retain)
+#define hook_boot JEMALLOC_N(hook_boot)
+#define hook_install JEMALLOC_N(hook_install)
+#define hook_invoke_alloc JEMALLOC_N(hook_invoke_alloc)
+#define hook_invoke_dalloc JEMALLOC_N(hook_invoke_dalloc)
+#define hook_invoke_expand JEMALLOC_N(hook_invoke_expand)
+#define hook_remove JEMALLOC_N(hook_remove)
+#define large_dalloc JEMALLOC_N(large_dalloc)
+#define large_dalloc_finish JEMALLOC_N(large_dalloc_finish)
+#define large_dalloc_junk JEMALLOC_N(large_dalloc_junk)
+#define large_dalloc_maybe_junk JEMALLOC_N(large_dalloc_maybe_junk)
+#define large_dalloc_prep_junked_locked JEMALLOC_N(large_dalloc_prep_junked_locked)
+#define large_malloc JEMALLOC_N(large_malloc)
+#define large_palloc JEMALLOC_N(large_palloc)
+#define large_prof_alloc_time_get JEMALLOC_N(large_prof_alloc_time_get)
+#define large_prof_alloc_time_set JEMALLOC_N(large_prof_alloc_time_set)
+#define large_prof_tctx_get JEMALLOC_N(large_prof_tctx_get)
+#define large_prof_tctx_reset JEMALLOC_N(large_prof_tctx_reset)
+#define large_prof_tctx_set JEMALLOC_N(large_prof_tctx_set)
+#define large_ralloc JEMALLOC_N(large_ralloc)
+#define large_ralloc_no_move JEMALLOC_N(large_ralloc_no_move)
+#define large_salloc JEMALLOC_N(large_salloc)
+#define log_init_done JEMALLOC_N(log_init_done)
+#define log_var_names JEMALLOC_N(log_var_names)
+#define log_var_update_state JEMALLOC_N(log_var_update_state)
+#define buferror JEMALLOC_N(buferror)
+#define malloc_cprintf JEMALLOC_N(malloc_cprintf)
+#define malloc_printf JEMALLOC_N(malloc_printf)
+#define malloc_snprintf JEMALLOC_N(malloc_snprintf)
+#define malloc_strtoumax JEMALLOC_N(malloc_strtoumax)
+#define malloc_vcprintf JEMALLOC_N(malloc_vcprintf)
+#define malloc_vsnprintf JEMALLOC_N(malloc_vsnprintf)
+#define malloc_write JEMALLOC_N(malloc_write)
+#define malloc_mutex_boot JEMALLOC_N(malloc_mutex_boot)
+#define malloc_mutex_init JEMALLOC_N(malloc_mutex_init)
+#define malloc_mutex_lock_slow JEMALLOC_N(malloc_mutex_lock_slow)
+#define malloc_mutex_postfork_child JEMALLOC_N(malloc_mutex_postfork_child)
+#define malloc_mutex_postfork_parent JEMALLOC_N(malloc_mutex_postfork_parent)
+#define malloc_mutex_prefork JEMALLOC_N(malloc_mutex_prefork)
+#define malloc_mutex_prof_data_reset JEMALLOC_N(malloc_mutex_prof_data_reset)
+#define mutex_pool_init JEMALLOC_N(mutex_pool_init)
+#define nstime_add JEMALLOC_N(nstime_add)
+#define nstime_compare JEMALLOC_N(nstime_compare)
+#define nstime_copy JEMALLOC_N(nstime_copy)
+#define nstime_divide JEMALLOC_N(nstime_divide)
+#define nstime_iadd JEMALLOC_N(nstime_iadd)
+#define nstime_idivide JEMALLOC_N(nstime_idivide)
+#define nstime_imultiply JEMALLOC_N(nstime_imultiply)
+#define nstime_init JEMALLOC_N(nstime_init)
+#define nstime_init2 JEMALLOC_N(nstime_init2)
+#define nstime_isubtract JEMALLOC_N(nstime_isubtract)
+#define nstime_monotonic JEMALLOC_N(nstime_monotonic)
+#define nstime_msec JEMALLOC_N(nstime_msec)
+#define nstime_ns JEMALLOC_N(nstime_ns)
+#define nstime_nsec JEMALLOC_N(nstime_nsec)
+#define nstime_sec JEMALLOC_N(nstime_sec)
+#define nstime_subtract JEMALLOC_N(nstime_subtract)
+#define nstime_update JEMALLOC_N(nstime_update)
+#define init_system_thp_mode JEMALLOC_N(init_system_thp_mode)
+#define opt_thp JEMALLOC_N(opt_thp)
+#define pages_boot JEMALLOC_N(pages_boot)
+#define pages_commit JEMALLOC_N(pages_commit)
+#define pages_decommit JEMALLOC_N(pages_decommit)
+#define pages_dodump JEMALLOC_N(pages_dodump)
+#define pages_dontdump JEMALLOC_N(pages_dontdump)
+#define pages_huge JEMALLOC_N(pages_huge)
+#define pages_map JEMALLOC_N(pages_map)
+#define pages_nohuge JEMALLOC_N(pages_nohuge)
+#define pages_purge_forced JEMALLOC_N(pages_purge_forced)
+#define pages_purge_lazy JEMALLOC_N(pages_purge_lazy)
+#define pages_set_thp_state JEMALLOC_N(pages_set_thp_state)
+#define pages_unmap JEMALLOC_N(pages_unmap)
+#define thp_mode_names JEMALLOC_N(thp_mode_names)
+#define bt2gctx_mtx JEMALLOC_N(bt2gctx_mtx)
+#define bt_init JEMALLOC_N(bt_init)
+#define lg_prof_sample JEMALLOC_N(lg_prof_sample)
+#define opt_lg_prof_interval JEMALLOC_N(opt_lg_prof_interval)
+#define opt_lg_prof_sample JEMALLOC_N(opt_lg_prof_sample)
+#define opt_prof JEMALLOC_N(opt_prof)
+#define opt_prof_accum JEMALLOC_N(opt_prof_accum)
+#define opt_prof_active JEMALLOC_N(opt_prof_active)
+#define opt_prof_final JEMALLOC_N(opt_prof_final)
+#define opt_prof_gdump JEMALLOC_N(opt_prof_gdump)
+#define opt_prof_leak JEMALLOC_N(opt_prof_leak)
+#define opt_prof_log JEMALLOC_N(opt_prof_log)
+#define opt_prof_prefix JEMALLOC_N(opt_prof_prefix)
+#define opt_prof_thread_active_init JEMALLOC_N(opt_prof_thread_active_init)
+#define prof_accum_init JEMALLOC_N(prof_accum_init)
+#define prof_active JEMALLOC_N(prof_active)
+#define prof_active_get JEMALLOC_N(prof_active_get)
+#define prof_active_set JEMALLOC_N(prof_active_set)
+#define prof_alloc_rollback JEMALLOC_N(prof_alloc_rollback)
+#define prof_backtrace JEMALLOC_N(prof_backtrace)
+#define prof_boot0 JEMALLOC_N(prof_boot0)
+#define prof_boot1 JEMALLOC_N(prof_boot1)
+#define prof_boot2 JEMALLOC_N(prof_boot2)
+#define prof_dump_header JEMALLOC_N(prof_dump_header)
+#define prof_dump_open JEMALLOC_N(prof_dump_open)
+#define prof_free_sampled_object JEMALLOC_N(prof_free_sampled_object)
+#define prof_gdump JEMALLOC_N(prof_gdump)
+#define prof_gdump_get JEMALLOC_N(prof_gdump_get)
+#define prof_gdump_set JEMALLOC_N(prof_gdump_set)
+#define prof_gdump_val JEMALLOC_N(prof_gdump_val)
+#define prof_idump JEMALLOC_N(prof_idump)
+#define prof_interval JEMALLOC_N(prof_interval)
+#define prof_log_start JEMALLOC_N(prof_log_start)
+#define prof_log_stop JEMALLOC_N(prof_log_stop)
+#define prof_logging_state JEMALLOC_N(prof_logging_state)
+#define prof_lookup JEMALLOC_N(prof_lookup)
+#define prof_malloc_sample_object JEMALLOC_N(prof_malloc_sample_object)
+#define prof_mdump JEMALLOC_N(prof_mdump)
+#define prof_postfork_child JEMALLOC_N(prof_postfork_child)
+#define prof_postfork_parent JEMALLOC_N(prof_postfork_parent)
+#define prof_prefork0 JEMALLOC_N(prof_prefork0)
+#define prof_prefork1 JEMALLOC_N(prof_prefork1)
+#define prof_reset JEMALLOC_N(prof_reset)
+#define prof_sample_threshold_update JEMALLOC_N(prof_sample_threshold_update)
+#define prof_tdata_cleanup JEMALLOC_N(prof_tdata_cleanup)
+#define prof_tdata_init JEMALLOC_N(prof_tdata_init)
+#define prof_tdata_reinit JEMALLOC_N(prof_tdata_reinit)
+#define prof_thread_active_get JEMALLOC_N(prof_thread_active_get)
+#define prof_thread_active_init_get JEMALLOC_N(prof_thread_active_init_get)
+#define prof_thread_active_init_set JEMALLOC_N(prof_thread_active_init_set)
+#define prof_thread_active_set JEMALLOC_N(prof_thread_active_set)
+#define prof_thread_name_get JEMALLOC_N(prof_thread_name_get)
+#define prof_thread_name_set JEMALLOC_N(prof_thread_name_set)
+#define rtree_ctx_data_init JEMALLOC_N(rtree_ctx_data_init)
+#define rtree_leaf_alloc JEMALLOC_N(rtree_leaf_alloc)
+#define rtree_leaf_dalloc JEMALLOC_N(rtree_leaf_dalloc)
+#define rtree_leaf_elm_lookup_hard JEMALLOC_N(rtree_leaf_elm_lookup_hard)
+#define rtree_new JEMALLOC_N(rtree_new)
+#define rtree_node_alloc JEMALLOC_N(rtree_node_alloc)
+#define rtree_node_dalloc JEMALLOC_N(rtree_node_dalloc)
+#define safety_check_fail JEMALLOC_N(safety_check_fail)
+#define safety_check_set_abort JEMALLOC_N(safety_check_set_abort)
+#define arena_mutex_names JEMALLOC_N(arena_mutex_names)
+#define global_mutex_names JEMALLOC_N(global_mutex_names)
+#define opt_stats_print JEMALLOC_N(opt_stats_print)
+#define opt_stats_print_opts JEMALLOC_N(opt_stats_print_opts)
+#define stats_print JEMALLOC_N(stats_print)
+#define sc_boot JEMALLOC_N(sc_boot)
+#define sc_data_global JEMALLOC_N(sc_data_global)
+#define sc_data_init JEMALLOC_N(sc_data_init)
+#define sc_data_update_slab_size JEMALLOC_N(sc_data_update_slab_size)
+#define sz_boot JEMALLOC_N(sz_boot)
+#define sz_index2size_tab JEMALLOC_N(sz_index2size_tab)
+#define sz_pind2sz_tab JEMALLOC_N(sz_pind2sz_tab)
+#define sz_size2index_tab JEMALLOC_N(sz_size2index_tab)
+#define nhbins JEMALLOC_N(nhbins)
+#define opt_lg_tcache_max JEMALLOC_N(opt_lg_tcache_max)
+#define opt_tcache JEMALLOC_N(opt_tcache)
+#define tcache_alloc_small_hard JEMALLOC_N(tcache_alloc_small_hard)
+#define tcache_arena_associate JEMALLOC_N(tcache_arena_associate)
+#define tcache_arena_reassociate JEMALLOC_N(tcache_arena_reassociate)
+#define tcache_bin_flush_large JEMALLOC_N(tcache_bin_flush_large)
+#define tcache_bin_flush_small JEMALLOC_N(tcache_bin_flush_small)
+#define tcache_bin_info JEMALLOC_N(tcache_bin_info)
+#define tcache_boot JEMALLOC_N(tcache_boot)
+#define tcache_cleanup JEMALLOC_N(tcache_cleanup)
+#define tcache_create_explicit JEMALLOC_N(tcache_create_explicit)
+#define tcache_event_hard JEMALLOC_N(tcache_event_hard)
+#define tcache_flush JEMALLOC_N(tcache_flush)
+#define tcache_maxclass JEMALLOC_N(tcache_maxclass)
+#define tcache_postfork_child JEMALLOC_N(tcache_postfork_child)
+#define tcache_postfork_parent JEMALLOC_N(tcache_postfork_parent)
+#define tcache_prefork JEMALLOC_N(tcache_prefork)
+#define tcache_salloc JEMALLOC_N(tcache_salloc)
+#define tcache_stats_merge JEMALLOC_N(tcache_stats_merge)
+#define tcaches JEMALLOC_N(tcaches)
+#define tcaches_create JEMALLOC_N(tcaches_create)
+#define tcaches_destroy JEMALLOC_N(tcaches_destroy)
+#define tcaches_flush JEMALLOC_N(tcaches_flush)
+#define tsd_tcache_data_init JEMALLOC_N(tsd_tcache_data_init)
+#define tsd_tcache_enabled_data_init JEMALLOC_N(tsd_tcache_enabled_data_init)
+#define test_hooks_arena_new_hook JEMALLOC_N(test_hooks_arena_new_hook)
+#define test_hooks_libc_hook JEMALLOC_N(test_hooks_libc_hook)
+#define malloc_tsd_boot0 JEMALLOC_N(malloc_tsd_boot0)
+#define malloc_tsd_boot1 JEMALLOC_N(malloc_tsd_boot1)
+#define malloc_tsd_cleanup_register JEMALLOC_N(malloc_tsd_cleanup_register)
+#define malloc_tsd_dalloc JEMALLOC_N(malloc_tsd_dalloc)
+#define malloc_tsd_malloc JEMALLOC_N(malloc_tsd_malloc)
+#define tsd_booted JEMALLOC_N(tsd_booted)
+#define tsd_cleanup JEMALLOC_N(tsd_cleanup)
+#define tsd_fetch_slow JEMALLOC_N(tsd_fetch_slow)
+#define tsd_global_slow JEMALLOC_N(tsd_global_slow)
+#define tsd_global_slow_dec JEMALLOC_N(tsd_global_slow_dec)
+#define tsd_global_slow_inc JEMALLOC_N(tsd_global_slow_inc)
+#define tsd_initialized JEMALLOC_N(tsd_initialized)
+#define tsd_postfork_child JEMALLOC_N(tsd_postfork_child)
+#define tsd_postfork_parent JEMALLOC_N(tsd_postfork_parent)
+#define tsd_prefork JEMALLOC_N(tsd_prefork)
+#define tsd_slow_update JEMALLOC_N(tsd_slow_update)
+#define tsd_state_set JEMALLOC_N(tsd_state_set)
+#define tsd_tls JEMALLOC_N(tsd_tls)
+#define witness_depth_error JEMALLOC_N(witness_depth_error)
+#define witness_init JEMALLOC_N(witness_init)
+#define witness_lock_error JEMALLOC_N(witness_lock_error)
+#define witness_not_owner_error JEMALLOC_N(witness_not_owner_error)
+#define witness_owner_error JEMALLOC_N(witness_owner_error)
+#define witness_postfork_child JEMALLOC_N(witness_postfork_child)
+#define witness_postfork_parent JEMALLOC_N(witness_postfork_parent)
+#define witness_prefork JEMALLOC_N(witness_prefork)
+#define witnesses_cleanup JEMALLOC_N(witnesses_cleanup)
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/public_namespace.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/public_namespace.h
new file mode 100644
index 000000000000..78d5c66377c3
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/internal/public_namespace.h
@@ -0,0 +1,22 @@
+#define je_aligned_alloc JEMALLOC_N(aligned_alloc)
+#define je_calloc JEMALLOC_N(calloc)
+#define je_dallocx JEMALLOC_N(dallocx)
+#define je_free JEMALLOC_N(free)
+#define je_mallctl JEMALLOC_N(mallctl)
+#define je_mallctlbymib JEMALLOC_N(mallctlbymib)
+#define je_mallctlnametomib JEMALLOC_N(mallctlnametomib)
+#define je_malloc JEMALLOC_N(malloc)
+#define je_malloc_conf JEMALLOC_N(malloc_conf)
+#define je_malloc_message JEMALLOC_N(malloc_message)
+#define je_malloc_stats_print JEMALLOC_N(malloc_stats_print)
+#define je_malloc_usable_size JEMALLOC_N(malloc_usable_size)
+#define je_mallocx JEMALLOC_N(mallocx)
+#define je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 JEMALLOC_N(smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756)
+#define je_nallocx JEMALLOC_N(nallocx)
+#define je_posix_memalign JEMALLOC_N(posix_memalign)
+#define je_rallocx JEMALLOC_N(rallocx)
+#define je_realloc JEMALLOC_N(realloc)
+#define je_sallocx JEMALLOC_N(sallocx)
+#define je_sdallocx JEMALLOC_N(sdallocx)
+#define je_xallocx JEMALLOC_N(xallocx)
+#define je_valloc JEMALLOC_N(valloc)
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h
new file mode 100644
index 000000000000..c3fa08e83f22
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc.h
@@ -0,0 +1,433 @@
+#ifndef JEMALLOC_H_
+#define JEMALLOC_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Defined if __attribute__((...)) syntax is supported. */
+#define JEMALLOC_HAVE_ATTR
+
+/* Defined if alloc_size attribute is supported. */
+#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE
+
+/* Defined if format_arg(...) attribute is supported. */
+#define JEMALLOC_HAVE_ATTR_FORMAT_ARG
+
+/* Defined if format(gnu_printf, ...) attribute is supported. */
+/* #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */
+
+/* Defined if format(printf, ...) attribute is supported. */
+#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF
+
+/*
+ * Define overrides for non-standard allocator-related functions if they are
+ * present on the system.
+ */
+/* #undef JEMALLOC_OVERRIDE_MEMALIGN */
+#define JEMALLOC_OVERRIDE_VALLOC
+
+/*
+ * At least Linux omits the "const" in:
+ *
+ * size_t malloc_usable_size(const void *ptr);
+ *
+ * Match the operating system's prototype.
+ */
+#define JEMALLOC_USABLE_SIZE_CONST const
+
+/*
+ * If defined, specify throw() for the public function prototypes when compiling
+ * with C++. The only justification for this is to match the prototypes that
+ * glibc defines.
+ */
+/* #undef JEMALLOC_USE_CXX_THROW */
+
+#ifdef _MSC_VER
+# ifdef _WIN64
+# define LG_SIZEOF_PTR_WIN 3
+# else
+# define LG_SIZEOF_PTR_WIN 2
+# endif
+#endif
+
+/* sizeof(void *) == 2^LG_SIZEOF_PTR. */
+#define LG_SIZEOF_PTR 3
+
+/*
+ * Name mangling for public symbols is controlled by --with-mangling and
+ * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by
+ * these macro definitions.
+ */
+#ifndef JEMALLOC_NO_RENAME
+# define je_aligned_alloc aligned_alloc
+# define je_calloc calloc
+# define je_dallocx dallocx
+# define je_free free
+# define je_mallctl mallctl
+# define je_mallctlbymib mallctlbymib
+# define je_mallctlnametomib mallctlnametomib
+# define je_malloc malloc
+# define je_malloc_conf malloc_conf
+# define je_malloc_message malloc_message
+# define je_malloc_stats_print malloc_stats_print
+# define je_malloc_usable_size malloc_usable_size
+# define je_mallocx mallocx
+# define je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
+# define je_nallocx nallocx
+# define je_posix_memalign posix_memalign
+# define je_rallocx rallocx
+# define je_realloc realloc
+# define je_sallocx sallocx
+# define je_sdallocx sdallocx
+# define je_xallocx xallocx
+# define je_valloc valloc
+#endif
+
+#include "jemalloc_FreeBSD.h"
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <limits.h>
+#include <strings.h>
+
+#define JEMALLOC_VERSION "5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756"
+#define JEMALLOC_VERSION_MAJOR 5
+#define JEMALLOC_VERSION_MINOR 2
+#define JEMALLOC_VERSION_BUGFIX 1
+#define JEMALLOC_VERSION_NREV 0
+#define JEMALLOC_VERSION_GID "ea6b3e973b477b8061e0076bb257dbd7f3faa756"
+#define JEMALLOC_VERSION_GID_IDENT ea6b3e973b477b8061e0076bb257dbd7f3faa756
+
+#define MALLOCX_LG_ALIGN(la) ((int)(la))
+#if LG_SIZEOF_PTR == 2
+# define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1))
+#else
+# define MALLOCX_ALIGN(a) \
+ ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \
+ ffs((int)(((size_t)(a))>>32))+31))
+#endif
+#define MALLOCX_ZERO ((int)0x40)
+/*
+ * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1
+ * encodes MALLOCX_TCACHE_NONE.
+ */
+#define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8))
+#define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1)
+/*
+ * Bias arena index bits so that 0 encodes "use an automatically chosen arena".
+ */
+#define MALLOCX_ARENA(a) ((((int)(a))+1) << 20)
+
+/*
+ * Use as arena index in "arena.<i>.{purge,decay,dss}" and
+ * "stats.arenas.<i>.*" mallctl interfaces to select all arenas. This
+ * definition is intentionally specified in raw decimal format to support
+ * cpp-based string concatenation, e.g.
+ *
+ * #define STRINGIFY_HELPER(x) #x
+ * #define STRINGIFY(x) STRINGIFY_HELPER(x)
+ *
+ * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL,
+ * 0);
+ */
+#define MALLCTL_ARENAS_ALL 4096
+/*
+ * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
+ * destroyed arenas.
+ */
+#define MALLCTL_ARENAS_DESTROYED 4097
+
+#if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
+# define JEMALLOC_CXX_THROW throw()
+#else
+# define JEMALLOC_CXX_THROW
+#endif
+
+#if defined(_MSC_VER)
+# define JEMALLOC_ATTR(s)
+# define JEMALLOC_ALIGNED(s) __declspec(align(s))
+# define JEMALLOC_ALLOC_SIZE(s)
+# define JEMALLOC_ALLOC_SIZE2(s1, s2)
+# ifndef JEMALLOC_EXPORT
+# ifdef DLLEXPORT
+# define JEMALLOC_EXPORT __declspec(dllexport)
+# else
+# define JEMALLOC_EXPORT __declspec(dllimport)
+# endif
+# endif
+# define JEMALLOC_FORMAT_ARG(i)
+# define JEMALLOC_FORMAT_PRINTF(s, i)
+# define JEMALLOC_NOINLINE __declspec(noinline)
+# ifdef __cplusplus
+# define JEMALLOC_NOTHROW __declspec(nothrow)
+# else
+# define JEMALLOC_NOTHROW
+# endif
+# define JEMALLOC_SECTION(s) __declspec(allocate(s))
+# define JEMALLOC_RESTRICT_RETURN __declspec(restrict)
+# if _MSC_VER >= 1900 && !defined(__EDG__)
+# define JEMALLOC_ALLOCATOR __declspec(allocator)
+# else
+# define JEMALLOC_ALLOCATOR
+# endif
+#elif defined(JEMALLOC_HAVE_ATTR)
+# define JEMALLOC_ATTR(s) __attribute__((s))
+# define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
+# ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
+# define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s))
+# define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2))
+# else
+# define JEMALLOC_ALLOC_SIZE(s)
+# define JEMALLOC_ALLOC_SIZE2(s1, s2)
+# endif
+# ifndef JEMALLOC_EXPORT
+# define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
+# endif
+# ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG
+# define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3))
+# else
+# define JEMALLOC_FORMAT_ARG(i)
+# endif
+# ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
+# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
+# elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
+# define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i))
+# else
+# define JEMALLOC_FORMAT_PRINTF(s, i)
+# endif
+# define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
+# define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow)
+# define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
+# define JEMALLOC_RESTRICT_RETURN
+# define JEMALLOC_ALLOCATOR
+#else
+# define JEMALLOC_ATTR(s)
+# define JEMALLOC_ALIGNED(s)
+# define JEMALLOC_ALLOC_SIZE(s)
+# define JEMALLOC_ALLOC_SIZE2(s1, s2)
+# define JEMALLOC_EXPORT
+# define JEMALLOC_FORMAT_PRINTF(s, i)
+# define JEMALLOC_NOINLINE
+# define JEMALLOC_NOTHROW
+# define JEMALLOC_SECTION(s)
+# define JEMALLOC_RESTRICT_RETURN
+# define JEMALLOC_ALLOCATOR
+#endif
+
+/*
+ * The je_ prefix on the following public symbol declarations is an artifact
+ * of namespace management, and should be omitted in application code unless
+ * JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h).
+ */
+extern JEMALLOC_EXPORT const char *je_malloc_conf;
+extern JEMALLOC_EXPORT void (*je_malloc_message)(void *cbopaque,
+ const char *s);
+
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_malloc(size_t size)
+ JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_calloc(size_t num, size_t size)
+ JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2);
+JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_posix_memalign(void **memptr,
+ size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1));
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_aligned_alloc(size_t alignment,
+ size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc)
+ JEMALLOC_ALLOC_SIZE(2);
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_realloc(void *ptr, size_t size)
+ JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2);
+JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_free(void *ptr)
+ JEMALLOC_CXX_THROW;
+
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_mallocx(size_t size, int flags)
+ JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_rallocx(void *ptr, size_t size,
+ int flags) JEMALLOC_ALLOC_SIZE(2);
+JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_xallocx(void *ptr, size_t size,
+ size_t extra, int flags);
+JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_sallocx(const void *ptr,
+ int flags) JEMALLOC_ATTR(pure);
+JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_dallocx(void *ptr, int flags);
+JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_sdallocx(void *ptr, size_t size,
+ int flags);
+JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_nallocx(size_t size, int flags)
+ JEMALLOC_ATTR(pure);
+
+JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char *name,
+ void *oldp, size_t *oldlenp, void *newp, size_t newlen);
+JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlnametomib(const char *name,
+ size_t *mibp, size_t *miblenp);
+JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlbymib(const size_t *mib,
+ size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
+JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_malloc_stats_print(
+ void (*write_cb)(void *, const char *), void *je_cbopaque,
+ const char *opts);
+JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size(
+ JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW;
+
+#ifdef JEMALLOC_OVERRIDE_MEMALIGN
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size)
+ JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc);
+#endif
+
+#ifdef JEMALLOC_OVERRIDE_VALLOC
+JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
+ void JEMALLOC_NOTHROW *je_valloc(size_t size) JEMALLOC_CXX_THROW
+ JEMALLOC_ATTR(malloc);
+#endif
+
+typedef struct extent_hooks_s extent_hooks_t;
+
+/*
+ * void *
+ * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
+ * size_t alignment, bool *zero, bool *commit, unsigned arena_ind);
+ */
+typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *,
+ bool *, unsigned);
+
+/*
+ * bool
+ * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * bool committed, unsigned arena_ind);
+ */
+typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool,
+ unsigned);
+
+/*
+ * void
+ * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * bool committed, unsigned arena_ind);
+ */
+typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool,
+ unsigned);
+
+/*
+ * bool
+ * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t offset, size_t length, unsigned arena_ind);
+ */
+typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
+ unsigned);
+
+/*
+ * bool
+ * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t offset, size_t length, unsigned arena_ind);
+ */
+typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t,
+ size_t, unsigned);
+
+/*
+ * bool
+ * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t offset, size_t length, unsigned arena_ind);
+ */
+typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
+ unsigned);
+
+/*
+ * bool
+ * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
+ */
+typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
+ bool, unsigned);
+
+/*
+ * bool
+ * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
+ * void *addr_b, size_t size_b, bool committed, unsigned arena_ind);
+ */
+typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t,
+ bool, unsigned);
+
+struct extent_hooks_s {
+ extent_alloc_t *alloc;
+ extent_dalloc_t *dalloc;
+ extent_destroy_t *destroy;
+ extent_commit_t *commit;
+ extent_decommit_t *decommit;
+ extent_purge_t *purge_lazy;
+ extent_purge_t *purge_forced;
+ extent_split_t *split;
+ extent_merge_t *merge;
+};
+
+/*
+ * By default application code must explicitly refer to mangled symbol names,
+ * so that it is possible to use jemalloc in conjunction with another allocator
+ * in the same application. Define JEMALLOC_MANGLE in order to cause automatic
+ * name mangling that matches the API prefixing that happened as a result of
+ * --with-mangling and/or --with-jemalloc-prefix configuration settings.
+ */
+#ifdef JEMALLOC_MANGLE
+# ifndef JEMALLOC_NO_DEMANGLE
+# define JEMALLOC_NO_DEMANGLE
+# endif
+# define aligned_alloc je_aligned_alloc
+# define calloc je_calloc
+# define dallocx je_dallocx
+# define free je_free
+# define mallctl je_mallctl
+# define mallctlbymib je_mallctlbymib
+# define mallctlnametomib je_mallctlnametomib
+# define malloc je_malloc
+# define malloc_conf je_malloc_conf
+# define malloc_message je_malloc_message
+# define malloc_stats_print je_malloc_stats_print
+# define malloc_usable_size je_malloc_usable_size
+# define mallocx je_mallocx
+# define smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
+# define nallocx je_nallocx
+# define posix_memalign je_posix_memalign
+# define rallocx je_rallocx
+# define realloc je_realloc
+# define sallocx je_sallocx
+# define sdallocx je_sdallocx
+# define xallocx je_xallocx
+# define valloc je_valloc
+#endif
+
+/*
+ * The je_* macros can be used as stable alternative names for the
+ * public jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily
+ * meant for use in jemalloc itself, but it can be used by application code to
+ * provide isolation from the name mangling specified via --with-mangling
+ * and/or --with-jemalloc-prefix.
+ */
+#ifndef JEMALLOC_NO_DEMANGLE
+# undef je_aligned_alloc
+# undef je_calloc
+# undef je_dallocx
+# undef je_free
+# undef je_mallctl
+# undef je_mallctlbymib
+# undef je_mallctlnametomib
+# undef je_malloc
+# undef je_malloc_conf
+# undef je_malloc_message
+# undef je_malloc_stats_print
+# undef je_malloc_usable_size
+# undef je_mallocx
+# undef je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
+# undef je_nallocx
+# undef je_posix_memalign
+# undef je_rallocx
+# undef je_realloc
+# undef je_sallocx
+# undef je_sdallocx
+# undef je_xallocx
+# undef je_valloc
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* JEMALLOC_H_ */
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_FreeBSD.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
new file mode 100644
index 000000000000..e733906bc146
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_FreeBSD.h
@@ -0,0 +1,199 @@
+/*
+ * Override settings that were generated in jemalloc_defs.h as necessary.
+ */
+
+#undef JEMALLOC_OVERRIDE_VALLOC
+
+#ifndef MALLOC_PRODUCTION
+#define JEMALLOC_DEBUG
+#endif
+
+#undef JEMALLOC_DSS
+
+#undef JEMALLOC_BACKGROUND_THREAD
+
+/*
+ * The following are architecture-dependent, so conditionally define them for
+ * each supported architecture.
+ */
+#undef JEMALLOC_TLS_MODEL
+#undef LG_PAGE
+#undef LG_VADDR
+#undef LG_SIZEOF_PTR
+#undef LG_SIZEOF_INT
+#undef LG_SIZEOF_LONG
+#undef LG_SIZEOF_INTMAX_T
+
+#ifdef __i386__
+# define LG_VADDR 32
+# define LG_SIZEOF_PTR 2
+# define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
+#endif
+#ifdef __ia64__
+# define LG_VADDR 64
+# define LG_SIZEOF_PTR 3
+#endif
+#ifdef __sparc64__
+# define LG_VADDR 64
+# define LG_SIZEOF_PTR 3
+# define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
+#endif
+#ifdef __amd64__
+#ifdef _USE_LG_VADDR_WIDE
+# define LG_VADDR 64
+#else
+# define LG_VADDR 48
+#endif
+# define LG_SIZEOF_PTR 3
+# define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
+#endif
+#ifdef __arm__
+# define LG_VADDR 32
+# define LG_SIZEOF_PTR 2
+#endif
+#ifdef __aarch64__
+# define LG_VADDR 48
+# define LG_SIZEOF_PTR 3
+#endif
+#ifdef __mips__
+#ifdef __mips_n64
+# define LG_VADDR 64
+# define LG_SIZEOF_PTR 3
+#else
+# define LG_VADDR 32
+# define LG_SIZEOF_PTR 2
+#endif
+#endif
+#ifdef __powerpc64__
+# define LG_VADDR 64
+# define LG_SIZEOF_PTR 3
+# define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
+#elif defined(__powerpc__)
+# define LG_VADDR 32
+# define LG_SIZEOF_PTR 2
+# define JEMALLOC_TLS_MODEL __attribute__((tls_model("initial-exec")))
+#endif
+#ifdef __riscv
+# define LG_VADDR 48
+# define LG_SIZEOF_PTR 3
+#endif
+
+#if LG_VADDR > 32
+# define JEMALLOC_RETAIN
+#endif
+
+#ifndef JEMALLOC_TLS_MODEL
+# define JEMALLOC_TLS_MODEL /* Default. */
+#endif
+
+#define LG_PAGE PAGE_SHIFT
+#define LG_SIZEOF_INT 2
+#define LG_SIZEOF_LONG LG_SIZEOF_PTR
+#define LG_SIZEOF_INTMAX_T 3
+
+#undef CPU_SPINWAIT
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#define CPU_SPINWAIT cpu_spinwait()
+
+/* Disable lazy-lock machinery, mangle isthreaded, and adjust its type. */
+#undef JEMALLOC_LAZY_LOCK
+extern int __isthreaded;
+#define isthreaded ((bool)__isthreaded)
+
+/* Mangle. */
+#undef je_malloc
+#undef je_calloc
+#undef je_posix_memalign
+#undef je_aligned_alloc
+#undef je_realloc
+#undef je_free
+#undef je_malloc_usable_size
+#undef je_mallocx
+#undef je_rallocx
+#undef je_xallocx
+#undef je_sallocx
+#undef je_dallocx
+#undef je_sdallocx
+#undef je_nallocx
+#undef je_mallctl
+#undef je_mallctlnametomib
+#undef je_mallctlbymib
+#undef je_malloc_stats_print
+#undef je_allocm
+#undef je_rallocm
+#undef je_dallocm
+#undef je_nallocm
+#define je_malloc __malloc
+#define je_calloc __calloc
+#define je_posix_memalign __posix_memalign
+#define je_aligned_alloc __aligned_alloc
+#define je_realloc __realloc
+#define je_free __free
+#define je_malloc_usable_size __malloc_usable_size
+#define je_mallocx __mallocx
+#define je_rallocx __rallocx
+#define je_xallocx __xallocx
+#define je_sallocx __sallocx
+#define je_dallocx __dallocx
+#define je_sdallocx __sdallocx
+#define je_nallocx __nallocx
+#define je_mallctl __mallctl
+#define je_mallctlnametomib __mallctlnametomib
+#define je_mallctlbymib __mallctlbymib
+#define je_malloc_stats_print __malloc_stats_print
+#define open _open
+#define read _read
+#define write _write
+#define close _close
+#define pthread_join _pthread_join
+#define pthread_once _pthread_once
+#define pthread_self _pthread_self
+#define pthread_equal _pthread_equal
+#define pthread_mutex_lock _pthread_mutex_lock
+#define pthread_mutex_trylock _pthread_mutex_trylock
+#define pthread_mutex_unlock _pthread_mutex_unlock
+#define pthread_cond_init _pthread_cond_init
+#define pthread_cond_wait _pthread_cond_wait
+#define pthread_cond_timedwait _pthread_cond_timedwait
+#define pthread_cond_signal _pthread_cond_signal
+
+#ifdef JEMALLOC_C_
+/*
+ * Define 'weak' symbols so that an application can have its own versions
+ * of malloc, calloc, realloc, free, et al.
+ */
+__weak_reference(__malloc, malloc);
+__weak_reference(__calloc, calloc);
+__weak_reference(__posix_memalign, posix_memalign);
+__weak_reference(__aligned_alloc, aligned_alloc);
+__weak_reference(__realloc, realloc);
+__weak_reference(__free, free);
+__weak_reference(__malloc_usable_size, malloc_usable_size);
+__weak_reference(__mallocx, mallocx);
+__weak_reference(__rallocx, rallocx);
+__weak_reference(__xallocx, xallocx);
+__weak_reference(__sallocx, sallocx);
+__weak_reference(__dallocx, dallocx);
+__weak_reference(__sdallocx, sdallocx);
+__weak_reference(__nallocx, nallocx);
+__weak_reference(__mallctl, mallctl);
+__weak_reference(__mallctlnametomib, mallctlnametomib);
+__weak_reference(__mallctlbymib, mallctlbymib);
+__weak_reference(__malloc_stats_print, malloc_stats_print);
+__weak_reference(je_allocm, weak_allocm);
+__weak_reference(je_rallocm, weak_rallocm);
+__weak_reference(je_sallocm, weak_sallocm);
+__weak_reference(je_dallocm, weak_dallocm);
+__weak_reference(je_nallocm, weak_nallocm);
+__sym_compat(__allocm, je_allocm, FBSD_1.3);
+__sym_compat(__rallocm, je_rallocm, FBSD_1.3);
+__sym_compat(__sallocm, je_sallocm, FBSD_1.3);
+__sym_compat(__dallocm, je_dallocm, FBSD_1.3);
+__sym_compat(__nallocm, je_nallocm, FBSD_1.3);
+__sym_compat(allocm, weak_allocm, FBSD_1.3);
+__sym_compat(rallocm, weak_rallocm, FBSD_1.3);
+__sym_compat(sallocm, weak_sallocm, FBSD_1.3);
+__sym_compat(dallocm, weak_dallocm, FBSD_1.3);
+__sym_compat(nallocm, weak_nallocm, FBSD_1.3);
+#endif
diff --git a/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_typedefs.h b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_typedefs.h
new file mode 100644
index 000000000000..1a58874306eb
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/include/jemalloc/jemalloc_typedefs.h
@@ -0,0 +1,77 @@
+typedef struct extent_hooks_s extent_hooks_t;
+
+/*
+ * void *
+ * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
+ * size_t alignment, bool *zero, bool *commit, unsigned arena_ind);
+ */
+typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *,
+ bool *, unsigned);
+
+/*
+ * bool
+ * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * bool committed, unsigned arena_ind);
+ */
+typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool,
+ unsigned);
+
+/*
+ * void
+ * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * bool committed, unsigned arena_ind);
+ */
+typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool,
+ unsigned);
+
+/*
+ * bool
+ * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t offset, size_t length, unsigned arena_ind);
+ */
+typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
+ unsigned);
+
+/*
+ * bool
+ * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t offset, size_t length, unsigned arena_ind);
+ */
+typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t,
+ size_t, unsigned);
+
+/*
+ * bool
+ * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t offset, size_t length, unsigned arena_ind);
+ */
+typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
+ unsigned);
+
+/*
+ * bool
+ * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
+ * size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
+ */
+typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
+ bool, unsigned);
+
+/*
+ * bool
+ * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
+ * void *addr_b, size_t size_b, bool committed, unsigned arena_ind);
+ */
+typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t,
+ bool, unsigned);
+
+struct extent_hooks_s {
+ extent_alloc_t *alloc;
+ extent_dalloc_t *dalloc;
+ extent_destroy_t *destroy;
+ extent_commit_t *commit;
+ extent_decommit_t *decommit;
+ extent_purge_t *purge_lazy;
+ extent_purge_t *purge_forced;
+ extent_split_t *split;
+ extent_merge_t *merge;
+};
diff --git a/lib/libc/stdlib/malloc/jemalloc/jemalloc.3 b/lib/libc/stdlib/malloc/jemalloc/jemalloc.3
new file mode 100644
index 000000000000..a4ea3e1f54a9
--- /dev/null
+++ b/lib/libc/stdlib/malloc/jemalloc/jemalloc.3
@@ -0,0 +1,2560 @@
+'\" t
+.\" Title: JEMALLOC
+.\" Author: Jason Evans
+.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
+.\" Date: 11/10/2019
+.\" Manual: User Manual
+.\" Source: jemalloc 5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756
+.\" Language: English
+.\"
+.TH "JEMALLOC" "3" "11/10/2019" "jemalloc 5.2.1-0-gea6b3e973b47" "User Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+jemalloc \- general purpose memory allocation functions
+.SH "LIBRARY"
+.PP
+This manual describes jemalloc 5\&.2\&.1\-0\-gea6b3e973b477b8061e0076bb257dbd7f3faa756\&. More information can be found at the
+\m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
+.PP
+The following configuration options are enabled in libc\*(Aqs built\-in jemalloc:
+\fB\-\-enable\-fill\fR,
+\fB\-\-enable\-lazy\-lock\fR,
+\fB\-\-enable\-stats\fR,
+\fB\-\-enable\-utrace\fR,
+\fB\-\-enable\-xmalloc\fR, and
+\fB\-\-with\-malloc\-conf=abort_conf:false\fR\&. Additionally,
+\fB\-\-enable\-debug\fR
+is enabled in development versions of FreeBSD (controlled by the
+\fBMK_MALLOC_PRODUCTION\fR
+make variable)\&.
+.SH "SYNOPSIS"
+.sp
+.ft B
+.nf
+#include <stdlib\&.h>
+#include <malloc_np\&.h>
+.fi
+.ft
+.SS "Standard API"
+.HP \w'void\ *malloc('u
+.BI "void *malloc(size_t\ " "size" ");"
+.HP \w'void\ *calloc('u
+.BI "void *calloc(size_t\ " "number" ", size_t\ " "size" ");"
+.HP \w'int\ posix_memalign('u
+.BI "int posix_memalign(void\ **" "ptr" ", size_t\ " "alignment" ", size_t\ " "size" ");"
+.HP \w'void\ *aligned_alloc('u
+.BI "void *aligned_alloc(size_t\ " "alignment" ", size_t\ " "size" ");"
+.HP \w'void\ *realloc('u
+.BI "void *realloc(void\ *" "ptr" ", size_t\ " "size" ");"
+.HP \w'void\ free('u
+.BI "void free(void\ *" "ptr" ");"
+.SS "Non\-standard API"
+.HP \w'void\ *mallocx('u
+.BI "void *mallocx(size_t\ " "size" ", int\ " "flags" ");"
+.HP \w'void\ *rallocx('u
+.BI "void *rallocx(void\ *" "ptr" ", size_t\ " "size" ", int\ " "flags" ");"
+.HP \w'size_t\ xallocx('u
+.BI "size_t xallocx(void\ *" "ptr" ", size_t\ " "size" ", size_t\ " "extra" ", int\ " "flags" ");"
+.HP \w'size_t\ sallocx('u
+.BI "size_t sallocx(void\ *" "ptr" ", int\ " "flags" ");"
+.HP \w'void\ dallocx('u
+.BI "void dallocx(void\ *" "ptr" ", int\ " "flags" ");"
+.HP \w'void\ sdallocx('u
+.BI "void sdallocx(void\ *" "ptr" ", size_t\ " "size" ", int\ " "flags" ");"
+.HP \w'size_t\ nallocx('u
+.BI "size_t nallocx(size_t\ " "size" ", int\ " "flags" ");"
+.HP \w'int\ mallctl('u
+.BI "int mallctl(const\ char\ *" "name" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
+.HP \w'int\ mallctlnametomib('u
+.BI "int mallctlnametomib(const\ char\ *" "name" ", size_t\ *" "mibp" ", size_t\ *" "miblenp" ");"
+.HP \w'int\ mallctlbymib('u
+.BI "int mallctlbymib(const\ size_t\ *" "mib" ", size_t\ " "miblen" ", void\ *" "oldp" ", size_t\ *" "oldlenp" ", void\ *" "newp" ", size_t\ " "newlen" ");"
+.HP \w'void\ malloc_stats_print('u
+.BI "void malloc_stats_print(void\ " "(*write_cb)" "\ (void\ *,\ const\ char\ *), void\ *" "cbopaque" ", const\ char\ *" "opts" ");"
+.HP \w'size_t\ malloc_usable_size('u
+.BI "size_t malloc_usable_size(const\ void\ *" "ptr" ");"
+.HP \w'void\ (*malloc_message)('u
+.BI "void (*malloc_message)(void\ *" "cbopaque" ", const\ char\ *" "s" ");"
+.PP
+const char *\fImalloc_conf\fR;
+.SH "DESCRIPTION"
+.SS "Standard API"
+.PP
+The
+malloc()
+function allocates
+\fIsize\fR
+bytes of uninitialized memory\&. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object\&.
+.PP
+The
+calloc()
+function allocates space for
+\fInumber\fR
+objects, each
+\fIsize\fR
+bytes in length\&. The result is identical to calling
+malloc()
+with an argument of
+\fInumber\fR
+*
+\fIsize\fR, with the exception that the allocated memory is explicitly initialized to zero bytes\&.
+.PP
+The
+posix_memalign()
+function allocates
+\fIsize\fR
+bytes of memory such that the allocation\*(Aqs base address is a multiple of
+\fIalignment\fR, and returns the allocation in the value pointed to by
+\fIptr\fR\&. The requested
+\fIalignment\fR
+must be a power of 2 at least as large as
+sizeof(\fBvoid *\fR)\&.
+.PP
+The
+aligned_alloc()
+function allocates
+\fIsize\fR
+bytes of memory such that the allocation\*(Aqs base address is a multiple of
+\fIalignment\fR\&. The requested
+\fIalignment\fR
+must be a power of 2\&. Behavior is undefined if
+\fIsize\fR
+is not an integral multiple of
+\fIalignment\fR\&.
+.PP
+The
+realloc()
+function changes the size of the previously allocated memory referenced by
+\fIptr\fR
+to
+\fIsize\fR
+bytes\&. The contents of the memory are unchanged up to the lesser of the new and old sizes\&. If the new size is larger, the contents of the newly allocated portion of the memory are undefined\&. Upon success, the memory referenced by
+\fIptr\fR
+is freed and a pointer to the newly allocated memory is returned\&. Note that
+realloc()
+may move the memory allocation, resulting in a different return value than
+\fIptr\fR\&. If
+\fIptr\fR
+is
+\fBNULL\fR, the
+realloc()
+function behaves identically to
+malloc()
+for the specified size\&.
+.PP
+The
+free()
+function causes the allocated memory referenced by
+\fIptr\fR
+to be made available for future allocations\&. If
+\fIptr\fR
+is
+\fBNULL\fR, no action occurs\&.
+.SS "Non\-standard API"
+.PP
+The
+mallocx(),
+rallocx(),
+xallocx(),
+sallocx(),
+dallocx(),
+sdallocx(), and
+nallocx()
+functions all have a
+\fIflags\fR
+argument that can be used to specify options\&. The functions only check the options that are contextually relevant\&. Use bitwise or (|) operations to specify one or more of the following:
+.PP
+\fBMALLOCX_LG_ALIGN(\fR\fB\fIla\fR\fR\fB) \fR
+.RS 4
+Align the memory allocation to start at an address that is a multiple of
+(1 << \fIla\fR)\&. This macro does not validate that
+\fIla\fR
+is within the valid range\&.
+.RE
+.PP
+\fBMALLOCX_ALIGN(\fR\fB\fIa\fR\fR\fB) \fR
+.RS 4
+Align the memory allocation to start at an address that is a multiple of
+\fIa\fR, where
+\fIa\fR
+is a power of two\&. This macro does not validate that
+\fIa\fR
+is a power of 2\&.
+.RE
+.PP
+\fBMALLOCX_ZERO\fR
+.RS 4
+Initialize newly allocated memory to contain zero bytes\&. In the growing reallocation case, the real size prior to reallocation defines the boundary between untouched bytes and those that are initialized to contain zero bytes\&. If this macro is absent, newly allocated memory is uninitialized\&.
+.RE
+.PP
+\fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB) \fR
+.RS 4
+Use the thread\-specific cache (tcache) specified by the identifier
+\fItc\fR, which must have been acquired via the
+tcache\&.create
+mallctl\&. This macro does not validate that
+\fItc\fR
+specifies a valid identifier\&.
+.RE
+.PP
+\fBMALLOCX_TCACHE_NONE\fR
+.RS 4
+Do not use a thread\-specific cache (tcache)\&. Unless
+\fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR
+or
+\fBMALLOCX_TCACHE_NONE\fR
+is specified, an automatically managed tcache will be used under many circumstances\&. This macro cannot be used in the same
+\fIflags\fR
+argument as
+\fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR\&.
+.RE
+.PP
+\fBMALLOCX_ARENA(\fR\fB\fIa\fR\fR\fB) \fR
+.RS 4
+Use the arena specified by the index
+\fIa\fR\&. This macro has no effect for regions that were allocated via an arena other than the one specified\&. This macro does not validate that
+\fIa\fR
+specifies an arena index in the valid range\&.
+.RE
+.PP
+The
+mallocx()
+function allocates at least
+\fIsize\fR
+bytes of memory, and returns a pointer to the base address of the allocation\&. Behavior is undefined if
+\fIsize\fR
+is
+\fB0\fR\&.
+.PP
+The
+rallocx()
+function resizes the allocation at
+\fIptr\fR
+to be at least
+\fIsize\fR
+bytes, and returns a pointer to the base address of the resulting allocation, which may or may not have moved from its original location\&. Behavior is undefined if
+\fIsize\fR
+is
+\fB0\fR\&.
+.PP
+The
+xallocx()
+function resizes the allocation at
+\fIptr\fR
+in place to be at least
+\fIsize\fR
+bytes, and returns the real size of the allocation\&. If
+\fIextra\fR
+is non\-zero, an attempt is made to resize the allocation to be at least
+(\fIsize\fR + \fIextra\fR)
+bytes, though inability to allocate the extra byte(s) will not by itself result in failure to resize\&. Behavior is undefined if
+\fIsize\fR
+is
+\fB0\fR, or if
+(\fIsize\fR + \fIextra\fR > \fBSIZE_T_MAX\fR)\&.
+.PP
+The
+sallocx()
+function returns the real size of the allocation at
+\fIptr\fR\&.
+.PP
+The
+dallocx()
+function causes the memory referenced by
+\fIptr\fR
+to be made available for future allocations\&.
+.PP
+The
+sdallocx()
+function is an extension of
+dallocx()
+with a
+\fIsize\fR
+parameter to allow the caller to pass in the allocation size as an optimization\&. The minimum valid input size is the original requested size of the allocation, and the maximum valid input size is the corresponding value returned by
+nallocx()
+or
+sallocx()\&.
+.PP
+The
+nallocx()
+function allocates no memory, but it performs the same size computation as the
+mallocx()
+function, and returns the real size of the allocation that would result from the equivalent
+mallocx()
+function call, or
+\fB0\fR
+if the inputs exceed the maximum supported size class and/or alignment\&. Behavior is undefined if
+\fIsize\fR
+is
+\fB0\fR\&.
+.PP
+The
+mallctl()
+function provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions\&. The period\-separated
+\fIname\fR
+argument specifies a location in a tree\-structured namespace; see the
+MALLCTL NAMESPACE
+section for documentation on the tree contents\&. To read a value, pass a pointer via
+\fIoldp\fR
+to adequate space to contain the value, and a pointer to its length via
+\fIoldlenp\fR; otherwise pass
+\fBNULL\fR
+and
+\fBNULL\fR\&. Similarly, to write a value, pass a pointer to the value via
+\fInewp\fR, and its length via
+\fInewlen\fR; otherwise pass
+\fBNULL\fR
+and
+\fB0\fR\&.
+.PP
+The
+mallctlnametomib()
+function provides a way to avoid repeated name lookups for applications that repeatedly query the same portion of the namespace, by translating a name to a
+\(lqManagement Information Base\(rq
+(MIB) that can be passed repeatedly to
+mallctlbymib()\&. Upon successful return from
+mallctlnametomib(),
+\fImibp\fR
+contains an array of
+\fI*miblenp\fR
+integers, where
+\fI*miblenp\fR
+is the lesser of the number of components in
+\fIname\fR
+and the input value of
+\fI*miblenp\fR\&. Thus it is possible to pass a
+\fI*miblenp\fR
+that is smaller than the number of period\-separated name components, which results in a partial MIB that can be used as the basis for constructing a complete MIB\&. For name components that are integers (e\&.g\&. the 2 in
+arenas\&.bin\&.2\&.size), the corresponding MIB component will always be that integer\&. Therefore, it is legitimate to construct code like the following:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+unsigned nbins, i;
+size_t mib[4];
+size_t len, miblen;
+
+len = sizeof(nbins);
+mallctl("arenas\&.nbins", &nbins, &len, NULL, 0);
+
+miblen = 4;
+mallctlnametomib("arenas\&.bin\&.0\&.size", mib, &miblen);
+for (i = 0; i < nbins; i++) {
+ size_t bin_size;
+
+ mib[2] = i;
+ len = sizeof(bin_size);
+ mallctlbymib(mib, miblen, (void *)&bin_size, &len, NULL, 0);
+ /* Do something with bin_size\&.\&.\&. */
+}
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+.RS 4
+.RE
+.PP
+The
+malloc_stats_print()
+function writes summary statistics via the
+\fIwrite_cb\fR
+callback function pointer and
+\fIcbopaque\fR
+data passed to
+\fIwrite_cb\fR, or
+malloc_message()
+if
+\fIwrite_cb\fR
+is
+\fBNULL\fR\&. The statistics are presented in human\-readable form unless
+\(lqJ\(rq
+is specified as a character within the
+\fIopts\fR
+string, in which case the statistics are presented in
+\m[blue]\fBJSON format\fR\m[]\&\s-2\u[2]\d\s+2\&. This function can be called repeatedly\&. General information that never changes during execution can be omitted by specifying
+\(lqg\(rq
+as a character within the
+\fIopts\fR
+string\&. Note that
+malloc_stats_print()
+uses the
+mallctl*()
+functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously\&. If
+\fB\-\-enable\-stats\fR
+is specified during configuration,
+\(lqm\(rq,
+\(lqd\(rq, and
+\(lqa\(rq
+can be specified to omit merged arena, destroyed merged arena, and per arena statistics, respectively;
+\(lqb\(rq
+and
+\(lql\(rq
+can be specified to omit per size class statistics for bins and large objects, respectively;
+\(lqx\(rq
+can be specified to omit all mutex statistics;
+\(lqe\(rq
+can be used to omit extent statistics\&. Unrecognized characters are silently ignored\&. Note that thread caching may prevent some statistics from being completely up to date, since extra locking would be required to merge counters that track thread cache operations\&.
+.PP
+The
+malloc_usable_size()
+function returns the usable size of the allocation pointed to by
+\fIptr\fR\&. The return value may be larger than the size that was requested during allocation\&. The
+malloc_usable_size()
+function is not a mechanism for in\-place
+realloc(); rather it is provided solely as a tool for introspection purposes\&. Any discrepancy between the requested allocation size and the size reported by
+malloc_usable_size()
+should not be depended on, since such behavior is entirely implementation\-dependent\&.
+.SH "TUNING"
+.PP
+Once, when the first call is made to one of the memory allocation routines, the allocator initializes its internals based in part on various options that can be specified at compile\- or run\-time\&.
+.PP
+The string specified via
+\fB\-\-with\-malloc\-conf\fR, the string pointed to by the global variable
+\fImalloc_conf\fR, the
+\(lqname\(rq
+of the file referenced by the symbolic link named
+/etc/malloc\&.conf, and the value of the environment variable
+\fBMALLOC_CONF\fR, will be interpreted, in that order, from left to right as options\&. Note that
+\fImalloc_conf\fR
+may be read before
+main()
+is entered, so the declaration of
+\fImalloc_conf\fR
+should specify an initializer that contains the final value to be read by jemalloc\&.
+\fB\-\-with\-malloc\-conf\fR
+and
+\fImalloc_conf\fR
+are compile\-time mechanisms, whereas
+/etc/malloc\&.conf
+and
+\fBMALLOC_CONF\fR
+can be safely set any time prior to program invocation\&.
+.PP
+An options string is a comma\-separated list of option:value pairs\&. There is one key corresponding to each
+opt\&.*
+mallctl (see the
+MALLCTL NAMESPACE
+section for options documentation)\&. For example,
+abort:true,narenas:1
+sets the
+opt\&.abort
+and
+opt\&.narenas
+options\&. Some options have boolean values (true/false), others have integer values (base 8, 10, or 16, depending on prefix), and yet others have raw string values\&.
+.SH "IMPLEMENTATION NOTES"
+.PP
+Traditionally, allocators have used
+\fBsbrk\fR(2)
+to obtain memory, which is suboptimal for several reasons, including race conditions, increased fragmentation, and artificial limitations on maximum usable memory\&. If
+\fBsbrk\fR(2)
+is supported by the operating system, this allocator uses both
+\fBmmap\fR(2)
+and
+\fBsbrk\fR(2), in that order of preference; otherwise only
+\fBmmap\fR(2)
+is used\&.
+.PP
+This allocator uses multiple arenas in order to reduce lock contention for threaded programs on multi\-processor systems\&. This works well with regard to threading scalability, but incurs some costs\&. There is a small fixed per\-arena overhead, and additionally, arenas manage memory completely independently of each other, which means a small fixed increase in overall memory fragmentation\&. These overheads are not generally an issue, given the number of arenas normally used\&. Note that using substantially more arenas than the default is not likely to improve performance, mainly due to reduced cache performance\&. However, it may make sense to reduce the number of arenas if an application does not make much use of the allocation functions\&.
+.PP
+In addition to multiple arenas, this allocator supports thread\-specific caching, in order to make it possible to completely avoid synchronization for most allocation requests\&. Such caching allows very fast allocation in the common case, but it increases memory usage and fragmentation, since a bounded number of objects can remain allocated in each thread cache\&.
+.PP
+Memory is conceptually broken into extents\&. Extents are always aligned to multiples of the page size\&. This alignment makes it possible to find metadata for user objects quickly\&. User objects are broken into two categories according to size: small and large\&. Contiguous small objects comprise a slab, which resides within a single extent, whereas large objects each have their own extents backing them\&.
+.PP
+Small objects are managed in groups by slabs\&. Each slab maintains a bitmap to track which regions are in use\&. Allocation requests that are no more than half the quantum (8 or 16, depending on architecture) are rounded up to the nearest power of two that is at least
+sizeof(\fBdouble\fR)\&. All other object size classes are multiples of the quantum, spaced such that there are four size classes for each doubling in size, which limits internal fragmentation to approximately 20% for all but the smallest size classes\&. Small size classes are smaller than four times the page size, and large size classes extend from four times the page size up to the largest size class that does not exceed
+\fBPTRDIFF_MAX\fR\&.
+.PP
+Allocations are packed tightly together, which can be an issue for multi\-threaded applications\&. If you need to assure that allocations do not suffer from cacheline sharing, round your allocation requests up to the nearest multiple of the cacheline size, or specify cacheline alignment when allocating\&.
+.PP
+The
+realloc(),
+rallocx(), and
+xallocx()
+functions may resize allocations without moving them under limited circumstances\&. Unlike the
+*allocx()
+API, the standard API does not officially round up the usable size of an allocation to the nearest size class, so technically it is necessary to call
+realloc()
+to grow e\&.g\&. a 9\-byte allocation to 16 bytes, or shrink a 16\-byte allocation to 9 bytes\&. Growth and shrinkage trivially succeeds in place as long as the pre\-size and post\-size both round up to the same size class\&. No other API guarantees are made regarding in\-place resizing, but the current implementation also tries to resize large allocations in place, as long as the pre\-size and post\-size are both large\&. For shrinkage to succeed, the extent allocator must support splitting (see
+arena\&.<i>\&.extent_hooks)\&. Growth only succeeds if the trailing memory is currently available, and the extent allocator supports merging\&.
+.PP
+Assuming 4 KiB pages and a 16\-byte quantum on a 64\-bit system, the size classes in each category are as shown in
+Table 1\&.
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.B Table\ \&1.\ \&Size classes
+.TS
+allbox tab(:);
+lB rB lB.
+T{
+Category
+T}:T{
+Spacing
+T}:T{
+Size
+T}
+.T&
+l r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+l r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l
+^ r l.
+T{
+Small
+T}:T{
+lg
+T}:T{
+[8]
+T}
+:T{
+16
+T}:T{
+[16, 32, 48, 64, 80, 96, 112, 128]
+T}
+:T{
+32
+T}:T{
+[160, 192, 224, 256]
+T}
+:T{
+64
+T}:T{
+[320, 384, 448, 512]
+T}
+:T{
+128
+T}:T{
+[640, 768, 896, 1024]
+T}
+:T{
+256
+T}:T{
+[1280, 1536, 1792, 2048]
+T}
+:T{
+512
+T}:T{
+[2560, 3072, 3584, 4096]
+T}
+:T{
+1 KiB
+T}:T{
+[5 KiB, 6 KiB, 7 KiB, 8 KiB]
+T}
+:T{
+2 KiB
+T}:T{
+[10 KiB, 12 KiB, 14 KiB]
+T}
+T{
+Large
+T}:T{
+2 KiB
+T}:T{
+[16 KiB]
+T}
+:T{
+4 KiB
+T}:T{
+[20 KiB, 24 KiB, 28 KiB, 32 KiB]
+T}
+:T{
+8 KiB
+T}:T{
+[40 KiB, 48 KiB, 54 KiB, 64 KiB]
+T}
+:T{
+16 KiB
+T}:T{
+[80 KiB, 96 KiB, 112 KiB, 128 KiB]
+T}
+:T{
+32 KiB
+T}:T{
+[160 KiB, 192 KiB, 224 KiB, 256 KiB]
+T}
+:T{
+64 KiB
+T}:T{
+[320 KiB, 384 KiB, 448 KiB, 512 KiB]
+T}
+:T{
+128 KiB
+T}:T{
+[640 KiB, 768 KiB, 896 KiB, 1 MiB]
+T}
+:T{
+256 KiB
+T}:T{
+[1280 KiB, 1536 KiB, 1792 KiB, 2 MiB]
+T}
+:T{
+512 KiB
+T}:T{
+[2560 KiB, 3 MiB, 3584 KiB, 4 MiB]
+T}
+:T{
+1 MiB
+T}:T{
+[5 MiB, 6 MiB, 7 MiB, 8 MiB]
+T}
+:T{
+2 MiB
+T}:T{
+[10 MiB, 12 MiB, 14 MiB, 16 MiB]
+T}
+:T{
+4 MiB
+T}:T{
+[20 MiB, 24 MiB, 28 MiB, 32 MiB]
+T}
+:T{
+8 MiB
+T}:T{
+[40 MiB, 48 MiB, 56 MiB, 64 MiB]
+T}
+:T{
+\&.\&.\&.
+T}:T{
+\&.\&.\&.
+T}
+:T{
+512 PiB
+T}:T{
+[2560 PiB, 3 EiB, 3584 PiB, 4 EiB]
+T}
+:T{
+1 EiB
+T}:T{
+[5 EiB, 6 EiB, 7 EiB]
+T}
+.TE
+.sp 1
+.SH "MALLCTL NAMESPACE"
+.PP
+The following names are defined in the namespace accessible via the
+mallctl*()
+functions\&. Value types are specified in parentheses, their readable/writable statuses are encoded as
+rw,
+r\-,
+\-w, or
+\-\-, and required build configuration flags follow, if any\&. A name element encoded as
+<i>
+or
+<j>
+indicates an integer component, where the integer varies from 0 to some upper value that must be determined via introspection\&. In the case of
+stats\&.arenas\&.<i>\&.*
+and
+arena\&.<i>\&.{initialized,purge,decay,dss},
+<i>
+equal to
+\fBMALLCTL_ARENAS_ALL\fR
+can be used to operate on all arenas or access the summation of statistics from all arenas; similarly
+<i>
+equal to
+\fBMALLCTL_ARENAS_DESTROYED\fR
+can be used to access the summation of statistics from all destroyed arenas\&. These constants can be utilized either via
+mallctlnametomib()
+followed by
+mallctlbymib(), or via code such as the following:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+#define STRINGIFY_HELPER(x) #x
+#define STRINGIFY(x) STRINGIFY_HELPER(x)
+
+mallctl("arena\&." STRINGIFY(MALLCTL_ARENAS_ALL) "\&.decay",
+ NULL, NULL, NULL, 0);
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Take special note of the
+epoch
+mallctl, which controls refreshing of cached dynamic statistics\&.
+.PP
+version (\fBconst char *\fR) r\-
+.RS 4
+Return the jemalloc version string\&.
+.RE
+.PP
+epoch (\fBuint64_t\fR) rw
+.RS 4
+If a value is passed in, refresh the data from which the
+mallctl*()
+functions report values, and increment the epoch\&. Return the current epoch\&. This is useful for detecting whether another thread caused a refresh\&.
+.RE
+.PP
+background_thread (\fBbool\fR) rw
+.RS 4
+Enable/disable internal background worker threads\&. When set to true, background threads are created on demand (the number of background threads will be no more than the number of CPUs or active arenas)\&. Threads run periodically, and handle
+purging
+asynchronously\&. When switching off, background threads are terminated synchronously\&. Note that after
+\fBfork\fR(2)
+function, the state in the child process will be disabled regardless the state in parent process\&. See
+stats\&.background_thread
+for related stats\&.
+opt\&.background_thread
+can be used to set the default option\&. This option is only available on selected pthread\-based platforms\&.
+.RE
+.PP
+max_background_threads (\fBsize_t\fR) rw
+.RS 4
+Maximum number of background worker threads that will be created\&. This value is capped at
+opt\&.max_background_threads
+at startup\&.
+.RE
+.PP
+config\&.cache_oblivious (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-cache\-oblivious\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.debug (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-debug\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.fill (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-fill\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.lazy_lock (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-lazy\-lock\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.malloc_conf (\fBconst char *\fR) r\-
+.RS 4
+Embedded configure\-time\-specified run\-time options string, empty unless
+\fB\-\-with\-malloc\-conf\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.prof (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-prof\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.prof_libgcc (\fBbool\fR) r\-
+.RS 4
+\fB\-\-disable\-prof\-libgcc\fR
+was not specified during build configuration\&.
+.RE
+.PP
+config\&.prof_libunwind (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-prof\-libunwind\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.stats (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-stats\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.utrace (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-utrace\fR
+was specified during build configuration\&.
+.RE
+.PP
+config\&.xmalloc (\fBbool\fR) r\-
+.RS 4
+\fB\-\-enable\-xmalloc\fR
+was specified during build configuration\&.
+.RE
+.PP
+opt\&.abort (\fBbool\fR) r\-
+.RS 4
+Abort\-on\-warning enabled/disabled\&. If true, most warnings are fatal\&. Note that runtime option warnings are not included (see
+opt\&.abort_conf
+for that)\&. The process will call
+\fBabort\fR(3)
+in these cases\&. This option is disabled by default unless
+\fB\-\-enable\-debug\fR
+is specified during configuration, in which case it is enabled by default\&.
+.RE
+.PP
+opt\&.confirm_conf (\fBbool\fR) r\-
+.RS 4
+Confirm\-runtime\-options\-when\-program\-starts enabled/disabled\&. If true, the string specified via
+\fB\-\-with\-malloc\-conf\fR, the string pointed to by the global variable
+\fImalloc_conf\fR, the
+\(lqname\(rq
+of the file referenced by the symbolic link named
+/etc/malloc\&.conf, and the value of the environment variable
+\fBMALLOC_CONF\fR, will be printed in order\&. Then, each option being set will be individually printed\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.abort_conf (\fBbool\fR) r\-
+.RS 4
+Abort\-on\-invalid\-configuration enabled/disabled\&. If true, invalid runtime options are fatal\&. The process will call
+\fBabort\fR(3)
+in these cases\&. This option is disabled by default unless
+\fB\-\-enable\-debug\fR
+is specified during configuration, in which case it is enabled by default\&.
+.RE
+.PP
+opt\&.metadata_thp (\fBconst char *\fR) r\-
+.RS 4
+Controls whether to allow jemalloc to use transparent huge page (THP) for internal metadata (see
+stats\&.metadata)\&.
+\(lqalways\(rq
+allows such usage\&.
+\(lqauto\(rq
+uses no THP initially, but may begin to do so when metadata usage reaches certain level\&. The default is
+\(lqdisabled\(rq\&.
+.RE
+.PP
+opt\&.retain (\fBbool\fR) r\-
+.RS 4
+If true, retain unused virtual memory for later reuse rather than discarding it by calling
+\fBmunmap\fR(2)
+or equivalent (see
+stats\&.retained
+for related details)\&. It also makes jemalloc use
+\fBmmap\fR(2)
+or equivalent in a more greedy way, mapping larger chunks in one go\&. This option is disabled by default unless discarding virtual memory is known to trigger platform\-specific performance problems, namely 1) for [64\-bit] Linux, which has a quirk in its virtual memory allocation algorithm that causes semi\-permanent VM map holes under normal jemalloc operation; and 2) for [64\-bit] Windows, which disallows split / merged regions with
+\fI\fBMEM_RELEASE\fR\fR\&. Although the same issues may present on 32\-bit platforms as well, retaining virtual memory for 32\-bit Linux and Windows is disabled by default due to the practical possibility of address space exhaustion\&.
+.RE
+.PP
+opt\&.dss (\fBconst char *\fR) r\-
+.RS 4
+dss (\fBsbrk\fR(2)) allocation precedence as related to
+\fBmmap\fR(2)
+allocation\&. The following settings are supported if
+\fBsbrk\fR(2)
+is supported by the operating system:
+\(lqdisabled\(rq,
+\(lqprimary\(rq, and
+\(lqsecondary\(rq; otherwise only
+\(lqdisabled\(rq
+is supported\&. The default is
+\(lqsecondary\(rq
+if
+\fBsbrk\fR(2)
+is supported by the operating system;
+\(lqdisabled\(rq
+otherwise\&.
+.RE
+.PP
+opt\&.narenas (\fBunsigned\fR) r\-
+.RS 4
+Maximum number of arenas to use for automatic multiplexing of threads and arenas\&. The default is four times the number of CPUs, or one if there is a single CPU\&.
+.RE
+.PP
+opt\&.oversize_threshold (\fBsize_t\fR) r\-
+.RS 4
+The threshold in bytes of which requests are considered oversize\&. Allocation requests with greater sizes are fulfilled from a dedicated arena (automatically managed, however not within
+narenas), in order to reduce fragmentation by not mixing huge allocations with small ones\&. In addition, the decay API guarantees on the extents greater than the specified threshold may be overridden\&. Note that requests with arena index specified via
+\fBMALLOCX_ARENA\fR, or threads associated with explicit arenas will not be considered\&. The default threshold is 8MiB\&. Values not within large size classes disables this feature\&.
+.RE
+.PP
+opt\&.percpu_arena (\fBconst char *\fR) r\-
+.RS 4
+Per CPU arena mode\&. Use the
+\(lqpercpu\(rq
+setting to enable this feature, which uses number of CPUs to determine number of arenas, and bind threads to arenas dynamically based on the CPU the thread runs on currently\&.
+\(lqphycpu\(rq
+setting uses one arena per physical CPU, which means the two hyper threads on the same CPU share one arena\&. Note that no runtime checking regarding the availability of hyper threading is done at the moment\&. When set to
+\(lqdisabled\(rq, narenas and thread to arena association will not be impacted by this option\&. The default is
+\(lqdisabled\(rq\&.
+.RE
+.PP
+opt\&.background_thread (\fBbool\fR) r\-
+.RS 4
+Internal background worker threads enabled/disabled\&. Because of potential circular dependencies, enabling background thread using this option may cause crash or deadlock during initialization\&. For a reliable way to use this feature, see
+background_thread
+for dynamic control options and details\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.max_background_threads (\fBsize_t\fR) r\-
+.RS 4
+Maximum number of background threads that will be created if
+background_thread
+is set\&. Defaults to number of cpus\&.
+.RE
+.PP
+opt\&.dirty_decay_ms (\fBssize_t\fR) r\-
+.RS 4
+Approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged (i\&.e\&. converted to muzzy via e\&.g\&.
+madvise(\fI\&.\&.\&.\fR\fI\fBMADV_FREE\fR\fR)
+if supported by the operating system, or converted to clean otherwise) and/or reused\&. Dirty pages are defined as previously having been potentially written to by the application, and therefore consuming physical memory, yet having no current use\&. The pages are incrementally purged according to a sigmoidal decay curve that starts and ends with zero purge rate\&. A decay time of 0 causes all unused dirty pages to be purged immediately upon creation\&. A decay time of \-1 disables purging\&. The default decay time is 10 seconds\&. See
+arenas\&.dirty_decay_ms
+and
+arena\&.<i>\&.dirty_decay_ms
+for related dynamic control options\&. See
+opt\&.muzzy_decay_ms
+for a description of muzzy pages\&.for a description of muzzy pages\&. Note that when the
+oversize_threshold
+feature is enabled, the arenas reserved for oversize requests may have its own default decay settings\&.
+.RE
+.PP
+opt\&.muzzy_decay_ms (\fBssize_t\fR) r\-
+.RS 4
+Approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged (i\&.e\&. converted to clean) and/or reused\&. Muzzy pages are defined as previously having been unused dirty pages that were subsequently purged in a manner that left them subject to the reclamation whims of the operating system (e\&.g\&.
+madvise(\fI\&.\&.\&.\fR\fI\fBMADV_FREE\fR\fR)), and therefore in an indeterminate state\&. The pages are incrementally purged according to a sigmoidal decay curve that starts and ends with zero purge rate\&. A decay time of 0 causes all unused muzzy pages to be purged immediately upon creation\&. A decay time of \-1 disables purging\&. The default decay time is 10 seconds\&. See
+arenas\&.muzzy_decay_ms
+and
+arena\&.<i>\&.muzzy_decay_ms
+for related dynamic control options\&.
+.RE
+.PP
+opt\&.lg_extent_max_active_fit (\fBsize_t\fR) r\-
+.RS 4
+When reusing dirty extents, this determines the (log base 2 of the) maximum ratio between the size of the active extent selected (to split off from) and the size of the requested allocation\&. This prevents the splitting of large active extents for smaller allocations, which can reduce fragmentation over the long run (especially for non\-active extents)\&. Lower value may reduce fragmentation, at the cost of extra active extents\&. The default value is 6, which gives a maximum ratio of 64 (2^6)\&.
+.RE
+.PP
+opt\&.stats_print (\fBbool\fR) r\-
+.RS 4
+Enable/disable statistics printing at exit\&. If enabled, the
+malloc_stats_print()
+function is called at program exit via an
+\fBatexit\fR(3)
+function\&.
+opt\&.stats_print_opts
+can be combined to specify output options\&. If
+\fB\-\-enable\-stats\fR
+is specified during configuration, this has the potential to cause deadlock for a multi\-threaded process that exits while one or more threads are executing in the memory allocation functions\&. Furthermore,
+atexit()
+may allocate memory during application initialization and then deadlock internally when jemalloc in turn calls
+atexit(), so this option is not universally usable (though the application can register its own
+atexit()
+function with equivalent functionality)\&. Therefore, this option should only be used with care; it is primarily intended as a performance tuning aid during application development\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.stats_print_opts (\fBconst char *\fR) r\-
+.RS 4
+Options (the
+\fIopts\fR
+string) to pass to the
+malloc_stats_print()
+at exit (enabled through
+opt\&.stats_print)\&. See available options in
+malloc_stats_print()\&. Has no effect unless
+opt\&.stats_print
+is enabled\&. The default is
+\(lq\(rq\&.
+.RE
+.PP
+opt\&.junk (\fBconst char *\fR) r\- [\fB\-\-enable\-fill\fR]
+.RS 4
+Junk filling\&. If set to
+\(lqalloc\(rq, each byte of uninitialized allocated memory will be initialized to
+0xa5\&. If set to
+\(lqfree\(rq, all deallocated memory will be initialized to
+0x5a\&. If set to
+\(lqtrue\(rq, both allocated and deallocated memory will be initialized, and if set to
+\(lqfalse\(rq, junk filling be disabled entirely\&. This is intended for debugging and will impact performance negatively\&. This option is
+\(lqfalse\(rq
+by default unless
+\fB\-\-enable\-debug\fR
+is specified during configuration, in which case it is
+\(lqtrue\(rq
+by default\&.
+.RE
+.PP
+opt\&.zero (\fBbool\fR) r\- [\fB\-\-enable\-fill\fR]
+.RS 4
+Zero filling enabled/disabled\&. If enabled, each byte of uninitialized allocated memory will be initialized to 0\&. Note that this initialization only happens once for each byte, so
+realloc()
+and
+rallocx()
+calls do not zero memory that was previously allocated\&. This is intended for debugging and will impact performance negatively\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.utrace (\fBbool\fR) r\- [\fB\-\-enable\-utrace\fR]
+.RS 4
+Allocation tracing based on
+\fButrace\fR(2)
+enabled/disabled\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.xmalloc (\fBbool\fR) r\- [\fB\-\-enable\-xmalloc\fR]
+.RS 4
+Abort\-on\-out\-of\-memory enabled/disabled\&. If enabled, rather than returning failure for any allocation function, display a diagnostic message on
+\fBSTDERR_FILENO\fR
+and cause the program to drop core (using
+\fBabort\fR(3))\&. If an application is designed to depend on this behavior, set the option at compile time by including the following in the source code:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+malloc_conf = "xmalloc:true";
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+This option is disabled by default\&.
+.RE
+.PP
+opt\&.tcache (\fBbool\fR) r\-
+.RS 4
+Thread\-specific caching (tcache) enabled/disabled\&. When there are multiple threads, each thread uses a tcache for objects up to a certain size\&. Thread\-specific caching allows many allocations to be satisfied without performing any thread synchronization, at the cost of increased memory use\&. See the
+opt\&.lg_tcache_max
+option for related tuning information\&. This option is enabled by default\&.
+.RE
+.PP
+opt\&.lg_tcache_max (\fBsize_t\fR) r\-
+.RS 4
+Maximum size class (log base 2) to cache in the thread\-specific cache (tcache)\&. At a minimum, all small size classes are cached, and at a maximum all large size classes are cached\&. The default maximum is 32 KiB (2^15)\&.
+.RE
+.PP
+opt\&.thp (\fBconst char *\fR) r\-
+.RS 4
+Transparent hugepage (THP) mode\&. Settings "always", "never" and "default" are available if THP is supported by the operating system\&. The "always" setting enables transparent hugepage for all user memory mappings with
+\fI\fBMADV_HUGEPAGE\fR\fR; "never" ensures no transparent hugepage with
+\fI\fBMADV_NOHUGEPAGE\fR\fR; the default setting "default" makes no changes\&. Note that: this option does not affect THP for jemalloc internal metadata (see
+opt\&.metadata_thp); in addition, for arenas with customized
+extent_hooks, this option is bypassed as it is implemented as part of the default extent hooks\&.
+.RE
+.PP
+opt\&.prof (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Memory profiling enabled/disabled\&. If enabled, profile memory allocation activity\&. See the
+opt\&.prof_active
+option for on\-the\-fly activation/deactivation\&. See the
+opt\&.lg_prof_sample
+option for probabilistic sampling control\&. See the
+opt\&.prof_accum
+option for control of cumulative sample reporting\&. See the
+opt\&.lg_prof_interval
+option for information on interval\-triggered profile dumping, the
+opt\&.prof_gdump
+option for information on high\-water\-triggered profile dumping, and the
+opt\&.prof_final
+option for final profile dumping\&. Profile output is compatible with the
+\fBjeprof\fR
+command, which is based on the
+\fBpprof\fR
+that is developed as part of the
+\m[blue]\fBgperftools package\fR\m[]\&\s-2\u[3]\d\s+2\&. See
+HEAP PROFILE FORMAT
+for heap profile format documentation\&.
+.RE
+.PP
+opt\&.prof_prefix (\fBconst char *\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Filename prefix for profile dumps\&. If the prefix is set to the empty string, no automatic dumps will occur; this is primarily useful for disabling the automatic final heap dump (which also disables leak reporting, if enabled)\&. The default prefix is
+jeprof\&.
+.RE
+.PP
+opt\&.prof_active (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Profiling activated/deactivated\&. This is a secondary control mechanism that makes it possible to start the application with profiling enabled (see the
+opt\&.prof
+option) but inactive, then toggle profiling at any time during program execution with the
+prof\&.active
+mallctl\&. This option is enabled by default\&.
+.RE
+.PP
+opt\&.prof_thread_active_init (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Initial setting for
+thread\&.prof\&.active
+in newly created threads\&. The initial setting for newly created threads can also be changed during execution via the
+prof\&.thread_active_init
+mallctl\&. This option is enabled by default\&.
+.RE
+.PP
+opt\&.lg_prof_sample (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Average interval (log base 2) between allocation samples, as measured in bytes of allocation activity\&. Increasing the sampling interval decreases profile fidelity, but also decreases the computational overhead\&. The default sample interval is 512 KiB (2^19 B)\&.
+.RE
+.PP
+opt\&.prof_accum (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Reporting of cumulative object/byte counts in profile dumps enabled/disabled\&. If this option is enabled, every unique backtrace must be stored for the duration of execution\&. Depending on the application, this can impose a large memory overhead, and the cumulative counts are not always of interest\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.lg_prof_interval (\fBssize_t\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Average interval (log base 2) between memory profile dumps, as measured in bytes of allocation activity\&. The actual interval between dumps may be sporadic because decentralized allocation counters are used to avoid synchronization bottlenecks\&. Profiles are dumped to files named according to the pattern
+<prefix>\&.<pid>\&.<seq>\&.i<iseq>\&.heap, where
+<prefix>
+is controlled by the
+opt\&.prof_prefix
+option\&. By default, interval\-triggered profile dumping is disabled (encoded as \-1)\&.
+.RE
+.PP
+opt\&.prof_gdump (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Set the initial state of
+prof\&.gdump, which when enabled triggers a memory profile dump every time the total virtual memory exceeds the previous maximum\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.prof_final (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Use an
+\fBatexit\fR(3)
+function to dump final memory usage to a file named according to the pattern
+<prefix>\&.<pid>\&.<seq>\&.f\&.heap, where
+<prefix>
+is controlled by the
+opt\&.prof_prefix
+option\&. Note that
+atexit()
+may allocate memory during application initialization and then deadlock internally when jemalloc in turn calls
+atexit(), so this option is not universally usable (though the application can register its own
+atexit()
+function with equivalent functionality)\&. This option is disabled by default\&.
+.RE
+.PP
+opt\&.prof_leak (\fBbool\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Leak reporting enabled/disabled\&. If enabled, use an
+\fBatexit\fR(3)
+function to report memory leaks detected by allocation sampling\&. See the
+opt\&.prof
+option for information on analyzing heap profile output\&. This option is disabled by default\&.
+.RE
+.PP
+thread\&.arena (\fBunsigned\fR) rw
+.RS 4
+Get or set the arena associated with the calling thread\&. If the specified arena was not initialized beforehand (see the
+arena\&.i\&.initialized
+mallctl), it will be automatically initialized as a side effect of calling this interface\&.
+.RE
+.PP
+thread\&.allocated (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Get the total number of bytes ever allocated by the calling thread\&. This counter has the potential to wrap around; it is up to the application to appropriately interpret the counter in such cases\&.
+.RE
+.PP
+thread\&.allocatedp (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Get a pointer to the the value that is returned by the
+thread\&.allocated
+mallctl\&. This is useful for avoiding the overhead of repeated
+mallctl*()
+calls\&.
+.RE
+.PP
+thread\&.deallocated (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Get the total number of bytes ever deallocated by the calling thread\&. This counter has the potential to wrap around; it is up to the application to appropriately interpret the counter in such cases\&.
+.RE
+.PP
+thread\&.deallocatedp (\fBuint64_t *\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Get a pointer to the the value that is returned by the
+thread\&.deallocated
+mallctl\&. This is useful for avoiding the overhead of repeated
+mallctl*()
+calls\&.
+.RE
+.PP
+thread\&.tcache\&.enabled (\fBbool\fR) rw
+.RS 4
+Enable/disable calling thread\*(Aqs tcache\&. The tcache is implicitly flushed as a side effect of becoming disabled (see
+thread\&.tcache\&.flush)\&.
+.RE
+.PP
+thread\&.tcache\&.flush (\fBvoid\fR) \-\-
+.RS 4
+Flush calling thread\*(Aqs thread\-specific cache (tcache)\&. This interface releases all cached objects and internal data structures associated with the calling thread\*(Aqs tcache\&. Ordinarily, this interface need not be called, since automatic periodic incremental garbage collection occurs, and the thread cache is automatically discarded when a thread exits\&. However, garbage collection is triggered by allocation activity, so it is possible for a thread that stops allocating/deallocating to retain its cache indefinitely, in which case the developer may find manual flushing useful\&.
+.RE
+.PP
+thread\&.prof\&.name (\fBconst char *\fR) r\- or \-w [\fB\-\-enable\-prof\fR]
+.RS 4
+Get/set the descriptive name associated with the calling thread in memory profile dumps\&. An internal copy of the name string is created, so the input string need not be maintained after this interface completes execution\&. The output string of this interface should be copied for non\-ephemeral uses, because multiple implementation details can cause asynchronous string deallocation\&. Furthermore, each invocation of this interface can only read or write; simultaneous read/write is not supported due to string lifetime limitations\&. The name string must be nil\-terminated and comprised only of characters in the sets recognized by
+\fBisgraph\fR(3)
+and
+\fBisblank\fR(3)\&.
+.RE
+.PP
+thread\&.prof\&.active (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
+.RS 4
+Control whether sampling is currently active for the calling thread\&. This is an activation mechanism in addition to
+prof\&.active; both must be active for the calling thread to sample\&. This flag is enabled by default\&.
+.RE
+.PP
+tcache\&.create (\fBunsigned\fR) r\-
+.RS 4
+Create an explicit thread\-specific cache (tcache) and return an identifier that can be passed to the
+\fBMALLOCX_TCACHE(\fR\fB\fItc\fR\fR\fB)\fR
+macro to explicitly use the specified cache rather than the automatically managed one that is used by default\&. Each explicit cache can be used by only one thread at a time; the application must assure that this constraint holds\&.
+.RE
+.PP
+tcache\&.flush (\fBunsigned\fR) \-w
+.RS 4
+Flush the specified thread\-specific cache (tcache)\&. The same considerations apply to this interface as to
+thread\&.tcache\&.flush, except that the tcache will never be automatically discarded\&.
+.RE
+.PP
+tcache\&.destroy (\fBunsigned\fR) \-w
+.RS 4
+Flush the specified thread\-specific cache (tcache) and make the identifier available for use during a future tcache creation\&.
+.RE
+.PP
+arena\&.<i>\&.initialized (\fBbool\fR) r\-
+.RS 4
+Get whether the specified arena\*(Aqs statistics are initialized (i\&.e\&. the arena was initialized prior to the current epoch)\&. This interface can also be nominally used to query whether the merged statistics corresponding to
+\fBMALLCTL_ARENAS_ALL\fR
+are initialized (always true)\&.
+.RE
+.PP
+arena\&.<i>\&.decay (\fBvoid\fR) \-\-
+.RS 4
+Trigger decay\-based purging of unused dirty/muzzy pages for arena <i>, or for all arenas if <i> equals
+\fBMALLCTL_ARENAS_ALL\fR\&. The proportion of unused dirty/muzzy pages to be purged depends on the current time; see
+opt\&.dirty_decay_ms
+and
+opt\&.muzy_decay_ms
+for details\&.
+.RE
+.PP
+arena\&.<i>\&.purge (\fBvoid\fR) \-\-
+.RS 4
+Purge all unused dirty pages for arena <i>, or for all arenas if <i> equals
+\fBMALLCTL_ARENAS_ALL\fR\&.
+.RE
+.PP
+arena\&.<i>\&.reset (\fBvoid\fR) \-\-
+.RS 4
+Discard all of the arena\*(Aqs extant allocations\&. This interface can only be used with arenas explicitly created via
+arenas\&.create\&. None of the arena\*(Aqs discarded/cached allocations may accessed afterward\&. As part of this requirement, all thread caches which were used to allocate/deallocate in conjunction with the arena must be flushed beforehand\&.
+.RE
+.PP
+arena\&.<i>\&.destroy (\fBvoid\fR) \-\-
+.RS 4
+Destroy the arena\&. Discard all of the arena\*(Aqs extant allocations using the same mechanism as for
+arena\&.<i>\&.reset
+(with all the same constraints and side effects), merge the arena stats into those accessible at arena index
+\fBMALLCTL_ARENAS_DESTROYED\fR, and then completely discard all metadata associated with the arena\&. Future calls to
+arenas\&.create
+may recycle the arena index\&. Destruction will fail if any threads are currently associated with the arena as a result of calls to
+thread\&.arena\&.
+.RE
+.PP
+arena\&.<i>\&.dss (\fBconst char *\fR) rw
+.RS 4
+Set the precedence of dss allocation as related to mmap allocation for arena <i>, or for all arenas if <i> equals
+\fBMALLCTL_ARENAS_ALL\fR\&. See
+opt\&.dss
+for supported settings\&.
+.RE
+.PP
+arena\&.<i>\&.dirty_decay_ms (\fBssize_t\fR) rw
+.RS 4
+Current per\-arena approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused\&. Each time this interface is set, all currently unused dirty pages are considered to have fully decayed, which causes immediate purging of all unused dirty pages unless the decay time is set to \-1 (i\&.e\&. purging disabled)\&. See
+opt\&.dirty_decay_ms
+for additional information\&.
+.RE
+.PP
+arena\&.<i>\&.muzzy_decay_ms (\fBssize_t\fR) rw
+.RS 4
+Current per\-arena approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged and/or reused\&. Each time this interface is set, all currently unused muzzy pages are considered to have fully decayed, which causes immediate purging of all unused muzzy pages unless the decay time is set to \-1 (i\&.e\&. purging disabled)\&. See
+opt\&.muzzy_decay_ms
+for additional information\&.
+.RE
+.PP
+arena\&.<i>\&.retain_grow_limit (\fBsize_t\fR) rw
+.RS 4
+Maximum size to grow retained region (only relevant when
+opt\&.retain
+is enabled)\&. This controls the maximum increment to expand virtual memory, or allocation through
+arena\&.<i>extent_hooks\&. In particular, if customized extent hooks reserve physical memory (e\&.g\&. 1G huge pages), this is useful to control the allocation hook\*(Aqs input size\&. The default is no limit\&.
+.RE
+.PP
+arena\&.<i>\&.extent_hooks (\fBextent_hooks_t *\fR) rw
+.RS 4
+Get or set the extent management hook functions for arena <i>\&. The functions must be capable of operating on all extant extents associated with arena <i>, usually by passing unknown extents to the replaced functions\&. In practice, it is feasible to control allocation for arenas explicitly created via
+arenas\&.create
+such that all extents originate from an application\-supplied extent allocator (by specifying the custom extent hook functions during arena creation)\&. However, the API guarantees for the automatically created arenas may be relaxed \-\- hooks set there may be called in a "best effort" fashion; in addition there may be extents created prior to the application having an opportunity to take over extent allocation\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+typedef extent_hooks_s extent_hooks_t;
+struct extent_hooks_s {
+ extent_alloc_t *alloc;
+ extent_dalloc_t *dalloc;
+ extent_destroy_t *destroy;
+ extent_commit_t *commit;
+ extent_decommit_t *decommit;
+ extent_purge_t *purge_lazy;
+ extent_purge_t *purge_forced;
+ extent_split_t *split;
+ extent_merge_t *merge;
+};
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The
+\fBextent_hooks_t\fR
+structure comprises function pointers which are described individually below\&. jemalloc uses these functions to manage extent lifetime, which starts off with allocation of mapped committed memory, in the simplest case followed by deallocation\&. However, there are performance and platform reasons to retain extents for later reuse\&. Cleanup attempts cascade from deallocation to decommit to forced purging to lazy purging, which gives the extent management functions opportunities to reject the most permanent cleanup operations in favor of less permanent (and often less costly) operations\&. All operations except allocation can be universally opted out of by setting the hook pointers to
+\fBNULL\fR, or selectively opted out of by returning failure\&. Note that once the extent hook is set, the structure is accessed directly by the associated arenas, so it must remain valid for the entire lifetime of the arenas\&.
+.HP \w'typedef\ void\ *(extent_alloc_t)('u
+.BI "typedef void *(extent_alloc_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "new_addr" ", size_t\ " "size" ", size_t\ " "alignment" ", bool\ *" "zero" ", bool\ *" "commit" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent allocation function conforms to the
+\fBextent_alloc_t\fR
+type and upon success returns a pointer to
+\fIsize\fR
+bytes of mapped memory on behalf of arena
+\fIarena_ind\fR
+such that the extent\*(Aqs base address is a multiple of
+\fIalignment\fR, as well as setting
+\fI*zero\fR
+to indicate whether the extent is zeroed and
+\fI*commit\fR
+to indicate whether the extent is committed\&. Upon error the function returns
+\fBNULL\fR
+and leaves
+\fI*zero\fR
+and
+\fI*commit\fR
+unmodified\&. The
+\fIsize\fR
+parameter is always a multiple of the page size\&. The
+\fIalignment\fR
+parameter is always a power of two at least as large as the page size\&. Zeroing is mandatory if
+\fI*zero\fR
+is true upon function entry\&. Committing is mandatory if
+\fI*commit\fR
+is true upon function entry\&. If
+\fInew_addr\fR
+is not
+\fBNULL\fR, the returned pointer must be
+\fInew_addr\fR
+on success or
+\fBNULL\fR
+on error\&. Committed memory may be committed in absolute terms as on a system that does not overcommit, or in implicit terms as on a system that overcommits and satisfies physical memory needs on demand via soft page faults\&. Note that replacing the default extent allocation function makes the arena\*(Aqs
+arena\&.<i>\&.dss
+setting irrelevant\&.
+.HP \w'typedef\ bool\ (extent_dalloc_t)('u
+.BI "typedef bool (extent_dalloc_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent deallocation function conforms to the
+\fBextent_dalloc_t\fR
+type and deallocates an extent at given
+\fIaddr\fR
+and
+\fIsize\fR
+with
+\fIcommitted\fR/decommited memory as indicated, on behalf of arena
+\fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates opt\-out from deallocation; the virtual memory mapping associated with the extent remains mapped, in the same commit state, and available for future use, in which case it will be automatically retained for later reuse\&.
+.HP \w'typedef\ void\ (extent_destroy_t)('u
+.BI "typedef void (extent_destroy_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent destruction function conforms to the
+\fBextent_destroy_t\fR
+type and unconditionally destroys an extent at given
+\fIaddr\fR
+and
+\fIsize\fR
+with
+\fIcommitted\fR/decommited memory as indicated, on behalf of arena
+\fIarena_ind\fR\&. This function may be called to destroy retained extents during arena destruction (see
+arena\&.<i>\&.destroy)\&.
+.HP \w'typedef\ bool\ (extent_commit_t)('u
+.BI "typedef bool (extent_commit_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent commit function conforms to the
+\fBextent_commit_t\fR
+type and commits zeroed physical memory to back pages within an extent at given
+\fIaddr\fR
+and
+\fIsize\fR
+at
+\fIoffset\fR
+bytes, extending for
+\fIlength\fR
+on behalf of arena
+\fIarena_ind\fR, returning false upon success\&. Committed memory may be committed in absolute terms as on a system that does not overcommit, or in implicit terms as on a system that overcommits and satisfies physical memory needs on demand via soft page faults\&. If the function returns true, this indicates insufficient physical memory to satisfy the request\&.
+.HP \w'typedef\ bool\ (extent_decommit_t)('u
+.BI "typedef bool (extent_decommit_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent decommit function conforms to the
+\fBextent_decommit_t\fR
+type and decommits any physical memory that is backing pages within an extent at given
+\fIaddr\fR
+and
+\fIsize\fR
+at
+\fIoffset\fR
+bytes, extending for
+\fIlength\fR
+on behalf of arena
+\fIarena_ind\fR, returning false upon success, in which case the pages will be committed via the extent commit function before being reused\&. If the function returns true, this indicates opt\-out from decommit; the memory remains committed and available for future use, in which case it will be automatically retained for later reuse\&.
+.HP \w'typedef\ bool\ (extent_purge_t)('u
+.BI "typedef bool (extent_purge_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "offset" ", size_t\ " "length" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent purge function conforms to the
+\fBextent_purge_t\fR
+type and discards physical pages within the virtual memory mapping associated with an extent at given
+\fIaddr\fR
+and
+\fIsize\fR
+at
+\fIoffset\fR
+bytes, extending for
+\fIlength\fR
+on behalf of arena
+\fIarena_ind\fR\&. A lazy extent purge function (e\&.g\&. implemented via
+madvise(\fI\&.\&.\&.\fR\fI\fBMADV_FREE\fR\fR)) can delay purging indefinitely and leave the pages within the purged virtual memory range in an indeterminite state, whereas a forced extent purge function immediately purges, and the pages within the virtual memory range will be zero\-filled the next time they are accessed\&. If the function returns true, this indicates failure to purge\&.
+.HP \w'typedef\ bool\ (extent_split_t)('u
+.BI "typedef bool (extent_split_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr" ", size_t\ " "size" ", size_t\ " "size_a" ", size_t\ " "size_b" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent split function conforms to the
+\fBextent_split_t\fR
+type and optionally splits an extent at given
+\fIaddr\fR
+and
+\fIsize\fR
+into two adjacent extents, the first of
+\fIsize_a\fR
+bytes, and the second of
+\fIsize_b\fR
+bytes, operating on
+\fIcommitted\fR/decommitted memory as indicated, on behalf of arena
+\fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates that the extent remains unsplit and therefore should continue to be operated on as a whole\&.
+.HP \w'typedef\ bool\ (extent_merge_t)('u
+.BI "typedef bool (extent_merge_t)(extent_hooks_t\ *" "extent_hooks" ", void\ *" "addr_a" ", size_t\ " "size_a" ", void\ *" "addr_b" ", size_t\ " "size_b" ", bool\ " "committed" ", unsigned\ " "arena_ind" ");"
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+An extent merge function conforms to the
+\fBextent_merge_t\fR
+type and optionally merges adjacent extents, at given
+\fIaddr_a\fR
+and
+\fIsize_a\fR
+with given
+\fIaddr_b\fR
+and
+\fIsize_b\fR
+into one contiguous extent, operating on
+\fIcommitted\fR/decommitted memory as indicated, on behalf of arena
+\fIarena_ind\fR, returning false upon success\&. If the function returns true, this indicates that the extents remain distinct mappings and therefore should continue to be operated on independently\&.
+.RE
+.PP
+arenas\&.narenas (\fBunsigned\fR) r\-
+.RS 4
+Current limit on number of arenas\&.
+.RE
+.PP
+arenas\&.dirty_decay_ms (\fBssize_t\fR) rw
+.RS 4
+Current default per\-arena approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused, used to initialize
+arena\&.<i>\&.dirty_decay_ms
+during arena creation\&. See
+opt\&.dirty_decay_ms
+for additional information\&.
+.RE
+.PP
+arenas\&.muzzy_decay_ms (\fBssize_t\fR) rw
+.RS 4
+Current default per\-arena approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged and/or reused, used to initialize
+arena\&.<i>\&.muzzy_decay_ms
+during arena creation\&. See
+opt\&.muzzy_decay_ms
+for additional information\&.
+.RE
+.PP
+arenas\&.quantum (\fBsize_t\fR) r\-
+.RS 4
+Quantum size\&.
+.RE
+.PP
+arenas\&.page (\fBsize_t\fR) r\-
+.RS 4
+Page size\&.
+.RE
+.PP
+arenas\&.tcache_max (\fBsize_t\fR) r\-
+.RS 4
+Maximum thread\-cached size class\&.
+.RE
+.PP
+arenas\&.nbins (\fBunsigned\fR) r\-
+.RS 4
+Number of bin size classes\&.
+.RE
+.PP
+arenas\&.nhbins (\fBunsigned\fR) r\-
+.RS 4
+Total number of thread cache bin size classes\&.
+.RE
+.PP
+arenas\&.bin\&.<i>\&.size (\fBsize_t\fR) r\-
+.RS 4
+Maximum size supported by size class\&.
+.RE
+.PP
+arenas\&.bin\&.<i>\&.nregs (\fBuint32_t\fR) r\-
+.RS 4
+Number of regions per slab\&.
+.RE
+.PP
+arenas\&.bin\&.<i>\&.slab_size (\fBsize_t\fR) r\-
+.RS 4
+Number of bytes per slab\&.
+.RE
+.PP
+arenas\&.nlextents (\fBunsigned\fR) r\-
+.RS 4
+Total number of large size classes\&.
+.RE
+.PP
+arenas\&.lextent\&.<i>\&.size (\fBsize_t\fR) r\-
+.RS 4
+Maximum size supported by this large size class\&.
+.RE
+.PP
+arenas\&.create (\fBunsigned\fR, \fBextent_hooks_t *\fR) rw
+.RS 4
+Explicitly create a new arena outside the range of automatically managed arenas, with optionally specified extent hooks, and return the new arena index\&.
+.RE
+.PP
+arenas\&.lookup (\fBunsigned\fR, \fBvoid*\fR) rw
+.RS 4
+Index of the arena to which an allocation belongs to\&.
+.RE
+.PP
+prof\&.thread_active_init (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
+.RS 4
+Control the initial setting for
+thread\&.prof\&.active
+in newly created threads\&. See the
+opt\&.prof_thread_active_init
+option for additional information\&.
+.RE
+.PP
+prof\&.active (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
+.RS 4
+Control whether sampling is currently active\&. See the
+opt\&.prof_active
+option for additional information, as well as the interrelated
+thread\&.prof\&.active
+mallctl\&.
+.RE
+.PP
+prof\&.dump (\fBconst char *\fR) \-w [\fB\-\-enable\-prof\fR]
+.RS 4
+Dump a memory profile to the specified file, or if NULL is specified, to a file according to the pattern
+<prefix>\&.<pid>\&.<seq>\&.m<mseq>\&.heap, where
+<prefix>
+is controlled by the
+opt\&.prof_prefix
+option\&.
+.RE
+.PP
+prof\&.gdump (\fBbool\fR) rw [\fB\-\-enable\-prof\fR]
+.RS 4
+When enabled, trigger a memory profile dump every time the total virtual memory exceeds the previous maximum\&. Profiles are dumped to files named according to the pattern
+<prefix>\&.<pid>\&.<seq>\&.u<useq>\&.heap, where
+<prefix>
+is controlled by the
+opt\&.prof_prefix
+option\&.
+.RE
+.PP
+prof\&.reset (\fBsize_t\fR) \-w [\fB\-\-enable\-prof\fR]
+.RS 4
+Reset all memory profile statistics, and optionally update the sample rate (see
+opt\&.lg_prof_sample
+and
+prof\&.lg_sample)\&.
+.RE
+.PP
+prof\&.lg_sample (\fBsize_t\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Get the current sample rate (see
+opt\&.lg_prof_sample)\&.
+.RE
+.PP
+prof\&.interval (\fBuint64_t\fR) r\- [\fB\-\-enable\-prof\fR]
+.RS 4
+Average number of bytes allocated between interval\-based profile dumps\&. See the
+opt\&.lg_prof_interval
+option for additional information\&.
+.RE
+.PP
+stats\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Total number of bytes allocated by the application\&.
+.RE
+.PP
+stats\&.active (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Total number of bytes in active pages allocated by the application\&. This is a multiple of the page size, and greater than or equal to
+stats\&.allocated\&. This does not include
+stats\&.arenas\&.<i>\&.pdirty,
+stats\&.arenas\&.<i>\&.pmuzzy, nor pages entirely devoted to allocator metadata\&.
+.RE
+.PP
+stats\&.metadata (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Total number of bytes dedicated to metadata, which comprise base allocations used for bootstrap\-sensitive allocator metadata structures (see
+stats\&.arenas\&.<i>\&.base) and internal allocations (see
+stats\&.arenas\&.<i>\&.internal)\&. Transparent huge page (enabled with
+opt\&.metadata_thp) usage is not considered\&.
+.RE
+.PP
+stats\&.metadata_thp (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of transparent huge pages (THP) used for metadata\&. See
+stats\&.metadata
+and
+opt\&.metadata_thp) for details\&.
+.RE
+.PP
+stats\&.resident (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Maximum number of bytes in physically resident data pages mapped by the allocator, comprising all pages dedicated to allocator metadata, pages backing active allocations, and unused dirty pages\&. This is a maximum rather than precise because pages may not actually be physically resident if they correspond to demand\-zeroed virtual memory that has not yet been touched\&. This is a multiple of the page size, and is larger than
+stats\&.active\&.
+.RE
+.PP
+stats\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Total number of bytes in active extents mapped by the allocator\&. This is larger than
+stats\&.active\&. This does not include inactive extents, even those that contain unused dirty pages, which means that there is no strict ordering between this and
+stats\&.resident\&.
+.RE
+.PP
+stats\&.retained (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Total number of bytes in virtual memory mappings that were retained rather than being returned to the operating system via e\&.g\&.
+\fBmunmap\fR(2)
+or similar\&. Retained virtual memory is typically untouched, decommitted, or purged, so it has no strongly associated physical memory (see
+extent hooks
+for details)\&. Retained memory is excluded from mapped memory statistics, e\&.g\&.
+stats\&.mapped\&.
+.RE
+.PP
+stats\&.background_thread\&.num_threads (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of
+background threads
+running currently\&.
+.RE
+.PP
+stats\&.background_thread\&.num_runs (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Total number of runs from all
+background threads\&.
+.RE
+.PP
+stats\&.background_thread\&.run_interval (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Average run interval in nanoseconds of
+background threads\&.
+.RE
+.PP
+stats\&.mutexes\&.ctl\&.{counter}; (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIctl\fR
+mutex (global scope; mallctl related)\&.
+{counter}
+is one of the counters below:
+.PP
+.RS 4
+\fInum_ops\fR
+(\fBuint64_t\fR): Total number of lock acquisition operations on this mutex\&.
+.sp
+\fInum_spin_acq\fR
+(\fBuint64_t\fR): Number of times the mutex was spin\-acquired\&. When the mutex is currently locked and cannot be acquired immediately, a short period of spin\-retry within jemalloc will be performed\&. Acquired through spin generally means the contention was lightweight and not causing context switches\&.
+.sp
+\fInum_wait\fR
+(\fBuint64_t\fR): Number of times the mutex was wait\-acquired, which means the mutex contention was not solved by spin\-retry, and blocking operation was likely involved in order to acquire the mutex\&. This event generally implies higher cost / longer delay, and should be investigated if it happens often\&.
+.sp
+\fImax_wait_time\fR
+(\fBuint64_t\fR): Maximum length of time in nanoseconds spent on a single wait\-acquired lock operation\&. Note that to avoid profiling overhead on the common path, this does not consider spin\-acquired cases\&.
+.sp
+\fItotal_wait_time\fR
+(\fBuint64_t\fR): Cumulative time in nanoseconds spent on wait\-acquired lock operations\&. Similarly, spin\-acquired cases are not considered\&.
+.sp
+\fImax_num_thds\fR
+(\fBuint32_t\fR): Maximum number of threads waiting on this mutex simultaneously\&. Similarly, spin\-acquired cases are not considered\&.
+.sp
+\fInum_owner_switch\fR
+(\fBuint64_t\fR): Number of times the current mutex owner is different from the previous one\&. This event does not generally imply an issue; rather it is an indicator of how often the protected data are accessed by different threads\&.
+.RE
+.RE
+.PP
+stats\&.mutexes\&.background_thread\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIbackground_thread\fR
+mutex (global scope;
+background_thread
+related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.mutexes\&.prof\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIprof\fR
+mutex (global scope; profiling related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.mutexes\&.reset (\fBvoid\fR) \-\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Reset all mutex profile statistics, including global mutexes, arena mutexes and bin mutexes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.dss (\fBconst char *\fR) r\-
+.RS 4
+dss (\fBsbrk\fR(2)) allocation precedence as related to
+\fBmmap\fR(2)
+allocation\&. See
+opt\&.dss
+for details\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.dirty_decay_ms (\fBssize_t\fR) r\-
+.RS 4
+Approximate time in milliseconds from the creation of a set of unused dirty pages until an equivalent set of unused dirty pages is purged and/or reused\&. See
+opt\&.dirty_decay_ms
+for details\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.muzzy_decay_ms (\fBssize_t\fR) r\-
+.RS 4
+Approximate time in milliseconds from the creation of a set of unused muzzy pages until an equivalent set of unused muzzy pages is purged and/or reused\&. See
+opt\&.muzzy_decay_ms
+for details\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.nthreads (\fBunsigned\fR) r\-
+.RS 4
+Number of threads currently assigned to arena\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.uptime (\fBuint64_t\fR) r\-
+.RS 4
+Time elapsed (in nanoseconds) since the arena was created\&. If <i> equals
+\fB0\fR
+or
+\fBMALLCTL_ARENAS_ALL\fR, this is the uptime since malloc initialization\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.pactive (\fBsize_t\fR) r\-
+.RS 4
+Number of pages in active extents\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.pdirty (\fBsize_t\fR) r\-
+.RS 4
+Number of pages within unused extents that are potentially dirty, and for which
+madvise()
+or similar has not been called\&. See
+opt\&.dirty_decay_ms
+for a description of dirty pages\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.pmuzzy (\fBsize_t\fR) r\-
+.RS 4
+Number of pages within unused extents that are muzzy\&. See
+opt\&.muzzy_decay_ms
+for a description of muzzy pages\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mapped (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of mapped bytes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.retained (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of retained bytes\&. See
+stats\&.retained
+for details\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.extent_avail (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of allocated (but unused) extent structs in this arena\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.base (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of bytes dedicated to bootstrap\-sensitive allocator metadata structures\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.internal (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of bytes dedicated to internal allocations\&. Internal allocations differ from application\-originated allocations in that they are for internal use, and that they are omitted from heap profiles\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.metadata_thp (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of transparent huge pages (THP) used for metadata\&. See
+opt\&.metadata_thp
+for details\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.resident (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Maximum number of bytes in physically resident data pages mapped by the arena, comprising all pages dedicated to allocator metadata, pages backing active allocations, and unused dirty pages\&. This is a maximum rather than precise because pages may not actually be physically resident if they correspond to demand\-zeroed virtual memory that has not yet been touched\&. This is a multiple of the page size\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.dirty_npurge (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of dirty page purge sweeps performed\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.dirty_nmadvise (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of
+madvise()
+or similar calls made to purge dirty pages\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.dirty_purged (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of dirty pages purged\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.muzzy_npurge (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of muzzy page purge sweeps performed\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.muzzy_nmadvise (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of
+madvise()
+or similar calls made to purge muzzy pages\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.muzzy_purged (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of muzzy pages purged\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.small\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of bytes currently allocated by small objects\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.small\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a small allocation was requested from the arena\*(Aqs bins, whether to fill the relevant tcache if
+opt\&.tcache
+is enabled, or to directly satisfy an allocation request otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.small\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a small allocation was returned to the arena\*(Aqs bins, whether to flush the relevant tcache if
+opt\&.tcache
+is enabled, or to directly deallocate an allocation otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.small\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of allocation requests satisfied by all bin size classes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.small\&.nfills (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of tcache fills by all small size classes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.small\&.nflushes (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of tcache flushes by all small size classes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.large\&.allocated (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of bytes currently allocated by large objects\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.large\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a large extent was allocated from the arena, whether to fill the relevant tcache if
+opt\&.tcache
+is enabled and the size class is within the range being cached, or to directly satisfy an allocation request otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.large\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a large extent was returned to the arena, whether to flush the relevant tcache if
+opt\&.tcache
+is enabled and the size class is within the range being cached, or to directly deallocate an allocation otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.large\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of allocation requests satisfied by all large size classes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.large\&.nfills (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of tcache fills by all large size classes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.large\&.nflushes (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of tcache flushes by all large size classes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a bin region of the corresponding size class was allocated from the arena, whether to fill the relevant tcache if
+opt\&.tcache
+is enabled, or to directly satisfy an allocation request otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a bin region of the corresponding size class was returned to the arena, whether to flush the relevant tcache if
+opt\&.tcache
+is enabled, or to directly deallocate an allocation otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of allocation requests satisfied by bin regions of the corresponding size class\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.curregs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Current number of regions for this size class\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nfills (\fBuint64_t\fR) r\-
+.RS 4
+Cumulative number of tcache fills\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nflushes (\fBuint64_t\fR) r\-
+.RS 4
+Cumulative number of tcache flushes\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nslabs (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of slabs created\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nreslabs (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times the current slab from which to allocate changed\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.curslabs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Current number of slabs\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.nonfull_slabs (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Current number of nonfull slabs\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.bins\&.<j>\&.mutex\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.bins\&.<j>\fR
+mutex (arena bin scope; bin operation related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.extents\&.<j>\&.n{extent_type} (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Number of extents of the given type in this arena in the bucket corresponding to page size index <j>\&. The extent type is one of dirty, muzzy, or retained\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.extents\&.<j>\&.{extent_type}_bytes (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Sum of the bytes managed by extents of the given type in this arena in the bucket corresponding to page size index <j>\&. The extent type is one of dirty, muzzy, or retained\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.lextents\&.<j>\&.nmalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a large extent of the corresponding size class was allocated from the arena, whether to fill the relevant tcache if
+opt\&.tcache
+is enabled and the size class is within the range being cached, or to directly satisfy an allocation request otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.lextents\&.<j>\&.ndalloc (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of times a large extent of the corresponding size class was returned to the arena, whether to flush the relevant tcache if
+opt\&.tcache
+is enabled and the size class is within the range being cached, or to directly deallocate an allocation otherwise\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.lextents\&.<j>\&.nrequests (\fBuint64_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Cumulative number of allocation requests satisfied by large extents of the corresponding size class\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.lextents\&.<j>\&.curlextents (\fBsize_t\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Current number of large allocations for this size class\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.large\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.large\fR
+mutex (arena scope; large allocation related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.extent_avail\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.extent_avail \fR
+mutex (arena scope; extent avail related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.extents_dirty\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.extents_dirty \fR
+mutex (arena scope; dirty extents related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.extents_muzzy\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.extents_muzzy \fR
+mutex (arena scope; muzzy extents related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.extents_retained\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.extents_retained \fR
+mutex (arena scope; retained extents related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.decay_dirty\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.decay_dirty \fR
+mutex (arena scope; decay for dirty pages related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.decay_muzzy\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.decay_muzzy \fR
+mutex (arena scope; decay for muzzy pages related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.base\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.base\fR
+mutex (arena scope; base allocator related)\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.PP
+stats\&.arenas\&.<i>\&.mutexes\&.tcache_list\&.{counter} (\fBcounter specific type\fR) r\- [\fB\-\-enable\-stats\fR]
+.RS 4
+Statistics on
+\fIarena\&.<i>\&.tcache_list\fR
+mutex (arena scope; tcache to arena association related)\&. This mutex is expected to be accessed less often\&.
+{counter}
+is one of the counters in
+mutex profiling counters\&.
+.RE
+.SH "HEAP PROFILE FORMAT"
+.PP
+Although the heap profiling functionality was originally designed to be compatible with the
+\fBpprof\fR
+command that is developed as part of the
+\m[blue]\fBgperftools package\fR\m[]\&\s-2\u[3]\d\s+2, the addition of per thread heap profiling functionality required a different heap profile format\&. The
+\fBjeprof\fR
+command is derived from
+\fBpprof\fR, with enhancements to support the heap profile format described here\&.
+.PP
+In the following hypothetical heap profile,
+\fB[\&.\&.\&.]\fR
+indicates elision for the sake of compactness\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+heap_v2/524288
+ t*: 28106: 56637512 [0: 0]
+ [\&.\&.\&.]
+ t3: 352: 16777344 [0: 0]
+ [\&.\&.\&.]
+ t99: 17754: 29341640 [0: 0]
+ [\&.\&.\&.]
+@ 0x5f86da8 0x5f5a1dc [\&.\&.\&.] 0x29e4d4e 0xa200316 0xabb2988 [\&.\&.\&.]
+ t*: 13: 6688 [0: 0]
+ t3: 12: 6496 [0: ]
+ t99: 1: 192 [0: 0]
+[\&.\&.\&.]
+
+MAPPED_LIBRARIES:
+[\&.\&.\&.]
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+The following matches the above heap profile, but most tokens are replaced with
+\fB<description>\fR
+to indicate descriptions of the corresponding fields\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+<heap_profile_format_version>/<mean_sample_interval>
+ <aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
+ [\&.\&.\&.]
+ <thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
+ [\&.\&.\&.]
+ <thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
+ [\&.\&.\&.]
+@ <top_frame> <frame> [\&.\&.\&.] <frame> <frame> <frame> [\&.\&.\&.]
+ <backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
+ <backtrace_thread_3>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
+ <backtrace_thread_99>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
+[\&.\&.\&.]
+
+MAPPED_LIBRARIES:
+</proc/<pid>/maps>
+.fi
+.if n \{\
+.RE
+.\}
+.SH "DEBUGGING MALLOC PROBLEMS"
+.PP
+When debugging, it is a good idea to configure/build jemalloc with the
+\fB\-\-enable\-debug\fR
+and
+\fB\-\-enable\-fill\fR
+options, and recompile the program with suitable options and symbols for debugger support\&. When so configured, jemalloc incorporates a wide variety of run\-time assertions that catch application errors such as double\-free, write\-after\-free, etc\&.
+.PP
+Programs often accidentally depend on
+\(lquninitialized\(rq
+memory actually being filled with zero bytes\&. Junk filling (see the
+opt\&.junk
+option) tends to expose such bugs in the form of obviously incorrect results and/or coredumps\&. Conversely, zero filling (see the
+opt\&.zero
+option) eliminates the symptoms of such bugs\&. Between these two options, it is usually possible to quickly detect, diagnose, and eliminate such bugs\&.
+.PP
+This implementation does not provide much detail about the problems it detects, because the performance impact for storing such information would be prohibitive\&.
+.SH "DIAGNOSTIC MESSAGES"
+.PP
+If any of the memory allocation/deallocation functions detect an error or warning condition, a message will be printed to file descriptor
+\fBSTDERR_FILENO\fR\&. Errors will result in the process dumping core\&. If the
+opt\&.abort
+option is set, most warnings are treated as errors\&.
+.PP
+The
+\fImalloc_message\fR
+variable allows the programmer to override the function which emits the text strings forming the errors and warnings if for some reason the
+\fBSTDERR_FILENO\fR
+file descriptor is not suitable for this\&.
+malloc_message()
+takes the
+\fIcbopaque\fR
+pointer argument that is
+\fBNULL\fR
+unless overridden by the arguments in a call to
+malloc_stats_print(), followed by a string pointer\&. Please note that doing anything which tries to allocate memory in this function is likely to result in a crash or deadlock\&.
+.PP
+All messages are prefixed by
+\(lq<jemalloc>: \(rq\&.
+.SH "RETURN VALUES"
+.SS "Standard API"
+.PP
+The
+malloc()
+and
+calloc()
+functions return a pointer to the allocated memory if successful; otherwise a
+\fBNULL\fR
+pointer is returned and
+\fIerrno\fR
+is set to
+ENOMEM\&.
+.PP
+The
+posix_memalign()
+function returns the value 0 if successful; otherwise it returns an error value\&. The
+posix_memalign()
+function will fail if:
+.PP
+EINVAL
+.RS 4
+The
+\fIalignment\fR
+parameter is not a power of 2 at least as large as
+sizeof(\fBvoid *\fR)\&.
+.RE
+.PP
+ENOMEM
+.RS 4
+Memory allocation error\&.
+.RE
+.PP
+The
+aligned_alloc()
+function returns a pointer to the allocated memory if successful; otherwise a
+\fBNULL\fR
+pointer is returned and
+\fIerrno\fR
+is set\&. The
+aligned_alloc()
+function will fail if:
+.PP
+EINVAL
+.RS 4
+The
+\fIalignment\fR
+parameter is not a power of 2\&.
+.RE
+.PP
+ENOMEM
+.RS 4
+Memory allocation error\&.
+.RE
+.PP
+The
+realloc()
+function returns a pointer, possibly identical to
+\fIptr\fR, to the allocated memory if successful; otherwise a
+\fBNULL\fR
+pointer is returned, and
+\fIerrno\fR
+is set to
+ENOMEM
+if the error was the result of an allocation failure\&. The
+realloc()
+function always leaves the original buffer intact when an error occurs\&.
+.PP
+The
+free()
+function returns no value\&.
+.SS "Non\-standard API"
+.PP
+The
+mallocx()
+and
+rallocx()
+functions return a pointer to the allocated memory if successful; otherwise a
+\fBNULL\fR
+pointer is returned to indicate insufficient contiguous memory was available to service the allocation request\&.
+.PP
+The
+xallocx()
+function returns the real size of the resulting resized allocation pointed to by
+\fIptr\fR, which is a value less than
+\fIsize\fR
+if the allocation could not be adequately grown in place\&.
+.PP
+The
+sallocx()
+function returns the real size of the allocation pointed to by
+\fIptr\fR\&.
+.PP
+The
+nallocx()
+returns the real size that would result from a successful equivalent
+mallocx()
+function call, or zero if insufficient memory is available to perform the size computation\&.
+.PP
+The
+mallctl(),
+mallctlnametomib(), and
+mallctlbymib()
+functions return 0 on success; otherwise they return an error value\&. The functions will fail if:
+.PP
+EINVAL
+.RS 4
+\fInewp\fR
+is not
+\fBNULL\fR, and
+\fInewlen\fR
+is too large or too small\&. Alternatively,
+\fI*oldlenp\fR
+is too large or too small; in this case as much data as possible are read despite the error\&.
+.RE
+.PP
+ENOENT
+.RS 4
+\fIname\fR
+or
+\fImib\fR
+specifies an unknown/invalid value\&.
+.RE
+.PP
+EPERM
+.RS 4
+Attempt to read or write void value, or attempt to write read\-only value\&.
+.RE
+.PP
+EAGAIN
+.RS 4
+A memory allocation failure occurred\&.
+.RE
+.PP
+EFAULT
+.RS 4
+An interface with side effects failed in some way not directly related to
+mallctl*()
+read/write processing\&.
+.RE
+.PP
+The
+malloc_usable_size()
+function returns the usable size of the allocation pointed to by
+\fIptr\fR\&.
+.SH "ENVIRONMENT"
+.PP
+The following environment variable affects the execution of the allocation functions:
+.PP
+\fBMALLOC_CONF\fR
+.RS 4
+If the environment variable
+\fBMALLOC_CONF\fR
+is set, the characters it contains will be interpreted as options\&.
+.RE
+.SH "EXAMPLES"
+.PP
+To dump core whenever a problem occurs:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+ln \-s \*(Aqabort:true\*(Aq /etc/malloc\&.conf
+.fi
+.if n \{\
+.RE
+.\}
+.PP
+To specify in the source that only one arena should be automatically created:
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+malloc_conf = "narenas:1";
+.fi
+.if n \{\
+.RE
+.\}
+.SH "SEE ALSO"
+.PP
+\fBmadvise\fR(2),
+\fBmmap\fR(2),
+\fBsbrk\fR(2),
+\fButrace\fR(2),
+\fBalloca\fR(3),
+\fBatexit\fR(3),
+\fBgetpagesize\fR(3)
+.SH "STANDARDS"
+.PP
+The
+malloc(),
+calloc(),
+realloc(), and
+free()
+functions conform to ISO/IEC 9899:1990 (\(lqISO C90\(rq)\&.
+.PP
+The
+posix_memalign()
+function conforms to IEEE Std 1003\&.1\-2001 (\(lqPOSIX\&.1\(rq)\&.
+.SH "HISTORY"
+.PP
+The
+malloc_usable_size()
+and
+posix_memalign()
+functions first appeared in FreeBSD 7\&.0\&.
+.PP
+The
+aligned_alloc(),
+malloc_stats_print(), and
+mallctl*()
+functions first appeared in FreeBSD 10\&.0\&.
+.PP
+The
+*allocx()
+functions first appeared in FreeBSD 11\&.0\&.
+.SH "AUTHOR"
+.PP
+\fBJason Evans\fR
+.RS 4
+.RE
+.SH "NOTES"
+.IP " 1." 4
+jemalloc website
+.RS 4
+\%http://jemalloc.net/
+.RE
+.IP " 2." 4
+JSON format
+.RS 4
+\%http://www.json.org/
+.RE
+.IP " 3." 4
+gperftools package
+.RS 4
+\%http://code.google.com/p/gperftools/
+.RE
diff --git a/lib/libc/stdlib/memory.3 b/lib/libc/stdlib/memory.3
index 143dce488f7e..b7703cf44bd5 100644
--- a/lib/libc/stdlib/memory.3
+++ b/lib/libc/stdlib/memory.3
@@ -25,52 +25,79 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memory.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
+.Dd October 18, 2023
.Dt MEMORY 3
.Os
.Sh NAME
-.Nm malloc ,
+.Nm aligned_alloc ,
+.Nm alloca ,
+.Nm calloc ,
.Nm free ,
+.Nm malloc ,
+.Nm posix_memalign ,
.Nm realloc ,
-.Nm calloc ,
-.Nm alloca ,
-.Nm mmap
-.Nd general memory allocation operations
+.Nm reallocf ,
+.Nm valloc ,
+.Nm mmap ,
+.Nm munmap
+.Nd memory management functions
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
.Ft void *
-.Fn malloc "size_t size"
+.Fn aligned_alloc "size_t alignment" "size_t size"
+.Ft void *
+.Fn alloca "size_t size"
+.Ft void *
+.Fn calloc "size_t nelem" "size_t elsize"
.Ft void
.Fn free "void *ptr"
.Ft void *
+.Fn malloc "size_t size"
+.Ft int
+.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size"
+.Ft void *
.Fn realloc "void *ptr" "size_t size"
.Ft void *
-.Fn calloc "size_t nelem" "size_t elsize"
+.Fn reallocf "void *ptr" "size_t size"
.Ft void *
-.Fn alloca "size_t size"
+.Fn valloc "size_t size"
.In sys/types.h
.In sys/mman.h
.Ft void *
.Fn mmap "void * addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
+.Ft int
+.Fn munmap "void *addr" "size_t len"
.Sh DESCRIPTION
These functions allocate and free memory for the calling process.
They are described in the
individual manual pages.
.Sh SEE ALSO
.Xr mmap 2 ,
+.Xr aligned_alloc 3 ,
.Xr alloca 3 ,
.Xr calloc 3 ,
.Xr free 3 ,
.Xr malloc 3 ,
-.Xr realloc 3
+.Xr posix_memalign 3 ,
+.Xr realloc 3 ,
+.Xr reallocf 3 ,
+.Xr valloc 3
.Sh STANDARDS
-These functions, with the exception of
-.Fn alloca
+The
+.Fn calloc ,
+.Fn free ,
+.Fn malloc ,
and
-.Fn mmap
-conform to
+.Fn realloc
+functions conform to
.St -isoC .
+.Pp
+The
+.Fn mmap ,
+.Fn munmap ,
+and
+.Fn posix_memalign
+functions conform to
+.St -p1003.1-2001 .
diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c
index 42f061be17a8..e70938088589 100644
--- a/lib/libc/stdlib/merge.c
+++ b/lib/libc/stdlib/merge.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* Hybrid exponential search/linear search merge sort with hybrid
* natural/pairwise first pass. Requires about .3% more comparisons
diff --git a/lib/libc/stdlib/ptsname.3 b/lib/libc/stdlib/ptsname.3
index 532ce9e92ae0..df23e9ae6129 100644
--- a/lib/libc/stdlib/ptsname.3
+++ b/lib/libc/stdlib/ptsname.3
@@ -29,7 +29,7 @@
.\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
.\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 17, 2020
+.Dd October 14, 2023
.Dt PTSNAME 3
.Os
.Sh NAME
@@ -104,7 +104,7 @@ function clears the lock held on the pseudo-terminal pair
for the master device specified with
.Fa fildes .
.Sh RETURN VALUES
-.Rv -std grantpt ptsname_r unlockpt
+.Rv -std grantpt unlockpt
.Pp
The
.Fn ptsname
@@ -112,6 +112,19 @@ function returns a pointer to the name
of the slave device on success; otherwise a
.Dv NULL
pointer is returned.
+.Pp
+The
+.Fn ptsname_r
+function returns the value 0 if successful;
+otherwise a nonzero value is returned and the global variable
+.Va errno
+is set to indicate the error.
+Note:
+.Fn ptsname_r
+was previously documented as returning -1 on error.
+In the future it will be changed to return an error number, for POSIX
+compatibility.
+Therefore, callers should not check for -1.
.Sh ERRORS
The
.Fn grantpt ,
diff --git a/lib/libc/stdlib/ptsname.c b/lib/libc/stdlib/ptsname.c
index 13fe1479cb0d..adbf0e1692a4 100644
--- a/lib/libc/stdlib/ptsname.c
+++ b/lib/libc/stdlib/ptsname.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#ifndef lint
-#endif /* not lint */
-
#include "namespace.h"
#include <sys/param.h>
#include <sys/ioctl.h>
diff --git a/lib/libc/stdlib/qsort.3 b/lib/libc/stdlib/qsort.3
index 6e585cecbf48..e2e29e7cf04f 100644
--- a/lib/libc/stdlib/qsort.3
+++ b/lib/libc/stdlib/qsort.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)qsort.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd April 19, 2023
+.Dd October 25, 2024
.Dt QSORT 3
.Os
.Sh NAME
@@ -250,16 +248,8 @@ untrue.
The
.Fn qsort_s
function behaves the same as
-.Fn qsort_r , except that:
-.Bl -dash
-.It
-The order of arguments is different
-.It
-The order of arguments to
-.Fa compar
-is different
-.It
-If
+.Fn qsort_r ,
+except that if
.Fa nmemb
or
.Fa size
@@ -279,7 +269,6 @@ returns an error.
Note that the handler is called before
.Fn qsort_s
returns the error, and the handler function might not return.
-.El
.Sh RETURN VALUES
The
.Fn qsort
@@ -335,16 +324,21 @@ main(void)
.Sh COMPATIBILITY
The order of arguments for the comparison function used with
.Fn qsort_r
-is different from the one used by
-.Fn qsort_s ,
+is historically different from the one used by
+.Fn qsort_s
and the GNU libc implementation of
.Fn qsort_r .
-When porting software written for GNU libc, it is usually possible
-to replace
+However, as of
+.Fx 14.0 ,
+the
.Fn qsort_r
-with
-.Fn qsort_s
-to work around this problem.
+has been updated so that the
+.Fa thunk
+parameter appears last to match
+.St -p1003.1-2024 .
+Both the historical and the updated interfaces are now accepted
+via C11 generic selection and C++ polymorphism,
+but the updated interface is recommended for portable applications.
.Pp
.Fn qsort_s
is part of the
@@ -428,11 +422,15 @@ were unable to allocate memory.
.Sh STANDARDS
The
.Fn qsort
-function
-conforms to
+function conforms to
.St -isoC .
+The
+.Fn qsort_r
+function conforms to
+.St -p1003.1-2024 .
+The
.Fn qsort_s
-conforms to
+function conforms to
.St -isoC-2011
K.3.6.3.2.
.Sh HISTORY
@@ -444,4 +442,5 @@ In
.Fx 14.0 ,
the prototype of
.Fn qsort_r
-was updated to match POSIX.
+was updated to match
+.St -p1003.1-2024 .
diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c
index d6b6005333f5..e0b06494cf98 100644
--- a/lib/libc/stdlib/qsort.c
+++ b/lib/libc/stdlib/qsort.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/quick_exit.c b/lib/libc/stdlib/quick_exit.c
index 05db690cb6e7..4dee7b20bd2b 100644
--- a/lib/libc/stdlib/quick_exit.c
+++ b/lib/libc/stdlib/quick_exit.c
@@ -2,6 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2011 David Chisnall
+ * Copyright (c) 2023 Klara, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,44 +28,35 @@
*/
#include <sys/types.h>
-#include <machine/atomic.h>
+
+#include <stdatomic.h>
#include <stdlib.h>
-#include <pthread.h>
/**
- * Linked list of quick exit handlers. This is simpler than the atexit()
- * version, because it is not required to support C++ destructors or
- * DSO-specific cleanups.
+ * Linked list of quick exit handlers. These will be invoked in reverse
+ * order of insertion when quick_exit() is called. This is simpler than
+ * the atexit() version, because it is not required to support C++
+ * destructors or DSO-specific cleanups.
*/
struct quick_exit_handler {
struct quick_exit_handler *next;
void (*cleanup)(void);
};
-/**
- * Lock protecting the handlers list.
- */
-static pthread_mutex_t atexit_mutex = PTHREAD_MUTEX_INITIALIZER;
-/**
- * Stack of cleanup handlers. These will be invoked in reverse order when
- */
-static struct quick_exit_handler *handlers;
+static _Atomic(struct quick_exit_handler *) handlers;
int
at_quick_exit(void (*func)(void))
{
struct quick_exit_handler *h;
-
- h = malloc(sizeof(*h));
- if (NULL == h)
- return (1);
+ if ((h = calloc(1, sizeof(*h))) == NULL) {
+ return (-1);
+ }
h->cleanup = func;
- pthread_mutex_lock(&atexit_mutex);
- h->next = handlers;
- __compiler_membar();
- handlers = h;
- pthread_mutex_unlock(&atexit_mutex);
+ while (!atomic_compare_exchange_strong(&handlers, &h->next, h)) {
+ /* nothing */ ;
+ }
return (0);
}
@@ -77,8 +69,8 @@ quick_exit(int status)
* XXX: The C++ spec requires us to call std::terminate if there is an
* exception here.
*/
- for (h = handlers; NULL != h; h = h->next) {
- __compiler_membar();
+ for (h = atomic_load_explicit(&handlers, memory_order_acquire);
+ h != NULL; h = h->next) {
h->cleanup();
}
_Exit(status);
diff --git a/lib/libc/stdlib/radixsort.3 b/lib/libc/stdlib/radixsort.3
index 8344eb3a77b1..8ae4008a946e 100644
--- a/lib/libc/stdlib/radixsort.3
+++ b/lib/libc/stdlib/radixsort.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)radixsort.3 8.2 (Berkeley) 1/27/94
-.\"
.Dd January 27, 1994
.Dt RADIXSORT 3
.Os
diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c
index 2f5b959cd549..4193df4d66d1 100644
--- a/lib/libc/stdlib/radixsort.c
+++ b/lib/libc/stdlib/radixsort.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)radixsort.c 8.2 (Berkeley) 4/28/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
/*
* Radixsort routines.
*
diff --git a/lib/libc/stdlib/rand.3 b/lib/libc/stdlib/rand.3
index ed0d4e31a8d6..33eaa191b4fe 100644
--- a/lib/libc/stdlib/rand.3
+++ b/lib/libc/stdlib/rand.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rand.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd February 1, 2020
.Dt RAND 3
.Os
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index f02839e06fc9..31b51b327a0d 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -31,10 +31,6 @@
* Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/stdlib/random.3 b/lib/libc/stdlib/random.3
index 3a58eb2f2f17..b29536d4371d 100644
--- a/lib/libc/stdlib/random.3
+++ b/lib/libc/stdlib/random.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)random.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd February 1, 2020
.Dt RANDOM 3
.Os
diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c
index 8e0832754b3b..6e9702229da8 100644
--- a/lib/libc/stdlib/random.c
+++ b/lib/libc/stdlib/random.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/stdlib/reallocarray.3 b/lib/libc/stdlib/reallocarray.3
index d92be7d3f66b..80035c67a497 100644
--- a/lib/libc/stdlib/reallocarray.3
+++ b/lib/libc/stdlib/reallocarray.3
@@ -131,6 +131,10 @@ if ((newp = reallocarray(p, num, size)) == NULL) {
.Ed
.Sh SEE ALSO
.Xr realloc 3
+.Sh STANDARDS
+.Fn reallocarray
+conforms to
+.St -p1003.1-2024 .
.Sh HISTORY
The
.Fn reallocarray
diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c
index 76e4d331c4ce..0868804486cc 100644
--- a/lib/libc/stdlib/reallocarray.c
+++ b/lib/libc/stdlib/reallocarray.c
@@ -15,7 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <stdint.h>
diff --git a/lib/libc/stdlib/reallocf.3 b/lib/libc/stdlib/reallocf.3
index 259357e6d071..647f213522f1 100644
--- a/lib/libc/stdlib/reallocf.3
+++ b/lib/libc/stdlib/reallocf.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd January 31, 2010
.Dt MALLOC 3
.Os
diff --git a/lib/libc/stdlib/reallocf.c b/lib/libc/stdlib/reallocf.c
index 63c42383a8bf..3ab90bfdf471 100644
--- a/lib/libc/stdlib/reallocf.c
+++ b/lib/libc/stdlib/reallocf.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
void *
diff --git a/lib/libc/stdlib/realpath.3 b/lib/libc/stdlib/realpath.3
index ec35518d8986..065ba312c2ef 100644
--- a/lib/libc/stdlib/realpath.3
+++ b/lib/libc/stdlib/realpath.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)realpath.3 8.2 (Berkeley) 2/16/94
-.\"
.Dd May 11, 2012
.Dt REALPATH 3
.Os
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c
index 302e3c1a8c8c..4c52b73319ab 100644
--- a/lib/libc/stdlib/realpath.c
+++ b/lib/libc/stdlib/realpath.c
@@ -28,24 +28,16 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)realpath.c 8.1 (Berkeley) 2/16/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-#include "namespace.h"
#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
+#include <fcntl.h>
+#include <libsys.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
-#include "un-namespace.h"
-#include "libc_private.h"
-
-extern int __realpathat(int fd, const char *path, char *buf, size_t size,
- int flags);
+#include <ssp/ssp.h>
/*
* Find the real name of path, by removing all ".", ".." and symlink
@@ -149,13 +141,14 @@ realpath1(const char *path, char *resolved)
return (NULL);
}
slen = readlink(resolved, symlink, sizeof(symlink));
- if (slen <= 0 || slen >= (ssize_t)sizeof(symlink)) {
- if (slen < 0)
- ; /* keep errno from readlink(2) call */
- else if (slen == 0)
- errno = ENOENT;
- else
- errno = ENAMETOOLONG;
+ if (slen < 0)
+ return (NULL);
+ if (slen == 0) {
+ errno = ENOENT;
+ return (NULL);
+ }
+ if ((size_t)slen >= sizeof(symlink)) {
+ errno = ENAMETOOLONG;
return (NULL);
}
symlink[slen] = '\0';
@@ -176,7 +169,7 @@ realpath1(const char *path, char *resolved)
*/
if (p != NULL) {
if (symlink[slen - 1] != '/') {
- if (slen + 1 >= (ssize_t)sizeof(symlink)) {
+ if ((size_t)slen + 1 >= sizeof(symlink)) {
errno = ENAMETOOLONG;
return (NULL);
}
@@ -207,7 +200,7 @@ realpath1(const char *path, char *resolved)
}
char *
-realpath(const char * __restrict path, char * __restrict resolved)
+__ssp_real(realpath)(const char * __restrict path, char * __restrict resolved)
{
char *m, *res;
@@ -226,9 +219,8 @@ realpath(const char * __restrict path, char * __restrict resolved)
if (resolved == NULL)
return (NULL);
}
- if (__getosreldate() >= 1300080) {
- if (__realpathat(AT_FDCWD, path, resolved, PATH_MAX, 0) == 0)
- return (resolved);
+ if (__sys___realpathat(AT_FDCWD, path, resolved, PATH_MAX, 0) == 0) {
+ return (resolved);
}
res = realpath1(path, resolved);
if (res == NULL)
diff --git a/lib/libc/stdlib/remque.c b/lib/libc/stdlib/remque.c
index 783ffc3a9934..1b532ce11ff6 100644
--- a/lib/libc/stdlib/remque.c
+++ b/lib/libc/stdlib/remque.c
@@ -6,7 +6,6 @@
* As long as the above copyright statement and this notice remain
* unchanged, you can do what ever you want with this file.
*/
-#include <sys/cdefs.h>
#define _SEARCH_PRIVATE
#include <search.h>
#include <stdlib.h> /* for NULL */
diff --git a/lib/libc/stdlib/set_constraint_handler_s.c b/lib/libc/stdlib/set_constraint_handler_s.c
index 76f9ecfe5a52..298c4d94a4b9 100644
--- a/lib/libc/stdlib/set_constraint_handler_s.c
+++ b/lib/libc/stdlib/set_constraint_handler_s.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <machine/atomic.h>
diff --git a/lib/libc/stdlib/strfmon.3 b/lib/libc/stdlib/strfmon.3
index 7cd283573239..20cc560d401d 100644
--- a/lib/libc/stdlib/strfmon.3
+++ b/lib/libc/stdlib/strfmon.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 25, 2023
+.Dd December 6, 2023
.Dt STRFMON 3
.Os
.Sh NAME
@@ -154,10 +154,10 @@ to the string
.Bd -literal -offset indent
#include <stdio.h>
#include <monetary.h>
-#include <xlocale.h>
+#include <locale.h>
int
-main()
+main(void)
{
char string[100];
double money = 1234567.89;
@@ -169,6 +169,8 @@ main()
strfmon(string, sizeof(string) - 1, "%n", money);
printf("%s\\n", string);
+
+ return (0);
}
.Ed
.Sh ERRORS
diff --git a/lib/libc/stdlib/strfmon.c b/lib/libc/stdlib/strfmon.c
index 0e36eb0babe5..68a36a6d5567 100644
--- a/lib/libc/stdlib/strfmon.c
+++ b/lib/libc/stdlib/strfmon.c
@@ -32,8 +32,8 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
+
#include <ctype.h>
#include <errno.h>
#include <limits.h>
@@ -58,7 +58,7 @@
/* internal macros */
#define PRINT(CH) do { \
- if (dst >= s + maxsize) \
+ if (dst >= s + maxsize) \
goto e2big_error; \
*dst++ = CH; \
} while (0)
@@ -69,9 +69,9 @@
PRINT(*tmps++); \
} while (0)
-#define GET_NUMBER(VAR, LOC) do { \
+#define GET_NUMBER(VAR, LOC) do { \
VAR = 0; \
- while (isdigit_l((unsigned char)*fmt, LOC)) { \
+ while (isdigit_l((unsigned char)*fmt, LOC)) { \
if (VAR > INT_MAX / 10) \
goto e2big_error; \
VAR *= 10; \
@@ -102,22 +102,22 @@ static char *__format_grouped_double(double, int *, int, int, int,
struct lconv *, locale_t);
static ssize_t
-vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
- const char * __restrict format, va_list ap)
+vstrfmon_l(char *__restrict s, size_t maxsize, locale_t loc,
+ const char *__restrict format, va_list ap)
{
char *dst; /* output destination pointer */
const char *fmt; /* current format poistion pointer */
struct lconv *lc; /* pointer to lconv structure */
char *asciivalue; /* formatted double pointer */
- int flags; /* formatting options */
- int pad_char; /* padding character */
- int pad_size; /* pad size */
- int width; /* field width */
- int left_prec; /* left precision */
- int right_prec; /* right precision */
- double value; /* just value */
- char space_char = ' '; /* space after currency */
+ int flags; /* formatting options */
+ int pad_char; /* padding character */
+ int pad_size; /* pad size */
+ int width; /* field width */
+ int left_prec; /* left precision */
+ int right_prec; /* right precision */
+ double value; /* just value */
+ char space_char = ' '; /* space after currency */
char cs_precedes, /* values gathered from struct lconv */
sep_by_space,
@@ -127,6 +127,7 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
char *tmpptr; /* temporary vars */
int sverrno;
+
FIX_LOCALE(loc);
lc = localeconv_l(loc);
@@ -135,7 +136,7 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
asciivalue = NULL;
currency_symbol = NULL;
- while (*fmt) {
+ while (*fmt != 0) {
/* pass nonformating characters AS IS */
if (*fmt != '%')
goto literal;
@@ -145,49 +146,48 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
/* "%%" mean just '%' */
if (*(fmt + 1) == '%') {
fmt++;
- literal:
+literal:
PRINT(*fmt++);
continue;
}
/* set up initial values */
- flags = (NEED_GROUPING|LOCALE_POSN);
+ flags = NEED_GROUPING | LOCALE_POSN;
pad_char = ' '; /* padding character is "space" */
pad_size = 0; /* no padding initially */
left_prec = -1; /* no left precision specified */
right_prec = -1; /* no right precision specified */
width = -1; /* no width specified */
- value = 0; /* we have no value to print now */
/* Flags */
while (1) {
switch (*++fmt) {
- case '=': /* fill character */
- pad_char = *++fmt;
- if (pad_char == '\0')
- goto format_error;
- continue;
- case '^': /* not group currency */
- flags &= ~(NEED_GROUPING);
- continue;
- case '+': /* use locale defined signs */
- if (flags & SIGN_POSN_USED)
- goto format_error;
- flags |= (SIGN_POSN_USED|LOCALE_POSN);
- continue;
- case '(': /* enclose negatives with () */
- if (flags & SIGN_POSN_USED)
- goto format_error;
- flags |= (SIGN_POSN_USED|PARENTH_POSN);
- continue;
- case '!': /* suppress currency symbol */
- flags |= SUPPRESS_CURR_SYMBOL;
- continue;
- case '-': /* alignment (left) */
- flags |= LEFT_JUSTIFY;
- continue;
- default:
- break;
+ case '=': /* fill character */
+ pad_char = *++fmt;
+ if (pad_char == '\0')
+ goto format_error;
+ continue;
+ case '^': /* not group currency */
+ flags &= ~(NEED_GROUPING);
+ continue;
+ case '+': /* use locale defined signs */
+ if (flags & SIGN_POSN_USED)
+ goto format_error;
+ flags |= (SIGN_POSN_USED | LOCALE_POSN);
+ continue;
+ case '(': /* enclose negatives with () */
+ if (flags & SIGN_POSN_USED)
+ goto format_error;
+ flags |= (SIGN_POSN_USED | PARENTH_POSN);
+ continue;
+ case '!': /* suppress currency symbol */
+ flags |= SUPPRESS_CURR_SYMBOL;
+ continue;
+ case '-': /* alignment (left) */
+ flags |= LEFT_JUSTIFY;
+ continue;
+ default:
+ break;
}
break;
}
@@ -195,7 +195,8 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
/* field Width */
if (isdigit_l((unsigned char)*fmt, loc)) {
GET_NUMBER(width, loc);
- /* Do we have enough space to put number with
+ /*
+ * Do we have enough space to put number with
* required width ?
*/
if ((unsigned int)width >= maxsize - (dst - s))
@@ -216,22 +217,24 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
if (!isdigit_l((unsigned char)*++fmt, loc))
goto format_error;
GET_NUMBER(right_prec, loc);
- if ((unsigned int)right_prec >= maxsize - (dst - s) -
- left_prec)
+ if ((unsigned int)right_prec >=
+ maxsize - (dst - s) - left_prec)
goto e2big_error;
}
/* Conversion Characters */
switch (*fmt++) {
- case 'i': /* use international currency format */
- flags |= USE_INTL_CURRENCY;
- break;
- case 'n': /* use national currency format */
- flags &= ~(USE_INTL_CURRENCY);
- break;
- default: /* required character is missing or
- premature EOS */
- goto format_error;
+ case 'i': /* use international currency format */
+ flags |= USE_INTL_CURRENCY;
+ break;
+ case 'n': /* use national currency format */
+ flags &= ~(USE_INTL_CURRENCY);
+ break;
+ default: /*
+ * required character is missing or
+ * premature EOS
+ */
+ goto format_error;
}
if (currency_symbol != NULL)
@@ -247,7 +250,7 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
currency_symbol = strdup(lc->currency_symbol);
if (currency_symbol == NULL)
- goto end_error; /* ENOMEM. */
+ goto end_error; /* ENOMEM. */
/* value itself */
value = va_arg(ap, double);
@@ -269,15 +272,17 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
if (asciivalue != NULL)
free(asciivalue);
- asciivalue = __format_grouped_double(value, &flags,
- left_prec, right_prec, pad_char, lc, loc);
+ asciivalue = __format_grouped_double(value, &flags, left_prec,
+ right_prec, pad_char, lc, loc);
if (asciivalue == NULL)
- goto end_error; /* errno already set */
- /* to ENOMEM by malloc() */
+ goto end_error; /*
+ * errno already set to ENOMEM by
+ * malloc()
+ */
/* set some variables for later use */
- __setup_vars(flags, &cs_precedes, &sep_by_space,
- &sign_posn, &signstr, lc);
+ __setup_vars(flags, &cs_precedes, &sep_by_space, &sign_posn,
+ &signstr, lc);
/*
* Description of some LC_MONETARY's values:
@@ -308,7 +313,6 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
* $currency_symbol
* = 3 - the sign string precedes the $currency_symbol
* = 4 - the sign string succeeds the $currency_symbol
- *
*/
tmpptr = dst;
@@ -354,12 +358,10 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
}
if (!(flags & SUPPRESS_CURR_SYMBOL)) {
- if ((sign_posn == 3 && sep_by_space == 2)
- || (sep_by_space == 1
- && (sign_posn == 0
- || sign_posn == 1
- || sign_posn == 2
- || sign_posn == 4)))
+ if ((sign_posn == 3 && sep_by_space == 2) ||
+ (sep_by_space == 1 &&
+ (sign_posn == 0 || sign_posn == 1 ||
+ sign_posn == 2 || sign_posn == 4)))
PRINT(space_char);
PRINTS(currency_symbol);
if (sign_posn == 4) {
@@ -400,7 +402,7 @@ vstrfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
PRINT('\0');
free(asciivalue);
free(currency_symbol);
- return (dst - s - 1); /* return size of put data except trailing '\0' */
+ return (dst - s - 1); /* size of put data except trailing '\0' */
e2big_error:
errno = E2BIG;
@@ -420,15 +422,15 @@ end_error:
}
static void
-__setup_vars(int flags, char *cs_precedes, char *sep_by_space,
- char *sign_posn, char **signstr, struct lconv *lc)
+__setup_vars(int flags, char *cs_precedes, char *sep_by_space, char *sign_posn,
+ char **signstr, struct lconv *lc)
{
if ((flags & IS_NEGATIVE) && (flags & USE_INTL_CURRENCY)) {
*cs_precedes = lc->int_n_cs_precedes;
*sep_by_space = lc->int_n_sep_by_space;
*sign_posn = (flags & PARENTH_POSN) ? 0 : lc->int_n_sign_posn;
- *signstr = (lc->negative_sign[0] == '\0') ? "-"
- : lc->negative_sign;
+ *signstr = (lc->negative_sign[0] == '\0') ? "-" :
+ lc->negative_sign;
} else if (flags & USE_INTL_CURRENCY) {
*cs_precedes = lc->int_p_cs_precedes;
*sep_by_space = lc->int_p_sep_by_space;
@@ -438,8 +440,8 @@ __setup_vars(int flags, char *cs_precedes, char *sep_by_space,
*cs_precedes = lc->n_cs_precedes;
*sep_by_space = lc->n_sep_by_space;
*sign_posn = (flags & PARENTH_POSN) ? 0 : lc->n_sign_posn;
- *signstr = (lc->negative_sign[0] == '\0') ? "-"
- : lc->negative_sign;
+ *signstr = (lc->negative_sign[0] == '\0') ? "-" :
+ lc->negative_sign;
} else {
*cs_precedes = lc->p_cs_precedes;
*sep_by_space = lc->p_sep_by_space;
@@ -462,8 +464,8 @@ __calc_left_pad(int flags, char *cur_symb, struct lconv *lc)
char cs_precedes, sep_by_space, sign_posn, *signstr;
int left_chars = 0;
- __setup_vars(flags, &cs_precedes, &sep_by_space, &sign_posn,
- &signstr, lc);
+ __setup_vars(flags, &cs_precedes, &sep_by_space, &sign_posn, &signstr,
+ lc);
if (cs_precedes != 0) {
left_chars += strlen(cur_symb);
@@ -472,17 +474,17 @@ __calc_left_pad(int flags, char *cur_symb, struct lconv *lc)
}
switch (sign_posn) {
- case 0:
- if (flags & IS_NEGATIVE)
- left_chars++;
- break;
- case 1:
+ case 0:
+ if (flags & IS_NEGATIVE)
+ left_chars++;
+ break;
+ case 1:
+ left_chars += strlen(signstr);
+ break;
+ case 3:
+ case 4:
+ if (cs_precedes != 0)
left_chars += strlen(signstr);
- break;
- case 3:
- case 4:
- if (cs_precedes != 0)
- left_chars += strlen(signstr);
}
return (left_chars);
}
@@ -512,8 +514,8 @@ get_groups(int size, char *grouping)
/* convert double to locale-encoded string */
static char *
-__format_grouped_double(double value, int *flags,
- int left_prec, int right_prec, int pad_char, struct lconv *lc, locale_t loc)
+__format_grouped_double(double value, int *flags, int left_prec, int right_prec,
+ int pad_char, struct lconv *lc, locale_t loc)
{
char *rslt;
@@ -531,7 +533,7 @@ __format_grouped_double(double value, int *flags,
size_t decimal_point_size;
size_t thousands_sep_size;
- int groups = 0;
+ int groups = 0;
grouping = lc->mon_grouping;
decimal_point = lc->mon_decimal_point;
@@ -594,10 +596,8 @@ __format_grouped_double(double value, int *flags,
avalue_size -= (right_prec + 1);
}
- if ((*flags & NEED_GROUPING) &&
- thousands_sep_size > 0 &&
- *grouping != CHAR_MAX &&
- *grouping > 0) {
+ if ((*flags & NEED_GROUPING) && thousands_sep_size > 0 &&
+ *grouping != CHAR_MAX && *grouping > 0) {
while (avalue_size > (int)*grouping) {
GRPCPY(*grouping);
GRPSEP;
@@ -640,8 +640,7 @@ __format_grouped_double(double value, int *flags,
}
ssize_t
-strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
- ...)
+strfmon(char *restrict s, size_t maxsize, const char *restrict format, ...)
{
ssize_t ret;
va_list ap;
@@ -654,8 +653,8 @@ strfmon(char * __restrict s, size_t maxsize, const char * __restrict format,
}
ssize_t
-strfmon_l(char * __restrict s, size_t maxsize, locale_t loc,
- const char * __restrict format, ...)
+strfmon_l(char *restrict s, size_t maxsize, locale_t loc,
+ const char *restrict format, ...)
{
ssize_t ret;
va_list ap;
diff --git a/lib/libc/stdlib/strtod.3 b/lib/libc/stdlib/strtod.3
index 728a819432a5..018e1e8c3c38 100644
--- a/lib/libc/stdlib/strtod.3
+++ b/lib/libc/stdlib/strtod.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strtod.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 11, 2010
.Dt STRTOD 3
.Os
diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c
index 5309b7d4305c..fe2a0a237e23 100644
--- a/lib/libc/stdlib/strtoimax.c
+++ b/lib/libc/stdlib/strtoimax.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/strtol.3 b/lib/libc/stdlib/strtol.3
index e2c5ff7ae3cb..af8bec579dbf 100644
--- a/lib/libc/stdlib/strtol.3
+++ b/lib/libc/stdlib/strtol.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strtol.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd August 21, 2023
.Dt STRTOL 3
.Os
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index 1ca95918ef12..54f728893e08 100644
--- a/lib/libc/stdlib/strtol.c
+++ b/lib/libc/stdlib/strtol.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtol.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <limits.h>
#include <ctype.h>
#include <errno.h>
diff --git a/lib/libc/stdlib/strtold.c b/lib/libc/stdlib/strtold.c
index 2f7cabbdd88b..fa05f7a63889 100644
--- a/lib/libc/stdlib/strtold.c
+++ b/lib/libc/stdlib/strtold.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include "xlocale_private.h"
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
index 6845776c5f03..3ce399277049 100644
--- a/lib/libc/stdlib/strtoll.c
+++ b/lib/libc/stdlib/strtoll.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
diff --git a/lib/libc/stdlib/strtonum.c b/lib/libc/stdlib/strtonum.c
index a25c43f6a330..0d0715bf39c1 100644
--- a/lib/libc/stdlib/strtonum.c
+++ b/lib/libc/stdlib/strtonum.c
@@ -17,7 +17,6 @@
* $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/strtoq.c b/lib/libc/stdlib/strtoq.c
index e83af1c7652a..2d97df712d37 100644
--- a/lib/libc/stdlib/strtoq.c
+++ b/lib/libc/stdlib/strtoq.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/strtoul.3 b/lib/libc/stdlib/strtoul.3
index 41b3b2c578bc..3e4b6bdc20fb 100644
--- a/lib/libc/stdlib/strtoul.3
+++ b/lib/libc/stdlib/strtoul.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strtoul.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd August 21, 2023
.Dt STRTOUL 3
.Os
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c
index c0dbd0c9fdac..dfe31ede0f44 100644
--- a/lib/libc/stdlib/strtoul.c
+++ b/lib/libc/stdlib/strtoul.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <limits.h>
#include <ctype.h>
#include <errno.h>
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
index fe44a9e01c05..be60956a53a6 100644
--- a/lib/libc/stdlib/strtoull.c
+++ b/lib/libc/stdlib/strtoull.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c
index 08140be38845..6f4443acece0 100644
--- a/lib/libc/stdlib/strtoumax.c
+++ b/lib/libc/stdlib/strtoumax.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/strtouq.c b/lib/libc/stdlib/strtouq.c
index 18e917b19b67..a50e02a2ee0b 100644
--- a/lib/libc/stdlib/strtouq.c
+++ b/lib/libc/stdlib/strtouq.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdlib.h>
diff --git a/lib/libc/stdlib/system.3 b/lib/libc/stdlib/system.3
index 7f1a34c69d2d..119432342f70 100644
--- a/lib/libc/stdlib/system.3
+++ b/lib/libc/stdlib/system.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)system.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 25, 2015
+.Dd January 11, 2024
.Dt SYSTEM 3
.Os
.Sh NAME
@@ -105,6 +103,6 @@ user to run arbitrary command,
because all meta-characters supported by
.Xr sh 1
would be honored.
-User supplied parameters should always be carefully santized
+User supplied parameters should always be carefully sanitized
before they appear in
.Fa string .
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 4ad5d605865b..b581a6ec3b14 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/lib/libc/stdlib/tdelete.c b/lib/libc/stdlib/tdelete.c
index 8b3f34848db0..3b00a6cf0852 100644
--- a/lib/libc/stdlib/tdelete.c
+++ b/lib/libc/stdlib/tdelete.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#define _SEARCH_PRIVATE
#include <search.h>
#include <stdbool.h>
diff --git a/lib/libc/stdlib/tsearch.c b/lib/libc/stdlib/tsearch.c
index 09d6e4d26a87..7826c555c065 100644
--- a/lib/libc/stdlib/tsearch.c
+++ b/lib/libc/stdlib/tsearch.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#define _SEARCH_PRIVATE
#include <search.h>
#include <stdlib.h>
diff --git a/lib/libc/stdtime/Makefile.inc b/lib/libc/stdtime/Makefile.inc
index 07ca69aab4c5..647cbe6f40ba 100644
--- a/lib/libc/stdtime/Makefile.inc
+++ b/lib/libc/stdtime/Makefile.inc
@@ -18,9 +18,10 @@ CFLAGS.${src}+= -I${LIBC_SRCTOP}/stdtime
CFLAGS.localtime.c+= -DALL_STATE -DTHREAD_SAFE
.if ${MK_DETECT_TZ_CHANGES} != "no"
CFLAGS.localtime.c+= -DDETECT_TZ_CHANGES
+CFLAGS.Version.map+= -DDETECT_TZ_CHANGES
.endif
-MAN+= ctime.3 strftime.3 strptime.3 time2posix.3
+MAN+= ctime.3 strftime.3 strptime.3 time2posix.3 tzset.3
MAN+= tzfile.5
MLINKS+=ctime.3 asctime.3 ctime.3 difftime.3 ctime.3 gmtime.3 \
@@ -30,3 +31,5 @@ MLINKS+=ctime.3 asctime.3 ctime.3 difftime.3 ctime.3 gmtime.3 \
MLINKS+=strftime.3 strftime_l.3
MLINKS+=strptime.3 strptime_l.3
MLINKS+=time2posix.3 posix2time.3
+MLINKS+=tzset.3 daylight.3 \
+ tzset.3 timezone.3
diff --git a/lib/libc/stdtime/Symbol.map b/lib/libc/stdtime/Symbol.map
index acdd3bbb89b4..6a34cd3ea590 100644
--- a/lib/libc/stdtime/Symbol.map
+++ b/lib/libc/stdtime/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
_time32_to_time;
_time_to_time32;
@@ -33,3 +30,14 @@ FBSD_1.0 {
asctime_r;
asctime;
};
+
+FBSD_1.8 {
+ daylight;
+ timezone;
+};
+
+FBSDprivate_1.0 {
+#ifdef DETECT_TZ_CHANGES
+ __tz_change_interval;
+#endif
+};
diff --git a/lib/libc/stdtime/ctime.3 b/lib/libc/stdtime/ctime.3
index 25a7c6a7656e..96b7f775535a 100644
--- a/lib/libc/stdtime/ctime.3
+++ b/lib/libc/stdtime/ctime.3
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd April 20, 2023
+.Dd March 26, 2024
.Dt CTIME 3
.Os
.Sh NAME
@@ -243,7 +241,21 @@ The
.Fn mktime
function
returns the specified calendar time; if the calendar time cannot be
-represented, it returns \-1;
+represented, it returns \-1 and sets
+.Xr errno 3
+to an appropriate value.
+.Pp
+Note that \-1 is a valid result (representing one second before
+midnight UTC on the evening of 31 December 1969), so this cannot be
+relied upon to indicate success or failure; instead,
+.Fa tm_wday
+and / or
+.Fa tm_yday
+should be set to an out-of-bounds value (e.g. \-1) prior to calling
+.Fn mktime
+or
+.Fn timegm
+and checked after the call.
.Pp
The
.Fn difftime
diff --git a/lib/libc/stdtime/strftime.3 b/lib/libc/stdtime/strftime.3
index 007f6b5fc34b..f46eee525900 100644
--- a/lib/libc/stdtime/strftime.3
+++ b/lib/libc/stdtime/strftime.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strftime.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 25, 2012
.Dt STRFTIME 3
.Os
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c
index 674aaa0bb302..89c9e4cf88ff 100644
--- a/lib/libc/stdtime/strftime.c
+++ b/lib/libc/stdtime/strftime.c
@@ -1,4 +1,6 @@
/*
+ * SPDX-License-Identifier: BSD-4.3TAHOE
+ *
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
*
@@ -20,23 +22,9 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-#ifndef NOID
-static const char elsieid[] = "@(#)strftime.3 8.3";
-/*
- * Based on the UCB version with the ID appearing below.
- * This is ANSIish only when "multibyte character == plain character".
- */
-#endif /* !defined NOID */
-#endif /* !defined lint */
-
#include "namespace.h"
#include "private.h"
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char sccsid[] = "@(#)strftime.c 5.4 (Berkeley) 3/14/89";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "tzfile.h"
#include <fcntl.h>
#include <sys/stat.h>
@@ -316,7 +304,7 @@ label:
time_t mkt;
tm = *t;
- mkt = mktime(&tm);
+ mkt = timeoff(&tm, t->tm_gmtoff);
if (TYPE_SIGNED(time_t))
(void) sprintf_l(buf, loc, "%ld",
(long) mkt);
diff --git a/lib/libc/stdtime/strptime.3 b/lib/libc/stdtime/strptime.3
index 0dfa33aa29cb..7df73d2d080a 100644
--- a/lib/libc/stdtime/strptime.3
+++ b/lib/libc/stdtime/strptime.3
@@ -23,7 +23,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" "
-.Dd October 2, 2014
+.Dd December 9, 2024
.Dt STRPTIME 3
.Os
.Sh NAME
@@ -135,6 +135,11 @@ function has been contributed by Powerdog Industries.
.Pp
This man page was written by
.An J\(:org Wunsch .
+.Sh CAVEATS
+The
+.Fn strptime
+function assumes the Gregorian calendar and will produce incorrect
+results for dates prior to its introduction.
.Sh BUGS
Both the
.Fa %e
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index 848b94545dd2..5f1293c7a267 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -37,14 +37,6 @@
* official policies, either expressed or implied, of Powerdog Industries.
*/
-#include <sys/cdefs.h>
-#ifndef lint
-#ifndef NOID
-static char copyright[] __unused =
-"@(#) Copyright (c) 1994 Powerdog Industries. All rights reserved.";
-static char sccsid[] __unused = "@(#)strptime.c 0.1 (Powerdog) 94/03/27";
-#endif /* !defined NOID */
-#endif /* not lint */
#include "namespace.h"
#include <time.h>
#include <ctype.h>
@@ -70,17 +62,16 @@ static char * _strptime(const char *, const char *, struct tm *, int *, locale_t
#define FLAG_WDAY (1 << 5)
/*
- * Calculate the week day of the first day of a year. Valid for
- * the Gregorian calendar, which began Sept 14, 1752 in the UK
- * and its colonies. Ref:
- * http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
+ * Gauss's algorithm for the day of the week of the first day of any year
+ * in the Gregorian calendar.
*/
-
static int
first_wday_of(int year)
{
- return (((2 * (3 - (year / 100) % 4)) + (year % 100) +
- ((year % 100) / 4) + (isleap(year) ? 6 : 0) + 1) % 7);
+ return ((1 +
+ 5 * ((year - 1) % 4) +
+ 4 * ((year - 1) % 100) +
+ 6 * ((year - 1) % 400)) % 7);
}
static char *
@@ -682,13 +673,8 @@ label:
flags |= FLAG_MDAY;
}
if (!(flags & FLAG_WDAY)) {
- i = 0;
- wday_offset = first_wday_of(tm->tm_year);
- while (i++ <= tm->tm_yday) {
- if (wday_offset++ >= 6)
- wday_offset = 0;
- }
- tm->tm_wday = wday_offset;
+ wday_offset = first_wday_of(tm->tm_year + TM_YEAR_BASE);
+ tm->tm_wday = (wday_offset + tm->tm_yday) % 7;
flags |= FLAG_WDAY;
}
}
diff --git a/lib/libc/stdtime/time32.c b/lib/libc/stdtime/time32.c
index 1be9e9dec74c..5fb7c95c22de 100644
--- a/lib/libc/stdtime/time32.c
+++ b/lib/libc/stdtime/time32.c
@@ -11,7 +11,6 @@
* base of the source tree.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <timeconv.h>
diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c
index 93b9868d0319..680270e0f9b1 100644
--- a/lib/libc/stdtime/timelocal.c
+++ b/lib/libc/stdtime/timelocal.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stddef.h>
#include "ldpart.h"
diff --git a/lib/libc/stdtime/tzset.3 b/lib/libc/stdtime/tzset.3
new file mode 100644
index 000000000000..94ccbec9aba7
--- /dev/null
+++ b/lib/libc/stdtime/tzset.3
@@ -0,0 +1,344 @@
+.\" Copyright (c) 1989, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Arthur Olson.
+.\"
+.\" 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.
+.\"
+.Dd December 25, 2023
+.Dt TZSET 3
+.Os
+.Sh NAME
+.Nm daylight ,
+.Nm timezone ,
+.Nm tzname ,
+.Nm tzset
+.Nd initialize time conversion information
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In time.h
+.Vt extern int daylight ;
+.Vt extern long timezone ;
+.Vt extern char *tzname[2] ;
+.Ft void
+.Fn tzset void
+.Sh DESCRIPTION
+The
+.Fn tzset
+function
+initializes time conversion information used by the library routine
+.Xr localtime 3 .
+The environment variable
+.Ev TZ
+specifies how this is done.
+.Pp
+If
+.Ev TZ
+does not appear in the environment, the best available approximation to
+local wall clock time, as specified by the
+.Xr tzfile 5 Ns -format
+file
+.Pa /etc/localtime
+is used.
+.Pp
+If
+.Ev TZ
+appears in the environment but its value is a null string, Coordinated
+Universal Time
+.Pq Tn UTC
+is used (without leap second correction).
+.Pp
+If
+.Ev TZ
+appears in the environment and its value begins with a colon
+.Pq Ql \&: ,
+the rest of its value is used as a pathname of a
+.Xr tzfile 5 Ns -format
+file from which to read the time conversion information.
+If the first character of the pathname is a slash
+.Pq Ql /
+it is used as
+an absolute pathname; otherwise, it is used as a pathname relative to
+the system time conversion information directory.
+.Pp
+If its value does not begin with a colon, it is first used as the pathname
+of a file (as described above) from which to read the time conversion
+information.
+If that file cannot be read, the value is then interpreted as a direct
+specification (the format is described below) of the time conversion
+information.
+.Pp
+If the
+.Ev TZ
+environment variable does not specify a
+.Xr tzfile 5 Ns -format
+file and cannot be interpreted as a direct specification,
+.Tn UTC
+is used.
+.Pp
+After the first call to
+.Nm tzset ,
+the
+.Vt timezone
+variable is set to the difference, in seconds, between Coordinated Universal
+Time (UTC) and the local time.
+The
+.Vt daylight
+variable is set to 0 if the local timezone is observing standard time.
+It is set to 1 if the local timezone ever observes an alternate time, such as summer time.
+The first element of the
+.Vt tzname
+array is the timezone name of standard time, while the second element is the
+name of the altnerative time zone.
+.Sh SPECIFICATION FORMAT
+When
+.Ev TZ
+is used directly as a specification of the time conversion information,
+it must have the following syntax (spaces inserted for clarity):
+.Bd -ragged -offset indent
+.Em std offset
+.Bo
+.Em dst
+.Bq Em offset
+.Bq , Em rule
+.Bc
+.Ed
+.Pp
+Where:
+.Bl -tag -width std_and_dst -offset indent
+.It Em std No and Em dst
+Three or more bytes that are the designation for the standard
+.Pq Em std
+or summer
+.Pq Em dst
+time zone.
+Only
+.Em std
+is required; if
+.Em dst
+is missing, then summer time does not apply in this locale.
+Upper and lowercase letters are explicitly allowed.
+Any characters
+except a leading colon
+.Pq Ql \&: ,
+digits, comma
+.Pq Ql \&, ,
+minus
+.Pq Ql \- ,
+plus
+.Pq Ql + ,
+and
+.Tn ASCII
+.Dv NUL
+are allowed.
+.It Em offset
+Indicates the value one must add to the local time to arrive at
+Coordinated Universal Time.
+The
+.Em offset
+has the form:
+.Bd -ragged -offset indent
+.Sm off
+.Em hh Bo
+.Em : mm
+.Bq Em : ss
+.Bc
+.Sm on
+.Ed
+.Pp
+The minutes
+.Pq Em mm
+and seconds
+.Pq Em ss
+are optional.
+The hour
+.Pq Em hh
+is required and may be a single digit.
+The
+.Em offset
+following
+.Em std
+is required.
+If no
+.Em offset
+follows
+.Em dst ,
+summer time is assumed to be one hour ahead of standard time.
+One or
+more digits may be used; the value is always interpreted as a decimal
+number.
+The hour must be between zero and 24, and the minutes (and
+seconds) \(em if present \(em between zero and 59.
+If preceded by a
+.Pq Ql \-
+the time zone shall be east of the Prime Meridian; otherwise it shall be
+west (which may be indicated by an optional preceding
+.Pq Ql + ) .
+.It Em rule
+Indicates when to change to and back from summer time.
+The
+.Em rule
+has the form:
+.Bd -ragged -offset indent
+.Em date/time,date/time
+.Ed
+.Pp
+where the first
+.Em date
+describes when the change from standard to summer time occurs and the
+second
+.Em date
+describes when the change back happens.
+Each
+.Em time
+field describes when, in current local time, the change to the other
+time is made.
+.Pp
+The format of
+.Em date
+is one of the following:
+.Bl -tag -width "M.m.n.d"
+.It Sy J Em n
+The Julian day
+.Em n
+(1 \*(Le
+.Em n
+\*(Le 365).
+Leap days are not counted; that is, in all years \(em including leap
+years \(em February 28 is day 59 and March 1 is day 60.
+It is
+impossible to explicitly refer to the occasional February 29.
+.It Em n
+The zero-based Julian day
+(0 \*(Le
+.Em n
+\*(Le 365 ) .
+Leap days are counted, and it is possible to refer to February 29.
+.It Sy M Em m.n.d
+The
+.Em d Ns 'th
+day (0 \*(Le
+.Em d
+\*(Le 6)
+of week
+.Em n
+of month
+.Em m
+of the year
+(1 \*(Le
+.Em n
+\*(Le 5),
+(1 \*(Le
+.Em m
+\*(Le 12),
+where week 5 means
+.Do
+the last
+.Em d
+day in month
+.Em m
+.Dc
+which may occur in either the fourth or the fifth week).
+Week 1 is the
+first week in which the
+.Em d Ns 'th
+day occurs.
+Day zero is Sunday.
+.Pp
+The
+.Em time
+has the same format as
+.Em offset
+except that no leading sign
+.Pq Ql \-
+or
+.Pq Ql +
+is allowed.
+The default, if
+.Em time
+is not given, is
+.Sy 02:00:00 .
+.El
+.Pp
+If no
+.Em rule
+is present in the
+.Ev TZ
+specification, the rules specified
+by the
+.Xr tzfile 5 Ns -format
+file
+.Em posixrules
+in the system time conversion information directory are used, with the
+standard and summer time offsets from
+.Tn UTC
+replaced by those specified by
+the
+.Em offset
+values in
+.Ev TZ .
+.El
+.Pp
+For compatibility with System V Release 3.1, a semicolon
+.Pq Ql \&;
+may be used to separate the
+.Em rule
+from the rest of the specification.
+.Sh FILES
+.Bl -tag -width /usr/share/zoneinfo/posixrules -compact
+.It Pa /etc/localtime
+local time zone file
+.It Pa /usr/share/zoneinfo
+time zone directory
+.It Pa /usr/share/zoneinfo/posixrules
+rules for
+.Tn POSIX Ns -style
+.Tn TZ Ns 's
+.It Pa /usr/share/zoneinfo/Etc/GMT
+for
+.Tn UTC
+leap seconds
+.El
+.Pp
+If the file
+.Pa /usr/share/zoneinfo/UTC
+does not exist,
+.Tn UTC
+leap seconds are loaded from
+.Pa /usr/share/zoneinfo/posixrules .
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr gettimeofday 2 ,
+.Xr ctime 3 ,
+.Xr getenv 3 ,
+.Xr time 3 ,
+.Xr tzfile 5
+.Sh HISTORY
+The
+.Fn tzset
+function first appeared in
+.Bx 4.4 .
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc
index a18eb62fddb8..5d4a9a6e3eed 100644
--- a/lib/libc/string/Makefile.inc
+++ b/lib/libc/string/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-
.if ${MK_MACHDEP_OPTIMIZATIONS} != "no"
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/string
.endif
@@ -13,6 +11,7 @@ MISRCS+=bcmp.c bcopy.c bzero.c explicit_bzero.c \
ffs.c ffsl.c ffsll.c fls.c flsl.c flsll.c \
memccpy.c memchr.c memrchr.c memcmp.c \
memcpy.c memmem.c memmove.c mempcpy.c memset.c memset_s.c \
+ memset_explicit.c \
stpcpy.c stpncpy.c strcasecmp.c \
strcat.c strcasestr.c strchr.c strchrnul.c strcmp.c strcoll.c strcpy.c\
strcspn.c strdup.c strerror.c strlcat.c strlcpy.c strlen.c strmode.c \
@@ -64,7 +63,8 @@ MLINKS+=ffs.3 ffsl.3 \
MLINKS+=index.3 rindex.3
MLINKS+=memchr.3 memrchr.3
MLINKS+=memcpy.3 mempcpy.3
-MLINKS+=memset.3 memset_s.3
+MLINKS+=memset.3 memset_s.3 \
+ memset.3 memset_explicit.3
MLINKS+=strcasecmp.3 strncasecmp.3 \
strcasecmp.3 strcasecmp_l.3 \
strcasecmp.3 strncasecmp_l.3
diff --git a/lib/libc/string/Symbol.map b/lib/libc/string/Symbol.map
index ec4778ff3c24..6b2c41124adf 100644
--- a/lib/libc/string/Symbol.map
+++ b/lib/libc/string/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
bcmp;
bcopy;
@@ -119,6 +116,10 @@ FBSD_1.7 {
wmempcpy;
};
+FBSD_1.8 {
+ memset_explicit;
+};
+
FBSDprivate_1.0 {
__strtok_r;
};
diff --git a/lib/libc/string/bcmp.3 b/lib/libc/string/bcmp.3
index 7867e643c542..954e10bfdeab 100644
--- a/lib/libc/string/bcmp.3
+++ b/lib/libc/string/bcmp.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)bcmp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd August 15, 2016
.Dt BCMP 3
.Os
diff --git a/lib/libc/string/bcmp.c b/lib/libc/string/bcmp.c
index 0a7c6f0948a6..cf1e487d391e 100644
--- a/lib/libc/string/bcmp.c
+++ b/lib/libc/string/bcmp.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <strings.h>
/*
diff --git a/lib/libc/string/bcopy.3 b/lib/libc/string/bcopy.3
index 6cae69c083b2..230ca2eea89a 100644
--- a/lib/libc/string/bcopy.3
+++ b/lib/libc/string/bcopy.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)bcopy.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd August 24, 2015
.Dt BCOPY 3
.Os
diff --git a/lib/libc/string/bcopy.c b/lib/libc/string/bcopy.c
index 4328542d2d54..20f7bc60b76a 100644
--- a/lib/libc/string/bcopy.c
+++ b/lib/libc/string/bcopy.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
typedef intptr_t word; /* "word" used for optimal copy speed */
@@ -51,6 +47,9 @@ typedef intptr_t word; /* "word" used for optimal copy speed */
#if defined(MEMCOPY) || defined(MEMMOVE)
#include <string.h>
+#undef memcpy /* _FORTIFY_SOURCE */
+#undef memmove /* _FORTIFY_SOURCE */
+
void *
#ifdef MEMCOPY
memcpy
@@ -61,6 +60,8 @@ memmove
#else
#include <strings.h>
+#undef bcopy /* _FORTIFY_SOURCE */
+
void
bcopy(const void *src0, void *dst0, size_t length)
#endif
diff --git a/lib/libc/string/bstring.3 b/lib/libc/string/bstring.3
index cb29a6db6b14..dd89af44fc4a 100644
--- a/lib/libc/string/bstring.3
+++ b/lib/libc/string/bstring.3
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)bstring.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
+.Dd December 5, 2023
.Dt BSTRING 3
.Os
.Sh NAME
@@ -58,7 +56,12 @@
.Ft int
.Fn memcmp "const void *b1" "const void *b2" "size_t len"
.Ft void *
-.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
+.Fo memccpy
+.Fa "void * restrict dst"
+.Fa "const void * restrict src"
+.Fa "int c"
+.Fa "size_t len"
+.Fc
.Ft void *
.Fn memcpy "void *dst" "const void *src" "size_t len"
.Ft void *
diff --git a/lib/libc/string/bzero.3 b/lib/libc/string/bzero.3
index a9e515763e25..2c791c497d8c 100644
--- a/lib/libc/string/bzero.3
+++ b/lib/libc/string/bzero.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)bzero.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd August 24, 2015
.Dt BZERO 3
.Os
diff --git a/lib/libc/string/bzero.c b/lib/libc/string/bzero.c
index fe149def7930..7bc2b3a7008a 100644
--- a/lib/libc/string/bzero.c
+++ b/lib/libc/string/bzero.c
@@ -1,3 +1,2 @@
-#include <sys/cdefs.h>
#define BZERO
#include "memset.c"
diff --git a/lib/libc/string/ffs.3 b/lib/libc/string/ffs.3
index 1adece73c8ae..2a5adb01c737 100644
--- a/lib/libc/string/ffs.3
+++ b/lib/libc/string/ffs.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ffs.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd October 17, 2015
.Dt FFS 3
.Os
diff --git a/lib/libc/string/ffs.c b/lib/libc/string/ffs.c
index b318c33f641b..0e137b6bb97e 100644
--- a/lib/libc/string/ffs.c
+++ b/lib/libc/string/ffs.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <strings.h>
/*
diff --git a/lib/libc/string/ffsl.c b/lib/libc/string/ffsl.c
index 237e62617315..c3a87a902526 100644
--- a/lib/libc/string/ffsl.c
+++ b/lib/libc/string/ffsl.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <strings.h>
/*
diff --git a/lib/libc/string/ffsll.c b/lib/libc/string/ffsll.c
index 4fb5ccc4ef7c..5c7abc1f7a23 100644
--- a/lib/libc/string/ffsll.c
+++ b/lib/libc/string/ffsll.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <strings.h>
/*
diff --git a/lib/libc/string/fls.c b/lib/libc/string/fls.c
index 554b8dc4b413..ac5fb7738722 100644
--- a/lib/libc/string/fls.c
+++ b/lib/libc/string/fls.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <strings.h>
diff --git a/lib/libc/string/flsl.c b/lib/libc/string/flsl.c
index 6b881bc39b9e..d88c8dfcdc63 100644
--- a/lib/libc/string/flsl.c
+++ b/lib/libc/string/flsl.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <strings.h>
diff --git a/lib/libc/string/flsll.c b/lib/libc/string/flsll.c
index 68d6d52bee4b..635ebacddf18 100644
--- a/lib/libc/string/flsll.c
+++ b/lib/libc/string/flsll.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <strings.h>
diff --git a/lib/libc/string/index.3 b/lib/libc/string/index.3
index cbc174a94f60..efab4e6d42ee 100644
--- a/lib/libc/string/index.3
+++ b/lib/libc/string/index.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)index.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 20, 2011
.Dt INDEX 3
.Os
diff --git a/lib/libc/string/memccpy.3 b/lib/libc/string/memccpy.3
index fb2409ada846..0d35a68fce67 100644
--- a/lib/libc/string/memccpy.3
+++ b/lib/libc/string/memccpy.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memccpy.3 8.1 (Berkeley) 6/9/93
-.\"
-.Dd June 9, 1993
+.Dd December 5, 2023
.Dt MEMCCPY 3
.Os
.Sh NAME
@@ -38,7 +36,12 @@
.Sh SYNOPSIS
.In string.h
.Ft void *
-.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
+.Fo memccpy
+.Fa "void * restrict dst"
+.Fa "const void * restrict src"
+.Fa "int c"
+.Fa "size_t len"
+.Fc
.Sh DESCRIPTION
The
.Fn memccpy
@@ -61,13 +64,33 @@ is returned.
Otherwise,
.Fa len
bytes are copied, and a NULL pointer is returned.
+If
+.Fa src
+and
+.Fa dst
+overlap, behavior is undefined.
.Sh SEE ALSO
.Xr bcopy 3 ,
.Xr memcpy 3 ,
.Xr memmove 3 ,
.Xr strcpy 3
+.Sh STANDARDS
+The
+.Fn memccpy
+function conforms to
+.St -p1003.1-2004
+and
+.St -isoC-2023 .
.Sh HISTORY
The
.Fn memccpy
function first appeared in
-.Bx 4.4 .
+.Bx 4.4
+and was first specified in the
+.St -svid1 .
+The
+.Ft restrict
+keyword was added to the prototype in
+.Fx 5.0.0
+in accordance with the updated specification of
+.St -p1003.1-2004 .
diff --git a/lib/libc/string/memccpy.c b/lib/libc/string/memccpy.c
index a81e8936e46a..d6a446503eb6 100644
--- a/lib/libc/string/memccpy.c
+++ b/lib/libc/string/memccpy.c
@@ -29,14 +29,10 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)memccpy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
void *
-memccpy(void *t, const void *f, int c, size_t n)
+memccpy(void * restrict t, const void * restrict f, int c, size_t n)
{
if (n) {
diff --git a/lib/libc/string/memchr.3 b/lib/libc/string/memchr.3
index 72a4fa70e536..c50e932d3382 100644
--- a/lib/libc/string/memchr.3
+++ b/lib/libc/string/memchr.3
@@ -29,14 +29,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memchr.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 9, 2008
.Dt MEMCHR 3
.Os
.Sh NAME
.Nm memchr
-.Nd locate byte in byte string
+.Nd locate byte in memory object
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -53,8 +51,11 @@ locates the first occurrence of
.Fa c
(converted to an
.Vt "unsigned char" )
-in string
-.Fa b .
+in object
+.Fa b ,
+limited to at most
+.Fa len
+characters.
.Pp
The
.Fn memrchr
@@ -62,16 +63,19 @@ function behaves like
.Fn memchr ,
except that it locates the last occurrence of
.Fa c
-in string
-.Fa b .
+in object
+.Fa b ,
+limited to the first
+.Fa len
+characters.
.Sh RETURN VALUES
The
.Fn memchr
and
.Fn memrchr
-functions
-return a pointer to the byte located,
-or NULL if no such byte exists within
+functions return a pointer to the byte located, or
+.Dv NULL
+if no such byte exists within
.Fa len
bytes.
.Sh SEE ALSO
diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c
index 10df015c5b64..367eac5108c1 100644
--- a/lib/libc/string/memchr.c
+++ b/lib/libc/string/memchr.c
@@ -22,7 +22,6 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/libc/string/memcmp.3 b/lib/libc/string/memcmp.3
index bf02412d9e70..8f4980d61c05 100644
--- a/lib/libc/string/memcmp.3
+++ b/lib/libc/string/memcmp.3
@@ -29,14 +29,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memcmp.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 15, 2016
+.Dd November 20, 2024
.Dt MEMCMP 3
.Os
.Sh NAME
.Nm memcmp
-.Nd compare byte string
+.Nd compare bytes in memory
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -47,27 +45,25 @@
The
.Fn memcmp
function
-compares byte string
+compares byte object
.Fa b1
-against byte string
+against byte object
.Fa b2 .
-Both strings are assumed to be
+Both objects are assumed to be
.Fa len
bytes long.
.Sh RETURN VALUES
The
.Fn memcmp
-function
-returns zero if the two strings are identical,
-otherwise returns the difference between the first two differing bytes
-(treated as
-.Vt "unsigned char"
-values, so that
-.Sq Li \e200
-is greater than
-.Sq Li \&\e0 ,
-for example).
-Zero-length strings are always identical.
+function returns zero if the two objects are identical.
+Zero-length objects are considered identical.
+The
+.Fn memcmp
+function returns a negative value if the first differing byte has a lower
+value in
+.Fa b1
+and a positive value if the first differing byte has a higher value in
+.Fa b1 .
.Sh SEE ALSO
.Xr bcmp 3 ,
.Xr strcasecmp 3 ,
@@ -82,3 +78,14 @@ The
function
conforms to
.St -isoC .
+.Sh CAVEATS
+If the objects differ, the C library
+.Fn memcmp
+implementation returns the difference between the first two differing bytes
+.Po treated as
+.Vt "unsigned char"
+values
+.Pc .
+This behavior is not specified by
+.St -isoC ,
+is not portable, and may not occur in light of compiler optimizations.
diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c
index 1a72e376c37a..1117e0565290 100644
--- a/lib/libc/string/memcmp.c
+++ b/lib/libc/string/memcmp.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
/*
diff --git a/lib/libc/string/memcpy.3 b/lib/libc/string/memcpy.3
index 5ce43d5dfe75..c1cf93af1cdc 100644
--- a/lib/libc/string/memcpy.3
+++ b/lib/libc/string/memcpy.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memcpy.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 14, 2021
+.Dd November 18, 2023
.Dt MEMCPY 3
.Os
.Sh NAME
@@ -77,7 +75,7 @@ function returns a pointer to the byte after the last written byte.
.Xr memccpy 3 ,
.Xr memmove 3 ,
.Xr strcpy 3 ,
-.Xr wmemcpy 3
+.Xr wmemcpy 3 ,
.Xr wmempcpy 3
.Sh STANDARDS
The
@@ -85,3 +83,14 @@ The
function
conforms to
.St -isoC .
+.Sh HISTORY
+The
+.Fn memcpy
+function first appeared in
+.At V
+and was reimplemented for
+.Bx 4.3 Tahoe .
+The
+.Fn mempcpy
+function first appeared in
+.Fx 13.1 .
diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c
index 886b7cb2c654..ee1150473aa9 100644
--- a/lib/libc/string/memcpy.c
+++ b/lib/libc/string/memcpy.c
@@ -1,3 +1,2 @@
-#include <sys/cdefs.h>
#define MEMCOPY
#include "bcopy.c"
diff --git a/lib/libc/string/memmem.3 b/lib/libc/string/memmem.3
index 5d8bcc84e31f..e301a0bd1e0f 100644
--- a/lib/libc/string/memmem.3
+++ b/lib/libc/string/memmem.3
@@ -67,10 +67,10 @@ is returned.
.Xr memchr 3 ,
.Xr strchr 3 ,
.Xr strstr 3
-.Sh CONFORMING TO
+.Sh STANDARDS
.Fn memmem
-started as a GNU extension but is now available in at least
-the GNU, musl, bionic, OpenBSD, NetBSD, macOS, and illumos C runtime libraries.
+conforms to
+.St -p1003.1-2024 .
.Sh HISTORY
The
.Fn memmem
diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c
index 11e1540bf1fc..4a244b5964ce 100644
--- a/lib/libc/string/memmem.c
+++ b/lib/libc/string/memmem.c
@@ -22,7 +22,6 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/libc/string/memmove.3 b/lib/libc/string/memmove.3
index 0b4ea6d3fa8f..4fd190610388 100644
--- a/lib/libc/string/memmove.3
+++ b/lib/libc/string/memmove.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memmove.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt MEMMOVE 3
.Os
diff --git a/lib/libc/string/memmove.c b/lib/libc/string/memmove.c
index 089a77a892a0..e9bb2c2ed14c 100644
--- a/lib/libc/string/memmove.c
+++ b/lib/libc/string/memmove.c
@@ -1,3 +1,2 @@
-#include <sys/cdefs.h>
#define MEMMOVE
#include "bcopy.c"
diff --git a/lib/libc/string/mempcpy.c b/lib/libc/string/mempcpy.c
index 2c645da97627..4ea0af87aef1 100644
--- a/lib/libc/string/mempcpy.c
+++ b/lib/libc/string/mempcpy.c
@@ -28,11 +28,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <string.h>
+#include <ssp/ssp.h>
void *
-mempcpy(void *__restrict dst, const void *__restrict src, size_t len)
+(mempcpy)(void *__restrict dst, const void *__restrict src,
+ size_t len)
{
return ((char *)memcpy(dst, src, len) + len);
}
diff --git a/lib/libc/string/memset.3 b/lib/libc/string/memset.3
index 656f1bbad749..f6ab9dacb516 100644
--- a/lib/libc/string/memset.3
+++ b/lib/libc/string/memset.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)memset.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 19, 2018
+.Dd October 24, 2024
.Dt MEMSET 3
.Os
.Sh NAME
@@ -43,6 +41,8 @@
.In string.h
.Ft void *
.Fn memset "void *dest" "int c" "size_t len"
+.Ft void *
+.Fn memset_explicit "void *dest" "int c" "size_t len"
.Fd #define __STDC_WANT_LIB_EXT1__ 1
.Ft errno_t
.Fn memset_s "void *dest" "rsize_t destsz" "int c" "rsize_t len"
@@ -70,6 +70,13 @@ The behaviour is also undefined if
is an invalid pointer.
.Pp
The
+.Fn memset_explicit
+function behaves the same as
+.Fn memset, but will not be removed by a compiler's dead store
+optimization pass, making it useful for clearing sensitive memory
+such as a password.
+.Pp
+The
.Fn memset_s
function behaves the same as
.Fn memset
@@ -110,7 +117,9 @@ before
.Sh RETURN VALUES
The
.Fn memset
-function returns its first argument.
+and
+.Fn memset_explicit
+functions return their first argument.
The
.Fn memset_s
function returns zero on success, non-zero on error.
@@ -130,3 +139,6 @@ conforms to
conforms to
.St -isoC-2011
K.3.7.4.1.
+.Fn memset_explicit
+conforms to
+.St -isoC-2023 .
diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c
index eed47014356f..811def0fc9b4 100644
--- a/lib/libc/string/memset.c
+++ b/lib/libc/string/memset.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <limits.h>
@@ -46,6 +42,8 @@ static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
#ifdef BZERO
#include <strings.h>
+#undef bzero /* _FORTIFY_SOURCE */
+
#define RETURN return
#define VAL 0
#define WIDEVAL 0
@@ -55,6 +53,8 @@ bzero(void *dst0, size_t length)
#else
#include <string.h>
+#undef memset /* _FORTIFY_SOURCE */
+
#define RETURN return (dst0)
#define VAL c0
#define WIDEVAL c
diff --git a/lib/libc/string/memset_explicit.c b/lib/libc/string/memset_explicit.c
new file mode 100644
index 000000000000..b2b9a79c40c8
--- /dev/null
+++ b/lib/libc/string/memset_explicit.c
@@ -0,0 +1,27 @@
+/*-
+ * SPDF-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Robert Clausecker <fuz@FreeBSD.org>
+ */
+
+#include <string.h>
+#include <ssp/ssp.h>
+
+__attribute__((weak)) void __memset_explicit_hook(void *, int, size_t);
+
+__attribute__((weak)) void
+__memset_explicit_hook(void *buf, int ch, size_t len)
+{
+ (void)buf;
+ (void)ch;
+ (void)len;
+}
+
+void *
+__ssp_real(memset_explicit)(void *buf, int ch, size_t len)
+{
+ memset(buf, ch, len);
+ __memset_explicit_hook(buf, ch, len);
+
+ return (buf);
+}
diff --git a/lib/libc/string/memset_s.c b/lib/libc/string/memset_s.c
index 3c7f76d19d7b..d6da7be8385d 100644
--- a/lib/libc/string/memset_s.c
+++ b/lib/libc/string/memset_s.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/lib/libc/string/stpcpy.c b/lib/libc/string/stpcpy.c
index 02640a68b0ae..4521e0877e07 100644
--- a/lib/libc/string/stpcpy.c
+++ b/lib/libc/string/stpcpy.c
@@ -31,12 +31,10 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
+#undef stpcpy /* _FORTIFY_SOURCE */
+
char *
stpcpy(char * __restrict to, const char * __restrict from)
{
diff --git a/lib/libc/string/stpncpy.c b/lib/libc/string/stpncpy.c
index 46e61c468d99..d3a1dddb4a65 100644
--- a/lib/libc/string/stpncpy.c
+++ b/lib/libc/string/stpncpy.c
@@ -26,9 +26,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <string.h>
+#undef stpncpy /* _FORTIFY_SOURCE */
+
char *
stpncpy(char * __restrict dst, const char * __restrict src, size_t n)
{
diff --git a/lib/libc/string/strcasecmp.3 b/lib/libc/string/strcasecmp.3
index a28b1e196e90..7297ec328724 100644
--- a/lib/libc/string/strcasecmp.3
+++ b/lib/libc/string/strcasecmp.3
@@ -27,8 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd May 29, 2014
.Dt STRCASECMP 3
.Os
diff --git a/lib/libc/string/strcasecmp.c b/lib/libc/string/strcasecmp.c
index c959869ad9f0..69c6d0aa4492 100644
--- a/lib/libc/string/strcasecmp.c
+++ b/lib/libc/string/strcasecmp.c
@@ -34,10 +34,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <strings.h>
#include <ctype.h>
#include "xlocale_private.h"
diff --git a/lib/libc/string/strcasestr.c b/lib/libc/string/strcasestr.c
index 591a2d95304b..c1be973f01f4 100644
--- a/lib/libc/string/strcasestr.c
+++ b/lib/libc/string/strcasestr.c
@@ -37,7 +37,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <string.h>
#include "xlocale_private.h"
diff --git a/lib/libc/string/strcat.3 b/lib/libc/string/strcat.3
index 061bd714a05d..a8365b8fbdf8 100644
--- a/lib/libc/string/strcat.3
+++ b/lib/libc/string/strcat.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strcat.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt STRCAT 3
.Os
diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c
index 94f851d4a257..1c13c519b563 100644
--- a/lib/libc/string/strcat.c
+++ b/lib/libc/string/strcat.c
@@ -29,12 +29,10 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcat.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
+#undef strcat /* _FORTIFY_SOURCE */
+
char *
strcat(char * __restrict s, const char * __restrict append)
{
diff --git a/lib/libc/string/strchr.3 b/lib/libc/string/strchr.3
index 3d420624abd9..45179a0001fc 100644
--- a/lib/libc/string/strchr.3
+++ b/lib/libc/string/strchr.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strchr.3 8.2 (Berkeley) 4/19/94
-.\"
.Dd February 13, 2013
.Dt STRCHR 3
.Os
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
index d4e35b07c8c1..8f6f947e9983 100644
--- a/lib/libc/string/strchr.c
+++ b/lib/libc/string/strchr.c
@@ -22,7 +22,6 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <string.h>
char *__strchrnul(const char *, int);
diff --git a/lib/libc/string/strchrnul.c b/lib/libc/string/strchrnul.c
index 1841185dc9b6..3a42c0e7c4c5 100644
--- a/lib/libc/string/strchrnul.c
+++ b/lib/libc/string/strchrnul.c
@@ -22,7 +22,6 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/libc/string/strcmp.3 b/lib/libc/string/strcmp.3
index 65baf65ed40b..6f39d8d95dd4 100644
--- a/lib/libc/string/strcmp.3
+++ b/lib/libc/string/strcmp.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strcmp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt STRCMP 3
.Os
diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c
index 9d590cc5a4f0..216efd318906 100644
--- a/lib/libc/string/strcmp.c
+++ b/lib/libc/string/strcmp.c
@@ -32,10 +32,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
/*
diff --git a/lib/libc/string/strcoll.3 b/lib/libc/string/strcoll.3
index 178e87fd7d48..863bc3a43d4e 100644
--- a/lib/libc/string/strcoll.3
+++ b/lib/libc/string/strcoll.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strcoll.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt STRCOLL 3
.Os
diff --git a/lib/libc/string/strcoll.c b/lib/libc/string/strcoll.c
index a682f352320f..77566f0c7cd7 100644
--- a/lib/libc/string/strcoll.c
+++ b/lib/libc/string/strcoll.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
diff --git a/lib/libc/string/strcpy.3 b/lib/libc/string/strcpy.3
index db9cf39b3b38..ed32d78826eb 100644
--- a/lib/libc/string/strcpy.3
+++ b/lib/libc/string/strcpy.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strcpy.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 6, 2018
.Dt STRCPY 3
.Os
diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c
index 5b0ca98fb8b5..432bcc0e9d62 100644
--- a/lib/libc/string/strcpy.c
+++ b/lib/libc/string/strcpy.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
#ifdef WEAK_STRCPY
diff --git a/lib/libc/string/strcspn.c b/lib/libc/string/strcspn.c
index 687a309d01d9..88bf68ff0733 100644
--- a/lib/libc/string/strcspn.c
+++ b/lib/libc/string/strcspn.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <limits.h>
#include <string.h>
diff --git a/lib/libc/string/strdup.3 b/lib/libc/string/strdup.3
index a19a00f5430b..576fa122b8d6 100644
--- a/lib/libc/string/strdup.3
+++ b/lib/libc/string/strdup.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd May 5, 2020
.Dt STRDUP 3
.Os
diff --git a/lib/libc/string/strdup.c b/lib/libc/string/strdup.c
index 3e6849abe12c..2d595e53eb6b 100644
--- a/lib/libc/string/strdup.c
+++ b/lib/libc/string/strdup.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3
index 9c6847144f89..fa72dcff627b 100644
--- a/lib/libc/string/strerror.3
+++ b/lib/libc/string/strerror.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strerror.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd December 17, 2020
.Dt STRERROR 3
.Os
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c
index 673ccbf37ef7..922bb0284497 100644
--- a/lib/libc/string/strerror.c
+++ b/lib/libc/string/strerror.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#if defined(NLS)
#include <nl_types.h>
#endif
@@ -42,6 +38,8 @@ static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93";
#include <string.h>
#include <stdio.h>
+#include <ssp/ssp.h>
+
#include "errlst.h"
#include "../locale/xlocale_private.h"
#include "libc_private.h"
@@ -78,8 +76,8 @@ errstr(int num, const char *uprefix, char *buf, size_t len)
strlcat(buf, t, len);
}
-static int
-strerror_rl(int errnum, char *strerrbuf, size_t buflen, locale_t locale)
+int
+__strerror_rl(int errnum, char *strerrbuf, size_t buflen, locale_t locale)
{
int retval = 0;
#if defined(NLS)
@@ -118,9 +116,9 @@ strerror_rl(int errnum, char *strerrbuf, size_t buflen, locale_t locale)
}
int
-strerror_r(int errnum, char *strerrbuf, size_t buflen)
+__ssp_real(strerror_r)(int errnum, char *strerrbuf, size_t buflen)
{
- return (strerror_rl(errnum, strerrbuf, buflen, __get_locale()));
+ return (__strerror_rl(errnum, strerrbuf, buflen, __get_locale()));
}
char *
@@ -128,7 +126,7 @@ strerror_l(int num, locale_t locale)
{
static _Thread_local char ebuf[NL_TEXTMAX];
- if (strerror_rl(num, ebuf, sizeof(ebuf), locale) != 0)
+ if (__strerror_rl(num, ebuf, sizeof(ebuf), locale) != 0)
errno = EINVAL;
return (ebuf);
}
@@ -138,7 +136,7 @@ strerror(int num)
{
static char ebuf[NL_TEXTMAX];
- if (strerror_rl(num, ebuf, sizeof(ebuf), __get_locale()) != 0)
+ if (__strerror_rl(num, ebuf, sizeof(ebuf), __get_locale()) != 0)
errno = EINVAL;
return (ebuf);
}
diff --git a/lib/libc/string/string.3 b/lib/libc/string/string.3
index a164aae01eec..3ffea6ce0369 100644
--- a/lib/libc/string/string.3
+++ b/lib/libc/string/string.3
@@ -27,9 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)string.3 8.2 (Berkeley) 12/11/93
-.\"
-.Dd December 11, 1993
+.Dd September 2, 2023
.Dt STRING 3
.Os
.Sh NAME
@@ -132,7 +130,8 @@ for size limitations.
.Xr strsep 3 ,
.Xr strspn 3 ,
.Xr strstr 3 ,
-.Xr strtok 3
+.Xr strtok 3 ,
+.Xr simd 7
.Sh STANDARDS
The
.Fn strcat ,
diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c
index e5040019b29b..fc18fad179db 100644
--- a/lib/libc/string/strlcat.c
+++ b/lib/libc/string/strlcat.c
@@ -16,10 +16,11 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
+#undef strlcat /* FORTIFY_SOURCE */
+
/*
* Appends src to string dst of size dsize (unlike strncat, dsize is the
* full size of dst, not space left). At most dsize-1 characters
diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3
index 148afcbbd2bd..89c9d62c5a25 100644
--- a/lib/libc/string/strlcpy.3
+++ b/lib/libc/string/strlcpy.3
@@ -25,7 +25,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 1, 2020
+.Dd October 27, 2023
.Dt STRLCPY 3
.Os
.Sh NAME
@@ -45,9 +45,11 @@ The
.Fn strlcpy
and
.Fn strlcat
-functions copy and concatenate strings with the
-same input parameters and output result as
-.Xr snprintf 3 .
+functions copy and concatenate strings with the same input parameters and output result as
+.Xr strcpy 3
+and
+.Xr strcat 3
+with proper overflow protection.
They are designed to be safer, more consistent, and less error
prone replacements for the easily misused functions
.Xr strncpy 3
@@ -100,22 +102,7 @@ and
.Fa dst
strings overlap, the behavior is undefined.
.Sh RETURN VALUES
-Besides quibbles over the return type
-.Pf ( Va size_t
-versus
-.Va int )
-and signal handler safety
-.Pf ( Xr snprintf 3
-is not entirely safe on some systems), the
-following two are equivalent:
-.Bd -literal -offset indent
-n = strlcpy(dst, src, len);
-n = snprintf(dst, len, "%s", src);
-.Ed
-.Pp
-Like
-.Xr snprintf 3 ,
-the
+The
.Fn strlcpy
and
.Fn strlcat
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c
index 8c7daa858960..79f7ab19cdfd 100644
--- a/lib/libc/string/strlcpy.c
+++ b/lib/libc/string/strlcpy.c
@@ -16,10 +16,11 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
+#undef strlcpy /* FORTIFY_SOURCE */
+
/*
* Copy string src to buffer dst of size dsize. At most dsize-1
* chars will be copied. Always NUL terminates (unless dsize == 0).
diff --git a/lib/libc/string/strlen.3 b/lib/libc/string/strlen.3
index 17427fc4c96c..91b82a085b01 100644
--- a/lib/libc/string/strlen.3
+++ b/lib/libc/string/strlen.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strlen.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd April 3, 2022
.Dt STRLEN 3
.Os
@@ -98,3 +96,8 @@ and was ported to
.At v7 .
The
.Fn strnlen
+function first appeared in
+.Fx 8.0 ,
+.Ox 4.8 ,
+and
+.Nx 6.0 .
diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c
index d7c744d6aa60..c33819707dce 100644
--- a/lib/libc/string/strlen.c
+++ b/lib/libc/string/strlen.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/limits.h>
#include <sys/types.h>
#include <string.h>
diff --git a/lib/libc/string/strmode.3 b/lib/libc/string/strmode.3
index 503bd3b1ae4a..7c9319979acd 100644
--- a/lib/libc/string/strmode.3
+++ b/lib/libc/string/strmode.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strmode.3 8.3 (Berkeley) 7/28/94
-.\"
.Dd July 28, 1994
.Dt STRMODE 3
.Os
diff --git a/lib/libc/string/strmode.c b/lib/libc/string/strmode.c
index 58b9490bb163..ae52c08b0c33 100644
--- a/lib/libc/string/strmode.c
+++ b/lib/libc/string/strmode.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strmode.c 8.3 (Berkeley) 8/15/94";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
diff --git a/lib/libc/string/strncat.c b/lib/libc/string/strncat.c
index 3220f036c458..086bdef32b68 100644
--- a/lib/libc/string/strncat.c
+++ b/lib/libc/string/strncat.c
@@ -32,12 +32,10 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strncat.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
+#undef strncat /* _FORTIFY_SOURCE */
+
/*
* Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes
* are written at dst (at most n+1 bytes being appended). Return dst.
diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c
index 111d77b592c2..abffdd41588b 100644
--- a/lib/libc/string/strncmp.c
+++ b/lib/libc/string/strncmp.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
int
diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c
index 6a00e1ba5135..67240a855196 100644
--- a/lib/libc/string/strncpy.c
+++ b/lib/libc/string/strncpy.c
@@ -32,12 +32,10 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strncpy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
+#undef strncpy /* FORTIFY_SOURCE */
+
/*
* Copy src to dst, truncating or null-padding to always copy n bytes.
* Return dst.
diff --git a/lib/libc/string/strndup.c b/lib/libc/string/strndup.c
index a2351bf40722..56034d1732fe 100644
--- a/lib/libc/string/strndup.c
+++ b/lib/libc/string/strndup.c
@@ -16,7 +16,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/string/strnlen.c b/lib/libc/string/strnlen.c
index 8fa984551b8e..b44f8ab21947 100644
--- a/lib/libc/string/strnlen.c
+++ b/lib/libc/string/strnlen.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <string.h>
size_t
diff --git a/lib/libc/string/strnstr.c b/lib/libc/string/strnstr.c
index 023b167e9c36..71e6b1d0f0a7 100644
--- a/lib/libc/string/strnstr.c
+++ b/lib/libc/string/strnstr.c
@@ -33,10 +33,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
/*
diff --git a/lib/libc/string/strpbrk.3 b/lib/libc/string/strpbrk.3
index 2e27c1dda46a..cdccf0da957f 100644
--- a/lib/libc/string/strpbrk.3
+++ b/lib/libc/string/strpbrk.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strpbrk.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt STRPBRK 3
.Os
diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c
index 80ac5ebc4bde..c7dd6c2cff37 100644
--- a/lib/libc/string/strpbrk.c
+++ b/lib/libc/string/strpbrk.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strpbrk.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
/*
diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c
index cfe6f9270bce..10cb32011cbd 100644
--- a/lib/libc/string/strrchr.c
+++ b/lib/libc/string/strrchr.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stddef.h>
#include <string.h>
diff --git a/lib/libc/string/strsep.3 b/lib/libc/string/strsep.3
index da9a3e998106..452f646d96d2 100644
--- a/lib/libc/string/strsep.3
+++ b/lib/libc/string/strsep.3
@@ -28,8 +28,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strsep.3 8.1 (Berkeley) 6/9/93
-.\"
.Dd May 28, 2018
.Dt STRSEP 3
.Os
diff --git a/lib/libc/string/strsep.c b/lib/libc/string/strsep.c
index a3d64c92ff53..bc7510362f62 100644
--- a/lib/libc/string/strsep.c
+++ b/lib/libc/string/strsep.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <string.h>
#include <stdio.h>
diff --git a/lib/libc/string/strsignal.c b/lib/libc/string/strsignal.c
index 5abe7b37ed99..b99da800cee9 100644
--- a/lib/libc/string/strsignal.c
+++ b/lib/libc/string/strsignal.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include "namespace.h"
#if defined(NLS)
#include <nl_types.h>
diff --git a/lib/libc/string/strspn.3 b/lib/libc/string/strspn.3
index ce43693d0871..3c87afaed1d9 100644
--- a/lib/libc/string/strspn.3
+++ b/lib/libc/string/strspn.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strspn.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd May 24, 2014
.Dt STRSPN 3
.Os
diff --git a/lib/libc/string/strspn.c b/lib/libc/string/strspn.c
index a9df4da92cbe..5f046cf4e66b 100644
--- a/lib/libc/string/strspn.c
+++ b/lib/libc/string/strspn.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <limits.h>
#include <string.h>
diff --git a/lib/libc/string/strstr.3 b/lib/libc/string/strstr.3
index 7ff9ec8c54e1..8957388db535 100644
--- a/lib/libc/string/strstr.3
+++ b/lib/libc/string/strstr.3
@@ -30,8 +30,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strstr.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd October 11, 2001
.Dt STRSTR 3
.Os
diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c
index f3658805996b..90f8bc701e0f 100644
--- a/lib/libc/string/strstr.c
+++ b/lib/libc/string/strstr.c
@@ -22,7 +22,6 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <stdint.h>
#include <string.h>
diff --git a/lib/libc/string/strtok.3 b/lib/libc/string/strtok.3
index c9bfd1988888..e905b655b024 100644
--- a/lib/libc/string/strtok.3
+++ b/lib/libc/string/strtok.3
@@ -41,8 +41,6 @@
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strtok.3 8.2 (Berkeley) 2/3/94
-.\"
.Dd January 22, 2016
.Dt STRTOK 3
.Os
diff --git a/lib/libc/string/strtok.c b/lib/libc/string/strtok.c
index 1ff7a3aa45fc..fb22913505ba 100644
--- a/lib/libc/string/strtok.c
+++ b/lib/libc/string/strtok.c
@@ -34,10 +34,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtok.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <stddef.h>
#ifdef DEBUG_STRTOK
#include <stdio.h>
diff --git a/lib/libc/string/strxfrm.3 b/lib/libc/string/strxfrm.3
index a28a4fb2ffa3..15964c72a04d 100644
--- a/lib/libc/string/strxfrm.3
+++ b/lib/libc/string/strxfrm.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)strxfrm.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt STRXFRM 3
.Os
diff --git a/lib/libc/string/strxfrm.c b/lib/libc/string/strxfrm.c
index d9f3d0a7b6d5..e327aaf1c2ff 100644
--- a/lib/libc/string/strxfrm.c
+++ b/lib/libc/string/strxfrm.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
diff --git a/lib/libc/string/swab.3 b/lib/libc/string/swab.3
index 55b3acc6aad4..050cab6c4dd6 100644
--- a/lib/libc/string/swab.3
+++ b/lib/libc/string/swab.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)swab.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 4, 2012
.Dt SWAB 3
.Os
diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c
index c239808291f0..ed4436a49810 100644
--- a/lib/libc/string/swab.c
+++ b/lib/libc/string/swab.c
@@ -1,62 +1,25 @@
/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jeffrey Mogul.
- *
- * 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.
+ * SPDX-License-Identifier: BSD-2-Clause
+ * Copyright (c) 2024 rilysh <nightquick@proton.me>
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)swab.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <unistd.h>
+#include <sys/endian.h>
void
swab(const void * __restrict from, void * __restrict to, ssize_t len)
{
- unsigned char temp;
- size_t n;
- const unsigned char *fp;
- unsigned char *tp;
+ const uint16_t *f __aligned(1) = from;
+ uint16_t *t __aligned(1) = to;
- if (len <= 0)
- return;
- n = (size_t)len >> 1;
- fp = (const unsigned char *)from;
- tp = (unsigned char *)to;
-#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp
- /* round to multiple of 8 */
- for (; n & 0x7; --n)
- STEP;
- for (n >>= 3; n > 0; --n) {
- STEP; STEP; STEP; STEP;
- STEP; STEP; STEP; STEP;
+ /*
+ * POSIX says overlapping copy behavior is undefined, however many
+ * applications assume the old FreeBSD and current GNU libc behavior
+ * that will swap the bytes correctly when from == to. Reading both bytes
+ * and swapping them before writing them back accomplishes this.
+ */
+ while (len > 1) {
+ *t++ = bswap16(*f++);
+ len -= 2;
}
}
diff --git a/lib/libc/string/timingsafe_bcmp.3 b/lib/libc/string/timingsafe_bcmp.3
index d3a4ce004757..52c7be7410ef 100644
--- a/lib/libc/string/timingsafe_bcmp.3
+++ b/lib/libc/string/timingsafe_bcmp.3
@@ -87,4 +87,4 @@ function first appeared in
.Ox 5.6 .
.Pp
Both functions first appeared in
-.Fx 12.0 .
+.Fx 11.1 .
diff --git a/lib/libc/string/timingsafe_bcmp.c b/lib/libc/string/timingsafe_bcmp.c
index 145b02b74b09..c3a595a18695 100644
--- a/lib/libc/string/timingsafe_bcmp.c
+++ b/lib/libc/string/timingsafe_bcmp.c
@@ -15,7 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <string.h>
int __timingsafe_bcmp(const void *, const void *, size_t);
diff --git a/lib/libc/string/timingsafe_memcmp.c b/lib/libc/string/timingsafe_memcmp.c
index 446a8a6cb2c3..97a146e06a2b 100644
--- a/lib/libc/string/timingsafe_memcmp.c
+++ b/lib/libc/string/timingsafe_memcmp.c
@@ -15,7 +15,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <string.h>
diff --git a/lib/libc/string/wcpcpy.c b/lib/libc/string/wcpcpy.c
index 22c623bef320..2ae014b31d29 100644
--- a/lib/libc/string/wcpcpy.c
+++ b/lib/libc/string/wcpcpy.c
@@ -31,14 +31,11 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wcpcpy(wchar_t * __restrict to, const wchar_t * __restrict from)
+__ssp_real(wcpcpy)(wchar_t * __restrict to, const wchar_t * __restrict from)
{
for (; (*to = *from); ++from, ++to);
diff --git a/lib/libc/string/wcpncpy.c b/lib/libc/string/wcpncpy.c
index 4249f8bd24aa..e89facfeb642 100644
--- a/lib/libc/string/wcpncpy.c
+++ b/lib/libc/string/wcpncpy.c
@@ -26,11 +26,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wcpncpy(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t n)
+__ssp_real(wcpncpy)(wchar_t * __restrict dst, const wchar_t * __restrict src,
+ size_t n)
{
for (; n--; dst++, src++) {
diff --git a/lib/libc/string/wcscasecmp.c b/lib/libc/string/wcscasecmp.c
index 50949ff38744..0132966fe0cf 100644
--- a/lib/libc/string/wcscasecmp.c
+++ b/lib/libc/string/wcscasecmp.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include <wctype.h>
diff --git a/lib/libc/string/wcscat.c b/lib/libc/string/wcscat.c
index 3599e562e9b4..98e088100a87 100644
--- a/lib/libc/string/wcscat.c
+++ b/lib/libc/string/wcscat.c
@@ -35,9 +35,10 @@ __RCSID("$NetBSD: wcscat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wcscat(wchar_t * __restrict s1, const wchar_t * __restrict s2)
+__ssp_real(wcscat)(wchar_t * __restrict s1, const wchar_t * __restrict s2)
{
wchar_t *cp;
diff --git a/lib/libc/string/wcschr.c b/lib/libc/string/wcschr.c
index 24c150ad17b4..356f8025c317 100644
--- a/lib/libc/string/wcschr.c
+++ b/lib/libc/string/wcschr.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
wchar_t *
diff --git a/lib/libc/string/wcscmp.c b/lib/libc/string/wcscmp.c
index ed02db771704..66e08ff782a7 100644
--- a/lib/libc/string/wcscmp.c
+++ b/lib/libc/string/wcscmp.c
@@ -32,13 +32,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93";
-#if 0
-__RCSID("$NetBSD: wcscmp.c,v 1.3 2001/01/05 12:13:12 itojun Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
+
+/* $NetBSD: wcscmp.c,v 1.3 2001/01/05 12:13:12 itojun Exp $ */
+
#include <wchar.h>
/*
diff --git a/lib/libc/string/wcscoll.3 b/lib/libc/string/wcscoll.3
index 9c0a8037e384..620787861f3a 100644
--- a/lib/libc/string/wcscoll.3
+++ b/lib/libc/string/wcscoll.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" @(#)strcoll.3 8.1 (Berkeley) 6/4/93
.\" FreeBSD: src/lib/libc/string/strcoll.3,v 1.11 2001/10/01 16:09:00 ru Exp
.\"
.Dd October 4, 2002
diff --git a/lib/libc/string/wcscoll.c b/lib/libc/string/wcscoll.c
index b7720c4069d1..e9394a83f60c 100644
--- a/lib/libc/string/wcscoll.c
+++ b/lib/libc/string/wcscoll.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libc/string/wcscpy.c b/lib/libc/string/wcscpy.c
index 622e4201f84b..d4aed8721bb8 100644
--- a/lib/libc/string/wcscpy.c
+++ b/lib/libc/string/wcscpy.c
@@ -35,9 +35,10 @@ __RCSID("$NetBSD: wcscpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)
+__ssp_real(wcscpy)(wchar_t * __restrict s1, const wchar_t * __restrict s2)
{
wchar_t *cp;
diff --git a/lib/libc/string/wcsdup.c b/lib/libc/string/wcsdup.c
index 9aa088d3315f..517acfa7ec49 100644
--- a/lib/libc/string/wcsdup.c
+++ b/lib/libc/string/wcsdup.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <wchar.h>
diff --git a/lib/libc/string/wcslcat.c b/lib/libc/string/wcslcat.c
index 336947e3cd23..f74ce520b6a7 100644
--- a/lib/libc/string/wcslcat.c
+++ b/lib/libc/string/wcslcat.c
@@ -37,6 +37,7 @@ __RCSID("$NetBSD: wcslcat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
#endif
#include <sys/types.h>
#include <wchar.h>
+#include <ssp/ssp.h>
/*
* Appends src to string dst of size siz (unlike wcsncat, siz is the
@@ -46,7 +47,7 @@ __RCSID("$NetBSD: wcslcat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
* truncation occurred.
*/
size_t
-wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
+__ssp_real(wcslcat)(wchar_t *dst, const wchar_t *src, size_t siz)
{
wchar_t *d = dst;
const wchar_t *s = src;
diff --git a/lib/libc/string/wcslcpy.c b/lib/libc/string/wcslcpy.c
index 920425bb5efc..82269656b985 100644
--- a/lib/libc/string/wcslcpy.c
+++ b/lib/libc/string/wcslcpy.c
@@ -37,6 +37,7 @@ __RCSID("$NetBSD: wcslcpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
#endif
#include <sys/types.h>
#include <wchar.h>
+#include <ssp/ssp.h>
/*
* Copy src to string dst of size siz. At most siz-1 characters
@@ -44,7 +45,7 @@ __RCSID("$NetBSD: wcslcpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
* Returns wcslen(src); if retval >= siz, truncation occurred.
*/
size_t
-wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
+__ssp_real(wcslcpy)(wchar_t *dst, const wchar_t *src, size_t siz)
{
wchar_t *d = dst;
const wchar_t *s = src;
diff --git a/lib/libc/string/wcsncasecmp.c b/lib/libc/string/wcsncasecmp.c
index 1b6772152f4a..0cd9f16796fa 100644
--- a/lib/libc/string/wcsncasecmp.c
+++ b/lib/libc/string/wcsncasecmp.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include <wctype.h>
diff --git a/lib/libc/string/wcsncat.c b/lib/libc/string/wcsncat.c
index 004391423f53..5b36fd40bb4f 100644
--- a/lib/libc/string/wcsncat.c
+++ b/lib/libc/string/wcsncat.c
@@ -35,9 +35,11 @@ __RCSID("$NetBSD: wcsncat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
+__ssp_real(wcsncat)(wchar_t * __restrict s1, const wchar_t * __restrict s2,
+ size_t n)
{
wchar_t *p;
wchar_t *q;
diff --git a/lib/libc/string/wcsncmp.c b/lib/libc/string/wcsncmp.c
index a7b2189d5fb9..141e42c3087f 100644
--- a/lib/libc/string/wcsncmp.c
+++ b/lib/libc/string/wcsncmp.c
@@ -29,13 +29,8 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 6/4/93";
-__RCSID("$NetBSD: wcsncmp.c,v 1.3 2001/01/05 12:13:13 itojun Exp $");
-#endif /* LIBC_SCCS and not lint */
-#endif
+/* $NetBSD: wcsncmp.c,v 1.3 2001/01/05 12:13:13 itojun Exp $ */
+
#include <wchar.h>
int
diff --git a/lib/libc/string/wcsncpy.c b/lib/libc/string/wcsncpy.c
index 16e3eb899b84..2491dadadfa4 100644
--- a/lib/libc/string/wcsncpy.c
+++ b/lib/libc/string/wcsncpy.c
@@ -32,20 +32,16 @@
* SUCH DAMAGE.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strncpy.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#endif
-#include <sys/cdefs.h>
#include <wchar.h>
+#include <ssp/ssp.h>
/*
* Copy src to dst, truncating or null-padding to always copy n bytes.
* Return dst.
*/
wchar_t *
-wcsncpy(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t n)
+__ssp_real(wcsncpy)(wchar_t * __restrict dst, const wchar_t * __restrict src,
+ size_t n)
{
if (n != 0) {
wchar_t *d = dst;
diff --git a/lib/libc/string/wcsnlen.c b/lib/libc/string/wcsnlen.c
index 3c500855eb1f..1dfc2d5ef913 100644
--- a/lib/libc/string/wcsnlen.c
+++ b/lib/libc/string/wcsnlen.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
size_t
diff --git a/lib/libc/string/wcsrchr.c b/lib/libc/string/wcsrchr.c
index 60f56551aaac..1679d808be2b 100644
--- a/lib/libc/string/wcsrchr.c
+++ b/lib/libc/string/wcsrchr.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
wchar_t *
diff --git a/lib/libc/string/wcsstr.c b/lib/libc/string/wcsstr.c
index ff8739f1c75a..beb5e8931742 100644
--- a/lib/libc/string/wcsstr.c
+++ b/lib/libc/string/wcsstr.c
@@ -32,12 +32,6 @@
* SUCH DAMAGE.
*/
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-#endif
-#include <sys/cdefs.h>
#include <wchar.h>
/*
diff --git a/lib/libc/string/wcstok.c b/lib/libc/string/wcstok.c
index 65312db85b56..839a650ce316 100644
--- a/lib/libc/string/wcstok.c
+++ b/lib/libc/string/wcstok.c
@@ -34,7 +34,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
wchar_t *
diff --git a/lib/libc/string/wcswidth.c b/lib/libc/string/wcswidth.c
index 84e9af602801..b6f3abd761eb 100644
--- a/lib/libc/string/wcswidth.c
+++ b/lib/libc/string/wcswidth.c
@@ -42,7 +42,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include "xlocale_private.h"
diff --git a/lib/libc/string/wcsxfrm.3 b/lib/libc/string/wcsxfrm.3
index 45e197ef8a83..8fca7c1b62df 100644
--- a/lib/libc/string/wcsxfrm.3
+++ b/lib/libc/string/wcsxfrm.3
@@ -28,8 +28,6 @@
.\" 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.
-.\"
-.\" @(#)strxfrm.3 8.1 (Berkeley) 6/4/93
.\" FreeBSD: src/lib/libc/string/strxfrm.3,v 1.16 2002/09/06 11:24:06 tjr Exp
.\"
.Dd October 4, 2002
diff --git a/lib/libc/string/wcsxfrm.c b/lib/libc/string/wcsxfrm.c
index 6e4d7534828b..8c6c542c9255 100644
--- a/lib/libc/string/wcsxfrm.c
+++ b/lib/libc/string/wcsxfrm.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
diff --git a/lib/libc/string/wmemchr.3 b/lib/libc/string/wmemchr.3
index 4466a7e9b1b4..c1701facb7d5 100644
--- a/lib/libc/string/wmemchr.3
+++ b/lib/libc/string/wmemchr.3
@@ -31,9 +31,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)strcpy.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 14, 2021
+.Dd March 21, 2024
.Dt WMEMCHR 3
.Os
.Sh NAME
@@ -82,9 +80,9 @@
.Ft wchar_t *
.Fn wmemset "wchar_t *s" "wchar_t c" "size_t n"
.Ft wchar_t *
-.Fn wcpcpy "wchar_t *s1" "wchar_t *s2"
+.Fn wcpcpy "wchar_t * restrict s1" "const wchar_t * restrict s2"
.Ft wchar_t *
-.Fn wcpncpy "wchar_t *s1" "wchar_t *s2" "size_t n"
+.Fn wcpncpy "wchar_t * restrict s1" "const wchar_t * restrict s2" "size_t n"
.Ft int
.Fn wcscasecmp "const wchar_t *s1" "const wchar_t *s2"
.Ft wchar_t *
diff --git a/lib/libc/string/wmemcpy.c b/lib/libc/string/wmemcpy.c
index f692a25fc95b..9db16fe77a69 100644
--- a/lib/libc/string/wmemcpy.c
+++ b/lib/libc/string/wmemcpy.c
@@ -36,9 +36,11 @@ __RCSID("$NetBSD: wmemcpy.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
#endif
#include <string.h>
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wmemcpy(wchar_t * __restrict d, const wchar_t * __restrict s, size_t n)
+__ssp_real(wmemcpy)(wchar_t * __restrict d, const wchar_t * __restrict s,
+ size_t n)
{
return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
}
diff --git a/lib/libc/string/wmemmove.c b/lib/libc/string/wmemmove.c
index cbbdb4afdd6c..837dbe12dc7a 100644
--- a/lib/libc/string/wmemmove.c
+++ b/lib/libc/string/wmemmove.c
@@ -36,9 +36,10 @@ __RCSID("$NetBSD: wmemmove.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
#endif
#include <string.h>
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wmemmove(wchar_t *d, const wchar_t *s, size_t n)
+__ssp_real(wmemmove)(wchar_t *d, const wchar_t *s, size_t n)
{
return (wchar_t *)memmove(d, s, n * sizeof(wchar_t));
}
diff --git a/lib/libc/string/wmempcpy.c b/lib/libc/string/wmempcpy.c
index a21621de3977..152bb76c7e80 100644
--- a/lib/libc/string/wmempcpy.c
+++ b/lib/libc/string/wmempcpy.c
@@ -28,12 +28,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <string.h>
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wmempcpy(wchar_t *__restrict dst, const wchar_t *__restrict src, size_t len)
+__ssp_real(wmempcpy)(wchar_t *__restrict dst, const wchar_t *__restrict src,
+ size_t len)
{
return (wmemcpy(dst, src, len) + len);
}
diff --git a/lib/libc/string/wmemset.c b/lib/libc/string/wmemset.c
index 4276373399f9..60fb14b6a4af 100644
--- a/lib/libc/string/wmemset.c
+++ b/lib/libc/string/wmemset.c
@@ -35,9 +35,10 @@ __RCSID("$NetBSD: wmemset.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#endif
#include <wchar.h>
+#include <ssp/ssp.h>
wchar_t *
-wmemset(wchar_t *s, wchar_t c, size_t n)
+__ssp_real(wmemset)(wchar_t *s, wchar_t c, size_t n)
{
size_t i;
wchar_t *p;
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 480002f9875e..ee761ce5ff55 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,518 +1,38 @@
-# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
+# libc-specific portion of the system call interface
-# sys sources
-.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/sys ${LIBC_SRCTOP}/sys
+.PATH: ${LIBC_SRCTOP}/sys
-# Include the generated makefile containing the *complete* list
-# of syscall names in MIASM.
-.include "${SRCTOP}/sys/sys/syscall.mk"
+# Most of the implementation is shared with libsys:
+.include "${LIBSYS_SRCTOP}/Makefile.sys"
-# Include machine dependent definitions.
-#
-# MDASM names override the default syscall names in MIASM.
-# NOASM will prevent the default syscall code from being generated.
-# PSEUDO generates _<sys>() and __sys_<sys>() symbols, but not <sys>().
-#
-# While historically machine dependent, all architectures have the following
-# declarations in common:
-#
-NOASM= exit.o \
- getlogin.o \
- sstk.o \
- yield.o
-PSEUDO= _exit.o \
- _getlogin.o
-.sinclude "${LIBC_SRCTOP}/${LIBC_ARCH}/sys/Makefile.inc"
-
-SRCS+= clock_gettime.c gettimeofday.c __vdso_gettimeofday.c
-NOASM+= clock_gettime.o gettimeofday.o
-PSEUDO+= _clock_gettime.o _gettimeofday.o
-
-# Sources common to both syscall interfaces:
-SRCS+= \
- __error.c \
- interposing_table.c
-
-SRCS+= getdents.c lstat.c mknod.c stat.c
-
-NOASM+= sched_getcpu.o
-PSEUDO+= _sched_getcpu.o
-
-SRCS+= fstat.c fstatat.c fstatfs.c getfsstat.c statfs.c
-NOASM+= fstat.o fstatat.o fstatfs.o getfsstat.o statfs.o
-PSEUDO+= _fstat.o _fstatat.o _fstatfs.o _getfsstat.o _statfs.o
-
-SRCS+= getdirentries.c
-NOASM+= getdirentries.o
-PSEUDO+= _getdirentries.o
-
-SRCS+= brk.c
-SRCS+= closefrom.c
-SRCS+= pipe.c
-SRCS+= shm_open.c
-SRCS+= vadvise.c
-SRCS+= POSIX2x_Fork.c
-
-SRCS+= compat-stub.c
-
-INTERPOSED = \
- accept \
- accept4 \
- aio_suspend \
- clock_nanosleep \
- close \
- connect \
- fcntl \
- fdatasync \
- fsync \
- fork \
- kevent \
- msync \
- nanosleep \
- open \
- openat \
- pdfork \
- poll \
- ppoll \
- pselect \
- ptrace \
- read \
- readv \
- recvfrom \
- recvmsg \
- select \
- sendmsg \
- sendto \
- setcontext \
- sigaction \
- sigprocmask \
- sigsuspend \
- sigtimedwait \
- sigwait \
- sigwaitinfo \
- swapcontext \
- wait4 \
- wait6 \
- write \
- writev
-
-SRCS+= ${INTERPOSED:S/$/.c/}
-NOASM+= ${INTERPOSED:S/$/.o/}
-PSEUDO+= ${INTERPOSED:C/^.*$/_&.o/}
-
-# Add machine dependent asm sources:
-SRCS+=${MDASM}
-
-# Look though the complete list of syscalls (MIASM) for names that are
-# not defined with machine dependent implementations (MDASM) and are
-# not declared for no generation of default code (NOASM). Add each
-# syscall that satisfies these conditions to the ASM list.
-.for _asm in ${MIASM}
-.if (${MDASM:R:M${_asm:R}} == "")
-.if (${NOASM:R:M${_asm:R}} == "")
-ASM+=$(_asm)
-.endif
-.endif
-.endfor
-
-SASM= ${ASM:S/.o/.S/}
-
-SPSEUDO= ${PSEUDO:S/.o/.S/}
-
-SRCS+= ${SASM} ${SPSEUDO}
+# emit empty assembly stubs for syscalls in dynamic libc
+SHARED_CFLAGS+= -D'_SYSCALL_BODY(name)='
SYM_MAPS+= ${LIBC_SRCTOP}/sys/Symbol.map
-# Generated files
-CLEANFILES+= ${SASM} ${SPSEUDO}
-
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \
- ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm"
-NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n'
-.else
-NOTE_GNU_STACK=''
-.endif
-
-${SASM}:
- printf '/* %sgenerated by libc/sys/Makefile.inc */\n' @ > ${.TARGET}
- printf '#include "compat.h"\n' >> ${.TARGET}
- printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' >> ${.TARGET}
- printf ${NOTE_GNU_STACK} >>${.TARGET}
-
-${SPSEUDO}:
- printf '/* %sgenerated by libc/sys/Makefile.inc */\n' @ > ${.TARGET}
- printf '#include "compat.h"\n' >> ${.TARGET}
- printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \
- >> ${.TARGET}
- printf ${NOTE_GNU_STACK} >>${.TARGET}
-
-MAN+= abort2.2 \
- accept.2 \
- access.2 \
- acct.2 \
- adjtime.2 \
- aio_cancel.2 \
- aio_error.2 \
- aio_fsync.2 \
- aio_mlock.2 \
- aio_read.2 \
- aio_return.2 \
- aio_suspend.2 \
- aio_waitcomplete.2 \
- aio_write.2 \
- bind.2 \
- bindat.2 \
- brk.2 \
- cap_enter.2 \
- cap_fcntls_limit.2 \
- cap_ioctls_limit.2 \
- cap_rights_limit.2 \
- chdir.2 \
- chflags.2 \
- chmod.2 \
- chown.2 \
- chroot.2 \
- clock_gettime.2 \
- close.2 \
- closefrom.2 \
- connect.2 \
- connectat.2 \
- copy_file_range.2 \
- cpuset.2 \
- cpuset_getaffinity.2 \
- cpuset_getdomain.2 \
- dup.2 \
- eventfd.2 \
- execve.2 \
- _exit.2 \
- extattr_get_file.2 \
- fcntl.2 \
- ffclock.2 \
- fhlink.2 \
- fhopen.2 \
- fhreadlink.2 \
- flock.2 \
- fork.2 \
- fspacectl.2 \
- fsync.2 \
- getdirentries.2 \
- getdtablesize.2 \
- getfh.2 \
- getfsstat.2 \
- getgid.2 \
- getgroups.2 \
- getitimer.2 \
- getlogin.2 \
- getloginclass.2 \
- getpeername.2 \
- getpgrp.2 \
- getpid.2 \
- getpriority.2 \
- getrandom.2 \
- getrlimit.2 \
- getrusage.2 \
- getsid.2 \
- getsockname.2 \
- getsockopt.2 \
- gettimeofday.2 \
- getuid.2 \
- intro.2 \
- ioctl.2 \
- issetugid.2 \
- jail.2 \
- kenv.2 \
- kill.2 \
- kldfind.2 \
- kldfirstmod.2 \
- kldload.2 \
- kldnext.2 \
- kldstat.2 \
- kldsym.2 \
- kldunload.2 \
- kqueue.2 \
- ktrace.2 \
- link.2 \
- lio_listio.2 \
- listen.2 \
- lseek.2 \
- madvise.2 \
- mincore.2 \
- minherit.2 \
- mkdir.2 \
- mkfifo.2 \
- mknod.2 \
- mlock.2 \
- mlockall.2 \
- mmap.2 \
- modfind.2 \
- modnext.2 \
- modstat.2 \
- mount.2 \
- mprotect.2 \
- mq_close.2 \
- mq_getattr.2 \
- mq_notify.2 \
- mq_open.2 \
- mq_receive.2 \
- mq_send.2 \
- mq_setattr.2 \
- mq_unlink.2 \
- msgctl.2 \
- msgget.2 \
- msgrcv.2 \
- msgsnd.2 \
- msync.2 \
- munmap.2 \
- nanosleep.2 \
- nfssvc.2 \
- ntp_adjtime.2 \
- open.2 \
- pathconf.2 \
- pdfork.2 \
- pipe.2 \
- poll.2 \
- posix_fadvise.2 \
- posix_fallocate.2 \
- posix_openpt.2 \
- procctl.2 \
- profil.2 \
- pselect.2 \
- ptrace.2 \
- quotactl.2 \
- rctl_add_rule.2 \
- read.2 \
- readlink.2 \
- reboot.2 \
- recv.2 \
- rename.2 \
- revoke.2 \
- rfork.2 \
- rmdir.2 \
- rtprio.2 \
- sched_get_priority_max.2 \
- sched_setparam.2 \
- sched_setscheduler.2 \
- sched_yield.2 \
- sctp_generic_recvmsg.2 \
- sctp_generic_sendmsg.2 \
- sctp_peeloff.2 \
- select.2 \
- semctl.2 \
- semget.2 \
- semop.2 \
- send.2 \
- setfib.2 \
- sendfile.2 \
- setgroups.2 \
- setpgid.2 \
- setregid.2 \
- setresuid.2 \
- setreuid.2 \
- setsid.2 \
- setuid.2 \
- shmat.2 \
- shmctl.2 \
- shmget.2 \
- shm_open.2 \
- shutdown.2 \
- sigaction.2 \
- sigaltstack.2 \
- sigfastblock.2 \
- sigpending.2 \
- sigprocmask.2 \
- sigqueue.2 \
- sigreturn.2 \
- sigstack.2 \
- sigsuspend.2 \
- sigwait.2 \
- sigwaitinfo.2 \
- socket.2 \
- socketpair.2 \
- stat.2 \
- statfs.2 \
- swapon.2 \
- symlink.2 \
- sync.2 \
- sysarch.2 \
- syscall.2 \
- thr_exit.2 \
- thr_kill.2 \
- thr_new.2 \
- thr_self.2 \
- thr_set_name.2 \
- thr_suspend.2 \
- thr_wake.2 \
- timer_create.2 \
- timer_delete.2 \
- timer_settime.2 \
- timerfd.2 \
- truncate.2 \
- umask.2 \
- undelete.2 \
- unlink.2 \
- utimensat.2 \
- utimes.2 \
- utrace.2 \
- uuidgen.2 \
- vfork.2 \
- wait.2 \
- write.2 \
- _umtx_op.2
+# Add the interposer wrappers
+SRCS+= ${INTERPOSED:S/$/.c/}
-MLINKS+=aio_read.2 aio_readv.2
-MLINKS+=aio_write.2 aio_writev.2
-MLINKS+=accept.2 accept4.2
-MLINKS+=access.2 eaccess.2 \
- access.2 faccessat.2
-MLINKS+=brk.2 sbrk.2
-MLINKS+=cap_enter.2 cap_getmode.2
-MLINKS+=cap_fcntls_limit.2 cap_fcntls_get.2
-MLINKS+=cap_ioctls_limit.2 cap_ioctls_get.2
-MLINKS+=chdir.2 fchdir.2
-MLINKS+=chflags.2 chflagsat.2 \
- chflags.2 fchflags.2 \
- chflags.2 lchflags.2
-MLINKS+=chmod.2 fchmod.2 \
- chmod.2 fchmodat.2 \
- chmod.2 lchmod.2
-MLINKS+=chown.2 fchown.2 \
- chown.2 fchownat.2 \
- chown.2 lchown.2
-MLINKS+=clock_gettime.2 clock_getres.2 \
- clock_gettime.2 clock_settime.2
-MLINKS+=closefrom.2 close_range.2
-MLINKS+=nanosleep.2 clock_nanosleep.2
-MLINKS+=cpuset.2 cpuset_getid.2 \
- cpuset.2 cpuset_setid.2
-MLINKS+=cpuset_getaffinity.2 cpuset_setaffinity.2
-MLINKS+=cpuset_getdomain.2 cpuset_setdomain.2
-MLINKS+=dup.2 dup2.2
-MLINKS+=eventfd.2 eventfd_read.3 \
- eventfd.2 eventfd_write.3
-MLINKS+=execve.2 fexecve.2
-MLINKS+=extattr_get_file.2 extattr.2 \
- extattr_get_file.2 extattr_delete_fd.2 \
- extattr_get_file.2 extattr_delete_file.2 \
- extattr_get_file.2 extattr_delete_link.2 \
- extattr_get_file.2 extattr_get_fd.2 \
- extattr_get_file.2 extattr_get_link.2 \
- extattr_get_file.2 extattr_list_fd.2 \
- extattr_get_file.2 extattr_list_file.2 \
- extattr_get_file.2 extattr_list_link.2 \
- extattr_get_file.2 extattr_set_fd.2 \
- extattr_get_file.2 extattr_set_file.2 \
- extattr_get_file.2 extattr_set_link.2
-MLINKS+=ffclock.2 ffclock_getcounter.2 \
- ffclock.2 ffclock_getestimate.2 \
- ffclock.2 ffclock_setestimate.2
-MLINKS+=fhlink.2 fhlinkat.2
-MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2
-MLINKS+=fork.2 _Fork.2
-MLINKS+=fsync.2 fdatasync.2
-MLINKS+=getdirentries.2 getdents.2
-MLINKS+=getfh.2 lgetfh.2 \
- getfh.2 getfhat.2
-MLINKS+=getgid.2 getegid.2
-MLINKS+=getitimer.2 setitimer.2
-MLINKS+=getlogin.2 getlogin_r.3
-MLINKS+=getlogin.2 setlogin.2
-MLINKS+=getloginclass.2 setloginclass.2
-MLINKS+=getpgrp.2 getpgid.2
-MLINKS+=getpid.2 getppid.2
-MLINKS+=getpriority.2 setpriority.2
-MLINKS+=getrlimit.2 setrlimit.2
-MLINKS+=getsockopt.2 setsockopt.2
-MLINKS+=gettimeofday.2 settimeofday.2
-MLINKS+=getuid.2 geteuid.2
-MLINKS+=intro.2 errno.2
-MLINKS+=jail.2 jail_attach.2 \
- jail.2 jail_get.2 \
- jail.2 jail_remove.2 \
- jail.2 jail_set.2
-MLINKS+=kldunload.2 kldunloadf.2
-MLINKS+=kqueue.2 kevent.2 \
- kqueue.2 kqueuex.2 \
- kqueue.2 EV_SET.3
-MLINKS+=link.2 linkat.2
-MLINKS+=madvise.2 posix_madvise.2
-MLINKS+=mkdir.2 mkdirat.2
-MLINKS+=mkfifo.2 mkfifoat.2
-MLINKS+=mknod.2 mknodat.2
-MLINKS+=mlock.2 munlock.2
-MLINKS+=mlockall.2 munlockall.2
-MLINKS+=modnext.2 modfnext.2
-MLINKS+=mount.2 nmount.2 \
- mount.2 unmount.2
-MLINKS+=mq_receive.2 mq_timedreceive.2
-MLINKS+=mq_send.2 mq_timedsend.2
-MLINKS+=ntp_adjtime.2 ntp_gettime.2
-MLINKS+=open.2 openat.2
-MLINKS+=pathconf.2 fpathconf.2
-MLINKS+=pathconf.2 lpathconf.2
-MLINKS+=pdfork.2 pdgetpid.2\
- pdfork.2 pdkill.2
-MLINKS+=pipe.2 pipe2.2
-MLINKS+=poll.2 ppoll.2
-MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \
- rctl_add_rule.2 rctl_get_racct.2 \
- rctl_add_rule.2 rctl_get_rules.2 \
- rctl_add_rule.2 rctl_remove_rule.2
-MLINKS+=read.2 pread.2 \
- read.2 preadv.2 \
- read.2 readv.2
-MLINKS+=readlink.2 readlinkat.2
-MLINKS+=recv.2 recvfrom.2 \
- recv.2 recvmsg.2
-MLINKS+=rename.2 renameat.2
-MLINKS+=rtprio.2 rtprio_thread.2
-MLINKS+=sched_get_priority_max.2 sched_get_priority_min.2 \
- sched_get_priority_max.2 sched_rr_get_interval.2
-MLINKS+=sched_setparam.2 sched_getparam.2
-MLINKS+=sched_setscheduler.2 sched_getscheduler.2
-MLINKS+=select.2 FD_CLR.3 \
- select.2 FD_ISSET.3 \
- select.2 FD_SET.3 \
- select.2 FD_ZERO.3
-MLINKS+=send.2 sendmsg.2 \
- send.2 sendto.2
-MLINKS+=setpgid.2 setpgrp.2
-MLINKS+=setresuid.2 getresgid.2 \
- setresuid.2 getresuid.2 \
- setresuid.2 setresgid.2
-MLINKS+=setuid.2 setegid.2 \
- setuid.2 seteuid.2 \
- setuid.2 setgid.2
-MLINKS+=shmat.2 shmdt.2
-MLINKS+=shm_open.2 memfd_create.3 \
- shm_open.2 shm_create_largepage.3 \
- shm_open.2 shm_unlink.2 \
- shm_open.2 shm_rename.2
-MLINKS+=sigwaitinfo.2 sigtimedwait.2
-MLINKS+=stat.2 fstat.2 \
- stat.2 fstatat.2 \
- stat.2 lstat.2
-MLINKS+=statfs.2 fstatfs.2
-MLINKS+=swapon.2 swapoff.2
-MLINKS+=symlink.2 symlinkat.2
-MLINKS+=syscall.2 __syscall.2
-MLINKS+=timer_settime.2 timer_getoverrun.2 \
- timer_settime.2 timer_gettime.2
-MLINKS+=timerfd.2 timerfd_create.2 \
- timerfd.2 timerfd_gettime.2 \
- timerfd.2 timerfd_settime.2
-MLINKS+=thr_kill.2 thr_kill2.2
-MLINKS+=truncate.2 ftruncate.2
-MLINKS+=unlink.2 unlinkat.2
-MLINKS+=unlink.2 funlinkat.2
-MLINKS+=utimensat.2 futimens.2
-MLINKS+=utimes.2 futimes.2 \
- utimes.2 futimesat.2 \
- utimes.2 lutimes.2
-MLINKS+=wait.2 wait3.2 \
- wait.2 wait4.2 \
- wait.2 waitpid.2 \
- wait.2 waitid.2 \
- wait.2 wait6.2
-MLINKS+=write.2 pwrite.2 \
- write.2 pwritev.2 \
- write.2 writev.2
+# Pseudo system calls implemented atop other interfaces.
+SRCS+= \
+ POSIX2x_Fork.c \
+ brk.c \
+ closefrom.c \
+ compat-stub.c \
+ creat.c \
+ getdents.c \
+ lockf.c \
+ lstat.c \
+ mknod.c \
+ pipe.c \
+ recv.c \
+ recvmmsg.c \
+ send.c \
+ sendmmsg.c \
+ shm_open.c \
+ stat.c \
+ vadvise.c \
+ wait.c \
+ wait3.c \
+ waitid.c \
+ waitpid.c
diff --git a/lib/libc/sys/POSIX2x_Fork.c b/lib/libc/sys/POSIX2x_Fork.c
index 4745f1be42b5..766bd4000036 100644
--- a/lib/libc/sys/POSIX2x_Fork.c
+++ b/lib/libc/sys/POSIX2x_Fork.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <unistd.h>
#include "libc_private.h"
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index 7937661e3787..32b1b0ecee05 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -1,376 +1,53 @@
-/*
- */
-
-/*
- * It'd be nice to automatically generate the syscall symbols, but we
- * don't know to what version they will eventually belong to, so for now
- * it has to be manual.
- */
FBSD_1.0 {
- __acl_aclcheck_fd;
- __acl_aclcheck_file;
- __acl_aclcheck_link;
- __acl_delete_fd;
- __acl_delete_file;
- __acl_delete_link;
- __acl_get_fd;
- __acl_get_file;
- __acl_get_link;
- __acl_set_fd;
- __acl_set_file;
- __acl_set_link;
- __getcwd;
- __mac_execve;
- __mac_get_fd;
- __mac_get_file;
- __mac_get_link;
- __mac_get_pid;
- __mac_get_proc;
- __mac_set_fd;
- __mac_set_file;
- __mac_set_link;
- __mac_set_proc;
- __setugid;
- __syscall;
- __sysctl;
- _umtx_op;
- abort2;
accept;
- access;
- acct;
- adjtime;
- aio_cancel;
- aio_error;
- aio_fsync;
- aio_read;
- aio_return;
aio_suspend;
- aio_waitcomplete;
- aio_write;
- audit;
- auditctl;
- auditon;
- bind;
- chdir;
- chflags;
- chmod;
- chown;
- chroot;
- clock_getres;
- clock_gettime;
- clock_settime;
close;
connect;
- dup;
- dup2;
- eaccess;
- execve;
- extattr_delete_fd;
- extattr_delete_file;
- extattr_delete_link;
- extattr_get_fd;
- extattr_get_file;
- extattr_get_link;
- extattr_list_fd;
- extattr_list_file;
- extattr_list_link;
- extattr_set_fd;
- extattr_set_file;
- extattr_set_link;
- extattrctl;
- fchdir;
- fchflags;
- fchmod;
- fchown;
fcntl;
- fhopen;
- flock;
fork;
- fpathconf;
fsync;
- futimes;
- getaudit;
- getaudit_addr;
- getauid;
- getcontext;
- getdtablesize;
- getegid;
- geteuid;
- getfh;
- getgid;
- getgroups;
- getitimer;
- getpeername;
- getpgid;
- getpgrp;
- getpid;
- getppid;
- getpriority;
- getresgid;
- getresuid;
- getrlimit;
- getrusage;
- getsid;
- getsockname;
- getsockopt;
- gettimeofday;
- getuid;
- ioctl;
- issetugid;
- jail;
- jail_attach;
- kenv;
- kill;
- kldfind;
- kldfirstmod;
- kldload;
- kldnext;
- kldstat;
- kldsym;
- kldunload;
- kldunloadf;
- kqueue;
- kmq_notify; /* Do we want these to be public interfaces? */
- kmq_open; /* librt uses them to provide mq_xxx. */
- kmq_setattr;
- kmq_timedreceive;
- kmq_timedsend;
- kmq_unlink;
- ksem_close;
- ksem_destroy;
- ksem_getvalue;
- ksem_init;
- ksem_open;
- ksem_post;
- ksem_timedwait;
- ksem_trywait;
- ksem_unlink;
- ksem_wait;
- ktrace;
- lchflags;
- lchmod;
- lchown;
- lgetfh;
- link;
- lio_listio;
- listen;
- lutimes;
- mac_syscall;
- madvise;
- mincore;
- minherit;
- mkdir;
- mkfifo;
- mlock;
- mlockall;
- modfind;
- modfnext;
- modnext;
- modstat;
- mount;
- mprotect;
- msgget;
- msgrcv;
- msgsnd;
- msgsys;
msync;
- munlock;
- munlockall;
- munmap;
nanosleep;
- nfssvc;
- nmount;
- ntp_adjtime;
- ntp_gettime;
open;
- pathconf;
pipe;
poll;
- posix_openpt;
- preadv;
- profil;
pselect;
ptrace;
- pwritev;
- quotactl;
read;
- readlink;
readv;
- reboot;
recvfrom;
recvmsg;
- rename;
- revoke;
- rfork;
- rmdir;
- rtprio;
- rtprio_thread;
- sched_get_priority_max;
- sched_get_priority_min;
- sched_getparam;
- sched_getscheduler;
- sched_rr_get_interval;
- sched_setparam;
- sched_setscheduler;
- sched_yield;
select;
- semget;
- semop;
- semsys;
- sendfile;
sendmsg;
sendto;
- setaudit;
- setaudit_addr;
- setauid;
- setegid;
- seteuid;
- setgid;
- setgroups;
- setitimer;
- setlogin;
- setpgid;
- setpriority;
- setregid;
- setresgid;
- setresuid;
- setreuid;
- setrlimit;
- setsid;
- setsockopt;
- settimeofday;
- setuid;
shm_open;
- shm_unlink;
- shmat;
- shmdt;
- shmget;
- shmsys;
- shutdown;
sigaction;
- sigaltstack;
- sigpending;
sigprocmask;
- sigqueue;
- sigreturn;
sigsuspend;
sigtimedwait;
sigwait;
sigwaitinfo;
- socket;
- socketpair;
- swapon;
- symlink;
- sync;
- sysarch;
- syscall;
- thr_create;
- thr_exit;
- thr_kill;
- thr_kill2;
- thr_new;
- thr_self;
- thr_set_name;
- thr_suspend;
- thr_wake;
- ktimer_create; /* Do we want these to be public interfaces? */
- ktimer_delete; /* librt uses them to provide timer_xxx. */
- ktimer_getoverrun;
- ktimer_gettime;
- ktimer_settime;
- umask;
- undelete;
- unlink;
- unmount;
- utimes;
- utrace;
- uuidgen;
vadvise;
wait4;
write;
writev;
-
- __error;
- ftruncate;
- lseek;
- mmap;
- pread;
- pwrite;
- truncate;
};
FBSD_1.1 {
- __semctl;
closefrom;
- cpuset;
- cpuset_getid;
- cpuset_setid;
- cpuset_getaffinity;
- cpuset_setaffinity;
- faccessat;
- fchmodat;
- fchownat;
- fexecve;
- futimesat;
- jail_get;
- jail_set;
- jail_remove;
- linkat;
- lpathconf;
- mkdirat;
- mkfifoat;
- msgctl;
- readlinkat;
- renameat;
- setfib;
- shmctl;
- symlinkat;
- unlinkat;
};
FBSD_1.2 {
- cap_enter;
- cap_getmode;
- getloginclass;
pdfork;
- pdgetpid;
- pdkill;
- posix_fallocate;
- rctl_get_racct;
- rctl_get_rules;
- rctl_get_limits;
- rctl_add_rule;
- rctl_remove_rule;
- setloginclass;
};
FBSD_1.3 {
accept4;
- aio_mlock;
- bindat;
- cap_fcntls_get;
- cap_fcntls_limit;
- cap_ioctls_get;
- cap_ioctls_limit;
- __cap_rights_get;
- cap_rights_limit;
- cap_sandboxed;
- chflagsat;
- clock_getcpuclockid2;
- connectat;
- ffclock_getcounter;
- ffclock_getestimate;
- ffclock_setestimate;
- pipe2;
- posix_fadvise;
- procctl;
wait6;
};
FBSD_1.4 {
- futimens;
ppoll;
- utimensat;
numa_setaffinity;
numa_getaffinity;
sendmmsg;
@@ -380,676 +57,17 @@ FBSD_1.4 {
FBSD_1.5 {
clock_nanosleep;
fdatasync;
- fhstat;
- fhstatfs;
- fstat;
- fstatat;
- fstatfs;
getdents;
- getdirentries;
- getfsstat;
- getrandom;
kevent;
lstat;
mknod;
- mknodat;
stat;
- statfs;
- cpuset_getdomain;
- cpuset_setdomain;
};
FBSD_1.6 {
- __sysctlbyname;
- aio_readv;
- aio_writev;
- close_range;
- copy_file_range;
- fhlink;
- fhlinkat;
- fhreadlink;
- getfhat;
- funlinkat;
- memfd_create;
shm_create_largepage;
- shm_rename;
};
FBSD_1.7 {
_Fork;
- fspacectl;
- kqueuex;
- membarrier;
- swapoff;
- timerfd_create;
- timerfd_gettime;
- timerfd_settime;
-};
-
-FBSDprivate_1.0 {
- ___acl_aclcheck_fd;
- __sys___acl_aclcheck_fd;
- ___acl_aclcheck_file;
- __sys___acl_aclcheck_file;
- ___acl_aclcheck_link;
- __sys___acl_aclcheck_link;
- ___acl_delete_fd;
- __sys___acl_delete_fd;
- ___acl_delete_file;
- __sys___acl_delete_file;
- ___acl_delete_link;
- __sys___acl_delete_link;
- ___acl_get_fd;
- __sys___acl_get_fd;
- ___acl_get_file;
- __sys___acl_get_file;
- ___acl_get_link;
- __sys___acl_get_link;
- ___acl_set_fd;
- __sys___acl_set_fd;
- ___acl_set_file;
- __sys___acl_set_file;
- ___acl_set_link;
- __sys___acl_set_link;
- ___getcwd;
- __sys___getcwd;
- ___mac_execve;
- __sys___mac_execve;
- ___mac_get_fd;
- __sys___mac_get_fd;
- ___mac_get_file;
- __sys___mac_get_file;
- ___mac_get_link;
- __sys___mac_get_link;
- ___mac_get_pid;
- __sys___mac_get_pid;
- ___mac_get_proc;
- __sys___mac_get_proc;
- ___mac_set_fd;
- __sys___mac_set_fd;
- ___mac_set_file;
- __sys___mac_set_file;
- ___mac_set_link;
- __sys___mac_set_link;
- ___mac_set_proc;
- __sys___mac_set_proc;
- ___semctl;
- __sys___semctl;
- ___setugid;
- __sys___setugid;
- ___syscall;
- __sys___syscall;
- ___sysctl;
- __sys___sysctl;
- __umtx_op;
- __sys__umtx_op;
- _abort2;
- __sys_abort2;
- _accept;
- __sys_accept;
- _accept4;
- __sys_accept4;
- _access;
- __sys_access;
- _acct;
- __sys_acct;
- _adjtime;
- __sys_adjtime;
- __sys_aio_cancel;
- __sys_aio_error;
- __sys_aio_fsync;
- __sys_aio_read;
- __sys_aio_readv;
- __sys_aio_return;
- __sys_aio_suspend;
- __sys_aio_waitcomplete;
- __sys_aio_write;
- __sys_aio_writev;
- _audit;
- __sys_audit;
- _auditctl;
- __sys_auditctl;
- _auditon;
- __sys_auditon;
- _bind;
- __sys_bind;
- _chdir;
- __sys_chdir;
- _chflags;
- __sys_chflags;
- _chmod;
- __sys_chmod;
- _chown;
- __sys_chown;
- _chroot;
- __sys_chroot;
- _clock_getcpuclockid2;
- __sys_clock_getcpuclockid2;
- _clock_getres;
- __sys_clock_getres;
- _clock_gettime;
- __sys_clock_gettime;
- __sys_clock_nanosleep;
- _clock_settime;
- __sys_clock_settime;
- _close;
- __sys_close;
- _connect;
- __sys_connect;
- _cpuset;
- __sys_cpuset;
- _cpuset_getid;
- __sys_cpuset_getid;
- _cpuset_setid;
- __sys_cpuset_setid;
- _cpuset_getaffinity;
- __sys_cpuset_getaffinity;
- _cpuset_setaffinity;
- __sys_cpuset_setaffinity;
- _dup;
- __sys_dup;
- _dup2;
- __sys_dup2;
- _eaccess;
- __sys_eaccess;
- _execve;
- __sys_execve;
- _extattr_delete_fd;
- __sys_extattr_delete_fd;
- _extattr_delete_file;
- __sys_extattr_delete_file;
- _extattr_delete_link;
- __sys_extattr_delete_link;
- _extattr_get_fd;
- __sys_extattr_get_fd;
- _extattr_get_file;
- __sys_extattr_get_file;
- _extattr_get_link;
- __sys_extattr_get_link;
- _extattr_list_fd;
- __sys_extattr_list_fd;
- _extattr_list_file;
- __sys_extattr_list_file;
- _extattr_list_link;
- __sys_extattr_list_link;
- _extattr_set_fd;
- __sys_extattr_set_fd;
- _extattr_set_file;
- __sys_extattr_set_file;
- _extattr_set_link;
- __sys_extattr_set_link;
- _extattrctl;
- __sys_extattrctl;
- __sys_sigfastblock;
- _fchdir;
- __sys_fchdir;
- _fchflags;
- __sys_fchflags;
- _fchmod;
- __sys_fchmod;
- _fchown;
- __sys_fchown;
- _fcntl;
- __sys_fcntl;
- __fcntl_compat;
- _fhopen;
- __sys_fhopen;
- _fhstat;
- __sys_fhstat;
- _fhstatfs;
- __sys_fhstatfs;
- _flock;
- __sys_flock;
- _fork;
- __sys_fork;
- _fpathconf;
- __sys_fpathconf;
- _fstat;
- __sys_fstat;
- _fstatfs;
- __sys_fstatfs;
- _fsync;
- __sys_fsync;
- _fdatasync;
- __sys_fdatasync;
- _futimes;
- __sys_futimes;
- _getaudit;
- __sys_getaudit;
- _getaudit_addr;
- __sys_getaudit_addr;
- _getauid;
- __sys_getauid;
- _getcontext;
- __sys_getcontext;
- _getdirentries;
- __sys_getdirentries;
- _getdtablesize;
- __sys_getdtablesize;
- _getegid;
- __sys_getegid;
- _geteuid;
- __sys_geteuid;
- _getfh;
- __sys_getfh;
- _getfsstat;
- __sys_getfsstat;
- _getgid;
- __sys_getgid;
- _getgroups;
- __sys_getgroups;
- _getitimer;
- __sys_getitimer;
- _getpeername;
- __sys_getpeername;
- _getpgid;
- __sys_getpgid;
- _getpgrp;
- __sys_getpgrp;
- _getpid;
- __sys_getpid;
- _getppid;
- __sys_getppid;
- _getpriority;
- __sys_getpriority;
- _getresgid;
- __sys_getresgid;
- _getresuid;
- __sys_getresuid;
- _getrlimit;
- __sys_getrlimit;
- _getrusage;
- __sys_getrusage;
- _getsid;
- __sys_getsid;
- _getsockname;
- __sys_getsockname;
- _getsockopt;
- __sys_getsockopt;
- _gettimeofday;
- __sys_gettimeofday;
- _getuid;
- __sys_getuid;
- _ioctl;
- __sys_ioctl;
- _issetugid;
- __sys_issetugid;
- _jail;
- __sys_jail;
- _jail_attach;
- __sys_jail_attach;
- _kenv;
- __sys_kenv;
- _kevent;
- __sys_kevent;
- _kill;
- __sys_kill;
- _kldfind;
- __sys_kldfind;
- _kldfirstmod;
- __sys_kldfirstmod;
- _kldload;
- __sys_kldload;
- _kldnext;
- __sys_kldnext;
- _kldstat;
- __sys_kldstat;
- _kldsym;
- __sys_kldsym;
- _kldunload;
- __sys_kldunload;
- _kldunloadf;
- __sys_kldunloadf;
- _kmq_notify;
- __sys_kmq_notify;
- _kmq_open;
- __sys_kmq_open;
- _kmq_setattr;
- __sys_kmq_setattr;
- _kmq_timedreceive;
- __sys_kmq_timedreceive;
- _kmq_timedsend;
- __sys_kmq_timedsend;
- _kmq_unlink;
- __sys_kmq_unlink;
- _kqueue;
- __sys_kqueue;
- _ksem_close;
- __sys_ksem_close;
- _ksem_destroy;
- __sys_ksem_destroy;
- _ksem_getvalue;
- __sys_ksem_getvalue;
- _ksem_init;
- __sys_ksem_init;
- _ksem_open;
- __sys_ksem_open;
- _ksem_post;
- __sys_ksem_post;
- _ksem_timedwait;
- __sys_ksem_timedwait;
- _ksem_trywait;
- __sys_ksem_trywait;
- _ksem_unlink;
- __sys_ksem_unlink;
- _ksem_wait;
- __sys_ksem_wait;
- _ktrace;
- __sys_ktrace;
- _lchflags;
- __sys_lchflags;
- _lchmod;
- __sys_lchmod;
- _lchown;
- __sys_lchown;
- _lgetfh;
- __sys_lgetfh;
- _link;
- __sys_link;
- __sys_lio_listio;
- _listen;
- __sys_listen;
- _lutimes;
- __sys_lutimes;
- _mac_syscall;
- __sys_mac_syscall;
- _madvise;
- __sys_madvise;
- _mincore;
- __sys_mincore;
- _minherit;
- __sys_minherit;
- _mkdir;
- __sys_mkdir;
- _mkfifo;
- __sys_mkfifo;
- _mknod;
- __sys_mknod;
- _mlock;
- __sys_mlock;
- _mlockall;
- __sys_mlockall;
- _mmap;
- __sys_mmap;
- _modfind;
- __sys_modfind;
- _modfnext;
- __sys_modfnext;
- _modnext;
- __sys_modnext;
- _modstat;
- __sys_modstat;
- _mount;
- __sys_mount;
- _mprotect;
- __sys_mprotect;
- _msgctl;
- __sys_msgctl;
- _msgget;
- __sys_msgget;
- _msgrcv;
- __sys_msgrcv;
- _msgsnd;
- __sys_msgsnd;
- _msgsys;
- __sys_msgsys;
- _msync;
- __sys_msync;
- _munlock;
- __sys_munlock;
- _munlockall;
- __sys_munlockall;
- _munmap;
- __sys_munmap;
- _nanosleep;
- __sys_nanosleep;
- _nfssvc;
- __sys_nfssvc;
- _nmount;
- __sys_nmount;
- _ntp_adjtime;
- __sys_ntp_adjtime;
- _ntp_gettime;
- __sys_ntp_gettime;
- _open;
- __sys_open;
- _openat;
- __sys_openat;
- _pathconf;
- __sys_pathconf;
- __sys_pdfork;
- _pipe;
- __sys_pipe;
- _poll;
- __sys_poll;
- _ppoll;
- __sys_ppoll;
- _preadv;
- __sys_preadv;
- _procctl;
- __sys_procctl;
- _profil;
- __sys_profil;
- _pselect;
- __sys_pselect;
- _ptrace;
- __sys_ptrace;
- _pwritev;
- __sys_pwritev;
- _quotactl;
- __sys_quotactl;
- _read;
- __sys_read;
- _readlink;
- __sys_readlink;
- _readv;
- __sys_readv;
- _reboot;
- __sys_reboot;
- _recvfrom;
- __sys_recvfrom;
- _recvmsg;
- __sys_recvmsg;
- _rename;
- __sys_rename;
- _revoke;
- __sys_revoke;
- _rfork;
- __sys_rfork;
- _rmdir;
- __sys_rmdir;
- _rtprio;
- __sys_rtprio;
- _rtprio_thread;
- __sys_rtprio_thread;
- _sched_get_priority_max;
- __sys_sched_get_priority_max;
- _sched_get_priority_min;
- __sys_sched_get_priority_min;
- _sched_getparam;
- __sys_sched_getparam;
- _sched_getscheduler;
- __sys_sched_getscheduler;
- _sched_rr_get_interval;
- __sys_sched_rr_get_interval;
- _sched_setparam;
- __sys_sched_setparam;
- _sched_setscheduler;
- __sys_sched_setscheduler;
- _sched_yield;
- __sys_sched_yield;
- _select;
- __sys_select;
- _semget;
- __sys_semget;
- _semop;
- __sys_semop;
- _semsys;
- __sys_semsys;
- _sendfile;
- __sys_sendfile;
- _sendmsg;
- __sys_sendmsg;
- _sendto;
- __sys_sendto;
- _setaudit;
- __sys_setaudit;
- _setaudit_addr;
- __sys_setaudit_addr;
- _setauid;
- __sys_setauid;
- _setcontext;
- __sys_setcontext;
- _setegid;
- __sys_setegid;
- _seteuid;
- __sys_seteuid;
- _setgid;
- __sys_setgid;
- _setgroups;
- __sys_setgroups;
- _setitimer;
- __sys_setitimer;
- _setlogin;
- __sys_setlogin;
- _setpgid;
- __sys_setpgid;
- _setpriority;
- __sys_setpriority;
- _setregid;
- __sys_setregid;
- _setresgid;
- __sys_setresgid;
- _setresuid;
- __sys_setresuid;
- _setreuid;
- __sys_setreuid;
- _setrlimit;
- __sys_setrlimit;
- _setsid;
- __sys_setsid;
- _setsockopt;
- __sys_setsockopt;
- _settimeofday;
- __sys_settimeofday;
- _setuid;
- __sys_setuid;
- _shm_open;
- __sys_shm_open;
- __sys_shm_open2;
- _shm_unlink;
- __sys_shm_unlink;
- _shmat;
- __sys_shmat;
- _shmctl;
- __sys_shmctl;
- _shmdt;
- __sys_shmdt;
- _shmget;
- __sys_shmget;
- _shmsys;
- __sys_shmsys;
- _shutdown;
- __sys_shutdown;
- _sigaction;
- __sys_sigaction;
- _sigaltstack;
- __sys_sigaltstack;
- _sigpending;
- __sys_sigpending;
- _sigprocmask;
- __sys_sigprocmask;
- _sigqueue;
- __sys_sigqueue;
- _sigreturn;
- __sys_sigreturn;
- _sigsuspend;
- __sys_sigsuspend;
- _sigtimedwait;
- __sys_sigtimedwait;
- _sigwait;
- __sigwait;
- __sys_sigwait;
- _sigwaitinfo;
- __sys_sigwaitinfo;
- _socket;
- __sys_socket;
- _socketpair;
- __sys_socketpair;
- _statfs;
- __sys_statfs;
- _swapcontext;
- __sys_swapcontext;
- _swapoff;
- __sys_swapoff;
- _swapon;
- __sys_swapon;
- _symlink;
- __sys_symlink;
- _sync;
- __sys_sync;
- _sysarch;
- __sys_sysarch;
- _syscall;
- __sys_syscall;
- _thr_create;
- __sys_thr_create;
- _thr_exit;
- __sys_thr_exit;
- _thr_kill;
- __sys_thr_kill;
- _thr_kill2;
- __sys_thr_kill2;
- _thr_new;
- __sys_thr_new;
- _thr_self;
- __sys_thr_self;
- _thr_set_name;
- __sys_thr_set_name;
- _thr_suspend;
- __sys_thr_suspend;
- _thr_wake;
- __sys_thr_wake;
- _ktimer_create;
- __sys_ktimer_create;
- _ktimer_delete;
- __sys_ktimer_delete;
- _ktimer_getoverrun;
- __sys_ktimer_getoverrun;
- _ktimer_gettime;
- __sys_ktimer_gettime;
- _ktimer_settime;
- __sys_ktimer_settime;
- _umask;
- __sys_umask;
- _undelete;
- __sys_undelete;
- _unlink;
- __sys_unlink;
- _unmount;
- __sys_unmount;
- _utimes;
- __sys_utimes;
- _utrace;
- __sys_utrace;
- _uuidgen;
- __sys_uuidgen;
- _wait4;
- __sys_wait4;
- _wait6;
- __sys_wait6;
- _write;
- __sys_write;
- _writev;
- __sys_writev;
- __set_error_selector;
- nlm_syscall;
- gssd_syscall;
- __libc_interposing_slot;
- __libc_sigwait;
- _cpuset_getdomain;
- __sys_cpuset_getdomain;
- _cpuset_setdomain;
- __sys_cpuset_setdomain;
- rpctls_syscall;
};
diff --git a/lib/libc/sys/__error.c b/lib/libc/sys/__error.c
deleted file mode 100644
index d37527052585..000000000000
--- a/lib/libc/sys/__error.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 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.
- */
-
-#include <sys/cdefs.h>
-#include "libc_private.h"
-
-extern int errno;
-
-static int *
-__error_unthreaded(void)
-{
-
- return (&errno);
-}
-
-static int *(*__error_selector)(void) = __error_unthreaded;
-
-void
-__set_error_selector(int *(*arg)(void))
-{
-
- __error_selector = arg;
-}
-
-int *
-__error(void)
-{
-
- return (__error_selector());
-}
diff --git a/lib/libc/sys/__vdso_gettimeofday.c b/lib/libc/sys/__vdso_gettimeofday.c
deleted file mode 100644
index f256849562dd..000000000000
--- a/lib/libc/sys/__vdso_gettimeofday.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/elf.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <strings.h>
-#include <time.h>
-#include <machine/atomic.h>
-#include "libc_private.h"
-
-static int
-tc_delta(const struct vdso_timehands *th, u_int *delta)
-{
- int error;
- u_int tc;
-
- error = __vdso_gettc(th, &tc);
- if (error == 0)
- *delta = (tc - th->th_offset_count) & th->th_counter_mask;
- return (error);
-}
-
-/*
- * Calculate the absolute or boot-relative time from the
- * machine-specific fast timecounter and the published timehands
- * structure read from the shared page.
- *
- * The lockless reading scheme is similar to the one used to read the
- * in-kernel timehands, see sys/kern/kern_tc.c:binuptime(). This code
- * is based on the kernel implementation.
- */
-static int
-binuptime(struct bintime *bt, struct vdso_timekeep *tk, bool abs)
-{
- struct vdso_timehands *th;
- uint32_t curr, gen;
- uint64_t scale, x;
- u_int delta, scale_bits;
- int error;
-
- do {
- if (!tk->tk_enabled)
- return (ENOSYS);
-
- curr = atomic_load_acq_32(&tk->tk_current);
- th = &tk->tk_th[curr];
- gen = atomic_load_acq_32(&th->th_gen);
- *bt = th->th_offset;
- error = tc_delta(th, &delta);
- if (error == EAGAIN)
- continue;
- if (error != 0)
- return (error);
- scale = th->th_scale;
-#ifdef _LP64
- scale_bits = flsl(scale);
-#else
- scale_bits = flsll(scale);
-#endif
- if (__predict_false(scale_bits + fls(delta) > 63)) {
- x = (scale >> 32) * delta;
- scale &= 0xffffffff;
- bt->sec += x >> 32;
- bintime_addx(bt, x << 32);
- }
- bintime_addx(bt, scale * delta);
- if (abs)
- bintime_add(bt, &th->th_boottime);
-
- /*
- * Ensure that the load of th_offset is completed
- * before the load of th_gen.
- */
- atomic_thread_fence_acq();
- } while (curr != tk->tk_current || gen == 0 || gen != th->th_gen);
- return (0);
-}
-
-static int
-getnanouptime(struct bintime *bt, struct vdso_timekeep *tk)
-{
- struct vdso_timehands *th;
- uint32_t curr, gen;
-
- do {
- if (!tk->tk_enabled)
- return (ENOSYS);
-
- curr = atomic_load_acq_32(&tk->tk_current);
- th = &tk->tk_th[curr];
- gen = atomic_load_acq_32(&th->th_gen);
- *bt = th->th_offset;
-
- /*
- * Ensure that the load of th_offset is completed
- * before the load of th_gen.
- */
- atomic_thread_fence_acq();
- } while (curr != tk->tk_current || gen == 0 || gen != th->th_gen);
- return (0);
-}
-
-static struct vdso_timekeep *tk;
-
-#pragma weak __vdso_gettimeofday
-int
-__vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
-{
- struct bintime bt;
- int error;
-
- if (tz != NULL)
- return (ENOSYS);
- if (tk == NULL) {
- error = __vdso_gettimekeep(&tk);
- if (error != 0 || tk == NULL)
- return (ENOSYS);
- }
- if (tk->tk_ver != VDSO_TK_VER_CURR)
- return (ENOSYS);
- error = binuptime(&bt, tk, true);
- if (error != 0)
- return (error);
- bintime2timeval(&bt, tv);
- return (0);
-}
-
-#pragma weak __vdso_clock_gettime
-int
-__vdso_clock_gettime(clockid_t clock_id, struct timespec *ts)
-{
- struct bintime bt;
- int error;
-
- if (tk == NULL) {
- error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk));
- if (error != 0 || tk == NULL)
- return (ENOSYS);
- }
- if (tk->tk_ver != VDSO_TK_VER_CURR)
- return (ENOSYS);
- switch (clock_id) {
- case CLOCK_REALTIME:
- case CLOCK_REALTIME_PRECISE:
- case CLOCK_REALTIME_FAST:
- case CLOCK_SECOND:
- error = binuptime(&bt, tk, true);
- break;
- case CLOCK_MONOTONIC:
- case CLOCK_MONOTONIC_PRECISE:
- case CLOCK_UPTIME:
- case CLOCK_UPTIME_PRECISE:
- error = binuptime(&bt, tk, false);
- break;
- case CLOCK_MONOTONIC_FAST:
- case CLOCK_UPTIME_FAST:
- error = getnanouptime(&bt, tk);
- break;
- default:
- error = ENOSYS;
- break;
- }
- if (error != 0)
- return (error);
- bintime2timespec(&bt, ts);
- if (clock_id == CLOCK_SECOND)
- ts->tv_nsec = 0;
- return (0);
-}
diff --git a/lib/libc/sys/_exit.2 b/lib/libc/sys/_exit.2
deleted file mode 100644
index 0a0fb022c8c5..000000000000
--- a/lib/libc/sys/_exit.2
+++ /dev/null
@@ -1,124 +0,0 @@
-.\" Copyright (c) 1980, 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.
-.\"
-.\" @(#)_exit.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd September 8, 2016
-.Dt EXIT 2
-.Os
-.Sh NAME
-.Nm _exit
-.Nd terminate the calling process
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft void
-.Fn _exit "int status"
-.Sh DESCRIPTION
-The
-.Fn _exit
-system call
-terminates a process with the following consequences:
-.Bl -bullet
-.It
-All of the descriptors open in the calling process are closed.
-This may entail delays, for example, waiting for output to drain;
-a process in this state may not be killed, as it is already dying.
-.It
-If the parent process of the calling process has an outstanding
-.Xr wait 2
-call
-or catches the
-.Dv SIGCHLD
-signal,
-it is notified of the calling process's termination and
-the
-.Fa status
-is set as defined by
-.Xr wait 2 .
-.It
-The parent process-ID of all of the calling process's existing child
-processes are set to the process-ID of the calling process's reaper;
-the reaper (normally the initialization process)
-inherits each of these processes
-(see
-.Xr procctl 2 ,
-.Xr init 8
-and the
-.Sx DEFINITIONS
-section of
-.Xr intro 2 ) .
-.It
-If the termination of the process causes any process group
-to become orphaned (usually because the parents of all members
-of the group have now exited; see
-.Dq orphaned process group
-in
-.Xr intro 2 ) ,
-and if any member of the orphaned group is stopped,
-the
-.Dv SIGHUP
-signal and the
-.Dv SIGCONT
-signal are sent to all members of the newly-orphaned process group.
-.It
-If the process is a controlling process (see
-.Xr intro 2 ) ,
-the
-.Dv SIGHUP
-signal is sent to the foreground process group of the controlling terminal,
-and all current access to the controlling terminal is revoked.
-.El
-.Pp
-Most C programs call the library routine
-.Xr exit 3 ,
-which flushes buffers, closes streams, unlinks temporary files, etc.,
-before
-calling
-.Fn _exit .
-.Sh RETURN VALUES
-The
-.Fn _exit
-system call
-can never return.
-.Sh SEE ALSO
-.Xr fork 2 ,
-.Xr sigaction 2 ,
-.Xr wait 2 ,
-.Xr exit 3 ,
-.Xr init 8
-.Sh STANDARDS
-The
-.Fn _exit
-system call is expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn _exit
-function appeared in
-.At v7 .
diff --git a/lib/libc/sys/_umtx_op.2 b/lib/libc/sys/_umtx_op.2
deleted file mode 100644
index 9c0f1f425e47..000000000000
--- a/lib/libc/sys/_umtx_op.2
+++ /dev/null
@@ -1,1539 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd November 23, 2020
-.Dt _UMTX_OP 2
-.Os
-.Sh NAME
-.Nm _umtx_op
-.Nd interface for implementation of userspace threading synchronization primitives
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/umtx.h
-.Ft int
-.Fn _umtx_op "void *obj" "int op" "u_long val" "void *uaddr" "void *uaddr2"
-.Sh DESCRIPTION
-The
-.Fn _umtx_op
-system call provides kernel support for userspace implementation of
-the threading synchronization primitives.
-The
-.Lb libthr
-uses the syscall to implement
-.St -p1003.1-2001
-pthread locks, like mutexes, condition variables and so on.
-.Ss STRUCTURES
-The operations, performed by the
-.Fn _umtx_op
-syscall, operate on userspace objects which are described
-by the following structures.
-Reserved fields and paddings are omitted.
-All objects require ABI-mandated alignment, but this is not currently
-enforced consistently on all architectures.
-.Pp
-The following flags are defined for flag fields of all structures:
-.Bl -tag -width indent
-.It Dv USYNC_PROCESS_SHARED
-Allow selection of the process-shared sleep queue for the thread sleep
-container, when the lock ownership cannot be granted immediately,
-and the operation must sleep.
-The process-shared or process-private sleep queue is selected based on
-the attributes of the memory mapping which contains the first byte of
-the structure, see
-.Xr mmap 2 .
-Otherwise, if the flag is not specified, the process-private sleep queue
-is selected regardless of the memory mapping attributes, as an optimization.
-.Pp
-See the
-.Sx SLEEP QUEUES
-subsection below for more details on sleep queues.
-.El
-.Bl -hang -offset indent
-.It Sy Mutex
-.Bd -literal
-struct umutex {
- volatile lwpid_t m_owner;
- uint32_t m_flags;
- uint32_t m_ceilings[2];
- uintptr_t m_rb_lnk;
-};
-.Ed
-.Pp
-The
-.Dv m_owner
-field is the actual lock.
-It contains either the thread identifier of the lock owner in the
-locked state, or zero when the lock is unowned.
-The highest bit set indicates that there is contention on the lock.
-The constants are defined for special values:
-.Bl -tag -width indent
-.It Dv UMUTEX_UNOWNED
-Zero, the value stored in the unowned lock.
-.It Dv UMUTEX_CONTESTED
-The contention indicator.
-.It Dv UMUTEX_RB_OWNERDEAD
-A thread owning the robust mutex terminated.
-The mutex is in unlocked state.
-.It Dv UMUTEX_RB_NOTRECOV
-The robust mutex is in a non-recoverable state.
-It cannot be locked until reinitialized.
-.El
-.Pp
-The
-.Dv m_flags
-field may contain the following umutex-specific flags, in addition to
-the common flags:
-.Bl -tag -width indent
-.It Dv UMUTEX_PRIO_INHERIT
-Mutex implements
-.Em Priority Inheritance
-protocol.
-.It Dv UMUTEX_PRIO_PROTECT
-Mutex implements
-.Em Priority Protection
-protocol.
-.It Dv UMUTEX_ROBUST
-Mutex is robust, as described in the
-.Sx ROBUST UMUTEXES
-section below.
-.It Dv UMUTEX_NONCONSISTENT
-Robust mutex is in a transient non-consistent state.
-Not used by kernel.
-.El
-.Pp
-In the manual page, mutexes not having
-.Dv UMUTEX_PRIO_INHERIT
-and
-.Dv UMUTEX_PRIO_PROTECT
-flags set, are called normal mutexes.
-Each type of mutex
-.Pq normal, priority-inherited, and priority-protected
-has a separate sleep queue associated
-with the given key.
-.Pp
-For priority protected mutexes, the
-.Dv m_ceilings
-array contains priority ceiling values.
-The
-.Dv m_ceilings[0]
-is the ceiling value for the mutex, as specified by
-.St -p1003.1-2008
-for the
-.Em Priority Protected
-mutex protocol.
-The
-.Dv m_ceilings[1]
-is used only for the unlock of a priority protected mutex, when
-unlock is done in an order other than the reversed lock order.
-In this case,
-.Dv m_ceilings[1]
-must contain the ceiling value for the last locked priority protected
-mutex, for proper priority reassignment.
-If, instead, the unlocking mutex was the last priority propagated
-mutex locked by the thread,
-.Dv m_ceilings[1]
-should contain \-1.
-This is required because kernel does not maintain the ordered lock list.
-.It Sy Condition variable
-.Bd -literal
-struct ucond {
- volatile uint32_t c_has_waiters;
- uint32_t c_flags;
- uint32_t c_clockid;
-};
-.Ed
-.Pp
-A non-zero
-.Dv c_has_waiters
-value indicates that there are in-kernel waiters for the condition,
-executing the
-.Dv UMTX_OP_CV_WAIT
-request.
-.Pp
-The
-.Dv c_flags
-field contains flags.
-Only the common flags
-.Pq Dv USYNC_PROCESS_SHARED
-are defined for ucond.
-.Pp
-The
-.Dv c_clockid
-member provides the clock identifier to use for timeout, when the
-.Dv UMTX_OP_CV_WAIT
-request has both the
-.Dv CVWAIT_CLOCKID
-flag and the timeout specified.
-Valid clock identifiers are a subset of those for
-.Xr clock_gettime 2 :
-.Bl -bullet -compact
-.It
-.Dv CLOCK_MONOTONIC
-.It
-.Dv CLOCK_MONOTONIC_FAST
-.It
-.Dv CLOCK_MONOTONIC_PRECISE
-.It
-.Dv CLOCK_PROF
-.It
-.Dv CLOCK_REALTIME
-.It
-.Dv CLOCK_REALTIME_FAST
-.It
-.Dv CLOCK_REALTIME_PRECISE
-.It
-.Dv CLOCK_SECOND
-.It
-.Dv CLOCK_UPTIME
-.It
-.Dv CLOCK_UPTIME_FAST
-.It
-.Dv CLOCK_UPTIME_PRECISE
-.It
-.Dv CLOCK_VIRTUAL
-.El
-.It Sy Reader/writer lock
-.Bd -literal
-struct urwlock {
- volatile int32_t rw_state;
- uint32_t rw_flags;
- uint32_t rw_blocked_readers;
- uint32_t rw_blocked_writers;
-};
-.Ed
-.Pp
-The
-.Dv rw_state
-field is the actual lock.
-It contains both the flags and counter of the read locks which were
-granted.
-Names of the
-.Dv rw_state
-bits are following:
-.Bl -tag -width indent
-.It Dv URWLOCK_WRITE_OWNER
-Write lock was granted.
-.It Dv URWLOCK_WRITE_WAITERS
-There are write lock waiters.
-.It Dv URWLOCK_READ_WAITERS
-There are read lock waiters.
-.It Dv URWLOCK_READER_COUNT(c)
-Returns the count of currently granted read locks.
-.El
-.Pp
-At any given time there may be only one thread to which the writer lock
-is granted on the
-.Vt struct rwlock ,
-and no threads are granted read lock.
-Or, at the given time, up to
-.Dv URWLOCK_MAX_READERS
-threads may be granted the read lock simultaneously, but write lock is
-not granted to any thread.
-.Pp
-The following flags for the
-.Dv rw_flags
-member of
-.Vt struct urwlock
-are defined, in addition to the common flags:
-.Bl -tag -width indent
-.It Dv URWLOCK_PREFER_READER
-If specified, immediately grant read lock requests when
-.Dv urwlock
-is already read-locked, even in presence of unsatisfied write
-lock requests.
-By default, if there is a write lock waiter, further read requests are
-not granted, to prevent unfair write lock waiter starvation.
-.El
-.Pp
-The
-.Dv rw_blocked_readers
-and
-.Dv rw_blocked_writers
-members contain the count of threads which are sleeping in kernel,
-waiting for the associated request type to be granted.
-The fields are used by kernel to update the
-.Dv URWLOCK_READ_WAITERS
-and
-.Dv URWLOCK_WRITE_WAITERS
-flags of the
-.Dv rw_state
-lock after requesting thread was woken up.
-.It Sy Semaphore
-.Bd -literal
-struct _usem2 {
- volatile uint32_t _count;
- uint32_t _flags;
-};
-.Ed
-.Pp
-The
-.Dv _count
-word represents a counting semaphore.
-A non-zero value indicates an unlocked (posted) semaphore, while zero
-represents the locked state.
-The maximal supported semaphore count is
-.Dv USEM_MAX_COUNT .
-.Pp
-The
-.Dv _count
-word, besides the counter of posts (unlocks), also contains the
-.Dv USEM_HAS_WAITERS
-bit, which indicates that locked semaphore has waiting threads.
-.Pp
-The
-.Dv USEM_COUNT()
-macro, applied to the
-.Dv _count
-word, returns the current semaphore counter, which is the number of posts
-issued on the semaphore.
-.Pp
-The following bits for the
-.Dv _flags
-member of
-.Vt struct _usem2
-are defined, in addition to the common flags:
-.Bl -tag -width indent
-.It Dv USEM_NAMED
-Flag is ignored by kernel.
-.El
-.It Sy Timeout parameter
-.Bd -literal
-struct _umtx_time {
- struct timespec _timeout;
- uint32_t _flags;
- uint32_t _clockid;
-};
-.Ed
-.Pp
-Several
-.Fn _umtx_op
-operations allow the blocking time to be limited, failing the request
-if it cannot be satisfied in the specified time period.
-The timeout is specified by passing either the address of
-.Vt struct timespec ,
-or its extended variant,
-.Vt struct _umtx_time ,
-as the
-.Fa uaddr2
-argument of
-.Fn _umtx_op .
-They are distinguished by the
-.Fa uaddr
-value, which must be equal to the size of the structure pointed to by
-.Fa uaddr2 ,
-casted to
-.Vt uintptr_t .
-.Pp
-The
-.Dv _timeout
-member specifies the time when the timeout should occur.
-Legal values for clock identifier
-.Dv _clockid
-are shared with the
-.Fa clock_id
-argument to the
-.Xr clock_gettime 2
-function,
-and use the same underlying clocks.
-The specified clock is used to obtain the current time value.
-Interval counting is always performed by the monotonic wall clock.
-.Pp
-The
-.Dv _flags
-argument allows the following flags to further define the timeout behaviour:
-.Bl -tag -width indent
-.It Dv UMTX_ABSTIME
-The
-.Dv _timeout
-value is the absolute time.
-The thread will be unblocked and the request failed when specified
-clock value is equal or exceeds the
-.Dv _timeout.
-.Pp
-If the flag is absent, the timeout value is relative, that is the amount
-of time, measured by the monotonic wall clock from the moment of the request
-start.
-.El
-.El
-.Ss SLEEP QUEUES
-When a locking request cannot be immediately satisfied, the thread is
-typically put to
-.Em sleep ,
-which is a non-runnable state terminated by the
-.Em wake
-operation.
-Lock operations include a
-.Em try
-variant which returns an error rather than sleeping if the lock cannot
-be obtained.
-Also,
-.Fn _umtx_op
-provides requests which explicitly put the thread to sleep.
-.Pp
-Wakes need to know which threads to make runnable, so sleeping threads
-are grouped into containers called
-.Em sleep queues .
-A sleep queue is identified by a key, which for
-.Fn _umtx_op
-is defined as the physical address of some variable.
-Note that the
-.Em physical
-address is used, which means that same variable mapped multiple
-times will give one key value.
-This mechanism enables the construction of
-.Em process-shared
-locks.
-.Pp
-A related attribute of the key is shareability.
-Some requests always interpret keys as private for the current process,
-creating sleep queues with the scope of the current process even if
-the memory is shared.
-Others either select the shareability automatically from the
-mapping attributes, or take additional input as the
-.Dv USYNC_PROCESS_SHARED
-common flag.
-This is done as optimization, allowing the lock scope to be limited
-regardless of the kind of backing memory.
-.Pp
-Only the address of the start byte of the variable specified as key is
-important for determining corresponding sleep queue.
-The size of the variable does not matter, so, for example, sleep on the same
-address interpeted as
-.Vt uint32_t
-and
-.Vt long
-on a little-endian 64-bit platform would collide.
-.Pp
-The last attribute of the key is the object type.
-The sleep queue to which a sleeping thread is assigned is an individual
-one for simple wait requests, mutexes, rwlocks, condvars and other
-primitives, even when the physical address of the key is same.
-.Pp
-When waking up a limited number of threads from a given sleep queue,
-the highest priority threads that have been blocked for the longest on
-the queue are selected.
-.Ss ROBUST UMUTEXES
-The
-.Em robust umutexes
-are provided as a substrate for a userspace library to implement
-.Tn POSIX
-robust mutexes.
-A robust umutex must have the
-.Dv UMUTEX_ROBUST
-flag set.
-.Pp
-On thread termination, the kernel walks two lists of mutexes.
-The two lists head addresses must be provided by a prior call to
-.Dv UMTX_OP_ROBUST_LISTS
-request.
-The lists are singly-linked.
-The link to next element is provided by the
-.Dv m_rb_lnk
-member of the
-.Vt struct umutex .
-.Pp
-Robust list processing is aborted if the kernel finds a mutex
-with any of the following conditions:
-.Bl -dash -offset indent -compact
-.It
-the
-.Dv UMUTEX_ROBUST
-flag is not set
-.It
-not owned by the current thread, except when the mutex is pointed to
-by the
-.Dv robust_inactive
-member of the
-.Vt struct umtx_robust_lists_params ,
-registered for the current thread
-.It
-the combination of mutex flags is invalid
-.It
-read of the umutex memory faults
-.It
-the list length limit described in
-.Xr libthr 3
-is reached.
-.El
-.Pp
-Every mutex in both lists is unlocked as if the
-.Dv UMTX_OP_MUTEX_UNLOCK
-request is performed on it, but instead of the
-.Dv UMUTEX_UNOWNED
-value, the
-.Dv m_owner
-field is written with the
-.Dv UMUTEX_RB_OWNERDEAD
-value.
-When a mutex in the
-.Dv UMUTEX_RB_OWNERDEAD
-state is locked by kernel due to the
-.Dv UMTX_OP_MUTEX_TRYLOCK
-and
-.Dv UMTX_OP_MUTEX_LOCK
-requests, the lock is granted and
-.Er EOWNERDEAD
-error is returned.
-.Pp
-Also, the kernel handles the
-.Dv UMUTEX_RB_NOTRECOV
-value of
-.Dv the m_owner
-field specially, always returning the
-.Er ENOTRECOVERABLE
-error for lock attempts, without granting the lock.
-.Ss OPERATIONS
-The following operations, requested by the
-.Fa op
-argument to the function, are implemented:
-.Bl -tag -width indent
-.It Dv UMTX_OP_WAIT
-Wait.
-The arguments for the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to a variable of type
-.Vt long .
-.It Fa val
-Current value of the
-.Dv *obj .
-.El
-.Pp
-The current value of the variable pointed to by the
-.Fa obj
-argument is compared with the
-.Fa val .
-If they are equal, the requesting thread is put to interruptible sleep
-until woken up or the optionally specified timeout expires.
-.Pp
-The comparison and sleep are atomic.
-In other words, if another thread writes a new value to
-.Dv *obj
-and then issues
-.Dv UMTX_OP_WAKE ,
-the request is guaranteed to not miss the wakeup,
-which might otherwise happen between comparison and blocking.
-.Pp
-The physical address of memory where the
-.Fa *obj
-variable is located, is used as a key to index sleeping threads.
-.Pp
-The read of the current value of the
-.Dv *obj
-variable is not guarded by barriers.
-In particular, it is the user's duty to ensure the lock acquire
-and release memory semantics, if the
-.Dv UMTX_OP_WAIT
-and
-.Dv UMTX_OP_WAKE
-requests are used as a substrate for implementing a simple lock.
-.Pp
-The request is not restartable.
-An unblocked signal delivered during the wait always results in sleep
-interruption and
-.Er EINTR
-error.
-.Pp
-Optionally, a timeout for the request may be specified.
-.It Dv UMTX_OP_WAKE
-Wake the threads possibly sleeping due to
-.Dv UMTX_OP_WAIT .
-The arguments for the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to a variable, used as a key to find sleeping threads.
-.It Fa val
-Up to
-.Fa val
-threads are woken up by this request.
-Specify
-.Dv INT_MAX
-to wake up all waiters.
-.El
-.It Dv UMTX_OP_MUTEX_TRYLOCK
-Try to lock umutex.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the umutex.
-.El
-.Pp
-Operates same as the
-.Dv UMTX_OP_MUTEX_LOCK
-request, but returns
-.Er EBUSY
-instead of sleeping if the lock cannot be obtained immediately.
-.It Dv UMTX_OP_MUTEX_LOCK
-Lock umutex.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the umutex.
-.El
-.Pp
-Locking is performed by writing the current thread id into the
-.Dv m_owner
-word of the
-.Vt struct umutex .
-The write is atomic, preserves the
-.Dv UMUTEX_CONTESTED
-contention indicator, and provides the acquire barrier for
-lock entrance semantic.
-.Pp
-If the lock cannot be obtained immediately because another thread owns
-the lock, the current thread is put to sleep, with
-.Dv UMUTEX_CONTESTED
-bit set before.
-Upon wake up, the lock conditions are re-tested.
-.Pp
-The request adheres to the priority protection or inheritance protocol
-of the mutex, specified by the
-.Dv UMUTEX_PRIO_PROTECT
-or
-.Dv UMUTEX_PRIO_INHERIT
-flag, respectively.
-.Pp
-Optionally, a timeout for the request may be specified.
-.Pp
-A request with a timeout specified is not restartable.
-An unblocked signal delivered during the wait always results in sleep
-interruption and
-.Er EINTR
-error.
-A request without timeout specified is always restarted after return
-from a signal handler.
-.It Dv UMTX_OP_MUTEX_UNLOCK
-Unlock umutex.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the umutex.
-.El
-.Pp
-Unlocks the mutex, by writing
-.Dv UMUTEX_UNOWNED
-(zero) value into
-.Dv m_owner
-word of the
-.Vt struct umutex .
-The write is done with a release barrier, to provide lock leave semantic.
-.Pp
-If there are threads sleeping in the sleep queue associated with the
-umutex, one thread is woken up.
-If more than one thread sleeps in the sleep queue, the
-.Dv UMUTEX_CONTESTED
-bit is set together with the write of the
-.Dv UMUTEX_UNOWNED
-value into
-.Dv m_owner .
-.Pp
-The request adheres to the priority protection or inheritance protocol
-of the mutex, specified by the
-.Dv UMUTEX_PRIO_PROTECT
-or
-.Dv UMUTEX_PRIO_INHERIT
-flag, respectively.
-See description of the
-.Dv m_ceilings
-member of the
-.Vt struct umutex
-structure for additional details of the request operation on the
-priority protected protocol mutex.
-.It Dv UMTX_OP_SET_CEILING
-Set ceiling for the priority protected umutex.
-The arguments to the request are:
-.Bl -tag -width "uaddr"
-.It Fa obj
-Pointer to the umutex.
-.It Fa val
-New ceiling value.
-.It Fa uaddr
-Address of a variable of type
-.Vt uint32_t .
-If not
-.Dv NULL
-and the update was successful, the previous ceiling value is
-written to the location pointed to by
-.Fa uaddr .
-.El
-.Pp
-The request locks the umutex pointed to by the
-.Fa obj
-parameter, waiting for the lock if not immediately available.
-After the lock is obtained, the new ceiling value
-.Fa val
-is written to the
-.Dv m_ceilings[0]
-member of the
-.Vt struct umutex,
-after which the umutex is unlocked.
-.Pp
-The locking does not adhere to the priority protect protocol,
-to conform to the
-.Tn POSIX
-requirements for the
-.Xr pthread_mutex_setprioceiling 3
-interface.
-.It Dv UMTX_OP_CV_WAIT
-Wait for a condition.
-The arguments to the request are:
-.Bl -tag -width "uaddr2"
-.It Fa obj
-Pointer to the
-.Vt struct ucond .
-.It Fa val
-Request flags, see below.
-.It Fa uaddr
-Pointer to the umutex.
-.It Fa uaddr2
-Optional pointer to a
-.Vt struct timespec
-for timeout specification.
-.El
-.Pp
-The request must be issued by the thread owning the mutex pointed to
-by the
-.Fa uaddr
-argument.
-The
-.Dv c_hash_waiters
-member of the
-.Vt struct ucond ,
-pointed to by the
-.Fa obj
-argument, is set to an arbitrary non-zero value, after which the
-.Fa uaddr
-mutex is unlocked (following the appropriate protocol), and
-the current thread is put to sleep on the sleep queue keyed by
-the
-.Fa obj
-argument.
-The operations are performed atomically.
-It is guaranteed to not miss a wakeup from
-.Dv UMTX_OP_CV_SIGNAL
-or
-.Dv UMTX_OP_CV_BROADCAST
-sent between mutex unlock and putting the current thread on the sleep queue.
-.Pp
-Upon wakeup, if the timeout expired and no other threads are sleeping in
-the same sleep queue, the
-.Dv c_hash_waiters
-member is cleared.
-After wakeup, the
-.Fa uaddr
-umutex is not relocked.
-.Pp
-The following flags are defined:
-.Bl -tag -width "CVWAIT_CLOCKID"
-.It Dv CVWAIT_ABSTIME
-Timeout is absolute.
-.It Dv CVWAIT_CLOCKID
-Clockid is provided.
-.El
-.Pp
-Optionally, a timeout for the request may be specified.
-Unlike other requests, the timeout value is specified directly by a
-.Vt struct timespec ,
-pointed to by the
-.Fa uaddr2
-argument.
-If the
-.Dv CVWAIT_CLOCKID
-flag is provided, the timeout uses the clock from the
-.Dv c_clockid
-member of the
-.Vt struct ucond ,
-pointed to by
-.Fa obj
-argument.
-Otherwise,
-.Dv CLOCK_REALTIME
-is used, regardless of the clock identifier possibly specified in the
-.Vt struct _umtx_time .
-If the
-.Dv CVWAIT_ABSTIME
-flag is supplied, the timeout specifies absolute time value, otherwise
-it denotes a relative time interval.
-.Pp
-The request is not restartable.
-An unblocked signal delivered during
-the wait always results in sleep interruption and
-.Er EINTR
-error.
-.It Dv UMTX_OP_CV_SIGNAL
-Wake up one condition waiter.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to
-.Vt struct ucond .
-.El
-.Pp
-The request wakes up at most one thread sleeping on the sleep queue keyed
-by the
-.Fa obj
-argument.
-If the woken up thread was the last on the sleep queue, the
-.Dv c_has_waiters
-member of the
-.Vt struct ucond
-is cleared.
-.It Dv UMTX_OP_CV_BROADCAST
-Wake up all condition waiters.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to
-.Vt struct ucond .
-.El
-.Pp
-The request wakes up all threads sleeping on the sleep queue keyed by the
-.Fa obj
-argument.
-The
-.Dv c_has_waiters
-member of the
-.Vt struct ucond
-is cleared.
-.It Dv UMTX_OP_WAIT_UINT
-Same as
-.Dv UMTX_OP_WAIT ,
-but the type of the variable pointed to by
-.Fa obj
-is
-.Vt u_int
-.Pq a 32-bit integer .
-.It Dv UMTX_OP_RW_RDLOCK
-Read-lock a
-.Vt struct rwlock
-lock.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the lock (of type
-.Vt struct rwlock )
-to be read-locked.
-.It Fa val
-Additional flags to augment locking behaviour.
-The valid flags in the
-.Fa val
-argument are:
-.Bl -tag -width indent
-.It Dv URWLOCK_PREFER_READER
-.El
-.El
-.Pp
-The request obtains the read lock on the specified
-.Vt struct rwlock
-by incrementing the count of readers in the
-.Dv rw_state
-word of the structure.
-If the
-.Dv URWLOCK_WRITE_OWNER
-bit is set in the word
-.Dv rw_state ,
-the lock was granted to a writer which has not yet relinquished
-its ownership.
-In this case the current thread is put to sleep until it makes sense to
-retry.
-.Pp
-If the
-.Dv URWLOCK_PREFER_READER
-flag is set either in the
-.Dv rw_flags
-word of the structure, or in the
-.Fa val
-argument of the request, the presence of the threads trying to obtain
-the write lock on the same structure does not prevent the current thread
-from trying to obtain the read lock.
-Otherwise, if the flag is not set, and the
-.Dv URWLOCK_WRITE_WAITERS
-flag is set in
-.Dv rw_state ,
-the current thread does not attempt to obtain read-lock.
-Instead it sets the
-.Dv URWLOCK_READ_WAITERS
-in the
-.Dv rw_state
-word and puts itself to sleep on corresponding sleep queue.
-Upon wakeup, the locking conditions are re-evaluated.
-.Pp
-Optionally, a timeout for the request may be specified.
-.Pp
-The request is not restartable.
-An unblocked signal delivered during the wait always results in sleep
-interruption and
-.Er EINTR
-error.
-.It Dv UMTX_OP_RW_WRLOCK
-Write-lock a
-.Vt struct rwlock
-lock.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the lock (of type
-.Vt struct rwlock )
-to be write-locked.
-.El
-.Pp
-The request obtains a write lock on the specified
-.Vt struct rwlock ,
-by setting the
-.Dv URWLOCK_WRITE_OWNER
-bit in the
-.Dv rw_state
-word of the structure.
-If there is already a write lock owner, as indicated by the
-.Dv URWLOCK_WRITE_OWNER
-bit being set, or there are read lock owners, as indicated
-by the read-lock counter, the current thread does not attempt to
-obtain the write-lock.
-Instead it sets the
-.Dv URWLOCK_WRITE_WAITERS
-in the
-.Dv rw_state
-word and puts itself to sleep on corresponding sleep queue.
-Upon wakeup, the locking conditions are re-evaluated.
-.Pp
-Optionally, a timeout for the request may be specified.
-.Pp
-The request is not restartable.
-An unblocked signal delivered during the wait always results in sleep
-interruption and
-.Er EINTR
-error.
-.It Dv UMTX_OP_RW_UNLOCK
-Unlock rwlock.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the lock (of type
-.Vt struct rwlock )
-to be unlocked.
-.El
-.Pp
-The unlock type (read or write) is determined by the
-current lock state.
-Note that the
-.Vt struct rwlock
-does not save information about the identity of the thread which
-acquired the lock.
-.Pp
-If there are pending writers after the unlock, and the
-.Dv URWLOCK_PREFER_READER
-flag is not set in the
-.Dv rw_flags
-member of the
-.Fa *obj
-structure, one writer is woken up, selected as described in the
-.Sx SLEEP QUEUES
-subsection.
-If the
-.Dv URWLOCK_PREFER_READER
-flag is set, a pending writer is woken up only if there is
-no pending readers.
-.Pp
-If there are no pending writers, or, in the case that the
-.Dv URWLOCK_PREFER_READER
-flag is set, then all pending readers are woken up by unlock.
-.It Dv UMTX_OP_WAIT_UINT_PRIVATE
-Same as
-.Dv UMTX_OP_WAIT_UINT ,
-but unconditionally select the process-private sleep queue.
-.It Dv UMTX_OP_WAKE_PRIVATE
-Same as
-.Dv UMTX_OP_WAKE ,
-but unconditionally select the process-private sleep queue.
-.It Dv UMTX_OP_MUTEX_WAIT
-Wait for mutex availability.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Address of the mutex.
-.El
-.Pp
-Similarly to the
-.Dv UMTX_OP_MUTEX_LOCK ,
-put the requesting thread to sleep if the mutex lock cannot be obtained
-immediately.
-The
-.Dv UMUTEX_CONTESTED
-bit is set in the
-.Dv m_owner
-word of the mutex to indicate that there is a waiter, before the thread
-is added to the sleep queue.
-Unlike the
-.Dv UMTX_OP_MUTEX_LOCK
-request, the lock is not obtained.
-.Pp
-The operation is not implemented for priority protected and
-priority inherited protocol mutexes.
-.Pp
-Optionally, a timeout for the request may be specified.
-.Pp
-A request with a timeout specified is not restartable.
-An unblocked signal delivered during the wait always results in sleep
-interruption and
-.Er EINTR
-error.
-A request without a timeout automatically restarts if the signal disposition
-requested restart via the
-.Dv SA_RESTART
-flag in
-.Vt struct sigaction
-member
-.Dv sa_flags .
-.It Dv UMTX_OP_NWAKE_PRIVATE
-Wake up a batch of sleeping threads.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the array of pointers.
-.It Fa val
-Number of elements in the array pointed to by
-.Fa obj .
-.El
-.Pp
-For each element in the array pointed to by
-.Fa obj ,
-wakes up all threads waiting on the
-.Em private
-sleep queue with the key
-being the byte addressed by the array element.
-.It Dv UMTX_OP_MUTEX_WAKE
-Check if a normal umutex is unlocked and wake up a waiter.
-The arguments for the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the umutex.
-.El
-.Pp
-If the
-.Dv m_owner
-word of the mutex pointed to by the
-.Fa obj
-argument indicates unowned mutex, which has its contention indicator bit
-.Dv UMUTEX_CONTESTED
-set, clear the bit and wake up one waiter in the sleep queue associated
-with the byte addressed by the
-.Fa obj ,
-if any.
-Only normal mutexes are supported by the request.
-The sleep queue is always one for a normal mutex type.
-.Pp
-This request is deprecated in favor of
-.Dv UMTX_OP_MUTEX_WAKE2
-since mutexes using it cannot synchronize their own destruction.
-That is, the
-.Dv m_owner
-word has already been set to
-.Dv UMUTEX_UNOWNED
-when this request is made,
-so that another thread can lock, unlock and destroy the mutex
-(if no other thread uses the mutex afterwards).
-Clearing the
-.Dv UMUTEX_CONTESTED
-bit may then modify freed memory.
-.It Dv UMTX_OP_MUTEX_WAKE2
-Check if a umutex is unlocked and wake up a waiter.
-The arguments for the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the umutex.
-.It Fa val
-The umutex flags.
-.El
-.Pp
-The request does not read the
-.Dv m_flags
-member of the
-.Vt struct umutex ;
-instead, the
-.Fa val
-argument supplies flag information, in particular, to determine the
-sleep queue where the waiters are found for wake up.
-.Pp
-If the mutex is unowned, one waiter is woken up.
-.Pp
-If the mutex memory cannot be accessed, all waiters are woken up.
-.Pp
-If there is more than one waiter on the sleep queue, or there is only
-one waiter but the mutex is owned by a thread, the
-.Dv UMUTEX_CONTESTED
-bit is set in the
-.Dv m_owner
-word of the
-.Vt struct umutex .
-.It Dv UMTX_OP_SEM2_WAIT
-Wait until semaphore is available.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the semaphore (of type
-.Vt struct _usem2 ) .
-.It Fa uaddr
-Size of the memory passed in via the
-.Fa uaddr2
-argument.
-.It Fa uaddr2
-Optional pointer to a structure of type
-.Vt struct _umtx_time ,
-which may be followed by a structure of type
-.Vt struct timespec .
-.El
-.Pp
-Put the requesting thread onto a sleep queue if the semaphore counter
-is zero.
-If the thread is put to sleep, the
-.Dv USEM_HAS_WAITERS
-bit is set in the
-.Dv _count
-word to indicate waiters.
-The function returns either due to
-.Dv _count
-indicating the semaphore is available (non-zero count due to post),
-or due to a wakeup.
-The return does not guarantee that the semaphore is available,
-nor does it consume the semaphore lock on successful return.
-.Pp
-Optionally, a timeout for the request may be specified.
-.Pp
-A request with non-absolute timeout value is not restartable.
-An unblocked signal delivered during such wait results in sleep
-interruption and
-.Er EINTR
-error.
-.Pp
-If
-.Dv UMTX_ABSTIME
-was not set, and the operation was interrupted and the caller passed in a
-.Fa uaddr2
-large enough to hold a
-.Vt struct timespec
-following the initial
-.Vt struct _umtx_time ,
-then the
-.Vt struct timespec
-is updated to contain the unslept amount.
-.It Dv UMTX_OP_SEM2_WAKE
-Wake up waiters on semaphore lock.
-The arguments to the request are:
-.Bl -tag -width "obj"
-.It Fa obj
-Pointer to the semaphore (of type
-.Vt struct _usem2 ) .
-.El
-.Pp
-The request wakes up one waiter for the semaphore lock.
-The function does not increment the semaphore lock count.
-If the
-.Dv USEM_HAS_WAITERS
-bit was set in the
-.Dv _count
-word, and the last sleeping thread was woken up, the bit is cleared.
-.It Dv UMTX_OP_SHM
-Manage anonymous
-.Tn POSIX
-shared memory objects (see
-.Xr shm_open 2 ) ,
-which can be attached to a byte of physical memory, mapped into the
-process address space.
-The objects are used to implement process-shared locks in
-.Dv libthr .
-.Pp
-The
-.Fa val
-argument specifies the sub-request of the
-.Dv UMTX_OP_SHM
-request:
-.Bl -tag -width indent
-.It Dv UMTX_SHM_CREAT
-Creates the anonymous shared memory object, which can be looked up
-with the specified key
-.Fa uaddr .
-If the object associated with the
-.Fa uaddr
-key already exists, it is returned instead of creating a new object.
-The object's size is one page.
-On success, the file descriptor referencing the object is returned.
-The descriptor can be used for mapping the object using
-.Xr mmap 2 ,
-or for other shared memory operations.
-.It Dv UMTX_SHM_LOOKUP
-Same as
-.Dv UMTX_SHM_CREATE
-request, but if there is no shared memory object associated with
-the specified key
-.Fa uaddr ,
-an error is returned, and no new object is created.
-.It Dv UMTX_SHM_DESTROY
-De-associate the shared object with the specified key
-.Fa uaddr .
-The object is destroyed after the last open file descriptor is closed
-and the last mapping for it is destroyed.
-.It Dv UMTX_SHM_ALIVE
-Checks whether there is a live shared object associated with the
-supplied key
-.Fa uaddr .
-Returns zero if there is, and an error otherwise.
-This request is an optimization of the
-.Dv UMTX_SHM_LOOKUP
-request.
-It is cheaper when only the liveness of the associated object is asked
-for, since no file descriptor is installed in the process fd table
-on success.
-.El
-.Pp
-The
-.Fa uaddr
-argument specifies the virtual address, which backing physical memory
-byte identity is used as a key for the anonymous shared object
-creation or lookup.
-.It Dv UMTX_OP_ROBUST_LISTS
-Register the list heads for the current thread's robust mutex lists.
-The arguments to the request are:
-.Bl -tag -width "uaddr"
-.It Fa val
-Size of the structure passed in the
-.Fa uaddr
-argument.
-.It Fa uaddr
-Pointer to the structure of type
-.Vt struct umtx_robust_lists_params .
-.El
-.Pp
-The structure is defined as
-.Bd -literal
-struct umtx_robust_lists_params {
- uintptr_t robust_list_offset;
- uintptr_t robust_priv_list_offset;
- uintptr_t robust_inact_offset;
-};
-.Ed
-.Pp
-The
-.Dv robust_list_offset
-member contains address of the first element in the list of locked
-robust shared mutexes.
-The
-.Dv robust_priv_list_offset
-member contains address of the first element in the list of locked
-robust private mutexes.
-The private and shared robust locked lists are split to allow fast
-termination of the shared list on fork, in the child.
-.Pp
-The
-.Dv robust_inact_offset
-contains a pointer to the mutex which might be locked in nearby future,
-or might have been just unlocked.
-It is typically set by the lock or unlock mutex implementation code
-around the whole operation, since lists can be only changed race-free
-when the thread owns the mutex.
-The kernel inspects the
-.Dv robust_inact_offset
-in addition to walking the shared and private lists.
-Also, the mutex pointed to by
-.Dv robust_inact_offset
-is handled more loosely at the thread termination time,
-than other mutexes on the list.
-That mutex is allowed to be not owned by the current thread,
-in which case list processing is continued.
-See
-.Sx ROBUST UMUTEXES
-subsection for details.
-.It Dv UMTX_OP_GET_MIN_TIMEOUT
-Writes out the current value of minimal umtx operations timeout,
-in nanoseconds, into the long integer variable pointed to by
-.Fa uaddr1 .
-.It Dv UMTX_OP_SET_MIN_TIMEOUT
-Set the minimal amount of time, in nanoseconds, the thread is required
-to sleep for umtx operations specifying a timeout using absolute clocks.
-The value is taken from the
-.Fa val
-argument of the call.
-Zero means no minimum.
-.El
-.Pp
-The
-.Fa op
-argument may be a bitwise OR of a single command from above with one or more of
-the following flags:
-.Bl -tag -width indent
-.It Dv UMTX_OP__I386
-Request i386 ABI compatibility from the native
-.Nm
-system call.
-Specifically, this implies that:
-.Bl -hang -offset indent
-.It
-.Fa obj
-arguments that point to a word, point to a 32-bit integer.
-.It
-The
-.Dv UMTX_OP_NWAKE_PRIVATE
-.Fa obj
-argument is a pointer to an array of 32-bit pointers.
-.It
-The
-.Dv m_rb_lnk
-member of
-.Vt struct umutex
-is a 32-bit pointer.
-.It
-.Vt struct timespec
-uses a 32-bit time_t.
-.El
-.Pp
-.Dv UMTX_OP__32BIT
-has no effect if this flag is set.
-This flag is valid for all architectures, but it is ignored on i386.
-.It Dv UMTX_OP__32BIT
-Request non-i386, 32-bit ABI compatibility from the native
-.Nm
-system call.
-Specifically, this implies that:
-.Bl -hang -offset indent
-.It
-.Fa obj
-arguments that point to a word, point to a 32-bit integer.
-.It
-The
-.Dv UMTX_OP_NWAKE_PRIVATE
-.Fa obj
-argument is a pointer to an array of 32-bit pointers.
-.It
-The
-.Dv m_rb_lnk
-member of
-.Vt struct umutex
-is a 32-bit pointer.
-.It
-.Vt struct timespec
-uses a 64-bit time_t.
-.El
-.Pp
-This flag has no effect if
-.Dv UMTX_OP__I386
-is set.
-This flag is valid for all architectures.
-.El
-.Pp
-Note that if any 32-bit ABI compatibility is being requested, then care must be
-taken with robust lists.
-A single thread may not mix 32-bit compatible robust lists with native
-robust lists.
-The first
-.Dv UMTX_OP_ROBUST_LISTS
-call in a given thread determines which ABI that thread will use for robust
-lists going forward.
-.Sh RETURN VALUES
-If successful,
-all requests, except
-.Dv UMTX_SHM_CREAT
-and
-.Dv UMTX_SHM_LOOKUP
-sub-requests of the
-.Dv UMTX_OP_SHM
-request, will return zero.
-The
-.Dv UMTX_SHM_CREAT
-and
-.Dv UMTX_SHM_LOOKUP
-return a shared memory file descriptor on success.
-On error \-1 is returned, and the
-.Va errno
-variable is set to indicate the error.
-.Sh ERRORS
-The
-.Fn _umtx_op
-operations can fail with the following errors:
-.Bl -tag -width "[ETIMEDOUT]"
-.It Bq Er EFAULT
-One of the arguments point to invalid memory.
-.It Bq Er EINVAL
-The clock identifier, specified for the
-.Vt struct _umtx_time
-timeout parameter, or in the
-.Dv c_clockid
-member of
-.Vt struct ucond,
-is invalid.
-.It Bq Er EINVAL
-The type of the mutex, encoded by the
-.Dv m_flags
-member of
-.Vt struct umutex ,
-is invalid.
-.It Bq Er EINVAL
-The
-.Dv m_owner
-member of the
-.Vt struct umutex
-has changed the lock owner thread identifier during unlock.
-.It Bq Er EINVAL
-The
-.Dv timeout.tv_sec
-or
-.Dv timeout.tv_nsec
-member of
-.Vt struct _umtx_time
-is less than zero, or
-.Dv timeout.tv_nsec
-is greater than 1000000000.
-.It Bq Er EINVAL
-The
-.Fa op
-argument specifies invalid operation.
-.It Bq Er EINVAL
-The
-.Fa uaddr
-argument for the
-.Dv UMTX_OP_SHM
-request specifies invalid operation.
-.It Bq Er EINVAL
-The
-.Dv UMTX_OP_SET_CEILING
-request specifies non priority protected mutex.
-.It Bq Er EINVAL
-The new ceiling value for the
-.Dv UMTX_OP_SET_CEILING
-request, or one or more of the values read from the
-.Dv m_ceilings
-array during lock or unlock operations, is greater than
-.Dv RTP_PRIO_MAX .
-.It Bq Er EPERM
-Unlock attempted on an object not owned by the current thread.
-.It Bq Er EOWNERDEAD
-The lock was requested on an umutex where the
-.Dv m_owner
-field was set to the
-.Dv UMUTEX_RB_OWNERDEAD
-value, indicating terminated robust mutex.
-The lock was granted to the caller, so this error in fact
-indicates success with additional conditions.
-.It Bq Er ENOTRECOVERABLE
-The lock was requested on an umutex which
-.Dv m_owner
-field is equal to the
-.Dv UMUTEX_RB_NOTRECOV
-value, indicating abandoned robust mutex after termination.
-The lock was not granted to the caller.
-.It Bq Er ENOTTY
-The shared memory object, associated with the address passed to the
-.Dv UMTX_SHM_ALIVE
-sub-request of
-.Dv UMTX_OP_SHM
-request, was destroyed.
-.It Bq Er ESRCH
-For the
-.Dv UMTX_SHM_LOOKUP ,
-.Dv UMTX_SHM_DESTROY ,
-and
-.Dv UMTX_SHM_ALIVE
-sub-requests of the
-.Dv UMTX_OP_SHM
-request, there is no shared memory object associated with the provided key.
-.It Bq Er ENOMEM
-The
-.Dv UMTX_SHM_CREAT
-sub-request of the
-.Dv UMTX_OP_SHM
-request cannot be satisfied, because allocation of the shared memory object
-would exceed the
-.Dv RLIMIT_UMTXP
-resource limit, see
-.Xr setrlimit 2 .
-.It Bq Er EAGAIN
-The maximum number of readers
-.Dv ( URWLOCK_MAX_READERS )
-were already granted ownership of the given
-.Vt struct rwlock
-for read.
-.It Bq Er EBUSY
-A try mutex lock operation was not able to obtain the lock.
-.It Bq Er ETIMEDOUT
-The request specified a timeout in the
-.Fa uaddr
-and
-.Fa uaddr2
-arguments, and timed out before obtaining the lock or being woken up.
-.It Bq Er EINTR
-A signal was delivered during wait, for a non-restartable operation.
-Operations with timeouts are typically non-restartable, but timeouts
-specified in absolute time may be restartable.
-.It Bq Er ERESTART
-A signal was delivered during wait, for a restartable operation.
-Mutex lock requests without timeout specified are restartable.
-The error is not returned to userspace code since restart
-is handled by usual adjustment of the instruction counter.
-.El
-.Sh SEE ALSO
-.Xr clock_gettime 2 ,
-.Xr mmap 2 ,
-.Xr setrlimit 2 ,
-.Xr shm_open 2 ,
-.Xr sigaction 2 ,
-.Xr thr_exit 2 ,
-.Xr thr_kill 2 ,
-.Xr thr_kill2 2 ,
-.Xr thr_new 2 ,
-.Xr thr_self 2 ,
-.Xr thr_set_name 2 ,
-.Xr signal 3
-.Sh STANDARDS
-The
-.Fn _umtx_op
-system call is non-standard and is used by the
-.Lb libthr
-to implement
-.St -p1003.1-2001
-.Xr pthread 3
-functionality.
-.Sh BUGS
-A window between a unlocking robust mutex and resetting the pointer in the
-.Dv robust_inact_offset
-member of the registered
-.Vt struct umtx_robust_lists_params
-allows another thread to destroy the mutex, thus making the kernel inspect
-freed or reused memory.
-The
-.Li libthr
-implementation is only vulnerable to this race when operating on
-a shared mutex.
-A possible fix for the current implementation is to strengthen the checks
-for shared mutexes before terminating them, in particular, verifying
-that the mutex memory is mapped from a shared memory object allocated
-by the
-.Dv UMTX_OP_SHM
-request.
-This is not done because it is believed that the race is adequately
-covered by other consistency checks, while adding the check would
-prevent alternative implementations of
-.Li libpthread .
diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2
deleted file mode 100644
index fe11d1972faa..000000000000
--- a/lib/libc/sys/accept.2
+++ /dev/null
@@ -1,238 +0,0 @@
-.\" Copyright (c) 1983, 1990, 1991, 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.
-.\"
-.\" @(#)accept.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd October 9, 2014
-.Dt ACCEPT 2
-.Os
-.Sh NAME
-.Nm accept ,
-.Nm accept4
-.Nd accept a connection on a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.Ft int
-.Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen"
-.Ft int
-.Fn accept4 "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "int flags"
-.Sh DESCRIPTION
-The argument
-.Fa s
-is a socket that has been created with
-.Xr socket 2 ,
-bound to an address with
-.Xr bind 2 ,
-and is listening for connections after a
-.Xr listen 2 .
-The
-.Fn accept
-system call extracts the first connection request on the
-queue of pending connections, creates a new socket,
-and allocates a new file descriptor for the socket which
-inherits the state of the
-.Dv O_NONBLOCK
-and
-.Dv O_ASYNC
-properties and the destination of
-.Dv SIGIO
-and
-.Dv SIGURG
-signals from the original socket
-.Fa s .
-.Pp
-The
-.Fn accept4
-system call is similar,
-but the
-.Dv O_NONBLOCK
-property of the new socket is instead determined by the
-.Dv SOCK_NONBLOCK
-flag in the
-.Fa flags
-argument,
-the
-.Dv O_ASYNC
-property is cleared,
-the signal destination is cleared
-and the close-on-exec flag on the new file descriptor can be set via the
-.Dv SOCK_CLOEXEC
-flag in the
-.Fa flags
-argument.
-.Pp
-If no pending connections are
-present on the queue, and the original socket
-is not marked as non-blocking,
-.Fn accept
-blocks the caller until a connection is present.
-If the original socket
-is marked non-blocking and no pending
-connections are present on the queue,
-.Fn accept
-returns an error as described below.
-The accepted socket
-may not be used
-to accept more connections.
-The original socket
-.Fa s
-remains open.
-.Pp
-The argument
-.Fa addr
-is a result argument that is filled-in with
-the address of the connecting entity,
-as known to the communications layer.
-The exact format of the
-.Fa addr
-argument is determined by the domain in which the communication
-is occurring.
-A null pointer may be specified for
-.Fa addr
-if the address information is not desired;
-in this case,
-.Fa addrlen
-is not used and should also be null.
-Otherwise, the
-.Fa addrlen
-argument
-is a value-result argument; it should initially contain the
-amount of space pointed to by
-.Fa addr ;
-on return it will contain the actual length (in bytes) of the
-address returned.
-This call
-is used with connection-based socket types, currently with
-.Dv SOCK_STREAM .
-.Pp
-It is possible to
-.Xr select 2
-a socket for the purposes of doing an
-.Fn accept
-by selecting it for read.
-.Pp
-For certain protocols which require an explicit confirmation,
-such as
-.Tn ISO
-or
-.Tn DATAKIT ,
-.Fn accept
-can be thought of
-as merely dequeueing the next connection
-request and not implying confirmation.
-Confirmation can be implied by a normal read or write on the new
-file descriptor, and rejection can be implied by closing the
-new socket.
-.Pp
-For some applications, performance may be enhanced by using an
-.Xr accept_filter 9
-to pre-process incoming connections.
-.Pp
-When using
-.Fn accept ,
-portable programs should not rely on the
-.Dv O_NONBLOCK
-and
-.Dv O_ASYNC
-properties and the signal destination being inherited,
-but should set them explicitly using
-.Xr fcntl 2 ;
-.Fn accept4
-sets these properties consistently,
-but may not be fully portable across
-.Ux
-platforms.
-.Sh RETURN VALUES
-These calls return \-1 on error.
-If they succeed, they return a non-negative
-integer that is a descriptor for the accepted socket.
-.Sh ERRORS
-The
-.Fn accept
-and
-.Fn accept4
-system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The descriptor is invalid.
-.It Bq Er EINTR
-The
-.Fn accept
-operation was interrupted.
-.It Bq Er EMFILE
-The per-process descriptor table is full.
-.It Bq Er ENFILE
-The system file table is full.
-.It Bq Er ENOTSOCK
-The descriptor references a file, not a socket.
-.It Bq Er EINVAL
-.Xr listen 2
-has not been called on the socket descriptor.
-.It Bq Er EFAULT
-The
-.Fa addr
-argument is not in a writable part of the
-user address space.
-.It Bo Er EWOULDBLOCK Bc or Bq Er EAGAIN
-The socket is marked non-blocking and no connections
-are present to be accepted.
-.It Bq Er ECONNABORTED
-A connection arrived, but it was closed while waiting
-on the listen queue.
-.El
-.Pp
-The
-.Fn accept4
-system call will also fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa flags
-argument is invalid.
-.El
-.Sh SEE ALSO
-.Xr bind 2 ,
-.Xr connect 2 ,
-.Xr getpeername 2 ,
-.Xr getsockname 2 ,
-.Xr listen 2 ,
-.Xr select 2 ,
-.Xr socket 2 ,
-.Xr accept_filter 9
-.Sh HISTORY
-The
-.Fn accept
-system call appeared in
-.Bx 4.2 .
-.Pp
-The
-.Fn accept4
-system call appeared in
-.Fx 10.0 .
diff --git a/lib/libc/sys/accept.c b/lib/libc/sys/accept.c
index 417fb344a91e..95c8b4a58c74 100644
--- a/lib/libc/sys/accept.c
+++ b/lib/libc/sys/accept.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_accept, __accept);
int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
-
- return (((int (*)(int, struct sockaddr *, socklen_t *))
- __libc_interposing[INTERPOS_accept])(s, addr, addrlen));
+ return (INTERPOS_SYS(accept, s, addr, addrlen));
}
diff --git a/lib/libc/sys/accept4.c b/lib/libc/sys/accept4.c
index 56cc06efdfe6..1a1f75c9f528 100644
--- a/lib/libc/sys/accept4.c
+++ b/lib/libc/sys/accept4.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_accept4, __accept4);
int
accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
-
- return (((int (*)(int, struct sockaddr *, socklen_t *, int))
- __libc_interposing[INTERPOS_accept4])(s, addr, addrlen, flags));
+ return (INTERPOS_SYS(accept4, s, addr, addrlen, flags));
}
diff --git a/lib/libc/sys/access.2 b/lib/libc/sys/access.2
deleted file mode 100644
index 681e4483a9e6..000000000000
--- a/lib/libc/sys/access.2
+++ /dev/null
@@ -1,271 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)access.2 8.2 (Berkeley) 4/1/94
-.\"
-.Dd March 30, 2021
-.Dt ACCESS 2
-.Os
-.Sh NAME
-.Nm access ,
-.Nm eaccess ,
-.Nm faccessat
-.Nd check accessibility of a file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn access "const char *path" "int mode"
-.Ft int
-.Fn eaccess "const char *path" "int mode"
-.Ft int
-.Fn faccessat "int fd" "const char *path" "int mode" "int flag"
-.Sh DESCRIPTION
-The
-.Fn access
-and
-.Fn eaccess
-system calls check the accessibility of the
-file named by
-the
-.Fa path
-argument
-for the access permissions indicated by
-the
-.Fa mode
-argument.
-The value of
-.Fa mode
-is either the bitwise-inclusive OR of the access permissions to be
-checked
-.Dv ( R_OK
-for read permission,
-.Dv W_OK
-for write permission, and
-.Dv X_OK
-for execute/search permission),
-or the existence test
-.Pq Dv F_OK .
-.Pp
-For additional information, see the
-.Sx "File Access Permission"
-section of
-.Xr intro 2 .
-.Pp
-The
-.Fn eaccess
-system call uses
-the effective user ID and the group access list
-to authorize the request;
-the
-.Fn access
-system call uses
-the real user ID in place of the effective user ID,
-the real group ID in place of the effective group ID,
-and the rest of the group access list.
-.Pp
-The
-.Fn faccessat
-system call is equivalent to
-.Fn access
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the file whose accessibility is to be determined is
-located relative to the directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn faccessat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn access .
-Values for
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from the following
-list, defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_EACCESS
-The checks for accessibility are performed using the effective user and group
-IDs instead of the real user and group ID as required in a call to
-.Fn access .
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa path
-argument is an empty string, operate on the file or directory
-referenced by the descriptor
-.Fa fd .
-If
-.Fa fd
-is equal to
-.Dv AT_FDCWD ,
-operate on the current working directory.
-.El
-.Pp
-Even if a process's real or effective user has appropriate privileges
-and indicates success for
-.Dv X_OK ,
-the file may not actually have execute permission bits set.
-Likewise for
-.Dv R_OK
-and
-.Dv W_OK .
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-.Fn access ,
-.Fn eaccess ,
-or
-.Fn faccessat
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value of the
-.Fa mode
-argument is invalid.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EROFS
-Write access is requested for a file on a read-only file system.
-.It Bq Er ETXTBSY
-Write access is requested for a pure procedure (shared text)
-file presently being executed.
-.It Bq Er EACCES
-Permission bits of the file mode do not permit the requested
-access, or search permission is denied on a component of the
-path prefix.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-Also, the
-.Fn faccessat
-system call may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is
-neither
-.Dv AT_FDCWD
-nor a valid file descriptor.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode.
-.El
-.Sh SEE ALSO
-.Xr chmod 2 ,
-.Xr intro 2 ,
-.Xr stat 2
-.Sh STANDARDS
-The
-.Fn access
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn faccessat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn access
-function appeared in
-.At v7 .
-The
-.Fn faccessat
-system call appeared in
-.Fx 8.0 .
-.Sh SECURITY CONSIDERATIONS
-The
-.Fn access
-system call
-is a potential security hole due to race conditions and
-should never be used.
-Set-user-ID and set-group-ID applications should restore the
-effective user or group ID,
-and perform actions directly rather than use
-.Fn access
-to simulate access checks for the real user or group ID.
-The
-.Fn eaccess
-system call
-likewise may be subject to races if used inappropriately.
-.Pp
-.Fn access
-remains useful for providing clues to users as to whether operations
-make sense for particular filesystem objects (e.g. 'delete' menu
-item only highlighted in a writable folder ... avoiding interpretation
-of the st_mode bits that the application might not understand --
-e.g. in the case of AFS).
-It also allows a cheaper file existence test than
-.Xr stat 2 .
diff --git a/lib/libc/sys/acct.2 b/lib/libc/sys/acct.2
deleted file mode 100644
index 78b0c8db4a91..000000000000
--- a/lib/libc/sys/acct.2
+++ /dev/null
@@ -1,132 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)acct.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt ACCT 2
-.Os
-.Sh NAME
-.Nm acct
-.Nd enable or disable process accounting
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn acct "const char *file"
-.Sh DESCRIPTION
-The
-.Fn acct
-system call enables or disables the collection of system accounting
-records.
-If the argument
-.Fa file
-is a null pointer, accounting is disabled.
-If
-.Fa file
-is an
-.Em existing
-pathname (null-terminated), record collection is enabled and for
-every process initiated which terminates under normal
-conditions an accounting record is appended to
-.Fa file .
-Abnormal conditions of termination are reboots
-or other fatal system problems.
-Records for processes which never terminate cannot be
-produced by
-.Fn acct .
-.Pp
-For more information on the record structure used by
-.Fn acct ,
-see
-.In sys/acct.h
-and
-.Xr acct 5 .
-.Pp
-This call is permitted only to the super-user.
-.Sh NOTES
-Accounting is automatically disabled when the file system the
-accounting file resides on runs out of space; it is enabled when
-space once again becomes available.
-The values controlling this behaviour can be modified using the following
-.Xr sysctl 8
-variables:
-.Bl -tag -width ".Va kern.acct_chkfreq"
-.It Va kern.acct_chkfreq
-Specifies the frequency (in seconds) with which free disk
-space should be checked.
-.It Va kern.acct_resume
-The percentage of free disk space above which process
-accounting will resume.
-.It Va kern.acct_suspend
-The percentage of free disk space below which process
-accounting will suspend.
-.El
-.Sh RETURN VALUES
-On error -1 is returned.
-The file must exist and the call may be exercised only by the super-user.
-.Sh ERRORS
-The
-.Fn acct
-system call will fail if one of the following is true:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller is not the super-user.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix,
-or the path name is not a regular file.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa file
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh SEE ALSO
-.Xr acct 5 ,
-.Xr accton 8 ,
-.Xr sa 8
-.Sh HISTORY
-The
-.Fn acct
-function appeared in
-.At v7 .
diff --git a/lib/libc/sys/adjtime.2 b/lib/libc/sys/adjtime.2
deleted file mode 100644
index e1957ace66b6..000000000000
--- a/lib/libc/sys/adjtime.2
+++ /dev/null
@@ -1,108 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)adjtime.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd May 13, 2021
-.Dt ADJTIME 2
-.Os
-.Sh NAME
-.Nm adjtime
-.Nd "correct the time to allow synchronization of the system clock"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/time.h
-.Ft int
-.Fn adjtime "const struct timeval *delta" "struct timeval *olddelta"
-.Sh DESCRIPTION
-The
-.Fn adjtime
-system call
-makes small adjustments to the system time, as returned by
-.Xr gettimeofday 2 ,
-advancing or retarding it
-by the time specified by the timeval
-.Fa delta .
-If
-.Fa delta
-is negative, the clock is
-slowed down by incrementing it more slowly than normal until
-the correction is complete.
-If
-.Fa delta
-is positive, a larger increment than normal
-is used.
-The skew used to perform the correction is generally a fraction of one percent.
-Thus, the time is always
-a monotonically increasing function.
-A time correction from an earlier call to
-.Fn adjtime
-may not be finished when
-.Fn adjtime
-is called again.
-If
-.Fa olddelta
-is not a null pointer,
-the structure pointed to will contain, upon return, the
-number of microseconds still to be corrected
-from the earlier call.
-.Pp
-This call may be used by time servers that synchronize the clocks
-of computers in a local area network.
-Such time servers would slow down the clocks of some machines
-and speed up the clocks of others to bring them to the average network time.
-.Pp
-The
-.Fn adjtime
-system call
-is restricted to the super-user.
-.Sh RETURN VALUES
-.Rv -std adjtime
-.Sh ERRORS
-The
-.Fn adjtime
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-An argument points outside the process's allocated address space.
-.It Bq Er EPERM
-The process's effective user ID is not that of the super-user.
-.El
-.Sh SEE ALSO
-.Xr date 1 ,
-.Xr gettimeofday 2
-.Rs
-.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
-.%A R. Gusella
-.%A S. Zatti
-.Re
-.Sh HISTORY
-The
-.Fn adjtime
-system call appeared in
-.Bx 4.3 .
diff --git a/lib/libc/sys/aio_fsync.2 b/lib/libc/sys/aio_fsync.2
deleted file mode 100644
index f386e0653b21..000000000000
--- a/lib/libc/sys/aio_fsync.2
+++ /dev/null
@@ -1,186 +0,0 @@
-.\" Copyright (c) 2013 Sergey Kandaurov
-.\" 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.
-.\"
-.Dd January 6, 2021
-.Dt AIO_FSYNC 2
-.Os
-.Sh NAME
-.Nm aio_fsync
-.Nd asynchronous file synchronization (REALTIME)
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In aio.h
-.Ft int
-.Fn aio_fsync "int op" "struct aiocb *iocb"
-.Sh DESCRIPTION
-The
-.Fn aio_fsync
-system call allows the calling process to move all modified data
-associated with the descriptor
-.Fa iocb->aio_fildes
-to a permanent storage device.
-The call returns immediately after the synchronization request has been
-enqueued to the descriptor; the synchronization may or may not have
-completed at the time the call returns.
-.Pp
-The
-.Fa op
-argument can be set to
-.Dv O_SYNC
-to cause all currently queued I/O operations to be completed
-as if by a call to
-.Xr fsync 2 ,
-or
-.Dv O_DSYNC
-for the behavior of
-.Xr fdatasync 2 .
-.Pp
-If _POSIX_PRIORITIZED_IO is defined, and the descriptor supports it,
-then the enqueued operation is submitted at a priority equal to that
-of the calling process minus
-.Fa iocb->aio_reqprio .
-.Pp
-The
-.Fa iocb
-pointer may be subsequently used as an argument to
-.Fn aio_return
-and
-.Fn aio_error
-in order to determine return or error status for the enqueued operation
-while it is in progress.
-.Pp
-If the request could not be enqueued (generally due to invalid arguments),
-the call returns without having enqueued the request.
-.Pp
-The
-.Fa iocb->aio_sigevent
-structure can be used to request notification of the operation's
-completion as described in
-.Xr aio 4 .
-.Sh RESTRICTIONS
-The Asynchronous I/O Control Block structure pointed to by
-.Fa iocb
-must remain valid until the
-operation has completed.
-.Pp
-The asynchronous I/O control buffer
-.Fa iocb
-should be zeroed before the
-.Fn aio_fsync
-call to avoid passing bogus context information to the kernel.
-.Pp
-Modification of the Asynchronous I/O Control Block structure is not allowed
-while the request is queued.
-.Sh RETURN VALUES
-.Rv -std aio_fsync
-.Sh ERRORS
-The
-.Fn aio_fsync
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The request was not queued because of system resource limitations.
-.It Bq Er EINVAL
-The asynchronous notification method in
-.Fa iocb->aio_sigevent.sigev_notify
-is invalid or not supported.
-.It Bq Er EOPNOTSUPP
-Asynchronous file synchronization operations on the file descriptor
-.Fa iocb->aio_fildes
-are unsafe and unsafe asynchronous I/O operations are disabled.
-.It Bq Er EINVAL
-A value of the
-.Fa op
-argument is not set to
-.Dv O_SYNC
-or
-.Dv O_DSYNC .
-.El
-.Pp
-The following conditions may be synchronously detected when the
-.Fn aio_fsync
-system call is made, or asynchronously, at any time thereafter.
-If they are detected at call time,
-.Fn aio_fsync
-returns -1 and sets
-.Va errno
-appropriately; otherwise the
-.Fn aio_return
-system call must be called, and will return -1, and
-.Fn aio_error
-must be called to determine the actual value that would have been
-returned in
-.Va errno .
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa iocb->aio_fildes
-argument
-is not a valid descriptor.
-.It Bq Er EINVAL
-This implementation does not support synchronized I/O for this file.
-.El
-.Pp
-If the request is successfully enqueued, but subsequently cancelled
-or an error occurs, the value returned by the
-.Fn aio_return
-system call is per the
-.Xr read 2
-and
-.Xr write 2
-system calls, and the value returned by the
-.Fn aio_error
-system call is one of the error returns from the
-.Xr read 2
-or
-.Xr write 2
-system calls.
-.Sh SEE ALSO
-.Xr aio_cancel 2 ,
-.Xr aio_error 2 ,
-.Xr aio_read 2 ,
-.Xr aio_return 2 ,
-.Xr aio_suspend 2 ,
-.Xr aio_waitcomplete 2 ,
-.Xr aio_write 2 ,
-.Xr fsync 2 ,
-.Xr sigevent 3 ,
-.Xr siginfo 3 ,
-.Xr aio 4
-.Sh STANDARDS
-The
-.Fn aio_fsync
-system call is expected to conform to the
-.St -p1003.1
-standard.
-.Sh HISTORY
-The
-.Fn aio_fsync
-system call first appeared in
-.Fx 7.0 .
-The
-.Dv O_DSYNC
-option appeared in
-.Fx 13.0 .
diff --git a/lib/libc/sys/aio_read.2 b/lib/libc/sys/aio_read.2
deleted file mode 100644
index 1470c70438a3..000000000000
--- a/lib/libc/sys/aio_read.2
+++ /dev/null
@@ -1,261 +0,0 @@
-.\" Copyright (c) 1998 Terry Lambert
-.\" 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.
-.\"
-.Dd January 2, 2021
-.Dt AIO_READ 2
-.Os
-.Sh NAME
-.Nm aio_read ,
-.Nm aio_readv
-.Nd asynchronous read from a file (REALTIME)
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In aio.h
-.Ft int
-.Fn aio_read "struct aiocb *iocb"
-.In sys/uio.h
-.Ft int
-.Fn aio_readv "struct aiocb *iocb"
-.Sh DESCRIPTION
-The
-.Fn aio_read
-and
-.Fn aio_readv
-system calls allow the calling process to read
-from the descriptor
-.Fa iocb->aio_fildes
-beginning at the offset
-.Fa iocb->aio_offset .
-.Fn aio_read
-will read
-.Fa iocb->aio_nbytes
-from the buffer pointed to by
-.Fa iocb->aio_buf ,
-whereas
-.Fn aio_readv
-reads the data into the
-.Fa iocb->aio_iovcnt
-buffers specified by the members of the
-.Fa iocb->aio_iov
-array.
-Both syscalls return immediately after the read request has
-been enqueued to the descriptor; the read may or may not have
-completed at the time the call returns.
-.Pp
-For
-.Fn aio_readv
-the
-.Fa iovec
-structure is defined in
-.Xr readv 2 .
-.Pp
-If _POSIX_PRIORITIZED_IO is defined, and the descriptor supports it,
-then the enqueued operation is submitted at a priority equal to that
-of the calling process minus
-.Fa iocb->aio_reqprio .
-.Pp
-The
-.Fa iocb->aio_lio_opcode
-argument
-is ignored by the
-.Fn aio_read
-and
-.Fn aio_readv
-system calls.
-.Pp
-The
-.Fa iocb
-pointer may be subsequently used as an argument to
-.Fn aio_return
-and
-.Fn aio_error
-in order to determine return or error status for the enqueued operation
-while it is in progress.
-.Pp
-If the request could not be enqueued (generally due to invalid arguments),
-then the call returns without having enqueued the request.
-.Pp
-If the request is successfully enqueued, the value of
-.Fa iocb->aio_offset
-can be modified during the request as context, so this value must
-not be referenced after the request is enqueued.
-.Pp
-The
-.Fa iocb->aio_sigevent
-structure can be used to request notification of the operation's
-completion as described in
-.Xr aio 4 .
-.Sh RESTRICTIONS
-The Asynchronous I/O Control Block structure pointed to by
-.Fa iocb
-and the buffer that the
-.Fa iocb->aio_buf
-member of that structure references must remain valid until the
-operation has completed.
-.Pp
-The asynchronous I/O control buffer
-.Fa iocb
-should be zeroed before the
-.Fn aio_read
-call to avoid passing bogus context information to the kernel.
-.Pp
-Modifications of the Asynchronous I/O Control Block structure or the
-buffer contents are not allowed while the request is queued.
-.Pp
-If the file offset in
-.Fa iocb->aio_offset
-is past the offset maximum for
-.Fa iocb->aio_fildes ,
-no I/O will occur.
-.Sh RETURN VALUES
-.Rv -std aio_read aio_readv
-.Sh DIAGNOSTICS
-None.
-.Sh ERRORS
-The
-.Fn aio_read
-and
-.Fn aio_readv
-system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The request was not queued because of system resource limitations.
-.It Bq Er EFAULT
-Part of
-.Fa aio_iov
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The asynchronous notification method in
-.Fa iocb->aio_sigevent.sigev_notify
-is invalid or not supported.
-.It Bq Er EOPNOTSUPP
-Asynchronous read operations on the file descriptor
-.Fa iocb->aio_fildes
-are unsafe and unsafe asynchronous I/O operations are disabled.
-.El
-.Pp
-The following conditions may be synchronously detected when the
-.Fn aio_read
-or
-.Fn aio_readv
-system call is made, or asynchronously, at any time thereafter.
-If they
-are detected at call time,
-.Fn aio_read
-or
-.Fn aio_readv
-returns -1 and sets
-.Va errno
-appropriately; otherwise the
-.Fn aio_return
-system call must be called, and will return -1, and
-.Fn aio_error
-must be called to determine the actual value that would have been
-returned in
-.Va errno .
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa iocb->aio_fildes
-argument
-is invalid.
-.It Bq Er EINVAL
-The offset
-.Fa iocb->aio_offset
-is not valid, the priority specified by
-.Fa iocb->aio_reqprio
-is not a valid priority, or the number of bytes specified by
-.Fa iocb->aio_nbytes
-is not valid.
-.It Bq Er EOVERFLOW
-The file is a regular file,
-.Fa iocb->aio_nbytes
-is greater than zero, the starting offset in
-.Fa iocb->aio_offset
-is before the end of the file, but is at or beyond the
-.Fa iocb->aio_fildes
-offset maximum.
-.El
-.Pp
-If the request is successfully enqueued, but subsequently cancelled
-or an error occurs, the value returned by the
-.Fn aio_return
-system call is per the
-.Xr read 2
-system call, and the value returned by the
-.Fn aio_error
-system call is either one of the error returns from the
-.Xr read 2
-system call, or one of:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa iocb->aio_fildes
-argument
-is invalid for reading.
-.It Bq Er ECANCELED
-The request was explicitly cancelled via a call to
-.Fn aio_cancel .
-.It Bq Er EINVAL
-The offset
-.Fa iocb->aio_offset
-would be invalid.
-.El
-.Sh SEE ALSO
-.Xr aio_cancel 2 ,
-.Xr aio_error 2 ,
-.Xr aio_return 2 ,
-.Xr aio_suspend 2 ,
-.Xr aio_waitcomplete 2 ,
-.Xr aio_write 2 ,
-.Xr sigevent 3 ,
-.Xr siginfo 3 ,
-.Xr aio 4
-.Sh STANDARDS
-The
-.Fn aio_read
-system call is expected to conform to the
-.St -p1003.1
-standard.
-The
-.Fn aio_readv
-system call is a FreeBSD extension, and should not be used in portable code.
-.Sh HISTORY
-The
-.Fn aio_read
-system call first appeared in
-.Fx 3.0 .
-The
-.Fn aio_readv
-system call first appeared in
-.Fx 13.0 .
-.Sh AUTHORS
-This
-manual page was written by
-.An Terry Lambert Aq Mt terry@whistle.com .
-.Sh BUGS
-Invalid information in
-.Fa iocb->_aiocb_private
-may confuse the kernel.
diff --git a/lib/libc/sys/aio_suspend.c b/lib/libc/sys/aio_suspend.c
index fc9a0d906c92..592cb5b0e1d7 100644
--- a/lib/libc/sys/aio_suspend.c
+++ b/lib/libc/sys/aio_suspend.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/aio.h>
#include "libc_private.h"
@@ -41,8 +40,5 @@ int
aio_suspend(const struct aiocb * const iocbs[], int niocb,
const struct timespec *timeout)
{
-
- return (((int (*)(const struct aiocb * const[], int,
- const struct timespec *))
- __libc_interposing[INTERPOS_aio_suspend])(iocbs, niocb, timeout));
+ return (INTERPOS_SYS(aio_suspend, iocbs, niocb, timeout));
}
diff --git a/lib/libc/sys/aio_waitcomplete.2 b/lib/libc/sys/aio_waitcomplete.2
deleted file mode 100644
index 1f20eca942ab..000000000000
--- a/lib/libc/sys/aio_waitcomplete.2
+++ /dev/null
@@ -1,135 +0,0 @@
-.\" Copyright (c) 1999 Christopher M Sedore.
-.\" 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 ``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.
-.\"
-.Dd March 21, 2016
-.Dt AIO_WAITCOMPLETE 2
-.Os
-.Sh NAME
-.Nm aio_waitcomplete
-.Nd wait for the next completion of an aio request
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In aio.h
-.Ft ssize_t
-.Fn aio_waitcomplete "struct aiocb **iocbp" "struct timespec *timeout"
-.Sh DESCRIPTION
-The
-.Fn aio_waitcomplete
-system call waits for completion of an asynchronous I/O request.
-Upon completion,
-.Fn aio_waitcomplete
-returns the result of the function and sets
-.Fa iocbp
-to point to the structure associated with the original request.
-If an asynchronous I/O request is completed before
-.Fn aio_waitcomplete
-is called, it returns immediately with the completed request.
-.Pp
-If
-.Fa timeout
-is a non-NULL pointer, it specifies a maximum interval to wait for a
-asynchronous I/O request to complete.
-If
-.Fa timeout
-is a NULL pointer,
-.Fn aio_waitcomplete
-waits indefinitely.
-To effect a poll, the
-.Fa timeout
-argument should be non-NULL, pointing to a zero-valued timeval structure.
-.Pp
-The
-.Fn aio_waitcomplete
-system call also serves the function of
-.Fn aio_return ,
-thus
-.Fn aio_return
-should not be called for the control block returned in
-.Fa iocbp .
-.Sh RETURN VALUES
-If an asynchronous I/O request has completed,
-.Fa iocbp
-is set to point to the control block passed with the original request,
-and the status is returned as described in
-.Xr read 2 ,
-.Xr write 2 ,
-or
-.Xr fsync 2 .
-On failure,
-.Fn aio_waitcomplete
-returns
-.Dv -1 ,
-sets iocbp to
-.Dv NULL
-and sets
-.Va errno
-to indicate the error condition.
-.Sh ERRORS
-The
-.Fn aio_waitcomplete
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The specified time limit is invalid.
-.It Bq Er EAGAIN
-The process has not yet called
-.Fn aio_read
-or
-.Fn aio_write .
-.It Bq Er EINTR
-A signal was delivered before the timeout expired and before any
-asynchronous I/O requests completed.
-.It Bq Er EWOULDBLOCK
-.It Bq Er EINPROGRESS
-The specified time limit expired before any asynchronous I/O requests
-completed.
-.El
-.Sh SEE ALSO
-.Xr aio_cancel 2 ,
-.Xr aio_error 2 ,
-.Xr aio_read 2 ,
-.Xr aio_return 2 ,
-.Xr aio_suspend 2 ,
-.Xr aio_write 2 ,
-.Xr fsync 2 ,
-.Xr read 2 ,
-.Xr write 2 ,
-.Xr aio 4
-.Sh STANDARDS
-The
-.Fn aio_waitcomplete
-system call is a
-.Fx Ns -specific
-extension.
-.Sh HISTORY
-The
-.Fn aio_waitcomplete
-system call first appeared in
-.Fx 4.0 .
-.Sh AUTHORS
-The
-.Fn aio_waitcomplete
-system call and this manual page were written by
-.An Christopher M Sedore Aq Mt cmsedore@maxwell.syr.edu .
diff --git a/lib/libc/sys/aio_write.2 b/lib/libc/sys/aio_write.2
deleted file mode 100644
index efc0938a5cf9..000000000000
--- a/lib/libc/sys/aio_write.2
+++ /dev/null
@@ -1,256 +0,0 @@
-.\" Copyright (c) 1999 Softweyr LLC.
-.\" 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 Softweyr LLC 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 Softweyr LLC 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.
-.\"
-.Dd January 2, 2021
-.Dt AIO_WRITE 2
-.Os
-.Sh NAME
-.Nm aio_write ,
-.Nm aio_writev
-.Nd asynchronous write to a file (REALTIME)
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In aio.h
-.Ft int
-.Fn aio_write "struct aiocb *iocb"
-.In sys/uio.h
-.Ft int
-.Fn aio_writev "struct aiocb *iocb"
-.Sh DESCRIPTION
-The
-.Fn aio_write
-and
-.Fn aio_writev
-system calls allow the calling process to write
-to the descriptor
-.Fa iocb->aio_fildes .
-.Fn aio_write
-will write
-.Fa iocb->aio_nbytes
-from the buffer pointed to by
-.Fa iocb->aio_buf ,
-whereas
-.Fn aio_writev
-gathers the data from the
-.Fa iocb->aio_iovcnt
-buffers specified by the members of the
-.Fa iocb->aio_iov
-array.
-Both syscalls return immediately after the write request has been enqueued
-to the descriptor; the write may or may not have completed at the time
-the call returns.
-If the request could not be enqueued, generally due
-to invalid arguments, the call returns without having enqueued the
-request.
-.Pp
-For
-.Fn aio_writev
-the
-.Fa iovec
-structure is defined in
-.Xr writev 2 .
-.Pp
-If
-.Dv O_APPEND
-is set for
-.Fa iocb->aio_fildes ,
-write operations append to the file in the same order as the calls were
-made.
-If
-.Dv O_APPEND
-is not set for the file descriptor, the write operation will occur at
-the absolute position from the beginning of the file plus
-.Fa iocb->aio_offset .
-.Pp
-If
-.Dv _POSIX_PRIORITIZED_IO
-is defined, and the descriptor supports it, then the enqueued
-operation is submitted at a priority equal to that of the calling
-process minus
-.Fa iocb->aio_reqprio .
-.Pp
-The
-.Fa iocb
-pointer may be subsequently used as an argument to
-.Fn aio_return
-and
-.Fn aio_error
-in order to determine return or error status for the enqueued operation
-while it is in progress.
-.Pp
-If the request is successfully enqueued, the value of
-.Fa iocb->aio_offset
-can be modified during the request as context, so this value must not
-be referenced after the request is enqueued.
-.Pp
-The
-.Fa iocb->aio_sigevent
-structure can be used to request notification of the operation's
-completion as described in
-.Xr aio 4 .
-.Sh RESTRICTIONS
-The Asynchronous I/O Control Block structure pointed to by
-.Fa iocb
-and the buffer that the
-.Fa iocb->aio_buf
-member of that structure references must remain valid until the
-operation has completed.
-.Pp
-The asynchronous I/O control buffer
-.Fa iocb
-should be zeroed before the
-.Fn aio_write
-or
-.Fn aio_writev
-system call to avoid passing bogus context information to the kernel.
-.Pp
-Modifications of the Asynchronous I/O Control Block structure or the
-buffer contents are not allowed while the request is queued.
-.Pp
-If the file offset in
-.Fa iocb->aio_offset
-is past the offset maximum for
-.Fa iocb->aio_fildes ,
-no I/O will occur.
-.Sh RETURN VALUES
-.Rv -std aio_write aio_writev
-.Sh ERRORS
-The
-.Fn aio_write
-and
-.Fn aio_writev
-system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The request was not queued because of system resource limitations.
-.It Bq Er EFAULT
-Part of
-.Fa aio_iov
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The asynchronous notification method in
-.Fa iocb->aio_sigevent.sigev_notify
-is invalid or not supported.
-.It Bq Er EOPNOTSUPP
-Asynchronous write operations on the file descriptor
-.Fa iocb->aio_fildes
-are unsafe and unsafe asynchronous I/O operations are disabled.
-.El
-.Pp
-The following conditions may be synchronously detected when the
-.Fn aio_write
-or
-.Fn aio_writev
-system call is made, or asynchronously, at any time thereafter.
-If they
-are detected at call time,
-.Fn aio_write
-or
-.Fn aio_writev
-returns -1 and sets
-.Va errno
-appropriately; otherwise the
-.Fn aio_return
-system call must be called, and will return -1, and
-.Fn aio_error
-must be called to determine the actual value that would have been
-returned in
-.Va errno .
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa iocb->aio_fildes
-argument
-is invalid, or is not opened for writing.
-.It Bq Er EINVAL
-The offset
-.Fa iocb->aio_offset
-is not valid, the priority specified by
-.Fa iocb->aio_reqprio
-is not a valid priority, or the number of bytes specified by
-.Fa iocb->aio_nbytes
-is not valid.
-.El
-.Pp
-If the request is successfully enqueued, but subsequently canceled
-or an error occurs, the value returned by the
-.Fn aio_return
-system call is per the
-.Xr write 2
-system call, and the value returned by the
-.Fn aio_error
-system call is either one of the error returns from the
-.Xr write 2
-system call, or one of:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa iocb->aio_fildes
-argument
-is invalid for writing.
-.It Bq Er ECANCELED
-The request was explicitly canceled via a call to
-.Fn aio_cancel .
-.It Bq Er EINVAL
-The offset
-.Fa iocb->aio_offset
-would be invalid.
-.El
-.Sh SEE ALSO
-.Xr aio_cancel 2 ,
-.Xr aio_error 2 ,
-.Xr aio_return 2 ,
-.Xr aio_suspend 2 ,
-.Xr aio_waitcomplete 2 ,
-.Xr sigevent 3 ,
-.Xr siginfo 3 ,
-.Xr aio 4
-.Sh STANDARDS
-The
-.Fn aio_write
-system call
-is expected to conform to the
-.St -p1003.1
-standard.
-.Pp
-The
-.Fn aio_writev
-system call is a FreeBSD extension, and should not be used in portable code.
-.Sh HISTORY
-The
-.Fn aio_write
-system call first appeared in
-.Fx 3.0 .
-The
-.Fn aio_writev
-system call first appeared in
-.Fx 13.0 .
-.Sh AUTHORS
-This manual page was written by
-.An Wes Peters Aq Mt wes@softweyr.com .
-.Sh BUGS
-Invalid information in
-.Fa iocb->_aiocb_private
-may confuse the kernel.
diff --git a/lib/libc/sys/bind.2 b/lib/libc/sys/bind.2
deleted file mode 100644
index 8f0923116dd7..000000000000
--- a/lib/libc/sys/bind.2
+++ /dev/null
@@ -1,140 +0,0 @@
-.\" Copyright (c) 1983, 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.
-.\"
-.\" @(#)bind.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt BIND 2
-.Os
-.Sh NAME
-.Nm bind
-.Nd assign a local protocol address to a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft int
-.Fn bind "int s" "const struct sockaddr *addr" "socklen_t addrlen"
-.Sh DESCRIPTION
-The
-.Fn bind
-system call
-assigns the local protocol address to a socket.
-When a socket is created
-with
-.Xr socket 2
-it exists in an address family space but has no protocol address assigned.
-The
-.Fn bind
-system call requests that
-.Fa addr
-be assigned to the socket.
-.Sh NOTES
-Binding an address in the UNIX domain creates a socket in the file
-system that must be deleted by the caller when it is no longer
-needed (using
-.Xr unlink 2 ) .
-.Pp
-The rules used in address binding vary between communication domains.
-Consult the manual entries in section 4 for detailed information.
-.Pp
-For maximum portability, you should always zero the socket address structure
-before populating it and passing it to
-.Fn bind .
-.Sh RETURN VALUES
-.Rv -std bind
-.Sh ERRORS
-The
-.Fn bind
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-Kernel resources to complete the request are
-temporarily unavailable.
-.It Bq Er EBADF
-The
-.Fa s
-argument
-is not a valid descriptor.
-.It Bq Er EINVAL
-The socket is already bound to an address, and the protocol does not support
-binding to a new address; or the socket has been shut down.
-.It Bq Er EINVAL
-The
-.Fa addrlen
-argument is not a valid length for the address family.
-.It Bq Er ENOTSOCK
-The
-.Fa s
-argument
-is not a socket.
-.It Bq Er EADDRNOTAVAIL
-The specified address is not available from the local machine.
-.It Bq Er EADDRINUSE
-The specified address is already in use.
-.It Bq Er EAFNOSUPPORT
-Addresses in the specified address family cannot be used with this socket.
-.It Bq Er EACCES
-The requested address is protected, and the current user
-has inadequate permission to access it.
-.It Bq Er EFAULT
-The
-.Fa addr
-argument is not in a valid part of the user
-address space.
-.El
-.Pp
-The following errors are specific to binding addresses in the UNIX domain.
-.Bl -tag -width EADDRNOTAVA
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A prefix component of the path name does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EIO
-An I/O error occurred while making the directory entry or allocating the inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The name would reside on a read-only file system.
-.It Bq Er EISDIR
-An empty pathname was specified.
-.El
-.Sh SEE ALSO
-.Xr connect 2 ,
-.Xr getsockname 2 ,
-.Xr listen 2 ,
-.Xr socket 2
-.Sh HISTORY
-The
-.Fn bind
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/brk.2 b/lib/libc/sys/brk.2
deleted file mode 100644
index 6a4b3534146c..000000000000
--- a/lib/libc/sys/brk.2
+++ /dev/null
@@ -1,189 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)brk.2 8.4 (Berkeley) 5/1/95
-.\"
-.Dd June 2, 2018
-.Dt BRK 2
-.Os
-.Sh NAME
-.Nm brk ,
-.Nm sbrk
-.Nd change data segment size
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn brk "const void *addr"
-.Ft void *
-.Fn sbrk "intptr_t incr"
-.Sh DESCRIPTION
-.Bf -symbolic
-The
-.Fn brk
-and
-.Fn sbrk
-functions are legacy interfaces from before the
-advent of modern virtual memory management.
-They are deprecated and not present on the arm64 or riscv architectures.
-The
-.Xr mmap 2
-interface should be used to allocate pages instead.
-.Ef
-.Pp
-The
-.Fn brk
-and
-.Fn sbrk
-functions are used to change the amount of memory allocated in a
-process's data segment.
-They do this by moving the location of the
-.Dq break .
-The break is the first address after the end of the process's
-uninitialized data segment (also known as the
-.Dq BSS ) .
-.Pp
-The
-.Fn brk
-function
-sets the break to
-.Fa addr .
-.Pp
-The
-.Fn sbrk
-function raises the break by
-.Fa incr
-bytes, thus allocating at least
-.Fa incr
-bytes of new memory in the data segment.
-If
-.Fa incr
-is negative,
-the break is lowered by
-.Fa incr
-bytes.
-.Sh NOTES
-While the actual process data segment size maintained by the kernel will only
-grow or shrink in page sizes, these functions allow setting the break
-to unaligned values (i.e., it may point to any address inside the last
-page of the data segment).
-.Pp
-The current value of the program break may be determined by calling
-.Fn sbrk 0 .
-See also
-.Xr end 3 .
-.Pp
-The
-.Xr getrlimit 2
-system call may be used to determine
-the maximum permissible size of the
-data segment.
-It will not be possible to set the break
-beyond
-.Dq Va etext No + Va rlim.rlim_max
-where the
-.Va rlim.rlim_max
-value is returned from a call to
-.Fn getrlimit RLIMIT_DATA &rlim .
-(See
-.Xr end 3
-for the definition of
-.Va etext ) .
-.Sh RETURN VALUES
-.Rv -std brk
-.Pp
-The
-.Fn sbrk
-function returns the prior break value if successful;
-otherwise the value
-.Po Vt "void *" Pc Ns \-1
-is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn brk
-and
-.Fn sbrk
-functions
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The requested break value was beyond the beginning of the data segment.
-.It Bq Er ENOMEM
-The data segment size limit, as set by
-.Xr setrlimit 2 ,
-was exceeded.
-.It Bq Er ENOMEM
-Insufficient space existed in the swap area
-to support the expansion of the data segment.
-.El
-.Sh SEE ALSO
-.Xr execve 2 ,
-.Xr getrlimit 2 ,
-.Xr mmap 2 ,
-.Xr end 3 ,
-.Xr free 3 ,
-.Xr malloc 3
-.Sh HISTORY
-The
-.Fn brk
-function appeared in
-.At v7 .
-.Fx 11.0
-introduced the arm64 and riscv architectures which do not support
-.Fn brk
-or
-.Fn sbrk .
-.Sh BUGS
-Mixing
-.Fn brk
-or
-.Fn sbrk
-with
-.Xr malloc 3 ,
-.Xr free 3 ,
-or similar functions will result in non-portable program behavior.
-.Pp
-Setting the break may fail due to a temporary lack of
-swap space.
-It is not possible to distinguish this
-from a failure caused by exceeding the maximum size of
-the data segment without consulting
-.Xr getrlimit 2 .
-.Pp
-.Fn sbrk
-is sometimes used to monitor heap use by calling with an argument of 0.
-The result is unlikely to reflect actual utilization in combination with an
-.Xr mmap 2
-based malloc.
-.Pp
-.Fn brk
-and
-.Fn sbrk
-are not thread-safe.
diff --git a/lib/libc/sys/brk.c b/lib/libc/sys/brk.c
index 51bbcbdfcaef..b3e6abdac981 100644
--- a/lib/libc/sys/brk.c
+++ b/lib/libc/sys/brk.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <errno.h>
diff --git a/lib/libc/sys/cap_rights_limit.2 b/lib/libc/sys/cap_rights_limit.2
deleted file mode 100644
index eca30f55ea48..000000000000
--- a/lib/libc/sys/cap_rights_limit.2
+++ /dev/null
@@ -1,162 +0,0 @@
-.\"
-.\" Copyright (c) 2008-2010 Robert N. M. Watson
-.\" Copyright (c) 2012-2013 The FreeBSD Foundation
-.\" All rights reserved.
-.\"
-.\" This software was developed at the University of Cambridge Computer
-.\" Laboratory with support from a grant from Google, Inc.
-.\"
-.\" Portions of this documentation were written by Pawel Jakub Dawidek
-.\" under sponsorship from the FreeBSD Foundation.
-.\"
-.\" 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.
-.\"
-.Dd March 9, 2023
-.Dt CAP_RIGHTS_LIMIT 2
-.Os
-.Sh NAME
-.Nm cap_rights_limit
-.Nd limit capability rights
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/capsicum.h
-.Ft int
-.Fn cap_rights_limit "int fd" "const cap_rights_t *rights"
-.Sh DESCRIPTION
-When a file descriptor is created by a function such as
-.Xr accept 2 ,
-.Xr accept4 2 ,
-.Xr fhopen 2 ,
-.Xr kqueue 2 ,
-.Xr mq_open 2 ,
-.Xr open 2 ,
-.Xr openat 2 ,
-.Xr pdfork 2 ,
-.Xr pipe 2 ,
-.Xr shm_open 2 ,
-.Xr socket 2
-or
-.Xr socketpair 2 ,
-it is assigned all capability rights.
-Those rights can be reduced (but never expanded) by using the
-.Fn cap_rights_limit
-system call.
-Once capability rights are reduced, operations on the file descriptor will be
-limited to those permitted by
-.Fa rights .
-.Pp
-The
-.Fa rights
-argument should be prepared using
-.Xr cap_rights_init 3
-family of functions.
-.Pp
-Capability rights assigned to a file descriptor can be obtained with the
-.Xr cap_rights_get 3
-function.
-.Pp
-The complete list of the capability rights can be found in the
-.Xr rights 4
-manual page.
-.Sh RETURN VALUES
-.Rv -std
-.Sh EXAMPLES
-The following example demonstrates how to limit file descriptor capability
-rights to allow reading only.
-.Bd -literal
-cap_rights_t setrights;
-char buf[1];
-int fd;
-
-fd = open("/tmp/foo", O_RDWR);
-if (fd < 0)
- err(1, "open() failed");
-
-if (cap_enter() < 0)
- err(1, "cap_enter() failed");
-
-cap_rights_init(&setrights, CAP_READ);
-if (cap_rights_limit(fd, &setrights) < 0)
- err(1, "cap_rights_limit() failed");
-
-buf[0] = 'X';
-
-if (write(fd, buf, sizeof(buf)) > 0)
- errx(1, "write() succeeded!");
-
-if (read(fd, buf, sizeof(buf)) < 0)
- err(1, "read() failed");
-.Ed
-.Sh ERRORS
-.Fn cap_rights_limit
-succeeds unless:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument is not a valid active descriptor.
-.It Bq Er EINVAL
-An invalid right has been requested in
-.Fa rights .
-.It Bq Er ENOSYS
-The running kernel was compiled without
-.Cd "options CAPABILITY_MODE" .
-.It Bq Er ENOTCAPABLE
-The
-.Fa rights
-argument contains capability rights not present for the given file descriptor.
-Capability rights list can only be reduced, never expanded.
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr accept4 2 ,
-.Xr cap_enter 2 ,
-.Xr fhopen 2 ,
-.Xr kqueue 2 ,
-.Xr mq_open 2 ,
-.Xr open 2 ,
-.Xr openat 2 ,
-.Xr pdfork 2 ,
-.Xr pipe 2 ,
-.Xr read 2 ,
-.Xr shm_open 2 ,
-.Xr socket 2 ,
-.Xr socketpair 2 ,
-.Xr write 2 ,
-.Xr cap_rights_get 3 ,
-.Xr cap_rights_init 3 ,
-.Xr err 3 ,
-.Xr capsicum 4 ,
-.Xr rights 4
-.Sh HISTORY
-The
-.Fn cap_rights_limit
-function first appeared in
-.Fx 8.3 .
-Support for capabilities and capabilities mode was developed as part of the
-.Tn TrustedBSD
-Project.
-.Sh AUTHORS
-This function was created by
-.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net
-under sponsorship of the FreeBSD Foundation.
diff --git a/lib/libc/sys/chdir.2 b/lib/libc/sys/chdir.2
deleted file mode 100644
index 9ea9472df5a2..000000000000
--- a/lib/libc/sys/chdir.2
+++ /dev/null
@@ -1,133 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)chdir.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd March 30, 2020
-.Dt CHDIR 2
-.Os
-.Sh NAME
-.Nm chdir ,
-.Nm fchdir
-.Nd change current working directory
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn chdir "const char *path"
-.Ft int
-.Fn fchdir "int fd"
-.Sh DESCRIPTION
-The
-.Fa path
-argument points to the pathname of a directory.
-The
-.Fn chdir
-system call
-causes the named directory
-to become the current working directory, that is,
-the starting point for path searches of pathnames not beginning with
-a slash,
-.Ql / .
-.Pp
-The
-.Fn fchdir
-system call
-causes the directory referenced by
-.Fa fd
-to become the current working directory,
-the starting point for path searches of pathnames not beginning with
-a slash,
-.Ql / .
-.Pp
-In order for a directory to become the current directory,
-a process must have execute (search) access to the directory.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn chdir
-system call
-will fail and the current working directory will be unchanged if
-one or more of the following are true:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named directory does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EACCES
-Search permission is denied for any component of
-the path name.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-The
-.Fn fchdir
-system call
-will fail and the current working directory will be unchanged if
-one or more of the following are true:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for the directory referenced by the
-file descriptor.
-.It Bq Er ENOTDIR
-The file descriptor does not reference a directory.
-.It Bq Er EBADF
-The argument
-.Fa fd
-is not a valid file descriptor.
-.El
-.Sh SEE ALSO
-.Xr chroot 2
-.Sh STANDARDS
-The
-.Fn chdir
-system call is expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn chdir
-system call appeared in
-.At v1 .
-The
-.Fn fchdir
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2
deleted file mode 100644
index 2529ba4cb0fe..000000000000
--- a/lib/libc/sys/chflags.2
+++ /dev/null
@@ -1,358 +0,0 @@
-.\" Copyright (c) 1989, 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.
-.\"
-.\" @(#)chflags.2 8.3 (Berkeley) 5/2/95
-.\"
-.Dd March 30, 2021
-.Dt CHFLAGS 2
-.Os
-.Sh NAME
-.Nm chflags ,
-.Nm lchflags ,
-.Nm fchflags ,
-.Nm chflagsat
-.Nd set file flags
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.In unistd.h
-.Ft int
-.Fn chflags "const char *path" "unsigned long flags"
-.Ft int
-.Fn lchflags "const char *path" "unsigned long flags"
-.Ft int
-.Fn fchflags "int fd" "unsigned long flags"
-.Ft int
-.Fn chflagsat "int fd" "const char *path" "unsigned long flags" "int atflag"
-.Sh DESCRIPTION
-The file whose name
-is given by
-.Fa path
-or referenced by the descriptor
-.Fa fd
-has its flags changed to
-.Fa flags .
-.Pp
-The
-.Fn lchflags
-system call is like
-.Fn chflags
-except in the case where the named file is a symbolic link,
-in which case
-.Fn lchflags
-will change the flags of the link itself,
-rather than the file it points to.
-.Pp
-The
-.Fn chflagsat
-is equivalent to either
-.Fn chflags
-or
-.Fn lchflags
-depending on the
-.Fa atflag
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the file to be changed is determined relative to the directory
-associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-The values for the
-.Fa atflag
-are constructed by a bitwise-inclusive OR of flags from the following list,
-defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_NOFOLLOW
-If
-.Fa path
-names a symbolic link, then the flags of the symbolic link are changed.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa path
-argument is an empty string, operate on the file or directory
-referenced by the descriptor
-.Fa fd .
-If
-.Fa fd
-is equal to
-.Dv AT_FDCWD ,
-operate on the current working directory.
-.El
-.Pp
-If
-.Fn chflagsat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used.
-If also
-.Fa atflag
-is zero, the behavior is identical to a call to
-.Fn chflags .
-.Pp
-The flags specified are formed by
-.Em or Ns 'ing
-the following values
-.Pp
-.Bl -tag -width ".Dv SF_IMMUTABLE" -compact -offset indent
-.It Dv SF_APPEND
-The file may only be appended to.
-.It Dv SF_ARCHIVED
-The file has been archived.
-This flag means the opposite of the DOS, Windows and CIFS
-FILE_ATTRIBUTE_ARCHIVE attribute.
-This flag has been deprecated, and may be removed in a future release.
-.It Dv SF_IMMUTABLE
-The file may not be changed.
-.It Dv SF_NOUNLINK
-The file may not be renamed or deleted.
-.It Dv SF_SNAPSHOT
-The file is a snapshot file.
-.It Dv UF_APPEND
-The file may only be appended to.
-.It Dv UF_ARCHIVE
-The file needs to be archived.
-This flag has the same meaning as the DOS, Windows and CIFS
-FILE_ATTRIBUTE_ARCHIVE attribute.
-Filesystems in FreeBSD may or may not have special handling for this flag.
-For instance, ZFS tracks changes to files and will set this bit when a
-file is updated.
-UFS only stores the flag, and relies on the application to change it when
-needed.
-.It Dv UF_HIDDEN
-The file may be hidden from directory listings at the application's
-discretion.
-The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_HIDDEN attribute.
-.It Dv UF_IMMUTABLE
-The file may not be changed.
-.It Dv UF_NODUMP
-Do not dump the file.
-.It Dv UF_NOUNLINK
-The file may not be renamed or deleted.
-.It Dv UF_OFFLINE
-The file is offline, or has the Windows and CIFS FILE_ATTRIBUTE_OFFLINE
-attribute.
-Filesystems in FreeBSD store and display this flag, but do not provide any
-special handling when it is set.
-.It Dv UF_OPAQUE
-The directory is opaque when viewed through a union stack.
-.It Dv UF_READONLY
-The file is read only, and may not be written or appended.
-Filesystems may use this flag to maintain compatibility with the DOS, Windows
-and CIFS FILE_ATTRIBUTE_READONLY attribute.
-.It Dv UF_REPARSE
-The file contains a Windows reparse point and has the Windows and CIFS
-FILE_ATTRIBUTE_REPARSE_POINT attribute.
-.It Dv UF_SPARSE
-The file has the Windows FILE_ATTRIBUTE_SPARSE_FILE attribute.
-This may also be used by a filesystem to indicate a sparse file.
-.It Dv UF_SYSTEM
-The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_SYSTEM attribute.
-Filesystems in FreeBSD may store and display this flag, but do not provide
-any special handling when it is set.
-.El
-.Pp
-If one of
-.Dv SF_IMMUTABLE , SF_APPEND ,
-or
-.Dv SF_NOUNLINK
-is set a non-super-user cannot change any flags and even the super-user
-can change flags only if securelevel is 0.
-(See
-.Xr init 8
-for details.)
-.Pp
-The
-.Dv UF_IMMUTABLE , UF_APPEND , UF_NOUNLINK , UF_NODUMP ,
-and
-.Dv UF_OPAQUE
-flags may be set or unset by either the owner of a file or the super-user.
-.Pp
-The
-.Dv SF_IMMUTABLE , SF_APPEND , SF_NOUNLINK ,
-and
-.Dv SF_ARCHIVED
-flags may only be set or unset by the super-user.
-Attempts to toggle these flags by non-super-users are rejected.
-These flags may be set at any time, but normally may only be unset when
-the system is in single-user mode.
-(See
-.Xr init 8
-for details.)
-.Pp
-The implementation of all flags is filesystem-dependent.
-See the description of the
-.Dv UF_ARCHIVE
-flag above for one example of the differences in behavior.
-Care should be exercised when writing applications to account for
-support or lack of support of these flags in various filesystems.
-.Pp
-The
-.Dv SF_SNAPSHOT
-flag is maintained by the system and cannot be toggled.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn chflags
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The effective user ID does not match the owner of the file and
-the effective user ID is not the super-user.
-.It Bq Er EPERM
-One of
-.Dv SF_IMMUTABLE , SF_APPEND ,
-or
-.Dv SF_NOUNLINK
-is set and the user is either not the super-user or
-securelevel is greater than 0.
-.It Bq Er EPERM
-A non-super-user attempted to toggle one of
-.Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND ,
-or
-.Dv SF_NOUNLINK .
-.It Bq Er EPERM
-An attempt was made to toggle the
-.Dv SF_SNAPSHOT
-flag.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EOPNOTSUPP
-The underlying file system does not support file flags, or
-does not support all of the flags set in
-.Fa flags .
-.El
-.Pp
-The
-.Fn fchflags
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The descriptor is not valid.
-.It Bq Er EINVAL
-The
-.Fa fd
-argument
-refers to a socket, not to a file.
-.It Bq Er EPERM
-The effective user ID does not match the owner of the file and
-the effective user ID is not the super-user.
-.It Bq Er EPERM
-One of
-.Dv SF_IMMUTABLE , SF_APPEND ,
-or
-.Dv SF_NOUNLINK
-is set and the user is either not the super-user or
-securelevel is greater than 0.
-.It Bq Er EPERM
-A non-super-user attempted to toggle one of
-.Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND ,
-or
-.Dv SF_NOUNLINK .
-.It Bq Er EPERM
-An attempt was made to toggle the
-.Dv SF_SNAPSHOT
-flag.
-.It Bq Er EROFS
-The file resides on a read-only file system.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EOPNOTSUPP
-The underlying file system does not support file flags, or
-does not support all of the flags set in
-.Fa flags .
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Sh SEE ALSO
-.Xr chflags 1 ,
-.Xr fflagstostr 3 ,
-.Xr strtofflags 3 ,
-.Xr init 8 ,
-.Xr mount_unionfs 8
-.Sh HISTORY
-The
-.Fn chflags
-and
-.Fn fchflags
-system calls first appeared in
-.Bx 4.4 .
-The
-.Fn lchflags
-system call first appeared in
-.Fx 5.0 .
-The
-.Fn chflagsat
-system call first appeared in
-.Fx 10.0 .
diff --git a/lib/libc/sys/chmod.2 b/lib/libc/sys/chmod.2
deleted file mode 100644
index 7bcf19d50a1d..000000000000
--- a/lib/libc/sys/chmod.2
+++ /dev/null
@@ -1,359 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)chmod.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2021
-.Dt CHMOD 2
-.Os
-.Sh NAME
-.Nm chmod ,
-.Nm fchmod ,
-.Nm lchmod ,
-.Nm fchmodat
-.Nd change mode of file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.Ft int
-.Fn chmod "const char *path" "mode_t mode"
-.Ft int
-.Fn fchmod "int fd" "mode_t mode"
-.Ft int
-.Fn lchmod "const char *path" "mode_t mode"
-.Ft int
-.Fn fchmodat "int fd" "const char *path" "mode_t mode" "int flag"
-.Sh DESCRIPTION
-The file permission bits of the file named specified by
-.Fa path
-or referenced by the file descriptor
-.Fa fd
-are changed to
-.Fa mode .
-The
-.Fn chmod
-system call verifies that the process owner (user) either owns
-the file specified by
-.Fa path
-(or
-.Fa fd ) ,
-or
-is the super-user.
-The
-.Fn chmod
-system call follows symbolic links to operate on the target of the link
-rather than the link itself.
-.Pp
-The
-.Fn lchmod
-system call is similar to
-.Fn chmod
-but does not follow symbolic links.
-.Pp
-The
-.Fn fchmodat
-is equivalent to either
-.Fn chmod
-or
-.Fn lchmod
-depending on the
-.Fa flag
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the file to be changed is determined relative to the directory
-associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-The values for the
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from the following list, defined
-in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_NOFOLLOW
-If
-.Fa path
-names a symbolic link, then the mode of the symbolic link is changed.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa path
-argument is an empty string, operate on the file or directory
-referenced by the descriptor
-.Fa fd .
-If
-.Fa fd
-is equal to
-.Dv AT_FDCWD ,
-operate on the current working directory.
-.El
-.Pp
-If
-.Fn fchmodat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used.
-If also
-.Fa flag
-is zero, the behavior is identical to a call to
-.Fn chmod .
-.Pp
-A mode is created from
-.Em or'd
-permission bit masks
-defined in
-.In sys/stat.h :
-.Pp
-.Bd -literal -offset indent -compact
-#define S_IRWXU 0000700 /* RWX mask for owner */
-#define S_IRUSR 0000400 /* R for owner */
-#define S_IWUSR 0000200 /* W for owner */
-#define S_IXUSR 0000100 /* X for owner */
-
-#define S_IRWXG 0000070 /* RWX mask for group */
-#define S_IRGRP 0000040 /* R for group */
-#define S_IWGRP 0000020 /* W for group */
-#define S_IXGRP 0000010 /* X for group */
-
-#define S_IRWXO 0000007 /* RWX mask for other */
-#define S_IROTH 0000004 /* R for other */
-#define S_IWOTH 0000002 /* W for other */
-#define S_IXOTH 0000001 /* X for other */
-
-#define S_ISUID 0004000 /* set user id on execution */
-#define S_ISGID 0002000 /* set group id on execution */
-#define S_ISVTX 0001000 /* sticky bit */
-.Ed
-.Pp
-The non-standard
-.Dv S_ISTXT
-is a synonym for
-.Dv S_ISVTX .
-.Pp
-The
-.Fx
-VM system totally ignores the sticky bit
-.Pq Dv S_ISVTX
-for executables.
-On UFS-based file systems (FFS, LFS) the sticky
-bit may only be set upon directories.
-.Pp
-If mode
-.Dv S_ISVTX
-(the `sticky bit') is set on a directory,
-an unprivileged user may not delete or rename
-files of other users in that directory.
-The sticky bit may be
-set by any user on a directory which the user owns or has appropriate
-permissions.
-For more details of the properties of the sticky bit, see
-.Xr sticky 7 .
-.Pp
-If mode ISUID (set UID) is set on a directory,
-and the MNT_SUIDDIR option was used in the mount of the file system,
-then the owner of any new files and sub-directories
-created within this directory are set
-to be the same as the owner of that directory.
-If this function is enabled, new directories will inherit
-the bit from their parents.
-Execute bits are removed from
-the file, and it will not be given to root.
-This behavior does not change the
-requirements for the user to be allowed to write the file, but only the eventual
-owner after it has been created.
-Group inheritance is not affected.
-.Pp
-This feature is designed for use on fileservers serving PC users via
-ftp, SAMBA, or netatalk.
-It provides security holes for shell users and as
-such should not be used on shell machines, especially on home directories.
-This option requires the SUIDDIR
-option in the kernel to work.
-Only UFS file systems support this option.
-For more details of the suiddir mount option, see
-.Xr mount 8 .
-.Pp
-Writing or changing the owner of a file
-turns off the set-user-id and set-group-id bits
-unless the user is the super-user.
-This makes the system somewhat more secure
-by protecting set-user-id (set-group-id) files
-from remaining set-user-id (set-group-id) if they are modified,
-at the expense of a degree of compatibility.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn chmod
-system call
-will fail and the file mode will be unchanged if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The effective user ID does not match the owner of the file and
-the effective user ID is not the super-user.
-.It Bq Er EPERM
-The effective user ID is not the super-user, the effective user ID do match the
-owner of the file, but the group ID of the file does not match the effective
-group ID nor one of the supplementary group IDs.
-.It Bq Er EPERM
-The named file has its immutable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFTYPE
-The effective user ID is not the super-user, the mode includes the sticky bit
-.Dv ( S_ISVTX ) ,
-and path does not refer to a directory.
-.El
-.Pp
-The
-.Fn fchmod
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The descriptor is not valid.
-.It Bq Er EINVAL
-The
-.Fa fd
-argument
-refers to a socket, not to a file.
-.It Bq Er EROFS
-The file resides on a read-only file system.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-In addition to the
-.Fn chmod
-errors,
-.Fn fchmodat
-fails if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Fa AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Sh SEE ALSO
-.Xr chmod 1 ,
-.Xr chflags 2 ,
-.Xr chown 2 ,
-.Xr open 2 ,
-.Xr stat 2 ,
-.Xr sticky 7
-.Sh STANDARDS
-The
-.Fn chmod
-system call is expected to conform to
-.St -p1003.1-90 ,
-except for the return of
-.Er EFTYPE .
-The
-.Dv S_ISVTX
-bit on directories is expected to conform to
-.St -susv3 .
-The
-.Fn fchmodat
-system call is expected to conform to
-.St -p1003.1-2008 .
-.Sh HISTORY
-The
-.Fn chmod
-function appeared in
-.At v1 .
-The
-.Fn fchmod
-system call appeared in
-.Bx 4.2 .
-The
-.Fn lchmod
-system call appeared in
-.Fx 3.0 .
-The
-.Fn fchmodat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/chown.2 b/lib/libc/sys/chown.2
deleted file mode 100644
index bf8c7d4b0856..000000000000
--- a/lib/libc/sys/chown.2
+++ /dev/null
@@ -1,300 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)chown.2 8.4 (Berkeley) 4/19/94
-.\"
-.Dd March 30, 2021
-.Dt CHOWN 2
-.Os
-.Sh NAME
-.Nm chown ,
-.Nm fchown ,
-.Nm lchown ,
-.Nm fchownat
-.Nd change owner and group of a file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn chown "const char *path" "uid_t owner" "gid_t group"
-.Ft int
-.Fn fchown "int fd" "uid_t owner" "gid_t group"
-.Ft int
-.Fn lchown "const char *path" "uid_t owner" "gid_t group"
-.Ft int
-.Fn fchownat "int fd" "const char *path" "uid_t owner" "gid_t group" "int flag"
-.Sh DESCRIPTION
-The owner ID and group ID of the file
-named by
-.Fa path
-or referenced by
-.Fa fd
-is changed as specified by the arguments
-.Fa owner
-and
-.Fa group .
-The owner of a file may change the
-.Fa group
-to a group of which
-he or she is a member,
-but the change
-.Fa owner
-capability is restricted to the super-user.
-.Pp
-The
-.Fn chown
-system call
-clears the set-user-id and set-group-id bits
-on the file
-to prevent accidental or mischievous creation of
-set-user-id and set-group-id programs if not executed
-by the super-user.
-The
-.Fn chown
-system call
-follows symbolic links to operate on the target of the link
-rather than the link itself.
-.Pp
-The
-.Fn fchown
-system call
-is particularly useful when used in conjunction
-with the file locking primitives (see
-.Xr flock 2 ) .
-.Pp
-The
-.Fn lchown
-system call is similar to
-.Fn chown
-but does not follow symbolic links.
-.Pp
-The
-.Fn fchownat
-system call is equivalent to the
-.Fn chown
-and
-.Fn lchown
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the file to be changed is determined relative to the directory
-associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-.Pp
-Values for
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from the following
-list, defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_NOFOLLOW
-If
-.Fa path
-names a symbolic link, ownership of the symbolic link is changed.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa path
-argument is an empty string, operate on the file or directory
-referenced by the descriptor
-.Fa fd .
-If
-.Fa fd
-is equal to
-.Dv AT_FDCWD ,
-operate on the current working directory.
-.El
-.Pp
-If
-.Fn fchownat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is identical
-to a call to
-.Fn chown
-or
-.Fn lchown
-respectively, depending on whether or not the
-.Dv AT_SYMLINK_NOFOLLOW
-bit is set in the
-.Fa flag
-argument.
-.Pp
-One of the owner or group id's
-may be left unchanged by specifying it as -1.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn chown
-and
-.Fn lchown
-will fail and the file will be unchanged if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The operation would change the ownership, but the effective user ID is not the
-super-user.
-.It Bq Er EPERM
-The named file has its immutable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-The
-.Fn fchown
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-does not refer to a valid descriptor.
-.It Bq Er EINVAL
-The
-.Fa fd
-argument
-refers to a socket, not a file.
-.It Bq Er EPERM
-The effective user ID is not the super-user.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-In addition to the errors specified for
-.Fn chown
-and
-.Fn lchown ,
-the
-.Fn fchownat
-system call may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Sh SEE ALSO
-.Xr chgrp 1 ,
-.Xr chflags 2 ,
-.Xr chmod 2 ,
-.Xr flock 2 ,
-.Xr chown 8
-.Sh STANDARDS
-The
-.Fn chown
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn fchownat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn chown
-function appeared in
-.At v1 .
-The
-.Fn fchown
-system call appeared in
-.Bx 4.2 .
-.Pp
-The
-.Fn chown
-system call was changed to follow symbolic links in
-.Bx 4.4 .
-The
-.Fn lchown
-system call was added in
-.Fx 3.0
-to compensate for the loss of functionality.
-.Pp
-The
-.Fn fchownat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/chroot.2 b/lib/libc/sys/chroot.2
deleted file mode 100644
index af37a58794b8..000000000000
--- a/lib/libc/sys/chroot.2
+++ /dev/null
@@ -1,164 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)chroot.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd September 29, 2020
-.Dt CHROOT 2
-.Os
-.Sh NAME
-.Nm chroot
-.Nd change root directory
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn chroot "const char *dirname"
-.Sh DESCRIPTION
-The
-.Fa dirname
-argument
-is the address of the pathname of a directory, terminated by an ASCII NUL.
-The
-.Fn chroot
-system call causes
-.Fa dirname
-to become the root directory,
-that is, the starting point for path searches of pathnames
-beginning with
-.Ql / .
-.Pp
-In order for a directory to become the root directory
-a process must have execute (search) access for that directory.
-.Pp
-It should be noted that
-.Fn chroot
-has no effect on the process's current directory.
-.Pp
-This call is restricted to the super-user.
-.Pp
-Depending on the setting of the
-.Ql kern.chroot_allow_open_directories
-sysctl variable, open filedescriptors which reference directories
-will make the
-.Fn chroot
-fail as follows:
-.Pp
-If
-.Ql kern.chroot_allow_open_directories
-is set to zero,
-.Fn chroot
-will always fail with
-.Er EPERM
-if there are any directories open.
-.Pp
-If
-.Ql kern.chroot_allow_open_directories
-is set to one (the default),
-.Fn chroot
-will fail with
-.Er EPERM
-if there are any directories open and the
-process is already subject to the
-.Fn chroot
-system call.
-.Pp
-Any other value for
-.Ql kern.chroot_allow_open_directories
-will bypass the check for open directories,
-mimicking the historic insecure behavior of
-.Fn chroot
-still present on other systems.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn chroot
-system call
-will fail and the root directory will be unchanged if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path name is not a directory.
-.It Bq Er EPERM
-The effective user ID is not the super-user, or one or more
-filedescriptors are open directories.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named directory does not exist.
-.It Bq Er EACCES
-Search permission is denied for any component of the path name.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EFAULT
-The
-.Fa dirname
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh SEE ALSO
-.Xr chdir 2 ,
-.Xr jail 2
-.Sh HISTORY
-The
-.Fn chroot
-system call appeared in
-.At v7 .
-It was marked as
-.Dq legacy
-in
-.St -susv2 ,
-and was removed in subsequent standards.
-.Sh BUGS
-If the process is able to change its working directory to the target
-directory, but another access control check fails (such as a check for
-open directories, or a MAC check), it is possible that this system
-call may return an error, with the working directory of the process
-left changed.
-.Sh SECURITY CONSIDERATIONS
-The system has many hardcoded paths to files which it may load after
-the process starts.
-It is generally recommended to drop privileges immediately after a
-successful
-.Nm
-call,
-and restrict write access to a limited subtree of the
-.Nm
-root.
-For instance,
-setup the sandbox so that the sandboxed user will have no write
-access to any well-known system directories.
-.Pp
-For complete isolation from the rest of the system, use
-.Xr jail 2
-instead.
diff --git a/lib/libc/sys/clock_gettime.2 b/lib/libc/sys/clock_gettime.2
deleted file mode 100644
index ed469153a40e..000000000000
--- a/lib/libc/sys/clock_gettime.2
+++ /dev/null
@@ -1,207 +0,0 @@
-.\" $OpenBSD: clock_gettime.2,v 1.4 1997/05/08 20:21:16 kstailey Exp $
-.\"
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.Dd July 8, 2022
-.Dt CLOCK_GETTIME 2
-.Os
-.Sh NAME
-.Nm clock_gettime ,
-.Nm clock_settime ,
-.Nm clock_getres
-.Nd get/set/calibrate date and time
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In time.h
-.Ft int
-.Fn clock_gettime "clockid_t clock_id" "struct timespec *tp"
-.Ft int
-.Fn clock_settime "clockid_t clock_id" "const struct timespec *tp"
-.Ft int
-.Fn clock_getres "clockid_t clock_id" "struct timespec *tp"
-.Sh DESCRIPTION
-The
-.Fn clock_gettime
-and
-.Fn clock_settime
-system calls allow the calling process to retrieve or set the value
-used by a clock which is specified by
-.Fa clock_id .
-.Pp
-The
-.Fa clock_id
-argument can be a value obtained from
-.Xr clock_getcpuclockid 3
-or
-.Xr pthread_getcpuclockid 3
-as well as the following values:
-.Pp
-.Bl -tag -width indent -compact
-.It Dv CLOCK_REALTIME
-.It Dv CLOCK_REALTIME_PRECISE
-.It Dv CLOCK_REALTIME_FAST
-.It Dv CLOCK_REALTIME_COARSE
-Increments as a wall clock should.
-.It Dv CLOCK_MONOTONIC
-.It Dv CLOCK_MONOTONIC_PRECISE
-.It Dv CLOCK_MONOTONIC_FAST
-.It Dv CLOCK_MONOTONIC_COARSE
-Increments in SI seconds.
-.It Dv CLOCK_UPTIME
-.It Dv CLOCK_UPTIME_PRECISE
-.It Dv CLOCK_UPTIME_FAST
-.It Dv CLOCK_BOOTTIME
-Starts at zero when the kernel boots and increments
-monotonically in SI seconds while the machine is running.
-.It Dv CLOCK_VIRTUAL
-Increments only when
-the CPU is running in user mode on behalf of the calling process.
-.It Dv CLOCK_PROF
-Increments when the CPU is running in user or kernel mode.
-.It Dv CLOCK_SECOND
-Returns the current second without performing a full time counter
-query, using an in-kernel cached value of the current second.
-.It Dv CLOCK_PROCESS_CPUTIME_ID
-Returns the execution time of the calling process.
-.It Dv CLOCK_THREAD_CPUTIME_ID
-Returns the execution time of the calling thread.
-.El
-.Pp
-The clock IDs
-.Fa CLOCK_REALTIME ,
-.Fa CLOCK_MONOTONIC ,
-and
-.Fa CLOCK_UPTIME
-perform a full time counter query.
-The clock IDs with the _FAST suffix, i.e.,
-.Fa CLOCK_REALTIME_FAST ,
-.Fa CLOCK_MONOTONIC_FAST ,
-and
-.Fa CLOCK_UPTIME_FAST ,
-do not perform
-a full time counter query, so their accuracy is one timer tick.
-Similarly,
-.Fa CLOCK_REALTIME_PRECISE ,
-.Fa CLOCK_MONOTONIC_PRECISE ,
-and
-.Fa CLOCK_UPTIME_PRECISE
-are used to get the most exact value as possible, at the expense of
-execution time.
-The clock IDs
-.Fa CLOCK_REALTIME_COARSE
-and
-.Fa CLOCK_MONOTONIC_COARSE
-are aliases of corresponding IDs with _FAST suffix for compatibility with other
-systems.
-Finally,
-.Dv CLOCK_BOOTTIME
-is an alias for
-.Dv CLOCK_UPTIME
-for compatibility with other systems.
-.Pp
-The structure pointed to by
-.Fa tp
-is defined in
-.In sys/timespec.h
-as:
-.Bd -literal
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* and nanoseconds */
-};
-.Ed
-.Pp
-Only the super-user may set the time of day, using only
-.Fa CLOCK_REALTIME .
-If the system
-.Xr securelevel 7
-is greater than 1 (see
-.Xr init 8 ) ,
-the time may only be advanced.
-This limitation is imposed to prevent a malicious super-user
-from setting arbitrary time stamps on files.
-The system time can still be adjusted backwards using the
-.Xr adjtime 2
-system call even when the system is secure.
-.Pp
-The resolution (granularity) of a clock is returned by the
-.Fn clock_getres
-system call.
-This value is placed in a (non-NULL)
-.Fa *tp .
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The following error codes may be set in
-.Va errno :
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa clock_id
-or
-.Fa timespec
-argument
-was not a valid value.
-.It Bq Er EPERM
-A user other than the super-user attempted to set the time.
-.El
-.Sh SEE ALSO
-.Xr date 1 ,
-.Xr adjtime 2 ,
-.Xr clock_getcpuclockid 3 ,
-.Xr ctime 3 ,
-.Xr pthread_getcpuclockid 3
-.Sh STANDARDS
-The
-.Fn clock_gettime ,
-.Fn clock_settime ,
-and
-.Fn clock_getres
-system calls conform to
-.St -p1003.1b-93 .
-The clock IDs
-.Fa CLOCK_REALTIME_FAST ,
-.Fa CLOCK_REALTIME_PRECISE ,
-.Fa CLOCK_MONOTONIC_FAST ,
-.Fa CLOCK_MONOTONIC_PRECISE ,
-.Fa CLOCK_UPTIME ,
-.Fa CLOCK_UPTIME_FAST ,
-.Fa CLOCK_UPTIME_PRECISE ,
-.Fa CLOCK_SECOND
-are
-.Fx
-extensions to the POSIX interface.
-.Sh HISTORY
-The
-.Fn clock_gettime ,
-.Fn clock_settime ,
-and
-.Fn clock_getres
-system calls first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/clock_gettime.c b/lib/libc/sys/clock_gettime.c
deleted file mode 100644
index 7894dbf4ef5a..000000000000
--- a/lib/libc/sys/clock_gettime.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <errno.h>
-#include <time.h>
-#include "libc_private.h"
-
-int __clock_gettime(clockid_t, struct timespec *ts);
-
-__weak_reference(__clock_gettime, clock_gettime);
-
-int
-__clock_gettime(clockid_t clock_id, struct timespec *ts)
-{
- int error;
-
- if (__vdso_clock_gettime != NULL && __vdso_gettc != NULL)
- error = __vdso_clock_gettime(clock_id, ts);
- else
- error = ENOSYS;
- if (error == ENOSYS) {
- error = __sys_clock_gettime(clock_id, ts);
- } else if (error != 0) {
- errno = error;
- error = -1;
- }
- return (error);
-}
diff --git a/lib/libc/sys/clock_nanosleep.c b/lib/libc/sys/clock_nanosleep.c
index 9989f1a995f5..a50af30e1fb3 100644
--- a/lib/libc/sys/clock_nanosleep.c
+++ b/lib/libc/sys/clock_nanosleep.c
@@ -30,7 +30,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <time.h>
#include "libc_private.h"
@@ -42,9 +41,5 @@ int
clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
struct timespec *rmtp)
{
-
- return (((int (*)(clockid_t, int, const struct timespec *,
- struct timespec *))
- __libc_interposing[INTERPOS_clock_nanosleep])(clock_id, flags,
- rqtp, rmtp));
+ return (INTERPOS_SYS(clock_nanosleep, clock_id, flags, rqtp, rmtp));
}
diff --git a/lib/libc/sys/close.2 b/lib/libc/sys/close.2
deleted file mode 100644
index aba9cac5ae8a..000000000000
--- a/lib/libc/sys/close.2
+++ /dev/null
@@ -1,143 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)close.2 8.2 (Berkeley) 4/19/94
-.\"
-.Dd December 1, 2017
-.Dt CLOSE 2
-.Os
-.Sh NAME
-.Nm close
-.Nd delete a descriptor
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn close "int fd"
-.Sh DESCRIPTION
-The
-.Fn close
-system call deletes a descriptor from the per-process object
-reference table.
-If this is the last reference to the underlying object, the
-object will be deactivated.
-For example, on the last close of a file
-the current
-.Em seek
-pointer associated with the file is lost;
-on the last close of a
-.Xr socket 2
-associated naming information and queued data are discarded;
-on the last close of a file holding an advisory lock
-the lock is released (see further
-.Xr flock 2 ) .
-However, the semantics of System V and
-.St -p1003.1-88
-dictate that all
-.Xr fcntl 2
-advisory record locks associated with a file for a given process
-are removed when
-.Em any
-file descriptor for that file is closed by that process.
-.Pp
-When a process exits,
-all associated file descriptors are freed, but since there is
-a limit on active descriptors per processes, the
-.Fn close
-system call
-is useful when a large quantity of file descriptors are being handled.
-.Pp
-When a process forks (see
-.Xr fork 2 ) ,
-all descriptors for the new child process reference the same
-objects as they did in the parent before the fork.
-If a new process is then to be run using
-.Xr execve 2 ,
-the process would normally inherit these descriptors.
-Most
-of the descriptors can be rearranged with
-.Xr dup2 2
-or deleted with
-.Fn close
-before the
-.Xr execve 2
-is attempted, but if some of these descriptors will still
-be needed if the execve fails, it is necessary to arrange for them
-to be closed if the execve succeeds.
-For this reason, the call
-.Dq Li fcntl(d, F_SETFD, FD_CLOEXEC)
-is provided,
-which arranges that a descriptor will be closed after a successful
-execve; the call
-.Dq Li fcntl(d, F_SETFD, 0)
-restores the default,
-which is to not close the descriptor.
-.Sh RETURN VALUES
-.Rv -std close
-.Sh ERRORS
-The
-.Fn close
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not an active descriptor.
-.It Bq Er EINTR
-An interrupt was received.
-.It Bq Er ENOSPC
-The underlying object did not fit, cached data was lost.
-.It Bq Er ECONNRESET
-The underlying object was a stream socket that was shut down by the peer
-before all pending data was delivered.
-.El
-.Pp
-In case of any error except
-.Er EBADF ,
-the supplied file descriptor is deallocated and therefore is no longer valid.
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr closefrom 2 ,
-.Xr execve 2 ,
-.Xr fcntl 2 ,
-.Xr flock 2 ,
-.Xr open 2 ,
-.Xr pipe 2 ,
-.Xr socket 2 ,
-.Xr socketpair 2
-.Sh STANDARDS
-The
-.Fn close
-system call is expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn close
-function appeared in
-.At v1 .
diff --git a/lib/libc/sys/close.c b/lib/libc/sys/close.c
index 0fb319b77102..08a5419361a9 100644
--- a/lib/libc/sys/close.c
+++ b/lib/libc/sys/close.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <unistd.h>
@@ -41,6 +40,5 @@ __weak_reference(__sys_close, __close);
int
close(int fd)
{
-
- return (((int (*)(int))__libc_interposing[INTERPOS_close])(fd));
+ return (INTERPOS_SYS(close, fd));
}
diff --git a/lib/libc/sys/closefrom.2 b/lib/libc/sys/closefrom.2
deleted file mode 100644
index aaa4c55607ac..000000000000
--- a/lib/libc/sys/closefrom.2
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" Copyright (c) 2009 Hudson River Trading LLC
-.\" Written by: John H. Baldwin <jhb@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.
-.\"
-.Dd March 3, 2022
-.Dt CLOSEFROM 2
-.Os
-.Sh NAME
-.Nm closefrom ,
-.Nm close_range
-.Nd delete open file descriptors
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft void
-.Fn closefrom "int lowfd"
-.Ft int
-.Fn close_range "u_int lowfd" "u_int highfd" "int flags"
-.Sh DESCRIPTION
-The
-.Fn closefrom
-system call deletes all open file descriptors greater than or equal to
-.Fa lowfd
-from the per-process object reference table.
-Any errors encountered while closing file descriptors are ignored.
-.Pp
-The
-.Fn close_range
-system call deletes all open file descriptors between
-.Fa lowfd
-and
-.Fa highfd
-inclusive, clamped to the range of open file descriptors.
-Any errors encountered while closing file descriptors are ignored.
-Supported
-.Fa flags :
-.Bl -tag -width ".Dv CLOSE_RANGE_CLOEXEC"
-.It Dv CLOSE_RANGE_CLOEXEC
-Set the close-on-exec flag on descriptors in the range instead of closing them.
-.El
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn close_range
-returns a value
-of 0.
-Otherwise, a value of -1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn close_range
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa highfd
-argument is lower than the
-.Fa lowfd
-argument.
-.It Bq Er EINVAL
-An invalid flag was set.
-.El
-.Sh SEE ALSO
-.Xr close 2
-.Sh HISTORY
-The
-.Fn closefrom
-function first appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/closefrom.c b/lib/libc/sys/closefrom.c
index 2eb8536e6968..76ed4e744397 100644
--- a/lib/libc/sys/closefrom.c
+++ b/lib/libc/sys/closefrom.c
@@ -25,22 +25,13 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
-#include <sys/syscall.h>
#include <unistd.h>
#include "libc_private.h"
-#define CLOSE_RANGE_OSREL 1300091
-
void
closefrom(int lowfd)
{
-
- if (__getosreldate() >= CLOSE_RANGE_OSREL)
- __sys_close_range(MAX(0, lowfd), ~0U, 0);
- else
- /* Fallback to closefrom(2) on older kernels. */
- syscall(SYS_freebsd12_closefrom, lowfd);
+ __sys_close_range(MAX(0, lowfd), ~0U, 0);
}
diff --git a/lib/libc/sys/compat-ino64.h b/lib/libc/sys/compat-ino64.h
deleted file mode 100644
index ded3c6c64124..000000000000
--- a/lib/libc/sys/compat-ino64.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-/*
- * Forward compatibility shim to convert old stat buffer to
- * new so we can call the old system call, but return data in
- * the new system call's format.
- */
-#define _WANT_FREEBSD11_STATFS
-#include <sys/fcntl.h>
-#include <sys/mount.h>
-
-#define _WANT_FREEBSD11_STAT
-#include <sys/stat.h>
-
-#include <string.h>
-
-#define INO64_FIRST 1200031
-
-static __inline void
-__stat11_to_stat(const struct freebsd11_stat *sb11, struct stat *sb)
-{
-
- sb->st_dev = sb11->st_dev;
- sb->st_ino = sb11->st_ino;
- sb->st_nlink = sb11->st_nlink;
- sb->st_mode = sb11->st_mode;
- sb->st_uid = sb11->st_uid;
- sb->st_gid = sb11->st_gid;
- sb->st_rdev = sb11->st_rdev;
- sb->st_atim = sb11->st_atim;
- sb->st_mtim = sb11->st_mtim;
- sb->st_ctim = sb11->st_ctim;
-#ifdef __STAT_TIME_T_EXT
- sb->st_atim_ext = 0;
- sb->st_mtim_ext = 0;
- sb->st_ctim_ext = 0;
- sb->st_btim_ext = 0;
-#endif
- sb->st_birthtim = sb11->st_birthtim;
- sb->st_size = sb11->st_size;
- sb->st_blocks = sb11->st_blocks;
- sb->st_blksize = sb11->st_blksize;
- sb->st_flags = sb11->st_flags;
- sb->st_gen = sb11->st_gen;
- sb->st_padding0 = 0;
- sb->st_padding1 = 0;
- memset(sb->st_spare, 0, sizeof(sb->st_spare));
-}
-
-static __inline void
-__statfs11_to_statfs(const struct freebsd11_statfs *sf11, struct statfs *sf)
-{
-
- sf->f_version = STATFS_VERSION;
- sf->f_type = sf11->f_type;
- sf->f_flags = sf11->f_flags;
- sf->f_bsize = sf11->f_bsize;
- sf->f_iosize = sf11->f_iosize;
- sf->f_blocks = sf11->f_blocks;
- sf->f_bfree = sf11->f_bfree;
- sf->f_bavail = sf11->f_bavail;
- sf->f_files = sf11->f_files;
- sf->f_ffree = sf11->f_ffree;
- sf->f_syncwrites = sf11->f_syncwrites;
- sf->f_asyncwrites = sf11->f_asyncwrites;
- sf->f_syncreads = sf11->f_syncreads;
- sf->f_asyncreads = sf11->f_asyncreads;
- sf->f_namemax = sf11->f_namemax;
- sf->f_owner = sf11->f_owner;
- sf->f_fsid = sf11->f_fsid;
- memset(sf->f_spare, 0, sizeof(sf->f_spare));
- memset(sf->f_charspare, 0, sizeof(sf->f_charspare));
- strlcpy(sf->f_fstypename, sf11->f_fstypename, sizeof(sf->f_fstypename));
- strlcpy(sf->f_mntfromname, sf11->f_mntfromname, sizeof(sf->f_mntfromname));
- strlcpy(sf->f_mntonname, sf11->f_mntonname, sizeof(sf->f_mntonname));
-}
diff --git a/lib/libc/sys/compat-stub.c b/lib/libc/sys/compat-stub.c
index b1dd906dc8a0..d23eaf3f89b8 100644
--- a/lib/libc/sys/compat-stub.c
+++ b/lib/libc/sys/compat-stub.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/errno.h>
diff --git a/lib/libc/sys/connect.2 b/lib/libc/sys/connect.2
deleted file mode 100644
index 3f68c3e9f557..000000000000
--- a/lib/libc/sys/connect.2
+++ /dev/null
@@ -1,184 +0,0 @@
-.\" Copyright (c) 1983, 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.
-.\"
-.\" @(#)connect.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 18, 2016
-.Dt CONNECT 2
-.Os
-.Sh NAME
-.Nm connect
-.Nd initiate a connection on a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft int
-.Fn connect "int s" "const struct sockaddr *name" "socklen_t namelen"
-.Sh DESCRIPTION
-The
-.Fa s
-argument
-is a socket.
-If it is of type
-.Dv SOCK_DGRAM ,
-this call specifies the peer with which the socket is to be associated;
-this address is that to which datagrams are to be sent,
-and the only address from which datagrams are to be received.
-If the socket is of type
-.Dv SOCK_STREAM ,
-this call attempts to make a connection to
-another socket.
-The other socket is specified by
-.Fa name ,
-which is an address in the communications space of the socket.
-.Fa namelen
-indicates the amount of space pointed to by
-.Fa name ,
-in bytes; the
-.Fa sa_len
-member of
-.Fa name
-is ignored.
-Each communications space interprets the
-.Fa name
-argument in its own way.
-Generally, stream sockets may successfully
-.Fn connect
-only once; datagram sockets may use
-.Fn connect
-multiple times to change their association.
-Datagram sockets may dissolve the association
-by connecting to an invalid address, such as a null address.
-.Sh RETURN VALUES
-.Rv -std connect
-.Sh ERRORS
-The
-.Fn connect
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa s
-argument
-is not a valid descriptor.
-.It Bq Er EINVAL
-The
-.Fa namelen
-argument is not a valid length for the address family.
-.It Bq Er ENOTSOCK
-The
-.Fa s
-argument
-is a descriptor for a file, not a socket.
-.It Bq Er EADDRNOTAVAIL
-The specified address is not available on this machine.
-.It Bq Er EAFNOSUPPORT
-Addresses in the specified address family cannot be used with this socket.
-.It Bq Er EISCONN
-The socket is already connected.
-.It Bq Er ETIMEDOUT
-Connection establishment timed out without establishing a connection.
-.It Bq Er ECONNREFUSED
-The attempt to connect was forcefully rejected.
-.It Bq Er ECONNRESET
-The connection was reset by the remote host.
-.It Bq Er ENETUNREACH
-The network is not reachable from this host.
-.It Bq Er EHOSTUNREACH
-The remote host is not reachable from this host.
-.It Bq Er EADDRINUSE
-The address is already in use.
-.It Bq Er EFAULT
-The
-.Fa name
-argument specifies an area outside
-the process address space.
-.It Bq Er EINPROGRESS
-The socket is non-blocking
-and the connection cannot
-be completed immediately.
-It is possible to
-.Xr select 2
-for completion by selecting the socket for writing.
-.It Bq Er EINTR
-The connection attempt was interrupted by the delivery of a signal.
-The connection will be established in the background,
-as in the case of
-.Er EINPROGRESS .
-.It Bq Er EALREADY
-A previous connection attempt has not yet been completed.
-.It Bq Er EACCES
-An attempt is made to connect to a broadcast address (obtained through the
-.Dv INADDR_BROADCAST
-constant or the
-.Dv INADDR_NONE
-return value) through a socket that does not provide broadcast functionality.
-.It Bq Er EAGAIN
-An auto-assigned port number was requested but no auto-assigned ports
-are available.
-Increasing the port range specified by
-.Xr sysctl 3
-MIB variables
-.Va net.inet.ip.portrange.first
-and
-.Va net.inet.ip.portrange.last
-may alleviate the problem.
-.El
-.Pp
-The following errors are specific to connecting names in the UNIX domain.
-These errors may not apply in future versions of the UNIX IPC domain.
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named socket does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-Write access to the named socket is denied.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-Write access to the named socket is denied.
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr getpeername 2 ,
-.Xr getsockname 2 ,
-.Xr select 2 ,
-.Xr socket 2 ,
-.Xr sysctl 3 ,
-.Xr sysctl 8
-.Sh HISTORY
-The
-.Fn connect
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/connect.c b/lib/libc/sys/connect.c
index 10277dfadc64..e64451683abc 100644
--- a/lib/libc/sys/connect.c
+++ b/lib/libc/sys/connect.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_connect, __connect);
int
connect(int s, const struct sockaddr *addr, socklen_t addrlen)
{
-
- return (((int (*)(int, const struct sockaddr *, socklen_t))
- __libc_interposing[INTERPOS_connect])(s, addr, addrlen));
+ return (INTERPOS_SYS(connect, s, addr, addrlen));
}
diff --git a/lib/libc/sys/copy_file_range.2 b/lib/libc/sys/copy_file_range.2
deleted file mode 100644
index c9fa593b7f4c..000000000000
--- a/lib/libc/sys/copy_file_range.2
+++ /dev/null
@@ -1,210 +0,0 @@
-.\" SPDX-License-Identifier: BSD-2-Clause
-.\"
-.\" Copyright (c) 2019 Rick Macklem
-.\"
-.\" 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.
-.\"
-.Dd January 2, 2021
-.Dt COPY_FILE_RANGE 2
-.Os
-.Sh NAME
-.Nm copy_file_range
-.Nd kernel copy of a byte range from one file to another
-or within one file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In unistd.h
-.Ft ssize_t
-.Fo copy_file_range
-.Fa "int infd"
-.Fa "off_t *inoffp"
-.Fa "int outfd"
-.Fa "off_t *outoffp"
-.Fa "size_t len"
-.Fa "unsigned int flags"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn copy_file_range
-system call
-copies up to
-.Fa len
-bytes from
-.Fa infd
-to
-.Fa outfd
-in the kernel.
-It may do this using a file system specific technique if
-.Fa infd
-and
-.Fa outfd
-are on the same file system.
-If
-.Fa infd
-and
-.Fa outfd
-refer to the same file, the byte ranges defined by
-the input file offset, output file offset and
-.Fa len
-cannot overlap.
-The
-.Fa infd
-argument must be opened for reading and the
-.Fa outfd
-argument must be opened for writing, but not
-.Dv O_APPEND .
-If
-.Fa inoffp
-or
-.Fa outoffp
-is
-.Dv NULL ,
-the file offset for
-.Fa infd
-or
-.Fa outfd
-respectively will be used and updated by
-the number of bytes copied.
-If
-.Fa inoffp
-or
-.Fa outoffp
-is not
-.Dv NULL ,
-the byte offset pointed to by
-.Fa inoffp
-or
-.Fa outoffp
-respectively will be used/updated and the file offset for
-.Fa infd
-or
-.Fa outfd
-respectively will not be affected.
-The
-.Fa flags
-argument must be 0.
-.Pp
-This system call attempts to maintain holes in the output file for
-the byte range being copied.
-However, this does not always work well.
-It is recommended that sparse files be copied in a loop using
-.Xr lseek 2
-with
-.Dv SEEK_HOLE ,
-.Dv SEEK_DATA
-arguments and this system call for the
-data ranges found.
-.Pp
-For best performance, call
-.Fn copy_file_range
-with the largest
-.Fa len
-value possible.
-It is interruptible on most file systems,
-so there is no penalty for using very large len values, even SSIZE_MAX.
-.Pp
-.Sh RETURN VALUES
-If it succeeds, the call returns the number of bytes copied, which can be fewer
-than
-.Fa len .
-Returning fewer bytes than
-.Fa len
-does not necessarily indicate that EOF was reached.
-However, a return of zero for a non-zero
-.Fa len
-argument indicates that the offset for
-.Fa infd
-is at or beyond EOF.
-.Fn copy_file_range
-should be used in a loop until copying of the desired byte range has been
-completed.
-If an error has occurred, a \-1 is returned and the error code is placed in
-the global variable
-.Va errno .
-.Sh ERRORS
-The
-.Fn copy_file_range
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-If
-.Fa infd
-is not open for reading or
-.Fa outfd
-is not open for writing, or opened for writing with
-.Dv O_APPEND ,
-or if
-.Fa infd
-and
-.Fa outfd
-refer to the same file.
-.It Bq Er EFBIG
-If the copy exceeds the process's file size limit or the maximum file size
-for the file system
-.Fa outfd
-resides on.
-.It Bq Er EINTR
-A signal interrupted the system call
-before it could be completed.
-This may happen for files on some NFS mounts.
-When this happens, the values pointed to by
-.Fa inoffp
-and
-.Fa outoffp
-are reset to the initial values for the system call.
-.It Bq Er EINVAL
-.Fa infd
-and
-.Fa outfd
-refer to the same file and the byte ranges overlap or
-.Fa flags
-is not zero.
-.It Bq Er EIO
-An I/O error occurred while reading/writing the files.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from a file system.
-.It Bq Er EISDIR
-If either
-.Fa infd
-or
-.Fa outfd
-refers to a directory.
-.It Bq Er ENOSPC
-File system that stores
-.Fa outfd
-is full.
-.El
-.Sh SEE ALSO
-.Xr lseek 2
-.Sh STANDARDS
-The
-.Fn copy_file_range
-system call is expected to be compatible with the Linux system call of
-the same name.
-.Sh HISTORY
-The
-.Fn copy_file_range
-function appeared in
-.Fx 13.0 .
diff --git a/lib/libc/sys/creat.c b/lib/libc/sys/creat.c
new file mode 100644
index 000000000000..afd626e928bb
--- /dev/null
+++ b/lib/libc/sys/creat.c
@@ -0,0 +1,49 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1989, 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.
+ */
+
+#include "namespace.h"
+#include <fcntl.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+
+__weak_reference(__creat, creat);
+__weak_reference(__creat, _creat);
+
+int __creat(const char *path, mode_t mode);
+
+#pragma weak creat
+int
+__creat(const char *path, mode_t mode)
+{
+ return (INTERPOS_SYS(openat, AT_FDCWD, path,
+ O_WRONLY | O_CREAT | O_TRUNC, mode));
+}
+
diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2
deleted file mode 100644
index 258bcc8012bb..000000000000
--- a/lib/libc/sys/dup.2
+++ /dev/null
@@ -1,170 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)dup.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 1, 2017
-.Dt DUP 2
-.Os
-.Sh NAME
-.Nm dup ,
-.Nm dup2
-.Nd duplicate an existing file descriptor
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn dup "int oldd"
-.Ft int
-.Fn dup2 "int oldd" "int newd"
-.Sh DESCRIPTION
-The
-.Fn dup
-system call
-duplicates an existing object descriptor and returns its value to
-the calling process
-.Fa ( newd
-=
-.Fn dup oldd ) .
-The argument
-.Fa oldd
-is a small non-negative integer index in
-the per-process descriptor table.
-The new descriptor returned by the call
-is the lowest numbered descriptor
-currently not in use by the process.
-.Pp
-The object referenced by the descriptor does not distinguish
-between
-.Fa oldd
-and
-.Fa newd
-in any way.
-Thus if
-.Fa newd
-and
-.Fa oldd
-are duplicate references to an open
-file,
-.Xr read 2 ,
-.Xr write 2
-and
-.Xr lseek 2
-calls all move a single pointer into the file,
-and append mode, non-blocking I/O and asynchronous I/O options
-are shared between the references.
-If a separate pointer into the file is desired, a different
-object reference to the file must be obtained by issuing an
-additional
-.Xr open 2
-system call.
-The close-on-exec flag on the new file descriptor is unset.
-.Pp
-In
-.Fn dup2 ,
-the value of the new descriptor
-.Fa newd
-is specified.
-If this descriptor is already in use and
-.Fa oldd
-\*(Ne
-.Fa newd ,
-the descriptor is first deallocated as if the
-.Xr close 2
-system call had been used.
-If
-.Fa oldd
-is not a valid descriptor, then
-.Fa newd
-is not closed.
-If
-.Fa oldd
-==
-.Fa newd
-and
-.Fa oldd
-is a valid descriptor, then
-.Fn dup2
-is successful, and does nothing.
-.Sh RETURN VALUES
-These calls return the new file descriptor if successful;
-otherwise the value -1 is returned and
-the external variable
-.Va errno
-is set to indicate the cause of the error.
-.Sh ERRORS
-The
-.Fn dup
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa oldd
-argument
-is not a valid active descriptor
-.It Bq Er EMFILE
-Too many descriptors are active.
-.El
-.Pp
-The
-.Fn dup2
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa oldd
-argument is not a valid active descriptor or the
-.Fa newd
-argument is negative or exceeds the maximum allowable descriptor number
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr close 2 ,
-.Xr fcntl 2 ,
-.Xr getdtablesize 2 ,
-.Xr open 2 ,
-.Xr pipe 2 ,
-.Xr socket 2 ,
-.Xr socketpair 2 ,
-.Xr dup3 3
-.Sh STANDARDS
-The
-.Fn dup
-and
-.Fn dup2
-system calls are expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn dup
-function appeared in
-.At v3 .
-The
-.Fn dup2
-function appeared in
-.At v7 .
diff --git a/lib/libc/sys/execve.2 b/lib/libc/sys/execve.2
deleted file mode 100644
index ca5dbd09beee..000000000000
--- a/lib/libc/sys/execve.2
+++ /dev/null
@@ -1,381 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)execve.2 8.5 (Berkeley) 6/1/94
-.\"
-.Dd January 26, 2022
-.Dt EXECVE 2
-.Os
-.Sh NAME
-.Nm execve ,
-.Nm fexecve
-.Nd execute a file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn execve "const char *path" "char *const argv[]" "char *const envp[]"
-.Ft int
-.Fn fexecve "int fd" "char *const argv[]" "char *const envp[]"
-.Sh DESCRIPTION
-The
-.Fn execve
-system call
-transforms the calling process into a new process.
-The new process is constructed from an ordinary file,
-whose name is pointed to by
-.Fa path ,
-called the
-.Em new process file .
-The
-.Fn fexecve
-system call is equivalent to
-.Fn execve
-except that the file to be executed is determined by the file
-descriptor
-.Fa fd
-instead of a
-.Fa path .
-This file is either an executable object file,
-or a file of data for an interpreter.
-An executable object file consists of an identifying header,
-followed by pages of data representing the initial program (text)
-and initialized data pages.
-Additional pages may be specified
-by the header to be initialized with zero data; see
-.Xr elf 5
-and
-.Xr a.out 5 .
-.Pp
-An interpreter file begins with a line of the form:
-.Pp
-.Bd -ragged -offset indent -compact
-.Sy \&#!
-.Em interpreter
-.Bq Em arg
-.Ed
-.Pp
-When an interpreter file is
-.Sy execve Ap d ,
-the system actually
-.Sy execve Ap s
-the specified
-.Em interpreter .
-If the optional
-.Em arg
-is specified, it becomes the first argument to the
-.Em interpreter ,
-and the name of the originally
-.Sy execve Ap d
-file becomes the second argument;
-otherwise, the name of the originally
-.Sy execve Ap d
-file becomes the first argument.
-The original arguments are shifted over to
-become the subsequent arguments.
-The zeroth argument is set to the specified
-.Em interpreter .
-.Pp
-The argument
-.Fa argv
-is a pointer to a null-terminated array of
-character pointers to null-terminated character strings.
-These strings construct the argument list to be made available to the new
-process.
-At least one argument must be present in
-the array; by custom, the first element should be
-the name of the executed program (for example, the last component of
-.Fa path ) .
-.Pp
-The argument
-.Fa envp
-is also a pointer to a null-terminated array of
-character pointers to null-terminated strings.
-A pointer to this array is normally stored in the global variable
-.Va environ .
-These strings pass information to the
-new process that is not directly an argument to the command (see
-.Xr environ 7 ) .
-.Pp
-File descriptors open in the calling process image remain open in
-the new process image, except for those for which the close-on-exec
-flag is set (see
-.Xr close 2
-and
-.Xr fcntl 2 ) .
-Descriptors that remain open are unaffected by
-.Fn execve .
-If any of the standard descriptors (0, 1, and/or 2) are closed at the
-time
-.Fn execve
-is called, and the process will gain privilege as a result of set-id
-semantics, those descriptors will be re-opened automatically.
-No programs, whether privileged or not, should assume that these descriptors
-will remain closed across a call to
-.Fn execve .
-.Pp
-Signals set to be ignored in the calling process are set to be ignored in
-the
-new process.
-Signals which are set to be caught in the calling process image
-are set to default action in the new process image.
-Blocked signals remain blocked regardless of changes to the signal action.
-The signal stack is reset to be undefined (see
-.Xr sigaction 2
-for more information).
-.Pp
-If the set-user-ID mode bit of the new process image file is set
-(see
-.Xr chmod 2 ) ,
-the effective user ID of the new process image is set to the owner ID
-of the new process image file.
-If the set-group-ID mode bit of the new process image file is set,
-the effective group ID of the new process image is set to the group ID
-of the new process image file.
-(The effective group ID is the first element of the group list.)
-The real user ID, real group ID and
-other group IDs of the new process image remain the same as the calling
-process image.
-After any set-user-ID and set-group-ID processing,
-the effective user ID is recorded as the saved set-user-ID,
-and the effective group ID is recorded as the saved set-group-ID.
-These values may be used in changing the effective IDs later (see
-.Xr setuid 2 ) .
-.Pp
-The set-ID bits are not honored if the respective file system has the
-.Cm nosuid
-option enabled or if the new process file is an interpreter file.
-Syscall
-tracing is disabled if effective IDs are changed.
-.Pp
-The new process also inherits the following attributes from
-the calling process:
-.Pp
-.Bl -column parent_process_ID -offset indent -compact
-.It process ID Ta see Xr getpid 2
-.It parent process ID Ta see Xr getppid 2
-.It process group ID Ta see Xr getpgrp 2
-.It access groups Ta see Xr getgroups 2
-.It working directory Ta see Xr chdir 2
-.It root directory Ta see Xr chroot 2
-.It control terminal Ta see Xr termios 4
-.It resource usages Ta see Xr getrusage 2
-.It interval timers Ta see Xr getitimer 2
-.It resource limits Ta see Xr getrlimit 2
-.It file mode mask Ta see Xr umask 2
-.It signal mask Ta see Xr sigaction 2 ,
-.Xr sigprocmask 2
-.El
-.Pp
-When a program is executed as a result of an
-.Fn execve
-system call, it is entered as follows:
-.Bd -literal -offset indent
-main(argc, argv, envp)
-int argc;
-char **argv, **envp;
-.Ed
-.Pp
-where
-.Fa argc
-is the number of elements in
-.Fa argv
-(the ``arg count'')
-and
-.Fa argv
-points to the array of character pointers
-to the arguments themselves.
-.Pp
-The
-.Fn fexecve
-ignores the file offset of
-.Fa fd .
-Since execute permission is checked by
-.Fn fexecve ,
-the file descriptor
-.Fa fd
-need not have been opened with the
-.Dv O_EXEC
-flag.
-However, if the file to be executed denies read permission for the process
-preparing to do the exec, the only way to provide the
-.Fa fd
-to
-.Fn fexecve
-is to use the
-.Dv O_EXEC
-flag when opening
-.Fa fd .
-Note that the file to be executed can not be open for writing.
-.Sh RETURN VALUES
-As the
-.Fn execve
-system call overlays the current process image
-with a new process image the successful call
-has no process to return to.
-If
-.Fn execve
-does return to the calling process an error has occurred; the
-return value will be -1 and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn execve
-system call
-will fail and return to the calling process if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOEXEC
-When invoking an interpreted script, the length of the first line,
-inclusive of the
-.Sy \&#!
-prefix and terminating newline, exceeds
-.Dv MAXSHELLCMDLEN
-characters.
-.It Bq Er ENOENT
-The new process file does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-The new process file is not an ordinary file.
-.It Bq Er EACCES
-The new process file mode denies execute permission.
-.It Bq Er EINVAL
-.Fa argv
-did not contain at least one element.
-.It Bq Er ENOEXEC
-The new process file has the appropriate access
-permission, but has an invalid magic number in its header.
-.It Bq Er ETXTBSY
-The new process file is a pure procedure (shared text)
-file that is currently open for writing by some process.
-.It Bq Er ENOMEM
-The new process requires more virtual memory than
-is allowed by the imposed maximum
-.Pq Xr getrlimit 2 .
-.It Bq Er E2BIG
-The number of bytes in the new process' argument list
-is larger than the system-imposed limit.
-This limit is specified by the
-.Xr sysctl 3
-MIB variable
-.Dv KERN_ARGMAX .
-.It Bq Er EFAULT
-The new process file is not as long as indicated by
-the size values in its header.
-.It Bq Er EFAULT
-The
-.Fa path ,
-.Fa argv ,
-or
-.Fa envp
-arguments
-point
-to an illegal address.
-.It Bq Er EIO
-An I/O error occurred while reading from the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-In addition, the
-.Fn fexecve
-will fail and return to the calling process if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument is not a valid file descriptor open for executing.
-.El
-.Sh SEE ALSO
-.Xr ktrace 1 ,
-.Xr _exit 2 ,
-.Xr fork 2 ,
-.Xr open 2 ,
-.Xr execl 3 ,
-.Xr exit 3 ,
-.Xr sysctl 3 ,
-.Xr a.out 5 ,
-.Xr elf 5 ,
-.Xr fdescfs 5 ,
-.Xr environ 7 ,
-.Xr mount 8
-.Sh STANDARDS
-The
-.Fn execve
-system call conforms to
-.St -p1003.1-2001 ,
-with the exception of reopening descriptors 0, 1, and/or 2 in certain
-circumstances.
-A future update of the Standard is expected to require this behavior,
-and it may become the default for non-privileged processes as well.
-.\" NB: update this caveat when TC1 is blessed.
-The support for executing interpreted programs is an extension.
-The
-.Fn fexecve
-system call conforms to The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn execve
-system call appeared in
-.At v7 .
-The
-.Fn fexecve
-system call appeared in
-.Fx 8.0 .
-.Sh CAVEATS
-If a program is
-.Em setuid
-to a non-super-user, but is executed when
-the real
-.Em uid
-is ``root'', then the program has some of the powers
-of a super-user as well.
-.Pp
-When executing an interpreted program through
-.Fn fexecve ,
-kernel supplies
-.Pa /dev/fd/n
-as a second argument to the interpreter,
-where
-.Ar n
-is the file descriptor passed in the
-.Fa fd
-argument to
-.Fn fexecve .
-For this construction to work correctly, the
-.Xr fdescfs 5
-filesystem shall be mounted on
-.Pa /dev/fd .
diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2
deleted file mode 100644
index 5de41f4c0476..000000000000
--- a/lib/libc/sys/fcntl.2
+++ /dev/null
@@ -1,792 +0,0 @@
-.\" Copyright (c) 1983, 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.
-.\"
-.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
-.\"
-.Dd December 7, 2021
-.Dt FCNTL 2
-.Os
-.Sh NAME
-.Nm fcntl
-.Nd file control
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In fcntl.h
-.Ft int
-.Fn fcntl "int fd" "int cmd" "..."
-.Sh DESCRIPTION
-The
-.Fn fcntl
-system call provides for control over descriptors.
-The argument
-.Fa fd
-is a descriptor to be operated on by
-.Fa cmd
-as described below.
-Depending on the value of
-.Fa cmd ,
-.Fn fcntl
-can take an additional third argument
-.Fa arg .
-Unless otherwise noted below for a specific operation,
-.Fa arg
-has type
-.Vt int .
-.Bl -tag -width F_DUP2FD_CLOEXEC
-.It Dv F_DUPFD
-Return a new descriptor as follows:
-.Pp
-.Bl -bullet -compact -offset 4n
-.It
-Lowest numbered available descriptor greater than or equal to
-.Fa arg .
-.It
-Same object references as the original descriptor.
-.It
-New descriptor shares the same file offset if the object
-was a file.
-.It
-Same access mode (read, write or read/write).
-.It
-Same file status flags (i.e., both file descriptors
-share the same file status flags).
-.It
-The close-on-exec flag
-.Dv FD_CLOEXEC
-associated with the new file descriptor is cleared, so the file descriptor is
-to remain open across
-.Xr execve 2
-system calls.
-.El
-.It Dv F_DUPFD_CLOEXEC
-Like
-.Dv F_DUPFD ,
-but the
-.Dv FD_CLOEXEC
-flag associated with the new file descriptor is set, so the file descriptor
-is closed when
-.Xr execve 2
-system call executes.
-.It Dv F_DUP2FD
-It is functionally equivalent to
-.Bd -literal -offset indent
-dup2(fd, arg)
-.Ed
-.It Dv F_DUP2FD_CLOEXEC
-Like
-.Dv F_DUP2FD ,
-but the
-.Dv FD_CLOEXEC
-flag associated with the new file descriptor is set.
-.Pp
-The
-.Dv F_DUP2FD
-and
-.Dv F_DUP2FD_CLOEXEC
-constants are not portable, so they should not be used if
-portability is needed.
-Use
-.Fn dup2
-instead of
-.Dv F_DUP2FD .
-.It Dv F_GETFD
-Get the close-on-exec flag associated with the file descriptor
-.Fa fd
-as
-.Dv FD_CLOEXEC .
-If the returned value ANDed with
-.Dv FD_CLOEXEC
-is 0,
-the file will remain open across
-.Fn exec ,
-otherwise the file will be closed upon execution of
-.Fn exec
-.Fa ( arg
-is ignored).
-.It Dv F_SETFD
-Set the close-on-exec flag associated with
-.Fa fd
-to
-.Fa arg ,
-where
-.Fa arg
-is either 0 or
-.Dv FD_CLOEXEC ,
-as described above.
-.It Dv F_GETFL
-Get descriptor status flags, as described below
-.Fa ( arg
-is ignored).
-.It Dv F_SETFL
-Set descriptor status flags to
-.Fa arg .
-.It Dv F_GETOWN
-Get the process ID or process group
-currently receiving
-.Dv SIGIO
-and
-.Dv SIGURG
-signals; process groups are returned
-as negative values
-.Fa ( arg
-is ignored).
-.It Dv F_SETOWN
-Set the process or process group
-to receive
-.Dv SIGIO
-and
-.Dv SIGURG
-signals;
-process groups are specified by supplying
-.Fa arg
-as negative, otherwise
-.Fa arg
-is interpreted as a process ID.
-.It Dv F_READAHEAD
-Set or clear the read ahead amount for sequential access to the third
-argument,
-.Fa arg ,
-which is rounded up to the nearest block size.
-A zero value in
-.Fa arg
-turns off read ahead, a negative value restores the system default.
-.It Dv F_RDAHEAD
-Equivalent to Darwin counterpart which sets read ahead amount of 128KB
-when the third argument,
-.Fa arg
-is non-zero.
-A zero value in
-.Fa arg
-turns off read ahead.
-.It Dv F_ADD_SEALS
-Add seals to the file as described below, if the underlying filesystem supports
-seals.
-.It Dv F_GET_SEALS
-Get seals associated with the file, if the underlying filesystem supports seals.
-.It Dv F_ISUNIONSTACK
-Check if the vnode is part of a union stack (either the "union" flag from
-.Xr mount 2
-or unionfs).
-This is a hack not intended to be used outside of libc.
-.It Dv F_KINFO
-Fills a
-.Vt struct kinfo_file
-for the file referenced by the specified file descriptor.
-The
-.Fa arg
-argument should point to the storage for
-.Vt struct kinfo_file .
-The
-.Va kf_structsize
-member of the passed structure must be initialized with the sizeof of
-.Vt struct kinfo_file ,
-to allow for the interface versioning and evolution.
-.El
-.Pp
-The flags for the
-.Dv F_GETFL
-and
-.Dv F_SETFL
-commands are as follows:
-.Bl -tag -width O_NONBLOCKX
-.It Dv O_NONBLOCK
-Non-blocking I/O; if no data is available to a
-.Xr read 2
-system call, or if a
-.Xr write 2
-operation would block,
-the read or write call returns -1 with the error
-.Er EAGAIN .
-.It Dv O_APPEND
-Force each write to append at the end of file;
-corresponds to the
-.Dv O_APPEND
-flag of
-.Xr open 2 .
-.It Dv O_DIRECT
-Minimize or eliminate the cache effects of reading and writing.
-The system
-will attempt to avoid caching the data you read or write.
-If it cannot
-avoid caching the data, it will minimize the impact the data has on the cache.
-Use of this flag can drastically reduce performance if not used with care.
-.It Dv O_ASYNC
-Enable the
-.Dv SIGIO
-signal to be sent to the process group
-when I/O is possible, e.g.,
-upon availability of data to be read.
-.It Dv O_SYNC
-Enable synchronous writes.
-Corresponds to the
-.Dv O_SYNC
-flag of
-.Xr open 2 .
-.Dv O_FSYNC
-is an historical synonym for
-.Dv O_SYNC .
-.It Dv O_DSYNC
-Enable synchronous data writes.
-Corresponds to the
-.Dv O_DSYNC
-flag of
-.Xr open 2 .
-.El
-.Pp
-The seals that may be applied with
-.Dv F_ADD_SEALS
-are as follows:
-.Bl -tag -width F_SEAL_SHRINK
-.It Dv F_SEAL_SEAL
-Prevent any further seals from being applied to the file.
-.It Dv F_SEAL_SHRINK
-Prevent the file from being shrunk with
-.Xr ftruncate 2 .
-.It Dv F_SEAL_GROW
-Prevent the file from being enlarged with
-.Xr ftruncate 2 .
-.It Dv F_SEAL_WRITE
-Prevent any further
-.Xr write 2
-calls to the file.
-Any writes in progress will finish before
-.Fn fcntl
-returns.
-If any writeable mappings exist, F_ADD_SEALS will fail and return
-.Dv EBUSY .
-.El
-.Pp
-Seals are on a per-inode basis and require support by the underlying filesystem.
-If the underlying filesystem does not support seals,
-.Dv F_ADD_SEALS
-and
-.Dv F_GET_SEALS
-will fail and return
-.Dv EINVAL .
-.Pp
-Several operations are available for doing advisory file locking;
-they all operate on the following structure:
-.Bd -literal
-struct flock {
- off_t l_start; /* starting offset */
- off_t l_len; /* len = 0 means until end of file */
- pid_t l_pid; /* lock owner */
- short l_type; /* lock type: read/write, etc. */
- short l_whence; /* type of l_start */
- int l_sysid; /* remote system id or zero for local */
-};
-.Ed
-These advisory file locking operations take a pointer to
-.Vt struct flock
-as the third argument
-.Fa arg .
-The commands available for advisory record locking are as follows:
-.Bl -tag -width F_SETLKWX
-.It Dv F_GETLK
-Get the first lock that blocks the lock description pointed to by the
-third argument,
-.Fa arg ,
-taken as a pointer to a
-.Fa "struct flock"
-(see above).
-The information retrieved overwrites the information passed to
-.Fn fcntl
-in the
-.Fa flock
-structure.
-If no lock is found that would prevent this lock from being created,
-the structure is left unchanged by this system call except for the
-lock type which is set to
-.Dv F_UNLCK .
-.It Dv F_SETLK
-Set or clear a file segment lock according to the lock description
-pointed to by the third argument,
-.Fa arg ,
-taken as a pointer to a
-.Fa "struct flock"
-(see above).
-.Dv F_SETLK
-is used to establish shared (or read) locks
-.Pq Dv F_RDLCK
-or exclusive (or write) locks,
-.Pq Dv F_WRLCK ,
-as well as remove either type of lock
-.Pq Dv F_UNLCK .
-If a shared or exclusive lock cannot be set,
-.Fn fcntl
-returns immediately with
-.Er EAGAIN .
-.It Dv F_SETLKW
-This command is the same as
-.Dv F_SETLK
-except that if a shared or exclusive lock is blocked by other locks,
-the process waits until the request can be satisfied.
-If a signal that is to be caught is received while
-.Fn fcntl
-is waiting for a region, the
-.Fn fcntl
-will be interrupted if the signal handler has not specified the
-.Dv SA_RESTART
-(see
-.Xr sigaction 2 ) .
-.El
-.Pp
-When a shared lock has been set on a segment of a file,
-other processes can set shared locks on that segment
-or a portion of it.
-A shared lock prevents any other process from setting an exclusive
-lock on any portion of the protected area.
-A request for a shared lock fails if the file descriptor was not
-opened with read access.
-.Pp
-An exclusive lock prevents any other process from setting a shared lock or
-an exclusive lock on any portion of the protected area.
-A request for an exclusive lock fails if the file was not
-opened with write access.
-.Pp
-The value of
-.Fa l_whence
-is
-.Dv SEEK_SET ,
-.Dv SEEK_CUR ,
-or
-.Dv SEEK_END
-to indicate that the relative offset,
-.Fa l_start
-bytes, will be measured from the start of the file,
-current position, or end of the file, respectively.
-The value of
-.Fa l_len
-is the number of consecutive bytes to be locked.
-If
-.Fa l_len
-is negative,
-.Fa l_start
-means end edge of the region.
-The
-.Fa l_pid
-and
-.Fa l_sysid
-fields are only used with
-.Dv F_GETLK
-to return the process ID of the process holding a blocking lock and
-the system ID of the system that owns that process.
-Locks created by the local system will have a system ID of zero.
-After a successful
-.Dv F_GETLK
-request, the value of
-.Fa l_whence
-is
-.Dv SEEK_SET .
-.Pp
-Locks may start and extend beyond the current end of a file,
-but may not start or extend before the beginning of the file.
-A lock is set to extend to the largest possible value of the
-file offset for that file if
-.Fa l_len
-is set to zero.
-If
-.Fa l_whence
-and
-.Fa l_start
-point to the beginning of the file, and
-.Fa l_len
-is zero, the entire file is locked.
-If an application wishes only to do entire file locking, the
-.Xr flock 2
-system call is much more efficient.
-.Pp
-There is at most one type of lock set for each byte in the file.
-Before a successful return from an
-.Dv F_SETLK
-or an
-.Dv F_SETLKW
-request when the calling process has previously existing locks
-on bytes in the region specified by the request,
-the previous lock type for each byte in the specified
-region is replaced by the new lock type.
-As specified above under the descriptions
-of shared locks and exclusive locks, an
-.Dv F_SETLK
-or an
-.Dv F_SETLKW
-request fails or blocks respectively when another process has existing
-locks on bytes in the specified region and the type of any of those
-locks conflicts with the type specified in the request.
-.Pp
-The queuing for
-.Dv F_SETLKW
-requests on local files is fair;
-that is, while the thread is blocked,
-subsequent requests conflicting with its requests will not be granted,
-even if these requests do not conflict with existing locks.
-.Pp
-This interface follows the completely stupid semantics of System V and
-.St -p1003.1-88
-that require that all locks associated with a file for a given process are
-removed when
-.Em any
-file descriptor for that file is closed by that process.
-This semantic means that applications must be aware of any files that
-a subroutine library may access.
-For example if an application for updating the password file locks the
-password file database while making the update, and then calls
-.Xr getpwnam 3
-to retrieve a record,
-the lock will be lost because
-.Xr getpwnam 3
-opens, reads, and closes the password database.
-The database close will release all locks that the process has
-associated with the database, even if the library routine never
-requested a lock on the database.
-Another minor semantic problem with this interface is that
-locks are not inherited by a child process created using the
-.Xr fork 2
-system call.
-The
-.Xr flock 2
-interface has much more rational last close semantics and
-allows locks to be inherited by child processes.
-The
-.Xr flock 2
-system call is recommended for applications that want to ensure the integrity
-of their locks when using library routines or wish to pass locks
-to their children.
-.Pp
-The
-.Fn fcntl ,
-.Xr flock 2 ,
-and
-.Xr lockf 3
-locks are compatible.
-Processes using different locking interfaces can cooperate
-over the same file safely.
-However, only one of such interfaces should be used within
-the same process.
-If a file is locked by a process through
-.Xr flock 2 ,
-any record within the file will be seen as locked
-from the viewpoint of another process using
-.Fn fcntl
-or
-.Xr lockf 3 ,
-and vice versa.
-Note that
-.Fn fcntl F_GETLK
-returns \-1 in
-.Fa l_pid
-if the process holding a blocking lock previously locked the
-file descriptor by
-.Xr flock 2 .
-.Pp
-All locks associated with a file for a given process are
-removed when the process terminates.
-.Pp
-All locks obtained before a call to
-.Xr execve 2
-remain in effect until the new program releases them.
-If the new program does not know about the locks, they will not be
-released until the program exits.
-.Pp
-A potential for deadlock occurs if a process controlling a locked region
-is put to sleep by attempting to lock the locked region of another process.
-This implementation detects that sleeping until a locked region is unlocked
-would cause a deadlock and fails with an
-.Er EDEADLK
-error.
-.Sh RETURN VALUES
-Upon successful completion, the value returned depends on
-.Fa cmd
-as follows:
-.Bl -tag -width F_GETOWNX -offset indent
-.It Dv F_DUPFD
-A new file descriptor.
-.It Dv F_DUP2FD
-A file descriptor equal to
-.Fa arg .
-.It Dv F_GETFD
-Value of flag (only the low-order bit is defined).
-.It Dv F_GETFL
-Value of flags.
-.It Dv F_GETOWN
-Value of file descriptor owner.
-.It other
-Value other than -1.
-.El
-.Pp
-Otherwise, a value of -1 is returned and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn fcntl
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The argument
-.Fa cmd
-is
-.Dv F_SETLK ,
-the type of lock
-.Pq Fa l_type
-is a shared lock
-.Pq Dv F_RDLCK
-or exclusive lock
-.Pq Dv F_WRLCK ,
-and the segment of a file to be locked is already
-exclusive-locked by another process;
-or the type is an exclusive lock and some portion of the
-segment of a file to be locked is already shared-locked or
-exclusive-locked by another process.
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid open file descriptor.
-.Pp
-The argument
-.Fa cmd
-is
-.Dv F_DUP2FD ,
-and
-.Fa arg
-is not a valid file descriptor.
-.Pp
-The argument
-.Fa cmd
-is
-.Dv F_SETLK
-or
-.Dv F_SETLKW ,
-the type of lock
-.Pq Fa l_type
-is a shared lock
-.Pq Dv F_RDLCK ,
-and
-.Fa fd
-is not a valid file descriptor open for reading.
-.Pp
-The argument
-.Fa cmd
-is
-.Dv F_SETLK
-or
-.Dv F_SETLKW ,
-the type of lock
-.Pq Fa l_type
-is an exclusive lock
-.Pq Dv F_WRLCK ,
-and
-.Fa fd
-is not a valid file descriptor open for writing.
-.It Bq Er EBUSY
-The argument
-.Fa cmd
-is
-.Dv F_ADD_SEALS ,
-attempting to set
-.Dv F_SEAL_WRITE ,
-and writeable mappings of the file exist.
-.It Bq Er EDEADLK
-The argument
-.Fa cmd
-is
-.Dv F_SETLKW ,
-and a deadlock condition was detected.
-.It Bq Er EINTR
-The argument
-.Fa cmd
-is
-.Dv F_SETLKW ,
-and the system call was interrupted by a signal.
-.It Bq Er EINVAL
-The
-.Fa cmd
-argument
-is
-.Dv F_DUPFD
-and
-.Fa arg
-is negative or greater than the maximum allowable number
-(see
-.Xr getdtablesize 2 ) .
-.Pp
-The argument
-.Fa cmd
-is
-.Dv F_GETLK ,
-.Dv F_SETLK
-or
-.Dv F_SETLKW
-and the data to which
-.Fa arg
-points is not valid.
-.Pp
-The argument
-.Fa cmd
-is
-.Dv F_ADD_SEALS
-or
-.Dv F_GET_SEALS ,
-and the underlying filesystem does not support sealing.
-.Pp
-The argument
-.Fa cmd
-is invalid.
-.It Bq Er EMFILE
-The argument
-.Fa cmd
-is
-.Dv F_DUPFD
-and the maximum number of file descriptors permitted for the
-process are already in use,
-or no file descriptors greater than or equal to
-.Fa arg
-are available.
-.It Bq Er ENOTTY
-The
-.Fa fd
-argument is not a valid file descriptor for the requested operation.
-This may be the case if
-.Fa fd
-is a device node, or a descriptor returned by
-.Xr kqueue 2 .
-.It Bq Er ENOLCK
-The argument
-.Fa cmd
-is
-.Dv F_SETLK
-or
-.Dv F_SETLKW ,
-and satisfying the lock or unlock request would result in the
-number of locked regions in the system exceeding a system-imposed limit.
-.It Bq Er EOPNOTSUPP
-The argument
-.Fa cmd
-is
-.Dv F_GETLK ,
-.Dv F_SETLK
-or
-.Dv F_SETLKW
-and
-.Fa fd
-refers to a file for which locking is not supported.
-.It Bq Er EOVERFLOW
-The argument
-.Fa cmd
-is
-.Dv F_GETLK ,
-.Dv F_SETLK
-or
-.Dv F_SETLKW
-and an
-.Fa off_t
-calculation overflowed.
-.It Bq Er EPERM
-The
-.Fa cmd
-argument
-is
-.Dv F_SETOWN
-and
-the process ID or process group given as an argument is in a
-different session than the caller.
-.Pp
-The
-.Fa cmd
-argument
-is
-.Dv F_ADD_SEALS
-and the
-.Dv F_SEAL_SEAL
-seal has already been set.
-.It Bq Er ESRCH
-The
-.Fa cmd
-argument
-is
-.Dv F_SETOWN
-and
-the process ID given as argument is not in use.
-.El
-.Pp
-In addition, if
-.Fa fd
-refers to a descriptor open on a terminal device (as opposed to a
-descriptor open on a socket), a
-.Fa cmd
-of
-.Dv F_SETOWN
-can fail for the same reasons as in
-.Xr tcsetpgrp 3 ,
-and a
-.Fa cmd
-of
-.Dv F_GETOWN
-for the reasons as stated in
-.Xr tcgetpgrp 3 .
-.Sh SEE ALSO
-.Xr close 2 ,
-.Xr dup2 2 ,
-.Xr execve 2 ,
-.Xr flock 2 ,
-.Xr getdtablesize 2 ,
-.Xr open 2 ,
-.Xr sigaction 2 ,
-.Xr lockf 3 ,
-.Xr tcgetpgrp 3 ,
-.Xr tcsetpgrp 3
-.Sh STANDARDS
-The
-.Dv F_DUP2FD
-constant is non portable.
-It is provided for compatibility with AIX and Solaris.
-.Pp
-Per
-.St -susv4 ,
-a call with
-.Dv F_SETLKW
-should fail with
-.Bq Er EINTR
-after any caught signal
-and should continue waiting during thread suspension such as a stop signal.
-However, in this implementation a call with
-.Dv F_SETLKW
-is restarted after catching a signal with a
-.Dv SA_RESTART
-handler or a thread suspension such as a stop signal.
-.Sh HISTORY
-The
-.Fn fcntl
-system call appeared in
-.Bx 4.2 .
-.Pp
-The
-.Dv F_DUP2FD
-constant first appeared in
-.Fx 7.1 .
diff --git a/lib/libc/sys/fcntl.c b/lib/libc/sys/fcntl.c
index ff231981d079..fc225fdeb379 100644
--- a/lib/libc/sys/fcntl.c
+++ b/lib/libc/sys/fcntl.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/types.h>
@@ -50,6 +49,5 @@ fcntl(int fd, int cmd, ...)
arg = va_arg(args, long);
va_end(args);
- return (((int (*)(int, int, ...))
- __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg));
+ return (INTERPOS_SYS(fcntl, fd, cmd, arg));
}
diff --git a/lib/libc/sys/fdatasync.c b/lib/libc/sys/fdatasync.c
index b56d5aa533d4..15cef821dc1e 100644
--- a/lib/libc/sys/fdatasync.c
+++ b/lib/libc/sys/fdatasync.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <unistd.h>
@@ -38,6 +37,5 @@
int
fdatasync(int fd)
{
-
- return (((int (*)(int))__libc_interposing[INTERPOS_fdatasync])(fd));
+ return (INTERPOS_SYS(fdatasync, fd));
}
diff --git a/lib/libc/sys/fhlink.2 b/lib/libc/sys/fhlink.2
deleted file mode 100644
index 332856630879..000000000000
--- a/lib/libc/sys/fhlink.2
+++ /dev/null
@@ -1,255 +0,0 @@
-.\" SPDX-License-Identifier: BSD-2-Clause
-.\"
-.\" Copyright (c) 2018 Gandi
-.\"
-.\" 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.
-.\"
-.Dd November 30, 2022
-.Dt FHLINK 2
-.Os
-.Sh NAME
-.Nm fhlink ,
-.Nm fhlinkat
-.Nd make a hard file link
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn fhlink "fhandle_t *fhp" "const char *to"
-.Ft int
-.Fn fhlinkat "fhandle_t *fhp" "int tofd" "const char *to"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn fhlink
-system call
-atomically creates the specified directory entry (hard link)
-.Fa to
-with the attributes of the underlying object pointed at by
-.Fa fhp .
-If the link is successful: the link count of the underlying object
-is incremented;
-.Fa fhp
-and
-.Fa to
-share equal access and rights
-to the
-underlying object.
-.Pp
-If
-.Fa fhp
-is removed, the file
-.Fa to
-is not deleted and the link count of the
-underlying object is
-decremented.
-.Pp
-The object pointed at by the
-.Fa fhp
-argument
-must exist for the hard link to
-succeed and
-both
-.Fa fhp
-and
-.Fa to
-must be in the same file system.
-The
-.Fa fhp
-argument
-may not be a directory.
-.Pp
-The
-.Fn fhlinkat
-system call is equivalent to
-.Fa fhlink
-except in the case where
-.Fa to
-is a relative paths.
-In this case a relative path
-.Fa to
-is interpreted relative to
-the directory associated with the file descriptor
-.Fa tofd
-instead of the current working directory.
-.Pp
-If
-.Fn fhlinkat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa tofd
-parameter, the current working directory is used for the
-.Fa to
-argument.
-If
-.Fa tofd
-has value
-.Dv AT_FDCWD ,
-the behavior is identical to a call to
-.Fn link .
-Unless
-.Fa flag
-contains the
-.Dv AT_SYMLINK_FOLLOW
-flag, if
-.Fa fhp
-names a symbolic link, a new link is created for the symbolic link
-.Fa fhp
-and not its target.
-.Sh RETURN VALUES
-.Rv -std link
-.Sh ERRORS
-The
-.Fn fhlink
-system call
-will fail and no link will be created if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of
-.Fa to
-prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of
-.Fa to
-exceeded 255 characters,
-or entire length of
-.Fa to
-name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of
-.Fa to
-prefix does not exist.
-.It Bq Er EOPNOTSUPP
-The file system containing the file pointed at by
-.Fa fhp
-does not support links.
-.It Bq Er EMLINK
-The link count of the file pointed at by
-.Fa fhp
-would exceed 32767.
-.It Bq Er EACCES
-A component of
-.Fa to
-prefix denies search permission.
-.It Bq Er EACCES
-The requested link requires writing in a directory with a mode
-that denies write permission.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating one of the pathnames.
-.It Bq Er ENOENT
-The file pointed at by
-.Fa fhp
-does not exist.
-.It Bq Er EEXIST
-The link named by
-.Fa to
-does exist.
-.It Bq Er EPERM
-The file pointed at by
-.Fa fhp
-is a directory.
-.It Bq Er EPERM
-The file pointed at by
-.Fa fhp
-has its immutable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EPERM
-The parent directory of the file named by
-.Fa to
-has its immutable flag set.
-.It Bq Er EXDEV
-The link named by
-.Fa to
-and the file pointed at by
-.Fa fhp
-are on different file systems.
-.It Bq Er ENOSPC
-The directory in which the entry for the new link is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er EDQUOT
-The directory in which the entry for the new link
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to
-the file system to make the directory entry.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The requested link requires writing in a directory on a read-only file
-system.
-.It Bq Er EFAULT
-One of the pathnames specified
-is outside the process's allocated address space.
-.It Bq Er ESTALE
-The file handle
-.Fa fhp
-is no longer valid
-.El
-.Pp
-In addition to the errors returned by the
-.Fn fhlink ,
-the
-.Fn fhlinkat
-system call may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fhp
-or
-.Fa to
-argument does not specify an absolute path and the
-.Fa tofd
-argument, is not
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa fhp
-or
-.Fa to
-argument is not an absolute path and
-.Fa tofd
-is not
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr fhopen 2 ,
-.Xr fhreadlink 2 ,
-.Xr fhstat 2
-.Sh HISTORY
-The
-.Fn fhlink
-and
-.Fn fhlinkat
-system calls first appeared in
-.Fx 12.1 .
diff --git a/lib/libc/sys/fhopen.2 b/lib/libc/sys/fhopen.2
deleted file mode 100644
index 5bd1e9f8d90b..000000000000
--- a/lib/libc/sys/fhopen.2
+++ /dev/null
@@ -1,145 +0,0 @@
-.\" $NetBSD: fhopen.2,v 1.1 1999/06/30 01:32:15 wrstuden Exp $
-.\"
-.\" Copyright (c) 1999 National Aeronautics & Space Administration
-.\" All rights reserved.
-.\"
-.\" This software was written by William Studenmund of the
-.\" Numerical Aerospace Simulation Facility, NASA Ames Research Center.
-.\"
-.\" 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 National Aeronautics & Space Administration
-.\" 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 NATIONAL AERONAUTICS & SPACE ADMINISTRATION
-.\" ``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 ADMINISTRATION OR CONTRIB-
-.\" UTORS 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.
-.\"
-.Dd June 29, 1999
-.Dt FHOPEN 2
-.Os
-.Sh NAME
-.Nm fhopen ,
-.Nm fhstat ,
-.Nm fhstatfs
-.Nd access file via file handle
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/mount.h
-.In sys/stat.h
-.Ft int
-.Fn fhopen "const fhandle_t *fhp" "int flags"
-.Ft int
-.Fn fhstat "const fhandle_t *fhp" "struct stat *sb"
-.Ft int
-.Fn fhstatfs "const fhandle_t *fhp" "struct statfs *buf"
-.Sh DESCRIPTION
-These system calls provide a means to access a file given the file handle
-.Fa fhp .
-As this method bypasses directory access restrictions, these calls are
-restricted to the superuser.
-.Pp
-The
-.Fn fhopen
-system call
-opens the file referenced by
-.Fa fhp
-for reading and/or writing as specified by the argument
-.Fa flags
-and returns the file descriptor to the calling process.
-The
-.Fa flags
-argument
-is specified by
-.Em or Ns 'ing
-together the flags used for the
-.Xr open 2
-system call.
-All said flags are valid except for
-.Dv O_CREAT .
-.Pp
-The
-.Fn fhstat
-and
-.Fn fhstatfs
-system calls
-provide the functionality of the
-.Xr fstat 2
-and
-.Xr fstatfs 2
-calls except that they return information for the file referred to by
-.Fa fhp
-rather than an open file.
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn fhopen
-returns the file descriptor for the opened file;
-otherwise the value \-1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Pp
-.Rv -std fhstat fhstatfs
-.Sh ERRORS
-In addition to the errors returned by
-.Xr open 2 ,
-.Xr fstat 2 ,
-and
-.Xr fstatfs 2
-respectively,
-.Fn fhopen ,
-.Fn fhstat ,
-and
-.Fn fhstatfs
-will return
-.Bl -tag -width Er
-.It Bq Er EINVAL
-Calling
-.Fn fhopen
-with
-.Dv O_CREAT
-set.
-.It Bq Er ESTALE
-The file handle
-.Fa fhp
-is no longer valid.
-.El
-.Sh SEE ALSO
-.Xr fstat 2 ,
-.Xr fstatfs 2 ,
-.Xr getfh 2 ,
-.Xr open 2
-.Sh HISTORY
-The
-.Fn fhopen ,
-.Fn fhstat ,
-and
-.Fn fhstatfs
-system calls first appeared in
-.Nx 1.5
-and were adapted to
-.Fx 4.0
-by
-.An Alfred Perlstein .
-.Sh AUTHORS
-This manual page was written by
-.An William Studenmund
-for
-.Nx .
diff --git a/lib/libc/sys/fhreadlink.2 b/lib/libc/sys/fhreadlink.2
deleted file mode 100644
index 23850c6a2117..000000000000
--- a/lib/libc/sys/fhreadlink.2
+++ /dev/null
@@ -1,97 +0,0 @@
-.\" SPDX-License-Identifier: BSD-2-Clause
-.\"
-.\" Copyright (c) 2018 Gandi
-.\"
-.\" 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.
-.\"
-.Dd November 30, 2022
-.Dt FHREADLINK 2
-.Os
-.Sh NAME
-.Nm fhreadlink
-.Nd read value of a symbolic link
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/mount.h
-.Ft int
-.Fn fhreadlink "fhandle_t *fhp" "char *buf" "size_t bufsize"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn fhreadlink
-system call
-places the contents of the symbolic link
-.Fa fhp
-in the buffer
-.Fa buf ,
-which has size
-.Fa bufsiz .
-The
-.Fn fhreadlink
-system call does not append a
-.Dv NUL
-character to
-.Fa buf .
-.Pp
-.Sh RETURN VALUES
-The call returns the count of characters placed in the buffer
-if it succeeds, or a \-1 if an error occurs, placing the error
-code in the global variable
-.Va errno .
-.Sh ERRORS
-The
-.Fn readlink
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the file handle
-.Fa fhp .
-.It Bq Er EINVAL
-The named file is not a symbolic link.
-.It Bq Er EIO
-An I/O error occurred while reading from the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-The
-.Fa buf
-argument
-extends outside the process's allocated address space.
-.It Bq Er ESTALE
-The file handle
-.Fa fhp
-is no longer valid
-.El
-.El
-.Sh SEE ALSO
-.Xr fhstat 2 ,
-.Xr fhlink 2 ,
-.Sh HISTORY
-The
-.Fn fhreadlink
-system call first appeared in
-.Fx 12.1 .
diff --git a/lib/libc/sys/flock.2 b/lib/libc/sys/flock.2
deleted file mode 100644
index 4e1ab99318b0..000000000000
--- a/lib/libc/sys/flock.2
+++ /dev/null
@@ -1,172 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)flock.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd November 9, 2011
-.Dt FLOCK 2
-.Os
-.Sh NAME
-.Nm flock
-.Nd "apply or remove an advisory lock on an open file"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/file.h
-.Fd "#define LOCK_SH 0x01 /* shared file lock */"
-.Fd "#define LOCK_EX 0x02 /* exclusive file lock */"
-.Fd "#define LOCK_NB 0x04 /* do not block when locking */"
-.Fd "#define LOCK_UN 0x08 /* unlock file */"
-.Ft int
-.Fn flock "int fd" "int operation"
-.Sh DESCRIPTION
-The
-.Fn flock
-system call applies or removes an
-.Em advisory
-lock on the file associated with the file descriptor
-.Fa fd .
-A lock is applied by specifying an
-.Fa operation
-argument that is one of
-.Dv LOCK_SH
-or
-.Dv LOCK_EX
-with the optional addition of
-.Dv LOCK_NB .
-To unlock
-an existing lock
-.Dv operation
-should be
-.Dv LOCK_UN .
-.Pp
-Advisory locks allow cooperating processes to perform
-consistent operations on files, but do not guarantee
-consistency (i.e., processes may still access files
-without using advisory locks possibly resulting in
-inconsistencies).
-.Pp
-The locking mechanism allows two types of locks:
-.Em shared
-locks and
-.Em exclusive
-locks.
-At any time multiple shared locks may be applied to a file,
-but at no time are multiple exclusive, or both shared and exclusive,
-locks allowed simultaneously on a file.
-.Pp
-A shared lock may be
-.Em upgraded
-to an exclusive lock, and vice versa, simply by specifying
-the appropriate lock type; this results in the previous
-lock being released and the new lock applied (possibly
-after other processes have gained and released the lock).
-.Pp
-Requesting a lock on an object that is already locked
-normally causes the caller to be blocked until the lock may be
-acquired.
-If
-.Dv LOCK_NB
-is included in
-.Fa operation ,
-then this will not happen; instead the call will fail and
-the error
-.Er EWOULDBLOCK
-will be returned.
-.Sh NOTES
-Locks are on files, not file descriptors.
-That is, file descriptors
-duplicated through
-.Xr dup 2
-or
-.Xr fork 2
-do not result in multiple instances of a lock, but rather multiple
-references to a single lock.
-If a process holding a lock on a file
-forks and the child explicitly unlocks the file, the parent will
-lose its lock.
-.Pp
-The
-.Fn flock ,
-.Xr fcntl 2 ,
-and
-.Xr lockf 3
-locks are compatible.
-Processes using different locking interfaces can cooperate
-over the same file safely.
-However, only one of such interfaces should be used within
-the same process.
-If a file is locked by a process through
-.Fn flock ,
-any record within the file will be seen as locked
-from the viewpoint of another process using
-.Xr fcntl 2
-or
-.Xr lockf 3 ,
-and vice versa.
-.Pp
-Processes blocked awaiting a lock may be awakened by signals.
-.Sh RETURN VALUES
-.Rv -std flock
-.Sh ERRORS
-The
-.Fn flock
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EWOULDBLOCK
-The file is locked and the
-.Dv LOCK_NB
-option was specified.
-.It Bq Er EBADF
-The argument
-.Fa fd
-is an invalid descriptor.
-.It Bq Er EINVAL
-The argument
-.Fa fd
-refers to an object other than a file.
-.It Bq Er EOPNOTSUPP
-The argument
-.Fa fd
-refers to an object that does not support file locking.
-.It Bq Er ENOLCK
-A lock was requested, but no locks are available.
-.El
-.Sh SEE ALSO
-.Xr close 2 ,
-.Xr dup 2 ,
-.Xr execve 2 ,
-.Xr fcntl 2 ,
-.Xr fork 2 ,
-.Xr open 2 ,
-.Xr flopen 3 ,
-.Xr lockf 3
-.Sh HISTORY
-The
-.Fn flock
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2
deleted file mode 100644
index eb9cfcd6130c..000000000000
--- a/lib/libc/sys/fork.2
+++ /dev/null
@@ -1,270 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)fork.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 5, 2021
-.Dt FORK 2
-.Os
-.Sh NAME
-.Nm fork
-.Nd create a new process
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft pid_t
-.Fn fork void
-.Ft pid_t
-.Fn _Fork void
-.Sh DESCRIPTION
-The
-.Fn fork
-function causes creation of a new process.
-The new process (child process) is an exact copy of the
-calling process (parent process) except for the following:
-.Bl -bullet -offset indent
-.It
-The child process has a unique process ID.
-.It
-The child process has a different parent
-process ID (i.e., the process ID of the parent process).
-.It
-The child process has its own copy of the parent's descriptors,
-except for descriptors returned by
-.Xr kqueue 2 ,
-which are not inherited from the parent process.
-These descriptors reference the same underlying objects, so that,
-for instance, file pointers in file objects are shared between
-the child and the parent, so that an
-.Xr lseek 2
-on a descriptor in the child process can affect a subsequent
-.Xr read 2
-or
-.Xr write 2
-by the parent.
-This descriptor copying is also used by the shell to
-establish standard input and output for newly created processes
-as well as to set up pipes.
-.It
-The child process' resource utilizations
-are set to 0; see
-.Xr setrlimit 2 .
-.It
-All interval timers are cleared; see
-.Xr setitimer 2 .
-.It
-The robust mutexes list (see
-.Xr pthread_mutexattr_setrobust 3 )
-is cleared for the child.
-.It
-The atfork handlers established with the
-.Xr pthread_atfork 3
-function are called as appropriate before fork in the parent process,
-and after the child is created, in parent and child.
-.It
-The child process has only one thread,
-corresponding to the calling thread in the parent process.
-If the process has more than one thread,
-locks and other resources held by the other threads are not released
-and therefore only async-signal-safe functions
-(see
-.Xr sigaction 2 )
-are guaranteed to work in the child process until a call to
-.Xr execve 2
-or a similar function.
-The
-.Fx
-implementation of
-.Fn fork
-provides a usable
-.Xr malloc 3 ,
-and
-.Xr rtld 1
-services in the child process.
-.El
-.Pp
-The
-.Fn fork
-function is not async-signal safe and creates a cancellation point
-in the parent process.
-It cannot be safely used from signal handlers, and the atfork handlers
-established by
-.Xr pthread_atfork 3
-do not need to be async-signal safe either.
-.Pp
-The
-.Fn _Fork
-function creates a new process, similarly to
-.Fn fork ,
-but it is async-signal safe.
-.Fn _Fork
-does not call atfork handlers, and does not create a cancellation point.
-It can be used safely from signal handlers, but then no userspace
-services (
-.Xr malloc 3
-or
-.Xr rtld 1 )
-are available in the child if forked from multi-threaded parent.
-In particular, if using dynamic linking, all dynamic symbols used by the
-child after
-.Fn _Fork
-must be pre-resolved.
-Note: resolving can be done globally by specifying the
-.Ev LD_BIND_NOW
-environment variable to the dynamic linker, or per-binary by passing the
-.Fl z Ar now
-option to the static linker
-.Xr ld 1 ,
-or by using each symbol before the
-.Fn _Fork
-call to force the binding.
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn fork
-and
-.Fn _Fork
-return a value
-of 0 to the child process and return the process ID of the child
-process to the parent process.
-Otherwise, a value of -1 is returned
-to the parent process, no child process is created, and the global
-variable
-.Va errno
-is set to indicate the error.
-.Sh EXAMPLES
-The following example shows a common pattern of how
-.Fn fork
-is used in practice.
-.Bd -literal -offset indent
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-int
-main(void)
-{
- pid_t pid;
-
- /*
- * If child is expected to use stdio(3), state of
- * the reused io streams must be synchronized between
- * parent and child, to avoid double output and other
- * possible issues.
- */
- fflush(stdout);
-
- switch (pid = fork()) {
- case -1:
- err(1, "Failed to fork");
- case 0:
- printf("Hello from child process!\en");
-
- /*
- * Since we wrote into stdout, child needs to use
- * exit(3) and not _exit(2). This causes handlers
- * registered with atexit(3) to be called twice,
- * once in parent, and once in the child. If such
- * behavior is undesirable, consider
- * terminating child with _exit(2) or _Exit(3).
- */
- exit(0);
- default:
- break;
- }
-
- printf("Hello from parent process (child's PID: %d)!\en", pid);
-
- return (0);
-}
-.Ed
-.Pp
-The output of such a program is along the lines of:
-.Bd -literal -offset indent
-Hello from parent process (child's PID: 27804)!
-Hello from child process!
-.Ed
-.Sh ERRORS
-The
-.Fn fork
-system call will fail and no child process will be created if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system-imposed limit on the total
-number of processes under execution would be exceeded.
-The limit is given by the
-.Xr sysctl 3
-MIB variable
-.Dv KERN_MAXPROC .
-(The limit is actually ten less than this
-except for the super user).
-.It Bq Er EAGAIN
-The user is not the super user, and
-the system-imposed limit
-on the total number of
-processes under execution by a single user would be exceeded.
-The limit is given by the
-.Xr sysctl 3
-MIB variable
-.Dv KERN_MAXPROCPERUID .
-.It Bq Er EAGAIN
-The user is not the super user, and
-the soft resource limit corresponding to the
-.Fa resource
-argument
-.Dv RLIMIT_NPROC
-would be exceeded (see
-.Xr getrlimit 2 ) .
-.It Bq Er ENOMEM
-There is insufficient swap space for the new process.
-.El
-.Sh SEE ALSO
-.Xr execve 2 ,
-.Xr rfork 2 ,
-.Xr setitimer 2 ,
-.Xr setrlimit 2 ,
-.Xr sigaction 2 ,
-.Xr vfork 2 ,
-.Xr wait 2 ,
-.Xr pthread_atfork 3
-.Sh HISTORY
-The
-.Fn fork
-function appeared in
-.At v1 .
-.Pp
-The
-.Fn _Fork
-function was defined by Austin Group together with the removal
-of a requirement that the
-.Fn fork
-implementation must be async-signal safe.
-The
-.Fn _Fork
-function appeared in
-.Fx 14.0 .
diff --git a/lib/libc/sys/fork.c b/lib/libc/sys/fork.c
index c45e5c93f226..e907c51b5cee 100644
--- a/lib/libc/sys/fork.c
+++ b/lib/libc/sys/fork.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <unistd.h>
#include "libc_private.h"
@@ -40,6 +39,5 @@ __weak_reference(__sys_fork, __fork);
pid_t
fork(void)
{
-
- return (((pid_t (*)(void))__libc_interposing[INTERPOS_fork])());
+ return (INTERPOS_SYS(fork));
}
diff --git a/lib/libc/sys/fstat.c b/lib/libc/sys/fstat.c
deleted file mode 100644
index 4efeecfd0978..000000000000
--- a/lib/libc/sys/fstat.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <sys/param.h>
-#include <sys/syscall.h>
-#include "compat-ino64.h"
-#include <unistd.h>
-
-#include "libc_private.h"
-
-#undef fstat
-__weak_reference(_fstat, fstat);
-
-#pragma weak _fstat
-int
-_fstat(int fd, struct stat *sb)
-{
- struct freebsd11_stat stat11;
- int rv;
-
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_fstat(fd, sb));
- rv = syscall(SYS_freebsd11_fstat, fd, &stat11);
- if (rv == 0)
- __stat11_to_stat(&stat11, sb);
- return (rv);
-}
diff --git a/lib/libc/sys/fstatat.c b/lib/libc/sys/fstatat.c
deleted file mode 100644
index d83647f98da1..000000000000
--- a/lib/libc/sys/fstatat.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <sys/param.h>
-#include <sys/syscall.h>
-#include "compat-ino64.h"
-#include <unistd.h>
-
-#include "libc_private.h"
-
-int
-fstatat(int fd, const char *path, struct stat *sb, int flag)
-{
- struct freebsd11_stat stat11;
- int rv;
-
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_fstatat(fd, path, sb, flag));
- rv = syscall(SYS_freebsd11_fstatat, fd, path, &stat11, flag);
- if (rv == 0)
- __stat11_to_stat(&stat11, sb);
- return (rv);
-}
diff --git a/lib/libc/sys/fstatfs.c b/lib/libc/sys/fstatfs.c
deleted file mode 100644
index 517ba2a420b6..000000000000
--- a/lib/libc/sys/fstatfs.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <sys/param.h>
-#include <sys/syscall.h>
-#include "compat-ino64.h"
-#include <unistd.h>
-
-#include "libc_private.h"
-
-#undef fstatfs
-__weak_reference(_fstatfs, fstatfs);
-
-#pragma weak _fstatfs
-int
-_fstatfs(int fd, struct statfs *buf)
-{
- struct freebsd11_statfs statfs11;
- int rv;
-
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_fstatfs(fd, buf));
- rv = syscall(SYS_freebsd11_fstatfs, fd, &statfs11);
- if (rv == 0)
- __statfs11_to_statfs(&statfs11, buf);
- return (rv);
-}
diff --git a/lib/libc/sys/fsync.2 b/lib/libc/sys/fsync.2
deleted file mode 100644
index 02cdf9bd656b..000000000000
--- a/lib/libc/sys/fsync.2
+++ /dev/null
@@ -1,132 +0,0 @@
-.\" Copyright (c) 1983, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" Parts of this documentation were written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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.
-.\"
-.\" @(#)fsync.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt FSYNC 2
-.Os
-.Sh NAME
-.Nm fdatasync ,
-.Nm fsync
-.Nd "synchronise changes to a file"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn fdatasync "int fd"
-.Ft int
-.Fn fsync "int fd"
-.Sh DESCRIPTION
-The
-.Fn fsync
-system call
-causes all modified data and attributes of the file referenced by
-the file descriptor
-.Fa fd
-to be moved to a permanent storage device.
-This normally results in all in-core modified copies
-of buffers for the associated file to be written to a disk.
-.Pp
-The
-.Fn fdatasync
-system call causes all modified data of
-.Fa fd
-to be moved to a permanent storage device.
-Unlike
-.Fn fsync ,
-the system call does not guarantee that file attributes or
-metadata necessary to access the file are committed to the permanent storage.
-.Pp
-The
-.Fn fsync
-system call
-should be used by programs that require a file to be
-in a known state, for example, in building a simple transaction
-facility.
-If the file metadata has already been committed, using
-.Fn fdatasync
-can be more efficient than
-.Fn fsync .
-.Pp
-Both
-.Fn fdatasync
-and
-.Fn fsync
-calls are cancellation points.
-.Sh RETURN VALUES
-.Rv -std fsync
-.Sh ERRORS
-The
-.Fn fsync
-and
-.Fn fdatasync
-calls fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid descriptor.
-.It Bq Er EINVAL
-The
-.Fa fd
-argument
-refers to a socket, not to a file.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh SEE ALSO
-.Xr fsync 1 ,
-.Xr sync 2 ,
-.Xr syncer 4 ,
-.Xr sync 8
-.Sh HISTORY
-The
-.Fn fsync
-system call appeared in
-.Bx 4.2 .
-The
-.Fn fdatasync
-system call appeared in
-.Fx 11.1 .
-.Sh BUGS
-The
-.Fn fdatasync
-system call currently does not guarantee that enqueued
-.Xr aio 4
-requests for the file referenced by
-.Fa fd
-are completed before the syscall returns.
diff --git a/lib/libc/sys/fsync.c b/lib/libc/sys/fsync.c
index ae9554f468f6..e542c8cdea48 100644
--- a/lib/libc/sys/fsync.c
+++ b/lib/libc/sys/fsync.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <unistd.h>
@@ -40,6 +39,5 @@ __weak_reference(__sys_fsync, __fsync);
int
fsync(int fd)
{
-
- return (((int (*)(int))__libc_interposing[INTERPOS_fsync])(fd));
+ return (INTERPOS_SYS(fsync, fd));
}
diff --git a/lib/libc/sys/getdents.c b/lib/libc/sys/getdents.c
index b34b7003a729..df8993a7b0f9 100644
--- a/lib/libc/sys/getdents.c
+++ b/lib/libc/sys/getdents.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/syscall.h>
@@ -34,11 +33,6 @@
ssize_t
getdents(int fd, char *buf, size_t nbytes)
{
- /*
- * _getdirentries knows how to call the right thing and
- * return it in the new format. It assumes that the entire
- * libc expecting the new format.
- */
- return (_getdirentries(fd, buf, nbytes, NULL));
+ return (__sys_getdirentries(fd, buf, nbytes, NULL));
}
diff --git a/lib/libc/sys/getdirentries.2 b/lib/libc/sys/getdirentries.2
deleted file mode 100644
index 38d5c1e525b0..000000000000
--- a/lib/libc/sys/getdirentries.2
+++ /dev/null
@@ -1,209 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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.
-.\"
-.\" @(#)getdirentries.2 8.2 (Berkeley) 5/3/95
-.\"
-.Dd April 11, 2022
-.Dt GETDIRENTRIES 2
-.Os
-.Sh NAME
-.Nm getdirentries ,
-.Nm getdents
-.Nd "get directory entries in a file system independent format"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In dirent.h
-.Ft ssize_t
-.Fn getdirentries "int fd" "char *buf" "size_t nbytes" "off_t *basep"
-.Ft ssize_t
-.Fn getdents "int fd" "char *buf" "size_t nbytes"
-.Sh DESCRIPTION
-The
-.Fn getdirentries
-and
-.Fn getdents
-system calls read directory entries from the directory
-referenced by the file descriptor
-.Fa fd
-into the buffer pointed to by
-.Fa buf ,
-in a file system independent format.
-Up to
-.Fa nbytes
-of data will be transferred.
-The
-.Fa nbytes
-argument must be greater than or equal to the
-block size associated with the file,
-see
-.Xr stat 2 .
-Some file systems may not support these system calls
-with buffers smaller than this size.
-.Pp
-The data in the buffer is a series of
-.Vt dirent
-structures each containing the following entries:
-.Bd -literal -offset indent
-ino_t d_fileno;
-off_t d_off;
-uint16_t d_reclen;
-uint8_t d_type;
-uint16_t d_namlen;
-char d_name[MAXNAMLEN + 1]; /* see below */
-.Ed
-.Pp
-The
-.Fa d_fileno
-entry is a number which is unique for each
-distinct file in the file system.
-Files that are linked by hard links (see
-.Xr link 2 )
-have the same
-.Fa d_fileno .
-The
-.Fa d_off
-field returns a cookie which, if non-zero, can be used with
-.Xr lseek 2
-to position the directory descriptor to the next entry.
-The
-.Fa d_reclen
-entry is the length, in bytes, of the directory record.
-The
-.Fa d_type
-entry is the type of the file pointed to by the directory record.
-The file type values are defined in
-.Fa <sys/dirent.h> .
-The
-.Fa d_name
-entry contains a null terminated file name.
-The
-.Fa d_namlen
-entry specifies the length of the file name excluding the null byte.
-Thus the actual size of
-.Fa d_name
-may vary from 1 to
-.Dv MAXNAMLEN
-\&+ 1.
-.Pp
-Entries may be separated by extra space.
-The
-.Fa d_reclen
-entry may be used as an offset from the start of a
-.Fa dirent
-structure to the next structure, if any.
-.Pp
-The actual number of bytes transferred is returned.
-The current position pointer associated with
-.Fa fd
-is set to point to the next block of entries.
-The pointer may not advance by the number of bytes returned by
-.Fn getdirentries
-or
-.Fn getdents .
-A value of zero is returned when
-the end of the directory has been reached.
-.Pp
-If the
-.Fa basep
-pointer value is non-NULL,
-the
-.Fn getdirentries
-system call writes the position of the block read into the location pointed to by
-.Fa basep .
-Alternatively, the current position pointer may be set and retrieved by
-.Xr lseek 2 .
-The current position pointer should only be set to a value returned by
-.Xr lseek 2 ,
-a value returned in the location pointed to by
-.Fa basep
-.Po Fn getdirentries
-only
-.Pc ,
-a value returned in the
-.Fa d_off
-field if it is non-zero,
-or zero.
-.Sh IMPLEMENTATION NOTES
-The
-.Fa d_off
-field is currently set to 0 by the NFS client, since the
-directory offset cookies returned by an NFS server cannot
-be used by
-.Xr lseek 2
-at this time.
-.Sh RETURN VALUES
-If successful, the number of bytes actually transferred is returned.
-Otherwise, -1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn getdirentries
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid file descriptor open for reading.
-.It Bq Er EFAULT
-Either
-.Fa buf
-or non-NULL
-.Fa basep
-point outside the allocated address space.
-.It Bq Er EINVAL
-The file referenced by
-.Fa fd
-is not a directory, or
-.Fa nbytes
-is too small for returning a directory entry or block of entries,
-or the current position pointer is invalid.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ENOENT
-Directory unlinked but still open.
-.El
-.Sh SEE ALSO
-.Xr lseek 2 ,
-.Xr open 2
-.Sh HISTORY
-The
-.Fn getdirentries
-system call first appeared in
-.Bx 4.4 .
-The
-.Fn getdents
-system call first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/getdirentries.c b/lib/libc/sys/getdirentries.c
deleted file mode 100644
index 92f43e74cab7..000000000000
--- a/lib/libc/sys/getdirentries.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#define _WANT_FREEBSD11_DIRENT
-
-#include "namespace.h"
-#include <sys/param.h>
-#include <sys/syscall.h>
-#include "compat-ino64.h"
-#include <dirent.h>
-#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include "libc_private.h"
-
-static ssize_t
-__cvt_dirents_from11(const char *de11, ssize_t len11, char *de, ssize_t len)
-{
- struct dirent *dst;
- const struct freebsd11_dirent *src;
- const char *edst, *esrc;
- ssize_t rlen;
-
- src = (const struct freebsd11_dirent *)de11;
- dst = (struct dirent *)de;
- esrc = de11 + len11;
- edst = de + len;
- while ((const char *)src < esrc && (const char *)dst < edst) {
- rlen = roundup(offsetof(struct dirent, d_name) + src->d_namlen + 1, 8);
- if ((const char *)dst + rlen >= edst)
- break;
- dst->d_fileno = src->d_fileno;
- dst->d_off = 0; /* nothing uses it yet, so safe for now */
- dst->d_reclen = rlen;
- dst->d_type = src->d_type;
- dst->d_pad0 = 0;
- dst->d_namlen = src->d_namlen;
- dst->d_pad1 = 0;
- memset(dst->d_name, 0, roundup(src->d_namlen + 1, 8));
- memcpy(dst->d_name, src->d_name, src->d_namlen);
- dst = (struct dirent *)((char *)dst + rlen);
- src = (const struct freebsd11_dirent *)((const char *)src + src->d_reclen);
- }
- return ((char *)dst - de);
-}
-
-#undef getdirentries
-__weak_reference(_getdirentries, getdirentries);
-
-#pragma weak _getdirentries
-ssize_t
-_getdirentries(int fd, char *buf, size_t nbytes, off_t *basep)
-{
- char *oldbuf;
- size_t len;
- ssize_t rv;
-
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_getdirentries(fd, buf, nbytes, basep));
-
- /*
- * Because the old system call returns entries that are smaller than the
- * new, we could wind up in a situation where we have too many to fit in
- * the buffer with the new encoding. So sacrifice a small bit of
- * efficiency to ensure that never happens. We pick 1/4 the size round
- * up to the next DIRBLKSIZ. This will guarnatee enough room exists in
- * the dst buffer due to changes in efficiency in packing dirent
- * entries. We don't check against minimum block size to avoid a lot of
- * stat calls, we'll see if that's wise or not.
- * TBD: Will this difference matter to lseek?
- */
- len = roundup(nbytes / 4, DIRBLKSIZ);
- oldbuf = malloc(len);
- if (oldbuf == NULL) {
- errno = EINVAL; /* ENOMEM not in possible list */
- return (-1);
- }
- rv = syscall(SYS_freebsd11_getdirentries, fd, oldbuf, len, basep);
- if (rv == -1) {
- free(oldbuf);
- return (rv);
- }
- if (rv > 0)
- rv = __cvt_dirents_from11(oldbuf, rv, buf, nbytes);
- free(oldbuf);
-
- return (rv);
-}
diff --git a/lib/libc/sys/getdtablesize.2 b/lib/libc/sys/getdtablesize.2
deleted file mode 100644
index 3c6b25ac626c..000000000000
--- a/lib/libc/sys/getdtablesize.2
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getdtablesize.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd April 24, 2013
-.Dt GETDTABLESIZE 2
-.Os
-.Sh NAME
-.Nm getdtablesize
-.Nd get file descriptor limit
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn getdtablesize void
-.Sh DESCRIPTION
-The
-.Fn getdtablesize
-system call returns the maximum number of file descriptors
-that the current process may open.
-The maximum file descriptor number that the system may assign
-is the return value minus one.
-Existing file descriptor numbers may be higher
-if the limit was lowered after they were opened.
-.Sh SEE ALSO
-.Xr close 2 ,
-.Xr closefrom 2 ,
-.Xr dup 2 ,
-.Xr getrlimit 2 ,
-.Xr sysconf 3
-.Sh HISTORY
-The
-.Fn getdtablesize
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/getfh.2 b/lib/libc/sys/getfh.2
deleted file mode 100644
index f5eaf4be7874..000000000000
--- a/lib/libc/sys/getfh.2
+++ /dev/null
@@ -1,233 +0,0 @@
-.\" Copyright (c) 1989, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\" Copyright (c) 2018 Gandi
-.\"
-.\" 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.
-.\"
-.\" @(#)getfh.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd November 30, 2022
-.Dt GETFH 2
-.Os
-.Sh NAME
-.Nm getfh ,
-.Nm lgetfh ,
-.Nm getfhat
-.Nd get file handle
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/mount.h
-.Ft int
-.Fn getfh "const char *path" "fhandle_t *fhp"
-.Ft int
-.Fn lgetfh "const char *path" "fhandle_t *fhp"
-.Ft int
-.Fn getfhat "int fd" "const char *path" "fhandle_t *fhp" "int flag"
-.Sh DESCRIPTION
-The
-.Fn getfh
-system call
-returns a file handle for the specified file or directory
-in the file handle pointed to by
-.Fa fhp .
-.Pp
-The
-.Fn lgetfh
-system call is like
-.Fn getfh
-except in the case where the named file is a symbolic link,
-in which case
-.Fn lgetfh
-returns information about the link,
-while
-.Fn getfh
-returns information about the file the link references.
-.Pp
-The
-.Fn getfhat
-system call is equivalent to
-.Fn getfh
-and
-.Fn lgetfh
-except when the
-.Fa path
-specifies a relative path.
-For
-.Fn getfhat
-and relative
-.Fa path ,
-the status is retrieved from a file relative to
-the directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-.Pp
-The values for the
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from this list,
-defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_NOFOLLOW
-If
-.Fa path
-names a symbolic link, the status of the symbolic link is returned.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.El
-.Pp
-If
-.Fn getfhat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn getfth
-or
-.Fn lgetfh
-respectively, depending on whether or not the
-.Dv AT_SYMLINK_NOFOLLOW
-bit is set in
-.Fa flag .
-.Pp
-When
-.Fn getfhat
-is called with an absolute
-.Fa path ,
-it ignores the
-.Fa fd
-argument.
-.Pp
-These system calls are restricted to the superuser.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn getfh
-and
-.Fn lgetfh
-system calls
-fail if one or more of the following are true:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller does not have appropriate privilege to perform the operation.
-.It Bq Er ENOTDIR
-A component of the path prefix of
-.Fa path
-is not a directory.
-.It Bq Er ENAMETOOLONG
-The length of a component of
-.Fa path
-exceeds 255 characters,
-or the length of
-.Fa path
-exceeds 1023 characters.
-.It Bq Er ENOENT
-The file referred to by
-.Fa path
-does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix of
-.Fa path .
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating
-.Fa path .
-.It Bq Er EFAULT
-The
-.Fa fhp
-argument
-points to an invalid address.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points to an invalid address.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ESTALE
-The file handle
-.Fa fhp
-is no longer valid.
-.El
-.Pp
-In addition to the errors returned by
-.Fn getfh ,
-and
-.Fn lgetfh ,
-the
-.Fn getfhat
-system call may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument, is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.Sh SEE ALSO
-.Xr fhopen 2 ,
-.Xr open 2 ,
-.Xr stat 2
-.Sh HISTORY
-The
-.Fn getfh
-system call first appeared in
-.Bx 4.4 .
-The
-.Fn lgetfh
-system call first appeared in
-.Fx 5.3 .
-The
-.Fn getfhat
-system call first appeared in
-.Fx 12.1 .
diff --git a/lib/libc/sys/getfsstat.2 b/lib/libc/sys/getfsstat.2
deleted file mode 100644
index 24406a0959b4..000000000000
--- a/lib/libc/sys/getfsstat.2
+++ /dev/null
@@ -1,131 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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.
-.\"
-.\" @(#)getfsstat.2 8.3 (Berkeley) 5/25/95
-.\"
-.Dd March 30, 2020
-.Dt GETFSSTAT 2
-.Os
-.Sh NAME
-.Nm getfsstat
-.Nd get list of all mounted file systems
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/ucred.h
-.In sys/mount.h
-.Ft int
-.Fn getfsstat "struct statfs *buf" "long bufsize" "int mode"
-.Sh DESCRIPTION
-The
-.Fn getfsstat
-system call
-returns information about all mounted file systems.
-The
-.Fa buf
-argument
-is a pointer to
-.Vt statfs
-structures, as described in
-.Xr statfs 2 .
-.Pp
-Fields that are undefined for a particular file system are set to -1.
-The buffer is filled with an array of
-.Fa statfs
-structures, one for each mounted file system
-up to the byte count specified by
-.Fa bufsize .
-Note, the
-.Fa bufsize
-argument is the number of bytes that
-.Fa buf
-can hold, not the count of statfs structures it will hold.
-.Pp
-If
-.Fa buf
-is given as NULL,
-.Fn getfsstat
-returns just the number of mounted file systems.
-.Pp
-Normally
-.Fa mode
-should be specified as
-.Dv MNT_WAIT .
-If
-.Fa mode
-is set to
-.Dv MNT_NOWAIT ,
-.Fn getfsstat
-will return the information it has available without requesting
-an update from each file system.
-Thus, some of the information will be out of date, but
-.Fn getfsstat
-will not block waiting for information from a file system that is
-unable to respond.
-It will also skip any file system that is in the process of being
-unmounted, even if the unmount would eventually fail.
-.Sh RETURN VALUES
-Upon successful completion, the number of
-.Fa statfs
-structures is returned.
-Otherwise, -1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn getfsstat
-system call
-fails if one or more of the following are true:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa buf
-argument
-points to an invalid address.
-.It Bq Er EINVAL
-.Fa mode
-is set to a value other than
-.Dv MNT_WAIT
-or
-.Dv MNT_NOWAIT .
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh SEE ALSO
-.Xr statfs 2 ,
-.Xr fstab 5 ,
-.Xr mount 8
-.Sh HISTORY
-The
-.Fn getfsstat
-system call first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/sys/getfsstat.c b/lib/libc/sys/getfsstat.c
deleted file mode 100644
index 60cd433c9d40..000000000000
--- a/lib/libc/sys/getfsstat.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <sys/param.h>
-#include "compat-ino64.h"
-#include <sys/errno.h>
-#include <sys/syscall.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "libc_private.h"
-
-int
-getfsstat(struct statfs *buf, long bufsize, int flags)
-{
- struct freebsd11_statfs *statfs11 = NULL;
- ssize_t len = 0;
- int rv, i;
-
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_getfsstat(buf, bufsize, flags));
- if (buf != NULL) {
- len = sizeof(struct freebsd11_statfs) * /* Round down on purpose to avoid */
- (bufsize / sizeof(struct statfs)); /* overflow on translation. */
- statfs11 = malloc(len);
- if (statfs11 == NULL) {
- errno = ENOMEM;
- return (-1);
- }
- }
- rv = syscall(SYS_freebsd11_getfsstat, statfs11, len, flags);
- if (rv != -1 && buf != NULL) {
- for (i = 0; i < rv; i++)
- __statfs11_to_statfs(&statfs11[i], &buf[i]);
- }
- free(statfs11);
- return (rv);
-}
diff --git a/lib/libc/sys/getgid.2 b/lib/libc/sys/getgid.2
deleted file mode 100644
index d6a3a8cd9764..000000000000
--- a/lib/libc/sys/getgid.2
+++ /dev/null
@@ -1,84 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getgid.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd May 1, 2020
-.Dt GETGID 2
-.Os
-.Sh NAME
-.Nm getgid ,
-.Nm getegid
-.Nd get group process identification
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft gid_t
-.Fn getgid void
-.Ft gid_t
-.Fn getegid void
-.Sh DESCRIPTION
-The
-.Fn getgid
-system call returns the real group ID of the calling process,
-.Fn getegid
-returns the effective group ID of the calling process.
-.Pp
-The real group ID is specified at login time.
-.Pp
-The real group ID is the group of the user who invoked the program.
-As the effective group ID gives the process additional permissions
-during the execution of
-.Dq Em set-group-ID
-mode processes,
-.Fn getgid
-is used to determine the real-user-id of the calling process.
-.Sh ERRORS
-The
-.Fn getgid
-and
-.Fn getegid
-system calls are always successful, and no return value is reserved to
-indicate an error.
-.Sh SEE ALSO
-.Xr getuid 2 ,
-.Xr issetugid 2 ,
-.Xr setgid 2 ,
-.Xr setregid 2
-.Sh STANDARDS
-The
-.Fn getgid
-and
-.Fn getegid
-system calls are expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn getgid
-function appeared in
-.At v4 .
diff --git a/lib/libc/sys/getgroups.2 b/lib/libc/sys/getgroups.2
deleted file mode 100644
index 44dff6b4c08d..000000000000
--- a/lib/libc/sys/getgroups.2
+++ /dev/null
@@ -1,106 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getgroups.2 8.2 (Berkeley) 4/16/94
-.\"
-.Dd January 21, 2011
-.Dt GETGROUPS 2
-.Os
-.Sh NAME
-.Nm getgroups
-.Nd get group access list
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn getgroups "int gidsetlen" "gid_t *gidset"
-.Sh DESCRIPTION
-The
-.Fn getgroups
-system call
-gets the current group access list of the user process
-and stores it in the array
-.Fa gidset .
-The
-.Fa gidsetlen
-argument
-indicates the number of entries that may be placed in
-.Fa gidset .
-The
-.Fn getgroups
-system call
-returns the actual number of groups returned in
-.Fa gidset .
-At least one and as many as {NGROUPS_MAX}+1 values may be returned.
-If
-.Fa gidsetlen
-is zero,
-.Fn getgroups
-returns the number of supplementary group IDs associated with
-the calling process without modifying the array pointed to by
-.Fa gidset .
-.Pp
-The value of
-.Dv {NGROUPS_MAX}
-should be obtained using
-.Xr sysconf 3
-to avoid hard-coding it into the executable.
-.Sh RETURN VALUES
-A successful call returns the number of groups in the group set.
-A value of -1 indicates that an error occurred, and the error
-code is stored in the global variable
-.Va errno .
-.Sh ERRORS
-The possible errors for
-.Fn getgroups
-are:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The argument
-.Fa gidsetlen
-is smaller than the number of groups in the group set.
-.It Bq Er EFAULT
-The argument
-.Fa gidset
-specifies
-an invalid address.
-.El
-.Sh SEE ALSO
-.Xr setgroups 2 ,
-.Xr initgroups 3 ,
-.Xr sysconf 3
-.Sh STANDARDS
-The
-.Fn getgroups
-system call conforms to
-.St -p1003.1-2008 .
-.Sh HISTORY
-The
-.Fn getgroups
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/getitimer.2 b/lib/libc/sys/getitimer.2
deleted file mode 100644
index 78348ee28fd8..000000000000
--- a/lib/libc/sys/getitimer.2
+++ /dev/null
@@ -1,194 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getitimer.2 8.3 (Berkeley) 5/16/95
-.\"
-.Dd May 1, 2020
-.Dt GETITIMER 2
-.Os
-.Sh NAME
-.Nm getitimer ,
-.Nm setitimer
-.Nd get/set value of interval timer
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/time.h
-.Fd "#define ITIMER_REAL 0"
-.Fd "#define ITIMER_VIRTUAL 1"
-.Fd "#define ITIMER_PROF 2"
-.Ft int
-.Fn getitimer "int which" "struct itimerval *value"
-.Ft int
-.Fn setitimer "int which" "const struct itimerval *value" "struct itimerval *ovalue"
-.Sh DESCRIPTION
-The system provides each process with three interval timers,
-defined in
-.In sys/time.h .
-The
-.Fn getitimer
-system call returns the current value for the timer specified in
-.Fa which
-in the structure at
-.Fa value .
-The
-.Fn setitimer
-system call sets a timer to the specified
-.Fa value
-(returning the previous value of the timer if
-.Fa ovalue
-is not a null pointer).
-.Pp
-A timer value is defined by the
-.Fa itimerval
-structure:
-.Bd -literal -offset indent
-struct itimerval {
- struct timeval it_interval; /* timer interval */
- struct timeval it_value; /* current value */
-};
-.Ed
-.Pp
-If
-.Fa it_value
-is non-zero, it indicates the time to the next timer expiration.
-If
-.Fa it_interval
-is non-zero, it specifies a value to be used in reloading
-.Fa it_value
-when the timer expires.
-Setting
-.Fa it_value
-to 0 disables a timer, regardless of the value of
-.Fa it_interval .
-Setting
-.Fa it_interval
-to 0 causes a timer to be disabled after its next expiration (assuming
-.Fa it_value
-is non-zero).
-.Pp
-Time values smaller than the resolution of the
-system clock are rounded up to this resolution
-(typically 10 milliseconds).
-.Pp
-The
-.Dv ITIMER_REAL
-timer decrements in real time.
-A
-.Dv SIGALRM
-signal is
-delivered when this timer expires.
-.Pp
-The
-.Dv ITIMER_VIRTUAL
-timer decrements in process virtual time.
-It runs only when the process is executing.
-A
-.Dv SIGVTALRM
-signal
-is delivered when it expires.
-.Pp
-The
-.Dv ITIMER_PROF
-timer decrements both in process virtual time and
-when the system is running on behalf of the process.
-It is designed
-to be used by interpreters in statistically profiling the execution
-of interpreted programs.
-Each time the
-.Dv ITIMER_PROF
-timer expires, the
-.Dv SIGPROF
-signal is
-delivered.
-Because this signal may interrupt in-progress
-system calls, programs using this timer must be prepared to
-restart interrupted system calls.
-.Pp
-The maximum number of seconds allowed for
-.Fa it_interval
-and
-.Fa it_value
-in
-.Fn setitimer
-is 100000000.
-.Sh NOTES
-Three macros for manipulating time values are defined in
-.In sys/time.h .
-The
-.Fn timerclear
-macro
-sets a time value to zero,
-.Fn timerisset
-tests if a time value is non-zero, and
-.Fn timercmp
-compares two time values.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn getitimer
-and
-.Fn setitimer
-system calls
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa value
-argument specified a bad address.
-.It Bq Er EINVAL
-The
-.Fa value
-argument specified a time that was too large
-to be handled.
-.El
-.Sh SEE ALSO
-.Xr gettimeofday 2 ,
-.Xr select 2 ,
-.Xr sigaction 2 ,
-.Xr clocks 7
-.Sh STANDARDS
-The
-.Fn getitimer
-and
-.Fn setitimer
-functions conform to
-.St -p1003.1-2001 .
-The later
-.St -p1003.1-2008
-revision however marked both functions as obsolescent,
-recommending the use of
-.Xr timer_gettime 2
-and
-.Xr timer_settime 2
-instead.
-.Sh HISTORY
-The
-.Fn getitimer
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/getlogin.2 b/lib/libc/sys/getlogin.2
deleted file mode 100644
index 6864282c41d2..000000000000
--- a/lib/libc/sys/getlogin.2
+++ /dev/null
@@ -1,203 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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.
-.\"
-.\" @(#)getlogin.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd September 9, 2020
-.Dt GETLOGIN 2
-.Os
-.Sh NAME
-.Nm getlogin ,
-.Nm getlogin_r ,
-.Nm setlogin
-.Nd get/set login name
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft char *
-.Fn getlogin void
-.In sys/param.h
-.Ft int
-.Fn getlogin_r "char *name" "size_t len"
-.Ft int
-.Fn setlogin "const char *name"
-.Sh DESCRIPTION
-The
-.Fn getlogin
-routine
-returns the login name of the user associated with the current session,
-as previously set by
-.Fn setlogin .
-The name is normally associated with a login shell
-at the time a session is created,
-and is inherited by all processes descended from the login shell.
-(This is true even if some of those processes assume another user ID,
-for example when
-.Xr su 1
-is used).
-.Pp
-The
-.Fn getlogin_r
-function
-provides the same service as
-.Fn getlogin
-except the caller must provide the buffer
-.Fa name
-with length
-.Fa len
-bytes
-to hold the result.
-The buffer should be at least
-.Dv MAXLOGNAME
-bytes in length.
-.Pp
-The
-.Fn setlogin
-system call
-sets the login name of the user associated with the current session to
-.Fa name .
-This system call is restricted to the super-user, and
-is normally used only when a new session is being created on behalf
-of the named user
-(for example, at login time, or when a remote shell is invoked).
-.Pp
-.Em NOTE :
-There is only one login name per session.
-.Pp
-It is
-.Em CRITICALLY
-important to ensure that
-.Fn setlogin
-is only ever called after the process has taken adequate steps to ensure
-that it is detached from its parent's session.
-Making a
-.Fn setsid
-system call is the
-.Em ONLY
-way to do this.
-The
-.Xr daemon 3
-function calls
-.Fn setsid
-which is an ideal way of detaching from a controlling terminal and
-forking into the background.
-.Pp
-In particular, doing a
-.Fn ioctl ttyfd TIOCNOTTY ...\&
-or
-.Fn setpgrp ...\&
-is
-.Em NOT
-sufficient.
-.Pp
-Once a parent process does a
-.Fn setsid
-system call, it is acceptable for some child of that process to then do a
-.Fn setlogin
-even though it is not the session leader, but beware that ALL processes
-in the session will change their login name at the same time, even the
-parent.
-.Pp
-This is not the same as the traditional UNIX behavior of inheriting privilege.
-.Pp
-Since the
-.Fn setlogin
-system call is restricted to the super-user, it is assumed that (like
-all other privileged programs) the programmer has taken adequate
-precautions to prevent security violations.
-.Sh RETURN VALUES
-If a call to
-.Fn getlogin
-succeeds, it returns a pointer to a null-terminated string in a static buffer,
-or
-.Dv NULL
-if the name has not been set.
-The
-.Fn getlogin_r
-function
-returns zero if successful, or the error number upon failure.
-.Pp
-.Rv -std setlogin
-.Sh ERRORS
-The following errors may be returned by these calls:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa name
-argument gave an
-invalid address.
-.It Bq Er EINVAL
-The
-.Fa name
-argument
-pointed to a string that was too long.
-Login names are limited to
-.Dv MAXLOGNAME
-(from
-.In sys/param.h )
-characters, currently 33 including null.
-.It Bq Er EPERM
-The caller tried to set the login name and was not the super-user.
-.It Bq Er ERANGE
-The size of the buffer is smaller than the result to be returned.
-.El
-.Sh SEE ALSO
-.Xr setsid 2 ,
-.Xr daemon 3
-.Sh STANDARDS
-The
-.Fn getlogin
-system call
-and
-the
-.Fn getlogin_r
-function
-conform to
-.St -p1003.1-96 .
-.Sh HISTORY
-The
-.Fn getlogin
-system call first appeared in
-.Bx 4.4 .
-The return value of
-.Fn getlogin_r
-was changed from earlier versions of
-.Fx
-to be conformant with
-.St -p1003.1-96 .
-.Sh BUGS
-In earlier versions of the system,
-.Fn getlogin
-failed unless the process was associated with a login terminal.
-The current implementation (using
-.Fn setlogin )
-allows getlogin to succeed even when the process has no controlling terminal.
-In earlier versions of the system, the value returned by
-.Fn getlogin
-could not be trusted without checking the user ID.
-Portable programs should probably still make this check.
diff --git a/lib/libc/sys/getpeername.2 b/lib/libc/sys/getpeername.2
deleted file mode 100644
index 914152e4dba8..000000000000
--- a/lib/libc/sys/getpeername.2
+++ /dev/null
@@ -1,97 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getpeername.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt GETPEERNAME 2
-.Os
-.Sh NAME
-.Nm getpeername
-.Nd get name of connected peer
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.Ft int
-.Fn getpeername "int s" "struct sockaddr * restrict name" "socklen_t * restrict namelen"
-.Sh DESCRIPTION
-The
-.Fn getpeername
-system call
-returns the name of the peer connected to
-socket
-.Fa s .
-The
-.Fa namelen
-argument should be initialized to indicate
-the amount of space pointed to by
-.Fa name .
-On return it contains the actual size of the name
-returned (in bytes).
-The name is truncated if the buffer provided is too small.
-.Sh RETURN VALUES
-.Rv -std getpeername
-.Sh ERRORS
-The call succeeds unless:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The argument
-.Fa s
-is not a valid descriptor.
-.It Bq Er ECONNRESET
-The connection has been reset by the peer.
-.It Bq Er EINVAL
-The value of the
-.Fa namelen
-argument is not valid.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is a file, not a socket.
-.It Bq Er ENOTCONN
-The socket is not connected.
-.It Bq Er ENOBUFS
-Insufficient resources were available in the system
-to perform the operation.
-.It Bq Er EFAULT
-The
-.Fa name
-argument points to memory not in a valid part of the
-process address space.
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr bind 2 ,
-.Xr getsockname 2 ,
-.Xr socket 2
-.Sh HISTORY
-The
-.Fn getpeername
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/getpgrp.2 b/lib/libc/sys/getpgrp.2
deleted file mode 100644
index 1d583d102621..000000000000
--- a/lib/libc/sys/getpgrp.2
+++ /dev/null
@@ -1,141 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getpgrp.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt GETPGRP 2
-.Os
-.Sh NAME
-.Nm getpgrp
-.Nd get process group
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft pid_t
-.Fn getpgrp void
-.Ft pid_t
-.Fn getpgid "pid_t pid"
-.Sh DESCRIPTION
-The process group of the current process is returned by
-.Fn getpgrp .
-The process group of the process identified by
-.Fa pid
-is returned by
-.Fn getpgid .
-If
-.Fa pid
-is zero,
-.Fn getpgid
-returns the process group of the current process.
-.Pp
-Process groups are used for distribution of signals, and
-by terminals to arbitrate requests for their input: processes
-that have the same process group as the terminal are foreground
-and may read, while others will block with a signal if they attempt
-to read.
-.Pp
-This system call is thus used by programs such as
-.Xr csh 1
-to create
-process groups
-in implementing job control.
-The
-.Fn tcgetpgrp
-and
-.Fn tcsetpgrp
-calls
-are used to get/set the process group of the control terminal.
-.Sh RETURN VALUES
-The
-.Fn getpgrp
-system call always succeeds.
-Upon successful completion, the
-.Fn getpgid
-system call returns the process group of the specified process;
-otherwise, it returns a value of \-1 and sets
-.Va errno
-to indicate the error.
-.Sh COMPATIBILITY
-This version of
-.Fn getpgrp
-differs from past Berkeley versions by not taking a
-.Fa "pid_t pid"
-argument.
-This incompatibility is required by
-.St -p1003.1-90 .
-.Pp
-From the
-.St -p1003.1-90
-Rationale:
-.Pp
-.Bx 4.3
-provides a
-.Fn getpgrp
-system call that returns the process group ID for a specified process.
-Although this function is used to support job control, all known
-job-control shells always specify the calling process with this
-function.
-Thus, the simpler
-.At V
-.Fn getpgrp
-suffices, and the added complexity of the
-.Bx 4.3
-.Fn getpgrp
-has been omitted from POSIX.1.
-The old functionality is available from the
-.Fn getpgid
-system call.
-.Sh ERRORS
-The
-.Fn getpgid
-system call
-will succeed unless:
-.Bl -tag -width Er
-.It Bq Er ESRCH
-there is no process whose process ID equals
-.Fa pid
-.El
-.Sh SEE ALSO
-.Xr getsid 2 ,
-.Xr setpgid 2 ,
-.Xr termios 4
-.Sh STANDARDS
-The
-.Fn getpgrp
-system call is expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn getpgrp
-system call appeared in
-.Bx 4.0 .
-The
-.Fn getpgid
-system call is derived from its usage in
-.At V.4 .
diff --git a/lib/libc/sys/getpid.2 b/lib/libc/sys/getpid.2
deleted file mode 100644
index d6c23d0577be..000000000000
--- a/lib/libc/sys/getpid.2
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)getpid.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 15, 2015
-.Dt GETPID 2
-.Os
-.Sh NAME
-.Nm getpid ,
-.Nm getppid
-.Nd get parent or calling process identification
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft pid_t
-.Fn getpid void
-.Ft pid_t
-.Fn getppid void
-.Sh DESCRIPTION
-The
-.Fn getpid
-system call
-returns
-the process ID of
-the calling process.
-Though the ID is guaranteed to be unique, it should
-.Em NOT
-be used for constructing temporary file names, for
-security reasons; see
-.Xr mkstemp 3
-instead.
-.Pp
-The
-.Fn getppid
-system call
-returns the process ID of the parent
-of the calling process.
-.Sh ERRORS
-The
-.Fn getpid
-and
-.Fn getppid
-system calls are always successful, and no return value is reserved to
-indicate an error.
-.Sh SEE ALSO
-.Xr fork 2 ,
-.Xr getpgrp 2 ,
-.Xr kill 2 ,
-.Xr setpgid 2 ,
-.Xr setsid 2 ,
-.Xr exec 3
-.Sh STANDARDS
-The
-.Fn getpid
-and
-.Fn getppid
-system calls are expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn getpid
-function appeared in
-.At v7 .
diff --git a/lib/libc/sys/getpriority.2 b/lib/libc/sys/getpriority.2
deleted file mode 100644
index 6f1332815585..000000000000
--- a/lib/libc/sys/getpriority.2
+++ /dev/null
@@ -1,149 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)getpriority.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt GETPRIORITY 2
-.Os
-.Sh NAME
-.Nm getpriority ,
-.Nm setpriority
-.Nd get/set program scheduling priority
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/time.h
-.In sys/resource.h
-.Ft int
-.Fn getpriority "int which" "int who"
-.Ft int
-.Fn setpriority "int which" "int who" "int prio"
-.Sh DESCRIPTION
-The scheduling
-priority of the process, process group, or user, as indicated by
-.Fa which
-and
-.Fa who
-is obtained with the
-.Fn getpriority
-system call and set with the
-.Fn setpriority
-system call.
-The
-.Fa which
-argument
-is one of
-.Dv PRIO_PROCESS ,
-.Dv PRIO_PGRP ,
-or
-.Dv PRIO_USER ,
-and
-.Fa who
-is interpreted relative to
-.Fa which
-(a process identifier for
-.Dv PRIO_PROCESS ,
-process group
-identifier for
-.Dv PRIO_PGRP ,
-and a user ID for
-.Dv PRIO_USER ) .
-A zero value of
-.Fa who
-denotes the current process, process group, or user.
-The
-.Fa prio
-argument
-is a value in the range -20 to 20.
-The default priority is 0;
-lower priorities cause more favorable scheduling.
-.Pp
-The
-.Fn getpriority
-system call returns the highest priority (lowest numerical value)
-enjoyed by any of the specified processes.
-The
-.Fn setpriority
-system call sets the priorities of all of the specified processes
-to the specified value.
-Only the super-user may lower priorities.
-.Sh RETURN VALUES
-Since
-.Fn getpriority
-can legitimately return the value -1, it is necessary
-to clear the external variable
-.Va errno
-prior to the
-call, then check it afterward to determine
-if a -1 is an error or a legitimate value.
-.Pp
-.Rv -std setpriority
-.Sh ERRORS
-The
-.Fn getpriority
-and
-.Fn setpriority
-system calls
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ESRCH
-No process was located using the
-.Fa which
-and
-.Fa who
-values specified.
-.It Bq Er EINVAL
-The
-.Fa which
-argument
-was not one of
-.Dv PRIO_PROCESS ,
-.Dv PRIO_PGRP ,
-or
-.Dv PRIO_USER .
-.El
-.Pp
-In addition to the errors indicated above,
-.Fn setpriority
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-A process was located, but neither its effective nor real user
-ID matched the effective user ID of the caller.
-.It Bq Er EACCES
-A non super-user attempted to lower a process priority.
-.El
-.Sh SEE ALSO
-.Xr nice 1 ,
-.Xr fork 2 ,
-.Xr renice 8
-.Sh HISTORY
-The
-.Fn getpriority
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/getrlimit.2 b/lib/libc/sys/getrlimit.2
deleted file mode 100644
index b28a82ca9534..000000000000
--- a/lib/libc/sys/getrlimit.2
+++ /dev/null
@@ -1,237 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)getrlimit.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd September 30, 2016
-.Dt GETRLIMIT 2
-.Os
-.Sh NAME
-.Nm getrlimit ,
-.Nm setrlimit
-.Nd control maximum system resource consumption
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/time.h
-.In sys/resource.h
-.Ft int
-.Fn getrlimit "int resource" "struct rlimit *rlp"
-.Ft int
-.Fn setrlimit "int resource" "const struct rlimit *rlp"
-.Sh DESCRIPTION
-Limits on the consumption of system resources by the current process
-and each process it creates may be obtained with the
-.Fn getrlimit
-system call, and set with the
-.Fn setrlimit
-system call.
-.Pp
-The
-.Fa resource
-argument is one of the following:
-.Bl -tag -width RLIMIT_FSIZEAA
-.It Dv RLIMIT_AS
-The maximum amount (in bytes) of virtual memory the process is
-allowed to map.
-.It Dv RLIMIT_CORE
-The largest size (in bytes)
-.Xr core 5
-file that may be created.
-.It Dv RLIMIT_CPU
-The maximum amount of cpu time (in seconds) to be used by
-each process.
-.It Dv RLIMIT_DATA
-The maximum size (in bytes) of the data segment for a process;
-this defines how far a program may extend its break with the
-.Xr sbrk 2
-function.
-.It Dv RLIMIT_FSIZE
-The largest size (in bytes) file that may be created.
-.It Dv RLIMIT_KQUEUES
-The maximum number of kqueues this user id is allowed to create.
-.It Dv RLIMIT_MEMLOCK
-The maximum size (in bytes) which a process may lock into memory
-using the
-.Xr mlock 2
-system call.
-.It Dv RLIMIT_NOFILE
-The maximum number of open files for this process.
-.It Dv RLIMIT_NPROC
-The maximum number of simultaneous processes for this user id.
-.It Dv RLIMIT_NPTS
-The maximum number of pseudo-terminals this user id is allowed to create.
-.It Dv RLIMIT_RSS
-When there is memory pressure and swap is available, prioritize eviction of
-a process' resident pages beyond this amount (in bytes).
-When memory is not under pressure, this rlimit is effectively ignored.
-Even when there is memory pressure, the amount of available swap space and some
-sysctl settings like
-.Xr vm.swap_enabled
-and
-.Xr vm.swap_idle_enabled
-can affect what happens to processes that have exceeded this size.
-.Pp
-Processes that exceed their set
-.Dv RLIMIT_RSS
-are not signalled or halted.
-The limit is merely a hint to the VM daemon to prefer to deactivate pages from
-processes that have exceeded their set
-.Dv RLIMIT_RSS .
-.It Dv RLIMIT_SBSIZE
-The maximum size (in bytes) of socket buffer usage for this user.
-This limits the amount of network memory, and hence the amount of
-mbufs, that this user may hold at any time.
-.It Dv RLIMIT_STACK
-The maximum size (in bytes) of the stack segment for a process;
-this defines how far a program's stack segment may be extended.
-Stack extension is performed automatically by the system.
-.It Dv RLIMIT_SWAP
-The maximum size (in bytes) of the swap space that may be reserved or
-used by all of this user id's processes.
-This limit is enforced only if bit 1 of the
-.Va vm.overcommit
-sysctl is set.
-Please see
-.Xr tuning 7
-for a complete description of this sysctl.
-.It Dv RLIMIT_VMEM
-An alias for
-.Dv RLIMIT_AS .
-.El
-.Pp
-A resource limit is specified as a soft limit and a hard limit.
-When a soft limit is exceeded, a process might or might not receive a signal.
-For example, signals are generated when the cpu time or file size is exceeded,
-but not if the address space or RSS limit is exceeded.
-A program that exceeds the soft limit is allowed to continue execution until it
-reaches the hard limit, or modifies its own resource limit.
-Even reaching the hard limit does not necessarily halt a process.
-For example, if the RSS hard limit is exceeded, nothing happens.
-.Pp
-The
-.Vt rlimit
-structure is used to specify the hard and soft limits on a resource.
-.Bd -literal -offset indent
-struct rlimit {
- rlim_t rlim_cur; /* current (soft) limit */
- rlim_t rlim_max; /* maximum value for rlim_cur */
-};
-.Ed
-.Pp
-Only the super-user may raise the maximum limits.
-Other users
-may only alter
-.Fa rlim_cur
-within the range from 0 to
-.Fa rlim_max
-or (irreversibly) lower
-.Fa rlim_max .
-.Pp
-An
-.Dq infinite
-value for a limit is defined as
-.Dv RLIM_INFINITY .
-.Pp
-Because this information is stored in the per-process information,
-this system call must be executed directly by the shell if it
-is to affect all future processes created by the shell;
-.Ic limit
-is thus a built-in command to
-.Xr csh 1 .
-.Pp
-The system refuses to extend the data or stack space when the limits
-would be exceeded in the normal way: a
-.Xr brk 2
-function fails if the data space limit is reached.
-When the stack limit is reached, the process receives
-a segmentation fault
-.Pq Dv SIGSEGV ;
-if this signal is not
-caught by a handler using the signal stack, this signal
-will kill the process.
-.Pp
-A file I/O operation that would create a file larger that the process'
-soft limit will cause the write to fail and a signal
-.Dv SIGXFSZ
-to be
-generated; this normally terminates the process, but may be caught.
-When
-the soft cpu time limit is exceeded, a
-.Dv SIGXCPU
-signal is sent to the
-offending process.
-.Pp
-When most operations would allocate more virtual memory than allowed by the
-soft limit of
-.Dv RLIMIT_AS ,
-the operation fails with
-.Dv ENOMEM
-and no signal is raised.
-A notable exception is stack extension, described above.
-If stack extension would allocate more virtual memory than allowed by the soft
-limit of
-.Dv RLIMIT_AS ,
-a
-.Dv SIGSEGV
-signal will be delivered.
-The caller is free to raise the soft address space limit up to the hard limit
-and retry the allocation.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn getrlimit
-and
-.Fn setrlimit
-system calls
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The address specified for
-.Fa rlp
-is invalid.
-.It Bq Er EPERM
-The limit specified to
-.Fn setrlimit
-would have
-raised the maximum limit value, and the caller is not the super-user.
-.El
-.Sh SEE ALSO
-.Xr csh 1 ,
-.Xr quota 1 ,
-.Xr quotactl 2 ,
-.Xr sigaction 2 ,
-.Xr sigaltstack 2 ,
-.Xr sysctl 3 ,
-.Xr ulimit 3
-.Sh HISTORY
-The
-.Fn getrlimit
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/getrusage.2 b/lib/libc/sys/getrusage.2
deleted file mode 100644
index 2038afb946e2..000000000000
--- a/lib/libc/sys/getrusage.2
+++ /dev/null
@@ -1,185 +0,0 @@
-.\" Copyright (c) 1985, 1991, 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.
-.\"
-.\" @(#)getrusage.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd May 1, 2010
-.Dt GETRUSAGE 2
-.Os
-.Sh NAME
-.Nm getrusage
-.Nd get information about resource utilization
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/time.h
-.In sys/resource.h
-.Fd "#define RUSAGE_SELF 0"
-.Fd "#define RUSAGE_CHILDREN -1"
-.Fd "#define RUSAGE_THREAD 1"
-.Ft int
-.Fn getrusage "int who" "struct rusage *rusage"
-.Sh DESCRIPTION
-The
-.Fn getrusage
-system call
-returns information describing the resources utilized by the current
-thread, the current process, or all its terminated child processes.
-The
-.Fa who
-argument is either
-.Dv RUSAGE_THREAD ,
-.Dv RUSAGE_SELF ,
-or
-.Dv RUSAGE_CHILDREN .
-The buffer to which
-.Fa rusage
-points will be filled in with
-the following structure:
-.Bd -literal
-struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
- long ru_maxrss; /* max resident set size */
- long ru_ixrss; /* integral shared text memory size */
- long ru_idrss; /* integral unshared data size */
- long ru_isrss; /* integral unshared stack size */
- long ru_minflt; /* page reclaims */
- long ru_majflt; /* page faults */
- long ru_nswap; /* swaps */
- long ru_inblock; /* block input operations */
- long ru_oublock; /* block output operations */
- long ru_msgsnd; /* messages sent */
- long ru_msgrcv; /* messages received */
- long ru_nsignals; /* signals received */
- long ru_nvcsw; /* voluntary context switches */
- long ru_nivcsw; /* involuntary context switches */
-};
-.Ed
-.Pp
-The fields are interpreted as follows:
-.Bl -tag -width ru_minfltaa
-.It Fa ru_utime
-the total amount of time spent executing in user mode.
-.It Fa ru_stime
-the total amount of time spent in the system executing on behalf
-of the process(es).
-.It Fa ru_maxrss
-the maximum resident set size utilized (in kilobytes).
-.It Fa ru_ixrss
-an
-.Dq integral
-value indicating the amount of memory used
-by the text segment
-that was also shared among other processes.
-This value is expressed
-in units of kilobytes * ticks-of-execution.
-Ticks are statistics clock ticks.
-The statistics clock has a frequency of
-.Fn sysconf _SC_CLK_TCK
-ticks per second.
-.It Fa ru_idrss
-an integral value of the amount of unshared memory residing in the
-data segment of a process (expressed in units of
-kilobytes * ticks-of-execution).
-.It Fa ru_isrss
-an integral value of the amount of unshared memory residing in the
-stack segment of a process (expressed in units of
-kilobytes * ticks-of-execution).
-.It Fa ru_minflt
-the number of page faults serviced without any I/O activity; here
-I/O activity is avoided by
-.Dq reclaiming
-a page frame from
-the list of pages awaiting reallocation.
-.It Fa ru_majflt
-the number of page faults serviced that required I/O activity.
-.It Fa ru_nswap
-the number of times a process was
-.Dq swapped
-out of main
-memory.
-.It Fa ru_inblock
-the number of times the file system had to perform input.
-.It Fa ru_oublock
-the number of times the file system had to perform output.
-.It Fa ru_msgsnd
-the number of IPC messages sent.
-.It Fa ru_msgrcv
-the number of IPC messages received.
-.It Fa ru_nsignals
-the number of signals delivered.
-.It Fa ru_nvcsw
-the number of times a context switch resulted due to a process
-voluntarily giving up the processor before its time slice was
-completed (usually to await availability of a resource).
-.It Fa ru_nivcsw
-the number of times a context switch resulted due to a higher
-priority process becoming runnable or because the current process
-exceeded its time slice.
-.El
-.Sh NOTES
-The numbers
-.Fa ru_inblock
-and
-.Fa ru_oublock
-account only for real
-I/O; data supplied by the caching mechanism is charged only
-to the first process to read or write the data.
-.Sh RETURN VALUES
-.Rv -std getrusage
-.Sh ERRORS
-The
-.Fn getrusage
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa who
-argument is not a valid value.
-.It Bq Er EFAULT
-The address specified by the
-.Fa rusage
-argument is not in a valid part of the process address space.
-.El
-.Sh SEE ALSO
-.Xr gettimeofday 2 ,
-.Xr wait 2 ,
-.Xr clocks 7
-.Sh HISTORY
-The
-.Fn getrusage
-system call appeared in
-.Bx 4.2 .
-The
-.Dv RUSAGE_THREAD
-facility first appeared in
-.Fx 8.1 .
-.Sh BUGS
-There is no way to obtain information about a child process
-that has not yet terminated.
diff --git a/lib/libc/sys/getsockname.2 b/lib/libc/sys/getsockname.2
deleted file mode 100644
index e7a992a3b4db..000000000000
--- a/lib/libc/sys/getsockname.2
+++ /dev/null
@@ -1,97 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getsockname.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt GETSOCKNAME 2
-.Os
-.Sh NAME
-.Nm getsockname
-.Nd get socket name
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.Ft int
-.Fn getsockname "int s" "struct sockaddr * restrict name" "socklen_t * restrict namelen"
-.Sh DESCRIPTION
-The
-.Fn getsockname
-system call
-returns the current
-.Fa name
-for the specified socket.
-The
-.Fa namelen
-argument should be initialized to indicate
-the amount of space pointed to by
-.Fa name .
-On return it contains the actual size of the name
-returned (in bytes).
-.Sh RETURN VALUES
-.Rv -std getsockname
-.Sh ERRORS
-The call succeeds unless:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The argument
-.Fa s
-is not a valid descriptor.
-.It Bq Er ECONNRESET
-The connection has been reset by the peer.
-.It Bq Er EINVAL
-The value of the
-.Fa namelen
-argument is not valid.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is a file, not a socket.
-.It Bq Er ENOBUFS
-Insufficient resources were available in the system
-to perform the operation.
-.It Bq Er EFAULT
-The
-.Fa name
-argument points to memory not in a valid part of the
-process address space.
-.El
-.Sh SEE ALSO
-.Xr bind 2 ,
-.Xr getpeername 2 ,
-.Xr socket 2
-.Sh HISTORY
-The
-.Fn getsockname
-system call appeared in
-.Bx 4.2 .
-.Sh BUGS
-Names bound to sockets in the UNIX domain are inaccessible;
-.Fn getsockname
-returns a zero length name.
diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2
deleted file mode 100644
index 3f49c3186209..000000000000
--- a/lib/libc/sys/getsockopt.2
+++ /dev/null
@@ -1,624 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95
-.\"
-.Dd February 8, 2021
-.Dt GETSOCKOPT 2
-.Os
-.Sh NAME
-.Nm getsockopt ,
-.Nm setsockopt
-.Nd get and set options on sockets
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.Ft int
-.Fn getsockopt "int s" "int level" "int optname" "void * restrict optval" "socklen_t * restrict optlen"
-.Ft int
-.Fn setsockopt "int s" "int level" "int optname" "const void *optval" "socklen_t optlen"
-.Sh DESCRIPTION
-The
-.Fn getsockopt
-and
-.Fn setsockopt
-system calls
-manipulate the
-.Em options
-associated with a socket.
-Options may exist at multiple
-protocol levels; they are always present at the uppermost
-.Dq socket
-level.
-.Pp
-When manipulating socket options the level at which the
-option resides and the name of the option must be specified.
-To manipulate options at the socket level,
-.Fa level
-is specified as
-.Dv SOL_SOCKET .
-To manipulate options at any
-other level the protocol number of the appropriate protocol
-controlling the option is supplied.
-For example,
-to indicate that an option is to be interpreted by the
-.Tn TCP
-protocol,
-.Fa level
-should be set to the protocol number of
-.Tn TCP ;
-see
-.Xr getprotoent 3 .
-.Pp
-The
-.Fa optval
-and
-.Fa optlen
-arguments
-are used to access option values for
-.Fn setsockopt .
-For
-.Fn getsockopt
-they identify a buffer in which the value for the
-requested option(s) are to be returned.
-For
-.Fn getsockopt ,
-.Fa optlen
-is a value-result argument, initially containing the
-size of the buffer pointed to by
-.Fa optval ,
-and modified on return to indicate the actual size of
-the value returned.
-If no option value is
-to be supplied or returned,
-.Fa optval
-may be NULL.
-.Pp
-The
-.Fa optname
-argument
-and any specified options are passed uninterpreted to the appropriate
-protocol module for interpretation.
-The include file
-.In sys/socket.h
-contains definitions for
-socket level options, described below.
-Options at other protocol levels vary in format and
-name; consult the appropriate entries in
-section
-4 of the manual.
-.Pp
-Most socket-level options utilize an
-.Vt int
-argument for
-.Fa optval .
-For
-.Fn setsockopt ,
-the argument should be non-zero to enable a boolean option,
-or zero if the option is to be disabled.
-.Dv SO_LINGER
-uses a
-.Vt "struct linger"
-argument, defined in
-.In sys/socket.h ,
-which specifies the desired state of the option and the
-linger interval (see below).
-.Dv SO_SNDTIMEO
-and
-.Dv SO_RCVTIMEO
-use a
-.Vt "struct timeval"
-argument, defined in
-.In sys/time.h .
-.Pp
-The following options are recognized at the socket level.
-For protocol-specific options, see protocol manual pages,
-e.g.
-.Xr ip 4
-or
-.Xr tcp 4 .
-Except as noted, each may be examined with
-.Fn getsockopt
-and set with
-.Fn setsockopt .
-.Bl -column SO_ACCEPTFILTER -offset indent
-.It Dv SO_DEBUG Ta "enables recording of debugging information"
-.It Dv SO_REUSEADDR Ta "enables local address reuse"
-.It Dv SO_REUSEPORT Ta "enables duplicate address and port bindings"
-.It Dv SO_REUSEPORT_LB Ta "enables duplicate address and port bindings with load balancing"
-.It Dv SO_KEEPALIVE Ta "enables keep connections alive"
-.It Dv SO_DONTROUTE Ta "enables routing bypass for outgoing messages"
-.It Dv SO_LINGER Ta "linger on close if data present"
-.It Dv SO_BROADCAST Ta "enables permission to transmit broadcast messages"
-.It Dv SO_OOBINLINE Ta "enables reception of out-of-band data in band"
-.It Dv SO_SNDBUF Ta "set buffer size for output"
-.It Dv SO_RCVBUF Ta "set buffer size for input"
-.It Dv SO_SNDLOWAT Ta "set minimum count for output"
-.It Dv SO_RCVLOWAT Ta "set minimum count for input"
-.It Dv SO_SNDTIMEO Ta "set timeout value for output"
-.It Dv SO_RCVTIMEO Ta "set timeout value for input"
-.It Dv SO_ACCEPTFILTER Ta "set accept filter on listening socket"
-.It Dv SO_NOSIGPIPE Ta
-controls generation of
-.Dv SIGPIPE
-for the socket
-.It Dv SO_TIMESTAMP Ta "enables reception of a timestamp with datagrams"
-.It Dv SO_BINTIME Ta "enables reception of a timestamp with datagrams"
-.It Dv SO_ACCEPTCONN Ta "get listening status of the socket (get only)"
-.It Dv SO_DOMAIN Ta "get the domain of the socket (get only)"
-.It Dv SO_TYPE Ta "get the type of the socket (get only)"
-.It Dv SO_PROTOCOL Ta "get the protocol number for the socket (get only)"
-.It Dv SO_PROTOTYPE Ta "SunOS alias for the Linux SO_PROTOCOL (get only)"
-.It Dv SO_ERROR Ta "get and clear error on the socket (get only)"
-.It Dv SO_RERROR Ta "enables receive error reporting"
-.It Dv SO_SETFIB Ta "set the associated FIB (routing table) for the socket (set only)"
-.El
-.Pp
-The following options are recognized in
-.Fx :
-.Bl -column SO_LISTENINCQLEN -offset indent
-.It Dv SO_LABEL Ta "get MAC label of the socket (get only)"
-.It Dv SO_PEERLABEL Ta "get socket's peer's MAC label (get only)"
-.It Dv SO_LISTENQLIMIT Ta "get backlog limit of the socket (get only)"
-.It Dv SO_LISTENQLEN Ta "get complete queue length of the socket (get only)"
-.It Dv SO_LISTENINCQLEN Ta "get incomplete queue length of the socket (get only)"
-.It Dv SO_USER_COOKIE Ta "set the 'so_user_cookie' value for the socket (uint32_t, set only)"
-.It Dv SO_TS_CLOCK Ta "set specific format of timestamp returned by SO_TIMESTAMP"
-.It Dv SO_MAX_PACING_RATE Ta "set the maximum transmit rate in bytes per second for the socket"
-.It Dv SO_NO_OFFLOAD Ta "disables protocol offloads"
-.It Dv SO_NO_DDP Ta "disables direct data placement offload"
-.El
-.Pp
-.Dv SO_DEBUG
-enables debugging in the underlying protocol modules.
-.Pp
-.Dv SO_REUSEADDR
-indicates that the rules used in validating addresses supplied
-in a
-.Xr bind 2
-system call should allow reuse of local addresses.
-.Pp
-.Dv SO_REUSEPORT
-allows completely duplicate bindings by multiple processes
-if they all set
-.Dv SO_REUSEPORT
-before binding the port.
-This option permits multiple instances of a program to each
-receive UDP/IP multicast or broadcast datagrams destined for the bound port.
-.Pp
-.Dv SO_REUSEPORT_LB
-allows completely duplicate bindings by multiple sockets
-if they all set
-.Dv SO_REUSEPORT_LB
-before binding the port.
-Incoming TCP and UDP connections are distributed among the participating
-listening sockets based on a hash function of local port number, and foreign IP
-address and port number.
-A maximum of 256 sockets can be bound to the same load-balancing group.
-.Pp
-.Dv SO_KEEPALIVE
-enables the
-periodic transmission of messages on a connected socket.
-Should the
-connected party fail to respond to these messages, the connection is
-considered broken and processes using the socket are notified via a
-.Dv SIGPIPE
-signal when attempting to send data.
-.Pp
-.Dv SO_DONTROUTE
-indicates that outgoing messages should
-bypass the standard routing facilities.
-Instead, messages are directed
-to the appropriate network interface according to the network portion
-of the destination address.
-.Pp
-.Dv SO_LINGER
-controls the action taken when unsent messages
-are queued on socket and a
-.Xr close 2
-is performed.
-If the socket promises reliable delivery of data and
-.Dv SO_LINGER
-is set,
-the system will block the process on the
-.Xr close 2
-attempt until it is able to transmit the data or until it decides it
-is unable to deliver the information (a timeout period, termed the
-linger interval, is specified in seconds in the
-.Fn setsockopt
-system call when
-.Dv SO_LINGER
-is requested).
-If
-.Dv SO_LINGER
-is disabled and a
-.Xr close 2
-is issued, the system will process the close in a manner that allows
-the process to continue as quickly as possible.
-.Pp
-The option
-.Dv SO_BROADCAST
-requests permission to send broadcast datagrams
-on the socket.
-Broadcast was a privileged operation in earlier versions of the system.
-.Pp
-With protocols that support out-of-band data, the
-.Dv SO_OOBINLINE
-option
-requests that out-of-band data be placed in the normal data input queue
-as received; it will then be accessible with
-.Xr recv 2
-or
-.Xr read 2
-calls without the
-.Dv MSG_OOB
-flag.
-Some protocols always behave as if this option is set.
-.Pp
-.Dv SO_SNDBUF
-and
-.Dv SO_RCVBUF
-are options to adjust the normal
-buffer sizes allocated for output and input buffers, respectively.
-The buffer size may be increased for high-volume connections,
-or may be decreased to limit the possible backlog of incoming data.
-The system places an absolute maximum on these values, which is accessible
-through the
-.Xr sysctl 3
-MIB variable
-.Dq Li kern.ipc.maxsockbuf .
-.Pp
-.Dv SO_SNDLOWAT
-is an option to set the minimum count for output operations.
-Most output operations process all of the data supplied
-by the call, delivering data to the protocol for transmission
-and blocking as necessary for flow control.
-Nonblocking output operations will process as much data as permitted
-subject to flow control without blocking, but will process no data
-if flow control does not allow the smaller of the low water mark value
-or the entire request to be processed.
-A
-.Xr select 2
-operation testing the ability to write to a socket will return true
-only if the low water mark amount could be processed.
-The default value for
-.Dv SO_SNDLOWAT
-is set to a convenient size for network efficiency, often 1024.
-.Pp
-.Dv SO_RCVLOWAT
-is an option to set the minimum count for input operations.
-In general, receive calls will block until any (non-zero) amount of data
-is received, then return with the smaller of the amount available or the amount
-requested.
-The default value for
-.Dv SO_RCVLOWAT
-is 1.
-If
-.Dv SO_RCVLOWAT
-is set to a larger value, blocking receive calls normally
-wait until they have received the smaller of the low water mark value
-or the requested amount.
-Receive calls may still return less than the low water mark if an error
-occurs, a signal is caught, or the type of data next in the receive queue
-is different from that which was returned.
-.Pp
-.Dv SO_SNDTIMEO
-is an option to set a timeout value for output operations.
-It accepts a
-.Vt "struct timeval"
-argument with the number of seconds and microseconds
-used to limit waits for output operations to complete.
-If a send operation has blocked for this much time,
-it returns with a partial count
-or with the error
-.Er EWOULDBLOCK
-if no data were sent.
-In the current implementation, this timer is restarted each time additional
-data are delivered to the protocol,
-implying that the limit applies to output portions ranging in size
-from the low water mark to the high water mark for output.
-.Pp
-.Dv SO_RCVTIMEO
-is an option to set a timeout value for input operations.
-It accepts a
-.Vt "struct timeval"
-argument with the number of seconds and microseconds
-used to limit waits for input operations to complete.
-In the current implementation, this timer is restarted each time additional
-data are received by the protocol,
-and thus the limit is in effect an inactivity timer.
-If a receive operation has been blocked for this much time without
-receiving additional data, it returns with a short count
-or with the error
-.Er EWOULDBLOCK
-if no data were received.
-.Pp
-.Dv SO_SETFIB
-can be used to over-ride the default FIB (routing table) for the given socket.
-The value must be from 0 to one less than the number returned from
-the sysctl
-.Em net.fibs .
-.Pp
-.Dv SO_USER_COOKIE
-can be used to set the uint32_t so_user_cookie field in the socket.
-The value is an uint32_t, and can be used in the kernel code that
-manipulates traffic related to the socket.
-The default value for the field is 0.
-As an example, the value can be used as the skipto target or
-pipe number in
-.Nm ipfw/dummynet .
-.Pp
-.Dv SO_ACCEPTFILTER
-places an
-.Xr accept_filter 9
-on the socket,
-which will filter incoming connections
-on a listening stream socket before being presented for
-.Xr accept 2 .
-Once more,
-.Xr listen 2
-must be called on the socket before
-trying to install the filter on it,
-or else the
-.Fn setsockopt
-system call will fail.
-.Bd -literal
-struct accept_filter_arg {
- char af_name[16];
- char af_arg[256-16];
-};
-.Ed
-.Pp
-The
-.Fa optval
-argument
-should point to a
-.Fa struct accept_filter_arg
-that will select and configure the
-.Xr accept_filter 9 .
-The
-.Fa af_name
-argument
-should be filled with the name of the accept filter
-that the application wishes to place on the listening socket.
-The optional argument
-.Fa af_arg
-can be passed to the accept
-filter specified by
-.Fa af_name
-to provide additional configuration options at attach time.
-Passing in an
-.Fa optval
-of NULL will remove the filter.
-.Pp
-The
-.Dv SO_NOSIGPIPE
-option controls generation of the
-.Dv SIGPIPE
-signal normally sent
-when writing to a connected socket where the other end has been
-closed returns with the error
-.Er EPIPE .
-.Pp
-If the
-.Dv SO_TIMESTAMP
-or
-.Dv SO_BINTIME
-option is enabled on a
-.Dv SOCK_DGRAM
-socket, the
-.Xr recvmsg 2
-call may return a timestamp corresponding to when the datagram was received.
-However, it may not, for example due to a resource shortage.
-The
-.Va msg_control
-field in the
-.Vt msghdr
-structure points to a buffer that contains a
-.Vt cmsghdr
-structure followed by a
-.Vt "struct timeval"
-for
-.Dv SO_TIMESTAMP
-and
-.Vt "struct bintime"
-for
-.Dv SO_BINTIME .
-The
-.Vt cmsghdr
-fields have the following values for TIMESTAMP by default:
-.Bd -literal
- cmsg_len = CMSG_LEN(sizeof(struct timeval));
- cmsg_level = SOL_SOCKET;
- cmsg_type = SCM_TIMESTAMP;
-.Ed
-.Pp
-and for
-.Dv SO_BINTIME :
-.Bd -literal
- cmsg_len = CMSG_LEN(sizeof(struct bintime));
- cmsg_level = SOL_SOCKET;
- cmsg_type = SCM_BINTIME;
-.Ed
-.Pp
-Additional timestamp types are available by following
-.Dv SO_TIMESTAMP
-with
-.Dv SO_TS_CLOCK ,
-which requests a specific timestamp format to be returned instead of
-.Dv SCM_TIMESTAMP when
-.Dv SO_TIMESTAMP is enabled.
-These
-.Dv SO_TS_CLOCK
-values are recognized in
-.Fx :
-.Bl -column SO_TS_CLOCK -offset indent
-.It Dv SO_TS_REALTIME_MICRO Ta "realtime (SCM_TIMESTAMP, struct timeval), default"
-.It Dv SO_TS_BINTIME Ta "realtime (SCM_BINTIME, struct bintime)"
-.It Dv SO_TS_REALTIME Ta "realtime (SCM_REALTIME, struct timespec)"
-.It Dv SO_TS_MONOTONIC Ta "monotonic time (SCM_MONOTONIC, struct timespec)"
-.El
-.Pp
-.Dv SO_ACCEPTCONN ,
-.Dv SO_TYPE ,
-.Dv SO_PROTOCOL
-(and its alias
-.Dv SO_PROTOTYPE )
-and
-.Dv SO_ERROR
-are options used only with
-.Fn getsockopt .
-.Dv SO_ACCEPTCONN
-returns whether the socket is currently accepting connections,
-that is, whether or not the
-.Xr listen 2
-system call was invoked on the socket.
-.Dv SO_TYPE
-returns the type of the socket, such as
-.Dv SOCK_STREAM ;
-it is useful for servers that inherit sockets on startup.
-.Dv SO_PROTOCOL
-returns the protocol number for the socket, for
-.Dv AF_INET
-and
-.Dv AF_INET6
-address families.
-.Dv SO_ERROR
-returns any pending error on the socket and clears
-the error status.
-It may be used to check for asynchronous errors on connected
-datagram sockets or for other asynchronous errors.
-.Dv SO_RERROR
-indicates that receive buffer overflows should be handled as errors.
-Historically receive buffer overflows have been ignored and programs
-could not tell if they missed messages or messages had been truncated
-because of overflows.
-Since programs historically do not expect to get receive overflow errors,
-this behavior is not the default.
-.Pp
-.Dv SO_LABEL
-returns the MAC label of the socket.
-.Dv SO_PEERLABEL
-returns the MAC label of the socket's peer.
-Note that your kernel must be compiled with MAC support.
-See
-.Xr mac 3
-for more information.
-.Pp
-.Dv SO_LISTENQLIMIT
-returns the maximal number of queued connections, as set by
-.Xr listen 2 .
-.Dv SO_LISTENQLEN
-returns the number of unaccepted complete connections.
-.Dv SO_LISTENINCQLEN
-returns the number of unaccepted incomplete connections.
-.Pp
-.Dv SO_MAX_PACING_RATE
-instruct the socket and underlying network adapter layers to limit the
-transfer rate to the given unsigned 32-bit value in bytes per second.
-.Pp
-.Dv SO_NO_OFFLOAD
-disables support for protocol offloads.
-At present, this prevents TCP sockets from using TCP offload engines.
-.Dv SO_NO_DDP
-disables support for a specific TCP offload known as direct data
-placement (DDP).
-DDP is an offload supported by Chelsio network adapters that permits
-reassembled TCP data streams to be received via zero-copy in
-user-supplied buffers using
-.Xr aio_read 2 .
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn getsockopt
-and
-.Fn setsockopt
-system calls succeed unless:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The argument
-.Fa s
-is not a valid descriptor.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is a file, not a socket.
-.It Bq Er ENOPROTOOPT
-The option is unknown at the level indicated.
-.It Bq Er EFAULT
-The address pointed to by
-.Fa optval
-is not in a valid part of the process address space.
-For
-.Fn getsockopt ,
-this error may also be returned if
-.Fa optlen
-is not in a valid part of the process address space.
-.It Bq Er EINVAL
-Installing an
-.Xr accept_filter 9
-on a non-listening socket was attempted.
-.It Bq Er ENOMEM
-A memory allocation failed that was required to service the request.
-.El
-.Pp
-The
-.Fn setsockopt
-system call may also return the following error:
-.Bl -tag -width Er
-.It Bq Er ENOBUFS
-Insufficient resources were available in the system
-to perform the operation.
-.El
-.Sh SEE ALSO
-.Xr ioctl 2 ,
-.Xr listen 2 ,
-.Xr recvmsg 2 ,
-.Xr socket 2 ,
-.Xr getprotoent 3 ,
-.Xr mac 3 ,
-.Xr sysctl 3 ,
-.Xr ip 4 ,
-.Xr ip6 4 ,
-.Xr sctp 4 ,
-.Xr tcp 4 ,
-.Xr protocols 5 ,
-.Xr sysctl 8 ,
-.Xr accept_filter 9 ,
-.Xr bintime 9
-.Sh HISTORY
-The
-.Fn getsockopt
-and
-.Fn setsockopt
-system calls appeared in
-.Bx 4.2 .
-.Sh BUGS
-Several of the socket options should be handled at lower levels of the system.
diff --git a/lib/libc/sys/gettimeofday.2 b/lib/libc/sys/gettimeofday.2
deleted file mode 100644
index a27aecba3fc7..000000000000
--- a/lib/libc/sys/gettimeofday.2
+++ /dev/null
@@ -1,130 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)gettimeofday.2 8.2 (Berkeley) 5/26/95
-.\"
-.Dd May 13, 2021
-.Dt GETTIMEOFDAY 2
-.Os
-.Sh NAME
-.Nm gettimeofday ,
-.Nm settimeofday
-.Nd get/set date and time
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/time.h
-.Ft int
-.Fn gettimeofday "struct timeval *tp" "struct timezone *tzp"
-.Ft int
-.Fn settimeofday "const struct timeval *tp" "const struct timezone *tzp"
-.Sh DESCRIPTION
-The system's notion of the current Greenwich time and the current time
-zone is obtained with the
-.Fn gettimeofday
-system call, and set with the
-.Fn settimeofday
-system call.
-The time is expressed in seconds and microseconds
-since midnight (0 hour), January 1, 1970.
-The resolution of the system
-clock is hardware dependent, and the time may be updated continuously or
-in
-.Dq ticks .
-If
-.Fa tp
-or
-.Fa tzp
-is NULL, the associated time
-information will not be returned or set.
-.Pp
-The structures pointed to by
-.Fa tp
-and
-.Fa tzp
-are defined in
-.In sys/time.h
-as:
-.Bd -literal
-struct timeval {
- time_t tv_sec; /* seconds */
- suseconds_t tv_usec; /* and microseconds */
-};
-
-struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
-};
-.Ed
-.Pp
-The
-.Vt timezone
-structure indicates the local time zone
-(measured in minutes of time westward from Greenwich),
-and a flag that, if nonzero, indicates that
-Daylight Saving time applies locally during
-the appropriate part of the year.
-The kernel generally does not track these values and they
-are usually returned as zero.
-Use
-.Xr localtime 3
-to find the offset for the currently active timezone.
-.Pp
-Only the super-user may set the time of day or time zone.
-If the system is running at securelevel >= 2 (see
-.Xr init 8 ) ,
-the time may only be advanced or retarded by a maximum of one second.
-This limitation is imposed to prevent a malicious super-user
-from setting arbitrary time stamps on files.
-The system time can be adjusted backwards without restriction using the
-.Xr adjtime 2
-system call even when the system is secure.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The following error codes may be set in
-.Va errno :
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The supplied
-.Fa timeval
-value is invalid.
-.It Bq Er EPERM
-A user other than the super-user attempted to set the time.
-.El
-.Sh SEE ALSO
-.Xr date 1 ,
-.Xr adjtime 2 ,
-.Xr clock_gettime 2 ,
-.Xr ctime 3 ,
-.Xr timeradd 3 ,
-.Xr clocks 7
-.Sh HISTORY
-The
-.Fn gettimeofday
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/gettimeofday.c b/lib/libc/sys/gettimeofday.c
deleted file mode 100644
index 8a09098d0ef5..000000000000
--- a/lib/libc/sys/gettimeofday.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <errno.h>
-#include "libc_private.h"
-
-int __gettimeofday(struct timeval *tv, struct timezone *tz);
-
-__weak_reference(__gettimeofday, gettimeofday);
-
-int
-__gettimeofday(struct timeval *tv, struct timezone *tz)
-{
- int error;
-
- error = __vdso_gettimeofday(tv, tz);
- if (error == ENOSYS) {
- error = __sys_gettimeofday(tv, tz);
- } else if (error != 0) {
- errno = error;
- error = -1;
- }
- return (error);
-}
diff --git a/lib/libc/sys/getuid.2 b/lib/libc/sys/getuid.2
deleted file mode 100644
index 623c3d4a5c1f..000000000000
--- a/lib/libc/sys/getuid.2
+++ /dev/null
@@ -1,90 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)getuid.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 1, 2017
-.Dt GETUID 2
-.Os
-.Sh NAME
-.Nm getuid ,
-.Nm geteuid
-.Nd get user identification
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft uid_t
-.Fn getuid void
-.Ft uid_t
-.Fn geteuid void
-.Sh DESCRIPTION
-The
-.Fn getuid
-system call returns the real user ID of the calling process.
-The
-.Fn geteuid
-system call
-returns the effective user ID of the calling process.
-.Pp
-The real user ID is that of the user who has invoked the program.
-As the effective user ID
-gives the process additional permissions during
-execution of
-.Dq Em set-user-ID
-mode processes,
-.Fn getuid
-is used to determine the real-user-id of the calling process.
-.Sh ERRORS
-The
-.Fn getuid
-and
-.Fn geteuid
-system calls are always successful, and no return value is reserved to
-indicate an error.
-.Sh SEE ALSO
-.Xr getgid 2 ,
-.Xr issetugid 2 ,
-.Xr setgid 2 ,
-.Xr setreuid 2 ,
-.Xr setuid 2
-.Sh STANDARDS
-The
-.Fn geteuid
-and
-.Fn getuid
-system calls are expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn getuid
-function appeared in
-.At v1 .
-The
-.Fn geteuid
-function appeared in
-.At v4 .
diff --git a/lib/libc/sys/interposing_table.c b/lib/libc/sys/interposing_table.c
deleted file mode 100644
index d5517a83b14a..000000000000
--- a/lib/libc/sys/interposing_table.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2014 The FreeBSD Foundation.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include "libc_private.h"
-
-#define SLOT(a, b) \
- [INTERPOS_##a] = (interpos_func_t)b
-interpos_func_t __libc_interposing[INTERPOS_MAX] = {
- SLOT(accept, __sys_accept),
- SLOT(accept4, __sys_accept4),
- SLOT(aio_suspend, __sys_aio_suspend),
- SLOT(close, __sys_close),
- SLOT(connect, __sys_connect),
- SLOT(fcntl, __sys_fcntl),
- SLOT(fsync, __sys_fsync),
- SLOT(fork, __sys_fork),
- SLOT(msync, __sys_msync),
- SLOT(nanosleep, __sys_nanosleep),
- SLOT(openat, __sys_openat),
- SLOT(poll, __sys_poll),
- SLOT(pselect, __sys_pselect),
- SLOT(read, __sys_read),
- SLOT(readv, __sys_readv),
- SLOT(recvfrom, __sys_recvfrom),
- SLOT(recvmsg, __sys_recvmsg),
- SLOT(select, __sys_select),
- SLOT(sendmsg, __sys_sendmsg),
- SLOT(sendto, __sys_sendto),
- SLOT(setcontext, __sys_setcontext),
- SLOT(sigaction, __sys_sigaction),
- SLOT(sigprocmask, __sys_sigprocmask),
- SLOT(sigsuspend, __sys_sigsuspend),
- SLOT(sigwait, __libc_sigwait),
- SLOT(sigtimedwait, __sys_sigtimedwait),
- SLOT(sigwaitinfo, __sys_sigwaitinfo),
- SLOT(swapcontext, __sys_swapcontext),
- SLOT(system, __libc_system),
- SLOT(tcdrain, __libc_tcdrain),
- SLOT(wait4, __sys_wait4),
- SLOT(write, __sys_write),
- SLOT(writev, __sys_writev),
- SLOT(_pthread_mutex_init_calloc_cb, _pthread_mutex_init_calloc_cb_stub),
- SLOT(spinlock, __libc_spinlock_stub),
- SLOT(spinunlock, __libc_spinunlock_stub),
- SLOT(kevent, __sys_kevent),
- SLOT(wait6, __sys_wait6),
- SLOT(ppoll, __sys_ppoll),
- SLOT(map_stacks_exec, __libc_map_stacks_exec),
- SLOT(fdatasync, __sys_fdatasync),
- SLOT(clock_nanosleep, __sys_clock_nanosleep),
- SLOT(distribute_static_tls, __libc_distribute_static_tls),
- SLOT(pdfork, __sys_pdfork),
-};
-#undef SLOT
-
-interpos_func_t *
-__libc_interposing_slot(int interposno)
-{
-
- return (&__libc_interposing[interposno]);
-}
diff --git a/lib/libc/sys/intro.2 b/lib/libc/sys/intro.2
deleted file mode 100644
index 1b84b219fe0e..000000000000
--- a/lib/libc/sys/intro.2
+++ /dev/null
@@ -1,767 +0,0 @@
-.\" Copyright (c) 1980, 1983, 1986, 1991, 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.
-.\"
-.\" @(#)intro.2 8.5 (Berkeley) 2/27/95
-.\"
-.Dd September 8, 2016
-.Dt INTRO 2
-.Os
-.Sh NAME
-.Nm intro
-.Nd introduction to system calls and error numbers
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In errno.h
-.Sh DESCRIPTION
-This section provides an overview of the system calls,
-their error returns, and other common definitions and concepts.
-.\".Pp
-.\".Sy System call restart
-.\".Pp
-.\"(more later...)
-.Sh RETURN VALUES
-Nearly all of the system calls provide an error number referenced via
-the external identifier errno.
-This identifier is defined in
-.In sys/errno.h
-as
-.Pp
-.Dl extern int * __error();
-.Dl #define errno (* __error())
-.Pp
-The
-.Va __error()
-function returns a pointer to a field in the thread specific structure for
-threads other than the initial thread.
-For the initial thread and
-non-threaded processes,
-.Va __error()
-returns a pointer to a global
-.Va errno
-variable that is compatible with the previous definition.
-.Pp
-When a system call detects an error,
-it returns an integer value
-indicating failure (usually -1)
-and sets the variable
-.Va errno
-accordingly.
-(This allows interpretation of the failure on receiving
-a -1 and to take action accordingly.)
-Successful calls never set
-.Va errno ;
-once set, it remains until another error occurs.
-It should only be examined after an error.
-Note that a number of system calls overload the meanings of these
-error numbers, and that the meanings must be interpreted according
-to the type and circumstances of the call.
-.Pp
-The following is a complete list of the errors and their
-names as given in
-.In sys/errno.h .
-.Bl -hang -width Ds
-.It Er 0 Em "Undefined error: 0" .
-Not used.
-.It Er 1 EPERM Em "Operation not permitted" .
-An attempt was made to perform an operation limited to processes
-with appropriate privileges or to the owner of a file or other
-resources.
-.It Er 2 ENOENT Em "No such file or directory" .
-A component of a specified pathname did not exist, or the
-pathname was an empty string.
-.It Er 3 ESRCH Em "No such process" .
-No process could be found corresponding to that specified by the given
-process ID.
-.It Er 4 EINTR Em "Interrupted system call" .
-An asynchronous signal (such as
-.Dv SIGINT
-or
-.Dv SIGQUIT )
-was caught by the process during the execution of an interruptible
-function.
-If the signal handler performs a normal return, the
-interrupted system call will seem to have returned the error condition.
-.It Er 5 EIO Em "Input/output error" .
-Some physical input or output error occurred.
-This error will not be reported until a subsequent operation on the same file
-descriptor and may be lost (over written) by any subsequent errors.
-.It Er 6 ENXIO Em "Device not configured" .
-Input or output on a special file referred to a device that did not
-exist, or
-made a request beyond the limits of the device.
-This error may also occur when, for example,
-a tape drive is not online or no disk pack is
-loaded on a drive.
-.It Er 7 E2BIG Em "Argument list too long" .
-The number of bytes used for the argument and environment
-list of the new process exceeded the current limit
-.Dv ( NCARGS
-in
-.In sys/param.h ) .
-.It Er 8 ENOEXEC Em "Exec format error" .
-A request was made to execute a file
-that, although it has the appropriate permissions,
-was not in the format required for an
-executable file.
-.It Er 9 EBADF Em "Bad file descriptor" .
-A file descriptor argument was out of range, referred to no open file,
-or a read (write) request was made to a file that was only open for
-writing (reading).
-.It Er 10 ECHILD Em "\&No child processes" .
-A
-.Xr wait 2
-or
-.Xr waitpid 2
-function was executed by a process that had no existing or unwaited-for
-child processes.
-.It Er 11 EDEADLK Em "Resource deadlock avoided" .
-An attempt was made to lock a system resource that
-would have resulted in a deadlock situation.
-.It Er 12 ENOMEM Em "Cannot allocate memory" .
-The new process image required more memory than was allowed by the hardware
-or by system-imposed memory management constraints.
-A lack of swap space is normally temporary; however,
-a lack of core is not.
-Soft limits may be increased to their corresponding hard limits.
-.It Er 13 EACCES Em "Permission denied" .
-An attempt was made to access a file in a way forbidden
-by its file access permissions.
-.It Er 14 EFAULT Em "Bad address" .
-The system detected an invalid address in attempting to
-use an argument of a call.
-.It Er 15 ENOTBLK Em "Block device required" .
-A block device operation was attempted on a non-block device or file.
-.It Er 16 EBUSY Em "Device busy" .
-An attempt to use a system resource which was in use at the time
-in a manner which would have conflicted with the request.
-.It Er 17 EEXIST Em "File exists" .
-An existing file was mentioned in an inappropriate context,
-for instance, as the new link name in a
-.Xr link 2
-system call.
-.It Er 18 EXDEV Em "Cross-device link" .
-A hard link to a file on another file system
-was attempted.
-.It Er 19 ENODEV Em "Operation not supported by device" .
-An attempt was made to apply an inappropriate
-function to a device,
-for example,
-trying to read a write-only device such as a printer.
-.It Er 20 ENOTDIR Em "Not a directory" .
-A component of the specified pathname existed, but it was
-not a directory, when a directory was expected.
-.It Er 21 EISDIR Em "Is a directory" .
-An attempt was made to open a directory with write mode specified.
-.It Er 22 EINVAL Em "Invalid argument" .
-Some invalid argument was supplied.
-(For example,
-specifying an undefined signal to a
-.Xr signal 3
-function
-or a
-.Xr kill 2
-system call).
-.It Er 23 ENFILE Em "Too many open files in system" .
-Maximum number of open files allowable on the system
-has been reached and requests for an open cannot be satisfied
-until at least one has been closed.
-.It Er 24 EMFILE Em "Too many open files" .
-Maximum number of file descriptors allowable in the process
-has been reached and requests for an open cannot be satisfied
-until at least one has been closed.
-The
-.Xr getdtablesize 2
-system call will obtain the current limit.
-.It Er 25 ENOTTY Em "Inappropriate ioctl for device" .
-A control function (see
-.Xr ioctl 2 )
-was attempted for a file or
-special device for which the operation was inappropriate.
-.It Er 26 ETXTBSY Em "Text file busy" .
-The new process was a pure procedure (shared text) file
-which was open for writing by another process, or
-while the pure procedure file was being executed an
-.Xr open 2
-call requested write access.
-.It Er 27 EFBIG Em "File too large" .
-The size of a file exceeded the maximum.
-.It Er 28 ENOSPC Em "No space left on device" .
-A
-.Xr write 2
-to an ordinary file, the creation of a
-directory or symbolic link, or the creation of a directory
-entry failed because no more disk blocks were available
-on the file system, or the allocation of an inode for a newly
-created file failed because no more inodes were available
-on the file system.
-.It Er 29 ESPIPE Em "Illegal seek" .
-An
-.Xr lseek 2
-system call was issued on a socket, pipe or
-.Tn FIFO .
-.It Er 30 EROFS Em "Read-only file system" .
-An attempt was made to modify a file or directory
-on a file system that was read-only at the time.
-.It Er 31 EMLINK Em "Too many links" .
-Maximum allowable hard links to a single file has been exceeded (limit
-of 32767 hard links per file).
-.It Er 32 EPIPE Em "Broken pipe" .
-A write on a pipe, socket or
-.Tn FIFO
-for which there is no process
-to read the data.
-.It Er 33 EDOM Em "Numerical argument out of domain" .
-A numerical input argument was outside the defined domain of the mathematical
-function.
-.It Er 34 ERANGE Em "Result too large" .
-A numerical result of the function was too large to fit in the
-available space (perhaps exceeded precision).
-.It Er 35 EAGAIN Em "Resource temporarily unavailable" .
-This is a temporary condition and later calls to the
-same routine may complete normally.
-.It Er 36 EINPROGRESS Em "Operation now in progress" .
-An operation that takes a long time to complete (such as
-a
-.Xr connect 2 )
-was attempted on a non-blocking object (see
-.Xr fcntl 2 ) .
-.It Er 37 EALREADY Em "Operation already in progress" .
-An operation was attempted on a non-blocking object that already
-had an operation in progress.
-.It Er 38 ENOTSOCK Em "Socket operation on non-socket" .
-Self-explanatory.
-.It Er 39 EDESTADDRREQ Em "Destination address required" .
-A required address was omitted from an operation on a socket.
-.It Er 40 EMSGSIZE Em "Message too long" .
-A message sent on a socket was larger than the internal message buffer
-or some other network limit.
-.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" .
-A protocol was specified that does not support the semantics of the
-socket type requested.
-For example, you cannot use the
-.Tn ARPA
-Internet
-.Tn UDP
-protocol with type
-.Dv SOCK_STREAM .
-.It Er 42 ENOPROTOOPT Em "Protocol not available" .
-A bad option or level was specified in a
-.Xr getsockopt 2
-or
-.Xr setsockopt 2
-call.
-.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" .
-The protocol has not been configured into the
-system or no implementation for it exists.
-.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" .
-The support for the socket type has not been configured into the
-system or no implementation for it exists.
-.It Er 45 EOPNOTSUPP Em "Operation not supported" .
-The attempted operation is not supported for the type of object referenced.
-Usually this occurs when a file descriptor refers to a file or socket
-that cannot support this operation,
-for example, trying to
-.Em accept
-a connection on a datagram socket.
-.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" .
-The protocol family has not been configured into the
-system or no implementation for it exists.
-.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" .
-An address incompatible with the requested protocol was used.
-For example, you should not necessarily expect to be able to use
-.Tn NS
-addresses with
-.Tn ARPA
-Internet protocols.
-.It Er 48 EADDRINUSE Em "Address already in use" .
-Only one usage of each address is normally permitted.
-.It Er 49 EADDRNOTAVAIL Em "Can't assign requested address" .
-Normally results from an attempt to create a socket with an
-address not on this machine.
-.It Er 50 ENETDOWN Em "Network is down" .
-A socket operation encountered a dead network.
-.It Er 51 ENETUNREACH Em "Network is unreachable" .
-A socket operation was attempted to an unreachable network.
-.It Er 52 ENETRESET Em "Network dropped connection on reset" .
-The host you were connected to crashed and rebooted.
-.It Er 53 ECONNABORTED Em "Software caused connection abort" .
-A connection abort was caused internal to your host machine.
-.It Er 54 ECONNRESET Em "Connection reset by peer" .
-A connection was forcibly closed by a peer.
-This normally
-results from a loss of the connection on the remote socket
-due to a timeout or a reboot.
-.It Er 55 ENOBUFS Em "\&No buffer space available" .
-An operation on a socket or pipe was not performed because
-the system lacked sufficient buffer space or because a queue was full.
-.It Er 56 EISCONN Em "Socket is already connected" .
-A
-.Xr connect 2
-request was made on an already connected socket; or,
-a
-.Xr sendto 2
-or
-.Xr sendmsg 2
-request on a connected socket specified a destination
-when already connected.
-.It Er 57 ENOTCONN Em "Socket is not connected" .
-An request to send or receive data was disallowed because
-the socket was not connected and (when sending on a datagram socket)
-no address was supplied.
-.It Er 58 ESHUTDOWN Em "Can't send after socket shutdown" .
-A request to send data was disallowed because the socket
-had already been shut down with a previous
-.Xr shutdown 2
-call.
-.It Er 60 ETIMEDOUT Em "Operation timed out" .
-A
-.Xr connect 2
-or
-.Xr send 2
-request failed because the connected party did not
-properly respond after a period of time.
-(The timeout
-period is dependent on the communication protocol.)
-.It Er 61 ECONNREFUSED Em "Connection refused" .
-No connection could be made because the target machine actively
-refused it.
-This usually results from trying to connect
-to a service that is inactive on the foreign host.
-.It Er 62 ELOOP Em "Too many levels of symbolic links" .
-A path name lookup involved more than 32
-.Pq Dv MAXSYMLINKS
-symbolic links.
-.It Er 63 ENAMETOOLONG Em "File name too long" .
-A component of a path name exceeded
-.Brq Dv NAME_MAX
-characters, or an entire
-path name exceeded
-.Brq Dv PATH_MAX
-characters.
-(See also the description of
-.Dv _PC_NO_TRUNC
-in
-.Xr pathconf 2 . )
-.It Er 64 EHOSTDOWN Em "Host is down" .
-A socket operation failed because the destination host was down.
-.It Er 65 EHOSTUNREACH Em "No route to host" .
-A socket operation was attempted to an unreachable host.
-.It Er 66 ENOTEMPTY Em "Directory not empty" .
-A directory with entries other than
-.Ql .\&
-and
-.Ql ..\&
-was supplied to a remove directory or rename call.
-.It Er 67 EPROCLIM Em "Too many processes" .
-.It Er 68 EUSERS Em "Too many users" .
-The quota system ran out of table entries.
-.It Er 69 EDQUOT Em "Disc quota exceeded" .
-A
-.Xr write 2
-to an ordinary file, the creation of a
-directory or symbolic link, or the creation of a directory
-entry failed because the user's quota of disk blocks was
-exhausted, or the allocation of an inode for a newly
-created file failed because the user's quota of inodes
-was exhausted.
-.It Er 70 ESTALE Em "Stale NFS file handle" .
-An attempt was made to access an open file (on an
-.Tn NFS
-file system)
-which is now unavailable as referenced by the file descriptor.
-This may indicate the file was deleted on the
-.Tn NFS
-server or some
-other catastrophic event occurred.
-.It Er 72 EBADRPC Em "RPC struct is bad" .
-Exchange of
-.Tn RPC
-information was unsuccessful.
-.It Er 73 ERPCMISMATCH Em "RPC version wrong" .
-The version of
-.Tn RPC
-on the remote peer is not compatible with
-the local version.
-.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" .
-The requested program is not registered on the remote host.
-.It Er 75 EPROGMISMATCH Em "Program version wrong" .
-The requested version of the program is not available
-on the remote host
-.Pq Tn RPC .
-.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" .
-An
-.Tn RPC
-call was attempted for a procedure which does not exist
-in the remote program.
-.It Er 77 ENOLCK Em "No locks available" .
-A system-imposed limit on the number of simultaneous file
-locks was reached.
-.It Er 78 ENOSYS Em "Function not implemented" .
-Attempted a system call that is not available on this
-system.
-.It Er 79 EFTYPE Em "Inappropriate file type or format" .
-The file was the wrong type for the operation, or a data file had
-the wrong format.
-.It Er 80 EAUTH Em "Authentication error" .
-Attempted to use an invalid authentication ticket to mount a
-.Tn NFS
-file system.
-.It Er 81 ENEEDAUTH Em "Need authenticator" .
-An authentication ticket must be obtained before the given
-.Tn NFS
-file system may be mounted.
-.It Er 82 EIDRM Em "Identifier removed" .
-An IPC identifier was removed while the current process was waiting on it.
-.It Er 83 ENOMSG Em "No message of desired type" .
-An IPC message queue does not contain a message of the desired type, or a
-message catalog does not contain the requested message.
-.It Er 84 EOVERFLOW Em "Value too large to be stored in data type" .
-A numerical result of the function was too large to be stored in the caller
-provided space.
-.It Er 85 ECANCELED Em "Operation canceled" .
-The scheduled operation was canceled.
-.It Er 86 EILSEQ Em "Illegal byte sequence" .
-While decoding a multibyte character the function came along an
-invalid or an incomplete sequence of bytes or the given wide
-character is invalid.
-.It Er 87 ENOATTR Em "Attribute not found" .
-The specified extended attribute does not exist.
-.It Er 88 EDOOFUS Em "Programming error" .
-A function or API is being abused in a way which could only be detected
-at run-time.
-.It Er 89 EBADMSG Em "Bad message" .
-A corrupted message was detected.
-.It Er 90 EMULTIHOP Em "Multihop attempted" .
-This error code is unused, but present for compatibility with other systems.
-.It Er 91 ENOLINK Em "Link has been severed" .
-This error code is unused, but present for compatibility with other systems.
-.It Er 92 EPROTO Em "Protocol error" .
-A device or socket encountered an unrecoverable protocol error.
-.It Er 93 ENOTCAPABLE Em "Capabilities insufficient" .
-An operation on a capability file descriptor requires greater privilege than
-the capability allows.
-.It Er 94 ECAPMODE Em "Not permitted in capability mode" .
-The system call or operation is not permitted for capability mode processes.
-.It Er 95 ENOTRECOVERABLE Em "State not recoverable" .
-The state protected by a robust mutex is not recoverable.
-.It Er 96 EOWNERDEAD Em "Previous owner died" .
-The owner of a robust mutex terminated while holding the mutex lock.
-.It Er 97 EINTEGRITY Em "Integrity check failed" .
-An integrity check such as a check-hash or a cross-correlation failed.
-The integrity error falls in the kernel I/O stack between
-.Er EINVAL
-that identifies errors in parameters to a system call and
-.Er EIO
-that identifies errors with the underlying storage media.
-It is typically raised by intermediate kernel layers such as a
-filesystem or an in-kernel GEOM subsystem when they detect inconsistencies.
-Uses include allowing the
-.Xr mount 8
-command to return a different exit value to automate the running of
-.Xr fsck 8
-during a system boot.
-.El
-.Sh DEFINITIONS
-.Bl -tag -width Ds
-.It Process ID .
-Each active process in the system is uniquely identified by a non-negative
-integer called a process ID.
-The range of this ID is from 0 to 99999.
-.It Parent process ID
-A new process is created by a currently active process (see
-.Xr fork 2 ) .
-The parent process ID of a process is initially the process ID of its creator.
-If the creating process exits,
-the parent process ID of each child is set to the ID of the calling process's
-reaper (see
-.Xr procctl 2 ) ,
-normally
-.Xr init 8 .
-.It Process Group
-Each active process is a member of a process group that is identified by
-a non-negative integer called the process group ID.
-This is the process
-ID of the group leader.
-This grouping permits the signaling of related
-processes (see
-.Xr termios 4 )
-and the job control mechanisms of
-.Xr csh 1 .
-.It Session
-A session is a set of one or more process groups.
-A session is created by a successful call to
-.Xr setsid 2 ,
-which causes the caller to become the only member of the only process
-group in the new session.
-.It Session leader
-A process that has created a new session by a successful call to
-.Xr setsid 2 ,
-is known as a session leader.
-Only a session leader may acquire a terminal as its controlling terminal (see
-.Xr termios 4 ) .
-.It Controlling process
-A session leader with a controlling terminal is a controlling process.
-.It Controlling terminal
-A terminal that is associated with a session is known as the controlling
-terminal for that session and its members.
-.It "Terminal Process Group ID"
-A terminal may be acquired by a session leader as its controlling terminal.
-Once a terminal is associated with a session, any of the process groups
-within the session may be placed into the foreground by setting
-the terminal process group ID to the ID of the process group.
-This facility is used
-to arbitrate between multiple jobs contending for the same terminal;
-(see
-.Xr csh 1
-and
-.Xr tty 4 ) .
-.It "Orphaned Process Group"
-A process group is considered to be
-.Em orphaned
-if it is not under the control of a job control shell.
-More precisely, a process group is orphaned
-when none of its members has a parent process that is in the same session
-as the group,
-but is in a different process group.
-Note that when a process exits, the parent process for its children
-is normally changed to be
-.Xr init 8 ,
-which is in a separate session.
-Not all members of an orphaned process group are necessarily orphaned
-processes (those whose creating process has exited).
-The process group of a session leader is orphaned by definition.
-.It "Real User ID and Real Group ID"
-Each user on the system is identified by a positive integer
-termed the real user ID.
-.Pp
-Each user is also a member of one or more groups.
-One of these groups is distinguished from others and
-used in implementing accounting facilities.
-The positive
-integer corresponding to this distinguished group is termed
-the real group ID.
-.Pp
-All processes have a real user ID and real group ID.
-These are initialized from the equivalent attributes
-of the process that created it.
-.It "Effective User Id, Effective Group Id, and Group Access List"
-Access to system resources is governed by two values:
-the effective user ID, and the group access list.
-The first member of the group access list is also known as the
-effective group ID.
-(In POSIX.1, the group access list is known as the set of supplementary
-group IDs, and it is unspecified whether the effective group ID is
-a member of the list.)
-.Pp
-The effective user ID and effective group ID are initially the
-process's real user ID and real group ID respectively.
-Either
-may be modified through execution of a set-user-ID or set-group-ID
-file (possibly by one its ancestors) (see
-.Xr execve 2 ) .
-By convention, the effective group ID (the first member of the group access
-list) is duplicated, so that the execution of a set-group-ID program
-does not result in the loss of the original (real) group ID.
-.Pp
-The group access list is a set of group IDs
-used only in determining resource accessibility.
-Access checks
-are performed as described below in ``File Access Permissions''.
-.It "Saved Set User ID and Saved Set Group ID"
-When a process executes a new file, the effective user ID is set
-to the owner of the file if the file is set-user-ID, and the effective
-group ID (first element of the group access list) is set to the group
-of the file if the file is set-group-ID.
-The effective user ID of the process is then recorded as the saved set-user-ID,
-and the effective group ID of the process is recorded as the saved set-group-ID.
-These values may be used to regain those values as the effective user
-or group ID after reverting to the real ID (see
-.Xr setuid 2 ) .
-(In POSIX.1, the saved set-user-ID and saved set-group-ID are optional,
-and are used in setuid and setgid, but this does not work as desired
-for the super-user.)
-.It Super-user
-A process is recognized as a
-.Em super-user
-process and is granted special privileges if its effective user ID is 0.
-.It Descriptor
-An integer assigned by the system when a file is referenced
-by
-.Xr open 2
-or
-.Xr dup 2 ,
-or when a socket is created by
-.Xr pipe 2 ,
-.Xr socket 2
-or
-.Xr socketpair 2 ,
-which uniquely identifies an access path to that file or socket from
-a given process or any of its children.
-.It File Name
-Names consisting of up to
-.Brq Dv NAME_MAX
-characters may be used to name
-an ordinary file, special file, or directory.
-.Pp
-These characters may be arbitrary eight-bit values,
-excluding
-.Dv NUL
-.Tn ( ASCII
-0) and the
-.Ql \&/
-character (slash,
-.Tn ASCII
-47).
-.Pp
-Note that it is generally unwise to use
-.Ql \&* ,
-.Ql \&? ,
-.Ql \&[
-or
-.Ql \&]
-as part of
-file names because of the special meaning attached to these characters
-by the shell.
-.It Path Name
-A path name is a
-.Dv NUL Ns -terminated
-character string starting with an
-optional slash
-.Ql \&/ ,
-followed by zero or more directory names separated
-by slashes, optionally followed by a file name.
-The total length of a path name must be less than
-.Brq Dv PATH_MAX
-characters.
-(On some systems, this limit may be infinite.)
-.Pp
-If a path name begins with a slash, the path search begins at the
-.Em root
-directory.
-Otherwise, the search begins from the current working directory.
-A slash by itself names the root directory.
-An empty
-pathname refers to the current directory.
-.It Directory
-A directory is a special type of file that contains entries
-that are references to other files.
-Directory entries are called links.
-By convention, a directory
-contains at least two links,
-.Ql .\&
-and
-.Ql \&.. ,
-referred to as
-.Em dot
-and
-.Em dot-dot
-respectively.
-Dot refers to the directory itself and
-dot-dot refers to its parent directory.
-.It "Root Directory and Current Working Directory"
-Each process has associated with it a concept of a root directory
-and a current working directory for the purpose of resolving path
-name searches.
-A process's root directory need not be the root
-directory of the root file system.
-.It File Access Permissions
-Every file in the file system has a set of access permissions.
-These permissions are used in determining whether a process
-may perform a requested operation on the file (such as opening
-a file for writing).
-Access permissions are established at the
-time a file is created.
-They may be changed at some later time
-through the
-.Xr chmod 2
-call.
-.Pp
-File access is broken down according to whether a file may be: read,
-written, or executed.
-Directory files use the execute
-permission to control if the directory may be searched.
-.Pp
-File access permissions are interpreted by the system as
-they apply to three different classes of users: the owner
-of the file, those users in the file's group, anyone else.
-Every file has an independent set of access permissions for
-each of these classes.
-When an access check is made, the system
-decides if permission should be granted by checking the access
-information applicable to the caller.
-.Pp
-Read, write, and execute/search permissions on
-a file are granted to a process if:
-.Pp
-The process's effective user ID is that of the super-user.
-(Note:
-even the super-user cannot execute a non-executable file.)
-.Pp
-The process's effective user ID matches the user ID of the owner
-of the file and the owner permissions allow the access.
-.Pp
-The process's effective user ID does not match the user ID of the
-owner of the file, and either the process's effective
-group ID matches the group ID
-of the file, or the group ID of the file is in
-the process's group access list,
-and the group permissions allow the access.
-.Pp
-Neither the effective user ID nor effective group ID
-and group access list of the process
-match the corresponding user ID and group ID of the file,
-but the permissions for ``other users'' allow access.
-.Pp
-Otherwise, permission is denied.
-.It Sockets and Address Families
-A socket is an endpoint for communication between processes.
-Each socket has queues for sending and receiving data.
-.Pp
-Sockets are typed according to their communications properties.
-These properties include whether messages sent and received
-at a socket require the name of the partner, whether communication
-is reliable, the format used in naming message recipients, etc.
-.Pp
-Each instance of the system supports some
-collection of socket types; consult
-.Xr socket 2
-for more information about the types available and
-their properties.
-.Pp
-Each instance of the system supports some number of sets of
-communications protocols.
-Each protocol set supports addresses
-of a certain format.
-An Address Family is the set of addresses
-for a specific group of protocols.
-Each socket has an address
-chosen from the address family in which the socket was created.
-.El
-.Sh SEE ALSO
-.Xr intro 3 ,
-.Xr perror 3
diff --git a/lib/libc/sys/ioctl.2 b/lib/libc/sys/ioctl.2
deleted file mode 100644
index d5b09cf67eba..000000000000
--- a/lib/libc/sys/ioctl.2
+++ /dev/null
@@ -1,153 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)ioctl.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd September 11, 2013
-.Dt IOCTL 2
-.Os
-.Sh NAME
-.Nm ioctl
-.Nd control device
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/ioctl.h
-.Ft int
-.Fn ioctl "int fd" "unsigned long request" ...
-.Sh DESCRIPTION
-The
-.Fn ioctl
-system call manipulates the underlying device parameters of special files.
-In particular, many operating
-characteristics of character special files (e.g.\& terminals)
-may be controlled with
-.Fn ioctl
-requests.
-The argument
-.Fa fd
-must be an open file descriptor.
-.Pp
-The third argument to
-.Fn ioctl
-is traditionally named
-.Va "char *argp" .
-Most uses of
-.Fn ioctl ,
-however, require the third argument to be a
-.Vt caddr_t
-or an
-.Vt int .
-.Pp
-An
-.Fn ioctl
-.Fa request
-has encoded in it whether the argument is an
-.Dq in
-argument
-or
-.Dq out
-argument, and the size of the argument
-.Fa argp
-in bytes.
-Macros and defines used in specifying an ioctl
-.Fa request
-are located in the file
-.In sys/ioctl.h .
-.Sh GENERIC IOCTLS
-Some generic ioctls are not implemented for all types of file
-descriptors.
-These include:
-.Bl -tag -width "xxxxxx"
-.It Dv FIONREAD int
-Get the number of bytes that are immediately available for reading.
-.It Dv FIONWRITE int
-Get the number of bytes in the descriptor's send queue.
-These bytes are data which has been written to the descriptor but
-which are being held by the kernel for further processing.
-The nature of the required processing depends on the underlying device.
-For TCP sockets, these bytes have not yet been acknowledged by the
-other side of the connection.
-.It Dv FIONSPACE int
-Get the free space in the descriptor's send queue.
-This value is the size of the send queue minus the number of bytes
-being held in the queue.
-Note: while this value represents the number of bytes that may be
-added to the queue, other resource limitations may cause a write
-not larger than the send queue's space to be blocked.
-One such limitation would be a lack of network buffers for a write
-to a network connection.
-.El
-.Sh RETURN VALUES
-If an error has occurred, a value of -1 is returned and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn ioctl
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid descriptor.
-.It Bq Er ENOTTY
-The
-.Fa fd
-argument
-is not associated with a character
-special device.
-.It Bq Er ENOTTY
-The specified request does not apply to the kind
-of object that the descriptor
-.Fa fd
-references.
-.It Bq Er EINVAL
-The
-.Fa request
-or
-.Fa argp
-argument
-is not valid.
-.It Bq Er EFAULT
-The
-.Fa argp
-argument
-points outside the process's allocated address space.
-.El
-.Sh SEE ALSO
-.Xr execve 2 ,
-.Xr fcntl 2 ,
-.Xr intro 4 ,
-.Xr tty 4
-.Sh HISTORY
-The
-.Fn ioctl
-function appeared in
-.At v7 .
diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2
deleted file mode 100644
index 4bb4a6dde7d2..000000000000
--- a/lib/libc/sys/jail.2
+++ /dev/null
@@ -1,412 +0,0 @@
-.\" Copyright (c) 1999 Poul-Henning Kamp.
-.\" Copyright (c) 2009 James Gritton.
-.\" 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.
-.\"
-.Dd February 19, 2021
-.Dt JAIL 2
-.Os
-.Sh NAME
-.Nm jail ,
-.Nm jail_get ,
-.Nm jail_set ,
-.Nm jail_remove ,
-.Nm jail_attach
-.Nd create and manage system jails
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/jail.h
-.Ft int
-.Fn jail "struct jail *jail"
-.Ft int
-.Fn jail_attach "int jid"
-.Ft int
-.Fn jail_remove "int jid"
-.In sys/uio.h
-.Ft int
-.Fn jail_get "struct iovec *iov" "u_int niov" "int flags"
-.Ft int
-.Fn jail_set "struct iovec *iov" "u_int niov" "int flags"
-.Sh DESCRIPTION
-The
-.Fn jail
-system call sets up a jail and locks the current process in it.
-.Pp
-The argument is a pointer to a structure describing the prison:
-.Bd -literal -offset indent
-struct jail {
- uint32_t version;
- char *path;
- char *hostname;
- char *jailname;
- unsigned int ip4s;
- unsigned int ip6s;
- struct in_addr *ip4;
- struct in6_addr *ip6;
-};
-.Ed
-.Pp
-.Dq Li version
-defines the version of the API in use.
-.Dv JAIL_API_VERSION
-is defined for the current version.
-.Pp
-The
-.Dq Li path
-pointer should be set to the directory which is to be the root of the
-prison.
-.Pp
-The
-.Dq Li hostname
-pointer can be set to the hostname of the prison.
-This can be changed
-from the inside of the prison.
-.Pp
-The
-.Dq Li jailname
-pointer is an optional name that can be assigned to the jail
-for example for management purposes.
-.Pp
-The
-.Dq Li ip4s
-and
-.Dq Li ip6s
-give the numbers of IPv4 and IPv6 addresses that will be passed
-via their respective pointers.
-.Pp
-The
-.Dq Li ip4
-and
-.Dq Li ip6
-pointers can be set to an arrays of IPv4 and IPv6 addresses to be assigned to
-the prison, or NULL if none.
-IPv4 addresses must be in network byte order.
-.Pp
-This is equivalent to, and deprecated in favor of, the
-.Fn jail_set
-system call (see below), with the parameters
-.Va path ,
-.Va host.hostname ,
-.Va name ,
-.Va ip4.addr ,
-and
-.Va ip6.addr ,
-and with the
-.Dv JAIL_ATTACH
-flag.
-.Pp
-The
-.Fn jail_set
-system call creates a new jail, or modifies an existing one, and optionally
-locks the current process in it.
-Jail parameters are passed as an array of name-value pairs in the array
-.Fa iov ,
-containing
-.Fa niov
-elements.
-Parameter names are a null-terminated string, and values may be strings,
-integers, or other arbitrary data.
-Some parameters are boolean, and do not have a value (their length is zero)
-but are set by the name alone with or without a
-.Dq no
-prefix, e.g.
-.Va persist
-or
-.Va nopersist .
-Any parameters not set will be given default values, generally based on
-the current environment.
-.Pp
-Jails have a set of core parameters, and modules can add their own jail
-parameters.
-The current set of available parameters, and their formats, can be
-retrieved via the
-.Va security.jail.param
-sysctl MIB entry.
-Notable parameters include those mentioned in the
-.Fn jail
-description above, as well as
-.Va jid
-and
-.Va name ,
-which identify the jail being created or modified.
-See
-.Xr jail 8
-for more information on the core jail parameters.
-.Pp
-The
-.Fa flags
-arguments consists of one or more of the following flags:
-.Bl -tag -width indent
-.It Dv JAIL_CREATE
-Create a new jail.
-If a
-.Va jid
-or
-.Va name
-parameters exists, they must not refer to an existing jail.
-.It Dv JAIL_UPDATE
-Modify an existing jail.
-One of the
-.Va jid
-or
-.Va name
-parameters must exist, and must refer to an existing jail.
-If both
-.Dv JAIL_CREATE
-and
-.Dv JAIL_UPDATE
-are set, a jail will be created if it does not yet exist, and modified if it
-does exist.
-.It Dv JAIL_ATTACH
-In addition to creating or modifying the jail, attach the current process to
-it, as with the
-.Fn jail_attach
-system call.
-.It Dv JAIL_DYING
-Allow setting a jail that is in the process of being removed.
-.El
-.Pp
-The
-.Fn jail_get
-system call retrieves jail parameters, using the same name-value list as
-.Fn jail_set
-in the
-.Fa iov
-and
-.Fa niov
-arguments.
-The jail to read can be specified by either
-.Va jid
-or
-.Va name
-by including those parameters in the list.
-If they are included but are not intended to be the search key, they
-should be cleared (zero and the empty string respectively).
-.Pp
-The special parameter
-.Va lastjid
-can be used to retrieve a list of all jails.
-It will fetch the jail with the jid above and closest to the passed value.
-The first jail (usually but not always jid 1) can be found by passing a
-.Va lastjid
-of zero.
-.Pp
-The
-.Fa flags
-arguments consists of one or more following flags:
-.Bl -tag -width indent
-.It Dv JAIL_DYING
-Allow getting a jail that is in the process of being removed.
-.El
-.Pp
-The
-.Fn jail_attach
-system call attaches the current process to an existing jail,
-identified by
-.Fa jid .
-It changes the process's root and current directories to the jail's
-.Va path
-directory.
-.Pp
-The
-.Fn jail_remove
-system call removes the jail identified by
-.Fa jid .
-It will kill all processes belonging to the jail, and remove any children
-of that jail.
-.Sh RETURN VALUES
-If successful,
-.Fn jail ,
-.Fn jail_set ,
-and
-.Fn jail_get
-return a non-negative integer, termed the jail identifier (JID).
-They return \-1 on failure, and set
-.Va errno
-to indicate the error.
-.Pp
-.Rv -std jail_attach jail_remove
-.Sh ERRORS
-The
-.Fn jail
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-This process is not allowed to create a jail, either because it is not
-the super-user, or because it would exceed the jail's
-.Va children.max
-limit.
-.It Bq Er EFAULT
-.Fa jail
-points to an address outside the allocated address space of the process.
-.It Bq Er EINVAL
-The version number of the argument is not correct.
-.It Bq Er EAGAIN
-No free JID could be found.
-.El
-.Pp
-The
-.Fn jail_set
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-This process is not allowed to create a jail, either because it is not
-the super-user, or because it would exceed the jail's
-.Va children.max
-limit.
-.It Bq Er EPERM
-A jail parameter was set to a less restrictive value then the current
-environment.
-.It Bq Er EFAULT
-.Fa Iov ,
-or one of the addresses contained within it,
-points to an address outside the allocated address space of the process.
-.It Bq Er ENOENT
-The jail referred to by a
-.Va jid
-or
-.Va name
-parameter does not exist, and the
-.Dv JAIL_CREATE
-flag is not set.
-.It Bq Er ENOENT
-The jail referred to by a
-.Va jid
-is not accessible by the process, because the process is in a different
-jail.
-.It Bq Er EEXIST
-The jail referred to by a
-.Va jid
-or
-.Va name
-parameter exists, and the
-.Dv JAIL_UPDATE
-flag is not set.
-.It Bq Er EINVAL
-A supplied parameter is the wrong size.
-.It Bq Er EINVAL
-A supplied parameter is out of range.
-.It Bq Er EINVAL
-A supplied string parameter is not null-terminated.
-.It Bq Er EINVAL
-A supplied parameter name does not match any known parameters.
-.It Bq Er EINVAL
-One of the
-.Dv JAIL_CREATE
-or
-.Dv JAIL_UPDATE
-flags is not set.
-.It Bq Er ENAMETOOLONG
-A supplied string parameter is longer than allowed.
-.It Bq Er EAGAIN
-There are no jail IDs left.
-.El
-.Pp
-The
-.Fn jail_get
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-.Fa Iov ,
-or one of the addresses contained within it,
-points to an address outside the allocated address space of the process.
-.It Bq Er ENOENT
-The jail referred to by a
-.Va jid
-or
-.Va name
-parameter does not exist.
-.It Bq Er ENOENT
-The jail referred to by a
-.Va jid
-is not accessible by the process, because the process is in a different
-jail.
-.It Bq Er ENOENT
-The
-.Va lastjid
-parameter is greater than the highest current jail ID.
-.It Bq Er EINVAL
-A supplied parameter is the wrong size.
-.It Bq Er EINVAL
-A supplied parameter name does not match any known parameters.
-.El
-.Pp
-The
-.Fn jail_attach
-and
-.Fn jail_remove
-system calls
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-A user other than the super-user attempted to attach to or remove a jail.
-.It Bq Er EINVAL
-The jail specified by
-.Fa jid
-does not exist.
-.El
-.Pp
-Further
-.Fn jail ,
-.Fn jail_set ,
-and
-.Fn jail_attach
-call
-.Xr chroot 2
-internally, so they can fail for all the same reasons.
-Please consult the
-.Xr chroot 2
-manual page for details.
-.Sh SEE ALSO
-.Xr chdir 2 ,
-.Xr chroot 2 ,
-.Xr jail 8
-.Sh HISTORY
-The
-.Fn jail
-system call appeared in
-.Fx 4.0 .
-The
-.Fn jail_attach
-system call appeared in
-.Fx 5.1 .
-The
-.Fn jail_set ,
-.Fn jail_get ,
-and
-.Fn jail_remove
-system calls appeared in
-.Fx 8.0 .
-.Sh AUTHORS
-The jail feature was written by
-.An Poul-Henning Kamp
-for R&D Associates
-who contributed it to
-.Fx .
-.An James Gritton
-added the extensible jail parameters and hierarchical jails.
diff --git a/lib/libc/sys/kevent.c b/lib/libc/sys/kevent.c
index ef2440721bb4..f16ac89a36c6 100644
--- a/lib/libc/sys/kevent.c
+++ b/lib/libc/sys/kevent.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
@@ -42,9 +41,6 @@ int
kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents, const struct timespec *timeout)
{
-
- return (((int (*)(int, const struct kevent *, int,
- struct kevent *, int, const struct timespec *))
- __libc_interposing[INTERPOS_kevent])(kq, changelist, nchanges,
- eventlist, nevents, timeout));
+ return (INTERPOS_SYS(kevent, kq, changelist, nchanges, eventlist,
+ nevents, timeout));
}
diff --git a/lib/libc/sys/kill.2 b/lib/libc/sys/kill.2
deleted file mode 100644
index 96787c7a4339..000000000000
--- a/lib/libc/sys/kill.2
+++ /dev/null
@@ -1,158 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)kill.2 8.3 (Berkeley) 4/19/94
-.\"
-.Dd December 1, 2019
-.Dt KILL 2
-.Os
-.Sh NAME
-.Nm kill
-.Nd send signal to a process
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In signal.h
-.Ft int
-.Fn kill "pid_t pid" "int sig"
-.Sh DESCRIPTION
-The
-.Fn kill
-system call sends the signal given by
-.Fa sig
-to
-.Fa pid ,
-a
-process or a group of processes.
-The
-.Fa sig
-argument
-may be one of the signals specified in
-.Xr sigaction 2
-or it may be 0, in which case
-error checking is performed but no
-signal is actually sent.
-This can be used to check the validity of
-.Fa pid .
-.Pp
-For a process to have permission to send a signal to a process designated
-by
-.Fa pid ,
-the user must be the super-user, or
-the real or saved user ID of the receiving process must match
-the real or effective user ID of the sending process.
-A single exception is the signal SIGCONT, which may always be sent
-to any process with the same session ID as the sender.
-In addition, if the
-.Va security.bsd.conservative_signals
-.Xr sysctl 9
-is set to 1, the user is not a super-user, and
-the receiver is set-uid, then
-only job control and terminal control signals may
-be sent (in particular, only SIGKILL, SIGINT, SIGTERM, SIGALRM,
-SIGSTOP, SIGTTIN, SIGTTOU, SIGTSTP, SIGHUP, SIGUSR1, SIGUSR2).
-.Bl -tag -width Ds
-.It \&If Fa pid No \&is greater than zero :
-The
-.Fa sig
-signal
-is sent to the process whose ID is equal to
-.Fa pid .
-.It \&If Fa pid No \&is zero :
-The
-.Fa sig
-signal
-is sent to all processes whose group ID is equal
-to the process group ID of the sender, and for which the
-process has permission;
-this is a variant of
-.Xr killpg 2 .
-.It \&If Fa pid No \&is -1 :
-If the user has super-user privileges,
-the signal is sent to all processes excluding
-system processes
-(with
-.Dv P_SYSTEM
-flag set),
-process with ID 1
-(usually
-.Xr init 8 ) ,
-and the process sending the signal.
-If the user is not the super user, the signal is sent to all processes
-which the caller has permissions to, excluding the process sending the signal.
-No error is returned if any process could be signaled.
-.El
-.Pp
-If the process number is negative but not -1,
-the signal is sent to all processes whose process group ID
-is equal to the absolute value of the process number.
-This is a variant of
-.Xr killpg 2 .
-.Sh RETURN VALUES
-.Rv -std kill
-.Sh ERRORS
-The
-.Fn kill
-system call
-will fail and no signal will be sent if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa sig
-argument
-is not a valid signal number.
-.It Bq Er ESRCH
-No process or process group can be found corresponding to that specified by
-.Fa pid .
-.It Bq Er EPERM
-The sending process does not have permission to send
-.Va sig
-to any receiving process.
-.El
-.Sh SEE ALSO
-.Xr getpgrp 2 ,
-.Xr getpid 2 ,
-.Xr killpg 2 ,
-.Xr sigaction 2 ,
-.Xr sigqueue 2 ,
-.Xr raise 3 ,
-.Xr init 8
-.Sh STANDARDS
-The
-.Fn kill
-system call is expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-A version of the
-.Fn kill
-function appeared in
-.At v3 .
-The signal number was added to the
-.Fn kill
-function in
-.At v4 .
diff --git a/lib/libc/sys/kldfind.2 b/lib/libc/sys/kldfind.2
deleted file mode 100644
index a7e147af55f1..000000000000
--- a/lib/libc/sys/kldfind.2
+++ /dev/null
@@ -1,84 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Chris Costello
-.\" 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.
-.\"
-.Dd March 3, 1999
-.Dt KLDFIND 2
-.Os
-.Sh NAME
-.Nm kldfind
-.Nd returns the fileid of a kld file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldfind "const char *file"
-.Sh DESCRIPTION
-The
-.Fn kldfind
-system call
-returns the fileid of the kld file referenced by
-.Fa file .
-.Sh RETURN VALUES
-The
-.Fn kldfind
-system call
-returns the fileid of the kld file referenced by
-.Fa file .
-Upon error,
-.Fn kldfind
-returns -1 and sets
-.Va errno
-to indicate the error.
-.Sh ERRORS
-.Va errno
-is set to the following if
-.Fn kldfind
-fails:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The data required for this operation could not be read from the kernel space.
-.It Bq Er ENOENT
-The file specified is not loaded in the kernel.
-.El
-.Sh SEE ALSO
-.Xr kldfirstmod 2 ,
-.Xr kldload 2 ,
-.Xr kldnext 2 ,
-.Xr kldstat 2 ,
-.Xr kldsym 2 ,
-.Xr kldunload 2 ,
-.Xr modfind 2 ,
-.Xr modfnext 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4 ,
-.Xr kldstat 8
-.Sh HISTORY
-The
-.Nm kld
-interface first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/kldfirstmod.2 b/lib/libc/sys/kldfirstmod.2
deleted file mode 100644
index 8e69b366c8aa..000000000000
--- a/lib/libc/sys/kldfirstmod.2
+++ /dev/null
@@ -1,74 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Chris Costello
-.\" 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.
-.\"
-.Dd March 3, 1999
-.Dt KLDFIRSTMOD 2
-.Os
-.Sh NAME
-.Nm kldfirstmod
-.Nd "return first module id from the kld file specified"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldfirstmod "int fileid"
-.Sh DESCRIPTION
-The
-.Fn kldfirstmod
-system call returns the module id pertaining to the first module referenced by
-.Fa fileid .
-.Sh RETURN VALUES
-The
-.Fn kldfirstmod
-will return the id of the first module referenced by
-.Fa fileid
-or 0 if there are no references.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er ENOENT
-The kld file referenced by
-.Fa fileid
-was not found.
-.El
-.Sh SEE ALSO
-.Xr kldfind 2 ,
-.Xr kldload 2 ,
-.Xr kldnext 2 ,
-.Xr kldstat 2 ,
-.Xr kldsym 2 ,
-.Xr kldunload 2 ,
-.Xr modfind 2 ,
-.Xr modfnext 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4 ,
-.Xr kldstat 8
-.Sh HISTORY
-The
-.Nm kld
-interface first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/kldload.2 b/lib/libc/sys/kldload.2
deleted file mode 100644
index 20bf3778c1ae..000000000000
--- a/lib/libc/sys/kldload.2
+++ /dev/null
@@ -1,94 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Chris Costello
-.\" 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.
-.\"
-.Dd March 3, 1999
-.Dt KLDLOAD 2
-.Os
-.Sh NAME
-.Nm kldload
-.Nd load KLD files into the kernel
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldload "const char *file"
-.Sh DESCRIPTION
-The
-.Fn kldload
-system call
-loads a kld file into the kernel using the kernel linker.
-.Sh RETURN VALUES
-The
-.Fn kldload
-system call
-returns the fileid of the kld file which was loaded into the kernel.
-If an error occurs,
-.Fn kldload
-will return -1 and set
-.Va errno
-to indicate the error.
-.Sh ERRORS
-The named file is loaded unless:
-.Bl -tag -width Er
-.It Bq Er EPERM
-You do not have access to read the file or link it with the kernel.
-You should be the root user to be able to use the
-.Nm kld
-system calls.
-.It Bq Er EFAULT
-Bad address encountered when adding kld info into the kernel space.
-.It Bq Er ENOMEM
-There is no memory to load the file into the kernel.
-.It Bq Er ENOENT
-The file was not found.
-.It Bq Er ENOEXEC
-The file format of
-.Fa file
-was unrecognized.
-.It Bq Er EEXIST
-The supplied
-.Fa file
-has already been loaded.
-.El
-.Sh SEE ALSO
-.Xr kldfind 2 ,
-.Xr kldfirstmod 2 ,
-.Xr kldnext 2 ,
-.Xr kldstat 2 ,
-.Xr kldsym 2 ,
-.Xr kldunload 2 ,
-.Xr modfind 2 ,
-.Xr modfnext 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4 ,
-.Xr kldload 8
-.Sh HISTORY
-The
-.Nm kld
-interface first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/kldnext.2 b/lib/libc/sys/kldnext.2
deleted file mode 100644
index 8d8102711494..000000000000
--- a/lib/libc/sys/kldnext.2
+++ /dev/null
@@ -1,87 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Chris Costello
-.\" 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.
-.\"
-.Dd February 22, 2006
-.Dt KLDNEXT 2
-.Os
-.Sh NAME
-.Nm kldnext
-.Nd return the fileid of the next kld file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldnext "int fileid"
-.Sh DESCRIPTION
-The
-.Fn kldnext
-system call
-returns the fileid of the next kld file (that is, the one after
-.Fa fileid )
-or 0 if
-.Fa fileid
-is the last file loaded.
-To get the fileid of the first kld file, pass
-.Fa fileid
-of 0 to
-.Fn kldnext .
-.Sh RETURN VALUES
-The
-.Fn kldnext
-system call
-returns the fileid of the next kld file or 0 if successful.
-Otherwise
-.Fn kldnext
-returns the value \-1 and sets the global variable
-.Va errno
-to indicate the error.
-.Sh ERRORS
-The only error set by
-.Fn kldnext
-is
-.Er ENOENT ,
-which is set when
-.Fa fileid
-refers to a kld file that does not exist (is not loaded).
-.Sh SEE ALSO
-.Xr kldfind 2 ,
-.Xr kldfirstmod 2 ,
-.Xr kldload 2 ,
-.Xr kldstat 2 ,
-.Xr kldsym 2 ,
-.Xr kldunload 2 ,
-.Xr modfind 2 ,
-.Xr modfnext 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4 ,
-.Xr kldstat 8
-.Sh HISTORY
-The
-.Nm kld
-interface first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/kldstat.2 b/lib/libc/sys/kldstat.2
deleted file mode 100644
index f0ab26ac2608..000000000000
--- a/lib/libc/sys/kldstat.2
+++ /dev/null
@@ -1,131 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Chris Costello
-.\" 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.
-.\"
-.Dd March 28, 2012
-.Dt KLDSTAT 2
-.Os
-.Sh NAME
-.Nm kldstat
-.Nd get status of kld file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldstat "int fileid" "struct kld_file_stat *stat"
-.Sh DESCRIPTION
-The
-.Fn kldstat
-system call writes the info for the file referred to by
-.Fa fileid
-into
-.Fa stat .
-.Bd -literal
-struct kld_file_stat {
- int version; /* set to sizeof(struct kld_file_stat) */
- char name[MAXPATHLEN];
- int refs;
- int id;
- caddr_t address;
- size_t size;
- char pathname[MAXPATHLEN];
-};
-.Ed
-.Bl -tag -width XXXaddress
-.It version
-This field is set to the size of the structure mentioned above by the code
-calling
-.Fn kldstat ,
-and not
-.Fn kldstat
-itself.
-.It name
-The name of the file referred to by
-.Fa fileid .
-.It refs
-The number of modules referenced by
-.Fa fileid .
-.It id
-The id of the file specified in
-.Fa fileid .
-.It address
-The load address of the kld file.
-.It size
-The amount of memory in bytes allocated by the file.
-.It pathname
-The full name of the file referred to by
-.Fa fileid ,
-including the path.
-.El
-.Sh RETURN VALUES
-.Rv -std kldstat
-.Sh ERRORS
-The information for the file referred to by
-.Fa fileid
-is filled into the structure pointed to by
-.Fa stat
-unless:
-.Bl -tag -width Er
-.It Bq Er ENOENT
-The file was not found (probably not loaded).
-.It Bq Er EINVAL
-The version specified in the
-.Fa version
-field of stat is not the proper version.
-You would need to rebuild world, the
-kernel, or your application, if this error occurs, given that you did properly
-fill in the
-.Fa version
-field.
-.It Bq Er EFAULT
-There was a problem copying one, some, or all of the fields into
-.Fa stat
-in the
-.Xr copyout 9
-function.
-.El
-.Sh SEE ALSO
-.Xr kldfind 2 ,
-.Xr kldfirstmod 2 ,
-.Xr kldload 2 ,
-.Xr kldnext 2 ,
-.Xr kldsym 2 ,
-.Xr kldunload 2 ,
-.Xr modfind 2 ,
-.Xr modfnext 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4 ,
-.Xr kldstat 8
-.Sh HISTORY
-The
-.Nm kld
-interface first appeared in
-.Fx 3.0 .
-.Sh BUGS
-The pathname may not be accurate if the file system mounts have
-changed since the module was loaded, or if this function is called
-within a chrooted environment.
diff --git a/lib/libc/sys/kldsym.2 b/lib/libc/sys/kldsym.2
deleted file mode 100644
index d3025ca536f8..000000000000
--- a/lib/libc/sys/kldsym.2
+++ /dev/null
@@ -1,119 +0,0 @@
-.\" Copyright (c) 2001 Chris Costello <chris@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.
-.\"
-.Dd October 17, 2016
-.Dt KLDSYM 2
-.Os
-.Sh NAME
-.Nm kldsym
-.Nd look up address by symbol name in a KLD
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldsym "int fileid" "int cmd" "void *data"
-.Sh DESCRIPTION
-The
-.Fn kldsym
-system call returns the address of the symbol specified in
-.Fa data
-in the module specified by
-.Fa fileid .
-If
-.Fa fileid
-is 0, all loaded modules are searched.
-Currently, the only
-.Fa cmd
-implemented is
-.Dv KLDSYM_LOOKUP .
-.Pp
-The
-.Fa data
-argument is of the following structure:
-.Bd -literal -offset indent
-struct kld_sym_lookup {
- int version; /* sizeof(struct kld_sym_lookup) */
- char *symname; /* Symbol name we are looking up */
- u_long symvalue;
- size_t symsize;
-};
-.Ed
-.Pp
-The
-.Va version
-member is to be set
-by the code calling
-.Fn kldsym
-to
-.Fn sizeof "struct kld_sym_lookup" .
-The next two members,
-.Va version
-and
-.Va symname ,
-are specified by the user.
-The last two,
-.Va symvalue
-and
-.Va symsize ,
-are filled in by
-.Fn kldsym
-and contain the address associated with
-.Va symname
-and the size of the data it points to, respectively.
-.Sh RETURN VALUES
-.Rv -std kldsym
-.Sh ERRORS
-The
-.Fn kldsym
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-Invalid value in
-.Fa data->version
-or
-.Fa cmd .
-.It Bq Er ENOENT
-The
-.Fa fileid
-argument
-is invalid,
-or the specified symbol could not be found.
-.El
-.Sh SEE ALSO
-.Xr kldfind 2 ,
-.Xr kldfirstmod 2 ,
-.Xr kldload 2 ,
-.Xr kldnext 2 ,
-.Xr kldunload 2 ,
-.Xr modfind 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4
-.Sh HISTORY
-The
-.Fn kldsym
-system call first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/kldunload.2 b/lib/libc/sys/kldunload.2
deleted file mode 100644
index 2d33aabb3f33..000000000000
--- a/lib/libc/sys/kldunload.2
+++ /dev/null
@@ -1,92 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Chris Costello
-.\" 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.
-.\"
-.Dd December 25, 2008
-.Dt KLDUNLOAD 2
-.Os
-.Sh NAME
-.Nm kldunload , kldunloadf
-.Nd unload kld files
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/linker.h
-.Ft int
-.Fn kldunload "int fileid"
-.Ft int
-.Fn kldunloadf "int fileid" "int flags"
-.Sh DESCRIPTION
-The
-.Fn kldunload
-system call
-unloads a kld file from the kernel that was previously linked via
-.Xr kldload 2 .
-.Pp
-The
-.Fn kldunloadf
-system call accepts an additional flags argument, which may be one of
-.Dv LINKER_UNLOAD_NORMAL ,
-giving the same behavior as
-.Fn kldunload ,
-or
-.Dv LINKER_UNLOAD_FORCE ,
-which causes the unload to ignore a failure to quiesce the module.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The file referred to by
-.Fa fileid
-is unloaded unless:
-.Bl -tag -width Er
-.It Bq Er EPERM
-You do not have access to unlink the file from the kernel.
-.It Bq Er ENOENT
-The file was not found.
-.It Bq Er EBUSY
-You attempted to unload a file linked by the kernel.
-.It Bq Er EINVAL
-The
-.Fn kldunloadf
-system call was passed invalid flags.
-.El
-.Sh SEE ALSO
-.Xr kldfind 2 ,
-.Xr kldfirstmod 2 ,
-.Xr kldload 2 ,
-.Xr kldnext 2 ,
-.Xr kldstat 2 ,
-.Xr kldsym 2 ,
-.Xr modfind 2 ,
-.Xr modfnext 2 ,
-.Xr modnext 2 ,
-.Xr modstat 2 ,
-.Xr kld 4 ,
-.Xr kldunload 8
-.Sh HISTORY
-The
-.Nm kld
-interface first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
deleted file mode 100644
index 066ad717111a..000000000000
--- a/lib/libc/sys/kqueue.2
+++ /dev/null
@@ -1,887 +0,0 @@
-.\" Copyright (c) 2000 Jonathan Lemon
-.\" 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 ``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.
-.\"
-.Dd March 26, 2023
-.Dt KQUEUE 2
-.Os
-.Sh NAME
-.Nm kqueue ,
-.Nm kevent
-.Nd kernel event notification mechanism
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/event.h
-.Ft int
-.Fn kqueue "void"
-.Ft int
-.Fn kqueuex "u_int flags"
-.Ft int
-.Fo kevent
-.Fa "int kq"
-.Fa "const struct kevent *changelist"
-.Fa "int nchanges"
-.Fa "struct kevent *eventlist"
-.Fa "int nevents"
-.Fa "const struct timespec *timeout"
-.Fc
-.Fn EV_SET "kev" ident filter flags fflags data udata
-.Sh DESCRIPTION
-The
-.Fn kqueue
-system call
-provides a generic method of notifying the user when an event
-happens or a condition holds, based on the results of small
-pieces of kernel code termed filters.
-A kevent is identified by the (ident, filter) pair; there may only
-be one unique kevent per kqueue.
-.Pp
-The filter is executed upon the initial registration of a kevent
-in order to detect whether a preexisting condition is present, and is also
-executed whenever an event is passed to the filter for evaluation.
-If the filter determines that the condition should be reported,
-then the kevent is placed on the kqueue for the user to retrieve.
-.Pp
-The filter is also run when the user attempts to retrieve the kevent
-from the kqueue.
-If the filter indicates that the condition that triggered
-the event no longer holds, the kevent is removed from the kqueue and
-is not returned.
-.Pp
-Multiple events which trigger the filter do not result in multiple
-kevents being placed on the kqueue; instead, the filter will aggregate
-the events into a single struct kevent.
-Calling
-.Fn close
-on a file descriptor will remove any kevents that reference the descriptor.
-.Pp
-The
-.Fn kqueue
-system call
-creates a new kernel event queue and returns a descriptor.
-The queue is not inherited by a child created with
-.Xr fork 2 .
-However, if
-.Xr rfork 2
-is called without the
-.Dv RFFDG
-flag, then the descriptor table is shared,
-which will allow sharing of the kqueue between two processes.
-.Pp
-The
-.Fn kqueuex
-system call also creates a new kernel event queue, and additionally takes
-the
-.Fa flags
-argument, which is a bitwise-inclusive OR of the following flags:
-.Bl -tag -width "KQUEUE_CLOEXEC"
-.It Fa KQUEUE_CLOEXEC
-The returned file descriptor is automatically closed on
-.Xr execve 2
-.El
-The
-.Ql fd = kqueue()
-call is equivalent to
-.Ql fd = kqueuex(0) .
-.Pp
-For compatibility with
-.Nx ,
-the
-.Fn kqueue1
-function is provided, which accepts the
-.Dv O_CLOEXEC
-flag with the expected semantic.
-.Pp
-The
-.Fn kevent
-system call
-is used to register events with the queue, and return any pending
-events to the user.
-The
-.Fa changelist
-argument
-is a pointer to an array of
-.Va kevent
-structures, as defined in
-.In sys/event.h .
-All changes contained in the
-.Fa changelist
-are applied before any pending events are read from the queue.
-The
-.Fa nchanges
-argument
-gives the size of
-.Fa changelist .
-The
-.Fa eventlist
-argument
-is a pointer to an array of kevent structures.
-The
-.Fa nevents
-argument
-determines the size of
-.Fa eventlist .
-When
-.Fa nevents
-is zero,
-.Fn kevent
-will return immediately even if there is a
-.Fa timeout
-specified unlike
-.Xr select 2 .
-If
-.Fa timeout
-is a non-NULL pointer, it specifies a maximum interval to wait
-for an event, which will be interpreted as a struct timespec.
-If
-.Fa timeout
-is a NULL pointer,
-.Fn kevent
-waits indefinitely.
-To effect a poll, the
-.Fa timeout
-argument should be non-NULL, pointing to a zero-valued
-.Va timespec
-structure.
-The same array may be used for the
-.Fa changelist
-and
-.Fa eventlist .
-.Pp
-The
-.Fn EV_SET
-macro is provided for ease of initializing a
-kevent structure.
-.Pp
-The
-.Va kevent
-structure is defined as:
-.Bd -literal
-struct kevent {
- uintptr_t ident; /* identifier for this event */
- short filter; /* filter for event */
- u_short flags; /* action flags for kqueue */
- u_int fflags; /* filter flag value */
- int64_t data; /* filter data value */
- void *udata; /* opaque user data identifier */
- uint64_t ext[4]; /* extensions */
-};
-.Ed
-.Pp
-The fields of
-.Fa struct kevent
-are:
-.Bl -tag -width "Fa filter"
-.It Fa ident
-Value used to identify this event.
-The exact interpretation is determined by the attached filter,
-but often is a file descriptor.
-.It Fa filter
-Identifies the kernel filter used to process this event.
-The pre-defined
-system filters are described below.
-.It Fa flags
-Actions to perform on the event.
-.It Fa fflags
-Filter-specific flags.
-.It Fa data
-Filter-specific data value.
-.It Fa udata
-Opaque user-defined value passed through the kernel unchanged.
-.It Fa ext
-Extended data passed to and from kernel.
-The
-.Fa ext[0]
-and
-.Fa ext[1]
-members use is defined by the filter.
-If the filter does not use them, the members are copied unchanged.
-The
-.Fa ext[2]
-and
-.Fa ext[3]
-members are always passed through the kernel as-is,
-making additional context available to application.
-.El
-.Pp
-The
-.Va flags
-field can contain the following values:
-.Bl -tag -width EV_DISPATCH
-.It Dv EV_ADD
-Adds the event to the kqueue.
-Re-adding an existing event
-will modify the parameters of the original event, and not result
-in a duplicate entry.
-Adding an event automatically enables it,
-unless overridden by the EV_DISABLE flag.
-.It Dv EV_ENABLE
-Permit
-.Fn kevent
-to return the event if it is triggered.
-.It Dv EV_DISABLE
-Disable the event so
-.Fn kevent
-will not return it.
-The filter itself is not disabled.
-.It Dv EV_DISPATCH
-Disable the event source immediately after delivery of an event.
-See
-.Dv EV_DISABLE
-above.
-.It Dv EV_DELETE
-Removes the event from the kqueue.
-Events which are attached to
-file descriptors are automatically deleted on the last close of
-the descriptor.
-.It Dv EV_RECEIPT
-This flag is useful for making bulk changes to a kqueue without draining
-any pending events.
-When passed as input, it forces
-.Dv EV_ERROR
-to always be returned.
-When a filter is successfully added the
-.Va data
-field will be zero.
-Note that if this flag is encountered and there is no remaining space in
-.Fa eventlist
-to hold the
-.Dv EV_ERROR
-event, then subsequent changes will not get processed.
-.It Dv EV_ONESHOT
-Causes the event to return only the first occurrence of the filter
-being triggered.
-After the user retrieves the event from the kqueue,
-it is deleted.
-.It Dv EV_CLEAR
-After the event is retrieved by the user, its state is reset.
-This is useful for filters which report state transitions
-instead of the current state.
-Note that some filters may automatically
-set this flag internally.
-.It Dv EV_EOF
-Filters may set this flag to indicate filter-specific EOF condition.
-.It Dv EV_ERROR
-See
-.Sx RETURN VALUES
-below.
-.It Dv EV_KEEPUDATA
-Causes
-.Fn kevent
-to leave unchanged any
-.Fa udata
-associated with an existing event.
-This allows other aspects of the event to be modified without requiring the
-caller to know the
-.Fa udata
-value presently associated.
-This is especially useful with
-.Dv NOTE_TRIGGER
-or flags like
-.Dv EV_ENABLE .
-This flag may not be used with
-.Dv EV_ADD .
-.El
-.Pp
-The predefined system filters are listed below.
-Arguments may be passed to and from the filter via the
-.Va fflags
-and
-.Va data
-fields in the kevent structure.
-.Bl -tag -width "Dv EVFILT_PROCDESC"
-.It Dv EVFILT_READ
-Takes a descriptor as the identifier, and returns whenever
-there is data available to read.
-The behavior of the filter is slightly different depending
-on the descriptor type.
-.Bl -tag -width 2n
-.It Sockets
-Sockets which have previously been passed to
-.Xr listen 2
-return when there is an incoming connection pending.
-.Va data
-contains the size of the listen backlog.
-.Pp
-Other socket descriptors return when there is data to be read,
-subject to the
-.Dv SO_RCVLOWAT
-value of the socket buffer.
-This may be overridden with a per-filter low water mark at the
-time the filter is added by setting the
-.Dv NOTE_LOWAT
-flag in
-.Va fflags ,
-and specifying the new low water mark in
-.Va data .
-On return,
-.Va data
-contains the number of bytes of protocol data available to read.
-.Pp
-If the read direction of the socket has shutdown, then the filter
-also sets
-.Dv EV_EOF
-in
-.Va flags ,
-and returns the socket error (if any) in
-.Va fflags .
-It is possible for EOF to be returned (indicating the connection is gone)
-while there is still data pending in the socket buffer.
-.It Vnodes
-Returns when the file pointer is not at the end of file.
-.Va data
-contains the offset from current position to end of file,
-and may be negative.
-.Pp
-This behavior is different from
-.Xr poll 2 ,
-where read events are triggered for regular files unconditionally.
-This event can be triggered unconditionally by setting the
-.Dv NOTE_FILE_POLL
-flag in
-.Va fflags .
-.It "Fifos, Pipes"
-Returns when the there is data to read;
-.Va data
-contains the number of bytes available.
-.Pp
-When the last writer disconnects, the filter will set
-.Dv EV_EOF
-in
-.Va flags .
-This will be cleared by the filter when a new writer connects,
-at which point the
-filter will resume waiting for data to become available before
-returning.
-.It "BPF devices"
-Returns when the BPF buffer is full, the BPF timeout has expired, or
-when the BPF has
-.Dq immediate mode
-enabled and there is any data to read;
-.Va data
-contains the number of bytes available.
-.It Eventfds
-Returns when the counter is greater than 0;
-.Va data
-contains the counter value, which must be cast to
-.Vt uint64_t .
-.It Kqueues
-Returns when pending events are present on the queue;
-.Va data
-contains the number of events available.
-.El
-.It Dv EVFILT_WRITE
-Takes a descriptor as the identifier, and returns whenever
-it is possible to write to the descriptor.
-For sockets, pipes
-and fifos,
-.Va data
-will contain the amount of space remaining in the write buffer.
-The filter will set
-.Dv EV_EOF
-when the reader disconnects, and for the fifo case, this will be cleared
-when a new reader connects.
-Note that this filter is not supported for vnodes.
-.Pp
-For sockets, the low water mark and socket error handling is
-identical to the
-.Dv EVFILT_READ
-case.
-.Pp
-For eventfds,
-.Va data
-will contain the maximum value that can be added to the counter
-without blocking.
-.Pp
-For BPF devices, when the descriptor is attached to an interface the filter
-always indicates that it is possible to write and
-.Va data
-will contain the MTU size of the underlying interface.
-.It Dv EVFILT_EMPTY
-Takes a descriptor as the identifier, and returns whenever
-there is no remaining data in the write buffer.
-.It Dv EVFILT_AIO
-Events for this filter are not registered with
-.Fn kevent
-directly but are registered via the
-.Va aio_sigevent
-member of an asynchronous I/O request when it is scheduled via an
-asynchronous I/O system call such as
-.Fn aio_read .
-The filter returns under the same conditions as
-.Fn aio_error .
-For more details on this filter see
-.Xr sigevent 3 and
-.Xr aio 4 .
-.It Dv EVFILT_VNODE
-Takes a file descriptor as the identifier and the events to watch for in
-.Va fflags ,
-and returns when one or more of the requested events occurs on the descriptor.
-The events to monitor are:
-.Bl -tag -width "Dv NOTE_CLOSE_WRITE"
-.It Dv NOTE_ATTRIB
-The file referenced by the descriptor had its attributes changed.
-.It Dv NOTE_CLOSE
-A file descriptor referencing the monitored file, was closed.
-The closed file descriptor did not have write access.
-.It Dv NOTE_CLOSE_WRITE
-A file descriptor referencing the monitored file, was closed.
-The closed file descriptor had write access.
-.Pp
-This note, as well as
-.Dv NOTE_CLOSE ,
-are not activated when files are closed forcibly by
-.Xr unmount 2 or
-.Xr revoke 2 .
-Instead,
-.Dv NOTE_REVOKE
-is sent for such events.
-.It Dv NOTE_DELETE
-The
-.Fn unlink
-system call was called on the file referenced by the descriptor.
-.It Dv NOTE_EXTEND
-For regular file, the file referenced by the descriptor was extended.
-.Pp
-For directory, reports that a directory entry was added or removed,
-as the result of rename operation.
-The
-.Dv NOTE_EXTEND
-event is not reported when a name is changed inside the directory.
-.It Dv NOTE_LINK
-The link count on the file changed.
-In particular, the
-.Dv NOTE_LINK
-event is reported if a subdirectory was created or deleted inside
-the directory referenced by the descriptor.
-.It Dv NOTE_OPEN
-The file referenced by the descriptor was opened.
-.It Dv NOTE_READ
-A read occurred on the file referenced by the descriptor.
-.It Dv NOTE_RENAME
-The file referenced by the descriptor was renamed.
-.It Dv NOTE_REVOKE
-Access to the file was revoked via
-.Xr revoke 2
-or the underlying file system was unmounted.
-.It Dv NOTE_WRITE
-A write occurred on the file referenced by the descriptor.
-.El
-.Pp
-On return,
-.Va fflags
-contains the events which triggered the filter.
-.It Dv EVFILT_PROC
-Takes the process ID to monitor as the identifier and the events to watch for
-in
-.Va fflags ,
-and returns when the process performs one or more of the requested events.
-If a process can normally see another process, it can attach an event to it.
-The events to monitor are:
-.Bl -tag -width "Dv NOTE_TRACKERR"
-.It Dv NOTE_EXIT
-The process has exited.
-The exit status will be stored in
-.Va data
-in the same format as the status returned by
-.Xr wait 2 .
-.It Dv NOTE_FORK
-The process has called
-.Fn fork .
-.It Dv NOTE_EXEC
-The process has executed a new process via
-.Xr execve 2
-or a similar call.
-.It Dv NOTE_TRACK
-Follow a process across
-.Fn fork
-calls.
-The parent process registers a new kevent to monitor the child process
-using the same
-.Va fflags
-as the original event.
-The child process will signal an event with
-.Dv NOTE_CHILD
-set in
-.Va fflags
-and the parent PID in
-.Va data .
-.Pp
-If the parent process fails to register a new kevent
-.Pq usually due to resource limitations ,
-it will signal an event with
-.Dv NOTE_TRACKERR
-set in
-.Va fflags ,
-and the child process will not signal a
-.Dv NOTE_CHILD
-event.
-.El
-.Pp
-On return,
-.Va fflags
-contains the events which triggered the filter.
-.It Dv EVFILT_PROCDESC
-Takes the process descriptor created by
-.Xr pdfork 2
-to monitor as the identifier and the events to watch for in
-.Va fflags ,
-and returns when the associated process performs one or more of the
-requested events.
-The events to monitor are:
-.Bl -tag -width "Dv NOTE_EXIT"
-.It Dv NOTE_EXIT
-The process has exited.
-The exit status will be stored in
-.Va data .
-.El
-.Pp
-On return,
-.Va fflags
-contains the events which triggered the filter.
-.It Dv EVFILT_SIGNAL
-Takes the signal number to monitor as the identifier and returns
-when the given signal is delivered to the process.
-This coexists with the
-.Fn signal
-and
-.Fn sigaction
-facilities, and has a lower precedence.
-The filter will record
-all attempts to deliver a signal to a process, even if the signal has
-been marked as
-.Dv SIG_IGN ,
-except for the
-.Dv SIGCHLD
-signal, which, if ignored, will not be recorded by the filter.
-Event notification happens after normal
-signal delivery processing.
-.Va data
-returns the number of times the signal has occurred since the last call to
-.Fn kevent .
-This filter automatically sets the
-.Dv EV_CLEAR
-flag internally.
-.It Dv EVFILT_TIMER
-Establishes an arbitrary timer identified by
-.Va ident .
-When adding a timer,
-.Va data
-specifies the moment to fire the timer (for
-.Dv NOTE_ABSTIME )
-or the timeout period.
-The timer will be periodic unless
-.Dv EV_ONESHOT
-or
-.Dv NOTE_ABSTIME
-is specified.
-On return,
-.Va data
-contains the number of times the timeout has expired since the last call to
-.Fn kevent .
-For non-monotonic timers, this filter automatically sets the
-.Dv EV_CLEAR
-flag internally.
-.Pp
-The filter accepts the following flags in the
-.Va fflags
-argument:
-.Bl -tag -width "Dv NOTE_MSECONDS"
-.It Dv NOTE_SECONDS
-.Va data
-is in seconds.
-.It Dv NOTE_MSECONDS
-.Va data
-is in milliseconds.
-.It Dv NOTE_USECONDS
-.Va data
-is in microseconds.
-.It Dv NOTE_NSECONDS
-.Va data
-is in nanoseconds.
-.It Dv NOTE_ABSTIME
-The specified expiration time is absolute.
-.El
-.Pp
-If
-.Va fflags
-is not set, the default is milliseconds.
-On return,
-.Va fflags
-contains the events which triggered the filter.
-.Pp
-Periodic timers with a specified timeout of 0 will be silently adjusted to
-timeout after 1 of the time units specified by the requested precision in
-.Va fflags .
-If an absolute time is specified that has already passed, then it is treated as
-if the current time were specified and the event will fire as soon as possible.
-.Pp
-If an existing timer is re-added, the existing timer will be
-effectively canceled (throwing away any undelivered record of previous
-timer expiration) and re-started using the new parameters contained in
-.Va data
-and
-.Va fflags .
-.Pp
-There is a system wide limit on the number of timers
-which is controlled by the
-.Va kern.kq_calloutmax
-sysctl.
-.It Dv EVFILT_USER
-Establishes a user event identified by
-.Va ident
-which is not associated with any kernel mechanism but is triggered by
-user level code.
-The lower 24 bits of the
-.Va fflags
-may be used for user defined flags and manipulated using the following:
-.Bl -tag -width "Dv NOTE_FFLAGSMASK"
-.It Dv NOTE_FFNOP
-Ignore the input
-.Va fflags .
-.It Dv NOTE_FFAND
-Bitwise AND
-.Va fflags .
-.It Dv NOTE_FFOR
-Bitwise OR
-.Va fflags .
-.It Dv NOTE_FFCOPY
-Copy
-.Va fflags .
-.It Dv NOTE_FFCTRLMASK
-Control mask for
-.Va fflags .
-.It Dv NOTE_FFLAGSMASK
-User defined flag mask for
-.Va fflags .
-.El
-.Pp
-A user event is triggered for output with the following:
-.Bl -tag -width "Dv NOTE_FFLAGSMASK"
-.It Dv NOTE_TRIGGER
-Cause the event to be triggered.
-.El
-.Pp
-On return,
-.Va fflags
-contains the users defined flags in the lower 24 bits.
-.El
-.Sh CANCELLATION BEHAVIOUR
-If
-.Fa nevents
-is non-zero, i.e., the function is potentially blocking, the call
-is a cancellation point.
-Otherwise, i.e., if
-.Fa nevents
-is zero, the call is not cancellable.
-Cancellation can only occur before any changes are made to the kqueue,
-or when the call was blocked and no changes to the queue were requested.
-.Sh RETURN VALUES
-The
-.Fn kqueue
-system call
-creates a new kernel event queue and returns a file descriptor.
-If there was an error creating the kernel event queue, a value of -1 is
-returned and errno set.
-.Pp
-The
-.Fn kevent
-system call
-returns the number of events placed in the
-.Fa eventlist ,
-up to the value given by
-.Fa nevents .
-If an error occurs while processing an element of the
-.Fa changelist
-and there is enough room in the
-.Fa eventlist ,
-then the event will be placed in the
-.Fa eventlist
-with
-.Dv EV_ERROR
-set in
-.Va flags
-and the system error in
-.Va data .
-Otherwise,
-.Dv -1
-will be returned, and
-.Dv errno
-will be set to indicate the error condition.
-If the time limit expires, then
-.Fn kevent
-returns 0.
-.Sh EXAMPLES
-.Bd -literal -compact
-#include <sys/event.h>
-#include <err.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int
-main(int argc, char **argv)
-{
- struct kevent event; /* Event we want to monitor */
- struct kevent tevent; /* Event triggered */
- int kq, fd, ret;
-
- if (argc != 2)
- err(EXIT_FAILURE, "Usage: %s path\en", argv[0]);
- fd = open(argv[1], O_RDONLY);
- if (fd == -1)
- err(EXIT_FAILURE, "Failed to open '%s'", argv[1]);
-
- /* Create kqueue. */
- kq = kqueue();
- if (kq == -1)
- err(EXIT_FAILURE, "kqueue() failed");
-
- /* Initialize kevent structure. */
- EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE,
- 0, NULL);
- /* Attach event to the kqueue. */
- ret = kevent(kq, &event, 1, NULL, 0, NULL);
- if (ret == -1)
- err(EXIT_FAILURE, "kevent register");
-
- for (;;) {
- /* Sleep until something happens. */
- ret = kevent(kq, NULL, 0, &tevent, 1, NULL);
- if (ret == -1) {
- err(EXIT_FAILURE, "kevent wait");
- } else if (ret > 0) {
- if (tevent.flags & EV_ERROR)
- errx(EXIT_FAILURE, "Event error: %s", strerror(event.data));
- else
- printf("Something was written in '%s'\en", argv[1]);
- }
- }
-
- /* kqueues are destroyed upon close() */
- (void)close(kq);
- (void)close(fd);
-}
-.Ed
-.Sh ERRORS
-The
-.Fn kqueue
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-The kernel failed to allocate enough memory for the kernel queue.
-.It Bq Er ENOMEM
-The
-.Dv RLIMIT_KQUEUES
-rlimit
-(see
-.Xr getrlimit 2 )
-for the current user would be exceeded.
-.It Bq Er EMFILE
-The per-process descriptor table is full.
-.It Bq Er ENFILE
-The system file table is full.
-.El
-.Pp
-The
-.Fn kevent
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-The process does not have permission to register a filter.
-.It Bq Er EFAULT
-There was an error reading or writing the
-.Va kevent
-structure.
-.It Bq Er EBADF
-The specified descriptor is invalid.
-.It Bq Er EINTR
-A signal was delivered before the timeout expired and before any
-events were placed on the kqueue for return.
-.It Bq Er EINTR
-A cancellation request was delivered to the thread, but not yet handled.
-.It Bq Er EINVAL
-The specified time limit or filter is invalid.
-.It Bq Er EINVAL
-The specified length of the event or change lists is negative.
-.It Bq Er ENOENT
-The event could not be found to be modified or deleted.
-.It Bq Er ENOMEM
-No memory was available to register the event
-or, in the special case of a timer, the maximum number of
-timers has been exceeded.
-This maximum is configurable via the
-.Va kern.kq_calloutmax
-sysctl.
-.It Bq Er ESRCH
-The specified process to attach to does not exist.
-.El
-.Pp
-When
-.Fn kevent
-call fails with
-.Er EINTR
-error, all changes in the
-.Fa changelist
-have been applied.
-.Sh SEE ALSO
-.Xr aio_error 2 ,
-.Xr aio_read 2 ,
-.Xr aio_return 2 ,
-.Xr poll 2 ,
-.Xr read 2 ,
-.Xr select 2 ,
-.Xr sigaction 2 ,
-.Xr write 2 ,
-.Xr pthread_setcancelstate 3 ,
-.Xr signal 3
-.Rs
-.%A Jonathan Lemon
-.%T "Kqueue: A Generic and Scalable Event Notification Facility"
-.%I USENIX Association
-.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference
-.%D June 25-30, 2001
-.\".http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf
-.Re
-.Sh HISTORY
-The
-.Fn kqueue
-and
-.Fn kevent
-system calls first appeared in
-.Fx 4.1 .
-.Sh AUTHORS
-The
-.Fn kqueue
-system and this manual page were written by
-.An Jonathan Lemon Aq Mt jlemon@FreeBSD.org .
-.Sh BUGS
-.Pp
-In versions older than
-.Fx 12.0 ,
-.In sys/event.h
-failed to parse without including
-.In sys/types.h
-manually.
diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2
deleted file mode 100644
index fe69d7e648f0..000000000000
--- a/lib/libc/sys/ktrace.2
+++ /dev/null
@@ -1,206 +0,0 @@
-.\" Copyright (c) 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.
-.\"
-.\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd November 2, 2022
-.Dt KTRACE 2
-.Os
-.Sh NAME
-.Nm ktrace
-.Nd process tracing
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/time.h
-.In sys/uio.h
-.In sys/ktrace.h
-.Ft int
-.Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid"
-.Sh DESCRIPTION
-The
-.Fn ktrace
-system call enables or disables tracing of one or more processes.
-Users may only trace their own processes.
-Only the super-user can trace setuid or setgid programs.
-.Pp
-The
-.Fa tracefile
-argument
-gives the pathname of the file to be used for tracing.
-The file must exist and be a regular file writable by the calling process.
-All trace records are always appended to the file,
-so the file must be truncated to zero length to discard
-previous trace data.
-If tracing points are being disabled (see KTROP_CLEAR below),
-.Fa tracefile
-may be NULL.
-.Pp
-The
-.Fa ops
-argument specifies the requested ktrace operation.
-The defined operations are:
-.Bl -column KTRFLAG_DESCENDXXX -offset indent
-.It KTROP_SET Ta "Enable trace points specified in"
-.Fa trpoints .
-.It KTROP_CLEAR Ta "Disable trace points specified in"
-.Fa trpoints .
-.It KTROP_CLEARFILE Ta "Stop all tracing."
-.It KTRFLAG_DESCEND Ta "The tracing change should apply to the"
-specified process and all its current children.
-.El
-.Pp
-The
-.Fa trpoints
-argument specifies the trace points of interest.
-The defined trace points are:
-.Bl -column KTRFAC_PROCCTORXXX -offset indent
-.It KTRFAC_SYSCALL Ta "Trace system calls."
-.It KTRFAC_SYSRET Ta "Trace return values from system calls."
-.It KTRFAC_NAMEI Ta "Trace name lookup operations."
-.It KTRFAC_GENIO Ta "Trace all I/O (note that this option can"
-generate much output).
-.It KTRFAC_PSIG Ta "Trace posted signals."
-.It KTRFAC_CSW Ta "Trace context switch points."
-.It KTRFAC_USER Ta "Trace application-specific events."
-.It KTRFAC_STRUCT Ta "Trace certain data structures."
-.It KTRFAC_SYSCTL Ta "Trace sysctls."
-.It KTRFAC_PROCCTOR Ta "Trace process construction."
-.It KTRFAC_PROCDTOR Ta "Trace process destruction."
-.It KTRFAC_CAPFAIL Ta "Trace capability failures."
-.It KTRFAC_FAULT Ta "Trace page faults."
-.It KTRFAC_FAULTEND Ta "Trace the end of page faults."
-.It KTRFAC_STRUCT_ARRAY Ta "Trace arrays of certain data structures."
-.It KTRFAC_INHERIT Ta "Inherit tracing to future children."
-.El
-.Pp
-Each tracing event outputs a record composed of a generic header
-followed by a trace point specific structure.
-The generic header is:
-.Bd -literal
-struct ktr_header {
- int ktr_len; /* length of buf */
- short ktr_type; /* trace record type */
- pid_t ktr_pid; /* process id */
- char ktr_comm[MAXCOMLEN+1]; /* command name */
- struct timeval ktr_time; /* timestamp */
- long ktr_tid; /* thread id */
-};
-.Ed
-.Pp
-The
-.Va ktr_len
-field specifies the length of the
-.Va ktr_type
-data that follows this header.
-The
-.Va ktr_pid
-and
-.Va ktr_comm
-fields specify the process and command generating the record.
-The
-.Va ktr_time
-field gives the time (with microsecond resolution)
-that the record was generated.
-The
-.Va ktr_tid
-field holds a thread id.
-.Pp
-The generic header is followed by
-.Va ktr_len
-bytes of a
-.Va ktr_type
-record.
-The type specific records are defined in the
-.In sys/ktrace.h
-include file.
-.Sh SYSCTL TUNABLES
-The following
-.Xr sysctl 8
-tunables influence the behaviour of
-.Fn ktrace :
-.Bl -tag -width indent
-.It Va kern.ktrace.geniosize
-bounds the amount of data a traced I/O request will log
-to the trace file.
-.It Va kern.ktrace.request_pool
-bounds the number of trace events being logged at a time.
-.El
-.Pp
-Sysctl tunables that control process debuggability (as determined by
-.Xr p_candebug 9 )
-also affect the operation of
-.Fn ktrace .
-.Sh RETURN VALUES
-.Rv -std ktrace
-.Sh ERRORS
-The
-.Fn ktrace
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named tracefile does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ENOSYS
-The kernel was not compiled with
-.Nm
-support.
-.El
-.Pp
-A thread may be unable to log one or more tracing events due to a
-temporary shortage of resources.
-This condition is remembered by the kernel, and the next tracing request
-that succeeds will have the flag
-.Li KTR_DROP
-set in its
-.Va ktr_type
-field.
-.Sh SEE ALSO
-.Xr kdump 1 ,
-.Xr ktrace 1 ,
-.Xr utrace 2 ,
-.Xr sysctl 8 ,
-.Xr p_candebug 9
-.Sh HISTORY
-The
-.Fn ktrace
-system call first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/sys/link.2 b/lib/libc/sys/link.2
deleted file mode 100644
index 20b4702002bf..000000000000
--- a/lib/libc/sys/link.2
+++ /dev/null
@@ -1,318 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)link.2 8.3 (Berkeley) 1/12/94
-.\"
-.Dd March 30, 2021
-.Dt LINK 2
-.Os
-.Sh NAME
-.Nm link ,
-.Nm linkat
-.Nd make a hard file link
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn link "const char *name1" "const char *name2"
-.Ft int
-.Fo linkat
-.Fa "int fd1" "const char *name1" "int fd2" "const char *name2" "int flag"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn link
-system call
-atomically creates the specified directory entry (hard link)
-.Fa name2
-with the attributes of the underlying object pointed at by
-.Fa name1 .
-If the link is successful: the link count of the underlying object
-is incremented;
-.Fa name1
-and
-.Fa name2
-share equal access and rights
-to the
-underlying object.
-.Pp
-If
-.Fa name1
-is removed, the file
-.Fa name2
-is not deleted and the link count of the
-underlying object is
-decremented.
-.Pp
-The object pointed at by the
-.Fa name1
-argument
-must exist for the hard link to
-succeed and
-both
-.Fa name1
-and
-.Fa name2
-must be in the same file system.
-The
-.Fa name1
-argument
-may not be a directory.
-.Pp
-The
-.Fn linkat
-system call is equivalent to
-.Fa link
-except in the case where either
-.Fa name1
-or
-.Fa name2
-or both are relative paths.
-In this case a relative path
-.Fa name1
-is interpreted relative to
-the directory associated with the file descriptor
-.Fa fd1
-instead of the current working directory and similarly for
-.Fa name2
-and the file descriptor
-.Fa fd2 .
-.Pp
-Values for
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from the following
-list, defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_FOLLOW
-If
-.Fa name1
-names a symbolic link, a new link for the target of the symbolic link is
-created.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd1
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa name1
-argument is an empty string, link the file referenced by the descriptor
-.Fa fd1 .
-The operation requires that the calling process has the
-.Dv PRIV_VFS_FHOPEN
-privilege, effectively being executed with effective user
-.Dv root .
-.El
-.Pp
-If
-.Fn linkat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd1
-or
-.Fa fd2
-parameter, the current working directory is used for the respective
-.Fa name
-argument.
-If both
-.Fa fd1
-and
-.Fa fd2
-have value
-.Dv AT_FDCWD ,
-the behavior is identical to a call to
-.Fn link .
-Unless
-.Fa flag
-contains the
-.Dv AT_SYMLINK_FOLLOW
-flag, if
-.Fa name1
-names a symbolic link, a new link is created for the symbolic link
-.Fa name1
-and not its target.
-.Sh RETURN VALUES
-.Rv -std link
-.Sh ERRORS
-The
-.Fn link
-system call
-will fail and no link will be created if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of either path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of either pathname exceeded 255 characters,
-or entire length of either path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of either path prefix does not exist.
-.It Bq Er EOPNOTSUPP
-The file system containing the file named by
-.Fa name1
-does not support links.
-.It Bq Er EMLINK
-The link count of the file named by
-.Fa name1
-would exceed 32767.
-.It Bq Er EACCES
-A component of either path prefix denies search permission.
-.It Bq Er EACCES
-The requested link requires writing in a directory with a mode
-that denies write permission.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating one of the pathnames.
-.It Bq Er ENOENT
-The file named by
-.Fa name1
-does not exist.
-.It Bq Er EEXIST
-The link named by
-.Fa name2
-does exist.
-.It Bq Er EPERM
-The file named by
-.Fa name1
-is a directory.
-.It Bq Er EPERM
-The file named by
-.Fa name1
-has its immutable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EPERM
-The parent directory of the file named by
-.Fa name2
-has its immutable flag set.
-.It Bq Er EXDEV
-The link named by
-.Fa name2
-and the file named by
-.Fa name1
-are on different file systems.
-.It Bq Er ENOSPC
-The directory in which the entry for the new link is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er EDQUOT
-The directory in which the entry for the new link
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to
-the file system to make the directory entry.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The requested link requires writing in a directory on a read-only file
-system.
-.It Bq Er EFAULT
-One of the pathnames specified
-is outside the process's allocated address space.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn link ,
-the
-.Fn linkat
-system call may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa name1
-or
-.Fa name2
-argument does not specify an absolute path and the
-.Fa fd1
-or
-.Fa fd2
-argument, respectively, is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa name1
-or
-.Fa name2
-argument is not an absolute path and
-.Fa fd1
-or
-.Fa fd2 ,
-respectively, is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa name1
-is not strictly relative to the starting directory.
-For example,
-.Fa name1
-is absolute or includes a ".." component that escapes
-the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr readlink 2 ,
-.Xr symlink 2 ,
-.Xr unlink 2
-.Sh STANDARDS
-The
-.Fn link
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn linkat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn link
-function appeared in
-.At v1 .
-The
-.Fn linkat
-system call appeared in
-.Fx 8.0 .
-.Pp
-The
-.Fn link
-system call traditionally allows the super-user to link directories which
-corrupts the file system coherency.
-This implementation no longer permits it.
diff --git a/lib/libc/sys/lio_listio.2 b/lib/libc/sys/lio_listio.2
deleted file mode 100644
index 34d2490cca01..000000000000
--- a/lib/libc/sys/lio_listio.2
+++ /dev/null
@@ -1,235 +0,0 @@
-.\" Copyright (c) 2003 Tim J. Robbins
-.\" 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.
-.\"
-.Dd August 22, 2021
-.Dt LIO_LISTIO 2
-.Os
-.Sh NAME
-.Nm lio_listio
-.Nd "list directed I/O (REALTIME)"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In aio.h
-.Ft int
-.Fo lio_listio
-.Fa "int mode"
-.Fa "struct aiocb * const list[]"
-.Fa "int nent"
-.Fa "struct sigevent *sig"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn lio_listio
-function initiates a list of I/O requests with a single function call.
-The
-.Fa list
-argument is an array of pointers to
-.Vt aiocb
-structures describing each operation to perform,
-with
-.Fa nent
-elements.
-.Dv NULL
-elements are ignored.
-.Pp
-The
-.Va aio_lio_opcode
-field of each
-.Vt aiocb
-specifies the operation to be performed.
-The following operations are supported:
-.Bl -tag -width ".Dv LIO_WRITE"
-.It Dv LIO_READ
-Read data as if by a call to
-.Xr aio_read 2 .
-.It Dv LIO_READV
-Read data as if by a call to
-.Xr aio_readv 2 .
-.It Dv LIO_NOP
-No operation.
-.It Dv LIO_WRITE
-Write data as if by a call to
-.Xr aio_write 2 .
-.It Dv LIO_WRITEV
-Write data as if by a call to
-.Xr aio_writev 2 .
-.El
-.Pp
-If the
-.Fa mode
-argument is
-.Dv LIO_WAIT ,
-.Fn lio_listio
-does not return until all the requested operations have been completed.
-If
-.Fa mode
-is
-.Dv LIO_NOWAIT ,
-.Fa sig
-can be used to request asynchronous notification when all operations have
-completed.
-If
-.Fa sig
-is
-.Dv NULL ,
-no notification is sent.
-.Pp
-For
-.Dv SIGEV_KEVENT
-notifications,
-the posted kevent will contain:
-.Bl -column ".Va filter"
-.It Sy Member Ta Sy Value
-.It Va ident Ta Fa list
-.It Va filter Ta Dv EVFILT_LIO
-.It Va udata Ta
-value stored in
-.Fa sig->sigev_value
-.El
-.Pp
-For
-.Dv SIGEV_SIGNO
-and
-.Dv SIGEV_THREAD_ID
-notifications,
-the information for the queued signal will include
-.Dv SI_ASYNCIO
-in the
-.Va si_code
-field and the value stored in
-.Fa sig->sigev_value
-in the
-.Va si_value
-field.
-.Pp
-For
-.Dv SIGEV_THREAD
-notifications,
-the value stored in
-.Fa sig->sigev_value
-is passed to the
-.Fa sig->sigev_notify_function
-as described in
-.Xr sigevent 3 .
-.Pp
-The order in which the requests are carried out is not specified;
-in particular, there is no guarantee that they will be executed in
-the order 0, 1, ...,
-.Fa nent Ns \-1 .
-.Sh RETURN VALUES
-If
-.Fa mode
-is
-.Dv LIO_WAIT ,
-the
-.Fn lio_listio
-function returns 0 if the operations completed successfully,
-otherwise \-1.
-.Pp
-If
-.Fa mode
-is
-.Dv LIO_NOWAIT ,
-the
-.Fn lio_listio
-function returns 0 if the operations are successfully queued,
-otherwise \-1.
-.Sh ERRORS
-The
-.Fn lio_listio
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-There are not enough resources to enqueue the requests.
-.It Bq Er EAGAIN
-The request would cause the system-wide limit
-.Dv {AIO_MAX}
-to be exceeded.
-.It Bq Er EINVAL
-The
-.Fa mode
-argument is neither
-.Dv LIO_WAIT
-nor
-.Dv LIO_NOWAIT ,
-or
-.Fa nent
-is greater than
-.Dv {AIO_LISTIO_MAX} .
-.It Bq Er EINVAL
-The asynchronous notification method in
-.Fa sig->sigev_notify
-is invalid or not supported.
-.It Bq Er EINTR
-A signal interrupted the system call before it could be completed.
-.It Bq Er EIO
-One or more requests failed.
-.El
-.Pp
-In addition, the
-.Fn lio_listio
-function may fail for any of the reasons listed for
-.Xr aio_read 2
-and
-.Xr aio_write 2 .
-.Pp
-If
-.Fn lio_listio
-succeeds, or fails with an error code of
-.Er EAGAIN , EINTR ,
-or
-.Er EIO ,
-some of the requests may have been initiated.
-The caller should check the error status of each
-.Vt aiocb
-structure individually by calling
-.Xr aio_error 2 .
-.Sh SEE ALSO
-.Xr aio_error 2 ,
-.Xr aio_read 2 ,
-.Xr aio_readv 2 ,
-.Xr aio_write 2 ,
-.Xr aio_writev 2 ,
-.Xr read 2 ,
-.Xr write 2 ,
-.Xr sigevent 3 ,
-.Xr siginfo 3 ,
-.Xr aio 4
-.Sh STANDARDS
-The
-.Fn lio_listio
-function is expected to conform to
-.St -p1003.1-2001 .
-The
-.Dv LIO_READV
-and
-.Dv LIO_WRITEV
-operations are
-.Fx extensions, and should not be used in portable code.
-.Sh HISTORY
-The
-.Fn lio_listio
-system call first appeared in
-.Fx 3.0 .
diff --git a/lib/libc/sys/listen.2 b/lib/libc/sys/listen.2
deleted file mode 100644
index 4c2e662dce71..000000000000
--- a/lib/libc/sys/listen.2
+++ /dev/null
@@ -1,203 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" From: @(#)listen.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd April 30, 2023
-.Dt LISTEN 2
-.Os
-.Sh NAME
-.Nm listen
-.Nd listen for connections on a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft int
-.Fn listen "int s" "int backlog"
-.Sh DESCRIPTION
-To accept connections, a socket
-is first created with
-.Xr socket 2 ,
-a willingness to accept incoming connections and
-a queue limit for incoming connections are specified with
-.Fn listen ,
-and then the connections are
-accepted with
-.Xr accept 2 .
-The
-.Fn listen
-system call applies only to sockets of type
-.Dv SOCK_STREAM
-or
-.Dv SOCK_SEQPACKET .
-.Pp
-The
-.Fa backlog
-argument defines the maximum length the queue of
-pending connections may grow to.
-The real maximum queue length will be 1.5 times more than the value
-specified in the
-.Fa backlog
-argument.
-A subsequent
-.Fn listen
-system call on the listening socket allows the caller to change the maximum
-queue length using a new
-.Fa backlog
-argument.
-If a connection
-request arrives with the queue full the client may
-receive an error with an indication of
-.Er ECONNREFUSED ,
-or, in the case of TCP, the connection will be
-silently dropped.
-.Pp
-Current queue lengths of listening sockets can be queried using
-.Xr netstat 1
-command.
-.Pp
-Note that before
-.Fx 4.5
-and the introduction of the syncache,
-the
-.Fa backlog
-argument also determined the length of the incomplete
-connection queue, which held TCP sockets in the process
-of completing TCP's 3-way handshake.
-These incomplete connections
-are now held entirely in the syncache, which is unaffected by
-queue lengths.
-Inflated
-.Fa backlog
-values to help handle denial
-of service attacks are no longer necessary.
-.Pp
-The
-.Xr sysctl 3
-MIB variable
-.Va kern.ipc.soacceptqueue
-specifies a hard limit on
-.Fa backlog ;
-if a value greater than
-.Va kern.ipc.soacceptqueue
-or less than zero is specified,
-.Fa backlog
-is silently forced to
-.Va kern.ipc.soacceptqueue .
-.Pp
-If the listen queue overflows, the kernel will emit a syslog message
-using default priority LOG_DEBUG (7).
-The
-.Xr sysctl 3
-MIB variable
-.Va kern.ipc.sooverprio
-may be used to change this priority to any value in a range of 0..7
-(LOG_EMERG..LOG_DEBUG).
-See
-.Xr syslog 3
-for details.
-It may be set to -1 to disable these messages.
-.Pp
-The variable
-.Va kern.ipc.sooverinterval
-specifies a per-socket limit on how often the kernel will emit these messages.
-.Sh INTERACTION WITH ACCEPT FILTERS
-When accept filtering is used on a socket, a second queue will
-be used to hold sockets that have connected, but have not yet
-met their accept filtering criteria.
-Once the criteria has been
-met, these sockets will be moved over into the completed connection
-queue to be
-.Xr accept 2 Ns ed .
-If this secondary queue is full and a
-new connection comes in, the oldest socket which has not yet met
-its accept filter criteria will be terminated.
-.Pp
-This secondary queue, like the primary listen queue, is sized
-according to the
-.Fa backlog
-argument.
-.Sh RETURN VALUES
-.Rv -std listen
-.Sh ERRORS
-The
-.Fn listen
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The argument
-.Fa s
-is not a valid descriptor.
-.It Bq Er EDESTADDRREQ
-The socket is not bound to a local address, and the protocol does not
-support listening on an unbound socket.
-.It Bq Er EINVAL
-The socket is already connected, or in the process of being connected.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is not a socket.
-.It Bq Er EOPNOTSUPP
-The socket is not of a type that supports the operation
-.Fn listen .
-.El
-.Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr accept 2 ,
-.Xr connect 2 ,
-.Xr socket 2 ,
-.Xr sysctl 3 ,
-.Xr syslog 3 ,
-.Xr sysctl 8 ,
-.Xr accept_filter 9
-.Sh HISTORY
-The
-.Fn listen
-system call appeared in
-.Bx 4.2 .
-The ability to configure the maximum
-.Fa backlog
-at run-time, and to use a negative
-.Fa backlog
-to request the maximum allowable value, was introduced in
-.Fx 2.2 .
-The
-.Va kern.ipc.somaxconn
-.Xr sysctl 3
-has been replaced with
-.Va kern.ipc.soacceptqueue
-in
-.Fx 10.0
-to prevent confusion about its actual functionality.
-The original
-.Xr sysctl 3
-.Va kern.ipc.somaxconn
-is still available but hidden from a
-.Xr sysctl 3
--a output so that existing applications and scripts continue to work.
diff --git a/lib/libc/sys/lockf.c b/lib/libc/sys/lockf.c
new file mode 100644
index 000000000000..6211275e5f16
--- /dev/null
+++ b/lib/libc/sys/lockf.c
@@ -0,0 +1,82 @@
+/* $NetBSD: lockf.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * 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.
+ */
+
+#include "namespace.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+
+int
+lockf(int filedes, int function, off_t size)
+{
+ struct flock fl;
+ int cmd;
+
+ fl.l_start = 0;
+ fl.l_len = size;
+ fl.l_whence = SEEK_CUR;
+
+ switch (function) {
+ case F_ULOCK:
+ cmd = F_SETLK;
+ fl.l_type = F_UNLCK;
+ break;
+ case F_LOCK:
+ cmd = F_SETLKW;
+ fl.l_type = F_WRLCK;
+ break;
+ case F_TLOCK:
+ cmd = F_SETLK;
+ fl.l_type = F_WRLCK;
+ break;
+ case F_TEST:
+ fl.l_type = F_WRLCK;
+ if (((int (*)(int, int, ...))
+ *(__libc_interposing_slot(INTERPOS_fcntl)))
+ (filedes, F_GETLK, &fl) == -1)
+ return (-1);
+ if (fl.l_type == F_UNLCK || (fl.l_sysid == 0 &&
+ fl.l_pid == getpid()))
+ return (0);
+ errno = EAGAIN;
+ return (-1);
+ /* NOTREACHED */
+ default:
+ errno = EINVAL;
+ return (-1);
+ /* NOTREACHED */
+ }
+
+ return (INTERPOS_SYS(fcntl, filedes, cmd, (intptr_t)&fl));
+}
diff --git a/lib/libc/sys/lseek.2 b/lib/libc/sys/lseek.2
deleted file mode 100644
index 0a0da8f999b9..000000000000
--- a/lib/libc/sys/lseek.2
+++ /dev/null
@@ -1,245 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)lseek.2 8.3 (Berkeley) 4/19/94
-.\"
-.Dd July 13, 2020
-.Dt LSEEK 2
-.Os
-.Sh NAME
-.Nm lseek
-.Nd reposition read/write file offset
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft off_t
-.Fn lseek "int fildes" "off_t offset" "int whence"
-.Sh DESCRIPTION
-The
-.Fn lseek
-system call repositions the offset of the file descriptor
-.Fa fildes
-to the
-argument
-.Fa offset
-according to the directive
-.Fa whence .
-The argument
-.Fa fildes
-must be an open
-file descriptor.
-The
-.Fn lseek
-system call
-repositions the file position pointer associated with the file
-descriptor
-.Fa fildes
-as follows:
-.Bl -item -offset indent
-.It
-If
-.Fa whence
-is
-.Dv SEEK_SET ,
-the offset is set to
-.Fa offset
-bytes.
-.It
-If
-.Fa whence
-is
-.Dv SEEK_CUR ,
-the offset is set to its current location plus
-.Fa offset
-bytes.
-.It
-If
-.Fa whence
-is
-.Dv SEEK_END ,
-the offset is set to the size of the
-file plus
-.Fa offset
-bytes.
-.It
-If
-.Fa whence
-is
-.Dv SEEK_HOLE ,
-the offset is set to the start of the next hole greater than or equal
-to the supplied
-.Fa offset .
-The definition of a hole is provided below.
-.It
-If
-.Fa whence
-is
-.Dv SEEK_DATA ,
-the offset is set to the start of the next non-hole file region greater
-than or equal to the supplied
-.Fa offset .
-.El
-.Pp
-The
-.Fn lseek
-system call allows the file offset to be set beyond the end
-of the existing end-of-file of the file.
-If data is later written
-at this point, subsequent reads of the data in the gap return
-bytes of zeros (until data is actually written into the gap).
-However, the
-.Fn lseek
-system call does not, by itself, extend the size of a file.
-.Pp
-A
-.Qq hole
-is defined as a contiguous range of bytes in a file, all having the value of
-zero, but not all zeros in a file are guaranteed to be represented as holes
-returned with
-.Dv SEEK_HOLE .
-File systems are allowed to expose ranges of zeros with
-.Dv SEEK_HOLE ,
-but not required to.
-Applications can use
-.Dv SEEK_HOLE
-to optimise their behavior for ranges of zeros, but must not depend on it to
-find all such ranges in a file.
-Each file is presented as having a zero-size virtual hole at the very
-end of the file.
-The existence of a hole at the end of every data region allows for easy
-programming and also provides compatibility to the original implementation
-in Solaris.
-It also causes the current file size (i.e., end-of-file offset) to be returned
-to indicate that there are no more holes past the supplied
-.Fa offset .
-Applications should use
-.Fn fpathconf _PC_MIN_HOLE_SIZE
-or
-.Fn pathconf _PC_MIN_HOLE_SIZE
-to determine if a file system supports
-.Dv SEEK_HOLE .
-See
-.Xr pathconf 2 .
-.Pp
-For file systems that do not supply information about holes, the file will be
-represented as one entire data region.
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn lseek
-returns the resulting offset location as measured in bytes from the
-beginning of the file.
-Otherwise,
-a value of -1 is returned and
-.Va errno
-is set to indicate
-the error.
-.Sh ERRORS
-The
-.Fn lseek
-system call
-will fail and the file position pointer will remain unchanged if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fildes
-argument
-is not an open file descriptor.
-.It Bq Er EINVAL
-The
-.Fa whence
-argument
-is not a proper value
-or the resulting file offset would
-be negative for a non-character special file.
-.It Bq Er ENXIO
-For
-.Dv SEEK_DATA ,
-there are no more data regions past the supplied offset.
-Due to existence of the hole at the end of the file, for
-.Dv SEEK_HOLE
-this error is only returned when the
-.Fa offset
-already points to the end-of-file position.
-.It Bq Er EOVERFLOW
-The resulting file offset would be a value which cannot be represented
-correctly in an object of type
-.Fa off_t .
-.It Bq Er ESPIPE
-The
-.Fa fildes
-argument
-is associated with a pipe, socket, or FIFO.
-.El
-.Sh SEE ALSO
-.Xr dup 2 ,
-.Xr open 2 ,
-.Xr pathconf 2
-.Sh STANDARDS
-The
-.Fn lseek
-system call is expected to conform to
-.St -p1003.1-2008 .
-.Pp
-The
-.Dv SEEK_HOLE
-and
-.Dv SEEK_DATA
-directives, along with the
-.Er ENXIO
-error, are extensions to that specification.
-.Sh HISTORY
-The
-.Fn lseek
-function appeared in
-.At v7 .
-.Sh BUGS
-If the
-.Fn lseek
-system call is operating on a device which is incapable of seeking,
-it will request the seek operation and return successfully,
-even though no seek was performed.
-Because the
-.Ar offset
-argument will be stored unconditionally in the file descriptor of that device,
-there is no way to confirm if the seek operation succeeded or not
-(e.g. using the
-.Fn ftell
-function).
-Device types which are known to be incapable of seeking include
-tape drives.
-.Pp
-The
-.Fn lseek
-system call will not detect whether media are present in changeable
-media devices such as DVD or Blu-ray devices.
-A requested seek operation will therefore return sucessfully when no
-medium is present.
-.Pp
-This document's use of
-.Fa whence
-is incorrect English, but is maintained for historical reasons.
diff --git a/lib/libc/sys/lstat.c b/lib/libc/sys/lstat.c
index c9c3351e79fc..3a6421120434 100644
--- a/lib/libc/sys/lstat.c
+++ b/lib/libc/sys/lstat.c
@@ -24,25 +24,17 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
+#include <sys/fcntl.h>
#include <sys/syscall.h>
-#include "compat-ino64.h"
+#include <sys/stat.h>
#include <unistd.h>
-
#include "libc_private.h"
int
lstat(const char *path, struct stat *sb)
{
- struct freebsd11_stat stat11;
- int rv;
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
- rv = syscall(SYS_freebsd11_lstat, path, &stat11);
- if (rv == 0)
- __stat11_to_stat(&stat11, sb);
- return (rv);
+ return (__sys_fstatat(AT_FDCWD, path, sb, AT_SYMLINK_NOFOLLOW));
}
diff --git a/lib/libc/sys/madvise.2 b/lib/libc/sys/madvise.2
deleted file mode 100644
index 91479030709d..000000000000
--- a/lib/libc/sys/madvise.2
+++ /dev/null
@@ -1,185 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd July 12, 2015
-.Dt MADVISE 2
-.Os
-.Sh NAME
-.Nm madvise , posix_madvise
-.Nd give advice about use of memory
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn madvise "void *addr" "size_t len" "int behav"
-.Ft int
-.Fn posix_madvise "void *addr" "size_t len" "int behav"
-.Sh DESCRIPTION
-The
-.Fn madvise
-system call
-allows a process that has knowledge of its memory behavior
-to describe it to the system.
-The
-.Fn posix_madvise
-interface is identical, except it returns an error number on error and does
-not modify
-.Va errno ,
-and is provided for standards conformance.
-.Pp
-The known behaviors are:
-.Bl -tag -width MADV_SEQUENTIAL
-.It Dv MADV_NORMAL
-Tells the system to revert to the default paging
-behavior.
-.It Dv MADV_RANDOM
-Is a hint that pages will be accessed randomly, and prefetching
-is likely not advantageous.
-.It Dv MADV_SEQUENTIAL
-Causes the VM system to depress the priority of
-pages immediately preceding a given page when it is faulted in.
-.It Dv MADV_WILLNEED
-Causes pages that are in a given virtual address range
-to temporarily have higher priority, and if they are in
-memory, decrease the likelihood of them being freed.
-Additionally,
-the pages that are already in memory will be immediately mapped into
-the process, thereby eliminating unnecessary overhead of going through
-the entire process of faulting the pages in.
-This WILL NOT fault
-pages in from backing store, but quickly map the pages already in memory
-into the calling process.
-.It Dv MADV_DONTNEED
-Allows the VM system to decrease the in-memory priority
-of pages in the specified address range.
-Consequently, future references to this address range are more likely
-to incur a page fault.
-.It Dv MADV_FREE
-Gives the VM system the freedom to free pages,
-and tells the system that information in the specified page range
-is no longer important.
-This is an efficient way of allowing
-.Xr malloc 3
-to free pages anywhere in the address space, while keeping the address space
-valid.
-The next time that the page is referenced, the page might be demand
-zeroed, or might contain the data that was there before the
-.Dv MADV_FREE
-call.
-References made to that address space range will not make the VM system
-page the information back in from backing store until the page is
-modified again.
-.It Dv MADV_NOSYNC
-Request that the system not flush the data associated with this map to
-physical backing store unless it needs to.
-Typically this prevents the
-file system update daemon from gratuitously writing pages dirtied
-by the VM system to physical disk.
-Note that VM/file system coherency is
-always maintained, this feature simply ensures that the mapped data is
-only flush when it needs to be, usually by the system pager.
-.Pp
-This feature is typically used when you want to use a file-backed shared
-memory area to communicate between processes (IPC) and do not particularly
-need the data being stored in that area to be physically written to disk.
-With this feature you get the equivalent performance with mmap that you
-would expect to get with SysV shared memory calls, but in a more controllable
-and less restrictive manner.
-However, note that this feature is not portable
-across UNIX platforms (though some may do the right thing by default).
-For more information see the MAP_NOSYNC section of
-.Xr mmap 2
-.It Dv MADV_AUTOSYNC
-Undoes the effects of MADV_NOSYNC for any future pages dirtied within the
-address range.
-The effect on pages already dirtied is indeterminate - they
-may or may not be reverted.
-You can guarantee reversion by using the
-.Xr msync 2
-or
-.Xr fsync 2
-system calls.
-.It Dv MADV_NOCORE
-Region is not included in a core file.
-.It Dv MADV_CORE
-Include region in a core file.
-.It Dv MADV_PROTECT
-Informs the VM system this process should not be killed when the
-swap space is exhausted.
-The process must have superuser privileges.
-This should be used judiciously in processes that must remain running
-for the system to properly function.
-.El
-.Pp
-Portable programs that call the
-.Fn posix_madvise
-interface should use the aliases
-.Dv POSIX_MADV_NORMAL , POSIX_MADV_SEQUENTIAL ,
-.Dv POSIX_MADV_RANDOM , POSIX_MADV_WILLNEED ,
-and
-.Dv POSIX_MADV_DONTNEED
-rather than the flags described above.
-.Sh RETURN VALUES
-.Rv -std madvise
-.Sh ERRORS
-The
-.Fn madvise
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa behav
-argument is not valid.
-.It Bq Er ENOMEM
-The virtual address range specified by the
-.Fa addr
-and
-.Fa len
-arguments is not valid.
-.It Bq Er EPERM
-.Dv MADV_PROTECT
-was specified and the process does not have superuser privileges.
-.El
-.Sh SEE ALSO
-.Xr mincore 2 ,
-.Xr mprotect 2 ,
-.Xr msync 2 ,
-.Xr munmap 2 ,
-.Xr posix_fadvise 2
-.Sh STANDARDS
-The
-.Fn posix_madvise
-interface conforms to
-.St -p1003.1-2001 .
-.Sh HISTORY
-The
-.Fn madvise
-system call first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/sys/mincore.2 b/lib/libc/sys/mincore.2
deleted file mode 100644
index 6120473ace10..000000000000
--- a/lib/libc/sys/mincore.2
+++ /dev/null
@@ -1,151 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)mincore.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd August 23, 2020
-.Dt MINCORE 2
-.Os
-.Sh NAME
-.Nm mincore
-.Nd determine residency of memory pages
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn mincore "const void *addr" "size_t len" "char *vec"
-.Sh DESCRIPTION
-The
-.Fn mincore
-system call determines whether each of the pages in the region beginning at
-.Fa addr
-and continuing for
-.Fa len
-bytes is resident or mapped, depending on the value of sysctl
-.Va vm.mincore_mapped .
-.\"The beginning address,
-.\".Fa addr ,
-.\"is first rounded down to a multiple of the page size (see
-.\".Xr getpagesize 3 ) .
-.\"The end address,
-.\".Fa addr No + Fa len ,
-.\"is rounded up to a multiple of the page size.
-The status is returned in the
-.Fa vec
-array, one character per page.
-Each character is either 0 if the page is not resident, or a combination of
-the following flags (defined in
-.In sys/mman.h ) :
-.Bl -tag -width ".Dv MINCORE_REFERENCED_OTHER"
-.It Dv MINCORE_INCORE
-Page is in core (resident).
-.It Dv MINCORE_REFERENCED
-Page has been referenced by us.
-.It Dv MINCORE_MODIFIED
-Page has been modified by us.
-.It Dv MINCORE_REFERENCED_OTHER
-Page has been referenced.
-.It Dv MINCORE_MODIFIED_OTHER
-Page has been modified.
-.It Dv MINCORE_PSIND(i)
-Page is part of a large
-.Pq Dq super
-page with size given by index
-.Dv i
-in the array returned by
-.Xr getpagesizes 3 .
-.It Dv MINCORE_SUPER
-A mask of the valid
-.Dv MINCORE_PSIND()
-values.
-If any bits in this mask are set, the page is part of a large
-.Pq Dq super
-page.
-.El
-.Pp
-The information returned by
-.Fn mincore
-may be out of date by the time the system call returns.
-The only way to ensure that a page is resident is to lock it into memory
-with the
-.Xr mlock 2
-system call.
-.Pp
-If the
-.Va vm.mincore_mapped
-sysctl is set to a non-zero value (default), only the current process'
-mappings of the pages in the specified virtual address range are examined.
-This does not preclude the system from returning
-.Dv MINCORE_REFERENCED_OTHER
-and
-.Dv MINCORE_MODIFIED_OTHER
-statuses.
-Otherwise, if the sysctl value is zero, all resident pages backing the
-specified address range are examined, regardless of the mapping state.
-.Sh IMPLEMENTATION NOTES
-Prior to the introduction of
-.Dv MINCORE_PSIND()
-in
-.Fx 13.0 ,
-.Dv MINCORE_SUPER
-consisted of a single bit equal to
-.Dv MINCORE_PSIND(1) .
-In particular, applications compiled using the old value of
-.Dv MINCORE_SUPER
-will not identify large pages with size index 2 as being large pages.
-.Sh RETURN VALUES
-.Rv -std mincore
-.Sh ERRORS
-The
-.Fn mincore
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-The virtual address range specified by the
-.Fa addr
-and
-.Fa len
-arguments is not fully mapped.
-.It Bq Er EFAULT
-The
-.Fa vec
-argument points to an illegal address.
-.El
-.Sh SEE ALSO
-.Xr madvise 2 ,
-.Xr mlock 2 ,
-.Xr mprotect 2 ,
-.Xr msync 2 ,
-.Xr munmap 2 ,
-.Xr getpagesize 3 ,
-.Xr getpagesizes 3
-.Sh HISTORY
-The
-.Fn mincore
-system call first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/sys/minherit.2 b/lib/libc/sys/minherit.2
deleted file mode 100644
index 166d75ad23ee..000000000000
--- a/lib/libc/sys/minherit.2
+++ /dev/null
@@ -1,150 +0,0 @@
-.\"
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)minherit.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd March 15, 2017
-.Dt MINHERIT 2
-.Os
-.Sh NAME
-.Nm minherit
-.Nd control the inheritance of pages
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn minherit "void *addr" "size_t len" "int inherit"
-.Sh DESCRIPTION
-The
-.Fn minherit
-system call
-changes the specified pages to have the inheritance characteristic
-.Fa inherit .
-Not all implementations will guarantee that the inheritance characteristic
-can be set on a page basis;
-the granularity of changes may be as large as an entire region.
-.Fx
-is capable of adjusting inheritance characteristics on a page basis.
-Inheritance only effects children created by
-.Fn fork .
-It has no effect on
-.Fn exec .
-exec'd processes replace their address space entirely.
-This system call also
-has no effect on the parent's address space (other than to potentially
-share the address space with its children).
-.Pp
-Inheritance is a rather esoteric feature largely superseded by the
-.Dv MAP_SHARED
-feature of
-.Fn mmap .
-However, it is possible to use
-.Fn minherit
-to share a block of memory between parent and child that has been mapped
-.Dv MAP_PRIVATE .
-That is, modifications made by parent or child are shared but
-the original underlying file is left untouched.
-.Bl -tag -width ".Dv INHERIT_SHARE"
-.It Dv INHERIT_SHARE
-This option causes the address space in question to be shared between
-parent and child.
-It has no effect on how the original underlying backing
-store was mapped.
-.It Dv INHERIT_NONE
-This option prevents the address space in question from being inherited
-at all.
-The address space will be unmapped in the child.
-.It Dv INHERIT_COPY
-This option causes the child to inherit the address space as copy-on-write.
-This option also has an unfortunate side effect of causing the parent
-address space to become copy-on-write when the parent forks.
-If the original mapping was
-.Dv MAP_SHARED ,
-it will no longer be shared in the parent
-after the parent forks and there is no way to get the previous
-shared-backing-store mapping without unmapping and remapping the address
-space in the parent.
-.It Dv INHERIT_ZERO
-This option causes the address space in question to be mapped as new
-anonymous pages,
-which would be initialized to all zero bytes,
-in the child process.
-.El
-.Sh RETURN VALUES
-.Rv -std minherit
-.Sh ERRORS
-The
-.Fn minherit
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The virtual address range specified by the
-.Fa addr
-and
-.Fa len
-arguments is not valid.
-.It Bq Er EACCES
-The flags specified by the
-.Fa inherit
-argument were not valid for the pages specified
-by the
-.Fa addr
-and
-.Fa len
-arguments.
-.El
-.Sh SEE ALSO
-.Xr fork 2 ,
-.Xr madvise 2 ,
-.Xr mincore 2 ,
-.Xr mprotect 2 ,
-.Xr msync 2 ,
-.Xr munmap 2 ,
-.Xr rfork 2
-.Sh HISTORY
-The
-.Fn minherit
-system call first appeared in
-.Ox
-and then in
-.Fx 2.2 .
-.Pp
-The
-.Dv INHERIT_ZERO
-support first appeared in
-.Ox 5.6
-and then in
-.Fx 12.0 .
-.Sh BUGS
-Once you set inheritance to
-.Dv MAP_PRIVATE
-or
-.Dv MAP_SHARED ,
-there is no way to recover the original copy-on-write semantics
-short of unmapping and remapping the area.
diff --git a/lib/libc/sys/mkdir.2 b/lib/libc/sys/mkdir.2
deleted file mode 100644
index 3cbe9ad794ea..000000000000
--- a/lib/libc/sys/mkdir.2
+++ /dev/null
@@ -1,181 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)mkdir.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd March 30, 2020
-.Dt MKDIR 2
-.Os
-.Sh NAME
-.Nm mkdir ,
-.Nm mkdirat
-.Nd make a directory file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.Ft int
-.Fn mkdir "const char *path" "mode_t mode"
-.Ft int
-.Fn mkdirat "int fd" "const char *path" "mode_t mode"
-.Sh DESCRIPTION
-The directory
-.Fa path
-is created with the access permissions specified by
-.Fa mode
-and restricted by the
-.Xr umask 2
-of the calling process.
-.Pp
-The directory's owner ID is set to the process's effective user ID.
-The directory's group ID is set to that of the parent directory in
-which it is created.
-.Pp
-The
-.Fn mkdirat
-system call is equivalent to
-.Fn mkdir
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the newly created directory is created relative to the
-directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn mkdirat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn mkdir .
-.Sh RETURN VALUES
-.Rv -std mkdir
-.Sh ERRORS
-The
-.Fn mkdir
-system call
-will fail and no directory will be created if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of the path prefix does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix,
-or write permission is denied
-on the parent directory of the directory to be created.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The parent directory of the directory to be created has its immutable flag set,
-see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EROFS
-The named directory would reside on a read-only file system.
-.It Bq Er EMLINK
-The new directory cannot be created because the parent directory contains
-too many subdirectories.
-.It Bq Er EEXIST
-The named file exists.
-.It Bq Er ENOSPC
-The new directory cannot be created because there is no space left
-on the file system that will contain the directory.
-.It Bq Er ENOSPC
-There are no free inodes on the file system on which the
-directory is being created.
-.It Bq Er EDQUOT
-The new directory cannot be created because the user's
-quota of disk blocks on the file system that will
-contain the directory has been exhausted.
-.It Bq Er EDQUOT
-The user's quota of inodes on the file system on
-which the directory is being created has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while making the directory entry or allocating the inode.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn mkdir ,
-the
-.Fn mkdirat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr chmod 2 ,
-.Xr stat 2 ,
-.Xr umask 2
-.Sh STANDARDS
-The
-.Fn mkdir
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn mkdirat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn mkdirat
-system call appeared in
-.Fx 8.0 .
-The
-.Fn mkdir
-system call appeared in
-.At v1 .
diff --git a/lib/libc/sys/mkfifo.2 b/lib/libc/sys/mkfifo.2
deleted file mode 100644
index 373bcbb61336..000000000000
--- a/lib/libc/sys/mkfifo.2
+++ /dev/null
@@ -1,182 +0,0 @@
-.\" Copyright (c) 1990, 1991, 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.
-.\"
-.\" @(#)mkfifo.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt MKFIFO 2
-.Os
-.Sh NAME
-.Nm mkfifo ,
-.Nm mkfifoat
-.Nd make a fifo file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/stat.h
-.Ft int
-.Fn mkfifo "const char *path" "mode_t mode"
-.Ft int
-.Fn mkfifoat "int fd" "const char *path" "mode_t mode"
-.Sh DESCRIPTION
-The
-.Fn mkfifo
-system call
-creates a new fifo file with name
-.Fa path .
-The access permissions are
-specified by
-.Fa mode
-and restricted by the
-.Xr umask 2
-of the calling process.
-.Pp
-The fifo's owner ID is set to the process's effective user ID.
-The fifo's group ID is set to that of the parent directory in
-which it is created.
-.Pp
-The
-.Fn mkfifoat
-system call is equivalent to
-.Fn mkfifo
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the newly created FIFO is created relative to the
-directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn mkfifoat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn mkfifo .
-.Sh RETURN VALUES
-.Rv -std mkfifo
-.Sh ERRORS
-The
-.Fn mkfifo
-system call
-will fail and no fifo will be created if:
-.Bl -tag -width Er
-.It Bq Er ENOTSUP
-The kernel has not been configured to support fifo's.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of the path prefix does not exist.
-.It Bq Er EACCES
-A component of the path prefix denies search permission, or write permission
-is denied on the parent directory of the fifo to be created.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EROFS
-The named file would reside on a read-only file system.
-.It Bq Er EEXIST
-The named file exists.
-.It Bq Er EPERM
-The parent directory of the named file has its immutable flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er ENOSPC
-The directory in which the entry for the new fifo is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er ENOSPC
-There are no free inodes on the file system on which the
-fifo is being created.
-.It Bq Er EDQUOT
-The directory in which the entry for the new fifo
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EDQUOT
-The user's quota of inodes on the file system on
-which the fifo is being created has been exhausted.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while making the directory entry or allocating the inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn mkfifo ,
-the
-.Fn mkfifoat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr chmod 2 ,
-.Xr mknod 2 ,
-.Xr stat 2 ,
-.Xr umask 2
-.Sh STANDARDS
-The
-.Fn mkfifo
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn mkfifoat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn mkfifoat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/mknod.2 b/lib/libc/sys/mknod.2
deleted file mode 100644
index ef546b93b3ca..000000000000
--- a/lib/libc/sys/mknod.2
+++ /dev/null
@@ -1,183 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)mknod.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt MKNOD 2
-.Os
-.Sh NAME
-.Nm mknod ,
-.Nm mknodat
-.Nd make a special file node
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.Ft int
-.Fn mknod "const char *path" "mode_t mode" "dev_t dev"
-.Ft int
-.Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev"
-.Sh DESCRIPTION
-The file system node
-.Fa path
-is created with the file type and access permissions specified in
-.Fa mode .
-The access permissions are modified by the process's umask value.
-.Pp
-If
-.Fa mode
-indicates a block or character special file,
-.Fa dev
-is a configuration dependent specification denoting a particular device
-on the system.
-Otherwise,
-.Fa dev
-is ignored.
-.Pp
-The
-.Fn mknod
-system call
-requires super-user privileges.
-.Pp
-The
-.Fn mknodat
-system call is equivalent to
-.Fn mknod
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the newly created device node is created relative to the
-directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn mknodat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn mknod .
-.Sh RETURN VALUES
-.Rv -std mknod
-.Sh ERRORS
-The
-.Fn mknod
-system call
-will fail and the file will be not created if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of the path prefix does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The process's effective user ID is not super-user.
-.It Bq Er EIO
-An I/O error occurred while making the directory entry or allocating the inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ENOSPC
-The directory in which the entry for the new node is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er ENOSPC
-There are no free inodes on the file system on which the
-node is being created.
-.It Bq Er EDQUOT
-The directory in which the entry for the new node
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EDQUOT
-The user's quota of inodes on the file system on
-which the node is being created has been exhausted.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EEXIST
-The named file exists.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-Creating anything else than a block or character special
-file (or a
-.Em whiteout )
-is not supported.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn mknod ,
-the
-.Fn mknodat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr chmod 2 ,
-.Xr mkfifo 2 ,
-.Xr stat 2 ,
-.Xr umask 2
-.Sh STANDARDS
-The
-.Fn mknodat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn mknod
-function appeared in
-.At v4 .
-The
-.Fn mknodat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/mknod.c b/lib/libc/sys/mknod.c
index 8e8fa9faaebf..fd224058b5fb 100644
--- a/lib/libc/sys/mknod.c
+++ b/lib/libc/sys/mknod.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/fcntl.h>
diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2
deleted file mode 100644
index cff2a2c69a3a..000000000000
--- a/lib/libc/sys/mlock.2
+++ /dev/null
@@ -1,178 +0,0 @@
-.\" Copyright (c) 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.
-.\"
-.\" @(#)mlock.2 8.2 (Berkeley) 12/11/93
-.\"
-.Dd May 13, 2019
-.Dt MLOCK 2
-.Os
-.Sh NAME
-.Nm mlock ,
-.Nm munlock
-.Nd lock (unlock) physical pages in memory
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn mlock "const void *addr" "size_t len"
-.Ft int
-.Fn munlock "const void *addr" "size_t len"
-.Sh DESCRIPTION
-The
-.Fn mlock
-system call
-locks into memory the physical pages associated with the virtual address
-range starting at
-.Fa addr
-for
-.Fa len
-bytes.
-The
-.Fn munlock
-system call unlocks pages previously locked by one or more
-.Fn mlock
-calls.
-For both, the
-.Fa addr
-argument should be aligned to a multiple of the page size.
-If the
-.Fa len
-argument is not a multiple of the page size, it will be rounded up
-to be so.
-The entire range must be allocated.
-.Pp
-After an
-.Fn mlock
-system call, the indicated pages will cause neither a non-resident page
-nor address-translation fault until they are unlocked.
-They may still cause protection-violation faults or TLB-miss faults on
-architectures with software-managed TLBs.
-The physical pages remain in memory until all locked mappings for the pages
-are removed.
-Multiple processes may have the same physical pages locked via their own
-virtual address mappings.
-A single process may likewise have pages multiply-locked via different virtual
-mappings of the same physical pages.
-Unlocking is performed explicitly by
-.Fn munlock
-or implicitly by a call to
-.Fn munmap
-which deallocates the unmapped address range.
-Locked mappings are not inherited by the child process after a
-.Xr fork 2 .
-.Pp
-Since physical memory is a potentially scarce resource, processes are
-limited in how much they can lock down.
-The amount of memory that a single process can
-.Fn mlock
-is limited by both the per-process
-.Dv RLIMIT_MEMLOCK
-resource limit and the
-system-wide
-.Dq wired pages
-limit
-.Va vm.max_user_wired .
-.Va vm.max_user_wired
-applies to the system as a whole, so the amount available to a single
-process at any given time is the difference between
-.Va vm.max_user_wired
-and
-.Va vm.stats.vm.v_user_wire_count .
-.Pp
-If
-.Va security.bsd.unprivileged_mlock
-is set to 0 these calls are only available to the super-user.
-.Sh RETURN VALUES
-.Rv -std
-.Pp
-If the call succeeds, all pages in the range become locked (unlocked);
-otherwise the locked status of all pages in the range remains unchanged.
-.Sh ERRORS
-The
-.Fn mlock
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-.Va security.bsd.unprivileged_mlock
-is set to 0 and the caller is not the super-user.
-.It Bq Er EINVAL
-The address range given wraps around zero.
-.It Bq Er ENOMEM
-Some portion of the indicated address range is not allocated.
-There was an error faulting/mapping a page.
-Locking the indicated range would exceed the per-process or system-wide limits
-for locked memory.
-.El
-The
-.Fn munlock
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-.Va security.bsd.unprivileged_mlock
-is set to 0 and the caller is not the super-user.
-.It Bq Er EINVAL
-The address range given wraps around zero.
-.It Bq Er ENOMEM
-Some or all of the address range specified by the addr and len
-arguments does not correspond to valid mapped pages in the address space
-of the process.
-.It Bq Er ENOMEM
-Locking the pages mapped by the specified range would exceed a limit on
-the amount of memory that the process may lock.
-.El
-.Sh "SEE ALSO"
-.Xr fork 2 ,
-.Xr mincore 2 ,
-.Xr minherit 2 ,
-.Xr mlockall 2 ,
-.Xr mmap 2 ,
-.Xr munlockall 2 ,
-.Xr munmap 2 ,
-.Xr setrlimit 2 ,
-.Xr getpagesize 3
-.Sh HISTORY
-The
-.Fn mlock
-and
-.Fn munlock
-system calls first appeared in
-.Bx 4.4 .
-.Sh BUGS
-Allocating too much wired memory can lead to a memory-allocation deadlock
-which requires a reboot to recover from.
-.Pp
-The per-process and system-wide resource limits of locked memory apply
-to the amount of virtual memory locked, not the amount of locked physical
-pages.
-Hence two distinct locked mappings of the same physical page counts as
-2 pages aginst the system limit, and also against the per-process limit
-if both mappings belong to the same physical map.
-.Pp
-The per-process resource limit is not currently supported.
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
deleted file mode 100644
index a3815d31a134..000000000000
--- a/lib/libc/sys/mmap.2
+++ /dev/null
@@ -1,566 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
-.\"
-.Dd August 14, 2023
-.Dt MMAP 2
-.Os
-.Sh NAME
-.Nm mmap
-.Nd allocate memory, or map files or devices into memory
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft void *
-.Fn mmap "void *addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
-.Sh DESCRIPTION
-The
-.Fn mmap
-system call causes the pages starting at
-.Fa addr
-and continuing for at most
-.Fa len
-bytes to be mapped from the object described by
-.Fa fd ,
-starting at byte offset
-.Fa offset .
-If
-.Fa len
-is not a multiple of the page size, the mapped region may extend past the
-specified range.
-Any such extension beyond the end of the mapped object will be zero-filled.
-.Pp
-If
-.Fa fd
-references a regular file or a shared memory object, the range of
-bytes starting at
-.Fa offset
-and continuing for
-.Fa len
-bytes must be legitimate for the possible (not necessarily
-current) offsets in the object.
-In particular, the
-.Fa offset
-value cannot be negative.
-If the object is truncated and the process later accesses a page that
-is wholly within the truncated region, the access is aborted and a
-.Dv SIGBUS
-signal is delivered to the process.
-.Pp
-If
-.Fa fd
-references a device file, the interpretation of the
-.Fa offset
-value is device specific and defined by the device driver.
-The virtual memory subsystem does not impose any restrictions on the
-.Fa offset
-value in this case, passing it unchanged to the driver.
-.Pp
-If
-.Fa addr
-is non-zero, it is used as a hint to the system.
-(As a convenience to the system, the actual address of the region may differ
-from the address supplied.)
-If
-.Fa addr
-is zero, an address will be selected by the system.
-The actual starting address of the region is returned.
-A successful
-.Fa mmap
-deletes any previous mapping in the allocated address range.
-.Pp
-The protections (region accessibility) are specified in the
-.Fa prot
-argument by
-.Em or Ns 'ing
-the following values:
-.Pp
-.Bl -tag -width PROT_WRITE -compact
-.It Dv PROT_NONE
-Pages may not be accessed.
-.It Dv PROT_READ
-Pages may be read.
-.It Dv PROT_WRITE
-Pages may be written.
-.It Dv PROT_EXEC
-Pages may be executed.
-.El
-.Pp
-In addition to these protection flags,
-.Fx
-provides the ability to set the maximum protection of a region allocated by
-.Nm
-and later altered by
-.Xr mprotect 2 .
-This is accomplished by
-.Em or Ns 'ing
-one or more
-.Dv PROT_
-values wrapped in the
-.Dv PROT_MAX()
-macro into the
-.Fa prot
-argument.
-.Pp
-The
-.Fa flags
-argument specifies the type of the mapped object, mapping options and
-whether modifications made to the mapped copy of the page are private
-to the process or are to be shared with other references.
-Sharing, mapping type and options are specified in the
-.Fa flags
-argument by
-.Em or Ns 'ing
-the following values:
-.Bl -tag -width MAP_PREFAULT_READ
-.It Dv MAP_32BIT
-Request a region in the first 2GB of the current process's address space.
-If a suitable region cannot be found,
-.Fn mmap
-will fail.
-.It Dv MAP_ALIGNED Ns Pq Fa n
-Align the region on a requested boundary.
-If a suitable region cannot be found,
-.Fn mmap
-will fail.
-The
-.Fa n
-argument specifies the binary logarithm of the desired alignment.
-.It Dv MAP_ALIGNED_SUPER
-Align the region to maximize the potential use of large
-.Pq Dq super
-pages.
-If a suitable region cannot be found,
-.Fn mmap
-will fail.
-The system will choose a suitable page size based on the size of
-mapping.
-The page size used as well as the alignment of the region may both be
-affected by properties of the file being mapped.
-In particular,
-the physical address of existing pages of a file may require a specific
-alignment.
-The region is not guaranteed to be aligned on any specific boundary.
-.It Dv MAP_ANON
-Map anonymous memory not associated with any specific file.
-The file descriptor used for creating
-.Dv MAP_ANON
-must be \-1.
-The
-.Fa offset
-argument must be 0.
-.\".It Dv MAP_FILE
-.\"Mapped from a regular file or character-special device memory.
-.It Dv MAP_ANONYMOUS
-This flag is identical to
-.Dv MAP_ANON
-and is provided for compatibility.
-.It Dv MAP_EXCL
-This flag can only be used in combination with
-.Dv MAP_FIXED .
-Please see the definition of
-.Dv MAP_FIXED
-for the description of its effect.
-.It Dv MAP_FIXED
-Do not permit the system to select a different address than the one
-specified.
-If the specified address cannot be used,
-.Fn mmap
-will fail.
-If
-.Dv MAP_FIXED
-is specified,
-.Fa addr
-must be a multiple of the page size.
-If
-.Dv MAP_EXCL
-is not specified, a successful
-.Dv MAP_FIXED
-request replaces any previous mappings for the process'
-pages in the range from
-.Fa addr
-to
-.Fa addr
-+
-.Fa len .
-In contrast, if
-.Dv MAP_EXCL
-is specified, the request will fail if a mapping
-already exists within the range.
-.It Dv MAP_GUARD
-Instead of a mapping, create a guard of the specified size.
-Guards allow a process to create reservations in its address space,
-which can later be replaced by actual mappings.
-.Pp
-.Fa mmap
-will not create mappings in the address range of a guard unless
-the request specifies
-.Dv MAP_FIXED .
-Guards can be destroyed with
-.Xr munmap 2 .
-Any memory access by a thread to the guarded range results
-in the delivery of a
-.Dv SIGSEGV
-signal to that thread.
-.It Dv MAP_NOCORE
-Region is not included in a core file.
-.It Dv MAP_NOSYNC
-Causes data dirtied via this VM map to be flushed to physical media
-only when necessary (usually by the pager) rather than gratuitously.
-Typically this prevents the update daemons from flushing pages dirtied
-through such maps and thus allows efficient sharing of memory across
-unassociated processes using a file-backed shared memory map.
-Without
-this option any VM pages you dirty may be flushed to disk every so often
-(every 30-60 seconds usually) which can create performance problems if you
-do not need that to occur (such as when you are using shared file-backed
-mmap regions for IPC purposes).
-Dirty data will be flushed automatically when all mappings of an object are
-removed and all descriptors referencing the object are closed.
-Note that VM/file system coherency is
-maintained whether you use
-.Dv MAP_NOSYNC
-or not.
-This option is not portable
-across
-.Ux
-platforms (yet), though some may implement the same behavior
-by default.
-.Pp
-.Em WARNING !
-Extending a file with
-.Xr ftruncate 2 ,
-thus creating a big hole, and then filling the hole by modifying a shared
-.Fn mmap
-can lead to severe file fragmentation.
-In order to avoid such fragmentation you should always pre-allocate the
-file's backing store by
-.Fn write Ns ing
-zero's into the newly extended area prior to modifying the area via your
-.Fn mmap .
-The fragmentation problem is especially sensitive to
-.Dv MAP_NOSYNC
-pages, because pages may be flushed to disk in a totally random order.
-.Pp
-The same applies when using
-.Dv MAP_NOSYNC
-to implement a file-based shared memory store.
-It is recommended that you create the backing store by
-.Fn write Ns ing
-zero's to the backing file rather than
-.Fn ftruncate Ns ing
-it.
-You can test file fragmentation by observing the KB/t (kilobytes per
-transfer) results from an
-.Dq Li iostat 1
-while reading a large file sequentially, e.g.,\& using
-.Dq Li dd if=filename of=/dev/null bs=32k .
-.Pp
-The
-.Xr fsync 2
-system call will flush all dirty data and metadata associated with a file,
-including dirty NOSYNC VM data, to physical media.
-The
-.Xr sync 8
-command and
-.Xr sync 2
-system call generally do not flush dirty NOSYNC VM data.
-The
-.Xr msync 2
-system call is usually not needed since
-.Bx
-implements a coherent file system buffer cache.
-However, it may be
-used to associate dirty VM pages with file system buffers and thus cause
-them to be flushed to physical media sooner rather than later.
-.It Dv MAP_PREFAULT_READ
-Immediately update the calling process's lowest-level virtual address
-translation structures, such as its page table, so that every memory
-resident page within the region is mapped for read access.
-Ordinarily these structures are updated lazily.
-The effect of this option is to eliminate any soft faults that would
-otherwise occur on the initial read accesses to the region.
-Although this option does not preclude
-.Fa prot
-from including
-.Dv PROT_WRITE ,
-it does not eliminate soft faults on the initial write accesses to the
-region.
-.It Dv MAP_PRIVATE
-Modifications are private.
-.It Dv MAP_SHARED
-Modifications are shared.
-.It Dv MAP_STACK
-Creates both a mapped region that grows downward on demand and an
-adjoining guard that both reserves address space for the mapped region
-to grow into and limits the mapped region's growth.
-Together, the mapped region and the guard occupy
-.Fa len
-bytes of the address space.
-The guard starts at the returned address, and the mapped region ends at
-the returned address plus
-.Fa len
-bytes.
-Upon access to the guard, the mapped region automatically grows in size,
-and the guard shrinks by an equal amount.
-Essentially, the boundary between the guard and the mapped region moves
-downward so that the access falls within the enlarged mapped region.
-However, the guard will never shrink to less than the number of pages
-specified by the sysctl
-.Dv security.bsd.stack_guard_page ,
-thereby ensuring that a gap for detecting stack overflow always exists
-between the downward growing mapped region and the closest mapped region
-beneath it.
-.Pp
-.Dv MAP_STACK
-implies
-.Dv MAP_ANON
-and
-.Fa offset
-of 0.
-The
-.Fa fd
-argument
-must be -1 and
-.Fa prot
-must include at least
-.Dv PROT_READ
-and
-.Dv PROT_WRITE .
-The size of the guard, in pages, is specified by sysctl
-.Dv security.bsd.stack_guard_page .
-.El
-.Pp
-The
-.Xr close 2
-system call does not unmap pages, see
-.Xr munmap 2
-for further information.
-.Sh NOTES
-Although this implementation does not impose any alignment restrictions on
-the
-.Fa offset
-argument, a portable program must only use page-aligned values.
-.Pp
-Large page mappings require that the pages backing an object be
-aligned in matching blocks in both the virtual address space and RAM.
-The system will automatically attempt to use large page mappings when
-mapping an object that is already backed by large pages in RAM by
-aligning the mapping request in the virtual address space to match the
-alignment of the large physical pages.
-The system may also use large page mappings when mapping portions of an
-object that are not yet backed by pages in RAM.
-The
-.Dv MAP_ALIGNED_SUPER
-flag is an optimization that will align the mapping request to the
-size of a large page similar to
-.Dv MAP_ALIGNED ,
-except that the system will override this alignment if an object already
-uses large pages so that the mapping will be consistent with the existing
-large pages.
-This flag is mostly useful for maximizing the use of large pages on the
-first mapping of objects that do not yet have pages present in RAM.
-.Sh RETURN VALUES
-Upon successful completion,
-.Fn mmap
-returns a pointer to the mapped region.
-Otherwise, a value of
-.Dv MAP_FAILED
-is returned and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn mmap
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-The flag
-.Dv PROT_READ
-was specified as part of the
-.Fa prot
-argument and
-.Fa fd
-was not open for reading.
-The flags
-.Dv MAP_SHARED
-and
-.Dv PROT_WRITE
-were specified as part of the
-.Fa flags
-and
-.Fa prot
-argument and
-.Fa fd
-was not open for writing.
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid open file descriptor.
-.It Bq Er EINVAL
-An invalid (negative) value was passed in the
-.Fa offset
-argument, when
-.Fa fd
-referenced a regular file or shared memory.
-.It Bq Er EINVAL
-An invalid value was passed in the
-.Fa prot
-argument.
-.It Bq Er EINVAL
-An undefined option was set in the
-.Fa flags
-argument.
-.It Bq Er EINVAL
-Both
-.Dv MAP_PRIVATE
-and
-.Dv MAP_SHARED
-were specified.
-.It Bq Er EINVAL
-None of
-.Dv MAP_ANON ,
-.Dv MAP_GUARD ,
-.Dv MAP_PRIVATE ,
-.Dv MAP_SHARED ,
-or
-.Dv MAP_STACK
-was specified.
-At least one of these flags must be included.
-.It Bq Er EINVAL
-.Dv MAP_STACK
-was specified and
-.Va len
-is less than or equal to the guard size.
-.It Bq Er EINVAL
-.Dv MAP_FIXED
-was specified and the
-.Fa addr
-argument was not page aligned, or part of the desired address space
-resides out of the valid address space for a user process.
-.It Bq Er EINVAL
-Both
-.Dv MAP_FIXED
-and
-.Dv MAP_32BIT
-were specified and part of the desired address space resides outside
-of the first 2GB of user address space.
-.It Bq Er EINVAL
-The
-.Fa len
-argument
-was equal to zero.
-.It Bq Er EINVAL
-.Dv MAP_ALIGNED
-was specified and the desired alignment was either larger than the
-virtual address size of the machine or smaller than a page.
-.It Bq Er EINVAL
-.Dv MAP_ANON
-was specified and the
-.Fa fd
-argument was not -1.
-.It Bq Er EINVAL
-.Dv MAP_ANON
-was specified and the
-.Fa offset
-argument was not 0.
-.It Bq Er EINVAL
-Both
-.Dv MAP_FIXED
-and
-.Dv MAP_EXCL
-were specified, but the requested region is already used by a mapping.
-.It Bq Er EINVAL
-.Dv MAP_EXCL
-was specified, but
-.Dv MAP_FIXED
-was not.
-.It Bq Er EINVAL
-.Dv MAP_GUARD
-was specified, but the
-.Fa offset
-argument was not zero, the
-.Fa fd
-argument was not -1, or the
-.Fa prot
-argument was not
-.Dv PROT_NONE .
-.It Bq Er EINVAL
-.Dv MAP_GUARD
-was specified together with one of the flags
-.Dv MAP_ANON ,
-.Dv MAP_PREFAULT ,
-.Dv MAP_PREFAULT_READ ,
-.Dv MAP_PRIVATE ,
-.Dv MAP_SHARED ,
-.Dv MAP_STACK .
-.It Bq Er ENODEV
-.Dv MAP_ANON
-has not been specified and
-.Fa fd
-did not reference a regular or character special file.
-.It Bq Er ENOMEM
-.Dv MAP_FIXED
-was specified and the
-.Fa addr
-argument was not available.
-.Dv MAP_ANON
-was specified and insufficient memory was available.
-.It Bq Er ENOTSUP
-The
-.Fa prot
-argument contains protections which are not a subset of the specified
-maximum protections.
-.El
-.Sh SEE ALSO
-.Xr madvise 2 ,
-.Xr mincore 2 ,
-.Xr minherit 2 ,
-.Xr mlock 2 ,
-.Xr mprotect 2 ,
-.Xr msync 2 ,
-.Xr munlock 2 ,
-.Xr munmap 2 ,
-.Xr getpagesize 3 ,
-.Xr getpagesizes 3
-.Sh HISTORY
-The
-.Nm
-system call was first documented in
-.Bx 4.2
-and implemented in
-.Bx 4.4 .
-.\" XXX: lots of missing history of FreeBSD additions.
-.Pp
-The
-.Dv PROT_MAX
-functionality was introduced in
-.Fx 13 .
diff --git a/lib/libc/sys/mount.2 b/lib/libc/sys/mount.2
deleted file mode 100644
index f8e11c386363..000000000000
--- a/lib/libc/sys/mount.2
+++ /dev/null
@@ -1,402 +0,0 @@
-.\" Copyright (c) 1980, 1989, 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.
-.\"
-.\" @(#)mount.2 8.3 (Berkeley) 5/24/95
-.\"
-.Dd March 30, 2020
-.Dt MOUNT 2
-.Os
-.Sh NAME
-.Nm mount ,
-.Nm nmount ,
-.Nm unmount
-.Nd mount or dismount a file system
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/mount.h
-.Ft int
-.Fn mount "const char *type" "const char *dir" "int flags" "void *data"
-.Ft int
-.Fn unmount "const char *dir" "int flags"
-.In sys/uio.h
-.Ft int
-.Fn nmount "struct iovec *iov" "u_int niov" "int flags"
-.Sh DESCRIPTION
-The
-.Fn mount
-system call grafts
-a file system object onto the system file tree
-at the point
-.Fa dir .
-The argument
-.Fa data
-describes the file system object to be mounted.
-The argument
-.Fa type
-tells the kernel how to interpret
-.Fa data
-(See
-.Fa type
-below).
-The contents of the file system
-become available through the new mount point
-.Fa dir .
-Any files in
-.Fa dir
-at the time
-of a successful mount are swept under the carpet so to speak, and
-are unavailable until the file system is unmounted.
-.Pp
-The
-.Fn nmount
-system call behaves similarly to
-.Fn mount ,
-except that the mount options (file system type name, device to mount,
-mount-point name, etc.) are passed as an array of name-value pairs
-in the array
-.Fa iov ,
-containing
-.Fa niov
-elements.
-The following options are required by all file systems:
-.Bl -column fstype -offset indent
-.It
-.Li fstype Ta file system type name (e.g., Dq Li procfs )
-.It
-.Li fspath Ta mount point pathname (e.g., Dq Li /proc )
-.El
-.Pp
-Depending on the file system type, other options may be
-recognized or required;
-for example, most disk-based file systems require a
-.Dq Li from
-option containing the pathname of a special device
-in addition to the options listed above.
-.Pp
-By default only the super-user may call the
-.Fn mount
-system call.
-This restriction can be removed by setting the
-.Va vfs.usermount
-.Xr sysctl 8
-variable
-to a non-zero value; see the BUGS section for more information.
-.Pp
-The following
-.Fa flags
-may be specified to
-suppress default semantics which affect file system access.
-.Bl -tag -width MNT_SYNCHRONOUS
-.It Dv MNT_RDONLY
-The file system should be treated as read-only;
-even the super-user may not write on it.
-Specifying MNT_UPDATE without this option will upgrade
-a read-only file system to read/write.
-.It Dv MNT_NOEXEC
-Do not allow files to be executed from the file system.
-.It Dv MNT_NOSUID
-Do not honor setuid or setgid bits on files when executing them.
-This flag is set automatically when the caller is not the super-user.
-.It Dv MNT_NOATIME
-Disable update of file access times.
-.It Dv MNT_SNAPSHOT
-Create a snapshot of the file system.
-This is currently only supported on UFS2 file systems, see
-.Xr mksnap_ffs 8
-for more information.
-.It Dv MNT_SUIDDIR
-Directories with the SUID bit set chown new files to their own owner.
-This flag requires the SUIDDIR option to have been compiled into the kernel
-to have any effect.
-See the
-.Xr mount 8
-and
-.Xr chmod 2
-pages for more information.
-.It Dv MNT_SYNCHRONOUS
-All I/O to the file system should be done synchronously.
-.It Dv MNT_ASYNC
-All I/O to the file system should be done asynchronously.
-.It Dv MNT_FORCE
-Force a read-write mount even if the file system appears to be unclean.
-Dangerous.
-Together with
-.Dv MNT_UPDATE
-and
-.Dv MNT_RDONLY ,
-specify that the file system is to be forcibly downgraded to a read-only
-mount even if some files are open for writing.
-.It Dv MNT_NOCLUSTERR
-Disable read clustering.
-.It Dv MNT_NOCLUSTERW
-Disable write clustering.
-.It Dv MNT_NOCOVER
-Do not mount over the root of another mount point.
-.It Dv MNT_EMPTYDIR
-Require an empty directory for the mount point directory.
-.El
-.Pp
-The flag
-.Dv MNT_UPDATE
-indicates that the mount command is being applied
-to an already mounted file system.
-This allows the mount flags to be changed without requiring
-that the file system be unmounted and remounted.
-Some file systems may not allow all flags to be changed.
-For example,
-many file systems will not allow a change from read-write to read-only.
-.Pp
-The flag
-.Dv MNT_RELOAD
-causes the vfs subsystem to update its data structures pertaining to
-the specified already mounted file system.
-.Pp
-The
-.Fa type
-argument names the file system.
-The types of file systems known to the system can be obtained with
-.Xr lsvfs 1 .
-.Pp
-The
-.Fa data
-argument
-is a pointer to a structure that contains the type
-specific arguments to mount.
-The format for these argument structures is described in the
-manual page for each file system.
-By convention file system manual pages are named
-by prefixing ``mount_'' to the name of the file system as returned by
-.Xr lsvfs 1 .
-Thus the
-.Tn NFS
-file system is described by the
-.Xr mount_nfs 8
-manual page.
-It should be noted that a manual page for default
-file systems, known as UFS and UFS2, does not exist.
-.Pp
-The
-.Fn unmount
-system call disassociates the file system from the specified
-mount point
-.Fa dir .
-.Pp
-The
-.Fa flags
-argument may include
-.Dv MNT_FORCE
-to specify that the file system should be forcibly unmounted
-even if files are still active.
-Active special devices continue to work,
-but any further accesses to any other active files result in errors
-even if the file system is later remounted.
-.Pp
-If the
-.Dv MNT_BYFSID
-flag is specified,
-.Fa dir
-should instead be a file system ID encoded as
-.Dq Li FSID : Ns Ar val0 : Ns Ar val1 ,
-where
-.Ar val0
-and
-.Ar val1
-are the contents of the
-.Vt fsid_t
-.Va val[]
-array in decimal.
-The file system that has the specified file system ID will be unmounted.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn mount
-and
-.Fn nmount
-system calls will fail when one of the following occurs:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller is neither the super-user nor the owner of
-.Fa dir .
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or the entire length of a path name exceeded 1023 characters.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating a pathname.
-.It Bq Er ENOENT
-A component of
-.Fa dir
-does not exist.
-.It Bq Er ENOTDIR
-A component of
-.Fa name
-is not a directory,
-or a path prefix of
-.Fa special
-is not a directory.
-.It Bq Er EBUSY
-Another process currently holds a reference to
-.Fa dir .
-.It Bq Er EBUSY
-The
-.Dv MNT_NOCOVER
-option was given, and the requested mount point
-is already the root of another mount point.
-.It Bq Er EFAULT
-The
-.Fa dir
-argument
-points outside the process's allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading data from
-.Fa special .
-.It Bq Er EINTEGRITY
-The backing store for
-.Fa special
-detected corrupted data while reading.
-.El
-.Pp
-The following errors can occur for a
-.Em ufs
-file system mount:
-.Bl -tag -width Er
-.It Bq Er ENODEV
-A component of ufs_args
-.Fa fspec
-does not exist.
-.It Bq Er ENOTBLK
-The
-.Fa fspec
-argument
-is not a block device.
-.It Bq Er ENOTEMPTY
-The
-.Dv MNT_EMPTYDIR
-option was specified, and the requested mount point
-is not an empty directory.
-.It Bq Er ENXIO
-The major device number of
-.Fa fspec
-is out of range (this indicates no device driver exists
-for the associated hardware).
-.It Bq Er EBUSY
-.Fa fspec
-is already mounted.
-.It Bq Er EMFILE
-No space remains in the mount table.
-.It Bq Er EINVAL
-The super block for the file system had a bad magic
-number or an out of range block size.
-.It Bq Er EINTEGRITY
-The super block for the file system had a bad check hash.
-The check hash can usually be corrected by running
-.Xr fsck 8 .
-.It Bq Er ENOMEM
-Not enough memory was available to read the cylinder
-group information for the file system.
-.It Bq Er EIO
-An I/O error occurred while reading the super block or
-cylinder group information.
-.It Bq Er EFAULT
-The
-.Fa fspec
-argument
-points outside the process's allocated address space.
-.El
-.Pp
-The following errors can occur for a
-.Em nfs
-file system mount:
-.Bl -tag -width Er
-.It Bq Er ETIMEDOUT
-.Em Nfs
-timed out trying to contact the server.
-.It Bq Er EFAULT
-Some part of the information described by nfs_args
-points outside the process's allocated address space.
-.El
-.Pp
-The
-.Fn unmount
-system call may fail with one of the following errors:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller is neither the super-user nor the user who issued the corresponding
-.Fn mount
-call.
-.It Bq Er ENAMETOOLONG
-The length of the path name exceeded 1023 characters.
-.It Bq Er EINVAL
-The requested directory is not in the mount table.
-.It Bq Er ENOENT
-The file system ID specified using
-.Dv MNT_BYFSID
-was not found in the mount table.
-.It Bq Er EINVAL
-The file system ID specified using
-.Dv MNT_BYFSID
-could not be decoded.
-.It Bq Er EINVAL
-The specified file system is the root file system.
-.It Bq Er EBUSY
-A process is holding a reference to a file located
-on the file system.
-.It Bq Er EIO
-An I/O error occurred while writing cached file system information.
-.It Bq Er EFAULT
-The
-.Fa dir
-argument
-points outside the process's allocated address space.
-.El
-.Sh SEE ALSO
-.Xr lsvfs 1 ,
-.Xr mksnap_ffs 8 ,
-.Xr mount 8 ,
-.Xr umount 8
-.Sh HISTORY
-The
-.Fn mount
-and
-.Fn unmount
-functions appeared in
-.At v1 .
-The
-.Fn nmount
-system call first appeared in
-.Fx 5.0 .
-.Sh BUGS
-Some of the error codes need translation to more obvious messages.
-.Pp
-Allowing untrusted users to mount arbitrary media, e.g. by enabling
-.Va vfs.usermount ,
-should not be considered safe.
-Most file systems in
-.Fx
-were not built to safeguard against malicious devices.
diff --git a/lib/libc/sys/mprotect.2 b/lib/libc/sys/mprotect.2
deleted file mode 100644
index 1521b311b90f..000000000000
--- a/lib/libc/sys/mprotect.2
+++ /dev/null
@@ -1,130 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)mprotect.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd September 7, 2021
-.Dt MPROTECT 2
-.Os
-.Sh NAME
-.Nm mprotect
-.Nd control the protection of pages
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn mprotect "void *addr" "size_t len" "int prot"
-.Sh DESCRIPTION
-The
-.Fn mprotect
-system call
-changes the specified pages to have protection
-.Fa prot .
-.Pp
-The
-.Fa prot
-argument shall be
-.Dv PROT_NONE
-(no permissions at all)
-or the bitwise
-.Em or
-of one or more of the following values:
-.Pp
-.Bl -tag -width ".Dv PROT_WRITE" -compact
-.It Dv PROT_READ
-The pages can be read.
-.It Dv PROT_WRITE
-The pages can be written.
-.It Dv PROT_EXEC
-The pages can be executed.
-.El
-.Pp
-In addition to these standard protection flags,
-the
-.Fx
-implementation of
-.Fn mprotect
-provides the ability to set the maximum protection of a region
-(which prevents
-.Nm
-from adding to the permissions later).
-This is accomplished by bitwise
-.Em or Ns 'ing
-one or more
-.Dv PROT_
-values wrapped in the
-.Dv PROT_MAX()
-macro into the
-.Fa prot
-argument.
-.Sh RETURN VALUES
-.Rv -std mprotect
-.Sh ERRORS
-The
-.Fn mprotect
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-The calling process was not allowed to change
-the protection to the value specified by
-the
-.Fa prot
-argument.
-.It Bq Er EINVAL
-The virtual address range specified by the
-.Fa addr
-and
-.Fa len
-arguments is not valid.
-.It Bq Er EINVAL
-The
-.Fa prot
-argument contains unhandled bits.
-.It Bq Er ENOTSUP
-The
-.Fa prot
-argument contains permissions which are not a subset of the specified
-maximum permissions.
-.El
-.Sh SEE ALSO
-.Xr madvise 2 ,
-.Xr mincore 2 ,
-.Xr msync 2 ,
-.Xr munmap 2
-.Sh HISTORY
-The
-.Fn mprotect
-system call was first documented in
-.Bx 4.2
-and first appeared in
-.Bx 4.4 .
-.Pp
-The
-.Dv PROT_MAX
-functionality was introduced in
-.Fx 13 .
diff --git a/lib/libc/sys/mq_open.2 b/lib/libc/sys/mq_open.2
deleted file mode 100644
index e5e7808c9e26..000000000000
--- a/lib/libc/sys/mq_open.2
+++ /dev/null
@@ -1,332 +0,0 @@
-.\" Copyright (c) 2005 David Xu <davidxu@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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" Portions of this text are reprinted and reproduced in electronic form
-.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
-.\" Portable Operating System Interface (POSIX), The Open Group Base
-.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
-.\" Electrical and Electronics Engineers, Inc and The Open Group. In the
-.\" event of any discrepancy between this version and the original IEEE and
-.\" The Open Group Standard, the original IEEE and The Open Group Standard is
-.\" the referee document. The original Standard can be obtained online at
-.\" http://www.opengroup.org/unix/online.html.
-.\"
-.Dd September 28, 2019
-.Dt MQ_OPEN 2
-.Os
-.Sh NAME
-.Nm mq_open
-.Nd "open a message queue (REALTIME)"
-.Sh LIBRARY
-.Lb librt
-.Sh SYNOPSIS
-.In mqueue.h
-.Ft mqd_t
-.Fn mq_open "const char *name" "int oflag" "..."
-.Sh DESCRIPTION
-The
-.Fn mq_open
-system call establishes the connection between a process and a message queue
-with a message queue descriptor.
-It creates an open message queue
-description that refers to the message queue, and a message queue descriptor
-that refers to that open message queue description.
-The message queue
-descriptor is used by other functions to refer to that message queue.
-The
-.Fa name
-argument points to a string naming a message queue.
-The
-.Fa name
-argument should conform to the construction rules for a pathname.
-The
-.Fa name
-should begin with a slash character.
-Processes calling
-.Fn mq_open
-with the same value of
-.Fa name
-refers to the same message queue object, as long as that name has not been
-removed.
-If the
-.Fa name
-argument is not the name of an existing message queue and creation is not
-requested,
-.Fn mq_open
-will fail and return an error.
-.Pp
-The
-.Fa oflag
-argument requests the desired receive and/or send access to the message
-queue.
-The requested access permission to receive messages or send messages
-would be granted if the calling process would be granted read or write access,
-respectively, to an equivalently protected file.
-.Pp
-The value of
-.Fa oflag
-is the bitwise-inclusive OR of values from the following list.
-Applications should specify exactly one of the first three values (access
-modes) below in the value of
-.Fa oflag :
-.Bl -tag -width ".Dv O_NONBLOCK"
-.It Dv O_RDONLY
-Open the message queue for receiving messages.
-The process can use the
-returned message queue descriptor with
-.Fn mq_receive ,
-but not
-.Fn mq_send .
-A message queue may be open multiple times in the same or different processes
-for receiving messages.
-.It Dv O_WRONLY
-Open the queue for sending messages.
-The process can use the returned
-message queue descriptor with
-.Fn mq_send
-but not
-.Fn mq_receive .
-A message queue may be open multiple times in the same or different processes
-for sending messages.
-.It Dv O_RDWR
-Open the queue for both receiving and sending messages.
-The process can use
-any of the functions allowed for
-.Dv O_RDONLY
-and
-.Dv O_WRONLY .
-A message queue may be open multiple times in the same or different processes
-for sending messages.
-.El
-.Pp
-Any combination of the remaining flags may be specified in the value of
-.Fa oflag :
-.Bl -tag -width ".Dv O_NONBLOCK"
-.It Dv O_CREAT
-Create a message queue.
-It requires two additional arguments:
-.Fa mode ,
-which is of type
-.Vt mode_t ,
-and
-.Fa attr ,
-which is a pointer to an
-.Vt mq_attr
-structure.
-If the pathname
-.Fa name
-has already been used to create a message queue that still exists, then
-this flag has no effect, except as noted under
-.Dv O_EXCL .
-Otherwise, a message queue will be created without any messages
-in it.
-The user ID of the message queue will be set to the effective user ID
-of the process, and the group ID of the message queue will be set to the
-effective group ID of the process.
-The permission bits of the message queue
-will be set to the value of the
-.Fa mode
-argument, except those set in the file mode creation mask of the process.
-When bits in
-.Fa mode
-other than the file permission bits are specified, the effect is
-unspecified.
-If
-.Fa attr
-is
-.Dv NULL ,
-the message queue is created with implementation-defined default message
-queue attributes.
-If attr is
-.Pf non- Dv NULL
-and the calling process has the
-appropriate privilege on name, the message queue
-.Va mq_maxmsg
-and
-.Va mq_msgsize
-attributes will be set to the values of the corresponding members in the
-.Vt mq_attr
-structure referred to by
-.Fa attr .
-If
-.Fa attr
-is
-.Pf non- Dv NULL ,
-but the calling process does not have the appropriate privilege
-on name, the
-.Fn mq_open
-function will fail and return an error without creating the message queue.
-.It Dv O_EXCL
-If
-.Dv O_EXCL
-and
-.Dv O_CREAT
-are set,
-.Fn mq_open
-will fail if the message queue name exists.
-.It Dv O_NONBLOCK
-Determines whether an
-.Fn mq_send
-or
-.Fn mq_receive
-waits for resources or messages that are not currently available, or fails
-with
-.Va errno
-set to
-.Er EAGAIN ;
-see
-.Xr mq_send 2
-and
-.Xr mq_receive 2
-for details.
-.El
-.Pp
-The
-.Fn mq_open
-system call does not add or remove messages from the queue.
-.Sh NOTES
-.Fx
-implements message queue based on file descriptor.
-The descriptor
-is inherited by child after
-.Xr fork 2 .
-The descriptor is closed in a new image after
-.Xr exec 3 .
-The
-.Xr select 2
-and
-.Xr kevent 2
-system calls are supported for message queue descriptor.
-.Pp
-Please see the
-.Xr mqueuefs 5
-man page for instructions on loading the module or compiling the service into
-the kernel.
-.Sh RETURN VALUES
-Upon successful completion, the function returns a message queue
-descriptor; otherwise, the function returns
-.Po Vt mqd_t Pc Ns \-1
-and sets the global variable
-.Va errno
-to indicate the error.
-.Sh ERRORS
-The
-.Fn mq_open
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-The message queue exists and the permissions specified by
-.Fa oflag
-are denied, or the message queue does not exist and permission to create the
-message queue is denied.
-.It Bq Er EEXIST
-.Dv O_CREAT
-and
-.Dv O_EXCL
-are set and the named message queue already exists.
-.It Bq Er EINTR
-The
-.Fn mq_open
-function was interrupted by a signal.
-.It Bq Er EINVAL
-The
-.Fn mq_open
-function is not supported for the given name.
-.It Bq Er EINVAL
-.Dv O_CREAT
-was specified in
-.Fa oflag ,
-the value of
-.Fa attr
-is not
-.Dv NULL ,
-and either
-.Va mq_maxmsg
-or
-.Va mq_msgsize
-was less than or equal to zero.
-.It Bq Er EMFILE
-Too many message queue descriptors or file descriptors are currently in use
-by this process.
-.It Bq Er ENAMETOOLONG
-The length of the
-.Fa name
-argument exceeds
-.Brq Dv PATH_MAX
-or a pathname component
-is longer than
-.Brq Dv NAME_MAX .
-.It Bq Er ENFILE
-Too many message queues are currently open in the system.
-.It Bq Er ENOENT
-.Dv O_CREAT
-is not set and the named message queue does not exist.
-.It Bq Er ENOSPC
-There is insufficient space for the creation of the new message queue.
-.El
-.Sh SEE ALSO
-.Xr mq_close 2 ,
-.Xr mq_getattr 2 ,
-.Xr mq_receive 2 ,
-.Xr mq_send 2 ,
-.Xr mq_setattr 2 ,
-.Xr mq_unlink 2 ,
-.Xr mq_timedreceive 3 ,
-.Xr mq_timedsend 3 ,
-.Xr mqueuefs 5
-.Sh STANDARDS
-The
-.Fn mq_open
-system call conforms to
-.St -p1003.1-2004 .
-.Sh HISTORY
-Support for POSIX message queues first appeared in
-.Fx 7.0 .
-.Sh BUGS
-This implementation places strict requirements on the value of
-.Fa name :
-it must begin with a slash
-.Pq Ql /
-and contain no other slash characters.
-.Pp
-The
-.Fa mode
-and
-.Fa attr
-arguments are variadic and may result in different calling conventions
-than might otherwise be expected.
-.Sh COPYRIGHT
-Portions of this text are reprinted and reproduced in electronic form
-from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
-Portable Operating System Interface (POSIX), The Open Group Base
-Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
-Electrical and Electronics Engineers, Inc and The Open Group. In the
-event of any discrepancy between this version and the original IEEE and
-The Open Group Standard, the original IEEE and The Open Group Standard is
-the referee document. The original Standard can be obtained online at
-http://www.opengroup.org/unix/online.html.
diff --git a/lib/libc/sys/mq_unlink.2 b/lib/libc/sys/mq_unlink.2
deleted file mode 100644
index 07f0364abe00..000000000000
--- a/lib/libc/sys/mq_unlink.2
+++ /dev/null
@@ -1,119 +0,0 @@
-.\" Copyright (c) 2021 Fernando Apesteguia <fernape@FreeBSD.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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" Portions of this text are reprinted and reproduced in electronic form
-.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
-.\" Portable Operating System Interface (POSIX), The Open Group Base
-.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
-.\" Electrical and Electronics Engineers, Inc and The Open Group. In the
-.\" event of any discrepancy between this version and the original IEEE and
-.\" The Open Group Standard, the original IEEE and The Open Group Standard is
-.\" the referee document. The original Standard can be obtained online at
-.\" http://www.opengroup.org/unix/online.html.
-.\"
-.Dd February 15, 2021
-.Dt MQ_UNLINK 2
-.Os
-.Sh NAME
-.Nm mq_unlink
-.Nd "mq_unlink - remove a message queue (REALTIME)"
-.Sh LIBRARY
-.Lb librt
-.Sh SYNOPSIS
-.In mqueue.h
-.Ft int
-.Fn mq_unlink "const char *name"
-.Sh DESCRIPTION
-The
-.Fn mq_unlink
-function removes the message queue named by the string
-.Fa name .
-If one or more processes have the message queue open when
-.Fn mq_unlink
-is called, destruction of the message queue will be postponed
-until all references to the message queue have been closed.
-However, the
-.Fn mq_unlink
-call need not block until all references have been closed; it may return
-immediately.
-.Pp
-After a successful call to
-.Fn mq_unlink ,
-reuse of the name will subsequently cause
-.Xr mq_open 2
-to behave as if no message queue of this name exists.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn mq_unlink
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCESS
-Permission is denied to unlink the message queue represented by
-.Fa name .
-.It Bq Er EINVAL
-.Fa name
-is invalid.
-.It Bq Er ENAMETOOLONG
-The length of the
-.Fa name
-argument exceeds
-.Brq Dv PATH_MAX
-or
-a pathname component is longer than
-.Brq Dv NAME_MAX .
-.It Bq Er ENOENT
-The message queue does not exist.
-.It Bq Er ENOSYS
-.Xr mqueuefs 5
-module is neither loaded nor included in the kernel.
-.El
-.Sh SEE ALSO
-.Xr mq_open 2
-.Sh STANDARDS
-The
-.Fn mq_unlink
-system call conforms to
-.St -p1003.1-2004 .
-The
-.Bq Er EACCESS
-error code is an extension to the standard.
-.Sh HISTORY
-Support for POSIX message queues first appeared in
-.Fx 7.0 .
-.Sh COPYRIGHT
-Portions of this text are reprinted and reproduced in electronic form
-from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
-Portable Operating System Interface (POSIX), The Open Group Base
-Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
-Electrical and Electronics Engineers, Inc and The Open Group.
-In the event of any discrepancy between this version and the original IEEE and
-The Open Group Standard, the original IEEE and The Open Group Standard is
-the referee document.
-The original Standard can be obtained online at
-http://www.opengroup.org/unix/online.html.
diff --git a/lib/libc/sys/msync.2 b/lib/libc/sys/msync.2
deleted file mode 100644
index 6b9ba2bb7cef..000000000000
--- a/lib/libc/sys/msync.2
+++ /dev/null
@@ -1,125 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)msync.2 8.2 (Berkeley) 6/21/94
-.\"
-.Dd March 18, 2012
-.Dt MSYNC 2
-.Os
-.Sh NAME
-.Nm msync
-.Nd synchronize a mapped region
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn msync "void *addr" "size_t len" "int flags"
-.Sh DESCRIPTION
-The
-.Fn msync
-system call
-writes any modified pages back to the file system and updates
-the file modification time.
-If
-.Fa len
-is 0, all modified pages within the region containing
-.Fa addr
-will be flushed;
-if
-.Fa len
-is non-zero, only those pages containing
-.Fa addr
-and
-.Fa len-1
-succeeding locations will be examined.
-The
-.Fa flags
-argument may be specified as follows:
-.Pp
-.Bl -tag -width ".Dv MS_INVALIDATE" -compact
-.It Dv MS_ASYNC
-Return immediately
-.It Dv MS_SYNC
-Perform synchronous writes
-.It Dv MS_INVALIDATE
-Invalidate all cached data
-.El
-.Sh RETURN VALUES
-.Rv -std msync
-.Sh ERRORS
-The
-.Fn msync
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-Some or all of the pages in the specified region are locked and
-.Dv MS_INVALIDATE
-is specified.
-.It Bq Er EINVAL
-The
-.Fa addr
-argument
-is not a multiple of the hardware page size.
-.It Bq Er ENOMEM
-The addresses in the range starting at
-.Fa addr
-and continuing for
-.Fa len
-bytes are outside the range allowed for the address space of a
-process or specify one or more pages that are not mapped.
-.It Bq Er EINVAL
-The
-.Fa flags
-argument
-was both MS_ASYNC and MS_INVALIDATE.
-Only one of these flags is allowed.
-.It Bq Er EIO
-An error occurred while writing at least one of the pages in
-the specified region.
-.El
-.Sh SEE ALSO
-.Xr madvise 2 ,
-.Xr mincore 2 ,
-.Xr mlock 2 ,
-.Xr mprotect 2 ,
-.Xr munmap 2
-.Sh HISTORY
-The
-.Fn msync
-system call first appeared in
-.Bx 4.4 .
-.Sh BUGS
-The
-.Fn msync
-system call is usually not needed since
-.Bx
-implements a coherent file system buffer cache.
-However, it may be used to associate dirty VM pages with file system
-buffers and thus cause them to be flushed to physical media sooner
-rather than later.
diff --git a/lib/libc/sys/msync.c b/lib/libc/sys/msync.c
index 96b0e778d115..f825db97b947 100644
--- a/lib/libc/sys/msync.c
+++ b/lib/libc/sys/msync.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/mman.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_msync, __msync);
int
msync(void *addr, size_t len, int flags)
{
-
- return (((int (*)(void *, size_t, int))
- __libc_interposing[INTERPOS_msync])(addr, len, flags));
+ return (INTERPOS_SYS(msync, addr, len, flags));
}
diff --git a/lib/libc/sys/munmap.2 b/lib/libc/sys/munmap.2
deleted file mode 100644
index 8f5cb0c02e2b..000000000000
--- a/lib/libc/sys/munmap.2
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)munmap.2 8.3 (Berkeley) 5/27/94
-.\"
-.Dd June 22, 2017
-.Dt MUNMAP 2
-.Os
-.Sh NAME
-.Nm munmap
-.Nd remove a mapping
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/mman.h
-.Ft int
-.Fn munmap "void *addr" "size_t len"
-.Sh DESCRIPTION
-The
-.Fn munmap
-system call
-deletes the mappings and guards for the specified address range,
-and causes further references to addresses within the range
-to generate invalid memory references.
-.Sh RETURN VALUES
-.Rv -std munmap
-.Sh ERRORS
-The
-.Fn munmap
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa addr
-argument was not page aligned, the
-.Fa len
-argument was zero or negative, or
-some part of the region being unmapped is outside the
-valid address range for a process.
-.El
-.Sh "SEE ALSO"
-.Xr madvise 2 ,
-.Xr mincore 2 ,
-.Xr mmap 2 ,
-.Xr mprotect 2 ,
-.Xr msync 2 ,
-.Xr getpagesize 3
-.Sh HISTORY
-The
-.Fn munmap
-system call first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/sys/nanosleep.2 b/lib/libc/sys/nanosleep.2
deleted file mode 100644
index 1a59b18372fa..000000000000
--- a/lib/libc/sys/nanosleep.2
+++ /dev/null
@@ -1,221 +0,0 @@
-.\" $NetBSD: nanosleep.2,v 1.23 2016/11/14 10:40:59 wiz Exp $
-.\"
-.\" Copyright (c) 1986, 1991, 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.
-.\"
-.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd April 3, 2022
-.Dt NANOSLEEP 2
-.Os
-.Sh NAME
-.Nm nanosleep
-.Nd high resolution sleep
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In time.h
-.Ft int
-.Fo clock_nanosleep
-.Fa "clockid_t clock_id"
-.Fa "int flags"
-.Fa "const struct timespec *rqtp"
-.Fa "struct timespec *rmtp"
-.Fc
-.Ft int
-.Fo nanosleep
-.Fa "const struct timespec *rqtp"
-.Fa "struct timespec *rmtp"
-.Fc
-.Sh DESCRIPTION
-If the
-.Dv TIMER_ABSTIME
-flag is not set in the
-.Fa flags
-argument, then
-.Fn clock_nanosleep
-suspends execution of the calling thread until either the
-time interval specified by the
-.Fa rqtp
-argument has elapsed,
-or a signal is delivered to the calling process and its
-action is to invoke a signal-catching function or to terminate the
-process.
-The clock used to measure the time is specified by the
-.Fa clock_id
-argument.
-.Pp
-If the
-.Dv TIMER_ABSTIME
-flag is set in the
-.Fa flags
-argument, then
-.Fn clock_nanosleep
-suspends execution of the calling thread until either the value
-of the clock specified by the
-.Fa clock_id
-argument reaches the absolute time specified by the
-.Fa rqtp
-argument,
-or a signal is delivered to the calling process and its
-action is to invoke a signal-catching function or to terminate the
-process.
-If, at the time of the call, the time value specified by
-.Fa rqtp
-is less than or equal to the time value of the specified clock, then
-.Fn clock_nanosleep
-returns immediately and the calling thread is not suspended.
-.Pp
-The suspension time may be longer than requested due to the
-scheduling of other activity by the system.
-It is also subject to the allowed time interval deviation
-specified by the
-.Va kern.timecounter.alloweddeviation
-.Xr sysctl 8
-variable.
-An unmasked signal will terminate the sleep early, regardless of the
-.Dv SA_RESTART
-value on the interrupting signal.
-The
-.Fa rqtp
-and
-.Fa rmtp
-arguments can point to the same object.
-.Pp
-The following
-.Fa clock_id
-values are supported:
-.Pp
-.Bl -item -compact -offset indent
-.It
-CLOCK_MONOTONIC
-.It
-CLOCK_MONOTONIC_FAST
-.It
-CLOCK_MONOTONIC_PRECISE
-.It
-CLOCK_REALTIME
-.It
-CLOCK_REALTIME_FAST
-.It
-CLOCK_REALTIME_PRECISE
-.It
-CLOCK_SECOND
-.It
-CLOCK_UPTIME
-.It
-CLOCK_UPTIME_FAST
-.It
-CLOCK_UPTIME_PRECISE
-.El
-.Pp
-The
-.Fn nanosleep
-function behaves like
-.Fn clock_nanosleep
-with a
-.Fa clock_id
-argument of
-.Dv CLOCK_REALTIME
-and without the
-.Dv TIMER_ABSTIME
-flag in the
-.Fa flags
-argument.
-.Sh RETURN VALUES
-These functions return zero when the requested time has elapsed.
-.Pp
-If these functions return for any other reason, then
-.Fn clock_nanosleep
-will directly return the error number, and
-.Fn nanosleep
-will return \-1 with the global variable
-.Va errno
-set to indicate the error.
-If a relative sleep is interrupted by a signal and
-.Fa rmtp
-is
-.Pf non- Dv NULL ,
-the timespec structure it references is updated to contain the
-unslept amount (the request time minus the time actually slept).
-.Sh ERRORS
-These functions can fail with the following errors.
-.Bl -tag -width Er
-.It Bq Er EFAULT
-Either
-.Fa rqtp
-or
-.Fa rmtp
-points to memory that is not a valid part of the process
-address space.
-.It Bq Er EINTR
-The function was interrupted by the delivery of a signal.
-.It Bq Er EINVAL
-The
-.Fa rqtp
-argument specified a nanosecond value less than zero
-or greater than or equal to 1000 million.
-.It Bq Er EINVAL
-The
-.Fa flags
-argument contained an invalid flag.
-.It Bq Er EINVAL
-The
-.Fa clock_id
-argument was
-.Dv CLOCK_THREAD_CPUTIME_ID
-or an unrecognized value.
-.It Bq Er ENOTSUP
-The
-.Fa clock_id
-argument was valid but not supported by this implementation of
-.Fn clock_nanosleep .
-.El
-.Sh SEE ALSO
-.Xr clock_gettime 2 ,
-.Xr sigaction 2 ,
-.Xr sleep 3
-.Sh STANDARDS
-These functions conform to
-.St -p1003.1-2008 .
-.Sh HISTORY
-The predecessor of this system call,
-.Fn sleep ,
-appeared in
-.At v3 ,
-but was removed when
-.Xr alarm 3
-was introduced into
-.At v7 .
-The
-.Fn nanosleep
-system call has been available since
-.Nx 1.3
-and was ported to
-.Ox 2.1
-and
-.Fx 3.0 .
diff --git a/lib/libc/sys/nanosleep.c b/lib/libc/sys/nanosleep.c
index 076ee33e44ea..bd0794c3af8e 100644
--- a/lib/libc/sys/nanosleep.c
+++ b/lib/libc/sys/nanosleep.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <time.h>
#include "libc_private.h"
@@ -40,7 +39,5 @@ __weak_reference(__sys_nanosleep, __nanosleep);
int
nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
-
- return (((int (*)(const struct timespec *, struct timespec *))
- __libc_interposing[INTERPOS_nanosleep])(rqtp, rmtp));
+ return (INTERPOS_SYS(nanosleep, rqtp, rmtp));
}
diff --git a/lib/libc/sys/nfssvc.2 b/lib/libc/sys/nfssvc.2
deleted file mode 100644
index 80813629d82b..000000000000
--- a/lib/libc/sys/nfssvc.2
+++ /dev/null
@@ -1,257 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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.
-.\"
-.\" @(#)nfssvc.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd June 9, 1993
-.Dt NFSSVC 2
-.Os
-.Sh NAME
-.Nm nfssvc
-.Nd NFS services
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/mount.h
-.In sys/time.h
-.In nfs/rpcv2.h
-.In nfsserver/nfs.h
-.In unistd.h
-.Ft int
-.Fn nfssvc "int flags" "void *argstructp"
-.Sh DESCRIPTION
-The
-.Fn nfssvc
-system call is used by the NFS daemons to pass information into and out
-of the kernel and also to enter the kernel as a server daemon.
-The
-.Fa flags
-argument consists of several bits that show what action is to be taken
-once in the kernel and the
-.Fa argstructp
-points to one of three structures depending on which bits are set in
-flags.
-.Pp
-On the client side,
-.Xr nfsiod 8
-calls
-.Fn nfssvc
-with the
-.Fa flags
-argument set to
-.Dv NFSSVC_BIOD
-and
-.Fa argstructp
-set to
-.Dv NULL
-to enter the kernel as a block I/O server daemon.
-For
-.Tn NQNFS ,
-.Xr mount_nfs 8
-calls
-.Fn nfssvc
-with the
-.Dv NFSSVC_MNTD
-flag, optionally or'd with the flags
-.Dv NFSSVC_GOTAUTH
-and
-.Dv NFSSVC_AUTHINFAIL
-along with a pointer to a
-.Bd -literal
-struct nfsd_cargs {
- char *ncd_dirp; /* Mount dir path */
- uid_t ncd_authuid; /* Effective uid */
- int ncd_authtype; /* Type of authenticator */
- int ncd_authlen; /* Length of authenticator string */
- u_char *ncd_authstr; /* Authenticator string */
- int ncd_verflen; /* and the verifier */
- u_char *ncd_verfstr;
- NFSKERBKEY_T ncd_key; /* Session key */
-};
-.Ed
-.Pp
-structure.
-The initial call has only the
-.Dv NFSSVC_MNTD
-flag set to specify service for the mount point.
-If the mount point is using Kerberos, then the
-.Xr mount_nfs 8
-utility will return from
-.Fn nfssvc
-with
-.Va errno
-==
-.Er ENEEDAUTH
-whenever the client side requires an ``rcmd''
-authentication ticket for the user.
-The
-.Xr mount_nfs 8
-utility will attempt to get the Kerberos ticket, and if successful will call
-.Fn nfssvc
-with the flags
-.Dv NFSSVC_MNTD
-and
-.Dv NFSSVC_GOTAUTH
-after filling the ticket into the
-ncd_authstr field
-and
-setting the ncd_authlen and ncd_authtype
-fields of the nfsd_cargs structure.
-If
-.Xr mount_nfs 8
-failed to get the ticket,
-.Fn nfssvc
-will be called with the flags
-.Dv NFSSVC_MNTD ,
-.Dv NFSSVC_GOTAUTH
-and
-.Dv NFSSVC_AUTHINFAIL
-to denote a failed authentication attempt.
-.Pp
-On the server side,
-.Fn nfssvc
-is called with the flag
-.Dv NFSSVC_NFSD
-and a pointer to a
-.Bd -literal
-struct nfsd_srvargs {
- struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
- uid_t nsd_uid; /* Effective uid mapped to cred */
- uint32_t nsd_haddr; /* Ip address of client */
- struct ucred nsd_cr; /* Cred. uid maps to */
- int nsd_authlen; /* Length of auth string (ret) */
- u_char *nsd_authstr; /* Auth string (ret) */
- int nsd_verflen; /* and the verifier */
- u_char *nsd_verfstr;
- struct timeval nsd_timestamp; /* timestamp from verifier */
- uint32_t nsd_ttl; /* credential ttl (sec) */
- NFSKERBKEY_T nsd_key; /* Session key */
-};
-.Ed
-.Pp
-to enter the kernel as an
-.Xr nfsd 8
-daemon.
-Whenever an
-.Xr nfsd 8
-daemon receives a Kerberos authentication ticket, it will return from
-.Fn nfssvc
-with
-.Va errno
-==
-.Er ENEEDAUTH .
-The
-.Xr nfsd 8
-utility will attempt to authenticate the ticket and generate a set of credentials
-on the server for the ``user id'' specified in the field nsd_uid.
-This is done by first authenticating the Kerberos ticket and then mapping
-the Kerberos principal to a local name and getting a set of credentials for
-that user via
-.Xr getpwnam 3
-and
-.Xr getgrouplist 3 .
-If successful, the
-.Xr nfsd 8
-utility will call
-.Fn nfssvc
-with the
-.Dv NFSSVC_NFSD
-and
-.Dv NFSSVC_AUTHIN
-flags set to pass the credential mapping in nsd_cr into the
-kernel to be cached on the server socket for that client.
-If the authentication failed,
-.Xr nfsd 8
-calls
-.Fn nfssvc
-with the flags
-.Dv NFSSVC_NFSD
-and
-.Dv NFSSVC_AUTHINFAIL
-to denote an authentication failure.
-.Pp
-The master
-.Xr nfsd 8
-server daemon calls
-.Fn nfssvc
-with the flag
-.Dv NFSSVC_ADDSOCK
-and a pointer to a
-.Bd -literal
-struct nfsd_args {
- int sock; /* Socket to serve */
- caddr_t name; /* Client address for connection based sockets */
- int namelen;/* Length of name */
-};
-.Ed
-.Pp
-to pass a server side
-.Tn NFS
-socket into the kernel for servicing by the
-.Xr nfsd 8
-daemons.
-.Sh RETURN VALUES
-Normally
-.Fn nfssvc
-does not return unless the server
-is terminated by a signal when a value of 0 is returned.
-Otherwise, -1 is returned and the global variable
-.Va errno
-is set to specify the error.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er ENEEDAUTH
-This special error value
-is really used for authentication support, particularly Kerberos,
-as explained above.
-.It Bq Er EPERM
-The caller is not the super-user.
-.El
-.Sh SEE ALSO
-.Xr mount_nfs 8 ,
-.Xr nfsd 8 ,
-.Xr nfsiod 8
-.Sh HISTORY
-The
-.Fn nfssvc
-system call first appeared in
-.Bx 4.4 .
-.Sh BUGS
-The
-.Fn nfssvc
-system call is designed specifically for the
-.Tn NFS
-support daemons and as such is specific to their requirements.
-It should really return values to indicate the need for authentication
-support, since
-.Er ENEEDAUTH
-is not really an error.
-Several fields of the argument structures are assumed to be valid and
-sometimes to be unchanged from a previous call, such that
-.Fn nfssvc
-must be used with extreme care.
diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
deleted file mode 100644
index ff0441d64507..000000000000
--- a/lib/libc/sys/open.2
+++ /dev/null
@@ -1,687 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)open.2 8.2 (Berkeley) 11/16/93
-.\"
-.Dd May 29, 2023
-.Dt OPEN 2
-.Os
-.Sh NAME
-.Nm open , openat
-.Nd open or create a file for reading, writing or executing
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In fcntl.h
-.Ft int
-.Fn open "const char *path" "int flags" "..."
-.Ft int
-.Fn openat "int fd" "const char *path" "int flags" "..."
-.Sh DESCRIPTION
-The file name specified by
-.Fa path
-is opened
-for either execution or reading and/or writing as specified by the
-argument
-.Fa flags
-and the file descriptor returned to the calling process.
-The
-.Fa flags
-argument may indicate the file is to be
-created if it does not exist (by specifying the
-.Dv O_CREAT
-flag).
-In this case
-.Fn open
-and
-.Fn openat
-require an additional argument
-.Fa "mode_t mode" ,
-and the file is created with mode
-.Fa mode
-as described in
-.Xr chmod 2
-and modified by the process' umask value (see
-.Xr umask 2 ) .
-.Pp
-The
-.Fn openat
-function is equivalent to the
-.Fn open
-function except in the case where the
-.Fa path
-specifies a relative path.
-For
-.Fn openat
-and relative
-.Fa path ,
-the file to be opened is determined relative to the directory
-associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-The
-.Fa flag
-parameter and the optional fourth parameter correspond exactly to
-the parameters of
-.Fn open .
-If
-.Fn openat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used
-and the behavior is identical to a call to
-.Fn open .
-.Pp
-When
-.Fn openat
-is called with an absolute
-.Fa path ,
-it ignores the
-.Fa fd
-argument.
-.Pp
-In
-.Xr capsicum 4
-capability mode,
-.Fn open
-is not permitted.
-The
-.Fa path
-argument to
-.Fn openat
-must be strictly relative to a file descriptor
-.Fa fd .
-.Fa path
-must not be an absolute path and must not contain ".." components
-which cause the path resolution to escape the directory hierarchy
-starting at
-.Fa fd .
-Additionally, no symbolic link in
-.Fa path
-may target absolute path or contain escaping ".." components.
-.Fa fd
-must not be
-.Dv AT_FDCWD .
-.Pp
-If the
-.Dv vfs.lookup_cap_dotdot
-.Xr sysctl 3
-MIB is set to zero, ".." components in the paths,
-used in capability mode,
-are completely disabled.
-If the
-.Dv vfs.lookup_cap_dotdot_nonlocal
-MIB is set to zero, ".." is not allowed if found on non-local filesystem.
-.Pp
-The flags specified are formed by
-.Em or Ns 'ing
-the following values
-.Pp
-.Bd -literal -offset indent -compact
-O_RDONLY open for reading only
-O_WRONLY open for writing only
-O_RDWR open for reading and writing
-O_EXEC open for execute only
-O_SEARCH open for search only, an alias for O_EXEC
-O_NONBLOCK do not block on open
-O_APPEND append on each write
-O_CREAT create file if it does not exist
-O_TRUNC truncate size to 0
-O_EXCL error if create and file exists
-O_SHLOCK atomically obtain a shared lock
-O_EXLOCK atomically obtain an exclusive lock
-O_DIRECT eliminate or reduce cache effects
-O_FSYNC synchronous writes (historical synonym for O_SYNC)
-O_SYNC synchronous writes
-O_DSYNC synchronous data writes
-O_NOFOLLOW do not follow symlinks
-O_NOCTTY ignored
-O_TTY_INIT ignored
-O_DIRECTORY error if file is not a directory
-O_CLOEXEC set FD_CLOEXEC upon open
-O_VERIFY verify the contents of the file
-O_RESOLVE_BENEATH path resolution must not cross the fd directory
-O_PATH record only the target path in the opened descriptor
-O_EMPTY_PATH openat, open file referenced by fd if path is empty
-.Ed
-.Pp
-Opening a file with
-.Dv O_APPEND
-set causes each write on the file
-to be appended to the end.
-If
-.Dv O_TRUNC
-is specified and the
-file exists, the file is truncated to zero length.
-If
-.Dv O_EXCL
-is set with
-.Dv O_CREAT
-and the file already
-exists,
-.Fn open
-returns an error.
-This may be used to
-implement a simple exclusive access locking mechanism.
-If
-.Dv O_EXCL
-is set and the last component of the pathname is
-a symbolic link,
-.Fn open
-will fail even if the symbolic
-link points to a non-existent name.
-If the
-.Dv O_NONBLOCK
-flag is specified and the
-.Fn open
-system call would result
-in the process being blocked for some reason (e.g., waiting for
-carrier on a dialup line),
-.Fn open
-returns immediately.
-The descriptor remains in non-blocking mode for subsequent operations.
-.Pp
-If
-.Dv O_SYNC
-is used in the mask, all writes will
-immediately and synchronously be written to disk.
-.Dv O_FSYNC
-is an historical synonym for
-.Dv O_SYNC .
-.Pp
-If
-.Dv O_DSYNC
-is used in the mask, all data and metadata required to read the data will be
-synchronously written to disk, but changes to metadata such as file access and
-modification timestamps may be written later.
-.Pp
-If
-.Dv O_NOFOLLOW
-is used in the mask and the target file passed to
-.Fn open
-is a symbolic link then the
-.Fn open
-will fail.
-.Pp
-When opening a file, a lock with
-.Xr flock 2
-semantics can be obtained by setting
-.Dv O_SHLOCK
-for a shared lock, or
-.Dv O_EXLOCK
-for an exclusive lock.
-If creating a file with
-.Dv O_CREAT ,
-the request for the lock will never fail
-(provided that the underlying file system supports locking).
-.Pp
-.Dv O_DIRECT
-may be used to minimize or eliminate the cache effects of reading and writing.
-The system will attempt to avoid caching the data you read or write.
-If it cannot avoid caching the data,
-it will minimize the impact the data has on the cache.
-Use of this flag can drastically reduce performance if not used with care.
-.Pp
-.Dv O_NOCTTY
-may be used to ensure the OS does not assign this file as the
-controlling terminal when it opens a tty device.
-This is the default on
-.Fx ,
-but is present for
-.Tn POSIX
-compatibility.
-The
-.Fn open
-system call will not assign controlling terminals on
-.Fx .
-.Pp
-.Dv O_TTY_INIT
-may be used to ensure the OS restores the terminal attributes when
-initially opening a TTY.
-This is the default on
-.Fx ,
-but is present for
-.Tn POSIX
-compatibility.
-The initial call to
-.Fn open
-on a TTY will always restore default terminal attributes on
-.Fx .
-.Pp
-.Dv O_DIRECTORY
-may be used to ensure the resulting file descriptor refers to a
-directory.
-This flag can be used to prevent applications with elevated privileges
-from opening files which are even unsafe to open with
-.Dv O_RDONLY ,
-such as device nodes.
-.Pp
-.Dv O_CLOEXEC
-may be used to set
-.Dv FD_CLOEXEC
-flag for the newly returned file descriptor.
-.Pp
-.Dv O_VERIFY
-may be used to indicate to the kernel that the contents of the file should
-be verified before allowing the open to proceed.
-The details of what
-.Dq verified
-means is implementation specific.
-The run-time linker (rtld) uses this flag to ensure shared objects have
-been verified before operating on them.
-.Pp
-.Dv O_RESOLVE_BENEATH
-returns
-.Er ENOTCAPABLE
-if any intermediate component of the specified relative path does not
-reside in the directory hierarchy beneath the starting directory.
-Absolute paths or even the temporal escape from beneath of the starting
-directory is not allowed.
-.Pp
-When
-.Fa fd
-is opened with
-.Dv O_SEARCH ,
-execute permissions are checked at open time.
-The
-.Fa fd
-may not be used for any read operations like
-.Xr getdirentries 2 .
-The primary use for this descriptor will be as the lookup descriptor for the
-.Fn *at
-family of functions.
-.Pp
-.Dv O_PATH
-returns a file descriptor that can be used as a directory file descriptor for
-.Xr openat 2
-and other system calls taking a file descriptor argument, like
-.Xr fstatat 2
-and others.
-The other functionality of the returned file descriptor is limited to
-the descriptor-level operations.
-It can be used for
-.Bl -tag -width readlinkat(2) -offset indent -compact
-.It Xr fcntl 2
-but advisory locking is not allowed
-.It Xr dup 2
-.It Xr close 2
-.It Xr fstat 2
-.It Xr fexecve 2
-.It Dv SCM_RIGHTS
-can be passed over a
-.Xr unix 4
-socket using a
-.Dv SCM_RIGHTS
-message
-.It Xr kqueue 2
-using for
-.Dv EVFILT_VNODE
-.It Xr readlinkat 2
-.It Xr __acl_get_fd 2 , Xr __acl_aclcheck_fd 2
-.El
-But operations like
-.Xr read 2 ,
-.Xr ftruncate 2 ,
-and any other that operate on file and not on file descriptor (except
-.Xr fstat 2 ),
-are not allowed.
-.Pp
-A file descriptor created with the
-.Dv O_PATH
-flag can be opened into normal (operable) file descriptor by
-specifying it as the
-.Fa fd
-argument to
-.Fn openat
-with empty
-.Fa path
-and flag
-.Dv O_EMPTY_PATH .
-Such an open behaves as if the current path of the file referenced by
-.Fa fd
-is passed, except that the path walk permissions are not checked.
-See also the description of
-.Dv AT_EMPTY_PATH
-flag for
-.Xr fstatat 2
-and related syscalls.
-.Pp
-If successful,
-.Fn open
-returns a non-negative integer, termed a file descriptor.
-It returns \-1 on failure.
-The file pointer used to mark the current position within the
-file is set to the beginning of the file.
-.Pp
-If a sleeping open of a device node from
-.Xr devfs 5
-is interrupted by a signal, the call always fails with
-.Er EINTR ,
-even if the
-.Dv SA_RESTART
-flag is set for the signal.
-A sleeping open of a fifo (see
-.Xr mkfifo 2 )
-is restarted as normal.
-.Pp
-When a new file is created it is given the group of the directory
-which contains it.
-.Pp
-Unless
-.Dv O_CLOEXEC
-flag was specified,
-the new descriptor is set to remain open across
-.Xr execve 2
-system calls; see
-.Xr close 2 ,
-.Xr fcntl 2
-and
-.Dv O_CLOEXEC
-description.
-.Pp
-The system imposes a limit on the number of file descriptors
-open simultaneously by one process.
-The
-.Xr getdtablesize 2
-system call returns the current system limit.
-.Sh RETURN VALUES
-If successful,
-.Fn open
-and
-.Fn openat
-return a non-negative integer, termed a file descriptor.
-They return \-1 on failure, and set
-.Va errno
-to indicate the error.
-.Sh ERRORS
-The named file is opened unless:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-.Dv O_CREAT
-is not set and the named file does not exist.
-.It Bq Er ENOENT
-A component of the path name that must exist does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-The required permissions (for reading and/or writing)
-are denied for the given flags.
-.It Bq Er EACCES
-.Dv O_TRUNC
-is specified and write permission is denied.
-.It Bq Er EACCES
-.Dv O_CREAT
-is specified,
-the file does not exist,
-and the directory in which it is to be created
-does not permit writing.
-.It Bq Er EPERM
-.Dv O_CREAT
-is specified, the file does not exist, and the directory in which it is to be
-created has its immutable flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EPERM
-The named file has its immutable flag set and the file is to be modified.
-.It Bq Er EPERM
-The named file has its append-only flag set, the file is to be modified, and
-.Dv O_TRUNC
-is specified or
-.Dv O_APPEND
-is not specified.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EISDIR
-The named file is a directory, and the arguments specify
-it is to be modified.
-.It Bq Er EISDIR
-The named file is a directory, and the flags specified
-.Dv O_CREAT
-without
-.Dv O_DIRECTORY .
-.It Bq Er EROFS
-The named file resides on a read-only file system,
-and the file is to be modified.
-.It Bq Er EROFS
-.Dv O_CREAT
-is specified and the named file would reside on a read-only file system.
-.It Bq Er EMFILE
-The process has already reached its limit for open file descriptors.
-.It Bq Er ENFILE
-The system file table is full.
-.It Bq Er EMLINK
-.Dv O_NOFOLLOW
-was specified and the target is a symbolic link.
-.It Bq Er ENXIO
-The named file is a character special or block
-special file, and the device associated with this special file
-does not exist.
-.It Bq Er ENXIO
-.Dv O_NONBLOCK
-is set, the named file is a fifo,
-.Dv O_WRONLY
-is set, and no process has the file open for reading.
-.It Bq Er EINTR
-The
-.Fn open
-operation was interrupted by a signal.
-.It Bq Er EOPNOTSUPP
-.Dv O_SHLOCK
-or
-.Dv O_EXLOCK
-is specified but the underlying file system does not support locking.
-.It Bq Er EOPNOTSUPP
-The named file is a special file mounted through a file system that
-does not support access to it (e.g.\& NFS).
-.It Bq Er EWOULDBLOCK
-.Dv O_NONBLOCK
-and one of
-.Dv O_SHLOCK
-or
-.Dv O_EXLOCK
-is specified and the file is locked.
-.It Bq Er ENOSPC
-.Dv O_CREAT
-is specified,
-the file does not exist,
-and the directory in which the entry for the new file is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er ENOSPC
-.Dv O_CREAT
-is specified,
-the file does not exist,
-and there are no free inodes on the file system on which the
-file is being created.
-.It Bq Er EDQUOT
-.Dv O_CREAT
-is specified,
-the file does not exist,
-and the directory in which the entry for the new file
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EDQUOT
-.Dv O_CREAT
-is specified,
-the file does not exist,
-and the user's quota of inodes on the file system on
-which the file is being created has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while making the directory entry or
-allocating the inode for
-.Dv O_CREAT .
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ETXTBSY
-The file is a pure procedure (shared text) file that is being
-executed and the
-.Fn open
-system call requests write access.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EEXIST
-.Dv O_CREAT
-and
-.Dv O_EXCL
-were specified and the file exists.
-.It Bq Er EOPNOTSUPP
-An attempt was made to open a socket (not currently implemented).
-.It Bq Er EINVAL
-An attempt was made to open a descriptor with an illegal combination
-of
-.Dv O_RDONLY ,
-.Dv O_WRONLY ,
-or
-.Dv O_RDWR ,
-and
-.Dv O_EXEC
-or
-.Dv O_SEARCH .
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is
-neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTDIR
-.Dv O_DIRECTORY
-is specified and the file is not a directory.
-.It Bq Er ECAPMODE
-.Dv AT_FDCWD
-is specified and the process is in capability mode.
-.It Bq Er ECAPMODE
-.Fn open
-was called and the process is in capability mode.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path and the process is in capability mode.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path and
-.Dv O_RESOLVE_BENEATH
-is specified.
-.It Bq Er ENOTCAPABLE
-.Fa path
-contains a ".." component leading to a directory outside
-of the directory hierarchy specified by
-.Fa fd
-and the process is in capability mode.
-.It Bq Er ENOTCAPABLE
-.Fa path
-contains a ".." component leading to a directory outside
-of the directory hierarchy specified by
-.Fa fd
-and
-.Dv O_RESOLVE_BENEATH
-is specified.
-.It Bq Er ENOTCAPABLE
-.Fa path
-contains a ".." component, the
-.Dv vfs.lookup_cap_dotdot
-.Xr sysctl 3
-is set, and the process is in capability mode.
-.El
-.Sh SEE ALSO
-.Xr chmod 2 ,
-.Xr close 2 ,
-.Xr dup 2 ,
-.Xr fexecve 2 ,
-.Xr fhopen 2 ,
-.Xr getdtablesize 2 ,
-.Xr getfh 2 ,
-.Xr lgetfh 2 ,
-.Xr lseek 2 ,
-.Xr read 2 ,
-.Xr umask 2 ,
-.Xr write 2 ,
-.Xr fopen 3 ,
-.Xr capsicum 4
-.Sh STANDARDS
-These functions are specified by
-.St -p1003.1-2008 .
-.Fx
-sets
-.Va errno
-to
-.Er EMLINK instead of
-.Er ELOOP
-as specified by
-.Tn POSIX
-when
-.Dv O_NOFOLLOW
-is set in flags and the final component of pathname is a symbolic link
-to distinguish it from the case of too many symbolic link traversals
-in one of its non-final components.
-.Sh HISTORY
-The
-.Fn open
-function appeared in
-.At v1 .
-The
-.Fn openat
-function was introduced in
-.Fx 8.0 .
-.Dv O_DSYNC
-appeared in 13.0.
-.Sh BUGS
-The Open Group Extended API Set 2 specification requires that the test
-for whether
-.Fa fd
-is searchable is based on whether
-.Fa fd
-is open for searching, not whether the underlying directory currently
-permits searches.
-The present implementation of the
-.Fa openat
-checks the current permissions of directory instead.
-.Pp
-The
-.Fa mode
-argument is variadic and may result in different calling conventions
-than might otherwise be expected.
diff --git a/lib/libc/sys/open.c b/lib/libc/sys/open.c
index 020134d5693b..57c07637d2aa 100644
--- a/lib/libc/sys/open.c
+++ b/lib/libc/sys/open.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <stdarg.h>
@@ -51,6 +50,5 @@ open(const char *path, int flags, ...)
} else {
mode = 0;
}
- return (((int (*)(int, const char *, int, ...))
- __libc_interposing[INTERPOS_openat])(AT_FDCWD, path, flags, mode));
+ return (INTERPOS_SYS(openat, AT_FDCWD, path, flags, mode));
}
diff --git a/lib/libc/sys/openat.c b/lib/libc/sys/openat.c
index 9edf7d493bfd..1cd8e7d90745 100644
--- a/lib/libc/sys/openat.c
+++ b/lib/libc/sys/openat.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <stdarg.h>
@@ -54,6 +53,5 @@ openat(int fd, const char *path, int flags, ...)
} else {
mode = 0;
}
- return (((int (*)(int, const char *, int, ...))
- __libc_interposing[INTERPOS_openat])(fd, path, flags, mode));
+ return (INTERPOS_SYS(openat, fd, path, flags, mode));
}
diff --git a/lib/libc/sys/pathconf.2 b/lib/libc/sys/pathconf.2
deleted file mode 100644
index 18bd7bdcf736..000000000000
--- a/lib/libc/sys/pathconf.2
+++ /dev/null
@@ -1,268 +0,0 @@
-.\" Copyright (c) 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.
-.\"
-.\" @(#)pathconf.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 6, 2021
-.Dt PATHCONF 2
-.Os
-.Sh NAME
-.Nm pathconf ,
-.Nm lpathconf ,
-.Nm fpathconf
-.Nd get configurable pathname variables
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft long
-.Fn pathconf "const char *path" "int name"
-.Ft long
-.Fn lpathconf "const char *path" "int name"
-.Ft long
-.Fn fpathconf "int fd" "int name"
-.Sh DESCRIPTION
-The
-.Fn pathconf ,
-.Fn lpathconf
-and
-.Fn fpathconf
-system calls provide a method for applications to determine the current
-value of a configurable system limit or option variable associated
-with a pathname or file descriptor.
-.Pp
-For
-.Fn pathconf
-and
-.Fn lpathconf ,
-the
-.Fa path
-argument is the name of a file or directory.
-For
-.Fn fpathconf ,
-the
-.Fa fd
-argument is an open file descriptor.
-The
-.Fa name
-argument specifies the system variable to be queried.
-Symbolic constants for each name value are found in the include file
-.Li <unistd.h> .
-.Pp
-The
-.Fn lpathconf
-system call is like
-.Fn pathconf
-except in the case where the named file is a symbolic link,
-in which case
-.Fn lpathconf
-returns information about the link,
-while
-.Fn pathconf
-returns information about the file the link references.
-.Pp
-The available values are as follows:
-.Bl -tag -width 6n
-.It Li _PC_LINK_MAX
-The maximum file link count.
-.It Li _PC_MAX_CANON
-The maximum number of bytes in terminal canonical input line.
-.It Li _PC_MAX_INPUT
-The minimum maximum number of bytes for which space is available in
-a terminal input queue.
-.It Li _PC_NAME_MAX
-The maximum number of bytes in a file name.
-.It Li _PC_PATH_MAX
-The maximum number of bytes in a pathname.
-.It Li _PC_PIPE_BUF
-The maximum number of bytes which will be written atomically to a pipe.
-.It Li _PC_CHOWN_RESTRICTED
-Return 1 if appropriate privilege is required for the
-.Xr chown 2
-system call, otherwise 0.
-.St -p1003.1-2001
-requires appropriate privilege in all cases, but this behavior was optional
-in prior editions of the standard.
-.It Li _PC_NO_TRUNC
-Return greater than zero if attempts to use pathname components longer than
-.Brq Dv NAME_MAX
-will result in an
-.Bq Er ENAMETOOLONG
-error; otherwise, such components will be truncated to
-.Brq Dv NAME_MAX .
-.St -p1003.1-2001
-requires the error in all cases, but this behavior was optional in prior
-editions of the standard, and some
-.No non- Ns Tn POSIX Ns -compliant
-file systems do not support this behavior.
-.It Li _PC_VDISABLE
-Returns the terminal character disabling value.
-.It Li _PC_ASYNC_IO
-Return 1 if asynchronous I/O is supported, otherwise 0.
-.It Li _PC_PRIO_IO
-Returns 1 if prioritised I/O is supported for this file,
-otherwise 0.
-.It Li _PC_SYNC_IO
-Returns 1 if synchronised I/O is supported for this file, otherwise 0.
-.It Li _PC_ALLOC_SIZE_MIN
-Minimum number of bytes of storage allocated for any portion of a file.
-.It Li _PC_FILESIZEBITS
-Number of bits needed to represent the maximum file size.
-.It Li _PC_REC_INCR_XFER_SIZE
-Recommended increment for file transfer sizes between
-.Dv _PC_REC_MIN_XFER_SIZE
-and
-.Dv _PC_REC_MAX_XFER_SIZE .
-.It Li _PC_REC_MAX_XFER_SIZE
-Maximum recommended file transfer size.
-.It Li _PC_REC_MIN_XFER_SIZE
-Minimum recommended file transfer size.
-.It Li _PC_REC_XFER_ALIGN
-Recommended file transfer buffer alignment.
-.It Li _PC_SYMLINK_MAX
-Maximum number of bytes in a symbolic link.
-.It Li _PC_ACL_EXTENDED
-Returns 1 if an Access Control List (ACL) can be set on the specified
-file, otherwise 0.
-.It Li _PC_ACL_NFS4
-Returns 1 if an NFSv4 ACLs can be set on the specified
-file, otherwise 0.
-.It Li _PC_ACL_PATH_MAX
-Maximum number of ACL entries per file.
-.It Li _PC_CAP_PRESENT
-Returns 1 if a capability state can be set on the specified file,
-otherwise 0.
-.It Li _PC_INF_PRESENT
-Returns 1 if an information label can be set on the specified file,
-otherwise 0.
-.It Li _PC_MAC_PRESENT
-Returns 1 if a Mandatory Access Control (MAC) label can be set on the
-specified file, otherwise 0.
-.It Li _PC_MIN_HOLE_SIZE
-If a file system supports the reporting of holes (see
-.Xr lseek 2 ) ,
-.Fn pathconf
-and
-.Fn fpathconf
-return a positive number that represents the minimum hole size returned in
-bytes.
-The offsets of holes returned will be aligned to this same value.
-A special value of 1 is returned if the file system does not specify the minimum
-hole size but still reports holes.
-.It Li _PC_DEALLOC_PRESENT
-Return 1 if a file system supports hole-punching (see
-.Xr fspacectl 2 ) ,
-otherwise 0.
-.El
-.Sh RETURN VALUES
-If the call to
-.Fn pathconf
-or
-.Fn fpathconf
-is not successful, \-1 is returned and
-.Va errno
-is set appropriately.
-Otherwise, if the variable is associated with functionality that does
-not have a limit in the system, \-1 is returned and
-.Va errno
-is not modified.
-Otherwise, the current variable value is returned.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn pathconf
-and
-.Fn fpathconf
-system calls shall return -1 and set
-.Va errno
-to the corresponding value.
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value of the
-.Fa name
-argument is invalid.
-.It Bq Er EINVAL
-The implementation does not support an association of the variable
-name with the associated file.
-.El
-.Pp
-The
-.Fn pathconf
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded
-.Brq Dv NAME_MAX
-characters (but see
-.Dv _PC_NO_TRUNC
-above),
-or an entire path name exceeded
-.Brq Dv PATH_MAX
-characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-The
-.Fn fpathconf
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid open file descriptor.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh SEE ALSO
-.Xr lseek 2 ,
-.Xr sysctl 3
-.Sh HISTORY
-The
-.Fn pathconf
-and
-.Fn fpathconf
-system calls first appeared in
-.Bx 4.4 .
-The
-.Fn lpathconf
-system call first appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/pdfork.c b/lib/libc/sys/pdfork.c
index 14867a2f20a5..f25f081ec174 100644
--- a/lib/libc/sys/pdfork.c
+++ b/lib/libc/sys/pdfork.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/procdesc.h>
#include "libc_private.h"
@@ -38,6 +37,5 @@
pid_t
pdfork(int *fdp, int flags)
{
- return (((pid_t (*)(int *, int))__libc_interposing[
- INTERPOS_pdfork])(fdp, flags));
+ return (INTERPOS_SYS(pdfork, fdp, flags));
}
diff --git a/lib/libc/sys/pipe.2 b/lib/libc/sys/pipe.2
deleted file mode 100644
index 975862fdf1cb..000000000000
--- a/lib/libc/sys/pipe.2
+++ /dev/null
@@ -1,177 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)pipe.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 1, 2017
-.Dt PIPE 2
-.Os
-.Sh NAME
-.Nm pipe ,
-.Nm pipe2
-.Nd create descriptor pair for interprocess communication
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn pipe "int fildes[2]"
-.Ft int
-.Fn pipe2 "int fildes[2]" "int flags"
-.Sh DESCRIPTION
-The
-.Fn pipe
-function
-creates a
-.Em pipe ,
-which is an object allowing
-bidirectional data flow,
-and allocates a pair of file descriptors.
-.Pp
-The
-.Fn pipe2
-system call allows control over the attributes of the file descriptors
-via the
-.Fa flags
-argument.
-Values for
-.Fa flags
-are constructed by a bitwise-inclusive OR of flags from the following
-list, defined in
-.In fcntl.h :
-.Bl -tag -width ".Dv O_NONBLOCK"
-.It Dv O_CLOEXEC
-Set the close-on-exec flag for the new file descriptors.
-.It Dv O_NONBLOCK
-Set the non-blocking flag for the ends of the pipe.
-.El
-.Pp
-If the
-.Fa flags
-argument is 0, the behavior is identical to a call to
-.Fn pipe .
-.Pp
-By convention, the first descriptor is normally used as the
-.Em read end
-of the pipe,
-and the second is normally the
-.Em write end ,
-so that data written to
-.Fa fildes[1]
-appears on (i.e., can be read from)
-.Fa fildes[0] .
-This allows the output of one program to be
-sent
-to another program:
-the source's standard output is set up to be
-the write end of the pipe,
-and the sink's standard input is set up to be
-the read end of the pipe.
-The pipe itself persists until all its associated descriptors are
-closed.
-.Pp
-A pipe that has had an end closed is considered
-.Em widowed .
-Writing on such a pipe causes the writing process to receive
-a
-.Dv SIGPIPE
-signal.
-Widowing a pipe is the only way to deliver end-of-file to a reader:
-after the reader consumes any buffered data, reading a widowed pipe
-returns a zero count.
-.Pp
-The bidirectional nature of this implementation of pipes is not
-portable to older systems, so it is recommended to use the convention
-for using the endpoints in the traditional manner when using a
-pipe in one direction.
-.Sh IMPLEMENTATION NOTES
-The
-.Fn pipe
-function calls the
-.Fn pipe2
-system call.
-As a result, system call traces such as those captured by
-.Xr dtrace 1
-or
-.Xr ktrace 1
-will show calls to
-.Fn pipe2 .
-.Sh RETURN VALUES
-.Rv -std pipe
-.Sh ERRORS
-The
-.Fn pipe
-and
-.Fn pipe2
-system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-.Ar fildes
-argument points to an invalid memory location.
-.It Bq Er EMFILE
-Too many descriptors are active.
-.It Bq Er ENFILE
-The system file table is full.
-.It Bq Er ENOMEM
-Not enough kernel memory to establish a pipe.
-.El
-.Pp
-The
-.Fn pipe2
-system call will also fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa flags
-argument is invalid.
-.El
-.Sh SEE ALSO
-.Xr sh 1 ,
-.Xr fork 2 ,
-.Xr read 2 ,
-.Xr socketpair 2 ,
-.Xr write 2
-.Sh HISTORY
-The
-.Fn pipe
-function appeared in
-.At v3 .
-.Pp
-Bidirectional pipes were first used on
-.At V.4 .
-.Pp
-The
-.Fn pipe2
-function appeared in
-.Fx 10.0 .
-.Pp
-The
-.Fn pipe
-function became a wrapper around
-.Fn pipe2
-in
-.Fx 11.0 .
diff --git a/lib/libc/sys/pipe.c b/lib/libc/sys/pipe.c
index 1c45ab0c8a19..370895166ad0 100644
--- a/lib/libc/sys/pipe.c
+++ b/lib/libc/sys/pipe.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <unistd.h>
diff --git a/lib/libc/sys/poll.2 b/lib/libc/sys/poll.2
deleted file mode 100644
index 175958ce644e..000000000000
--- a/lib/libc/sys/poll.2
+++ /dev/null
@@ -1,293 +0,0 @@
-.\" $NetBSD: poll.2,v 1.3 1996/09/07 21:53:08 mycroft Exp $
-.\"
-.\" Copyright (c) 1996 Charles M. Hannum. 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Charles M. Hannum.
-.\" 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.
-.\"
-.Dd April 27, 2021
-.Dt POLL 2
-.Os
-.Sh NAME
-.Nm poll
-.Nd synchronous I/O multiplexing
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In poll.h
-.Ft int
-.Fn poll "struct pollfd fds[]" "nfds_t nfds" "int timeout"
-.Ft int
-.Fo ppoll
-.Fa "struct pollfd fds[]"
-.Fa "nfds_t nfds"
-.Fa "const struct timespec * restrict timeout"
-.Fa "const sigset_t * restrict newsigmask"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn poll
-system call
-examines a set of file descriptors to see if some of them are ready for
-I/O.
-The
-.Fa fds
-argument is a pointer to an array of pollfd structures as defined in
-.In poll.h
-(shown below).
-The
-.Fa nfds
-argument determines the size of the
-.Fa fds
-array.
-.Bd -literal
-struct pollfd {
- int fd; /* file descriptor */
- short events; /* events to look for */
- short revents; /* events returned */
-};
-.Ed
-.Pp
-The fields of
-.Fa struct pollfd
-are as follows:
-.Bl -tag -width XXXrevents
-.It fd
-File descriptor to poll.
-If fd is equal to -1 then
-.Fa revents
-is cleared (set to zero), and that pollfd is not checked.
-.It events
-Events to poll for.
-(See below.)
-.It revents
-Events which may occur.
-(See below.)
-.El
-.Pp
-The event bitmasks in
-.Fa events
-and
-.Fa revents
-have the following bits:
-.Bl -tag -width XXXPOLLWRNORM
-.It POLLIN
-Data other than high priority data may be read without blocking.
-.It POLLRDNORM
-Normal data may be read without blocking.
-.It POLLRDBAND
-Data with a non-zero priority may be read without blocking.
-.It POLLPRI
-High priority data may be read without blocking.
-.It POLLOUT
-.It POLLWRNORM
-Normal data may be written without blocking.
-.It POLLWRBAND
-Data with a non-zero priority may be written without blocking.
-.It POLLERR
-An exceptional condition has occurred on the device or socket.
-This
-flag is always checked, even if not present in the
-.Fa events
-bitmask.
-.It POLLHUP
-The device or socket has been disconnected.
-This flag is always
-checked, even if not present in the
-.Fa events
-bitmask.
-Note that
-POLLHUP
-and
-POLLOUT
-should never be present in the
-.Fa revents
-bitmask at the same time.
-.It POLLRDHUP
-Remote peer closed connection, or shut down writing.
-Unlike
-POLLHUP,
-POLLRDHUP
-must be present in the
-.Fa events
-bitmask to be reported.
-Applies only to stream sockets.
-.It POLLNVAL
-The file descriptor is not open,
-or in capability mode the file descriptor has insufficient rights.
-This flag is always checked, even
-if not present in the
-.Fa events
-bitmask.
-.El
-.Pp
-If
-.Fa timeout
-is neither zero nor INFTIM (-1), it specifies a maximum interval to
-wait for any file descriptor to become ready, in milliseconds.
-If
-.Fa timeout
-is INFTIM (-1), the poll blocks indefinitely.
-If
-.Fa timeout
-is zero, then
-.Fn poll
-will return without blocking.
-.Pp
-The
-.Fn ppoll
-system call, unlike
-.Fn poll ,
-is used to safely wait until either a set of file descriptors becomes
-ready or until a signal is caught.
-The
-.Fa fds
-and
-.Fa nfds
-arguments are identical to the analogous arguments of
-.Fn poll .
-The
-.Fa timeout
-argument in
-.Fn ppoll
-points to a
-.Vt "const struct timespec"
-which is defined in
-.In sys/timespec.h
-(shown below) rather than the
-.Vt "int timeout"
-used by
-.Fn poll .
-A null pointer may be passed to indicate that
-.Fn ppoll
-should wait indefinitely.
-Finally,
-.Fa newsigmask
-specifies a signal mask which is set while waiting for input.
-When
-.Fn ppoll
-returns, the original signal mask is restored.
-.Bd -literal
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* and nanoseconds */
-};
-.Ed
-.Sh RETURN VALUES
-The
-.Fn poll
-system call
-returns the number of descriptors that are ready for I/O, or -1 if an
-error occurred.
-If the time limit expires,
-.Fn poll
-returns 0.
-If
-.Fn poll
-returns with an error,
-including one due to an interrupted system call,
-the
-.Fa fds
-array will be unmodified.
-.Sh COMPATIBILITY
-This implementation differs from the historical one in that a given
-file descriptor may not cause
-.Fn poll
-to return with an error.
-In cases where this would have happened in
-the historical implementation (e.g.\& trying to poll a
-.Xr revoke 2 Ns ed
-descriptor), this implementation instead copies the
-.Fa events
-bitmask to the
-.Fa revents
-bitmask.
-Attempting to perform I/O on this descriptor will then
-return an error.
-This behaviour is believed to be more useful.
-.Sh ERRORS
-An error return from
-.Fn poll
-indicates:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa fds
-argument
-points outside the process's allocated address space.
-.It Bq Er EINTR
-A signal was delivered before the time limit expired and
-before any of the selected events occurred.
-.It Bq Er EINVAL
-The specified time limit is invalid.
-One of its components is negative or too large.
-.It Bq Er EINVAL
-The number of pollfd structures specified by
-.Fa nfds
-exceeds the system tunable
-.Va kern.maxfilesperproc
-and
-.Dv FD_SETSIZE .
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr connect 2 ,
-.Xr kqueue 2 ,
-.Xr pselect 2 ,
-.Xr read 2 ,
-.Xr recv 2 ,
-.Xr select 2 ,
-.Xr send 2 ,
-.Xr write 2
-.Sh STANDARDS
-The
-.Fn poll
-function conforms to
-.St -p1003.1-2001 .
-The
-.Fn ppoll
-is not specified by POSIX.
-The
-POLLRDHUP
-flag is not specified by POSIX, but is compatible with Linux and illumos.
-.Sh HISTORY
-The
-.Fn poll
-function appeared in
-.At V .
-This manual page and the core of the implementation was taken from
-.Nx .
-The
-.Fn ppoll
-function first appeared in
-.Fx 11.0
-.Sh BUGS
-The distinction between some of the fields in the
-.Fa events
-and
-.Fa revents
-bitmasks is really not useful without STREAMS.
-The fields are
-defined for compatibility with existing software.
diff --git a/lib/libc/sys/poll.c b/lib/libc/sys/poll.c
index f03320dc9319..5e000f7e728f 100644
--- a/lib/libc/sys/poll.c
+++ b/lib/libc/sys/poll.c
@@ -29,18 +29,15 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/poll.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
__weak_reference(__sys_poll, __poll);
-#pragma weak poll
-int
-poll(struct pollfd pfd[], nfds_t nfds, int timeout)
+int __weak_symbol
+__ssp_real(poll)(struct pollfd pfd[], nfds_t nfds, int timeout)
{
-
- return (((int (*)(struct pollfd *, nfds_t, int))
- __libc_interposing[INTERPOS_poll])(pfd, nfds, timeout));
+ return (INTERPOS_SYS(poll, pfd, nfds, timeout));
}
diff --git a/lib/libc/sys/posix_fadvise.2 b/lib/libc/sys/posix_fadvise.2
deleted file mode 100644
index f1e46bceba0a..000000000000
--- a/lib/libc/sys/posix_fadvise.2
+++ /dev/null
@@ -1,142 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
-.\"
-.Dd March 30, 2020
-.Dt POSIX_FADVISE 2
-.Os
-.Sh NAME
-.Nm posix_fadvise
-.Nd give advice about use of file data
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In fcntl.h
-.Ft int
-.Fn posix_fadvise "int fd" "off_t offset" "off_t len" "int advice"
-.Sh DESCRIPTION
-The
-.Fn posix_fadvise
-system call
-allows a process to describe to the system its data access behavior for an
-open file descriptor
-.Fa fd .
-The advice covers the data starting at offset
-.Fa offset
-and continuing for
-.Fa len
-bytes.
-If
-.Fa len
-is zero,
-all data from
-.Fa offset
-to the end of the file is covered.
-.Pp
-The behavior is specified by the
-.Fa advice
-parameter and may be one of:
-.Bl -tag -width POSIX_FADV_SEQUENTIAL
-.It Dv POSIX_FADV_NORMAL
-Tells the system to revert to the default data access behavior.
-.It Dv POSIX_FADV_RANDOM
-Is a hint that file data will be accessed randomly,
-and prefetching is likely not advantageous.
-.It Dv POSIX_FADV_SEQUENTIAL
-Tells the system that file data will be accessed sequentially.
-This currently does nothing as the default behavior uses heuristics to
-detect sequential behavior.
-.It Dv POSIX_FADV_WILLNEED
-Tells the system that the specified data will be accessed in the near future.
-The system may initiate an asynchronous read of the data if it is not already
-present in memory.
-.It Dv POSIX_FADV_DONTNEED
-Tells the system that the specified data will not be accessed in the near
-future.
-The system may decrease the in-memory priority of clean data within the
-specified range and future access to this data may require a read operation.
-.It Dv POSIX_FADV_NOREUSE
-Tells the system that the specified data will only be accessed once and
-then not reused.
-The system may decrease the in-memory priority of data once it has been
-read or written.
-Future access to this data may require a read operation.
-.El
-.Sh RETURN VALUES
-If successful,
-.Fn posix_fadvise
-returns zero.
-It returns an error on failure, without setting
-.Va errno .
-.Sh ERRORS
-Possible failure conditions:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument is not a valid file descriptor.
-.It Bq Er EINVAL
-The
-.Fa advice
-argument is not valid.
-.It Bq Er EINVAL
-The
-.Fa offset
-or
-.Fa len
-arguments are negative,
-or
-.Fa offset
-+
-.Fa len
-is greater than the maximum file size.
-.It Bq Er ENODEV
-The
-.Fa fd
-argument does not refer to a regular file.
-.It Bq Er ESPIPE
-The
-.Fa fd
-argument is associated with a pipe or FIFO.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to a file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh SEE ALSO
-.Xr madvise 2
-.Sh STANDARDS
-The
-.Fn posix_fadvise
-interface conforms to
-.St -p1003.1-2001 .
-.Sh HISTORY
-The
-.Fn posix_fadvise
-system call first appeared in
-.Fx 9.1 .
diff --git a/lib/libc/sys/posix_fallocate.2 b/lib/libc/sys/posix_fallocate.2
deleted file mode 100644
index 5504c13a3e8f..000000000000
--- a/lib/libc/sys/posix_fallocate.2
+++ /dev/null
@@ -1,151 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)open.2 8.2 (Berkeley) 11/16/93
-.\"
-.Dd March 30, 2020
-.Dt POSIX_FALLOCATE 2
-.Os
-.Sh NAME
-.Nm posix_fallocate
-.Nd pre-allocate storage for a range in a file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In fcntl.h
-.Ft int
-.Fn posix_fallocate "int fd" "off_t offset" "off_t len"
-.Sh DESCRIPTION
-Required storage for the range
-.Fa offset
-to
-.Fa offset +
-.Fa len
-in the file referenced by
-.Fa fd
-is guaranteed to be allocated upon successful return.
-That is, if
-.Fn posix_fallocate
-returns successfully, subsequent writes to the specified file data
-will not fail due to lack of free space on the file system storage
-media.
-Any existing file data in the specified range is unmodified.
-If
-.Fa offset +
-.Fa len
-is beyond the current file size, then
-.Fn posix_fallocate
-will adjust the file size to
-.Fa offset +
-.Fa len .
-Otherwise, the file size will not be changed.
-.Pp
-Space allocated by
-.Fn posix_fallocate
-will be freed by a successful call to
-.Xr creat 2
-or
-.Xr open 2
-that truncates the size of the file.
-Space allocated via
-.Fn posix_fallocate
-may be freed by a successful call to
-.Xr ftruncate 2
-that reduces the file size to a size smaller than
-.Fa offset +
-.Fa len .
-.Sh RETURN VALUES
-If successful,
-.Fn posix_fallocate
-returns zero.
-It returns an error on failure, without setting
-.Va errno .
-.Sh ERRORS
-Possible failure conditions:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument is not a valid file descriptor.
-.It Bq Er EBADF
-The
-.Fa fd
-argument references a file that was opened without write permission.
-.It Bq Er EFBIG
-The value of
-.Fa offset +
-.Fa len
-is greater than the maximum file size.
-.It Bq Er EINTR
-A signal was caught during execution.
-.It Bq Er EINVAL
-The
-.Fa len
-argument was less than or equal to zero, the
-.Fa offset
-argument was less than zero,
-or the operation is not supported by the file system.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to a file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ENODEV
-The
-.Fa fd
-argument does not refer to a file that supports
-.Nm .
-.It Bq Er ENOSPC
-There is insufficient free space remaining on the file system storage
-media.
-.It Bq Er ENOTCAPABLE
-The file descriptor
-.Fa fd
-has insufficient rights.
-.It Bq Er ESPIPE
-The
-.Fa fd
-argument is associated with a pipe or FIFO.
-.El
-.Sh SEE ALSO
-.Xr creat 2 ,
-.Xr ftruncate 2 ,
-.Xr open 2 ,
-.Xr unlink 2
-.Sh STANDARDS
-The
-.Fn posix_fallocate
-system call conforms to
-.St -p1003.1-2004 .
-.Sh HISTORY
-The
-.Fn posix_fallocate
-function appeared in
-.Fx 9.0 .
-.Sh AUTHORS
-.Fn posix_fallocate
-and this manual page were initially written by
-.An Matthew Fleming Aq Mt mdf@FreeBSD.org .
diff --git a/lib/libc/sys/ppoll.c b/lib/libc/sys/ppoll.c
index 8f886b8c5108..72c0b5d5e421 100644
--- a/lib/libc/sys/ppoll.c
+++ b/lib/libc/sys/ppoll.c
@@ -29,20 +29,17 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/poll.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
__weak_reference(__sys_ppoll, __ppoll);
-#pragma weak ppoll
-int
-ppoll(struct pollfd pfd[], nfds_t nfds, const struct timespec *__restrict
- timeout, const sigset_t *__restrict newsigmask)
+int __weak_symbol
+__ssp_real(ppoll)(struct pollfd pfd[], nfds_t nfds,
+ const struct timespec *__restrict timeout,
+ const sigset_t *__restrict newsigmask)
{
-
- return (((int (*)(struct pollfd *, nfds_t, const struct timespec *,
- const sigset_t *)) __libc_interposing[INTERPOS_ppoll])(pfd, nfds,
- timeout, newsigmask));
+ return (INTERPOS_SYS(ppoll, pfd, nfds, timeout, newsigmask));
}
diff --git a/lib/libc/sys/procctl.2 b/lib/libc/sys/procctl.2
deleted file mode 100644
index e269edb8acaa..000000000000
--- a/lib/libc/sys/procctl.2
+++ /dev/null
@@ -1,857 +0,0 @@
-.\" Copyright (c) 2013 Hudson River Trading LLC
-.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Copyright (c) 2014 The FreeBSD Foundation
-.\" Portions of this documentation were written by Konstantin Belousov
-.\" under sponsorship from the FreeBSD Foundation.
-.\"
-.\" 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.
-.\"
-.Dd April 15, 2023
-.Dt PROCCTL 2
-.Os
-.Sh NAME
-.Nm procctl
-.Nd control processes
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/procctl.h
-.Ft int
-.Fn procctl "idtype_t idtype" "id_t id" "int cmd" "void *data"
-.Sh DESCRIPTION
-The
-.Fn procctl
-system call provides for control over processes.
-The
-.Fa idtype
-and
-.Fa id
-arguments specify the set of processes to control.
-If multiple processes match the identifier,
-.Nm
-will make a
-.Dq best effort
-to control as many of the selected processes as possible.
-An error is only returned if no selected processes successfully complete
-the request.
-The following identifier types are supported:
-.Bl -tag -width P_PGID
-.It Dv P_PID
-Control the process with the process ID
-.Fa id .
-.Fa id
-zero is a shortcut for the calling process ID.
-.It Dv P_PGID
-Control processes belonging to the process group with the ID
-.Fa id .
-.El
-.Pp
-The control request to perform is specified by the
-.Fa cmd
-argument.
-.Pp
-All status changing requests
-.Dv *_CTL
-require the caller to have the right to debug the target.
-All status query requests
-.DV *_STATUS
-require the caller to have the right to observe the target.
-.Pp
-The following commands are supported:
-.Bl -tag -width PROC_TRAPCAP_STATUS
-.It Dv PROC_ASLR_CTL
-Controls the Address Space Layout Randomization (ASLR) in the program
-images created
-by
-.Xr execve 2
-in the specified process or its descendants that did not changed
-the control nor modified it by other means.
-The
-.Fa data
-parameter must point to the integer variable holding one of the following
-values:
-.Bl -tag -width PROC_ASLR_FORCE_DISABLE
-.It Dv PROC_ASLR_FORCE_ENABLE
-Request that ASLR is enabled after execution, even if it is disabled
-system-wide.
-The image flag and set-uid might prevent ASLR enablement still.
-.It Dv PROC_ASLR_FORCE_DISABLE
-Request that ASLR is disabled after execution.
-Same notes as for
-.Dv PROC_ASLR_FORCE_ENABLE
-apply.
-.It Dv PROC_ASLR_NOFORCE
-Use the system-wide configured policy for ASLR.
-.El
-.It Dv PROC_ASLR_STATUS
-Returns the current status of ASLR enablement for the target process.
-The
-.Fa data
-parameter must point to the integer variable, where one of the
-following values is written:
-.Bl -tag -width PROC_ASLR_FORCE_DISABLE
-.It Dv PROC_ASLR_FORCE_ENABLE
-.It Dv PROC_ASLR_FORCE_DISABLE
-.It Dv PROC_ASLR_NOFORCE
-.El
-.Pp
-If the currently executed image in the process itself has ASLR enabled,
-the
-.Dv PROC_ASLR_ACTIVE
-flag is or-ed with the value listed above.
-.It Dv PROC_PROTMAX_CTL
-Controls implicit application of PROT_MAX protection equal to the
-.Fa prot
-argument of the
-.Xr mmap 2
-syscall, in the target process.
-The
-.Fa data
-parameter must point to the integer variable holding one of the following
-values:
-.Bl -tag -width PROC_PROTMAX_FORCE_DISABLE
-.It Dv PROC_PROTMAX_FORCE_ENABLE
-Enables implicit PROT_MAX application,
-even if it is disabled system-wide by the sysctl
-.Va vm.imply_prot_max .
-The image flag might still prevent the enablement.
-.It Dv PROC_PROTMAX_FORCE_DISABLE
-Request that implicit application of PROT_MAX be disabled.
-Same notes as for
-.Dv PROC_PROTMAX_FORCE_ENABLE
-apply.
-.It Dv PROC_PROTMAX_NOFORCE
-Use the system-wide configured policy for PROT_MAX.
-.El
-.It Dv PROC_PROTMAX_STATUS
-Returns the current status of implicit PROT_MAX enablement for the
-target process.
-The
-.Fa data
-parameter must point to the integer variable, where one of the
-following values is written:
-.Bl -tag -width PROC_PROTMAX_FORCE_DISABLE
-.It Dv PROC_PROTMAX_FORCE_ENABLE
-.It Dv PROC_PROTMAX_FORCE_DISABLE
-.It Dv PROC_PROTMAX_NOFORCE
-.El
-.Pp
-If the currently executed image in the process itself has implicit PROT_MAX
-application enabled, the
-.Dv PROC_PROTMAX_ACTIVE
-flag is or-ed with the value listed above.
-.It Dv PROC_SPROTECT
-Set process protection state.
-This is used to mark a process as protected from being killed if the system
-exhausts the available memory and swap.
-The
-.Fa data
-parameter must point to an integer containing an operation and zero or more
-optional flags.
-The following operations are supported:
-.Bl -tag -width PPROT_CLEAR
-.It Dv PPROT_SET
-Mark the selected processes as protected.
-.It Dv PPROT_CLEAR
-Clear the protected state of selected processes.
-.El
-.Pp
-The following optional flags are supported:
-.Bl -tag -width PPROT_DESCEND
-.It Dv PPROT_DESCEND
-Apply the requested operation to all child processes of each selected process
-in addition to each selected process.
-.It Dv PPROT_INHERIT
-When used with
-.Dv PPROT_SET ,
-mark all future child processes of each selected process as protected.
-Future child processes will also mark all of their future child processes.
-.El
-.It Dv PROC_REAP_ACQUIRE
-Acquires the reaper status for the current process.
-Reaper status means that children orphaned by the reaper's descendants
-that were forked after the acquisition of reaper status are reparented to the
-reaper process.
-After system initialization,
-.Xr init 8
-is the default reaper.
-.It Dv PROC_REAP_RELEASE
-Release the reaper state for the current process.
-The reaper of the current process becomes the new reaper of the
-current process's descendants.
-.It Dv PROC_REAP_STATUS
-Provides information about the reaper of the specified process,
-or the process itself when it is a reaper.
-The
-.Fa data
-argument must point to a
-.Vt procctl_reaper_status
-structure which is filled in by the syscall on successful return.
-.Bd -literal
-struct procctl_reaper_status {
- u_int rs_flags;
- u_int rs_children;
- u_int rs_descendants;
- pid_t rs_reaper;
- pid_t rs_pid;
-};
-.Ed
-The
-.Fa rs_flags
-may have the following flags returned:
-.Bl -tag -width REAPER_STATUS_REALINIT
-.It Dv REAPER_STATUS_OWNED
-The specified process has acquired reaper status and has not
-released it.
-When the flag is returned, the specified process
-.Fa id ,
-pid, identifies the reaper, otherwise the
-.Fa rs_reaper
-field of the structure is set to the pid of the reaper
-for the specified process id.
-.It Dv REAPER_STATUS_REALINIT
-The specified process is the root of the reaper tree, i.e.,
-.Xr init 8 .
-.El
-.Pp
-The
-.Fa rs_children
-field returns the number of children of the reaper among the descendants.
-It is possible to have a child whose reaper is not the specified process,
-since the reaper for any existing children is not reset on the
-.Dv PROC_REAP_ACQUIRE
-operation.
-The
-.Fa rs_descendants
-field returns the total number of descendants of the reaper(s),
-not counting descendants of the reaper in the subtree.
-The
-.Fa rs_reaper
-field returns the reaper pid.
-The
-.Fa rs_pid
-returns the pid of one reaper child if there are any descendants.
-.It Dv PROC_REAP_GETPIDS
-Queries the list of descendants of the reaper of the specified process.
-The request takes a pointer to a
-.Vt procctl_reaper_pids
-structure in the
-.Fa data
-parameter.
-.Bd -literal
-struct procctl_reaper_pids {
- u_int rp_count;
- struct procctl_reaper_pidinfo *rp_pids;
-};
-.Ed
-When called, the
-.Fa rp_pids
-field must point to an array of
-.Vt procctl_reaper_pidinfo
-structures, to be filled in on return,
-and the
-.Fa rp_count
-field must specify the size of the array,
-into which no more than
-.Fa rp_count
-elements will be filled in by the kernel.
-.Pp
-The
-.Vt "struct procctl_reaper_pidinfo"
-structure provides some information about one of the reaper's descendants.
-Note that for a descendant that is not a child, it may be incorrectly
-identified because of a race in which the original child process exited
-and the exited process's pid was reused for an unrelated process.
-.Bd -literal
-struct procctl_reaper_pidinfo {
- pid_t pi_pid;
- pid_t pi_subtree;
- u_int pi_flags;
-};
-.Ed
-The
-.Fa pi_pid
-field is the process id of the descendant.
-The
-.Fa pi_subtree
-field provides the pid of the child of the reaper, which is the (grand-)parent
-of the process.
-The
-.Fa pi_flags
-field returns the following flags, further describing the descendant:
-.Bl -tag -width REAPER_PIDINFO_EXITING
-.It Dv REAPER_PIDINFO_VALID
-Set to indicate that the
-.Vt procctl_reaper_pidinfo
-structure was filled in by the kernel.
-Zero-filling the
-.Fa rp_pids
-array and testing the
-.Dv REAPER_PIDINFO_VALID
-flag allows the caller to detect the end
-of the returned array.
-.It Dv REAPER_PIDINFO_CHILD
-The
-.Fa pi_pid
-field identifies the direct child of the reaper.
-.It Dv REAPER_PIDINFO_REAPER
-The reported process is itself a reaper.
-The descendants of the subordinate reaper are not reported.
-.It Dv REAPER_PIDINFO_ZOMBIE
-The reported process is in the zombie state, ready to be reaped.
-.It Dv REAPER_PIDINFO_STOPPED
-The reported process is stopped by a SIGSTOP/SIGTSTP signal.
-.It Dv REAPER_PIDINFO_EXITING
-The reported process is in the process of exiting (but not yet a zombie).
-.El
-.It Dv PROC_REAP_KILL
-Request to deliver a signal to some subset of the descendants of the reaper.
-The
-.Fa data
-parameter must point to a
-.Vt procctl_reaper_kill
-structure, which is used both for parameters and status return.
-.Bd -literal
-struct procctl_reaper_kill {
- int rk_sig;
- u_int rk_flags;
- pid_t rk_subtree;
- u_int rk_killed;
- pid_t rk_fpid;
-};
-.Ed
-The
-.Fa rk_sig
-field specifies the signal to be delivered.
-Zero is not a valid signal number, unlike for
-.Xr kill 2 .
-The
-.Fa rk_flags
-field further directs the operation.
-It is or-ed from the following flags:
-.Bl -tag -width REAPER_KILL_CHILDREN
-.It Dv REAPER_KILL_CHILDREN
-Deliver the specified signal only to direct children of the reaper.
-.It Dv REAPER_KILL_SUBTREE
-Deliver the specified signal only to descendants that were forked by
-the direct child with pid specified in the
-.Fa rk_subtree
-field.
-.El
-If neither the
-.Dv REAPER_KILL_CHILDREN
-nor the
-.Dv REAPER_KILL_SUBTREE
-flags are specified, all current descendants of the reaper are signalled.
-.Pp
-If a signal was delivered to any process, the return value from the request
-is zero.
-In this case, the
-.Fa rk_killed
-field identifies the number of processes signalled.
-The
-.Fa rk_fpid
-field is set to the pid of the first process for which signal
-delivery failed, e.g., due to permission problems.
-If no such process exists, the
-.Fa rk_fpid
-field is set to -1.
-.It Dv PROC_TRACE_CTL
-Enable or disable tracing of the specified process(es), according to the
-value of the integer argument.
-Tracing includes attachment to the process using the
-.Xr ptrace 2
-and
-.Xr ktrace 2 ,
-debugging sysctls,
-.Xr hwpmc 4 ,
-.Xr dtrace 1 ,
-and core dumping.
-Possible values for the
-.Fa data
-argument are:
-.Bl -tag -width PROC_TRACE_CTL_DISABLE_EXEC
-.It Dv PROC_TRACE_CTL_ENABLE
-Enable tracing, after it was disabled by
-.Dv PROC_TRACE_CTL_DISABLE .
-Only allowed for self.
-.It Dv PROC_TRACE_CTL_DISABLE
-Disable tracing for the specified process.
-Tracing is re-enabled when the process changes the executing
-program with the
-.Xr execve 2
-syscall.
-A child inherits the trace settings from the parent on
-.Xr fork 2 .
-.It Dv PROC_TRACE_CTL_DISABLE_EXEC
-Same as
-.Dv PROC_TRACE_CTL_DISABLE ,
-but the setting persists for the process even after
-.Xr execve 2 .
-.El
-.It Dv PROC_TRACE_STATUS
-Returns the current tracing status for the specified process in
-the integer variable pointed to by
-.Fa data .
-If tracing is disabled,
-.Fa data
-is set to -1.
-If tracing is enabled, but no debugger is attached by the
-.Xr ptrace 2
-syscall,
-.Fa data
-is set to 0.
-If a debugger is attached,
-.Fa data
-is set to the pid of the debugger process.
-.It Dv PROC_TRAPCAP_CTL
-Controls the capability mode sandbox actions for the specified
-sandboxed processes,
-on a return from any syscall which gives either a
-.Er ENOTCAPABLE
-or
-.Er ECAPMODE
-error.
-If the control is enabled, such errors from the syscalls cause
-delivery of the synchronous
-.Dv SIGTRAP
-signal to the thread immediately before returning from the syscalls.
-.Pp
-Possible values for the
-.Fa data
-argument are:
-.Bl -tag -width PROC_TRAPCAP_CTL_DISABLE
-.It Dv PROC_TRAPCAP_CTL_ENABLE
-Enable the
-.Dv SIGTRAP
-signal delivery on capability mode access violations.
-The enabled mode is inherited by the children of the process,
-and is kept after
-.Xr fexecve 2
-calls.
-.It Dv PROC_TRAPCAP_CTL_DISABLE
-Disable the signal delivery on capability mode access violations.
-Note that the global sysctl
-.Dv kern.trap_enotcap
-might still cause the signal to be delivered.
-See
-.Xr capsicum 4 .
-.El
-.Pp
-On signal delivery, the
-.Va si_errno
-member of the
-.Fa siginfo
-signal handler parameter is set to the syscall error value,
-and the
-.Va si_code
-member is set to
-.Dv TRAP_CAP .
-The system call number is stored in the
-.Va si_syscall
-field of the
-.Fa siginfo
-signal handler parameter.
-The other system call parameters can be read from the
-.Fa ucontext_t
-but the system call number is typically stored in the register
-that also contains the return value and so is unavailable in the
-signal handler.
-.Pp
-See
-.Xr capsicum 4
-for more information about the capability mode.
-.It Dv PROC_TRAPCAP_STATUS
-Return the current status of signalling capability mode access
-violations for the specified process.
-The integer value pointed to by the
-.Fa data
-argument is set to the
-.Dv PROC_TRAPCAP_CTL_ENABLE
-value if the process control enables signal delivery, and to
-.Dv PROC_TRAPCAP_CTL_DISABLE
-otherwise.
-.Pp
-See the note about sysctl
-.Dv kern.trap_enotcap
-above, which gives independent global control of signal delivery.
-.It Dv PROC_PDEATHSIG_CTL
-Request the delivery of a signal when the parent of the calling
-process exits.
-.Fa idtype
-must be
-.Dv P_PID
-and
-.Fa id
-must be the either caller's pid or zero, with no difference in effect.
-The value is cleared for child processes
-and when executing set-user-ID or set-group-ID binaries.
-.Fa data
-must point to a value of type
-.Vt int
-indicating the signal
-that should be delivered to the caller.
-Use zero to cancel a previously requested signal delivery.
-.It Dv PROC_PDEATHSIG_STATUS
-Query the current signal number that will be delivered when the parent
-of the calling process exits.
-.Fa idtype
-must be
-.Dv P_PID
-and
-.Fa id
-must be the either caller's pid or zero, with no difference in effect.
-.Fa data
-must point to a memory location that can hold a value of type
-.Vt int .
-If signal delivery has not been requested, it will contain zero
-on return.
-.It Dv PROC_STACKGAP_CTL
-Controls the stack gaps in the specified process.
-A stack gap is the part of the growth area for a
-.Dv MAP_STACK
-mapped region that is reserved and never filled by memory.
-Instead, the process is guaranteed to receive a
-.Dv SIGSEGV
-signal on accessing pages in the gap.
-Gaps protect against stack overflow corrupting memory adjacent
-to the stack.
-.Pp
-The
-.Fa data
-argument must point to an integer variable containing flags.
-The following flags are allowed:
-.Bl -tag -width PROC_STACKGAP_DISABLE_EXEC
-.It Dv PROC_STACKGAP_ENABLE
-This flag is only accepted for consistency with
-.Dv PROC_STACKGAP_STATUS .
-If stack gaps are enabled, the flag is ignored.
-If disabled, the flag causes an
-.Ev EINVAL
-error to be returned.
-After gaps are disabled in a process, they can only be re-enabled when an
-.Xr execve 2
-is performed.
-.It Dv PROC_STACKGAP_DISABLE
-Disable stack gaps for the process.
-For existing stacks, the gap is no longer a reserved part of the growth
-area and can be filled by memory on access.
-.It Dv PROC_STACKGAP_ENABLE_EXEC
-Enable stack gaps for programs started after an
-.Xr execve 2
-by the specified process.
-.It Dv PROC_STACKGAP_DISABLE_EXEC
-Inherit disabled stack gaps state after
-.Xr execve 2 .
-In other words, if the currently executing program has stack gaps disabled,
-they are kept disabled on exec.
-If gaps were enabled, they are kept enabled after exec.
-.El
-.Pp
-The stack gap state is inherited from the parent on
-.Xr fork 2 .
-.It Dv PROC_STACKGAP_STATUS
-Returns the current stack gap state for the specified process.
-.Fa data
-must point to an integer variable, which is used to return a bitmask
-consisting of the following flags:
-.Bl -tag -width PROC_STACKGAP_DISABLE_EXEC
-.It Dv PROC_STACKGAP_ENABLE
-Stack gaps are enabled.
-.It Dv PROC_STACKGAP_DISABLE
-Stack gaps are disabled.
-.It Dv PROC_STACKGAP_ENABLE_EXEC
-Stack gaps are enabled in the process after
-.Xr execve 2 .
-.It Dv PROC_STACKGAP_DISABLE_EXEC
-Stack gaps are disabled in the process after
-.Xr execve 2 .
-.El
-.It Dv PROC_NO_NEW_PRIVS_CTL
-Allows one to ignore the SUID and SGID bits on the program
-images activated by
-.Xr execve 2
-in the specified process and its future descendants.
-The
-.Fa data
-parameter must point to the integer variable holding the following
-value:
-.Bl -tag -width PROC_NO_NEW_PRIVS_ENABLE
-.It Dv PROC_NO_NEW_PRIVS_ENABLE
-Request SUID and SGID bits to be ignored.
-.El
-.Pp
-It is not possible to disable it once it has been enabled.
-.It Dv PROC_NO_NEW_PRIVS_STATUS
-Returns the current status of SUID/SGID enablement for the target process.
-The
-.Fa data
-parameter must point to the integer variable, where one of the
-following values is written:
-.Bl -tag -width PROC_NO_NEW_PRIVS_DISABLE
-.It Dv PROC_NO_NEW_PRIVS_ENABLE
-.It Dv PROC_NO_NEW_PRIVS_DISABLE
-.El
-.It Dv PROC_WXMAP_CTL
-Controls the 'write exclusive against execution' permissions for the
-mappings in the process address space.
-It overrides the global settings established by the
-.Dv kern.elf{32/64}.allow_wx
-sysctl,
-and the corresponding bit in the ELF control note, see
-.Xr elfctl 1 .
-.Pp
-The
-.Fa data
-parameter must point to the integer variable holding one of the
-following values:
-.Bl -tag -width PROC_WX_MAPPINGS_DISALLOW_EXEC
-.It Dv PROC_WX_MAPPINGS_PERMIT
-Enable creation of mappings that have both write and execute
-protection attributes, in the specified process' address space.
-.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
-In the new address space created by
-.Xr execve 2 ,
-disallow creation of mappings that have both write and execute
-permissions.
-.El
-.Pp
-Once creation of writeable and executable mappings is allowed,
-it is impossible (and pointless) to disallow it.
-The only way to ensure the absence of such mappings after they
-were enabled in a given process, is to set the
-.Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
-flag and
-.Xr execve 2
-an image.
-.It Dv PROC_WXMAP_STATUS
-Returns the current status of the 'write exclusive against execution'
-enforcement for the specified process.
-The
-.Dv data
-parameter must point to the integer variable, where one of the
-following values is written:
-.Bl -tag -width PROC_WX_MAPPINGS_DISALLOW_EXEC
-.It Dv PROC_WX_MAPPINGS_PERMIT
-Creation of simultaneously writable and executable mapping is permitted,
-otherwise the process cannot create such mappings.
-.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
-After
-.Xr execve 2 ,
-the new address space should disallow creation of simultaneously
-writable and executable mappings.
-.El
-.Pp
-Additionally, if the address space of the process disallows
-creation of simultaneously writable and executable mappings and
-it is guaranteed that no such mapping was created since address space
-creation, the
-.Dv PROC_WXORX_ENFORCE
-flag is set in the returned value.
-.El
-.Sh x86 MACHINE-SPECIFIC REQUESTS
-.Bl -tag -width PROC_KPTI_STATUS
-.It Dv PROC_KPTI_CTL
-AMD64 only.
-Controls the Kernel Page Table Isolation (KPTI) option for the children
-of the specified process.
-For the command to work, the
-.Va vm.pmap.kpti
-tunable must be enabled on boot.
-It is not possible to change the KPTI setting for a running process,
-except at the
-.Xr execve 2 ,
-where the address space is reinitialized.
-.Pp
-The
-.Fa data
-parameter must point to an integer variable containing one of the
-following commands:
-.Bl -tag -width PROC_KPTI_CTL_DISABLE_ON_EXEC
-.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC
-Enable KPTI after
-.Xr execve 2 .
-.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC
-Disable KPTI after
-.Xr execve 2 .
-Only root or a process having the
-.Va PRIV_IO
-privilege might use this option.
-.El
-.It Dv PROC_KPTI_STATUS
-Returns the current KPTI status for the specified process.
-.Fa data
-must point to the integer variable, which returns the
-following statuses:
-.Bl -tag -width PROC_KPTI_CTL_DISABLE_ON_EXEC
-.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC
-.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC
-.El
-.Pp
-The status is or-ed with the
-.Va PROC_KPTI_STATUS_ACTIVE
-in case KPTI is active for the current address space of the process.
-.Sh NOTES
-Disabling tracing on a process should not be considered a security
-feature, as it is bypassable both by the kernel and privileged processes,
-and via other system mechanisms.
-As such, it should not be utilized to reliably protect cryptographic
-keying material or other confidential data.
-.Pp
-Note that processes can trivially bypass the 'no simultaneously
-writable and executable mappings' policy by first marking some mapping
-as writeable and write code to it, then removing write and adding
-execute permission.
-This may be legitimately required by some programs, such as JIT compilers.
-.Sh RETURN VALUES
-If an error occurs, a value of -1 is returned and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn procctl
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa data
-parameter points outside the process's allocated address space.
-.It Bq Er EINVAL
-The
-.Fa cmd
-argument specifies an unsupported command.
-.Pp
-The
-.Fa idtype
-argument specifies an unsupported identifier type.
-.It Bq Er EPERM
-The calling process does not have permission to perform the requested
-operation on any of the selected processes.
-.It Bq Er ESRCH
-No processes matched the requested
-.Fa idtype
-and
-.Fa id .
-.It Bq Er EINVAL
-An invalid operation or flag was passed in
-.Fa data
-for a
-.Dv PROC_SPROTECT
-command.
-.It Bq Er EPERM
-The
-.Fa idtype
-argument is not equal to
-.Dv P_PID ,
-or
-.Fa id
-is not equal to the pid of the calling process, for
-.Dv PROC_REAP_ACQUIRE
-or
-.Dv PROC_REAP_RELEASE
-requests.
-.It Bq Er EINVAL
-Invalid or undefined flags were passed to a
-.Dv PROC_REAP_KILL
-request.
-.It Bq Er EINVAL
-An invalid or zero signal number was requested for a
-.Dv PROC_REAP_KILL
-request.
-.It Bq Er EINVAL
-The
-.Dv PROC_REAP_RELEASE
-request was issued by the
-.Xr init 8
-process.
-.It Bq Er EBUSY
-The
-.Dv PROC_REAP_ACQUIRE
-request was issued by a process that had already acquired reaper status
-and has not yet released it.
-.It Bq Er EBUSY
-The
-.Dv PROC_TRACE_CTL
-request was issued for a process already being traced.
-.It Bq Er EPERM
-The
-.Dv PROC_TRACE_CTL
-request to re-enable tracing of the process
-.Po Dv PROC_TRACE_CTL_ENABLE Pc ,
-or to disable persistence of
-.Dv PROC_TRACE_CTL_DISABLE
-on
-.Xr execve 2
-was issued for a non-current process.
-.It Bq Er EINVAL
-The value of the integer
-.Fa data
-parameter for the
-.Dv PROC_TRACE_CTL
-or
-.Dv PROC_TRAPCAP_CTL
-request is invalid.
-.It Bq Er EINVAL
-The
-.Dv PROC_PDEATHSIG_CTL
-or
-.Dv PROC_PDEATHSIG_STATUS
-request referenced an unsupported
-.Fa id ,
-.Fa idtype
-or invalid signal number.
-.El
-.Sh SEE ALSO
-.Xr dtrace 1 ,
-.Xr proccontrol 1 ,
-.Xr protect 1 ,
-.Xr cap_enter 2 ,
-.Xr kill 2 ,
-.Xr ktrace 2 ,
-.Xr mmap 2 ,
-.Xr mprotect 2 ,
-.Xr ptrace 2 ,
-.Xr wait 2 ,
-.Xr capsicum 4 ,
-.Xr hwpmc 4 ,
-.Xr init 8
-.Sh HISTORY
-The
-.Fn procctl
-function appeared in
-.Fx 10.0 .
-.Pp
-The reaper facility is based on a similar feature of Linux and
-DragonflyBSD, and first appeared in
-.Fx 10.2 .
-.Pp
-The
-.Dv PROC_PDEATHSIG_CTL
-facility is based on the prctl(PR_SET_PDEATHSIG, ...) feature of Linux,
-and first appeared in
-.Fx 11.2 .
-.Pp
-The ASLR support was added to system for the checklists compliance in
-.Fx 13.0 .
diff --git a/lib/libc/sys/profil.2 b/lib/libc/sys/profil.2
deleted file mode 100644
index ecf660503fa3..000000000000
--- a/lib/libc/sys/profil.2
+++ /dev/null
@@ -1,121 +0,0 @@
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Donn Seeley of BSDI.
-.\"
-.\" 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.
-.\"
-.\" @(#)profil.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 1, 2017
-.Dt PROFIL 2
-.Os
-.Sh NAME
-.Nm profil
-.Nd control process profiling
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn profil "char *samples" "size_t size" "vm_offset_t offset" "int scale"
-.Sh DESCRIPTION
-The
-.Fn profil
-system call enables or disables
-program counter profiling of the current process.
-If profiling is enabled,
-then at every profiling clock tick,
-the kernel updates an appropriate count in the
-.Fa samples
-buffer.
-The frequency of the profiling clock is recorded
-in the header in the profiling output file.
-.Pp
-The buffer
-.Fa samples
-contains
-.Fa size
-bytes and is divided into
-a series of 16-bit bins.
-Each bin counts the number of times the program counter
-was in a particular address range in the process
-when a profiling clock tick occurred while profiling was enabled.
-For a given program counter address,
-the number of the corresponding bin is given
-by the relation:
-.Bd -literal -offset indent
-[(pc - offset) / 2] * scale / 65536
-.Ed
-.Pp
-The
-.Fa offset
-argument is the lowest address at which
-the kernel takes program counter samples.
-The
-.Fa scale
-argument ranges from 1 to 65536 and
-can be used to change the span of the bins.
-A scale of 65536 maps each bin to 2 bytes of address range;
-a scale of 32768 gives 4 bytes, 16384 gives 8 bytes and so on.
-Intermediate values provide approximate intermediate ranges.
-A
-.Fa scale
-value of 0 disables profiling.
-.Sh RETURN VALUES
-.Rv -std profil
-.Sh FILES
-.Bl -tag -width /usr/lib/gcrt0.o -compact
-.It Pa /usr/lib/gcrt0.o
-profiling C run-time startup file
-.It Pa gmon.out
-conventional name for profiling output file
-.El
-.Sh ERRORS
-The following error may be reported:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The buffer
-.Fa samples
-contains an invalid address.
-.El
-.Sh SEE ALSO
-.Xr gprof 1
-.Sh HISTORY
-The
-.Fn profil
-functionality first appeared in
-.At v3 .
-.Sh BUGS
-This routine should be named
-.Fn profile .
-.Pp
-The
-.Fa samples
-argument should really be a vector of type
-.Fa "unsigned short" .
-.Pp
-The format of the gmon.out file is undocumented.
diff --git a/lib/libc/sys/pselect.c b/lib/libc/sys/pselect.c
index 2ea717ef1d65..38477e39af44 100644
--- a/lib/libc/sys/pselect.c
+++ b/lib/libc/sys/pselect.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/select.h>
#include "libc_private.h"
@@ -41,8 +40,5 @@ int
pselect(int n, fd_set *rs, fd_set *ws, fd_set *es, const struct timespec *t,
const sigset_t *s)
{
-
- return (((int (*)(int, fd_set *, fd_set *, fd_set *,
- const struct timespec *, const sigset_t *))
- __libc_interposing[INTERPOS_pselect])(n, rs, ws, es, t, s));
+ return (INTERPOS_SYS(pselect, n, rs, ws, es, t, s));
}
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
deleted file mode 100644
index d7d244b1d84a..000000000000
--- a/lib/libc/sys/ptrace.2
+++ /dev/null
@@ -1,1435 +0,0 @@
-.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
-.\"
-.\" This file is in the public domain.
-.Dd December 15, 2022
-.Dt PTRACE 2
-.Os
-.Sh NAME
-.Nm ptrace
-.Nd process tracing and debugging
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/ptrace.h
-.Ft int
-.Fn ptrace "int request" "pid_t pid" "caddr_t addr" "int data"
-.Sh DESCRIPTION
-The
-.Fn ptrace
-system call
-provides tracing and debugging facilities.
-It allows one process
-(the
-.Em tracing
-process)
-to control another
-(the
-.Em traced
-process).
-The tracing process must first attach to the traced process, and then
-issue a series of
-.Fn ptrace
-system calls to control the execution of the process, as well as access
-process memory and register state.
-For the duration of the tracing session, the traced process will be
-.Dq re-parented ,
-with its parent process ID (and resulting behavior)
-changed to the tracing process.
-It is permissible for a tracing process to attach to more than one
-other process at a time.
-When the tracing process has completed its work, it must detach the
-traced process; if a tracing process exits without first detaching all
-processes it has attached, those processes will be killed.
-.Pp
-Most of the time, the traced process runs normally, but when it
-receives a signal
-(see
-.Xr sigaction 2 ) ,
-it stops.
-The tracing process is expected to notice this via
-.Xr wait 2
-or the delivery of a
-.Dv SIGCHLD
-signal, examine the state of the stopped process, and cause it to
-terminate or continue as appropriate.
-The signal may be a normal process signal, generated as a result of
-traced process behavior, or use of the
-.Xr kill 2
-system call; alternatively, it may be generated by the tracing facility
-as a result of attaching, stepping by the tracing
-process,
-or an event in the traced process.
-The tracing process may choose to intercept the signal, using it to
-observe process behavior (such as
-.Dv SIGTRAP ) ,
-or forward the signal to the process if appropriate.
-The
-.Fn ptrace
-system call
-is the mechanism by which all this happens.
-.Pp
-A traced process may report additional signal stops corresponding to
-events in the traced process.
-These additional signal stops are reported as
-.Dv SIGTRAP
-or
-.Dv SIGSTOP
-signals.
-The tracing process can use the
-.Dv PT_LWPINFO
-request to determine which events are associated with a
-.Dv SIGTRAP
-or
-.Dv SIGSTOP
-signal.
-Note that multiple events may be associated with a single signal.
-For example, events indicated by the
-.Dv PL_FLAG_BORN ,
-.Dv PL_FLAG_FORKED ,
-and
-.Dv PL_FLAG_EXEC
-flags are also reported as a system call exit event
-.Pq Dv PL_FLAG_SCX .
-The signal stop for a new child process enabled via
-.Dv PTRACE_FORK
-will report a
-.Dv SIGSTOP
-signal.
-All other additional signal stops use
-.Dv SIGTRAP .
-.Sh DETACH AND TERMINATION
-.Pp
-Normally, exiting tracing process should wait for all pending
-debugging events and then detach from all alive traced processes
-before exiting using
-.Dv PT_DETACH
-request.
-If tracing process exits without detaching, for instance due to abnormal
-termination, the destiny of the traced children processes is determined
-by the
-.Dv kern.kill_on_debugger_exit
-sysctl control.
-.Pp
-If the control is set to the default value 1, such traced processes
-are terminated.
-If set to zero, kernel implicitly detaches traced processes.
-Traced processes are un-stopped if needed, and then continue the execution
-without tracing.
-Kernel drops any
-.Dv SIGTRAP
-signals queued to the traced children, which could be either generated by
-not yet consumed debug events, or sent by other means, the later should
-not be done anyway.
-.Sh SELECTING THE TARGET
-The
-.Fa pid
-argument of the call specifies the target on which to perform
-the requested operation.
-For operations affecting the global process state, the process ID
-is typically passed there.
-Similarly, for operations affecting only a thread, the thread ID
-needs to be passed.
-.Pp
-Still, for global operations, the ID of any thread can be used as the
-target, and system will perform the request on the process owning
-that thread.
-If a thread operation got the process ID as
-.Fa pid ,
-the system randomly selects a thread from among the threads owned
-by the process.
-For single-threaded processes there is no difference between specifying
-process or thread ID as the target.
-.Sh DISABLING PTRACE
-The
-.Nm
-subsystem provides rich facilities to manipulate other processes state.
-Sometimes it may be desirable to disallow it either completely, or limit
-its scope.
-The following controls are provided for this:
-.Bl -tag -width security.bsd.unprivileged_proc_debug
-.It Dv security.bsd.allow_ptrace
-Setting this sysctl to zero value makes
-.Nm
-return
-.Er ENOSYS
-always as if the syscall is not implemented by the kernel.
-.It Dv security.bsd.unprivileged_proc_debug
-Setting this sysctl to zero disallows use of
-.Fn ptrace
-by unprivileged processes.
-.It Dv security.bsd.see_other_uids
-Setting this sysctl to zero value disallows
-.Fn ptrace
-requests from targeting processes with the real user identifier different
-from the real user identifier of the caller.
-The requests return
-.Er ESRCH
-if policy is not met.
-.It Dv security.bsd.see_other_gids
-Setting this sysctl to zero value disallows
-.Fn ptrace
-requests from process belonging to a group that is not also one of
-the group of the target process.
-The requests return
-.Er ESRCH
-if policy is not met.
-.It Dv securelevel and init
-The
-.Xr init 1
-process can only be traced with
-.Nm
-if securelevel is zero.
-.It Dv procctl(2) PROC_TRACE_CTL
-Process can deny attempts to trace itself with
-.Xr procctl 2
-.Dv PROC_TRACE_CTL
-request.
-In this case requests return
-.Xr EPERM
-error.
-.El
-.Sh TRACING EVENTS
-.Pp
-Each traced process has a tracing event mask.
-An event in the traced process only reports a
-signal stop if the corresponding flag is set in the tracing event mask.
-The current set of tracing event flags include:
-.Bl -tag -width "Dv PTRACE_SYSCALL"
-.It Dv PTRACE_EXEC
-Report a stop for a successful invocation of
-.Xr execve 2 .
-This event is indicated by the
-.Dv PL_FLAG_EXEC
-flag in the
-.Va pl_flags
-member of
-.Vt "struct ptrace_lwpinfo" .
-.It Dv PTRACE_SCE
-Report a stop on each system call entry.
-This event is indicated by the
-.Dv PL_FLAG_SCE
-flag in the
-.Va pl_flags
-member of
-.Vt "struct ptrace_lwpinfo" .
-.It Dv PTRACE_SCX
-Report a stop on each system call exit.
-This event is indicated by the
-.Dv PL_FLAG_SCX
-flag in the
-.Va pl_flags
-member of
-.Vt "struct ptrace_lwpinfo" .
-.It Dv PTRACE_SYSCALL
-Report stops for both system call entry and exit.
-.It Dv PTRACE_FORK
-This event flag controls tracing for new child processes of a traced process.
-.Pp
-When this event flag is enabled,
-new child processes will enable tracing and stop before executing their
-first instruction.
-The new child process will include the
-.Dv PL_FLAG_CHILD
-flag in the
-.Va pl_flags
-member of
-.Vt "struct ptrace_lwpinfo" .
-The traced process will report a stop that includes the
-.Dv PL_FLAG_FORKED
-flag.
-The process ID of the new child process will also be present in the
-.Va pl_child_pid
-member of
-.Vt "struct ptrace_lwpinfo" .
-If the new child process was created via
-.Xr vfork 2 ,
-the traced process's stop will also include the
-.Dv PL_FLAG_VFORKED
-flag.
-Note that new child processes will be attached with the default
-tracing event mask;
-they do not inherit the event mask of the traced process.
-.Pp
-When this event flag is not enabled,
-new child processes will execute without tracing enabled.
-.It Dv PTRACE_LWP
-This event flag controls tracing of LWP
-.Pq kernel thread
-creation and destruction.
-When this event is enabled,
-new LWPs will stop and report an event with
-.Dv PL_FLAG_BORN
-set before executing their first instruction,
-and exiting LWPs will stop and report an event with
-.Dv PL_FLAG_EXITED
-set before completing their termination.
-.Pp
-Note that new processes do not report an event for the creation of their
-initial thread,
-and exiting processes do not report an event for the termination of the
-last thread.
-.It Dv PTRACE_VFORK
-Report a stop event when a parent process resumes after a
-.Xr vfork 2 .
-.Pp
-When a thread in the traced process creates a new child process via
-.Xr vfork 2 ,
-the stop that reports
-.Dv PL_FLAG_FORKED
-and
-.Dv PL_FLAG_SCX
-occurs just after the child process is created,
-but before the thread waits for the child process to stop sharing process
-memory.
-If a debugger is not tracing the new child process,
-it must ensure that no breakpoints are enabled in the shared process
-memory before detaching from the new child process.
-This means that no breakpoints are enabled in the parent process either.
-.Pp
-The
-.Dv PTRACE_VFORK
-flag enables a new stop that indicates when the new child process stops
-sharing the process memory of the parent process.
-A debugger can reinsert breakpoints in the parent process and resume it
-in response to this event.
-This event is indicated by setting the
-.Dv PL_FLAG_VFORK_DONE
-flag.
-.El
-.Pp
-The default tracing event mask when attaching to a process via
-.Dv PT_ATTACH ,
-.Dv PT_TRACE_ME ,
-or
-.Dv PTRACE_FORK
-includes only
-.Dv PTRACE_EXEC
-events.
-All other event flags are disabled.
-.Sh PTRACE REQUESTS
-.Pp
-The
-.Fa request
-argument specifies what operation is being performed; the meaning of
-the rest of the arguments depends on the operation, but except for one
-special case noted below, all
-.Fn ptrace
-calls are made by the tracing process, and the
-.Fa pid
-argument specifies the process ID of the traced process
-or a corresponding thread ID.
-The
-.Fa request
-argument
-can be:
-.Bl -tag -width "Dv PT_GET_EVENT_MASK"
-.It Dv PT_TRACE_ME
-This request is the only one used by the traced process; it declares
-that the process expects to be traced by its parent.
-All the other arguments are ignored.
-(If the parent process does not expect to trace the child, it will
-probably be rather confused by the results; once the traced process
-stops, it cannot be made to continue except via
-.Fn ptrace . )
-When a process has used this request and calls
-.Xr execve 2
-or any of the routines built on it
-(such as
-.Xr execv 3 ) ,
-it will stop before executing the first instruction of the new image.
-Also, any setuid or setgid bits on the executable being executed will
-be ignored.
-If the child was created by
-.Xr vfork 2
-system call or
-.Xr rfork 2
-call with the
-.Dv RFMEM
-flag specified, the debugging events are reported to the parent
-only after the
-.Xr execve 2
-is executed.
-.It Dv PT_READ_I , Dv PT_READ_D
-These requests read a single
-.Vt int
-of data from the traced process's address space.
-Traditionally,
-.Fn ptrace
-has allowed for machines with distinct address spaces for instruction
-and data, which is why there are two requests: conceptually,
-.Dv PT_READ_I
-reads from the instruction space and
-.Dv PT_READ_D
-reads from the data space.
-In the current
-.Fx
-implementation, these two requests are completely identical.
-The
-.Fa addr
-argument specifies the address
-(in the traced process's virtual address space)
-at which the read is to be done.
-This address does not have to meet any alignment constraints.
-The value read is returned as the return value from
-.Fn ptrace .
-.It Dv PT_WRITE_I , Dv PT_WRITE_D
-These requests parallel
-.Dv PT_READ_I
-and
-.Dv PT_READ_D ,
-except that they write rather than read.
-The
-.Fa data
-argument supplies the value to be written.
-.It Dv PT_IO
-This request allows reading and writing arbitrary amounts of data in
-the traced process's address space.
-The
-.Fa addr
-argument specifies a pointer to a
-.Vt "struct ptrace_io_desc" ,
-which is defined as follows:
-.Bd -literal
-struct ptrace_io_desc {
- int piod_op; /* I/O operation */
- void *piod_offs; /* child offset */
- void *piod_addr; /* parent offset */
- size_t piod_len; /* request length */
-};
-
-/*
- * Operations in piod_op.
- */
-#define PIOD_READ_D 1 /* Read from D space */
-#define PIOD_WRITE_D 2 /* Write to D space */
-#define PIOD_READ_I 3 /* Read from I space */
-#define PIOD_WRITE_I 4 /* Write to I space */
-.Ed
-.Pp
-The
-.Fa data
-argument is ignored.
-The actual number of bytes read or written is stored in
-.Va piod_len
-upon return.
-.It Dv PT_CONTINUE
-The traced process continues execution.
-The
-.Fa addr
-argument
-is an address specifying the place where execution is to be resumed
-(a new value for the program counter),
-or
-.Po Vt caddr_t Pc Ns 1
-to indicate that execution is to pick up where it left off.
-The
-.Fa data
-argument
-provides a signal number to be delivered to the traced process as it
-resumes execution, or 0 if no signal is to be sent.
-.It Dv PT_STEP
-The traced process is single stepped one instruction.
-The
-.Fa addr
-argument
-should be passed
-.Po Vt caddr_t Pc Ns 1 .
-The
-.Fa data
-argument
-provides a signal number to be delivered to the traced process as it
-resumes execution, or 0 if no signal is to be sent.
-.It Dv PT_KILL
-The traced process terminates, as if
-.Dv PT_CONTINUE
-had been used with
-.Dv SIGKILL
-given as the signal to be delivered.
-.It Dv PT_ATTACH
-This request allows a process to gain control of an otherwise
-unrelated process and begin tracing it.
-It does not need any cooperation from the process to trace.
-In
-this case,
-.Fa pid
-specifies the process ID of the process to trace, and the other
-two arguments are ignored.
-This request requires that the target process must have the same real
-UID as the tracing process, and that it must not be executing a setuid
-or setgid executable.
-(If the tracing process is running as root, these restrictions do not
-apply.)
-The tracing process will see the newly-traced process stop and may
-then control it as if it had been traced all along.
-.It Dv PT_DETACH
-This request is like PT_CONTINUE, except that it does not allow
-specifying an alternate place to continue execution, and after it
-succeeds, the traced process is no longer traced and continues
-execution normally.
-.It Dv PT_GETREGS
-This request reads the traced process's machine registers into the
-.Do
-.Vt "struct reg"
-.Dc
-(defined in
-.In machine/reg.h )
-pointed to by
-.Fa addr .
-.It Dv PT_SETREGS
-This request is the converse of
-.Dv PT_GETREGS ;
-it loads the traced process's machine registers from the
-.Do
-.Vt "struct reg"
-.Dc
-(defined in
-.In machine/reg.h )
-pointed to by
-.Fa addr .
-.It Dv PT_GETFPREGS
-This request reads the traced process's floating-point registers into
-the
-.Do
-.Vt "struct fpreg"
-.Dc
-(defined in
-.In machine/reg.h )
-pointed to by
-.Fa addr .
-.It Dv PT_SETFPREGS
-This request is the converse of
-.Dv PT_GETFPREGS ;
-it loads the traced process's floating-point registers from the
-.Do
-.Vt "struct fpreg"
-.Dc
-(defined in
-.In machine/reg.h )
-pointed to by
-.Fa addr .
-.It Dv PT_GETDBREGS
-This request reads the traced process's debug registers into
-the
-.Do
-.Vt "struct dbreg"
-.Dc
-(defined in
-.In machine/reg.h )
-pointed to by
-.Fa addr .
-.It Dv PT_SETDBREGS
-This request is the converse of
-.Dv PT_GETDBREGS ;
-it loads the traced process's debug registers from the
-.Do
-.Vt "struct dbreg"
-.Dc
-(defined in
-.In machine/reg.h )
-pointed to by
-.Fa addr .
-.It Dv PT_GETREGSET
-This request reads the registers from the traced process.
-The
-.Fa data
-argument specifies the register set to read, with the
-.Fa addr
-argument pointing at a
-.Vt "struct iovec"
-where the
-.Va iov_base
-field points to a register set specific structure to hold the registers,
-and the
-.Va iov_len
-field holds the length of the structure.
-.It Dv PT_SETREGSET
-This request writes to the registers of the traced process.
-The
-.Fa data
-argument specifies the register set to write to, with the
-.Fa addr
-argument pointing at a
-.Vt "struct iovec"
-where the
-.Va iov_base
-field points to a register set specific structure to hold the registers,
-and the
-.Va iov_len
-field holds the length of the structure.
-If
-.Va iov_base
-is NULL the kernel will return the expected length of the register set
-specific structure in the
-.Va iov_len
-field and not change the target register set.
-.It Dv PT_LWPINFO
-This request can be used to obtain information about the kernel thread,
-also known as light-weight process, that caused the traced process to stop.
-The
-.Fa addr
-argument specifies a pointer to a
-.Vt "struct ptrace_lwpinfo" ,
-which is defined as follows:
-.Bd -literal
-struct ptrace_lwpinfo {
- lwpid_t pl_lwpid;
- int pl_event;
- int pl_flags;
- sigset_t pl_sigmask;
- sigset_t pl_siglist;
- siginfo_t pl_siginfo;
- char pl_tdname[MAXCOMLEN + 1];
- pid_t pl_child_pid;
- u_int pl_syscall_code;
- u_int pl_syscall_narg;
-};
-.Ed
-.Pp
-The
-.Fa data
-argument is to be set to the size of the structure known to the caller.
-This allows the structure to grow without affecting older programs.
-.Pp
-The fields in the
-.Vt "struct ptrace_lwpinfo"
-have the following meaning:
-.Bl -tag -width indent -compact
-.It Va pl_lwpid
-LWP id of the thread
-.It Va pl_event
-Event that caused the stop.
-Currently defined events are:
-.Bl -tag -width "Dv PL_EVENT_SIGNAL" -compact
-.It Dv PL_EVENT_NONE
-No reason given
-.It Dv PL_EVENT_SIGNAL
-Thread stopped due to the pending signal
-.El
-.It Va pl_flags
-Flags that specify additional details about observed stop.
-Currently defined flags are:
-.Bl -tag -width indent -compact
-.It Dv PL_FLAG_SCE
-The thread stopped due to system call entry, right after the kernel is entered.
-The debugger may examine syscall arguments that are stored in memory and
-registers according to the ABI of the current process, and modify them,
-if needed.
-.It Dv PL_FLAG_SCX
-The thread is stopped immediately before syscall is returning to the usermode.
-The debugger may examine system call return values in the ABI-defined registers
-and/or memory.
-.It Dv PL_FLAG_EXEC
-When
-.Dv PL_FLAG_SCX
-is set, this flag may be additionally specified to inform that the
-program being executed by debuggee process has been changed by successful
-execution of a system call from the
-.Fn execve 2
-family.
-.It Dv PL_FLAG_SI
-Indicates that
-.Va pl_siginfo
-member of
-.Vt "struct ptrace_lwpinfo"
-contains valid information.
-.It Dv PL_FLAG_FORKED
-Indicates that the process is returning from a call to
-.Fn fork 2
-that created a new child process.
-The process identifier of the new process is available in the
-.Va pl_child_pid
-member of
-.Vt "struct ptrace_lwpinfo" .
-.It Dv PL_FLAG_CHILD
-The flag is set for first event reported from a new child which is
-automatically attached when
-.Dv PTRACE_FORK
-is enabled.
-.It Dv PL_FLAG_BORN
-This flag is set for the first event reported from a new LWP when
-.Dv PTRACE_LWP
-is enabled.
-It is reported along with
-.Dv PL_FLAG_SCX .
-.It Dv PL_FLAG_EXITED
-This flag is set for the last event reported by an exiting LWP when
-.Dv PTRACE_LWP
-is enabled.
-Note that this event is not reported when the last LWP in a process exits.
-The termination of the last thread is reported via a normal process exit
-event.
-.It Dv PL_FLAG_VFORKED
-Indicates that the thread is returning from a call to
-.Xr vfork 2
-that created a new child process.
-This flag is set in addition to
-.Dv PL_FLAG_FORKED .
-.It Dv PL_FLAG_VFORK_DONE
-Indicates that the thread has resumed after a child process created via
-.Xr vfork 2
-has stopped sharing its address space with the traced process.
-.El
-.It Va pl_sigmask
-The current signal mask of the LWP
-.It Va pl_siglist
-The current pending set of signals for the LWP.
-Note that signals that are delivered to the process would not appear
-on an LWP siglist until the thread is selected for delivery.
-.It Va pl_siginfo
-The siginfo that accompanies the signal pending.
-Only valid for
-.Dv PL_EVENT_SIGNAL
-stop when
-.Dv PL_FLAG_SI
-is set in
-.Va pl_flags .
-.It Va pl_tdname
-The name of the thread.
-.It Va pl_child_pid
-The process identifier of the new child process.
-Only valid for a
-.Dv PL_EVENT_SIGNAL
-stop when
-.Dv PL_FLAG_FORKED
-is set in
-.Va pl_flags .
-.It Va pl_syscall_code
-The ABI-specific identifier of the current system call.
-Note that for indirect system calls this field reports the indirected
-system call.
-Only valid when
-.Dv PL_FLAG_SCE
-or
-.Dv PL_FLAG_SCX
-is set in
-.Va pl_flags .
-.It Va pl_syscall_narg
-The number of arguments passed to the current system call not counting
-the system call identifier.
-Note that for indirect system calls this field reports the arguments
-passed to the indirected system call.
-Only valid when
-.Dv PL_FLAG_SCE
-or
-.Dv PL_FLAG_SCX
-is set in
-.Va pl_flags .
-.El
-.It Dv PT_GETNUMLWPS
-This request returns the number of kernel threads associated with the
-traced process.
-.It Dv PT_GETLWPLIST
-This request can be used to get the current thread list.
-A pointer to an array of type
-.Vt lwpid_t
-should be passed in
-.Fa addr ,
-with the array size specified by
-.Fa data .
-The return value from
-.Fn ptrace
-is the count of array entries filled in.
-.It Dv PT_SETSTEP
-This request will turn on single stepping of the specified process.
-Stepping is automatically disabled when a single step trap is caught.
-.It Dv PT_CLEARSTEP
-This request will turn off single stepping of the specified process.
-.It Dv PT_SUSPEND
-This request will suspend the specified thread.
-.It Dv PT_RESUME
-This request will resume the specified thread.
-.It Dv PT_TO_SCE
-This request will set the
-.Dv PTRACE_SCE
-event flag to trace all future system call entries and continue the process.
-The
-.Fa addr
-and
-.Fa data
-arguments are used the same as for
-.Dv PT_CONTINUE .
-.It Dv PT_TO_SCX
-This request will set the
-.Dv PTRACE_SCX
-event flag to trace all future system call exits and continue the process.
-The
-.Fa addr
-and
-.Fa data
-arguments are used the same as for
-.Dv PT_CONTINUE .
-.It Dv PT_SYSCALL
-This request will set the
-.Dv PTRACE_SYSCALL
-event flag to trace all future system call entries and exits and continue
-the process.
-The
-.Fa addr
-and
-.Fa data
-arguments are used the same as for
-.Dv PT_CONTINUE .
-.It Dv PT_GET_SC_ARGS
-For the thread which is stopped in either
-.Dv PL_FLAG_SCE
-or
-.Dv PL_FLAG_SCX
-state, that is, on entry or exit to a syscall,
-this request fetches the syscall arguments.
-.Pp
-The arguments are copied out into the buffer pointed to by the
-.Fa addr
-pointer, sequentially.
-Each syscall argument is stored as the machine word.
-Kernel copies out as many arguments as the syscall accepts,
-see the
-.Va pl_syscall_narg
-member of the
-.Vt struct ptrace_lwpinfo ,
-but not more than the
-.Fa data
-bytes in total are copied.
-.It Dv PT_GET_SC_RET
-Fetch the system call return values on exit from a syscall.
-This request is only valid for threads stopped in a syscall
-exit (the
-.Dv PL_FLAG_SCX
-state).
-The
-.Fa addr
-argument specifies a pointer to a
-.Vt "struct ptrace_sc_ret" ,
-which is defined as follows:
-.Bd -literal
-struct ptrace_sc_ret {
- register_t sr_retval[2];
- int sr_error;
-};
-.Ed
-.Pp
-The
-.Fa data
-argument is set to the size of the structure.
-.Pp
-If the system call completed successfully,
-.Va sr_error
-is set to zero and the return values of the system call are saved in
-.Va sr_retval .
-If the system call failed to execute,
-.Va sr_error
-field is set to a positive
-.Xr errno 2
-value.
-If the system call completed in an unusual fashion,
-.Va sr_error
-is set to a negative value:
-.Bl -tag -width Dv EJUSTRETURN -compact
-.It Dv ERESTART
-System call will be restarted.
-.It Dv EJUSTRETURN
-System call completed sucessfully but did not set a return value
-.Po for example,
-.Xr setcontext 2
-and
-.Xr sigreturn 2
-.Pc .
-.El
-.It Dv PT_FOLLOW_FORK
-This request controls tracing for new child processes of a traced process.
-If
-.Fa data
-is non-zero,
-.Dv PTRACE_FORK
-is set in the traced process's event tracing mask.
-If
-.Fa data
-is zero,
-.Dv PTRACE_FORK
-is cleared from the traced process's event tracing mask.
-.It Dv PT_LWP_EVENTS
-This request controls tracing of LWP creation and destruction.
-If
-.Fa data
-is non-zero,
-.Dv PTRACE_LWP
-is set in the traced process's event tracing mask.
-If
-.Fa data
-is zero,
-.Dv PTRACE_LWP
-is cleared from the traced process's event tracing mask.
-.It Dv PT_GET_EVENT_MASK
-This request reads the traced process's event tracing mask into the
-integer pointed to by
-.Fa addr .
-The size of the integer must be passed in
-.Fa data .
-.It Dv PT_SET_EVENT_MASK
-This request sets the traced process's event tracing mask from the
-integer pointed to by
-.Fa addr .
-The size of the integer must be passed in
-.Fa data .
-.It Dv PT_VM_TIMESTAMP
-This request returns the generation number or timestamp of the memory map of
-the traced process as the return value from
-.Fn ptrace .
-This provides a low-cost way for the tracing process to determine if the
-VM map changed since the last time this request was made.
-.It Dv PT_VM_ENTRY
-This request is used to iterate over the entries of the VM map of the traced
-process.
-The
-.Fa addr
-argument specifies a pointer to a
-.Vt "struct ptrace_vm_entry" ,
-which is defined as follows:
-.Bd -literal
-struct ptrace_vm_entry {
- int pve_entry;
- int pve_timestamp;
- u_long pve_start;
- u_long pve_end;
- u_long pve_offset;
- u_int pve_prot;
- u_int pve_pathlen;
- long pve_fileid;
- uint32_t pve_fsid;
- char *pve_path;
-};
-.Ed
-.Pp
-The first entry is returned by setting
-.Va pve_entry
-to zero.
-Subsequent entries are returned by leaving
-.Va pve_entry
-unmodified from the value returned by previous requests.
-The
-.Va pve_timestamp
-field can be used to detect changes to the VM map while iterating over the
-entries.
-The tracing process can then take appropriate action, such as restarting.
-By setting
-.Va pve_pathlen
-to a non-zero value on entry, the pathname of the backing object is returned
-in the buffer pointed to by
-.Va pve_path ,
-provided the entry is backed by a vnode.
-The
-.Va pve_pathlen
-field is updated with the actual length of the pathname (including the
-terminating null character).
-The
-.Va pve_offset
-field is the offset within the backing object at which the range starts.
-The range is located in the VM space at
-.Va pve_start
-and extends up to
-.Va pve_end
-(inclusive).
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_COREDUMP
-This request creates a coredump for the stopped program.
-The
-.Fa addr
-argument specifies a pointer to a
-.Vt "struct ptrace_coredump" ,
-which is defined as follows:
-.Bd -literal
-struct ptrace_coredump {
- int pc_fd;
- uint32_t pc_flags;
- off_t pc_limit;
-};
-.Ed
-The fields of the structure are:
-.Bl -tag -width pc_flags
-.It Dv pc_fd
-File descriptor to write the dump to.
-It must refer to a regular file, opened for writing.
-.It Dv pc_flags
-Flags.
-The following flags are defined:
-.Bl -tag -width PC_COMPRESS
-.It Dv PC_COMPRESS
-Request compression of the dump.
-.It Dv PC_ALL
-Include non-dumpable entries into the dump.
-The dumper ignores
-.Dv MAP_NOCORE
-flag of the process map entry, but device mappings are not dumped even with
-.Dv PC_ALL
-set.
-.El
-.It Dv pc_limit
-Maximum size of the coredump.
-Specify zero for no limit.
-.El
-.Pp
-The size of
-.Vt "struct ptrace_coredump"
-must be passed in
-.Fa data .
-.It Dv PT_SC_REMOTE
-Request to execute a syscall in the context of the traced process,
-in the specified thread.
-The
-.Fa addr
-argument must point to the
-.Vt "struct ptrace_sc_remote" ,
-which describes the requested syscall and its arguments, and receives
-the result.
-The size of
-.Vt "struct ptrace_sc_remote"
-must be passed in
-.Fa data.
-.Bd -literal
-struct ptrace_sc_remote {
- struct ptrace_sc_ret pscr_ret;
- u_int pscr_syscall;
- u_int pscr_nargs;
- u_long *pscr_args;
-};
-.Ed
-The
-.Dv pscr_syscall
-contains the syscall number to execute, the
-.Dv pscr_nargs
-is the number of supplied arguments, which are supplied in the
-.Dv pscr_args
-array.
-Result of the execution is returned in the
-.Dv pscr_ret
-member.
-Note that the request and its result do not affect the returned value from
-the currently executed syscall, if any.
-.El
-.Sh PT_COREDUMP and PT_SC_REMOTE usage
-The process must be stopped before dumping or initiating a remote system call.
-A single thread in the target process is temporarily unsuspended
-in the kernel to perform the action.
-If the
-.Nm
-call fails before a thread is unsuspended, there is no event to
-.Xr waitpid 2
-for.
-If a thread was unsuspended, it will stop again before the
-.Nm
-call returns, and the process must be waited upon using
-.Xr waitpid 2
-to consume the new stop event.
-Since it is hard to deduce whether a thread was unsuspended before
-an error occurred, it is recommended to unconditionally perform
-.Xr waitpid 2
-with
-.Dv WNOHANG
-flag after
-.Dv PT_COREDUMP
-and
-.Dv PT_SC_REMOTE ,
-and silently accept zero result from it.
-.Pp
-For
-.Dv PT_SC_REMOTE ,
-the selected thread must be stopped in the safe place, which is
-currently defined as a syscall exit, or a return from kernel to
-user mode (basically, a signal handler call place).
-Kernel returns
-.Er EBUSY
-status if attempt is made to execute remote syscall at unsafe stop.
-.Pp
-Note that neither
-.Dv kern.trap_enotcap
-sysctl setting, nor the corresponding
-.Xr procctl 2
-flag
-.Dv PROC_TRAPCAP_CTL_ENABLE
-are obeyed during the execution of the syscall by
-.Dv PT_SC_REMOTE .
-In other words,
-.Dv SIGTRAP
-signal is not sent to a process executing in capability mode,
-which violated a mode access restriction.
-.Pp
-Note that due to the mode of execution for the remote syscall, in
-particular, the setting where only one thread is allowed to run,
-the syscall might block on resources owned by suspended threads.
-This might result in the target process deadlock.
-In this situation, the only way out is to kill the target.
-.Sh ARM MACHINE-SPECIFIC REQUESTS
-.Bl -tag -width "Dv PT_SETVFPREGS"
-.It Dv PT_GETVFPREGS
-Return the thread's
-.Dv VFP
-machine state in the buffer pointed to by
-.Fa addr .
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_SETVFPREGS
-Set the thread's
-.Dv VFP
-machine state from the buffer pointed to by
-.Fa addr .
-.Pp
-The
-.Fa data
-argument is ignored.
-.El
-.Sh x86 MACHINE-SPECIFIC REQUESTS
-.Bl -tag -width "Dv PT_GETXSTATE_INFO"
-.It Dv PT_GETXMMREGS
-Copy the XMM FPU state into the buffer pointed to by the
-argument
-.Fa addr .
-The buffer has the same layout as the 32-bit save buffer for the
-machine instruction
-.Dv FXSAVE .
-.Pp
-This request is only valid for i386 programs, both on native 32-bit
-systems and on amd64 kernels.
-For 64-bit amd64 programs, the XMM state is reported as part of
-the FPU state returned by the
-.Dv PT_GETFPREGS
-request.
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_SETXMMREGS
-Load the XMM FPU state for the thread from the buffer pointed to
-by the argument
-.Fa addr .
-The buffer has the same layout as the 32-bit load buffer for the
-machine instruction
-.Dv FXRSTOR .
-.Pp
-As with
-.Dv PT_GETXMMREGS ,
-this request is only valid for i386 programs.
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_GETXSTATE_INFO
-Report which XSAVE FPU extensions are supported by the CPU
-and allowed in userspace programs.
-The
-.Fa addr
-argument must point to a variable of type
-.Vt struct ptrace_xstate_info ,
-which contains the information on the request return.
-.Vt struct ptrace_xstate_info
-is defined as follows:
-.Bd -literal
-struct ptrace_xstate_info {
- uint64_t xsave_mask;
- uint32_t xsave_len;
-};
-.Ed
-The
-.Dv xsave_mask
-field is a bitmask of the currently enabled extensions.
-The meaning of the bits is defined in the Intel and AMD
-processor documentation.
-The
-.Dv xsave_len
-field reports the length of the XSAVE area for storing the hardware
-state for currently enabled extensions in the format defined by the x86
-.Dv XSAVE
-machine instruction.
-.Pp
-The
-.Fa data
-argument value must be equal to the size of the
-.Vt struct ptrace_xstate_info .
-.It Dv PT_GETXSTATE
-Return the content of the XSAVE area for the thread.
-The
-.Fa addr
-argument points to the buffer where the content is copied, and the
-.Fa data
-argument specifies the size of the buffer.
-The kernel copies out as much content as allowed by the buffer size.
-The buffer layout is specified by the layout of the save area for the
-.Dv XSAVE
-machine instruction.
-.It Dv PT_SETXSTATE
-Load the XSAVE state for the thread from the buffer specified by the
-.Fa addr
-pointer.
-The buffer size is passed in the
-.Fa data
-argument.
-The buffer must be at least as large as the
-.Vt struct savefpu
-(defined in
-.Pa x86/fpu.h )
-to allow the complete x87 FPU and XMM state load.
-It must not be larger than the XSAVE state length, as reported by the
-.Dv xsave_len
-field from the
-.Vt struct ptrace_xstate_info
-of the
-.Dv PT_GETXSTATE_INFO
-request.
-Layout of the buffer is identical to the layout of the load area for the
-.Dv XRSTOR
-machine instruction.
-.It Dv PT_GETFSBASE
-Return the value of the base used when doing segmented
-memory addressing using the %fs segment register.
-The
-.Fa addr
-argument points to an
-.Vt unsigned long
-variable where the base value is stored.
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_GETGSBASE
-Like the
-.Dv PT_GETFSBASE
-request, but returns the base for the %gs segment register.
-.It Dv PT_SETFSBASE
-Set the base for the %fs segment register to the value pointed to
-by the
-.Fa addr
-argument.
-.Fa addr
-must point to the
-.Vt unsigned long
-variable containing the new base.
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_SETGSBASE
-Like the
-.Dv PT_SETFSBASE
-request, but sets the base for the %gs segment register.
-.El
-.Sh PowerPC MACHINE-SPECIFIC REQUESTS
-.Bl -tag -width "Dv PT_SETVRREGS"
-.It Dv PT_GETVRREGS
-Return the thread's
-.Dv ALTIVEC
-machine state in the buffer pointed to by
-.Fa addr .
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_SETVRREGS
-Set the thread's
-.Dv ALTIVEC
-machine state from the buffer pointed to by
-.Fa addr .
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_GETVSRREGS
-Return doubleword 1 of the thread's
-.Dv VSX
-registers VSR0-VSR31 in the buffer pointed to by
-.Fa addr .
-.Pp
-The
-.Fa data
-argument is ignored.
-.It Dv PT_SETVSRREGS
-Set doubleword 1 of the thread's
-.Dv VSX
-registers VSR0-VSR31 from the buffer pointed to by
-.Fa addr .
-.Pp
-The
-.Fa data
-argument is ignored.
-.El
-.Pp
-Additionally, other machine-specific requests can exist.
-.Sh RETURN VALUES
-Most requests return 0 on success and \-1 on error.
-Some requests can cause
-.Fn ptrace
-to return
-\-1
-as a non-error value, among them are
-.Dv PT_READ_I
-and
-.Dv PT_READ_D ,
-which return the value read from the process memory on success.
-To disambiguate,
-.Va errno
-can be set to 0 before the call and checked afterwards.
-.Pp
-The current
-.Fn ptrace
-implementation always sets
-.Va errno
-to 0 before calling into the kernel, both for historic reasons and for
-consistency with other operating systems.
-It is recommended to assign zero to
-.Va errno
-explicitly for forward compatibility.
-.Sh ERRORS
-The
-.Fn ptrace
-system call may fail if:
-.Bl -tag -width Er
-.It Bq Er ESRCH
-.Bl -bullet -compact
-.It
-No process having the specified process ID exists.
-.El
-.It Bq Er EINVAL
-.Bl -bullet -compact
-.It
-A process attempted to use
-.Dv PT_ATTACH
-on itself.
-.It
-The
-.Fa request
-argument
-was not one of the legal requests.
-.It
-The signal number
-(in
-.Fa data )
-to
-.Dv PT_CONTINUE
-was neither 0 nor a legal signal number.
-.It
-.Dv PT_GETREGS ,
-.Dv PT_SETREGS ,
-.Dv PT_GETFPREGS ,
-.Dv PT_SETFPREGS ,
-.Dv PT_GETDBREGS ,
-or
-.Dv PT_SETDBREGS
-was attempted on a process with no valid register set.
-(This is normally true only of system processes.)
-.It
-.Dv PT_VM_ENTRY
-was given an invalid value for
-.Fa pve_entry .
-This can also be caused by changes to the VM map of the process.
-.It
-The size (in
-.Fa data )
-provided to
-.Dv PT_LWPINFO
-was less than or equal to zero, or larger than the
-.Vt ptrace_lwpinfo
-structure known to the kernel.
-.It
-The size (in
-.Fa data )
-provided to the x86-specific
-.Dv PT_GETXSTATE_INFO
-request was not equal to the size of the
-.Vt struct ptrace_xstate_info .
-.It
-The size (in
-.Fa data )
-provided to the x86-specific
-.Dv PT_SETXSTATE
-request was less than the size of the x87 plus the XMM save area.
-.It
-The size (in
-.Fa data )
-provided to the x86-specific
-.Dv PT_SETXSTATE
-request was larger than returned in the
-.Dv xsave_len
-member of the
-.Vt struct ptrace_xstate_info
-from the
-.Dv PT_GETXSTATE_INFO
-request.
-.It
-The base value, provided to the amd64-specific requests
-.Dv PT_SETFSBASE
-or
-.Dv PT_SETGSBASE ,
-pointed outside of the valid user address space.
-This error will not occur in 32-bit programs.
-.El
-.It Bq Er EBUSY
-.Bl -bullet -compact
-.It
-.Dv PT_ATTACH
-was attempted on a process that was already being traced.
-.It
-A request attempted to manipulate a process that was being traced by
-some process other than the one making the request.
-.It
-A request
-(other than
-.Dv PT_ATTACH )
-specified a process that was not stopped.
-.El
-.It Bq Er EPERM
-.Bl -bullet -compact
-.It
-A request
-(other than
-.Dv PT_ATTACH )
-attempted to manipulate a process that was not being traced at all.
-.It
-An attempt was made to use
-.Dv PT_ATTACH
-on a process in violation of the requirements listed under
-.Dv PT_ATTACH
-above.
-.El
-.It Bq Er ENOENT
-.Bl -bullet -compact
-.It
-.Dv PT_VM_ENTRY
-previously returned the last entry of the memory map.
-No more entries exist.
-.El
-.It Bq Er ENOMEM
-.Bl -bullet -compact
-.It
-A
-.Dv PT_READ_I,
-.Dv PT_READ_D,
-.Dv PT_WRITE_I, or
-.Dv PT_WRITE_D
-request attempted to access an invalid address, or a memory allocation failure
-occurred when accessing process memory.
-.El
-.It Bq Er ENAMETOOLONG
-.Bl -bullet -compact
-.It
-.Dv PT_VM_ENTRY
-cannot return the pathname of the backing object because the buffer is not big
-enough.
-.Fa pve_pathlen
-holds the minimum buffer size required on return.
-.El
-.El
-.Sh SEE ALSO
-.Xr execve 2 ,
-.Xr sigaction 2 ,
-.Xr wait 2 ,
-.Xr execv 3 ,
-.Xr i386_clr_watch 3 ,
-.Xr i386_set_watch 3
-.Sh HISTORY
-The
-.Fn ptrace
-function appeared in
-.At v6 .
diff --git a/lib/libc/sys/ptrace.c b/lib/libc/sys/ptrace.c
deleted file mode 100644
index 55ad50e025aa..000000000000
--- a/lib/libc/sys/ptrace.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016 The FreeBSD Foundation.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/ptrace.h>
-#include <errno.h>
-#include "libc_private.h"
-
-__weak_reference(_ptrace, ptrace);
-
-int
-_ptrace(int request, pid_t pid, caddr_t addr, int data)
-{
-
- errno = 0;
- return (__sys_ptrace(request, pid, addr, data));
-}
diff --git a/lib/libc/sys/quotactl.2 b/lib/libc/sys/quotactl.2
deleted file mode 100644
index 25d1710bd06d..000000000000
--- a/lib/libc/sys/quotactl.2
+++ /dev/null
@@ -1,262 +0,0 @@
-.\" Copyright (c) 1983, 1990, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Robert Elz at The University of Melbourne.
-.\"
-.\" 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.
-.\"
-.\" @(#)quotactl.2 8.2 (Berkeley) 3/10/95
-.\"
-.Dd March 30, 2020
-.Dt QUOTACTL 2
-.Os
-.Sh NAME
-.Nm quotactl
-.Nd manipulate file system quotas
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In ufs/ufs/quota.h
-.Ft int
-.Fn quotactl "const char *path" "int cmd" "int id" "void *addr"
-.Sh DESCRIPTION
-The
-.Fn quotactl
-system call enables, disables and
-manipulates file system quotas.
-A quota control command
-given by
-.Fa cmd
-operates on the given filename
-.Fa path
-for the given user or group
-.Fa id .
-(NOTE: One should use the QCMD macro defined in
-.In ufs/ufs/quota.h
-to formulate the value for
-.Fa cmd . )
-The address of an optional command specific data structure,
-.Fa addr ,
-may be given; its interpretation
-is discussed below with each command.
-.Pp
-For commands that use the
-.Fa id
-identifier, it must be either -1 or any positive value.
-The value of -1 indicates that the current UID or GID should be used.
-Any other negative value will return an error.
-.Pp
-Currently quotas are supported only for the
-.Dq ufs
-file system.
-For
-.Dq ufs ,
-a command is composed of a primary command (see below)
-and a command type used to interpret the
-.Fa id .
-Types are supported for interpretation of user identifiers (USRQUOTA)
-and group identifiers (GRPQUOTA).
-The
-.Dq ufs
-specific commands are:
-.Bl -tag -width Q_GETQUOTASIZEx
-.It Dv Q_QUOTAON
-Enable disk quotas for the file system specified by
-.Fa path .
-The command type specifies the type of the quotas being enabled.
-The
-.Fa addr
-argument specifies a file from which to take the quotas.
-The quota file must exist;
-it is normally created with the
-.Xr quotacheck 8
-program.
-The
-.Fa id
-argument is unused.
-Only the super-user may turn quotas on.
-.It Dv Q_QUOTAOFF
-Disable disk quotas for the file system specified by
-.Fa path .
-The command type specifies the type of the quotas being disabled.
-The
-.Fa addr
-and
-.Fa id
-arguments are unused.
-Only the super-user may turn quotas off.
-.It Dv Q_GETQUOTASIZE
-Get the wordsize used to represent the quotas for the user or group
-(as determined by the command type).
-Possible values are 32 for the old-style quota file
-and 64 for the new-style quota file.
-The
-.Fa addr
-argument is a pointer to an integer into which the size is stored.
-The identifier
-.Fa id
-is not used.
-.It Dv Q_GETQUOTA
-Get disk quota limits and current usage for the user or group
-(as determined by the command type) with identifier
-.Fa id .
-The
-.Fa addr
-argument
-is a pointer to a
-.Fa struct dqblk
-structure (defined in
-.In ufs/ufs/quota.h ) .
-.It Dv Q_SETQUOTA
-Set disk quota limits for the user or group
-(as determined by the command type) with identifier
-.Fa id .
-The
-.Fa addr
-argument
-is a pointer to a
-.Fa struct dqblk
-structure (defined in
-.In ufs/ufs/quota.h ) .
-The usage fields of the
-.Fa dqblk
-structure are ignored.
-This system call is restricted to the super-user.
-.It Dv Q_SETUSE
-Set disk usage limits for the user or group
-(as determined by the command type) with identifier
-.Fa id .
-The
-.Fa addr
-argument
-is a pointer to a
-.Fa struct dqblk
-structure (defined in
-.In ufs/ufs/quota.h ) .
-Only the usage fields are used.
-This system call is restricted to the super-user.
-.It Dv Q_SYNC
-Update the on-disk copy of quota usages.
-The command type specifies which type of quotas are to be updated.
-The
-.Fa id
-and
-.Fa addr
-arguments are ignored.
-.El
-.Sh RETURN VALUES
-.Rv -std quotactl
-.Sh ERRORS
-The
-.Fn quotactl
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EOPNOTSUPP
-The kernel has not been compiled with the
-.Dv QUOTA
-option.
-.It Bq Er EUSERS
-The quota table cannot be expanded.
-.It Bq Er EINVAL
-The
-.Fa cmd
-argument
-or the command type is invalid.
-In
-.Dv Q_GETQUOTASIZE ,
-.Dv Q_GETQUOTA ,
-.Dv Q_SETQUOTA ,
-and
-.Dv Q_SETUSE ,
-quotas are not currently enabled for this file system.
-.Pp
-The
-.Fa id
-argument to
-.Dv Q_GETQUOTA ,
-.Dv Q_SETQUOTA
-or
-.Dv Q_SETUSE
-is a negative value.
-.It Bq Er EACCES
-In
-.Dv Q_QUOTAON ,
-the quota file is not a plain file.
-.It Bq Er EACCES
-Search permission is denied for a component of a path prefix.
-.It Bq Er ENOTDIR
-A component of a path prefix was not a directory.
-.It Bq Er ENAMETOOLONG
-A component of either pathname exceeded 255 characters,
-or the entire length of either path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A filename does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating a pathname.
-.It Bq Er EROFS
-In
-.Dv Q_QUOTAON ,
-either the file system on which quotas are to be enabled is mounted read-only
-or the quota file resides on a read-only file system.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing
-to a file containing quotas.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-An invalid
-.Fa addr
-was supplied; the associated structure could not be copied in or out
-of the kernel.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EPERM
-The call was privileged and the caller was not the super-user.
-.El
-.Sh SEE ALSO
-.Xr quota 1 ,
-.Xr fstab 5 ,
-.Xr edquota 8 ,
-.Xr quotacheck 8 ,
-.Xr quotaon 8 ,
-.Xr repquota 8
-.Sh HISTORY
-The
-.Fn quotactl
-system call appeared in
-.Bx 4.3 Reno .
-.Sh BUGS
-There should be some way to integrate this call with the resource
-limit interface provided by
-.Xr setrlimit 2
-and
-.Xr getrlimit 2 .
diff --git a/lib/libc/sys/read.2 b/lib/libc/sys/read.2
deleted file mode 100644
index e3b5b21d1c31..000000000000
--- a/lib/libc/sys/read.2
+++ /dev/null
@@ -1,309 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)read.2 8.4 (Berkeley) 2/26/94
-.\"
-.Dd June 4, 2020
-.Dt READ 2
-.Os
-.Sh NAME
-.Nm read ,
-.Nm readv ,
-.Nm pread ,
-.Nm preadv
-.Nd read input
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft ssize_t
-.Fn read "int fd" "void *buf" "size_t nbytes"
-.Ft ssize_t
-.Fn pread "int fd" "void *buf" "size_t nbytes" "off_t offset"
-.In sys/uio.h
-.Ft ssize_t
-.Fn readv "int fd" "const struct iovec *iov" "int iovcnt"
-.Ft ssize_t
-.Fn preadv "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset"
-.Sh DESCRIPTION
-The
-.Fn read
-system call
-attempts to read
-.Fa nbytes
-of data from the object referenced by the descriptor
-.Fa fd
-into the buffer pointed to by
-.Fa buf .
-The
-.Fn readv
-system call
-performs the same action, but scatters the input data
-into the
-.Fa iovcnt
-buffers specified by the members of the
-.Fa iov
-array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
-The
-.Fn pread
-and
-.Fn preadv
-system calls
-perform the same functions, but read from the specified position in
-the file without modifying the file pointer.
-.Pp
-For
-.Fn readv
-and
-.Fn preadv ,
-the
-.Fa iovec
-structure is defined as:
-.Pp
-.Bd -literal -offset indent -compact
-struct iovec {
- void *iov_base; /* Base address. */
- size_t iov_len; /* Length. */
-};
-.Ed
-.Pp
-Each
-.Fa iovec
-entry specifies the base address and length of an area
-in memory where data should be placed.
-The
-.Fn readv
-system call
-will always fill an area completely before proceeding
-to the next.
-.Pp
-On objects capable of seeking, the
-.Fn read
-starts at a position
-given by the pointer associated with
-.Fa fd
-(see
-.Xr lseek 2 ) .
-Upon return from
-.Fn read ,
-the pointer is incremented by the number of bytes actually read.
-.Pp
-Objects that are not capable of seeking always read from the current
-position.
-The value of the pointer associated with such an
-object is undefined.
-.Pp
-Upon successful completion,
-.Fn read ,
-.Fn readv ,
-.Fn pread
-and
-.Fn preadv
-return the number of bytes actually read and placed in the buffer.
-The system guarantees to read the number of bytes requested if
-the descriptor references a normal file that has that many bytes left
-before the end-of-file, but in no other case.
-.Pp
-In accordance with
-.St -p1003.1-2004 ,
-both
-.Xr read 2
-and
-.Xr write 2
-syscalls are atomic with respect to each other in the effects on file
-content, when they operate on regular files.
-If two threads each call one of the
-.Xr read 2
-or
-.Xr write 2 ,
-syscalls, each call will see either all of the changes of the other call,
-or none of them.
-The
-.Fx
-kernel implements this guarantee by locking the file ranges affected by
-the calls.
-.Sh RETURN VALUES
-If successful, the
-number of bytes actually read is returned.
-Upon reading end-of-file,
-zero is returned.
-Otherwise, a -1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn read ,
-.Fn readv ,
-.Fn pread
-and
-.Fn preadv
-system calls
-will succeed unless:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid file or socket descriptor open for reading.
-.It Bq Er ECONNRESET
-The
-.Fa fd
-argument refers to a socket, and the remote socket end is
-forcibly closed.
-.It Bq Er EFAULT
-The
-.Fa buf
-argument
-points outside the allocated address space.
-.It Bq Er EIO
-An I/O error occurred while reading from the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EBUSY
-Failed to read from a file, e.g. /proc/<pid>/regs while <pid> is not stopped
-.It Bq Er EINTR
-A read from a slow device
-(i.e.\& one that might block for an arbitrary amount of time)
-was interrupted by the delivery of a signal
-before any data arrived.
-.It Bq Er EINVAL
-The pointer associated with
-.Fa fd
-was negative.
-.It Bq Er EAGAIN
-The file was marked for non-blocking I/O,
-and no data were ready to be read.
-.It Bq Er EISDIR
-The file descriptor is associated with a directory.
-Directories may only be read directly by root if the filesystem supports it and
-the
-.Dv security.bsd.allow_read_dir
-sysctl MIB is set to a non-zero value.
-For most scenarios, the
-.Xr readdir 3
-function should be used instead.
-.It Bq Er EOPNOTSUPP
-The file descriptor is associated with a file system and file type that
-do not allow regular read operations on it.
-.It Bq Er EOVERFLOW
-The file descriptor is associated with a regular file,
-.Fa nbytes
-is greater than 0,
-.Fa offset
-is before the end-of-file, and
-.Fa offset
-is greater than or equal to the offset maximum established
-for this file system.
-.It Bq Er EINVAL
-The value
-.Fa nbytes
-is greater than
-.Dv INT_MAX .
-.El
-.Pp
-In addition,
-.Fn readv
-and
-.Fn preadv
-may return one of the following errors:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa iovcnt
-argument
-was less than or equal to 0, or greater than
-.Dv IOV_MAX .
-.It Bq Er EINVAL
-One of the
-.Fa iov_len
-values in the
-.Fa iov
-array was negative.
-.It Bq Er EINVAL
-The sum of the
-.Fa iov_len
-values in the
-.Fa iov
-array overflowed a 32-bit integer.
-.It Bq Er EFAULT
-Part of the
-.Fa iov
-array points outside the process's allocated address space.
-.El
-.Pp
-The
-.Fn pread
-and
-.Fn preadv
-system calls may also return the following errors:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa offset
-value was negative.
-.It Bq Er ESPIPE
-The file descriptor is associated with a pipe, socket, or FIFO.
-.El
-.Sh SEE ALSO
-.Xr dup 2 ,
-.Xr fcntl 2 ,
-.Xr getdirentries 2 ,
-.Xr open 2 ,
-.Xr pipe 2 ,
-.Xr select 2 ,
-.Xr socket 2 ,
-.Xr socketpair 2 ,
-.Xr fread 3 ,
-.Xr readdir 3
-.Sh STANDARDS
-The
-.Fn read
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn readv
-and
-.Fn pread
-system calls are expected to conform to
-.St -xpg4.2 .
-.Sh HISTORY
-The
-.Fn preadv
-system call appeared in
-.Fx 6.0 .
-The
-.Fn pread
-function appeared in
-.At V.4 .
-The
-.Fn readv
-system call appeared in
-.Bx 4.2 .
-The
-.Fn read
-function appeared in
-.At v1 .
diff --git a/lib/libc/sys/read.c b/lib/libc/sys/read.c
index abc37431194d..b4610e0c38c3 100644
--- a/lib/libc/sys/read.c
+++ b/lib/libc/sys/read.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_read, __read);
ssize_t
read(int fd, void *buf, size_t nbytes)
{
-
- return (((ssize_t (*)(int, void *, size_t))
- __libc_interposing[INTERPOS_read])(fd, buf, nbytes));
+ return (INTERPOS_SYS(read, fd, buf, nbytes));
}
diff --git a/lib/libc/sys/readlink.2 b/lib/libc/sys/readlink.2
deleted file mode 100644
index 99d88e1ab7b1..000000000000
--- a/lib/libc/sys/readlink.2
+++ /dev/null
@@ -1,159 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)readlink.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt READLINK 2
-.Os
-.Sh NAME
-.Nm readlink ,
-.Nm readlinkat
-.Nd read value of a symbolic link
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft ssize_t
-.Fn readlink "const char *restrict path" "char *restrict buf" "size_t bufsiz"
-.Ft ssize_t
-.Fo readlinkat
-.Fa "int fd" "const char *restrict path" "char *restrict buf" "size_t bufsize"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn readlink
-system call
-places the contents of the symbolic link
-.Fa path
-in the buffer
-.Fa buf ,
-which has size
-.Fa bufsiz .
-The
-.Fn readlink
-system call does not append a
-.Dv NUL
-character to
-.Fa buf .
-.Pp
-The
-.Fn readlinkat
-system call is equivalent to
-.Fn readlink
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the symbolic link whose content is read relative to the
-directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn readlinkat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn readlink .
-.Sh RETURN VALUES
-The call returns the count of characters placed in the buffer
-if it succeeds, or a \-1 if an error occurs, placing the error
-code in the global variable
-.Va errno .
-.Sh ERRORS
-The
-.Fn readlink
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EINVAL
-The named file is not a symbolic link.
-.It Bq Er EIO
-An I/O error occurred while reading from the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-The
-.Fa buf
-argument
-extends outside the process's allocated address space.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn readlink ,
-the
-.Fn readlinkat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr lstat 2 ,
-.Xr stat 2 ,
-.Xr symlink 2 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Fn readlinkat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn readlink
-system call appeared in
-.Bx 4.2 .
-The
-.Fn readlinkat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/readv.c b/lib/libc/sys/readv.c
index 21bfc25c5d84..2729f6ed99da 100644
--- a/lib/libc/sys/readv.c
+++ b/lib/libc/sys/readv.c
@@ -29,20 +29,17 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/uio.h>
#include <unistd.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
__weak_reference(__sys_readv, __readv);
-#pragma weak readv
-ssize_t
-readv(int fd, const struct iovec *iov, int iovcnt)
+ssize_t __weak_symbol
+__ssp_real(readv)(int fd, const struct iovec *iov, int iovcnt)
{
-
- return (((ssize_t (*)(int, const struct iovec *, int))
- __libc_interposing[INTERPOS_readv])(fd, iov, iovcnt));
+ return (INTERPOS_SYS(readv, fd, iov, iovcnt));
}
diff --git a/lib/libc/sys/reboot.2 b/lib/libc/sys/reboot.2
deleted file mode 100644
index f1ab1b3f6364..000000000000
--- a/lib/libc/sys/reboot.2
+++ /dev/null
@@ -1,164 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)reboot.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 10, 2018
-.Dt REBOOT 2
-.Os
-.Sh NAME
-.Nm reboot
-.Nd reboot system or halt processor
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.In sys/reboot.h
-.Ft int
-.Fn reboot "int howto"
-.Sh DESCRIPTION
-The
-.Fn reboot
-system call
-reboots the system.
-Only the super-user may reboot a machine on demand.
-However, a reboot is invoked
-automatically in the event of unrecoverable system failures.
-.Pp
-The
-.Fa howto
-argument
-is a mask of options; the system call interface allows the following
-options, defined in the include file
-.In sys/reboot.h ,
-to be passed
-to the new kernel or the new bootstrap and init programs.
-.Bl -tag -width RB_POWERCYCLE
-.It Dv RB_AUTOBOOT
-The default, causing the system to reboot in its usual fashion.
-.It Dv RB_ASKNAME
-Normally the system only prompts the user if the loader specified root
-file system has an error.
-This flag forces it to always prompt the user for the root partition.
-.It Dv RB_DFLTROOT
-Use the compiled in root device.
-Normally, the system uses the device from which it was booted
-as the root device if possible.
-(The default behavior is dependent on the ability of the bootstrap program
-to determine the drive from which it was loaded, which is not possible
-on all systems.)
-.It Dv RB_DUMP
-Dump kernel memory before rebooting; see
-.Xr savecore 8
-for more information.
-.It Dv RB_HALT
-The processor is simply halted; no reboot takes place.
-This option should be used with caution.
-.It Dv RB_POWERCYCLE
-After halting, the shutdown code will do what it can to turn
-off the power and then turn the power back on.
-This requires hardware support, usually an auxiliary microprocessor
-that can sequence the power supply.
-At present only the
-.Xr ipmi 4
-driver implements this feature.
-.It Dv RB_POWEROFF
-After halting, the shutdown code will do what it can to turn
-off the power.
-This requires hardware support.
-.It Dv RB_KDB
-Load the symbol table and enable a built-in debugger in the system.
-This option will have no useful function if the kernel is not configured
-for debugging.
-Several other options have different meaning if combined
-with this option, although their use may not be possible
-via the
-.Fn reboot
-system call.
-See
-.Xr ddb 4
-for more information.
-.It Dv RB_NOSYNC
-Normally, the disks are sync'd (see
-.Xr sync 8 )
-before the processor is halted or rebooted.
-This option may be useful if file system changes have been made manually
-or if the processor is on fire.
-.It Dv RB_REROOT
-Instead of rebooting, unmount all filesystems except the one containing
-currently-running executable, and mount root filesystem using the same
-mechanism which is used during normal boot, based on
-vfs.root.mountfrom
-.Xr kenv 1
-variable.
-.It Dv RB_RDONLY
-Initially mount the root file system read-only.
-This is currently the default, and this option has been deprecated.
-.It Dv RB_SINGLE
-Normally, the reboot procedure involves an automatic disk consistency
-check and then multi-user operations.
-.Dv RB_SINGLE
-prevents this, booting the system with a single-user shell
-on the console.
-.Dv RB_SINGLE
-is actually interpreted by the
-.Xr init 8
-program in the newly booted system.
-.El
-.Pp
-When no options are given (i.e.,
-.Dv RB_AUTOBOOT
-is used), the system is
-rebooted from file
-.Dq kernel
-in the root file system of unit 0
-of a disk chosen in a processor specific way.
-An automatic consistency check of the disks is normally performed
-(see
-.Xr fsck 8 ) .
-.Sh RETURN VALUES
-If successful, this call never returns.
-Otherwise, a -1 is returned and an error is returned in the global
-variable
-.Va errno .
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller is not the super-user.
-.El
-.Sh SEE ALSO
-.Xr crash 8 ,
-.Xr halt 8 ,
-.Xr init 8 ,
-.Xr reboot 8 ,
-.Xr savecore 8 ,
-.Xr reboot 9
-.Sh HISTORY
-The
-.Fn reboot
-system call appeared in
-.Bx 4.0 .
diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2
deleted file mode 100644
index 68dc70e14800..000000000000
--- a/lib/libc/sys/recv.2
+++ /dev/null
@@ -1,396 +0,0 @@
-.\" Copyright (c) 1983, 1990, 1991, 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.
-.\"
-.\" @(#)recv.2 8.3 (Berkeley) 2/21/94
-.\"
-.Dd July 30, 2022
-.Dt RECV 2
-.Os
-.Sh NAME
-.Nm recv ,
-.Nm recvfrom ,
-.Nm recvmsg ,
-.Nm recvmmsg
-.Nd receive message(s) from a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft ssize_t
-.Fn recv "int s" "void *buf" "size_t len" "int flags"
-.Ft ssize_t
-.Fn recvfrom "int s" "void *buf" "size_t len" "int flags" "struct sockaddr * restrict from" "socklen_t * restrict fromlen"
-.Ft ssize_t
-.Fn recvmsg "int s" "struct msghdr *msg" "int flags"
-.Ft ssize_t
-.Fn recvmmsg "int s" "struct mmsghdr * restrict msgvec" "size_t vlen" "int flags" "const struct timespec * restrict timeout"
-.Sh DESCRIPTION
-The
-.Fn recvfrom ,
-.Fn recvmsg ,
-and
-.Fn recvmmsg
-system calls
-are used to receive messages from a socket,
-and may be used to receive data on a socket whether or not
-it is connection-oriented.
-.Pp
-If
-.Fa from
-is not a null pointer
-and the socket is not connection-oriented,
-the source address of the message is filled in.
-The
-.Fa fromlen
-argument
-is a value-result argument, initialized to the size of
-the buffer associated with
-.Fa from ,
-and modified on return to indicate the actual size of the
-address stored there.
-.Pp
-The
-.Fn recv
-function is normally used only on a
-.Em connected
-socket (see
-.Xr connect 2 )
-and is identical to
-.Fn recvfrom
-with a
-null pointer passed as its
-.Fa from
-argument.
-.Pp
-The
-.Fn recvmmsg
-function is used to receive multiple
-messages at a call.
-Their number is supplied by
-.Fa vlen .
-The messages are placed in the buffers described by
-.Fa msgvec
-vector, after reception.
-The size of each received message is placed in the
-.Fa msg_len
-field of each element of the vector.
-If
-.Fa timeout
-is NULL the call blocks until the data is available for each
-supplied message buffer.
-Otherwise it waits for data for the specified amount of time.
-If the timeout expired and there is no data received,
-a value 0 is returned.
-The
-.Xr ppoll 2
-system call is used to implement the timeout mechanism,
-before first receive is performed.
-.Pp
-The
-.Fn recv ,
-.Fn recvfrom
-and
-.Fn recvmsg
-return the length of the message on successful
-completion, whereas
-.Fn recvmmsg
-returns the number of received messages.
-If a message is too long to fit in the supplied buffer,
-excess bytes may be discarded depending on the type of socket
-the message is received from (see
-.Xr socket 2 ) .
-.Pp
-If no messages are available at the socket, the
-receive call waits for a message to arrive, unless
-the socket is non-blocking (see
-.Xr fcntl 2 )
-in which case the value
-\-1 is returned and the global variable
-.Va errno
-is set to
-.Er EAGAIN .
-The receive calls except
-.Fn recvmmsg
-normally return any data available,
-up to the requested amount,
-rather than waiting for receipt of the full amount requested;
-this behavior is affected by the socket-level options
-.Dv SO_RCVLOWAT
-and
-.Dv SO_RCVTIMEO
-described in
-.Xr getsockopt 2 .
-The
-.Fn recvmmsg
-function implements this behaviour for each message in the vector.
-.Pp
-The
-.Xr select 2
-system call may be used to determine when more data arrives.
-.Pp
-The
-.Fa flags
-argument to a
-.Fn recv
-function is formed by
-.Em or Ap ing
-one or more of the values:
-.Bl -column ".Dv MSG_CMSG_CLOEXEC" -offset indent
-.It Dv MSG_OOB Ta process out-of-band data
-.It Dv MSG_PEEK Ta peek at incoming message
-.It Dv MSG_TRUNC Ta return real packet or datagram length
-.It Dv MSG_WAITALL Ta wait for full request or error
-.It Dv MSG_DONTWAIT Ta do not block
-.It Dv MSG_CMSG_CLOEXEC Ta set received fds close-on-exec
-.It Dv MSG_WAITFORONE Ta do not block after receiving the first message
-(only for
-.Fn recvmmsg
-)
-.El
-.Pp
-The
-.Dv MSG_OOB
-flag requests receipt of out-of-band data
-that would not be received in the normal data stream.
-Some protocols place expedited data at the head of the normal
-data queue, and thus this flag cannot be used with such protocols.
-The
-.Dv MSG_PEEK
-flag causes the receive operation to return data
-from the beginning of the receive queue without removing that
-data from the queue.
-Thus, a subsequent receive call will return the same data.
-The
-.Dv MSG_TRUNC
-flag causes the receive operation to return the full length of the packet
-or datagram even if larger than provided buffer. The flag is supported
-on SOCK_DGRAM sockets for
-.Dv AF_INET
-,
-.Dv AF_INET6
-and
-.Dv AF_UNIX
-families.
-The
-.Dv MSG_WAITALL
-flag requests that the operation block until
-the full request is satisfied.
-However, the call may still return less data than requested
-if a signal is caught, an error or disconnect occurs,
-or the next data to be received is of a different type than that returned.
-The
-.Dv MSG_DONTWAIT
-flag requests the call to return when it would block otherwise.
-If no data is available,
-.Va errno
-is set to
-.Er EAGAIN .
-This flag is not available in
-.St -ansiC
-or
-.St -isoC-99
-compilation mode.
-The
-.Dv MSG_WAITFORONE
-flag sets MSG_DONTWAIT after the first message has been received.
-This flag is only relevant for
-.Fn recvmmsg .
-.Pp
-The
-.Fn recvmsg
-system call uses a
-.Fa msghdr
-structure to minimize the number of directly supplied arguments.
-This structure has the following form, as defined in
-.In sys/socket.h :
-.Bd -literal
-struct msghdr {
- void *msg_name; /* optional address */
- socklen_t msg_namelen; /* size of address */
- struct iovec *msg_iov; /* scatter/gather array */
- int msg_iovlen; /* # elements in msg_iov */
- void *msg_control; /* ancillary data, see below */
- socklen_t msg_controllen;/* ancillary data buffer len */
- int msg_flags; /* flags on received message */
-};
-.Ed
-.Pp
-Here
-.Fa msg_name
-and
-.Fa msg_namelen
-specify the source address if the socket is unconnected;
-.Fa msg_name
-may be given as a null pointer if no names are desired or required.
-The
-.Fa msg_iov
-and
-.Fa msg_iovlen
-arguments
-describe scatter gather locations, as discussed in
-.Xr read 2 .
-The
-.Fa msg_control
-argument,
-which has length
-.Fa msg_controllen ,
-points to a buffer for other protocol control related messages
-or other miscellaneous ancillary data.
-The messages are of the form:
-.Bd -literal
-struct cmsghdr {
- socklen_t cmsg_len; /* data byte count, including hdr */
- int cmsg_level; /* originating protocol */
- int cmsg_type; /* protocol-specific type */
-/* followed by
- u_char cmsg_data[]; */
-};
-.Ed
-.Pp
-As an example, the SO_TIMESTAMP socket option returns a reception
-timestamp for UDP packets.
-.Pp
-With
-.Dv AF_UNIX
-domain sockets, ancillary data can be used to pass file descriptors and
-process credentials.
-See
-.Xr unix 4
-for details.
-.Pp
-The
-.Fa msg_flags
-field is set on return according to the message received.
-.Dv MSG_EOR
-indicates end-of-record;
-the data returned completed a record (generally used with sockets of type
-.Dv SOCK_SEQPACKET ) .
-.Dv MSG_TRUNC
-indicates that
-the trailing portion of a datagram was discarded because the datagram
-was larger than the buffer supplied.
-.Dv MSG_CTRUNC
-indicates that some
-control data were discarded due to lack of space in the buffer
-for ancillary data.
-.Dv MSG_OOB
-is returned to indicate that expedited or out-of-band data were received.
-.Pp
-The
-.Fn recvmmsg
-system call uses the
-.Fa mmsghdr
-structure, defined as follows in the
-.In sys/socket.h
-header:
-.Bd -literal
-struct mmsghdr {
- struct msghdr msg_hdr; /* message header */
- ssize_t msg_len; /* message length */
-};
-.Ed
-.Pp
-On data reception the
-.Fa msg_len
-field is updated to the length of the received message.
-.Sh RETURN VALUES
-These calls except
-.Fn recvmmsg
-return the number of bytes received.
-.Fn recvmmsg
-returns the number of messages received.
-A value of -1 is returned if an error occurred.
-.Sh ERRORS
-The calls fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The argument
-.Fa s
-is an invalid descriptor.
-.It Bq Er ECONNRESET
-The remote socket end is forcibly closed.
-.It Bq Er ENOTCONN
-The socket is associated with a connection-oriented protocol
-and has not been connected (see
-.Xr connect 2
-and
-.Xr accept 2 ) .
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-does not refer to a socket.
-.It Bq Er EMFILE
-The
-.Fn recvmsg
-system call
-was used to receive rights (file descriptors) that were in flight on the
-connection.
-However, the receiving program did not have enough free file
-descriptor slots to accept them.
-In this case the descriptors are closed, with pending data either discarded
-in the case of the unreliable datagram protocol or preserved in the case of a
-reliable protocol.
-The pending data can be retrieved with another call to
-.Fn recvmsg .
-.It Bq Er EMSGSIZE
-The
-.Fa msg_iovlen
-member of the
-.Fa msghdr
-structure pointed to by
-.Fa msg
-is less than or equal to 0, or is greater than
-.Va IOV_MAX .
-.It Bq Er EAGAIN
-The socket is marked non-blocking and the receive operation
-would block, or
-a receive timeout had been set
-and the timeout expired before data were received.
-.It Bq Er EINTR
-The receive was interrupted by delivery of a signal before
-any data were available.
-.It Bq Er EFAULT
-The receive buffer pointer(s) point outside the process's
-address space.
-.El
-.Sh SEE ALSO
-.Xr fcntl 2 ,
-.Xr getsockopt 2 ,
-.Xr read 2 ,
-.Xr select 2 ,
-.Xr socket 2 ,
-.Xr CMSG_DATA 3 ,
-.Xr unix 4
-.Sh HISTORY
-The
-.Fn recv
-function appeared in
-.Bx 4.2 .
-The
-.Fn recvmmsg
-function appeared in
-.Fx 11.0 .
diff --git a/lib/libc/sys/recv.c b/lib/libc/sys/recv.c
new file mode 100644
index 000000000000..2bccfbee4eed
--- /dev/null
+++ b/lib/libc/sys/recv.c
@@ -0,0 +1,47 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1988, 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.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <ssp/ssp.h>
+#include "libc_private.h"
+
+#include <stddef.h>
+
+ssize_t
+__ssp_real(recv)(int s, void *buf, size_t len, int flags)
+{
+ /*
+ * POSIX says recv() shall be a cancellation point, so call the
+ * cancellation-enabled recvfrom() and not _recvfrom().
+ */
+ return (INTERPOS_SYS(recvfrom, s, buf, len, flags, NULL, NULL));
+}
diff --git a/lib/libc/sys/recvfrom.c b/lib/libc/sys/recvfrom.c
index 5f5f95640932..0cdbd8a4ccaa 100644
--- a/lib/libc/sys/recvfrom.c
+++ b/lib/libc/sys/recvfrom.c
@@ -29,22 +29,17 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
__weak_reference(__sys_recvfrom, __recvfrom);
-#pragma weak recvfrom
-ssize_t
-recvfrom(int s, void *buf, size_t len, int flags,
+ssize_t __weak_symbol
+__ssp_real(recvfrom)(int s, void *buf, size_t len, int flags,
struct sockaddr * __restrict from, socklen_t * __restrict fromlen)
{
-
- return (((ssize_t (*)(int, void *, size_t, int,
- struct sockaddr *, socklen_t *))
- __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
- from, fromlen));
+ return (INTERPOS_SYS(recvfrom, s, buf, len, flags, from, fromlen));
}
diff --git a/lib/libc/sys/recvmsg.c b/lib/libc/sys/recvmsg.c
index 44b38aeab2d4..ce0f5e0478cd 100644
--- a/lib/libc/sys/recvmsg.c
+++ b/lib/libc/sys/recvmsg.c
@@ -29,19 +29,16 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
+#include <ssp/ssp.h>
#include "libc_private.h"
__weak_reference(__sys_recvmsg, __recvmsg);
-#pragma weak recvmsg
-ssize_t
-recvmsg(int s, struct msghdr *msg, int flags)
+ssize_t __weak_symbol
+__ssp_real(recvmsg)(int s, struct msghdr *msg, int flags)
{
-
- return (((int (*)(int, struct msghdr *, int))
- __libc_interposing[INTERPOS_recvmsg])(s, msg, flags));
+ return (INTERPOS_SYS(recvmsg, s, msg, flags));
}
diff --git a/lib/libc/sys/rename.2 b/lib/libc/sys/rename.2
deleted file mode 100644
index 2b68274e4a8e..000000000000
--- a/lib/libc/sys/rename.2
+++ /dev/null
@@ -1,341 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)rename.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt RENAME 2
-.Os
-.Sh NAME
-.Nm rename
-.Nd change the name of a file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdio.h
-.Ft int
-.Fn rename "const char *from" "const char *to"
-.Ft int
-.Fn renameat "int fromfd" "const char *from" "int tofd" "const char *to"
-.Sh DESCRIPTION
-The
-.Fn rename
-system call
-causes the link named
-.Fa from
-to be renamed as
-.Fa to .
-If
-.Fa to
-exists, it is first removed.
-Both
-.Fa from
-and
-.Fa to
-must be of the same type (that is, both directories or both
-non-directories), and must reside on the same file system.
-.Pp
-The
-.Fn rename
-system call
-guarantees that if
-.Fa to
-already exists, an instance of
-.Fa to
-will always exist, even if the system should crash in
-the middle of the operation.
-.Pp
-If the final component of
-.Fa from
-is a symbolic link,
-the symbolic link is renamed,
-not the file or directory to which it points.
-.Pp
-If
-.Fa from
-and
-.Fa to
-resolve to the same directory entry, or to different directory
-entries for the same existing file,
-.Fn rename
-returns success without taking any further action.
-.Pp
-The
-.Fn renameat
-system call is equivalent to
-.Fn rename
-except in the case where either
-.Fa from
-or
-.Fa to
-specifies a relative path.
-If
-.Fa from
-is a relative path, the file to be renamed is located
-relative to the directory associated with the file descriptor
-.Fa fromfd
-instead of the current working directory.
-If the
-.Fa to
-is a relative path, the same happens only relative to the directory associated
-with
-.Fa tofd .
-If the
-.Fn renameat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fromfd
-or
-.Fa tofd
-parameter, the current working directory is used in the determination
-of the file for the respective path parameter.
-.\".Sh CAVEAT
-.\"The system can deadlock if a loop in the file system graph is present.
-.\"This loop takes the form of an entry in directory
-.\".Pa a ,
-.\"say
-.\".Pa a/foo ,
-.\"being a hard link to directory
-.\".Pa b ,
-.\"and an entry in
-.\"directory
-.\".Pa b ,
-.\"say
-.\".Pa b/bar ,
-.\"being a hard link
-.\"to directory
-.\".Pa a .
-.\"When such a loop exists and two separate processes attempt to
-.\"perform
-.\".Ql rename a/foo b/bar
-.\"and
-.\".Ql rename b/bar a/foo ,
-.\"respectively,
-.\"the system may deadlock attempting to lock
-.\"both directories for modification.
-.\"Hard links to directories should be
-.\"replaced by symbolic links by the system administrator.
-.Sh RETURN VALUES
-.Rv -std rename
-.Sh ERRORS
-The
-.Fn rename
-system call
-will fail and neither of the argument files will be
-affected if:
-.Bl -tag -width Er
-.It Bq Er ENAMETOOLONG
-A component of either pathname exceeded 255 characters,
-or the entire length of either path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of the
-.Fa from
-path does not exist,
-or a path prefix of
-.Fa to
-does not exist.
-.It Bq Er EACCES
-A component of either path prefix denies search permission.
-.It Bq Er EACCES
-The requested link requires writing in a directory with a mode
-that denies write permission.
-.It Bq Er EACCES
-The directory pointed at by the
-.Fa from
-argument denies write permission, and the operation would move
-it to another parent directory.
-.It Bq Er EPERM
-The file pointed at by the
-.Fa from
-argument has its immutable, undeletable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EPERM
-The parent directory of the file pointed at by the
-.Fa from
-argument has its immutable or append-only flag set.
-.It Bq Er EPERM
-The parent directory of the file pointed at by the
-.Fa to
-argument has its immutable flag set.
-.It Bq Er EPERM
-The directory containing
-.Fa from
-is marked sticky,
-and neither the containing directory nor
-.Fa from
-are owned by the effective user ID.
-.It Bq Er EPERM
-The file pointed at by the
-.Fa to
-argument
-exists,
-the directory containing
-.Fa to
-is marked sticky,
-and neither the containing directory nor
-.Fa to
-are owned by the effective user ID.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating either pathname.
-.It Bq Er ENOTDIR
-A component of either path prefix is not a directory.
-.It Bq Er ENOTDIR
-The
-.Fa from
-argument
-is a directory, but
-.Fa to
-is not a directory.
-.It Bq Er EISDIR
-The
-.Fa to
-argument
-is a directory, but
-.Fa from
-is not a directory.
-.It Bq Er EXDEV
-The link named by
-.Fa to
-and the file named by
-.Fa from
-are on different logical devices (file systems).
-Note that this error
-code will not be returned if the implementation permits cross-device
-links.
-.It Bq Er ENOSPC
-The directory in which the entry for the new name is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er EDQUOT
-The directory in which the entry for the new name
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while making or updating a directory entry.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The requested link requires writing in a directory on a read-only file
-system.
-.It Bq Er EFAULT
-Path
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The
-.Fa from
-argument
-is a parent directory of
-.Fa to ,
-or an attempt is made to rename
-.Ql .\&
-or
-.Ql \&.. .
-.It Bq Er ENOTEMPTY
-The
-.Fa to
-argument
-is a directory and is not empty.
-.It Bq Er ECAPMODE
-.Fn rename
-was called and the process is in capability mode.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn rename ,
-the
-.Fn renameat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa from
-argument does not specify an absolute path and the
-.Fa fromfd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching, or the
-.Fa to
-argument does not specify an absolute path and the
-.Fa tofd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa from
-argument is not an absolute path and
-.Fa fromfd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory, or the
-.Fa to
-argument is not an absolute path and
-.Fa tofd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ECAPMODE
-.Dv AT_FDCWD
-is specified and the process is in capability mode.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path or contained a ".." component leading to a directory
-outside of the directory hierarchy specified by
-.Fa fromfd
-or
-.Fa tofd .
-.It Bq Er ENOTCAPABLE
-The
-.Fa fromfd
-file descriptor lacks the
-.Dv CAP_RENAMEAT_SOURCE
-right, or the
-.Fa tofd
-file descriptor lacks the
-.Dv CAP_RENAMEAT_TARGET
-right.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr open 2 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Fn rename
-system call is expected to conform to
-.St -p1003.1-96 .
-The
-.Fn renameat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn renameat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/revoke.2 b/lib/libc/sys/revoke.2
deleted file mode 100644
index dc92512d3129..000000000000
--- a/lib/libc/sys/revoke.2
+++ /dev/null
@@ -1,109 +0,0 @@
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Berkeley Software Design, 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.
-.\"
-.\" @(#)revoke.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd January 25, 2016
-.Dt REVOKE 2
-.Os
-.Sh NAME
-.Nm revoke
-.Nd revoke file access
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn revoke "const char *path"
-.Sh DESCRIPTION
-The
-.Fn revoke
-system call invalidates all current open file descriptors in the system
-for the file named by
-.Fa path .
-Subsequent operations on any such descriptors
-fail, with the exceptions that a
-.Fn read
-from a character device file which has been revoked
-returns a count of zero (end of file),
-and a
-.Fn close
-system call will succeed.
-If the file is a special file for a device which is open,
-the device close function
-is called as if all open references to the file had been closed
-using a special close method which does not block.
-.Pp
-Access to a file may be revoked only by its owner or the super user.
-The
-.Fn revoke
-system call is currently supported only for block and character special
-device files.
-It is normally used to prepare a terminal device for a new login session,
-preventing any access by a previous user of the terminal.
-.Sh RETURN VALUES
-.Rv -std revoke
-.Sh ERRORS
-Access to the named file is revoked unless one of the following:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1024 characters.
-.It Bq Er ENOENT
-The named file or a component of the path name does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The implementation does not support the
-.Fn revoke
-operation on the named file.
-.It Bq Er EPERM
-The caller is neither the owner of the file nor the super user.
-.El
-.Sh SEE ALSO
-.Xr revoke 1 ,
-.Xr close 2
-.Sh HISTORY
-The
-.Fn revoke
-system call first appeared in
-.Bx 4.3 Reno .
-.Sh BUGS
-The non-blocking close method is only correctly implemented for
-terminal devices.
diff --git a/lib/libc/sys/rmdir.2 b/lib/libc/sys/rmdir.2
deleted file mode 100644
index e5a7b06795d2..000000000000
--- a/lib/libc/sys/rmdir.2
+++ /dev/null
@@ -1,119 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)rmdir.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt RMDIR 2
-.Os
-.Sh NAME
-.Nm rmdir
-.Nd remove a directory file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn rmdir "const char *path"
-.Sh DESCRIPTION
-The
-.Fn rmdir
-system call
-removes a directory file
-whose name is given by
-.Fa path .
-The directory must not have any entries other
-than
-.Ql .\&
-and
-.Ql \&.. .
-.Sh RETURN VALUES
-.Rv -std rmdir
-.Sh ERRORS
-The named file is removed unless:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named directory does not exist.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er ENOTEMPTY
-The named directory contains files other than
-.Ql .\&
-and
-.Ql ..\&
-in it.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-Write permission is denied on the directory containing the link
-to be removed.
-.It Bq Er EPERM
-The directory to be removed has its immutable, undeletable or append-only flag
-set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EPERM
-The parent directory of the directory to be removed has its immutable or
-append-only flag set.
-.It Bq Er EPERM
-The directory containing the directory to be removed is marked sticky,
-and neither the containing directory nor the directory to be removed
-are owned by the effective user ID.
-.It Bq Er EINVAL
-The last component of the path is
-.Ql .\&
-or
-.Ql .. .
-.It Bq Er EBUSY
-The directory to be removed is the mount point
-for a mounted file system.
-.It Bq Er EIO
-An I/O error occurred while deleting the directory entry
-or deallocating the inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The directory entry to be removed resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.El
-.Sh SEE ALSO
-.Xr mkdir 2 ,
-.Xr unlink 2
-.Sh HISTORY
-The
-.Fn rmdir
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/sctp_generic_sendmsg.2 b/lib/libc/sys/sctp_generic_sendmsg.2
deleted file mode 100644
index 5c62328aeace..000000000000
--- a/lib/libc/sys/sctp_generic_sendmsg.2
+++ /dev/null
@@ -1,84 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.Dd October 30, 2007
-.Dt SCTP_GENERIC_SENDMSG 2
-.Os
-.Sh NAME
-.Nm sctp_generic_sendmsg
-.Nm sctp_generic_sendmsg_iov
-.Nd send data to a peer
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.In netinet/sctp.h
-.Ft int
-.Fn sctp_generic_sendmsg "int s" "void *msg" "int msglen" "struct sockaddr *to" "socklen_t len" "struct sctp_sndrcvinfo *sinfo" "int flags"
-.Ft int
-.Fn sctp_generic_sendmsg_iov "int s" "struct iovec *iov" "int iovlen" "struct sockaddr *to" "struct sctp_sndrcvinfo *sinfo" "int flags"
-.Sh DESCRIPTION
-.Fn sctp_generic_sendmsg
-and
-.Fn sctp_generic_sendmsg_iov
-are the true system calls used by the
-.Xr sctp_sendmsg 3
-and
-.Xr sctp_send 3
-function calls.
-These are more efficient since they are
-true system calls but they are specific to
-.Fx
-and can be expected
-.Em not
-to be present on any other operating
-system.
-For detailed usage please see either the
-.Xr sctp_send 3
-or
-.Xr sctp_sendmsg 3
-function calls.
-.Sh RETURN VALUES
-The call returns the number of bytes written on success and -1 upon failure.
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EBADF
-The argument
-.Fa s
-is not a valid descriptor.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is not a socket.
-.El
-.Sh SEE ALSO
-.Xr sctp_send 3 ,
-.Xr sctp_sendmsg 3 ,
-.Xr sctp_sendmsgx 3 ,
-.Xr sctp_sendx 3 ,
-.Xr sctp 4
diff --git a/lib/libc/sys/sctp_peeloff.2 b/lib/libc/sys/sctp_peeloff.2
deleted file mode 100644
index 5aa246cfa49f..000000000000
--- a/lib/libc/sys/sctp_peeloff.2
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.Dd October 30, 2007
-.Dt SCTP_PEELOFF 2
-.Os
-.Sh NAME
-.Nm sctp_peeloff
-.Nd detach an association from a one-to-many socket to its own fd
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.In netinet/sctp.h
-.Ft int
-.Fn sctp_peeloff "int s" "sctp_assoc_t id"
-.Sh DESCRIPTION
-The
-.Fn sctp_peeloff
-system call attempts detach the association specified by
-.Fa id
-into its own separate socket.
-.Sh RETURN VALUES
-The call returns -1 on failure and the new socket descriptor
-upon success.
-.Sh ERRORS
-The
-.Fn sctp_peeloff
-system call can return the following errors:
-.Bl -tag -width Er
-.It Bq Er ENOTCONN
-The
-.Fa id
-given to the call does not map to a valid
-association.
-.It Bq Er E2BIG
-The size of the address list exceeds the amount of
-data provided.
-.It Bq Er EBADF
-The argument
-.Fa s
-is not a valid descriptor.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is not a socket.
-.El
-.Sh SEE ALSO
-.Xr sctp 4
diff --git a/lib/libc/sys/select.2 b/lib/libc/sys/select.2
deleted file mode 100644
index f8749cab4283..000000000000
--- a/lib/libc/sys/select.2
+++ /dev/null
@@ -1,227 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)select.2 8.2 (Berkeley) 3/25/94
-.\"
-.Dd June 25, 2020
-.Dt SELECT 2
-.Os
-.Sh NAME
-.Nm select
-.Nd synchronous I/O multiplexing
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/select.h
-.Ft int
-.Fn select "int nfds" "fd_set *readfds" "fd_set *writefds" "fd_set *exceptfds" "struct timeval *timeout"
-.Fn FD_SET fd &fdset
-.Fn FD_CLR fd &fdset
-.Fn FD_ISSET fd &fdset
-.Fn FD_ZERO &fdset
-.Sh DESCRIPTION
-The
-.Fn select
-system call
-examines the I/O descriptor sets whose addresses are passed in
-.Fa readfds ,
-.Fa writefds ,
-and
-.Fa exceptfds
-to see if some of their descriptors
-are ready for reading, are ready for writing, or have an exceptional
-condition pending, respectively.
-The only exceptional condition detectable is out-of-band
-data received on a socket.
-The first
-.Fa nfds
-descriptors are checked in each set;
-i.e., the descriptors from 0 through
-.Fa nfds Ns No -1
-in the descriptor sets are examined.
-On return,
-.Fn select
-replaces the given descriptor sets
-with subsets consisting of those descriptors that are ready
-for the requested operation.
-The
-.Fn select
-system call
-returns the total number of ready descriptors in all the sets.
-.Pp
-The descriptor sets are stored as bit fields in arrays of integers.
-The following macros are provided for manipulating such descriptor sets:
-.Fn FD_ZERO &fdset
-initializes a descriptor set
-.Fa fdset
-to the null set.
-.Fn FD_SET fd &fdset
-includes a particular descriptor
-.Fa fd
-in
-.Fa fdset .
-.Fn FD_CLR fd &fdset
-removes
-.Fa fd
-from
-.Fa fdset .
-.Fn FD_ISSET fd &fdset
-is non-zero if
-.Fa fd
-is a member of
-.Fa fdset ,
-zero otherwise.
-The behavior of these macros is undefined if
-a descriptor value is less than zero or greater than or equal to
-.Dv FD_SETSIZE ,
-which is normally at least equal
-to the maximum number of descriptors supported by the system.
-.Pp
-If
-.Fa timeout
-is not a null pointer, it specifies the maximum interval to wait for the
-selection to complete.
-System activity can lengthen the interval by
-an indeterminate amount.
-.Pp
-If
-.Fa timeout
-is a null pointer, the select blocks indefinitely.
-.Pp
-To effect a poll, the
-.Fa timeout
-argument should not be a null pointer,
-but it should point to a zero-valued timeval structure.
-.Pp
-Any of
-.Fa readfds ,
-.Fa writefds ,
-and
-.Fa exceptfds
-may be given as null pointers if no descriptors are of interest.
-.Sh RETURN VALUES
-The
-.Fn select
-system call
-returns the number of ready descriptors that are contained in
-the descriptor sets,
-or -1 if an error occurred.
-If the time limit expires,
-.Fn select
-returns 0.
-If
-.Fn select
-returns with an error,
-including one due to an interrupted system call,
-the descriptor sets will be unmodified.
-.Sh ERRORS
-An error return from
-.Fn select
-indicates:
-.Bl -tag -width Er
-.It Bq Er EBADF
-One of the descriptor sets specified an invalid descriptor.
-.It Bq Er EFAULT
-One of the arguments
-.Fa readfds , writefds , exceptfds ,
-or
-.Fa timeout
-points to an invalid address.
-.It Bq Er EINTR
-A signal was delivered before the time limit expired and
-before any of the selected events occurred.
-.It Bq Er EINVAL
-The specified time limit is invalid.
-One of its components is
-negative or too large.
-.It Bq Er EINVAL
-The
-.Fa nfds
-argument
-was invalid.
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr connect 2 ,
-.Xr getdtablesize 2 ,
-.Xr gettimeofday 2 ,
-.Xr kqueue 2 ,
-.Xr poll 2 ,
-.Xr pselect 2 ,
-.Xr read 2 ,
-.Xr recv 2 ,
-.Xr send 2 ,
-.Xr write 2 ,
-.Xr clocks 7
-.Sh NOTES
-The default size of
-.Dv FD_SETSIZE
-is currently 1024.
-In order to accommodate programs which might potentially
-use a larger number of open files with
-.Fn select ,
-it is possible
-to increase this size by having the program define
-.Dv FD_SETSIZE
-before the inclusion of any header which includes
-.In sys/types.h .
-.Pp
-If
-.Fa nfds
-is greater than the number of open files,
-.Fn select
-is not guaranteed to examine the unused file descriptors.
-For historical
-reasons,
-.Fn select
-will always examine the first 256 descriptors.
-.Sh STANDARDS
-The
-.Fn select
-system call and
-.Fn FD_CLR ,
-.Fn FD_ISSET ,
-.Fn FD_SET ,
-and
-.Fn FD_ZERO
-macros conform with
-.St -p1003.1-2001 .
-.Sh HISTORY
-The
-.Fn select
-system call appeared in
-.Bx 4.2 .
-.Sh BUGS
-.St -susv2
-allows systems to modify the original timeout in place.
-Thus, it is unwise to assume that the timeout value will be unmodified
-by the
-.Fn select
-system call.
-.Fx
-does not modify the return value, which can cause problems for applications
-ported from other systems.
diff --git a/lib/libc/sys/select.c b/lib/libc/sys/select.c
index a43e04bd5009..bbbcfc8bf1e0 100644
--- a/lib/libc/sys/select.c
+++ b/lib/libc/sys/select.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/select.h>
#include "libc_private.h"
@@ -40,7 +39,5 @@ __weak_reference(__sys_select, __select);
int
select(int n, fd_set *rs, fd_set *ws, fd_set *es, struct timeval *t)
{
-
- return (((int (*)(int, fd_set *, fd_set *, fd_set *, struct timeval *))
- __libc_interposing[INTERPOS_select])(n, rs, ws, es, t));
+ return (INTERPOS_SYS(select, n, rs, ws, es, t));
}
diff --git a/lib/libc/sys/send.2 b/lib/libc/sys/send.2
deleted file mode 100644
index 506e05c666e6..000000000000
--- a/lib/libc/sys/send.2
+++ /dev/null
@@ -1,294 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
-.\"
-.Dd April 27, 2020
-.Dt SEND 2
-.Os
-.Sh NAME
-.Nm send ,
-.Nm sendto ,
-.Nm sendmsg ,
-.Nm sendmmsg
-.Nd send message(s) from a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft ssize_t
-.Fn send "int s" "const void *msg" "size_t len" "int flags"
-.Ft ssize_t
-.Fn sendto "int s" "const void *msg" "size_t len" "int flags" "const struct sockaddr *to" "socklen_t tolen"
-.Ft ssize_t
-.Fn sendmsg "int s" "const struct msghdr *msg" "int flags"
-.Ft ssize_t
-.Fn sendmmsg "int s" "struct mmsghdr * restrict msgvec" "size_t vlen" "int flags"
-.Sh DESCRIPTION
-The
-.Fn send
-and
-.Fn sendmmsg
-functions,
-and
-.Fn sendto
-and
-.Fn sendmsg
-system calls
-are used to transmit one or more messages (with the
-.Fn sendmmsg
-call) to
-another socket.
-The
-.Fn send
-function
-may be used only when the socket is in a
-.Em connected
-state.
-The functions
-.Fn sendto ,
-.Fn sendmsg
-and
-.Fn sendmmsg
-may be used at any time if the socket is connectionless-mode.
-If the socket is connection-mode, the protocol
-must support implied connect (currently
-.Xr tcp 4
-is the only protocol with support) or the socket must be in a
-connected state before use.
-.Pp
-The address of the target is given by
-.Fa to
-with
-.Fa tolen
-specifying its size, or the equivalent
-.Fa msg_name
-and
-.Fa msg_namelen
-in
-.Fa struct msghdr .
-If the socket is in a connected state, the target address passed to
-.Fn sendto ,
-.Fn sendmsg
-or
-.Fn sendmmsg
-is ignored.
-The length of the message is given by
-.Fa len .
-If the message is too long to pass atomically through the
-underlying protocol, the error
-.Er EMSGSIZE
-is returned, and
-the message is not transmitted.
-.Pp
-The
-.Fn sendmmsg
-function sends multiple messages at a call.
-They are given by the
-.Fa msgvec
-vector along with
-.Fa vlen
-specifying the vector size.
-The number of octets sent per each message is placed in the
-.Fa msg_len
-field of each processed element of the vector after transmission.
-.Pp
-No indication of failure to deliver is implicit in a
-.Fn send .
-Locally detected errors are indicated by a return value of -1.
-.Pp
-If no messages space is available at the socket to hold
-the message to be transmitted, then
-.Fn send
-normally blocks, unless the socket has been placed in
-non-blocking I/O mode.
-The
-.Xr select 2
-system call may be used to determine when it is possible to
-send more data.
-.Pp
-The
-.Fa flags
-argument may include one or more of the following:
-.Bd -literal
-#define MSG_OOB 0x00001 /* process out-of-band data */
-#define MSG_DONTROUTE 0x00004 /* bypass routing, use direct interface */
-#define MSG_EOR 0x00008 /* data completes record */
-#define MSG_DONTWAIT 0x00080 /* do not block */
-#define MSG_EOF 0x00100 /* data completes transaction */
-#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */
-.Ed
-.Pp
-The flag
-.Dv MSG_OOB
-is used to send
-.Dq out-of-band
-data on sockets that support this notion (e.g.\&
-.Dv SOCK_STREAM ) ;
-the underlying protocol must also support
-.Dq out-of-band
-data.
-.Dv MSG_EOR
-is used to indicate a record mark for protocols which support the
-concept.
-The
-.Dv MSG_DONTWAIT
-flag request the call to return when it would block otherwise.
-.Dv MSG_EOF
-requests that the sender side of a socket be shut down, and that an
-appropriate indication be sent at the end of the specified data;
-this flag is only implemented for
-.Dv SOCK_STREAM
-sockets in the
-.Dv PF_INET
-protocol family.
-.Dv MSG_DONTROUTE
-is usually used only by diagnostic or routing programs.
-.Dv MSG_NOSIGNAL
-is used to prevent
-.Dv SIGPIPE
-generation when writing a socket that
-may be closed.
-.Pp
-See
-.Xr recv 2
-for a description of the
-.Fa msghdr
-structure and the
-.Fa mmsghdr
-structure.
-.Sh RETURN VALUES
-The
-.Fn send ,
-.Fn sendto
-and
-.Fn sendmsg
-calls
-return the number of octets sent.
-The
-.Fn sendmmsg
-call returns the number of messages sent.
-If an error occurred a value of -1 is returned.
-.Sh ERRORS
-The
-.Fn send
-and
-.Fn sendmmsg
-functions and
-.Fn sendto
-and
-.Fn sendmsg
-system calls
-fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-An invalid descriptor was specified.
-.It Bq Er EACCES
-The destination address is a broadcast address, and
-.Dv SO_BROADCAST
-has not been set on the socket.
-.It Bq Er ENOTCONN
-The socket is connection-mode but is not connected.
-.It Bq Er ENOTSOCK
-The argument
-.Fa s
-is not a socket.
-.It Bq Er EFAULT
-An invalid user space address was specified for an argument.
-.It Bq Er EMSGSIZE
-The socket requires that message be sent atomically,
-and the size of the message to be sent made this impossible.
-.It Bq Er EAGAIN
-The socket is marked non-blocking, or
-.Dv MSG_DONTWAIT
-is specified, and the requested operation would block.
-.It Bq Er ENOBUFS
-The system was unable to allocate an internal buffer.
-The operation may succeed when buffers become available.
-.It Bq Er ENOBUFS
-The output queue for a network interface was full.
-This generally indicates that the interface has stopped sending,
-but may be caused by transient congestion.
-.It Bq Er EHOSTUNREACH
-The remote host was unreachable.
-.It Bq Er EISCONN
-A destination address was specified and the socket is already connected.
-.It Bq Er ECONNREFUSED
-The socket received an ICMP destination unreachable message
-from the last message sent.
-This typically means that the
-receiver is not listening on the remote port.
-.It Bq Er EHOSTDOWN
-The remote host was down.
-.It Bq Er ENETDOWN
-The remote network was down.
-.It Bq Er EADDRNOTAVAIL
-The process using a
-.Dv SOCK_RAW
-socket was jailed and the source
-address specified in the IP header did not match the IP
-address bound to the prison.
-.It Bq Er EPIPE
-The socket is unable to send anymore data
-.Dv ( SBS_CANTSENDMORE
-has been set on the socket).
-This typically means that the socket
-is not connected.
-.El
-.Sh SEE ALSO
-.Xr connect 2 ,
-.Xr fcntl 2 ,
-.Xr getsockopt 2 ,
-.Xr recv 2 ,
-.Xr select 2 ,
-.Xr socket 2 ,
-.Xr write 2 ,
-.Xr CMSG_DATA 3
-.Sh HISTORY
-The
-.Fn send
-function appeared in
-.Bx 4.2 .
-The
-.Fn sendmmsg
-function appeared in
-.Fx 11.0 .
-.Sh BUGS
-Because
-.Fn sendmsg
-does not necessarily block until the data has been transferred, it
-is possible to transfer an open file descriptor across an
-.Dv AF_UNIX
-domain socket
-(see
-.Xr recv 2 ) ,
-then
-.Fn close
-it before it has actually been sent, the result being that the receiver
-gets a closed file descriptor.
-It is left to the application to
-implement an acknowledgment mechanism to prevent this from happening.
diff --git a/lib/libc/sys/send.c b/lib/libc/sys/send.c
new file mode 100644
index 000000000000..82715c1b880b
--- /dev/null
+++ b/lib/libc/sys/send.c
@@ -0,0 +1,46 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1988, 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.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "libc_private.h"
+
+#include <stddef.h>
+
+ssize_t
+send(int s, const void *msg, size_t len, int flags)
+{
+ /*
+ * POSIX says send() shall be a cancellation point, so call the
+ * cancellation-enabled sendto() and not _sendto().
+ */
+ return (INTERPOS_SYS(sendto, s, msg, len, flags, NULL, 0));
+}
diff --git a/lib/libc/sys/sendfile.2 b/lib/libc/sys/sendfile.2
deleted file mode 100644
index 3ffbd733494d..000000000000
--- a/lib/libc/sys/sendfile.2
+++ /dev/null
@@ -1,443 +0,0 @@
-.\" Copyright (c) 2003, David G. Lawrence
-.\" 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 unmodified, 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.
-.\"
-.Dd March 30, 2020
-.Dt SENDFILE 2
-.Os
-.Sh NAME
-.Nm sendfile
-.Nd send a file to a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.In sys/uio.h
-.Ft int
-.Fo sendfile
-.Fa "int fd" "int s" "off_t offset" "size_t nbytes"
-.Fa "struct sf_hdtr *hdtr" "off_t *sbytes" "int flags"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn sendfile
-system call
-sends a regular file or shared memory object specified by descriptor
-.Fa fd
-out a stream socket specified by descriptor
-.Fa s .
-.Pp
-The
-.Fa offset
-argument specifies where to begin in the file.
-Should
-.Fa offset
-fall beyond the end of file, the system will return
-success and report 0 bytes sent as described below.
-The
-.Fa nbytes
-argument specifies how many bytes of the file should be sent, with 0 having the special
-meaning of send until the end of file has been reached.
-.Pp
-An optional header and/or trailer can be sent before and after the file data by specifying
-a pointer to a
-.Vt "struct sf_hdtr" ,
-which has the following structure:
-.Pp
-.Bd -literal -offset indent -compact
-struct sf_hdtr {
- struct iovec *headers; /* pointer to header iovecs */
- int hdr_cnt; /* number of header iovecs */
- struct iovec *trailers; /* pointer to trailer iovecs */
- int trl_cnt; /* number of trailer iovecs */
-};
-.Ed
-.Pp
-The
-.Fa headers
-and
-.Fa trailers
-pointers, if
-.Pf non- Dv NULL ,
-point to arrays of
-.Vt "struct iovec"
-structures.
-See the
-.Fn writev
-system call for information on the iovec structure.
-The number of iovecs in these
-arrays is specified by
-.Fa hdr_cnt
-and
-.Fa trl_cnt .
-.Pp
-If
-.Pf non- Dv NULL ,
-the system will write the total number of bytes sent on the socket to the
-variable pointed to by
-.Fa sbytes .
-.Pp
-The least significant 16 bits of
-.Fa flags
-argument is a bitmap of these values:
-.Bl -tag -offset indent -width "SF_USER_READAHEAD"
-.It Dv SF_NODISKIO
-This flag causes
-.Nm
-to return
-.Er EBUSY
-instead of blocking when a busy page is encountered.
-This rare situation can happen if some other process is now working
-with the same region of the file.
-It is advised to retry the operation after a short period.
-.Pp
-Note that in older
-.Fx
-versions the
-.Dv SF_NODISKIO
-had slightly different notion.
-The flag prevented
-.Nm
-to run I/O operations in case if an invalid (not cached) page is encountered,
-thus avoiding blocking on I/O.
-Starting with
-.Fx 11
-.Nm
-sending files off the
-.Xr ffs 7
-filesystem does not block on I/O
-(see
-.Sx IMPLEMENTATION NOTES
-), so the condition no longer applies.
-However, it is safe if an application utilizes
-.Dv SF_NODISKIO
-and on
-.Er EBUSY
-performs the same action as it did in
-older
-.Fx
-versions, e.g.,
-.Xr aio_read 2 ,
-.Xr read 2
-or
-.Nm
-in a different context.
-.It Dv SF_NOCACHE
-The data sent to socket will not be cached by the virtual memory system,
-and will be freed directly to the pool of free pages.
-.It Dv SF_SYNC
-.Nm
-sleeps until the network stack no longer references the VM pages
-of the file, making subsequent modifications to it safe.
-Please note that this is not a guarantee that the data has actually
-been sent.
-.It Dv SF_USER_READAHEAD
-.Nm
-has some internal heuristics to do readahead when sending data.
-This flag forces
-.Nm
-to override any heuristically calculated readahead and use exactly the
-application specified readahead.
-See
-.Sx SETTING READAHEAD
-for more details on readahead.
-.El
-.Pp
-When using a socket marked for non-blocking I/O,
-.Fn sendfile
-may send fewer bytes than requested.
-In this case, the number of bytes successfully
-written is returned in
-.Fa *sbytes
-(if specified),
-and the error
-.Er EAGAIN
-is returned.
-.Sh SETTING READAHEAD
-.Nm
-uses internal heuristics based on request size and file system layout
-to do readahead.
-Additionally application may request extra readahead.
-The most significant 16 bits of
-.Fa flags
-specify amount of pages that
-.Nm
-may read ahead when reading the file.
-A macro
-.Fn SF_FLAGS
-is provided to combine readahead amount and flags.
-An example showing specifying readahead of 16 pages and
-.Dv SF_NOCACHE
-flag:
-.Pp
-.Bd -literal -offset indent -compact
- SF_FLAGS(16, SF_NOCACHE)
-.Ed
-.Pp
-.Nm
-will use either application specified readahead or internally calculated,
-whichever is bigger.
-Setting flag
-.Dv SF_USER_READAHEAD
-would turn off any heuristics and set maximum possible readahead length to
-the number of pages specified via flags.
-.Sh IMPLEMENTATION NOTES
-The
-.Fx
-implementation of
-.Fn sendfile
-does not block on disk I/O when it sends a file off the
-.Xr ffs 7
-filesystem.
-The syscall returns success before the actual I/O completes, and data
-is put into the socket later unattended.
-However, the order of data in the socket is preserved, so it is safe
-to do further writes to the socket.
-.Pp
-The
-.Fx
-implementation of
-.Fn sendfile
-is "zero-copy", meaning that it has been optimized so that copying of the file data is avoided.
-.Sh TUNING
-.Ss physical paging buffers
-.Fn sendfile
-uses vnode pager to read file pages into memory.
-The pager uses a pool of physical buffers to run its I/O operations.
-When system runs out of pbufs, sendfile will block and report state
-.Dq Li zonelimit .
-Size of the pool can be tuned with
-.Va vm.vnode_pbufs
-.Xr loader.conf 5
-tunable and can be checked with
-.Xr sysctl 8
-OID of the same name at runtime.
-.Ss sendfile(2) buffers
-On some architectures, this system call internally uses a special
-.Fn sendfile
-buffer
-.Pq Vt "struct sf_buf"
-to handle sending file data to the client.
-If the sending socket is
-blocking, and there are not enough
-.Fn sendfile
-buffers available,
-.Fn sendfile
-will block and report a state of
-.Dq Li sfbufa .
-If the sending socket is non-blocking and there are not enough
-.Fn sendfile
-buffers available, the call will block and wait for the
-necessary buffers to become available before finishing the call.
-.Pp
-The number of
-.Vt sf_buf Ns 's
-allocated should be proportional to the number of nmbclusters used to
-send data to a client via
-.Fn sendfile .
-Tune accordingly to avoid blocking!
-Busy installations that make extensive use of
-.Fn sendfile
-may want to increase these values to be inline with their
-.Va kern.ipc.nmbclusters
-(see
-.Xr tuning 7
-for details).
-.Pp
-The number of
-.Fn sendfile
-buffers available is determined at boot time by either the
-.Va kern.ipc.nsfbufs
-.Xr loader.conf 5
-variable or the
-.Dv NSFBUFS
-kernel configuration tunable.
-The number of
-.Fn sendfile
-buffers scales with
-.Va kern.maxusers .
-The
-.Va kern.ipc.nsfbufsused
-and
-.Va kern.ipc.nsfbufspeak
-read-only
-.Xr sysctl 8
-variables show current and peak
-.Fn sendfile
-buffers usage respectively.
-These values may also be viewed through
-.Nm netstat Fl m .
-.Pp
-If
-.Xr sysctl 8
-OID
-.Va kern.ipc.nsfbufs
-doesn't exist, your architecture does not need to use
-.Fn sendfile
-buffers because their task can be efficiently performed
-by the generic virtual memory structures.
-.Sh RETURN VALUES
-.Rv -std sendfile
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The socket is marked for non-blocking I/O and not all data was sent due to
-the socket buffer being filled.
-If specified, the number of bytes successfully sent will be returned in
-.Fa *sbytes .
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid file descriptor.
-.It Bq Er EBADF
-The
-.Fa s
-argument
-is not a valid socket descriptor.
-.It Bq Er EBUSY
-A busy page was encountered and
-.Dv SF_NODISKIO
-had been specified.
-Partial data may have been sent.
-.It Bq Er EFAULT
-An invalid address was specified for an argument.
-.It Bq Er EINTR
-A signal interrupted
-.Fn sendfile
-before it could be completed.
-If specified, the number
-of bytes successfully sent will be returned in
-.Fa *sbytes .
-.It Bq Er EINVAL
-The
-.Fa fd
-argument
-is not a regular file.
-.It Bq Er EINVAL
-The
-.Fa s
-argument
-is not a SOCK_STREAM type socket.
-.It Bq Er EINVAL
-The
-.Fa offset
-argument
-is negative.
-.It Bq Er EIO
-An error occurred while reading from
-.Fa fd .
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from
-.Fa fd .
-.It Bq Er ENOTCAPABLE
-The
-.Fa fd
-or the
-.Fa s
-argument has insufficient rights.
-.It Bq Er ENOBUFS
-The system was unable to allocate an internal buffer.
-.It Bq Er ENOTCONN
-The
-.Fa s
-argument
-points to an unconnected socket.
-.It Bq Er ENOTSOCK
-The
-.Fa s
-argument
-is not a socket.
-.It Bq Er EOPNOTSUPP
-The file system for descriptor
-.Fa fd
-does not support
-.Fn sendfile .
-.It Bq Er EPIPE
-The socket peer has closed the connection.
-.El
-.Sh SEE ALSO
-.Xr netstat 1 ,
-.Xr open 2 ,
-.Xr send 2 ,
-.Xr socket 2 ,
-.Xr writev 2 ,
-.Xr loader.conf 5 ,
-.Xr tuning 7 ,
-.Xr sysctl 8
-.Rs
-.%A K. Elmeleegy
-.%A A. Chanda
-.%A A. L. Cox
-.%A W. Zwaenepoel
-.%T A Portable Kernel Abstraction for Low-Overhead Ephemeral Mapping Management
-.%J The Proceedings of the 2005 USENIX Annual Technical Conference
-.%P pp 223-236
-.%D 2005
-.Re
-.Sh HISTORY
-The
-.Fn sendfile
-system call
-first appeared in
-.Fx 3.0 .
-This manual page first appeared in
-.Fx 3.1 .
-In
-.Fx 10
-support for sending shared memory descriptors had been introduced.
-In
-.Fx 11
-a non-blocking implementation had been introduced.
-.Sh AUTHORS
-The initial implementation of
-.Fn sendfile
-system call
-and this manual page were written by
-.An David G. Lawrence Aq Mt dg@dglawrence.com .
-The
-.Fx 11
-implementation was written by
-.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org .
-.Sh BUGS
-The
-.Fn sendfile
-system call will not fail, i.e., return
-.Dv -1
-and set
-.Va errno
-to
-.Er EFAULT ,
-if provided an invalid address for
-.Fa sbytes .
-The
-.Fn sendfile
-system call does not support SCTP sockets,
-it will return
-.Dv -1
-and set
-.Va errno
-to
-.Er EINVAL .
diff --git a/lib/libc/sys/sendmsg.c b/lib/libc/sys/sendmsg.c
index f78fbaa258a5..fd4e41837c48 100644
--- a/lib/libc/sys/sendmsg.c
+++ b/lib/libc/sys/sendmsg.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_sendmsg, __sendmsg);
ssize_t
sendmsg(int s, const struct msghdr *msg, int flags)
{
-
- return (((int (*)(int, const struct msghdr *, int))
- __libc_interposing[INTERPOS_sendmsg])(s, msg, flags));
+ return (INTERPOS_SYS(sendmsg, s, msg, flags));
}
diff --git a/lib/libc/sys/sendto.c b/lib/libc/sys/sendto.c
index d27d8638e750..708fc6ec9368 100644
--- a/lib/libc/sys/sendto.c
+++ b/lib/libc/sys/sendto.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
@@ -42,9 +41,5 @@ ssize_t
sendto(int s, const void *msg, size_t len, int flags,
const struct sockaddr *to, socklen_t tolen)
{
-
- return (((ssize_t (*)(int, const void *, size_t, int,
- const struct sockaddr *, socklen_t))
- __libc_interposing[INTERPOS_sendto])(s, msg, len, flags,
- to, tolen));
+ return (INTERPOS_SYS(sendto, s, msg, len, flags, to, tolen));
}
diff --git a/lib/libc/sys/setcontext.c b/lib/libc/sys/setcontext.c
index ffdd7ebbf890..96b5dc115067 100644
--- a/lib/libc/sys/setcontext.c
+++ b/lib/libc/sys/setcontext.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ucontext.h>
#include "libc_private.h"
@@ -43,7 +42,5 @@ __sym_default(setcontext, setcontext, FBSD_1.2);
int
setcontext(const ucontext_t *uc)
{
-
- return (((int (*)(const ucontext_t *))
- __libc_interposing[INTERPOS_setcontext])(uc));
+ return (INTERPOS_SYS(setcontext, uc));
}
diff --git a/lib/libc/sys/setfib.2 b/lib/libc/sys/setfib.2
deleted file mode 100644
index efbb7bf171ae..000000000000
--- a/lib/libc/sys/setfib.2
+++ /dev/null
@@ -1,105 +0,0 @@
-.\" Copyright (c) 2008 Cisco Systems. All rights reserved.
-.\" Author: Julian Elischer
-.\"
-.\" 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. Neither the name of the Cisco Systems nor the names of its employees
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
-.\"
-.Dd March 19, 2012
-.Dt SETFIB 2
-.Os
-.Sh NAME
-.Nm setfib
-.Nd set the default FIB (routing table) for the calling process
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft int
-.Fn setfib "int fib"
-.Sh DESCRIPTION
-The
-.Fn setfib
-system call sets the associated fib for all sockets opened
-subsequent to the call, to be that of the argument
-.Fa fib .
-The
-.Fa fib
-argument
-must be greater than or equal to 0
-and less than the current system maximum which
-may be retrieved by the
-.Va net.fibs
-sysctl.
-The system maximum is set in the kernel configuration file with
-.Bd -ragged -offset indent
-.Cd "options ROUTETABLES=" Ns Em N
-.Ed
-.Pp
-or in
-.Pa /boot/loader.conf
-with
-.Pp
-.Dl net.fibs= Ns Qq Em N
-.Pp
-where
-.Em N
-is an integer.
-This maximum is capped at 65536 due to the implementation storing
-the fib number in a 16-bit field in the
-.Xr mbuf 9
-packet header, however it is not suggested that one use such a large number
-as memory is allocated for every FIB regardless of whether it is used, and
-there are places where all FIBs are iterated over.
-.Pp
-The default fib of the process will be applied to all protocol families
-that support multiple fibs, and ignored by those that do not.
-The default fib for a process may be overridden for a socket with the use
-of the
-.Dv SO_SETFIB
-socket option.
-.Sh RETURN VALUES
-.Rv -std setfib
-.Sh ERRORS
-The
-.Fn setfib
-system call
-will fail and no action will be taken and return
-.Er EINVAL
-if the
-.Fa fib
-argument is greater than the current system maximum.
-.Sh SEE ALSO
-.Xr setfib 1 ,
-.Xr setsockopt 2
-.Sh STANDARDS
-The
-.Fn setfib
-system call is a
-.Fx
-extension however similar extensions
-have been added to many other
-.Ux
-style kernels.
-.Sh HISTORY
-The
-.Fn setfib
-function appeared in
-.Fx 7.1 .
diff --git a/lib/libc/sys/setgroups.2 b/lib/libc/sys/setgroups.2
deleted file mode 100644
index a6109a9b5888..000000000000
--- a/lib/libc/sys/setgroups.2
+++ /dev/null
@@ -1,103 +0,0 @@
-.\" Copyright (c) 1983, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)setgroups.2 8.2 (Berkeley) 4/16/94
-.\"
-.Dd January 19, 2018
-.Dt SETGROUPS 2
-.Os
-.Sh NAME
-.Nm setgroups
-.Nd set group access list
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In unistd.h
-.Ft int
-.Fn setgroups "int ngroups" "const gid_t *gidset"
-.Sh DESCRIPTION
-The
-.Fn setgroups
-system call
-sets the group access list of the current user process
-according to the array
-.Fa gidset .
-The
-.Fa ngroups
-argument
-indicates the number of entries in the array and must be no
-more than
-.Dv {NGROUPS_MAX}+1 .
-.Pp
-Only the super-user may set a new group list.
-.Pp
-The first entry of the group array
-.Pq Va gidset[0]
-is used as the effective group-ID for the process.
-This entry is over-written when a setgid program is run.
-To avoid losing access to the privileges of the
-.Va gidset[0]
-entry, it should be duplicated later in the group array.
-By convention,
-this happens because the group value indicated
-in the password file also appears in
-.Pa /etc/group .
-The group value in the password file is placed in
-.Va gidset[0]
-and that value then gets added a second time when the
-.Pa /etc/group
-file is scanned to create the group set.
-.Sh RETURN VALUES
-.Rv -std setgroups
-.Sh ERRORS
-The
-.Fn setgroups
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller is not the super-user.
-.It Bq Er EINVAL
-The number specified in the
-.Fa ngroups
-argument is larger than the
-.Dv {NGROUPS_MAX}+1
-limit.
-.It Bq Er EFAULT
-The address specified for
-.Fa gidset
-is outside the process
-address space.
-.El
-.Sh SEE ALSO
-.Xr getgroups 2 ,
-.Xr initgroups 3
-.Sh HISTORY
-The
-.Fn setgroups
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/setpgid.2 b/lib/libc/sys/setpgid.2
deleted file mode 100644
index d00e8bf39511..000000000000
--- a/lib/libc/sys/setpgid.2
+++ /dev/null
@@ -1,109 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)setpgid.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd February 8, 2004
-.Dt SETPGID 2
-.Os
-.Sh NAME
-.Nm setpgid ,
-.Nm setpgrp
-.Nd set process group
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn setpgid "pid_t pid" "pid_t pgrp"
-.Ft int
-.Fn setpgrp "pid_t pid" "pid_t pgrp"
-.Sh DESCRIPTION
-The
-.Fn setpgid
-system call
-sets the process group of the specified process
-.Fa pid
-to the specified
-.Fa pgrp .
-If
-.Fa pid
-is zero, then the call applies to the current process.
-If
-.Fa pgrp
-is zero, then the process id of the process specified by
-.Fa pid
-is used instead.
-.Pp
-If the affected process is not the invoking process, then it must be a
-child of the invoking process, it must not have performed an
-.Xr exec 3
-operation, and both processes must be in the same session.
-The requested process group ID must already exist in the session of
-the caller, or it must be equal to the target process ID.
-.Sh RETURN VALUES
-.Rv -std setpgid
-.Sh COMPATIBILITY
-The
-.Fn setpgrp
-system call
-is identical to
-.Fn setpgid ,
-and is retained for calling convention compatibility with historical
-versions of
-.Bx .
-.Sh ERRORS
-The
-.Fn setpgid
-system call
-will fail and the process group will not be altered if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The requested process group ID is not legal.
-.It Bq Er ESRCH
-The requested process does not exist.
-.It Bq Er ESRCH
-The target process is not the calling process or
-a child of the calling process.
-.It Bq Er EACCES
-The requested process is a child of the calling process,
-but it has performed an
-.Xr exec 3
-operation.
-.It Bq Er EPERM
-The target process is a session leader.
-.It Bq Er EPERM
-The requested process group ID is not in the session of the caller,
-and it is not equal to the process ID of the target process.
-.El
-.Sh SEE ALSO
-.Xr getpgrp 2
-.Sh STANDARDS
-The
-.Fn setpgid
-system call is expected to conform to
-.St -p1003.1-90 .
diff --git a/lib/libc/sys/setregid.2 b/lib/libc/sys/setregid.2
deleted file mode 100644
index 7fed33503b10..000000000000
--- a/lib/libc/sys/setregid.2
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)setregid.2 8.2 (Berkeley) 4/16/94
-.\"
-.Dd April 16, 1994
-.Dt SETREGID 2
-.Os
-.Sh NAME
-.Nm setregid
-.Nd set real and effective group ID
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn setregid "gid_t rgid" "gid_t egid"
-.Sh DESCRIPTION
-The real and effective group ID's of the current process
-are set to the arguments.
-If the real group ID is changed, the saved group ID is changed to the
-new value of the effective group ID.
-.Pp
-Unprivileged users may change the real group
-ID to the effective group ID and vice-versa; only the super-user may
-make other changes.
-.Pp
-Supplying a value of -1 for either the real or effective
-group ID forces the system to substitute the current
-ID in place of the -1 argument.
-.Pp
-The
-.Fn setregid
-system call was intended to allow swapping
-the real and effective group IDs
-in set-group-ID programs to temporarily relinquish the set-group-ID value.
-This system call did not work correctly,
-and its purpose is now better served by the use of the
-.Xr setegid 2
-system call.
-.Pp
-When setting the real and effective group IDs to the same value,
-the standard
-.Fn setgid
-system call is preferred.
-.Sh RETURN VALUES
-.Rv -std setregid
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EPERM
-The current process is not the super-user and a change
-other than changing the effective group-id to the real group-id
-was specified.
-.El
-.Sh SEE ALSO
-.Xr getgid 2 ,
-.Xr issetugid 2 ,
-.Xr setegid 2 ,
-.Xr setgid 2 ,
-.Xr setuid 2
-.Sh HISTORY
-The
-.Fn setregid
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/setreuid.2 b/lib/libc/sys/setreuid.2
deleted file mode 100644
index 579eaf4a5bc9..000000000000
--- a/lib/libc/sys/setreuid.2
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)setreuid.2 8.2 (Berkeley) 4/16/94
-.\"
-.Dd February 8, 2001
-.Dt SETREUID 2
-.Os
-.Sh NAME
-.Nm setreuid
-.Nd set real and effective user ID's
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn setreuid "uid_t ruid" "uid_t euid"
-.Sh DESCRIPTION
-The real and effective user IDs of the
-current process are set according to the arguments.
-If
-.Fa ruid
-or
-.Fa euid
-is -1, the current uid is filled in by the system.
-Unprivileged users may change the real user
-ID to the effective user ID and vice-versa; only the super-user may
-make other changes.
-.Pp
-If the real user ID is changed (i.e.\&
-.Fa ruid
-is not -1) or the effective user ID is changed to something other than
-the real user ID, then the saved user ID will be set to the effective user ID.
-.Pp
-The
-.Fn setreuid
-system call has been used to swap the real and effective user IDs
-in set-user-ID programs to temporarily relinquish the set-user-ID value.
-This purpose is now better served by the use of the
-.Xr seteuid 2
-system call.
-.Pp
-When setting the real and effective user IDs to the same value,
-the standard
-.Fn setuid
-system call is preferred.
-.Sh RETURN VALUES
-.Rv -std setreuid
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EPERM
-The current process is not the super-user and a change
-other than changing the effective user-id to the real user-id
-was specified.
-.El
-.Sh SEE ALSO
-.Xr getuid 2 ,
-.Xr issetugid 2 ,
-.Xr seteuid 2 ,
-.Xr setuid 2
-.Sh HISTORY
-The
-.Fn setreuid
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/setsid.2 b/lib/libc/sys/setsid.2
deleted file mode 100644
index 8cb680d9cd91..000000000000
--- a/lib/libc/sys/setsid.2
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1991, 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.
-.\"
-.\" @(#)setsid.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt SETSID 2
-.Os
-.Sh NAME
-.Nm setsid
-.Nd create session and set process group ID
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft pid_t
-.Fn setsid void
-.Sh DESCRIPTION
-The
-.Fn setsid
-system call creates a new session.
-The calling process is the session leader of the new session, is the
-process group leader of a new process group and has no controlling
-terminal.
-The calling process is the only process in either the session or the
-process group.
-.Sh RETURN VALUES
-Upon successful completion, the
-.Fn setsid
-system call returns the value of the process group ID of the new process
-group, which is the same as the process ID of the calling process.
-If an error occurs,
-.Fn setsid
-returns -1 and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn setsid
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The calling process is already a process group leader, or the process
-group ID of a process other than the calling process matches the process
-ID of the calling process.
-.El
-.Sh SEE ALSO
-.Xr setpgid 2 ,
-.Xr tcgetpgrp 3 ,
-.Xr tcsetpgrp 3
-.Sh STANDARDS
-The
-.Fn setsid
-system call is expected to be compliant with the
-.St -p1003.1-90
-specification.
diff --git a/lib/libc/sys/setuid.2 b/lib/libc/sys/setuid.2
deleted file mode 100644
index 036d3586aafa..000000000000
--- a/lib/libc/sys/setuid.2
+++ /dev/null
@@ -1,188 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)setuid.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 15, 2015
-.Dt SETUID 2
-.Os
-.Sh NAME
-.Nm setuid ,
-.Nm seteuid ,
-.Nm setgid ,
-.Nm setegid
-.Nd set user and group ID
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn setuid "uid_t uid"
-.Ft int
-.Fn seteuid "uid_t euid"
-.Ft int
-.Fn setgid "gid_t gid"
-.Ft int
-.Fn setegid "gid_t egid"
-.Sh DESCRIPTION
-The
-.Fn setuid
-system call
-sets the real and effective
-user IDs and the saved set-user-ID of the current process
-to the specified value.
-.\" Comment out next block for !_POSIX_SAVED_IDS
-.\" The real user ID and the saved set-user-ID are changed only if the
-.\" effective user ID is that of the super user.
-.\" I.e.
-.\" .Fn setuid
-.\" system call is equal to
-.\" .Fn seteuid
-.\" system call if the effective user ID is not that of the super user.
-.\" End of block
-The
-.Fn setuid
-system call is permitted if the specified ID is equal to the real user ID
-.\" Comment out next line for !_POSIX_SAVED_IDS
-.\" or the saved set-user-ID
-.\" Next line is for Appendix B.4.2.2 case.
-or the effective user ID
-of the process, or if the effective user ID is that of the super user.
-.Pp
-The
-.Fn setgid
-system call
-sets the real and effective
-group IDs and the saved set-group-ID of the current process
-to the specified value.
-.\" Comment out next block for !_POSIX_SAVED_IDS
-.\" The real group ID and the saved set-group-ID are changed only if the
-.\" effective user ID is that of the super user.
-.\" I.e.
-.\" .Fn setgid
-.\" system call is equal to
-.\" .Fn setegid
-.\" system call if the effective user ID is not that of the super user.
-.\" End of block
-The
-.Fn setgid
-system call is permitted if the specified ID is equal to the real group ID
-.\" Comment out next line for !_POSIX_SAVED_IDS
-.\" or the saved set-group-ID
-.\" Next line is for Appendix B.4.2.2 case.
-or the effective group ID
-of the process, or if the effective user ID is that of the super user.
-.Pp
-The
-.Fn seteuid
-system call
-.Pq Fn setegid
-sets the effective user ID (group ID) of the
-current process.
-The effective user ID may be set to the value
-of the real user ID or the saved set-user-ID (see
-.Xr intro 2
-and
-.Xr execve 2 ) ;
-in this way, the effective user ID of a set-user-ID executable
-may be toggled by switching to the real user ID, then re-enabled
-by reverting to the set-user-ID value.
-Similarly, the effective group ID may be set to the value
-of the real group ID or the saved set-group-ID.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The user is not the super user and the ID
-specified is not the real, effective ID, or saved ID.
-.El
-.Sh SEE ALSO
-.Xr getgid 2 ,
-.Xr getuid 2 ,
-.Xr issetugid 2 ,
-.Xr setregid 2 ,
-.Xr setreuid 2
-.Sh STANDARDS
-The
-.Fn setuid
-and
-.Fn setgid
-system calls are compliant with the
-.St -p1003.1-90
-specification with
-.Li _POSIX_SAVED_IDS
-.\" Uncomment next line for !_POSIX_SAVED_IDS
-not
-defined with the permitted extensions from Appendix B.4.2.2.
-The
-.Fn seteuid
-and
-.Fn setegid
-system calls are extensions based on the
-.Tn POSIX
-concept of
-.Li _POSIX_SAVED_IDS ,
-and have been proposed for a future revision of the standard.
-.Sh HISTORY
-The
-.Fn setuid
-function appeared in
-.At v1 .
-The
-.Fn setgid
-function appeared in
-.At v4 .
-.Sh SECURITY CONSIDERATIONS
-Read and write permissions to files are determined upon a call to
-.Xr open 2 .
-Once a file descriptor is open, dropping privilege does not affect
-the process's read/write permissions, even if the user ID specified
-has no read or write permissions to the file.
-These files normally remain open in any new process executed,
-resulting in a user being able to read or modify
-potentially sensitive data.
-.Pp
-To prevent these files from remaining open after an
-.Xr exec 3
-call, be sure to set the close-on-exec flag:
-.Bd -literal
-void
-pseudocode(void)
-{
- int fd;
- /* ... */
-
- fd = open("/path/to/sensitive/data", O_RDWR | O_CLOEXEC);
- if (fd == -1)
- err(1, "open");
-
- /* ... */
- execve(path, argv, environ);
-}
-.Ed
diff --git a/lib/libc/sys/shm_open.c b/lib/libc/sys/shm_open.c
index 200103442d04..eb3022c857b1 100644
--- a/lib/libc/sys/shm_open.c
+++ b/lib/libc/sys/shm_open.c
@@ -28,16 +28,12 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/filio.h>
#include <sys/mman.h>
#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -46,12 +42,9 @@
__weak_reference(shm_open, _shm_open);
__weak_reference(shm_open, __sys_shm_open);
-#define MEMFD_NAME_PREFIX "memfd:"
-
int
shm_open(const char *path, int flags, mode_t mode)
{
-
return (__sys_shm_open2(path, flags | O_CLOEXEC, mode, 0, NULL));
}
@@ -78,90 +71,3 @@ shm_create_largepage(const char *path, int flags, int psind, int alloc_policy,
}
return (fd);
}
-
-/*
- * The path argument is passed to the kernel, but the kernel doesn't currently
- * do anything with it. Linux exposes it in linprocfs for debugging purposes
- * only, but our kernel currently will not do the same.
- */
-int
-memfd_create(const char *name, unsigned int flags)
-{
- char memfd_name[NAME_MAX + 1];
- size_t namelen, *pgs, pgsize;
- struct shm_largepage_conf slc;
- int error, fd, npgs, oflags, pgidx, saved_errno, shmflags;
-
- if (name == NULL) {
- errno = EBADF;
- return (-1);
- }
- namelen = strlen(name);
- if (namelen + sizeof(MEMFD_NAME_PREFIX) - 1 > NAME_MAX) {
- errno = EINVAL;
- return (-1);
- }
- if ((flags & ~(MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_HUGETLB |
- MFD_HUGE_MASK)) != 0) {
- errno = EINVAL;
- return (-1);
- }
- /* Size specified but no HUGETLB. */
- if ((flags & MFD_HUGE_MASK) != 0 && (flags & MFD_HUGETLB) == 0) {
- errno = EINVAL;
- return (-1);
- }
-
- /* We've already validated that we're sufficiently sized. */
- snprintf(memfd_name, NAME_MAX + 1, "%s%s", MEMFD_NAME_PREFIX, name);
- oflags = O_RDWR;
- shmflags = 0;
- if ((flags & MFD_CLOEXEC) != 0)
- oflags |= O_CLOEXEC;
- if ((flags & MFD_ALLOW_SEALING) != 0)
- shmflags |= SHM_ALLOW_SEALING;
- if ((flags & MFD_HUGETLB) != 0)
- shmflags |= SHM_LARGEPAGE;
- else
- shmflags |= SHM_GROW_ON_WRITE;
- fd = __sys_shm_open2(SHM_ANON, oflags, 0, shmflags, memfd_name);
- if (fd == -1 || (flags & MFD_HUGETLB) == 0)
- return (fd);
-
- pgs = NULL;
- npgs = getpagesizes(NULL, 0);
- if (npgs == -1)
- goto clean;
- pgs = calloc(npgs, sizeof(size_t));
- if (pgs == NULL)
- goto clean;
- error = getpagesizes(pgs, npgs);
- if (error == -1)
- goto clean;
- pgsize = (size_t)1 << ((flags & MFD_HUGE_MASK) >> MFD_HUGE_SHIFT);
- for (pgidx = 0; pgidx < npgs; pgidx++) {
- if (pgsize == pgs[pgidx])
- break;
- }
- if (pgidx == npgs) {
- errno = EOPNOTSUPP;
- goto clean;
- }
- free(pgs);
- pgs = NULL;
-
- memset(&slc, 0, sizeof(slc));
- slc.psind = pgidx;
- slc.alloc_policy = SHM_LARGEPAGE_ALLOC_DEFAULT;
- error = ioctl(fd, FIOSSHMLPGCNF, &slc);
- if (error == -1)
- goto clean;
- return (fd);
-
-clean:
- saved_errno = errno;
- close(fd);
- free(pgs);
- errno = saved_errno;
- return (-1);
-}
diff --git a/lib/libc/sys/shutdown.2 b/lib/libc/sys/shutdown.2
deleted file mode 100644
index aecc279e47df..000000000000
--- a/lib/libc/sys/shutdown.2
+++ /dev/null
@@ -1,170 +0,0 @@
-.\" Copyright (c) 2007 Bruce M. Simpson.
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)shutdown.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd July 27, 2015
-.Dt SHUTDOWN 2
-.Os
-.Sh NAME
-.Nm shutdown
-.Nd disable sends and/or receives on a socket
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.Ft int
-.Fn shutdown "int s" "int how"
-.Sh DESCRIPTION
-The
-.Fn shutdown
-system call disables sends or receives on a socket.
-The
-.Fa how
-argument specifies the type of shutdown.
-Possible values are:
-.Bl -tag -width ".Dv SHUT_RDWR"
-.It Dv SHUT_RD
-Further receives will be disallowed.
-.It Dv SHUT_WR
-Further sends will be disallowed.
-This may cause actions specific to the protocol family of the socket
-.Fa s
-to happen; see
-.Sx IMPLEMENTATION NOTES .
-.It Dv SHUT_RDWR
-Further sends and receives will be disallowed.
-Implies
-.Dv SHUT_WR .
-.El
-.Pp
-If the file descriptor
-.Fa s
-is associated with a
-.Dv SOCK_STREAM
-socket, all or part of the full-duplex connection will be shut down.
-.\"
-.Sh IMPLEMENTATION NOTES
-The following protocol specific actions apply to the use of
-.Dv SHUT_WR
-(and potentially also
-.Dv SHUT_RDWR ) ,
-based on the properties of the socket associated with the file descriptor
-.Fa s .
-.Bl -column ".Dv PF_INET6" ".Dv SOCK_STREAM" ".Dv IPPROTO_SCTP"
-.It Sy Domain Ta Sy Type Ta Sy Protocol Ta Sy Action
-.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta
-Failure,
-as socket is not connected.
-.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta
-Failure,
-as socket is not connected.
-.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta
-Send queued data and tear down association.
-.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta
-Send queued data, wait for ACK, then send FIN.
-.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta
-Failure,
-as socket is not connected.
-.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta
-Failure,
-as socket is not connected.
-.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta
-Send queued data and tear down association.
-.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta
-Send queued data, wait for ACK, then send FIN.
-.El
-.\"
-.Sh RETURN VALUES
-.Rv -std shutdown
-.Sh ERRORS
-The
-.Fn shutdown
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa s
-argument is not a valid file descriptor.
-.It Bq Er EINVAL
-The
-.Fa how
-argument is invalid.
-.It Bq Er ENOTCONN
-The
-.Fa s
-argument specifies a socket which is not connected.
-.It Bq Er ENOTSOCK
-The
-.Fa s
-argument does not refer to a socket.
-.El
-.Sh SEE ALSO
-.Xr connect 2 ,
-.Xr socket 2 ,
-.Xr inet 4 ,
-.Xr inet6 4
-.Sh STANDARDS
-The
-.Fn shutdown
-system call is expected to comply with
-.St -p1003.1g-2000 ,
-when finalized.
-.Sh HISTORY
-The
-.Fn shutdown
-system call appeared in
-.Bx 4.2 .
-The
-.Dv SHUT_RD , SHUT_WR ,
-and
-.Dv SHUT_RDWR
-constants appeared in
-.St -p1003.1g-2000 .
-.Sh AUTHORS
-.An -nosplit
-This manual page was updated by
-.An Bruce M. Simpson Aq Mt bms@FreeBSD.org
-to reflect how
-.Fn shutdown
-behaves with
-.Dv PF_INET
-and
-.Dv PF_INET6
-sockets.
-.Sh BUGS
-The ICMP
-.Dq Li "port unreachable"
-message should be generated in response to
-datagrams received on a local port to which
-.Fa s
-is bound
-after
-.Fn shutdown
-is called.
diff --git a/lib/libc/sys/sigaction.2 b/lib/libc/sys/sigaction.2
deleted file mode 100644
index 913ad60a6b40..000000000000
--- a/lib/libc/sys/sigaction.2
+++ /dev/null
@@ -1,794 +0,0 @@
-.\" Copyright (c) 1980, 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.
-.\"
-.\" From: @(#)sigaction.2 8.2 (Berkeley) 4/3/94
-.\"
-.Dd June 29, 2020
-.Dt SIGACTION 2
-.Os
-.Sh NAME
-.Nm sigaction
-.Nd software signal facilities
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Bd -literal
-struct sigaction {
- void (*sa_handler)(int);
- void (*sa_sigaction)(int, siginfo_t *, void *);
- int sa_flags; /* see signal options below */
- sigset_t sa_mask; /* signal mask to apply */
-};
-.Ed
-.Pp
-.Ft int
-.Fo sigaction
-.Fa "int sig"
-.Fa "const struct sigaction * restrict act"
-.Fa "struct sigaction * restrict oact"
-.Fc
-.Sh DESCRIPTION
-The system defines a set of signals that may be delivered to a process.
-Signal delivery resembles the occurrence of a hardware interrupt:
-the signal is normally blocked from further occurrence, the current thread
-context is saved, and a new one is built.
-A process may specify a
-.Em handler
-to which a signal is delivered, or specify that a signal is to be
-.Em ignored .
-A process may also specify that a default action is to be taken
-by the system when a signal occurs.
-A signal may also be
-.Em blocked
-for a thread,
-in which case it will not be delivered to that thread until it is
-.Em unblocked .
-The action to be taken on delivery is determined at the time
-of delivery.
-Normally, signal handlers execute on the current stack
-of the thread.
-This may be changed, on a per-handler basis,
-so that signals are taken on a special
-.Em "signal stack" .
-.Pp
-Signal routines normally execute with the signal that caused their
-invocation
-.Em blocked ,
-but other signals may yet occur.
-A global
-.Em "signal mask"
-defines the set of signals currently blocked from delivery
-to a thread.
-The signal mask for a thread is initialized
-from that of its parent (normally empty).
-It may be changed with a
-.Xr sigprocmask 2
-or
-.Xr pthread_sigmask 3
-call, or when a signal is delivered to the thread.
-.Pp
-When a signal
-condition arises for a process or thread, the signal is added to a set of
-signals pending for the process or thread.
-Whether the signal is directed at the process in general or at a specific
-thread depends on how it is generated.
-For signals directed at a specific thread,
-if the signal is not currently
-.Em blocked
-by the thread then it is delivered to the thread.
-For signals directed at the process,
-if the signal is not currently
-.Em blocked
-by all threads then it is delivered to one thread that does not have it blocked
-(the selection of which is unspecified).
-Signals may be delivered any time a thread enters the operating system
-(e.g., during a system call, page fault or trap, or clock interrupt).
-If multiple signals are ready to be delivered at the same time,
-any signals that could be caused by traps are delivered first.
-Additional signals may be processed at the same time, with each
-appearing to interrupt the handlers for the previous signals
-before their first instructions.
-The set of pending signals is returned by the
-.Xr sigpending 2
-system call.
-When a caught signal
-is delivered, the current state of the thread is saved,
-a new signal mask is calculated (as described below),
-and the signal handler is invoked.
-The call to the handler
-is arranged so that if the signal handling routine returns
-normally the thread will resume execution in the context
-from before the signal's delivery.
-If the thread wishes to resume in a different context, then it
-must arrange to restore the previous context itself.
-.Pp
-When a signal is delivered to a thread a new signal mask is
-installed for the duration of the process' signal handler
-(or until a
-.Xr sigprocmask 2
-system call is made).
-This mask is formed by taking the union of the current signal mask set,
-the signal to be delivered, and
-the signal mask associated with the handler to be invoked.
-.Pp
-The
-.Fn sigaction
-system call
-assigns an action for a signal specified by
-.Fa sig .
-If
-.Fa act
-is non-NULL, it specifies an action
-.Dv ( SIG_DFL ,
-.Dv SIG_IGN ,
-or a handler routine) and mask to be used when delivering the specified signal.
-If
-.Fa oact
-is non-NULL, the previous handling information for the signal
-is returned to the user.
-.Pp
-The above declaration of
-.Vt "struct sigaction"
-is not literal.
-It is provided only to list the accessible members.
-See
-.In sys/signal.h
-for the actual definition.
-In particular, the storage occupied by
-.Va sa_handler
-and
-.Va sa_sigaction
-overlaps, and it is nonsensical for an application to attempt to use both
-simultaneously.
-.Pp
-Once a signal handler is installed, it normally remains installed
-until another
-.Fn sigaction
-system call is made, or an
-.Xr execve 2
-is performed.
-A signal-specific default action may be reset by
-setting
-.Va sa_handler
-to
-.Dv SIG_DFL .
-The defaults are process termination, possibly with core dump;
-no action; stopping the process; or continuing the process.
-See the signal list below for each signal's default action.
-If
-.Va sa_handler
-is
-.Dv SIG_DFL ,
-the default action for the signal is to discard the signal,
-and if a signal is pending,
-the pending signal is discarded even if the signal is masked.
-If
-.Va sa_handler
-is set to
-.Dv SIG_IGN
-current and pending instances
-of the signal are ignored and discarded.
-.Pp
-Options may be specified by setting
-.Va sa_flags .
-The meaning of the various bits is as follows:
-.Bl -tag -offset indent -width SA_RESETHANDXX
-.It Dv SA_NOCLDSTOP
-If this bit is set when installing a catching function
-for the
-.Dv SIGCHLD
-signal,
-the
-.Dv SIGCHLD
-signal will be generated only when a child process exits,
-not when a child process stops.
-.It Dv SA_NOCLDWAIT
-If this bit is set when calling
-.Fn sigaction
-for the
-.Dv SIGCHLD
-signal, the system will not create zombie processes when children of
-the calling process exit.
-If the calling process subsequently issues a
-.Xr wait 2
-(or equivalent), it blocks until all of the calling process's child
-processes terminate, and then returns a value of \-1 with
-.Va errno
-set to
-.Er ECHILD .
-The same effect of avoiding zombie creation can also be achieved by setting
-.Va sa_handler
-for
-.Dv SIGCHLD
-to
-.Dv SIG_IGN .
-.It Dv SA_ONSTACK
-If this bit is set, the system will deliver the signal to the process
-on a
-.Em "signal stack" ,
-specified by each thread with
-.Xr sigaltstack 2 .
-.It Dv SA_NODEFER
-If this bit is set, further occurrences of the delivered signal are
-not masked during the execution of the handler.
-.It Dv SA_RESETHAND
-If this bit is set, the handler is reset back to
-.Dv SIG_DFL
-at the moment the signal is delivered.
-.It Dv SA_RESTART
-See paragraph below.
-.It Dv SA_SIGINFO
-If this bit is set, the handler function is assumed to be pointed to by the
-.Va sa_sigaction
-member of
-.Vt "struct sigaction"
-and should match the prototype shown above or as below in
-.Sx EXAMPLES .
-This bit should not be set when assigning
-.Dv SIG_DFL
-or
-.Dv SIG_IGN .
-.El
-.Pp
-If a signal is caught during the system calls listed below,
-the call may be forced to terminate
-with the error
-.Er EINTR ,
-the call may return with a data transfer shorter than requested,
-or the call may be restarted.
-Restart of pending calls is requested
-by setting the
-.Dv SA_RESTART
-bit in
-.Va sa_flags .
-The affected system calls include
-.Xr open 2 ,
-.Xr read 2 ,
-.Xr write 2 ,
-.Xr sendto 2 ,
-.Xr recvfrom 2 ,
-.Xr sendmsg 2
-and
-.Xr recvmsg 2
-on a communications channel or a slow device (such as a terminal,
-but not a regular file)
-and during a
-.Xr wait 2
-or
-.Xr ioctl 2 .
-However, calls that have already committed are not restarted,
-but instead return a partial success (for example, a short read count).
-.Pp
-After a
-.Xr pthread_create 3
-the signal mask is inherited by the new thread and
-the set of pending signals and the signal stack for the new thread are empty.
-.Pp
-After a
-.Xr fork 2
-or
-.Xr vfork 2
-all signals, the signal mask, the signal stack,
-and the restart/interrupt flags are inherited by the child.
-.Pp
-The
-.Xr execve 2
-system call reinstates the default
-action for all signals which were caught and
-resets all signals to be caught on the user stack.
-Ignored signals remain ignored;
-the signal mask remains the same;
-signals that restart pending system calls continue to do so.
-.Pp
-The following is a list of all signals
-with names as in the include file
-.In signal.h :
-.Bl -column SIGVTALARMXX "create core imagexxx"
-.It Sy NAME Ta Sy Default Action Ta Sy Description
-.It Dv SIGHUP Ta terminate process Ta terminal line hangup
-.It Dv SIGINT Ta terminate process Ta interrupt program
-.It Dv SIGQUIT Ta create core image Ta quit program
-.It Dv SIGILL Ta create core image Ta illegal instruction
-.It Dv SIGTRAP Ta create core image Ta trace trap
-.It Dv SIGABRT Ta create core image Ta Xr abort 3 call (formerly Dv SIGIOT )
-.It Dv SIGEMT Ta create core image Ta emulate instruction executed
-.It Dv SIGFPE Ta create core image Ta floating-point exception
-.It Dv SIGKILL Ta terminate process Ta kill program
-.It Dv SIGBUS Ta create core image Ta bus error
-.It Dv SIGSEGV Ta create core image Ta segmentation violation
-.It Dv SIGSYS Ta create core image Ta non-existent system call invoked
-.It Dv SIGPIPE Ta terminate process Ta write on a pipe with no reader
-.It Dv SIGALRM Ta terminate process Ta real-time timer expired
-.It Dv SIGTERM Ta terminate process Ta software termination signal
-.It Dv SIGURG Ta discard signal Ta urgent condition present on socket
-.It Dv SIGSTOP Ta stop process Ta stop (cannot be caught or ignored)
-.It Dv SIGTSTP Ta stop process Ta stop signal generated from keyboard
-.It Dv SIGCONT Ta discard signal Ta continue after stop
-.It Dv SIGCHLD Ta discard signal Ta child status has changed
-.It Dv SIGTTIN Ta stop process Ta background read attempted from control terminal
-.It Dv SIGTTOU Ta stop process Ta background write attempted to control terminal
-.It Dv SIGIO Ta discard signal Ta I/O is possible on a descriptor (see Xr fcntl 2 )
-.It Dv SIGXCPU Ta terminate process Ta cpu time limit exceeded (see Xr setrlimit 2 )
-.It Dv SIGXFSZ Ta terminate process Ta file size limit exceeded (see Xr setrlimit 2 )
-.It Dv SIGVTALRM Ta terminate process Ta virtual time alarm (see Xr setitimer 2 )
-.It Dv SIGPROF Ta terminate process Ta profiling timer alarm (see Xr setitimer 2 )
-.It Dv SIGWINCH Ta discard signal Ta window size change
-.It Dv SIGINFO Ta discard signal Ta status request from keyboard
-.It Dv SIGUSR1 Ta terminate process Ta user defined signal 1
-.It Dv SIGUSR2 Ta terminate process Ta user defined signal 2
-.El
-.Sh NOTE
-The
-.Va sa_mask
-field specified in
-.Fa act
-is not allowed to block
-.Dv SIGKILL
-or
-.Dv SIGSTOP .
-Any attempt to do so will be silently ignored.
-.Pp
-The following functions are either reentrant or not interruptible
-by signals and are async-signal safe.
-Therefore applications may
-invoke them, without restriction, from signal-catching functions
-or from a child process after calling
-.Xr fork 2
-in a multi-threaded process:
-.Pp
-Base Interfaces:
-.Pp
-.Fn _Exit ,
-.Fn _exit ,
-.Fn accept ,
-.Fn access ,
-.Fn alarm ,
-.Fn bind ,
-.Fn cfgetispeed ,
-.Fn cfgetospeed ,
-.Fn cfsetispeed ,
-.Fn cfsetospeed ,
-.Fn chdir ,
-.Fn chmod ,
-.Fn chown ,
-.Fn close ,
-.Fn connect ,
-.Fn creat ,
-.Fn dup ,
-.Fn dup2 ,
-.Fn execl ,
-.Fn execle ,
-.Fn execv ,
-.Fn execve ,
-.Fn faccessat ,
-.Fn fchdir ,
-.Fn fchmod ,
-.Fn fchmodat ,
-.Fn fchown ,
-.Fn fchownat ,
-.Fn fcntl ,
-.Fn fork ,
-.Fn fstat ,
-.Fn fstatat ,
-.Fn fsync ,
-.Fn ftruncate ,
-.Fn getegid ,
-.Fn geteuid ,
-.Fn getgid ,
-.Fn getgroups ,
-.Fn getpeername ,
-.Fn getpgrp ,
-.Fn getpid ,
-.Fn getppid ,
-.Fn getsockname ,
-.Fn getsockopt ,
-.Fn getuid ,
-.Fn kill ,
-.Fn link ,
-.Fn linkat ,
-.Fn listen ,
-.Fn lseek ,
-.Fn lstat ,
-.Fn mkdir ,
-.Fn mkdirat ,
-.Fn mkfifo ,
-.Fn mkfifoat ,
-.Fn mknod ,
-.Fn mknodat ,
-.Fn open ,
-.Fn openat ,
-.Fn pause ,
-.Fn pipe ,
-.Fn poll ,
-.Fn pselect ,
-.Fn pthread_sigmask ,
-.Fn raise ,
-.Fn read ,
-.Fn readlink ,
-.Fn readlinkat ,
-.Fn recv ,
-.Fn recvfrom ,
-.Fn recvmsg ,
-.Fn rename ,
-.Fn renameat ,
-.Fn rmdir ,
-.Fn select ,
-.Fn send ,
-.Fn sendmsg ,
-.Fn sendto ,
-.Fn setgid ,
-.Fn setpgid ,
-.Fn setsid ,
-.Fn setsockopt ,
-.Fn setuid ,
-.Fn shutdown ,
-.Fn sigaction ,
-.Fn sigaddset ,
-.Fn sigdelset ,
-.Fn sigemptyset ,
-.Fn sigfillset ,
-.Fn sigismember ,
-.Fn signal ,
-.Fn sigpending ,
-.Fn sigprocmask ,
-.Fn sigsuspend ,
-.Fn sleep ,
-.Fn sockatmark ,
-.Fn socket ,
-.Fn socketpair ,
-.Fn stat ,
-.Fn symlink ,
-.Fn symlinkat ,
-.Fn tcdrain ,
-.Fn tcflow ,
-.Fn tcflush ,
-.Fn tcgetattr ,
-.Fn tcgetpgrp ,
-.Fn tcsendbreak ,
-.Fn tcsetattr ,
-.Fn tcsetpgrp ,
-.Fn time ,
-.Fn times ,
-.Fn umask ,
-.Fn uname ,
-.Fn unlink ,
-.Fn unlinkat ,
-.Fn utime ,
-.Fn wait ,
-.Fn waitpid ,
-.Fn write .
-.Pp
-X/Open Systems Interfaces:
-.Pp
-.Fn sigpause ,
-.Fn sigset ,
-.Fn utimes .
-.Pp
-Realtime Interfaces:
-.Pp
-.Fn aio_error ,
-.Fn clock_gettime ,
-.Fn timer_getoverrun ,
-.Fn aio_return ,
-.Fn fdatasync ,
-.Fn sigqueue ,
-.Fn timer_gettime ,
-.Fn aio_suspend ,
-.Fn sem_post ,
-.Fn timer_settime .
-.Pp
-Base Interfaces not specified as async-signal safe by
-.Tn POSIX :
-.Pp
-.Fn fpathconf ,
-.Fn pathconf ,
-.Fn sysconf .
-.Pp
-Base Interfaces not specified as async-signal safe by
-.Tn POSIX ,
-but planned to be:
-.Pp
-.Fn ffs ,
-.Fn htonl ,
-.Fn htons ,
-.Fn memccpy ,
-.Fn memchr ,
-.Fn memcmp ,
-.Fn memcpy ,
-.Fn memmove ,
-.Fn memset ,
-.Fn ntohl ,
-.Fn ntohs ,
-.Fn stpcpy ,
-.Fn stpncpy ,
-.Fn strcat ,
-.Fn strchr ,
-.Fn strcmp ,
-.Fn strcpy ,
-.Fn strcspn ,
-.Fn strlen ,
-.Fn strncat ,
-.Fn strncmp ,
-.Fn strncpy ,
-.Fn strnlen ,
-.Fn strpbrk ,
-.Fn strrchr ,
-.Fn strspn ,
-.Fn strstr ,
-.Fn strtok_r ,
-.Fn wcpcpy ,
-.Fn wcpncpy ,
-.Fn wcscat ,
-.Fn wcschr ,
-.Fn wcscmp ,
-.Fn wcscpy ,
-.Fn wcscspn ,
-.Fn wcslen ,
-.Fn wcsncat ,
-.Fn wcsncmp ,
-.Fn wcsncpy ,
-.Fn wcsnlen ,
-.Fn wcspbrk ,
-.Fn wcsrchr ,
-.Fn wcsspn ,
-.Fn wcsstr ,
-.Fn wcstok ,
-.Fn wmemchr ,
-.Fn wmemcmp ,
-.Fn wmemcpy ,
-.Fn wmemmove ,
-.Fn wmemset .
-.Pp
-Extension Interfaces:
-.Pp
-.Fn accept4 ,
-.Fn bindat ,
-.Fn close_range ,
-.Fn closefrom ,
-.Fn connectat ,
-.Fn eaccess ,
-.Fn ffsl ,
-.Fn ffsll ,
-.Fn flock ,
-.Fn fls ,
-.Fn flsl ,
-.Fn flsll ,
-.Fn futimesat ,
-.Fn pipe2 ,
-.Fn strlcat .
-.Fn strlcpy ,
-.Fn strsep .
-.Pp
-In addition, reading or writing
-.Va errno
-is async-signal safe.
-.Pp
-All functions not in the above lists are considered to be unsafe
-with respect to signals.
-That is to say, the behaviour of such
-functions is undefined when they are called from a signal handler
-that interrupted an unsafe function.
-In general though, signal handlers should do little more than set a
-flag; most other actions are not safe.
-.Pp
-Also, it is good practice to make a copy of the global variable
-.Va errno
-and restore it before returning from the signal handler.
-This protects against the side effect of
-.Va errno
-being set by functions called from inside the signal handler.
-.Sh RETURN VALUES
-.Rv -std sigaction
-.Sh EXAMPLES
-There are three possible prototypes the handler may match:
-.Bl -tag -offset indent -width short
-.It Tn ANSI C :
-.Ft void
-.Fn handler int ;
-.It Traditional BSD style:
-.Ft void
-.Fn handler int "int code" "struct sigcontext *scp" ;
-.It Tn POSIX Dv SA_SIGINFO :
-.Ft void
-.Fn handler int "siginfo_t *info" "ucontext_t *uap" ;
-.El
-.Pp
-The handler function should match the
-.Dv SA_SIGINFO
-prototype if the
-.Dv SA_SIGINFO
-bit is set in
-.Va sa_flags .
-It then should be pointed to by the
-.Va sa_sigaction
-member of
-.Vt "struct sigaction" .
-Note that you should not assign
-.Dv SIG_DFL
-or
-.Dv SIG_IGN
-this way.
-.Pp
-If the
-.Dv SA_SIGINFO
-flag is not set, the handler function should match
-either the
-.Tn ANSI C
-or traditional
-.Bx
-prototype and be pointed to by
-the
-.Va sa_handler
-member of
-.Vt "struct sigaction" .
-In practice,
-.Fx
-always sends the three arguments of the latter and since the
-.Tn ANSI C
-prototype is a subset, both will work.
-The
-.Va sa_handler
-member declaration in
-.Fx
-include files is that of
-.Tn ANSI C
-(as required by
-.Tn POSIX ) ,
-so a function pointer of a
-.Bx Ns -style
-function needs to be casted to
-compile without warning.
-The traditional
-.Bx
-style is not portable and since its capabilities
-are a full subset of a
-.Dv SA_SIGINFO
-handler,
-its use is deprecated.
-.Pp
-The
-.Fa sig
-argument is the signal number, one of the
-.Dv SIG...
-values from
-.In signal.h .
-.Pp
-The
-.Fa code
-argument of the
-.Bx Ns -style
-handler and the
-.Va si_code
-member of the
-.Fa info
-argument to a
-.Dv SA_SIGINFO
-handler contain a numeric code explaining the
-cause of the signal, usually one of the
-.Dv SI_...
-values from
-.In sys/signal.h
-or codes specific to a signal, i.e., one of the
-.Dv FPE_...
-values for
-.Dv SIGFPE .
-.Pp
-The
-.Fa scp
-argument to a
-.Bx Ns -style
-handler points to an instance of
-.Vt "struct sigcontext" .
-.Pp
-The
-.Fa uap
-argument to a
-.Tn POSIX
-.Dv SA_SIGINFO
-handler points to an instance of
-ucontext_t.
-.Sh ERRORS
-The
-.Fn sigaction
-system call
-will fail and no new signal handler will be installed if one
-of the following occurs:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa sig
-argument
-is not a valid signal number.
-.It Bq Er EINVAL
-An attempt is made to ignore or supply a handler for
-.Dv SIGKILL
-or
-.Dv SIGSTOP .
-.El
-.Sh SEE ALSO
-.Xr kill 1 ,
-.Xr kill 2 ,
-.Xr ptrace 2 ,
-.Xr setitimer 2 ,
-.Xr setrlimit 2 ,
-.Xr sigaltstack 2 ,
-.Xr sigpending 2 ,
-.Xr sigprocmask 2 ,
-.Xr sigsuspend 2 ,
-.Xr wait 2 ,
-.Xr fpsetmask 3 ,
-.Xr setjmp 3 ,
-.Xr siginfo 3 ,
-.Xr siginterrupt 3 ,
-.Xr sigsetops 3 ,
-.Xr ucontext 3 ,
-.Xr tty 4
-.Sh STANDARDS
-The
-.Fn sigaction
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Dv SA_ONSTACK
-and
-.Dv SA_RESTART
-flags are Berkeley extensions,
-as are the signals,
-.Dv SIGTRAP ,
-.Dv SIGEMT ,
-.Dv SIGBUS ,
-.Dv SIGSYS ,
-.Dv SIGURG ,
-.Dv SIGIO ,
-.Dv SIGXCPU ,
-.Dv SIGXFSZ ,
-.Dv SIGVTALRM ,
-.Dv SIGPROF ,
-.Dv SIGWINCH ,
-and
-.Dv SIGINFO .
-Those signals are available on most
-.Bx Ns \-derived
-systems.
-The
-.Dv SA_NODEFER
-and
-.Dv SA_RESETHAND
-flags are intended for backwards compatibility with other operating
-systems.
-The
-.Dv SA_NOCLDSTOP ,
-and
-.Dv SA_NOCLDWAIT
-.\" and
-.\" SA_SIGINFO
-flags are featuring options commonly found in other operating systems.
-The flags are approved by
-.St -susv2 ,
-along with the option to avoid zombie creation by ignoring
-.Dv SIGCHLD .
diff --git a/lib/libc/sys/sigaction.c b/lib/libc/sys/sigaction.c
index 7352f0a84989..809881ca4d3f 100644
--- a/lib/libc/sys/sigaction.c
+++ b/lib/libc/sys/sigaction.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include "libc_private.h"
@@ -41,7 +40,5 @@ __weak_reference(sigaction, __libc_sigaction);
int
sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
-
- return (((int (*)(int, const struct sigaction *, struct sigaction *))
- __libc_interposing[INTERPOS_sigaction])(sig, act, oact));
+ return (INTERPOS_SYS(sigaction, sig, act, oact));
}
diff --git a/lib/libc/sys/sigaltstack.2 b/lib/libc/sys/sigaltstack.2
deleted file mode 100644
index eb29d2e588a6..000000000000
--- a/lib/libc/sys/sigaltstack.2
+++ /dev/null
@@ -1,161 +0,0 @@
-.\" Copyright (c) 1983, 1991, 1992, 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.
-.\"
-.\" @(#)sigaltstack.2 8.2 (Berkeley) 5/1/95
-.\"
-.Dd May 6, 2010
-.Dt SIGALTSTACK 2
-.Os
-.Sh NAME
-.Nm sigaltstack
-.Nd set and/or get signal stack context
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Bd -literal
-typedef struct {
- char *ss_sp;
- size_t ss_size;
- int ss_flags;
-} stack_t;
-.Ed
-.Ft int
-.Fn sigaltstack "const stack_t * restrict ss" "stack_t * restrict oss"
-.Sh DESCRIPTION
-The
-.Fn sigaltstack
-system call
-allows defining an alternate stack on which signals
-are to be processed for the current thread.
-If
-.Fa ss
-is non-zero,
-it specifies a pointer to and the size of a
-.Em "signal stack"
-on which to deliver signals.
-When a signal's action indicates its handler
-should execute on the signal stack (specified with a
-.Xr sigaction 2
-system call), the system checks to see
-if the thread is currently executing on that stack.
-If the thread is not currently executing on the signal stack,
-the system arranges a switch to the signal stack for the
-duration of the signal handler's execution.
-.Pp
-An active stack cannot be modified.
-.Pp
-If
-.Dv SS_DISABLE
-is set in
-.Fa ss_flags ,
-.Fa ss_sp
-and
-.Fa ss_size
-are ignored and the signal stack will be disabled.
-A disabled stack will cause all signals to be
-taken on the regular user stack.
-If the stack is later re-enabled then all signals that were specified
-to be processed on an alternate stack will resume doing so.
-.Pp
-If
-.Fa oss
-is non-zero, the current signal stack state is returned.
-The
-.Fa ss_flags
-field will contain the value
-.Dv SS_ONSTACK
-if the thread is currently on a signal stack and
-.Dv SS_DISABLE
-if the signal stack is currently disabled.
-.Sh NOTES
-The value
-.Dv SIGSTKSZ
-is defined to be the number of bytes/chars that would be used to cover
-the usual case when allocating an alternate stack area.
-The following code fragment is typically used to allocate an alternate stack.
-.Bd -literal -offset indent
-if ((sigstk.ss_sp = malloc(SIGSTKSZ)) == NULL)
- /* error return */
-sigstk.ss_size = SIGSTKSZ;
-sigstk.ss_flags = 0;
-if (sigaltstack(&sigstk, NULL) < 0)
- perror("sigaltstack");
-.Ed
-An alternative approach is provided for programs with signal handlers
-that require a specific amount of stack space other than the default size.
-The value
-.Dv MINSIGSTKSZ
-is defined to be the number of bytes/chars that is required by
-the operating system to implement the alternate stack feature.
-In computing an alternate stack size,
-programs should add
-.Dv MINSIGSTKSZ
-to their stack requirements to allow for the operating system overhead.
-.Pp
-Signal stacks are automatically adjusted for the direction of stack
-growth and alignment requirements.
-Signal stacks may or may not be protected by the hardware and
-are not ``grown'' automatically as is done for the normal stack.
-If the stack overflows and this space is not protected
-unpredictable results may occur.
-.Sh RETURN VALUES
-.Rv -std sigaltstack
-.Sh ERRORS
-The
-.Fn sigaltstack
-system call
-will fail and the signal stack context will remain unchanged
-if one of the following occurs.
-.Bl -tag -width Er
-.It Bq Er EFAULT
-Either
-.Fa ss
-or
-.Fa oss
-points to memory that is not a valid part of the process
-address space.
-.It Bq Er EPERM
-An attempt was made to modify an active stack.
-.It Bq Er EINVAL
-The
-.Fa ss_flags
-field was invalid.
-.It Bq Er ENOMEM
-Size of alternate stack area is less than or equal to
-.Dv MINSIGSTKSZ .
-.El
-.Sh SEE ALSO
-.Xr sigaction 2 ,
-.Xr setjmp 3
-.Sh HISTORY
-The predecessor to
-.Fn sigaltstack ,
-the
-.Fn sigstack
-system call, appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/sigfastblock.2 b/lib/libc/sys/sigfastblock.2
deleted file mode 100644
index 84ce6cd15090..000000000000
--- a/lib/libc/sys/sigfastblock.2
+++ /dev/null
@@ -1,164 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd December 13, 2019
-.Dt SIGFASTBLOCK 2
-.Os
-.Sh NAME
-.Nm sigfastblock
-.Nd controls signals blocking with a simple memory write
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/signalvar.h
-.Ft int
-.Fn sigfastblock "int cmd" "void *ptr"
-.Sh DESCRIPTION
-.Bf -symbolic
-This function is not intended for a direct usage by applications.
-The functionality is provided for implementing some optimizations in
-.Xr ld-elf.so.1 8
-and
-.Lb libthr .
-.Ef
-.Pp
-The function configures the kernel facility that allows a thread to
-block asynchronous signals delivery with a single write to userspace
-memory, avoiding overhead of system calls like
-.Xr sigprocmask 2
-for establishing critical sections.
-The C runtime uses it to optimize implementation of async-signal-safe
-functionality.
-.Pp
-A thread might register a
-.Dv sigblock
-variable of type
-.Vt int
-as a location which is consulted by kernel when calculating the
-blocked signal mask for delivery of asynchronous signals.
-If the variable indicates that blocking is requested, then the kernel
-effectively operates as if the mask containing all blockable signals was
-supplied to
-.Xr sigprocmask 2 .
-.Pp
-The variable is supposed to be modified only from the owning thread,
-there is no way to guarantee visibility of update from other thread
-to kernel when signals are delivered.
-.Pp
-Lower bits of the sigblock variable are reserved as flags,
-which might be set or cleared by kernel at arbitrary moments.
-Userspace code should use
-.Xr atomic 9
-operations of incrementing and decrementing by
-.Dv SIGFASTBLOCK_INC
-quantity to recursively block or unblock signals delivery.
-.Pp
-If a signal would be delivered when unmasked, kernel might set the
-.Dv SIGFASTBLOCK_PEND
-.Dq pending signal
-flag in the sigblock variable.
-Userspace should perform
-.Dv SIGFASTBLOCK_UNBLOCK
-operation when clearing the variable if it notes the pending signal
-bit is set, which would deliver the pending signals immediately.
-Otherwise, signals delivery might be postponed.
-.Pp
-The
-.Fa cmd
-argument specifies one of the following operations:
-.Bl -tag -width SIGFASTBLOCK_UNSETPTR
-.It Dv SIGFASTBLOCK_SETPTR
-Register the variable of type
-.Vt int
-at location pointed to by the
-.Fa ptr
-argument as sigblock variable for the calling thread.
-.It Dv SIGFASTBLOCK_UNSETPTR
-Unregister the currently registered sigblock location.
-Kernel stops inferring the blocked mask from non-zero value of its
-blocked count.
-New location can be registered after previous one is deregistered.
-.It Dv SIGFASTBLOCK_UNBLOCK
-If there are pending signals which should be delivered to the calling
-thread, they are delivered before returning from the call.
-The sigblock variable should have zero blocking count, and indicate
-that the pending signal exists.
-Effectively this means that the variable should have the value
-.Dv SIGFASTBLOCK_PEND .
-.El
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The operation may fail with the following errors:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The
-.Dv SIGFASTBLOCK_SETPTR
-attempted while the sigblock address was already registered.
-The
-.Dv SIGFASTBLOCK_UNBLOCK
-was called while sigblock variable value is not equal to
-.Dv SIGFASTBLOCK_PEND .
-.It Bq Er EINVAL
-The variable address passed to
-.Dv SIGFASTBLOCK_SETPTR
-is not aligned naturally.
-The
-.Dv SIGFASTBLOCK_UNSETPTR
-operation was attempted without prior successfull call to
-.Dv SIGFASTBLOCK_SETPTR .
-.It Bq Er EFAULT
-Attempt to read or write to the sigblock variable failed.
-Note that kernel generates the
-.Dv SIGSEGV
-signal if an attempt to read from the sigblock variable faulted
-during implicit accesses from syscall entry.
-.El
-.Sh SEE ALSO
-.Xr kill 2 ,
-.Xr signal 2 ,
-.Xr sigprocmask 2 ,
-.Xr libthr 3 ,
-.Xr ld-elf.so.1 8
-.Sh STANDARDS
-The
-.Nm
-function is non-standard, although a similar functionality is a common
-optimization provided by several other systems.
-.Sh HISTORY
-The
-.Nm
-function was introduced in
-.Fx 13.0 .
-.Sh BUGS
-The
-.Nm
-symbol is currently not exported by libc, on purpose.
-Consumers should either use the
-.Dv __sys_fast_sigblock
-symbol from the private libc namespace, or utilize
-.Xr syscall 2 .
diff --git a/lib/libc/sys/sigpending.2 b/lib/libc/sys/sigpending.2
deleted file mode 100644
index cf9748515469..000000000000
--- a/lib/libc/sys/sigpending.2
+++ /dev/null
@@ -1,76 +0,0 @@
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Berkeley Software Design, 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.
-.\"
-.\" @(#)sigpending.2 8.3 (Berkeley) 1/12/94
-.\"
-.Dd September 6, 2013
-.Dt SIGPENDING 2
-.Os
-.Sh NAME
-.Nm sigpending
-.Nd get pending signals
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Ft int
-.Fn sigpending "sigset_t *set"
-.Sh DESCRIPTION
-The
-.Fn sigpending
-system call returns a mask of the signals pending for delivery
-to the calling thread or the calling process in the location indicated by
-.Fa set .
-Signals may be pending because they are currently masked,
-or transiently before delivery (although the latter case is not
-normally detectable).
-.Sh RETURN VALUES
-.Rv -std sigpending
-.Sh ERRORS
-The
-.Fn sigpending
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa set
-argument specified an invalid address.
-.El
-.Sh SEE ALSO
-.Xr sigaction 2 ,
-.Xr sigprocmask 2 ,
-.Xr sigsuspend 2 ,
-.Xr sigsetops 3
-.Sh STANDARDS
-The
-.Fn sigpending
-system call is expected to conform to
-.St -p1003.1-90 .
diff --git a/lib/libc/sys/sigprocmask.2 b/lib/libc/sys/sigprocmask.2
deleted file mode 100644
index b3c9064106fa..000000000000
--- a/lib/libc/sys/sigprocmask.2
+++ /dev/null
@@ -1,130 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)sigprocmask.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd May 7, 2010
-.Dt SIGPROCMASK 2
-.Os
-.Sh NAME
-.Nm sigprocmask
-.Nd manipulate current signal mask
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Ft int
-.Fo sigprocmask
-.Fa "int how"
-.Fa "const sigset_t * restrict set"
-.Fa "sigset_t * restrict oset"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn sigprocmask
-system call examines and/or changes the current signal mask (those signals
-that are blocked from delivery).
-Signals are blocked if they are members of the current signal mask set.
-.Pp
-If
-.Fa set
-is not null, the action of
-.Fn sigprocmask
-depends on the value of the
-.Fa how
-argument.
-The signal mask is changed as a function of the specified
-.Fa set
-and the current mask.
-The function is specified by
-.Fa how
-using one of the following values from
-.In signal.h :
-.Bl -tag -width SIG_UNBLOCK
-.It Dv SIG_BLOCK
-The new mask is the union of the current mask and the specified
-.Fa set .
-.It Dv SIG_UNBLOCK
-The new mask is the intersection of the current mask
-and the complement of the specified
-.Fa set .
-.It Dv SIG_SETMASK
-The current mask is replaced by the specified
-.Fa set .
-.El
-.Pp
-If
-.Fa oset
-is not null, it is set to
-the previous value of the signal mask.
-When
-.Fa set
-is null,
-the value of
-.Fa how
-is insignificant and the mask remains unset
-providing a way to examine the signal mask without modification.
-.Pp
-The system
-quietly disallows
-.Dv SIGKILL
-or
-.Dv SIGSTOP
-to be blocked.
-.Pp
-In threaded applications,
-.Xr pthread_sigmask 3
-must be used instead of
-.Fn sigprocmask .
-.Sh RETURN VALUES
-.Rv -std sigprocmask
-.Sh ERRORS
-The
-.Fn sigprocmask
-system call will fail and the signal mask will be unchanged if one
-of the following occurs:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa how
-argument
-has a value other than those listed here.
-.El
-.Sh SEE ALSO
-.Xr kill 2 ,
-.Xr sigaction 2 ,
-.Xr sigpending 2 ,
-.Xr sigsuspend 2 ,
-.Xr fpsetmask 3 ,
-.Xr pthread_sigmask 3 ,
-.Xr sigsetops 3
-.Sh STANDARDS
-The
-.Fn sigprocmask
-system call is expected to
-conform to
-.St -p1003.1-90 .
diff --git a/lib/libc/sys/sigprocmask.c b/lib/libc/sys/sigprocmask.c
index c807d42fb2de..96cb9586509b 100644
--- a/lib/libc/sys/sigprocmask.c
+++ b/lib/libc/sys/sigprocmask.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include "libc_private.h"
@@ -41,7 +40,5 @@ __weak_reference(sigprocmask, __libc_sigprocmask);
int
sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
-
- return (((int (*)(int, const sigset_t *, sigset_t *))
- __libc_interposing[INTERPOS_sigprocmask])(how, set, oset));
+ return (INTERPOS_SYS(sigprocmask, how, set, oset));
}
diff --git a/lib/libc/sys/sigqueue.2 b/lib/libc/sys/sigqueue.2
deleted file mode 100644
index 5b154efa20fd..000000000000
--- a/lib/libc/sys/sigqueue.2
+++ /dev/null
@@ -1,161 +0,0 @@
-.\" Copyright (c) 2005 David Xu <davidxu@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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.Dd May 5, 2017
-.Dt SIGQUEUE 2
-.Os
-.Sh NAME
-.Nm sigqueue
-.Nd "queue a signal to a process (REALTIME)"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Ft int
-.Fn sigqueue "pid_t pid" "int signo" "const union sigval value"
-.Sh DESCRIPTION
-The
-.Fn sigqueue
-system call causes the signal specified by
-.Fa signo
-to be sent with the value specified by
-.Fa value
-to the process specified by
-.Fa pid .
-If
-.Fa signo
-is zero (the null signal), error checking is performed but
-no signal is actually sent.
-The null signal can be used to check the
-validity of PID.
-.Pp
-The conditions required for a process to have permission to queue a
-signal to another process are the same as for the
-.Xr kill 2
-system call.
-The
-.Fn sigqueue
-system call queues a signal to a single process specified by the
-.Fa pid
-argument.
-.Pp
-The
-.Fn sigqueue
-system call returns immediately.
-If the resources were
-available to queue the signal, the signal will be queued and sent to
-the receiving process.
-.Pp
-If the value of
-.Fa pid
-causes
-.Fa signo
-to be generated for the sending process, and if
-.Fa signo
-is not blocked for the calling thread and if no other thread has
-.Fa signo
-unblocked or is waiting in a
-.Fn sigwait
-system call for
-.Fa signo ,
-either
-.Fa signo
-or at least the pending, unblocked signal will be delivered to the
-calling thread before
-.Fn sigqueue
-returns.
-Should any multiple pending signals in the range
-.Dv SIGRTMIN
-to
-.Dv SIGRTMAX
-be selected for delivery, it is the lowest numbered
-one.
-The selection order between realtime and non-realtime signals, or
-between multiple pending non-realtime signals, is unspecified.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn sigqueue
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-No resources are available to queue the signal.
-The process has already
-queued
-.Brq Dv SIGQUEUE_MAX
-signals that are still pending at the receiver(s),
-or a system-wide resource limit has been exceeded.
-.It Bq Er EINVAL
-The value of the
-.Fa signo
-argument is an invalid or unsupported signal number.
-.It Bq Er EPERM
-The process does not have the appropriate privilege to send the signal
-to the receiving process.
-.It Bq Er ESRCH
-The process
-.Fa pid
-does not exist.
-.El
-.Sh SEE ALSO
-.Xr kill 2 ,
-.Xr sigaction 2 ,
-.Xr sigpending 2 ,
-.Xr sigsuspend 2 ,
-.Xr sigtimedwait 2 ,
-.Xr sigwait 2 ,
-.Xr sigwaitinfo 2 ,
-.Xr pause 3 ,
-.Xr pthread_sigmask 3 ,
-.Xr siginfo 3
-.Sh STANDARDS
-The
-.Fn sigqueue
-system call conforms to
-.St -p1003.1-2004 .
-.Sh HISTORY
-Support for
-.Tn POSIX
-realtime signal queue first appeared in
-.Fx 7.0 .
-.Sh CAVEATS
-When using
-.Nm
-to send signals to a process which might have a different ABI
-(for instance, one is 32-bit and the other 64-bit),
-the
-.Va sival_int
-member of
-.Fa value
-can be delivered reliably, but the
-.Va sival_ptr
-may be truncated in endian dependent ways and must not be relied on.
-Further, many pointer integrity schemes disallow sending pointers to other
-processes, and this technique should not be used in programs intended to
-be portable.
diff --git a/lib/libc/sys/sigreturn.2 b/lib/libc/sys/sigreturn.2
deleted file mode 100644
index 52baa7fe5ca6..000000000000
--- a/lib/libc/sys/sigreturn.2
+++ /dev/null
@@ -1,88 +0,0 @@
-.\" Copyright (c) 1985, 1991, 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.
-.\"
-.\" @(#)sigreturn.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd September 6, 2013
-.Dt SIGRETURN 2
-.Os
-.Sh NAME
-.Nm sigreturn
-.Nd return from signal
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Ft int
-.Fn sigreturn "const ucontext_t *scp"
-.Sh DESCRIPTION
-The
-.Fn sigreturn
-system call
-allows users to atomically unmask, switch stacks,
-and return from a signal context.
-The thread's signal mask and stack status are
-restored from the context structure pointed to by
-.Fa scp .
-The system call does not return;
-the users stack pointer, frame pointer, argument pointer,
-and processor status longword are restored from the context.
-Execution resumes at the specified pc.
-This system call is used by the trampoline code and
-.Xr longjmp 3
-when returning from a signal to the previously executing program.
-.Sh RETURN VALUES
-If successful, the system call does not return.
-Otherwise, a value of -1 is returned and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn sigreturn
-system call
-will fail and the thread context will remain unchanged
-if one of the following occurs.
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The
-.Fa scp
-argument
-points to memory that is not a valid part of the process
-address space.
-.It Bq Er EINVAL
-The process status longword is invalid or would improperly
-raise the privilege level of the process.
-.El
-.Sh SEE ALSO
-.Xr sigaction 2 ,
-.Xr setjmp 3 ,
-.Xr ucontext 3
-.Sh HISTORY
-The
-.Fn sigreturn
-system call appeared in
-.Bx 4.3 .
diff --git a/lib/libc/sys/sigstack.2 b/lib/libc/sys/sigstack.2
deleted file mode 100644
index 3d5efe0daa6c..000000000000
--- a/lib/libc/sys/sigstack.2
+++ /dev/null
@@ -1,49 +0,0 @@
-.\" Copyright (c) 1983, 1992, 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.
-.\"
-.\" @(#)sigstack.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt SIGSTACK 2
-.Os
-.Sh NAME
-.Nm sigstack
-.Nd set and/or get signal stack context
-.Sh LIBRARY
-.Lb libc
-.Sh DESCRIPTION
-The
-.Fn sigstack
-function has been deprecated in favor of the interface described in
-.Xr sigaltstack 2 .
-.Sh SEE ALSO
-.Xr sigaltstack 2
-.Sh HISTORY
-The
-.Fn sigstack
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/sigsuspend.2 b/lib/libc/sys/sigsuspend.2
deleted file mode 100644
index b0fe435c5fa5..000000000000
--- a/lib/libc/sys/sigsuspend.2
+++ /dev/null
@@ -1,84 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)sigsuspend.2 8.2 (Berkeley) 5/16/95
-.\"
-.Dd August 16, 2013
-.Dt SIGSUSPEND 2
-.Os
-.Sh NAME
-.Nm sigsuspend
-.Nd atomically release blocked signals and wait for interrupt
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In signal.h
-.Ft int
-.Fn sigsuspend "const sigset_t *sigmask"
-.Sh DESCRIPTION
-The
-.Fn sigsuspend
-system call
-temporarily changes the blocked signal mask to the set to which
-.Fa sigmask
-points,
-and then waits for a signal to arrive;
-on return the previous set of masked signals is restored.
-The signal mask set
-is usually empty to indicate that all
-signals are to be unblocked for the duration of the call.
-.Pp
-In normal usage, a signal is blocked using
-.Xr sigprocmask 2
-to begin a critical section, variables modified on the occurrence
-of the signal are examined to determine that there is no work
-to be done, and the process pauses awaiting work by using
-.Fn sigsuspend
-with the previous mask returned by
-.Xr sigprocmask 2 .
-.Sh RETURN VALUES
-The
-.Fn sigsuspend
-system call
-always terminates by being interrupted, returning -1 with
-.Va errno
-set to
-.Er EINTR .
-.Sh SEE ALSO
-.Xr pselect 2 ,
-.Xr sigaction 2 ,
-.Xr sigpending 2 ,
-.Xr sigprocmask 2 ,
-.Xr sigtimedwait 2 ,
-.Xr sigwait 2 ,
-.Xr sigwaitinfo 2 ,
-.Xr sigsetops 3
-.Sh STANDARDS
-The
-.Fn sigsuspend
-system call is expected to conform to
-.St -p1003.1-90 .
diff --git a/lib/libc/sys/sigsuspend.c b/lib/libc/sys/sigsuspend.c
index 46d5dc0edf49..e5a9495f9f39 100644
--- a/lib/libc/sys/sigsuspend.c
+++ b/lib/libc/sys/sigsuspend.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include "libc_private.h"
@@ -41,7 +40,5 @@ __weak_reference(sigsuspend, __libc_sigsuspend);
int
sigsuspend(const sigset_t *set)
{
-
- return (((int (*)(const sigset_t *))
- __libc_interposing[INTERPOS_sigsuspend])(set));
+ return (INTERPOS_SYS(sigsuspend, set));
}
diff --git a/lib/libc/sys/sigtimedwait.c b/lib/libc/sys/sigtimedwait.c
index 898f723987e2..839e5fe4d992 100644
--- a/lib/libc/sys/sigtimedwait.c
+++ b/lib/libc/sys/sigtimedwait.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include "libc_private.h"
@@ -41,8 +40,5 @@ int
sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info,
const struct timespec * __restrict t)
{
-
- return (((int (*)(const sigset_t *, siginfo_t *,
- const struct timespec *))
- __libc_interposing[INTERPOS_sigtimedwait])(set, info, t));
+ return (INTERPOS_SYS(sigtimedwait, set, info, t));
}
diff --git a/lib/libc/sys/sigwait.c b/lib/libc/sys/sigwait.c
index 2e1551b972ca..5a7d71bf3ed9 100644
--- a/lib/libc/sys/sigwait.c
+++ b/lib/libc/sys/sigwait.c
@@ -25,30 +25,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#include <errno.h>
#include <signal.h>
#include "libc_private.h"
-__weak_reference(__libc_sigwait, __sigwait);
-
#pragma weak sigwait
int
sigwait(const sigset_t *set, int *sig)
{
-
- return (((int (*)(const sigset_t *, int *))
- __libc_interposing[INTERPOS_sigwait])(set, sig));
-}
-
-int
-__libc_sigwait(const sigset_t *set, int *sig)
-{
- int ret;
-
- /* POSIX does not allow EINTR to be returned */
- do {
- ret = __sys_sigwait(set, sig);
- } while (ret == EINTR);
- return (ret);
+ return (INTERPOS_SYS(sigwait, set, sig));
}
diff --git a/lib/libc/sys/sigwaitinfo.c b/lib/libc/sys/sigwaitinfo.c
index 4caa52f3398d..611d09c3c221 100644
--- a/lib/libc/sys/sigwaitinfo.c
+++ b/lib/libc/sys/sigwaitinfo.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include "libc_private.h"
@@ -40,7 +39,5 @@ __weak_reference(__sys_sigwaitinfo, __sigwaitinfo);
int
sigwaitinfo(const sigset_t * __restrict set, siginfo_t * __restrict info)
{
-
- return (((int (*)(const sigset_t *, siginfo_t *))
- __libc_interposing[INTERPOS_sigwaitinfo])(set, info));
+ return (INTERPOS_SYS(sigwaitinfo, set, info));
}
diff --git a/lib/libc/sys/socket.2 b/lib/libc/sys/socket.2
deleted file mode 100644
index 3e2206aefe72..000000000000
--- a/lib/libc/sys/socket.2
+++ /dev/null
@@ -1,351 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" From: @(#)socket.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd January 15, 2023
-.Dt SOCKET 2
-.Os
-.Sh NAME
-.Nm socket
-.Nd create an endpoint for communication
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/socket.h
-.Ft int
-.Fn socket "int domain" "int type" "int protocol"
-.Sh DESCRIPTION
-The
-.Fn socket
-system call
-creates an endpoint for communication and returns a descriptor.
-.Pp
-The
-.Fa domain
-argument specifies a communications domain within which
-communication will take place; this selects the protocol family
-which should be used.
-These families are defined in the include file
-.In sys/socket.h .
-The currently understood formats are:
-.Pp
-.Bd -literal -offset indent -compact
-PF_LOCAL Host-internal protocols (alias for PF_UNIX),
-PF_UNIX Host-internal protocols,
-PF_INET Internet version 4 protocols,
-PF_INET6 Internet version 6 protocols,
-PF_DIVERT Firewall packet diversion/re-injection,
-PF_ROUTE Internal routing protocol,
-PF_KEY Internal key-management function,
-PF_NETGRAPH Netgraph sockets,
-PF_NETLINK Netlink protocols,
-PF_BLUETOOTH Bluetooth protocols,
-PF_INET_SDP OFED socket direct protocol (IPv4),
-AF_HYPERV HyperV sockets
-.Ed
-.Pp
-Each protocol family is connected to an address family, which has the
-same name except that the prefix is
-.Dq Dv AF_
-in place of
-.Dq Dv PF_ .
-Other protocol families may be also defined, beginning with
-.Dq Dv PF_ ,
-with corresponding address families.
-.Pp
-The socket has the indicated
-.Fa type ,
-which specifies the semantics of communication.
-Currently
-defined types are:
-.Pp
-.Bd -literal -offset indent -compact
-SOCK_STREAM Stream socket,
-SOCK_DGRAM Datagram socket,
-SOCK_RAW Raw-protocol interface,
-SOCK_SEQPACKET Sequenced packet stream
-.Ed
-.Pp
-A
-.Dv SOCK_STREAM
-type provides sequenced, reliable,
-two-way connection based byte streams.
-An out-of-band data transmission mechanism may be supported.
-A
-.Dv SOCK_DGRAM
-socket supports
-datagrams (connectionless, unreliable messages of
-a fixed (typically small) maximum length).
-A
-.Dv SOCK_SEQPACKET
-socket may provide a sequenced, reliable,
-two-way connection-based data transmission path for datagrams
-of fixed maximum length; a consumer may be required to read
-an entire packet with each read system call.
-This facility may have protocol-specific properties.
-.Dv SOCK_RAW
-sockets provide access to internal network protocols and interfaces.
-The
-.Dv SOCK_RAW
-type is available only to the super-user and is described in
-.Xr ip 4
-and
-.Xr ip6 4 .
-.Pp
-Additionally, the following flags are allowed in the
-.Fa type
-argument:
-.Pp
-.Bd -literal -offset indent -compact
-SOCK_CLOEXEC Set close-on-exec on the new descriptor,
-SOCK_NONBLOCK Set non-blocking mode on the new socket
-.Ed
-.Pp
-The
-.Fa protocol
-argument
-specifies a particular protocol to be used with the socket.
-Normally only a single protocol exists to support a particular
-socket type within a given protocol family.
-However, it is possible
-that many protocols may exist, in which case a particular protocol
-must be specified in this manner.
-The protocol number to use is
-particular to the
-.Dq "communication domain"
-in which communication
-is to take place; see
-.Xr protocols 5 .
-.Pp
-The
-.Fa protocol
-argument may be set to zero (0) to request the default
-implementation of a socket type for the protocol, if any.
-.Pp
-Sockets of type
-.Dv SOCK_STREAM
-are full-duplex byte streams, similar
-to pipes.
-A stream socket must be in a
-.Em connected
-state before any data may be sent or received
-on it.
-A connection to another socket is created with a
-.Xr connect 2
-system call.
-Once connected, data may be transferred using
-.Xr read 2
-and
-.Xr write 2
-calls or some variant of the
-.Xr send 2
-and
-.Xr recv 2
-functions.
-(Some protocol families, such as the Internet family,
-support the notion of an
-.Dq implied connect ,
-which permits data to be sent piggybacked onto a connect operation by
-using the
-.Xr sendto 2
-system call.)
-When a session has been completed a
-.Xr close 2
-may be performed.
-Out-of-band data may also be transmitted as described in
-.Xr send 2
-and received as described in
-.Xr recv 2 .
-.Pp
-The communications protocols used to implement a
-.Dv SOCK_STREAM
-ensure that data
-is not lost or duplicated.
-If a piece of data for which the
-peer protocol has buffer space cannot be successfully transmitted
-within a reasonable length of time, then
-the connection is considered broken and calls
-will indicate an error with
--1 returns and with
-.Er ETIMEDOUT
-as the specific code
-in the global variable
-.Va errno .
-The protocols optionally keep sockets
-.Dq warm
-by forcing transmissions
-roughly every minute in the absence of other activity.
-An error is then indicated if no response can be
-elicited on an otherwise
-idle connection for an extended period (e.g.\& 5 minutes).
-By default, a
-.Dv SIGPIPE
-signal is raised if a process sends
-on a broken stream, but this behavior may be inhibited via
-.Xr setsockopt 2 .
-.Pp
-.Dv SOCK_SEQPACKET
-sockets employ the same system calls
-as
-.Dv SOCK_STREAM
-sockets.
-The only difference
-is that
-.Xr read 2
-calls will return only the amount of data requested,
-and any remaining in the arriving packet will be discarded.
-.Pp
-.Dv SOCK_DGRAM
-and
-.Dv SOCK_RAW
-sockets allow sending of datagrams to correspondents
-named in
-.Xr send 2
-calls.
-Datagrams are generally received with
-.Xr recvfrom 2 ,
-which returns the next datagram with its return address.
-.Pp
-An
-.Xr fcntl 2
-system call can be used to specify a process group to receive
-a
-.Dv SIGURG
-signal when the out-of-band data arrives.
-It may also enable non-blocking I/O
-and asynchronous notification of I/O events
-via
-.Dv SIGIO .
-.Pp
-The operation of sockets is controlled by socket level
-.Em options .
-These options are defined in the file
-.In sys/socket.h .
-The
-.Xr setsockopt 2
-and
-.Xr getsockopt 2
-system calls are used to set and get options, respectively.
-.Sh RETURN VALUES
-A -1 is returned if an error occurs, otherwise the return
-value is a descriptor referencing the socket.
-.Sh ERRORS
-The
-.Fn socket
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Permission to create a socket of the specified type and/or protocol
-is denied.
-.It Bq Er EAFNOSUPPORT
-The address family (domain) is not supported or the
-specified domain is not supported by this protocol family.
-.It Bq Er EMFILE
-The per-process descriptor table is full.
-.It Bq Er ENFILE
-The system file table is full.
-.It Bq Er ENOBUFS
-Insufficient buffer space is available.
-The socket cannot be created until sufficient resources are freed.
-.It Bq Er EPERM
-User has insufficient privileges to carry out the requested operation.
-.It Bq Er EPROTONOSUPPORT
-The protocol type or the specified protocol is not supported
-within this domain.
-.It Bq Er EPROTOTYPE
-The socket type is not supported by the protocol.
-.El
-.Sh SEE ALSO
-.Xr accept 2 ,
-.Xr bind 2 ,
-.Xr connect 2 ,
-.Xr divert 4 ,
-.Xr getpeername 2 ,
-.Xr getsockname 2 ,
-.Xr getsockopt 2 ,
-.Xr ioctl 2 ,
-.Xr ip 4 ,
-.Xr ip6 4 ,
-.Xr listen 2 ,
-.Xr read 2 ,
-.Xr recv 2 ,
-.Xr select 2 ,
-.Xr send 2 ,
-.Xr shutdown 2 ,
-.Xr socketpair 2 ,
-.Xr write 2 ,
-.Xr CMSG_DATA 3 ,
-.Xr getprotoent 3 ,
-.Xr netgraph 4 ,
-.Xr protocols 5
-.Rs
-.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
-.%B PS1
-.%N 7
-.Re
-.Rs
-.%T "BSD Interprocess Communication Tutorial"
-.%B PS1
-.%N 8
-.Re
-.Sh STANDARDS
-The
-.Fn socket
-function conforms to
-.St -p1003.1-2008 .
-The
-.Tn POSIX
-standard specifies only the
-.Dv AF_INET ,
-.Dv AF_INET6 ,
-and
-.Dv AF_UNIX
-constants for address families, and requires the use of
-.Dv AF_*
-constants for the
-.Fa domain
-argument of
-.Fn socket .
-The
-.Dv SOCK_CLOEXEC
-flag is expected to conform to the next revision of the
-.Tn POSIX
-standard.
-The
-.Dv SOCK_RDM
-.Fa type ,
-the
-.Dv PF_*
-constants, and other address families are
-.Fx
-extensions.
-.Sh HISTORY
-The
-.Fn socket
-system call appeared in
-.Bx 4.2 .
diff --git a/lib/libc/sys/socketpair.2 b/lib/libc/sys/socketpair.2
deleted file mode 100644
index 1821048c4dbf..000000000000
--- a/lib/libc/sys/socketpair.2
+++ /dev/null
@@ -1,106 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd February 10, 2018
-.Dt SOCKETPAIR 2
-.Os
-.Sh NAME
-.Nm socketpair
-.Nd create a pair of connected sockets
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/socket.h
-.Ft int
-.Fn socketpair "int domain" "int type" "int protocol" "int *sv"
-.Sh DESCRIPTION
-The
-.Fn socketpair
-system call creates an unnamed pair of connected sockets in
-the specified communications
-.Fa domain ,
-of the specified
-.Fa type ,
-and using the optionally specified
-.Fa protocol .
-The descriptors used in referencing the new sockets
-are returned in
-.Fa sv Ns [0]
-and
-.Fa sv Ns [1] .
-The two sockets are indistinguishable.
-.Pp
-The
-.Dv SOCK_CLOEXEC
-and
-.Dv SOCK_NONBLOCK
-flags in the
-.Fa type
-argument apply to both descriptors.
-.Sh RETURN VALUES
-.Rv -std socketpair
-.Sh ERRORS
-The call succeeds unless:
-.Bl -tag -width Er
-.It Bq Er EMFILE
-Too many descriptors are in use by this process.
-.It Bq Er EAFNOSUPPORT
-The specified address family is not supported on this machine.
-.It Bq Er EPROTONOSUPPORT
-The specified protocol is not supported on this machine.
-.It Bq Er EOPNOTSUPP
-The specified protocol does not support creation of socket pairs.
-.It Bq Er EFAULT
-The address
-.Fa sv
-does not specify a valid part of the
-process address space.
-.El
-.Sh SEE ALSO
-.Xr pipe 2 ,
-.Xr read 2 ,
-.Xr socket 2 ,
-.Xr write 2
-.Sh STANDARDS
-The
-.Fn socketpair
-system call conforms to
-.St -p1003.1-2001
-and
-.St -p1003.1-2008 .
-.Sh HISTORY
-The
-.Fn socketpair
-system call appeared in
-.Bx 4.2 .
-.Sh BUGS
-This call is currently implemented only for the
-.Ux
-domain.
diff --git a/lib/libc/sys/stat.2 b/lib/libc/sys/stat.2
deleted file mode 100644
index 6b2f2a7c7eab..000000000000
--- a/lib/libc/sys/stat.2
+++ /dev/null
@@ -1,491 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)stat.2 8.4 (Berkeley) 5/1/95
-.\"
-.Dd March 30, 2021
-.Dt STAT 2
-.Os
-.Sh NAME
-.Nm stat ,
-.Nm lstat ,
-.Nm fstat ,
-.Nm fstatat
-.Nd get file status
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.Ft int
-.Fn stat "const char * restrict path" "struct stat * restrict sb"
-.Ft int
-.Fn lstat "const char * restrict path" "struct stat * restrict sb"
-.Ft int
-.Fn fstat "int fd" "struct stat *sb"
-.Ft int
-.Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag"
-.Sh DESCRIPTION
-The
-.Fn stat
-system call obtains information about the file pointed to by
-.Fa path .
-Read, write or execute
-permission of the named file is not required, but all directories
-listed in the path name leading to the file must be searchable.
-.Pp
-The
-.Fn lstat
-system call is like
-.Fn stat
-except when the named file is a symbolic link,
-in which case
-.Fn lstat
-returns information about the link,
-while
-.Fn stat
-returns information about the file the link references.
-.Pp
-The
-.Fn fstat
-system call obtains the same information about an open file
-known by the file descriptor
-.Fa fd .
-.Pp
-The
-.Fn fstatat
-system call is equivalent to
-.Fn stat
-and
-.Fn lstat
-except when the
-.Fa path
-specifies a relative path.
-For
-.Fn fstatat
-and relative
-.Fa path ,
-the status is retrieved from a file relative to
-the directory associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-.Pp
-The values for the
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from this list,
-defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_NOFOLLOW
-If
-.Fa path
-names a symbolic link, the status of the symbolic link is returned.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the starting directory.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa path
-argument is an empty string, operate on the file or directory
-referenced by the descriptor
-.Fa fd .
-If
-.Fa fd
-is equal to
-.Dv AT_FDCWD ,
-operate on the current working directory.
-.El
-.Pp
-If
-.Fn fstatat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn stat
-or
-.Fn lstat
-respectively, depending on whether or not the
-.Dv AT_SYMLINK_NOFOLLOW
-bit is set in
-.Fa flag .
-.Pp
-When
-.Fn fstatat
-is called with an absolute
-.Fa path ,
-it ignores the
-.Fa fd
-argument.
-.Pp
-The
-.Fa sb
-argument is a pointer to a
-.Vt stat
-structure
-as defined by
-.In sys/stat.h
-and into which information is placed concerning the file.
-.Pp
-The fields of
-.Vt "struct stat"
-related to the file system are:
-.Bl -tag -width ".Va st_nlink"
-.It Va st_dev
-Numeric ID of the device containing the file.
-.It Va st_ino
-The file's inode number.
-.It Va st_nlink
-Number of hard links to the file.
-.It Va st_flags
-Flags enabled for the file.
-See
-.Xr chflags 2
-for the list of flags and their description.
-.El
-.Pp
-The
-.Va st_dev
-and
-.Va st_ino
-fields together identify the file uniquely within the system.
-.Pp
-The time-related fields of
-.Vt "struct stat"
-are:
-.Bl -tag -width ".Va st_birthtim"
-.It Va st_atim
-Time when file data was last accessed.
-Changed implicitly by syscalls such as
-.Xr read 2
-and
-.Xr readv 2 ,
-and explicitly by
-.Xr utimes 2 .
-.It Va st_mtim
-Time when file data was last modified.
-Changed implicitly by syscalls such as
-.Xr truncate 2 ,
-.Xr write 2 ,
-and
-.Xr writev 2 ,
-and explicitly by
-.Xr utimes 2 .
-Also, any syscall which modifies directory content changes the
-.Va st_mtim
-for the affected directory.
-For instance,
-.Xr creat 2 ,
-.Xr mkdir 2 ,
-.Xr rename 2 ,
-.Xr link 2 ,
-and
-.Xr unlink 2 .
-.It Va st_ctim
-Time when file status was last changed (inode data modification).
-Changed implicitly by any syscall that affects file metadata, including
-.Va st_mtim ,
-such as
-.Xr chflags 2 ,
-.Xr chmod 2 ,
-.Xr chown 2 ,
-.Xr truncate 2 ,
-.Xr utimes 2 ,
-and
-.Xr write 2 .
-Also, any syscall which modifies directory content changes the
-.Va st_ctim
-for the affected directory.
-For instance,
-.Xr creat 2 ,
-.Xr mkdir 2 ,
-.Xr rename 2 ,
-.Xr link 2 ,
-and
-.Xr unlink 2 .
-.It Va st_birthtim
-Time when the inode was created.
-.El
-.Pp
-These time-related macros are defined for compatibility:
-.Bd -literal
-#define st_atime st_atim.tv_sec
-#define st_mtime st_mtim.tv_sec
-#define st_ctime st_ctim.tv_sec
-#ifndef _POSIX_SOURCE
-#define st_birthtime st_birthtim.tv_sec
-#endif
-
-#ifndef _POSIX_SOURCE
-#define st_atimespec st_atim
-#define st_mtimespec st_mtim
-#define st_ctimespec st_ctim
-#define st_birthtimespec st_birthtim
-#endif
-.Ed
-.Pp
-Size-related fields of the
-.Vt "struct stat"
-are:
-.Bl -tag -width ".Va st_blksize"
-.It Va st_size
-File size in bytes.
-.It Va st_blksize
-Optimal I/O block size for the file.
-.It Va st_blocks
-Actual number of blocks allocated for the file in 512-byte units.
-As short symbolic links are stored in the inode, this number may
-be zero.
-.El
-.Pp
-The access-related fields of
-.Vt "struct stat"
-are:
-.Bl -tag -width ".Va st_mode"
-.It Va st_uid
-User ID of the file's owner.
-.It Va st_gid
-Group ID of the file.
-.It Va st_mode
-Status of the file (see below).
-.El
-.Pp
-The status information word
-.Fa st_mode
-has these bits:
-.Bd -literal
-#define S_IFMT 0170000 /* type of file mask */
-#define S_IFIFO 0010000 /* named pipe (fifo) */
-#define S_IFCHR 0020000 /* character special */
-#define S_IFDIR 0040000 /* directory */
-#define S_IFBLK 0060000 /* block special */
-#define S_IFREG 0100000 /* regular */
-#define S_IFLNK 0120000 /* symbolic link */
-#define S_IFSOCK 0140000 /* socket */
-#define S_IFWHT 0160000 /* whiteout */
-#define S_ISUID 0004000 /* set user id on execution */
-#define S_ISGID 0002000 /* set group id on execution */
-#define S_ISVTX 0001000 /* save swapped text even after use */
-#define S_IRWXU 0000700 /* RWX mask for owner */
-#define S_IRUSR 0000400 /* read permission, owner */
-#define S_IWUSR 0000200 /* write permission, owner */
-#define S_IXUSR 0000100 /* execute/search permission, owner */
-#define S_IRWXG 0000070 /* RWX mask for group */
-#define S_IRGRP 0000040 /* read permission, group */
-#define S_IWGRP 0000020 /* write permission, group */
-#define S_IXGRP 0000010 /* execute/search permission, group */
-#define S_IRWXO 0000007 /* RWX mask for other */
-#define S_IROTH 0000004 /* read permission, other */
-#define S_IWOTH 0000002 /* write permission, other */
-#define S_IXOTH 0000001 /* execute/search permission, other */
-.Ed
-.Pp
-For a list of access modes, see
-.In sys/stat.h ,
-.Xr access 2
-and
-.Xr chmod 2 .
-These macros are available to test whether a
-.Va st_mode
-value passed in the
-.Fa m
-argument corresponds to a file of the specified type:
-.Bl -tag -width ".Fn S_ISFIFO m"
-.It Fn S_ISBLK m
-Test for a block special file.
-.It Fn S_ISCHR m
-Test for a character special file.
-.It Fn S_ISDIR m
-Test for a directory.
-.It Fn S_ISFIFO m
-Test for a pipe or FIFO special file.
-.It Fn S_ISLNK m
-Test for a symbolic link.
-.It Fn S_ISREG m
-Test for a regular file.
-.It Fn S_ISSOCK m
-Test for a socket.
-.It Fn S_ISWHT m
-Test for a whiteout.
-.El
-.Pp
-The macros evaluate to a non-zero value if the test is true
-or to the value 0 if the test is false.
-.Sh RETURN VALUES
-.Rv -std
-.Sh COMPATIBILITY
-Previous versions of the system used different types for the
-.Va st_dev ,
-.Va st_uid ,
-.Va st_gid ,
-.Va st_rdev ,
-.Va st_size ,
-.Va st_blksize
-and
-.Va st_blocks
-fields.
-.Sh ERRORS
-The
-.Fn stat
-and
-.Fn lstat
-system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EFAULT
-The
-.Fa sb
-or
-.Fa path
-argument
-points to an invalid address.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er EOVERFLOW
-The file size in bytes cannot be
-represented correctly in the structure pointed to by
-.Fa sb .
-.El
-.Pp
-The
-.Fn fstat
-system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid open file descriptor.
-.It Bq Er EFAULT
-The
-.Fa sb
-argument
-points to an invalid address.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EOVERFLOW
-The file size in bytes cannot be
-represented correctly in the structure pointed to by
-.Fa sb .
-.El
-.Pp
-In addition to the errors returned by the
-.Fn lstat ,
-the
-.Fn fstatat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Sh SEE ALSO
-.Xr access 2 ,
-.Xr chmod 2 ,
-.Xr chown 2 ,
-.Xr fhstat 2 ,
-.Xr statfs 2 ,
-.Xr utimes 2 ,
-.Xr sticky 7 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Fn stat
-and
-.Fn fstat
-system calls are expected to conform to
-.St -p1003.1-90 .
-The
-.Fn fstatat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn stat
-and
-.Fn fstat
-system calls appeared in
-.At v1 .
-The
-.Fn lstat
-system call appeared in
-.Bx 4.2 .
-The
-.Fn fstatat
-system call appeared in
-.Fx 8.0 .
-.Sh BUGS
-Applying
-.Fn fstat
-to a socket
-returns a zeroed buffer,
-except for the blocksize field,
-and a unique device and inode number.
diff --git a/lib/libc/sys/stat.c b/lib/libc/sys/stat.c
index dc9ef16c79e7..262c265d09c9 100644
--- a/lib/libc/sys/stat.c
+++ b/lib/libc/sys/stat.c
@@ -24,25 +24,17 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
+#include <sys/fcntl.h>
#include <sys/syscall.h>
-#include "compat-ino64.h"
+#include <sys/stat.h>
#include <unistd.h>
-
#include "libc_private.h"
int
stat(const char *path, struct stat *sb)
{
- struct freebsd11_stat stat11;
- int rv;
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_fstatat(AT_FDCWD, path, sb, 0));
- rv = syscall(SYS_freebsd11_stat, path, &stat11);
- if (rv == 0)
- __stat11_to_stat(&stat11, sb);
- return (rv);
+ return (__sys_fstatat(AT_FDCWD, path, sb, 0));
}
diff --git a/lib/libc/sys/statfs.2 b/lib/libc/sys/statfs.2
deleted file mode 100644
index 6111b127b8e3..000000000000
--- a/lib/libc/sys/statfs.2
+++ /dev/null
@@ -1,255 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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.
-.\"
-.\" @(#)statfs.2 8.5 (Berkeley) 5/24/95
-.\"
-.Dd March 29, 2023
-.Dt STATFS 2
-.Os
-.Sh NAME
-.Nm statfs
-.Nd get file system statistics
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/param.h
-.In sys/mount.h
-.Ft int
-.Fn statfs "const char *path" "struct statfs *buf"
-.Ft int
-.Fn fstatfs "int fd" "struct statfs *buf"
-.Sh DESCRIPTION
-The
-.Fn statfs
-system call
-returns information about a mounted file system.
-The
-.Fa path
-argument
-is the path name of any file within the mounted file system.
-The
-.Fa buf
-argument
-is a pointer to a
-.Vt statfs
-structure defined as follows:
-.Bd -literal
-typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
-
-/*
- * filesystem statistics
- */
-
-#define MFSNAMELEN 16 /* length of type name including null */
-#define MNAMELEN 1024 /* size of on/from name bufs */
-#define STATFS_VERSION 0x20140518 /* current version number */
-
-struct statfs {
-uint32_t f_version; /* structure version number */
-uint32_t f_type; /* type of filesystem */
-uint64_t f_flags; /* copy of mount exported flags */
-uint64_t f_bsize; /* filesystem fragment size */
-uint64_t f_iosize; /* optimal transfer block size */
-uint64_t f_blocks; /* total data blocks in filesystem */
-uint64_t f_bfree; /* free blocks in filesystem */
-int64_t f_bavail; /* free blocks avail to non-superuser */
-uint64_t f_files; /* total file nodes in filesystem */
-int64_t f_ffree; /* free nodes avail to non-superuser */
-uint64_t f_syncwrites; /* count of sync writes since mount */
-uint64_t f_asyncwrites; /* count of async writes since mount */
-uint64_t f_syncreads; /* count of sync reads since mount */
-uint64_t f_asyncreads; /* count of async reads since mount */
-uint64_t f_spare[10]; /* unused spare */
-uint32_t f_namemax; /* maximum filename length */
-uid_t f_owner; /* user that mounted the filesystem */
-fsid_t f_fsid; /* filesystem id */
-char f_charspare[80]; /* spare string space */
-char f_fstypename[MFSNAMELEN]; /* filesystem type name */
-char f_mntfromname[MNAMELEN]; /* mounted filesystem */
-char f_mntonname[MNAMELEN]; /* directory on which mounted */
-};
-.Ed
-.Pp
-The flags that may be returned include:
-.Bl -tag -width MNT_SYNCHRONOUS
-.It Dv MNT_RDONLY
-The file system is mounted read-only;
-Even the super-user may not write on it.
-.It Dv MNT_NOEXEC
-Files may not be executed from the file system.
-.It Dv MNT_NOSUID
-Setuid and setgid bits on files are not honored when they are executed.
-.It Dv MNT_SYNCHRONOUS
-All I/O to the file system is done synchronously.
-.It Dv MNT_ASYNC
-No file system I/O is done synchronously.
-.It Dv MNT_SOFTDEP
-Soft updates being done (see
-.Xr ffs 7 ) .
-.It Dv MNT_GJOURNAL
-Journaling with gjournal is enabled (see
-.Xr gjournal 8 ) .
-.It Dv MNT_SUIDDIR
-Special handling of SUID bit on directories.
-.It Dv MNT_UNION
-Union with underlying file system.
-.It Dv MNT_NOSYMFOLLOW
-Symbolic links are not followed.
-.It Dv MNT_NOCLUSTERR
-Read clustering is disabled.
-.It Dv MNT_NOCLUSTERW
-Write clustering is disabled.
-.\".It Dv MNT_JAILDEVFS
-.\"XXX
-.It Dv MNT_MULTILABEL
-Mandatory Access Control (MAC) support for individual objects
-(see
-.Xr mac 4 ) .
-.It Dv MNT_ACLS
-Access Control List (ACL) support enabled.
-.It Dv MNT_LOCAL
-The file system resides locally.
-.It Dv MNT_QUOTA
-The file system has quotas enabled on it.
-.It Dv MNT_ROOTFS
-Identifies the root file system.
-.It Dv MNT_EXRDONLY
-The file system is exported read-only.
-.It Dv MNT_NOATIME
-Updating of file access times is disabled.
-.It Dv MNT_USER
-The file system has been mounted by a user.
-.\".It Dv MNT_IGNORE
-.\"XXX
-.It Dv MNT_EXPORTED
-The file system is exported for both reading and writing.
-.It Dv MNT_DEFEXPORTED
-The file system is exported for both reading and writing to any Internet host.
-.It Dv MNT_EXPORTANON
-The file system maps all remote accesses to the anonymous user.
-.It Dv MNT_EXKERB
-The file system is exported with Kerberos uid mapping.
-.It Dv MNT_EXPUBLIC
-The file system is exported publicly (WebNFS).
-.El
-.Pp
-Fields that are undefined for a particular file system are set to -1.
-The
-.Fn fstatfs
-system call
-returns the same information about an open file referenced by descriptor
-.Fa fd .
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-The
-.Fn statfs
-system call
-fails if one or more of the following are true:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix of
-.Fa path
-is not a directory.
-.It Bq Er ENAMETOOLONG
-The length of a component of
-.Fa path
-exceeds 255 characters,
-or the length of
-.Fa path
-exceeds 1023 characters.
-.It Bq Er ENOENT
-The file referred to by
-.Fa path
-does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix of
-.Fa path .
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating
-.Fa path .
-.It Bq Er EFAULT
-The
-.Fa buf
-or
-.Fa path
-argument
-points to an invalid address.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Pp
-The
-.Fn fstatfs
-system call
-fails if one or more of the following are true:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid open file descriptor.
-.It Bq Er EFAULT
-The
-.Fa buf
-argument
-points to an invalid address.
-.It Bq Er EIO
-An
-.Tn I/O
-error occurred while reading from or writing to the file system.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.El
-.Sh NOTES
-The fields in the
-.Vt statfs
-structure have been defined to provide the parameters relevant for
-traditional
-.Tm UNIX
-file systems.
-For some other file systems, values that have similar, but not
-identical, semantics to those described above may be returned.
-An example is msdosfs, which in case of FAT12 or FAT16 file systems
-reports the number of available and of free root directory entries
-instead of inodes
-.Po
-where 1 to 21 such directory entries are required to store
-each file or directory name or disk label
-.Pc .
-.Sh SEE ALSO
-.Xr fhstatfs 2 ,
-.Xr getfsstat 2
-.Sh HISTORY
-The
-.Fn statfs
-system call first appeared in
-.Bx 4.4 .
diff --git a/lib/libc/sys/statfs.c b/lib/libc/sys/statfs.c
deleted file mode 100644
index b8ac38b131ca..000000000000
--- a/lib/libc/sys/statfs.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 2017 M. Warner Losh <imp@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include "namespace.h"
-#include <sys/param.h>
-#include <sys/syscall.h>
-#include "compat-ino64.h"
-#include <unistd.h>
-
-#include "libc_private.h"
-
-int
-statfs(const char *path, struct statfs *buf)
-{
- struct freebsd11_statfs statfs11;
- int rv;
-
- if (__getosreldate() >= INO64_FIRST)
- return (__sys_statfs(path, buf));
- rv = syscall(SYS_freebsd11_statfs, path, &statfs11);
- if (rv == 0)
- __statfs11_to_statfs(&statfs11, buf);
- return (rv);
-}
diff --git a/lib/libc/sys/swapcontext.c b/lib/libc/sys/swapcontext.c
index 1427468e50df..b69a5b19e698 100644
--- a/lib/libc/sys/swapcontext.c
+++ b/lib/libc/sys/swapcontext.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/signal.h>
#include <sys/ucontext.h>
@@ -45,7 +44,5 @@ __sym_default(swapcontext, swapcontext, FBSD_1.2);
int
swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
{
-
- return (((int (*)(ucontext_t *, const ucontext_t *))
- __libc_interposing[INTERPOS_swapcontext])(oucp, ucp));
+ return (INTERPOS_SYS(swapcontext, oucp, ucp));
}
diff --git a/lib/libc/sys/swapon.2 b/lib/libc/sys/swapon.2
deleted file mode 100644
index 1a64d39f3029..000000000000
--- a/lib/libc/sys/swapon.2
+++ /dev/null
@@ -1,161 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)swapon.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 8, 2021
-.Dt SWAPON 2
-.Os
-.Sh NAME
-.Nm swapon , swapoff
-.Nd control devices for interleaved paging/swapping
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.It vm/vm_param.h
-.It vm/swap_pager.h
-.In unistd.h
-.Ft int
-.Fn swapon "const char *special"
-.Ft int
-.Fn swapoff "const char *special" "u_int flags"
-.Sh DESCRIPTION
-The
-.Fn swapon
-system call
-makes the block device
-.Fa special
-available to the system for
-allocation for paging and swapping.
-The names of potentially
-available devices are known to the system and defined at system
-configuration time.
-The size of the swap area on
-.Fa special
-is calculated at the time the device is first made available
-for swapping.
-.Pp
-The
-.Fn swapoff
-system call disables paging and swapping on the given device.
-All associated swap metadata are deallocated, and the device
-is made available for other purposes.
-.Pp
-The
-.Fa special
-argument points to the name of the device or file used for swapping.
-.The
-.Va flags
-argument takes the following flags:
-.Bl -tag -width SWAPOFF_FORCE
-.It Dv SWAPOFF_FORCE
-Overrides a very conservative check that prevents swapoff
-if the total amount of free memory and remaining swap
-devices space might be unsufficient for the system to continue
-operating.
-.El
-.Sh RETURN VALUES
-If an error has occurred, a value of -1 is returned and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-Both
-.Fn swapon
-and
-.Fn swapoff
-can fail if:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named device does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The caller is not the super-user.
-.It Bq Er EFAULT
-The
-.Fa special
-argument
-points outside the process's allocated address space.
-.El
-.Pp
-Additionally,
-.Fn swapon
-can fail for the following reasons:
-.Bl -tag -width Er
-.It Bq Er ENOTBLK
-The
-.Fa special
-argument
-is not a block device.
-.It Bq Er EBUSY
-The device specified by
-.Fa special
-has already
-been made available for swapping
-.It Bq Er ENXIO
-The major device number of
-.Fa special
-is out of range (this indicates no device driver exists
-for the associated hardware).
-.It Bq Er EIO
-An I/O error occurred while opening the swap device.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system to open the
-swap device.
-.El
-.Pp
-Lastly,
-.Fn swapoff
-can fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The system is not currently swapping to
-.Fa special .
-.It Bq Er ENOMEM
-Not enough virtual memory is available to safely disable
-paging and swapping to the given device.
-.El
-.Sh SEE ALSO
-.Xr config 8 ,
-.Xr swapon 8 ,
-.Xr sysctl 8
-.Sh HISTORY
-The
-.Fn swapon
-system call appeared in
-.Bx 4.0 .
-The
-.Fn swapoff
-system call appeared in
-.Fx 5.0 .
diff --git a/lib/libc/sys/symlink.2 b/lib/libc/sys/symlink.2
deleted file mode 100644
index bae615be5069..000000000000
--- a/lib/libc/sys/symlink.2
+++ /dev/null
@@ -1,205 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)symlink.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt SYMLINK 2
-.Os
-.Sh NAME
-.Nm symlink ,
-.Nm symlinkat
-.Nd make symbolic link to a file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn symlink "const char *name1" "const char *name2"
-.Ft int
-.Fn symlinkat "const char *name1" "int fd" "const char *name2"
-.Sh DESCRIPTION
-A symbolic link
-.Fa name2
-is created to
-.Fa name1
-.Fa ( name2
-is the name of the
-file created,
-.Fa name1
-is the string
-used in creating the symbolic link).
-Either name may be an arbitrary path name; the files need not
-be on the same file system.
-.Pp
-The
-.Fn symlinkat
-system call is equivalent to
-.Fn symlink
-except in the case where
-.Fa name2
-specifies a relative path.
-In this case the symbolic link is created relative to the directory
-associated with the file descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn symlinkat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fn symlink .
-.Sh RETURN VALUES
-.Rv -std symlink
-.Sh ERRORS
-The symbolic link succeeds unless:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the
-.Fa name2
-path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of the
-.Fa name2
-pathname exceeded 255 characters,
-or the entire length of either path name exceeded 1023 characters.
-.It Bq Er ENOENT
-A component of the
-.Fa name2
-path prefix does not exist.
-.It Bq Er EACCES
-A component of the
-.Fa name2
-path prefix denies search permission, or write permission is denied on the
-parent directory of the file to be created.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the
-.Fa name2
-path name.
-.It Bq Er EEXIST
-The path name pointed at by the
-.Fa name2
-argument
-already exists.
-.It Bq Er EPERM
-The parent directory of the file named by
-.Fa name2
-has its immutable flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EIO
-An I/O error occurred while making the directory entry for
-.Fa name2 ,
-allocating the inode for
-.Fa name2 ,
-or writing out the link contents of
-.Fa name2 .
-.It Bq Er EROFS
-The file
-.Fa name2
-would reside on a read-only file system.
-.It Bq Er ENOSPC
-The directory in which the entry for the new symbolic link is being placed
-cannot be extended because there is no space left on the file
-system containing the directory.
-.It Bq Er ENOSPC
-The new symbolic link cannot be created because
-there is no space left on the file
-system that will contain the symbolic link.
-.It Bq Er ENOSPC
-There are no free inodes on the file system on which the
-symbolic link is being created.
-.It Bq Er EDQUOT
-The directory in which the entry for the new symbolic link
-is being placed cannot be extended because the
-user's quota of disk blocks on the file system
-containing the directory has been exhausted.
-.It Bq Er EDQUOT
-The new symbolic link cannot be created because the user's
-quota of disk blocks on the file system that will
-contain the symbolic link has been exhausted.
-.It Bq Er EDQUOT
-The user's quota of inodes on the file system on
-which the symbolic link is being created has been exhausted.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-The
-.Fa name1
-or
-.Fa name2
-argument
-points outside the process's allocated address space.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn symlink ,
-the
-.Fn symlinkat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa name2
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa name2
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr ln 1 ,
-.Xr chflags 2 ,
-.Xr link 2 ,
-.Xr lstat 2 ,
-.Xr readlink 2 ,
-.Xr unlink 2 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Fn symlinkat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn symlink
-system call appeared in
-.Bx 4.2 .
-The
-.Fn symlinkat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/sync.2 b/lib/libc/sys/sync.2
deleted file mode 100644
index 91c2e28565f3..000000000000
--- a/lib/libc/sys/sync.2
+++ /dev/null
@@ -1,76 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)sync.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd December 1, 2017
-.Dt SYNC 2
-.Os
-.Sh NAME
-.Nm sync
-.Nd "schedule file system updates"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft void
-.Fn sync void
-.Sh DESCRIPTION
-The
-.Fn sync
-system call forces a write of dirty (modified) buffers
-in the block buffer cache out
-to disk.
-The kernel keeps this information in core to reduce
-the number of disk I/O transfers required by the system.
-As information in the cache is lost after a system crash, a
-.Fn sync
-system call is issued
-frequently
-by the kernel process
-.Xr syncer 4
-(about every 30 seconds).
-.Pp
-The
-.Xr fsync 2
-system call
-may be used to synchronize individual file descriptor
-attributes.
-.Sh SEE ALSO
-.Xr fsync 2 ,
-.Xr syncer 4 ,
-.Xr sync 8
-.Sh HISTORY
-The
-.Fn sync
-function appeared in
-.At v3 .
-.Sh BUGS
-The
-.Fn sync
-system call
-may return before the buffers are completely flushed.
diff --git a/lib/libc/sys/sysarch.2 b/lib/libc/sys/sysarch.2
deleted file mode 100644
index ee37c7409425..000000000000
--- a/lib/libc/sys/sysarch.2
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" $NetBSD: sysarch.2,v 1.6 1998/02/25 21:24:57 perry Exp $
-.\"
-.\" Copyright (c) 1980, 1991 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.
-.\"
-.\" from: @(#)syscall.2 6.3 (Berkeley) 3/10/91
-.\"
-.Dd October 11, 1993
-.Dt SYSARCH 2
-.Os
-.Sh NAME
-.Nm sysarch
-.Nd architecture-dependent system call
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In machine/sysarch.h
-.Ft int
-.Fn sysarch "int number" "void *args"
-.Sh DESCRIPTION
-The
-.Fn sysarch
-system call
-performs the architecture-dependent function
-specified by
-.Fa number
-with the arguments specified by the
-.Fa args
-pointer.
-The
-.Fa args
-argument
-is a pointer to a structure defining the actual
-arguments of the function.
-Symbolic constants and argument structures
-for the architecture-dependent
-functions can be found in the header file
-.In machine/sysarch.h .
-.Pp
-The
-.Fn sysarch
-system call should never be called directly by
-user programs.
-Instead, they should access
-its functions using the architecture-dependent
-library.
-.Sh RETURN VALUES
-See the manual pages for specific architecture-dependent system calls
-for information about their return values.
-.Sh SEE ALSO
-.Xr i386_get_ioperm 2 ,
-.Xr i386_get_ldt 2 ,
-.Xr i386_vm86 2
-.Sh HISTORY
-This manual page was taken from
-.Nx .
diff --git a/lib/libc/sys/syscall.2 b/lib/libc/sys/syscall.2
deleted file mode 100644
index 53a6a89a4e1a..000000000000
--- a/lib/libc/sys/syscall.2
+++ /dev/null
@@ -1,76 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)syscall.2 8.1 (Berkeley) 6/16/93
-.\"
-.Dd June 16, 1993
-.Dt SYSCALL 2
-.Os
-.Sh NAME
-.Nm syscall ,
-.Nm __syscall
-.Nd indirect system call
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/syscall.h
-.In unistd.h
-.Ft int
-.Fn syscall "int number" ...
-.Ft off_t
-.Fn __syscall "quad_t number" ...
-.Sh DESCRIPTION
-The
-.Fn syscall
-function
-performs the system call whose assembly language
-interface has the specified
-.Fa number
-with the specified arguments.
-Symbolic constants for system calls can be found in the header file
-.In sys/syscall.h .
-The
-.Fn __syscall
-form should be used when one or more of the arguments is a
-64-bit argument to ensure that argument alignment is correct.
-This system call is useful for testing new system calls that
-do not have entries in the C library.
-.Sh RETURN VALUES
-The return values are defined by the system call being invoked.
-In general, a 0 return value indicates success.
-A -1 return value indicates an error,
-and an error code is stored in
-.Va errno .
-.Sh HISTORY
-The
-.Fn syscall
-function appeared in
-.Bx 4.0 .
-.Sh BUGS
-There is no way to simulate system calls that have multiple return values
-such as
-.Xr pipe 2 .
diff --git a/lib/libc/sys/thr_exit.2 b/lib/libc/sys/thr_exit.2
deleted file mode 100644
index 62d6e6da22ce..000000000000
--- a/lib/libc/sys/thr_exit.2
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_EXIT 2
-.Os
-.Sh NAME
-.Nm thr_exit
-.Nd terminate current thread
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft void
-.Fn thr_exit "long *state"
-.Sh DESCRIPTION
-.Bf -symbolic
-This function is intended for implementing threading.
-Normal applications should call
-.Xr pthread_exit 3
-instead.
-.Ef
-.Pp
-The
-.Fn thr_exit
-system call terminates the current kernel-scheduled thread.
-.Pp
-If the
-.Fa state
-argument is not
-.Dv NULL ,
-the location pointed to by the argument is
-updated with an arbitrary non-zero value, and an
-.Xr _umtx_op 2
-.Dv UMTX_OP_WAKE
-operation is consequently performed on the location.
-.Pp
-Attempts to terminate the last thread in the process are silently ignored.
-Use
-.Xr _exit 2
-syscall to terminate the process.
-.Sh RETURN VALUES
-The function does not return a value.
-A return from the function indicates that the calling thread was the
-last one in the process.
-.Sh SEE ALSO
-.Xr _exit 2 ,
-.Xr _umtx_op 2 ,
-.Xr thr_kill 2 ,
-.Xr thr_kill2 2 ,
-.Xr thr_new 2 ,
-.Xr thr_self 2 ,
-.Xr thr_set_name 2 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-The
-.Fn thr_exit
-system call is non-standard and is used by
-.Lb libthr
-to implement
-.St -p1003.1-2001
-.Xr pthread 3
-functionality.
-.Sh HISTORY
-The
-.Fn thr_exit
-system call first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/thr_kill.2 b/lib/libc/sys/thr_kill.2
deleted file mode 100644
index a18e53e61008..000000000000
--- a/lib/libc/sys/thr_kill.2
+++ /dev/null
@@ -1,137 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_kill 2
-.Os
-.Sh NAME
-.Nm thr_kill
-.Nd send signal to thread
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft int
-.Fn thr_kill "long id" "int sig"
-.Ft int
-.Fn thr_kill2 "pid_t pid" "long id" "int sig"
-.Sh DESCRIPTION
-The
-.Fn thr_kill
-and
-.Fn thr_kill2
-system calls allow sending a signal, specified by the
-.Fa sig
-argument, to some threads in a process.
-For the
-.Fn thr_kill
-function, signalled threads are always limited to the current process.
-For the
-.Fn thr_kill2
-function, the
-.Fa pid
-argument specifies the process with threads to be signalled.
-.Pp
-The
-.Fa id
-argument specifies which threads get the signal.
-If
-.Fa id
-is equal to \-1, all threads in the specified process are signalled.
-Otherwise, only the thread with the thread identifier equal to the
-argument is signalled.
-.Pp
-The
-.Fa sig
-argument defines the delivered signal.
-It must be a valid signal number or zero.
-In the latter case no signal is actually sent, and the call is used to
-verify the liveness of the thread.
-.Pp
-The signal is delivered with
-.Dv siginfo
-.Dv si_code
-set to
-.Dv SI_LWP .
-.Sh RETURN VALUES
-If successful,
-.Fn thr_kill
-and
-.Fn thr_kill2
-will return zero, otherwise \-1 is returned, and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn thr_kill
-and
-.Fn thr_kill2
-operations return the following errors:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa sig
-argument is not zero and does not specify valid signal.
-.It Bq Er ESRCH
-The specified process or thread was not found.
-.El
-.Pp
-Additionally, the
-.Fn thr_kill2
-may return the following errors:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The current process does not have sufficient privilege to check existence or
-send a signal to the specified process.
-.El
-.Sh SEE ALSO
-.Xr kill 2 ,
-.Xr thr_exit 2 ,
-.Xr thr_new 2 ,
-.Xr thr_self 2 ,
-.Xr thr_set_name 2 ,
-.Xr _umtx_op 2 ,
-.Xr pthread_kill 3 ,
-.Xr signal 3
-.Sh STANDARDS
-The
-.Fn thr_kill
-and
-.Fn thr_kill2
-system calls are non-standard and are used by the
-.Lb libthr
-to implement
-.St -p1003.1-2001
-.Xr pthread 3
-functionality.
-.Sh HISTORY
-The
-.Fn thr_kill
-and
-.Fn thr_kill2
-system calls first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/thr_new.2 b/lib/libc/sys/thr_new.2
deleted file mode 100644
index 27408008c1a0..000000000000
--- a/lib/libc/sys/thr_new.2
+++ /dev/null
@@ -1,247 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_NEW 2
-.Os
-.Sh NAME
-.Nm thr_new
-.Nd create new thread of execution
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft int
-.Fn thr_new "struct thr_param *param" "int param_size"
-.Sh DESCRIPTION
-.Bf -symbolic
-This function is intended for implementing threading.
-Normal applications should call
-.Xr pthread_create 3
-instead.
-.Ef
-.Pp
-The
-.Fn thr_new
-system call creates a new kernel-scheduled thread of execution in the context
-of the current process.
-The newly created thread shares all attributes of the process with the
-existing kernel-scheduled threads in the process, but has private processor
-execution state.
-The machine context for the new thread is copied from the creating thread's
-context, including coprocessor state.
-FPU state and specific machine registers are excluded from the copy.
-These are set according to ABI requirements and syscall parameters.
-The FPU state for the new thread is reinitialized to clean.
-.Pp
-The
-.Fa param
-structure supplies parameters affecting the thread creation.
-The structure is defined in the
-.In sys/thr.h
-header as follows
-.Bd -literal
-struct thr_param {
- void (*start_func)(void *);
- void *arg;
- char *stack_base;
- size_t stack_size;
- char *tls_base;
- size_t tls_size;
- long *child_tid;
- long *parent_tid;
- int flags;
- struct rtprio *rtp;
-};
-.Ed
-and contains the following fields:
-.Bl -tag -width ".Va parent_tid"
-.It Va start_func
-Pointer to the thread entry function.
-The kernel arranges for the new thread to start executing the function
-upon the first return to userspace.
-.It Va arg
-Opaque argument supplied to the entry function.
-.It Va stack_base
-Stack base address.
-The stack must be allocated by the caller.
-On some architectures, the ABI might require that the system put information
-on the stack to ensure the execution environment for
-.Va start_func .
-.It Va stack_size
-Stack size.
-.It Va tls_base
-TLS base address.
-The value of TLS base is loaded into the ABI-defined machine register
-in the new thread context.
-.It Va tls_size
-TLS size.
-.It Va child_tid
-Address to store the new thread identifier, for the child's use.
-.It Va parent_tid
-Address to store the new thread identifier, for the parent's use.
-.Pp
-Both
-.Va child_tid
-and
-.Va parent_tid
-are provided, with the intent that
-.Va child_tid
-is used by the new thread to get its thread identifier without
-issuing the
-.Xr thr_self 2
-syscall, while
-.Va parent_tid
-is used by the thread creator.
-The latter is separate from
-.Va child_tid
-because the new thread might exit and free its thread data before the parent
-has a chance to execute far enough to access it.
-.It Va flags
-Thread creation flags.
-The
-.Va flags
-member may specify the following flags:
-.Bl -tag -width ".Dv THR_SYSTEM_SCOPE"
-.It Dv THR_SUSPENDED
-Create the new thread in the suspended state.
-The flag is not currently implemented.
-.It Dv THR_SYSTEM_SCOPE
-Create the system scope thread.
-The flag is not currently implemented.
-.El
-.It Va rtp
-Real-time scheduling priority for the new thread.
-May be
-.Dv NULL
-to inherit the priority from the
-creating thread.
-.El
-.Pp
-The
-.Fa param_size
-argument should be set to the size of the
-.Fa param
-structure.
-.Pp
-After the first successful creation of an additional thread,
-the process is marked by the kernel as multi-threaded.
-In particular, the
-.Dv P_HADTHREADS
-flag is set in the process'
-.Dv p_flag
-(visible in the
-.Xr ps 1
-output), and several operations are executed in multi-threaded mode.
-For instance, the
-.Xr execve 2
-system call terminates all threads but the calling one on successful
-execution.
-.Sh RETURN VALUES
-If successful,
-.Fn thr_new
-will return zero, otherwise \-1 is returned, and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn thr_new
-operation returns the following errors:
-.Bl -tag -width Er
-.\" When changing this list, consider updating share/man/man3/pthread_create.3,
-.\" since that function can return any of these errors.
-.It Bq Er EFAULT
-The memory pointed to by the
-.Fa param
-argument is not valid.
-.It Bq Er EFAULT
-The memory pointed to by the
-.Fa param
-structure
-.Fa child_tid , parent_tid
-or
-.Fa rtp
-arguments is not valid.
-.It Bq Er EFAULT
-The specified stack base is invalid, or the kernel was unable to put required
-initial data on the stack.
-.It Bq Er EINVAL
-The
-.Fa param_size
-argument specifies a negative value, or the value is greater than the
-largest
-.Fa struct param
-size the kernel can interpret.
-.It Bq Er EINVAL
-The
-.Fa rtp
-member is not
-.Dv NULL
-and specifies invalid scheduling parameters.
-.It Bq Er EINVAL
-The specified TLS base is invalid.
-.It Bq Er EPERM
-The caller does not have permission to set the scheduling parameters or
-scheduling policy.
-.It Bq Er EPROCLIM
-Creation of the new thread would exceed the
-.Dv RACCT_NTHR
-limit, see
-.Xr rctl_get_racct 2 .
-.It Bq Er EPROCLIM
-Creation of the new thread would exceed the
-.Dv kern.threads.max_threads_per_proc
-.Xr sysctl 3
-limit.
-.It Bq Er ENOMEM
-There was not enough kernel memory to allocate the new thread structures.
-.El
-.Sh SEE ALSO
-.Xr ps 1 ,
-.Xr _umtx_op 2 ,
-.Xr execve 2 ,
-.Xr rctl_get_racct 2 ,
-.Xr thr_exit 2 ,
-.Xr thr_kill 2 ,
-.Xr thr_kill2 2 ,
-.Xr thr_self 2 ,
-.Xr thr_set_name 2 ,
-.Xr pthread_create 3
-.Sh STANDARDS
-The
-.Fn thr_new
-system call is non-standard and is used by the
-.Lb libthr
-to implement
-.St -p1003.1-2001
-.Xr pthread 3
-functionality.
-.Sh HISTORY
-The
-.Fn thr_new
-system call first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/thr_self.2 b/lib/libc/sys/thr_self.2
deleted file mode 100644
index 0637dca1d7b7..000000000000
--- a/lib/libc/sys/thr_self.2
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_SELF 2
-.Os
-.Sh NAME
-.Nm thr_self
-.Nd return thread identifier for the calling thread
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft int
-.Fn thr_self "long *id"
-.Sh DESCRIPTION
-The
-.Fn thr_self
-system call stores the system-wide thread identifier for the current
-kernel-scheduled thread in the variable pointed by the argument
-.Va id .
-.Pp
-The thread identifier is an integer in the range from
-.Dv PID_MAX + 2
-(100001) to
-.Dv INT_MAX .
-The thread identifier is guaranteed to be unique at any given time,
-for each running thread in the system.
-After the thread exits, the identifier may be reused.
-.Sh RETURN VALUES
-If successful,
-.Fn thr_self
-will return zero, otherwise \-1 is returned, and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn thr_self
-operation may return the following errors:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The memory pointed to by the
-.Fa id
-argument is not valid.
-.El
-.Sh SEE ALSO
-.Xr _umtx_op 2 ,
-.Xr thr_exit 2 ,
-.Xr thr_kill 2 ,
-.Xr thr_kill2 2 ,
-.Xr thr_new 2 ,
-.Xr thr_set_name 2 ,
-.Xr pthread_getthreadid_np 3 ,
-.Xr pthread_self 3
-.Sh STANDARDS
-The
-.Fn thr_self
-system call is non-standard and is used by
-.Lb libthr
-to implement
-.St -p1003.1-2001
-.Xr pthread 3
-functionality.
-.Sh HISTORY
-The
-.Fn thr_self
-system call first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/thr_set_name.2 b/lib/libc/sys/thr_set_name.2
deleted file mode 100644
index f43a60a4b3a5..000000000000
--- a/lib/libc/sys/thr_set_name.2
+++ /dev/null
@@ -1,96 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_SET_NAME 2
-.Os
-.Sh NAME
-.Nm thr_set_name
-.Nd set user-visible thread name
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft int
-.Fn thr_set_name "long id" "const char *name"
-.Sh DESCRIPTION
-The
-.Fn thr_set_name
-system call sets the user-visible name for the thread with the identifier
-.Va id
-in the current process to the NUL-terminated string
-.Va name .
-The name will be silently truncated to fit into a buffer of
-.Dv MAXCOMLEN + 1
-bytes.
-The thread name can be seen in the output of the
-.Xr ps 1
-and
-.Xr top 1
-commands, in the kernel debuggers and kernel tracing facility outputs,
-and in userland debuggers and program core files, as notes.
-.Sh RETURN VALUES
-If successful,
-.Fn thr_set_name
-returns zero; otherwise, \-1 is returned, and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn thr_set_name
-system call may return the following errors:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The memory pointed to by the
-.Fa name
-argument is not valid.
-.It Bq Er ESRCH
-The thread with the identifier
-.Fa id
-does not exist in the current process.
-.El
-.Sh SEE ALSO
-.Xr ps 1 ,
-.Xr _umtx_op 2 ,
-.Xr thr_exit 2 ,
-.Xr thr_kill 2 ,
-.Xr thr_kill2 2 ,
-.Xr thr_new 2 ,
-.Xr thr_self 2 ,
-.Xr pthread_set_name_np 3 ,
-.Xr ddb 4 ,
-.Xr ktr 9
-.Sh STANDARDS
-The
-.Fn thr_set_name
-system call is non-standard and is used by the
-.Lb libthr .
-.Sh HISTORY
-The
-.Fn thr_set_name
-system call first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/thr_suspend.2 b/lib/libc/sys/thr_suspend.2
deleted file mode 100644
index ee4261b3676c..000000000000
--- a/lib/libc/sys/thr_suspend.2
+++ /dev/null
@@ -1,131 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_SUSPEND 2
-.Os
-.Sh NAME
-.Nm thr_suspend
-.Nd suspend the calling thread
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft int
-.Fn thr_suspend "struct timespec *timeout"
-.Sh DESCRIPTION
-.Bf -symbolic
-This function is intended for implementing threading.
-Normal applications should use
-.Xr pthread_cond_timedwait 3
-together with
-.Xr pthread_cond_broadcast 3
-for typical safe suspension with cooperation of the thread
-being suspended, or
-.Xr pthread_suspend_np 3
-and
-.Xr pthread_resume_np 3
-in some specific situations, instead.
-.Ef
-.Pp
-The
-.Fn thr_suspend
-system call puts the calling thread in a suspended state, where it is
-not eligible for CPU time.
-This state is exited by another thread calling
-.Xr thr_wake 2 ,
-when the time interval specified by
-.Fa timeout
-has elapsed,
-or by the delivery of a signal to the suspended thread.
-.Pp
-If the
-.Fa timeout
-argument is
-.Dv NULL ,
-the suspended state can be only terminated by explicit
-.Fn thr_wake
-or signal.
-.Pp
-If a wake from
-.Xr thr_wake 2
-was delivered before the
-.Nm
-call, the thread is not put into a suspended state.
-Instead, the call
-returns immediately without an error.
-.Pp
-If a thread previously called
-.Xr thr_wake 2
-with its own thread identifier, which resulted in setting the internal kernel
-flag to immediately abort interruptible sleeps with an
-.Er EINTR
-error
-.Po
-see
-.Xr thr_wake 2
-.Pc ,
-the flag is cleared.
-As with
-.Xr thr_wake 2
-called from another thread, the next
-.Nm
-call does not result in suspension.
-.Sh RETURN VALUES
-.Rv -std thr_suspend
-.Sh ERRORS
-The
-.Fn thr_suspend
-operation returns the following errors:
-.Bl -tag -width Er
-.It Bq Er EFAULT
-The memory pointed to by the
-.Fa timeout
-argument is not valid.
-.It Bq Er ETIMEDOUT
-The specified timeout expired.
-.It Bq Er ETIMEDOUT
-The
-.Fa timeout
-argument specified a zero time interval.
-.It Bq Er EINTR
-The sleep was interrupted by a signal.
-.El
-.Sh SEE ALSO
-.Xr ps 1 ,
-.Xr thr_wake 2 ,
-.Xr pthread_resume_np 3 ,
-.Xr pthread_suspend_np 3
-.Sh STANDARDS
-The
-.Fn thr_suspend
-system call is non-standard.
-.Sh HISTORY
-The
-.Fn thr_suspend
-system call first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/thr_wake.2 b/lib/libc/sys/thr_wake.2
deleted file mode 100644
index 0a196c2dd18b..000000000000
--- a/lib/libc/sys/thr_wake.2
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd May 5, 2020
-.Dt THR_WAKE 2
-.Os
-.Sh NAME
-.Nm thr_wake
-.Nd wake up the suspended thread
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/thr.h
-.Ft int
-.Fn thr_wake "long id"
-.Sh DESCRIPTION
-.Bf -symbolic
-This function is intended for implementing threading.
-Normal applications should use
-.Xr pthread_cond_timedwait 3
-together with
-.Xr pthread_cond_broadcast 3
-for typical safe suspension with cooperation of the thread
-being suspended, or
-.Xr pthread_suspend_np 3
-and
-.Xr pthread_resume_np 3
-in some specific situations, instead.
-.Ef
-.Pp
-Passing the thread identifier of the calling thread
-.Po
-see
-.Xr thr_self 2
-.Pc
-to
-.Fn thr_wake
-sets a thread's flag to cause the next signal-interruptible sleep
-of that thread in the kernel to fail immediately with the
-.Er EINTR
-error.
-The flag is cleared by an interruptible sleep attempt or by a call to
-.Xr thr_suspend 2 .
-This is used by the system threading library to implement cancellation.
-.Pp
-If
-.Fa id
-is not equal to the current thread identifier, the specified thread is
-woken up if suspended by the
-.Xr thr_suspend 2
-system call.
-If the thread is not suspended at the time of the
-.Nm
-call, the wake is remembered and the next attempt of the thread to
-suspend itself with the
-.Xr thr_suspend 2
-results in immediate return with success.
-Only one wake is remembered.
-.Sh RETURN VALUES
-.Rv -std thr_wake
-.Sh ERRORS
-The
-.Fn thr_wake
-operation returns these errors:
-.Bl -tag -width Er
-.It Bq Er ESRCH
-The specified thread was not found or does not belong to the process
-of the calling thread.
-.El
-.Sh SEE ALSO
-.Xr ps 1 ,
-.Xr thr_self 2 ,
-.Xr thr_suspend 2 ,
-.Xr pthread_cancel 3 ,
-.Xr pthread_resume_np 3 ,
-.Xr pthread_suspend_np 3
-.Sh STANDARDS
-The
-.Fn thr_suspend
-system call is non-standard and is used by
-.Lb libthr
-to implement
-.St -p1003.1-2001
-.Xr pthread 3
-functionality.
-.Sh HISTORY
-The
-.Fn thr_suspend
-system call first appeared in
-.Fx 5.2 .
diff --git a/lib/libc/sys/timer_create.2 b/lib/libc/sys/timer_create.2
deleted file mode 100644
index e8489b390845..000000000000
--- a/lib/libc/sys/timer_create.2
+++ /dev/null
@@ -1,198 +0,0 @@
-.\" Copyright (c) 2005 David Xu <davidxu@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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.Dd July 15, 2016
-.Dt TIMER_CREATE 2
-.Os
-.Sh NAME
-.Nm timer_create
-.Nd "create a per-process timer (REALTIME)"
-.Sh LIBRARY
-.Lb librt
-.Sh SYNOPSIS
-.In time.h
-.In signal.h
-.Ft int
-.Fo timer_create
-.Fa "clockid_t clockid" "struct sigevent *restrict evp"
-.Fa "timer_t *restrict timerid"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn timer_create
-system call creates a per-process timer using the specified clock,
-.Fa clock_id ,
-as the timing base.
-The
-.Fn timer_create
-system call returns, in the location referenced by
-.Fa timerid ,
-a timer ID of type
-.Vt timer_t
-used to identify the timer in timer requests.
-This timer ID is unique within the calling process until the timer is deleted.
-The particular clock,
-.Fa clock_id ,
-is defined in
-.In time.h .
-The timer whose ID is returned is in a disarmed state upon return from
-.Fn timer_create .
-.Pp
-The
-.Fa evp
-argument, if
-.Pf non- Dv NULL ,
-points to a
-.Vt sigevent
-structure.
-This structure,
-allocated by the application, defines the asynchronous notification to occur
-when the timer expires.
-.Pp
-If
-.Fa evp->sigev_notify
-is
-.Dv SIGEV_SIGNO
-or
-.Dv SIGEV_THREAD_ID ,
-the signal specified in
-.Fa evp->sigev_signo
-will be sent to the calling process
-.Pq Dv SIGEV_SIGNO
-or to the thread whose LWP ID is
-.Fa evp->sigev_notify_thread_id
-.Pq Dv SIGEV_THREAD_ID .
-The information for the queued signal will include:
-.Bl -column ".Va si_value"
-.It Sy Member Ta Sy Value
-.It Va si_code Ta Dv SI_TIMER
-.It Va si_value Ta
-the value stored in
-.Fa evp->sigev_value
-.It Va si_timerid Ta timer ID
-.It Va si_overrun Ta timer overrun count
-.It Va si_errno Ta
-If timer overrun is
-.Brq Dv DELAYTIMER_MAX ,
-an error code defined in
-.In errno.h
-.El
-.Pp
-If the
-.Fa evp
-argument is
-.Dv NULL ,
-the effect is as if the
-.Fa evp
-argument pointed to a
-.Vt sigevent
-structure with the
-.Va sigev_notify
-member having the value
-.Dv SIGEV_SIGNAL ,
-the
-.Va sigev_signo
-having a default signal number
-.Pq Dv SIGALRM ,
-and the
-.Va sigev_value
-member having
-the value of the timer ID.
-.Pp
-This implementation supports a
-.Fa clock_id
-of
-.Dv CLOCK_REALTIME
-or
-.Dv CLOCK_MONOTONIC .
-.Pp
-If
-.Fa evp->sigev_notify
-is
-.Dv SIGEV_THREAD
-and
-.Fa sev->sigev_notify_attributes
-is not
-.Dv NULL ,
-if the attribute pointed to by
-.Fa sev->sigev_notify_attributes
-has
-a thread stack address specified by a call to
-.Fn pthread_attr_setstack
-or
-.Fn pthread_attr_setstackaddr ,
-the results are unspecified if the signal is generated more than once.
-.Sh RETURN VALUES
-If the call succeeds,
-.Fn timer_create
-returns zero and updates the location referenced by
-.Fa timerid
-to a
-.Vt timer_t ,
-which can be passed to the per-process timer calls.
-If an error
-occurs, the system call returns a value of \-1
-and the global variable
-.Va errno
-is set to indicate the
-error.
-The value of
-.Fa timerid
-is undefined if an error occurs.
-.Sh ERRORS
-The
-.Fn timer_create
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The calling process has already created all of the timers it is allowed by
-this implementation.
-.It Bq Er EINVAL
-The specified clock ID is not supported.
-.It Bq Er EINVAL
-The specified asynchronous notification method is not supported.
-.It Bq Er EFAULT
-Any arguments point outside the allocated address space or there is a
-memory protection fault.
-.El
-.Sh SEE ALSO
-.Xr clock_getres 2 ,
-.Xr timer_delete 2 ,
-.Xr timer_getoverrun 2 ,
-.Xr sigevent 3 ,
-.Xr siginfo 3
-.Sh STANDARDS
-The
-.Fn timer_create
-system call conforms to
-.St -p1003.1-2004 .
-.Sh HISTORY
-Support for
-.Tn POSIX
-per-process timer first appeared in
-.Fx 7.0 .
diff --git a/lib/libc/sys/timerfd.2 b/lib/libc/sys/timerfd.2
deleted file mode 100644
index e5dab05821bd..000000000000
--- a/lib/libc/sys/timerfd.2
+++ /dev/null
@@ -1,340 +0,0 @@
-.\" SPDX-License-Identifier: BSD-2-Clause
-.\"
-.\" Copyright (c) 2023 Jake Freeland <jfree@FreeBSD.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.
-.\"
-.\" 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.
-.\"
-.Dd May 21, 2023
-.Dt TIMERFD 2
-.Os
-.Sh NAME
-.Nm timerfd ,
-.Nm timerfd_create ,
-.Nm timerfd_gettime ,
-.Nm timerfd_settime
-.Nd timers with file descriptor semantics
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/timerfd.h
-.Ft int
-.Fo timerfd_create
-.Fa "int clockid"
-.Fa "int flags"
-.Fc
-.Ft int
-.Fo timerfd_gettime
-.Fa "int fd"
-.Fa "struct itimerspec *curr_value"
-.Fc
-.Ft int
-.Fo timerfd_settime
-.Fa "int fd"
-.Fa "int flags"
-.Fa "const struct itimerspec *new_value"
-.Fa "struct itimerspec *old_value"
-.Fc
-.Sh DESCRIPTION
-The
-.Nm
-system calls operate on timers, identified by special
-.Nm
-file descriptors.
-These calls are analogous to
-.Fn timer_create ,
-.Fn timer_gettime ,
-and
-.Fn timer_settime
-per-process timer functions, but use a
-.Nm
-descriptor in place of
-.Fa timerid .
-.Pp
-All
-.Nm
-descriptors possess traditional file descriptor semantics; they may be passed
-to other processes, preserved across
-.Xr fork 2 ,
-and monitored via
-.Xr kevent 2 ,
-.Xr poll 2 ,
-or
-.Xr select 2 .
-When a
-.Nm
-descriptor is no longer needed, it may be disposed of using
-.Xr close 2 .
-.Bl -tag -width "Fn timerfd_settime"
-.It Fn timerfd_create
-Initialize a
-.Nm
-object and return its file descriptor.
-The
-.Fa clockid
-argument specifies the clock used as a timing base and may be:
-.Pp
-.Bl -tag -width "Dv CLOCK_MONOTONIC" -compact
-.It Dv CLOCK_REALTIME
-Increments as a wall clock should.
-.It Dv CLOCK_MONOTONIC
-Increments monotonically in SI seconds.
-.El
-.Pp
-The
-.Fa flags
-argument may contain the result of
-.Em or Ns 'ing
-the following values:
-.Pp
-.Bl -tag -width "Dv TFD_NONBLOCK" -compact
-.It Dv TFD_CLOEXEC
-The newly generated file descriptor will close-on-exec.
-.It Dv TFD_NONBLOCK
-Do not block on read/write operations.
-.El
-.It Fn timerfd_gettime
-Retrieve the current state of the timer denoted by
-.Fa fd .
-The result is stored in
-.Fa curr_value
-as a
-.Dv struct itimerspec .
-The
-.Fa it_value
-and
-.Fa it_interval
-members of
-.Fa curr_value
-represent the relative time until the next expiration and the interval
-reload value last set by
-.Fn timerfd_settime ,
-respectively.
-.It Fn timerfd_settime
-Update the timer denoted by
-.Fa fd
-with the
-.Dv struct itimerspec
-in
-.Fa new_value .
-The
-.Fa it_value
-member of
-.Fa new_value
-should contain the amount of time before the timer expires, or zero if the
-timer should be disarmed.
-The
-.Fa it_interval
-member should contain the reload time if an interval timer is desired.
-.Pp
-The previous timer state will be stored in
-.Fa old_value
-given
-.Fa old_value
-is not
-.Dv NULL .
-.Pp
-The
-.Fa flags
-argument may contain the result of
-.Em or Ns 'ing
-the following values:
-.Pp
-.Bl -tag -width TFD_TIMER_CANCEL_ON_SET -compact
-.It Dv TFD_TIMER_ABSTIME
-Expiration will occur at the absolute time provided in
-.Fa new_value .
-Normally,
-.Fa new_value
-represents a relative time compared to the timer's
-.Fa clockid
-clock.
-.It Dv TFD_TIMER_CANCEL_ON_SET
-If
-.Fa clockid
-has been set to
-.Dv CLOCK_REALTIME
-and the realtime clock has experienced a discontinuous jump,
-then the timer will be canceled and the next
-.Xr read 2
-will fail with
-.Dv ECANCELED .
-.El
-.El
-.Pp
-File operations have the following semantics:
-.Bl -tag -width ioctl
-.It Xr read 2
-Transfer the number of timer expirations that have occurred since the last
-successful
-.Xr read 2
-or
-.Fn timerfd_settime
-into the output buffer of size
-.Vt uint64_t .
-If the expiration counter is zero,
-.Xr read 2
-blocks until a timer expiration occurs unless
-.Dv TFD_NONBLOCK
-is set, where
-.Dv EAGAIN
-is returned.
-.It Xr poll 2
-The file descriptor is readable when its timer expiration counter is greater
-than zero.
-.It Xr ioctl 2
-.Bl -tag -width FIONREAD
-.It Dv FIOASYNC int
-A non-zero input will set the FASYNC flag.
-A zero input will clear the FASYNC flag.
-.It Dv FIONBIO int
-A non-zero input will set the FNONBLOCK flag.
-A zero input will clear the FNONBLOCK flag.
-.El
-.El
-.Sh RETURN VALUES
-The
-.Fn timerfd_create
-system call creates a
-.Nm
-object and returns its file descriptor.
-If an error occurs, -1 is returned and the global variable
-.Fa errno
-is set to indicate the error.
-.Pp
-The
-.Fn timerfd_gettime
-and
-.Fn timerfd_settime
-system calls return 0 on success.
-If an error occurs, -1 is returned and the global variable
-.Fa errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn timerfd_create
-system call fails if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The specified
-.Fa clockid
-is not supported.
-.It Bq Er EINVAL
-The provided
-.Fa flags
-are invalid.
-.It Bq Er EMFILE
-The per-process descriptor table is full.
-.It Bq Er ENFILE
-The system file table is full.
-.It Bq Er ENOMEM
-The kernel failed to allocate enough memory for the timer.
-.El
-.Pp
-Both
-.Fn timerfd_gettime
-and
-.Fn timerfd_settime
-system calls fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The provided
-.Fa fd
-is invalid.
-.It Bq Er EFAULT
-The addresses provided by
-.Fa curr_value ,
-.Fa new_value ,
-or
-.Fa old_value
-are invalid.
-.It Bq Er EINVAL
-The provided
-.Fa fd
-is valid, but was not generated by
-.Fn timerfd_create .
-.El
-.Pp
-The following errors only apply to
-.Fn timerfd_settime :
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The provided
-.Fa flags
-are invalid.
-.It Bq Er EINVAL
-A nanosecond field in the
-.Fa new_value
-argument specified a value less than zero, or greater than or equal to 10^9.
-.It Bq Er ECANCELED
-The timer was created with the clock ID
-.Dv CLOCK_REALTIME ,
-was configured with the
-.Dv TFD_TIMER_CANCEL_ON_SET
-flag, and the system realtime clock experienced a discontinuous change without
-being read.
-.El
-.Pp
-A read from a
-.Nm
-object fails if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The timer's expiration counter is zero and the
-.Nm
-object is is set for non-blocking I/O.
-.It Bq Er ECANCELED
-The timer was created with the clock ID
-.Dv CLOCK_REALTIME ,
-was configured with the
-.Dv TFD_TIMER_CANCEL_ON_SET
-flag, and the system realtime clock experienced a discontinuous change.
-.It Bq Er EINVAL
-The size of the read buffer is not large enough to hold the
-.Vt uint64_t
-sized timer expiration counter.
-.El
-.Sh SEE ALSO
-.Xr eventfd 2 ,
-.Xr kqueue 2 ,
-.Xr poll 2 ,
-.Xr read 2 ,
-.Xr timer_create 2 ,
-.Xr timer_gettime 2 ,
-.Xr timer_settime 2
-.Sh STANDARDS
-The
-.Nm
-system calls originated from Linux and are non-standard.
-.Sh HISTORY
-.An -nosplit
-The
-.Nm
-facility was originally ported to
-.Fx Ns 's
-Linux compatibility layer by
-.An Dmitry Chagin Aq Mt dchagin@FreeBSD.org
-in
-.Fx 12.0 .
-It was revised and adapted to be native by
-.An Jake Freeland Aq Mt jfree@FreeBSD.org
-in
-.Fx 14.0 .
diff --git a/lib/libc/sys/trivial-vdso_tc.c b/lib/libc/sys/trivial-vdso_tc.c
deleted file mode 100644
index 0a9d9fa46173..000000000000
--- a/lib/libc/sys/trivial-vdso_tc.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2013 Konstantin Belousov <kib@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <errno.h>
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
-
- return (ENOSYS);
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
-
- return (ENOSYS);
-}
diff --git a/lib/libc/sys/truncate.2 b/lib/libc/sys/truncate.2
deleted file mode 100644
index 23e3301f55e2..000000000000
--- a/lib/libc/sys/truncate.2
+++ /dev/null
@@ -1,169 +0,0 @@
-.\" Copyright (c) 1983, 1991, 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.
-.\"
-.\" @(#)truncate.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt TRUNCATE 2
-.Os
-.Sh NAME
-.Nm truncate ,
-.Nm ftruncate
-.Nd truncate or extend a file to a specified length
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn truncate "const char *path" "off_t length"
-.Ft int
-.Fn ftruncate "int fd" "off_t length"
-.Sh DESCRIPTION
-The
-.Fn truncate
-system call
-causes the file named by
-.Fa path
-or referenced by
-.Fa fd
-to be truncated or extended to
-.Fa length
-bytes in size.
-If the file
-was larger than this size, the extra data
-is lost.
-If the file was smaller than this size,
-it will be extended as if by writing bytes
-with the value zero.
-.Pp
-The
-.Fn ftruncate
-system call causes the file or shared memory object backing the file descriptor
-.Fa fd
-to be truncated or extended to
-.Fa length
-bytes in size.
-The file descriptor must be a valid file descriptor open for writing.
-The file position pointer associated with the file descriptor
-.Fa fd
-will not be modified.
-.Sh RETURN VALUES
-.Rv -std
-If the file to be modified is not a directory or
-a regular file, the
-.Fn truncate
-call has no effect and returns the value 0.
-.Sh ERRORS
-The
-.Fn truncate
-system call
-succeeds unless:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-The named file is not writable by the user.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The named file has its immutable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EISDIR
-The named file is a directory.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er ETXTBSY
-The file is a pure procedure (shared text) file that is being executed.
-.It Bq Er EFBIG
-The
-.Fa length
-argument was greater than the maximum file size.
-.It Bq Er EINVAL
-The
-.Fa length
-argument was less than 0.
-.It Bq Er EIO
-An I/O error occurred updating the inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.El
-.Pp
-The
-.Fn ftruncate
-system call
-succeeds unless:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid descriptor.
-.It Bq Er EINVAL
-The
-.Fa fd
-argument
-references a file descriptor that is not a regular file or shared memory object.
-.It Bq Er EINVAL
-The
-.Fa fd
-descriptor
-is not open for writing.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr open 2 ,
-.Xr shm_open 2
-.Sh HISTORY
-The
-.Fn truncate
-and
-.Fn ftruncate
-system calls appeared in
-.Bx 4.2 .
-.Sh BUGS
-These calls should be generalized to allow ranges
-of bytes in a file to be discarded.
-.Pp
-Historically, the use of
-.Fn truncate
-or
-.Fn ftruncate
-to extend a file was not portable, but this behavior became required in
-.St -p1003.1-2008 .
diff --git a/lib/libc/sys/umask.2 b/lib/libc/sys/umask.2
deleted file mode 100644
index f43e2febf78a..000000000000
--- a/lib/libc/sys/umask.2
+++ /dev/null
@@ -1,87 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)umask.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 4, 1993
-.Dt UMASK 2
-.Os
-.Sh NAME
-.Nm umask
-.Nd set file creation mode mask
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.Ft mode_t
-.Fn umask "mode_t numask"
-.Sh DESCRIPTION
-The
-.Fn umask
-routine sets the process's file mode creation mask to
-.Fa numask
-and returns the previous value of the mask.
-The 9 low-order
-access permission
-bits of
-.Fa numask
-are used by system calls, including
-.Xr open 2 ,
-.Xr mkdir 2 ,
-and
-.Xr mkfifo 2 ,
-to turn off corresponding bits
-requested in file mode.
-(See
-.Xr chmod 2 ) .
-This clearing allows each user to restrict the default access
-to his files.
-.Pp
-The default mask value is S_IWGRP|S_IWOTH (022, write access for the
-owner only).
-Child processes inherit the mask of the calling process.
-.Sh RETURN VALUES
-The previous value of the file mode mask is returned by the call.
-.Sh ERRORS
-The
-.Fn umask
-system call is always successful.
-.Sh SEE ALSO
-.Xr chmod 2 ,
-.Xr mkfifo 2 ,
-.Xr mknod 2 ,
-.Xr open 2
-.Sh STANDARDS
-The
-.Fn umask
-system call is expected to conform to
-.St -p1003.1-90 .
-.Sh HISTORY
-The
-.Fn umask
-function appeared in
-.At v7 .
diff --git a/lib/libc/sys/undelete.2 b/lib/libc/sys/undelete.2
deleted file mode 100644
index 7e5ea03f64a3..000000000000
--- a/lib/libc/sys/undelete.2
+++ /dev/null
@@ -1,106 +0,0 @@
-.\" Copyright (c) 1994
-.\" Jan-Simon Pendry
-.\" 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.
-.\"
-.\" @(#)undelete.2 8.4 (Berkeley) 10/18/94
-.\"
-.Dd March 30, 2020
-.Dt UNDELETE 2
-.Os
-.Sh NAME
-.Nm undelete
-.Nd attempt to recover a deleted file
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn undelete "const char *path"
-.Sh DESCRIPTION
-The
-.Fn undelete
-system call attempts to recover the deleted file named by
-.Fa path .
-Currently, this works only when the named object
-is a whiteout in a union file system.
-The system call removes the whiteout causing
-any objects in a lower layer of the
-union stack to become visible once more.
-.Pp
-Eventually, the
-.Fn undelete
-functionality may be expanded to other file systems able to recover
-deleted files such as the log-structured file system.
-.Sh RETURN VALUES
-.Rv -std undelete
-.Sh ERRORS
-The
-.Fn undelete
-succeeds unless:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er EEXIST
-The path does not reference a whiteout.
-.It Bq Er ENOENT
-The named whiteout does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-Write permission is denied on the directory containing the name
-to be undeleted.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The directory containing the name is marked sticky,
-and the containing directory is not owned by the effective user ID.
-.It Bq Er EINVAL
-The last component of the path is
-.Ql .. .
-.It Bq Er EIO
-An I/O error occurred while updating the directory entry.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The name resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.El
-.Sh SEE ALSO
-.Xr unlink 2 ,
-.Xr mount_unionfs 8
-.Sh HISTORY
-The
-.Fn undelete
-system call first appeared in
-.Bx 4.4 Lite .
diff --git a/lib/libc/sys/unlink.2 b/lib/libc/sys/unlink.2
deleted file mode 100644
index 9b49174ce136..000000000000
--- a/lib/libc/sys/unlink.2
+++ /dev/null
@@ -1,283 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)unlink.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd February 23, 2021
-.Dt UNLINK 2
-.Os
-.Sh NAME
-.Nm unlink ,
-.Nm unlinkat ,
-.Nm funlinkat
-.Nd remove directory entry
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft int
-.Fn unlink "const char *path"
-.Ft int
-.Fn unlinkat "int dfd" "const char *path" "int flag"
-.Ft int
-.Fn funlinkat "int dfd" "const char *path" "int fd" "int flag"
-.Sh DESCRIPTION
-The
-.Fn unlink
-system call
-removes the link named by
-.Fa path
-from its directory and decrements the link count of the
-file which was referenced by the link.
-If that decrement reduces the link count of the file
-to zero,
-and no process has the file open, then
-all resources associated with the file are reclaimed.
-If one or more process have the file open when the last link is removed,
-the link is removed, but the removal of the file is delayed until
-all references to it have been closed.
-The
-.Fa path
-argument
-may not be a directory.
-.Pp
-The
-.Fn unlinkat
-system call is equivalent to
-.Fn unlink
-or
-.Fn rmdir
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the directory entry to be removed is determined
-relative to the directory associated with the file descriptor
-.Fa dfd
-instead of the current working directory.
-.Pp
-The values for
-.Fa flag
-are constructed by a bitwise-inclusive OR of flags from the following list,
-defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_REMOVEDIR
-Remove the directory entry specified by
-.Fa fd
-and
-.Fa path
-as a directory, not a normal file.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.El
-.Pp
-If
-.Fn unlinkat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior is
-identical to a call to
-.Fa unlink
-or
-.Fa rmdir
-respectively, depending on whether or not the
-.Dv AT_REMOVEDIR
-bit is set in flag.
-.Pp
-The
-.Fn funlinkat
-system call can be used to unlink an already-opened file, unless that
-file has been replaced since it was opened.
-It is equivalent to
-.Fn unlinkat
-in the case where
-.Fa path
-is already open as the file descriptor
-.Fa fd .
-Otherwise, the path will not be removed and an error will be returned.
-The
-.Fa fd
-can be set the
-.Dv FD_NONE .
-In that case
-.Fn funlinkat
-behaves exactly like
-.Fn unlinkat .
-.Sh RETURN VALUES
-.Rv -std unlink
-.Sh ERRORS
-The
-.Fn unlink
-succeeds unless:
-.Bl -tag -width Er
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er EISDIR
-The named file is a directory.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters,
-or an entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-Write permission is denied on the directory containing the link
-to be removed.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er EPERM
-The named file is a directory.
-.It Bq Er EPERM
-The named file has its immutable, undeletable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EPERM
-The parent directory of the named file has its immutable or append-only flag
-set.
-.It Bq Er EPERM
-The directory containing the file is marked sticky,
-and neither the containing directory nor the file to be removed
-are owned by the effective user ID.
-.It Bq Er EIO
-An I/O error occurred while deleting the directory entry
-or deallocating the inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EROFS
-The named file resides on a read-only file system.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er ENOSPC
-On file systems supporting copy-on-write or snapshots, there was not enough
-free space to record metadata for the delete operation of the file.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn unlink ,
-the
-.Fn unlinkat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTEMPTY
-The
-.Fa flag
-parameter has the
-.Dv AT_REMOVEDIR
-bit set and the
-.Fa path
-argument names a directory that is not an empty directory,
-or there are hard links to the directory other than dot or
-a single entry in dot-dot.
-.It Bq Er ENOTDIR
-The
-.Fa flag
-parameter has the
-.Dv AT_REMOVEDIR
-bit set and
-.Fa path
-does not name a directory.
-.It Bq Er EINVAL
-The value of the
-.Fa flag
-argument is not valid.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Pp
-In addition to the errors returned by
-.Fn unlinkat ,
-.Fn funlinkat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EDEADLK
-The file descriptor is not associated with the path.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr close 2 ,
-.Xr link 2 ,
-.Xr rmdir 2 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Fn unlinkat
-system call follows The Open Group Extended API Set 2 specification.
-.Sh HISTORY
-The
-.Fn unlink
-function appeared in
-.At v1 .
-The
-.Fn unlinkat
-system call appeared in
-.Fx 8.0 .
-The
-.Fn funlinkat
-system call appeared in
-.Fx 13.0 .
-.Pp
-The
-.Fn unlink
-system call traditionally allows the super-user to unlink directories which
-can damage the file system integrity.
-This implementation no longer permits it.
diff --git a/lib/libc/sys/utimensat.2 b/lib/libc/sys/utimensat.2
deleted file mode 100644
index cd0ac61f9f4f..000000000000
--- a/lib/libc/sys/utimensat.2
+++ /dev/null
@@ -1,309 +0,0 @@
-.\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled Exp $
-.\"
-.\" Copyright (c) 1990, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\" Copyright (c) 2012, Jilles Tjoelker
-.\"
-.\" 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.
-.\"
-.\" @(#)utimes.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd June 12, 2022
-.Dt UTIMENSAT 2
-.Os
-.Sh NAME
-.Nm futimens ,
-.Nm utimensat
-.Nd set file access and modification times
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/stat.h
-.Ft int
-.Fn futimens "int fd" "const struct timespec times[2]"
-.Ft int
-.Fo utimensat
-.Fa "int fd"
-.Fa "const char *path"
-.Fa "const struct timespec times[2]"
-.Fa "int flag"
-.Fc
-.Sh DESCRIPTION
-The access and modification times of the file named by
-.Fa path
-or referenced by
-.Fa fd
-are changed as specified by the argument
-.Fa times .
-The inode-change-time of the file is set to the current time.
-.Pp
-If
-.Fa path
-specifies a relative path,
-it is relative to the current working directory if
-.Fa fd
-is
-.Dv AT_FDCWD
-and otherwise relative to the directory associated with the file descriptor
-.Fa fd .
-.Pp
-The
-.Va tv_nsec
-field of a
-.Vt timespec
-structure
-can be set to the special value
-.Dv UTIME_NOW
-to set the current time, or to
-.Dv UTIME_OMIT
-to leave the time unchanged.
-In either case, the
-.Va tv_sec
-field is ignored.
-.Pp
-If
-.Fa times
-is
-.No non- Ns Dv NULL ,
-it is assumed to point to an array of two timespec structures.
-The access time is set to the value of the first element, and the
-modification time is set to the value of the second element.
-For file systems that support file birth (creation) times (such as
-.Dv UFS2 ) ,
-the birth time will be set to the value of the second element
-if the second element is older than the currently set birth time.
-To set both a birth time and a modification time,
-two calls are required; the first to set the birth time
-and the second to set the (presumably newer) modification time.
-Ideally a new system call will be added that allows the setting
-of all three times at once.
-If
-.Fa times
-is
-.Dv NULL ,
-this is equivalent to passing
-a pointer to an array of two timespec structures
-with both
-.Va tv_nsec
-fields set to
-.Dv UTIME_NOW .
-.Pp
-If both
-.Va tv_nsec
-fields are
-.Dv UTIME_OMIT ,
-the timestamps remain unchanged and
-no permissions are needed for the file itself,
-although search permissions may be required for the path prefix.
-The call may or may not succeed if the named file does not exist.
-.Pp
-If both
-.Va tv_nsec
-fields are
-.Dv UTIME_NOW ,
-the caller must be the owner of the file, have permission to
-write the file, or be the super-user.
-.Pp
-For all other values of the timestamps,
-the caller must be the owner of the file or be the super-user.
-.Pp
-The values for the
-.Fa flag
-argument of the
-.Fn utimensat
-system call
-are constructed by a bitwise-inclusive OR of flags from the following list,
-defined in
-.In fcntl.h :
-.Bl -tag -width indent
-.It Dv AT_SYMLINK_NOFOLLOW
-If
-.Fa path
-names a symbolic link, the symbolic link's times are changed.
-By default,
-.Fn utimensat
-changes the times of the file referenced by the symbolic link.
-.It Dv AT_RESOLVE_BENEATH
-Only walk paths below the directory specified by the
-.Ar fd
-descriptor.
-See the description of the
-.Dv O_RESOLVE_BENEATH
-flag in the
-.Xr open 2
-manual page.
-.It Dv AT_EMPTY_PATH
-If the
-.Fa path
-argument is an empty string, operate on the file or directory
-referenced by the descriptor
-.Fa fd .
-If
-.Fa fd
-is equal to
-.Dv AT_FDCWD ,
-operate on the current working directory.
-.El
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-These system calls will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-The
-.Fa times
-argument is
-.Dv NULL ,
-or both
-.Va tv_nsec
-values are
-.Dv UTIME_NOW ,
-and the effective user ID of the process does not
-match the owner of the file, and is not the super-user, and write
-access is denied.
-.It Bq Er EFAULT
-The
-.Fa times
-argument
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The
-.Va tv_nsec
-component of at least one of the values specified by the
-.Fa times
-argument has a value less than 0 or greater than 999999999 and is not equal to
-.Dv UTIME_NOW
-or
-.Dv UTIME_OMIT .
-.It Bq Er EIO
-An I/O error occurred while reading or writing the affected inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er EPERM
-The
-.Fa times
-argument is not
-.Dv NULL
-nor are both
-.Va tv_nsec
-values
-.Dv UTIME_NOW ,
-nor are both
-.Va tv_nsec
-values
-.Dv UTIME_OMIT
-and the calling process's effective user ID
-does not match the owner of the file and is not the super-user.
-.It Bq Er EPERM
-The named file has its immutable or append-only flag set, see the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EROFS
-The file system containing the file is mounted read-only.
-.El
-.Pp
-The
-.Fn futimens
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-does not refer to a valid descriptor.
-.El
-.Pp
-The
-.Fn utimensat
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor.
-.It Bq Er EFAULT
-The
-.Fa path
-argument
-points outside the process's allocated address space.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded
-.Dv NAME_MAX
-characters, or an entire path name exceeded
-.Dv PATH_MAX
-characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.It Bq Er ENOTCAPABLE
-.Fa path
-is an absolute path,
-or contained a ".." component leading to a
-directory outside of the directory hierarchy specified by
-.Fa fd ,
-and the process is in capability mode or the
-.Dv AT_RESOLVE_BENEATH
-flag was specified.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr stat 2 ,
-.Xr symlink 2 ,
-.Xr utimes 2 ,
-.Xr utime 3 ,
-.Xr symlink 7
-.Sh STANDARDS
-The
-.Fn futimens
-and
-.Fn utimensat
-system calls are expected to conform to
-.St -p1003.1-2008 .
-.Sh HISTORY
-The
-.Fn futimens
-and
-.Fn utimensat
-system calls appeared in
-.Fx 10.3 .
diff --git a/lib/libc/sys/utimes.2 b/lib/libc/sys/utimes.2
deleted file mode 100644
index 04114d36c577..000000000000
--- a/lib/libc/sys/utimes.2
+++ /dev/null
@@ -1,263 +0,0 @@
-.\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled 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.
-.\"
-.\" @(#)utimes.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd March 30, 2020
-.Dt UTIMES 2
-.Os
-.Sh NAME
-.Nm utimes ,
-.Nm lutimes ,
-.Nm futimes ,
-.Nm futimesat
-.Nd set file access and modification times
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/time.h
-.Ft int
-.Fn utimes "const char *path" "const struct timeval *times"
-.Ft int
-.Fn lutimes "const char *path" "const struct timeval *times"
-.Ft int
-.Fn futimes "int fd" "const struct timeval *times"
-.Ft int
-.Fn futimesat "int fd" "const char *path" "const struct timeval times[2]"
-.Sh DESCRIPTION
-.Bf -symbolic
-These interfaces are obsoleted by
-.Xr futimens 2
-and
-.Xr utimensat 2
-because they are not accurate to nanoseconds.
-.Ef
-.Pp
-The access and modification times of the file named by
-.Fa path
-or referenced by
-.Fa fd
-are changed as specified by the argument
-.Fa times .
-.Pp
-If
-.Fa times
-is
-.Dv NULL ,
-the access and modification times are set to the current time.
-The caller must be the owner of the file, have permission to
-write the file, or be the super-user.
-.Pp
-If
-.Fa times
-is
-.No non- Ns Dv NULL ,
-it is assumed to point to an array of two timeval structures.
-The access time is set to the value of the first element, and the
-modification time is set to the value of the second element.
-For file systems that support file birth (creation) times (such as
-.Dv UFS2 ) ,
-the birth time will be set to the value of the second element
-if the second element is older than the currently set birth time.
-To set both a birth time and a modification time,
-two calls are required; the first to set the birth time
-and the second to set the (presumably newer) modification time.
-Ideally a new system call will be added that allows the setting
-of all three times at once.
-The caller must be the owner of the file or be the super-user.
-.Pp
-In either case, the inode-change-time of the file is set to the current
-time.
-.Pp
-The
-.Fn lutimes
-system call
-is like
-.Fn utimes
-except in the case where the named file is a symbolic link,
-in which case
-.Fn lutimes
-changes the access and modification times of the link,
-while
-.Fn utimes
-changes the times of the file the link references.
-.Pp
-The
-.Fn futimesat
-system call is equivalent to
-.Fn utimes
-except in the case where
-.Fa path
-specifies a relative path.
-In this case the access and modification time
-is set to that of a file relative to the directory associated with the file
-descriptor
-.Fa fd
-instead of the current working directory.
-If
-.Fn futimesat
-is passed the special value
-.Dv AT_FDCWD
-in the
-.Fa fd
-parameter, the current working directory is used and the behavior
-is identical to a call to
-.Fn utimes .
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-All of the system call will fail if:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix.
-.It Bq Er EACCES
-The
-.Fa times
-argument is
-.Dv NULL
-and the effective user ID of the process does not
-match the owner of the file, and is not the super-user, and write
-access is denied.
-.It Bq Er EFAULT
-The
-.Fa path
-or
-.Fa times
-argument
-points outside the process's allocated address space.
-.It Bq Er EFAULT
-The
-.Fa times
-argument
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The
-.Va tv_usec
-component of at least one of the values specified by the
-.Fa times
-argument has a value less than 0 or greater than 999999.
-.It Bq Er EIO
-An I/O error occurred while reading or writing the affected inode.
-.It Bq Er EINTEGRITY
-Corrupted data was detected while reading from the file system.
-.It Bq Er ELOOP
-Too many symbolic links were encountered in translating the pathname.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded
-.Dv NAME_MAX
-characters, or an entire path name exceeded
-.Dv PATH_MAX
-characters.
-.It Bq Er ENOENT
-The named file does not exist.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-.It Bq Er EPERM
-The
-.Fa times
-argument is not
-.Dv NULL
-and the calling process's effective user ID
-does not match the owner of the file and is not the super-user.
-.It Bq Er EPERM
-The named file has its immutable or append-only flags set.
-See the
-.Xr chflags 2
-manual page for more information.
-.It Bq Er EROFS
-The file system containing the file is mounted read-only.
-.El
-.Pp
-The
-.Fn futimes
-system call
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-does not refer to a valid descriptor.
-.El
-.Pp
-In addition to the errors returned by the
-.Fn utimes ,
-the
-.Fn futimesat
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa path
-argument does not specify an absolute path and the
-.Fa fd
-argument is neither
-.Dv AT_FDCWD
-nor a valid file descriptor open for searching.
-.It Bq Er ENOTDIR
-The
-.Fa path
-argument is not an absolute path and
-.Fa fd
-is neither
-.Dv AT_FDCWD
-nor a file descriptor associated with a directory.
-.El
-.Sh SEE ALSO
-.Xr chflags 2 ,
-.Xr stat 2 ,
-.Xr utimensat 2 ,
-.Xr utime 3
-.Sh STANDARDS
-The
-.Fn utimes
-function is expected to conform to
-.St -xpg4.2 .
-The
-.Fn futimesat
-system call follows The Open Group Extended API Set 2 specification
-but was replaced by
-.Fn utimensat
-in
-.St -p1003.1-2008 .
-.Sh HISTORY
-The
-.Fn utimes
-system call appeared in
-.Bx 4.2 .
-The
-.Fn futimes
-and
-.Fn lutimes
-system calls first appeared in
-.Fx 3.0 .
-The
-.Fn futimesat
-system call appeared in
-.Fx 8.0 .
diff --git a/lib/libc/sys/vadvise.c b/lib/libc/sys/vadvise.c
index 09251394253e..44e26a69f9c1 100644
--- a/lib/libc/sys/vadvise.c
+++ b/lib/libc/sys/vadvise.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/errno.h>
int vadvise(int);
diff --git a/lib/libc/sys/vfork.2 b/lib/libc/sys/vfork.2
deleted file mode 100644
index a88ada6b87fc..000000000000
--- a/lib/libc/sys/vfork.2
+++ /dev/null
@@ -1,144 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)vfork.2 8.1 (Berkeley) 6/4/93
-.\"
-.Dd May 22, 2016
-.Dt VFORK 2
-.Os
-.Sh NAME
-.Nm vfork
-.Nd create a new process without copying the address space
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft pid_t
-.Fn vfork void
-.Sh DESCRIPTION
-.Bf -symbolic
-Since this function is hard to use correctly from application software,
-it is recommended to use
-.Xr posix_spawn 3
-or
-.Xr fork 2
-instead.
-.Ef
-.Pp
-The
-.Fn vfork
-system call
-can be used to create new processes without fully copying the address
-space of the old process, which is inefficient in a paged
-environment.
-It is useful when the purpose of
-.Xr fork 2
-would have been to create a new system context for an
-.Xr execve 2 .
-The
-.Fn vfork
-system call
-differs from
-.Xr fork 2
-in that the child borrows the parent process's address space and the
-calling thread's stack
-until a call to
-.Xr execve 2
-or an exit (either by a call to
-.Xr _exit 2
-or abnormally).
-The calling thread is suspended while the child is using its resources.
-Other threads continue to run.
-.Pp
-The
-.Fn vfork
-system call
-returns 0 in the child's context and (later) the pid of the child in
-the parent's context.
-.Pp
-Many problems can occur when replacing
-.Xr fork 2
-with
-.Fn vfork .
-For example, it does not work to return while running in the child's context
-from the procedure that called
-.Fn vfork
-since the eventual return from
-.Fn vfork
-would then return to a no longer existent stack frame.
-Also, changing process state which is partially implemented in user space
-such as signal handlers with
-.Xr libthr 3
-will corrupt the parent's state.
-.Pp
-Be careful, also, to call
-.Xr _exit 2
-rather than
-.Xr exit 3
-if you cannot
-.Xr execve 2 ,
-since
-.Xr exit 3
-will flush and close standard I/O channels, and thereby mess up the
-parent processes standard I/O data structures.
-(Even with
-.Xr fork 2
-it is wrong to call
-.Xr exit 3
-since buffered data would then be flushed twice.)
-.Sh RETURN VALUES
-Same as for
-.Xr fork 2 .
-.Sh SEE ALSO
-.Xr _exit 2 ,
-.Xr execve 2 ,
-.Xr fork 2 ,
-.Xr rfork 2 ,
-.Xr sigaction 2 ,
-.Xr wait 2 ,
-.Xr exit 3 ,
-.Xr posix_spawn 3
-.Sh HISTORY
-The
-.Fn vfork
-system call appeared in
-.Bx 3 .
-.Sh BUGS
-To avoid a possible deadlock situation,
-processes that are children in the middle
-of a
-.Fn vfork
-are never sent
-.Dv SIGTTOU
-or
-.Dv SIGTTIN
-signals; rather,
-output or
-.Xr ioctl 2
-calls
-are allowed
-and input attempts result in an end-of-file indication.
diff --git a/lib/libc/sys/wait.2 b/lib/libc/sys/wait.2
deleted file mode 100644
index b62ed585a333..000000000000
--- a/lib/libc/sys/wait.2
+++ /dev/null
@@ -1,687 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993, 1994
-.\" 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.
-.\"
-.\" @(#)wait.2 8.2 (Berkeley) 4/19/94
-.\"
-.Dd June 24, 2022
-.Dt WAIT 2
-.Os
-.Sh NAME
-.Nm wait ,
-.Nm waitid ,
-.Nm waitpid ,
-.Nm wait3 ,
-.Nm wait4 ,
-.Nm wait6
-.Nd wait for processes to change status
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In sys/wait.h
-.Ft pid_t
-.Fn wait "int *status"
-.Ft pid_t
-.Fn waitpid "pid_t wpid" "int *status" "int options"
-.In signal.h
-.Ft int
-.Fn waitid "idtype_t idtype" "id_t id" "siginfo_t *info" "int options"
-.In sys/time.h
-.In sys/resource.h
-.Ft pid_t
-.Fn wait3 "int *status" "int options" "struct rusage *rusage"
-.Ft pid_t
-.Fn wait4 "pid_t wpid" "int *status" "int options" "struct rusage *rusage"
-.Ft pid_t
-.Fo wait6
-.Fa "idtype_t idtype" "id_t id"
-.Fa "int *status"
-.Fa "int options"
-.Fa "struct __wrusage *wrusage"
-.Fa "siginfo_t *infop"
-.Fc
-.Sh DESCRIPTION
-The
-.Fn wait
-function suspends execution of its calling thread until
-.Fa status
-information is available for a child process
-or a signal is received.
-On return from a successful
-.Fn wait
-call,
-the
-.Fa status
-area contains information about the process that reported a status change
-as defined below.
-.Pp
-The
-.Fn wait4
-and
-.Fn wait6
-system calls provide a more general interface for programs
-that need to wait for specific child processes,
-that need resource utilization statistics accumulated by child processes,
-or that require options.
-The other wait functions are implemented using either
-.Fn wait4
-or
-.Fn wait6 .
-.Pp
-The
-.Fn wait6
-function is the most general function in this family and its distinct
-features are:
-.Pp
-All of the desired process statuses to be waited on must be explicitly
-specified in
-.Fa options .
-The
-.Fn wait ,
-.Fn waitpid ,
-.Fn wait3 ,
-and
-.Fn wait4
-functions all implicitly wait for exited and trapped processes,
-but the
-.Fn waitid
-and
-.Fn wait6
-functions require the corresponding
-.Dv WEXITED
-and
-.Dv WTRAPPED
-flags to be explicitly specified.
-This allows waiting for processes which have experienced other
-status changes without having to also handle the exit status from
-terminated processes.
-.Pp
-The
-.Fn wait6
-function accepts a
-.Fa wrusage
-argument which points to a structure defined as:
-.Bd -literal
-struct __wrusage {
- struct rusage wru_self;
- struct rusage wru_children;
-};
-.Ed
-.Pp
-This allows the calling process to collect resource usage statistics
-from both its own child process as well as from its grand children.
-When no resource usage statistics are needed this pointer can be
-.Dv NULL .
-.Pp
-The last argument
-.Fa infop
-must be either
-.Dv NULL
-or a pointer to a
-.Fa siginfo_t
-structure.
-If
-.Pf non- Dv NULL ,
-the structure is filled with the same data as for a
-.Dv SIGCHLD
-signal delivered when the process changed state.
-.Pp
-The set of child processes to be queried is specified by the arguments
-.Fa idtype
-and
-.Fa id .
-The separate
-.Fa idtype
-and
-.Fa id
-arguments support many other types of
-identifiers in addition to process IDs and process group IDs.
-.Bl -bullet -offset indent
-.It
-If
-.Fa idtype
-is
-.Dv P_PID ,
-.Fn waitid
-and
-.Fn wait6
-wait for the child process with a process ID equal to
-.Dv (pid_t)id .
-.It
-If
-.Fa idtype
-is
-.Dv P_PGID ,
-.Fn waitid
-and
-.Fn wait6
-wait for the child process with a process group ID equal to
-.Dv (pid_t)id .
-.It
-If
-.Fa idtype
-is
-.Dv P_ALL ,
-.Fn waitid
-and
-.Fn wait6
-wait for any child process and the
-.Dv id
-is ignored.
-.It
-If
-.Fa idtype
-is
-.Dv P_PID
-or
-.Dv P_PGID
-and the
-.Dv id
-is zero,
-.Fn waitid
-and
-.Fn wait6
-wait for any child process in the same process group as the caller.
-.El
-.Pp
-Non-standard identifier types supported by this
-implementation of
-.Fn waitid
-and
-.Fn wait6
-are:
-.Bl -tag -width P_JAILID
-.It Dv P_UID
-Wait for processes whose effective user ID is equal to
-.Dv (uid_t) Fa id .
-.It Dv P_GID
-Wait for processes whose effective group ID is equal to
-.Dv (gid_t) Fa id .
-.It Dv P_SID
-Wait for processes whose session ID is equal to
-.Fa id .
-.\" This is just how sessions work, not sure this needs to be documented here
-If the child process started its own session,
-its session ID will be the same as its process ID.
-Otherwise the session ID of a child process will match the caller's session ID.
-.It Dv P_JAILID
-Waits for processes within a jail whose jail identifier is equal to
-.Fa id .
-.El
-.Pp
-For the
-.Fn waitpid
-and
-.Fn wait4
-functions, the single
-.Fa wpid
-argument specifies the set of child processes for which to wait.
-.Bl -bullet -offset indent
-.It
-If
-.Fa wpid
-is -1, the call waits for any child process.
-.It
-If
-.Fa wpid
-is 0,
-the call waits for any child process in the process group of the caller.
-.It
-If
-.Fa wpid
-is greater than zero, the call waits for the process with process ID
-.Fa wpid .
-.It
-If
-.Fa wpid
-is less than -1, the call waits for any process whose process group ID
-equals the absolute value of
-.Fa wpid .
-.El
-.Pp
-The
-.Fa status
-argument is defined below.
-.Pp
-The
-.Fa options
-argument contains the bitwise OR of any of the following options.
-.Bl -tag -width WCONTINUED
-.It Dv WCONTINUED
-Report the status of selected processes that
-have continued from a job control stop by receiving a
-.Dv SIGCONT
-signal.
-.It Dv WNOHANG
-Do not block when
-there are no processes wishing to report status.
-.It Dv WUNTRACED
-Report the status of selected processes which are stopped due to a
-.Dv SIGTTIN , SIGTTOU , SIGTSTP ,
-or
-.Dv SIGSTOP
-signal.
-.It Dv WSTOPPED
-An alias for
-.Dv WUNTRACED .
-.It Dv WTRAPPED
-Report the status of selected processes which are being traced via
-.Xr ptrace 2
-and have trapped or reached a breakpoint.
-This flag is implicitly set for the functions
-.Fn wait ,
-.Fn waitpid ,
-.Fn wait3 ,
-and
-.Fn wait4 .
-.br
-For the
-.Fn waitid
-and
-.Fn wait6
-functions, the flag has to be explicitly included in
-.Fa options
-if status reports from trapped processes are expected.
-.It Dv WEXITED
-Report the status of selected processes which have terminated.
-This flag is implicitly set for the functions
-.Fn wait ,
-.Fn waitpid ,
-.Fn wait3 ,
-and
-.Fn wait4 .
-.br
-For the
-.Fn waitid
-and
-.Fn wait6
-functions, the flag has to be explicitly included in
-.Fa options
-if status reports from terminated processes are expected.
-.It Dv WNOWAIT
-Keep the process whose status is returned in a waitable state.
-The process may be waited for again after this call completes.
-.El
-.sp
-For the
-.Fn waitid
-and
-.Fn wait6
-functions, at least one of the options
-.Dv WEXITED ,
-.Dv WUNTRACED ,
-.Dv WSTOPPED ,
-.Dv WTRAPPED ,
-or
-.Dv WCONTINUED
-must be specified.
-Otherwise there will be no events for the call to report.
-To avoid hanging indefinitely in such a case these functions
-return -1 with
-.Dv errno
-set to
-.Dv EINVAL .
-.Pp
-If
-.Fa rusage
-is non-NULL, a summary of the resources used by the terminated
-process and all its children is returned.
-.Pp
-If
-.Fa wrusage
-is non-NULL, separate summaries are returned for the resources used
-by the terminated process and the resources used by all its children.
-.Pp
-If
-.Fa infop
-is non-NULL, a
-.Dv siginfo_t
-structure is returned with the
-.Fa si_signo
-field set to
-.Dv SIGCHLD
-and the
-.Fa si_pid
-field set to the process ID of the process reporting status.
-For the exited process, the
-.Fa si_status
-field of the
-.Dv siginfo_t
-structure contains the full 32 bit exit status passed to
-.Xr _exit 2 ;
-the
-.Fa status
-argument of other calls only returns 8 lowest bits of the exit status.
-.Pp
-When the
-.Dv WNOHANG
-option is specified and no processes
-wish to report status,
-.Fn waitid
-sets the
-.Fa si_signo
-and
-.Fa si_pid
-fields in
-.Fa infop
-to zero.
-Checking these fields is the only way to know if a status change was reported.
-.Pp
-When the
-.Dv WNOHANG
-option is specified and no processes
-wish to report status,
-.Fn wait4
-and
-.Fn wait6
-return a
-process id
-of 0.
-.Pp
-The
-.Fn wait
-call is the same as
-.Fn wait4
-with a
-.Fa wpid
-value of -1,
-with an
-.Fa options
-value of zero,
-and a
-.Fa rusage
-value of
-.Dv NULL .
-The
-.Fn waitpid
-function is identical to
-.Fn wait4
-with an
-.Fa rusage
-value of
-.Dv NULL .
-The older
-.Fn wait3
-call is the same as
-.Fn wait4
-with a
-.Fa wpid
-value of -1.
-The
-.Fn wait4
-function is identical to
-.Fn wait6
-with the flags
-.Dv WEXITED
-and
-.Dv WTRAPPED
-set in
-.Fa options
-and
-.Fa infop
-set to
-.Dv NULL .
-.Pp
-The following macros may be used to test the current status of the process.
-Exactly one of the following four macros will evaluate to a non-zero
-.Pq true
-value:
-.Bl -tag -width Ds
-.It Fn WIFCONTINUED status
-True if the process has not terminated, and
-has continued after a job control stop.
-This macro can be true only if the wait call specified the
-.Dv WCONTINUED
-option.
-.It Fn WIFEXITED status
-True if the process terminated normally by a call to
-.Xr _exit 2
-or
-.Xr exit 3 .
-.It Fn WIFSIGNALED status
-True if the process terminated due to receipt of a signal.
-.It Fn WIFSTOPPED status
-True if the process has not terminated, but has stopped and can be restarted.
-This macro can be true only if the wait call specified the
-.Dv WUNTRACED
-option
-or if the child process is being traced (see
-.Xr ptrace 2 ) .
-.El
-.Pp
-Depending on the values of those macros, the following macros
-produce the remaining status information about the child process:
-.Bl -tag -width Ds
-.It Fn WEXITSTATUS status
-If
-.Fn WIFEXITED status
-is true, evaluates to the low-order 8 bits
-of the argument passed to
-.Xr _exit 2
-or
-.Xr exit 3
-by the child.
-.It Fn WTERMSIG status
-If
-.Fn WIFSIGNALED status
-is true, evaluates to the number of the signal
-that caused the termination of the process.
-.It Fn WCOREDUMP status
-If
-.Fn WIFSIGNALED status
-is true, evaluates as true if the termination
-of the process was accompanied by the creation of a core file
-containing an image of the process when the signal was received.
-.It Fn WSTOPSIG status
-If
-.Fn WIFSTOPPED status
-is true, evaluates to the number of the signal
-that caused the process to stop.
-.El
-.Sh NOTES
-See
-.Xr sigaction 2
-for a list of termination signals.
-A status of 0 indicates normal termination.
-.Pp
-If a parent process terminates without
-waiting for all of its child processes to terminate,
-the remaining child processes are re-assigned to the reaper
-of the exiting process as the parent, see
-.Xr procctl 2
-.Dv PROC_REAP_ACQUIRE .
-If no specific reaper was assigned, the process with ID 1, the init process,
-becomes the parent of the orphaned children by default.
-.Pp
-If a signal is caught while any of the
-.Fn wait
-calls are pending,
-the call may be interrupted or restarted when the signal-catching routine
-returns,
-depending on the options in effect for the signal;
-see discussion of
-.Dv SA_RESTART
-in
-.Xr sigaction 2 .
-.Pp
-The implementation queues one
-.Dv SIGCHLD
-signal for each child process whose
-status has changed; if
-.Fn wait
-returns because the status of a child process is available, the pending
-SIGCHLD signal associated with the process ID of the child process will
-be discarded.
-Any other pending
-.Dv SIGCHLD
-signals remain pending.
-.Pp
-If
-.Dv SIGCHLD
-is blocked and
-.Fn wait
-returns because the status of a child process is available, the pending
-.Dv SIGCHLD
-signal will be cleared unless another status of the child process
-is available.
-.Sh RETURN VALUES
-If
-.Fn wait
-returns due to a stopped, continued,
-or terminated child process, the process ID of the child
-is returned to the calling process.
-Otherwise, a value of \-1
-is returned and
-.Va errno
-is set to indicate the error.
-.Pp
-If
-.Fn wait6 ,
-.Fn wait4 ,
-.Fn wait3 ,
-or
-.Fn waitpid
-returns due to a stopped, continued,
-or terminated child process, the process ID of the child
-is returned to the calling process.
-If there are no children not previously awaited,
--1 is returned with
-.Va errno
-set to
-.Er ECHILD .
-Otherwise, if
-.Dv WNOHANG
-is specified and there are
-no stopped, continued or exited children,
-0 is returned.
-If an error is detected or a caught signal aborts the call,
-a value of -1
-is returned and
-.Va errno
-is set to indicate the error.
-.Pp
-If
-.Fn waitid
-returns because one or more processes have a state change to report,
-0 is returned.
-If an error is detected,
-a value of -1
-is returned and
-.Va errno
-is set to indicate the error.
-If
-.Dv WNOHANG
-is specified and there are
-no stopped, continued or exited children,
-0 is returned.
-The
-.Fa si_signo
-and
-.Fa si_pid
-fields of
-.Fa infop
-must be checked against zero to determine if a process reported status.
-.Pp
-The
-.Fn wait
-family of functions will not return a child process created with
-.Xr pdfork 2
-unless specifically directed to do so by specifying its process ID.
-.Sh ERRORS
-The
-.Fn wait
-function
-will fail and return immediately if:
-.Bl -tag -width Er
-.It Bq Er ECHILD
-The calling process has no existing unwaited-for
-child processes.
-.It Bq Er ECHILD
-No status from the terminated child process is available
-because the calling process has asked the system to discard
-such status by ignoring the signal
-.Dv SIGCHLD
-or setting the flag
-.Dv SA_NOCLDWAIT
-for that signal.
-.It Bq Er EFAULT
-The
-.Fa status
-or
-.Fa rusage
-argument points to an illegal address.
-(May not be detected before exit of a child process.)
-.It Bq Er EINTR
-The call was interrupted by a caught signal,
-or the signal did not have the
-.Dv SA_RESTART
-flag set.
-.It Bq Er EINVAL
-An invalid value was specified for
-.Fa options ,
-or
-.Fa idtype
-and
-.Fa id
-do not specify a valid set of processes.
-.El
-.Sh SEE ALSO
-.Xr _exit 2 ,
-.Xr procctl 2 ,
-.Xr ptrace 2 ,
-.Xr sigaction 2 ,
-.Xr exit 3 ,
-.Xr siginfo 3
-.Sh STANDARDS
-The
-.Fn wait ,
-.Fn waitpid ,
-and
-.Fn waitid
-functions are defined by POSIX;
-.Fn wait6 ,
-.Fn wait4 ,
-and
-.Fn wait3
-are not specified by POSIX.
-The
-.Fn WCOREDUMP
-macro
-is an extension to the POSIX interface.
-.Pp
-The ability to use the
-.Dv WNOWAIT
-flag with
-.Fn waitpid
-is an extension;
-.Tn POSIX
-only permits this flag with
-.Fn waitid .
-.Sh HISTORY
-The
-.Fn wait
-function appeared in
-.At v1 .
diff --git a/lib/libc/sys/wait.c b/lib/libc/sys/wait.c
new file mode 100644
index 000000000000..6678ecc522ba
--- /dev/null
+++ b/lib/libc/sys/wait.c
@@ -0,0 +1,50 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1988, 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.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <sys/resource.h>
+#include "un-namespace.h"
+
+#include "libc_private.h"
+
+pid_t __wait(int *);
+
+pid_t
+__wait(int *istat)
+{
+ return (INTERPOS_SYS(wait4, WAIT_ANY, istat, 0, NULL));
+}
+
+__weak_reference(__wait, wait);
+__weak_reference(__wait, _wait);
diff --git a/lib/libc/sys/wait3.c b/lib/libc/sys/wait3.c
new file mode 100644
index 000000000000..4e98ccff5227
--- /dev/null
+++ b/lib/libc/sys/wait3.c
@@ -0,0 +1,49 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1988, 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.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <sys/resource.h>
+#include "un-namespace.h"
+
+#include "libc_private.h"
+
+pid_t __wait3(int *, int, struct rusage *);
+
+pid_t
+__wait3(int *istat, int options, struct rusage *rup)
+{
+ return (INTERPOS_SYS(wait4, WAIT_ANY, istat, options, rup));
+}
+
+__weak_reference(__wait3, wait3);
diff --git a/lib/libc/sys/wait4.c b/lib/libc/sys/wait4.c
index 9efabec529d7..57b0071ef87f 100644
--- a/lib/libc/sys/wait4.c
+++ b/lib/libc/sys/wait4.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "libc_private.h"
@@ -40,7 +39,5 @@ __weak_reference(__sys_wait4, __wait4);
pid_t
wait4(pid_t pid, int *status, int options, struct rusage *ru)
{
-
- return (((pid_t (*)(pid_t, int *, int, struct rusage *))
- __libc_interposing[INTERPOS_wait4])(pid, status, options, ru));
+ return (INTERPOS_SYS(wait4, pid, status, options, ru));
}
diff --git a/lib/libc/sys/wait6.c b/lib/libc/sys/wait6.c
index 1bba04200e69..118a7ef6b99e 100644
--- a/lib/libc/sys/wait6.c
+++ b/lib/libc/sys/wait6.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
@@ -42,8 +41,5 @@ pid_t
wait6(idtype_t idtype, id_t id, int *status, int options, struct __wrusage *ru,
siginfo_t *infop)
{
-
- return (((pid_t (*)(idtype_t, id_t, int *, int, struct __wrusage *,
- siginfo_t *))__libc_interposing[INTERPOS_wait6])(idtype, id,
- status, options, ru, infop));
+ return (INTERPOS_SYS(wait6, idtype, id, status, options, ru, infop));
}
diff --git a/lib/libc/sys/waitid.c b/lib/libc/sys/waitid.c
new file mode 100644
index 000000000000..334f25e99bb6
--- /dev/null
+++ b/lib/libc/sys/waitid.c
@@ -0,0 +1,67 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012 Jukka A. Ukkonen
+ * All rights reserved.
+ *
+ * This software was developed by Jukka Ukkonen for FreeBSD.
+ *
+ * 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.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stddef.h>
+#include <string.h>
+#include <signal.h>
+#include <errno.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+
+int __waitid(idtype_t, id_t, siginfo_t *, int);
+
+int
+__waitid(idtype_t idtype, id_t id, siginfo_t *info, int flags)
+{
+ int status;
+ pid_t ret;
+
+ ret = INTERPOS_SYS(wait6, idtype, id, &status, flags, NULL, info);
+
+ /*
+ * According to SUSv4, waitid() shall not return a PID when a
+ * process is found, but only 0. If a process was actually
+ * found, siginfo_t fields si_signo and si_pid will be
+ * non-zero. In case WNOHANG was set in the flags and no
+ * process was found those fields are set to zero using
+ * memset() below.
+ */
+ if (ret == 0 && info != NULL)
+ memset(info, 0, sizeof(*info));
+ else if (ret > 0)
+ ret = 0;
+ return (ret);
+}
+
+__weak_reference(__waitid, waitid);
+__weak_reference(__waitid, _waitid);
diff --git a/lib/libc/sys/waitpid.c b/lib/libc/sys/waitpid.c
new file mode 100644
index 000000000000..d8fdcec23a1c
--- /dev/null
+++ b/lib/libc/sys/waitpid.c
@@ -0,0 +1,50 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1988, 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.
+ */
+
+#include "namespace.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <sys/resource.h>
+#include "un-namespace.h"
+
+#include "libc_private.h"
+
+pid_t __waitpid(pid_t, int *, int);
+
+pid_t
+__waitpid(pid_t pid, int *istat, int options)
+{
+ return (INTERPOS_SYS(wait4, pid, istat, options, NULL));
+}
+
+__weak_reference(__waitpid, waitpid);
+__weak_reference(__waitpid, _waitpid);
diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2
deleted file mode 100644
index ce70947c5094..000000000000
--- a/lib/libc/sys/write.2
+++ /dev/null
@@ -1,313 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)write.2 8.5 (Berkeley) 4/2/94
-.\"
-.Dd February 11, 2021
-.Dt WRITE 2
-.Os
-.Sh NAME
-.Nm write ,
-.Nm writev ,
-.Nm pwrite ,
-.Nm pwritev
-.Nd write output
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In unistd.h
-.Ft ssize_t
-.Fn write "int fd" "const void *buf" "size_t nbytes"
-.Ft ssize_t
-.Fn pwrite "int fd" "const void *buf" "size_t nbytes" "off_t offset"
-.In sys/uio.h
-.Ft ssize_t
-.Fn writev "int fd" "const struct iovec *iov" "int iovcnt"
-.Ft ssize_t
-.Fn pwritev "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset"
-.Sh DESCRIPTION
-The
-.Fn write
-system call
-attempts to write
-.Fa nbytes
-of data to the object referenced by the descriptor
-.Fa fd
-from the buffer pointed to by
-.Fa buf .
-The
-.Fn writev
-system call
-performs the same action, but gathers the output data
-from the
-.Fa iovcnt
-buffers specified by the members of the
-.Fa iov
-array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
-The
-.Fn pwrite
-and
-.Fn pwritev
-system calls
-perform the same functions, but write to the specified position in
-the file without modifying the file pointer.
-.Pp
-For
-.Fn writev
-and
-.Fn pwritev ,
-the
-.Fa iovec
-structure is defined as:
-.Pp
-.Bd -literal -offset indent -compact
-struct iovec {
- void *iov_base; /* Base address. */
- size_t iov_len; /* Length. */
-};
-.Ed
-.Pp
-Each
-.Fa iovec
-entry specifies the base address and length of an area
-in memory from which data should be written.
-The
-.Fn writev
-system call
-will always write a complete area before proceeding
-to the next.
-.Pp
-On objects capable of seeking, the
-.Fn write
-starts at a position
-given by the pointer associated with
-.Fa fd ,
-see
-.Xr lseek 2 .
-Upon return from
-.Fn write ,
-the pointer is incremented by the number of bytes which were written.
-.Pp
-Objects that are not capable of seeking always write from the current
-position.
-The value of the pointer associated with such an object
-is undefined.
-.Pp
-If the real user is not the super-user, then
-.Fn write
-clears the set-user-id bit on a file.
-This prevents penetration of system security
-by a user who
-.Dq captures
-a writable set-user-id file
-owned by the super-user.
-.Pp
-When using non-blocking I/O on objects such as sockets that are subject
-to flow control,
-.Fn write
-and
-.Fn writev
-may write fewer bytes than requested;
-the return value must be noted,
-and the remainder of the operation should be retried when possible.
-.Sh RETURN VALUES
-Upon successful completion the number of bytes which were written
-is returned.
-Otherwise a -1 is returned and the global variable
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-The
-.Fn write ,
-.Fn writev ,
-.Fn pwrite
-and
-.Fn pwritev
-system calls
-will fail and the file pointer will remain unchanged if:
-.Bl -tag -width Er
-.It Bq Er EBADF
-The
-.Fa fd
-argument
-is not a valid descriptor open for writing.
-.It Bq Er EPIPE
-An attempt is made to write to a pipe that is not open
-for reading by any process.
-.It Bq Er EPIPE
-An attempt is made to write to a socket of type
-.Dv SOCK_STREAM
-that is not connected to a peer socket.
-.It Bq Er EFBIG
-An attempt was made to write a file that exceeds the process's
-file size limit or the maximum file size.
-.It Bq Er EFAULT
-Part of
-.Fa iov
-or data to be written to the file
-points outside the process's allocated address space.
-.It Bq Er EINVAL
-The pointer associated with
-.Fa fd
-was negative.
-.It Bq Er ENOSPC
-There is no free space remaining on the file system
-containing the file.
-.It Bq Er EDQUOT
-The user's quota of disk blocks on the file system
-containing the file has been exhausted.
-.It Bq Er EIO
-An I/O error occurred while reading from or writing to the file system.
-.It Bq Er EINTR
-A signal interrupted the write before it could be completed.
-.It Bq Er EAGAIN
-The file was marked for non-blocking I/O,
-and no data could be written immediately.
-.It Bq Er EROFS
-An attempt was made to write over a disk label area at the beginning
-of a slice.
-Use
-.Xr disklabel 8
-.Fl W
-to enable writing on the disk label area.
-.It Bq Er EINVAL
-The value
-.Fa nbytes
-is greater than
-.Dv SSIZE_MAX
-(or greater than
-.Dv INT_MAX ,
-if the sysctl
-.Va debug.iosize_max_clamp
-is non-zero).
-.It Bq Er EINTEGRITY
-The backing store for
-.Fa fd
-detected corrupted data while reading.
-(For example, writing a partial filesystem block may require first reading
-the existing block which may trigger this error.)
-.El
-.Pp
-In addition,
-.Fn writev
-and
-.Fn pwritev
-may return one of the following errors:
-.Bl -tag -width Er
-.It Bq Er EDESTADDRREQ
-The destination is no longer available when writing to a
-.Ux
-domain datagram socket on which
-.Xr connect 2
-had been used to set a destination address.
-.It Bq Er EINVAL
-The
-.Fa iovcnt
-argument
-was less than or equal to 0, or greater than
-.Dv IOV_MAX .
-.It Bq Er EINVAL
-One of the
-.Fa iov_len
-values in the
-.Fa iov
-array was negative.
-.It Bq Er EINVAL
-The sum of the
-.Fa iov_len
-values is greater than
-.Dv SSIZE_MAX
-(or greater than
-.Dv INT_MAX ,
-if the sysctl
-.Va debug.iosize_max_clamp
-is non-zero).
-.It Bq Er ENOBUFS
-The mbuf pool has been completely exhausted when writing to a socket.
-.El
-.Pp
-The
-.Fn pwrite
-and
-.Fn pwritev
-system calls may also return the following errors:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa offset
-value was negative.
-.It Bq Er ESPIPE
-The file descriptor is associated with a pipe, socket, or FIFO.
-.El
-.Sh SEE ALSO
-.Xr fcntl 2 ,
-.Xr lseek 2 ,
-.Xr open 2 ,
-.Xr pipe 2 ,
-.Xr select 2
-.Sh STANDARDS
-The
-.Fn write
-system call is expected to conform to
-.St -p1003.1-90 .
-The
-.Fn writev
-and
-.Fn pwrite
-system calls are expected to conform to
-.St -xpg4.2 .
-.Sh HISTORY
-The
-.Fn pwritev
-system call appeared in
-.Fx 6.0 .
-The
-.Fn pwrite
-function appeared in
-.At V.4 .
-The
-.Fn writev
-system call appeared in
-.Bx 4.2 .
-The
-.Fn write
-function appeared in
-.At v1 .
-.Sh BUGS
-The
-.Fn pwrite
-system call appends the file without changing the file offset if
-.Dv O_APPEND
-is set, contrary to
-.St -p1003.1-2008
-where
-.Fn pwrite
-writes into
-.Fa offset
-regardless of whether
-.Dv O_APPEND
-is set.
diff --git a/lib/libc/sys/write.c b/lib/libc/sys/write.c
index 461975cd72fb..5880856b8af8 100644
--- a/lib/libc/sys/write.c
+++ b/lib/libc/sys/write.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <unistd.h>
@@ -41,7 +40,5 @@ __weak_reference(__sys_write, __write);
ssize_t
write(int fd, const void *buf, size_t nbytes)
{
-
- return (((ssize_t (*)(int, const void *, size_t))
- __libc_interposing[INTERPOS_write])(fd, buf, nbytes));
+ return (INTERPOS_SYS(write, fd, buf, nbytes));
}
diff --git a/lib/libc/sys/writev.c b/lib/libc/sys/writev.c
index 4d91d4dec95a..9a32cb603ab8 100644
--- a/lib/libc/sys/writev.c
+++ b/lib/libc/sys/writev.c
@@ -29,7 +29,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/uio.h>
@@ -42,7 +41,5 @@ __weak_reference(__sys_writev, __writev);
ssize_t
writev(int fd, const struct iovec *iov, int iovcnt)
{
-
- return (((ssize_t (*)(int, const struct iovec *, int))
- __libc_interposing[INTERPOS_writev])(fd, iov, iovcnt));
+ return (INTERPOS_SYS(writev, fd, iov, iovcnt));
}
diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile
index 7b262ea646fb..975c895770ee 100644
--- a/lib/libc/tests/Makefile
+++ b/lib/libc/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
SUBDIR= tls_dso
@@ -13,9 +12,11 @@ TESTS_SUBDIRS+= nss
TESTS_SUBDIRS+= regex
TESTS_SUBDIRS+= resolv
TESTS_SUBDIRS+= rpc
+TESTS_SUBDIRS+= secure
TESTS_SUBDIRS+= setjmp
TESTS_SUBDIRS+= stdio
TESTS_SUBDIRS+= stdlib
+TESTS_SUBDIRS+= stdtime
TESTS_SUBDIRS+= string
TESTS_SUBDIRS+= sys
TESTS_SUBDIRS+= termios
diff --git a/lib/libc/tests/Makefile.netbsd-tests b/lib/libc/tests/Makefile.netbsd-tests
index 98ff48bde5c8..43710d39aca2 100644
--- a/lib/libc/tests/Makefile.netbsd-tests
+++ b/lib/libc/tests/Makefile.netbsd-tests
@@ -1,4 +1,3 @@
-
TESTSRC:= ${SRCTOP}/contrib/netbsd-tests/${RELDIR:C/libc\/tests/libc/}
TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/}
diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile
index d71ddad1f5f4..c1d8b01c1abd 100644
--- a/lib/libc/tests/c063/Makefile
+++ b/lib/libc/tests/c063/Makefile
@@ -1,4 +1,3 @@
-
NETBSD_ATF_TESTS_C= faccessat_test
NETBSD_ATF_TESTS_C+= fchmodat_test
NETBSD_ATF_TESTS_C+= fchownat_test
diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile
index 617295b8b145..771569183584 100644
--- a/lib/libc/tests/db/Makefile
+++ b/lib/libc/tests/db/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
BINDIR= ${TESTSDIR}
@@ -8,6 +7,10 @@ PROGS+= h_lfsr
${PACKAGE}FILES+= README
+ATF_TESTS_C+= dbm_open_test
+ATF_TESTS_C+= dbm_perm_test
+ATF_TESTS_C+= dbm_nextkey_test
+
NETBSD_ATF_TESTS_C+= db_hash_seq_test
NETBSD_ATF_TESTS_SH+= db_test
ATF_TESTS_SH_SED_db_test= -e 's,/bin/csh,/bin/cat,g'
diff --git a/lib/libc/tests/db/dbm_nextkey_test.c b/lib/libc/tests/db/dbm_nextkey_test.c
new file mode 100644
index 000000000000..67b745efb196
--- /dev/null
+++ b/lib/libc/tests/db/dbm_nextkey_test.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <fcntl.h>
+#include <ndbm.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+static const char *path = "tmp";
+static const char *dbname = "tmp.db";
+
+ATF_TC(dbm_nextkey_test);
+ATF_TC_HEAD(dbm_nextkey_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Check that dbm_nextkey always returns NULL after reaching the end of the database");
+}
+
+ATF_TC_BODY(dbm_nextkey_test, tc)
+{
+ DBM *db;
+ datum key, data;
+
+ data.dptr = "bar";
+ data.dsize = strlen("bar");
+ key.dptr = "foo";
+ key.dsize = strlen("foo");
+
+ db = dbm_open(path, O_RDWR | O_CREAT, 0755);
+ ATF_CHECK(db != NULL);
+ ATF_REQUIRE(atf_utils_file_exists(dbname));
+ ATF_REQUIRE(dbm_store(db, key, data, DBM_INSERT) != -1);
+
+ key = dbm_firstkey(db);
+ ATF_REQUIRE(key.dptr != NULL);
+ key = dbm_nextkey(db);
+ ATF_REQUIRE(key.dptr == NULL);
+ key = dbm_nextkey(db);
+ ATF_REQUIRE(key.dptr == NULL);
+
+ dbm_close(db);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, dbm_nextkey_test);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/db/dbm_open_test.c b/lib/libc/tests/db/dbm_open_test.c
new file mode 100644
index 000000000000..8a3e888bf72c
--- /dev/null
+++ b/lib/libc/tests/db/dbm_open_test.c
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <fcntl.h>
+#include <ndbm.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+static const char *path = "tmp";
+static const char *dbname = "tmp.db";
+
+ATF_TC(dbm_open_missing_test);
+ATF_TC_HEAD(dbm_open_missing_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test dbm_open when creating a new database");
+}
+
+ATF_TC_BODY(dbm_open_missing_test, tc)
+{
+
+ /*
+ * POSIX.1 specifies that a missing database file should
+ * always get created if O_CREAT is present, except when
+ * O_EXCL is specified as well.
+ */
+ ATF_CHECK(dbm_open(path, O_RDONLY, 0755) == NULL);
+ ATF_REQUIRE(!atf_utils_file_exists(dbname));
+ ATF_CHECK(dbm_open(path, O_RDONLY | O_CREAT, 0755) != NULL);
+ ATF_REQUIRE(atf_utils_file_exists(dbname));
+ ATF_CHECK(dbm_open(path, O_RDONLY | O_CREAT | O_EXCL, 0755) == NULL);
+}
+
+ATF_TC_WITHOUT_HEAD(dbm_open_wronly_test);
+ATF_TC_BODY(dbm_open_wronly_test, tc)
+{
+ ATF_CHECK(dbm_open(path, O_WRONLY, 0755) == NULL);
+ ATF_REQUIRE(!atf_utils_file_exists(dbname));
+ ATF_CHECK(dbm_open(path, O_WRONLY | O_CREAT, 0755) != NULL);
+ ATF_REQUIRE(atf_utils_file_exists(dbname));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, dbm_open_missing_test);
+ ATF_TP_ADD_TC(tp, dbm_open_wronly_test);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/db/dbm_perm_test.c b/lib/libc/tests/db/dbm_perm_test.c
new file mode 100644
index 000000000000..c07210292014
--- /dev/null
+++ b/lib/libc/tests/db/dbm_perm_test.c
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <ndbm.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+static const char *path = "tmp";
+static const char *dbname = "tmp.db";
+
+static void
+create_db(void)
+{
+ DB *db;
+ datum data, key;
+
+ data.dptr = "bar";
+ data.dsize = strlen("bar");
+ key.dptr = "foo";
+ key.dsize = strlen("foo");
+
+ db = dbm_open(path, O_RDWR | O_CREAT, 0755);
+ ATF_CHECK(db != NULL);
+ ATF_REQUIRE(atf_utils_file_exists(dbname));
+ ATF_REQUIRE(dbm_store(db, key, data, DBM_INSERT) != -1);
+ dbm_close(db);
+}
+
+ATF_TC_WITHOUT_HEAD(dbm_rdonly_test);
+ATF_TC_BODY(dbm_rdonly_test, tc)
+{
+ DB *db;
+ datum data, key;
+
+ bzero(&data, sizeof(data));
+ key.dptr = "foo";
+ key.dsize = strlen("foo");
+ create_db();
+
+ db = dbm_open(path, O_RDONLY, 0755);
+ data = dbm_fetch(db, key);
+ ATF_REQUIRE(data.dptr != NULL);
+ ATF_REQUIRE(strncmp((const char*)data.dptr, "bar", data.dsize) == 0);
+ ATF_REQUIRE(dbm_store(db, key, data, DBM_REPLACE) == -1);
+ ATF_REQUIRE(errno == EPERM);
+}
+
+ATF_TC_WITHOUT_HEAD(dbm_wronly_test);
+ATF_TC_BODY(dbm_wronly_test, tc)
+{
+ DB *db;
+ datum data, key;
+
+ key.dptr = "foo";
+ key.dsize = strlen("foo");
+ data.dptr = "baz";
+ data.dsize = strlen("baz");
+ create_db();
+
+ db = dbm_open(path, O_WRONLY, 0755);
+ data = dbm_fetch(db, key);
+ ATF_REQUIRE(data.dptr == NULL);
+ ATF_REQUIRE(errno == EPERM);
+ ATF_REQUIRE(dbm_store(db, key, data, DBM_REPLACE) != -1);
+}
+
+ATF_TC_WITHOUT_HEAD(dbm_rdwr_test);
+ATF_TC_BODY(dbm_rdwr_test, tc)
+{
+ DB *db;
+ datum data, key;
+
+ key.dptr = "foo";
+ key.dsize = strlen("foo");
+ create_db();
+
+ db = dbm_open(path, O_RDWR, 0755);
+ data = dbm_fetch(db, key);
+ ATF_REQUIRE(data.dptr != NULL);
+ data.dptr = "baz";
+ data.dsize = strlen("baz");
+ ATF_REQUIRE(dbm_store(db, key, data, DBM_REPLACE) != -1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, dbm_rdonly_test);
+ ATF_TP_ADD_TC(tp, dbm_wronly_test);
+ ATF_TP_ADD_TC(tp, dbm_rdwr_test);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile
index edffdc98b35e..8c2151105209 100644
--- a/lib/libc/tests/gen/Makefile
+++ b/lib/libc/tests/gen/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
ATF_TESTS_C+= arc4random_test
@@ -8,14 +7,28 @@ ATF_TESTS_C+= fmtcheck2_test
ATF_TESTS_C+= fmtmsg_test
ATF_TESTS_C+= fnmatch2_test
ATF_TESTS_C+= fpclassify2_test
+.if ${COMPILER_FEATURES:Mblocks}
+ATF_TESTS_C+= fts_blocks_test
+.endif
+ATF_TESTS_C+= fts_misc_test
+ATF_TESTS_C+= fts_options_test
ATF_TESTS_C+= ftw_test
ATF_TESTS_C+= getentropy_test
ATF_TESTS_C+= getmntinfo_test
ATF_TESTS_C+= glob2_test
+.if ${COMPILER_FEATURES:Mblocks}
+ATF_TESTS_C+= glob_blocks_test
+.endif
ATF_TESTS_C+= makecontext_test
+ATF_TESTS_C+= opendir_test
ATF_TESTS_C+= popen_test
ATF_TESTS_C+= posix_spawn_test
ATF_TESTS_C+= realpath2_test
+ATF_TESTS_C+= scandir_test
+.if ${COMPILER_FEATURES:Mblocks}
+ATF_TESTS_C+= scandir_blocks_test
+.endif
+ATF_TESTS_C+= sig2str_test
ATF_TESTS_C+= sigsetops_test
ATF_TESTS_C+= wordexp_test
@@ -93,6 +106,20 @@ TEST_METADATA.setdomainname_test+= is_exclusive=true
TESTS_SUBDIRS= execve
TESTS_SUBDIRS+= posix_spawn
+# Tests that require address sanitizer
+.if ${COMPILER_FEATURES:Masan}
+.for t in scandir_test realpath2_test
+CFLAGS.${t}.c+= -fsanitize=address
+LDFLAGS.${t}+= -fsanitize=address
+.endfor
+.endif
+
+# Tests that require blocks support
+.for t in fts_blocks_test glob_blocks_test scandir_blocks_test
+CFLAGS.${t}.c+= -fblocks
+LIBADD.${t}+= BlocksRuntime
+.endfor
+
# The old testcase name
TEST_FNMATCH= test-fnmatch
CLEANFILES+= ${GEN_SH_CASE_TESTCASES}
diff --git a/lib/libc/tests/gen/arc4random_test.c b/lib/libc/tests/gen/arc4random_test.c
index c3ec207077d3..79139f29f8fa 100644
--- a/lib/libc/tests/gen/arc4random_test.c
+++ b/lib/libc/tests/gen/arc4random_test.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2011 David Schultz
+ * Copyright (c) 2024 Robert Clausecker <fuz@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,12 +25,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -78,10 +79,34 @@ ATF_TC_BODY(test_arc4random, tc)
"sequences are the same");
}
+/*
+ * Test whether arc4random_uniform() returns a number below the given threshold.
+ * Test with various thresholds.
+ */
+ATF_TC_WITHOUT_HEAD(test_arc4random_uniform);
+ATF_TC_BODY(test_arc4random_uniform, tc)
+{
+ size_t i, j;
+ static const uint32_t thresholds[] = {
+ 1, 2, 3, 4, 5, 10, 100, 1000,
+ INT32_MAX, (uint32_t)INT32_MAX + 1,
+ UINT32_MAX - 1000000000, UINT32_MAX - 1000000, UINT32_MAX - 1, 0
+ };
+
+ for (i = 0; thresholds[i] != 0; i++)
+ for (j = 0; j < 10000; j++)
+ ATF_CHECK(arc4random_uniform(thresholds[i]) < thresholds[i]);
+
+ /* for a threshold of zero, just check that we get zero every time */
+ for (j = 0; j < 1000; j++)
+ ATF_CHECK_EQ(0, arc4random_uniform(0));
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, test_arc4random);
+ ATF_TP_ADD_TC(tp, test_arc4random_uniform);
return (atf_no_error());
}
diff --git a/lib/libc/tests/gen/dir2_test.c b/lib/libc/tests/gen/dir2_test.c
index 5c9604856f11..4ec5a1759d06 100644
--- a/lib/libc/tests/gen/dir2_test.c
+++ b/lib/libc/tests/gen/dir2_test.c
@@ -31,7 +31,6 @@
* opendir, readdir, seekdir, telldir, closedir, etc
*/
-#include <sys/cdefs.h>
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
diff --git a/lib/libc/tests/gen/dlopen_empty_test.c b/lib/libc/tests/gen/dlopen_empty_test.c
index 1b48fd9d8d33..6fb3bf8d8343 100644
--- a/lib/libc/tests/gen/dlopen_empty_test.c
+++ b/lib/libc/tests/gen/dlopen_empty_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include <errno.h>
diff --git a/lib/libc/tests/gen/execve/Makefile b/lib/libc/tests/gen/execve/Makefile
index 5f563dc8e3cd..7bf911d1cb47 100644
--- a/lib/libc/tests/gen/execve/Makefile
+++ b/lib/libc/tests/gen/execve/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
NETBSD_ATF_TESTS_C= execve_test
diff --git a/lib/libc/tests/gen/fmtcheck_test.c b/lib/libc/tests/gen/fmtcheck_test.c
index 0df30cee96f0..27a12217e81e 100644
--- a/lib/libc/tests/gen/fmtcheck_test.c
+++ b/lib/libc/tests/gen/fmtcheck_test.c
@@ -28,7 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <err.h>
#include <stdio.h>
diff --git a/lib/libc/tests/gen/fmtmsg_test.c b/lib/libc/tests/gen/fmtmsg_test.c
index 7ab6a335c8e2..30a5156cdcc8 100644
--- a/lib/libc/tests/gen/fmtmsg_test.c
+++ b/lib/libc/tests/gen/fmtmsg_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <err.h>
diff --git a/lib/libc/tests/gen/fnmatch_test.c b/lib/libc/tests/gen/fnmatch_test.c
index abb7308f021b..0ff7400a4a4f 100644
--- a/lib/libc/tests/gen/fnmatch_test.c
+++ b/lib/libc/tests/gen/fnmatch_test.c
@@ -24,9 +24,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -177,10 +177,90 @@ ATF_TC_BODY(fnmatch_test, tc)
}
+ATF_TC(fnmatch_characterclass);
+ATF_TC_HEAD(fnmatch_characterclass, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test fnmatch with character classes");
+}
+
+ATF_TC_BODY(fnmatch_characterclass, tc)
+{
+ ATF_CHECK(fnmatch("[[:alnum:]]", "a", 0) == 0);
+ ATF_CHECK(fnmatch("[[:cntrl:]]", "\a", 0) == 0);
+ ATF_CHECK(fnmatch("[[:lower:]]", "a", 0) == 0);
+ ATF_CHECK(fnmatch("[[:space:]]", " ", 0) == 0);
+ ATF_CHECK(fnmatch("[[:alpha:]]", "a", 0) == 0);
+ ATF_CHECK(fnmatch("[[:digit:]]", "0", 0) == 0);
+ ATF_CHECK(fnmatch("[[:print:]]", "a", 0) == 0);
+ ATF_CHECK(fnmatch("[[:upper:]]", "A", 0) == 0);
+ ATF_CHECK(fnmatch("[[:blank:]]", " ", 0) == 0);
+ ATF_CHECK(fnmatch("[[:graph:]]", "a", 0) == 0);
+ ATF_CHECK(fnmatch("[[:punct:]]", ".", 0) == 0);
+ ATF_CHECK(fnmatch("[[:xdigit:]]", "f", 0) == 0);
+
+ /*
+ * POSIX.1, section 9.3.5. states that '[:' and ':]'
+ * should be interpreted as character classes symbol only
+ * when part of a bracket expression.
+ */
+ ATF_CHECK(fnmatch("[:alnum:]", "a", 0) == 0);
+ ATF_CHECK(fnmatch("[:alnum:]", ":", 0) == 0);
+ ATF_CHECK(fnmatch("[:alnum:]", "1", 0) != 0);
+}
+
+ATF_TC(fnmatch_collsym);
+ATF_TC_HEAD(fnmatch_collsym, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test fnmatch with collating symbols");
+}
+
+ATF_TC_BODY(fnmatch_collsym, tc)
+{
+ setlocale(LC_ALL, "cs_CZ.UTF-8");
+ ATF_CHECK(fnmatch("[ch]", "ch", 0) != 0);
+ ATF_CHECK(fnmatch("[[.ch.]]", "ch", 0) == 0);
+ ATF_CHECK(fnmatch("[[.ch.]]h", "chh", 0) == 0);
+
+ /*
+ * POSIX.1, section 9.3.5. states that '[.' and '.]'
+ * should be interpreted as a collating symbol only
+ * when part of a bracket expression.
+ */
+ ATF_CHECK(fnmatch("[.ch.]", "c", 0) == 0);
+ ATF_CHECK(fnmatch("[.ch.]", "h", 0) == 0);
+ ATF_CHECK(fnmatch("[.ch.]", ".", 0) == 0);
+}
+
+ATF_TC(fnmatch_equivclass);
+ATF_TC_HEAD(fnmatch_equivclass, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test fnmatch with equivalence classes");
+}
+
+ATF_TC_BODY(fnmatch_equivclass, tc)
+{
+ setlocale(LC_ALL, "en_US.UTF-8");
+ ATF_CHECK(fnmatch("[[=a=]]b", "ab", 0) == 0);
+ ATF_CHECK(fnmatch("[[=a=]]b", "Ab", 0) == 0);
+ ATF_CHECK(fnmatch("[[=à=]]b", "ab", 0) == 0);
+ ATF_CHECK(fnmatch("[[=a=]]b", "àb", 0) == 0);
+
+ /*
+ * POSIX.1, section 9.3.5. states that '[=' and '=]'
+ * should be interpreted as an equivalence class only
+ * when part of a bracket expression.
+ */
+ ATF_CHECK(fnmatch("[=a=]b", "=b", 0) == 0);
+ ATF_CHECK(fnmatch("[=a=]b", "ab", 0) == 0);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, fnmatch_test);
+ ATF_TP_ADD_TC(tp, fnmatch_collsym);
+ ATF_TP_ADD_TC(tp, fnmatch_characterclass);
+ ATF_TP_ADD_TC(tp, fnmatch_equivclass);
return (atf_no_error());
}
diff --git a/lib/libc/tests/gen/fnmatch_testcases.h b/lib/libc/tests/gen/fnmatch_testcases.h
index d205605826cf..196160a4801b 100644
--- a/lib/libc/tests/gen/fnmatch_testcases.h
+++ b/lib/libc/tests/gen/fnmatch_testcases.h
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fnmatch.h>
struct testcase {
diff --git a/lib/libc/tests/gen/fts_blocks_test.c b/lib/libc/tests/gen/fts_blocks_test.c
new file mode 100644
index 000000000000..f020dd8dea45
--- /dev/null
+++ b/lib/libc/tests/gen/fts_blocks_test.c
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <fts.h>
+
+#include <atf-c.h>
+
+/*
+ * Create two directories with three files each in lexicographical order,
+ * then call FTS with a sort block that sorts in reverse lexicographical
+ * order. This has the least chance of getting a false positive due to
+ * differing file system semantics. UFS will return the files in the
+ * order they were created while ZFS will sort them lexicographically; in
+ * both cases, the order we expect is the reverse.
+ */
+ATF_TC(fts_blocks_test);
+ATF_TC_HEAD(fts_blocks_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test FTS with a block in lieu of a comparison function");
+}
+ATF_TC_BODY(fts_blocks_test, tc)
+{
+ char *args[] = {
+ "bar", "foo", NULL
+ };
+ char *paths[] = {
+ "foo", "z", "y", "x", "foo",
+ "bar", "c", "b", "a", "bar",
+ NULL
+ };
+ char **expect = paths;
+ FTS *fts;
+ FTSENT *ftse;
+
+ ATF_REQUIRE_EQ(0, mkdir("bar", 0755));
+ ATF_REQUIRE_EQ(0, close(creat("bar/a", 0644)));
+ ATF_REQUIRE_EQ(0, close(creat("bar/b", 0644)));
+ ATF_REQUIRE_EQ(0, close(creat("bar/c", 0644)));
+ ATF_REQUIRE_EQ(0, mkdir("foo", 0755));
+ ATF_REQUIRE_EQ(0, close(creat("foo/x", 0644)));
+ ATF_REQUIRE_EQ(0, close(creat("foo/y", 0644)));
+ ATF_REQUIRE_EQ(0, close(creat("foo/z", 0644)));
+ fts = fts_open_b(args, 0,
+ ^(const FTSENT * const *a, const FTSENT * const *b) {
+ return (strcmp((*b)->fts_name, (*a)->fts_name));
+ });
+ ATF_REQUIRE_MSG(fts != NULL, "fts_open_b(): %m");
+ while ((ftse = fts_read(fts)) != NULL && *expect != NULL) {
+ ATF_CHECK_STREQ(*expect, ftse->fts_name);
+ expect++;
+ }
+ ATF_CHECK_EQ(NULL, ftse);
+ ATF_CHECK_EQ(NULL, *expect);
+ ATF_REQUIRE_EQ_MSG(0, fts_close(fts), "fts_close(): %m");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, fts_blocks_test);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/fts_misc_test.c b/lib/libc/tests/gen/fts_misc_test.c
new file mode 100644
index 000000000000..91640078f63c
--- /dev/null
+++ b/lib/libc/tests/gen/fts_misc_test.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <fts.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "fts_test.h"
+
+ATF_TC(fts_unrdir);
+ATF_TC_HEAD(fts_unrdir, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "unreadable directories");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+ATF_TC_BODY(fts_unrdir, tc)
+{
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE_EQ(0, mkdir("dir/unr", 0100));
+ ATF_REQUIRE_EQ(0, mkdir("dir/unx", 0400));
+ fts_test(tc, &(struct fts_testcase){
+ (char *[]){ "dir", NULL },
+ FTS_PHYSICAL,
+ (struct fts_expect[]){
+ { FTS_D, "dir", "dir" },
+ { FTS_D, "unr", "unr" },
+ { FTS_DNR, "unr", "unr" },
+ { FTS_D, "unx", "unx" },
+ { FTS_DP, "unx", "unx" },
+ { FTS_DP, "dir", "dir" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_unrdir_nochdir);
+ATF_TC_HEAD(fts_unrdir_nochdir, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "unreadable directories (nochdir)");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+ATF_TC_BODY(fts_unrdir_nochdir, tc)
+{
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE_EQ(0, mkdir("dir/unr", 0100));
+ ATF_REQUIRE_EQ(0, mkdir("dir/unx", 0400));
+ fts_test(tc, &(struct fts_testcase){
+ (char *[]){ "dir", NULL },
+ FTS_PHYSICAL | FTS_NOCHDIR,
+ (struct fts_expect[]){
+ { FTS_D, "dir", "dir" },
+ { FTS_D, "unr", "dir/unr" },
+ { FTS_DNR, "unr", "dir/unr" },
+ { FTS_D, "unx", "dir/unx" },
+ { FTS_DP, "unx", "dir/unx" },
+ { FTS_DP, "dir", "dir" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ fts_check_debug();
+ ATF_TP_ADD_TC(tp, fts_unrdir);
+ ATF_TP_ADD_TC(tp, fts_unrdir_nochdir);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/fts_options_test.c b/lib/libc/tests/gen/fts_options_test.c
new file mode 100644
index 000000000000..fc3015138a49
--- /dev/null
+++ b/lib/libc/tests/gen/fts_options_test.c
@@ -0,0 +1,394 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <fts.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#include "fts_test.h"
+
+static char *all_paths[] = {
+ "dir",
+ "dirl",
+ "file",
+ "filel",
+ "dead",
+ "noent",
+ NULL
+};
+
+/*
+ * Prepare the files and directories we will be inspecting.
+ */
+static void
+fts_options_prepare(const struct atf_tc *tc)
+{
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE_EQ(0, close(creat("file", 0644)));
+ ATF_REQUIRE_EQ(0, close(creat("dir/file", 0644)));
+ ATF_REQUIRE_EQ(0, symlink("..", "dir/up"));
+ ATF_REQUIRE_EQ(0, symlink("dir", "dirl"));
+ ATF_REQUIRE_EQ(0, symlink("file", "filel"));
+ ATF_REQUIRE_EQ(0, symlink("noent", "dead"));
+}
+
+ATF_TC(fts_options_logical);
+ATF_TC_HEAD(fts_options_logical, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_LOGICAL");
+}
+ATF_TC_BODY(fts_options_logical, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_LOGICAL,
+ (struct fts_expect[]){
+ { FTS_DL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "file", "dir/file" },
+ { FTS_D, "up", "dir/up" },
+ { FTS_DL, "dead", "dir/up/dead" },
+ { FTS_DC, "dir", "dir/up/dir" },
+ { FTS_DC, "dirl", "dir/up/dirl" },
+ { FTS_F, "file", "dir/up/file" },
+ { FTS_F, "filel", "dir/up/filel" },
+ { FTS_DP, "up", "dir/up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_D, "dirl", "dirl" },
+ { FTS_F, "file", "dirl/file" },
+ { FTS_D, "up", "dirl/up" },
+ { FTS_DL, "dead", "dirl/up/dead" },
+ { FTS_DC, "dir", "dirl/up/dir" },
+ { FTS_DC, "dirl", "dirl/up/dirl" },
+ { FTS_F, "file", "dirl/up/file" },
+ { FTS_F, "filel", "dirl/up/filel" },
+ { FTS_DP, "up", "dirl/up" },
+ { FTS_DP, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_F, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_logical_nostat);
+ATF_TC_HEAD(fts_options_logical_nostat, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_LOGICAL | FTS_NOSTAT");
+}
+ATF_TC_BODY(fts_options_logical_nostat, tc)
+{
+ /*
+ * While FTS_LOGICAL is not documented as being incompatible with
+ * FTS_NOSTAT, and FTS does not clear FTS_NOSTAT if FTS_LOGICAL is
+ * set, FTS_LOGICAL effectively nullifies FTS_NOSTAT by overriding
+ * the follow check in fts_stat(). In theory, FTS could easily be
+ * changed to only stat links (to check what they point to) in the
+ * FTS_LOGICAL | FTS_NOSTAT case, which would produce a different
+ * result here, so keep the test around in case that ever happens.
+ */
+ atf_tc_expect_fail("FTS_LOGICAL nullifies FTS_NOSTAT");
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_LOGICAL | FTS_NOSTAT,
+ (struct fts_expect[]){
+ { FTS_DL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_NSOK, "file", "dir/file" },
+ { FTS_D, "up", "dir/up" },
+ { FTS_DL, "dead", "dir/up/dead" },
+ { FTS_DC, "dir", "dir/up/dir" },
+ { FTS_DC, "dirl", "dir/up/dirl" },
+ { FTS_NSOK, "file", "dir/up/file" },
+ { FTS_NSOK, "filel", "dir/up/filel" },
+ { FTS_DP, "up", "dir/up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_D, "dirl", "dirl" },
+ { FTS_NSOK, "file", "dirl/file" },
+ { FTS_D, "up", "dirl/up" },
+ { FTS_DL, "dead", "dirl/up/dead" },
+ { FTS_DC, "dir", "dirl/up/dir" },
+ { FTS_DC, "dirl", "dirl/up/dirl" },
+ { FTS_NSOK, "file", "dirl/up/file" },
+ { FTS_NSOK, "filel", "dirl/up/filel" },
+ { FTS_DP, "up", "dirl/up" },
+ { FTS_DP, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_F, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_logical_seedot);
+ATF_TC_HEAD(fts_options_logical_seedot, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_LOGICAL | FTS_SEEDOT");
+}
+ATF_TC_BODY(fts_options_logical_seedot, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_LOGICAL | FTS_SEEDOT,
+ (struct fts_expect[]){
+ { FTS_DL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_DOT, ".", "dir/." },
+ { FTS_DOT, "..", "dir/.." },
+ { FTS_F, "file", "dir/file" },
+ { FTS_D, "up", "dir/up" },
+ { FTS_DOT, ".", "dir/up/." },
+ { FTS_DOT, "..", "dir/up/.." },
+ { FTS_DL, "dead", "dir/up/dead" },
+ { FTS_DC, "dir", "dir/up/dir" },
+ { FTS_DC, "dirl", "dir/up/dirl" },
+ { FTS_F, "file", "dir/up/file" },
+ { FTS_F, "filel", "dir/up/filel" },
+ { FTS_DP, "up", "dir/up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_D, "dirl", "dirl" },
+ { FTS_DOT, ".", "dirl/." },
+ { FTS_DOT, "..", "dirl/.." },
+ { FTS_F, "file", "dirl/file" },
+ { FTS_D, "up", "dirl/up" },
+ { FTS_DOT, ".", "dirl/up/." },
+ { FTS_DOT, "..", "dirl/up/.." },
+ { FTS_DL, "dead", "dirl/up/dead" },
+ { FTS_DC, "dir", "dirl/up/dir" },
+ { FTS_DC, "dirl", "dirl/up/dirl" },
+ { FTS_F, "file", "dirl/up/file" },
+ { FTS_F, "filel", "dirl/up/filel" },
+ { FTS_DP, "up", "dirl/up" },
+ { FTS_DP, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_F, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical);
+ATF_TC_HEAD(fts_options_physical, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL");
+}
+ATF_TC_BODY(fts_options_physical, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL,
+ (struct fts_expect[]){
+ { FTS_SL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_SL, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical_nochdir);
+ATF_TC_HEAD(fts_options_physical_nochdir, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL | FTS_NOCHDIR");
+}
+ATF_TC_BODY(fts_options_physical_nochdir, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL | FTS_NOCHDIR,
+ (struct fts_expect[]){
+ { FTS_SL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "file", "dir/file" },
+ { FTS_SL, "up", "dir/up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_SL, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical_comfollow);
+ATF_TC_HEAD(fts_options_physical_comfollow, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL | FTS_COMFOLLOW");
+}
+ATF_TC_BODY(fts_options_physical_comfollow, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL | FTS_COMFOLLOW,
+ (struct fts_expect[]){
+ { FTS_DL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_D, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_F, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical_comfollowdir);
+ATF_TC_HEAD(fts_options_physical_comfollowdir, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL | FTS_COMFOLLOWDIR");
+}
+ATF_TC_BODY(fts_options_physical_comfollowdir, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL | FTS_COMFOLLOWDIR,
+ (struct fts_expect[]){
+ { FTS_DL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_D, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical_nostat);
+ATF_TC_HEAD(fts_options_physical_nostat, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL | FTS_NOSTAT");
+}
+ATF_TC_BODY(fts_options_physical_nostat, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL | FTS_NOSTAT,
+ (struct fts_expect[]){
+ { FTS_SL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_NSOK, "file", "file" },
+ { FTS_NSOK, "up", "up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_SL, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical_nostat_type);
+ATF_TC_HEAD(fts_options_physical_nostat_type, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL | FTS_NOSTAT_TYPE");
+}
+ATF_TC_BODY(fts_options_physical_nostat_type, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL | FTS_NOSTAT_TYPE,
+ (struct fts_expect[]){
+ { FTS_SL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_SL, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+ATF_TC(fts_options_physical_seedot);
+ATF_TC_HEAD(fts_options_physical_seedot, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "FTS_PHYSICAL | FTS_SEEDOT");
+}
+ATF_TC_BODY(fts_options_physical_seedot, tc)
+{
+ fts_options_prepare(tc);
+ fts_test(tc, &(struct fts_testcase){
+ all_paths,
+ FTS_PHYSICAL | FTS_SEEDOT,
+ (struct fts_expect[]){
+ { FTS_SL, "dead", "dead" },
+ { FTS_D, "dir", "dir" },
+ { FTS_DOT, ".", "." },
+ { FTS_DOT, "..", ".." },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "up", "up" },
+ { FTS_DP, "dir", "dir" },
+ { FTS_SL, "dirl", "dirl" },
+ { FTS_F, "file", "file" },
+ { FTS_SL, "filel", "filel" },
+ { FTS_NS, "noent", "noent" },
+ { 0 }
+ },
+ });
+}
+
+/*
+ * TODO: Add tests for FTS_XDEV and FTS_WHITEOUT
+ */
+
+ATF_TP_ADD_TCS(tp)
+{
+ fts_check_debug();
+ ATF_TP_ADD_TC(tp, fts_options_logical);
+ ATF_TP_ADD_TC(tp, fts_options_logical_nostat);
+ ATF_TP_ADD_TC(tp, fts_options_logical_seedot);
+ ATF_TP_ADD_TC(tp, fts_options_physical);
+ ATF_TP_ADD_TC(tp, fts_options_physical_nochdir);
+ ATF_TP_ADD_TC(tp, fts_options_physical_comfollow);
+ ATF_TP_ADD_TC(tp, fts_options_physical_comfollowdir);
+ ATF_TP_ADD_TC(tp, fts_options_physical_nostat);
+ ATF_TP_ADD_TC(tp, fts_options_physical_nostat_type);
+ ATF_TP_ADD_TC(tp, fts_options_physical_seedot);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/fts_test.h b/lib/libc/tests/gen/fts_test.h
new file mode 100644
index 000000000000..b3f15050f265
--- /dev/null
+++ b/lib/libc/tests/gen/fts_test.h
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#ifndef FTS_TEST_H_INCLUDED
+#define FTS_TEST_H_INCLUDED
+
+struct fts_expect {
+ int fts_info;
+ const char *fts_name;
+ const char *fts_accpath;
+};
+
+struct fts_testcase {
+ char **paths;
+ int fts_options;
+ struct fts_expect *fts_expect;
+};
+
+/* shorter name for dead links */
+#define FTS_DL FTS_SLNONE
+
+/* are we being debugged? */
+static bool fts_test_debug;
+
+/*
+ * Set debug flag if appropriate.
+ */
+static void
+fts_check_debug(void)
+{
+ fts_test_debug = !getenv("__RUNNING_INSIDE_ATF_RUN") &&
+ isatty(STDERR_FILENO);
+}
+
+/*
+ * Lexical order for reproducability.
+ */
+static int
+fts_lexical_compar(const FTSENT * const *a, const FTSENT * const *b)
+{
+ return (strcmp((*a)->fts_name, (*b)->fts_name));
+}
+
+/*
+ * Run FTS with the specified paths and options and verify that it
+ * produces the expected result in the correct order.
+ */
+static void
+fts_test(const struct atf_tc *tc, const struct fts_testcase *fts_tc)
+{
+ FTS *fts;
+ FTSENT *ftse;
+ const struct fts_expect *expect = fts_tc->fts_expect;
+ long level = 0;
+
+ fts = fts_open(fts_tc->paths, fts_tc->fts_options, fts_lexical_compar);
+ ATF_REQUIRE_MSG(fts != NULL, "fts_open(): %m");
+ while ((ftse = fts_read(fts)) != NULL && expect->fts_name != NULL) {
+ if (expect->fts_info == FTS_DP || expect->fts_info == FTS_DNR)
+ level--;
+ if (fts_test_debug) {
+ fprintf(stderr, "%2ld %2d %s\n", level,
+ ftse->fts_info, ftse->fts_name);
+ }
+ ATF_CHECK_STREQ(expect->fts_name, ftse->fts_name);
+ ATF_CHECK_STREQ(expect->fts_accpath, ftse->fts_accpath);
+ ATF_CHECK_INTEQ(expect->fts_info, ftse->fts_info);
+ ATF_CHECK_INTEQ(level, ftse->fts_level);
+ if (expect->fts_info == FTS_D)
+ level++;
+ expect++;
+ }
+ ATF_CHECK_EQ(NULL, ftse);
+ ATF_CHECK_EQ(NULL, expect->fts_name);
+ ATF_REQUIRE_EQ_MSG(0, fts_close(fts), "fts_close(): %m");
+}
+
+#endif /* FTS_TEST_H_INCLUDED */
diff --git a/lib/libc/tests/gen/ftw_test.c b/lib/libc/tests/gen/ftw_test.c
index d6fe56f6499d..3d2cf3446dee 100644
--- a/lib/libc/tests/gen/ftw_test.c
+++ b/lib/libc/tests/gen/ftw_test.c
@@ -28,7 +28,6 @@
* Limited test program for nftw() as specified by IEEE Std. 1003.1-2008.
*/
-#include <sys/cdefs.h>
#include <sys/wait.h>
#include <err.h>
#include <errno.h>
diff --git a/lib/libc/tests/gen/getentropy_test.c b/lib/libc/tests/gen/getentropy_test.c
index a79ef0628f97..6ac9d5678ea6 100644
--- a/lib/libc/tests/gen/getentropy_test.c
+++ b/lib/libc/tests/gen/getentropy_test.c
@@ -26,9 +26,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
+#include <limits.h>
#include <signal.h>
#include <unistd.h>
@@ -63,13 +63,13 @@ ATF_TC_BODY(getentropy_sizes, tc)
char buf[512];
ATF_REQUIRE_EQ(getentropy(buf, sizeof(buf)), -1);
- ATF_REQUIRE_EQ(errno, EIO);
- ATF_REQUIRE_EQ(getentropy(buf, 257), -1);
- ATF_REQUIRE_EQ(errno, EIO);
+ ATF_REQUIRE_EQ(errno, EINVAL);
+ ATF_REQUIRE_EQ(getentropy(buf, GETENTROPY_MAX + 1), -1);
+ ATF_REQUIRE_EQ(errno, EINVAL);
/* Smaller sizes always succeed: */
- ATF_REQUIRE_EQ(getentropy(buf, 256), 0);
- ATF_REQUIRE_EQ(getentropy(buf, 128), 0);
+ ATF_REQUIRE_EQ(getentropy(buf, GETENTROPY_MAX), 0);
+ ATF_REQUIRE_EQ(getentropy(buf, GETENTROPY_MAX / 2), 0);
ATF_REQUIRE_EQ(getentropy(buf, 0), 0);
}
diff --git a/lib/libc/tests/gen/getmntinfo_test.c b/lib/libc/tests/gen/getmntinfo_test.c
index 2284a6146556..06e1091d8a15 100644
--- a/lib/libc/tests/gen/getmntinfo_test.c
+++ b/lib/libc/tests/gen/getmntinfo_test.c
@@ -28,7 +28,6 @@
* Limited test program for getmntinfo(3), a non-standard BSDism.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/ucred.h>
diff --git a/lib/libc/tests/gen/glob2_test.c b/lib/libc/tests/gen/glob2_test.c
index c18e03cc1025..ff1b36b830b8 100644
--- a/lib/libc/tests/gen/glob2_test.c
+++ b/lib/libc/tests/gen/glob2_test.c
@@ -24,11 +24,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
+#include <sys/stat.h>
+
#include <errno.h>
#include <fcntl.h>
#include <glob.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -103,10 +105,80 @@ ATF_TC_BODY(glob_pathological_test, tc)
}
}
+ATF_TC(glob_period);
+ATF_TC_HEAD(glob_period, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test behaviour when matching files that start with a period"
+ "(documented in the glob(3) CAVEATS section).");
+}
+ATF_TC_BODY(glob_period, tc)
+{
+ int i;
+ glob_t g;
+
+ atf_utils_create_file(".test", "");
+ glob(".", 0, NULL, &g);
+ ATF_REQUIRE_MSG(g.gl_matchc == 1,
+ "glob(3) shouldn't match files starting with a period when using '.'");
+ for (i = 0; i < g.gl_matchc; i++)
+ printf("%s\n", g.gl_pathv[i]);
+ glob(".*", 0, NULL, &g);
+ ATF_REQUIRE_MSG(g.gl_matchc == 3 && strcmp(g.gl_pathv[2], ".test") == 0,
+ "glob(3) should match files starting with a period when using '.*'");
+}
+
+static bool glob_callback_invoked;
+
+static int
+errfunc(const char *path, int err)
+{
+ ATF_CHECK_STREQ(path, "test/");
+ ATF_CHECK(err == EACCES);
+ glob_callback_invoked = true;
+ /* Suppress EACCES errors. */
+ return (0);
+}
+
+ATF_TC(glob_callback);
+ATF_TC_HEAD(glob_callback, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test ability of callback function to suppress errors");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+ATF_TC_BODY(glob_callback, tc)
+{
+ glob_t g;
+ int rv;
+
+ ATF_REQUIRE_EQ(0, mkdir("test", 0755));
+ ATF_REQUIRE_EQ(0, symlink("foo", "test/foo"));
+ ATF_REQUIRE_EQ(0, chmod("test", 0));
+
+ glob_callback_invoked = false;
+ rv = glob("test/*", 0, errfunc, &g);
+ ATF_CHECK_MSG(glob_callback_invoked,
+ "glob(3) failed to invoke callback function");
+ ATF_CHECK_EQ_MSG(GLOB_NOMATCH, rv,
+ "callback function failed to suppress EACCES");
+ globfree(&g);
+
+ /* GLOB_ERR should ignore the suppressed error. */
+ glob_callback_invoked = false;
+ rv = glob("test/*", GLOB_ERR, errfunc, &g);
+ ATF_CHECK_MSG(glob_callback_invoked,
+ "glob(3) failed to invoke callback function");
+ ATF_CHECK_EQ_MSG(GLOB_ABORTED, rv,
+ "GLOB_ERR didn't override callback function");
+ globfree(&g);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, glob_pathological_test);
-
+ ATF_TP_ADD_TC(tp, glob_period);
+ ATF_TP_ADD_TC(tp, glob_callback);
return (atf_no_error());
}
diff --git a/lib/libc/tests/gen/glob_blocks_test.c b/lib/libc/tests/gen/glob_blocks_test.c
new file mode 100644
index 000000000000..629b90bee762
--- /dev/null
+++ b/lib/libc/tests/gen/glob_blocks_test.c
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <glob.h>
+#include <stdbool.h>
+
+#include <atf-c.h>
+
+ATF_TC(glob_b_callback);
+ATF_TC_HEAD(glob_b_callback, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test ability of callback block to suppress errors");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+ATF_TC_BODY(glob_b_callback, tc)
+{
+ static bool glob_callback_invoked;
+ static int (^errblk)(const char *, int) =
+ ^(const char *path, int err) {
+ ATF_CHECK_STREQ(path, "test/");
+ ATF_CHECK(err == EACCES);
+ glob_callback_invoked = true;
+ /* Suppress EACCES errors. */
+ return (0);
+ };
+ glob_t g;
+ int rv;
+
+ ATF_REQUIRE_EQ(0, mkdir("test", 0755));
+ ATF_REQUIRE_EQ(0, symlink("foo", "test/foo"));
+ ATF_REQUIRE_EQ(0, chmod("test", 0));
+
+ glob_callback_invoked = false;
+ rv = glob_b("test/*", 0, errblk, &g);
+ ATF_CHECK_MSG(glob_callback_invoked,
+ "glob(3) failed to invoke callback block");
+ ATF_CHECK_EQ_MSG(GLOB_NOMATCH, rv,
+ "callback function failed to suppress EACCES");
+ globfree(&g);
+
+ /* GLOB_ERR should ignore the suppressed error. */
+ glob_callback_invoked = false;
+ rv = glob_b("test/*", GLOB_ERR, errblk, &g);
+ ATF_CHECK_MSG(glob_callback_invoked,
+ "glob(3) failed to invoke callback block");
+ ATF_CHECK_EQ_MSG(GLOB_ABORTED, rv,
+ "GLOB_ERR didn't override callback block");
+ globfree(&g);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, glob_b_callback);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/makecontext_test.c b/lib/libc/tests/gen/makecontext_test.c
index 7c5c5c48ede0..23e3cf85f677 100644
--- a/lib/libc/tests/gen/makecontext_test.c
+++ b/lib/libc/tests/gen/makecontext_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <atf-c.h>
#include <ucontext.h>
diff --git a/lib/libc/tests/gen/opendir_test.c b/lib/libc/tests/gen/opendir_test.c
new file mode 100644
index 000000000000..b7481255654f
--- /dev/null
+++ b/lib/libc/tests/gen/opendir_test.c
@@ -0,0 +1,145 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+/*
+ * Create a directory with a single subdirectory.
+ */
+static void
+opendir_prepare(const struct atf_tc *tc)
+{
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE_EQ(0, mkdir("dir/subdir", 0755));
+}
+
+/*
+ * Assuming dirp represents the directory created by opendir_prepare(),
+ * verify that readdir() returns what we expected to see there.
+ */
+static void
+opendir_check(const struct atf_tc *tc, DIR *dirp)
+{
+ struct dirent *ent;
+
+ ATF_REQUIRE((ent = readdir(dirp)) != NULL);
+ ATF_CHECK_EQ(1, ent->d_namlen);
+ ATF_CHECK_STREQ(".", ent->d_name);
+ ATF_CHECK_EQ(DT_DIR, ent->d_type);
+ ATF_REQUIRE((ent = readdir(dirp)) != NULL);
+ ATF_CHECK_EQ(2, ent->d_namlen);
+ ATF_CHECK_STREQ("..", ent->d_name);
+ ATF_CHECK_EQ(DT_DIR, ent->d_type);
+ ATF_REQUIRE((ent = readdir(dirp)) != NULL);
+ ATF_CHECK_EQ(sizeof("subdir") - 1, ent->d_namlen);
+ ATF_CHECK_STREQ("subdir", ent->d_name);
+ ATF_CHECK_EQ(DT_DIR, ent->d_type);
+ ATF_CHECK(readdir(dirp) == NULL);
+ ATF_CHECK(readdir(dirp) == NULL);
+}
+
+ATF_TC(opendir_ok);
+ATF_TC_HEAD(opendir_ok, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Open a directory.");
+}
+ATF_TC_BODY(opendir_ok, tc)
+{
+ DIR *dirp;
+
+ opendir_prepare(tc);
+ ATF_REQUIRE((dirp = opendir("dir")) != NULL);
+ opendir_check(tc, dirp);
+ ATF_CHECK_EQ(0, closedir(dirp));
+}
+
+ATF_TC(opendir_fifo);
+ATF_TC_HEAD(opendir_fifo, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Do not hang if given a named pipe.");
+}
+ATF_TC_BODY(opendir_fifo, tc)
+{
+ DIR *dirp;
+ int fd;
+
+ ATF_REQUIRE((fd = mkfifo("fifo", 0644)) >= 0);
+ ATF_REQUIRE_EQ(0, close(fd));
+ ATF_REQUIRE((dirp = opendir("fifo")) == NULL);
+ ATF_CHECK_EQ(ENOTDIR, errno);
+}
+
+ATF_TC(fdopendir_ok);
+ATF_TC_HEAD(fdopendir_ok, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Open a directory from a directory descriptor.");
+}
+ATF_TC_BODY(fdopendir_ok, tc)
+{
+ DIR *dirp;
+ int dd;
+
+ opendir_prepare(tc);
+ ATF_REQUIRE((dd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0);
+ ATF_REQUIRE((dirp = fdopendir(dd)) != NULL);
+ opendir_check(tc, dirp);
+ ATF_CHECK_EQ(dd, fdclosedir(dirp));
+ ATF_CHECK_EQ(0, close(dd));
+}
+
+ATF_TC(fdopendir_ebadf);
+ATF_TC_HEAD(fdopendir_ebadf, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Open a directory from an invalid descriptor.");
+}
+ATF_TC_BODY(fdopendir_ebadf, tc)
+{
+ DIR *dirp;
+ int dd;
+
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE((dd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0);
+ ATF_CHECK_EQ(0, close(dd));
+ ATF_REQUIRE((dirp = fdopendir(dd)) == NULL);
+ ATF_CHECK_EQ(EBADF, errno);
+}
+
+ATF_TC(fdopendir_enotdir);
+ATF_TC_HEAD(fdopendir_enotdir, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Open a directory from a non-directory descriptor.");
+}
+ATF_TC_BODY(fdopendir_enotdir, tc)
+{
+ DIR *dirp;
+ int fd;
+
+ ATF_REQUIRE((fd = open("file", O_CREAT | O_RDWR, 0644)) >= 0);
+ ATF_REQUIRE((dirp = fdopendir(fd)) == NULL);
+ ATF_CHECK_EQ(ENOTDIR, errno);
+ ATF_CHECK_EQ(0, close(fd));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, opendir_ok);
+ ATF_TP_ADD_TC(tp, fdopendir_ok);
+ ATF_TP_ADD_TC(tp, fdopendir_ebadf);
+ ATF_TP_ADD_TC(tp, fdopendir_enotdir);
+ ATF_TP_ADD_TC(tp, opendir_fifo);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/popen_test.c b/lib/libc/tests/gen/popen_test.c
index 89be6d257c34..43eadd380f39 100644
--- a/lib/libc/tests/gen/popen_test.c
+++ b/lib/libc/tests/gen/popen_test.c
@@ -29,7 +29,6 @@
* with BSD extensions.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <errno.h>
diff --git a/lib/libc/tests/gen/posix_spawn/Makefile b/lib/libc/tests/gen/posix_spawn/Makefile
index 7a13fdf501c5..df428876708b 100644
--- a/lib/libc/tests/gen/posix_spawn/Makefile
+++ b/lib/libc/tests/gen/posix_spawn/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
BINDIR= ${TESTSDIR}
diff --git a/lib/libc/tests/gen/posix_spawn_test.c b/lib/libc/tests/gen/posix_spawn_test.c
index dc1381813098..22133cf1d59a 100644
--- a/lib/libc/tests/gen/posix_spawn_test.c
+++ b/lib/libc/tests/gen/posix_spawn_test.c
@@ -29,9 +29,11 @@
* IEEE Std. 1003.1-2008.
*/
-#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/stat.h>
#include <sys/wait.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -39,6 +41,10 @@
#include <atf-c.h>
+static const char true_script[] =
+ "#!/usr/bin/env\n"
+ "/usr/bin/true\n";
+
char *myenv[2] = { "answer=42", NULL };
ATF_TC_WITHOUT_HEAD(posix_spawn_simple_test);
@@ -125,6 +131,48 @@ ATF_TC_BODY(posix_spawnp_enoexec_fallback_null_argv0, tc)
ATF_REQUIRE(error == EINVAL);
}
+ATF_TC(posix_spawnp_eacces);
+ATF_TC_HEAD(posix_spawnp_eacces, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verify EACCES behavior in posix_spawnp");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+ATF_TC_BODY(posix_spawnp_eacces, tc)
+{
+ const struct spawnp_eacces_tc {
+ const char *pathvar;
+ int error_expected;
+ } spawnp_eacces_tests[] = {
+ { ".", EACCES }, /* File exists, but not +x */
+ { "unsearchable", ENOENT }, /* File exists, dir not +x */
+ };
+ char *myargs[2] = { "eacces", NULL };
+ int error;
+
+ error = mkdir("unsearchable", 0755);
+ ATF_REQUIRE(error == 0);
+ error = symlink("/usr/bin/true", "unsearchable/eacces");
+ ATF_REQUIRE(error == 0);
+
+ (void)chmod("unsearchable", 0444);
+
+ /* this will create a non-executable file */
+ atf_utils_create_file("eacces", true_script);
+
+ for (size_t i = 0; i < nitems(spawnp_eacces_tests); i++) {
+ const struct spawnp_eacces_tc *tc = &spawnp_eacces_tests[i];
+ pid_t pid;
+
+ error = setenv("PATH", tc->pathvar, 1);
+ ATF_REQUIRE_EQ(0, error);
+
+ error = posix_spawnp(&pid, myargs[0], NULL, NULL, myargs,
+ myenv);
+ ATF_CHECK_INTEQ_MSG(tc->error_expected, error,
+ "path '%s'", tc->pathvar);
+ }
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -132,6 +180,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, posix_spawn_no_such_command_negative_test);
ATF_TP_ADD_TC(tp, posix_spawnp_enoexec_fallback);
ATF_TP_ADD_TC(tp, posix_spawnp_enoexec_fallback_null_argv0);
+ ATF_TP_ADD_TC(tp, posix_spawnp_eacces);
return (atf_no_error());
}
diff --git a/lib/libc/tests/gen/realpath2_test.c b/lib/libc/tests/gen/realpath2_test.c
index e3bd83448942..f89dd99cbb72 100644
--- a/lib/libc/tests/gen/realpath2_test.c
+++ b/lib/libc/tests/gen/realpath2_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libc/tests/gen/scandir_blocks_test.c b/lib/libc/tests/gen/scandir_blocks_test.c
new file mode 100644
index 000000000000..b94270bc410e
--- /dev/null
+++ b/lib/libc/tests/gen/scandir_blocks_test.c
@@ -0,0 +1,118 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+static void
+scandir_blocks_prepare(const struct atf_tc *tc)
+{
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE_EQ(0, mkdir("dir/dir", 0755));
+ ATF_REQUIRE_EQ(0, close(creat("dir/file", 0644)));
+ ATF_REQUIRE_EQ(0, symlink("file", "dir/link"));
+ ATF_REQUIRE_EQ(0, mkdir("dir/skip", 0755));
+}
+
+static void
+scandir_blocks_verify(const struct atf_tc *tc, int n, struct dirent **namelist)
+{
+ ATF_REQUIRE_EQ_MSG(5, n, "return value is %d", n);
+ ATF_CHECK_STREQ("link", namelist[0]->d_name);
+ ATF_CHECK_STREQ("file", namelist[1]->d_name);
+ ATF_CHECK_STREQ("dir", namelist[2]->d_name);
+ ATF_CHECK_STREQ("..", namelist[3]->d_name);
+ ATF_CHECK_STREQ(".", namelist[4]->d_name);
+}
+
+ATF_TC(scandir_b_test);
+ATF_TC_HEAD(scandir_b_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test scandir_b()");
+}
+ATF_TC_BODY(scandir_b_test, tc)
+{
+ struct dirent **namelist = NULL;
+ int i, ret;
+
+ scandir_blocks_prepare(tc);
+ ret = scandir_b("dir", &namelist,
+ ^(const struct dirent *ent) {
+ return (strcmp(ent->d_name, "skip") != 0);
+ },
+ ^(const struct dirent **a, const struct dirent **b) {
+ return (strcmp((*b)->d_name, (*a)->d_name));
+ });
+ scandir_blocks_verify(tc, ret, namelist);
+ for (i = 0; i < ret; i++)
+ free(namelist[i]);
+ free(namelist);
+}
+
+ATF_TC(fdscandir_b_test);
+ATF_TC_HEAD(fdscandir_b_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test fdscandir_b()");
+}
+ATF_TC_BODY(fdscandir_b_test, tc)
+{
+ struct dirent **namelist = NULL;
+ int fd, i, ret;
+
+ scandir_blocks_prepare(tc);
+ ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0);
+ ret = fdscandir_b(fd, &namelist,
+ ^(const struct dirent *ent) {
+ return (strcmp(ent->d_name, "skip") != 0);
+ },
+ ^(const struct dirent **a, const struct dirent **b) {
+ return (strcmp((*b)->d_name, (*a)->d_name));
+ });
+ scandir_blocks_verify(tc, ret, namelist);
+ for (i = 0; i < ret; i++)
+ free(namelist[i]);
+ free(namelist);
+ ATF_REQUIRE_EQ(0, close(fd));
+}
+
+ATF_TC(scandirat_b_test);
+ATF_TC_HEAD(scandirat_b_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test scandirat_b()");
+}
+ATF_TC_BODY(scandirat_b_test, tc)
+{
+ struct dirent **namelist = NULL;
+ int fd, i, ret;
+
+ scandir_blocks_prepare(tc);
+ ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_SEARCH)) >= 0);
+ ret = scandirat_b(fd, ".", &namelist,
+ ^(const struct dirent *ent) {
+ return (strcmp(ent->d_name, "skip") != 0);
+ },
+ ^(const struct dirent **a, const struct dirent **b) {
+ return (strcmp((*b)->d_name, (*a)->d_name));
+ });
+ scandir_blocks_verify(tc, ret, namelist);
+ for (i = 0; i < ret; i++)
+ free(namelist[i]);
+ free(namelist);
+ ATF_REQUIRE_EQ(0, close(fd));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, scandir_b_test);
+ ATF_TP_ADD_TC(tp, fdscandir_b_test);
+ ATF_TP_ADD_TC(tp, scandirat_b_test);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/scandir_test.c b/lib/libc/tests/gen/scandir_test.c
new file mode 100644
index 000000000000..afd25bf7c0b2
--- /dev/null
+++ b/lib/libc/tests/gen/scandir_test.c
@@ -0,0 +1,195 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+static void
+scandir_prepare(const struct atf_tc *tc)
+{
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ ATF_REQUIRE_EQ(0, mkdir("dir/dir", 0755));
+ ATF_REQUIRE_EQ(0, close(creat("dir/file", 0644)));
+ ATF_REQUIRE_EQ(0, symlink("file", "dir/link"));
+ ATF_REQUIRE_EQ(0, mkdir("dir/skip", 0755));
+}
+
+static void
+scandir_verify(const struct atf_tc *tc, int n, struct dirent **namelist)
+{
+ ATF_REQUIRE_EQ_MSG(5, n, "return value is %d", n);
+ ATF_CHECK_STREQ("link", namelist[0]->d_name);
+ ATF_CHECK_STREQ("file", namelist[1]->d_name);
+ ATF_CHECK_STREQ("dir", namelist[2]->d_name);
+ ATF_CHECK_STREQ("..", namelist[3]->d_name);
+ ATF_CHECK_STREQ(".", namelist[4]->d_name);
+}
+
+static int
+scandir_select(const struct dirent *ent)
+{
+ return (strcmp(ent->d_name, "skip") != 0);
+}
+
+static int
+scandir_compare(const struct dirent **a, const struct dirent **b)
+{
+ return (strcmp((*b)->d_name, (*a)->d_name));
+}
+
+ATF_TC(scandir_test);
+ATF_TC_HEAD(scandir_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test scandir()");
+}
+ATF_TC_BODY(scandir_test, tc)
+{
+ struct dirent **namelist = NULL;
+ int i, ret;
+
+ scandir_prepare(tc);
+ ret = scandir("dir", &namelist, scandir_select, scandir_compare);
+ scandir_verify(tc, ret, namelist);
+ for (i = 0; i < ret; i++)
+ free(namelist[i]);
+ free(namelist);
+}
+
+ATF_TC(fdscandir_test);
+ATF_TC_HEAD(fdscandir_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test fdscandir()");
+}
+ATF_TC_BODY(fdscandir_test, tc)
+{
+ struct dirent **namelist = NULL;
+ int fd, i, ret;
+
+ scandir_prepare(tc);
+ ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0);
+ ret = fdscandir(fd, &namelist, scandir_select, scandir_compare);
+ scandir_verify(tc, ret, namelist);
+ for (i = 0; i < ret; i++)
+ free(namelist[i]);
+ free(namelist);
+ ATF_REQUIRE_EQ(0, close(fd));
+}
+
+ATF_TC(scandirat_test);
+ATF_TC_HEAD(scandirat_test, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test scandirat()");
+}
+ATF_TC_BODY(scandirat_test, tc)
+{
+ struct dirent **namelist = NULL;
+ int fd, i, ret;
+
+ scandir_prepare(tc);
+ ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_SEARCH)) >= 0);
+ ret = scandirat(fd, ".", &namelist, scandir_select, scandir_compare);
+ scandir_verify(tc, ret, namelist);
+ for (i = 0; i < ret; i++)
+ free(namelist[i]);
+ free(namelist);
+ ATF_REQUIRE_EQ(0, close(fd));
+}
+
+static int
+scandir_none(const struct dirent *ent __unused)
+{
+ return (0);
+}
+
+ATF_TC(scandir_none);
+ATF_TC_HEAD(scandir_none, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test scandir() when no entries are selected");
+}
+ATF_TC_BODY(scandir_none, tc)
+{
+ struct dirent **namelist = NULL;
+
+ ATF_REQUIRE_EQ(0, scandir(".", &namelist, scandir_none, alphasort));
+ ATF_REQUIRE(namelist);
+ free(namelist);
+}
+
+/*
+ * Test that scandir() propagates errors from readdir(): we create a
+ * directory with enough entries that it can't be read in a single
+ * getdirentries() call, then abuse the selection callback to close the
+ * file descriptor scandir() is using after the first call, causing the
+ * next one to fail, and verify that readdir() returns an error instead of
+ * a partial result. We make two passes, one in which nothing was
+ * selected before the error occurred, and one in which everything was.
+ */
+static int scandir_error_count;
+static int scandir_error_fd;
+static int scandir_error_select_return;
+
+static int
+scandir_error_select(const struct dirent *ent __unused)
+{
+ if (scandir_error_count++ == 0)
+ close(scandir_error_fd);
+ return (scandir_error_select_return);
+}
+
+ATF_TC(scandir_error);
+ATF_TC_HEAD(scandir_error, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that scandir() propagates errors from readdir()");
+}
+ATF_TC_BODY(scandir_error, tc)
+{
+ char path[16];
+ struct dirent **namelist = NULL;
+ int fd, i;
+
+ ATF_REQUIRE_EQ(0, mkdir("dir", 0755));
+ for (i = 0; i < 1024; i++) {
+ snprintf(path, sizeof(path), "dir/%04x", i);
+ ATF_REQUIRE_EQ(0, symlink(path + 4, path));
+ }
+
+ /* first pass, select nothing */
+ ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0);
+ scandir_error_count = 0;
+ scandir_error_fd = fd;
+ scandir_error_select_return = 0;
+ ATF_CHECK_ERRNO(EBADF,
+ fdscandir(fd, &namelist, scandir_error_select, NULL) < 0);
+ ATF_CHECK_EQ(NULL, namelist);
+
+ /* second pass, select everything */
+ ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0);
+ scandir_error_count = 0;
+ scandir_error_fd = fd;
+ scandir_error_select_return = 1;
+ ATF_CHECK_ERRNO(EBADF,
+ fdscandir(fd, &namelist, scandir_error_select, NULL) < 0);
+ ATF_CHECK_EQ(NULL, namelist);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, scandir_test);
+ ATF_TP_ADD_TC(tp, fdscandir_test);
+ ATF_TP_ADD_TC(tp, scandirat_test);
+ ATF_TP_ADD_TC(tp, scandir_none);
+ ATF_TP_ADD_TC(tp, scandir_error);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/sig2str_test.c b/lib/libc/tests/gen/sig2str_test.c
new file mode 100644
index 000000000000..00b6ebb2349a
--- /dev/null
+++ b/lib/libc/tests/gen/sig2str_test.c
@@ -0,0 +1,213 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Ricardo Branco <rbranco@suse.de>
+ * 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.
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+static void
+test_roundtrip(int signum)
+{
+ char str[SIG2STR_MAX];
+ int sig;
+
+ ATF_REQUIRE_EQ_MSG(sig2str(signum, str), 0,
+ "sig2str(%d) failed", signum);
+ ATF_REQUIRE_EQ_MSG(str2sig(str, &sig), 0,
+ "str2sig(\"%s\") failed", str);
+ ATF_REQUIRE_INTEQ_MSG(sig, signum,
+ "Mismatch: roundtrip conversion gave %d instead of %d",
+ sig, signum);
+}
+
+ATF_TC_WITHOUT_HEAD(sig2str_valid);
+ATF_TC_BODY(sig2str_valid, tc)
+{
+ int sig;
+
+ for (sig = 1; sig < sys_nsig; sig++) {
+ test_roundtrip(sig);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(sig2str_invalid);
+ATF_TC_BODY(sig2str_invalid, tc)
+{
+ char buf[SIG2STR_MAX];
+
+ ATF_CHECK(sig2str(0, buf) != 0);
+ ATF_CHECK(sig2str(-1, buf) != 0);
+ ATF_CHECK(sig2str(SIGRTMAX + 1, buf) != 0);
+}
+
+ATF_TC_WITHOUT_HEAD(str2sig_rtmin_rtmax);
+ATF_TC_BODY(str2sig_rtmin_rtmax, tc)
+{
+ int sig;
+
+ ATF_CHECK_MSG(str2sig("RTMIN", &sig) == 0,
+ "str2sig(\"RTMIN\") failed");
+ ATF_CHECK_INTEQ_MSG(sig, SIGRTMIN,
+ "RTMIN mapped to %d, expected %d", sig, SIGRTMIN);
+
+ ATF_CHECK_MSG(str2sig("RTMAX", &sig) == 0,
+ "str2sig(\"RTMAX\") failed");
+ ATF_CHECK_INTEQ_MSG(sig, SIGRTMAX,
+ "RTMAX mapped to %d, expected %d", sig, SIGRTMAX);
+
+ ATF_CHECK_MSG(str2sig("RTMIN+1", &sig) == 0,
+ "str2sig(\"RTMIN+1\") failed");
+ ATF_CHECK_INTEQ_MSG(sig, SIGRTMIN + 1,
+ "RTMIN+1 mapped to %d, expected %d", sig, SIGRTMIN + 1);
+
+ ATF_CHECK_MSG(str2sig("RTMAX-1", &sig) == 0,
+ "str2sig(\"RTMAX-1\") failed");
+ ATF_CHECK_INTEQ_MSG(sig, SIGRTMAX - 1,
+ "RTMAX-1 mapped to %d, expected %d", sig, SIGRTMAX - 1);
+}
+
+ATF_TC_WITHOUT_HEAD(str2sig_invalid_rt);
+ATF_TC_BODY(str2sig_invalid_rt, tc)
+{
+ int i, sig;
+
+ const char *invalid[] = {
+ "RTMIN+0",
+ "RTMAX-0",
+ "RTMIN-777",
+ "RTMIN+777",
+ "RTMAX-777",
+ "RTMAX+777",
+ "RTMIN-",
+ "RTMAX-",
+ "RTMIN0",
+ "RTMAX1",
+ "RTMIN+abc",
+ "RTMIN-abc",
+ NULL
+ };
+
+ for (i = 0; invalid[i] != NULL; i++) {
+ ATF_CHECK_MSG(str2sig(invalid[i], &sig) != 0,
+ "str2sig(\"%s\") unexpectedly succeeded", invalid[i]);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(str2sig_fullname);
+ATF_TC_BODY(str2sig_fullname, tc)
+{
+ char fullname[SIG2STR_MAX + 3];
+ int n, sig;
+
+ for (sig = 1; sig < sys_nsig; sig++) {
+ snprintf(fullname, sizeof(fullname), "SIG%s", sys_signame[sig]);
+
+ ATF_CHECK_MSG(str2sig(fullname, &n) == 0,
+ "str2sig(\"%s\") failed with errno %d (%s)",
+ fullname, errno, strerror(errno));
+
+ ATF_CHECK_INTEQ_MSG(n, sig,
+ "Mismatch: %s = %d, str2sig(\"%s\") = %d",
+ sys_signame[sig], sig, fullname, n);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(str2sig_lowercase);
+ATF_TC_BODY(str2sig_lowercase, tc)
+{
+ char fullname[SIG2STR_MAX + 3];
+ int n, sig;
+
+ for (sig = 1; sig < sys_nsig; sig++) {
+ snprintf(fullname, sizeof(fullname), "sig%s", sys_signame[sig]);
+ for (size_t i = 3; i < strlen(fullname); i++)
+ fullname[i] = toupper((unsigned char)fullname[i]);
+
+ ATF_CHECK_MSG(str2sig(fullname, &n) == 0,
+ "str2sig(\"%s\") failed with errno %d (%s)",
+ fullname, errno, strerror(errno));
+
+ ATF_CHECK_INTEQ_MSG(n, sig,
+ "Mismatch: %s = %d, str2sig(\"%s\") = %d",
+ sys_signame[sig], sig, fullname, n);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(str2sig_numeric);
+ATF_TC_BODY(str2sig_numeric, tc)
+{
+ char buf[16];
+ int n, sig;
+
+ for (sig = NSIG; sig < SIGRTMIN; sig++) {
+ snprintf(buf, sizeof(buf), "%d", sig);
+ ATF_CHECK_MSG(str2sig(buf, &n) == 0,
+ "str2sig(\"%s\") failed", buf);
+ ATF_CHECK_INTEQ_MSG(n, sig,
+ "Mismatch: str2sig(\"%s\") = %d, expected %d",
+ buf, n, sig);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(str2sig_invalid);
+ATF_TC_BODY(str2sig_invalid, tc)
+{
+ const char *invalid[] = {
+ "SIGDOESNOTEXIST",
+ "DOESNOTEXIST",
+ "INTERRUPT",
+ "",
+ "SIG",
+ "123abc",
+ "sig1extra",
+ NULL
+ };
+ int i, sig;
+
+ for (i = 0; invalid[i] != NULL; i++) {
+ ATF_CHECK_MSG(str2sig(invalid[i], &sig) != 0,
+ "str2sig(\"%s\") unexpectedly succeeded", invalid[i]);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, sig2str_valid);
+ ATF_TP_ADD_TC(tp, sig2str_invalid);
+ ATF_TP_ADD_TC(tp, str2sig_rtmin_rtmax);
+ ATF_TP_ADD_TC(tp, str2sig_invalid_rt);
+ ATF_TP_ADD_TC(tp, str2sig_fullname);
+ ATF_TP_ADD_TC(tp, str2sig_lowercase);
+ ATF_TP_ADD_TC(tp, str2sig_numeric);
+ ATF_TP_ADD_TC(tp, str2sig_invalid);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/gen/sigsetops_test.c b/lib/libc/tests/gen/sigsetops_test.c
index 498d34bb23a4..a22c4b3f4f59 100644
--- a/lib/libc/tests/gen/sigsetops_test.c
+++ b/lib/libc/tests/gen/sigsetops_test.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
diff --git a/lib/libc/tests/gen/test-fnmatch.c b/lib/libc/tests/gen/test-fnmatch.c
index e7c63b329439..1a6c6ed7efdf 100644
--- a/lib/libc/tests/gen/test-fnmatch.c
+++ b/lib/libc/tests/gen/test-fnmatch.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/gen/wordexp_test.c b/lib/libc/tests/gen/wordexp_test.c
index ea8dc3d37828..a8b9d5509633 100644
--- a/lib/libc/tests/gen/wordexp_test.c
+++ b/lib/libc/tests/gen/wordexp_test.c
@@ -29,7 +29,6 @@
* IEEE Std. 1003.1-2001.
*/
-#include <sys/cdefs.h>
#include <sys/wait.h>
#include <errno.h>
#include <signal.h>
@@ -293,6 +292,31 @@ ATF_TC_BODY(with_SIGCHILD_handler_test, tc)
ATF_REQUIRE(r == 0);
}
+ATF_TC_WITHOUT_HEAD(with_SIGCHILD_ignore_test);
+ATF_TC_BODY(with_SIGCHILD_ignore_test, tc)
+{
+ struct sigaction sa;
+ wordexp_t we;
+ int r;
+
+ /* With SIGCHLD set to ignore so that the kernel auto-reaps zombies. */
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_handler = SIG_IGN;
+ r = sigaction(SIGCHLD, &sa, NULL);
+ ATF_REQUIRE(r == 0);
+ r = wordexp("hello world", &we, 0);
+ ATF_REQUIRE(r == 0);
+ ATF_REQUIRE(we.we_wordc == 2);
+ ATF_REQUIRE(strcmp(we.we_wordv[0], "hello") == 0);
+ ATF_REQUIRE(strcmp(we.we_wordv[1], "world") == 0);
+ ATF_REQUIRE(we.we_wordv[2] == NULL);
+ wordfree(&we);
+ sa.sa_handler = SIG_DFL;
+ r = sigaction(SIGCHLD, &sa, NULL);
+ ATF_REQUIRE(r == 0);
+}
+
ATF_TC_WITHOUT_HEAD(with_unused_non_default_IFS_test);
ATF_TC_BODY(with_unused_non_default_IFS_test, tc)
{
@@ -351,6 +375,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, WRDE_BADCHAR_test);
ATF_TP_ADD_TC(tp, WRDE_SYNTAX_test);
ATF_TP_ADD_TC(tp, with_SIGCHILD_handler_test);
+ ATF_TP_ADD_TC(tp, with_SIGCHILD_ignore_test);
ATF_TP_ADD_TC(tp, with_unused_non_default_IFS_test);
ATF_TP_ADD_TC(tp, with_used_non_default_IFS_test);
diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile
index 009b7d1c5239..d09d87b7cd8b 100644
--- a/lib/libc/tests/hash/Makefile
+++ b/lib/libc/tests/hash/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
.include <src.opts.mk>
diff --git a/lib/libc/tests/iconv/Makefile b/lib/libc/tests/iconv/Makefile
index fd4ab284ebe3..dc2dc5a925b9 100644
--- a/lib/libc/tests/iconv/Makefile
+++ b/lib/libc/tests/iconv/Makefile
@@ -1,4 +1,3 @@
-
TESTSDIR= ${TESTSBASE}/lib/libc/iconv
ATF_TESTS_C+= iconvctl_test
diff --git a/lib/libc/tests/iconv/iconvctl_test.c b/lib/libc/tests/iconv/iconvctl_test.c
index 06c882a6eee6..f534218cf294 100644
--- a/lib/libc/tests/iconv/iconvctl_test.c
+++ b/lib/libc/tests/iconv/iconvctl_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <iconv.h>
#include <atf-c.h>
diff --git a/lib/libc/tests/inet/Makefile b/lib/libc/tests/inet/Makefile
index 0c5a1674237d..3ceadfb8868c 100644
--- a/lib/libc/tests/inet/Makefile
+++ b/lib/libc/tests/inet/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
NETBSD_ATF_TESTS_C+= inet_addr_test
diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile
index 03e89571aacd..70905cc58d24 100644
--- a/lib/libc/tests/locale/Makefile
+++ b/lib/libc/tests/locale/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
ATF_TESTS_C+= btowc_test
diff --git a/lib/libc/tests/locale/btowc_test.c b/lib/libc/tests/locale/btowc_test.c
index 85be466eac7e..27e6ff533621 100644
--- a/lib/libc/tests/locale/btowc_test.c
+++ b/lib/libc/tests/locale/btowc_test.c
@@ -31,7 +31,6 @@
* The function is tested in the "C" and "ja_JP.eucJP" locales.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
diff --git a/lib/libc/tests/locale/c16rtomb_test.c b/lib/libc/tests/locale/c16rtomb_test.c
index df9fbcf61711..6812fbbc5164 100644
--- a/lib/libc/tests/locale/c16rtomb_test.c
+++ b/lib/libc/tests/locale/c16rtomb_test.c
@@ -30,7 +30,6 @@
* Test program for c16rtomb() as specified by ISO/IEC 9899:2011.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/iswctype_test.c b/lib/libc/tests/locale/iswctype_test.c
index 1780ade0bd4d..79b941522d2b 100644
--- a/lib/libc/tests/locale/iswctype_test.c
+++ b/lib/libc/tests/locale/iswctype_test.c
@@ -31,7 +31,6 @@
* The functions are tested in the "C" and "ja_JP.eucJP" locales.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mblen_test.c b/lib/libc/tests/locale/mblen_test.c
index 91d01958e79a..e081b0d4246a 100644
--- a/lib/libc/tests/locale/mblen_test.c
+++ b/lib/libc/tests/locale/mblen_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
diff --git a/lib/libc/tests/locale/mbrlen_test.c b/lib/libc/tests/locale/mbrlen_test.c
index 33fa156bd2f0..50088596fc89 100644
--- a/lib/libc/tests/locale/mbrlen_test.c
+++ b/lib/libc/tests/locale/mbrlen_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mbrtoc16_test.c b/lib/libc/tests/locale/mbrtoc16_test.c
index 09e0379ca021..98a140c56fc0 100644
--- a/lib/libc/tests/locale/mbrtoc16_test.c
+++ b/lib/libc/tests/locale/mbrtoc16_test.c
@@ -30,7 +30,6 @@
* Test program for mbrtoc16() as specified by ISO/IEC 9899:2011.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mbrtowc_test.c b/lib/libc/tests/locale/mbrtowc_test.c
index a7b7f9ae08a6..df611a7df573 100644
--- a/lib/libc/tests/locale/mbrtowc_test.c
+++ b/lib/libc/tests/locale/mbrtowc_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mbsnrtowcs_test.c b/lib/libc/tests/locale/mbsnrtowcs_test.c
index 3295379eee0d..a355bc7d7a6a 100644
--- a/lib/libc/tests/locale/mbsnrtowcs_test.c
+++ b/lib/libc/tests/locale/mbsnrtowcs_test.c
@@ -31,7 +31,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mbsrtowcs_test.c b/lib/libc/tests/locale/mbsrtowcs_test.c
index 8c67023b134d..d8d215fda2ad 100644
--- a/lib/libc/tests/locale/mbsrtowcs_test.c
+++ b/lib/libc/tests/locale/mbsrtowcs_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mbstowcs_test.c b/lib/libc/tests/locale/mbstowcs_test.c
index ad5ac183ba5f..404adfd7b19a 100644
--- a/lib/libc/tests/locale/mbstowcs_test.c
+++ b/lib/libc/tests/locale/mbstowcs_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/mbtowc_test.c b/lib/libc/tests/locale/mbtowc_test.c
index 2a58b60df908..e5ff276b4610 100644
--- a/lib/libc/tests/locale/mbtowc_test.c
+++ b/lib/libc/tests/locale/mbtowc_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include <locale.h>
#include <stdio.h>
diff --git a/lib/libc/tests/locale/towctrans_test.c b/lib/libc/tests/locale/towctrans_test.c
index 734c7557252d..f34eb554f283 100644
--- a/lib/libc/tests/locale/towctrans_test.c
+++ b/lib/libc/tests/locale/towctrans_test.c
@@ -31,7 +31,6 @@
* The functions are tested in the "C" and "ja_JP.eucJP" locales.
*/
-#include <sys/cdefs.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
diff --git a/lib/libc/tests/locale/wcrtomb_test.c b/lib/libc/tests/locale/wcrtomb_test.c
index 58713faf625d..2bc7cbc2365f 100644
--- a/lib/libc/tests/locale/wcrtomb_test.c
+++ b/lib/libc/tests/locale/wcrtomb_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/wcsnrtombs_test.c b/lib/libc/tests/locale/wcsnrtombs_test.c
index d6b8be0dbdbe..8764c1567066 100644
--- a/lib/libc/tests/locale/wcsnrtombs_test.c
+++ b/lib/libc/tests/locale/wcsnrtombs_test.c
@@ -31,7 +31,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/wcsrtombs_test.c b/lib/libc/tests/locale/wcsrtombs_test.c
index 10f4a4d46e1a..dcb111dfd87c 100644
--- a/lib/libc/tests/locale/wcsrtombs_test.c
+++ b/lib/libc/tests/locale/wcsrtombs_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/wcstombs_test.c b/lib/libc/tests/locale/wcstombs_test.c
index 90f893b2fb31..2506be2806f6 100644
--- a/lib/libc/tests/locale/wcstombs_test.c
+++ b/lib/libc/tests/locale/wcstombs_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/locale/wctomb_test.c b/lib/libc/tests/locale/wctomb_test.c
index a1f19a44be4b..ef2a6dcbe1e3 100644
--- a/lib/libc/tests/locale/wctomb_test.c
+++ b/lib/libc/tests/locale/wctomb_test.c
@@ -32,7 +32,6 @@
* "ja_JP.eucJP". Other encodings are not tested.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
@@ -42,6 +41,18 @@
#include <atf-c.h>
+ATF_TC_WITHOUT_HEAD(euccs1_test);
+ATF_TC_BODY(euccs1_test, tc)
+{
+ wchar_t wc = 0x8e000000;
+ char buf[MB_LEN_MAX];
+
+ ATF_REQUIRE(strcmp(setlocale(LC_CTYPE, "zh_CN.eucCN"),
+ "zh_CN.eucCN") == 0);
+
+ ATF_REQUIRE(wctomb(&buf[0], wc) == 4);
+}
+
ATF_TC_WITHOUT_HEAD(wctomb_test);
ATF_TC_BODY(wctomb_test, tc)
{
@@ -105,6 +116,7 @@ ATF_TC_BODY(wctomb_test, tc)
ATF_TP_ADD_TCS(tp)
{
+ ATF_TP_ADD_TC(tp, euccs1_test);
ATF_TP_ADD_TC(tp, wctomb_test);
return (atf_no_error());
diff --git a/lib/libc/tests/net/Makefile b/lib/libc/tests/net/Makefile
index 6e90f22b98f5..24cff61e8d24 100644
--- a/lib/libc/tests/net/Makefile
+++ b/lib/libc/tests/net/Makefile
@@ -1,9 +1,11 @@
-
PACKAGE= tests
ATF_TESTS_C+= ether_test
ATF_TESTS_C+= eui64_aton_test
ATF_TESTS_C+= eui64_ntoa_test
+ATF_TESTS_CXX+= link_addr_test
+
+CXXSTD.link_addr_test= c++20
CFLAGS+= -I${.CURDIR}
@@ -32,8 +34,7 @@ aton_ether_subr.c: gen_ether_subr ${SRCTOP}/sys/net/if_ethersubr.c
.include "../Makefile.netbsd-tests"
-# TODO: the testcases needs to be ported to FreeBSD
-#TESTS_SUBDIRS= getaddrinfo
+TESTS_SUBDIRS= getaddrinfo
${PACKAGE}FILES+= hosts
${PACKAGE}FILES+= resolv.conf
diff --git a/lib/libc/tests/net/getaddrinfo/Makefile b/lib/libc/tests/net/getaddrinfo/Makefile
index c9c9fba7d53c..1299e91615b7 100644
--- a/lib/libc/tests/net/getaddrinfo/Makefile
+++ b/lib/libc/tests/net/getaddrinfo/Makefile
@@ -1,15 +1,11 @@
-
PACKAGE= tests
-TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/net/${.CURDIR:T}
-
.include <bsd.own.mk>
BINDIR= ${TESTSDIR}
-.error This testcase needs to be ported to FreeBSD (the output from getaddrinfo_test differs from NetBSD)
-
-NETBSD_ATF_TESTS_SH= getaddrinfo_test
+ATF_TESTS_SH= getaddrinfo_test
+ATF_TESTS_C= getaddrinfo
PROGS= h_gai
@@ -18,13 +14,33 @@ ${PACKAGE}DATA_FILESPACKAGE= tests
${PACKAGE}DATA_FILESDIR= ${TESTSDIR}/data
-${PACKAGE}DATA_FILES+= basics_v4.exp basics_v4v6.exp
-${PACKAGE}DATA_FILES+= no_host_v4.exp no_host_v4v6.exp
-${PACKAGE}DATA_FILES+= no_serv_v4.exp no_serv_v4v6.exp
-${PACKAGE}DATA_FILES+= sock_raw_v4.exp sock_raw_v4v6.exp
-${PACKAGE}DATA_FILES+= spec_fam_v4.exp spec_fam_v4v6.exp
-${PACKAGE}DATA_FILES+= scoped.exp
-${PACKAGE}DATA_FILES+= unsup_fam.exp
+${PACKAGE}DATA_FILES+= data/basics_v4.exp
+${PACKAGE}DATA_FILES+= data/basics_v4_only.exp
+${PACKAGE}DATA_FILES+= data/basics_v4v6.exp
+${PACKAGE}DATA_FILES+= data/basics_v4v6_prefer_v4.exp
+${PACKAGE}DATA_FILES+= data/no_host_v4.exp
+${PACKAGE}DATA_FILES+= data/no_host_v4_only.exp
+${PACKAGE}DATA_FILES+= data/no_host_v4v6.exp
+${PACKAGE}DATA_FILES+= data/no_host_v4v6_prefer_v4.exp
+${PACKAGE}DATA_FILES+= data/no_serv_v4.exp
+${PACKAGE}DATA_FILES+= data/no_serv_v4_only.exp
+${PACKAGE}DATA_FILES+= data/no_serv_v4v6.exp
+${PACKAGE}DATA_FILES+= data/no_serv_v4v6_prefer_v4.exp
+${PACKAGE}DATA_FILES+= data/scoped.exp
+${PACKAGE}DATA_FILES+= data/scoped_v4_only.exp
+${PACKAGE}DATA_FILES+= data/scoped_v4v6_prefer_v4.exp
+${PACKAGE}DATA_FILES+= data/sock_raw_v4.exp
+${PACKAGE}DATA_FILES+= data/sock_raw_v4_only.exp
+${PACKAGE}DATA_FILES+= data/sock_raw_v4v6.exp
+${PACKAGE}DATA_FILES+= data/sock_raw_v4v6_prefer_v4.exp
+${PACKAGE}DATA_FILES+= data/spec_fam_v4.exp
+${PACKAGE}DATA_FILES+= data/spec_fam_v4_only.exp
+${PACKAGE}DATA_FILES+= data/spec_fam_v4v6.exp
+${PACKAGE}DATA_FILES+= data/spec_fam_v4v6_prefer_v4.exp
+${PACKAGE}DATA_FILES+= data/unsup_fam.exp
+${PACKAGE}DATA_FILES+= data/unsup_fam_v4_only.exp
+${PACKAGE}DATA_FILES+= data/unsup_fam_v4v6_prefer_v4.exp
+
.include "../../Makefile.netbsd-tests"
diff --git a/lib/libc/tests/net/getaddrinfo/data/basics_v4.exp b/lib/libc/tests/net/getaddrinfo/data/basics_v4.exp
new file mode 100644
index 000000000000..4f1ee3517211
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/basics_v4.exp
@@ -0,0 +1,42 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/basics_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/basics_v4_only.exp
new file mode 100644
index 000000000000..0a37d3212649
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/basics_v4_only.exp
@@ -0,0 +1,50 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+ai4: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai5: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai6: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+ai3: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai4: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+ai4: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai5: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai6: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/basics_v4v6.exp b/lib/libc/tests/net/getaddrinfo/data/basics_v4v6.exp
new file mode 100644
index 000000000000..b74758e93e2e
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/basics_v4v6.exp
@@ -0,0 +1,50 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+ai3: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/basics_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/basics_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..0a37d3212649
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/basics_v4v6_prefer_v4.exp
@@ -0,0 +1,50 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+ai4: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai5: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai6: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+ai3: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai4: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+ai4: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai5: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai6: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/generate_testdata.sh b/lib/libc/tests/net/getaddrinfo/data/generate_testdata.sh
new file mode 100755
index 000000000000..f0425a3b0283
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/generate_testdata.sh
@@ -0,0 +1,45 @@
+#service ip6addrctl prefer_ipv4
+TEST=./h_gai
+family=v4_only
+
+( $TEST ::1 http
+ $TEST 127.0.0.1 http
+ $TEST localhost http
+ $TEST ::1 tftp
+ $TEST 127.0.0.1 tftp
+ $TEST localhost tftp
+ $TEST ::1 echo
+ $TEST 127.0.0.1 echo
+ $TEST localhost echo ) > basics_${family}.exp
+
+( $TEST -4 localhost http
+ $TEST -6 localhost http ) > spec_fam_${family}.exp
+
+( $TEST '' http
+ $TEST '' echo
+ $TEST '' tftp
+ $TEST '' 80
+ $TEST -P '' http
+ $TEST -P '' echo
+ $TEST -P '' tftp
+ $TEST -P '' 80
+ $TEST -S '' 80
+ $TEST -D '' 80 ) > no_host_${family}.exp
+
+( $TEST ::1 ''
+ $TEST 127.0.0.1 ''
+ $TEST localhost ''
+ $TEST '' '' ) > no_serv_${family}.exp
+
+( $TEST -R -p 0 localhost ''
+ $TEST -R -p 59 localhost ''
+ $TEST -R -p 59 localhost 80
+ $TEST -R -p 59 localhost www
+ $TEST -R -p 59 ::1 '' ) > sock_raw_${family}.exp
+
+( $TEST -f 99 localhost '' ) > unsup_fam_${family}.exp
+
+( $TEST fe80::1%lo0 http
+# IF=`ifconfig -a | grep -v '^ ' | sed -e 's/:.*//' | head -1 | awk '{print $1}'`
+# $TEST fe80::1%$IF http
+) > scoped_${family}.exp
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_host_v4.exp b/lib/libc/tests/net/getaddrinfo/data/no_host_v4.exp
new file mode 100644
index 000000000000..7ed41cd9d88a
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_host_v4.exp
@@ -0,0 +1,44 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai2: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai3: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv echo
+ai2: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv echo
+ai3: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv echo
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv tftp
+ai2: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv tftp
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai2: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai3: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x2 family 0 socktype 1 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 2 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_host_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/no_host_v4_only.exp
new file mode 100644
index 000000000000..596799305117
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_host_v4_only.exp
@@ -0,0 +1,68 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+ai3: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv http
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv http
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv http
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv echo
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv echo
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv echo
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv echo
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv echo
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv echo
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv tftp
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv tftp
+ai3: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv tftp
+ai4: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv tftp
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv http
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv http
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv http
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x2 family 0 socktype 1 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 2 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_host_v4v6.exp b/lib/libc/tests/net/getaddrinfo/data/no_host_v4v6.exp
new file mode 100644
index 000000000000..596799305117
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_host_v4v6.exp
@@ -0,0 +1,68 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+ai3: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv http
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv http
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv http
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv echo
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv echo
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv echo
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv echo
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv echo
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv echo
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv tftp
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv tftp
+ai3: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv tftp
+ai4: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv tftp
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv http
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv http
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv http
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x2 family 0 socktype 1 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 2 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_host_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/no_host_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..596799305117
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_host_v4v6_prefer_v4.exp
@@ -0,0 +1,68 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv echo
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv echo
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv tftp
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv tftp
+ai3: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv tftp
+ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv tftp
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv http
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv http
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv http
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv echo
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv echo
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv echo
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv echo
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv echo
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv echo
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv tftp
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv tftp
+ai3: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv tftp
+ai4: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv tftp
+
+arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x3 family 28 socktype 2 protocol 17 addrlen 28 host :: serv http
+ai2: flags 0x3 family 28 socktype 1 protocol 6 addrlen 28 host :: serv http
+ai3: flags 0x3 family 28 socktype 5 protocol 132 addrlen 28 host :: serv http
+ai4: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv http
+ai5: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv http
+ai6: flags 0x3 family 2 socktype 5 protocol 132 addrlen 16 host 0.0.0.0 serv http
+
+arg: flags 0x2 family 0 socktype 1 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 0 socktype 2 protocol 0 addrlen 0 host (empty) serv 80
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_serv_v4.exp b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4.exp
new file mode 100644
index 000000000000..667234d2161f
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4.exp
@@ -0,0 +1,17 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv (empty)
+Name does not resolve
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_serv_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4_only.exp
new file mode 100644
index 000000000000..0d28490c8d81
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4_only.exp
@@ -0,0 +1,20 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+ai4: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai5: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai6: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv (empty)
+Name does not resolve
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6.exp b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6.exp
new file mode 100644
index 000000000000..53502547c40e
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6.exp
@@ -0,0 +1,20 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+ai4: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai5: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai6: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv (empty)
+Name does not resolve
diff --git a/lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..0d28490c8d81
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/no_serv_v4v6_prefer_v4.exp
@@ -0,0 +1,20 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv 0
+ai4: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
+ai5: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
+ai6: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv (empty)
+Name does not resolve
diff --git a/lib/libc/tests/net/getaddrinfo/data/scoped.exp b/lib/libc/tests/net/getaddrinfo/data/scoped.exp
new file mode 100644
index 000000000000..f5ddb4bf6feb
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/scoped.exp
@@ -0,0 +1,5 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host fe80::1%lo0 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host fe80::1%lo0 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host fe80::1%lo0 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host fe80::1%lo0 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/scoped_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/scoped_v4_only.exp
new file mode 100644
index 000000000000..f5ddb4bf6feb
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/scoped_v4_only.exp
@@ -0,0 +1,5 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host fe80::1%lo0 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host fe80::1%lo0 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host fe80::1%lo0 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host fe80::1%lo0 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/scoped_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/scoped_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..f5ddb4bf6feb
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/scoped_v4v6_prefer_v4.exp
@@ -0,0 +1,5 @@
+arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host fe80::1%lo0 serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host fe80::1%lo0 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host fe80::1%lo0 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host fe80::1%lo0 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4.exp b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4.exp
new file mode 100644
index 000000000000..021038b81dcc
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4.exp
@@ -0,0 +1,13 @@
+arg: flags 0x2 family 0 socktype 3 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 3 protocol 0 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 3 protocol 59 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv 80
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv www
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4_only.exp
new file mode 100644
index 000000000000..932c1faab0d3
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4_only.exp
@@ -0,0 +1,15 @@
+arg: flags 0x2 family 0 socktype 3 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 3 protocol 0 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 28 socktype 3 protocol 0 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 3 protocol 59 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv 80
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv www
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6.exp b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6.exp
new file mode 100644
index 000000000000..e494271a3d35
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6.exp
@@ -0,0 +1,15 @@
+arg: flags 0x2 family 0 socktype 3 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 28 socktype 3 protocol 0 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 2 socktype 3 protocol 0 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+ai2: flags 0x2 family 2 socktype 3 protocol 59 addrlen 16 host 127.0.0.1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv 80
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv www
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..932c1faab0d3
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/sock_raw_v4v6_prefer_v4.exp
@@ -0,0 +1,15 @@
+arg: flags 0x2 family 0 socktype 3 protocol 0 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 3 protocol 0 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 28 socktype 3 protocol 0 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv (empty)
+ai1: flags 0x2 family 2 socktype 3 protocol 59 addrlen 16 host 127.0.0.1 serv 0
+ai2: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv 80
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv www
+Service was not recognized for socket type
+arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host ::1 serv (empty)
+ai1: flags 0x2 family 28 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4.exp b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4.exp
new file mode 100644
index 000000000000..924d2a16f47c
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4.exp
@@ -0,0 +1,7 @@
+arg: flags 0x2 family 2 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 28 socktype 0 protocol 0 addrlen 0 host localhost serv http
+Address family for hostname not supported
diff --git a/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4_only.exp
new file mode 100644
index 000000000000..af3506938503
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4_only.exp
@@ -0,0 +1,10 @@
+arg: flags 0x2 family 2 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 28 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6.exp b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6.exp
new file mode 100644
index 000000000000..af3506938503
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6.exp
@@ -0,0 +1,10 @@
+arg: flags 0x2 family 2 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 28 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..af3506938503
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/spec_fam_v4v6_prefer_v4.exp
@@ -0,0 +1,10 @@
+arg: flags 0x2 family 2 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv http
+ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv http
+ai3: flags 0x2 family 2 socktype 5 protocol 132 addrlen 16 host 127.0.0.1 serv http
+
+arg: flags 0x2 family 28 socktype 0 protocol 0 addrlen 0 host localhost serv http
+ai1: flags 0x2 family 28 socktype 2 protocol 17 addrlen 28 host ::1 serv http
+ai2: flags 0x2 family 28 socktype 1 protocol 6 addrlen 28 host ::1 serv http
+ai3: flags 0x2 family 28 socktype 5 protocol 132 addrlen 28 host ::1 serv http
+
diff --git a/lib/libc/tests/net/getaddrinfo/data/unsup_fam.exp b/lib/libc/tests/net/getaddrinfo/data/unsup_fam.exp
new file mode 100644
index 000000000000..69e6b48a854b
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/unsup_fam.exp
@@ -0,0 +1,2 @@
+arg: flags 0x2 family 99 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+Address family not recognized
diff --git a/lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4_only.exp b/lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4_only.exp
new file mode 100644
index 000000000000..69e6b48a854b
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4_only.exp
@@ -0,0 +1,2 @@
+arg: flags 0x2 family 99 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+Address family not recognized
diff --git a/lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4v6_prefer_v4.exp b/lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4v6_prefer_v4.exp
new file mode 100644
index 000000000000..69e6b48a854b
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/data/unsup_fam_v4v6_prefer_v4.exp
@@ -0,0 +1,2 @@
+arg: flags 0x2 family 99 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
+Address family not recognized
diff --git a/lib/libc/tests/net/getaddrinfo/getaddrinfo.c b/lib/libc/tests/net/getaddrinfo/getaddrinfo.c
new file mode 100644
index 000000000000..1e066add3119
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/getaddrinfo.c
@@ -0,0 +1,271 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Gleb Smirnoff <glebius@FreeBSD.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.
+ *
+ * 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.
+ */
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <string.h>
+#include <resolv.h>
+
+#include <atf-c.h>
+
+static const char goodname[] = "www.freebsd.org";
+static const char goodname_dot[] = "www.freebsd.org.";
+static const char badname[] = "does-not-exist.freebsd.org";
+static const char badname_dot[] = "does-not-exist.freebsd.org.";
+static const char ipv6onlyname[] = "beefy15.nyi.freebsd.org";
+static const char ipv6onlyname_dot[] = "beefy15.nyi.freebsd.org.";
+static const char ipv4onlyname[] = "ipv4only.arpa";
+static const char ipv4onlyname_dot[] = "ipv4only.arpa.";
+/*
+ * We need an IP address that doesn't exist, but not reported with ICMP
+ * unreachable by the nearest router. Let's try TEST-NET-3.
+ */
+static char badresolvconf[] = "nameserver 203.0.113.1";
+static char badresolvconf2[] = "nameserver 203.0.113.1\n"
+ "nameserver 203.0.113.2";
+static char *resconf = NULL;
+FILE *
+fopen(const char * restrict path, const char * restrict mode)
+{
+ static FILE *(*orig)(const char *, const char *);
+
+ if (orig == NULL && (orig = dlsym(RTLD_NEXT, "fopen")) == NULL)
+ atf_libc_error(ENOENT, "dlsym(fopen): %s", dlerror());
+ if (resconf != NULL && strcmp(path, _PATH_RESCONF) == 0)
+ return (fmemopen(resconf, strlen(resconf), mode));
+ else
+ return (orig(path, mode));
+}
+
+static int send_error = 0;
+ssize_t
+send(int s, const void *msg, size_t len, int flags)
+{
+ static ssize_t (*orig)(int, const void *, size_t, int);
+
+ if (orig == NULL && (orig = dlsym(RTLD_NEXT, "send")) == NULL)
+ atf_libc_error(ENOENT, "dlsym(send): %s", dlerror());
+ if (send_error != 0) {
+ errno = send_error;
+ return (-1);
+ } else {
+ return (orig(s, msg, len, flags));
+ }
+}
+
+ATF_TC(basic);
+ATF_TC_HEAD(basic, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
+
+ATF_TC_BODY(basic, tc)
+{
+ static const struct addrinfo hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_CANONNAME,
+ };
+ struct addrinfo *res;
+ int rv;
+
+ rv = getaddrinfo(goodname, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == 0,
+ "Expected 0, got %d (%s)", rv, gai_strerror(rv));
+ freeaddrinfo(res);
+
+ rv = getaddrinfo(goodname_dot, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == 0,
+ "Expected 0, got %d (%s)", rv, gai_strerror(rv));
+ freeaddrinfo(res);
+
+ rv = getaddrinfo(badname, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_NONAME,
+ "Expected %d (EAI_NONAME), got %d (%s)",
+ EAI_NONAME, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(badname_dot, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_NONAME,
+ "Expected %d (EAI_NONAME), got %d (%s)",
+ EAI_NONAME, rv, gai_strerror(rv));
+}
+
+ATF_TC_WITHOUT_HEAD(timeout);
+ATF_TC_BODY(timeout, tc)
+{
+ static const struct addrinfo hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_CANONNAME,
+ };
+ struct addrinfo *res;
+ int rv;
+
+ resconf = badresolvconf;
+ rv = getaddrinfo(goodname, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(goodname_dot, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+}
+
+ATF_TC_WITHOUT_HEAD(timeout_specific);
+ATF_TC_BODY(timeout_specific, tc)
+{
+ static const struct addrinfo hints = {
+ .ai_family = AF_INET,
+ .ai_socktype = SOCK_STREAM,
+ .ai_flags = AI_CANONNAME,
+ };
+ struct addrinfo *res;
+ int rv;
+
+ resconf = badresolvconf;
+ rv = getaddrinfo(goodname, "666", &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(goodname_dot, "666", &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+}
+
+ATF_TC_WITHOUT_HEAD(timeout2);
+ATF_TC_BODY(timeout2, tc)
+{
+ static const struct addrinfo hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_CANONNAME,
+ };
+ struct addrinfo *res;
+ int rv;
+
+ resconf = badresolvconf2;
+ rv = getaddrinfo(goodname, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(goodname_dot, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+}
+
+/*
+ * Emulate interface/network down.
+ */
+ATF_TC_WITHOUT_HEAD(netdown);
+ATF_TC_BODY(netdown, tc)
+{
+ static const struct addrinfo hints = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_CANONNAME,
+ };
+ struct addrinfo *res;
+ int rv;
+
+ send_error = ENETDOWN;
+ rv = getaddrinfo(goodname, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(goodname_dot, NULL, &hints, &res);
+ ATF_REQUIRE_MSG(rv == EAI_AGAIN,
+ "Expected %d (EAI_AGAIN), got %d (%s)",
+ EAI_AGAIN, rv, gai_strerror(rv));
+}
+
+/*
+ * See https://reviews.freebsd.org/D37139.
+ */
+ATF_TC(nofamily);
+ATF_TC_HEAD(nofamily, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
+ATF_TC_BODY(nofamily, tc)
+{
+ static const struct addrinfo hints4 = {
+ .ai_family = AF_INET,
+ .ai_flags = AI_CANONNAME,
+ }, hints6 = {
+ .ai_family = AF_INET6,
+ .ai_flags = AI_CANONNAME,
+ };
+ struct addrinfo *res;
+ int rv;
+
+ rv = getaddrinfo(ipv6onlyname, NULL, &hints4, &res);
+ ATF_REQUIRE_MSG(rv == EAI_ADDRFAMILY,
+ "Expected %d (EAI_ADDRFAMILY), got %d (%s)",
+ EAI_ADDRFAMILY, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(ipv6onlyname_dot, NULL, &hints4, &res);
+ ATF_REQUIRE_MSG(rv == EAI_ADDRFAMILY,
+ "Expected %d (EAI_ADDRFAMILY), got %d (%s)",
+ EAI_ADDRFAMILY, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(ipv4onlyname, NULL, &hints6, &res);
+ ATF_REQUIRE_MSG(rv == EAI_ADDRFAMILY,
+ "Expected %d (EAI_ADDRFAMILY), got %d (%s)",
+ EAI_ADDRFAMILY, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(ipv4onlyname_dot, NULL, &hints6, &res);
+ ATF_REQUIRE_MSG(rv == EAI_ADDRFAMILY,
+ "Expected %d (EAI_ADDRFAMILY), got %d (%s)",
+ EAI_ADDRFAMILY, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(badname, NULL, &hints4, &res);
+ ATF_REQUIRE_MSG(rv == EAI_NONAME,
+ "Expected %d (EAI_NONAME), got %d (%s)",
+ EAI_NONAME, rv, gai_strerror(rv));
+
+ rv = getaddrinfo(badname_dot, NULL, &hints6, &res);
+ ATF_REQUIRE_MSG(rv == EAI_NONAME,
+ "Expected %d (EAI_NONAME), got %d (%s)",
+ EAI_NONAME, rv, gai_strerror(rv));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, basic);
+ ATF_TP_ADD_TC(tp, timeout);
+ ATF_TP_ADD_TC(tp, timeout_specific);
+ ATF_TP_ADD_TC(tp, timeout2);
+ ATF_TP_ADD_TC(tp, netdown);
+ ATF_TP_ADD_TC(tp, nofamily);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/net/getaddrinfo/getaddrinfo_test.sh b/lib/libc/tests/net/getaddrinfo/getaddrinfo_test.sh
new file mode 100755
index 000000000000..dd17ab2e3f4a
--- /dev/null
+++ b/lib/libc/tests/net/getaddrinfo/getaddrinfo_test.sh
@@ -0,0 +1,443 @@
+# $NetBSD: t_getaddrinfo.sh,v 1.2 2011/06/15 07:54:32 jmmv Exp $
+
+#
+# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, and 2002 WIDE Project.
+# 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 project 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 PROJECT 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 PROJECT 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.
+#
+
+if [ "$(sysctl -i -n kern.features.vimage)" != 1 ]; then
+ atf_skip "This test requires VIMAGE"
+fi
+
+vnet_mkjail()
+{
+ jailname=getaddrinfo_test_$1
+ jail -c name=${jailname} persist vnet
+ ifconfig -j ${jailname} lo0 inet 127.0.0.1/8
+ # For those machines not support IPv6
+ ifconfig -j ${jailname} lo0 inet6 ::1/64 || true
+ service -j ${jailname} ip6addrctl $2 || true
+}
+
+vnet_cleanup()
+{
+ jailname=getaddrinfo_test_$1
+ jail -r ${jailname}
+}
+
+check_output()
+{
+ if [ "$2" = "none" ]; then
+ if [ "$3" = "prefer_v6" ]; then
+ exp="${1}.exp"
+ else
+ exp="${1}_v4_only.exp"
+ fi
+ elif [ "$2" = "hosts" ]; then
+ lcl=$(cat /etc/hosts | sed -e 's/#.*$//' -e 's/[ ][ ]*/ /g' | awk '/ localhost($| )/ {printf "%s ", $1}')
+ if [ "${lcl%*::*}" = "${lcl}" ]; then
+ exp="${1}_v4_only.exp"
+ else
+ if [ "$3" = "prefer_v6" ]; then
+ exp="${1}_v4v6.exp"
+ else
+ exp="${1}_v4v6_prefer_v4.exp"
+ fi
+ fi
+ elif [ "$2" = "ifconfig" ]; then
+ lcl=$(ifconfig lo0 | grep inet6)
+ if [ -n "${lcl}" ]; then
+ if [ "$3" = "prefer_v6" ]; then
+ exp="${1}_v4v6.exp"
+ else
+ exp="${1}_v4v6_prefer_v4.exp"
+ fi
+ else
+ exp="${1}_v4_only.exp"
+ fi
+ else
+ atf_fail "Invalid family_match_type $2 requested."
+ fi
+
+ cmp -s "$(atf_get_srcdir)/data/${exp}" out && return
+ diff -u "$(atf_get_srcdir)/data/${exp}" out || atf_fail "Actual output does not match expected output"
+}
+
+atf_test_case basic_prefer_v4 cleanup
+basic_prefer_v4_head()
+{
+ atf_set "descr" "Testing basic ones with prefer_v4"
+ atf_set "require.user" "root"
+}
+basic_prefer_v4_body()
+{
+ vnet_mkjail basic_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_basic_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST ::1 http
+ $TEST 127.0.0.1 http
+ $TEST localhost http
+ $TEST ::1 tftp
+ $TEST 127.0.0.1 tftp
+ $TEST localhost tftp
+ $TEST ::1 echo
+ $TEST 127.0.0.1 echo
+ $TEST localhost echo ) > out 2>&1
+
+ check_output basics hosts prefer_v4
+}
+basic_prefer_v4_cleanup()
+{
+ vnet_cleanup basic_prefer_v4
+}
+
+atf_test_case basic cleanup
+basic_head()
+{
+ atf_set "descr" "Testing basic ones with prefer_v6"
+ atf_set "require.user" "root"
+}
+basic_body()
+{
+ vnet_mkjail basic prefer_ipv6
+ TEST="jexec getaddrinfo_test_basic $(atf_get_srcdir)/h_gai"
+
+ ( $TEST ::1 http
+ $TEST 127.0.0.1 http
+ $TEST localhost http
+ $TEST ::1 tftp
+ $TEST 127.0.0.1 tftp
+ $TEST localhost tftp
+ $TEST ::1 echo
+ $TEST 127.0.0.1 echo
+ $TEST localhost echo ) > out 2>&1
+
+ check_output basics ifconfig prefer_v6
+}
+basic_cleanup()
+{
+ vnet_cleanup basic
+}
+
+atf_test_case specific_prefer_v4 cleanup
+specific_prefer_v4_head()
+{
+ atf_set "descr" "Testing specific address family with prefer_v4"
+ atf_set "require.user" "root"
+}
+specific_prefer_v4_body()
+{
+ vnet_mkjail specific_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_specific_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST -4 localhost http
+ $TEST -6 localhost http ) > out 2>&1
+
+ check_output spec_fam hosts prefer_v4
+}
+specific_prefer_v4_cleanup()
+{
+ vnet_cleanup specific_prefer_v4
+}
+
+atf_test_case specific cleanup
+specific_head()
+{
+ atf_set "descr" "Testing specific address family with prefer_v6"
+ atf_set "require.user" "root"
+}
+specific_body()
+{
+ vnet_mkjail specific prefer_ipv6
+ TEST="jexec getaddrinfo_test_specific $(atf_get_srcdir)/h_gai"
+
+ ( $TEST -4 localhost http
+ $TEST -6 localhost http ) > out 2>&1
+
+ check_output spec_fam hosts prefer_v6
+}
+specific_cleanup()
+{
+ vnet_cleanup specific
+}
+
+atf_test_case empty_hostname_prefer_v4 cleanup
+empty_hostname_prefer_v4_head()
+{
+ atf_set "descr" "Testing empty hostname with prefer_v4"
+ atf_set "require.user" "root"
+}
+empty_hostname_prefer_v4_body()
+{
+ vnet_mkjail empty_hostname_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_empty_hostname_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST '' http
+ $TEST '' echo
+ $TEST '' tftp
+ $TEST '' 80
+ $TEST -P '' http
+ $TEST -P '' echo
+ $TEST -P '' tftp
+ $TEST -P '' 80
+ $TEST -S '' 80
+ $TEST -D '' 80 ) > out 2>&1
+
+ check_output no_host ifconfig prefer_v4
+}
+empty_hostname_prefer_v4_cleanup()
+{
+ vnet_cleanup empty_hostname_prefer_v4
+}
+
+atf_test_case empty_hostname cleanup
+empty_hostname_head()
+{
+ atf_set "descr" "Testing empty hostname with prefer_v6"
+ atf_set "require.user" "root"
+}
+empty_hostname_body()
+{
+ vnet_mkjail empty_hostname prefer_ipv6
+ TEST="jexec getaddrinfo_test_empty_hostname $(atf_get_srcdir)/h_gai"
+
+ ( $TEST '' http
+ $TEST '' echo
+ $TEST '' tftp
+ $TEST '' 80
+ $TEST -P '' http
+ $TEST -P '' echo
+ $TEST -P '' tftp
+ $TEST -P '' 80
+ $TEST -S '' 80
+ $TEST -D '' 80 ) > out 2>&1
+
+ check_output no_host ifconfig prefer_v6
+}
+empty_hostname_cleanup()
+{
+ vnet_cleanup empty_hostname
+}
+
+atf_test_case empty_servname_prefer_v4 cleanup
+empty_servname_prefer_v4_head()
+{
+ atf_set "descr" "Testing empty service name with prefer_v4"
+ atf_set "require.user" "root"
+}
+empty_servname_prefer_v4_body()
+{
+ vnet_mkjail empty_servname_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_empty_servname_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST ::1 ''
+ $TEST 127.0.0.1 ''
+ $TEST localhost ''
+ $TEST '' '' ) > out 2>&1
+
+ check_output no_serv hosts prefer_v4
+}
+empty_servname_prefer_v4_cleanup()
+{
+ vnet_cleanup empty_servname_prefer_v4
+}
+
+atf_test_case empty_servname cleanup
+empty_servname_head()
+{
+ atf_set "descr" "Testing empty service name with prefer_v6"
+ atf_set "require.user" "root"
+}
+empty_servname_body()
+{
+ vnet_mkjail empty_servname prefer_ipv6
+ TEST="jexec getaddrinfo_test_empty_servname $(atf_get_srcdir)/h_gai"
+
+ ( $TEST ::1 ''
+ $TEST 127.0.0.1 ''
+ $TEST localhost ''
+ $TEST '' '' ) > out 2>&1
+
+ check_output no_serv ifconfig prefer_v6
+}
+empty_servname_cleanup()
+{
+ vnet_cleanup empty_servname
+}
+
+atf_test_case sock_raw_prefer_v4 cleanup
+sock_raw_prefer_v4_head()
+{
+ atf_set "descr" "Testing raw socket with prefer_v4"
+ atf_set "require.user" "root"
+}
+sock_raw_prefer_v4_body()
+{
+ vnet_mkjail sock_raw_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_sock_raw_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST -R -p 0 localhost ''
+ $TEST -R -p 59 localhost ''
+ $TEST -R -p 59 localhost 80
+ $TEST -R -p 59 localhost www
+ $TEST -R -p 59 ::1 '' ) > out 2>&1
+
+ check_output sock_raw hosts prefer_v4
+}
+sock_raw_prefer_v4_cleanup()
+{
+ vnet_cleanup sock_raw_prefer_v4
+}
+
+atf_test_case sock_raw cleanup
+sock_raw_head()
+{
+ atf_set "descr" "Testing raw socket with prefer_v6"
+ atf_set "require.user" "root"
+}
+sock_raw_body()
+{
+ vnet_mkjail sock_raw prefer_ipv6
+ TEST="jexec getaddrinfo_test_sock_raw $(atf_get_srcdir)/h_gai"
+
+ ( $TEST -R -p 0 localhost ''
+ $TEST -R -p 59 localhost ''
+ $TEST -R -p 59 localhost 80
+ $TEST -R -p 59 localhost www
+ $TEST -R -p 59 ::1 '' ) > out 2>&1
+
+ check_output sock_raw ifconfig prefer_v6
+}
+sock_raw_cleanup()
+{
+ vnet_cleanup sock_raw
+}
+
+atf_test_case unsupported_family_prefer_v4 cleanup
+unsupported_family_prefer_v4_head()
+{
+ atf_set "descr" "Testing unsupported family with prefer_v4"
+ atf_set "require.user" "root"
+}
+unsupported_family_prefer_v4_body()
+{
+ vnet_mkjail unsupported_family_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_unsupported_family_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST -f 99 localhost '' ) > out 2>&1
+
+ check_output unsup_fam ifconfig prefer_v4
+}
+unsupported_family_prefer_v4_cleanup()
+{
+ vnet_cleanup unsupported_family_prefer_v4
+}
+
+atf_test_case unsupported_family cleanup
+unsupported_family_head()
+{
+ atf_set "descr" "Testing unsupported family with prefer_v6"
+ atf_set "require.user" "root"
+}
+unsupported_family_body()
+{
+ vnet_mkjail unsupported_family prefer_ipv6
+ TEST="jexec getaddrinfo_test_unsupported_family $(atf_get_srcdir)/h_gai"
+
+ ( $TEST -f 99 localhost '' ) > out 2>&1
+
+ check_output unsup_fam none prefer_v6
+}
+unsupported_family_cleanup()
+{
+ vnet_cleanup unsupported_family
+}
+
+atf_test_case scopeaddr_prefer_v4 cleanup
+scopeaddr_prefer_v4_head()
+{
+ atf_set "descr" "Testing scoped address format with prefer_v4"
+ atf_set "require.user" "root"
+}
+scopeaddr_prefer_v4_body()
+{
+ vnet_mkjail scopeaddr_prefer_v4 prefer_ipv4
+ TEST="jexec getaddrinfo_test_scopeaddr_prefer_v4 $(atf_get_srcdir)/h_gai"
+
+ ( $TEST fe80::1%lo0 http
+# IF=ifconfig -a | grep -v '^ ' | sed -e 's/:.*//' | head -1 | awk '{print $1}'
+# $TEST fe80::1%$IF http
+ ) > out 2>&1
+
+ check_output scoped ifconfig prefer_v4
+}
+scopeaddr_prefer_v4_cleanup()
+{
+ vnet_cleanup scopeaddr_prefer_v4
+}
+
+atf_test_case scopeaddr cleanup
+scopeaddr_head()
+{
+ atf_set "descr" "Testing scoped address format with prefer_v6"
+ atf_set "require.user" "root"
+}
+scopeaddr_body()
+{
+ vnet_mkjail scopeaddr prefer_ipv6
+ TEST="jexec getaddrinfo_test_scopeaddr $(atf_get_srcdir)/h_gai"
+
+ ( $TEST fe80::1%lo0 http
+# IF=ifconfig -a | grep -v '^ ' | sed -e 's/:.*//' | head -1 | awk '{print $1}'
+# $TEST fe80::1%$IF http
+ ) > out 2>&1
+
+ check_output scoped none prefer_v6
+}
+scopeaddr_cleanup()
+{
+ vnet_cleanup scopeaddr
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic_prefer_v4
+ atf_add_test_case specific_prefer_v4
+ atf_add_test_case empty_hostname_prefer_v4
+ atf_add_test_case empty_servname_prefer_v4
+ atf_add_test_case sock_raw_prefer_v4
+ atf_add_test_case unsupported_family_prefer_v4
+ atf_add_test_case scopeaddr_prefer_v4
+
+ atf_add_test_case basic
+ atf_add_test_case specific
+ atf_add_test_case empty_hostname
+ atf_add_test_case empty_servname
+ atf_add_test_case sock_raw
+ atf_add_test_case unsupported_family
+ atf_add_test_case scopeaddr
+}
diff --git a/lib/libc/tests/net/link_addr_test.cc b/lib/libc/tests/net/link_addr_test.cc
new file mode 100644
index 000000000000..b973b924dc13
--- /dev/null
+++ b/lib/libc/tests/net/link_addr_test.cc
@@ -0,0 +1,532 @@
+/*
+ * Copyright (c) 2025 Lexi Winter
+ *
+ * SPDX-License-Identifier: ISC
+ */
+
+/*
+ * Tests for link_addr() and link_ntoa().
+ *
+ * link_addr converts a string representing an (optionally null) interface name
+ * followed by an Ethernet address into a sockaddr_dl. The expected format is
+ * "[ifname]:lladdr". This means if ifname is not specified, the leading colon
+ * is still required.
+ *
+ * link_ntoa does the inverse of link_addr, returning a string representation
+ * of the address.
+ *
+ * Note that the output format of link_ntoa is not valid input for link_addr
+ * since the leading colon may be omitted. This is by design.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <net/ethernet.h>
+#include <net/if_dl.h>
+
+#include <format>
+#include <iostream>
+#include <ranges>
+#include <span>
+#include <utility>
+#include <vector>
+
+#include <cstddef>
+#include <cstdint>
+
+#include <atf-c++.hpp>
+
+using namespace std::literals;
+
+/*
+ * Define operator== and operator<< for ether_addr so we can use them in
+ * ATF_EXPECT_EQ expressions.
+ */
+
+bool
+operator==(ether_addr a, ether_addr b)
+{
+ return (std::ranges::equal(a.octet, b.octet));
+}
+
+std::ostream &
+operator<<(std::ostream &s, ether_addr a)
+{
+ for (unsigned i = 0; i < ETHER_ADDR_LEN; ++i) {
+ if (i > 0)
+ s << ":";
+
+ s << std::format("{:02x}", static_cast<int>(a.octet[i]));
+ }
+
+ return (s);
+}
+
+/*
+ * Create a sockaddr_dl from a string using link_addr(), and ensure the
+ * returned struct looks valid.
+ */
+sockaddr_dl
+make_linkaddr(const std::string &addr)
+{
+ auto sdl = sockaddr_dl{};
+ int ret;
+
+ sdl.sdl_len = sizeof(sdl);
+ ret = ::link_addr(addr.c_str(), &sdl);
+
+ ATF_REQUIRE_EQ(0, ret);
+ ATF_REQUIRE_EQ(AF_LINK, static_cast<int>(sdl.sdl_family));
+ ATF_REQUIRE_EQ(true, sdl.sdl_len > 0);
+ ATF_REQUIRE_EQ(true, sdl.sdl_nlen >= 0);
+
+ return (sdl);
+}
+
+/*
+ * Return the data stored in a sockaddr_dl as a span.
+ */
+std::span<const char>
+data(const sockaddr_dl &sdl)
+{
+ // sdl_len is the entire structure, but we only want the length of the
+ // data area.
+ auto dlen = sdl.sdl_len - offsetof(sockaddr_dl, sdl_data);
+ return {&sdl.sdl_data[0], dlen};
+}
+
+/*
+ * Return the interface name stored in a sockaddr_dl as a string.
+ */
+std::string_view
+ifname(const sockaddr_dl &sdl)
+{
+ auto name = data(sdl).subspan(0, sdl.sdl_nlen);
+ return {name.begin(), name.end()};
+}
+
+/*
+ * Return the Ethernet address stored in a sockaddr_dl as an ether_addr.
+ */
+ether_addr
+addr(const sockaddr_dl &sdl)
+{
+ ether_addr ret{};
+ ATF_REQUIRE_EQ(ETHER_ADDR_LEN, sdl.sdl_alen);
+ std::ranges::copy(data(sdl).subspan(sdl.sdl_nlen, ETHER_ADDR_LEN),
+ &ret.octet[0]);
+ return (ret);
+}
+
+/*
+ * Return the link address stored in a sockaddr_dl as a span of octets.
+ */
+std::span<const std::uint8_t>
+lladdr(const sockaddr_dl &sdl)
+{
+ auto data = reinterpret_cast<const uint8_t *>(LLADDR(&sdl));
+ return {data, data + sdl.sdl_alen};
+}
+
+
+/*
+ * Some sample addresses we use for testing. Include at least one address for
+ * each format we want to support.
+ */
+
+struct test_address {
+ std::string input; /* value passed to link_addr */
+ std::string ntoa; /* expected return from link_ntoa */
+ ether_addr addr{}; /* expected return from link_addr */
+};
+
+std::vector<test_address> test_addresses{
+ // No delimiter
+ {"001122334455"s, "0.11.22.33.44.55",
+ ether_addr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}},
+
+ // Colon delimiter
+ {"00:11:22:33:44:55"s, "0.11.22.33.44.55",
+ ether_addr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}},
+
+ // Dash delimiter
+ {"00-11-22-33-44-55"s, "0.11.22.33.44.55",
+ ether_addr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}},
+
+ // Period delimiter (link_ntoa format)
+ {"00.11.22.33.44.55"s, "0.11.22.33.44.55",
+ ether_addr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}},
+
+ // Period delimiter (Cisco format)
+ {"0011.2233.4455"s, "0.11.22.33.44.55",
+ ether_addr{0x00, 0x11, 0x22, 0x33, 0x44, 0x55}},
+
+ // An addresses without leading zeroes.
+ {"0:1:02:30:4:55"s, "0.1.2.30.4.55",
+ ether_addr{0x00, 0x01, 0x02, 0x30, 0x04, 0x55}},
+
+ // An address with some uppercase letters.
+ {"AA:B:cC:Dd:e0:1f"s, "aa.b.cc.dd.e0.1f",
+ ether_addr{0xaa, 0x0b, 0xcc, 0xdd, 0xe0, 0x1f}},
+
+ // Addresses composed only of letters, to make sure they're not
+ // confused with an interface name.
+
+ {"aabbccddeeff"s, "aa.bb.cc.dd.ee.ff",
+ ether_addr{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}},
+
+ {"aa:bb:cc:dd:ee:ff"s, "aa.bb.cc.dd.ee.ff",
+ ether_addr{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}},
+
+ // Address with a blank octet; this is an old form of Ethernet address.
+ {"00:11::33:44:55"s, "0.11.0.33.44.55",
+ ether_addr{0x00, 0x11, 0x00, 0x33, 0x44, 0x55}},
+};
+
+/*
+ * Test without an interface name.
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(basic)
+ATF_TEST_CASE_BODY(basic)
+{
+ for (const auto &ta : test_addresses) {
+ // This does basic tests on the returned value.
+ auto sdl = make_linkaddr(":" + ta.input);
+
+ // Check the ifname and address.
+ ATF_REQUIRE_EQ(""s, ifname(sdl));
+ ATF_REQUIRE_EQ(ETHER_ADDR_LEN, static_cast<int>(sdl.sdl_alen));
+ ATF_REQUIRE_EQ(ta.addr, addr(sdl));
+
+ // Check link_ntoa returns the expected value.
+ auto ntoa = std::string(::link_ntoa(&sdl));
+ ATF_REQUIRE_EQ(ta.ntoa, ntoa);
+ }
+
+}
+
+/*
+ * Test with an interface name.
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(ifname)
+ATF_TEST_CASE_BODY(ifname)
+{
+ for (const auto &ta : test_addresses) {
+ auto sdl = make_linkaddr("ix0:" + ta.input);
+
+ ATF_REQUIRE_EQ("ix0", ifname(sdl));
+ ATF_REQUIRE_EQ(ETHER_ADDR_LEN, static_cast<int>(sdl.sdl_alen));
+ ATF_REQUIRE_EQ(ta.addr, addr(sdl));
+
+ auto ntoa = std::string(::link_ntoa(&sdl));
+ ATF_REQUIRE_EQ("ix0:" + ta.ntoa, ntoa);
+ }
+
+}
+
+/*
+ * Test with some invalid addresses.
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(invalid)
+ATF_TEST_CASE_BODY(invalid)
+{
+ auto const invalid_addresses = std::vector{
+ // Invalid separator
+ ":1/2/3"s,
+ "ix0:1/2/3"s,
+
+ // Multiple different separators
+ ":1.2-3"s,
+ "ix0:1.2-3"s,
+
+ // An IP address
+ ":10.1.2.200/28"s,
+ "ix0:10.1.2.200/28"s,
+
+ // Valid address followed by garbage
+ ":1.2.3xxx"s,
+ ":1.2.3.xxx"s,
+ "ix0:1.2.3xxx"s,
+ "ix0:1.2.3.xxx"s,
+ };
+
+ for (auto const &addr : invalid_addresses) {
+ int ret;
+
+ auto sdl = sockaddr_dl{};
+ sdl.sdl_len = sizeof(sdl);
+
+ ret = link_addr(addr.c_str(), &sdl);
+ ATF_REQUIRE_EQ(-1, ret);
+ }
+}
+
+/*
+ * Test some non-Ethernet addresses.
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(nonether)
+ATF_TEST_CASE_BODY(nonether)
+{
+ sockaddr_dl sdl;
+
+ /* A short address */
+ sdl = make_linkaddr(":1:23:cc");
+ ATF_REQUIRE_EQ("", ifname(sdl));
+ ATF_REQUIRE_EQ("1.23.cc"s, ::link_ntoa(&sdl));
+ ATF_REQUIRE_EQ(3, sdl.sdl_alen);
+ ATF_REQUIRE_EQ(true,
+ std::ranges::equal(std::vector{0x01u, 0x23u, 0xccu}, lladdr(sdl)));
+
+ /* A long address */
+ sdl = make_linkaddr(":1:23:cc:a:b:c:d:e:f");
+ ATF_REQUIRE_EQ("", ifname(sdl));
+ ATF_REQUIRE_EQ("1.23.cc.a.b.c.d.e.f"s, ::link_ntoa(&sdl));
+ ATF_REQUIRE_EQ(9, sdl.sdl_alen);
+ ATF_REQUIRE_EQ(true, std::ranges::equal(
+ std::vector{0x01u, 0x23u, 0xccu, 0xau, 0xbu, 0xcu, 0xdu, 0xeu, 0xfu},
+ lladdr(sdl)));
+}
+
+/*
+ * Test link_addr behaviour with undersized buffers.
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(smallbuf)
+ATF_TEST_CASE_BODY(smallbuf)
+{
+ static constexpr auto garbage = std::byte{0xcc};
+ auto buf = std::vector<std::byte>();
+ sockaddr_dl *sdl;
+ int ret;
+
+ /*
+ * Make an sdl with an sdl_data member of the appropriate size, and
+ * place it in buf. Ensure it's followed by a trailing byte of garbage
+ * so we can test that link_addr doesn't write past the end.
+ */
+ auto mksdl = [&buf](std::size_t datalen) -> sockaddr_dl * {
+ auto actual_size = datalen + offsetof(sockaddr_dl, sdl_data);
+
+ buf.resize(actual_size + 1);
+ std::ranges::fill(buf, garbage);
+
+ auto *sdl = new(reinterpret_cast<sockaddr_dl *>(&buf[0]))
+ sockaddr_dl;
+ sdl->sdl_len = actual_size;
+ return (sdl);
+ };
+
+ /* An sdl large enough to store the interface name */
+ sdl = mksdl(3);
+ ret = link_addr("ix0:1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(ENOSPC, errno);
+ ATF_REQUIRE_EQ(3, sdl->sdl_nlen);
+ ATF_REQUIRE_EQ("ix0", ifname(*sdl));
+ ATF_REQUIRE_EQ(0, static_cast<int>(sdl->sdl_alen));
+
+ /*
+ * For these tests, test both with and without an interface name, since
+ * that will overflow the buffer in different places.
+ */
+
+ /* An empty sdl. Nothing may grow on this cursed ground. */
+
+ sdl = mksdl(0);
+ ret = link_addr("ix0:1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(ENOSPC, errno);
+ ATF_REQUIRE_EQ(0, sdl->sdl_nlen);
+ ATF_REQUIRE_EQ(0, static_cast<int>(sdl->sdl_alen));
+
+ sdl = mksdl(0);
+ ret = link_addr(":1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(ENOSPC, errno);
+ ATF_REQUIRE_EQ(0, sdl->sdl_nlen);
+ ATF_REQUIRE_EQ(0, static_cast<int>(sdl->sdl_alen));
+
+ /*
+ * An sdl large enough to store the interface name and two octets of the
+ * address.
+ */
+
+ sdl = mksdl(5);
+ ret = link_addr("ix0:1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(ENOSPC, errno);
+ ATF_REQUIRE_EQ("ix0", ifname(*sdl));
+ ATF_REQUIRE(std::ranges::equal(
+ std::vector{ 0x01, 0x02 }, lladdr(*sdl)));
+
+ sdl = mksdl(2);
+ ret = link_addr(":1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(ENOSPC, errno);
+ ATF_REQUIRE_EQ("", ifname(*sdl));
+ ATF_REQUIRE(std::ranges::equal(
+ std::vector{ 0x01, 0x02 }, lladdr(*sdl)));
+
+ /*
+ * An sdl large enough to store the entire address.
+ */
+
+ sdl = mksdl(6);
+ ret = link_addr("ix0:1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(0, ret);
+ ATF_REQUIRE_EQ("ix0", ifname(*sdl));
+ ATF_REQUIRE(std::ranges::equal(
+ std::vector{ 0x01, 0x02, 0x03 }, lladdr(*sdl)));
+
+ sdl = mksdl(3);
+ ret = link_addr(":1.2.3", sdl);
+ ATF_REQUIRE(*rbegin(buf) == garbage);
+ ATF_REQUIRE_EQ(0, ret);
+ ATF_REQUIRE_EQ("", ifname(*sdl));
+ ATF_REQUIRE(std::ranges::equal(
+ std::vector{ 0x01, 0x02, 0x03 }, lladdr(*sdl)));
+}
+
+/*
+ * Test an extremely long address which would overflow link_ntoa's internal
+ * buffer. It should handle this by truncating the output.
+ * (Test for SA-16:37.libc / CVE-2016-6559.)
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(overlong)
+ATF_TEST_CASE_BODY(overlong)
+{
+ auto sdl = make_linkaddr(
+ ":01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f."
+ "11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f."
+ "22.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f");
+
+ ATF_REQUIRE_EQ(
+ "1.2.3.4.5.6.7.8.9.a.b.c.d.e.f.11.12.13.14.15.16.17.18.19.1a.1b."s,
+ ::link_ntoa(&sdl));
+}
+
+/*
+ * Test link_ntoa_r, the re-entrant version of link_ntoa().
+ */
+ATF_TEST_CASE_WITHOUT_HEAD(link_ntoa_r)
+ATF_TEST_CASE_BODY(link_ntoa_r)
+{
+ static constexpr char garbage = 0x41;
+ std::vector<char> buf;
+ sockaddr_dl sdl;
+ size_t len;
+ int ret;
+
+ // Return the contents of buf as a string, using the NUL terminator to
+ // determine length. This is to ensure we're using the return value in
+ // the same way C code would, but we do a bit more verification to
+ // elicit a test failure rather than a SEGV if it's broken.
+ auto bufstr = [&buf]() -> std::string_view {
+ // Find the NUL.
+ auto end = std::ranges::find(buf, '\0');
+ ATF_REQUIRE(end != buf.end());
+
+ // Intentionally chopping the NUL off.
+ return {begin(buf), end};
+ };
+
+ // Resize the buffer and set the contents to a known garbage value, so
+ // we don't accidentally have a NUL in the right place when link_ntoa_r
+ // didn't put it there.
+ auto resetbuf = [&buf, &len](std::size_t size) {
+ len = size;
+ buf.resize(len);
+ std::ranges::fill(buf, garbage);
+ };
+
+ // Test a short address with a large buffer.
+ sdl = make_linkaddr("ix0:1.2.3");
+ resetbuf(64);
+ ret = ::link_ntoa_r(&sdl, &buf[0], &len);
+ ATF_REQUIRE_EQ(0, ret);
+ ATF_REQUIRE_EQ(10, len);
+ ATF_REQUIRE_EQ("ix0:1.2.3"s, bufstr());
+
+ // Test a buffer which is exactly the right size.
+ sdl = make_linkaddr("ix0:1.2.3");
+ resetbuf(10);
+ ret = ::link_ntoa_r(&sdl, &buf[0], &len);
+ ATF_REQUIRE_EQ(0, ret);
+ ATF_REQUIRE_EQ(10, len);
+ ATF_REQUIRE_EQ("ix0:1.2.3"sv, bufstr());
+
+ // Test various short buffers, using a table of buffer length and the
+ // output we expect. All of these should produce valid but truncated
+ // strings, with a trailing NUL and with buflen set correctly.
+
+ auto buftests = std::vector<std::pair<std::size_t, std::string_view>>{
+ {1u, ""sv},
+ {2u, ""sv},
+ {3u, ""sv},
+ {4u, "ix0"sv},
+ {5u, "ix0:"sv},
+ {6u, "ix0:1"sv},
+ {7u, "ix0:1."sv},
+ {8u, "ix0:1.2"sv},
+ {9u, "ix0:1.2."sv},
+ };
+
+ for (auto const &[buflen, expected] : buftests) {
+ sdl = make_linkaddr("ix0:1.2.3");
+ resetbuf(buflen);
+ ret = ::link_ntoa_r(&sdl, &buf[0], &len);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(10, len);
+ ATF_REQUIRE_EQ(expected, bufstr());
+ }
+
+ // Test a NULL buffer, which should just set buflen.
+ sdl = make_linkaddr("ix0:1.2.3");
+ len = 0;
+ ret = ::link_ntoa_r(&sdl, NULL, &len);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(10, len);
+
+ // A NULL buffer with a non-zero length should also be accepted.
+ sdl = make_linkaddr("ix0:1.2.3");
+ len = 64;
+ ret = ::link_ntoa_r(&sdl, NULL, &len);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(10, len);
+
+ // Test a non-NULL buffer, but with a length of zero.
+ sdl = make_linkaddr("ix0:1.2.3");
+ resetbuf(1);
+ len = 0;
+ ret = ::link_ntoa_r(&sdl, &buf[0], &len);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(10, len);
+ // Check we really didn't write anything.
+ ATF_REQUIRE_EQ(garbage, buf[0]);
+
+ // Test a buffer which would be truncated in the middle of a two-digit
+ // hex octet, which should not write the truncated octet at all.
+ sdl = make_linkaddr("ix0:1.22.3");
+ resetbuf(8);
+ ret = ::link_ntoa_r(&sdl, &buf[0], &len);
+ ATF_REQUIRE_EQ(-1, ret);
+ ATF_REQUIRE_EQ(11, len);
+ ATF_REQUIRE_EQ("ix0:1."sv, bufstr());
+}
+
+ATF_INIT_TEST_CASES(tcs)
+{
+ ATF_ADD_TEST_CASE(tcs, basic);
+ ATF_ADD_TEST_CASE(tcs, ifname);
+ ATF_ADD_TEST_CASE(tcs, smallbuf);
+ ATF_ADD_TEST_CASE(tcs, invalid);
+ ATF_ADD_TEST_CASE(tcs, nonether);
+ ATF_ADD_TEST_CASE(tcs, overlong);
+ ATF_ADD_TEST_CASE(tcs, link_ntoa_r);
+}
diff --git a/lib/libc/tests/nss/Makefile b/lib/libc/tests/nss/Makefile
index df85dd463937..790af8c6312c 100644
--- a/lib/libc/tests/nss/Makefile
+++ b/lib/libc/tests/nss/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/resolv
PACKAGE= tests
diff --git a/lib/libc/tests/nss/getaddrinfo_test.c b/lib/libc/tests/nss/getaddrinfo_test.c
index b7c4eec99779..4528e272a46f 100644
--- a/lib/libc/tests/nss/getaddrinfo_test.c
+++ b/lib/libc/tests/nss/getaddrinfo_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <arpa/inet.h>
diff --git a/lib/libc/tests/nss/getgr_test.c b/lib/libc/tests/nss/getgr_test.c
index 28c5e2e98028..974632d4b7c7 100644
--- a/lib/libc/tests/nss/getgr_test.c
+++ b/lib/libc/tests/nss/getgr_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <arpa/inet.h>
#include <errno.h>
#include <grp.h>
@@ -294,6 +293,8 @@ group_fill_test_data(struct group_test_data *td,
int (*cb)(struct group *, void *))
{
struct group *grp;
+ const int limit = 1024;
+ int count = 0;
setgroupent(1);
while ((grp = getgrent()) != NULL) {
@@ -304,6 +305,8 @@ group_fill_test_data(struct group_test_data *td,
} else {
return (-1);
}
+ if (++count >= limit)
+ break;
}
endgrent();
diff --git a/lib/libc/tests/nss/gethostby_test.c b/lib/libc/tests/nss/gethostby_test.c
index e13ffce15dac..0ed96170fc6d 100644
--- a/lib/libc/tests/nss/gethostby_test.c
+++ b/lib/libc/tests/nss/gethostby_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <arpa/inet.h>
diff --git a/lib/libc/tests/nss/getproto_test.c b/lib/libc/tests/nss/getproto_test.c
index 18a8f8b667af..9b8250e47032 100644
--- a/lib/libc/tests/nss/getproto_test.c
+++ b/lib/libc/tests/nss/getproto_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
diff --git a/lib/libc/tests/nss/getpw_test.c b/lib/libc/tests/nss/getpw_test.c
index 7525cd28b962..434d86a31591 100644
--- a/lib/libc/tests/nss/getpw_test.c
+++ b/lib/libc/tests/nss/getpw_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <pwd.h>
#include <stdio.h>
@@ -241,6 +240,8 @@ passwd_fill_test_data(struct passwd_test_data *td,
int (*cb)(struct passwd *, void *))
{
struct passwd *pwd;
+ const int limit = 1024;
+ int count = 0;
setpassent(1);
while ((pwd = getpwent()) != NULL) {
@@ -251,6 +252,8 @@ passwd_fill_test_data(struct passwd_test_data *td,
} else {
return (-1);
}
+ if (++count >= limit)
+ break;
}
endpwent();
diff --git a/lib/libc/tests/nss/getrpc_test.c b/lib/libc/tests/nss/getrpc_test.c
index 5b7098962cf3..6cca3cab9e86 100644
--- a/lib/libc/tests/nss/getrpc_test.c
+++ b/lib/libc/tests/nss/getrpc_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <errno.h>
diff --git a/lib/libc/tests/nss/getserv_test.c b/lib/libc/tests/nss/getserv_test.c
index d74feb113a69..cc66fdb2fa52 100644
--- a/lib/libc/tests/nss/getserv_test.c
+++ b/lib/libc/tests/nss/getserv_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netdb.h>
@@ -284,6 +283,8 @@ static int
servent_fill_test_data(struct servent_test_data *td)
{
struct servent *serv;
+ const int limit = 1024;
+ int count = 0;
setservent(1);
while ((serv = getservent()) != NULL) {
@@ -291,6 +292,8 @@ servent_fill_test_data(struct servent_test_data *td)
TEST_DATA_APPEND(servent, td, serv);
else
return (-1);
+ if (++count >= limit)
+ break;
}
endservent();
diff --git a/lib/libc/tests/nss/getusershell_test.c b/lib/libc/tests/nss/getusershell_test.c
index e130f36351fb..ac23792fde8e 100644
--- a/lib/libc/tests/nss/getusershell_test.c
+++ b/lib/libc/tests/nss/getusershell_test.c
@@ -25,7 +25,6 @@
*
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
diff --git a/lib/libc/tests/regex/Makefile b/lib/libc/tests/regex/Makefile
index 00f681c0751f..65675d94c59c 100644
--- a/lib/libc/tests/regex/Makefile
+++ b/lib/libc/tests/regex/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
# local test cases
diff --git a/lib/libc/tests/regex/Makefile.inc b/lib/libc/tests/regex/Makefile.inc
index 1af987faa15e..aca7ae47be18 100644
--- a/lib/libc/tests/regex/Makefile.inc
+++ b/lib/libc/tests/regex/Makefile.inc
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
BINDIR?= ${TESTSDIR}
diff --git a/lib/libc/tests/regex/multibyte.sh b/lib/libc/tests/regex/multibyte.sh
index a736352bf0a2..18323f500a2b 100755
--- a/lib/libc/tests/regex/multibyte.sh
+++ b/lib/libc/tests/regex/multibyte.sh
@@ -1,4 +1,3 @@
-
atf_test_case bmpat
bmpat_head()
{
@@ -45,8 +44,50 @@ icase_body()
echo $c | atf_check -o "inline:$c\n" sed -ne "/$a/Ip"
}
+atf_test_case mbset cleanup
+mbset_head()
+{
+ atf_set "descr" "Check multibyte sets matching"
+}
+mbset_body()
+{
+ export LC_CTYPE="C.UTF-8"
+
+ # This involved an erroneously implemented optimization which reduces
+ # single-element sets to an exact match with a single codepoint.
+ # Match sets record small-codepoint characters in a bitmap and
+ # large-codepoint characters in an array; the optimization would falsely
+ # trigger if either the bitmap or the array was a singleton, ignoring
+ # the members of the other side of the set.
+ #
+ # To exercise this, we construct sets which have one member of one side
+ # and one or more of the other, and verify that all members can be
+ # found.
+ printf "a" > mbset; atf_check -o not-empty sed -ne '/[aà]/p' mbset
+ printf "à" > mbset; atf_check -o not-empty sed -ne '/[aà]/p' mbset
+ printf "a" > mbset; atf_check -o not-empty sed -ne '/[aàá]/p' mbset
+ printf "à" > mbset; atf_check -o not-empty sed -ne '/[aàá]/p' mbset
+ printf "á" > mbset; atf_check -o not-empty sed -ne '/[aàá]/p' mbset
+ printf "à" > mbset; atf_check -o not-empty sed -ne '/[abà]/p' mbset
+ printf "a" > mbset; atf_check -o not-empty sed -ne '/[abà]/p' mbset
+ printf "b" > mbset; atf_check -o not-empty sed -ne '/[abà]/p' mbset
+ printf "a" > mbset; atf_check -o not-empty sed -Ene '/[aà]/p' mbset
+ printf "à" > mbset; atf_check -o not-empty sed -Ene '/[aà]/p' mbset
+ printf "a" > mbset; atf_check -o not-empty sed -Ene '/[aàá]/p' mbset
+ printf "à" > mbset; atf_check -o not-empty sed -Ene '/[aàá]/p' mbset
+ printf "á" > mbset; atf_check -o not-empty sed -Ene '/[aàá]/p' mbset
+ printf "à" > mbset; atf_check -o not-empty sed -Ene '/[abà]/p' mbset
+ printf "a" > mbset; atf_check -o not-empty sed -Ene '/[abà]/p' mbset
+ printf "b" > mbset; atf_check -o not-empty sed -Ene '/[abà]/p' mbset
+}
+mbset_cleanup()
+{
+ rm -f mbset
+}
+
atf_init_test_cases()
{
atf_add_test_case bmpat
atf_add_test_case icase
+ atf_add_test_case mbset
}
diff --git a/lib/libc/tests/resolv/Makefile b/lib/libc/tests/resolv/Makefile
index f1c00f7ea5c9..25c659d56685 100644
--- a/lib/libc/tests/resolv/Makefile
+++ b/lib/libc/tests/resolv/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
TESTSDIR= ${TESTSBASE}/lib/libc/resolv
diff --git a/lib/libc/tests/rpc/Makefile b/lib/libc/tests/rpc/Makefile
index 8c908ce40c6f..621af96eb954 100644
--- a/lib/libc/tests/rpc/Makefile
+++ b/lib/libc/tests/rpc/Makefile
@@ -1,4 +1,3 @@
-
SRCS.xdr_test= ${RPCSRC:.x=_xdr.c} t_xdr.c ${RPCSRC:.x=.h} \
h_testbits.h
diff --git a/lib/libc/tests/secure/Makefile b/lib/libc/tests/secure/Makefile
new file mode 100644
index 000000000000..515f8f53a43e
--- /dev/null
+++ b/lib/libc/tests/secure/Makefile
@@ -0,0 +1,39 @@
+.include <bsd.own.mk>
+
+TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/}
+
+# sys/ headers
+FORTIFY_TCATS+= random
+FORTIFY_TCATS+= select
+FORTIFY_TCATS+= socket
+FORTIFY_TCATS+= uio
+
+# non-sys/ headers
+FORTIFY_TCATS+= poll
+FORTIFY_TCATS+= signal
+FORTIFY_TCATS+= stdlib
+FORTIFY_TCATS+= stdio
+FORTIFY_TCATS+= string
+FORTIFY_TCATS+= strings
+FORTIFY_TCATS+= unistd
+FORTIFY_TCATS+= wchar
+
+# Manually run after updating the test generator.
+lint-generator: .PHONY
+ @if ! which luacheck>/dev/null; then \
+ 1>&2 echo "devel/lua-luacheck is required to regenerate and lint these tests"; \
+ exit 1; \
+ fi
+ luacheck ${.CURDIR}/generate-fortify-tests.lua
+
+generate-tests: .PHONY lint-generator
+.for tcat in ${FORTIFY_TCATS}
+ATF_TESTS_C+= fortify_${tcat}_test
+
+.ORDER: lint-generator generate-tests-${tcat}
+generate-tests: generate-tests-${tcat}
+generate-tests-${tcat}: .PHONY
+ ${.CURDIR}/generate-fortify-tests.lua ${tcat} > ${.CURDIR}/fortify_${tcat}_test.c
+.endfor
+
+.include <bsd.test.mk>
diff --git a/lib/libc/tests/secure/fortify_poll_test.c b/lib/libc/tests/secure/fortify_poll_test.c
new file mode 100644
index 000000000000..3810c16c122f
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_poll_test.c
@@ -0,0 +1,617 @@
+/* @generated by `generate-fortify-tests.lua "poll"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(poll_before_end);
+ATF_TC_HEAD(poll_before_end, tc)
+{
+}
+ATF_TC_BODY(poll_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ poll(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(poll_end);
+ATF_TC_HEAD(poll_end, tc)
+{
+}
+ATF_TC_BODY(poll_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ poll(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(poll_after_end);
+ATF_TC_HEAD(poll_after_end, tc)
+{
+}
+ATF_TC_BODY(poll_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ poll(__stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(poll_heap_before_end);
+ATF_TC_HEAD(poll_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(poll_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ poll(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(poll_heap_end);
+ATF_TC_HEAD(poll_heap_end, tc)
+{
+}
+ATF_TC_BODY(poll_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ poll(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(poll_heap_after_end);
+ATF_TC_HEAD(poll_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(poll_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ poll(__stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(ppoll_before_end);
+ATF_TC_HEAD(ppoll_before_end, tc)
+{
+}
+ATF_TC_BODY(ppoll_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+ struct timespec tv = { 0 };
+
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ ppoll(__stack.__buf, __len, &tv, NULL);
+#undef BUF
+
+}
+
+ATF_TC(ppoll_end);
+ATF_TC_HEAD(ppoll_end, tc)
+{
+}
+ATF_TC_BODY(ppoll_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+ struct timespec tv = { 0 };
+
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ ppoll(__stack.__buf, __len, &tv, NULL);
+#undef BUF
+
+}
+
+ATF_TC(ppoll_after_end);
+ATF_TC_HEAD(ppoll_after_end, tc)
+{
+}
+ATF_TC_BODY(ppoll_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ struct timespec tv = { 0 };
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ ppoll(__stack.__buf, __len, &tv, NULL);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(ppoll_heap_before_end);
+ATF_TC_HEAD(ppoll_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(ppoll_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+ struct timespec tv = { 0 };
+
+ __stack.__buf = malloc(__bufsz);
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ ppoll(__stack.__buf, __len, &tv, NULL);
+#undef BUF
+
+}
+
+ATF_TC(ppoll_heap_end);
+ATF_TC_HEAD(ppoll_heap_end, tc)
+{
+}
+ATF_TC_BODY(ppoll_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+ struct timespec tv = { 0 };
+
+ __stack.__buf = malloc(__bufsz);
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ ppoll(__stack.__buf, __len, &tv, NULL);
+#undef BUF
+
+}
+
+ATF_TC(ppoll_heap_after_end);
+ATF_TC_HEAD(ppoll_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(ppoll_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct pollfd * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ struct timespec tv = { 0 };
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+
+ ppoll(__stack.__buf, __len, &tv, NULL);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, poll_before_end);
+ ATF_TP_ADD_TC(tp, poll_end);
+ ATF_TP_ADD_TC(tp, poll_after_end);
+ ATF_TP_ADD_TC(tp, poll_heap_before_end);
+ ATF_TP_ADD_TC(tp, poll_heap_end);
+ ATF_TP_ADD_TC(tp, poll_heap_after_end);
+ ATF_TP_ADD_TC(tp, ppoll_before_end);
+ ATF_TP_ADD_TC(tp, ppoll_end);
+ ATF_TP_ADD_TC(tp, ppoll_after_end);
+ ATF_TP_ADD_TC(tp, ppoll_heap_before_end);
+ ATF_TP_ADD_TC(tp, ppoll_heap_end);
+ ATF_TP_ADD_TC(tp, ppoll_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_random_test.c b/lib/libc/tests/secure/fortify_random_test.c
new file mode 100644
index 000000000000..2f47c981b5ae
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_random_test.c
@@ -0,0 +1,316 @@
+/* @generated by `generate-fortify-tests.lua "random"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(getrandom_before_end);
+ATF_TC_HEAD(getrandom_before_end, tc)
+{
+}
+ATF_TC_BODY(getrandom_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getrandom(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(getrandom_end);
+ATF_TC_HEAD(getrandom_end, tc)
+{
+}
+ATF_TC_BODY(getrandom_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ getrandom(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(getrandom_heap_before_end);
+ATF_TC_HEAD(getrandom_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getrandom_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getrandom(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(getrandom_heap_end);
+ATF_TC_HEAD(getrandom_heap_end, tc)
+{
+}
+ATF_TC_BODY(getrandom_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getrandom(__stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(getrandom_heap_after_end);
+ATF_TC_HEAD(getrandom_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getrandom_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getrandom(__stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, getrandom_before_end);
+ ATF_TP_ADD_TC(tp, getrandom_end);
+ ATF_TP_ADD_TC(tp, getrandom_heap_before_end);
+ ATF_TP_ADD_TC(tp, getrandom_heap_end);
+ ATF_TP_ADD_TC(tp, getrandom_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_select_test.c b/lib/libc/tests/secure/fortify_select_test.c
new file mode 100644
index 000000000000..5ee97a352e2e
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_select_test.c
@@ -0,0 +1,769 @@
+/* @generated by `generate-fortify-tests.lua "select"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(FD_SET_before_end);
+ATF_TC_HEAD(FD_SET_before_end, tc)
+{
+}
+ATF_TC_BODY(FD_SET_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE - 1;
+ const size_t __idx __unused = __len - 1;
+
+ FD_SET(__idx, &__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_SET_end);
+ATF_TC_HEAD(FD_SET_end, tc)
+{
+}
+ATF_TC_BODY(FD_SET_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE;
+ const size_t __idx __unused = __len - 1;
+
+ FD_SET(__idx, &__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_SET_after_end);
+ATF_TC_HEAD(FD_SET_after_end, tc)
+{
+}
+ATF_TC_BODY(FD_SET_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ FD_SET(__idx, &__stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(FD_SET_heap_before_end);
+ATF_TC_HEAD(FD_SET_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(FD_SET_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ FD_SET(__idx, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_SET_heap_end);
+ATF_TC_HEAD(FD_SET_heap_end, tc)
+{
+}
+ATF_TC_BODY(FD_SET_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ FD_SET(__idx, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_SET_heap_after_end);
+ATF_TC_HEAD(FD_SET_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(FD_SET_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ FD_SET(__idx, __stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(FD_CLR_before_end);
+ATF_TC_HEAD(FD_CLR_before_end, tc)
+{
+}
+ATF_TC_BODY(FD_CLR_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE - 1;
+ const size_t __idx __unused = __len - 1;
+
+ FD_CLR(__idx, &__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_CLR_end);
+ATF_TC_HEAD(FD_CLR_end, tc)
+{
+}
+ATF_TC_BODY(FD_CLR_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE;
+ const size_t __idx __unused = __len - 1;
+
+ FD_CLR(__idx, &__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_CLR_after_end);
+ATF_TC_HEAD(FD_CLR_after_end, tc)
+{
+}
+ATF_TC_BODY(FD_CLR_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ FD_CLR(__idx, &__stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(FD_CLR_heap_before_end);
+ATF_TC_HEAD(FD_CLR_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(FD_CLR_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ FD_CLR(__idx, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_CLR_heap_end);
+ATF_TC_HEAD(FD_CLR_heap_end, tc)
+{
+}
+ATF_TC_BODY(FD_CLR_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ FD_CLR(__idx, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_CLR_heap_after_end);
+ATF_TC_HEAD(FD_CLR_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(FD_CLR_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ FD_CLR(__idx, __stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(FD_ISSET_before_end);
+ATF_TC_HEAD(FD_ISSET_before_end, tc)
+{
+}
+ATF_TC_BODY(FD_ISSET_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE - 1;
+ const size_t __idx __unused = __len - 1;
+
+ FD_ISSET(__idx, &__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_ISSET_end);
+ATF_TC_HEAD(FD_ISSET_end, tc)
+{
+}
+ATF_TC_BODY(FD_ISSET_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE;
+ const size_t __idx __unused = __len - 1;
+
+ FD_ISSET(__idx, &__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_ISSET_after_end);
+ATF_TC_HEAD(FD_ISSET_after_end, tc)
+{
+}
+ATF_TC_BODY(FD_ISSET_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = FD_SETSIZE + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ FD_ISSET(__idx, &__stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(FD_ISSET_heap_before_end);
+ATF_TC_HEAD(FD_ISSET_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(FD_ISSET_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ FD_ISSET(__idx, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_ISSET_heap_end);
+ATF_TC_HEAD(FD_ISSET_heap_end, tc)
+{
+}
+ATF_TC_BODY(FD_ISSET_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ FD_ISSET(__idx, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(FD_ISSET_heap_after_end);
+ATF_TC_HEAD(FD_ISSET_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(FD_ISSET_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ fd_set * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = FD_SETSIZE + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ FD_ISSET(__idx, __stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, FD_SET_before_end);
+ ATF_TP_ADD_TC(tp, FD_SET_end);
+ ATF_TP_ADD_TC(tp, FD_SET_after_end);
+ ATF_TP_ADD_TC(tp, FD_SET_heap_before_end);
+ ATF_TP_ADD_TC(tp, FD_SET_heap_end);
+ ATF_TP_ADD_TC(tp, FD_SET_heap_after_end);
+ ATF_TP_ADD_TC(tp, FD_CLR_before_end);
+ ATF_TP_ADD_TC(tp, FD_CLR_end);
+ ATF_TP_ADD_TC(tp, FD_CLR_after_end);
+ ATF_TP_ADD_TC(tp, FD_CLR_heap_before_end);
+ ATF_TP_ADD_TC(tp, FD_CLR_heap_end);
+ ATF_TP_ADD_TC(tp, FD_CLR_heap_after_end);
+ ATF_TP_ADD_TC(tp, FD_ISSET_before_end);
+ ATF_TP_ADD_TC(tp, FD_ISSET_end);
+ ATF_TP_ADD_TC(tp, FD_ISSET_after_end);
+ ATF_TP_ADD_TC(tp, FD_ISSET_heap_before_end);
+ ATF_TP_ADD_TC(tp, FD_ISSET_heap_end);
+ ATF_TP_ADD_TC(tp, FD_ISSET_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_signal_test.c b/lib/libc/tests/secure/fortify_signal_test.c
new file mode 100644
index 000000000000..03cfb9a9a13a
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_signal_test.c
@@ -0,0 +1,316 @@
+/* @generated by `generate-fortify-tests.lua "signal"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(sig2str_before_end);
+ATF_TC_HEAD(sig2str_before_end, tc)
+{
+}
+ATF_TC_BODY(sig2str_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[SIG2STR_MAX + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = SIG2STR_MAX + 1;
+ const size_t __idx __unused = __len - 1;
+
+ sig2str(1, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(sig2str_end);
+ATF_TC_HEAD(sig2str_end, tc)
+{
+}
+ATF_TC_BODY(sig2str_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[SIG2STR_MAX];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = SIG2STR_MAX;
+ const size_t __idx __unused = __len - 1;
+
+ sig2str(1, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(sig2str_heap_before_end);
+ATF_TC_HEAD(sig2str_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(sig2str_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (SIG2STR_MAX + 1);
+ const size_t __len = SIG2STR_MAX + 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ sig2str(1, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(sig2str_heap_end);
+ATF_TC_HEAD(sig2str_heap_end, tc)
+{
+}
+ATF_TC_BODY(sig2str_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (SIG2STR_MAX);
+ const size_t __len = SIG2STR_MAX;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ sig2str(1, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(sig2str_heap_after_end);
+ATF_TC_HEAD(sig2str_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(sig2str_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (SIG2STR_MAX - 1);
+ const size_t __len = SIG2STR_MAX - 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ sig2str(1, __stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, sig2str_before_end);
+ ATF_TP_ADD_TC(tp, sig2str_end);
+ ATF_TP_ADD_TC(tp, sig2str_heap_before_end);
+ ATF_TP_ADD_TC(tp, sig2str_heap_end);
+ ATF_TP_ADD_TC(tp, sig2str_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_socket_test.c b/lib/libc/tests/secure/fortify_socket_test.c
new file mode 100644
index 000000000000..3d2dc86f4e1c
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_socket_test.c
@@ -0,0 +1,1971 @@
+/* @generated by `generate-fortify-tests.lua "socket"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(getpeername_before_end);
+ATF_TC_HEAD(getpeername_before_end, tc)
+{
+}
+ATF_TC_BODY(getpeername_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ new_socket(sock);
+ socklen = __len;
+
+ getpeername(sock[0], &__stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getpeername_end);
+ATF_TC_HEAD(getpeername_end, tc)
+{
+}
+ATF_TC_BODY(getpeername_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ new_socket(sock);
+ socklen = __len;
+
+ getpeername(sock[0], &__stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getpeername_heap_before_end);
+ATF_TC_HEAD(getpeername_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getpeername_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ getpeername(sock[0], __stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getpeername_heap_end);
+ATF_TC_HEAD(getpeername_heap_end, tc)
+{
+}
+ATF_TC_BODY(getpeername_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ getpeername(sock[0], __stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getpeername_heap_after_end);
+ATF_TC_HEAD(getpeername_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getpeername_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ getpeername(sock[0], __stack.__buf, &socklen);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getsockname_before_end);
+ATF_TC_HEAD(getsockname_before_end, tc)
+{
+}
+ATF_TC_BODY(getsockname_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ new_socket(sock);
+ socklen = __len;
+
+ getsockname(sock[0], &__stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getsockname_end);
+ATF_TC_HEAD(getsockname_end, tc)
+{
+}
+ATF_TC_BODY(getsockname_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ new_socket(sock);
+ socklen = __len;
+
+ getsockname(sock[0], &__stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getsockname_heap_before_end);
+ATF_TC_HEAD(getsockname_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getsockname_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ getsockname(sock[0], __stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getsockname_heap_end);
+ATF_TC_HEAD(getsockname_heap_end, tc)
+{
+}
+ATF_TC_BODY(getsockname_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ getsockname(sock[0], __stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(getsockname_heap_after_end);
+ATF_TC_HEAD(getsockname_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getsockname_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ socklen_t socklen;
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ getsockname(sock[0], __stack.__buf, &socklen);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recv_before_end);
+ATF_TC_HEAD(recv_before_end, tc)
+{
+}
+ATF_TC_BODY(recv_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ new_socket(sock);
+
+ recv(sock[0], __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(recv_end);
+ATF_TC_HEAD(recv_end, tc)
+{
+}
+ATF_TC_BODY(recv_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ new_socket(sock);
+
+ recv(sock[0], __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(recv_heap_before_end);
+ATF_TC_HEAD(recv_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recv_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+
+ recv(sock[0], __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(recv_heap_end);
+ATF_TC_HEAD(recv_heap_end, tc)
+{
+}
+ATF_TC_BODY(recv_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+
+ recv(sock[0], __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(recv_heap_after_end);
+ATF_TC_HEAD(recv_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recv_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+
+ recv(sock[0], __stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_before_end);
+ATF_TC_HEAD(recvfrom_before_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ new_socket(sock);
+
+ recvfrom(sock[0], __stack.__buf, __len, 0, NULL, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_end);
+ATF_TC_HEAD(recvfrom_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ new_socket(sock);
+
+ recvfrom(sock[0], __stack.__buf, __len, 0, NULL, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_heap_before_end);
+ATF_TC_HEAD(recvfrom_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+
+ recvfrom(sock[0], __stack.__buf, __len, 0, NULL, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_heap_end);
+ATF_TC_HEAD(recvfrom_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+
+ recvfrom(sock[0], __stack.__buf, __len, 0, NULL, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_heap_after_end);
+ATF_TC_HEAD(recvfrom_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+
+ recvfrom(sock[0], __stack.__buf, __len, 0, NULL, NULL);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_sockaddr_before_end);
+ATF_TC_HEAD(recvfrom_sockaddr_before_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_sockaddr_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ char data[16];
+ socklen_t socklen;
+
+ new_socket(sock);
+ socklen = __len;
+
+ recvfrom(sock[0], data, sizeof(data), 0, &__stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_sockaddr_end);
+ATF_TC_HEAD(recvfrom_sockaddr_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_sockaddr_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ char data[16];
+ socklen_t socklen;
+
+ new_socket(sock);
+ socklen = __len;
+
+ recvfrom(sock[0], data, sizeof(data), 0, &__stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_sockaddr_heap_before_end);
+ATF_TC_HEAD(recvfrom_sockaddr_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_sockaddr_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ char data[16];
+ socklen_t socklen;
+
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ recvfrom(sock[0], data, sizeof(data), 0, __stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_sockaddr_heap_end);
+ATF_TC_HEAD(recvfrom_sockaddr_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_sockaddr_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ char data[16];
+ socklen_t socklen;
+
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ recvfrom(sock[0], data, sizeof(data), 0, __stack.__buf, &socklen);
+#undef BUF
+
+}
+
+ATF_TC(recvfrom_sockaddr_heap_after_end);
+ATF_TC_HEAD(recvfrom_sockaddr_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvfrom_sockaddr_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ char data[16];
+ socklen_t socklen;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ new_socket(sock);
+ socklen = __len;
+
+ recvfrom(sock[0], data, sizeof(data), 0, __stack.__buf, &socklen);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_name_before_end);
+ATF_TC_HEAD(recvmsg_msg_name_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_name_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = BUF;
+ msg.msg_namelen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_name_end);
+ATF_TC_HEAD(recvmsg_msg_name_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_name_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = BUF;
+ msg.msg_namelen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_name_heap_before_end);
+ATF_TC_HEAD(recvmsg_msg_name_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_name_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = BUF;
+ msg.msg_namelen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_name_heap_end);
+ATF_TC_HEAD(recvmsg_msg_name_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_name_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr);
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = BUF;
+ msg.msg_namelen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_name_heap_after_end);
+ATF_TC_HEAD(recvmsg_msg_name_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_name_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct sockaddr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (1);
+ const size_t __len = sizeof(struct sockaddr) + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = BUF;
+ msg.msg_namelen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_iov_before_end);
+ATF_TC_HEAD(recvmsg_msg_iov_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_iov_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&iov[0], 0, sizeof(iov));
+
+ /*
+ * We position the buffer second just so that we can confirm that the
+ * fortification bits are traversing the iovec correctly.
+ */
+ iov[1].iov_base = BUF;
+ iov[1].iov_len = __len;
+
+ msg.msg_iov = &iov[0];
+ msg.msg_iovlen = nitems(iov);
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_iov_end);
+ATF_TC_HEAD(recvmsg_msg_iov_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_iov_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ memset(&msg, 0, sizeof(msg));
+ memset(&iov[0], 0, sizeof(iov));
+
+ /*
+ * We position the buffer second just so that we can confirm that the
+ * fortification bits are traversing the iovec correctly.
+ */
+ iov[1].iov_base = BUF;
+ iov[1].iov_len = __len;
+
+ msg.msg_iov = &iov[0];
+ msg.msg_iovlen = nitems(iov);
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_iov_heap_before_end);
+ATF_TC_HEAD(recvmsg_msg_iov_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_iov_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+ memset(&iov[0], 0, sizeof(iov));
+
+ /*
+ * We position the buffer second just so that we can confirm that the
+ * fortification bits are traversing the iovec correctly.
+ */
+ iov[1].iov_base = BUF;
+ iov[1].iov_len = __len;
+
+ msg.msg_iov = &iov[0];
+ msg.msg_iovlen = nitems(iov);
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_iov_heap_end);
+ATF_TC_HEAD(recvmsg_msg_iov_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_iov_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+ memset(&iov[0], 0, sizeof(iov));
+
+ /*
+ * We position the buffer second just so that we can confirm that the
+ * fortification bits are traversing the iovec correctly.
+ */
+ iov[1].iov_base = BUF;
+ iov[1].iov_len = __len;
+
+ msg.msg_iov = &iov[0];
+ msg.msg_iovlen = nitems(iov);
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_iov_heap_after_end);
+ATF_TC_HEAD(recvmsg_msg_iov_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_iov_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+ struct iovec iov[2];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+ memset(&iov[0], 0, sizeof(iov));
+
+ /*
+ * We position the buffer second just so that we can confirm that the
+ * fortification bits are traversing the iovec correctly.
+ */
+ iov[1].iov_base = BUF;
+ iov[1].iov_len = __len;
+
+ msg.msg_iov = &iov[0];
+ msg.msg_iovlen = nitems(iov);
+
+ recvmsg(sock[0], &msg, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_control_before_end);
+ATF_TC_HEAD(recvmsg_msg_control_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_control_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[CMSG_SPACE(sizeof(int))];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = CMSG_SPACE(sizeof(int)) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = BUF;
+ msg.msg_controllen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_control_end);
+ATF_TC_HEAD(recvmsg_msg_control_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_control_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[CMSG_SPACE(sizeof(int))];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = CMSG_SPACE(sizeof(int));
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = BUF;
+ msg.msg_controllen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_control_heap_before_end);
+ATF_TC_HEAD(recvmsg_msg_control_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_control_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (CMSG_SPACE(sizeof(int)));
+ const size_t __len = CMSG_SPACE(sizeof(int)) - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = BUF;
+ msg.msg_controllen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_control_heap_end);
+ATF_TC_HEAD(recvmsg_msg_control_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_control_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (CMSG_SPACE(sizeof(int)));
+ const size_t __len = CMSG_SPACE(sizeof(int));
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = BUF;
+ msg.msg_controllen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+#undef BUF
+
+}
+
+ATF_TC(recvmsg_msg_control_heap_after_end);
+ATF_TC_HEAD(recvmsg_msg_control_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvmsg_msg_control_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (CMSG_SPACE(sizeof(int)));
+ const size_t __len = CMSG_SPACE(sizeof(int)) + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ struct msghdr msg;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = BUF;
+ msg.msg_controllen = __len;
+
+ recvmsg(sock[0], &msg, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msgvec_before_end);
+ATF_TC_HEAD(recvmmsg_msgvec_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msgvec_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct mmsghdr __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ recvmmsg(sock[0], __stack.__buf, __len, 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msgvec_end);
+ATF_TC_HEAD(recvmmsg_msgvec_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msgvec_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct mmsghdr __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ recvmmsg(sock[0], __stack.__buf, __len, 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msgvec_after_end);
+ATF_TC_HEAD(recvmmsg_msgvec_after_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msgvec_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct mmsghdr __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ recvmmsg(sock[0], __stack.__buf, __len, 0, NULL);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msgvec_heap_before_end);
+ATF_TC_HEAD(recvmmsg_msgvec_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msgvec_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct mmsghdr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ __stack.__buf = malloc(__bufsz);
+
+ recvmmsg(sock[0], __stack.__buf, __len, 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msgvec_heap_end);
+ATF_TC_HEAD(recvmmsg_msgvec_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msgvec_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct mmsghdr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+
+ __stack.__buf = malloc(__bufsz);
+
+ recvmmsg(sock[0], __stack.__buf, __len, 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msgvec_heap_after_end);
+ATF_TC_HEAD(recvmmsg_msgvec_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msgvec_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct mmsghdr * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ recvmmsg(sock[0], __stack.__buf, __len, 0, NULL);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msghdr_before_end);
+ATF_TC_HEAD(recvmmsg_msghdr_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msghdr_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct mmsghdr msgvec[2];
+
+ memset(&msgvec[0], 0, sizeof(msgvec));
+
+ /*
+ * Same as above, make sure fortification isn't ignoring n > 1 elements
+ * of the msgvec.
+ */
+ msgvec[1].msg_hdr.msg_control = BUF;
+ msgvec[1].msg_hdr.msg_controllen = __len;
+
+ recvmmsg(sock[0], &msgvec[0], nitems(msgvec), 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msghdr_end);
+ATF_TC_HEAD(recvmmsg_msghdr_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msghdr_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct mmsghdr msgvec[2];
+
+ memset(&msgvec[0], 0, sizeof(msgvec));
+
+ /*
+ * Same as above, make sure fortification isn't ignoring n > 1 elements
+ * of the msgvec.
+ */
+ msgvec[1].msg_hdr.msg_control = BUF;
+ msgvec[1].msg_hdr.msg_controllen = __len;
+
+ recvmmsg(sock[0], &msgvec[0], nitems(msgvec), 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msghdr_heap_before_end);
+ATF_TC_HEAD(recvmmsg_msghdr_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msghdr_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct mmsghdr msgvec[2];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msgvec[0], 0, sizeof(msgvec));
+
+ /*
+ * Same as above, make sure fortification isn't ignoring n > 1 elements
+ * of the msgvec.
+ */
+ msgvec[1].msg_hdr.msg_control = BUF;
+ msgvec[1].msg_hdr.msg_controllen = __len;
+
+ recvmmsg(sock[0], &msgvec[0], nitems(msgvec), 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msghdr_heap_end);
+ATF_TC_HEAD(recvmmsg_msghdr_heap_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msghdr_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int sock[2] = { -1, -1 };
+ struct mmsghdr msgvec[2];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(&msgvec[0], 0, sizeof(msgvec));
+
+ /*
+ * Same as above, make sure fortification isn't ignoring n > 1 elements
+ * of the msgvec.
+ */
+ msgvec[1].msg_hdr.msg_control = BUF;
+ msgvec[1].msg_hdr.msg_controllen = __len;
+
+ recvmmsg(sock[0], &msgvec[0], nitems(msgvec), 0, NULL);
+#undef BUF
+
+}
+
+ATF_TC(recvmmsg_msghdr_heap_after_end);
+ATF_TC_HEAD(recvmmsg_msghdr_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(recvmmsg_msghdr_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int sock[2] = { -1, -1 };
+ struct mmsghdr msgvec[2];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(&msgvec[0], 0, sizeof(msgvec));
+
+ /*
+ * Same as above, make sure fortification isn't ignoring n > 1 elements
+ * of the msgvec.
+ */
+ msgvec[1].msg_hdr.msg_control = BUF;
+ msgvec[1].msg_hdr.msg_controllen = __len;
+
+ recvmmsg(sock[0], &msgvec[0], nitems(msgvec), 0, NULL);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, getpeername_before_end);
+ ATF_TP_ADD_TC(tp, getpeername_end);
+ ATF_TP_ADD_TC(tp, getpeername_heap_before_end);
+ ATF_TP_ADD_TC(tp, getpeername_heap_end);
+ ATF_TP_ADD_TC(tp, getpeername_heap_after_end);
+ ATF_TP_ADD_TC(tp, getsockname_before_end);
+ ATF_TP_ADD_TC(tp, getsockname_end);
+ ATF_TP_ADD_TC(tp, getsockname_heap_before_end);
+ ATF_TP_ADD_TC(tp, getsockname_heap_end);
+ ATF_TP_ADD_TC(tp, getsockname_heap_after_end);
+ ATF_TP_ADD_TC(tp, recv_before_end);
+ ATF_TP_ADD_TC(tp, recv_end);
+ ATF_TP_ADD_TC(tp, recv_heap_before_end);
+ ATF_TP_ADD_TC(tp, recv_heap_end);
+ ATF_TP_ADD_TC(tp, recv_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvfrom_before_end);
+ ATF_TP_ADD_TC(tp, recvfrom_end);
+ ATF_TP_ADD_TC(tp, recvfrom_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvfrom_heap_end);
+ ATF_TP_ADD_TC(tp, recvfrom_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvfrom_sockaddr_before_end);
+ ATF_TP_ADD_TC(tp, recvfrom_sockaddr_end);
+ ATF_TP_ADD_TC(tp, recvfrom_sockaddr_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvfrom_sockaddr_heap_end);
+ ATF_TP_ADD_TC(tp, recvfrom_sockaddr_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_name_before_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_name_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_name_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_name_heap_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_name_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_iov_before_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_iov_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_iov_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_iov_heap_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_iov_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_control_before_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_control_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_control_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_control_heap_end);
+ ATF_TP_ADD_TC(tp, recvmsg_msg_control_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msgvec_before_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msgvec_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msgvec_after_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msgvec_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msgvec_heap_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msgvec_heap_after_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msghdr_before_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msghdr_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msghdr_heap_before_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msghdr_heap_end);
+ ATF_TP_ADD_TC(tp, recvmmsg_msghdr_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_stdio_test.c b/lib/libc/tests/secure/fortify_stdio_test.c
new file mode 100644
index 000000000000..17842393a740
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_stdio_test.c
@@ -0,0 +1,1559 @@
+/* @generated by `generate-fortify-tests.lua "stdio"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(ctermid_before_end);
+ATF_TC_HEAD(ctermid_before_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[L_ctermid + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = L_ctermid + 1;
+ const size_t __idx __unused = __len - 1;
+
+ ctermid(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_end);
+ATF_TC_HEAD(ctermid_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[L_ctermid];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = L_ctermid;
+ const size_t __idx __unused = __len - 1;
+
+ ctermid(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_heap_before_end);
+ATF_TC_HEAD(ctermid_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_ctermid + 1);
+ const size_t __len = L_ctermid + 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ ctermid(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_heap_end);
+ATF_TC_HEAD(ctermid_heap_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_ctermid);
+ const size_t __len = L_ctermid;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ ctermid(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_heap_after_end);
+ATF_TC_HEAD(ctermid_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_ctermid - 1);
+ const size_t __len = L_ctermid - 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ ctermid(__stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(ctermid_r_before_end);
+ATF_TC_HEAD(ctermid_r_before_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_r_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[L_ctermid + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = L_ctermid + 1;
+ const size_t __idx __unused = __len - 1;
+
+ ctermid_r(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_r_end);
+ATF_TC_HEAD(ctermid_r_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_r_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[L_ctermid];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = L_ctermid;
+ const size_t __idx __unused = __len - 1;
+
+ ctermid_r(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_r_heap_before_end);
+ATF_TC_HEAD(ctermid_r_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_r_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_ctermid + 1);
+ const size_t __len = L_ctermid + 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ ctermid_r(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_r_heap_end);
+ATF_TC_HEAD(ctermid_r_heap_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_r_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_ctermid);
+ const size_t __len = L_ctermid;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ ctermid_r(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(ctermid_r_heap_after_end);
+ATF_TC_HEAD(ctermid_r_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(ctermid_r_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_ctermid - 1);
+ const size_t __len = L_ctermid - 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ ctermid_r(__stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(fread_before_end);
+ATF_TC_HEAD(fread_before_end, tc)
+{
+}
+ATF_TC_BODY(fread_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ replace_stdin();
+
+ fread(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_end);
+ATF_TC_HEAD(fread_end, tc)
+{
+}
+ATF_TC_BODY(fread_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ replace_stdin();
+
+ fread(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_heap_before_end);
+ATF_TC_HEAD(fread_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(fread_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ fread(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_heap_end);
+ATF_TC_HEAD(fread_heap_end, tc)
+{
+}
+ATF_TC_BODY(fread_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ fread(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_heap_after_end);
+ATF_TC_HEAD(fread_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(fread_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ fread(__stack.__buf, __len, 1, stdin);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(fread_unlocked_before_end);
+ATF_TC_HEAD(fread_unlocked_before_end, tc)
+{
+}
+ATF_TC_BODY(fread_unlocked_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ replace_stdin();
+
+ fread_unlocked(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_unlocked_end);
+ATF_TC_HEAD(fread_unlocked_end, tc)
+{
+}
+ATF_TC_BODY(fread_unlocked_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ replace_stdin();
+
+ fread_unlocked(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_unlocked_heap_before_end);
+ATF_TC_HEAD(fread_unlocked_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(fread_unlocked_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ fread_unlocked(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_unlocked_heap_end);
+ATF_TC_HEAD(fread_unlocked_heap_end, tc)
+{
+}
+ATF_TC_BODY(fread_unlocked_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ fread_unlocked(__stack.__buf, __len, 1, stdin);
+#undef BUF
+
+}
+
+ATF_TC(fread_unlocked_heap_after_end);
+ATF_TC_HEAD(fread_unlocked_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(fread_unlocked_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ fread_unlocked(__stack.__buf, __len, 1, stdin);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(gets_s_before_end);
+ATF_TC_HEAD(gets_s_before_end, tc)
+{
+}
+ATF_TC_BODY(gets_s_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ replace_stdin();
+
+ gets_s(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gets_s_end);
+ATF_TC_HEAD(gets_s_end, tc)
+{
+}
+ATF_TC_BODY(gets_s_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ replace_stdin();
+
+ gets_s(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gets_s_heap_before_end);
+ATF_TC_HEAD(gets_s_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(gets_s_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ gets_s(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gets_s_heap_end);
+ATF_TC_HEAD(gets_s_heap_end, tc)
+{
+}
+ATF_TC_BODY(gets_s_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ gets_s(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gets_s_heap_after_end);
+ATF_TC_HEAD(gets_s_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(gets_s_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ replace_stdin();
+
+ gets_s(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(sprintf_before_end);
+ATF_TC_HEAD(sprintf_before_end, tc)
+{
+}
+ATF_TC_BODY(sprintf_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ sprintf(__stack.__buf, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(sprintf_end);
+ATF_TC_HEAD(sprintf_end, tc)
+{
+}
+ATF_TC_BODY(sprintf_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ sprintf(__stack.__buf, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(sprintf_heap_before_end);
+ATF_TC_HEAD(sprintf_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(sprintf_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ sprintf(__stack.__buf, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(sprintf_heap_end);
+ATF_TC_HEAD(sprintf_heap_end, tc)
+{
+}
+ATF_TC_BODY(sprintf_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ sprintf(__stack.__buf, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(sprintf_heap_after_end);
+ATF_TC_HEAD(sprintf_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(sprintf_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char srcvar[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ sprintf(__stack.__buf, "%.*s", (int)__len - 1, srcvar);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(snprintf_before_end);
+ATF_TC_HEAD(snprintf_before_end, tc)
+{
+}
+ATF_TC_BODY(snprintf_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ snprintf(__stack.__buf, __len, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(snprintf_end);
+ATF_TC_HEAD(snprintf_end, tc)
+{
+}
+ATF_TC_BODY(snprintf_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ snprintf(__stack.__buf, __len, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(snprintf_heap_before_end);
+ATF_TC_HEAD(snprintf_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(snprintf_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ snprintf(__stack.__buf, __len, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(snprintf_heap_end);
+ATF_TC_HEAD(snprintf_heap_end, tc)
+{
+}
+ATF_TC_BODY(snprintf_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char srcvar[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ snprintf(__stack.__buf, __len, "%.*s", (int)__len - 1, srcvar);
+#undef BUF
+
+}
+
+ATF_TC(snprintf_heap_after_end);
+ATF_TC_HEAD(snprintf_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(snprintf_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char srcvar[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+
+ snprintf(__stack.__buf, __len, "%.*s", (int)__len - 1, srcvar);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(tmpnam_before_end);
+ATF_TC_HEAD(tmpnam_before_end, tc)
+{
+}
+ATF_TC_BODY(tmpnam_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[L_tmpnam + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = L_tmpnam + 1;
+ const size_t __idx __unused = __len - 1;
+
+ tmpnam(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(tmpnam_end);
+ATF_TC_HEAD(tmpnam_end, tc)
+{
+}
+ATF_TC_BODY(tmpnam_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[L_tmpnam];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = L_tmpnam;
+ const size_t __idx __unused = __len - 1;
+
+ tmpnam(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(tmpnam_heap_before_end);
+ATF_TC_HEAD(tmpnam_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(tmpnam_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_tmpnam + 1);
+ const size_t __len = L_tmpnam + 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ tmpnam(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(tmpnam_heap_end);
+ATF_TC_HEAD(tmpnam_heap_end, tc)
+{
+}
+ATF_TC_BODY(tmpnam_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_tmpnam);
+ const size_t __len = L_tmpnam;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ tmpnam(__stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(tmpnam_heap_after_end);
+ATF_TC_HEAD(tmpnam_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(tmpnam_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (L_tmpnam - 1);
+ const size_t __len = L_tmpnam - 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ tmpnam(__stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(fgets_before_end);
+ATF_TC_HEAD(fgets_before_end, tc)
+{
+}
+ATF_TC_BODY(fgets_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ FILE *fp;
+
+ fp = new_fp(__len);
+
+ fgets(__stack.__buf, __len, fp);
+#undef BUF
+
+}
+
+ATF_TC(fgets_end);
+ATF_TC_HEAD(fgets_end, tc)
+{
+}
+ATF_TC_BODY(fgets_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ FILE *fp;
+
+ fp = new_fp(__len);
+
+ fgets(__stack.__buf, __len, fp);
+#undef BUF
+
+}
+
+ATF_TC(fgets_heap_before_end);
+ATF_TC_HEAD(fgets_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(fgets_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ FILE *fp;
+
+ __stack.__buf = malloc(__bufsz);
+ fp = new_fp(__len);
+
+ fgets(__stack.__buf, __len, fp);
+#undef BUF
+
+}
+
+ATF_TC(fgets_heap_end);
+ATF_TC_HEAD(fgets_heap_end, tc)
+{
+}
+ATF_TC_BODY(fgets_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ FILE *fp;
+
+ __stack.__buf = malloc(__bufsz);
+ fp = new_fp(__len);
+
+ fgets(__stack.__buf, __len, fp);
+#undef BUF
+
+}
+
+ATF_TC(fgets_heap_after_end);
+ATF_TC_HEAD(fgets_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(fgets_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ FILE *fp;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ fp = new_fp(__len);
+
+ fgets(__stack.__buf, __len, fp);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, ctermid_before_end);
+ ATF_TP_ADD_TC(tp, ctermid_end);
+ ATF_TP_ADD_TC(tp, ctermid_heap_before_end);
+ ATF_TP_ADD_TC(tp, ctermid_heap_end);
+ ATF_TP_ADD_TC(tp, ctermid_heap_after_end);
+ ATF_TP_ADD_TC(tp, ctermid_r_before_end);
+ ATF_TP_ADD_TC(tp, ctermid_r_end);
+ ATF_TP_ADD_TC(tp, ctermid_r_heap_before_end);
+ ATF_TP_ADD_TC(tp, ctermid_r_heap_end);
+ ATF_TP_ADD_TC(tp, ctermid_r_heap_after_end);
+ ATF_TP_ADD_TC(tp, fread_before_end);
+ ATF_TP_ADD_TC(tp, fread_end);
+ ATF_TP_ADD_TC(tp, fread_heap_before_end);
+ ATF_TP_ADD_TC(tp, fread_heap_end);
+ ATF_TP_ADD_TC(tp, fread_heap_after_end);
+ ATF_TP_ADD_TC(tp, fread_unlocked_before_end);
+ ATF_TP_ADD_TC(tp, fread_unlocked_end);
+ ATF_TP_ADD_TC(tp, fread_unlocked_heap_before_end);
+ ATF_TP_ADD_TC(tp, fread_unlocked_heap_end);
+ ATF_TP_ADD_TC(tp, fread_unlocked_heap_after_end);
+ ATF_TP_ADD_TC(tp, gets_s_before_end);
+ ATF_TP_ADD_TC(tp, gets_s_end);
+ ATF_TP_ADD_TC(tp, gets_s_heap_before_end);
+ ATF_TP_ADD_TC(tp, gets_s_heap_end);
+ ATF_TP_ADD_TC(tp, gets_s_heap_after_end);
+ ATF_TP_ADD_TC(tp, sprintf_before_end);
+ ATF_TP_ADD_TC(tp, sprintf_end);
+ ATF_TP_ADD_TC(tp, sprintf_heap_before_end);
+ ATF_TP_ADD_TC(tp, sprintf_heap_end);
+ ATF_TP_ADD_TC(tp, sprintf_heap_after_end);
+ ATF_TP_ADD_TC(tp, snprintf_before_end);
+ ATF_TP_ADD_TC(tp, snprintf_end);
+ ATF_TP_ADD_TC(tp, snprintf_heap_before_end);
+ ATF_TP_ADD_TC(tp, snprintf_heap_end);
+ ATF_TP_ADD_TC(tp, snprintf_heap_after_end);
+ ATF_TP_ADD_TC(tp, tmpnam_before_end);
+ ATF_TP_ADD_TC(tp, tmpnam_end);
+ ATF_TP_ADD_TC(tp, tmpnam_heap_before_end);
+ ATF_TP_ADD_TC(tp, tmpnam_heap_end);
+ ATF_TP_ADD_TC(tp, tmpnam_heap_after_end);
+ ATF_TP_ADD_TC(tp, fgets_before_end);
+ ATF_TP_ADD_TC(tp, fgets_end);
+ ATF_TP_ADD_TC(tp, fgets_heap_before_end);
+ ATF_TP_ADD_TC(tp, fgets_heap_end);
+ ATF_TP_ADD_TC(tp, fgets_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_stdlib_test.c b/lib/libc/tests/secure/fortify_stdlib_test.c
new file mode 100644
index 000000000000..d0b1af78da86
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_stdlib_test.c
@@ -0,0 +1,610 @@
+/* @generated by `generate-fortify-tests.lua "stdlib"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(arc4random_buf_before_end);
+ATF_TC_HEAD(arc4random_buf_before_end, tc)
+{
+}
+ATF_TC_BODY(arc4random_buf_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ arc4random_buf(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(arc4random_buf_end);
+ATF_TC_HEAD(arc4random_buf_end, tc)
+{
+}
+ATF_TC_BODY(arc4random_buf_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ arc4random_buf(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(arc4random_buf_heap_before_end);
+ATF_TC_HEAD(arc4random_buf_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(arc4random_buf_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ arc4random_buf(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(arc4random_buf_heap_end);
+ATF_TC_HEAD(arc4random_buf_heap_end, tc)
+{
+}
+ATF_TC_BODY(arc4random_buf_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ arc4random_buf(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(arc4random_buf_heap_after_end);
+ATF_TC_HEAD(arc4random_buf_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(arc4random_buf_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ arc4random_buf(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getenv_r_before_end);
+ATF_TC_HEAD(getenv_r_before_end, tc)
+{
+}
+ATF_TC_BODY(getenv_r_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getenv_r("PATH", __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getenv_r_end);
+ATF_TC_HEAD(getenv_r_end, tc)
+{
+}
+ATF_TC_BODY(getenv_r_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ getenv_r("PATH", __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getenv_r_heap_before_end);
+ATF_TC_HEAD(getenv_r_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getenv_r_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getenv_r("PATH", __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getenv_r_heap_end);
+ATF_TC_HEAD(getenv_r_heap_end, tc)
+{
+}
+ATF_TC_BODY(getenv_r_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getenv_r("PATH", __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getenv_r_heap_after_end);
+ATF_TC_HEAD(getenv_r_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getenv_r_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getenv_r("PATH", __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(realpath_before_end);
+ATF_TC_HEAD(realpath_before_end, tc)
+{
+}
+ATF_TC_BODY(realpath_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[PATH_MAX + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = PATH_MAX + 1;
+ const size_t __idx __unused = __len - 1;
+
+ realpath(".", __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(realpath_end);
+ATF_TC_HEAD(realpath_end, tc)
+{
+}
+ATF_TC_BODY(realpath_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[PATH_MAX];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = PATH_MAX;
+ const size_t __idx __unused = __len - 1;
+
+ realpath(".", __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(realpath_heap_before_end);
+ATF_TC_HEAD(realpath_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(realpath_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (PATH_MAX + 1);
+ const size_t __len = PATH_MAX + 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ realpath(".", __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(realpath_heap_end);
+ATF_TC_HEAD(realpath_heap_end, tc)
+{
+}
+ATF_TC_BODY(realpath_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (PATH_MAX);
+ const size_t __len = PATH_MAX;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ realpath(".", __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(realpath_heap_after_end);
+ATF_TC_HEAD(realpath_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(realpath_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (PATH_MAX - 1);
+ const size_t __len = PATH_MAX - 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ realpath(".", __stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, arc4random_buf_before_end);
+ ATF_TP_ADD_TC(tp, arc4random_buf_end);
+ ATF_TP_ADD_TC(tp, arc4random_buf_heap_before_end);
+ ATF_TP_ADD_TC(tp, arc4random_buf_heap_end);
+ ATF_TP_ADD_TC(tp, arc4random_buf_heap_after_end);
+ ATF_TP_ADD_TC(tp, getenv_r_before_end);
+ ATF_TP_ADD_TC(tp, getenv_r_end);
+ ATF_TP_ADD_TC(tp, getenv_r_heap_before_end);
+ ATF_TP_ADD_TC(tp, getenv_r_heap_end);
+ ATF_TP_ADD_TC(tp, getenv_r_heap_after_end);
+ ATF_TP_ADD_TC(tp, realpath_before_end);
+ ATF_TP_ADD_TC(tp, realpath_end);
+ ATF_TP_ADD_TC(tp, realpath_heap_before_end);
+ ATF_TP_ADD_TC(tp, realpath_heap_end);
+ ATF_TP_ADD_TC(tp, realpath_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_string_test.c b/lib/libc/tests/secure/fortify_string_test.c
new file mode 100644
index 000000000000..cfea261ff66f
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_string_test.c
@@ -0,0 +1,2271 @@
+/* @generated by `generate-fortify-tests.lua "string"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(memcpy_before_end);
+ATF_TC_HEAD(memcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(memcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ memcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memcpy_end);
+ATF_TC_HEAD(memcpy_end, tc)
+{
+}
+ATF_TC_BODY(memcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ memcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memcpy_heap_before_end);
+ATF_TC_HEAD(memcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(memcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ memcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memcpy_heap_end);
+ATF_TC_HEAD(memcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(memcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ memcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memcpy_heap_after_end);
+ATF_TC_HEAD(memcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(memcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ memcpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(mempcpy_before_end);
+ATF_TC_HEAD(mempcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(mempcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ mempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(mempcpy_end);
+ATF_TC_HEAD(mempcpy_end, tc)
+{
+}
+ATF_TC_BODY(mempcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ mempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(mempcpy_heap_before_end);
+ATF_TC_HEAD(mempcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(mempcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ mempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(mempcpy_heap_end);
+ATF_TC_HEAD(mempcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(mempcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ mempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(mempcpy_heap_after_end);
+ATF_TC_HEAD(mempcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(mempcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ mempcpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(memmove_before_end);
+ATF_TC_HEAD(memmove_before_end, tc)
+{
+}
+ATF_TC_BODY(memmove_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ memmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memmove_end);
+ATF_TC_HEAD(memmove_end, tc)
+{
+}
+ATF_TC_BODY(memmove_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ memmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memmove_heap_before_end);
+ATF_TC_HEAD(memmove_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(memmove_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ memmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memmove_heap_end);
+ATF_TC_HEAD(memmove_heap_end, tc)
+{
+}
+ATF_TC_BODY(memmove_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ memmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(memmove_heap_after_end);
+ATF_TC_HEAD(memmove_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(memmove_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ memmove(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(memset_before_end);
+ATF_TC_HEAD(memset_before_end, tc)
+{
+}
+ATF_TC_BODY(memset_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ memset(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_end);
+ATF_TC_HEAD(memset_end, tc)
+{
+}
+ATF_TC_BODY(memset_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ memset(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_heap_before_end);
+ATF_TC_HEAD(memset_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(memset_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ memset(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_heap_end);
+ATF_TC_HEAD(memset_heap_end, tc)
+{
+}
+ATF_TC_BODY(memset_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ memset(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_heap_after_end);
+ATF_TC_HEAD(memset_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(memset_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ memset(__stack.__buf, 0, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(memset_explicit_before_end);
+ATF_TC_HEAD(memset_explicit_before_end, tc)
+{
+}
+ATF_TC_BODY(memset_explicit_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ memset_explicit(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_explicit_end);
+ATF_TC_HEAD(memset_explicit_end, tc)
+{
+}
+ATF_TC_BODY(memset_explicit_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ memset_explicit(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_explicit_heap_before_end);
+ATF_TC_HEAD(memset_explicit_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(memset_explicit_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ memset_explicit(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_explicit_heap_end);
+ATF_TC_HEAD(memset_explicit_heap_end, tc)
+{
+}
+ATF_TC_BODY(memset_explicit_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ memset_explicit(__stack.__buf, 0, __len);
+#undef BUF
+
+}
+
+ATF_TC(memset_explicit_heap_after_end);
+ATF_TC_HEAD(memset_explicit_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(memset_explicit_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ memset_explicit(__stack.__buf, 0, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(stpcpy_before_end);
+ATF_TC_HEAD(stpcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(stpcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(stpcpy_end);
+ATF_TC_HEAD(stpcpy_end, tc)
+{
+}
+ATF_TC_BODY(stpcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(stpcpy_heap_before_end);
+ATF_TC_HEAD(stpcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(stpcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(stpcpy_heap_end);
+ATF_TC_HEAD(stpcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(stpcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(stpcpy_heap_after_end);
+ATF_TC_HEAD(stpcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(stpcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpcpy(__stack.__buf, src);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(stpncpy_before_end);
+ATF_TC_HEAD(stpncpy_before_end, tc)
+{
+}
+ATF_TC_BODY(stpncpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(stpncpy_end);
+ATF_TC_HEAD(stpncpy_end, tc)
+{
+}
+ATF_TC_BODY(stpncpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(stpncpy_heap_before_end);
+ATF_TC_HEAD(stpncpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(stpncpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(stpncpy_heap_end);
+ATF_TC_HEAD(stpncpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(stpncpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(stpncpy_heap_after_end);
+ATF_TC_HEAD(stpncpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(stpncpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ stpncpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(strcat_before_end);
+ATF_TC_HEAD(strcat_before_end, tc)
+{
+}
+ATF_TC_BODY(strcat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcat_end);
+ATF_TC_HEAD(strcat_end, tc)
+{
+}
+ATF_TC_BODY(strcat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcat_heap_before_end);
+ATF_TC_HEAD(strcat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(strcat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcat_heap_end);
+ATF_TC_HEAD(strcat_heap_end, tc)
+{
+}
+ATF_TC_BODY(strcat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcat_heap_after_end);
+ATF_TC_HEAD(strcat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(strcat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcat(__stack.__buf, src);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(strlcat_before_end);
+ATF_TC_HEAD(strlcat_before_end, tc)
+{
+}
+ATF_TC_BODY(strlcat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcat_end);
+ATF_TC_HEAD(strlcat_end, tc)
+{
+}
+ATF_TC_BODY(strlcat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcat_heap_before_end);
+ATF_TC_HEAD(strlcat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(strlcat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcat_heap_end);
+ATF_TC_HEAD(strlcat_heap_end, tc)
+{
+}
+ATF_TC_BODY(strlcat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcat_heap_after_end);
+ATF_TC_HEAD(strlcat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(strlcat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcat(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(strncat_before_end);
+ATF_TC_HEAD(strncat_before_end, tc)
+{
+}
+ATF_TC_BODY(strncat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncat_end);
+ATF_TC_HEAD(strncat_end, tc)
+{
+}
+ATF_TC_BODY(strncat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncat_heap_before_end);
+ATF_TC_HEAD(strncat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(strncat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncat_heap_end);
+ATF_TC_HEAD(strncat_heap_end, tc)
+{
+}
+ATF_TC_BODY(strncat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncat_heap_after_end);
+ATF_TC_HEAD(strncat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(strncat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncat(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(strcpy_before_end);
+ATF_TC_HEAD(strcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(strcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcpy_end);
+ATF_TC_HEAD(strcpy_end, tc)
+{
+}
+ATF_TC_BODY(strcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcpy_heap_before_end);
+ATF_TC_HEAD(strcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(strcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcpy_heap_end);
+ATF_TC_HEAD(strcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(strcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(strcpy_heap_after_end);
+ATF_TC_HEAD(strcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(strcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strcpy(__stack.__buf, src);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(strlcpy_before_end);
+ATF_TC_HEAD(strlcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(strlcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcpy_end);
+ATF_TC_HEAD(strlcpy_end, tc)
+{
+}
+ATF_TC_BODY(strlcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcpy_heap_before_end);
+ATF_TC_HEAD(strlcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(strlcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcpy_heap_end);
+ATF_TC_HEAD(strlcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(strlcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strlcpy_heap_after_end);
+ATF_TC_HEAD(strlcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(strlcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strlcpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(strncpy_before_end);
+ATF_TC_HEAD(strncpy_before_end, tc)
+{
+}
+ATF_TC_BODY(strncpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncpy_end);
+ATF_TC_HEAD(strncpy_end, tc)
+{
+}
+ATF_TC_BODY(strncpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncpy_heap_before_end);
+ATF_TC_HEAD(strncpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(strncpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncpy_heap_end);
+ATF_TC_HEAD(strncpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(strncpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(strncpy_heap_after_end);
+ATF_TC_HEAD(strncpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(strncpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ strncpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, memcpy_before_end);
+ ATF_TP_ADD_TC(tp, memcpy_end);
+ ATF_TP_ADD_TC(tp, memcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, memcpy_heap_end);
+ ATF_TP_ADD_TC(tp, memcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, mempcpy_before_end);
+ ATF_TP_ADD_TC(tp, mempcpy_end);
+ ATF_TP_ADD_TC(tp, mempcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, mempcpy_heap_end);
+ ATF_TP_ADD_TC(tp, mempcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, memmove_before_end);
+ ATF_TP_ADD_TC(tp, memmove_end);
+ ATF_TP_ADD_TC(tp, memmove_heap_before_end);
+ ATF_TP_ADD_TC(tp, memmove_heap_end);
+ ATF_TP_ADD_TC(tp, memmove_heap_after_end);
+ ATF_TP_ADD_TC(tp, memset_before_end);
+ ATF_TP_ADD_TC(tp, memset_end);
+ ATF_TP_ADD_TC(tp, memset_heap_before_end);
+ ATF_TP_ADD_TC(tp, memset_heap_end);
+ ATF_TP_ADD_TC(tp, memset_heap_after_end);
+ ATF_TP_ADD_TC(tp, memset_explicit_before_end);
+ ATF_TP_ADD_TC(tp, memset_explicit_end);
+ ATF_TP_ADD_TC(tp, memset_explicit_heap_before_end);
+ ATF_TP_ADD_TC(tp, memset_explicit_heap_end);
+ ATF_TP_ADD_TC(tp, memset_explicit_heap_after_end);
+ ATF_TP_ADD_TC(tp, stpcpy_before_end);
+ ATF_TP_ADD_TC(tp, stpcpy_end);
+ ATF_TP_ADD_TC(tp, stpcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, stpcpy_heap_end);
+ ATF_TP_ADD_TC(tp, stpcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, stpncpy_before_end);
+ ATF_TP_ADD_TC(tp, stpncpy_end);
+ ATF_TP_ADD_TC(tp, stpncpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, stpncpy_heap_end);
+ ATF_TP_ADD_TC(tp, stpncpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, strcat_before_end);
+ ATF_TP_ADD_TC(tp, strcat_end);
+ ATF_TP_ADD_TC(tp, strcat_heap_before_end);
+ ATF_TP_ADD_TC(tp, strcat_heap_end);
+ ATF_TP_ADD_TC(tp, strcat_heap_after_end);
+ ATF_TP_ADD_TC(tp, strlcat_before_end);
+ ATF_TP_ADD_TC(tp, strlcat_end);
+ ATF_TP_ADD_TC(tp, strlcat_heap_before_end);
+ ATF_TP_ADD_TC(tp, strlcat_heap_end);
+ ATF_TP_ADD_TC(tp, strlcat_heap_after_end);
+ ATF_TP_ADD_TC(tp, strncat_before_end);
+ ATF_TP_ADD_TC(tp, strncat_end);
+ ATF_TP_ADD_TC(tp, strncat_heap_before_end);
+ ATF_TP_ADD_TC(tp, strncat_heap_end);
+ ATF_TP_ADD_TC(tp, strncat_heap_after_end);
+ ATF_TP_ADD_TC(tp, strcpy_before_end);
+ ATF_TP_ADD_TC(tp, strcpy_end);
+ ATF_TP_ADD_TC(tp, strcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, strcpy_heap_end);
+ ATF_TP_ADD_TC(tp, strcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, strlcpy_before_end);
+ ATF_TP_ADD_TC(tp, strlcpy_end);
+ ATF_TP_ADD_TC(tp, strlcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, strlcpy_heap_end);
+ ATF_TP_ADD_TC(tp, strlcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, strncpy_before_end);
+ ATF_TP_ADD_TC(tp, strncpy_end);
+ ATF_TP_ADD_TC(tp, strncpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, strncpy_heap_end);
+ ATF_TP_ADD_TC(tp, strncpy_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_strings_test.c b/lib/libc/tests/secure/fortify_strings_test.c
new file mode 100644
index 000000000000..9f7d37a2480e
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_strings_test.c
@@ -0,0 +1,615 @@
+/* @generated by `generate-fortify-tests.lua "strings"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(bcopy_before_end);
+ATF_TC_HEAD(bcopy_before_end, tc)
+{
+}
+ATF_TC_BODY(bcopy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ bcopy(src, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bcopy_end);
+ATF_TC_HEAD(bcopy_end, tc)
+{
+}
+ATF_TC_BODY(bcopy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ bcopy(src, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bcopy_heap_before_end);
+ATF_TC_HEAD(bcopy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(bcopy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ bcopy(src, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bcopy_heap_end);
+ATF_TC_HEAD(bcopy_heap_end, tc)
+{
+}
+ATF_TC_BODY(bcopy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ char src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ bcopy(src, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bcopy_heap_after_end);
+ATF_TC_HEAD(bcopy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(bcopy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ char src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ bcopy(src, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(bzero_before_end);
+ATF_TC_HEAD(bzero_before_end, tc)
+{
+}
+ATF_TC_BODY(bzero_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bzero_end);
+ATF_TC_HEAD(bzero_end, tc)
+{
+}
+ATF_TC_BODY(bzero_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bzero_heap_before_end);
+ATF_TC_HEAD(bzero_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(bzero_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bzero_heap_end);
+ATF_TC_HEAD(bzero_heap_end, tc)
+{
+}
+ATF_TC_BODY(bzero_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(bzero_heap_after_end);
+ATF_TC_HEAD(bzero_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(bzero_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ bzero(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(explicit_bzero_before_end);
+ATF_TC_HEAD(explicit_bzero_before_end, tc)
+{
+}
+ATF_TC_BODY(explicit_bzero_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ explicit_bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(explicit_bzero_end);
+ATF_TC_HEAD(explicit_bzero_end, tc)
+{
+}
+ATF_TC_BODY(explicit_bzero_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ explicit_bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(explicit_bzero_heap_before_end);
+ATF_TC_HEAD(explicit_bzero_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(explicit_bzero_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ explicit_bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(explicit_bzero_heap_end);
+ATF_TC_HEAD(explicit_bzero_heap_end, tc)
+{
+}
+ATF_TC_BODY(explicit_bzero_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ explicit_bzero(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(explicit_bzero_heap_after_end);
+ATF_TC_HEAD(explicit_bzero_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(explicit_bzero_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ explicit_bzero(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, bcopy_before_end);
+ ATF_TP_ADD_TC(tp, bcopy_end);
+ ATF_TP_ADD_TC(tp, bcopy_heap_before_end);
+ ATF_TP_ADD_TC(tp, bcopy_heap_end);
+ ATF_TP_ADD_TC(tp, bcopy_heap_after_end);
+ ATF_TP_ADD_TC(tp, bzero_before_end);
+ ATF_TP_ADD_TC(tp, bzero_end);
+ ATF_TP_ADD_TC(tp, bzero_heap_before_end);
+ ATF_TP_ADD_TC(tp, bzero_heap_end);
+ ATF_TP_ADD_TC(tp, bzero_heap_after_end);
+ ATF_TP_ADD_TC(tp, explicit_bzero_before_end);
+ ATF_TP_ADD_TC(tp, explicit_bzero_end);
+ ATF_TP_ADD_TC(tp, explicit_bzero_heap_before_end);
+ ATF_TP_ADD_TC(tp, explicit_bzero_heap_end);
+ ATF_TP_ADD_TC(tp, explicit_bzero_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_uio_test.c b/lib/libc/tests/secure/fortify_uio_test.c
new file mode 100644
index 000000000000..46b46ed2f7df
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_uio_test.c
@@ -0,0 +1,917 @@
+/* @generated by `generate-fortify-tests.lua "uio"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(readv_before_end);
+ATF_TC_HEAD(readv_before_end, tc)
+{
+}
+ATF_TC_BODY(readv_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ readv(STDIN_FILENO, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readv_end);
+ATF_TC_HEAD(readv_end, tc)
+{
+}
+ATF_TC_BODY(readv_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2;
+ const size_t __idx __unused = __len - 1;
+
+ readv(STDIN_FILENO, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readv_after_end);
+ATF_TC_HEAD(readv_after_end, tc)
+{
+}
+ATF_TC_BODY(readv_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ readv(STDIN_FILENO, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(readv_heap_before_end);
+ATF_TC_HEAD(readv_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(readv_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ readv(STDIN_FILENO, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readv_heap_end);
+ATF_TC_HEAD(readv_heap_end, tc)
+{
+}
+ATF_TC_BODY(readv_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ readv(STDIN_FILENO, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readv_heap_after_end);
+ATF_TC_HEAD(readv_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(readv_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ readv(STDIN_FILENO, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(readv_iov_before_end);
+ATF_TC_HEAD(readv_iov_before_end, tc)
+{
+}
+ATF_TC_BODY(readv_iov_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ readv(STDIN_FILENO, iov, nitems(iov));
+#undef BUF
+
+}
+
+ATF_TC(readv_iov_end);
+ATF_TC_HEAD(readv_iov_end, tc)
+{
+}
+ATF_TC_BODY(readv_iov_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ readv(STDIN_FILENO, iov, nitems(iov));
+#undef BUF
+
+}
+
+ATF_TC(readv_iov_heap_before_end);
+ATF_TC_HEAD(readv_iov_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(readv_iov_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ __stack.__buf = malloc(__bufsz);
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ readv(STDIN_FILENO, iov, nitems(iov));
+#undef BUF
+
+}
+
+ATF_TC(readv_iov_heap_end);
+ATF_TC_HEAD(readv_iov_heap_end, tc)
+{
+}
+ATF_TC_BODY(readv_iov_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ __stack.__buf = malloc(__bufsz);
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ readv(STDIN_FILENO, iov, nitems(iov));
+#undef BUF
+
+}
+
+ATF_TC(readv_iov_heap_after_end);
+ATF_TC_HEAD(readv_iov_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(readv_iov_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ struct iovec iov[1];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ readv(STDIN_FILENO, iov, nitems(iov));
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(preadv_before_end);
+ATF_TC_HEAD(preadv_before_end, tc)
+{
+}
+ATF_TC_BODY(preadv_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ preadv(STDIN_FILENO, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_end);
+ATF_TC_HEAD(preadv_end, tc)
+{
+}
+ATF_TC_BODY(preadv_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2;
+ const size_t __idx __unused = __len - 1;
+
+ preadv(STDIN_FILENO, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_after_end);
+ATF_TC_HEAD(preadv_after_end, tc)
+{
+}
+ATF_TC_BODY(preadv_after_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec __buf[2];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 2 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ preadv(STDIN_FILENO, __stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(preadv_heap_before_end);
+ATF_TC_HEAD(preadv_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(preadv_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ preadv(STDIN_FILENO, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_heap_end);
+ATF_TC_HEAD(preadv_heap_end, tc)
+{
+}
+ATF_TC_BODY(preadv_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ preadv(STDIN_FILENO, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_heap_after_end);
+ATF_TC_HEAD(preadv_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(preadv_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ struct iovec * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (2);
+ const size_t __len = 2 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ preadv(STDIN_FILENO, __stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(preadv_iov_before_end);
+ATF_TC_HEAD(preadv_iov_before_end, tc)
+{
+}
+ATF_TC_BODY(preadv_iov_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ preadv(STDIN_FILENO, iov, nitems(iov), 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_iov_end);
+ATF_TC_HEAD(preadv_iov_end, tc)
+{
+}
+ATF_TC_BODY(preadv_iov_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ preadv(STDIN_FILENO, iov, nitems(iov), 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_iov_heap_before_end);
+ATF_TC_HEAD(preadv_iov_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(preadv_iov_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ __stack.__buf = malloc(__bufsz);
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ preadv(STDIN_FILENO, iov, nitems(iov), 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_iov_heap_end);
+ATF_TC_HEAD(preadv_iov_heap_end, tc)
+{
+}
+ATF_TC_BODY(preadv_iov_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ struct iovec iov[1];
+
+ __stack.__buf = malloc(__bufsz);
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ preadv(STDIN_FILENO, iov, nitems(iov), 0);
+#undef BUF
+
+}
+
+ATF_TC(preadv_iov_heap_after_end);
+ATF_TC_HEAD(preadv_iov_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(preadv_iov_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ struct iovec iov[1];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+
+ preadv(STDIN_FILENO, iov, nitems(iov), 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, readv_before_end);
+ ATF_TP_ADD_TC(tp, readv_end);
+ ATF_TP_ADD_TC(tp, readv_after_end);
+ ATF_TP_ADD_TC(tp, readv_heap_before_end);
+ ATF_TP_ADD_TC(tp, readv_heap_end);
+ ATF_TP_ADD_TC(tp, readv_heap_after_end);
+ ATF_TP_ADD_TC(tp, readv_iov_before_end);
+ ATF_TP_ADD_TC(tp, readv_iov_end);
+ ATF_TP_ADD_TC(tp, readv_iov_heap_before_end);
+ ATF_TP_ADD_TC(tp, readv_iov_heap_end);
+ ATF_TP_ADD_TC(tp, readv_iov_heap_after_end);
+ ATF_TP_ADD_TC(tp, preadv_before_end);
+ ATF_TP_ADD_TC(tp, preadv_end);
+ ATF_TP_ADD_TC(tp, preadv_after_end);
+ ATF_TP_ADD_TC(tp, preadv_heap_before_end);
+ ATF_TP_ADD_TC(tp, preadv_heap_end);
+ ATF_TP_ADD_TC(tp, preadv_heap_after_end);
+ ATF_TP_ADD_TC(tp, preadv_iov_before_end);
+ ATF_TP_ADD_TC(tp, preadv_iov_end);
+ ATF_TP_ADD_TC(tp, preadv_iov_heap_before_end);
+ ATF_TP_ADD_TC(tp, preadv_iov_heap_end);
+ ATF_TP_ADD_TC(tp, preadv_iov_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_unistd_test.c b/lib/libc/tests/secure/fortify_unistd_test.c
new file mode 100644
index 000000000000..b12ef2bbb8ea
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_unistd_test.c
@@ -0,0 +1,2199 @@
+/* @generated by `generate-fortify-tests.lua "unistd"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+#define JAIL_HOSTNAME "host.example.com"
+#define JAIL_DOMAINNAME "example.com"
+static void
+dhost_jail(void)
+{
+ struct iovec iov[4];
+ int jid;
+
+ iov[0].iov_base = __DECONST(char *, "host.hostname");
+ iov[0].iov_len = sizeof("host.hostname");
+ iov[1].iov_base = __DECONST(char *, JAIL_HOSTNAME);
+ iov[1].iov_len = sizeof(JAIL_HOSTNAME);
+ iov[2].iov_base = __DECONST(char *, "host.domainname");
+ iov[2].iov_len = sizeof("host.domainname");
+ iov[3].iov_base = __DECONST(char *, JAIL_DOMAINNAME);
+ iov[3].iov_len = sizeof(JAIL_DOMAINNAME);
+
+ jid = jail_set(iov, nitems(iov), JAIL_CREATE | JAIL_ATTACH);
+ ATF_REQUIRE_MSG(jid > 0, "Jail creation failed: %s", strerror(errno));
+}
+
+ATF_TC(getcwd_before_end);
+ATF_TC_HEAD(getcwd_before_end, tc)
+{
+}
+ATF_TC_BODY(getcwd_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[8];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 8 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getcwd(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getcwd_end);
+ATF_TC_HEAD(getcwd_end, tc)
+{
+}
+ATF_TC_BODY(getcwd_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[8];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 8;
+ const size_t __idx __unused = __len - 1;
+
+ getcwd(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getcwd_heap_before_end);
+ATF_TC_HEAD(getcwd_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getcwd_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (8);
+ const size_t __len = 8 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getcwd(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getcwd_heap_end);
+ATF_TC_HEAD(getcwd_heap_end, tc)
+{
+}
+ATF_TC_BODY(getcwd_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (8);
+ const size_t __len = 8;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getcwd(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getcwd_heap_after_end);
+ATF_TC_HEAD(getcwd_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getcwd_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (8);
+ const size_t __len = 8 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getcwd(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getgrouplist_before_end);
+ATF_TC_HEAD(getgrouplist_before_end, tc)
+{
+}
+ATF_TC_BODY(getgrouplist_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+ int intlen = (int)__len;
+
+ getgrouplist("root", 0, __stack.__buf, &intlen);
+#undef BUF
+
+}
+
+ATF_TC(getgrouplist_end);
+ATF_TC_HEAD(getgrouplist_end, tc)
+{
+}
+ATF_TC_BODY(getgrouplist_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+ int intlen = (int)__len;
+
+ getgrouplist("root", 0, __stack.__buf, &intlen);
+#undef BUF
+
+}
+
+ATF_TC(getgrouplist_heap_before_end);
+ATF_TC_HEAD(getgrouplist_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getgrouplist_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+ int intlen = (int)__len;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getgrouplist("root", 0, __stack.__buf, &intlen);
+#undef BUF
+
+}
+
+ATF_TC(getgrouplist_heap_end);
+ATF_TC_HEAD(getgrouplist_heap_end, tc)
+{
+}
+ATF_TC_BODY(getgrouplist_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+ int intlen = (int)__len;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getgrouplist("root", 0, __stack.__buf, &intlen);
+#undef BUF
+
+}
+
+ATF_TC(getgrouplist_heap_after_end);
+ATF_TC_HEAD(getgrouplist_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getgrouplist_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int intlen = (int)__len;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getgrouplist("root", 0, __stack.__buf, &intlen);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getgroups_before_end);
+ATF_TC_HEAD(getgroups_before_end, tc)
+{
+}
+ATF_TC_BODY(getgroups_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getgroups(__len, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(getgroups_end);
+ATF_TC_HEAD(getgroups_end, tc)
+{
+}
+ATF_TC_BODY(getgroups_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t __buf[4];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+
+ getgroups(__len, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(getgroups_heap_before_end);
+ATF_TC_HEAD(getgroups_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getgroups_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getgroups(__len, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(getgroups_heap_end);
+ATF_TC_HEAD(getgroups_heap_end, tc)
+{
+}
+ATF_TC_BODY(getgroups_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getgroups(__len, __stack.__buf);
+#undef BUF
+
+}
+
+ATF_TC(getgroups_heap_after_end);
+ATF_TC_HEAD(getgroups_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getgroups_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ gid_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4);
+ const size_t __len = 4 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getgroups(__len, __stack.__buf);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getloginclass_before_end);
+ATF_TC_HEAD(getloginclass_before_end, tc)
+{
+}
+ATF_TC_BODY(getloginclass_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getloginclass(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getloginclass_end);
+ATF_TC_HEAD(getloginclass_end, tc)
+{
+}
+ATF_TC_BODY(getloginclass_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ getloginclass(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getloginclass_heap_before_end);
+ATF_TC_HEAD(getloginclass_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getloginclass_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getloginclass(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getloginclass_heap_end);
+ATF_TC_HEAD(getloginclass_heap_end, tc)
+{
+}
+ATF_TC_BODY(getloginclass_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getloginclass(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getloginclass_heap_after_end);
+ATF_TC_HEAD(getloginclass_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getloginclass_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getloginclass(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(pread_before_end);
+ATF_TC_HEAD(pread_before_end, tc)
+{
+}
+ATF_TC_BODY(pread_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[41];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 41 - 1;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = new_tmpfile(); /* Cannot fail */
+
+ pread(fd, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(pread_end);
+ATF_TC_HEAD(pread_end, tc)
+{
+}
+ATF_TC_BODY(pread_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[41];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 41;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = new_tmpfile(); /* Cannot fail */
+
+ pread(fd, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(pread_heap_before_end);
+ATF_TC_HEAD(pread_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(pread_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (41);
+ const size_t __len = 41 - 1;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ __stack.__buf = malloc(__bufsz);
+ fd = new_tmpfile(); /* Cannot fail */
+
+ pread(fd, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(pread_heap_end);
+ATF_TC_HEAD(pread_heap_end, tc)
+{
+}
+ATF_TC_BODY(pread_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (41);
+ const size_t __len = 41;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ __stack.__buf = malloc(__bufsz);
+ fd = new_tmpfile(); /* Cannot fail */
+
+ pread(fd, __stack.__buf, __len, 0);
+#undef BUF
+
+}
+
+ATF_TC(pread_heap_after_end);
+ATF_TC_HEAD(pread_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(pread_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (41);
+ const size_t __len = 41 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int fd;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ fd = new_tmpfile(); /* Cannot fail */
+
+ pread(fd, __stack.__buf, __len, 0);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(read_before_end);
+ATF_TC_HEAD(read_before_end, tc)
+{
+}
+ATF_TC_BODY(read_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[41];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 41 - 1;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = new_tmpfile(); /* Cannot fail */
+
+ read(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(read_end);
+ATF_TC_HEAD(read_end, tc)
+{
+}
+ATF_TC_BODY(read_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[41];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 41;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = new_tmpfile(); /* Cannot fail */
+
+ read(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(read_heap_before_end);
+ATF_TC_HEAD(read_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(read_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (41);
+ const size_t __len = 41 - 1;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ __stack.__buf = malloc(__bufsz);
+ fd = new_tmpfile(); /* Cannot fail */
+
+ read(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(read_heap_end);
+ATF_TC_HEAD(read_heap_end, tc)
+{
+}
+ATF_TC_BODY(read_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (41);
+ const size_t __len = 41;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ __stack.__buf = malloc(__bufsz);
+ fd = new_tmpfile(); /* Cannot fail */
+
+ read(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(read_heap_after_end);
+ATF_TC_HEAD(read_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(read_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (41);
+ const size_t __len = 41 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int fd;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ fd = new_tmpfile(); /* Cannot fail */
+
+ read(fd, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(readlink_before_end);
+ATF_TC_HEAD(readlink_before_end, tc)
+{
+}
+ATF_TC_BODY(readlink_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlink(path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlink_end);
+ATF_TC_HEAD(readlink_end, tc)
+{
+}
+ATF_TC_BODY(readlink_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlink(path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlink_heap_before_end);
+ATF_TC_HEAD(readlink_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(readlink_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ __stack.__buf = malloc(__bufsz);
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlink(path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlink_heap_end);
+ATF_TC_HEAD(readlink_heap_end, tc)
+{
+}
+ATF_TC_BODY(readlink_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ __stack.__buf = malloc(__bufsz);
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlink(path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlink_heap_after_end);
+ATF_TC_HEAD(readlink_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(readlink_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ const char *path;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlink(path, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(readlinkat_before_end);
+ATF_TC_HEAD(readlinkat_before_end, tc)
+{
+}
+ATF_TC_BODY(readlinkat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlinkat(AT_FDCWD, path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlinkat_end);
+ATF_TC_HEAD(readlinkat_end, tc)
+{
+}
+ATF_TC_BODY(readlinkat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlinkat(AT_FDCWD, path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlinkat_heap_before_end);
+ATF_TC_HEAD(readlinkat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(readlinkat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ __stack.__buf = malloc(__bufsz);
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlinkat(AT_FDCWD, path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlinkat_heap_end);
+ATF_TC_HEAD(readlinkat_heap_end, tc)
+{
+}
+ATF_TC_BODY(readlinkat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ const char *path;
+
+ __stack.__buf = malloc(__bufsz);
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlinkat(AT_FDCWD, path, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(readlinkat_heap_after_end);
+ATF_TC_HEAD(readlinkat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(readlinkat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ const char *path;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ path = new_symlink(__len); /* Cannot fail */
+
+ readlinkat(AT_FDCWD, path, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getdomainname_before_end);
+ATF_TC_HEAD(getdomainname_before_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(getdomainname_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[12];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 12 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ getdomainname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getdomainname_end);
+ATF_TC_HEAD(getdomainname_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(getdomainname_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[12];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 12;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ getdomainname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getdomainname_heap_before_end);
+ATF_TC_HEAD(getdomainname_heap_before_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(getdomainname_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (12);
+ const size_t __len = 12 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ __stack.__buf = malloc(__bufsz);
+
+ getdomainname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getdomainname_heap_end);
+ATF_TC_HEAD(getdomainname_heap_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(getdomainname_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (12);
+ const size_t __len = 12;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ __stack.__buf = malloc(__bufsz);
+
+ getdomainname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getdomainname_heap_after_end);
+ATF_TC_HEAD(getdomainname_heap_after_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(getdomainname_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (12);
+ const size_t __len = 12 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ dhost_jail();
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getdomainname(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getentropy_before_end);
+ATF_TC_HEAD(getentropy_before_end, tc)
+{
+}
+ATF_TC_BODY(getentropy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getentropy(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getentropy_end);
+ATF_TC_HEAD(getentropy_end, tc)
+{
+}
+ATF_TC_BODY(getentropy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ getentropy(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getentropy_heap_before_end);
+ATF_TC_HEAD(getentropy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getentropy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getentropy(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getentropy_heap_end);
+ATF_TC_HEAD(getentropy_heap_end, tc)
+{
+}
+ATF_TC_BODY(getentropy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getentropy(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getentropy_heap_after_end);
+ATF_TC_HEAD(getentropy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getentropy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getentropy(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(gethostname_before_end);
+ATF_TC_HEAD(gethostname_before_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(gethostname_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[17];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 17 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ gethostname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gethostname_end);
+ATF_TC_HEAD(gethostname_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(gethostname_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[17];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 17;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ gethostname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gethostname_heap_before_end);
+ATF_TC_HEAD(gethostname_heap_before_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(gethostname_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (17);
+ const size_t __len = 17 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ __stack.__buf = malloc(__bufsz);
+
+ gethostname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gethostname_heap_end);
+ATF_TC_HEAD(gethostname_heap_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(gethostname_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (17);
+ const size_t __len = 17;
+ const size_t __idx __unused = __len - 1;
+
+ dhost_jail();
+ __stack.__buf = malloc(__bufsz);
+
+ gethostname(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(gethostname_heap_after_end);
+ATF_TC_HEAD(gethostname_heap_after_end, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+ATF_TC_BODY(gethostname_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (17);
+ const size_t __len = 17 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ dhost_jail();
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ gethostname(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(getlogin_r_before_end);
+ATF_TC_HEAD(getlogin_r_before_end, tc)
+{
+}
+ATF_TC_BODY(getlogin_r_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[MAXLOGNAME + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = MAXLOGNAME + 1 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ getlogin_r(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getlogin_r_end);
+ATF_TC_HEAD(getlogin_r_end, tc)
+{
+}
+ATF_TC_BODY(getlogin_r_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[MAXLOGNAME + 1];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = MAXLOGNAME + 1;
+ const size_t __idx __unused = __len - 1;
+
+ getlogin_r(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getlogin_r_heap_before_end);
+ATF_TC_HEAD(getlogin_r_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(getlogin_r_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (MAXLOGNAME + 1);
+ const size_t __len = MAXLOGNAME + 1 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getlogin_r(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getlogin_r_heap_end);
+ATF_TC_HEAD(getlogin_r_heap_end, tc)
+{
+}
+ATF_TC_BODY(getlogin_r_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (MAXLOGNAME + 1);
+ const size_t __len = MAXLOGNAME + 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ getlogin_r(__stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(getlogin_r_heap_after_end);
+ATF_TC_HEAD(getlogin_r_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(getlogin_r_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (MAXLOGNAME + 1);
+ const size_t __len = MAXLOGNAME + 1 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ getlogin_r(__stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(ttyname_r_before_end);
+ATF_TC_HEAD(ttyname_r_before_end, tc)
+{
+}
+ATF_TC_BODY(ttyname_r_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = STDIN_FILENO;
+ if (!isatty(fd))
+ atf_tc_skip("stdin is not an fd");
+
+ ttyname_r(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(ttyname_r_end);
+ATF_TC_HEAD(ttyname_r_end, tc)
+{
+}
+ATF_TC_BODY(ttyname_r_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = STDIN_FILENO;
+ if (!isatty(fd))
+ atf_tc_skip("stdin is not an fd");
+
+ ttyname_r(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(ttyname_r_heap_before_end);
+ATF_TC_HEAD(ttyname_r_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(ttyname_r_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = STDIN_FILENO;
+ if (!isatty(fd))
+ atf_tc_skip("stdin is not an fd");
+
+ __stack.__buf = malloc(__bufsz);
+
+ ttyname_r(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(ttyname_r_heap_end);
+ATF_TC_HEAD(ttyname_r_heap_end, tc)
+{
+}
+ATF_TC_BODY(ttyname_r_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ int fd;
+
+ fd = STDIN_FILENO;
+ if (!isatty(fd))
+ atf_tc_skip("stdin is not an fd");
+
+ __stack.__buf = malloc(__bufsz);
+
+ ttyname_r(fd, __stack.__buf, __len);
+#undef BUF
+
+}
+
+ATF_TC(ttyname_r_heap_after_end);
+ATF_TC_HEAD(ttyname_r_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(ttyname_r_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ unsigned char * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ int fd;
+
+ fd = STDIN_FILENO;
+ if (!isatty(fd))
+ atf_tc_skip("stdin is not an fd");
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ ttyname_r(fd, __stack.__buf, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, getcwd_before_end);
+ ATF_TP_ADD_TC(tp, getcwd_end);
+ ATF_TP_ADD_TC(tp, getcwd_heap_before_end);
+ ATF_TP_ADD_TC(tp, getcwd_heap_end);
+ ATF_TP_ADD_TC(tp, getcwd_heap_after_end);
+ ATF_TP_ADD_TC(tp, getgrouplist_before_end);
+ ATF_TP_ADD_TC(tp, getgrouplist_end);
+ ATF_TP_ADD_TC(tp, getgrouplist_heap_before_end);
+ ATF_TP_ADD_TC(tp, getgrouplist_heap_end);
+ ATF_TP_ADD_TC(tp, getgrouplist_heap_after_end);
+ ATF_TP_ADD_TC(tp, getgroups_before_end);
+ ATF_TP_ADD_TC(tp, getgroups_end);
+ ATF_TP_ADD_TC(tp, getgroups_heap_before_end);
+ ATF_TP_ADD_TC(tp, getgroups_heap_end);
+ ATF_TP_ADD_TC(tp, getgroups_heap_after_end);
+ ATF_TP_ADD_TC(tp, getloginclass_before_end);
+ ATF_TP_ADD_TC(tp, getloginclass_end);
+ ATF_TP_ADD_TC(tp, getloginclass_heap_before_end);
+ ATF_TP_ADD_TC(tp, getloginclass_heap_end);
+ ATF_TP_ADD_TC(tp, getloginclass_heap_after_end);
+ ATF_TP_ADD_TC(tp, pread_before_end);
+ ATF_TP_ADD_TC(tp, pread_end);
+ ATF_TP_ADD_TC(tp, pread_heap_before_end);
+ ATF_TP_ADD_TC(tp, pread_heap_end);
+ ATF_TP_ADD_TC(tp, pread_heap_after_end);
+ ATF_TP_ADD_TC(tp, read_before_end);
+ ATF_TP_ADD_TC(tp, read_end);
+ ATF_TP_ADD_TC(tp, read_heap_before_end);
+ ATF_TP_ADD_TC(tp, read_heap_end);
+ ATF_TP_ADD_TC(tp, read_heap_after_end);
+ ATF_TP_ADD_TC(tp, readlink_before_end);
+ ATF_TP_ADD_TC(tp, readlink_end);
+ ATF_TP_ADD_TC(tp, readlink_heap_before_end);
+ ATF_TP_ADD_TC(tp, readlink_heap_end);
+ ATF_TP_ADD_TC(tp, readlink_heap_after_end);
+ ATF_TP_ADD_TC(tp, readlinkat_before_end);
+ ATF_TP_ADD_TC(tp, readlinkat_end);
+ ATF_TP_ADD_TC(tp, readlinkat_heap_before_end);
+ ATF_TP_ADD_TC(tp, readlinkat_heap_end);
+ ATF_TP_ADD_TC(tp, readlinkat_heap_after_end);
+ ATF_TP_ADD_TC(tp, getdomainname_before_end);
+ ATF_TP_ADD_TC(tp, getdomainname_end);
+ ATF_TP_ADD_TC(tp, getdomainname_heap_before_end);
+ ATF_TP_ADD_TC(tp, getdomainname_heap_end);
+ ATF_TP_ADD_TC(tp, getdomainname_heap_after_end);
+ ATF_TP_ADD_TC(tp, getentropy_before_end);
+ ATF_TP_ADD_TC(tp, getentropy_end);
+ ATF_TP_ADD_TC(tp, getentropy_heap_before_end);
+ ATF_TP_ADD_TC(tp, getentropy_heap_end);
+ ATF_TP_ADD_TC(tp, getentropy_heap_after_end);
+ ATF_TP_ADD_TC(tp, gethostname_before_end);
+ ATF_TP_ADD_TC(tp, gethostname_end);
+ ATF_TP_ADD_TC(tp, gethostname_heap_before_end);
+ ATF_TP_ADD_TC(tp, gethostname_heap_end);
+ ATF_TP_ADD_TC(tp, gethostname_heap_after_end);
+ ATF_TP_ADD_TC(tp, getlogin_r_before_end);
+ ATF_TP_ADD_TC(tp, getlogin_r_end);
+ ATF_TP_ADD_TC(tp, getlogin_r_heap_before_end);
+ ATF_TP_ADD_TC(tp, getlogin_r_heap_end);
+ ATF_TP_ADD_TC(tp, getlogin_r_heap_after_end);
+ ATF_TP_ADD_TC(tp, ttyname_r_before_end);
+ ATF_TP_ADD_TC(tp, ttyname_r_end);
+ ATF_TP_ADD_TC(tp, ttyname_r_heap_before_end);
+ ATF_TP_ADD_TC(tp, ttyname_r_heap_end);
+ ATF_TP_ADD_TC(tp, ttyname_r_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/fortify_wchar_test.c b/lib/libc/tests/secure/fortify_wchar_test.c
new file mode 100644
index 000000000000..43c7997bc6a3
--- /dev/null
+++ b/lib/libc/tests/secure/fortify_wchar_test.c
@@ -0,0 +1,2124 @@
+/* @generated by `generate-fortify-tests.lua "wchar"` */
+
+#define _FORTIFY_SOURCE 2
+#define TMPFILE_SIZE (1024 * 32)
+
+#include <sys/param.h>
+#include <sys/jail.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <wchar.h>
+#include <atf-c.h>
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+ATF_TC(wmemcpy_before_end);
+ATF_TC_HEAD(wmemcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wmemcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ wmemcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemcpy_end);
+ATF_TC_HEAD(wmemcpy_end, tc)
+{
+}
+ATF_TC_BODY(wmemcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ wmemcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemcpy_heap_before_end);
+ATF_TC_HEAD(wmemcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wmemcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmemcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemcpy_heap_end);
+ATF_TC_HEAD(wmemcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wmemcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmemcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemcpy_heap_after_end);
+ATF_TC_HEAD(wmemcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wmemcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ wmemcpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wmempcpy_before_end);
+ATF_TC_HEAD(wmempcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wmempcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ wmempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmempcpy_end);
+ATF_TC_HEAD(wmempcpy_end, tc)
+{
+}
+ATF_TC_BODY(wmempcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ wmempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmempcpy_heap_before_end);
+ATF_TC_HEAD(wmempcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wmempcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmempcpy_heap_end);
+ATF_TC_HEAD(wmempcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wmempcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmempcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmempcpy_heap_after_end);
+ATF_TC_HEAD(wmempcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wmempcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ wmempcpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wmemmove_before_end);
+ATF_TC_HEAD(wmemmove_before_end, tc)
+{
+}
+ATF_TC_BODY(wmemmove_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ wmemmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemmove_end);
+ATF_TC_HEAD(wmemmove_end, tc)
+{
+}
+ATF_TC_BODY(wmemmove_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ wmemmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemmove_heap_before_end);
+ATF_TC_HEAD(wmemmove_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wmemmove_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmemmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemmove_heap_end);
+ATF_TC_HEAD(wmemmove_heap_end, tc)
+{
+}
+ATF_TC_BODY(wmemmove_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len + 10];
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmemmove(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemmove_heap_after_end);
+ATF_TC_HEAD(wmemmove_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wmemmove_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len + 10];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ wmemmove(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wmemset_before_end);
+ATF_TC_HEAD(wmemset_before_end, tc)
+{
+}
+ATF_TC_BODY(wmemset_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ wmemset(__stack.__buf, L'0', __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemset_end);
+ATF_TC_HEAD(wmemset_end, tc)
+{
+}
+ATF_TC_BODY(wmemset_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ wmemset(__stack.__buf, L'0', __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemset_heap_before_end);
+ATF_TC_HEAD(wmemset_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wmemset_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmemset(__stack.__buf, L'0', __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemset_heap_end);
+ATF_TC_HEAD(wmemset_heap_end, tc)
+{
+}
+ATF_TC_BODY(wmemset_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+
+ __stack.__buf = malloc(__bufsz);
+
+ wmemset(__stack.__buf, L'0', __len);
+#undef BUF
+
+}
+
+ATF_TC(wmemset_heap_after_end);
+ATF_TC_HEAD(wmemset_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wmemset_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+
+ wmemset(__stack.__buf, L'0', __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcpcpy_before_end);
+ATF_TC_HEAD(wcpcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wcpcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcpcpy_end);
+ATF_TC_HEAD(wcpcpy_end, tc)
+{
+}
+ATF_TC_BODY(wcpcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcpcpy_heap_before_end);
+ATF_TC_HEAD(wcpcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcpcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcpcpy_heap_end);
+ATF_TC_HEAD(wcpcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcpcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpcpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcpcpy_heap_after_end);
+ATF_TC_HEAD(wcpcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcpcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpcpy(__stack.__buf, src);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcpncpy_before_end);
+ATF_TC_HEAD(wcpncpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wcpncpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcpncpy_end);
+ATF_TC_HEAD(wcpncpy_end, tc)
+{
+}
+ATF_TC_BODY(wcpncpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcpncpy_heap_before_end);
+ATF_TC_HEAD(wcpncpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcpncpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcpncpy_heap_end);
+ATF_TC_HEAD(wcpncpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcpncpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcpncpy_heap_after_end);
+ATF_TC_HEAD(wcpncpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcpncpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcpncpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcscat_before_end);
+ATF_TC_HEAD(wcscat_before_end, tc)
+{
+}
+ATF_TC_BODY(wcscat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscat_end);
+ATF_TC_HEAD(wcscat_end, tc)
+{
+}
+ATF_TC_BODY(wcscat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscat_heap_before_end);
+ATF_TC_HEAD(wcscat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcscat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscat_heap_end);
+ATF_TC_HEAD(wcscat_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcscat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscat(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscat_heap_after_end);
+ATF_TC_HEAD(wcscat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcscat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscat(__stack.__buf, src);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcslcat_before_end);
+ATF_TC_HEAD(wcslcat_before_end, tc)
+{
+}
+ATF_TC_BODY(wcslcat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcat_end);
+ATF_TC_HEAD(wcslcat_end, tc)
+{
+}
+ATF_TC_BODY(wcslcat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcat_heap_before_end);
+ATF_TC_HEAD(wcslcat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcslcat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcat_heap_end);
+ATF_TC_HEAD(wcslcat_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcslcat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcat_heap_after_end);
+ATF_TC_HEAD(wcslcat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcslcat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcat(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcsncat_before_end);
+ATF_TC_HEAD(wcsncat_before_end, tc)
+{
+}
+ATF_TC_BODY(wcsncat_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncat_end);
+ATF_TC_HEAD(wcsncat_end, tc)
+{
+}
+ATF_TC_BODY(wcsncat_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncat_heap_before_end);
+ATF_TC_HEAD(wcsncat_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcsncat_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncat_heap_end);
+ATF_TC_HEAD(wcsncat_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcsncat_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncat(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncat_heap_after_end);
+ATF_TC_HEAD(wcsncat_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcsncat_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncat(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcscpy_before_end);
+ATF_TC_HEAD(wcscpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wcscpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscpy_end);
+ATF_TC_HEAD(wcscpy_end, tc)
+{
+}
+ATF_TC_BODY(wcscpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscpy_heap_before_end);
+ATF_TC_HEAD(wcscpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcscpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscpy_heap_end);
+ATF_TC_HEAD(wcscpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcscpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscpy(__stack.__buf, src);
+#undef BUF
+
+}
+
+ATF_TC(wcscpy_heap_after_end);
+ATF_TC_HEAD(wcscpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcscpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcscpy(__stack.__buf, src);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcslcpy_before_end);
+ATF_TC_HEAD(wcslcpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wcslcpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcpy_end);
+ATF_TC_HEAD(wcslcpy_end, tc)
+{
+}
+ATF_TC_BODY(wcslcpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcpy_heap_before_end);
+ATF_TC_HEAD(wcslcpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcslcpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcpy_heap_end);
+ATF_TC_HEAD(wcslcpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcslcpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcslcpy_heap_after_end);
+ATF_TC_HEAD(wcslcpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcslcpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcslcpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TC(wcsncpy_before_end);
+ATF_TC_HEAD(wcsncpy_before_end, tc)
+{
+}
+ATF_TC_BODY(wcsncpy_before_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncpy_end);
+ATF_TC_HEAD(wcsncpy_end, tc)
+{
+}
+ATF_TC_BODY(wcsncpy_end, tc)
+{
+#define BUF &__stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t __buf[42];
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(__stack.__buf);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncpy_heap_before_end);
+ATF_TC_HEAD(wcsncpy_heap_before_end, tc)
+{
+}
+ATF_TC_BODY(wcsncpy_heap_before_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 - 1;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncpy_heap_end);
+ATF_TC_HEAD(wcsncpy_heap_end, tc)
+{
+}
+ATF_TC_BODY(wcsncpy_heap_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42;
+ const size_t __idx __unused = __len - 1;
+ wchar_t src[__len];
+
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncpy(__stack.__buf, src, __len);
+#undef BUF
+
+}
+
+ATF_TC(wcsncpy_heap_after_end);
+ATF_TC_HEAD(wcsncpy_heap_after_end, tc)
+{
+}
+ATF_TC_BODY(wcsncpy_heap_after_end, tc)
+{
+#define BUF __stack.__buf
+ struct {
+ uint8_t padding_l;
+ wchar_t * __buf;
+ uint8_t padding_r;
+ } __stack;
+ const size_t __bufsz __unused = sizeof(*__stack.__buf) * (42);
+ const size_t __len = 42 + 1;
+ const size_t __idx __unused = __len - 1;
+ pid_t __child;
+ int __status;
+ wchar_t src[__len];
+
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+ __stack.__buf = malloc(__bufsz);
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+
+ wcsncpy(__stack.__buf, src, __len);
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+#undef BUF
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, wmemcpy_before_end);
+ ATF_TP_ADD_TC(tp, wmemcpy_end);
+ ATF_TP_ADD_TC(tp, wmemcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wmemcpy_heap_end);
+ ATF_TP_ADD_TC(tp, wmemcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, wmempcpy_before_end);
+ ATF_TP_ADD_TC(tp, wmempcpy_end);
+ ATF_TP_ADD_TC(tp, wmempcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wmempcpy_heap_end);
+ ATF_TP_ADD_TC(tp, wmempcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, wmemmove_before_end);
+ ATF_TP_ADD_TC(tp, wmemmove_end);
+ ATF_TP_ADD_TC(tp, wmemmove_heap_before_end);
+ ATF_TP_ADD_TC(tp, wmemmove_heap_end);
+ ATF_TP_ADD_TC(tp, wmemmove_heap_after_end);
+ ATF_TP_ADD_TC(tp, wmemset_before_end);
+ ATF_TP_ADD_TC(tp, wmemset_end);
+ ATF_TP_ADD_TC(tp, wmemset_heap_before_end);
+ ATF_TP_ADD_TC(tp, wmemset_heap_end);
+ ATF_TP_ADD_TC(tp, wmemset_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcpcpy_before_end);
+ ATF_TP_ADD_TC(tp, wcpcpy_end);
+ ATF_TP_ADD_TC(tp, wcpcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcpcpy_heap_end);
+ ATF_TP_ADD_TC(tp, wcpcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcpncpy_before_end);
+ ATF_TP_ADD_TC(tp, wcpncpy_end);
+ ATF_TP_ADD_TC(tp, wcpncpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcpncpy_heap_end);
+ ATF_TP_ADD_TC(tp, wcpncpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcscat_before_end);
+ ATF_TP_ADD_TC(tp, wcscat_end);
+ ATF_TP_ADD_TC(tp, wcscat_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcscat_heap_end);
+ ATF_TP_ADD_TC(tp, wcscat_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcslcat_before_end);
+ ATF_TP_ADD_TC(tp, wcslcat_end);
+ ATF_TP_ADD_TC(tp, wcslcat_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcslcat_heap_end);
+ ATF_TP_ADD_TC(tp, wcslcat_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcsncat_before_end);
+ ATF_TP_ADD_TC(tp, wcsncat_end);
+ ATF_TP_ADD_TC(tp, wcsncat_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcsncat_heap_end);
+ ATF_TP_ADD_TC(tp, wcsncat_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcscpy_before_end);
+ ATF_TP_ADD_TC(tp, wcscpy_end);
+ ATF_TP_ADD_TC(tp, wcscpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcscpy_heap_end);
+ ATF_TP_ADD_TC(tp, wcscpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcslcpy_before_end);
+ ATF_TP_ADD_TC(tp, wcslcpy_end);
+ ATF_TP_ADD_TC(tp, wcslcpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcslcpy_heap_end);
+ ATF_TP_ADD_TC(tp, wcslcpy_heap_after_end);
+ ATF_TP_ADD_TC(tp, wcsncpy_before_end);
+ ATF_TP_ADD_TC(tp, wcsncpy_end);
+ ATF_TP_ADD_TC(tp, wcsncpy_heap_before_end);
+ ATF_TP_ADD_TC(tp, wcsncpy_heap_end);
+ ATF_TP_ADD_TC(tp, wcsncpy_heap_after_end);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/secure/generate-fortify-tests.lua b/lib/libc/tests/secure/generate-fortify-tests.lua
new file mode 100755
index 000000000000..c9cd9353a869
--- /dev/null
+++ b/lib/libc/tests/secure/generate-fortify-tests.lua
@@ -0,0 +1,1581 @@
+#!/usr/libexec/flua
+--
+-- SPDX-License-Identifier: BSD-2-Clause
+--
+-- Copyright (c) 2024, Klara, 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.
+--
+-- 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.
+--
+
+-- THEORY OF OPERATION
+--
+-- generate-fortify-tests.lua is intended to test fortified functions as found
+-- mostly in the various headers in /usr/include/ssp. Each fortified function
+-- gets three basic tests:
+--
+-- 1. Write just before the end of the buffer,
+-- 2. Write right at the end of the buffer,
+-- 3. Write just after the end of the buffer.
+--
+-- Each test is actually generated twice: once with a buffer on the stack, and
+-- again with a buffer on the heap, to confirm that __builtin_object_size(3) can
+-- deduce the buffer size in both scenarios. The tests work by setting up the
+-- stack with our buffer (and some padding on either side to avoid tripping any
+-- other stack or memory protection), doing any initialization as described by
+-- the test definition, then calling the fortified function with the buffer as
+-- outlined by the test definition.
+--
+-- For the 'before' and 'at' the end tests, we're ensuring that valid writes
+-- that are on the verge of being invalid aren't accidentally being detected as
+-- invalid.
+--
+-- The 'after' test is the one that actually tests the functional benefit of
+-- _FORTIFY_SOURCE by violating a boundary that should trigger an abort. As
+-- such, this test differs more from the other two in that it has to fork() off
+-- the fortified function call so that we can monitor for a SIGABRT and
+-- pass/fail the test at function end appropriately.
+
+-- Some tests, like the FD_*() macros, may define these differently. For
+-- instance, for fd sets we're varying the index we pass and not using arbitrary
+-- buffers. Other tests that don't use the length in any way may physically
+-- vary the buffer size for each test case when we'd typically vary the length
+-- we're requesting a write for.
+
+local includes = {
+ "sys/param.h",
+ "sys/jail.h",
+ "sys/random.h",
+ "sys/resource.h",
+ "sys/select.h",
+ "sys/socket.h",
+ "sys/time.h",
+ "sys/uio.h",
+ "sys/wait.h",
+ "dirent.h",
+ "errno.h",
+ "fcntl.h",
+ "limits.h",
+ "poll.h",
+ "signal.h",
+ "stdio.h",
+ "stdlib.h",
+ "string.h",
+ "strings.h",
+ "sysexits.h",
+ "unistd.h",
+ "wchar.h",
+ "atf-c.h",
+}
+
+local tests_added = {}
+
+-- Configuration for tests that want the host/domainname
+local hostname = "host.example.com"
+local domainname = "example.com"
+
+-- Some of these will need to be excluded because clang sees the wrong size when
+-- an array is embedded inside a struct, we'll get something that looks more
+-- like __builtin_object_size(ptr, 0) than it does the correct
+-- __builtin_object_size(ptr, 1) (i.e., includes the padding after). This is
+-- almost certainly a bug in llvm.
+local function excludes_stack_overflow(disposition, is_heap)
+ return (not is_heap) and disposition > 0
+end
+
+local poll_init = [[
+ for (size_t i = 0; i < howmany(__bufsz, sizeof(struct pollfd)); i++) {
+ __stack.__buf[i].fd = -1;
+ }
+]]
+
+local printf_stackvars = "\tchar srcvar[__len + 10];\n"
+local printf_init = [[
+ memset(srcvar, 'A', sizeof(srcvar) - 1);
+ srcvar[sizeof(srcvar) - 1] = '\0';
+]]
+
+local readv_stackvars = "\tstruct iovec iov[1];\n"
+local readv_init = [[
+ iov[0].iov_base = __stack.__buf;
+ iov[0].iov_len = __len;
+
+ replace_stdin();
+]]
+
+local socket_stackvars = "\tint sock[2] = { -1, -1 };\n"
+local recvfrom_sockaddr_stackvars = socket_stackvars .. [[
+ char data[16];
+ socklen_t socklen;
+]]
+local recvmsg_stackvars = socket_stackvars .. "\tstruct msghdr msg;\n"
+local socket_init = [[
+ new_socket(sock);
+]]
+local socket_socklen_init = socket_init .. [[
+ socklen = __len;
+]]
+
+local stdio_init = [[
+ replace_stdin();
+]]
+
+local string_stackvars = "\tchar src[__len];\n"
+local string_init = [[
+ memset(__stack.__buf, 0, __len);
+ memset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+]]
+
+local wstring_stackvars = "\twchar_t src[__len];\n"
+local wstring_init = [[
+ wmemset(__stack.__buf, 0, __len);
+ wmemset(src, 'A', __len - 1);
+ src[__len - 1] = '\0';
+]]
+
+-- Each test entry describes how to test a given function. We need to know how
+-- to construct the buffer, we need to know the argument set we're dealing with,
+-- and we need to know what we're passing to each argument. We could be passing
+-- fixed values, or we could be passing the __buf under test.
+--
+-- definition:
+-- func: name of the function under test to call
+-- bufsize: size of buffer to generate, defaults to 42
+-- buftype: type of buffer to generate, defaults to unsigned char[]
+-- arguments: __buf, __len, or the name of a variable placed on the stack
+-- exclude: a function(disposition, is_heap) that returns true if this combo
+-- should be excluded.
+-- stackvars: extra variables to be placed on the stack, should be a string
+-- optionally formatted with tabs and newlines
+-- init: extra code to inject just before the function call for initialization
+-- of the buffer or any of the above-added stackvars; also a string
+-- uses_len: bool-ish, necessary if arguments doesn't include either __idx or
+-- or __len so that the test generator doesn't try to vary the size of the
+-- buffer instead of just manipulating __idx/__len to try and induce an
+-- overflow.
+--
+-- Most tests will just use the default bufsize/buftype, but under some
+-- circumstances it's useful to use a different type (e.g., for alignment
+-- requirements).
+local all_tests = {
+ random = {
+ -- <sys/random.h>
+ {
+ func = "getrandom",
+ arguments = {
+ "__buf",
+ "__len",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ },
+ select = {
+ -- <sys/select.h>
+ {
+ func = "FD_SET",
+ bufsize = "FD_SETSIZE",
+ buftype = "fd_set",
+ arguments = {
+ "__idx",
+ "__buf",
+ },
+ },
+ {
+ func = "FD_CLR",
+ bufsize = "FD_SETSIZE",
+ buftype = "fd_set",
+ arguments = {
+ "__idx",
+ "__buf",
+ },
+ },
+ {
+ func = "FD_ISSET",
+ bufsize = "FD_SETSIZE",
+ buftype = "fd_set",
+ arguments = {
+ "__idx",
+ "__buf",
+ },
+ },
+ },
+ socket = {
+ -- <sys/socket.h>
+ {
+ func = "getpeername",
+ buftype = "struct sockaddr",
+ bufsize = "sizeof(struct sockaddr)",
+ arguments = {
+ "sock[0]",
+ "__buf",
+ "&socklen",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = socket_stackvars .. "\tsocklen_t socklen;",
+ init = socket_socklen_init,
+ uses_len = true,
+ },
+ {
+ func = "getsockname",
+ buftype = "struct sockaddr",
+ bufsize = "sizeof(struct sockaddr)",
+ arguments = {
+ "sock[0]",
+ "__buf",
+ "&socklen",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = socket_stackvars .. "\tsocklen_t socklen;",
+ init = socket_socklen_init,
+ uses_len = true,
+ },
+ {
+ func = "recv",
+ arguments = {
+ "sock[0]",
+ "__buf",
+ "__len",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = socket_stackvars,
+ init = socket_init,
+ },
+ {
+ func = "recvfrom",
+ arguments = {
+ "sock[0]",
+ "__buf",
+ "__len",
+ "0",
+ "NULL",
+ "NULL",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = socket_stackvars,
+ init = socket_init,
+ },
+ {
+ func = "recvfrom",
+ variant = "sockaddr",
+ buftype = "struct sockaddr",
+ bufsize = "sizeof(struct sockaddr)",
+ arguments = {
+ "sock[0]",
+ "data",
+ "sizeof(data)",
+ "0",
+ "__buf",
+ "&socklen",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = recvfrom_sockaddr_stackvars,
+ init = socket_socklen_init,
+ uses_len = true,
+ },
+ {
+ func = "recvmsg",
+ variant = "msg_name",
+ buftype = "struct sockaddr",
+ bufsize = "sizeof(struct sockaddr)",
+ arguments = {
+ "sock[0]",
+ "&msg",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = recvmsg_stackvars,
+ init = [[
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_name = BUF;
+ msg.msg_namelen = __len;
+]],
+ uses_len = true,
+ },
+ {
+ func = "recvmsg",
+ variant = "msg_iov",
+ arguments = {
+ "sock[0]",
+ "&msg",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = recvmsg_stackvars .. "\tstruct iovec iov[2];\n",
+ init = [[
+ memset(&msg, 0, sizeof(msg));
+ memset(&iov[0], 0, sizeof(iov));
+
+ /*
+ * We position the buffer second just so that we can confirm that the
+ * fortification bits are traversing the iovec correctly.
+ */
+ iov[1].iov_base = BUF;
+ iov[1].iov_len = __len;
+
+ msg.msg_iov = &iov[0];
+ msg.msg_iovlen = nitems(iov);
+]],
+ uses_len = true,
+ },
+ {
+ func = "recvmsg",
+ variant = "msg_control",
+ bufsize = "CMSG_SPACE(sizeof(int))",
+ arguments = {
+ "sock[0]",
+ "&msg",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = recvmsg_stackvars,
+ init = [[
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg_control = BUF;
+ msg.msg_controllen = __len;
+]],
+ uses_len = true,
+ },
+ {
+ func = "recvmmsg",
+ variant = "msgvec",
+ buftype = "struct mmsghdr[]",
+ bufsize = "2",
+ arguments = {
+ "sock[0]",
+ "__buf",
+ "__len",
+ "0",
+ "NULL",
+ },
+ stackvars = socket_stackvars,
+ },
+ {
+ -- We'll assume that recvmsg is covering msghdr
+ -- validation thoroughly enough, we'll just try tossing
+ -- an error in the second element of a msgvec to try and
+ -- make sure that each one is being validated.
+ func = "recvmmsg",
+ variant = "msghdr",
+ arguments = {
+ "sock[0]",
+ "&msgvec[0]",
+ "nitems(msgvec)",
+ "0",
+ "NULL",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = socket_stackvars .. "\tstruct mmsghdr msgvec[2];\n",
+ init = [[
+ memset(&msgvec[0], 0, sizeof(msgvec));
+
+ /*
+ * Same as above, make sure fortification isn't ignoring n > 1 elements
+ * of the msgvec.
+ */
+ msgvec[1].msg_hdr.msg_control = BUF;
+ msgvec[1].msg_hdr.msg_controllen = __len;
+]],
+ uses_len = true,
+ },
+ },
+ uio = {
+ -- <sys/uio.h>
+ {
+ func = "readv",
+ buftype = "struct iovec[]",
+ bufsize = 2,
+ arguments = {
+ "STDIN_FILENO",
+ "__buf",
+ "__len",
+ },
+ },
+ {
+ func = "readv",
+ variant = "iov",
+ arguments = {
+ "STDIN_FILENO",
+ "iov",
+ "nitems(iov)",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = readv_stackvars,
+ init = readv_init,
+ uses_len = true,
+ },
+ {
+ func = "preadv",
+ buftype = "struct iovec[]",
+ bufsize = 2,
+ arguments = {
+ "STDIN_FILENO",
+ "__buf",
+ "__len",
+ "0",
+ },
+ },
+ {
+ func = "preadv",
+ variant = "iov",
+ arguments = {
+ "STDIN_FILENO",
+ "iov",
+ "nitems(iov)",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = readv_stackvars,
+ init = readv_init,
+ uses_len = true,
+ },
+ },
+ poll = {
+ -- <poll.h>
+ {
+ func = "poll",
+ bufsize = "4",
+ buftype = "struct pollfd[]",
+ arguments = {
+ "__buf",
+ "__len",
+ "0",
+ },
+ init = poll_init,
+ },
+ {
+ func = "ppoll",
+ bufsize = "4",
+ buftype = "struct pollfd[]",
+ arguments = {
+ "__buf",
+ "__len",
+ "&tv",
+ "NULL",
+ },
+ stackvars = "\tstruct timespec tv = { 0 };\n",
+ init = poll_init,
+ },
+ },
+ signal = {
+ -- <signal.h>
+ {
+ func = "sig2str",
+ bufsize = "SIG2STR_MAX",
+ arguments = {
+ "1",
+ "__buf",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ },
+ stdio = {
+ -- <stdio.h>
+ {
+ func = "ctermid",
+ bufsize = "L_ctermid",
+ arguments = {
+ "__buf",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "ctermid_r",
+ bufsize = "L_ctermid",
+ arguments = {
+ "__buf",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "fread",
+ arguments = {
+ "__buf",
+ "__len",
+ "1",
+ "stdin",
+ },
+ exclude = excludes_stack_overflow,
+ init = stdio_init,
+ },
+ {
+ func = "fread_unlocked",
+ arguments = {
+ "__buf",
+ "__len",
+ "1",
+ "stdin",
+ },
+ exclude = excludes_stack_overflow,
+ init = stdio_init,
+ },
+ {
+ func = "gets_s",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ init = stdio_init,
+ },
+ {
+ func = "sprintf",
+ arguments = {
+ "__buf",
+ "\"%.*s\"",
+ "(int)__len - 1", -- - 1 for NUL terminator
+ "srcvar",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = printf_stackvars,
+ init = printf_init,
+ },
+ {
+ func = "snprintf",
+ arguments = {
+ "__buf",
+ "__len",
+ "\"%.*s\"",
+ "(int)__len - 1", -- - 1 for NUL terminator
+ "srcvar",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = printf_stackvars,
+ init = printf_init,
+ },
+ {
+ func = "tmpnam",
+ bufsize = "L_tmpnam",
+ arguments = {
+ "__buf",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "fgets",
+ arguments = {
+ "__buf",
+ "__len",
+ "fp",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tFILE *fp;\n",
+ init = [[
+ fp = new_fp(__len);
+]],
+ },
+ },
+ stdlib = {
+ -- <stdlib.h>
+ {
+ func = "arc4random_buf",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "getenv_r",
+ arguments = {
+ "\"PATH\"",
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "realpath",
+ bufsize = "PATH_MAX",
+ arguments = {
+ "\".\"",
+ "__buf",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ },
+ string = {
+ -- <string.h>
+ {
+ func = "memcpy",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tchar src[__len + 10];\n",
+ },
+ {
+ func = "mempcpy",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tchar src[__len + 10];\n",
+ },
+ {
+ func = "memmove",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tchar src[__len + 10];\n",
+ },
+ {
+ func = "memset",
+ arguments = {
+ "__buf",
+ "0",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "memset_explicit",
+ arguments = {
+ "__buf",
+ "0",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "stpcpy",
+ arguments = {
+ "__buf",
+ "src",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ uses_len = true,
+ },
+ {
+ func = "stpncpy",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ },
+ {
+ func = "strcat",
+ arguments = {
+ "__buf",
+ "src",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ uses_len = true,
+ },
+ {
+ func = "strlcat",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ },
+ {
+ func = "strncat",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ },
+ {
+ func = "strcpy",
+ arguments = {
+ "__buf",
+ "src",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ uses_len = true,
+ },
+ {
+ func = "strlcpy",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ },
+ {
+ func = "strncpy",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = string_stackvars,
+ init = string_init,
+ },
+ },
+ strings = {
+ -- <strings.h>
+ {
+ func = "bcopy",
+ arguments = {
+ "src",
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tchar src[__len + 10];\n",
+ },
+ {
+ func = "bzero",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "explicit_bzero",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ },
+ unistd = {
+ -- <unistd.h>
+ {
+ func = "getcwd",
+ bufsize = "8",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "getgrouplist",
+ bufsize = "4",
+ buftype = "gid_t[]",
+ arguments = {
+ "\"root\"",
+ "0",
+ "__buf",
+ "&intlen",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tint intlen = (int)__len;\n",
+ uses_len = true,
+ },
+ {
+ func = "getgroups",
+ bufsize = "4",
+ buftype = "gid_t[]",
+ arguments = {
+ "__len",
+ "__buf",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "getloginclass",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "pread",
+ bufsize = "41",
+ arguments = {
+ "fd",
+ "__buf",
+ "__len",
+ "0",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tint fd;\n",
+ init = [[
+ fd = new_tmpfile(); /* Cannot fail */
+]],
+ },
+ {
+ func = "read",
+ bufsize = "41",
+ arguments = {
+ "fd",
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tint fd;\n",
+ init = [[
+ fd = new_tmpfile(); /* Cannot fail */
+]],
+ },
+ {
+ func = "readlink",
+ arguments = {
+ "path",
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tconst char *path;\n",
+ init = [[
+ path = new_symlink(__len); /* Cannot fail */
+]],
+ },
+ {
+ func = "readlinkat",
+ arguments = {
+ "AT_FDCWD",
+ "path",
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tconst char *path;\n",
+ init = [[
+ path = new_symlink(__len); /* Cannot fail */
+]],
+ },
+ {
+ func = "getdomainname",
+ bufsize = #domainname + 1,
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ need_root = true,
+ exclude = excludes_stack_overflow,
+ early_init = " dhost_jail();",
+ },
+ {
+ func = "getentropy",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "gethostname",
+ bufsize = #hostname + 1,
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ need_root = true,
+ exclude = excludes_stack_overflow,
+ early_init = " dhost_jail();",
+ },
+ {
+ func = "getlogin_r",
+ bufsize = "MAXLOGNAME + 1",
+ arguments = {
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "ttyname_r",
+ arguments = {
+ "fd",
+ "__buf",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\tint fd;\n",
+ early_init = [[
+ fd = STDIN_FILENO;
+ if (!isatty(fd))
+ atf_tc_skip("stdin is not an fd");
+]]
+ },
+ },
+ wchar = {
+ -- <wchar.h>
+ {
+ func = "wmemcpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\twchar_t src[__len + 10];\n",
+ },
+ {
+ func = "wmempcpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\twchar_t src[__len + 10];\n",
+ },
+ {
+ func = "wmemmove",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = "\twchar_t src[__len + 10];\n",
+ },
+ {
+ func = "wmemset",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "L'0'",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ },
+ {
+ func = "wcpcpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ uses_len = true,
+ },
+ {
+ func = "wcpncpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ },
+ {
+ func = "wcscat",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ uses_len = true,
+ },
+ {
+ func = "wcslcat",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ },
+ {
+ func = "wcsncat",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ },
+ {
+ func = "wcscpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ uses_len = true,
+ },
+ {
+ func = "wcslcpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ },
+ {
+ func = "wcsncpy",
+ buftype = "wchar_t[]",
+ arguments = {
+ "__buf",
+ "src",
+ "__len",
+ },
+ exclude = excludes_stack_overflow,
+ stackvars = wstring_stackvars,
+ init = wstring_init,
+ },
+ },
+}
+
+local function write_test_boilerplate(fh, name, body, def)
+ fh:write("ATF_TC(" .. name .. ");\n")
+ fh:write("ATF_TC_HEAD(" .. name .. ", tc)\n")
+ fh:write("{\n")
+ if def.need_root then
+ fh:write(" atf_tc_set_md_var(tc, \"require.user\", \"root\");\n")
+ end
+ fh:write("}\n")
+
+ fh:write("ATF_TC_BODY(" .. name .. ", tc)\n")
+ fh:write("{\n" .. body .. "\n}\n\n")
+ return name
+end
+
+local function generate_test_name(func, variant, disposition, heap)
+ local basename = func
+ if variant then
+ basename = basename .. "_" .. variant
+ end
+ if heap then
+ basename = basename .. "_heap"
+ end
+ if disposition < 0 then
+ return basename .. "_before_end"
+ elseif disposition == 0 then
+ return basename .. "_end"
+ else
+ return basename .. "_after_end"
+ end
+end
+
+local function array_type(buftype)
+ if not buftype:match("%[%]") then
+ return nil
+ end
+
+ return buftype:gsub("%[%]", "")
+end
+
+local function configurable(def, idx)
+ local cfgitem = def[idx]
+
+ if not cfgitem then
+ return nil
+ end
+
+ if type(cfgitem) == "function" then
+ return cfgitem()
+ end
+
+ return cfgitem
+end
+
+local function generate_stackframe(buftype, bufsize, disposition, heap, def)
+ local function len_offset(inverted)
+ -- Tests that don't use __len in their arguments may use an
+ -- inverted sense because we can't just specify a length that
+ -- would induce an access just after the end. Instead, we have
+ -- to manipulate the buffer size to be too short so that the
+ -- function under test would write one too many.
+ if disposition < 0 then
+ return ((inverted and " + ") or " - ") .. "1"
+ elseif disposition == 0 then
+ return ""
+ else
+ return ((inverted and " - ") or " + ") .. "1"
+ end
+ end
+
+ local function test_uses_len()
+ if def.uses_len then
+ return true
+ end
+
+ for _, arg in ipairs(def.arguments) do
+ if arg:match("__len") or arg:match("__idx") then
+ return true
+ end
+ end
+
+ return false
+ end
+
+
+ -- This is perhaps a little convoluted, but we toss the buffer into a
+ -- struct on the stack to guarantee that we have at least one valid
+ -- byte on either side of the buffer -- a measure to make sure that
+ -- we're tripping _FORTIFY_SOURCE specifically in the buffer + 1 case,
+ -- rather than some other stack or memory protection.
+ local vars = "\tstruct {\n"
+ vars = vars .. "\t\tuint8_t padding_l;\n"
+
+ local uses_len = test_uses_len()
+ local bufsize_offset = len_offset(not uses_len)
+ local buftype_elem = array_type(buftype)
+ local size_expr = bufsize
+
+ if not uses_len then
+ -- If the length isn't in use, we have to vary the buffer size
+ -- since the fortified function likely has some internal size
+ -- constraint that it's supposed to be checking.
+ size_expr = size_expr .. bufsize_offset
+ end
+
+ if not heap and buftype_elem then
+ -- Array type: size goes after identifier
+ vars = vars .. "\t\t" .. buftype_elem ..
+ " __buf[" .. size_expr .. "];\n"
+ else
+ local basic_type = buftype_elem or buftype
+
+ -- Heap tests obviously just put a pointer on the stack that
+ -- points to our new allocation, but we leave it in the padded
+ -- struct just to simplify our generator.
+ if heap then
+ basic_type = basic_type .. " *"
+ end
+ vars = vars .. "\t\t" .. basic_type .. " __buf;\n"
+ end
+
+ -- padding_r is our just-past-the-end padding that we use to make sure
+ -- that there's a valid portion after the buffer that isn't being
+ -- included in our function calls. If we didn't have it, then we'd have
+ -- a hard time feeling confident that an abort on the just-after tests
+ -- isn't maybe from some other memory or stack protection.
+ vars = vars .. "\t\tuint8_t padding_r;\n"
+ vars = vars .. "\t} __stack;\n"
+
+ -- Not all tests will use __bufsz, but some do for, e.g., clearing
+ -- memory..
+ vars = vars .. "\tconst size_t __bufsz __unused = "
+ if heap then
+ local scalar = 1
+ if buftype_elem then
+ scalar = size_expr
+ end
+
+ vars = vars .. "sizeof(*__stack.__buf) * (" .. scalar .. ");\n"
+ else
+ vars = vars .. "sizeof(__stack.__buf);\n"
+ end
+
+ vars = vars .. "\tconst size_t __len = " .. bufsize ..
+ bufsize_offset .. ";\n"
+ vars = vars .. "\tconst size_t __idx __unused = __len - 1;\n"
+
+ -- For overflow testing, we need to fork() because we're expecting the
+ -- test to ultimately abort()/_exit(). Then we can collect the exit
+ -- status and report appropriately.
+ if disposition > 0 then
+ vars = vars .. "\tpid_t __child;\n"
+ vars = vars .. "\tint __status;\n"
+ end
+
+ -- Any other stackvars defined by the test get placed after everything
+ -- else.
+ vars = vars .. (configurable(def, "stackvars") or "")
+
+ return vars
+end
+
+local function write_test(fh, func, disposition, heap, def)
+ local testname = generate_test_name(func, def.variant, disposition, heap)
+ local buftype = def.buftype or "unsigned char[]"
+ local bufsize = def.bufsize or 42
+ local body = ""
+
+ if def.exclude and def.exclude(disposition, heap) then
+ return
+ end
+
+ local function need_addr()
+ return not (buftype:match("%[%]") or buftype:match("%*"))
+ end
+
+ if heap then
+ body = body .. "#define BUF __stack.__buf\n"
+ else
+ body = body .. "#define BUF &__stack.__buf\n"
+ end
+
+ -- Setup the buffer
+ body = body .. generate_stackframe(buftype, bufsize, disposition, heap, def) ..
+ "\n"
+
+ -- Any early initialization goes before we would fork for the just-after
+ -- tests, because they may want to skip the test based on some criteria
+ -- and we can't propagate that up very easily once we're forked.
+ local early_init = configurable(def, "early_init")
+ body = body .. (early_init or "")
+ if early_init then
+ body = body .. "\n"
+ end
+
+ -- Fork off, iff we're testing some access past the end of the buffer.
+ if disposition > 0 then
+ body = body .. [[
+ __child = fork();
+ ATF_REQUIRE(__child >= 0);
+ if (__child > 0)
+ goto monitor;
+
+ /* Child */
+ disable_coredumps();
+]]
+ end
+
+ local bufvar = "__stack.__buf"
+ if heap then
+ -- Buffer needs to be initialized because it's a heap allocation.
+ body = body .. "\t" .. bufvar .. " = malloc(__bufsz);\n"
+ end
+
+ -- Non-early init happens just after the fork in the child, not the
+ -- monitor. This is used to setup any other buffers we may need, for
+ -- instance.
+ local extra_init = configurable(def, "init")
+ body = body .. (extra_init or "")
+
+ if heap or extra_init then
+ body = body .. "\n"
+ end
+
+ -- Setup the function call with arguments as described in the test
+ -- definition.
+ body = body .. "\t" .. func .. "("
+
+ for idx, arg in ipairs(def.arguments) do
+ if idx > 1 then
+ body = body .. ", "
+ end
+
+ if arg == "__buf" then
+ if not heap and need_addr() then
+ body = body .. "&"
+ end
+
+ body = body .. bufvar
+ else
+ local argname = arg
+
+ if def.value_of then
+ argname = argname or def.value_of(arg)
+ end
+
+ body = body .. argname
+ end
+ end
+
+ body = body .. ");\n"
+
+ -- Monitor stuff follows, for OOB access.
+ if disposition <= 0 then
+ goto skip
+ end
+
+ body = body .. [[
+ _exit(EX_SOFTWARE); /* Should have aborted. */
+
+monitor:
+ while (waitpid(__child, &__status, 0) != __child) {
+ ATF_REQUIRE_EQ(EINTR, errno);
+ }
+
+ if (!WIFSIGNALED(__status)) {
+ switch (WEXITSTATUS(__status)) {
+ case EX_SOFTWARE:
+ atf_tc_fail("FORTIFY_SOURCE failed to abort");
+ break;
+ case EX_OSERR:
+ atf_tc_fail("setrlimit(2) failed");
+ break;
+ default:
+ atf_tc_fail("child exited with status %d",
+ WEXITSTATUS(__status));
+ }
+ } else {
+ ATF_REQUIRE_EQ(SIGABRT, WTERMSIG(__status));
+ }
+]]
+
+::skip::
+ body = body .. "#undef BUF\n"
+ return write_test_boilerplate(fh, testname, body, def)
+end
+
+-- main()
+local tests
+local tcat = assert(arg[1], "usage: generate-fortify-tests.lua <category>")
+for k, defs in pairs(all_tests) do
+ if k == tcat then
+ tests = defs
+ break
+ end
+end
+
+assert(tests, "category " .. tcat .. " not found")
+
+local fh = io.stdout
+fh:write("/* @" .. "generated" .. " by `generate-fortify-tests.lua \"" ..
+ tcat .. "\"` */\n\n")
+fh:write("#define _FORTIFY_SOURCE 2\n")
+fh:write("#define TMPFILE_SIZE (1024 * 32)\n")
+
+fh:write("\n")
+for _, inc in ipairs(includes) do
+ fh:write("#include <" .. inc .. ">\n")
+end
+
+fh:write([[
+
+static FILE * __unused
+new_fp(size_t __len)
+{
+ static char fpbuf[LINE_MAX];
+ FILE *fp;
+
+ ATF_REQUIRE(__len <= sizeof(fpbuf));
+
+ memset(fpbuf, 'A', sizeof(fpbuf) - 1);
+ fpbuf[sizeof(fpbuf) - 1] = '\0';
+
+ fp = fmemopen(fpbuf, sizeof(fpbuf), "rb");
+ ATF_REQUIRE(fp != NULL);
+
+ return (fp);
+}
+
+/*
+ * Create a new symlink to use for readlink(2) style tests, we'll just use a
+ * random target name to have something interesting to look at.
+ */
+static const char * __unused
+new_symlink(size_t __len)
+{
+ static const char linkname[] = "link";
+ char target[MAXNAMLEN];
+ int error;
+
+ ATF_REQUIRE(__len <= sizeof(target));
+
+ arc4random_buf(target, sizeof(target));
+
+ error = unlink(linkname);
+ ATF_REQUIRE(error == 0 || errno == ENOENT);
+
+ error = symlink(target, linkname);
+ ATF_REQUIRE(error == 0);
+
+ return (linkname);
+}
+
+/*
+ * For our purposes, first descriptor will be the reader; we'll send both
+ * raw data and a control message over it so that the result can be used for
+ * any of our recv*() tests.
+ */
+static void __unused
+new_socket(int sock[2])
+{
+ unsigned char ctrl[CMSG_SPACE(sizeof(int))] = { 0 };
+ static char sockbuf[256];
+ ssize_t rv;
+ size_t total = 0;
+ struct msghdr hdr = { 0 };
+ struct cmsghdr *cmsg;
+ int error, fd;
+
+ error = socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
+ ATF_REQUIRE(error == 0);
+
+ while (total != sizeof(sockbuf)) {
+ rv = send(sock[1], &sockbuf[total], sizeof(sockbuf) - total, 0);
+
+ ATF_REQUIRE_MSG(rv > 0,
+ "expected bytes sent, got %zd with %zu left (size %zu, total %zu)",
+ rv, sizeof(sockbuf) - total, sizeof(sockbuf), total);
+ ATF_REQUIRE_MSG(total + (size_t)rv <= sizeof(sockbuf),
+ "%zd exceeds total %zu", rv, sizeof(sockbuf));
+ total += rv;
+ }
+
+ hdr.msg_control = ctrl;
+ hdr.msg_controllen = sizeof(ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&hdr);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
+ fd = STDIN_FILENO;
+ memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
+
+ error = sendmsg(sock[1], &hdr, 0);
+ ATF_REQUIRE(error != -1);
+}
+
+/*
+ * Constructs a tmpfile that we can use for testing read(2) and friends.
+ */
+static int __unused
+new_tmpfile(void)
+{
+ char buf[1024];
+ ssize_t rv;
+ size_t written;
+ int fd;
+
+ fd = open("tmpfile", O_RDWR | O_CREAT | O_TRUNC, 0644);
+ ATF_REQUIRE(fd >= 0);
+
+ written = 0;
+ while (written < TMPFILE_SIZE) {
+ rv = write(fd, buf, sizeof(buf));
+ ATF_REQUIRE(rv > 0);
+
+ written += rv;
+ }
+
+ ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET));
+ return (fd);
+}
+
+static void
+disable_coredumps(void)
+{
+ struct rlimit rl = { 0 };
+
+ if (setrlimit(RLIMIT_CORE, &rl) == -1)
+ _exit(EX_OSERR);
+}
+
+/*
+ * Replaces stdin with a file that we can actually read from, for tests where
+ * we want a FILE * or fd that we can get data from.
+ */
+static void __unused
+replace_stdin(void)
+{
+ int fd;
+
+ fd = new_tmpfile();
+
+ (void)dup2(fd, STDIN_FILENO);
+ if (fd != STDIN_FILENO)
+ close(fd);
+}
+
+]])
+
+if tcat == "unistd" then
+ fh:write("#define JAIL_HOSTNAME \"" .. hostname .. "\"\n")
+ fh:write("#define JAIL_DOMAINNAME \"" .. domainname .. "\"\n")
+ fh:write([[
+static void
+dhost_jail(void)
+{
+ struct iovec iov[4];
+ int jid;
+
+ iov[0].iov_base = __DECONST(char *, "host.hostname");
+ iov[0].iov_len = sizeof("host.hostname");
+ iov[1].iov_base = __DECONST(char *, JAIL_HOSTNAME);
+ iov[1].iov_len = sizeof(JAIL_HOSTNAME);
+ iov[2].iov_base = __DECONST(char *, "host.domainname");
+ iov[2].iov_len = sizeof("host.domainname");
+ iov[3].iov_base = __DECONST(char *, JAIL_DOMAINNAME);
+ iov[3].iov_len = sizeof(JAIL_DOMAINNAME);
+
+ jid = jail_set(iov, nitems(iov), JAIL_CREATE | JAIL_ATTACH);
+ ATF_REQUIRE_MSG(jid > 0, "Jail creation failed: %s", strerror(errno));
+}
+
+]])
+end
+
+for _, def in pairs(tests) do
+ local func = def.func
+ local function write_tests(heap)
+ -- Dispositions here are relative to the buffer size prescribed
+ -- by the test definition.
+ local dispositions = def.dispositions or { -1, 0, 1 }
+
+ for _, disposition in ipairs(dispositions) do
+ tests_added[#tests_added + 1] = write_test(fh, func, disposition, heap, def)
+ end
+ end
+
+ write_tests(false)
+ write_tests(true)
+end
+
+fh:write("ATF_TP_ADD_TCS(tp)\n")
+fh:write("{\n")
+for idx = 1, #tests_added do
+ fh:write("\tATF_TP_ADD_TC(tp, " .. tests_added[idx] .. ");\n")
+end
+fh:write("\treturn (atf_no_error());\n")
+fh:write("}\n")
diff --git a/lib/libc/tests/setjmp/Makefile b/lib/libc/tests/setjmp/Makefile
index 309a5c82c462..8ea8550dfba0 100644
--- a/lib/libc/tests/setjmp/Makefile
+++ b/lib/libc/tests/setjmp/Makefile
@@ -1,4 +1,3 @@
-
NETBSD_ATF_TESTS_C= setjmp_test
NETBSD_ATF_TESTS_C+= threadjmp_test
diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile
index c6f850ec1a33..644d5a6d64a2 100644
--- a/lib/libc/tests/ssp/Makefile
+++ b/lib/libc/tests/ssp/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
MK_WERROR= no
@@ -10,6 +9,7 @@ CFLAGS.h_raw+= -fstack-protector-all -Wstack-protector
# override the sanitizer runtime libraries to be the ones installed on the
# target system.
CFLAGS.h_raw+= -fsanitize=bounds
+LIBADD+=sys
.elif ${COMPILER_TYPE} == "gcc"
CFLAGS.h_raw+= --param ssp-buffer-size=1
LDADD+= -lssp
@@ -29,7 +29,8 @@ PROGS+= h_memset
# now on amd64 when it trips the stack bounds specified in t_ssp.sh . This
# probably needs to be fixed as it's currently hardcoded.
.if ${COMPILER_TYPE} == "clang" && !defined(_SKIP_BUILD) && \
- (!defined(_RECURSING_PROGS) || ${PROG} == "h_raw")
+ (!defined(_RECURSING_PROGS) || ${PROG} == "h_raw") && \
+ defined(MK_CLANG) && ${MK_CLANG} == "yes"
.include "${SRCTOP}/lib/libclang_rt/compiler-rt-vars.mk"
_libclang_rt_ubsan= ${SYSROOT}${SANITIZER_LIBDIR}/libclang_rt.ubsan_standalone-${CRTARCH}.a
.if exists(${_libclang_rt_ubsan})
diff --git a/lib/libc/tests/stdio/Makefile b/lib/libc/tests/stdio/Makefile
index f7383e5b3ef4..6dca927c4fb7 100644
--- a/lib/libc/tests/stdio/Makefile
+++ b/lib/libc/tests/stdio/Makefile
@@ -1,8 +1,8 @@
-
.include <bsd.own.mk>
ATF_TESTS_C+= eintr_test
ATF_TESTS_C+= fdopen_test
+ATF_TESTS_C+= flushlbuf_test
ATF_TESTS_C+= fmemopen2_test
ATF_TESTS_C+= fopen2_test
ATF_TESTS_C+= freopen_test
@@ -18,6 +18,7 @@ ATF_TESTS_C+= printfloat_test
ATF_TESTS_C+= scanfloat_test
ATF_TESTS_C+= snprintf_test
ATF_TESTS_C+= sscanf_test
+ATF_TESTS_C+= swprintf_test
ATF_TESTS_C+= swscanf_test
SRCS.fopen2_test= fopen_test.c
@@ -37,9 +38,15 @@ LIBADD.eintr_test+= md
LIBADD.printfloat_test+= m
LIBADD.scanfloat_test+= m
+# Older toolchains won't understand C23 %b, %wN, %wfN
+PROG_OVERRIDE_VARS+= NO_WFORMAT
+NO_WFORMAT.snprintf_test=
+NO_WFORMAT.sscanf_test=
+NO_WFORMAT.swprintf_test=
+NO_WFORMAT.swscanf_test=
+
.if ${COMPILER_TYPE} == "gcc"
# 90: use of assignment suppression and length modifier together in scanf format
-PROG_OVERRIDE_VARS+= NO_WFORMAT
NO_WFORMAT.scanfloat_test=
.endif
diff --git a/lib/libc/tests/stdio/fdopen_test.c b/lib/libc/tests/stdio/fdopen_test.c
index 211e16279a3c..5abaed7375b6 100644
--- a/lib/libc/tests/stdio/fdopen_test.c
+++ b/lib/libc/tests/stdio/fdopen_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
diff --git a/lib/libc/tests/stdio/flushlbuf_test.c b/lib/libc/tests/stdio/flushlbuf_test.c
new file mode 100644
index 000000000000..11d9ea4ecc6c
--- /dev/null
+++ b/lib/libc/tests/stdio/flushlbuf_test.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2023 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+#define BUFSIZE 16
+
+static const char seq[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
+
+struct stream {
+ char buf[BUFSIZE];
+ unsigned int len;
+ unsigned int pos;
+};
+
+static int writefn(void *cookie, const char *buf, int len)
+{
+ struct stream *s = cookie;
+ int written = 0;
+
+ if (len <= 0)
+ return 0;
+ while (len > 0 && s->pos < s->len) {
+ s->buf[s->pos++] = *buf++;
+ written++;
+ len--;
+ }
+ if (written > 0)
+ return written;
+ errno = EAGAIN;
+ return -1;
+}
+
+ATF_TC_WITHOUT_HEAD(flushlbuf_partial);
+ATF_TC_BODY(flushlbuf_partial, tc)
+{
+ static struct stream s;
+ static char buf[BUFSIZE + 1];
+ FILE *f;
+ unsigned int i = 0;
+ int ret = 0;
+
+ /*
+ * Create the stream and its buffer, print just enough characters
+ * to the stream to fill the buffer without triggering a flush,
+ * then check the state.
+ */
+ s.len = BUFSIZE / 2; // write will fail after this amount
+ ATF_REQUIRE((f = fwopen(&s, writefn)) != NULL);
+ ATF_REQUIRE(setvbuf(f, buf, _IOLBF, BUFSIZE) == 0);
+ while (i < BUFSIZE)
+ if ((ret = fprintf(f, "%c", seq[i++])) < 0)
+ break;
+ ATF_CHECK_EQ(BUFSIZE, i);
+ ATF_CHECK_EQ(seq[i - 1], buf[BUFSIZE - 1]);
+ ATF_CHECK_EQ(1, ret);
+ ATF_CHECK_EQ(0, s.pos);
+
+ /*
+ * At this point, the buffer is full but writefn() has not yet
+ * been called. The next fprintf() call will trigger a preemptive
+ * fflush(), and writefn() will consume s.len characters before
+ * returning EAGAIN, causing fprintf() to fail without having
+ * written anything (which is why we don't increment i here).
+ */
+ ret = fprintf(f, "%c", seq[i]);
+ ATF_CHECK_ERRNO(EAGAIN, ret < 0);
+ ATF_CHECK_EQ(s.len, s.pos);
+
+ /*
+ * We have consumed s.len characters from the buffer, so continue
+ * printing until it is full again and check that no overflow has
+ * occurred yet.
+ */
+ while (i < BUFSIZE + s.len)
+ fprintf(f, "%c", seq[i++]);
+ ATF_CHECK_EQ(BUFSIZE + s.len, i);
+ ATF_CHECK_EQ(seq[i - 1], buf[BUFSIZE - 1]);
+ ATF_CHECK_EQ(0, buf[BUFSIZE]);
+
+ /*
+ * The straw that breaks the camel's back: libc fails to recognize
+ * that the buffer is full and continues to write beyond its end.
+ */
+ fprintf(f, "%c", seq[i++]);
+ ATF_CHECK_EQ(0, buf[BUFSIZE]);
+}
+
+ATF_TC_WITHOUT_HEAD(flushlbuf_full);
+ATF_TC_BODY(flushlbuf_full, tc)
+{
+ static struct stream s;
+ static char buf[BUFSIZE];
+ FILE *f;
+ unsigned int i = 0;
+ int ret = 0;
+
+ /*
+ * Create the stream and its buffer, print just enough characters
+ * to the stream to fill the buffer without triggering a flush,
+ * then check the state.
+ */
+ s.len = 0; // any attempt to write will fail
+ ATF_REQUIRE((f = fwopen(&s, writefn)) != NULL);
+ ATF_REQUIRE(setvbuf(f, buf, _IOLBF, BUFSIZE) == 0);
+ while (i < BUFSIZE)
+ if ((ret = fprintf(f, "%c", seq[i++])) < 0)
+ break;
+ ATF_CHECK_EQ(BUFSIZE, i);
+ ATF_CHECK_EQ(seq[i - 1], buf[BUFSIZE - 1]);
+ ATF_CHECK_EQ(1, ret);
+ ATF_CHECK_EQ(0, s.pos);
+
+ /*
+ * At this point, the buffer is full but writefn() has not yet
+ * been called. The next fprintf() call will trigger a preemptive
+ * fflush(), and writefn() will immediately return EAGAIN, causing
+ * fprintf() to fail without having written anything (which is why
+ * we don't increment i here).
+ */
+ ret = fprintf(f, "%c", seq[i]);
+ ATF_CHECK_ERRNO(EAGAIN, ret < 0);
+ ATF_CHECK_EQ(s.len, s.pos);
+
+ /*
+ * Now make our stream writeable.
+ */
+ s.len = sizeof(s.buf);
+
+ /*
+ * Flush the stream again. The data we failed to write previously
+ * should still be in the buffer and will now be written to the
+ * stream.
+ */
+ ATF_CHECK_EQ(0, fflush(f));
+ ATF_CHECK_EQ(seq[0], s.buf[0]);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, flushlbuf_partial);
+ ATF_TP_ADD_TC(tp, flushlbuf_full);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/stdio/fmemopen2_test.c b/lib/libc/tests/stdio/fmemopen2_test.c
index d68150d19594..a558ff3515e9 100644
--- a/lib/libc/tests/stdio/fmemopen2_test.c
+++ b/lib/libc/tests/stdio/fmemopen2_test.c
@@ -28,7 +28,6 @@ SUCH DAMAGE.
* a FILE * retrieved using fmemopen()
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
@@ -133,9 +132,11 @@ ATF_TC_BODY(test_autoalloc, tc)
/* Open a FILE * using a wrong mode */
fp = fmemopen(NULL, 512, "r");
ATF_REQUIRE(fp == NULL);
+ ATF_REQUIRE(errno == EINVAL);
fp = fmemopen(NULL, 512, "w");
ATF_REQUIRE(fp == NULL);
+ ATF_REQUIRE(errno == EINVAL);
}
ATF_TC_WITHOUT_HEAD(test_data_length);
@@ -272,6 +273,36 @@ ATF_TC_BODY(test_size_0, tc)
ATF_REQUIRE(errno == EINVAL);
}
+/*
+ * PR281953 - ensure we cannot write in read-only only mode, and cannot read in
+ * write-only mode.
+ */
+ATF_TC_WITHOUT_HEAD(test_rdonly_wronly);
+ATF_TC_BODY(test_rdonly_wronly, tc)
+{
+ FILE *fp;
+ char buf[16];
+ char buf_orig[16] = "input data";
+ char buf_write[16] = "write";
+ size_t sz;
+
+ memcpy(buf, buf_orig, sizeof(buf));
+ fp = fmemopen(buf, sizeof(buf), "r");
+ ATF_REQUIRE(fp != NULL);
+ sz = fwrite(buf_write, 1, strlen(buf_write), fp);
+ ATF_REQUIRE(sz == 0);
+ ATF_REQUIRE(errno == EBADF);
+ ATF_REQUIRE(memcmp(buf, buf_orig, sizeof(buf)) == 0);
+ fclose(fp);
+
+ fp = fmemopen(buf_orig, sizeof(buf), "w");
+ ATF_REQUIRE(fp != NULL);
+ sz = fread(buf, sizeof(buf), 1, fp);
+ ATF_REQUIRE(sz == 0);
+ ATF_REQUIRE(errno == EBADF);
+ fclose(fp);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -281,6 +312,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, test_binary);
ATF_TP_ADD_TC(tp, test_append_binary_pos);
ATF_TP_ADD_TC(tp, test_size_0);
+ ATF_TP_ADD_TC(tp, test_rdonly_wronly);
return (atf_no_error());
}
diff --git a/lib/libc/tests/stdio/fopen_test.c b/lib/libc/tests/stdio/fopen_test.c
index fdc460716ff2..4dda5cbf0e5e 100644
--- a/lib/libc/tests/stdio/fopen_test.c
+++ b/lib/libc/tests/stdio/fopen_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
diff --git a/lib/libc/tests/stdio/freopen_test.c b/lib/libc/tests/stdio/freopen_test.c
index 7318a95df089..55fe3c580dd3 100644
--- a/lib/libc/tests/stdio/freopen_test.c
+++ b/lib/libc/tests/stdio/freopen_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <paths.h>
#include <stdbool.h>
diff --git a/lib/libc/tests/stdio/getdelim_test.c b/lib/libc/tests/stdio/getdelim_test.c
index 8cb1763d9e01..01a0ab0949fe 100644
--- a/lib/libc/tests/stdio/getdelim_test.c
+++ b/lib/libc/tests/stdio/getdelim_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libc/tests/stdio/gets_s_test.c b/lib/libc/tests/stdio/gets_s_test.c
index c6eda57c03ea..4e1a59006b60 100644
--- a/lib/libc/tests/stdio/gets_s_test.c
+++ b/lib/libc/tests/stdio/gets_s_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/lib/libc/tests/stdio/mkostemp_test.c b/lib/libc/tests/stdio/mkostemp_test.c
index 1e3f6dc03768..b31335fed43f 100644
--- a/lib/libc/tests/stdio/mkostemp_test.c
+++ b/lib/libc/tests/stdio/mkostemp_test.c
@@ -28,7 +28,6 @@
* Test program for mkostemp().
*/
-#include <sys/cdefs.h>
#include <sys/stat.h>
#include <errno.h>
diff --git a/lib/libc/tests/stdio/open_memstream2_test.c b/lib/libc/tests/stdio/open_memstream2_test.c
index 513192965c93..c9c6528832d8 100644
--- a/lib/libc/tests/stdio/open_memstream2_test.c
+++ b/lib/libc/tests/stdio/open_memstream2_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/tests/stdio/open_wmemstream_test.c b/lib/libc/tests/stdio/open_wmemstream_test.c
index cbe7e4776737..7ab882a4740a 100644
--- a/lib/libc/tests/stdio/open_wmemstream_test.c
+++ b/lib/libc/tests/stdio/open_wmemstream_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/tests/stdio/perror_test.c b/lib/libc/tests/stdio/perror_test.c
index e6d2c0c130a6..f3cb646d094e 100644
--- a/lib/libc/tests/stdio/perror_test.c
+++ b/lib/libc/tests/stdio/perror_test.c
@@ -29,7 +29,6 @@
* ISO/IEC 9899:1999.
*/
-#include <sys/cdefs.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
diff --git a/lib/libc/tests/stdio/print_positional_test.c b/lib/libc/tests/stdio/print_positional_test.c
index ba5a7b13135c..f896a30882f4 100644
--- a/lib/libc/tests/stdio/print_positional_test.c
+++ b/lib/libc/tests/stdio/print_positional_test.c
@@ -29,7 +29,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c
index 5f47979c0ff0..411dff518795 100644
--- a/lib/libc/tests/stdio/printbasic_test.c
+++ b/lib/libc/tests/stdio/printbasic_test.c
@@ -28,7 +28,6 @@
* Tests for basic and miscellaneous printf() formats.
*/
-#include <sys/cdefs.h>
#include <err.h>
#include <limits.h>
#include <locale.h>
diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c
index aeb4ed43b772..031859124163 100644
--- a/lib/libc/tests/stdio/printfloat_test.c
+++ b/lib/libc/tests/stdio/printfloat_test.c
@@ -28,7 +28,6 @@
* Test for printf() floating point formats.
*/
-#include <sys/cdefs.h>
#include <err.h>
#include <fenv.h>
#include <float.h>
diff --git a/lib/libc/tests/stdio/scanfloat_test.c b/lib/libc/tests/stdio/scanfloat_test.c
index 473565b25747..635d93d560b3 100644
--- a/lib/libc/tests/stdio/scanfloat_test.c
+++ b/lib/libc/tests/stdio/scanfloat_test.c
@@ -28,7 +28,6 @@
* Test for scanf() floating point formats.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <float.h>
#include <locale.h>
@@ -60,88 +59,88 @@ ATF_TC_BODY(normalized_numbers, tc)
buf[0] = '\0';
ATF_REQUIRE(setlocale(LC_NUMERIC, ""));
- sscanf("3.141592", "%e", &f);
+ ATF_REQUIRE_EQ(1, sscanf("3.141592", "%e", &f));
ATF_REQUIRE(eq(FLT, f, 3.141592));
- sscanf("3.141592653589793", "%lf", &d);
+ ATF_REQUIRE_EQ(1, sscanf("3.141592653589793", "%lf", &d));
ATF_REQUIRE(eq(DBL, d, 3.141592653589793));
- sscanf("1.234568e+06", "%E", &f);
+ ATF_REQUIRE_EQ(1, sscanf("1.234568e+06", "%E", &f));
ATF_REQUIRE(eq(FLT, f, 1.234568e+06));
- sscanf("-1.234568e6", "%lF", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-1.234568e6", "%lF", &d));
ATF_REQUIRE(eq(DBL, d, -1.234568e6));
- sscanf("+1.234568e-52", "%LG", &ld);
+ ATF_REQUIRE_EQ(1, sscanf("+1.234568e-52", "%LG", &ld));
ATF_REQUIRE(eq(LDBL, ld, 1.234568e-52L));
- sscanf("0.1", "%la", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0.1", "%la", &d));
ATF_REQUIRE(eq(DBL, d, 0.1));
- sscanf("00.2", "%lA", &d);
+ ATF_REQUIRE_EQ(1, sscanf("00.2", "%lA", &d));
ATF_REQUIRE(eq(DBL, d, 0.2));
- sscanf("123456", "%5le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("123456", "%5le%s", &d, buf));
ATF_REQUIRE(eq(DBL, d, 12345.));
ATF_REQUIRE(strcmp(buf, "6") == 0);
- sscanf("1.0Q", "%*5le%s", buf);
+ ATF_REQUIRE_EQ(1, sscanf("1.0Q", "%*5le%s", buf));
ATF_REQUIRE(strcmp(buf, "Q") == 0);
- sscanf("-1.23e", "%e%s", &f, buf);
+ ATF_REQUIRE_EQ(2, sscanf("-1.23e", "%e%s", &f, buf));
ATF_REQUIRE(eq(FLT, f, -1.23));
ATF_REQUIRE(strcmp(buf, "e") == 0);
- sscanf("1.25e+", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("1.25e+", "%le%s", &d, buf));
ATF_REQUIRE(eq(DBL, d, 1.25));
ATF_REQUIRE(strcmp(buf, "e+") == 0);
- sscanf("1.23E4E5", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("1.23E4E5", "%le%s", &d, buf));
ATF_REQUIRE(eq(DBL, d, 1.23e4));
ATF_REQUIRE(strcmp(buf, "E5") == 0);
- sscanf("12e6", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("12e6", "%le", &d));
ATF_REQUIRE(eq(DBL, d, 12e6));
- sscanf("1.a", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("1.a", "%le%s", &d, buf));
ATF_REQUIRE(eq(DBL, d, 1.0));
ATF_REQUIRE(strcmp(buf, "a") == 0);
- sscanf(".0p4", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf(".0p4", "%le%s", &d, buf));
ATF_REQUIRE(eq(DBL, d, 0.0));
ATF_REQUIRE(strcmp(buf, "p4") == 0);
d = 0.25;
- ATF_REQUIRE(sscanf(".", "%le", &d) == 0);
+ ATF_REQUIRE_EQ(0, sscanf(".", "%le", &d));
ATF_REQUIRE(d == 0.25);
- sscanf("0x08", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x08", "%le", &d));
ATF_REQUIRE(d == 0x8p0);
- sscanf("0x90a.bcdefP+09a", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("0x90a.bcdefP+09a", "%le%s", &d, buf));
ATF_REQUIRE(d == 0x90a.bcdefp+09);
ATF_REQUIRE(strcmp(buf, "a") == 0);
#if (LDBL_MANT_DIG > DBL_MANT_DIG) && !defined(__i386__)
- sscanf("3.14159265358979323846", "%Lg", &ld);
+ ATF_REQUIRE_EQ(1, sscanf("3.14159265358979323846", "%Lg", &ld));
ATF_REQUIRE(eq(LDBL, ld, 3.14159265358979323846L));
- sscanf(" 0X.0123456789abcdefffp-3g", "%Le%s", &ld, buf);
+ ATF_REQUIRE_EQ(2, sscanf(" 0X.0123456789abcdefffp-3g", "%Le%s", &ld, buf));
ATF_REQUIRE(ld == 0x0.0123456789abcdefffp-3L);
ATF_REQUIRE(strcmp(buf, "g") == 0);
#endif
- sscanf("0xg", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("0xg", "%le%s", &d, buf));
ATF_REQUIRE(d == 0.0);
ATF_REQUIRE(strcmp(buf, "xg") == 0);
ATF_REQUIRE(setlocale(LC_NUMERIC, "ru_RU.ISO8859-5")); /* decimalpoint==, */
- sscanf("1.23", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("1.23", "%le%s", &d, buf));
ATF_REQUIRE(d == 1.0);
ATF_REQUIRE(strcmp(buf, ".23") == 0);
- sscanf("1,23", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1,23", "%le", &d));
ATF_REQUIRE(d == 1.23);
ATF_REQUIRE(setlocale(LC_NUMERIC, ""));
@@ -157,40 +156,40 @@ ATF_TC_BODY(infinities_and_nans, tc)
ATF_REQUIRE(setlocale(LC_NUMERIC, "C"));
- sscanf("-Inf", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-Inf", "%le", &d));
ATF_REQUIRE(d < 0.0 && isinf(d));
- sscanf("iNfInItY and beyond", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("iNfInItY and beyond", "%le%s", &d, buf));
ATF_REQUIRE(d > 0.0 && isinf(d));
ATF_REQUIRE(strcmp(buf, " and beyond"));
- sscanf("NaN", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("NaN", "%le", &d));
ATF_REQUIRE(isnan(d));
- sscanf("NAN(123Y", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("NAN(123Y", "%le%s", &d, buf));
ATF_REQUIRE(isnan(d));
ATF_REQUIRE(strcmp(buf, "(123Y") == 0);
- sscanf("nan(f00f)plugh", "%le%s", &d, buf);
+ ATF_REQUIRE_EQ(2, sscanf("nan(f00f)plugh", "%le%s", &d, buf));
ATF_REQUIRE(isnan(d));
ATF_REQUIRE(strcmp(buf, "plugh") == 0);
- sscanf("-nan", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-nan", "%le", &d));
ATF_REQUIRE(isnan(d));
/* Only quiet NaNs should be returned. */
- sscanf("NaN", "%e", &f);
- sscanf("nan", "%le", &d);
- sscanf("nan", "%Le", &ld);
- feclearexcept(FE_ALL_EXCEPT);
+ ATF_REQUIRE_EQ(1, sscanf("NaN", "%e", &f));
+ ATF_REQUIRE_EQ(1, sscanf("nan", "%le", &d));
+ ATF_REQUIRE_EQ(1, sscanf("nan", "%Le", &ld));
+ ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
ATF_REQUIRE(f != f);
ATF_REQUIRE(d != d);
ATF_REQUIRE(ld != ld);
ATF_REQUIRE(fetestexcept(FE_INVALID) == 0);
- sscanf("nan(1234)", "%e", &f);
- sscanf("nan(1234)", "%le", &d);
- sscanf("nan(1234)", "%Le", &ld);
- feclearexcept(FE_ALL_EXCEPT);
+ ATF_REQUIRE_EQ(1, sscanf("nan(1234)", "%e", &f));
+ ATF_REQUIRE_EQ(1, sscanf("nan(1234)", "%le", &d));
+ ATF_REQUIRE_EQ(1, sscanf("nan(1234)", "%Le", &ld));
+ ATF_REQUIRE_EQ(0, feclearexcept(FE_ALL_EXCEPT));
ATF_REQUIRE(f != f);
ATF_REQUIRE(d != d);
ATF_REQUIRE(ld != ld);
@@ -206,74 +205,74 @@ ATF_TC_BODY(rounding_tests, tc)
ATF_REQUIRE(setlocale(LC_NUMERIC, "C"));
- fesetround(FE_DOWNWARD);
+ ATF_REQUIRE_EQ(0, fesetround(FE_DOWNWARD));
- sscanf("1.999999999999999999999999999999999", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.999999999999999999999999999999999", "%le", &d));
ATF_REQUIRE(d < 2.0);
- sscanf("0x1.ffffffffffffffp0", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.ffffffffffffffp0", "%le", &d));
ATF_REQUIRE(d < 2.0);
- sscanf("1.999999999999999999999999999999999", "%Le", &ld);
+ ATF_REQUIRE_EQ(1, sscanf("1.999999999999999999999999999999999", "%Le", &ld));
ATF_REQUIRE(ld < 2.0);
- sscanf("1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc59p0);
- sscanf("-1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == -0x1.0ea3f4af0dc5ap0);
- sscanf("1.0571892669084010", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084010", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc5ap0);
- sscanf("0x1.23p-5000", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.23p-5000", "%le", &d));
ATF_REQUIRE(d == 0.0);
- sscanf("0x1.2345678p-1050", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.2345678p-1050", "%le", &d));
ATF_REQUIRE(d == 0x1.234567p-1050);
- fesetround(FE_UPWARD);
+ ATF_REQUIRE_EQ(0, fesetround(FE_UPWARD));
- sscanf("1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc5ap0);
- sscanf("-1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == -0x1.0ea3f4af0dc59p0);
- sscanf("1.0571892669084010", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084010", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc5bp0);
- sscanf("0x1.23p-5000", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.23p-5000", "%le", &d));
ATF_REQUIRE(d == 0x1p-1074);
- sscanf("0x1.2345678p-1050", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.2345678p-1050", "%le", &d));
ATF_REQUIRE(d == 0x1.234568p-1050);
- fesetround(FE_TOWARDZERO);
+ ATF_REQUIRE_EQ(0, fesetround(FE_TOWARDZERO));
- sscanf("1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc59p0);
- sscanf("-1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == -0x1.0ea3f4af0dc59p0);
- sscanf("1.0571892669084010", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084010", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc5ap0);
- sscanf("0x1.23p-5000", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.23p-5000", "%le", &d));
ATF_REQUIRE(d == 0.0);
- sscanf("0x1.2345678p-1050", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.2345678p-1050", "%le", &d));
ATF_REQUIRE(d == 0x1.234567p-1050);
- fesetround(FE_TONEAREST);
+ ATF_REQUIRE_EQ(0, fesetround(FE_TONEAREST));
/* 1.0571892669084007 is slightly closer to 0x1.0ea3f4af0dc59p0 */
- sscanf("1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc59p0);
- sscanf("-1.0571892669084007", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("-1.0571892669084007", "%le", &d));
ATF_REQUIRE(d == -0x1.0ea3f4af0dc59p0);
- sscanf("1.0571892669084010", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("1.0571892669084010", "%le", &d));
ATF_REQUIRE(d == 0x1.0ea3f4af0dc5bp0);
/* strtod() should round small numbers to 0. */
- sscanf("0x1.23p-5000", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.23p-5000", "%le", &d));
ATF_REQUIRE(d == 0.0);
/* Extra digits in a denormal shouldn't break anything. */
- sscanf("0x1.2345678p-1050", "%le", &d);
+ ATF_REQUIRE_EQ(1, sscanf("0x1.2345678p-1050", "%le", &d));
ATF_REQUIRE(d == 0x1.234568p-1050);
}
@@ -288,16 +287,16 @@ ATF_TC_BODY(strtod, tc)
ATF_REQUIRE(strcmp("xy", endp) == 0);
/* This used to cause an infinite loop and round the wrong way. */
- fesetround(FE_DOWNWARD);
+ ATF_REQUIRE_EQ(0, fesetround(FE_DOWNWARD));
ATF_REQUIRE(strtof("3.5e38", &endp) == FLT_MAX);
ATF_REQUIRE(strtod("2e308", &endp) == DBL_MAX);
- fesetround(FE_UPWARD);
+ ATF_REQUIRE_EQ(0, fesetround(FE_UPWARD));
ATF_REQUIRE(strtof("3.5e38", &endp) == INFINITY);
ATF_REQUIRE(strtod("2e308", &endp) == INFINITY);
- fesetround(FE_TOWARDZERO);
+ ATF_REQUIRE_EQ(0, fesetround(FE_TOWARDZERO));
ATF_REQUIRE(strtof("3.5e38", &endp) == FLT_MAX);
ATF_REQUIRE(strtod("2e308", &endp) == DBL_MAX);
- fesetround(FE_TONEAREST);
+ ATF_REQUIRE_EQ(0, fesetround(FE_TONEAREST));
ATF_REQUIRE(strtof("3.5e38", &endp) == INFINITY);
ATF_REQUIRE(strtod("2e308", &endp) == INFINITY);
}
diff --git a/lib/libc/tests/stdio/snprintf_test.c b/lib/libc/tests/stdio/snprintf_test.c
index 0c335bc1a512..29b908b65120 100644
--- a/lib/libc/tests/stdio/snprintf_test.c
+++ b/lib/libc/tests/stdio/snprintf_test.c
@@ -12,18 +12,19 @@
#include <atf-c.h>
-#define SNPRINTF_TEST(output, format, ...) \
+#ifndef nitems
+#define nitems(a) (sizeof(a) / sizeof(a[0]))
+#endif
+
+#define SNPRINTF_TEST(output, format, ...) \
do { \
char buf[256]; \
- assert(output == NULL || strlen(output) < sizeof(buf)); \
- int ret = snprintf(buf, sizeof(buf), format, __VA_ARGS__); \
- if (output == NULL) { \
- ATF_CHECK_EQ(-1, ret); \
- } else { \
- ATF_CHECK_EQ(strlen(output), ret); \
- if (ret > 0) { \
- ATF_CHECK_STREQ(output, buf); \
- } \
+ assert(strlen(output) < nitems(buf)); \
+ int ret = snprintf(buf, nitems(buf), format, \
+ __VA_ARGS__); \
+ ATF_CHECK_EQ(strlen(output), ret); \
+ if (ret > 0) { \
+ ATF_CHECK_EQ(0, strcmp(output, buf)); \
} \
} while (0)
@@ -126,6 +127,70 @@ ATF_TC_BODY(snprintf_X, tc)
SNPRINTF_TEST("0X007FFFFFFF", "%#012X", INT_MAX);
}
+ATF_TC_WITHOUT_HEAD(snprintf_wN);
+ATF_TC_BODY(snprintf_wN, tc)
+{
+ SNPRINTF_TEST("0", "%w8d", (int8_t)0);
+ SNPRINTF_TEST("-128", "%w8d", (int8_t)SCHAR_MIN);
+ SNPRINTF_TEST("127", "%w8d", (int8_t)SCHAR_MAX);
+ SNPRINTF_TEST("0", "%w8u", (uint8_t)0);
+ SNPRINTF_TEST("255", "%w8u", (uint8_t)UCHAR_MAX);
+
+ SNPRINTF_TEST("0", "%w16d", (int16_t)0);
+ SNPRINTF_TEST("-32768", "%w16d", (int16_t)SHRT_MIN);
+ SNPRINTF_TEST("32767", "%w16d", (int16_t)SHRT_MAX);
+ SNPRINTF_TEST("0", "%w16u", (uint16_t)0);
+ SNPRINTF_TEST("65535", "%w16u", (uint16_t)USHRT_MAX);
+
+ SNPRINTF_TEST("0", "%w32d", (int32_t)0);
+ SNPRINTF_TEST("-2147483648", "%w32d", (int32_t)INT_MIN);
+ SNPRINTF_TEST("2147483647", "%w32d", (int32_t)INT_MAX);
+ SNPRINTF_TEST("0", "%w32u", (uint32_t)0);
+ SNPRINTF_TEST("4294967295", "%w32u", (uint32_t)UINT_MAX);
+
+ SNPRINTF_TEST("0", "%w64d", (int64_t)0);
+ SNPRINTF_TEST("-9223372036854775808", "%w64d", (int64_t)LLONG_MIN);
+ SNPRINTF_TEST("9223372036854775807", "%w64d", (int64_t)LLONG_MAX);
+ SNPRINTF_TEST("0", "%w64u", (uint64_t)0);
+ SNPRINTF_TEST("18446744073709551615", "%w64u", (uint64_t)ULLONG_MAX);
+
+ SNPRINTF_TEST("wd", "%wd", 0);
+ SNPRINTF_TEST("w1d", "%w1d", 0);
+ SNPRINTF_TEST("w128d", "%w128d", 0);
+}
+
+ATF_TC_WITHOUT_HEAD(snprintf_wfN);
+ATF_TC_BODY(snprintf_wfN, tc)
+{
+ SNPRINTF_TEST("0", "%wf8d", (int_fast8_t)0);
+ SNPRINTF_TEST("-2147483648", "%wf8d", (int_fast8_t)INT_MIN);
+ SNPRINTF_TEST("2147483647", "%wf8d", (int_fast8_t)INT_MAX);
+ SNPRINTF_TEST("0", "%wf8u", (uint8_t)0);
+ SNPRINTF_TEST("4294967295", "%wf8u", (uint_fast8_t)UINT_MAX);
+
+ SNPRINTF_TEST("0", "%wf16d", (int_fast16_t)0);
+ SNPRINTF_TEST("-2147483648", "%wf16d", (int_fast16_t)INT_MIN);
+ SNPRINTF_TEST("2147483647", "%wf16d", (int_fast16_t)INT_MAX);
+ SNPRINTF_TEST("0", "%wf16u", (uint16_t)0);
+ SNPRINTF_TEST("4294967295", "%wf16u", (uint_fast16_t)UINT_MAX);
+
+ SNPRINTF_TEST("0", "%wf32d", (int_fast32_t)0);
+ SNPRINTF_TEST("-2147483648", "%wf32d", (int_fast32_t)INT_MIN);
+ SNPRINTF_TEST("2147483647", "%wf32d", (int_fast32_t)INT_MAX);
+ SNPRINTF_TEST("0", "%wf32u", (uint32_t)0);
+ SNPRINTF_TEST("4294967295", "%wf32u", (uint_fast32_t)UINT_MAX);
+
+ SNPRINTF_TEST("0", "%wf64d", (int_fast64_t)0);
+ SNPRINTF_TEST("-9223372036854775808", "%wf64d", (int_fast64_t)LLONG_MIN);
+ SNPRINTF_TEST("9223372036854775807", "%wf64d", (int_fast64_t)LLONG_MAX);
+ SNPRINTF_TEST("0", "%wf64u", (uint64_t)0);
+ SNPRINTF_TEST("18446744073709551615", "%wf64u", (uint_fast64_t)ULLONG_MAX);
+
+ SNPRINTF_TEST("wfd", "%wfd", 0);
+ SNPRINTF_TEST("wf1d", "%wf1d", 0);
+ SNPRINTF_TEST("wf128d", "%wf128d", 0);
+}
+
ATF_TP_ADD_TCS(tp)
{
setlocale(LC_NUMERIC, "en_US.UTF-8");
@@ -134,5 +199,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, snprintf_d);
ATF_TP_ADD_TC(tp, snprintf_x);
ATF_TP_ADD_TC(tp, snprintf_X);
+ ATF_TP_ADD_TC(tp, snprintf_wN);
+ ATF_TP_ADD_TC(tp, snprintf_wfN);
return (atf_no_error());
}
diff --git a/lib/libc/tests/stdio/sscanf_test.c b/lib/libc/tests/stdio/sscanf_test.c
index 462b4a6586da..e916873d38c3 100644
--- a/lib/libc/tests/stdio/sscanf_test.c
+++ b/lib/libc/tests/stdio/sscanf_test.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <limits.h>
#include <locale.h>
#include <stdint.h>
#include <stdio.h>
@@ -237,6 +238,68 @@ ATF_TC_BODY(sscanf_i, tc)
}
}
+ATF_TC_WITHOUT_HEAD(sscanf_wN);
+ATF_TC_BODY(sscanf_wN, tc)
+{
+ const char x00[] = "0x00";
+ const char x7f[] = "0x7fffffffffffffff";
+ const char xff[] = "0xffffffffffffffff";
+
+#define SSCANF_WN_TEST(N, imin, umax) \
+ do { \
+ int##N##_t i; \
+ uint##N##_t u; \
+ ATF_CHECK_EQ(1, sscanf(x00, "%w" #N "i", &i)); \
+ ATF_CHECK_EQ(0, i); \
+ ATF_CHECK_EQ(1, sscanf(x7f, "%w" #N "i", &i)); \
+ ATF_CHECK_EQ(imin, i); \
+ ATF_CHECK_EQ(1, sscanf(x00, "%w" #N "x", &u)); \
+ ATF_CHECK_EQ(0, u); \
+ ATF_CHECK_EQ(1, sscanf(xff, "%w" #N "x", &u)); \
+ ATF_CHECK_EQ(umax, u); \
+ } while (0)
+ SSCANF_WN_TEST(8, -1, UCHAR_MAX);
+ SSCANF_WN_TEST(16, -1, USHRT_MAX);
+ SSCANF_WN_TEST(32, -1, UINT_MAX);
+ SSCANF_WN_TEST(64, LLONG_MAX, ULLONG_MAX);
+#undef SSCANF_WN_TEST
+
+ ATF_CHECK_EQ(0, sscanf(x00, "%wi", (int *)NULL));
+ ATF_CHECK_EQ(0, sscanf(x00, "%w1i", (int *)NULL));
+ ATF_CHECK_EQ(0, sscanf(x00, "%w128i", (int *)NULL));
+}
+
+ATF_TC_WITHOUT_HEAD(sscanf_wfN);
+ATF_TC_BODY(sscanf_wfN, tc)
+{
+ const char x00[] = "0x00";
+ const char x7f[] = "0x7fffffffffffffff";
+ const char xff[] = "0xffffffffffffffff";
+
+#define SSCANF_WFN_TEST(N, imin, umax) \
+ do { \
+ int_fast##N##_t i; \
+ uint_fast##N##_t u; \
+ ATF_CHECK_EQ(1, sscanf(x00, "%wf" #N "i", &i)); \
+ ATF_CHECK_EQ(0, i); \
+ ATF_CHECK_EQ(1, sscanf(x7f, "%wf" #N "i", &i)); \
+ ATF_CHECK_EQ(imin, i); \
+ ATF_CHECK_EQ(1, sscanf(x00, "%wf" #N "x", &u)); \
+ ATF_CHECK_EQ(0, u); \
+ ATF_CHECK_EQ(1, sscanf(xff, "%wf" #N "x", &u)); \
+ ATF_CHECK_EQ(umax, u); \
+ } while (0)
+ SSCANF_WFN_TEST(8, -1, UINT_MAX);
+ SSCANF_WFN_TEST(16, -1, UINT_MAX);
+ SSCANF_WFN_TEST(32, -1, UINT_MAX);
+ SSCANF_WFN_TEST(64, LLONG_MAX, ULLONG_MAX);
+#undef SSCANF_WFN_TEST
+
+ ATF_CHECK_EQ(0, sscanf(x00, "%wfi", (int *)NULL));
+ ATF_CHECK_EQ(0, sscanf(x00, "%wf1i", (int *)NULL));
+ ATF_CHECK_EQ(0, sscanf(x00, "%wf128i", (int *)NULL));
+}
+
/*
* Test termination cases: non-numeric character, fixed width, EOF
*/
@@ -261,6 +324,8 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, sscanf_d);
ATF_TP_ADD_TC(tp, sscanf_x);
ATF_TP_ADD_TC(tp, sscanf_i);
+ ATF_TP_ADD_TC(tp, sscanf_wN);
+ ATF_TP_ADD_TC(tp, sscanf_wfN);
ATF_TP_ADD_TC(tp, sscanf_termination);
return (atf_no_error());
}
diff --git a/lib/libc/tests/stdio/swprintf_test.c b/lib/libc/tests/stdio/swprintf_test.c
new file mode 100644
index 000000000000..f00ecc7f1c1d
--- /dev/null
+++ b/lib/libc/tests/stdio/swprintf_test.c
@@ -0,0 +1,206 @@
+/*-
+ * Copyright (c) 2023 Dag-Erling Smørgrav
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <assert.h>
+#include <limits.h>
+#include <locale.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.h>
+
+#include <atf-c.h>
+
+#ifndef nitems
+#define nitems(a) (sizeof(a) / sizeof(a[0]))
+#endif
+
+#define SWPRINTF_TEST(output, format, ...) \
+ do { \
+ wchar_t buf[256]; \
+ assert(wcslen(L##output) < nitems(buf)); \
+ int ret = swprintf(buf, nitems(buf), L##format, \
+ __VA_ARGS__); \
+ ATF_CHECK_EQ(wcslen(L##output), ret); \
+ if (ret > 0) { \
+ ATF_CHECK_EQ(0, wcscmp(L##output, buf)); \
+ } \
+ } while (0)
+
+ATF_TC_WITHOUT_HEAD(swprintf_b);
+ATF_TC_BODY(swprintf_b, tc)
+{
+ SWPRINTF_TEST("0", "%b", 0);
+ SWPRINTF_TEST(" 0", "%12b", 0);
+ SWPRINTF_TEST("000000000000", "%012b", 0);
+ SWPRINTF_TEST("1", "%b", 1);
+ SWPRINTF_TEST(" 1", "%12b", 1);
+ SWPRINTF_TEST("000000000001", "%012b", 1);
+ SWPRINTF_TEST("1111111111111111111111111111111", "%b", INT_MAX);
+ SWPRINTF_TEST("0", "%#b", 0);
+ SWPRINTF_TEST(" 0", "%#12b", 0);
+ SWPRINTF_TEST("000000000000", "%#012b", 0);
+ SWPRINTF_TEST("0b1", "%#b", 1);
+ SWPRINTF_TEST(" 0b1", "%#12b", 1);
+ SWPRINTF_TEST("0b0000000001", "%#012b", 1);
+ SWPRINTF_TEST("0b1111111111111111111111111111111", "%#b", INT_MAX);
+}
+
+ATF_TC_WITHOUT_HEAD(swprintf_B);
+ATF_TC_BODY(swprintf_B, tc)
+{
+ SWPRINTF_TEST("0", "%B", 0);
+ SWPRINTF_TEST(" 0", "%12B", 0);
+ SWPRINTF_TEST("000000000000", "%012B", 0);
+ SWPRINTF_TEST("1", "%B", 1);
+ SWPRINTF_TEST(" 1", "%12B", 1);
+ SWPRINTF_TEST("000000000001", "%012B", 1);
+ SWPRINTF_TEST("1111111111111111111111111111111", "%B", INT_MAX);
+ SWPRINTF_TEST("0", "%#B", 0);
+ SWPRINTF_TEST(" 0", "%#12B", 0);
+ SWPRINTF_TEST("000000000000", "%#012B", 0);
+ SWPRINTF_TEST("0B1", "%#B", 1);
+ SWPRINTF_TEST(" 0B1", "%#12B", 1);
+ SWPRINTF_TEST("0B0000000001", "%#012B", 1);
+ SWPRINTF_TEST("0B1111111111111111111111111111111", "%#B", INT_MAX);
+}
+
+ATF_TC_WITHOUT_HEAD(swprintf_d);
+ATF_TC_BODY(swprintf_d, tc)
+{
+ SWPRINTF_TEST("0", "%d", 0);
+ SWPRINTF_TEST(" 0", "%12d", 0);
+ SWPRINTF_TEST("000000000000", "%012d", 0);
+ SWPRINTF_TEST("1", "%d", 1);
+ SWPRINTF_TEST(" 1", "%12d", 1);
+ SWPRINTF_TEST("000000000001", "%012d", 1);
+ SWPRINTF_TEST("2147483647", "%d", INT_MAX);
+ SWPRINTF_TEST(" 2147483647", "%12d", INT_MAX);
+ SWPRINTF_TEST("002147483647", "%012d", INT_MAX);
+ SWPRINTF_TEST("2,147,483,647", "%'d", INT_MAX);
+}
+
+ATF_TC_WITHOUT_HEAD(swprintf_x);
+ATF_TC_BODY(swprintf_x, tc)
+{
+ SWPRINTF_TEST("0", "%x", 0);
+ SWPRINTF_TEST(" 0", "%12x", 0);
+ SWPRINTF_TEST("000000000000", "%012x", 0);
+ SWPRINTF_TEST("1", "%x", 1);
+ SWPRINTF_TEST(" 1", "%12x", 1);
+ SWPRINTF_TEST("000000000001", "%012x", 1);
+ SWPRINTF_TEST("7fffffff", "%x", INT_MAX);
+ SWPRINTF_TEST(" 7fffffff", "%12x", INT_MAX);
+ SWPRINTF_TEST("00007fffffff", "%012x", INT_MAX);
+ SWPRINTF_TEST("0", "%#x", 0);
+ SWPRINTF_TEST(" 0", "%#12x", 0);
+ SWPRINTF_TEST("000000000000", "%#012x", 0);
+ SWPRINTF_TEST("0x1", "%#x", 1);
+ SWPRINTF_TEST(" 0x1", "%#12x", 1);
+ SWPRINTF_TEST("0x0000000001", "%#012x", 1);
+ SWPRINTF_TEST("0x7fffffff", "%#x", INT_MAX);
+ SWPRINTF_TEST(" 0x7fffffff", "%#12x", INT_MAX);
+ SWPRINTF_TEST("0x007fffffff", "%#012x", INT_MAX);
+}
+
+ATF_TC_WITHOUT_HEAD(swprintf_X);
+ATF_TC_BODY(swprintf_X, tc)
+{
+ SWPRINTF_TEST("0", "%X", 0);
+ SWPRINTF_TEST(" 0", "%12X", 0);
+ SWPRINTF_TEST("000000000000", "%012X", 0);
+ SWPRINTF_TEST("1", "%X", 1);
+ SWPRINTF_TEST(" 1", "%12X", 1);
+ SWPRINTF_TEST("000000000001", "%012X", 1);
+ SWPRINTF_TEST("7FFFFFFF", "%X", INT_MAX);
+ SWPRINTF_TEST(" 7FFFFFFF", "%12X", INT_MAX);
+ SWPRINTF_TEST("00007FFFFFFF", "%012X", INT_MAX);
+ SWPRINTF_TEST("0", "%#X", 0);
+ SWPRINTF_TEST(" 0", "%#12X", 0);
+ SWPRINTF_TEST("000000000000", "%#012X", 0);
+ SWPRINTF_TEST("0X1", "%#X", 1);
+ SWPRINTF_TEST(" 0X1", "%#12X", 1);
+ SWPRINTF_TEST("0X0000000001", "%#012X", 1);
+ SWPRINTF_TEST("0X7FFFFFFF", "%#X", INT_MAX);
+ SWPRINTF_TEST(" 0X7FFFFFFF", "%#12X", INT_MAX);
+ SWPRINTF_TEST("0X007FFFFFFF", "%#012X", INT_MAX);
+}
+
+ATF_TC_WITHOUT_HEAD(swprintf_wN);
+ATF_TC_BODY(swprintf_wN, tc)
+{
+ SWPRINTF_TEST("0", "%w8d", (int8_t)0);
+ SWPRINTF_TEST("-128", "%w8d", (int8_t)SCHAR_MIN);
+ SWPRINTF_TEST("127", "%w8d", (int8_t)SCHAR_MAX);
+ SWPRINTF_TEST("0", "%w8u", (uint8_t)0);
+ SWPRINTF_TEST("255", "%w8u", (uint8_t)UCHAR_MAX);
+
+ SWPRINTF_TEST("0", "%w16d", (int16_t)0);
+ SWPRINTF_TEST("-32768", "%w16d", (int16_t)SHRT_MIN);
+ SWPRINTF_TEST("32767", "%w16d", (int16_t)SHRT_MAX);
+ SWPRINTF_TEST("0", "%w16u", (uint16_t)0);
+ SWPRINTF_TEST("65535", "%w16u", (uint16_t)USHRT_MAX);
+
+ SWPRINTF_TEST("0", "%w32d", (int32_t)0);
+ SWPRINTF_TEST("-2147483648", "%w32d", (int32_t)INT_MIN);
+ SWPRINTF_TEST("2147483647", "%w32d", (int32_t)INT_MAX);
+ SWPRINTF_TEST("0", "%w32u", (uint32_t)0);
+ SWPRINTF_TEST("4294967295", "%w32u", (uint32_t)UINT_MAX);
+
+ SWPRINTF_TEST("0", "%w64d", (int64_t)0);
+ SWPRINTF_TEST("-9223372036854775808", "%w64d", (int64_t)LLONG_MIN);
+ SWPRINTF_TEST("9223372036854775807", "%w64d", (int64_t)LLONG_MAX);
+ SWPRINTF_TEST("0", "%w64u", (uint64_t)0);
+ SWPRINTF_TEST("18446744073709551615", "%w64u", (uint64_t)ULLONG_MAX);
+
+ SWPRINTF_TEST("wd", "%wd", 0);
+ SWPRINTF_TEST("w1d", "%w1d", 0);
+ SWPRINTF_TEST("w128d", "%w128d", 0);
+}
+
+ATF_TC_WITHOUT_HEAD(swprintf_wfN);
+ATF_TC_BODY(swprintf_wfN, tc)
+{
+ SWPRINTF_TEST("0", "%wf8d", (int_fast8_t)0);
+ SWPRINTF_TEST("-2147483648", "%wf8d", (int_fast8_t)INT_MIN);
+ SWPRINTF_TEST("2147483647", "%wf8d", (int_fast8_t)INT_MAX);
+ SWPRINTF_TEST("0", "%wf8u", (uint8_t)0);
+ SWPRINTF_TEST("4294967295", "%wf8u", (uint_fast8_t)UINT_MAX);
+
+ SWPRINTF_TEST("0", "%wf16d", (int_fast16_t)0);
+ SWPRINTF_TEST("-2147483648", "%wf16d", (int_fast16_t)INT_MIN);
+ SWPRINTF_TEST("2147483647", "%wf16d", (int_fast16_t)INT_MAX);
+ SWPRINTF_TEST("0", "%wf16u", (uint16_t)0);
+ SWPRINTF_TEST("4294967295", "%wf16u", (uint_fast16_t)UINT_MAX);
+
+ SWPRINTF_TEST("0", "%wf32d", (int_fast32_t)0);
+ SWPRINTF_TEST("-2147483648", "%wf32d", (int_fast32_t)INT_MIN);
+ SWPRINTF_TEST("2147483647", "%wf32d", (int_fast32_t)INT_MAX);
+ SWPRINTF_TEST("0", "%wf32u", (uint32_t)0);
+ SWPRINTF_TEST("4294967295", "%wf32u", (uint_fast32_t)UINT_MAX);
+
+ SWPRINTF_TEST("0", "%wf64d", (int_fast64_t)0);
+ SWPRINTF_TEST("-9223372036854775808", "%wf64d", (int_fast64_t)LLONG_MIN);
+ SWPRINTF_TEST("9223372036854775807", "%wf64d", (int_fast64_t)LLONG_MAX);
+ SWPRINTF_TEST("0", "%wf64u", (uint64_t)0);
+ SWPRINTF_TEST("18446744073709551615", "%wf64u", (uint_fast64_t)ULLONG_MAX);
+
+ SWPRINTF_TEST("wfd", "%wfd", 0);
+ SWPRINTF_TEST("wf1d", "%wf1d", 0);
+ SWPRINTF_TEST("wf128d", "%wf128d", 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ setlocale(LC_NUMERIC, "en_US.UTF-8");
+ ATF_TP_ADD_TC(tp, swprintf_b);
+ ATF_TP_ADD_TC(tp, swprintf_B);
+ ATF_TP_ADD_TC(tp, swprintf_d);
+ ATF_TP_ADD_TC(tp, swprintf_x);
+ ATF_TP_ADD_TC(tp, swprintf_X);
+ ATF_TP_ADD_TC(tp, swprintf_wN);
+ ATF_TP_ADD_TC(tp, swprintf_wfN);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/stdio/swscanf_test.c b/lib/libc/tests/stdio/swscanf_test.c
index 10eaf786e5fa..f7ad30b963a7 100644
--- a/lib/libc/tests/stdio/swscanf_test.c
+++ b/lib/libc/tests/stdio/swscanf_test.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <limits.h>
#include <locale.h>
#include <stdint.h>
#include <stdio.h>
@@ -11,6 +12,8 @@
#include <atf-c.h>
+#define L(s) L ## s
+
static const struct swscanf_test_case {
wchar_t input[8];
struct {
@@ -150,7 +153,7 @@ static const struct swscanf_test_case {
#define SWSCANF_TEST(string, format, expret, expval, explen) \
do { \
int ret = 0, val = 0, len = 0; \
- ret = swscanf(string, format "%n", &val, &len); \
+ ret = swscanf(string, format L"%n", &val, &len); \
ATF_CHECK_EQ(expret, ret); \
if (expret && ret) { \
ATF_CHECK_EQ(expval, val); \
@@ -238,6 +241,68 @@ ATF_TC_BODY(swscanf_i, tc)
}
}
+ATF_TC_WITHOUT_HEAD(swscanf_wN);
+ATF_TC_BODY(swscanf_wN, tc)
+{
+ const wchar_t x00[] = L"0x00";
+ const wchar_t x7f[] = L"0x7fffffffffffffff";
+ const wchar_t xff[] = L"0xffffffffffffffff";
+
+#define SWSCANF_WN_TEST(N, imin, umax) \
+ do { \
+ int##N##_t i; \
+ uint##N##_t u; \
+ ATF_CHECK_EQ(1, swscanf(x00, L"%w" L(#N) L"i", &i)); \
+ ATF_CHECK_EQ(0, i); \
+ ATF_CHECK_EQ(1, swscanf(x7f, L"%w" L(#N) L"i", &i)); \
+ ATF_CHECK_EQ(imin, i); \
+ ATF_CHECK_EQ(1, swscanf(x00, L"%w" L(#N) L"x", &u)); \
+ ATF_CHECK_EQ(0, u); \
+ ATF_CHECK_EQ(1, swscanf(xff, L"%w" L(#N) L"x", &u)); \
+ ATF_CHECK_EQ(umax, u); \
+ } while (0)
+ SWSCANF_WN_TEST(8, -1, UCHAR_MAX);
+ SWSCANF_WN_TEST(16, -1, USHRT_MAX);
+ SWSCANF_WN_TEST(32, -1, UINT_MAX);
+ SWSCANF_WN_TEST(64, LLONG_MAX, ULLONG_MAX);
+#undef SWSCANF_WN_TEST
+
+ ATF_CHECK_EQ(0, swscanf(x00, L"%wi", (int *)NULL));
+ ATF_CHECK_EQ(0, swscanf(x00, L"%w1i", (int *)NULL));
+ ATF_CHECK_EQ(0, swscanf(x00, L"%w128i", (int *)NULL));
+}
+
+ATF_TC_WITHOUT_HEAD(swscanf_wfN);
+ATF_TC_BODY(swscanf_wfN, tc)
+{
+ const wchar_t x00[] = L"0x00";
+ const wchar_t x7f[] = L"0x7fffffffffffffff";
+ const wchar_t xff[] = L"0xffffffffffffffff";
+
+#define SWSCANF_WFN_TEST(N, imin, umax) \
+ do { \
+ int_fast##N##_t i; \
+ uint_fast##N##_t u; \
+ ATF_CHECK_EQ(1, swscanf(x00, L"%wf" L(#N) L"i", &i)); \
+ ATF_CHECK_EQ(0, i); \
+ ATF_CHECK_EQ(1, swscanf(x7f, L"%wf" L(#N) L"i", &i)); \
+ ATF_CHECK_EQ(imin, i); \
+ ATF_CHECK_EQ(1, swscanf(x00, L"%wf" L(#N) L"x", &u)); \
+ ATF_CHECK_EQ(0, u); \
+ ATF_CHECK_EQ(1, swscanf(xff, L"%wf" L(#N) L"x", &u)); \
+ ATF_CHECK_EQ(umax, u); \
+ } while (0)
+ SWSCANF_WFN_TEST(8, -1, UINT_MAX);
+ SWSCANF_WFN_TEST(16, -1, UINT_MAX);
+ SWSCANF_WFN_TEST(32, -1, UINT_MAX);
+ SWSCANF_WFN_TEST(64, LLONG_MAX, ULLONG_MAX);
+#undef SWSCANF_WFN_TEST
+
+ ATF_CHECK_EQ(0, swscanf(x00, L"%wfi", (int *)NULL));
+ ATF_CHECK_EQ(0, swscanf(x00, L"%wf1i", (int *)NULL));
+ ATF_CHECK_EQ(0, swscanf(x00, L"%wf128i", (int *)NULL));
+}
+
/*
* Test termination cases: non-numeric character, fixed width, EOF
*/
@@ -245,9 +310,9 @@ ATF_TC_WITHOUT_HEAD(swscanf_termination);
ATF_TC_BODY(swscanf_termination, tc)
{
int a = 0, b = 0, c = 0;
- char d = 0;
+ wchar_t d = 0;
- ATF_CHECK_EQ(4, swscanf(L"3.1415", L"%d%c%2d%d", &a, &d, &b, &c));
+ ATF_CHECK_EQ(4, swscanf(L"3.1415", L"%d%lc%2d%d", &a, &d, &b, &c));
ATF_CHECK_EQ(3, a);
ATF_CHECK_EQ(14, b);
ATF_CHECK_EQ(15, c);
@@ -262,6 +327,8 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, swscanf_d);
ATF_TP_ADD_TC(tp, swscanf_x);
ATF_TP_ADD_TC(tp, swscanf_i);
+ ATF_TP_ADD_TC(tp, swscanf_wN);
+ ATF_TP_ADD_TC(tp, swscanf_wfN);
ATF_TP_ADD_TC(tp, swscanf_termination);
return (atf_no_error());
}
diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile
index a2a6420aba41..50726a5d8af6 100644
--- a/lib/libc/tests/stdlib/Makefile
+++ b/lib/libc/tests/stdlib/Makefile
@@ -1,12 +1,14 @@
-
.include <src.opts.mk>
ATF_TESTS_C+= clearenv_test
+ATF_TESTS_C+= cxa_atexit_test
ATF_TESTS_C+= dynthr_test
+ATF_TESTS_C+= getenv_r_test
ATF_TESTS_C+= heapsort_test
+ATF_TESTS_C+= libc_exit_test
ATF_TESTS_C+= mergesort_test
ATF_TESTS_C+= qsort_test
-.if ${COMPILER_TYPE} == "clang"
+.if ${COMPILER_FEATURES:Mblocks}
ATF_TESTS_C+= qsort_b_test
.endif
ATF_TESTS_C+= qsort_r_compat_test
@@ -58,11 +60,9 @@ PROGS+= h_getopt h_getopt_long
CFLAGS+= -I${.CURDIR}
-CXXSTD.cxa_thread_atexit_test= c++11
-CXXSTD.cxa_thread_atexit_nothr_test= c++11
LIBADD.cxa_thread_atexit_test+= pthread
-# Tests that requires Blocks feature
+# Tests that require blocks support
.for t in qsort_b_test
CFLAGS.${t}.c+= -fblocks
LIBADD.${t}+= BlocksRuntime
@@ -75,8 +75,10 @@ LDFLAGS.$t+= -L${LIBNETBSD_OBJDIR}
LIBADD.${t}+= netbsd util
.endfor
+LIBADD.libc_exit_test+= pthread
LIBADD.strtod_test+= m
SUBDIR+= dynthr_mod
+SUBDIR+= libatexit
.include <bsd.test.mk>
diff --git a/lib/libc/tests/stdlib/clearenv_test.c b/lib/libc/tests/stdlib/clearenv_test.c
index 369d64b2e3b4..003535a00060 100644
--- a/lib/libc/tests/stdlib/clearenv_test.c
+++ b/lib/libc/tests/stdlib/clearenv_test.c
@@ -29,7 +29,6 @@
* Test for clearenv(3) routine.
*/
-#include <sys/cdefs.h>
#include <atf-c.h>
#include <stdio.h>
diff --git a/lib/libc/tests/stdlib/cxa_atexit_test.c b/lib/libc/tests/stdlib/cxa_atexit_test.c
new file mode 100644
index 000000000000..7e2cafbce850
--- /dev/null
+++ b/lib/libc/tests/stdlib/cxa_atexit_test.c
@@ -0,0 +1,132 @@
+/*-
+ * Copyright (c) 2025 Kyle Evans <kevans@FreeBSD.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/wait.h>
+
+#include <dlfcn.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+#define ARBITRARY_EXIT_CODE 42
+
+static char *
+get_shlib(const char *srcdir)
+{
+ char *shlib;
+
+ shlib = NULL;
+ if (asprintf(&shlib, "%s/libatexit.so", srcdir) < 0)
+ atf_tc_fail("failed to construct path to libatexit.so");
+ return (shlib);
+}
+
+static void
+run_test(const atf_tc_t *tc, bool with_fatal_atexit, bool with_exit)
+{
+ pid_t p;
+ void (*set_fatal_atexit)(bool);
+ void (*set_exit_code)(int);
+ void *hdl;
+ char *shlib;
+
+ shlib = get_shlib(atf_tc_get_config_var(tc, "srcdir"));
+
+ hdl = dlopen(shlib, RTLD_LAZY);
+ ATF_REQUIRE_MSG(hdl != NULL, "dlopen: %s", dlerror());
+
+ free(shlib);
+
+ if (with_fatal_atexit) {
+ set_fatal_atexit = dlsym(hdl, "set_fatal_atexit");
+ ATF_REQUIRE_MSG(set_fatal_atexit != NULL,
+ "set_fatal_atexit: %s", dlerror());
+ }
+ if (with_exit) {
+ set_exit_code = dlsym(hdl, "set_exit_code");
+ ATF_REQUIRE_MSG(set_exit_code != NULL, "set_exit_code: %s",
+ dlerror());
+ }
+
+ p = atf_utils_fork();
+ if (p == 0) {
+ /*
+ * Don't let the child clobber the results file; stderr/stdout
+ * have been replaced by atf_utils_fork() to capture it. We're
+ * intentionally using exit() instead of _exit() here to run
+ * __cxa_finalize at exit, otherwise we'd just leave it be.
+ */
+ closefrom(3);
+
+ if (with_fatal_atexit)
+ set_fatal_atexit(true);
+ if (with_exit)
+ set_exit_code(ARBITRARY_EXIT_CODE);
+
+ dlclose(hdl);
+
+ /*
+ * If the dtor was supposed to exit (most cases), then we should
+ * not have made it to this point. If it's not supposed to
+ * exit, then we just exit with success here because we might
+ * be expecting either a clean exit or a signal on our way out
+ * as the final __cxa_finalize tries to run a callback in the
+ * unloaded DSO.
+ */
+ if (with_exit)
+ exit(1);
+ exit(0);
+ }
+
+ dlclose(hdl);
+ atf_utils_wait(p, with_exit ? ARBITRARY_EXIT_CODE : 0, "", "");
+}
+
+ATF_TC_WITHOUT_HEAD(simple_cxa_atexit);
+ATF_TC_BODY(simple_cxa_atexit, tc)
+{
+ /*
+ * This test exits in a global object's dtor so that we check for our
+ * dtor being run at dlclose() time. If it isn't, then the forked child
+ * will have a chance to exit(1) after dlclose() to raise a failure.
+ */
+ run_test(tc, false, true);
+}
+
+ATF_TC_WITHOUT_HEAD(late_cxa_atexit);
+ATF_TC_BODY(late_cxa_atexit, tc)
+{
+ /*
+ * This test creates another global object during a __cxa_atexit handler
+ * invocation. It's been observed in the wild that we weren't executing
+ * it, then the DSO gets torn down and it was executed at application
+ * exit time instead. In the best case scenario we would crash if
+ * something else hadn't been mapped there.
+ */
+ run_test(tc, true, false);
+}
+
+ATF_TC_WITHOUT_HEAD(late_cxa_atexit_ran);
+ATF_TC_BODY(late_cxa_atexit_ran, tc)
+{
+ /*
+ * This is a slight variation of the previous test where we trigger an
+ * exit() in our late-registered __cxa_atexit handler so that we can
+ * ensure it was ran *before* dlclose() finished and not through some
+ * weird chain of events afterwards.
+ */
+ run_test(tc, true, true);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, simple_cxa_atexit);
+ ATF_TP_ADD_TC(tp, late_cxa_atexit);
+ ATF_TP_ADD_TC(tp, late_cxa_atexit_ran);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/stdlib/cxa_thread_atexit_nothr_test.cc b/lib/libc/tests/stdlib/cxa_thread_atexit_nothr_test.cc
index 8f9c6348e0b0..0b3b9497a6bd 100644
--- a/lib/libc/tests/stdlib/cxa_thread_atexit_nothr_test.cc
+++ b/lib/libc/tests/stdlib/cxa_thread_atexit_nothr_test.cc
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <dlfcn.h>
#include <atf-c++.hpp>
#include <cstdio>
diff --git a/lib/libc/tests/stdlib/cxa_thread_atexit_test.cc b/lib/libc/tests/stdlib/cxa_thread_atexit_test.cc
index d2e1369c91dd..628a70b510d1 100644
--- a/lib/libc/tests/stdlib/cxa_thread_atexit_test.cc
+++ b/lib/libc/tests/stdlib/cxa_thread_atexit_test.cc
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <dlfcn.h>
#include <atf-c++.hpp>
#include <cstdio>
diff --git a/lib/libc/tests/stdlib/dynthr_mod/Makefile b/lib/libc/tests/stdlib/dynthr_mod/Makefile
index 3c6330cb712f..3602e81e5be1 100644
--- a/lib/libc/tests/stdlib/dynthr_mod/Makefile
+++ b/lib/libc/tests/stdlib/dynthr_mod/Makefile
@@ -1,8 +1,8 @@
-
SHLIB_NAME= dynthr_mod.so
SHLIBDIR= ${TESTSDIR}
SRCS= dynthr_mod.c
LIBADD= pthread
+PACKAGE= tests
TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/:H}
diff --git a/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c b/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c
index 21c9e19d4468..eccffcd0bd49 100644
--- a/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c
+++ b/lib/libc/tests/stdlib/dynthr_mod/dynthr_mod.c
@@ -31,7 +31,6 @@
* may be omitted in redistributions.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/lib/libc/tests/stdlib/dynthr_test.c b/lib/libc/tests/stdlib/dynthr_test.c
index 7c22499c7567..5b0af718afc7 100644
--- a/lib/libc/tests/stdlib/dynthr_test.c
+++ b/lib/libc/tests/stdlib/dynthr_test.c
@@ -31,7 +31,6 @@
* may be omitted in redistributions.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
diff --git a/lib/libc/tests/stdlib/getenv_r_test.c b/lib/libc/tests/stdlib/getenv_r_test.c
new file mode 100644
index 000000000000..8085b92b1064
--- /dev/null
+++ b/lib/libc/tests/stdlib/getenv_r_test.c
@@ -0,0 +1,69 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(getenv_r_ok);
+ATF_TC_BODY(getenv_r_ok, tc)
+{
+ const char *ident = atf_tc_get_ident(tc);
+ char buf[256];
+
+ ATF_REQUIRE_EQ(0, setenv("ATF_TC_IDENT", ident, 1));
+ ATF_REQUIRE_EQ(0, getenv_r("ATF_TC_IDENT", buf, sizeof(buf)));
+ ATF_REQUIRE_STREQ(ident, buf);
+}
+
+ATF_TC_WITHOUT_HEAD(getenv_r_einval);
+ATF_TC_BODY(getenv_r_einval, tc)
+{
+ char buf[256];
+
+ errno = 0;
+ ATF_REQUIRE_EQ(-1, getenv_r(NULL, buf, sizeof(buf)));
+ ATF_REQUIRE_EQ(EINVAL, errno);
+ errno = 0;
+ ATF_REQUIRE_EQ(-1, getenv_r("", buf, sizeof(buf)));
+ ATF_REQUIRE_EQ(EINVAL, errno);
+ errno = 0;
+ ATF_REQUIRE_EQ(-1, getenv_r("A=B", buf, sizeof(buf)));
+ ATF_REQUIRE_EQ(EINVAL, errno);
+}
+
+ATF_TC_WITHOUT_HEAD(getenv_r_enoent);
+ATF_TC_BODY(getenv_r_enoent, tc)
+{
+ char buf[256];
+
+ errno = 0;
+ ATF_REQUIRE_EQ(-1, getenv_r("no such variable", buf, sizeof(buf)));
+ ATF_REQUIRE_EQ(ENOENT, errno);
+}
+
+ATF_TC_WITHOUT_HEAD(getenv_r_erange);
+ATF_TC_BODY(getenv_r_erange, tc)
+{
+ const char *ident = atf_tc_get_ident(tc);
+ char buf[256];
+
+ ATF_REQUIRE_EQ(0, setenv("ATF_TC_IDENT", ident, 1));
+ errno = 0;
+ ATF_REQUIRE_EQ(-1, getenv_r("ATF_TC_IDENT", buf, strlen(ident)));
+ ATF_REQUIRE_EQ(ERANGE, errno);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, getenv_r_ok);
+ ATF_TP_ADD_TC(tp, getenv_r_einval);
+ ATF_TP_ADD_TC(tp, getenv_r_enoent);
+ ATF_TP_ADD_TC(tp, getenv_r_erange);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/stdlib/heapsort_test.c b/lib/libc/tests/stdlib/heapsort_test.c
index 875326354e0f..b6747ff5d3aa 100644
--- a/lib/libc/tests/stdlib/heapsort_test.c
+++ b/lib/libc/tests/stdlib/heapsort_test.c
@@ -28,7 +28,6 @@
* Test for heapsort() routine.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/libatexit/Makefile b/lib/libc/tests/stdlib/libatexit/Makefile
new file mode 100644
index 000000000000..9ba04c77af62
--- /dev/null
+++ b/lib/libc/tests/stdlib/libatexit/Makefile
@@ -0,0 +1,11 @@
+SHLIB_CXX= libatexit
+SHLIB_NAME= libatexit.so
+SHLIB_MAJOR= 1
+SHLIBDIR= ${TESTSDIR}
+PACKAGE= tests
+SRCS= libatexit.cc
+
+TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/:H}
+
+
+.include <bsd.lib.mk>
diff --git a/lib/libc/tests/stdlib/libatexit/libatexit.cc b/lib/libc/tests/stdlib/libatexit/libatexit.cc
new file mode 100644
index 000000000000..bb286c97e421
--- /dev/null
+++ b/lib/libc/tests/stdlib/libatexit/libatexit.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2025 Kyle Evans <kevans@FreeBSD.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ */
+
+#include <unistd.h>
+
+static int exit_code = -1;
+static bool fatal_atexit;
+
+extern "C" {
+ void set_fatal_atexit(bool);
+ void set_exit_code(int);
+}
+
+void
+set_fatal_atexit(bool fexit)
+{
+ fatal_atexit = fexit;
+}
+
+void
+set_exit_code(int code)
+{
+ exit_code = code;
+}
+
+struct other_object {
+ ~other_object() {
+
+ /*
+ * In previous versions of our __cxa_atexit handling, we would
+ * never actually execute this handler because it's added during
+ * ~object() below; __cxa_finalize would never revisit it. We
+ * will allow the caller to configure us to exit with a certain
+ * exit code so that it can run us twice: once to ensure we
+ * don't crash at the end, and again to make sure the handler
+ * actually ran.
+ */
+ if (exit_code != -1)
+ _exit(exit_code);
+ }
+};
+
+void
+create_staticobj()
+{
+ static other_object obj;
+}
+
+struct object {
+ ~object() {
+ /*
+ * If we're doing the fatal_atexit behavior (i.e., create an
+ * object that will add its own dtor for __cxa_finalize), then
+ * we don't exit here.
+ */
+ if (fatal_atexit)
+ create_staticobj();
+ else if (exit_code != -1)
+ _exit(exit_code);
+ }
+};
+
+static object obj;
diff --git a/lib/libc/tests/stdlib/libc_exit_test.c b/lib/libc/tests/stdlib/libc_exit_test.c
new file mode 100644
index 000000000000..12965261bdb3
--- /dev/null
+++ b/lib/libc/tests/stdlib/libc_exit_test.c
@@ -0,0 +1,154 @@
+/*-
+ * Copyright (c) 2023 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/wait.h>
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+static void
+func_a(void)
+{
+ if (write(STDOUT_FILENO, "a", 1) != 1)
+ _Exit(1);
+}
+
+static void
+func_b(void)
+{
+ if (write(STDOUT_FILENO, "b", 1) != 1)
+ _Exit(1);
+}
+
+static void
+func_c(void)
+{
+ if (write(STDOUT_FILENO, "c", 1) != 1)
+ _Exit(1);
+}
+
+static void
+child(void)
+{
+ /* this will be received by the parent */
+ printf("hello, ");
+ fflush(stdout);
+ /* this won't, because quick_exit() does not flush */
+ printf("world");
+ /* these will be called in reverse order, producing "abc" */
+ if (at_quick_exit(func_c) != 0 ||
+ at_quick_exit(func_b) != 0 ||
+ at_quick_exit(func_a) != 0)
+ _Exit(1);
+ quick_exit(0);
+}
+
+ATF_TC_WITHOUT_HEAD(quick_exit);
+ATF_TC_BODY(quick_exit, tc)
+{
+ char buf[100] = "";
+ ssize_t len;
+ int p[2], wstatus = 0;
+ pid_t pid;
+
+ ATF_REQUIRE(pipe(p) == 0);
+ pid = fork();
+ if (pid == 0) {
+ if (dup2(p[1], STDOUT_FILENO) < 0)
+ _Exit(1);
+ (void)close(p[1]);
+ (void)close(p[0]);
+ child();
+ _Exit(1);
+ }
+ ATF_REQUIRE_MSG(pid > 0,
+ "expect fork() to succeed");
+ ATF_CHECK_EQ_MSG(pid, waitpid(pid, &wstatus, 0),
+ "expect to collect child process");
+ ATF_CHECK_EQ_MSG(0, wstatus,
+ "expect child to exit cleanly");
+ ATF_CHECK_MSG((len = read(p[0], buf, sizeof(buf))) > 0,
+ "expect to receive output from child");
+ ATF_CHECK_STREQ("hello, abc", buf);
+}
+
+static void
+myatexit1(void)
+{
+ exit(12);
+}
+
+ATF_TC_WITHOUT_HEAD(recursive_exit1);
+ATF_TC_BODY(recursive_exit1, tc)
+{
+ pid_t pid;
+ int wstatus;
+
+ pid = fork();
+ if (pid == 0) {
+ atexit(myatexit1);
+ exit(1);
+ }
+ ATF_REQUIRE_MSG(pid > 0,
+ "expect fork() to succeed");
+ ATF_CHECK_EQ_MSG(pid, waitpid(pid, &wstatus, 0),
+ "expect to collect child process");
+ ATF_CHECK(WIFEXITED(wstatus));
+ ATF_CHECK_EQ(WEXITSTATUS(wstatus), 12);
+}
+
+static pthread_barrier_t barrier;
+
+static void
+myatexit2(void)
+{
+ pthread_barrier_wait(&barrier);
+ exit(12);
+}
+
+static void *
+mythreadexit(void *arg)
+{
+ pthread_barrier_wait(&barrier);
+ exit(15);
+}
+
+ATF_TC_WITHOUT_HEAD(recursive_exit2);
+ATF_TC_BODY(recursive_exit2, tc)
+{
+ pid_t pid;
+ int wstatus;
+
+ pid = fork();
+ if (pid == 0) {
+ pthread_t thr;
+
+ atexit(myatexit2);
+
+ pthread_barrier_init(&barrier, NULL, 2);
+ pthread_create(&thr, NULL, mythreadexit, NULL);
+
+ exit(1);
+ }
+ ATF_REQUIRE_MSG(pid > 0,
+ "expect fork() to succeed");
+ ATF_CHECK_EQ_MSG(pid, waitpid(pid, &wstatus, 0),
+ "expect to collect child process");
+ ATF_CHECK(WIFEXITED(wstatus));
+ ATF_CHECK_EQ(WEXITSTATUS(wstatus), 12);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, quick_exit);
+ ATF_TP_ADD_TC(tp, recursive_exit1);
+ ATF_TP_ADD_TC(tp, recursive_exit2);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/stdlib/mergesort_test.c b/lib/libc/tests/stdlib/mergesort_test.c
index e57def84e3ab..156d6bb7c2c3 100644
--- a/lib/libc/tests/stdlib/mergesort_test.c
+++ b/lib/libc/tests/stdlib/mergesort_test.c
@@ -28,7 +28,6 @@
* Test for mergesort() routine.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/qsort_r_compat_test.c b/lib/libc/tests/stdlib/qsort_r_compat_test.c
index d2734c8678de..d7b06615292e 100644
--- a/lib/libc/tests/stdlib/qsort_r_compat_test.c
+++ b/lib/libc/tests/stdlib/qsort_r_compat_test.c
@@ -29,7 +29,6 @@
* Test for historical qsort_r(3) routine.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/qsort_r_test.c b/lib/libc/tests/stdlib/qsort_r_test.c
index 962a3792beb4..446d63279fbf 100644
--- a/lib/libc/tests/stdlib/qsort_r_test.c
+++ b/lib/libc/tests/stdlib/qsort_r_test.c
@@ -29,7 +29,6 @@
* Test for qsort_r(3) routine.
*/
-#include <sys/cdefs.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/qsort_s_test.c b/lib/libc/tests/stdlib/qsort_s_test.c
index 9682d447edb7..c3210caf24e1 100644
--- a/lib/libc/tests/stdlib/qsort_s_test.c
+++ b/lib/libc/tests/stdlib/qsort_s_test.c
@@ -30,7 +30,6 @@
* Test for qsort_s(3) routine.
*/
-#include <sys/cdefs.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/qsort_test.c b/lib/libc/tests/stdlib/qsort_test.c
index 1a0587a94ade..a6202e55fd62 100644
--- a/lib/libc/tests/stdlib/qsort_test.c
+++ b/lib/libc/tests/stdlib/qsort_test.c
@@ -28,7 +28,6 @@
* Test for qsort() routine.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/set_constraint_handler_s_test.c b/lib/libc/tests/stdlib/set_constraint_handler_s_test.c
index b718b4fc11fd..87db1f71ed4d 100644
--- a/lib/libc/tests/stdlib/set_constraint_handler_s_test.c
+++ b/lib/libc/tests/stdlib/set_constraint_handler_s_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c
index f092c071724a..86f6256dba0b 100644
--- a/lib/libc/tests/stdlib/strfmon_test.c
+++ b/lib/libc/tests/stdlib/strfmon_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <locale.h>
diff --git a/lib/libc/tests/stdlib/tsearch_test.c b/lib/libc/tests/stdlib/tsearch_test.c
index 6dc53b3f6f81..ee9deec588cb 100644
--- a/lib/libc/tests/stdlib/tsearch_test.c
+++ b/lib/libc/tests/stdlib/tsearch_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <atf-c.h>
#define _SEARCH_PRIVATE
#include <search.h>
diff --git a/lib/libc/tests/stdtime/Makefile b/lib/libc/tests/stdtime/Makefile
new file mode 100644
index 000000000000..adb883cc5b9a
--- /dev/null
+++ b/lib/libc/tests/stdtime/Makefile
@@ -0,0 +1,10 @@
+.include <src.opts.mk>
+
+ATF_TESTS_C+= strptime_test
+.if ${MK_DETECT_TZ_CHANGES} != "no"
+ATF_TESTS_C+= detect_tz_changes_test
+.endif
+
+TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/}
+
+.include <bsd.test.mk>
diff --git a/lib/libc/tests/stdtime/detect_tz_changes_test.c b/lib/libc/tests/stdtime/detect_tz_changes_test.c
new file mode 100644
index 000000000000..9722546747fd
--- /dev/null
+++ b/lib/libc/tests/stdtime/detect_tz_changes_test.c
@@ -0,0 +1,281 @@
+/*-
+ * Copyright (c) 2025 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+static const time_t then = 1751328000; /* 2025-07-01 00:00:00 UTC */
+static const char *tz_change_interval_sym = "__tz_change_interval";
+static int *tz_change_interval_p;
+static const int tz_change_interval = 3;
+static int tz_change_timeout = 90;
+
+static bool debugging;
+
+static void
+debug(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (debugging) {
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+ }
+}
+
+static void
+change_tz(const char *tzn)
+{
+ static const char *zfn = "/usr/share/zoneinfo";
+ static const char *tfn = "root/etc/.localtime";
+ static const char *dfn = "root/etc/localtime";
+ ssize_t clen;
+ int zfd, sfd, dfd;
+
+ ATF_REQUIRE((zfd = open(zfn, O_DIRECTORY | O_SEARCH)) >= 0);
+ ATF_REQUIRE((sfd = openat(zfd, tzn, O_RDONLY)) >= 0);
+ ATF_REQUIRE((dfd = open(tfn, O_CREAT | O_TRUNC | O_WRONLY)) >= 0);
+ do {
+ clen = copy_file_range(sfd, NULL, dfd, NULL, SSIZE_MAX, 0);
+ ATF_REQUIRE_MSG(clen != -1, "failed to copy %s/%s: %m",
+ zfn, tzn);
+ } while (clen > 0);
+ ATF_CHECK_EQ(0, close(dfd));
+ ATF_CHECK_EQ(0, close(sfd));
+ ATF_CHECK_EQ(0, close(zfd));
+ ATF_REQUIRE_EQ(0, rename(tfn, dfn));
+ debug("time zone %s installed", tzn);
+}
+
+/*
+ * Test time zone change detection.
+ *
+ * The parent creates a chroot containing only /etc/localtime, initially
+ * set to UTC. It then forks a child which enters the chroot, repeatedly
+ * checks the current time zone, and prints it to stdout if it changes
+ * (including once on startup). Meanwhile, the parent waits for output
+ * from the child. Every time it receives a line of text from the child,
+ * it checks that it is as expected, then changes /etc/localtime within
+ * the chroot to the next case in the list. Once it reaches the end of
+ * the list, it closes a pipe to notify the child, which terminates.
+ *
+ * Note that ATF and / or Kyua may have set the timezone before the test
+ * case starts (even unintentionally). Therefore, we start the test only
+ * after we've received and discarded the first report from the child,
+ * which should come almost immediately on startup.
+ */
+ATF_TC(detect_tz_changes);
+ATF_TC_HEAD(detect_tz_changes, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test timezone change detection");
+ atf_tc_set_md_var(tc, "require.user", "root");
+ atf_tc_set_md_var(tc, "timeout", "600");
+}
+ATF_TC_BODY(detect_tz_changes, tc)
+{
+ static const struct tzcase {
+ const char *tzfn;
+ const char *expect;
+ } tzcases[] = {
+ /*
+ * A handful of time zones and the expected result of
+ * strftime("%z (%Z)", tm) when that time zone is active
+ * and tm represents a date in the summer of 2025.
+ */
+ { "America/Vancouver", "-0700 (PDT)" },
+ { "America/New_York", "-0400 (EDT)" },
+ { "Europe/London", "+0100 (BST)" },
+ { "Europe/Paris", "+0200 (CEST)" },
+ { "Asia/Kolkata", "+0530 (IST)" },
+ { "Asia/Tokyo", "+0900 (JST)" },
+ { "Australia/Canberra", "+1000 (AEST)" },
+ { "UTC", "+0000 (UTC)" },
+ { 0 },
+ };
+ char obuf[1024] = "";
+ char ebuf[1024] = "";
+ struct pollfd fds[3];
+ int opd[2], epd[2], spd[2];
+ time_t changed, now;
+ const struct tzcase *tzcase = NULL;
+ struct tm *tm;
+ size_t olen = 0, elen = 0;
+ ssize_t rlen;
+ long curoff = LONG_MIN;
+ pid_t pid;
+ int nfds, status;
+
+ /* speed up the test if possible */
+ tz_change_interval_p = dlsym(RTLD_SELF, tz_change_interval_sym);
+ if (tz_change_interval_p != NULL &&
+ *tz_change_interval_p > tz_change_interval) {
+ debug("reducing detection interval from %d to %d",
+ *tz_change_interval_p, tz_change_interval);
+ *tz_change_interval_p = tz_change_interval;
+ tz_change_timeout = tz_change_interval * 3;
+ }
+ /* prepare chroot */
+ ATF_REQUIRE_EQ(0, mkdir("root", 0755));
+ ATF_REQUIRE_EQ(0, mkdir("root/etc", 0755));
+ change_tz("UTC");
+ time(&changed);
+ /* output, error, sync pipes */
+ if (pipe(opd) != 0 || pipe(epd) != 0 || pipe(spd) != 0)
+ atf_tc_fail("failed to pipe");
+ /* fork child */
+ if ((pid = fork()) < 0)
+ atf_tc_fail("failed to fork");
+ if (pid == 0) {
+ /* child */
+ dup2(opd[1], STDOUT_FILENO);
+ close(opd[0]);
+ close(opd[1]);
+ dup2(epd[1], STDERR_FILENO);
+ close(epd[0]);
+ close(epd[1]);
+ close(spd[0]);
+ unsetenv("TZ");
+ ATF_REQUIRE_EQ(0, chroot("root"));
+ ATF_REQUIRE_EQ(0, chdir("/"));
+ fds[0].fd = spd[1];
+ fds[0].events = POLLIN;
+ for (;;) {
+ ATF_REQUIRE(poll(fds, 1, 100) >= 0);
+ if (fds[0].revents & POLLHUP) {
+ /* parent closed sync pipe */
+ _exit(0);
+ }
+ ATF_REQUIRE((tm = localtime(&then)) != NULL);
+ if (tm->tm_gmtoff == curoff)
+ continue;
+ olen = strftime(obuf, sizeof(obuf), "%z (%Z)", tm);
+ ATF_REQUIRE(olen > 0);
+ fprintf(stdout, "%s\n", obuf);
+ fflush(stdout);
+ curoff = tm->tm_gmtoff;
+ }
+ _exit(2);
+ }
+ /* parent */
+ close(opd[1]);
+ close(epd[1]);
+ close(spd[1]);
+ /* receive output until child terminates */
+ fds[0].fd = opd[0];
+ fds[0].events = POLLIN;
+ fds[1].fd = epd[0];
+ fds[1].events = POLLIN;
+ fds[2].fd = spd[0];
+ fds[2].events = POLLIN;
+ nfds = 3;
+ for (;;) {
+ ATF_REQUIRE(poll(fds, 3, 1000) >= 0);
+ time(&now);
+ if (fds[0].revents & POLLIN && olen < sizeof(obuf)) {
+ rlen = read(opd[0], obuf + olen, sizeof(obuf) - olen);
+ ATF_REQUIRE(rlen >= 0);
+ olen += rlen;
+ }
+ if (olen > 0) {
+ ATF_REQUIRE_EQ('\n', obuf[olen - 1]);
+ obuf[--olen] = '\0';
+ /* tzcase will be NULL at first */
+ if (tzcase != NULL) {
+ debug("%s", obuf);
+ ATF_REQUIRE_STREQ(tzcase->expect, obuf);
+ debug("change to %s detected after %d s",
+ tzcase->tzfn, (int)(now - changed));
+ if (tz_change_interval_p != NULL) {
+ ATF_CHECK((int)(now - changed) >=
+ *tz_change_interval_p - 1);
+ ATF_CHECK((int)(now - changed) <=
+ *tz_change_interval_p + 1);
+ }
+ }
+ olen = 0;
+ /* first / next test case */
+ if (tzcase == NULL)
+ tzcase = tzcases;
+ else
+ tzcase++;
+ if (tzcase->tzfn == NULL) {
+ /* test is over */
+ break;
+ }
+ change_tz(tzcase->tzfn);
+ changed = now;
+ }
+ if (fds[1].revents & POLLIN && elen < sizeof(ebuf)) {
+ rlen = read(epd[0], ebuf + elen, sizeof(ebuf) - elen);
+ ATF_REQUIRE(rlen >= 0);
+ elen += rlen;
+ }
+ if (elen > 0) {
+ ATF_REQUIRE_EQ(elen, fwrite(ebuf, 1, elen, stderr));
+ elen = 0;
+ }
+ if (nfds > 2 && fds[2].revents & POLLHUP) {
+ /* child closed sync pipe */
+ break;
+ }
+ /*
+ * The timeout for this test case is set to 10 minutes,
+ * because it can take that long to run with the default
+ * 61-second interval. However, each individual tzcase
+ * entry should not take much longer than the detection
+ * interval to test, so we can detect a problem long
+ * before Kyua terminates us.
+ */
+ if ((now - changed) > tz_change_timeout) {
+ close(spd[0]);
+ if (tz_change_interval_p == NULL &&
+ tzcase == tzcases) {
+ /*
+ * The most likely explanation in this
+ * case is that libc was built without
+ * time zone change detection.
+ */
+ atf_tc_skip("time zone change detection "
+ "does not appear to be enabled");
+ }
+ atf_tc_fail("timed out waiting for change to %s "
+ "to be detected", tzcase->tzfn);
+ }
+ }
+ close(opd[0]);
+ close(epd[0]);
+ close(spd[0]); /* this will wake up and terminate the child */
+ if (olen > 0)
+ ATF_REQUIRE_EQ(olen, fwrite(obuf, 1, olen, stdout));
+ if (elen > 0)
+ ATF_REQUIRE_EQ(elen, fwrite(ebuf, 1, elen, stderr));
+ ATF_REQUIRE_EQ(pid, waitpid(pid, &status, 0));
+ ATF_REQUIRE(WIFEXITED(status));
+ ATF_REQUIRE_EQ(0, WEXITSTATUS(status));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ debugging = !getenv("__RUNNING_INSIDE_ATF_RUN") &&
+ isatty(STDERR_FILENO);
+ ATF_TP_ADD_TC(tp, detect_tz_changes);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/stdtime/strptime_test.c b/lib/libc/tests/stdtime/strptime_test.c
new file mode 100644
index 000000000000..79a97764999c
--- /dev/null
+++ b/lib/libc/tests/stdtime/strptime_test.c
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2024 Dag-Erling Smørgrav
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <time.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(dayofweek);
+ATF_TC_BODY(dayofweek, tc)
+{
+ static const struct {
+ const char *str;
+ int wday;
+ } cases[] = {
+ { "1582-12-20", 1 },
+ { "1700-03-01", 1 },
+ { "1752-09-14", 4 },
+ { "1800-12-31", 3 },
+ { "1801-01-01", 4 },
+ { "1900-12-31", 1 },
+ { "1901-01-01", 2 },
+ { "2000-12-31", 0 },
+ { "2001-01-01", 1 },
+ { "2100-12-31", 5 },
+ { "2101-01-01", 6 },
+ { "2200-12-31", 3 },
+ { "2201-01-01", 4 },
+ { },
+ };
+ struct tm tm;
+
+ for (unsigned int i = 0; cases[i].str != NULL; i++) {
+ if (strptime(cases[i].str, "%Y-%m-%d", &tm) == NULL) {
+ atf_tc_fail_nonfatal("failed to parse %s",
+ cases[i].str);
+ } else if (tm.tm_wday != cases[i].wday) {
+ atf_tc_fail_nonfatal("expected %d for %s, got %d",
+ cases[i].wday, cases[i].str, tm.tm_wday);
+ }
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, dayofweek);
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/string/Makefile b/lib/libc/tests/string/Makefile
index a7545b75e0e9..a019939c30af 100644
--- a/lib/libc/tests/string/Makefile
+++ b/lib/libc/tests/string/Makefile
@@ -1,19 +1,30 @@
-
# ensure libc functions are tested, not clang's builtins
CFLAGS+= -fno-builtin
+ATF_TESTS_C+= bcmp_test
ATF_TESTS_C+= ffs_test
ATF_TESTS_C+= ffsl_test
ATF_TESTS_C+= ffsll_test
ATF_TESTS_C+= fls_test
ATF_TESTS_C+= flsl_test
ATF_TESTS_C+= flsll_test
+ATF_TESTS_C+= memccpy_test
ATF_TESTS_C+= memcmp_test
+ATF_TESTS_C+= memrchr_test
+ATF_TESTS_C+= memset2_test
ATF_TESTS_C+= memset_s_test
+ATF_TESTS_C+= strncmp_test
ATF_TESTS_C+= stpncpy_test
+ATF_TESTS_C+= strnlen_test
+ATF_TESTS_C+= strcmp2_test
+ATF_TESTS_C+= strcspn_test
ATF_TESTS_C+= strerror2_test
+ATF_TESTS_C+= strlcpy_test
+ATF_TESTS_C+= strspn_test
ATF_TESTS_C+= strverscmp_test
ATF_TESTS_C+= strxfrm_test
+ATF_TESTS_C+= timingsafe_bcmp_test
+ATF_TESTS_C+= timingsafe_memcmp_test
ATF_TESTS_C+= wcscasecmp_test
ATF_TESTS_C+= wcscoll_test
ATF_TESTS_C+= wcsnlen_test
@@ -29,14 +40,14 @@ NETBSD_ATF_TESTS_C+= strchr_test
NETBSD_ATF_TESTS_C+= strchrnul_test
NETBSD_ATF_TESTS_C+= strcmp_test
NETBSD_ATF_TESTS_C+= strcpy_test
-NETBSD_ATF_TESTS_C+= strcspn_test
NETBSD_ATF_TESTS_C+= strerror_test
NETBSD_ATF_TESTS_C+= strlen_test
NETBSD_ATF_TESTS_C+= strpbrk_test
NETBSD_ATF_TESTS_C+= strrchr_test
-NETBSD_ATF_TESTS_C+= strspn_test
NETBSD_ATF_TESTS_C+= swab_test
+SRCS.memset2_test= memset_test.c
+SRCS.strcmp2_test= strcmp_test.c
SRCS.strerror2_test= strerror_test.c
.include "../Makefile.netbsd-tests"
diff --git a/lib/libc/tests/string/bcmp_test.c b/lib/libc/tests/string/bcmp_test.c
new file mode 100644
index 000000000000..fdf5e48b3eb4
--- /dev/null
+++ b/lib/libc/tests/string/bcmp_test.c
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#define MEMCMP bcmp
+#define RES(x) ((x) != 0)
+
+#include "memcmp_test.c"
diff --git a/lib/libc/tests/string/ffs_test.c b/lib/libc/tests/string/ffs_test.c
index aea61254482e..4b59385d712e 100644
--- a/lib/libc/tests/string/ffs_test.c
+++ b/lib/libc/tests/string/ffs_test.c
@@ -25,7 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE
*/
-#include <sys/cdefs.h>
#include <atf-c.h>
#include <limits.h>
diff --git a/lib/libc/tests/string/fls_test.c b/lib/libc/tests/string/fls_test.c
index 847977d260c9..55691b36617c 100644
--- a/lib/libc/tests/string/fls_test.c
+++ b/lib/libc/tests/string/fls_test.c
@@ -25,7 +25,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE
*/
-#include <sys/cdefs.h>
#include <atf-c.h>
#include <limits.h>
diff --git a/lib/libc/tests/string/memccpy_test.c b/lib/libc/tests/string/memccpy_test.c
new file mode 100644
index 000000000000..4784fee4ede5
--- /dev/null
+++ b/lib/libc/tests/string/memccpy_test.c
@@ -0,0 +1,229 @@
+/*-
+ * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
+ * Copyright (c) 2023, 2024 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <assert.h>
+#include <dlfcn.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+void *(*memccpy_fn)(void *restrict, const void *restrict, int, size_t);
+
+static char *
+makebuf(size_t len, int guard_at_end)
+{
+ char *buf;
+ size_t alloc_size, page_size;
+
+ page_size = getpagesize();
+ alloc_size = roundup2(len, page_size) + page_size;
+
+ buf = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
+ assert(buf);
+ if (guard_at_end) {
+ assert(mprotect(buf + alloc_size - page_size, page_size, PROT_NONE) == 0);
+ return (buf + alloc_size - page_size - len);
+ } else {
+ assert(mprotect(buf, page_size, PROT_NONE) == 0);
+ return (buf + page_size);
+ }
+}
+
+static void
+freebuf(char * buf, size_t len, int guard_at_end)
+{
+ size_t alloc_size, page_size;
+
+ page_size = getpagesize();
+ alloc_size = roundup2(len, page_size) + page_size;
+
+ if (guard_at_end)
+ munmap(buf + len + page_size - alloc_size, alloc_size);
+ else
+ munmap(buf - page_size, alloc_size);
+}
+
+static void
+test_memccpy(const char *s, size_t size)
+{
+ char *src, *dst, *expected;
+ size_t bufsize, x;
+ int i, j;
+
+ for (i = 0; i <= 1; i++) {
+ for (j = 0; j <= 1; j++) {
+ for (bufsize = 0; bufsize <= size + 32; bufsize++) {
+ dst = makebuf(bufsize, j);
+ if (bufsize < size) {
+ src = makebuf(bufsize, i);
+ memcpy(src, s, bufsize);
+ expected = NULL;
+ } else {
+ src = makebuf(size, i);
+ memcpy(src, s, size);
+ expected = dst + size;
+ }
+
+ memset(dst, 'X', bufsize);
+ assert(memccpy_fn(dst, src, s[size-1], bufsize) == expected);
+ assert(memcmp(src, dst, MIN(bufsize, size)) == 0);
+ for (x = size; x < bufsize; x++)
+ assert(dst[x] == 'X');
+
+ freebuf(dst, bufsize, j);
+ freebuf(src, bufsize < size ? bufsize : size, i);
+ }
+ }
+ }
+}
+
+static void
+test_sentinel(char *dest, char *src, size_t destlen, size_t srclen)
+{
+ size_t i, effective_len;
+ void *res, *wantres;
+ const char *fail = NULL;
+ char terminator;
+
+ for (i = 0; i < srclen; i++)
+ /* src will never include (){} */
+ src[i] = '0' + i;
+
+ /* source sentinels: not to be copied */
+ src[-1] = '(';
+ src[srclen] = ')';
+
+ memset(dest, '\xee', destlen);
+
+ /* destination sentinels: not to be touched */
+ dest[-1] = '{';
+ dest[destlen] = '}';
+
+ effective_len = srclen < destlen ? srclen : destlen;
+ wantres = srclen <= destlen ? dest + srclen : NULL;
+ terminator = src[srclen-1];
+ res = memccpy_fn(dest, src, terminator, destlen);
+
+ if (dest[-1] != '{')
+ fail = "start sentinel overwritten";
+ else if (dest[destlen] != '}')
+ fail = "end sentinel overwritten";
+ else if (res != wantres)
+ fail = "incorrect return value";
+ else if (destlen > 0 && memcmp(src, dest, effective_len) != 0)
+ fail = "string not copied correctly";
+ else for (i = srclen; i < destlen; i++)
+ if (dest[i] != '\xee') {
+ fail = "buffer mutilated behind string";
+ break;
+ }
+
+ if (fail)
+ atf_tc_fail_nonfatal("%s\n"
+ "memccpy(%p \"%s\", %p \"%s\", %u '%c', %zu) = %p (want %p)\n",
+ fail, dest, dest, src, src, terminator, terminator, destlen, res, wantres);
+}
+
+ATF_TC_WITHOUT_HEAD(null);
+ATF_TC_BODY(null, tc)
+{
+ ATF_CHECK_EQ(memccpy_fn(NULL, "foo", 42, 0), NULL);
+}
+
+ATF_TC(zero_extension);
+ATF_TC_HEAD(zero_extension, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Ensure the upper bits of the terminator are ignored");
+}
+ATF_TC_BODY(zero_extension, tc)
+{
+ int mask = -1 & ~UCHAR_MAX;
+ char buf[16];
+
+ memset(buf, 0xcc, sizeof(buf));
+ ATF_CHECK_EQ(memccpy(buf, "foobar", 'r', sizeof(buf)), buf + sizeof("foobar") - 1);
+ ATF_CHECK_EQ(memcmp(buf, "foobar", sizeof("foobar") - 1), 0);
+
+ memset(buf, 0xcc, sizeof(buf));
+ ATF_CHECK_EQ(memccpy(buf, "foobar", mask | 'r', sizeof(buf)), buf + sizeof("foobar") - 1);
+ ATF_CHECK_EQ(memcmp(buf, "foobar", sizeof("foobar") - 1), 0);
+}
+
+ATF_TC_WITHOUT_HEAD(bounds);
+ATF_TC_BODY(bounds, tc)
+{
+ size_t i;
+ char buf[64];
+
+ for (i = 0; i < sizeof(buf) - 1; i++) {
+ buf[i] = ' ' + i;
+ buf[i+1] = '\0';
+ test_memccpy(buf, i + 1);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(alignments);
+ATF_TC_BODY(alignments, tc)
+{
+ size_t srcalign, destalign, srclen, destlen;
+ char src[15+2+64]; /* 15 offsets + 64 max length + sentinels */
+ char dest[15+2+64]; /* 15 offsets + 64 max length + sentinels */
+
+ for (srcalign = 0; srcalign < 16; srcalign++)
+ for (destalign = 0; destalign < 16; destalign++)
+ for (srclen = 1; srclen < 64; srclen++)
+ for (destlen = 0; destlen < 64; destlen++)
+ test_sentinel(dest+destalign+1,
+ src+srcalign+1, destlen, srclen);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ memccpy_fn = dlsym(dl_handle, "test_memccpy");
+ if (memccpy_fn == NULL)
+ memccpy_fn = memccpy;
+
+ ATF_TP_ADD_TC(tp, null);
+ ATF_TP_ADD_TC(tp, zero_extension);
+ ATF_TP_ADD_TC(tp, bounds);
+ ATF_TP_ADD_TC(tp, alignments);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/string/memcmp_test.c b/lib/libc/tests/string/memcmp_test.c
index ab782c92f255..5286a0b994f3 100644
--- a/lib/libc/tests/string/memcmp_test.c
+++ b/lib/libc/tests/string/memcmp_test.c
@@ -1,7 +1,11 @@
/*-
* Copyright (c) 2016 Jilles Tjoelker <jilles@FreeBSD.org>
+ * Copyright (c) 2023 The FreeBSD Foundation
* All rights reserved.
*
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -24,20 +28,48 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
+#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atf-c.h>
+#ifndef MEMCMP
+#define MEMCMP memcmp
+#endif
+
+/*
+ * On FreeBSD we demand that memcmp returns the difference between the
+ * characters at the first site of mismatch. However, ISO/IEC 9899:1990
+ * only specifies that a number greater than, equal to, or less than
+ * zero shall be returned. If a unit test for this less strict
+ * behaviour is desired, define RES(x) to be (((x) > 0) - ((x) < 0)).
+ */
+#ifndef RES
+#define RES(x) (x)
+#endif
+
+static int (*memcmp_fn)(const void *, const void *, size_t);
+
+static void
+check_memcmp(const char *a, const char *b, size_t len, int expected)
+{
+ int got;
+
+ got = memcmp_fn(a, b, len);
+ ATF_CHECK_EQ_MSG(RES(expected), RES(got),
+ "%s(%p, %p, %zu) gave %d, but wanted %d",
+ __XSTRING(MEMCMP), a, b, len, got, expected);
+}
+
ATF_TC_WITHOUT_HEAD(zero);
ATF_TC_BODY(zero, tc)
{
- assert(memcmp("a", "b", 0) == 0);
- assert(memcmp("", "", 0) == 0);
+ check_memcmp("a", "b", 0, 0);
+ check_memcmp("", "", 0, 0);
}
ATF_TC_WITHOUT_HEAD(eq);
@@ -49,9 +81,9 @@ ATF_TC_BODY(eq, tc)
for (i = 0; i < 256; i++)
data1[i] = data2[i] = i ^ 0x55;
for (i = 1; i < 256; i++)
- assert(memcmp(data1, data2, i) == 0);
+ check_memcmp(data1, data2, i, 0);
for (i = 1; i < 256; i++)
- assert(memcmp(data1 + i, data2 + i, 256 - i) == 0);
+ check_memcmp(data1 + i, data2 + i, 256 - i, 0);
}
ATF_TC_WITHOUT_HEAD(neq);
@@ -65,9 +97,9 @@ ATF_TC_BODY(neq, tc)
data2[i] = i ^ 0x55;
}
for (i = 1; i < 256; i++)
- assert(memcmp(data1, data2, i) != 0);
+ check_memcmp(data1, data2, i, -0x55);
for (i = 1; i < 256; i++)
- assert(memcmp(data1 + i, data2 + i, 256 - i) != 0);
+ check_memcmp(data1 + i, data2 + i, 256 - i, i - (i ^ 0x55));
}
ATF_TC_WITHOUT_HEAD(diff);
@@ -81,37 +113,43 @@ ATF_TC_BODY(diff, tc)
data1[128] = 255;
data2[128] = 0;
for (i = 1; i < 66; i++) {
- assert(memcmp(data1 + 128, data2 + 128, i) == 255);
- assert(memcmp(data2 + 128, data1 + 128, i) == -255);
- assert(memcmp(data1 + 129 - i, data2 + 129 - i, i) == 255);
- assert(memcmp(data2 + 129 - i, data1 + 129 - i, i) == -255);
- assert(memcmp(data1 + 129 - i, data2 + 129 - i, i * 2) == 255);
- assert(memcmp(data2 + 129 - i, data1 + 129 - i, i * 2) == -255);
+ check_memcmp(data1 + 128, data2 + 128, i, 255);
+ check_memcmp(data2 + 128, data1 + 128, i, -255);
+ check_memcmp(data1 + 129 - i, data2 + 129 - i, i, 255);
+ check_memcmp(data2 + 129 - i, data1 + 129 - i, i, -255);
+ check_memcmp(data1 + 129 - i, data2 + 129 - i, i * 2, 255);
+ check_memcmp(data2 + 129 - i, data1 + 129 - i, i * 2, -255);
}
data1[128] = 'c';
data2[128] = 'e';
for (i = 1; i < 66; i++) {
- assert(memcmp(data1 + 128, data2 + 128, i) == -2);
- assert(memcmp(data2 + 128, data1 + 128, i) == 2);
- assert(memcmp(data1 + 129 - i, data2 + 129 - i, i) == -2);
- assert(memcmp(data2 + 129 - i, data1 + 129 - i, i) == 2);
- assert(memcmp(data1 + 129 - i, data2 + 129 - i, i * 2) == -2);
- assert(memcmp(data2 + 129 - i, data1 + 129 - i, i * 2) == 2);
+ check_memcmp(data1 + 128, data2 + 128, i, -2);
+ check_memcmp(data2 + 128, data1 + 128, i, 2);
+ check_memcmp(data1 + 129 - i, data2 + 129 - i, i, -2);
+ check_memcmp(data2 + 129 - i, data1 + 129 - i, i, 2);
+ check_memcmp(data1 + 129 - i, data2 + 129 - i, i * 2, -2);
+ check_memcmp(data2 + 129 - i, data1 + 129 - i, i * 2, 2);
}
memset(data1 + 129, 'A', sizeof(data1) - 129);
memset(data2 + 129, 'Z', sizeof(data2) - 129);
for (i = 1; i < 66; i++) {
- assert(memcmp(data1 + 128, data2 + 128, i) == -2);
- assert(memcmp(data2 + 128, data1 + 128, i) == 2);
- assert(memcmp(data1 + 129 - i, data2 + 129 - i, i) == -2);
- assert(memcmp(data2 + 129 - i, data1 + 129 - i, i) == 2);
- assert(memcmp(data1 + 129 - i, data2 + 129 - i, i * 2) == -2);
- assert(memcmp(data2 + 129 - i, data1 + 129 - i, i * 2) == 2);
+ check_memcmp(data1 + 128, data2 + 128, i, -2);
+ check_memcmp(data2 + 128, data1 + 128, i, 2);
+ check_memcmp(data1 + 129 - i, data2 + 129 - i, i, -2);
+ check_memcmp(data2 + 129 - i, data1 + 129 - i, i, 2);
+ check_memcmp(data1 + 129 - i, data2 + 129 - i, i * 2, -2);
+ check_memcmp(data2 + 129 - i, data1 + 129 - i, i * 2, 2);
}
}
ATF_TP_ADD_TCS(tp)
{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ memcmp_fn = dlsym(dl_handle, "test_" __XSTRING(MEMCMP));
+ if (memcmp_fn == NULL)
+ memcmp_fn = MEMCMP;
ATF_TP_ADD_TC(tp, zero);
ATF_TP_ADD_TC(tp, eq);
diff --git a/lib/libc/tests/string/memrchr_test.c b/lib/libc/tests/string/memrchr_test.c
new file mode 100644
index 000000000000..12f696c9dc1e
--- /dev/null
+++ b/lib/libc/tests/string/memrchr_test.c
@@ -0,0 +1,116 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2023 Robert Clausecker
+ */
+
+#include <sys/cdefs.h>
+
+#include <dlfcn.h>
+#include <limits.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+static void *(*memrchr_fn)(const void *, int, size_t);
+
+ATF_TC_WITHOUT_HEAD(null);
+ATF_TC_BODY(null, tc)
+{
+ ATF_CHECK_EQ(memrchr_fn(NULL, 42, 0), NULL);
+}
+
+ATF_TC_WITHOUT_HEAD(not_found);
+ATF_TC_BODY(not_found, tc)
+{
+ size_t i, j;
+ char buf[1+15+64+1]; /* offset [0..15] + 64 buffer bytes + sentinels */
+
+ buf[0] = 'X';
+ memset(buf + 1, '-', sizeof(buf) - 1);
+
+ for (i = 0; i < 16; i++)
+ for (j = 0; j < 64; j++) {
+ buf[i + j + 1] = 'X';
+ ATF_CHECK_EQ(memrchr_fn(buf + i + 1, 'X', j), NULL);
+ buf[i + j + 1] = '-';
+ }
+}
+
+static void
+do_found_test(char buf[], size_t len, size_t first, size_t second)
+{
+ /* invariant: first <= second */
+
+ buf[first] = 'X';
+ buf[second] = 'X';
+ ATF_CHECK_EQ(memrchr_fn(buf, 'X', len), buf + second);
+ buf[first] = '-';
+ buf[second] = '-';
+}
+
+ATF_TC_WITHOUT_HEAD(found);
+ATF_TC_BODY(found, tc)
+{
+ size_t i, j, k, l;
+ char buf[1+15+64+1];
+
+ buf[0] = 'X';
+ memset(buf + 1, '-', sizeof(buf) - 1);
+
+ for (i = 0; i < 16; i++)
+ for (j = 0; j < 64; j++)
+ for (k = 0; k < j; k++)
+ for (l = 0; l <= k; l++) {
+ buf[i + j + 1] = 'X';
+ do_found_test(buf + i + 1, j, l, k);
+ buf[i + j + 1] = '-';
+ }
+}
+
+/* check that the right character is found */
+static void
+do_values_test(unsigned char buf[], size_t len, size_t i, int c)
+{
+ /* sentinels */
+ buf[-1] = c;
+ buf[len] = c;
+ memset(buf, c + 1, len);
+
+ if (i < len) {
+ buf[i] = c;
+ ATF_CHECK_EQ(memrchr_fn(buf, c, len), buf + i);
+ } else
+ ATF_CHECK_EQ(memrchr_fn(buf, c, len), NULL);
+}
+
+ATF_TC_WITHOUT_HEAD(values);
+ATF_TC_BODY(values, tc)
+{
+ size_t i, j, k;
+ int c;
+ unsigned char buf[1+15+64+1];
+
+ for (i = 0; i < 16; i++)
+ for (j = 0; j < 64; j++)
+ for (k = 0; k <= j; k++)
+ for (c = 0; c <= UCHAR_MAX; c++)
+ do_values_test(buf + i + 1, j, k, c);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ memrchr_fn = dlsym(dl_handle, "test_memrchr");
+ if (memrchr_fn == NULL)
+ memrchr_fn = memrchr;
+
+ ATF_TP_ADD_TC(tp, null);
+ ATF_TP_ADD_TC(tp, not_found);
+ ATF_TP_ADD_TC(tp, found);
+ ATF_TP_ADD_TC(tp, values);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/string/memset_s_test.c b/lib/libc/tests/string/memset_s_test.c
index 90a6958cb369..c822a2ee4554 100644
--- a/lib/libc/tests/string/memset_s_test.c
+++ b/lib/libc/tests/string/memset_s_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/string/memset_test.c b/lib/libc/tests/string/memset_test.c
new file mode 100644
index 000000000000..b898ad5af251
--- /dev/null
+++ b/lib/libc/tests/string/memset_test.c
@@ -0,0 +1,29 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <assert.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(int_char_conv);
+ATF_TC_BODY(int_char_conv, tc)
+{
+ char b[64];
+ int c = 0xDEADBEEF;
+ memset(&b, c, 64);
+ for(int i = 0; i < 64; i++) {
+ assert(b[i] == (char)c);
+ }
+
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, int_char_conv);
+ return (atf_no_error());
+}
+
diff --git a/lib/libc/tests/string/stpncpy_test.c b/lib/libc/tests/string/stpncpy_test.c
index 6602bda0c2a9..8574b2d591be 100644
--- a/lib/libc/tests/string/stpncpy_test.c
+++ b/lib/libc/tests/string/stpncpy_test.c
@@ -1,7 +1,11 @@
/*-
* Copyright (c) 2009 David Schultz <das@FreeBSD.org>
+ * Copyright (c) 2023 The FreeBSD Foundation
* All rights reserved.
*
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -24,16 +28,18 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <assert.h>
+#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atf-c.h>
+static char *(*stpncpy_fn)(char *restrict, const char *restrict, size_t);
+
static char *
makebuf(size_t len, int guard_at_end)
{
@@ -70,7 +76,7 @@ test_stpncpy(const char *s)
dst = makebuf(bufsize, j);
memset(dst, 'X', bufsize);
len = (bufsize < size) ? bufsize : size - 1;
- assert(stpncpy(dst, src, bufsize) == dst+len);
+ assert(stpncpy_fn(dst, src, bufsize) == dst+len);
assert(memcmp(src, dst, len) == 0);
for (x = len; x < bufsize; x++)
assert(dst[x] == '\0');
@@ -79,33 +85,97 @@ test_stpncpy(const char *s)
}
}
-ATF_TC_WITHOUT_HEAD(nul);
-ATF_TC_BODY(nul, tc)
+static void
+test_sentinel(char *dest, char *src, size_t destlen, size_t srclen)
{
+ size_t i;
+ const char *res, *wantres;
+ const char *fail = NULL;
+
+ for (i = 0; i < srclen; i++)
+ /* src will never include (){} */
+ src[i] = '0' + i;
+ src[srclen] = '\0';
+
+ /* source sentinels: not to be copied */
+ src[-1] = '(';
+ src[srclen+1] = ')';
+
+ memset(dest, 0xee, destlen);
+
+ /* destination sentinels: not to be touched */
+ dest[-1] = '{';
+ dest[destlen] = '}';
+
+ wantres = dest + (srclen > destlen ? destlen : srclen);
+ res = stpncpy_fn(dest, src, destlen);
+
+ if (dest[-1] != '{')
+ fail = "start sentinel overwritten";
+ else if (dest[destlen] != '}')
+ fail = "end sentinel overwritten";
+ else if (strncmp(src, dest, destlen) != 0)
+ fail = "string not copied correctly";
+ else if (res != wantres)
+ fail = "incorrect return value";
+ else for (i = srclen; i < destlen; i++)
+ if (dest[i] != '\0') {
+ fail = "incomplete NUL padding";
+ break;
+ }
- test_stpncpy("");
+ if (fail)
+ atf_tc_fail_nonfatal("%s\n"
+ "stpncpy(%p \"%s\", %p \"%s\", %zu) = %p (want %p)\n",
+ fail, dest, dest, src, src, destlen, res, wantres);
}
-ATF_TC_WITHOUT_HEAD(foo);
-ATF_TC_BODY(foo, tc)
+ATF_TC_WITHOUT_HEAD(null);
+ATF_TC_BODY(null, tc)
{
-
- test_stpncpy("foo");
+ ATF_CHECK_EQ(stpncpy_fn(NULL, NULL, 0), NULL);
}
-ATF_TC_WITHOUT_HEAD(glorp);
-ATF_TC_BODY(glorp, tc)
+ATF_TC_WITHOUT_HEAD(bounds);
+ATF_TC_BODY(bounds, tc)
{
+ size_t i;
+ char buf[64+1];
- test_stpncpy("glorp");
+ for (i = 0; i < sizeof(buf) - 1; i++) {
+ buf[i] = ' ' + i;
+ buf[i+1] = '\0';
+ test_stpncpy(buf);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(alignments);
+ATF_TC_BODY(alignments, tc)
+{
+ size_t srcalign, destalign, srclen, destlen;
+ char src[15+3+64]; /* 15 offsets + 64 max length + NUL + sentinels */
+ char dest[15+2+64]; /* 15 offsets + 64 max length + sentinels */
+
+ for (srcalign = 0; srcalign < 16; srcalign++)
+ for (destalign = 0; destalign < 16; destalign++)
+ for (srclen = 0; srclen < 64; srclen++)
+ for (destlen = 0; destlen < 64; destlen++)
+ test_sentinel(dest+destalign+1,
+ src+srcalign+1, destlen, srclen);
}
ATF_TP_ADD_TCS(tp)
{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ stpncpy_fn = dlsym(dl_handle, "test_stpncpy");
+ if (stpncpy_fn == NULL)
+ stpncpy_fn = stpncpy;
- ATF_TP_ADD_TC(tp, nul);
- ATF_TP_ADD_TC(tp, foo);
- ATF_TP_ADD_TC(tp, glorp);
+ ATF_TP_ADD_TC(tp, null);
+ ATF_TP_ADD_TC(tp, bounds);
+ ATF_TP_ADD_TC(tp, alignments);
return (atf_no_error());
}
diff --git a/lib/libc/tests/string/strcmp_test.c b/lib/libc/tests/string/strcmp_test.c
new file mode 100644
index 000000000000..75ebcbcadda2
--- /dev/null
+++ b/lib/libc/tests/string/strcmp_test.c
@@ -0,0 +1,132 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+
+#include <atf-c.h>
+#include <dlfcn.h>
+#include <string.h>
+
+int (*volatile strcmp_fn)(const char *, const char *);
+
+ATF_TC(strcmp_alignments);
+ATF_TC_HEAD(strcmp_alignments, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strcmp(3) with various alignments");
+}
+
+static void
+alignment_testcase(char *a, char *b, int want)
+{
+ int res;
+
+ res = strcmp_fn(a, b);
+ ATF_CHECK_MSG(want == (res > 0) - (res < 0),
+ "strcmp(%p \"%s\", %p \"%s\") = %d != %d",
+ (void *)a, a, (void *)b, b, res, want);
+}
+
+static void
+check_strcmp_alignments(char a[], char b[],
+ size_t a_off, size_t b_off, size_t len, size_t pos)
+{
+ char *a_str, *b_str, a_orig, b_orig;
+
+ a[a_off] = '\0';
+ b[b_off] = '\0';
+
+ a_str = a + a_off + 1;
+ b_str = b + b_off + 1;
+
+ a_str[len] = '\0';
+ b_str[len] = '\0';
+ a_str[len+1] = 'A';
+ b_str[len+1] = 'B';
+
+ a_orig = a_str[pos];
+ b_orig = b_str[pos];
+
+ alignment_testcase(a_str, b_str, 0);
+
+ if (pos < len) {
+ a_str[pos] = '\0';
+ alignment_testcase(a_str, b_str, -1);
+ a_str[pos] = a_orig;
+ b_str[pos] = '\0';
+ alignment_testcase(a_str, b_str, 1);
+ b_str[pos] = b_orig;
+ }
+
+ a_str[pos] = 'X';
+ alignment_testcase(a_str, b_str, 1);
+ a_str[pos] = a_orig;
+ b_str[pos] = 'X';
+ alignment_testcase(a_str, b_str, -1);
+ b_str[pos] = b_orig;
+
+ a[a_off] = '-';
+ b[b_off] = '-';
+ a_str[len] = '-';
+ b_str[len] = '-';
+ a_str[len+1] = '-';
+ b_str[len+1] = '-';
+}
+
+ATF_TC_BODY(strcmp_alignments, tc)
+{
+ size_t a_off, b_off, len, pos;
+ /* 16B alignment offset + 64B buffer + sentinel before/after + NUL */
+ char a[64+16+3], b[64+16+3];
+
+ memset(a, '-', sizeof(a));
+ memset(b, '-', sizeof(b));
+ a[sizeof(a) - 1] = '\0';
+ b[sizeof(b) - 1] = '\0';
+
+ /* check alignment offsets relevant for SSE routines */
+ for (a_off = 0; a_off < 16; a_off++)
+ for (b_off = 0; b_off < 16; b_off++)
+ /* ensure main loop (@ 32B) is completed at least once */
+ for (len = 1; len <= 64; len++)
+ for (pos = 0; pos <= len; pos++)
+ check_strcmp_alignments(a, b, a_off, b_off, len, pos);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strcmp_fn = dlsym(dl_handle, "test_strcmp");
+ if (strcmp_fn == NULL)
+ strcmp_fn = strcmp;
+
+ ATF_TP_ADD_TC(tp, strcmp_alignments);
+
+ return atf_no_error();
+}
diff --git a/lib/libc/tests/string/strcspn_test.c b/lib/libc/tests/string/strcspn_test.c
new file mode 100644
index 000000000000..293fc2bc8d4e
--- /dev/null
+++ b/lib/libc/tests/string/strcspn_test.c
@@ -0,0 +1,269 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+
+#include <atf-c.h>
+#include <assert.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <string.h>
+
+enum {
+ MAXALIGN = 16, /* test all offsets from this alignment */
+ MAXBUF = 64, /* test up to this buffer length */
+};
+
+enum { NOMATCH, MATCH };
+
+#ifdef STRSPN
+#define STRXSPN strspn
+#else
+#define STRXSPN strcspn
+#endif
+
+static void
+testcase(char *buf, size_t buflen, char *set, size_t setlen, int want_match)
+{
+ size_t i, outcome, expected;
+
+ assert(setlen < UCHAR_MAX - 2);
+
+ for (i = 0; i < buflen; i++)
+#ifdef STRSPN
+ buf[i] = UCHAR_MAX - i % (setlen > 0 ? setlen : 1);
+#else /* strcspn */
+ buf[i] = 1 + i % (UCHAR_MAX - setlen - 1);
+#endif
+
+ buf[i] = '\0';
+
+ for (i = 0; i < setlen; i++)
+ set[i] = UCHAR_MAX - i;
+
+ set[i] = '\0';
+
+#ifdef STRSPN
+ if (setlen == 0)
+ expected = 0;
+ else if (want_match == MATCH && buflen > 0) {
+ buf[buflen - 1] = 1;
+ expected = buflen - 1;
+ } else
+ expected = buflen;
+#else /* strcspn */
+ if (want_match == MATCH && buflen > 0 && setlen > 0) {
+ buf[buflen - 1] = UCHAR_MAX;
+ expected = buflen - 1;
+ } else
+ expected = buflen;
+#endif
+
+ outcome = STRXSPN(buf, set);
+ ATF_CHECK_EQ_MSG(expected, outcome, "%s(%p[%zu], %p[%zu]) = %zu != %zu",
+ __XSTRING(STRXSPN), buf, buflen, set, setlen, outcome, expected);
+}
+
+/* test set with all alignments and lengths of buf */
+static void
+test_buf_alignments(char *set, size_t setlen, int want_match)
+{
+ char buf[MAXALIGN + MAXBUF + 1];
+ size_t i, j;
+
+ for (i = 0; i < MAXALIGN; i++)
+ for (j = 0; j <= MAXBUF; j++)
+ testcase(buf + i, j, set, setlen, want_match);
+}
+
+/* test buf with all alignments and lengths of set */
+static void
+test_set_alignments(char *buf, size_t buflen, int want_match)
+{
+ char set[MAXALIGN + MAXBUF + 1];
+ size_t i, j;
+
+ for (i = 0; i < MAXALIGN; i++)
+ for (j = 0; j <= MAXBUF; j++)
+ testcase(buf, buflen, set + i, j, want_match);
+}
+
+ATF_TC_WITHOUT_HEAD(buf_alignments);
+ATF_TC_BODY(buf_alignments, tc)
+{
+ char set[41];
+
+ test_buf_alignments(set, 0, MATCH);
+ test_buf_alignments(set, 1, MATCH);
+ test_buf_alignments(set, 5, MATCH);
+ test_buf_alignments(set, 20, MATCH);
+ test_buf_alignments(set, 40, MATCH);
+
+ test_buf_alignments(set, 0, NOMATCH);
+ test_buf_alignments(set, 1, NOMATCH);
+ test_buf_alignments(set, 5, NOMATCH);
+ test_buf_alignments(set, 20, NOMATCH);
+ test_buf_alignments(set, 40, NOMATCH);
+}
+
+ATF_TC_WITHOUT_HEAD(set_alignments);
+ATF_TC_BODY(set_alignments, tc)
+{
+ char buf[31];
+
+ test_set_alignments(buf, 0, MATCH);
+ test_set_alignments(buf, 10, MATCH);
+ test_set_alignments(buf, 20, MATCH);
+ test_set_alignments(buf, 30, MATCH);
+
+ test_set_alignments(buf, 0, NOMATCH);
+ test_set_alignments(buf, 10, NOMATCH);
+ test_set_alignments(buf, 20, NOMATCH);
+ test_set_alignments(buf, 30, NOMATCH);
+}
+
+#ifndef STRSPN
+/* test all positions in which set could match buf */
+static void
+test_match_positions(char *buf, char *set, size_t buflen, size_t setlen)
+{
+ size_t i, j, outcome;
+
+ memset(buf, '-', buflen);
+
+ for (i = 0; i < setlen; i++)
+ set[i] = 'A' + i;
+
+ buf[buflen] = '\0';
+ set[setlen] = '\0';
+
+ /*
+ * Check for (mis)match at buffer position i
+ * against set position j.
+ */
+ for (i = 0; i < buflen; i++) {
+ for (j = 0; j < setlen; j++) {
+ buf[i] = set[j];
+
+ outcome = strcspn(buf, set);
+ ATF_CHECK_EQ_MSG(i, outcome,
+ "strcspn(\"%s\", \"%s\") = %zu != %zu",
+ buf, set, outcome, i);
+ }
+
+ buf[i] = '-';
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(match_positions);
+ATF_TC_BODY(match_positions, tc)
+{
+ char buf[129], set[65];
+
+ test_match_positions(buf, set, 128, 64);
+ test_match_positions(buf, set, 64, 64);
+ test_match_positions(buf, set, 32, 64);
+ test_match_positions(buf, set, 16, 64);
+ test_match_positions(buf, set, 8, 64);
+ test_match_positions(buf, set, 128, 32);
+ test_match_positions(buf, set, 64, 32);
+ test_match_positions(buf, set, 32, 32);
+ test_match_positions(buf, set, 16, 32);
+ test_match_positions(buf, set, 8, 32);
+ test_match_positions(buf, set, 128, 16);
+ test_match_positions(buf, set, 64, 16);
+ test_match_positions(buf, set, 32, 16);
+ test_match_positions(buf, set, 16, 16);
+ test_match_positions(buf, set, 8, 16);
+ test_match_positions(buf, set, 128, 8);
+ test_match_positions(buf, set, 64, 8);
+ test_match_positions(buf, set, 32, 8);
+ test_match_positions(buf, set, 16, 8);
+ test_match_positions(buf, set, 8, 8);
+}
+
+/* if there are two matches, check that the earlier match is taken */
+static void
+test_match_order(char *buf, char *set, size_t buflen, size_t setlen)
+{
+ size_t i, j, k, l, outcome;
+
+ memset(buf, '-', buflen);
+
+ for (i = 0; i < setlen; i++)
+ set[i] = 'A' + i;
+
+ buf[buflen] = '\0';
+ set[setlen] = '\0';
+
+ for (i = 0; i < setlen; i++)
+ for (j = 0; j < setlen; j++)
+ for (k = 0; k + 1 < buflen; k++)
+ for (l = k + 1; l < buflen; l++) {
+ buf[k] = set[i];
+ buf[l] = set[j];
+ outcome = strcspn(buf, set);
+ ATF_CHECK_EQ_MSG(k, outcome,
+ "strcspn(\"%s\", \"%s\") = %zu != %zu",
+ buf, set, outcome, k);
+ buf[k] = '-';
+ buf[l] = '-';
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(match_order);
+ATF_TC_BODY(match_order, tc)
+{
+ char buf[33], set[65];
+
+ test_match_order(buf, set, 32, 64);
+ test_match_order(buf, set, 16, 64);
+ test_match_order(buf, set, 8, 64);
+ test_match_order(buf, set, 32, 32);
+ test_match_order(buf, set, 16, 32);
+ test_match_order(buf, set, 8, 32);
+ test_match_order(buf, set, 32, 16);
+ test_match_order(buf, set, 16, 16);
+ test_match_order(buf, set, 8, 16);
+ test_match_order(buf, set, 32, 8);
+ test_match_order(buf, set, 16, 8);
+ test_match_order(buf, set, 8, 8);
+}
+#endif /* !defined(STRSPN) */
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, buf_alignments);
+ ATF_TP_ADD_TC(tp, set_alignments);
+#ifndef STRSPN
+ ATF_TP_ADD_TC(tp, match_positions);
+ ATF_TP_ADD_TC(tp, match_order);
+#endif
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/string/strlcpy_test.c b/lib/libc/tests/string/strlcpy_test.c
new file mode 100644
index 000000000000..646bef42683e
--- /dev/null
+++ b/lib/libc/tests/string/strlcpy_test.c
@@ -0,0 +1,183 @@
+/*-
+ * Copyright (c) 2009 David Schultz <das@FreeBSD.org>
+ * Copyright (c) 2023 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Robert Clausecker
+ * <fuz@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <assert.h>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <atf-c.h>
+
+size_t (*strlcpy_fn)(char *restrict, const char *restrict, size_t);
+
+static char *
+makebuf(size_t len, int guard_at_end)
+{
+ char *buf;
+ size_t alloc_size, page_size;
+
+ page_size = getpagesize();
+ alloc_size = roundup2(len, page_size) + page_size;
+
+ buf = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
+ assert(buf);
+ if (guard_at_end) {
+ assert(munmap(buf + alloc_size - page_size, page_size) == 0);
+ return (buf + alloc_size - page_size - len);
+ } else {
+ assert(munmap(buf, page_size) == 0);
+ return (buf + page_size);
+ }
+}
+
+static void
+test_strlcpy(const char *s)
+{
+ char *src, *dst;
+ size_t size, bufsize, x;
+ int i, j;
+
+ size = strlen(s) + 1;
+ for (i = 0; i <= 1; i++) {
+ for (j = 0; j <= 1; j++) {
+ for (bufsize = 0; bufsize <= size + 10; bufsize++) {
+ src = makebuf(size, i);
+ memcpy(src, s, size);
+ dst = makebuf(bufsize, j);
+ memset(dst, 'X', bufsize);
+ assert(strlcpy_fn(dst, src, bufsize) == size-1);
+ assert(bufsize == 0 || strncmp(src, dst, bufsize - 1) == 0);
+ for (x = size; x < bufsize; x++)
+ assert(dst[x] == 'X');
+ }
+ }
+ }
+}
+
+static void
+test_sentinel(char *dest, char *src, size_t destlen, size_t srclen)
+{
+ size_t i;
+ size_t res, wantres;
+ const char *fail = NULL;
+
+ for (i = 0; i < srclen; i++)
+ /* src will never include (){} */
+ src[i] = '0' + i;
+ src[srclen] = '\0';
+
+ /* source sentinels: not to be copied */
+ src[-1] = '(';
+ src[srclen+1] = ')';
+
+ memset(dest, '\xee', destlen);
+
+ /* destination sentinels: not to be touched */
+ dest[-1] = '{';
+ dest[destlen] = '}';
+
+ wantres = srclen;
+ res = strlcpy_fn(dest, src, destlen);
+
+ if (dest[-1] != '{')
+ fail = "start sentinel overwritten";
+ else if (dest[destlen] != '}')
+ fail = "end sentinel overwritten";
+ else if (res != wantres)
+ fail = "incorrect return value";
+ else if (destlen > 0 && strncmp(src, dest, destlen - 1) != 0)
+ fail = "string not copied correctly";
+ else if (destlen > 0 && srclen >= destlen - 1 && dest[destlen-1] != '\0')
+ fail = "string not NUL terminated";
+ else for (i = srclen + 1; i < destlen; i++)
+ if (dest[i] != '\xee') {
+ fail = "buffer mutilated behind string";
+ break;
+ }
+
+ if (fail)
+ atf_tc_fail_nonfatal("%s\n"
+ "strlcpy(%p \"%s\", %p \"%s\", %zu) = %zu (want %zu)\n",
+ fail, dest, dest, src, src, destlen, res, wantres);
+}
+
+ATF_TC_WITHOUT_HEAD(null);
+ATF_TC_BODY(null, tc)
+{
+ ATF_CHECK_EQ(strlcpy_fn(NULL, "foo", 0), 3);
+}
+
+ATF_TC_WITHOUT_HEAD(bounds);
+ATF_TC_BODY(bounds, tc)
+{
+ size_t i;
+ char buf[64+1];
+
+ for (i = 0; i < sizeof(buf) - 1; i++) {
+ buf[i] = ' ' + i;
+ buf[i+1] = '\0';
+ test_strlcpy(buf);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(alignments);
+ATF_TC_BODY(alignments, tc)
+{
+ size_t srcalign, destalign, srclen, destlen;
+ char src[15+3+64]; /* 15 offsets + 64 max length + NUL + sentinels */
+ char dest[15+2+64]; /* 15 offsets + 64 max length + sentinels */
+
+ for (srcalign = 0; srcalign < 16; srcalign++)
+ for (destalign = 0; destalign < 16; destalign++)
+ for (srclen = 0; srclen < 64; srclen++)
+ for (destlen = 0; destlen < 64; destlen++)
+ test_sentinel(dest+destalign+1,
+ src+srcalign+1, destlen, srclen);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strlcpy_fn = dlsym(dl_handle, "test_strlcpy");
+ if (strlcpy_fn == NULL)
+ strlcpy_fn = strlcpy;
+
+ ATF_TP_ADD_TC(tp, null);
+ ATF_TP_ADD_TC(tp, bounds);
+ ATF_TP_ADD_TC(tp, alignments);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/string/strncmp_test.c b/lib/libc/tests/string/strncmp_test.c
new file mode 100644
index 000000000000..989c58bcfedf
--- /dev/null
+++ b/lib/libc/tests/string/strncmp_test.c
@@ -0,0 +1,165 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#include <sys/cdefs.h>
+
+#include <atf-c.h>
+#include <dlfcn.h>
+#include <string.h>
+
+int (*volatile strncmp_fn)(const char *, const char *, size_t);
+
+static void
+alignment_testcase(char *a, char *b, int want, size_t len)
+{
+ int res;
+
+ res = strncmp_fn(a, b, len);
+ ATF_CHECK_MSG(want == (res > 0) - (res < 0),
+ "strcmp(%p \"%s\", %p \"%s\", %zu) = %d != %d",
+ (void *)a, a, (void *)b, b, len, res, want);
+}
+
+static void
+check_strncmp_alignments(char a[], char b[],
+ size_t a_off, size_t b_off, size_t len, size_t pos)
+{
+ char *a_str, *b_str, a_orig, b_orig;
+
+ a[a_off] = '\0';
+ b[b_off] = '\0';
+
+ a_str = a + a_off + 1;
+ b_str = b + b_off + 1;
+
+ a_str[len] = '\0';
+ b_str[len] = '\0';
+ a_str[len+1] = 'A';
+ b_str[len+1] = 'B';
+
+ a_orig = a_str[pos];
+ b_orig = b_str[pos];
+
+ alignment_testcase(a_str, b_str, 0, len + 16);
+ alignment_testcase(a_str, b_str, 0, len + 1);
+ alignment_testcase(a_str, b_str, 0, len);
+
+ if (pos < len) {
+ a_str[pos] = '\0';
+ alignment_testcase(a_str, b_str, -1, len + 16);
+ alignment_testcase(a_str, b_str, -1, len + 1);
+ alignment_testcase(a_str, b_str, -1, len);
+ alignment_testcase(a_str, b_str, -1, pos + 1);
+ alignment_testcase(a_str, b_str, 0, pos);
+ a_str[pos] = a_orig;
+
+ b_str[pos] = '\0';
+ alignment_testcase(a_str, b_str, 1, len + 16);
+ alignment_testcase(a_str, b_str, 1, len + 1);
+ alignment_testcase(a_str, b_str, 1, len);
+ alignment_testcase(a_str, b_str, 1, pos + 1);
+ alignment_testcase(a_str, b_str, 0, pos);
+ b_str[pos] = b_orig;
+ }
+
+ a_str[pos] = 'X';
+ alignment_testcase(a_str, b_str, 1, len + 16);
+ alignment_testcase(a_str, b_str, 0, pos);
+ alignment_testcase(a_str, b_str, 1, pos + 1);
+ if (pos < len) {
+ alignment_testcase(a_str, b_str, 1, len);
+ alignment_testcase(a_str, b_str, 1, len + 1);
+ }
+ a_str[pos] = a_orig;
+
+ b_str[pos] = 'X';
+ alignment_testcase(a_str, b_str, -1, len + 16);
+ alignment_testcase(a_str, b_str, 0, pos);
+ alignment_testcase(a_str, b_str, -1, pos + 1);
+ if (pos < len) {
+ alignment_testcase(a_str, b_str, -1, len);
+ alignment_testcase(a_str, b_str, -1, len + 1);
+ }
+ b_str[pos] = b_orig;
+
+ a[a_off] = '-';
+ b[b_off] = '-';
+ a_str[len] = '-';
+ b_str[len] = '-';
+ a_str[len+1] = '-';
+ b_str[len+1] = '-';
+}
+
+ATF_TC(strncmp_alignments);
+ATF_TC_HEAD(strncmp_alignments, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strncmp(3) with various alignments");
+}
+
+ATF_TC_BODY(strncmp_alignments, tc)
+{
+ size_t a_off, b_off, len, pos;
+ char a[64+16+16+3], b[64+16+16+3];
+
+ memset(a, '-', sizeof(a));
+ memset(b, '-', sizeof(b));
+ a[sizeof(a) - 1] = '\0';
+ b[sizeof(b) - 1] = '\0';
+
+ for (a_off = 0; a_off < 16; a_off++)
+ for (b_off = 0; b_off < 16; b_off++)
+ for (len = 1; len <= 64; len++)
+ for (pos = 0; pos <= len; pos++)
+ check_strncmp_alignments(a, b, a_off, b_off, len, pos);
+}
+
+ATF_TC(strncmp_null);
+ATF_TC_HEAD(strncmp_null, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strncmp(3) with null pointers");
+}
+
+ATF_TC_BODY(strncmp_null, tc)
+{
+ alignment_testcase(NULL, NULL, 0, 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strncmp_fn = dlsym(dl_handle, "test_strncmp");
+ if (strncmp_fn == NULL)
+ strncmp_fn = strncmp;
+
+ ATF_TP_ADD_TC(tp, strncmp_alignments);
+ ATF_TP_ADD_TC(tp, strncmp_null);
+
+ return atf_no_error();
+}
diff --git a/lib/libc/tests/string/strnlen_test.c b/lib/libc/tests/string/strnlen_test.c
new file mode 100644
index 000000000000..31c2384bb30f
--- /dev/null
+++ b/lib/libc/tests/string/strnlen_test.c
@@ -0,0 +1,141 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdalign.h>
+#include <stdint.h>
+
+#include <atf-c.h>
+
+ATF_TC(strnlen_alignments);
+ATF_TC_HEAD(strnlen_alignments, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strnlen(3) with different alignments");
+}
+
+ATF_TC_BODY(strnlen_alignments, tc)
+{
+ size_t (*strnlen_fn)(const char*, size_t) = strnlen;
+ char alignas(16) buffer[1 + 16 + 64 + 1 + 1];
+
+ memset(buffer, '/', sizeof(buffer));
+
+ for (int align = 1; align < 1 + 16; align++) {
+ char *s = buffer + align;
+
+ for (size_t maxlen = 0; maxlen <= 64; maxlen++) {
+ for (size_t len = 0; len <= maxlen; len++) {
+ /* returns length */
+
+ /* without sentinels */
+ s[len] = '\0';
+ size_t val = strnlen_fn(s, maxlen);
+ if (val != len) {
+ fprintf(stderr, "align = %d, maxlen = %zu, len = %zu",
+ align, maxlen, len);
+ atf_tc_fail("returned incorrect len");
+ }
+
+ /* with sentinels */
+ s[-1] = '\0';
+ s[maxlen + 1] = '\0';
+ val = strnlen_fn(s, maxlen);
+ if (val != len) {
+ fprintf(stderr, "align = %d, maxlen = %zu, len = %zu",
+ align, maxlen, len);
+ atf_tc_fail("returned incorrect len (sentinels)");
+ }
+
+ /* cleanup */
+ s[-1] = '/';
+ s[len] = '/';
+ s[maxlen + 1] = '/';
+
+ }
+
+ /* returns maxlen */
+
+ /* without sentinels */
+ size_t val = strnlen_fn(s, maxlen);
+ if (val != maxlen) {
+ fprintf(stderr, "align = %d, maxlen = %zu",
+ align, maxlen);
+ atf_tc_fail("should return maxlen");
+ }
+
+ /* with sentinels */
+ s[-1] = '\0';
+ s[maxlen + 1] = '\0';
+ val = strnlen_fn(s, maxlen);
+ if (val != maxlen) {
+ fprintf(stderr, "align = %d, maxlen = %zu",
+ align, maxlen);
+ atf_tc_fail("should return maxlen (sentinels)");
+ }
+
+ /* cleanup */
+ s[-1] = '/';
+ s[maxlen + 1] = '/';
+ }
+ }
+}
+
+ATF_TC(strnlen_size_max);
+ATF_TC_HEAD(strnlen_size_max, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strnlen(3) with maxlen=SIZE_MAX");
+}
+
+ATF_TC_BODY(strnlen_size_max, tc)
+{
+ size_t (*strnlen_fn)(const char*, size_t) = strnlen;
+ char alignas(16) buffer[1 + 16 + 64 + 1 + 1];
+
+ memset(buffer, '/', sizeof(buffer));
+
+ for (int align = 1; align < 1 + 16; align++) {
+ char* s = buffer + align;
+
+ for (size_t len = 0; len <= 64; len++) {
+ /* returns length */
+
+ /* without sentinels */
+ s[len] = '\0';
+ size_t val = strnlen_fn(s, SIZE_MAX);
+ if (val != len) {
+ fprintf(stderr, "align = %d, maxlen = %zu, len = %zu",
+ align, SIZE_MAX, len);
+ atf_tc_fail("returned incorrect len (SIZE_MAX)");
+ }
+
+ /* with sentinels */
+ s[-1] = '\0';
+ val = strnlen_fn(s, SIZE_MAX);
+ if (val != len) {
+ fprintf(stderr, "align = %d, maxlen = %zu, len = %zu",
+ align, SIZE_MAX, len);
+ atf_tc_fail("returned incorrect len (sentinels) (SIZE_MAX)");
+ }
+
+ /* cleanup */
+ s[-1] = '/';
+ s[len] = '/';
+ }
+ }
+}
+
+
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, strnlen_alignments);
+ ATF_TP_ADD_TC(tp, strnlen_size_max);
+
+ return atf_no_error();
+}
diff --git a/lib/libc/tests/string/strspn_test.c b/lib/libc/tests/string/strspn_test.c
new file mode 100644
index 000000000000..73a08ddefa1b
--- /dev/null
+++ b/lib/libc/tests/string/strspn_test.c
@@ -0,0 +1,30 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#define STRSPN
+#include "strcspn_test.c"
diff --git a/lib/libc/tests/string/strxfrm_test.c b/lib/libc/tests/string/strxfrm_test.c
index 3c2ab58cb72b..becc620ba79c 100644
--- a/lib/libc/tests/string/strxfrm_test.c
+++ b/lib/libc/tests/string/strxfrm_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <string.h>
#include <locale.h>
#include <stdio.h>
diff --git a/lib/libc/tests/string/timingsafe_bcmp_test.c b/lib/libc/tests/string/timingsafe_bcmp_test.c
new file mode 100644
index 000000000000..96bf789633f2
--- /dev/null
+++ b/lib/libc/tests/string/timingsafe_bcmp_test.c
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#define MEMCMP timingsafe_bcmp
+#define RES(x) ((x) != 0)
+
+#include "memcmp_test.c"
diff --git a/lib/libc/tests/string/timingsafe_memcmp_test.c b/lib/libc/tests/string/timingsafe_memcmp_test.c
new file mode 100644
index 000000000000..5f97e41fcf8a
--- /dev/null
+++ b/lib/libc/tests/string/timingsafe_memcmp_test.c
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2023 The FreeBSD Foundation
+ *
+ * This software was developed by Robert Clausecker <fuz@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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
+ */
+
+#define MEMCMP timingsafe_memcmp
+#define RES(x) (((x) > 0) - ((x) < 0))
+
+#include "memcmp_test.c"
diff --git a/lib/libc/tests/string/wcscasecmp_test.c b/lib/libc/tests/string/wcscasecmp_test.c
index 5927345e7f4a..9a47c0d91b31 100644
--- a/lib/libc/tests/string/wcscasecmp_test.c
+++ b/lib/libc/tests/string/wcscasecmp_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <assert.h>
#include <locale.h>
#include <stdio.h>
diff --git a/lib/libc/tests/string/wcscoll_test.c b/lib/libc/tests/string/wcscoll_test.c
index d64e03f0605a..2ce85bbb986b 100644
--- a/lib/libc/tests/string/wcscoll_test.c
+++ b/lib/libc/tests/string/wcscoll_test.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <wchar.h>
#include <locale.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/string/wcsnlen_test.c b/lib/libc/tests/string/wcsnlen_test.c
index 56a2ef1e3623..ba2e1c8d7c57 100644
--- a/lib/libc/tests/string/wcsnlen_test.c
+++ b/lib/libc/tests/string/wcsnlen_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <assert.h>
diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile
index f44cec11225d..88f8191a16eb 100644
--- a/lib/libc/tests/sys/Makefile
+++ b/lib/libc/tests/sys/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
.include <bsd.own.mk>
@@ -7,11 +6,12 @@ PACKAGE= tests
ATF_TESTS_C+= brk_test
.endif
ATF_TESTS_C+= cpuset_test
+ATF_TESTS_C+= errno_test
+ATF_TESTS_C+= swapcontext_test
ATF_TESTS_C+= queue_test
ATF_TESTS_C+= sendfile_test
-# TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg,
-# swapcontext
+# TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg
NETBSD_ATF_TESTS_C+= access_test
NETBSD_ATF_TESTS_C+= bind_test
NETBSD_ATF_TESTS_C+= chroot_test
diff --git a/lib/libc/tests/sys/brk_test.c b/lib/libc/tests/sys/brk_test.c
index 38093b4cbd29..2d8c7af38ff7 100644
--- a/lib/libc/tests/sys/brk_test.c
+++ b/lib/libc/tests/sys/brk_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mman.h>
diff --git a/lib/libc/tests/sys/cpuset_test.c b/lib/libc/tests/sys/cpuset_test.c
index 52c0dc877ab8..53d6a8215bbc 100644
--- a/lib/libc/tests/sys/cpuset_test.c
+++ b/lib/libc/tests/sys/cpuset_test.c
@@ -25,9 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD");
-
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/jail.h>
diff --git a/lib/libc/tests/sys/errno_test.c b/lib/libc/tests/sys/errno_test.c
new file mode 100644
index 000000000000..27d0548fc29d
--- /dev/null
+++ b/lib/libc/tests/sys/errno_test.c
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2024 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+ATF_TC(errno_basic);
+ATF_TC_HEAD(errno_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic functionality of errno");
+}
+
+ATF_TC_BODY(errno_basic, tc)
+{
+ int res;
+
+ res = unlink("/non/existent/file");
+ ATF_REQUIRE(res == -1);
+ ATF_REQUIRE(errno == ENOENT);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, errno_basic);
+
+ return (atf_no_error());
+}
diff --git a/lib/libc/tests/sys/mlock_helper.c b/lib/libc/tests/sys/mlock_helper.c
index 31471b2b281c..e7a3d5e39c3f 100644
--- a/lib/libc/tests/sys/mlock_helper.c
+++ b/lib/libc/tests/sys/mlock_helper.c
@@ -28,7 +28,6 @@
* Helper for mlock(3) to avoid EAGAIN errors
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
diff --git a/lib/libc/tests/sys/queue_test.c b/lib/libc/tests/sys/queue_test.c
index 8db5b5cae7b6..cfe9ac934cbd 100644
--- a/lib/libc/tests/sys/queue_test.c
+++ b/lib/libc/tests/sys/queue_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/sys/sendfile_test.c b/lib/libc/tests/sys/sendfile_test.c
index cfa885d1e8e3..d46e7b0cb186 100644
--- a/lib/libc/tests/sys/sendfile_test.c
+++ b/lib/libc/tests/sys/sendfile_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/socket.h>
diff --git a/lib/libc/tests/sys/swapcontext_test.c b/lib/libc/tests/sys/swapcontext_test.c
new file mode 100644
index 000000000000..f341a746e515
--- /dev/null
+++ b/lib/libc/tests/sys/swapcontext_test.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2025 Raptor Computing Systems, LLC
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ucontext.h>
+#include <errno.h>
+
+#include <atf-c.h>
+
+#define STACK_SIZE (64ull << 10)
+
+static volatile int callback_reached = 0;
+
+static ucontext_t uctx_save, uctx_switch;
+
+static void swapcontext_callback()
+{
+ // Increment callback reached variable
+ // If this is called multiple times, we will fail the test
+ // If this is not called at all, we will fail the test
+ callback_reached++;
+}
+
+ATF_TC(swapcontext_basic);
+ATF_TC_HEAD(swapcontext_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify basic functionality of swapcontext");
+}
+
+ATF_TC_BODY(swapcontext_basic, tc)
+{
+ char *stack;
+ int res;
+
+ stack = malloc(STACK_SIZE);
+ ATF_REQUIRE_MSG(stack != NULL, "malloc failed: %s", strerror(errno));
+ res = getcontext(&uctx_switch);
+ ATF_REQUIRE_MSG(res == 0, "getcontext failed: %s", strerror(errno));
+
+ uctx_switch.uc_stack.ss_sp = stack;
+ uctx_switch.uc_stack.ss_size = STACK_SIZE;
+ uctx_switch.uc_link = &uctx_save;
+ makecontext(&uctx_switch, swapcontext_callback, 0);
+
+ res = swapcontext(&uctx_save, &uctx_switch);
+
+ ATF_REQUIRE_MSG(res == 0, "swapcontext failed: %s", strerror(errno));
+ ATF_REQUIRE_MSG(callback_reached == 1,
+ "callback failed, reached %d times", callback_reached);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, swapcontext_basic);
+
+ return (atf_no_error());
+}
+
diff --git a/lib/libc/tests/termios/Makefile b/lib/libc/tests/termios/Makefile
index 4900f0067ce0..76879b805035 100644
--- a/lib/libc/tests/termios/Makefile
+++ b/lib/libc/tests/termios/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
NETBSD_ATF_TESTS_C= tcsetpgrp_test
diff --git a/lib/libc/tests/time/Makefile b/lib/libc/tests/time/Makefile
index ac6d3bc55be0..9e0230a70f54 100644
--- a/lib/libc/tests/time/Makefile
+++ b/lib/libc/tests/time/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
NETBSD_ATF_TESTS_C= mktime_test
diff --git a/lib/libc/tests/tls/Makefile b/lib/libc/tests/tls/Makefile
index dc0fbb4c90aa..6d53493f56f5 100644
--- a/lib/libc/tests/tls/Makefile
+++ b/lib/libc/tests/tls/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
.if !defined(NO_PIC)
diff --git a/lib/libc/tests/tls/dso/Makefile b/lib/libc/tests/tls/dso/Makefile
index ec996105f4d3..5efd8b29a6bd 100644
--- a/lib/libc/tests/tls/dso/Makefile
+++ b/lib/libc/tests/tls/dso/Makefile
@@ -1,4 +1,3 @@
-
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/tls/${.CURDIR:T}
LIB= h_tls_dlopen
@@ -6,6 +5,7 @@ SHLIB_NAME= h_tls_dlopen.so
SRCS= h_tls_dlopen.c
MAN=
+PACKAGE= tests
LIBDIR= ${TESTSBASE}/lib/libc/tls
SHLIB_MAJOR= 1
diff --git a/lib/libc/tests/tls_dso/Makefile b/lib/libc/tests/tls_dso/Makefile
index 403d789a01f7..89296c643695 100644
--- a/lib/libc/tests/tls_dso/Makefile
+++ b/lib/libc/tests/tls_dso/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
LIB= h_tls_dynamic
@@ -7,6 +6,7 @@ SRCS= h_tls_dynamic.c
LIBDIR= ${TESTSBASE}/lib/libc/tls
SHLIBDIR= ${TESTSBASE}/lib/libc/tls
SHLIB_MAJOR= 1
+PACKAGE= tests
WITHOUT_STATIC=
WITHOUT_PROFILE=
diff --git a/lib/libc/tests/ttyio/Makefile b/lib/libc/tests/ttyio/Makefile
index 79ec9a4039e5..2d2dda2f854f 100644
--- a/lib/libc/tests/ttyio/Makefile
+++ b/lib/libc/tests/ttyio/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
# TODO: ptm_test
diff --git a/lib/libc/uuid/Makefile.inc b/lib/libc/uuid/Makefile.inc
index d9c8b0a6083d..d887bf816262 100644
--- a/lib/libc/uuid/Makefile.inc
+++ b/lib/libc/uuid/Makefile.inc
@@ -1,4 +1,3 @@
-
# DCE 1.1 UUID implementation sources
.PATH: ${LIBC_SRCTOP}/uuid
diff --git a/lib/libc/uuid/Symbol.map b/lib/libc/uuid/Symbol.map
index 49fb239913d2..e1e587199a92 100644
--- a/lib/libc/uuid/Symbol.map
+++ b/lib/libc/uuid/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
uuid_to_string;
uuid_is_nil;
diff --git a/lib/libc/uuid/uuid.3 b/lib/libc/uuid/uuid.3
index 42f7a4b43ccd..1cfd3a86ad91 100644
--- a/lib/libc/uuid/uuid.3
+++ b/lib/libc/uuid/uuid.3
@@ -27,8 +27,14 @@
.Dt UUID 3
.Os
.Sh NAME
-.Nm uuid_compare , uuid_create , uuid_create_nil , uuid_equal ,
-.Nm uuid_from_string , uuid_hash , uuid_is_nil , uuid_to_string
+.Nm uuid_compare ,
+.Nm uuid_create ,
+.Nm uuid_create_nil ,
+.Nm uuid_equal ,
+.Nm uuid_from_string ,
+.Nm uuid_hash ,
+.Nm uuid_is_nil ,
+.Nm uuid_to_string
.Nd DCE 1.1 compliant UUID functions
.Sh LIBRARY
.Lb libc
diff --git a/lib/libc/uuid/uuid_stream.c b/lib/libc/uuid/uuid_stream.c
index 996b74de3250..cd5a35655f0f 100644
--- a/lib/libc/uuid/uuid_stream.c
+++ b/lib/libc/uuid/uuid_stream.c
@@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/endian.h>
#include <uuid.h>
diff --git a/lib/libc/x86/gen/Makefile.inc b/lib/libc/x86/gen/Makefile.inc
index 7449ef52fa61..c2ff1ffb0014 100644
--- a/lib/libc/x86/gen/Makefile.inc
+++ b/lib/libc/x86/gen/Makefile.inc
@@ -1,4 +1,3 @@
-
.PATH: ${LIBC_SRCTOP}/x86/gen
SRCS+= \
diff --git a/lib/libc/x86/gen/getcontextx.c b/lib/libc/x86/gen/getcontextx.c
index d50180a8ac6c..7373ae7395b9 100644
--- a/lib/libc/x86/gen/getcontextx.c
+++ b/lib/libc/x86/gen/getcontextx.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ucontext.h>
#include <errno.h>
diff --git a/lib/libc/x86/sys/Makefile.inc b/lib/libc/x86/sys/Makefile.inc
deleted file mode 100644
index c06d18b06e3d..000000000000
--- a/lib/libc/x86/sys/Makefile.inc
+++ /dev/null
@@ -1,23 +0,0 @@
-
-.PATH: ${LIBC_SRCTOP}/x86/sys
-
-SRCS+= \
- __vdso_gettc.c \
- pkru.c \
- sched_getcpu_x86.c
-
-MAN+= \
- pkru.3
-
-# Note: vdso support for hyperv only on amd64
-.if ${MACHINE_CPUARCH} == "amd64" && ${MK_HYPERV} != "no"
-CFLAGS+= -DWANT_HYPERV
-.endif
-# We can't use sanitizer instrumentation on ifuncs called during sanitizer
-# runtime startup.
-.if ${MK_ASAN} != "no"
-CFLAGS.__vdso_gettc.c+=-fno-sanitize=address
-.endif
-.if ${MK_UBSAN} != "no"
-CFLAGS.__vdso_gettc.c+=-fno-sanitize=undefined
-.endif
diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
deleted file mode 100644
index 11632677e577..000000000000
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/*-
- * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
- * Copyright (c) 2016, 2017, 2019 The FreeBSD Foundation
- * All rights reserved.
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include "namespace.h"
-#include <sys/capsicum.h>
-#include <sys/elf.h>
-#include <sys/fcntl.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <sys/vdso.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include "un-namespace.h"
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/pvclock.h>
-#include <machine/specialreg.h>
-#include <dev/acpica/acpi_hpet.h>
-#ifdef WANT_HYPERV
-#include <dev/hyperv/hyperv.h>
-#endif
-#include <x86/ifunc.h>
-#include "libc_private.h"
-
-static inline u_int
-rdtsc_low(const struct vdso_timehands *th)
-{
- u_int rv;
-
- __asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
- : "=a" (rv) : "c" (th->th_x86_shift) : "edx");
- return (rv);
-}
-
-static inline u_int
-rdtscp_low(const struct vdso_timehands *th)
-{
- u_int rv;
-
- __asm __volatile("rdtscp; movl %%edi,%%ecx; shrd %%cl, %%edx, %0"
- : "=a" (rv) : "D" (th->th_x86_shift) : "ecx", "edx");
- return (rv);
-}
-
-static u_int
-rdtsc_low_mb_lfence(const struct vdso_timehands *th)
-{
- lfence();
- return (rdtsc_low(th));
-}
-
-static u_int
-rdtsc_low_mb_mfence(const struct vdso_timehands *th)
-{
- mfence();
- return (rdtsc_low(th));
-}
-
-static u_int
-rdtsc_low_mb_none(const struct vdso_timehands *th)
-{
- return (rdtsc_low(th));
-}
-
-static u_int
-rdtsc32_mb_lfence(void)
-{
- lfence();
- return (rdtsc32());
-}
-
-static uint64_t
-rdtsc_mb_lfence(void)
-{
- lfence();
- return (rdtsc());
-}
-
-static u_int
-rdtsc32_mb_mfence(void)
-{
- mfence();
- return (rdtsc32());
-}
-
-static uint64_t
-rdtsc_mb_mfence(void)
-{
- mfence();
- return (rdtsc());
-}
-
-static u_int
-rdtsc32_mb_none(void)
-{
- return (rdtsc32());
-}
-
-static uint64_t
-rdtsc_mb_none(void)
-{
- return (rdtsc());
-}
-
-static u_int
-rdtscp32_(void)
-{
- return (rdtscp32());
-}
-
-static uint64_t
-rdtscp_(void)
-{
- return (rdtscp());
-}
-
-struct tsc_selector_tag {
- u_int (*ts_rdtsc32)(void);
- uint64_t (*ts_rdtsc)(void);
- u_int (*ts_rdtsc_low)(const struct vdso_timehands *);
-};
-
-static const struct tsc_selector_tag tsc_selector[] = {
- [0] = { /* Intel, LFENCE */
- .ts_rdtsc32 = rdtsc32_mb_lfence,
- .ts_rdtsc = rdtsc_mb_lfence,
- .ts_rdtsc_low = rdtsc_low_mb_lfence,
- },
- [1] = { /* AMD, MFENCE */
- .ts_rdtsc32 = rdtsc32_mb_mfence,
- .ts_rdtsc = rdtsc_mb_mfence,
- .ts_rdtsc_low = rdtsc_low_mb_mfence,
- },
- [2] = { /* No SSE2 */
- .ts_rdtsc32 = rdtsc32_mb_none,
- .ts_rdtsc = rdtsc_mb_none,
- .ts_rdtsc_low = rdtsc_low_mb_none,
- },
- [3] = { /* RDTSCP */
- .ts_rdtsc32 = rdtscp32_,
- .ts_rdtsc = rdtscp_,
- .ts_rdtsc_low = rdtscp_low,
- },
-};
-
-static int
-tsc_selector_idx(u_int cpu_feature)
-{
- u_int amd_feature, cpu_exthigh, p[4], v[3];
- static const char amd_id[] = "AuthenticAMD";
- static const char hygon_id[] = "HygonGenuine";
- bool amd_cpu;
-
- if (cpu_feature == 0)
- return (2); /* should not happen due to RDTSC */
-
- do_cpuid(0, p);
- v[0] = p[1];
- v[1] = p[3];
- v[2] = p[2];
- amd_cpu = memcmp(v, amd_id, sizeof(amd_id) - 1) == 0 ||
- memcmp(v, hygon_id, sizeof(hygon_id) - 1) == 0;
-
- if (cpu_feature != 0) {
- do_cpuid(0x80000000, p);
- cpu_exthigh = p[0];
- } else {
- cpu_exthigh = 0;
- }
- if (cpu_exthigh >= 0x80000001) {
- do_cpuid(0x80000001, p);
- amd_feature = p[3];
- } else {
- amd_feature = 0;
- }
-
- if ((amd_feature & AMDID_RDTSCP) != 0)
- return (3);
- if ((cpu_feature & CPUID_SSE2) == 0)
- return (2);
- return (amd_cpu ? 1 : 0);
-}
-
-DEFINE_UIFUNC(static, u_int, __vdso_gettc_rdtsc_low,
- (const struct vdso_timehands *th))
-{
- return (tsc_selector[tsc_selector_idx(cpu_feature)].ts_rdtsc_low);
-}
-
-DEFINE_UIFUNC(static, u_int, __vdso_gettc_rdtsc32, (void))
-{
- return (tsc_selector[tsc_selector_idx(cpu_feature)].ts_rdtsc32);
-}
-
-DEFINE_UIFUNC(static, uint64_t, __vdso_gettc_rdtsc, (void))
-{
- return (tsc_selector[tsc_selector_idx(cpu_feature)].ts_rdtsc);
-}
-
-#define HPET_DEV_MAP_MAX 10
-static volatile char *hpet_dev_map[HPET_DEV_MAP_MAX];
-
-static void
-__vdso_init_hpet(uint32_t u)
-{
- static const char devprefix[] = "/dev/hpet";
- char devname[64], *c, *c1, t;
- volatile char *new_map, *old_map;
- unsigned int mode;
- uint32_t u1;
- int fd;
-
- c1 = c = stpcpy(devname, devprefix);
- u1 = u;
- do {
- *c++ = u1 % 10 + '0';
- u1 /= 10;
- } while (u1 != 0);
- *c = '\0';
- for (c--; c1 != c; c1++, c--) {
- t = *c1;
- *c1 = *c;
- *c = t;
- }
-
- old_map = hpet_dev_map[u];
- if (old_map != NULL)
- return;
-
- /*
- * Explicitely check for the capability mode to avoid
- * triggering trap_enocap on the device open by absolute path.
- */
- if ((cap_getmode(&mode) == 0 && mode != 0) ||
- (fd = _open(devname, O_RDONLY | O_CLOEXEC)) == -1) {
- /* Prevent the caller from re-entering. */
- atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
- (uintptr_t)old_map, (uintptr_t)MAP_FAILED);
- return;
- }
-
- new_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
- _close(fd);
- if (atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
- (uintptr_t)old_map, (uintptr_t)new_map) == 0 &&
- new_map != MAP_FAILED)
- munmap((void *)new_map, PAGE_SIZE);
-}
-
-#ifdef WANT_HYPERV
-
-#define HYPERV_REFTSC_DEVPATH "/dev/" HYPERV_REFTSC_DEVNAME
-
-/*
- * NOTE:
- * We use 'NULL' for this variable to indicate that initialization
- * is required. And if this variable is 'MAP_FAILED', then Hyper-V
- * reference TSC can not be used, e.g. in misconfigured jail.
- */
-static struct hyperv_reftsc *hyperv_ref_tsc;
-
-static void
-__vdso_init_hyperv_tsc(void)
-{
- int fd;
- unsigned int mode;
-
- if (cap_getmode(&mode) == 0 && mode != 0)
- goto fail;
-
- fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY | O_CLOEXEC);
- if (fd < 0)
- goto fail;
- hyperv_ref_tsc = mmap(NULL, sizeof(*hyperv_ref_tsc), PROT_READ,
- MAP_SHARED, fd, 0);
- _close(fd);
-
- return;
-fail:
- /* Prevent the caller from re-entering. */
- hyperv_ref_tsc = MAP_FAILED;
-}
-
-static int
-__vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc)
-{
- uint64_t disc, ret, tsc, scale;
- uint32_t seq;
- int64_t ofs;
-
- while ((seq = atomic_load_acq_int(&tsc_ref->tsc_seq)) != 0) {
- scale = tsc_ref->tsc_scale;
- ofs = tsc_ref->tsc_ofs;
-
- mfence(); /* XXXKIB */
- tsc = rdtsc();
-
- /* ret = ((tsc * scale) >> 64) + ofs */
- __asm__ __volatile__ ("mulq %3" :
- "=d" (ret), "=a" (disc) :
- "a" (tsc), "r" (scale));
- ret += ofs;
-
- atomic_thread_fence_acq();
- if (tsc_ref->tsc_seq == seq) {
- *tc = ret;
- return (0);
- }
-
- /* Sequence changed; re-sync. */
- }
- return (ENOSYS);
-}
-
-#endif /* WANT_HYPERV */
-
-static struct pvclock_vcpu_time_info *pvclock_timeinfos;
-
-static int
-__vdso_pvclock_gettc(const struct vdso_timehands *th, u_int *tc)
-{
- uint64_t delta, ns, tsc;
- struct pvclock_vcpu_time_info *ti;
- uint32_t cpuid_ti, cpuid_tsc, version;
- bool stable;
-
- do {
- ti = &pvclock_timeinfos[0];
- version = atomic_load_acq_32(&ti->version);
- stable = (ti->flags & th->th_x86_pvc_stable_mask) != 0;
- if (stable) {
- tsc = __vdso_gettc_rdtsc();
- } else {
- (void)rdtscp_aux(&cpuid_ti);
- ti = &pvclock_timeinfos[cpuid_ti];
- version = atomic_load_acq_32(&ti->version);
- tsc = rdtscp_aux(&cpuid_tsc);
- }
- delta = tsc - ti->tsc_timestamp;
- ns = ti->system_time + pvclock_scale_delta(delta,
- ti->tsc_to_system_mul, ti->tsc_shift);
- atomic_thread_fence_acq();
- } while ((ti->version & 1) != 0 || ti->version != version ||
- (!stable && cpuid_ti != cpuid_tsc));
- *tc = MAX(ns, th->th_x86_pvc_last_systime);
- return (0);
-}
-
-static void
-__vdso_init_pvclock_timeinfos(void)
-{
- struct pvclock_vcpu_time_info *timeinfos;
- size_t len;
- int fd, ncpus;
- unsigned int mode;
-
- timeinfos = MAP_FAILED;
- if (_elf_aux_info(AT_NCPUS, &ncpus, sizeof(ncpus)) != 0 ||
- (cap_getmode(&mode) == 0 && mode != 0) ||
- (fd = _open("/dev/" PVCLOCK_CDEVNAME, O_RDONLY | O_CLOEXEC)) < 0)
- goto leave;
- len = ncpus * sizeof(*pvclock_timeinfos);
- timeinfos = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
- _close(fd);
-leave:
- if (atomic_cmpset_rel_ptr(
- (volatile uintptr_t *)&pvclock_timeinfos, (uintptr_t)NULL,
- (uintptr_t)timeinfos) == 0 && timeinfos != MAP_FAILED)
- (void)munmap((void *)timeinfos, len);
-}
-
-#pragma weak __vdso_gettc
-int
-__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
-{
- volatile char *map;
- uint32_t idx;
-
- switch (th->th_algo) {
- case VDSO_TH_ALGO_X86_TSC:
- *tc = th->th_x86_shift > 0 ? __vdso_gettc_rdtsc_low(th) :
- __vdso_gettc_rdtsc32();
- return (0);
- case VDSO_TH_ALGO_X86_HPET:
- idx = th->th_x86_hpet_idx;
- if (idx >= HPET_DEV_MAP_MAX)
- return (ENOSYS);
- map = (volatile char *)atomic_load_acq_ptr(
- (volatile uintptr_t *)&hpet_dev_map[idx]);
- if (map == NULL) {
- __vdso_init_hpet(idx);
- map = (volatile char *)atomic_load_acq_ptr(
- (volatile uintptr_t *)&hpet_dev_map[idx]);
- }
- if (map == MAP_FAILED)
- return (ENOSYS);
- *tc = *(volatile uint32_t *)(map + HPET_MAIN_COUNTER);
- return (0);
-#ifdef WANT_HYPERV
- case VDSO_TH_ALGO_X86_HVTSC:
- if (hyperv_ref_tsc == NULL)
- __vdso_init_hyperv_tsc();
- if (hyperv_ref_tsc == MAP_FAILED)
- return (ENOSYS);
- return (__vdso_hyperv_tsc(hyperv_ref_tsc, tc));
-#endif
- case VDSO_TH_ALGO_X86_PVCLK:
- if (pvclock_timeinfos == NULL)
- __vdso_init_pvclock_timeinfos();
- if (pvclock_timeinfos == MAP_FAILED)
- return (ENOSYS);
- return (__vdso_pvclock_gettc(th, tc));
- default:
- return (ENOSYS);
- }
-}
-
-#pragma weak __vdso_gettimekeep
-int
-__vdso_gettimekeep(struct vdso_timekeep **tk)
-{
-
- return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
-}
diff --git a/lib/libc/x86/sys/pkru.3 b/lib/libc/x86/sys/pkru.3
deleted file mode 100644
index 1785f93cf4b6..000000000000
--- a/lib/libc/x86/sys/pkru.3
+++ /dev/null
@@ -1,203 +0,0 @@
-.\" Copyright (c) 2019 The FreeBSD Foundation, Inc.
-.\"
-.\" This documentation was written by
-.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
-.\" from the FreeBSD Foundation.
-.\"
-.\" 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 AUTHORS 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 AUTHORS 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.
-.\"
-.Dd February 16, 2019
-.Dt PKRU 3
-.Os
-.Sh NAME
-.Nm Protection Key Rights for User pages
-.Nd provide fast user-managed key-based access control for pages
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In machine/sysarch.h
-.Ft int
-.Fn x86_pkru_get_perm "unsigned int keyidx" "int *access" "int *modify"
-.Ft int
-.Fn x86_pkru_set_perm "unsigned int keyidx" "int access" "int modify"
-.Ft int
-.Fo x86_pkru_protect_range
-.Fa "void *addr"
-.Fa "unsigned long len"
-.Fa "unsigned int keyidx"
-.Fa "int flag"
-.Fc
-.Ft int
-.Fn x86_pkru_unprotect_range "void *addr" "unsigned long len"
-.Sh DESCRIPTION
-The protection keys feature provides an additional mechanism, besides the
-normal page permissions as established by
-.Xr mmap 2
-and
-.Xr mprotect 2 ,
-to control access to user-mode addresses.
-The mechanism gives safety measures which can be used to avoid
-incidental read or modification of sensitive memory,
-or as a debugging feature.
-It cannot guard against conscious accesses since permissions
-are user-controllable.
-.Pp
-If supported by hardware, each mapped user linear address
-has an associated 4-bit protection key.
-A new per-thread PKRU hardware register determines, for each protection
-key, whether user-mode addresses with that protection key may be
-read or written.
-.Pp
-Only one key may apply to a given range at a time.
-The default protection key index is zero, it is used even if no key
-was explicitly assigned to the address, or if the key was removed.
-.Pp
-The protection prevents the system from accessing user addresses as well
-as the user applications.
-When a system call was unable to read or write user memory due to key
-protection, it returns the
-.Er EFAULT
-error code.
-Note that some side effects may have occurred if this error is reported.
-.Pp
-Protection keys require that the system uses 4-level paging
-(also called long mode),
-which means that it is only available on amd64 system.
-Both 64-bit and 32-bit applications can use protection keys.
-More information about the hardware feature is provided in the IA32 Software
-Developer's Manual published by Intel Corp.
-.Pp
-The key indexes written into the page table entries are managed by the
-.Fn sysarch
-syscall.
-Per-key permissions are managed using the user-mode instructions
-.Em RDPKRU
-and
-.Em WRPKRU .
-The system provides convenient library helpers for both the syscall and
-the instructions, described below.
-.Pp
-The
-.Fn x86_pkru_protect_range
-function assigns key
-.Fa keyidx
-to the range starting at
-.Fa addr
-and having length
-.Fa len .
-Starting address is truncated to the page start,
-and the end is rounded up to the end of the page.
-After a successfull call, the range has the specified key assigned,
-even if the key is zero and it did not change the page table entries.
-.Pp
-The
-.Fa flags
-argument takes the logical OR of the following values:
-.Bl -tag -width
-.It Bq Va AMD64_PKRU_EXCL
-Only assign the key if the range does not have any other keys assigned
-(including the zero key).
-You must first remove any existing key with
-.Fn x86_pkru_unprotect_range
-in order for this request to succeed.
-If the
-.Va AMD64_PKRU_EXCL
-flag is not specified,
-.Fn x86_pkru_protect_range
-replaces any existing key.
-.It Bq Va AMD64_PKRU_PERSIST
-The keys assigned to the range are persistent.
-They are re-established when the current mapping is destroyed
-and a new mapping is created in any sub-range of the specified range.
-You must use a
-.Fn x86_pkru_unprotect_range
-call to forget the key.
-.El
-.Pp
-The
-.Fn x86_pkru_unprotect_range
-function removes any keys assigned to the specified range.
-Existing mappings are changed to use key index zero in page table entries.
-Keys are no longer considered installed for all mappings in the range,
-for the purposes of
-.Fn x86_pkru_protect_range
-with the
-.Va AMD64_PKRU_EXCL
-flag.
-.Pp
-The
-.Fn x86_pkru_get_perm
-function returns access rights for the key specified by the
-.Fa keyidx
-argument.
-If the value pointed to by
-.Fa access
-is zero after the call, no read or write permissions is granted for
-mappings which are assigned the key
-.Fa keyidx .
-If
-.Fa access
-is not zero, read access is permitted.
-The non-zero value of the variable pointed to by the
-.Fa modify
-argument indicates that write access is permitted.
-.Pp
-Conversely, the
-.Fn x86_pkru_set_perm
-establishes the access and modify permissions for the given key index
-as specified by its arguments.
-.Sh RETURN VALUES
-.Rv -std
-.Sh ERRORS
-.Bl -tag -width Er
-.It Bq Er EOPNOTSUPP
-The hardware does not support protection keys.
-.It Bq Er EINVAL
-The supplied key index is invalid (greater than 15).
-.It Bq Er EINVAL
-The supplied
-.Fa flags
-argument for
-.Fn x86_pkru_protect_range
-has reserved bits set.
-.It Bq Er EFAULT
-The supplied address range does not completely fit into the user-managed
-address range.
-.It Bq Er ENOMEM
-The memory shortage prevents the completion of the operation.
-.It Bq Er EBUSY
-The
-.Va AMD64_PKRU_EXCL
-flag was specified for
-.Fn x86_pkru_protect_range
-and the range already has defined protection keys.
-.El
-.Sh SEE ALSO
-.Xr mmap 2 ,
-.Xr mprotect 2 ,
-.Xr munmap 2 ,
-.Xr sysarch 2 .
-.Sh STANDARDS
-The
-.Nm
-functions are non-standard and first appeared in
-.Fx 13.0 .
diff --git a/lib/libc/x86/sys/pkru.c b/lib/libc/x86/sys/pkru.c
deleted file mode 100644
index a03becb3e101..000000000000
--- a/lib/libc/x86/sys/pkru.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * Portions of this software were developed by Konstantin Belousov
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/param.h>
-#include <machine/cpufunc.h>
-#include <machine/specialreg.h>
-#include <machine/sysarch.h>
-#include <x86/ifunc.h>
-#include <errno.h>
-#include <string.h>
-
-#define MAX_PKRU_IDX 0xf
-#ifdef __i386__
-#define X86_SET_PKRU I386_SET_PKRU
-#define X86_CLEAR_PKRU I386_CLEAR_PKRU
-#else
-#define X86_SET_PKRU AMD64_SET_PKRU
-#define X86_CLEAR_PKRU AMD64_CLEAR_PKRU
-#endif
-
-static int
-x86_pkru_get_perm_unsup(u_int keyidx, int *access, int *modify)
-{
-
- errno = EOPNOTSUPP;
- return (-1);
-}
-
-static int
-x86_pkru_get_perm_hw(u_int keyidx, int *access, int *modify)
-{
- uint32_t pkru;
-
- if (keyidx > MAX_PKRU_IDX) {
- errno = EINVAL;
- return (-1);
- }
- keyidx *= 2;
- pkru = rdpkru();
- *access = (pkru & (1 << keyidx)) == 0;
- *modify = (pkru & (2 << keyidx)) == 0;
- return (0);
-}
-
-DEFINE_UIFUNC(, int, x86_pkru_get_perm, (u_int, int *, int *))
-{
-
- return ((cpu_stdext_feature2 & CPUID_STDEXT2_OSPKE) == 0 ?
- x86_pkru_get_perm_unsup : x86_pkru_get_perm_hw);
-}
-
-static int
-x86_pkru_set_perm_unsup(u_int keyidx, int access, int modify)
-{
-
- errno = EOPNOTSUPP;
- return (-1);
-}
-
-static int
-x86_pkru_set_perm_hw(u_int keyidx, int access, int modify)
-{
- uint32_t pkru;
-
- if (keyidx > MAX_PKRU_IDX) {
- errno = EINVAL;
- return (-1);
- }
- keyidx *= 2;
- pkru = rdpkru();
- pkru &= ~(3 << keyidx);
- if (!access)
- pkru |= 1 << keyidx;
- if (!modify)
- pkru |= 2 << keyidx;
- wrpkru(pkru);
- return (0);
-}
-
-DEFINE_UIFUNC(, int, x86_pkru_set_perm, (u_int, int, int))
-{
-
- return ((cpu_stdext_feature2 & CPUID_STDEXT2_OSPKE) == 0 ?
- x86_pkru_set_perm_unsup : x86_pkru_set_perm_hw);
-}
-
-int
-x86_pkru_protect_range(void *addr, unsigned long len, u_int keyidx, int flags)
-{
- struct amd64_set_pkru a64pkru;
-
- memset(&a64pkru, 0, sizeof(a64pkru));
- a64pkru.addr = addr;
- a64pkru.len = len;
- a64pkru.keyidx = keyidx;
- a64pkru.flags = flags;
- return (sysarch(X86_SET_PKRU, &a64pkru));
-}
-
-int
-x86_pkru_unprotect_range(void *addr, unsigned long len)
-{
- struct amd64_set_pkru a64pkru;
-
- memset(&a64pkru, 0, sizeof(a64pkru));
- a64pkru.addr = addr;
- a64pkru.len = len;
- return (sysarch(X86_CLEAR_PKRU, &a64pkru));
-}
diff --git a/lib/libc/xdr/Makefile.inc b/lib/libc/xdr/Makefile.inc
index 76997c1da218..559ed5ed044e 100644
--- a/lib/libc/xdr/Makefile.inc
+++ b/lib/libc/xdr/Makefile.inc
@@ -1,5 +1,3 @@
-# @(#)Makefile 5.11 (Berkeley) 9/6/90
-
.PATH: ${LIBC_SRCTOP}/xdr ${LIBC_SRCTOP}/.
SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \
xdr_rec.c xdr_reference.c xdr_sizeof.c \
@@ -26,26 +24,31 @@ MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 \
xdr.3 xdr_float.3 \
xdr.3 xdr_free.3 \
xdr.3 xdr_getpos.3 \
+ xdr.3 xdr_hyper.3 \
xdr.3 xdr_inline.3 \
xdr.3 xdr_int.3 \
xdr.3 xdr_long.3 \
- xdr.3 xdrmem_create.3 \
+ xdr.3 xdr_longlong_t.3 \
xdr.3 xdr_opaque.3 \
xdr.3 xdr_pointer.3 \
- xdr.3 xdrrec_create.3 \
- xdr.3 xdrrec_endofrecord.3 \
- xdr.3 xdrrec_eof.3 \
- xdr.3 xdrrec_skiprecord.3 \
xdr.3 xdr_reference.3 \
xdr.3 xdr_setpos.3 \
xdr.3 xdr_short.3 \
xdr.3 xdr_sizeof.3 \
- xdr.3 xdrstdio_create.3 \
xdr.3 xdr_string.3 \
xdr.3 xdr_u_char.3 \
+ xdr.3 xdr_u_hyper.3 \
+ xdr.3 xdr_u_int.3 \
xdr.3 xdr_u_long.3 \
+ xdr.3 xdr_u_longlong_t.3 \
xdr.3 xdr_u_short.3 \
xdr.3 xdr_union.3 \
xdr.3 xdr_vector.3 \
xdr.3 xdr_void.3 \
+ xdr.3 xdrmem_create.3 \
+ xdr.3 xdrrec_create.3 \
+ xdr.3 xdrrec_endofrecord.3 \
+ xdr.3 xdrrec_eof.3 \
+ xdr.3 xdrrec_skiprecord.3 \
+ xdr.3 xdrstdio_create.3 \
xdr.3 xdr_wrapstring.3
diff --git a/lib/libc/xdr/Symbol.map b/lib/libc/xdr/Symbol.map
index 1ee5afda2425..0a964fecdbdb 100644
--- a/lib/libc/xdr/Symbol.map
+++ b/lib/libc/xdr/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
xdr_free;
xdr_void;
diff --git a/lib/libc/xdr/xdr.3 b/lib/libc/xdr/xdr.3
index ed6121859204..65adb050fa44 100644
--- a/lib/libc/xdr/xdr.3
+++ b/lib/libc/xdr/xdr.3
@@ -1,4 +1,3 @@
-.\" @(#)xdr.3n 2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
.\"
.Dd February 16, 1988
.Dt XDR 3
diff --git a/lib/libc/xdr/xdr.c b/lib/libc/xdr/xdr.c
index 6d44a012443b..59a843405abf 100644
--- a/lib/libc/xdr/xdr.c
+++ b/lib/libc/xdr/xdr.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr.c 1.35 87/08/12";
-static char *sccsid = "@(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr.c, Generic XDR routines implementation.
*
@@ -89,13 +84,11 @@ xdr_free(xdrproc_t proc, void *objp)
* XDR nothing
*/
bool_t
-xdr_void(void)
+xdr_void(XDR *xdrs __unused, void *ptr __unused)
{
-
return (TRUE);
}
-
/*
* XDR integers
*/
@@ -626,7 +619,7 @@ xdr_netobj(XDR *xdrs, struct netobj *np)
}
/*
- * XDR a descriminated union
+ * XDR a discriminated union
* Support routine for discriminated unions.
* You create an array of xdrdiscrim structures, terminated with
* an entry with a null procedure pointer. The routine gets
diff --git a/lib/libc/xdr/xdr_array.c b/lib/libc/xdr/xdr_array.c
index 6e910557c702..3d39895e756e 100644
--- a/lib/libc/xdr/xdr_array.c
+++ b/lib/libc/xdr/xdr_array.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr_array.c, Generic XDR routines implementation.
*
diff --git a/lib/libc/xdr/xdr_float.c b/lib/libc/xdr/xdr_float.c
index 4366a04586a1..87c6feacf3c5 100644
--- a/lib/libc/xdr/xdr_float.c
+++ b/lib/libc/xdr/xdr_float.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr_float.c, Generic XDR routines implementation.
*
diff --git a/lib/libc/xdr/xdr_mem.c b/lib/libc/xdr/xdr_mem.c
index b08606e54fa3..f8a69d163d7e 100644
--- a/lib/libc/xdr/xdr_mem.c
+++ b/lib/libc/xdr/xdr_mem.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr_mem.h, XDR implementation using memory buffers.
*
diff --git a/lib/libc/xdr/xdr_rec.c b/lib/libc/xdr/xdr_rec.c
index cd99eecf6108..7dc9bbb31ec3 100644
--- a/lib/libc/xdr/xdr_rec.c
+++ b/lib/libc/xdr/xdr_rec.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking"
* layer above tcp (for rpc's use).
@@ -227,7 +222,7 @@ xdrrec_create(XDR *xdrs, u_int sendsize, u_int recvsize, void *tcp_handle,
/*
- * The reoutines defined below are the xdr ops which will go into the
+ * The routines defined below are the xdr ops which will go into the
* xdr handle filled in by xdrrec_create.
*/
@@ -323,27 +318,30 @@ xdrrec_putbytes(XDR *xdrs, const char *addr, u_int len)
return (TRUE);
}
+/*
+ * XXX: xdrrec operates on a TCP stream and doesn't keep record of how many
+ * bytes were sent/received overall. Thus, the XDR_GETPOS() and XDR_SETPOS()
+ * can operate only within small internal buffer. So far, the limited set of
+ * consumers of this xdr are fine with that. It also seems that methods are
+ * never called in the XDR_DECODE mode.
+ */
static u_int
xdrrec_getpos(XDR *xdrs)
{
RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
- off_t pos;
+ ptrdiff_t pos;
- pos = lseek((int)(u_long)rstrm->tcp_handle, (off_t)0, 1);
- if (pos == -1)
- pos = 0;
switch (xdrs->x_op) {
-
case XDR_ENCODE:
- pos += rstrm->out_finger - rstrm->out_base;
+ pos = rstrm->out_finger - rstrm->out_base;
break;
case XDR_DECODE:
- pos -= rstrm->in_boundry - rstrm->in_finger;
+ pos = rstrm->in_finger - rstrm->in_base;
break;
- default:
- pos = (off_t) -1;
+ case XDR_FREE:
+ pos = -1;
break;
}
return ((u_int) pos);
@@ -357,32 +355,30 @@ xdrrec_setpos(XDR *xdrs, u_int pos)
int delta = currpos - pos;
char *newpos;
- if ((int)currpos != -1)
- switch (xdrs->x_op) {
-
- case XDR_ENCODE:
- newpos = rstrm->out_finger - delta;
- if ((newpos > (char *)(void *)(rstrm->frag_header)) &&
- (newpos < rstrm->out_boundry)) {
- rstrm->out_finger = newpos;
- return (TRUE);
- }
- break;
-
- case XDR_DECODE:
- newpos = rstrm->in_finger - delta;
- if ((delta < (int)(rstrm->fbtbc)) &&
- (newpos <= rstrm->in_boundry) &&
- (newpos >= rstrm->in_base)) {
- rstrm->in_finger = newpos;
- rstrm->fbtbc -= delta;
- return (TRUE);
- }
- break;
-
- case XDR_FREE:
- break;
+ switch (xdrs->x_op) {
+ case XDR_ENCODE:
+ newpos = rstrm->out_finger - delta;
+ if ((newpos > (char *)(void *)(rstrm->frag_header)) &&
+ (newpos < rstrm->out_boundry)) {
+ rstrm->out_finger = newpos;
+ return (TRUE);
}
+ break;
+
+ case XDR_DECODE:
+ newpos = rstrm->in_finger - delta;
+ if ((delta < (int)(rstrm->fbtbc)) &&
+ (newpos <= rstrm->in_boundry) &&
+ (newpos >= rstrm->in_base)) {
+ rstrm->in_finger = newpos;
+ rstrm->fbtbc -= delta;
+ return (TRUE);
+ }
+ break;
+
+ case XDR_FREE:
+ break;
+ }
return (FALSE);
}
@@ -489,9 +485,9 @@ xdrrec_eof(XDR *xdrs)
/*
* The client must tell the package when an end-of-record has occurred.
- * The second paraemters tells whether the record should be flushed to the
+ * The second parameters tells whether the record should be flushed to the
* (output) tcp stream. (This let's the package support batched or
- * pipelined procedure calls.) TRUE => immmediate flush to tcp connection.
+ * pipelined procedure calls.) TRUE => immediate flush to tcp connection.
*/
bool_t
xdrrec_endofrecord(XDR *xdrs, bool_t sendnow)
diff --git a/lib/libc/xdr/xdr_reference.c b/lib/libc/xdr/xdr_reference.c
index 321aa1d9f6ad..e3698a35acd9 100644
--- a/lib/libc/xdr/xdr_reference.c
+++ b/lib/libc/xdr/xdr_reference.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
-static char *sccsid = "@(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr_reference.c, Generic XDR routines implementation.
*
@@ -61,7 +56,7 @@ static char *sccsid = "@(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";
* referenced by a pointer inside the structure that is currently being
* translated. pp references a pointer to storage. If *pp is null
* the necessary storage is allocated.
- * size is the sizeof the referneced structure.
+ * size is the sizeof the referenced structure.
* proc is the routine to handle the referenced structure.
*/
bool_t
diff --git a/lib/libc/xdr/xdr_sizeof.c b/lib/libc/xdr/xdr_sizeof.c
index b0889c233c10..b374daf82a39 100644
--- a/lib/libc/xdr/xdr_sizeof.c
+++ b/lib/libc/xdr/xdr_sizeof.c
@@ -37,7 +37,6 @@
* when serialized using XDR.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <rpc/types.h>
#include <rpc/xdr.h>
diff --git a/lib/libc/xdr/xdr_stdio.c b/lib/libc/xdr/xdr_stdio.c
index 26335372d544..22588bca2946 100644
--- a/lib/libc/xdr/xdr_stdio.c
+++ b/lib/libc/xdr/xdr_stdio.c
@@ -33,11 +33,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *sccsid2 = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
-static char *sccsid = "@(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";
-#endif
-#include <sys/cdefs.h>
/*
* xdr_stdio.c, XDR implementation on standard i/o file.
*
diff --git a/lib/libc/yp/Makefile.inc b/lib/libc/yp/Makefile.inc
index b19baeeb8f0e..7aeac84090e7 100644
--- a/lib/libc/yp/Makefile.inc
+++ b/lib/libc/yp/Makefile.inc
@@ -1,5 +1,3 @@
-# from: @(#)Makefile.inc 5.3 (Berkeley) 2/20/91
-
# yp sources
.PATH: ${LIBC_SRCTOP}/yp
diff --git a/lib/libc/yp/Symbol.map b/lib/libc/yp/Symbol.map
index ecd17af4a29a..f50beed7be31 100644
--- a/lib/libc/yp/Symbol.map
+++ b/lib/libc/yp/Symbol.map
@@ -1,6 +1,3 @@
-/*
- */
-
FBSD_1.0 {
xdr_datum;
xdr_ypresp_all_seq;
@@ -21,4 +18,36 @@ FBSD_1.0 {
yperr_string;
ypprot_err;
_yp_check;
+
+ /* From yp_xdr.c (generated by rpcgen - include/rpcsvc/yp.x) */
+ xdr_domainname;
+ xdr_keydat;
+ xdr_mapname;
+ xdr_peername;
+ xdr_valdat;
+ xdr_ypbind_binding;
+ xdr_ypbind_resp;
+ xdr_ypbind_resptype;
+ xdr_ypbind_setdom;
+ xdr_ypmap_parms;
+ xdr_ypmaplist;
+ xdr_yppush_status;
+ xdr_yppushresp_xfr;
+ xdr_ypreq_key;
+ xdr_ypreq_nokey;
+ xdr_ypreq_xfr;
+ xdr_ypreqtype;
+ xdr_yprequest;
+ xdr_ypresp_all;
+ xdr_ypresp_key_val;
+ xdr_ypresp_maplist;
+ xdr_ypresp_master;
+ xdr_ypresp_order;
+ xdr_ypresp_val;
+ xdr_ypresp_xfr;
+ xdr_ypresponse;
+ xdr_ypresptype;
+ xdr_ypstat;
+ xdr_ypxfrstat;
+
};
diff --git a/lib/libc/yp/xdryp.c b/lib/libc/yp/xdryp.c
index ebd76cb48050..eae57e7e8347 100644
--- a/lib/libc/yp/xdryp.c
+++ b/lib/libc/yp/xdryp.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <rpc/rpc.h>
#include <rpcsvc/yp.h>
#include <stdlib.h>
diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c
index cddaaa697ab6..95ed526b2e75 100644
--- a/lib/libc/yp/yplib.c
+++ b/lib/libc/yp/yplib.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include "reentrant.h"
#include <sys/param.h>
@@ -92,7 +91,7 @@ struct dom_binding {
bool_t xdr_ypresp_all_seq(XDR *xdrs, u_long *objp);
-int (*ypresp_allfn)();
+int (*ypresp_allfn)(unsigned long, char *, int, char *, int, void *);
void *ypresp_data;
static void _yp_unbind(struct dom_binding *);
diff --git a/lib/libc_nonshared/Makefile b/lib/libc_nonshared/Makefile
index 0f6cf561a7c6..90c3b756b0a5 100644
--- a/lib/libc_nonshared/Makefile
+++ b/lib/libc_nonshared/Makefile
@@ -1,9 +1,7 @@
-
# We're actually creating a libc_noshared.a that is PIC along side libc.so.*
# It is used exclusively with libc.so.* - there is no need for any other
# compile modes.
# bsd.lib.mk doesn't have an easy way to express that.
-MK_PROFILE?=no
.include <src.opts.mk>
NO_PIC=
# -fpic on some platforms, -fPIC on others.
diff --git a/lib/libc_nonshared/Makefile.iconv b/lib/libc_nonshared/Makefile.iconv
index 3fbd06f1b6a6..a17d3436f999 100644
--- a/lib/libc_nonshared/Makefile.iconv
+++ b/lib/libc_nonshared/Makefile.iconv
@@ -1,4 +1,3 @@
-
.if ${MK_ICONV} == "yes"
LIBC_NONSHARED_SRCS+= \
__iconv.c __iconv_free_list.c __iconv_get_list.c \
diff --git a/lib/libcalendar/Makefile b/lib/libcalendar/Makefile
index aac15461b84b..e28e7ef08ea6 100644
--- a/lib/libcalendar/Makefile
+++ b/lib/libcalendar/Makefile
@@ -1,4 +1,3 @@
-
LIB= calendar
SRCS= calendar.c easter.c
diff --git a/lib/libcam/Makefile b/lib/libcam/Makefile
index f3f43a90d4bc..d4efbbdf4d9b 100644
--- a/lib/libcam/Makefile
+++ b/lib/libcam/Makefile
@@ -1,10 +1,9 @@
-
PACKAGE= runtime
LIB= cam
SHLIBDIR?= /lib
SRCS= camlib.c scsi_cmdparse.c scsi_all.c scsi_da.c scsi_sa.c cam.c \
- ata_all.c nvme_all.c smp_all.c scsi_wrap.c
+ ata_all.c nvme_all.c nvme_util.c smp_all.c scsi_wrap.c
INCS= camlib.h scsi_wrap.h
LIBADD= sbuf
@@ -40,7 +39,8 @@ MLINKS+= cam.3 cam_open_device.3 \
${SRCTOP}/sys/cam/ata \
${SRCTOP}/sys/cam/nvme \
${SRCTOP}/sys/cam/mmc \
- ${SRCTOP}/sys/cam/scsi
+ ${SRCTOP}/sys/cam/scsi \
+ ${SRCTOP}/sys/dev/nvme
CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index 6074cdebeb63..6b3e62e13e6f 100644
--- a/lib/libcam/camlib.c
+++ b/lib/libcam/camlib.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <assert.h>
diff --git a/lib/libcam/camlib.h b/lib/libcam/camlib.h
index 621ac5bf08d4..c82a529181cb 100644
--- a/lib/libcam/camlib.h
+++ b/lib/libcam/camlib.h
@@ -64,7 +64,6 @@
#ifndef _CAMLIB_H
#define _CAMLIB_H
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <cam/cam.h>
diff --git a/lib/libcam/scsi_cmdparse.c b/lib/libcam/scsi_cmdparse.c
index 81c8708c8d68..5aa69cd88fdb 100644
--- a/lib/libcam/scsi_cmdparse.c
+++ b/lib/libcam/scsi_cmdparse.c
@@ -37,7 +37,6 @@
* From: scsi.c,v 1.8 1997/02/22 15:07:54 peter Exp $
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdlib.h>
diff --git a/lib/libcam/scsi_wrap.c b/lib/libcam/scsi_wrap.c
index e5bd76e6e9be..584f760bcc42 100644
--- a/lib/libcam/scsi_wrap.c
+++ b/lib/libcam/scsi_wrap.c
@@ -28,7 +28,6 @@
* details.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <err.h>
diff --git a/lib/libcam/tests/Makefile b/lib/libcam/tests/Makefile
index f762332b0c73..a1726638fdc9 100644
--- a/lib/libcam/tests/Makefile
+++ b/lib/libcam/tests/Makefile
@@ -1,4 +1,3 @@
-
ATF_TESTS_C+= libcam_test
ATF_TESTS_C+= cam_test
diff --git a/lib/libcapsicum/Makefile b/lib/libcapsicum/Makefile
index 48577bb7fb5f..3cb476e67e28 100644
--- a/lib/libcapsicum/Makefile
+++ b/lib/libcapsicum/Makefile
@@ -1,4 +1,3 @@
-
INCS= capsicum_helpers.h
MAN+= capsicum_helpers.3
diff --git a/lib/libcapsicum/capsicum_helpers.3 b/lib/libcapsicum/capsicum_helpers.3
index 9c4c0bfa0229..fdb4f6f87977 100644
--- a/lib/libcapsicum/capsicum_helpers.3
+++ b/lib/libcapsicum/capsicum_helpers.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 2, 2020
+.Dd May 16, 2024
.Dt CAPSICUM_HELPERS 3
.Os
.Sh NAME
@@ -150,7 +150,31 @@ NLS data is used for localized error printing by
and
.Xr err 3 ,
among others.
-.Ed
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn caph_enter ,
+.Fn caph_enter_casper ,
+.Fn caph_rights_limit ,
+.Fn caph_ioctls_limit ,
+.Fn caph_fcntls_limit ,
+.Fn caph_limit_stream ,
+.Fn caph_limit_stdin ,
+.Fn caph_limit_stderr ,
+.Fn caph_limit_stdout ,
+and
+.Fn caph_limit_stdio
+return a value
+of 0.
+Otherwise, a value of -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Pp
+Functions
+.Fn caph_stream_rights ,
+.Fn caph_cache_tzdata ,
+and
+.Fn caph_cache_catpages
+can not fail.
.Sh SEE ALSO
.Xr cap_enter 2 ,
.Xr cap_rights_limit 2 ,
diff --git a/lib/libcapsicum/capsicum_helpers.h b/lib/libcapsicum/capsicum_helpers.h
index f137ec1806f9..a6c696aa9a8e 100644
--- a/lib/libcapsicum/capsicum_helpers.h
+++ b/lib/libcapsicum/capsicum_helpers.h
@@ -133,8 +133,17 @@ caph_limit_stdio(void)
static __inline void
caph_cache_tzdata(void)
{
+ time_t delta;
tzset();
+
+ /*
+ * The tzset() function does not cache all time zones.
+ * Some functions, such as gmtime(), require a GMT time zone.
+ * The only way to cache them is to call the function directly.
+ */
+ delta = 0;
+ (void)gmtime(&delta);
}
static __inline void
diff --git a/lib/libcasper/Makefile b/lib/libcasper/Makefile
index ce6bfb941160..0a1074d4613d 100644
--- a/lib/libcasper/Makefile
+++ b/lib/libcasper/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
SUBDIR= libcasper
diff --git a/lib/libcasper/Makefile.inc b/lib/libcasper/Makefile.inc
index ca5f4a2b3606..00bd221feb27 100644
--- a/lib/libcasper/Makefile.inc
+++ b/lib/libcasper/Makefile.inc
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
.if ${MK_CASPER} != "no"
diff --git a/lib/libcasper/libcasper/Makefile b/lib/libcasper/libcasper/Makefile
index 8d7e49bf94af..4db26f665f19 100644
--- a/lib/libcasper/libcasper/Makefile
+++ b/lib/libcasper/libcasper/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
SHLIBDIR?= /lib
diff --git a/lib/libcasper/libcasper/libcasper.3 b/lib/libcasper/libcasper/libcasper.3
index c98a3044df25..15f231d7e366 100644
--- a/lib/libcasper/libcasper/libcasper.3
+++ b/lib/libcasper/libcasper/libcasper.3
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 10, 2023
+.Dd December 6, 2023
.Dt LIBCASPER 3
.Os
.Sh NAME
@@ -94,7 +94,6 @@ The
.Fn cap_init
function instantiates a capability to allow a program to access
the casper daemon.
-It must be called from a single-threaded context.
.Pp
The
.Fn cap_wrap
@@ -212,6 +211,8 @@ Casper supports the following services in the base system:
.Bl -tag -width "system.random" -compact -offset indent
.It system.dns
provides libc compatible DNS API
+.It system.fileargs
+provides an API for opening files specified on a command line
.It system.grp
provides a
.Xr getgrent 3
@@ -233,6 +234,21 @@ provides a
.Xr syslog 3
compatible API
.El
+.Pp
+.Fn cap_init
+must be called from a single-threaded context.
+.Fn cap_clone ,
+.Fn cap_close ,
+.Fn cap_limit_get ,
+.Fn cap_limit_set ,
+.Fn cap_send_nvlist ,
+.Fn cap_recv_nvlist ,
+and
+.Fn cap_service_open
+are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh RETURN VALUES
The
.Fn cap_clone ,
@@ -272,6 +288,7 @@ functions always succeed.
.Xr poll 2 ,
.Xr select 2 ,
.Xr cap_dns 3 ,
+.Xr cap_fileargs 3 ,
.Xr cap_grp 3 ,
.Xr cap_net 3 ,
.Xr cap_netdb 3 ,
diff --git a/lib/libcasper/libcasper/libcasper.c b/lib/libcasper/libcasper/libcasper.c
index 095bbb9161e4..9cc008cdb7bc 100644
--- a/lib/libcasper/libcasper/libcasper.c
+++ b/lib/libcasper/libcasper/libcasper.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/nv.h>
diff --git a/lib/libcasper/libcasper/libcasper_service.c b/lib/libcasper/libcasper/libcasper_service.c
index 3468b520e275..df58f48d78eb 100644
--- a/lib/libcasper/libcasper/libcasper_service.c
+++ b/lib/libcasper/libcasper/libcasper_service.c
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
diff --git a/lib/libcasper/libcasper/service.c b/lib/libcasper/libcasper/service.c
index 478221a681da..70418db50085 100644
--- a/lib/libcasper/libcasper/service.c
+++ b/lib/libcasper/libcasper/service.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
@@ -59,7 +58,7 @@
* The problem is that we may restrict/sandbox service instance according
* to the limits provided. When new connection comes in with different
* limits we won't be able to access requested resources.
- * Not to mention one process will serve to mutiple mutually untrusted
+ * Not to mention one process will serve to multiple mutually untrusted
* clients and compromise of this service instance by one of its clients
* can lead to compromise of the other clients.
*/
diff --git a/lib/libcasper/libcasper/zygote.c b/lib/libcasper/libcasper/zygote.c
index e0dcc665ee9e..976e391d8dcb 100644
--- a/lib/libcasper/libcasper/zygote.c
+++ b/lib/libcasper/libcasper/zygote.c
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/capsicum.h>
#include <sys/procdesc.h>
diff --git a/lib/libcasper/services/Makefile b/lib/libcasper/services/Makefile
index f51531d12b22..c86b199f879b 100644
--- a/lib/libcasper/services/Makefile
+++ b/lib/libcasper/services/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
SUBDIR= cap_dns
diff --git a/lib/libcasper/services/Makefile.inc b/lib/libcasper/services/Makefile.inc
index d3b5cbd3a79b..01b5f23410c8 100644
--- a/lib/libcasper/services/Makefile.inc
+++ b/lib/libcasper/services/Makefile.inc
@@ -1,2 +1 @@
-
.include "../Makefile.inc"
diff --git a/lib/libcasper/services/cap_dns/Makefile b/lib/libcasper/services/cap_dns/Makefile
index eec1ac9d7d70..4b11c97d29e5 100644
--- a/lib/libcasper/services/cap_dns/Makefile
+++ b/lib/libcasper/services/cap_dns/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libcasper/services/cap_dns/cap_dns.c b/lib/libcasper/services/cap_dns/cap_dns.c
index 8548715a6978..8681f0baef40 100644
--- a/lib/libcasper/services/cap_dns/cap_dns.c
+++ b/lib/libcasper/services/cap_dns/cap_dns.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2012-2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -85,7 +84,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_length = (int)nvlist_get_number(nvl, "length");
nitems = (unsigned int)nvlist_get_number(nvl, "naliases");
- hp->h_aliases = calloc(sizeof(hp->h_aliases[0]), nitems + 1);
+ hp->h_aliases = calloc(nitems + 1, sizeof(hp->h_aliases[0]));
if (hp->h_aliases == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
@@ -99,7 +98,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_aliases[ii] = NULL;
nitems = (unsigned int)nvlist_get_number(nvl, "naddrs");
- hp->h_addr_list = calloc(sizeof(hp->h_addr_list[0]), nitems + 1);
+ hp->h_addr_list = calloc(nitems + 1, sizeof(hp->h_addr_list[0]));
if (hp->h_addr_list == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
diff --git a/lib/libcasper/services/cap_dns/cap_dns.h b/lib/libcasper/services/cap_dns/cap_dns.h
index 4bf8e3648a2d..556cac1158d2 100644
--- a/lib/libcasper/services/cap_dns/cap_dns.h
+++ b/lib/libcasper/services/cap_dns/cap_dns.h
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2012 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libcasper/services/cap_dns/tests/Makefile b/lib/libcasper/services/cap_dns/tests/Makefile
index b11586df6a85..c7306581a803 100644
--- a/lib/libcasper/services/cap_dns/tests/Makefile
+++ b/lib/libcasper/services/cap_dns/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
ATF_TESTS_C= dns_test
diff --git a/lib/libcasper/services/cap_dns/tests/Makefile.depend b/lib/libcasper/services/cap_dns/tests/Makefile.depend
index 11aba52f82cf..560f3166bc47 100644
--- a/lib/libcasper/services/cap_dns/tests/Makefile.depend
+++ b/lib/libcasper/services/cap_dns/tests/Makefile.depend
@@ -1,6 +1,16 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/atf/libatf-c \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_dns \
+ lib/libcompiler_rt \
+ lib/libnv \
.include <dirdeps.mk>
diff --git a/lib/libcasper/services/cap_dns/tests/dns_test.c b/lib/libcasper/services/cap_dns/tests/dns_test.c
index 3786414053ad..56d867e474f5 100644
--- a/lib/libcasper/services/cap_dns/tests/dns_test.c
+++ b/lib/libcasper/services/cap_dns/tests/dns_test.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/capsicum.h>
#include <sys/nv.h>
@@ -200,18 +198,17 @@ hostent_compare(const struct hostent *hp0, const struct hostent *hp1)
static void
runtest(cap_channel_t *capdns, unsigned int expected)
{
- unsigned int result, failure;
+ unsigned int result;
struct addrinfo *ais, *aic, hints, *hintsp;
struct hostent *hps, *hpc;
struct in_addr ip4;
struct in6_addr ip6;
int caperr, syserr;
- failure = result = 0;
+ result = 0;
hps = gethostbyname("example.com");
if (hps == NULL) {
- failure |= GETHOSTBYNAME;
fprintf(stderr, "Unable to resolve %s IPv4.\n", "example.com");
} else {
hpc = cap_gethostbyname(capdns, "example.com");
@@ -221,7 +218,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
hps = gethostbyname2("example.com", AF_INET);
if (hps == NULL) {
- failure |= GETHOSTBYNAME2_AF_INET;
fprintf(stderr, "Unable to resolve %s IPv4.\n", "example.com");
} else {
hpc = cap_gethostbyname2(capdns, "example.com", AF_INET);
@@ -231,7 +227,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
hps = gethostbyname2("example.com", AF_INET6);
if (hps == NULL) {
- failure |= GETHOSTBYNAME2_AF_INET6;
fprintf(stderr, "Unable to resolve %s IPv6.\n", "example.com");
} else {
hpc = cap_gethostbyname2(capdns, "example.com", AF_INET6);
@@ -252,7 +247,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
syserr = getaddrinfo("freebsd.org", "25", hintsp, &ais);
if (syserr != 0) {
- failure |= GETADDRINFO_AF_UNSPEC;
fprintf(stderr,
"Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",
gai_strerror(syserr));
@@ -270,7 +264,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
hints.ai_family = AF_INET;
syserr = getaddrinfo("freebsd.org", "25", hintsp, &ais);
if (syserr != 0) {
- failure |= GETADDRINFO_AF_INET;
fprintf(stderr,
"Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",
gai_strerror(syserr));
@@ -288,7 +281,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
hints.ai_family = AF_INET6;
syserr = getaddrinfo("freebsd.org", "25", hintsp, &ais);
if (syserr != 0) {
- failure |= GETADDRINFO_AF_INET6;
fprintf(stderr,
"Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",
gai_strerror(syserr));
@@ -310,7 +302,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
inet_pton(AF_INET, GOOGLE_DNS_IPV4, &ip4);
hps = gethostbyaddr(&ip4, sizeof(ip4), AF_INET);
if (hps == NULL) {
- failure |= GETHOSTBYADDR_AF_INET;
fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV4);
} else {
hpc = cap_gethostbyaddr(capdns, &ip4, sizeof(ip4), AF_INET);
@@ -321,7 +312,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
inet_pton(AF_INET6, GOOGLE_DNS_IPV6, &ip6);
hps = gethostbyaddr(&ip6, sizeof(ip6), AF_INET6);
if (hps == NULL) {
- failure |= GETHOSTBYADDR_AF_INET6;
fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV6);
} else {
hpc = cap_gethostbyaddr(capdns, &ip6, sizeof(ip6), AF_INET6);
@@ -331,21 +321,6 @@ runtest(cap_channel_t *capdns, unsigned int expected)
}
}
- /*
- * If we had any failures, make sure that all lookups failed. If some
- * succeeded and some failed, there's a problem with the test or the DNS
- * and we should not fail silently.
- */
- if (failure != 0) {
- ATF_REQUIRE_MSG(failure == (GETHOSTBYNAME |
- GETHOSTBYNAME2_AF_INET | GETHOSTBYNAME2_AF_INET6 |
- GETADDRINFO_AF_UNSPEC | GETADDRINFO_AF_INET |
- GETADDRINFO_AF_INET6 |
- GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6),
- "expected all tests to fail, got 0x%x", failure);
- atf_tc_skip(
- "no name lookups succeeded, tests require Internet access");
- }
ATF_REQUIRE_MSG(result == expected,
"expected 0x%x, got 0x%x", expected, result);
}
@@ -369,6 +344,7 @@ cap_dns_init(void)
ATF_TC(dns_no_limits);
ATF_TC_HEAD(dns_no_limits, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_no_limits, tc)
{
@@ -388,6 +364,7 @@ ATF_TC_BODY(dns_no_limits, tc)
ATF_TC(dns_all_limits);
ATF_TC_HEAD(dns_all_limits, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_all_limits, tc)
{
@@ -419,6 +396,7 @@ ATF_TC_BODY(dns_all_limits, tc)
ATF_TC(dns_name_limit);
ATF_TC_HEAD(dns_name_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_name_limit, tc)
{
@@ -450,6 +428,7 @@ ATF_TC_BODY(dns_name_limit, tc)
ATF_TC(dns_addr_limit);
ATF_TC_HEAD(dns_addr_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_addr_limit, tc)
{
@@ -480,6 +459,7 @@ ATF_TC_BODY(dns_addr_limit, tc)
ATF_TC(dns_inet_limit);
ATF_TC_HEAD(dns_inet_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_inet_limit, tc)
{
@@ -511,6 +491,7 @@ ATF_TC_BODY(dns_inet_limit, tc)
ATF_TC(dns_inet6_limit);
ATF_TC_HEAD(dns_inet6_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_inet6_limit, tc)
{
@@ -542,6 +523,7 @@ ATF_TC_BODY(dns_inet6_limit, tc)
ATF_TC(dns_name_inet_limit);
ATF_TC_HEAD(dns_name_inet_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_name_inet_limit, tc)
{
@@ -583,6 +565,7 @@ ATF_TC_BODY(dns_name_inet_limit, tc)
ATF_TC(dns_name_inet6_limit);
ATF_TC_HEAD(dns_name_inet6_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_name_inet6_limit, tc)
{
@@ -624,6 +607,7 @@ ATF_TC_BODY(dns_name_inet6_limit, tc)
ATF_TC(dns_addr_inet_limit);
ATF_TC_HEAD(dns_addr_inet_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_addr_inet_limit, tc)
{
@@ -664,6 +648,7 @@ ATF_TC_BODY(dns_addr_inet_limit, tc)
ATF_TC(dns_addr_inet6_limit);
ATF_TC_HEAD(dns_addr_inet6_limit, tc)
{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
}
ATF_TC_BODY(dns_addr_inet6_limit, tc)
{
diff --git a/lib/libcasper/services/cap_fileargs/Makefile b/lib/libcasper/services/cap_fileargs/Makefile
index 31febd080962..2c52d0887a48 100644
--- a/lib/libcasper/services/cap_fileargs/Makefile
+++ b/lib/libcasper/services/cap_fileargs/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libcasper/services/cap_fileargs/cap_fileargs.3 b/lib/libcasper/services/cap_fileargs/cap_fileargs.3
index ef43c26cb3ed..c7ce45c518d1 100644
--- a/lib/libcasper/services/cap_fileargs/cap_fileargs.3
+++ b/lib/libcasper/services/cap_fileargs/cap_fileargs.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 10, 2021
+.Dd December 6, 2023
.Dt CAP_FILEARGS 3
.Os
.Sh NAME
@@ -169,6 +169,18 @@ The function
.Fn fileargs_realpath
is equivalent to
.Xr realpath 3 .
+.Pp
+.Fn fileargs_open ,
+.Fn fileargs_lstat ,
+.Fn fileargs_realpath ,
+.Fn fileargs_cinitnv ,
+.Fn fileargs_initnv ,
+and
+.Fn fileargs_fopen
+are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh LIMITS
This section describe which values and types should be used to pass arguments to the
.Fa system.fileargs
diff --git a/lib/libcasper/services/cap_fileargs/cap_fileargs.c b/lib/libcasper/services/cap_fileargs/cap_fileargs.c
index 859c862ef9e5..233b47ede613 100644
--- a/lib/libcasper/services/cap_fileargs/cap_fileargs.c
+++ b/lib/libcasper/services/cap_fileargs/cap_fileargs.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/capsicum.h>
#include <sys/sysctl.h>
diff --git a/lib/libcasper/services/cap_fileargs/tests/Makefile b/lib/libcasper/services/cap_fileargs/tests/Makefile
index 46059698aa07..02f02cceab8e 100644
--- a/lib/libcasper/services/cap_fileargs/tests/Makefile
+++ b/lib/libcasper/services/cap_fileargs/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
ATF_TESTS_C= fileargs_test
diff --git a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
index 4df43f183735..088edaaa294d 100644
--- a/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
+++ b/lib/libcasper/services/cap_fileargs/tests/fileargs_test.c
@@ -23,7 +23,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/capsicum.h>
#include <sys/stat.h>
@@ -292,7 +291,7 @@ ATF_TC_BODY(fileargs__open_read, tc)
prepare_files(MAX_FILES, true);
- cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_READ, CAP_FCNTL);
cap_rights_init(&norights, CAP_WRITE);
fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights,
FA_OPEN);
@@ -339,7 +338,7 @@ ATF_TC_BODY(fileargs__open_write, tc)
prepare_files(MAX_FILES, true);
- cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_WRITE, CAP_FCNTL);
cap_rights_init(&norights, CAP_READ);
fa = fileargs_init(MAX_FILES, files, O_WRONLY, 0, &rights,
FA_OPEN);
@@ -386,7 +385,7 @@ ATF_TC_BODY(fileargs__open_create, tc)
prepare_files(MAX_FILES, false);
- cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL | CAP_READ);
+ cap_rights_init(&rights, CAP_WRITE, CAP_FCNTL, CAP_READ);
cap_rights_init(&norights, CAP_FCHMOD);
fa = fileargs_init(MAX_FILES, files, O_RDWR | O_CREAT, 666,
&rights, FA_OPEN);
@@ -467,7 +466,7 @@ ATF_TC_BODY(fileargs__fopen_read, tc)
prepare_files(MAX_FILES, true);
- cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_READ, CAP_FCNTL);
cap_rights_init(&norights, CAP_WRITE);
fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights,
FA_OPEN);
@@ -517,7 +516,7 @@ ATF_TC_BODY(fileargs__fopen_write, tc)
prepare_files(MAX_FILES, true);
- cap_rights_init(&rights, CAP_WRITE | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_WRITE, CAP_FCNTL);
cap_rights_init(&norights, CAP_READ);
fa = fileargs_init(MAX_FILES, files, O_WRONLY, 0, &rights,
FA_OPEN);
@@ -567,7 +566,7 @@ ATF_TC_BODY(fileargs__fopen_create, tc)
prepare_files(MAX_FILES, false);
- cap_rights_init(&rights, CAP_READ | CAP_WRITE | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FCNTL);
fa = fileargs_init(MAX_FILES, files, O_RDWR | O_CREAT, 0, &rights,
FA_OPEN);
ATF_REQUIRE(fa != NULL);
@@ -673,7 +672,7 @@ ATF_TC_BODY(fileargs__open_lstat, tc)
prepare_files(MAX_FILES, true);
- cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_READ, CAP_FCNTL);
cap_rights_init(&norights, CAP_WRITE);
fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights,
FA_OPEN | FA_LSTAT);
@@ -721,7 +720,7 @@ ATF_TC_BODY(fileargs__open_realpath, tc)
prepare_files(MAX_FILES, true);
- cap_rights_init(&rights, CAP_READ | CAP_FCNTL);
+ cap_rights_init(&rights, CAP_READ, CAP_FCNTL);
cap_rights_init(&norights, CAP_WRITE);
fa = fileargs_init(MAX_FILES, files, O_RDONLY, 0, &rights,
FA_OPEN | FA_REALPATH);
diff --git a/lib/libcasper/services/cap_grp/Makefile b/lib/libcasper/services/cap_grp/Makefile
index b46f3bfdaa47..a921dfa87e7c 100644
--- a/lib/libcasper/services/cap_grp/Makefile
+++ b/lib/libcasper/services/cap_grp/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -40,3 +39,6 @@ MLINKS+=cap_grp.3 cap_grp_limit_fields.3
MLINKS+=cap_grp.3 cap_grp_limit_groups.3
.include <bsd.lib.mk>
+
+# GCC 13 complains incorrectly about free after failed realloc: GCC bug #110501
+CFLAGS.cap_grp.c+= ${NO_WUSE_AFTER_FREE}
diff --git a/lib/libcasper/services/cap_grp/cap_grp.3 b/lib/libcasper/services/cap_grp/cap_grp.3
index 7c1bf0320e25..578d8edffbfa 100644
--- a/lib/libcasper/services/cap_grp/cap_grp.3
+++ b/lib/libcasper/services/cap_grp/cap_grp.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 5, 2020
+.Dd December 6, 2023
.Dt CAP_GRP 3
.Os
.Sh NAME
@@ -59,7 +59,7 @@
.Fn cap_getgrgid_r "cap_channel_t *chan" "gid_t gid" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
.Ft int
.Fn cap_setgroupent "cap_channel_t *chan" "int stayopen"
-.Ft int
+.Ft int
.Fn cap_setgrent "cap_channel_t *chan"
.Ft void
.Fn cap_endgrent "cap_channel_t *chan"
@@ -152,6 +152,11 @@ The
and
.Fa ngids
variables provide numbers of limited names and gids.
+.Pp
+All of these functions are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh EXAMPLES
The following example first opens a capability to casper and then uses this
capability to create the
diff --git a/lib/libcasper/services/cap_grp/cap_grp.c b/lib/libcasper/services/cap_grp/cap_grp.c
index 6a5ad84fcd22..025ce00adf56 100644
--- a/lib/libcasper/services/cap_grp/cap_grp.c
+++ b/lib/libcasper/services/cap_grp/cap_grp.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libcasper/services/cap_grp/cap_grp.h b/lib/libcasper/services/cap_grp/cap_grp.h
index a478a91cf760..9be2e7a78dd5 100644
--- a/lib/libcasper/services/cap_grp/cap_grp.h
+++ b/lib/libcasper/services/cap_grp/cap_grp.h
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libcasper/services/cap_grp/tests/Makefile b/lib/libcasper/services/cap_grp/tests/Makefile
index 18074380b7f0..f57d58972c52 100644
--- a/lib/libcasper/services/cap_grp/tests/Makefile
+++ b/lib/libcasper/services/cap_grp/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
TAP_TESTS_C= grp_test
diff --git a/lib/libcasper/services/cap_grp/tests/Makefile.depend b/lib/libcasper/services/cap_grp/tests/Makefile.depend
index 11aba52f82cf..fd331b1176a3 100644
--- a/lib/libcasper/services/cap_grp/tests/Makefile.depend
+++ b/lib/libcasper/services/cap_grp/tests/Makefile.depend
@@ -1,6 +1,14 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_grp \
+ lib/libcompiler_rt \
+ lib/libnv \
.include <dirdeps.mk>
diff --git a/lib/libcasper/services/cap_grp/tests/grp_test.c b/lib/libcasper/services/cap_grp/tests/grp_test.c
index c120c61e0cf1..d7e9cf12954a 100644
--- a/lib/libcasper/services/cap_grp/tests/grp_test.c
+++ b/lib/libcasper/services/cap_grp/tests/grp_test.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/capsicum.h>
#include <sys/nv.h>
diff --git a/lib/libcasper/services/cap_net/Makefile b/lib/libcasper/services/cap_net/Makefile
index 365d5bb63e9d..1ba35a674a05 100644
--- a/lib/libcasper/services/cap_net/Makefile
+++ b/lib/libcasper/services/cap_net/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libcasper/services/cap_net/Makefile.depend b/lib/libcasper/services/cap_net/Makefile.depend
index e69de29bb2d1..02bae00eb04d 100644
--- a/lib/libcasper/services/cap_net/Makefile.depend
+++ b/lib/libcasper/services/cap_net/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libcasper/services/cap_net/cap_net.3 b/lib/libcasper/services/cap_net/cap_net.3
index 97a044e3f950..e322222e866f 100644
--- a/lib/libcasper/services/cap_net/cap_net.3
+++ b/lib/libcasper/services/cap_net/cap_net.3
@@ -21,7 +21,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 15, 2021
+.Dd December 6, 2023
.Dt CAP_NET 3
.Os
.Sh NAME
@@ -84,22 +84,31 @@
The functions
.Fn cap_bind ,
.Fn cap_connect ,
+.Fn cap_getaddrinfo ,
+.Fn cap_getnameinfo ,
.Fn cap_gethostbyname ,
.Fn cap_gethostbyname2 ,
-.Fn cap_gethostbyaddr
and
-.Fn cap_getnameinfo
+.Fn cap_gethostbyaddr
provide a set of APIs equivalent to
.Xr bind 2 ,
.Xr connect 2 ,
+.Xr getaddrinfo 3 ,
+.Xr getnameinfo 3 ,
.Xr gethostbyname 3 ,
.Xr gethostbyname2 3 ,
-.Xr gethostbyaddr 3
and
-.Xr getnameinfo 3
+.Xr gethostbyaddr 3
except that a connection to the
.Nm system.net
service needs to be provided.
+.Pp
+These functions, as well as
+.Fn cap_net_limit ,
+are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh LIMITS
By default, the cap_net capability provides unrestricted access to the network
namespace.
@@ -112,7 +121,7 @@ The
.Fn cap_net_limit_init
returns an opaque limit handle used to store a list of capabilities.
The
-.Fv mode
+.Fa mode
restricts the functionality of the service.
Modes are encoded using the following flags:
.Pp
@@ -188,17 +197,14 @@ any port will be accepted in the
.Fn cap_connect
function.
.Pp
+The
.Fn cap_net_limit
-applies a set of sysctl limits to the capability, denying access to sysctl
-variables not belonging to the set.
+will consume and apply the limits.
.Pp
Once a set of limits is applied, subsequent calls to
.Fn cap_net_limit
will fail unless the new set is a subset of the current set.
.Pp
-The
-.Fn cap_net_limit
-will consume the limits.
If the
.Fn cap_net_limit
was not called the rights may be freed using
diff --git a/lib/libcasper/services/cap_net/cap_net.c b/lib/libcasper/services/cap_net/cap_net.c
index bbb2a666440f..5887fe3c407e 100644
--- a/lib/libcasper/services/cap_net/cap_net.c
+++ b/lib/libcasper/services/cap_net/cap_net.c
@@ -105,7 +105,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_length = (int)nvlist_get_number(nvl, "length");
nitems = (unsigned int)nvlist_get_number(nvl, "naliases");
- hp->h_aliases = calloc(sizeof(hp->h_aliases[0]), nitems + 1);
+ hp->h_aliases = calloc(nitems + 1, sizeof(hp->h_aliases[0]));
if (hp->h_aliases == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
@@ -119,7 +119,7 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_aliases[ii] = NULL;
nitems = (unsigned int)nvlist_get_number(nvl, "naddrs");
- hp->h_addr_list = calloc(sizeof(hp->h_addr_list[0]), nitems + 1);
+ hp->h_addr_list = calloc(nitems + 1, sizeof(hp->h_addr_list[0]));
if (hp->h_addr_list == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
@@ -288,7 +288,7 @@ cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
const nvlist_t *nvlai;
char nvlname[64];
nvlist_t *nvl;
- int error, n;
+ int error, serrno, n;
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "getaddrinfo");
@@ -311,7 +311,9 @@ cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
return (EAI_MEMORY);
if (nvlist_get_number(nvl, "error") != 0) {
error = (int)nvlist_get_number(nvl, "error");
+ serrno = dnvlist_get_number(nvl, "errno", 0);
nvlist_destroy(nvl);
+ errno = (error == EAI_SYSTEM) ? serrno : 0;
return (error);
}
@@ -350,7 +352,7 @@ cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen,
char *host, size_t hostlen, char *serv, size_t servlen, int flags)
{
nvlist_t *nvl;
- int error;
+ int error, serrno;
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "getnameinfo");
@@ -363,7 +365,9 @@ cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen,
return (EAI_MEMORY);
if (nvlist_get_number(nvl, "error") != 0) {
error = (int)nvlist_get_number(nvl, "error");
+ serrno = dnvlist_get_number(nvl, "errno", 0);
nvlist_destroy(nvl);
+ errno = (error == EAI_SYSTEM) ? serrno : 0;
return (error);
}
@@ -858,19 +862,21 @@ net_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
char *host, *serv;
size_t sabinsize, hostlen, servlen;
socklen_t salen;
- int error, flags;
+ int error, serrno, flags;
const nvlist_t *funclimit;
- if (!net_allowed_mode(limits, CAPNET_ADDR2NAME))
- return (ENOTCAPABLE);
+ host = serv = NULL;
+ if (!net_allowed_mode(limits, CAPNET_ADDR2NAME)) {
+ serrno = ENOTCAPABLE;
+ error = EAI_SYSTEM;
+ goto out;
+ }
funclimit = NULL;
if (limits != NULL) {
funclimit = dnvlist_get_nvlist(limits, LIMIT_NV_ADDR2NAME,
NULL);
}
-
error = 0;
- host = serv = NULL;
memset(&sast, 0, sizeof(sast));
hostlen = (size_t)nvlist_get_number(nvlin, "hostlen");
@@ -897,7 +903,8 @@ net_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
goto out;
}
if (!net_allowed_bsaddr(funclimit, sabin, sabinsize)) {
- error = ENOTCAPABLE;
+ serrno = ENOTCAPABLE;
+ error = EAI_SYSTEM;
goto out;
}
@@ -913,7 +920,8 @@ net_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
}
if (!net_allowed_family(funclimit, (int)sast.ss_family)) {
- error = ENOTCAPABLE;
+ serrno = ENOTCAPABLE;
+ error = EAI_SYSTEM;
goto out;
}
@@ -921,6 +929,7 @@ net_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
error = getnameinfo((struct sockaddr *)&sast, salen, host, hostlen,
serv, servlen, flags);
+ serrno = errno;
if (error != 0)
goto out;
@@ -932,6 +941,8 @@ out:
if (error != 0) {
free(host);
free(serv);
+ if (error == EAI_SYSTEM)
+ nvlist_add_number(nvlout, "errno", serrno);
}
return (error);
}
@@ -961,12 +972,15 @@ net_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
char nvlname[64];
nvlist_t *elem;
unsigned int ii;
- int error, family, n;
+ int error, serrno, family, n;
const nvlist_t *funclimit;
bool dnscache;
- if (!net_allowed_mode(limits, CAPNET_NAME2ADDR))
- return (ENOTCAPABLE);
+ if (!net_allowed_mode(limits, CAPNET_NAME2ADDR)) {
+ serrno = ENOTCAPABLE;
+ error = EAI_SYSTEM;
+ goto out;
+ }
dnscache = net_allowed_mode(limits, CAPNET_CONNECTDNS);
funclimit = NULL;
if (limits != NULL) {
@@ -996,11 +1010,18 @@ net_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
family = AF_UNSPEC;
}
- if (!net_allowed_family(funclimit, family))
- return (ENOTCAPABLE);
- if (!net_allowed_hosts(funclimit, hostname, servname))
- return (ENOTCAPABLE);
+ if (!net_allowed_family(funclimit, family)) {
+ errno = ENOTCAPABLE;
+ error = EAI_SYSTEM;
+ goto out;
+ }
+ if (!net_allowed_hosts(funclimit, hostname, servname)) {
+ errno = ENOTCAPABLE;
+ error = EAI_SYSTEM;
+ goto out;
+ }
error = getaddrinfo(hostname, servname, hintsp, &res);
+ serrno = errno;
if (error != 0) {
goto out;
}
@@ -1019,6 +1040,8 @@ net_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
freeaddrinfo(res);
error = 0;
out:
+ if (error == EAI_SYSTEM)
+ nvlist_add_number(nvlout, "errno", serrno);
return (error);
}
@@ -1232,7 +1255,7 @@ verify_name2addr_newlimits(const nvlist_t *oldlimits,
oldfunclimits = NULL;
if (oldlimits != NULL) {
oldfunclimits = dnvlist_get_nvlist(oldlimits,
- LIMIT_NV_ADDR2NAME, NULL);
+ LIMIT_NV_NAME2ADDR, NULL);
}
cookie = NULL;
diff --git a/lib/libcasper/services/cap_net/cap_net.h b/lib/libcasper/services/cap_net/cap_net.h
index 1e9a6021d240..75f936954199 100644
--- a/lib/libcasper/services/cap_net/cap_net.h
+++ b/lib/libcasper/services/cap_net/cap_net.h
@@ -93,18 +93,14 @@ struct hostent *cap_gethostbyaddr(cap_channel_t *chan, const void *addr,
socklen_t len, int af);
#else
/* Capability functions. */
-#define cap_bind(chan, s, addr, addrlen) \
- bind(s, addr, addrlen)
-#define cap_connect(chan, s, name, namelen) \
- connect(s, name, namelen)
-#define cap_getaddrinfo(chan, hostname, servname, hints, res) \
- getaddrinfo(hostname, servname, hints, res)
-#define cap_getnameinfo(chan, sa, salen, host, hostlen, serv, servlen, flags) \
- getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
+#define cap_bind(chan, ...) bind(__VA_ARGS__)
+#define cap_connect(chan, ...) connect(__VA_ARGS__)
+#define cap_getaddrinfo(chan, ...) getaddrinfo(__VA_ARGS__)
+#define cap_getnameinfo(chan, ...) getnameinfo(__VA_ARGS__)
/* Limit functions. */
-#define cap_net_limit_init(chan, mode) ((cap_net_limit_t *)malloc(8))
-#define cap_net_free(limit) free(limit)
+#define cap_net_limit_init(chan, ...) ((cap_net_limit_t *)malloc(8))
+#define cap_net_free(...) free(__VA_ARGS__)
static inline int
cap_net_limit(cap_net_limit_t *limit)
{
@@ -155,9 +151,9 @@ cap_net_limit_bind(cap_net_limit_t *limit,
}
/* Deprecated functions. */
-#define cap_gethostbyname(chan, name) gethostbyname(name)
-#define cap_gethostbyname2(chan, name, type) gethostbyname2(name, type)
-#define cap_gethostbyaddr(chan, addr, len, type) gethostbyaddr(addr, len, type)
+#define cap_gethostbyname(chan, ...) gethostbyname(__VA_ARGS__)
+#define cap_gethostbyname2(chan, ...) gethostbyname2(__VA_ARGS__)
+#define cap_gethostbyaddr(chan, ...) gethostbyaddr(__VA_ARGS__)
#endif
#endif /* !_CAP_NETWORK_H_ */
diff --git a/lib/libcasper/services/cap_net/tests/Makefile b/lib/libcasper/services/cap_net/tests/Makefile
index 7b0b98f869bf..5798d7385440 100644
--- a/lib/libcasper/services/cap_net/tests/Makefile
+++ b/lib/libcasper/services/cap_net/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
ATF_TESTS_C= net_test
diff --git a/lib/libcasper/services/cap_net/tests/net_test.c b/lib/libcasper/services/cap_net/tests/net_test.c
index 5522f92516eb..adf5773233c8 100644
--- a/lib/libcasper/services/cap_net/tests/net_test.c
+++ b/lib/libcasper/services/cap_net/tests/net_test.c
@@ -23,7 +23,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -332,7 +331,11 @@ test_extend_mode(cap_channel_t *capnet, int current)
}
}
-ATF_TC_WITHOUT_HEAD(capnet__getnameinfo);
+ATF_TC(capnet__getnameinfo);
+ATF_TC_HEAD(capnet__getnameinfo, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__getnameinfo, tc)
{
cap_channel_t *capnet;
@@ -345,7 +348,11 @@ ATF_TC_BODY(capnet__getnameinfo, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__connect);
+ATF_TC(capnet__connect);
+ATF_TC_HEAD(capnet__connect, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__connect, tc)
{
cap_channel_t *capnet;
@@ -357,7 +364,11 @@ ATF_TC_BODY(capnet__connect, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__bind);
+ATF_TC(capnet__bind);
+ATF_TC_HEAD(capnet__bind, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__bind, tc)
{
cap_channel_t *capnet;
@@ -369,7 +380,11 @@ ATF_TC_BODY(capnet__bind, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__getaddrinfo);
+ATF_TC(capnet__getaddrinfo);
+ATF_TC_HEAD(capnet__getaddrinfo, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__getaddrinfo, tc)
{
cap_channel_t *capnet;
@@ -387,7 +402,11 @@ ATF_TC_BODY(capnet__getaddrinfo, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__gethostbyname);
+ATF_TC(capnet__gethostbyname);
+ATF_TC_HEAD(capnet__gethostbyname, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__gethostbyname, tc)
{
cap_channel_t *capnet;
@@ -399,7 +418,11 @@ ATF_TC_BODY(capnet__gethostbyname, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__gethostbyaddr);
+ATF_TC(capnet__gethostbyaddr);
+ATF_TC_HEAD(capnet__gethostbyaddr, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__gethostbyaddr, tc)
{
cap_channel_t *capnet;
@@ -412,7 +435,11 @@ ATF_TC_BODY(capnet__gethostbyaddr, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__getnameinfo_buffer);
+ATF_TC(capnet__getnameinfo_buffer);
+ATF_TC_HEAD(capnet__getnameinfo_buffer, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__getnameinfo_buffer, tc)
{
cap_channel_t *chan;
@@ -451,7 +478,11 @@ ATF_TC_BODY(capnet__getnameinfo_buffer, tc)
cap_close(chan);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_addr2name_mode);
+ATF_TC(capnet__limits_addr2name_mode);
+ATF_TC_HEAD(capnet__limits_addr2name_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_addr2name_mode, tc)
{
cap_channel_t *capnet;
@@ -482,7 +513,11 @@ ATF_TC_BODY(capnet__limits_addr2name_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_addr2name_family);
+ATF_TC(capnet__limits_addr2name_family);
+ATF_TC_HEAD(capnet__limits_addr2name_family, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_addr2name_family, tc)
{
cap_channel_t *capnet;
@@ -527,7 +562,11 @@ ATF_TC_BODY(capnet__limits_addr2name_family, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_addr2name);
+ATF_TC(capnet__limits_addr2name);
+ATF_TC_HEAD(capnet__limits_addr2name, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_addr2name, tc)
{
cap_channel_t *capnet;
@@ -581,7 +620,11 @@ ATF_TC_BODY(capnet__limits_addr2name, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_addr2name_mode);
+ATF_TC(capnet__limits_deprecated_addr2name_mode);
+ATF_TC_HEAD(capnet__limits_deprecated_addr2name_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_addr2name_mode, tc)
{
cap_channel_t *capnet;
@@ -610,7 +653,11 @@ ATF_TC_BODY(capnet__limits_deprecated_addr2name_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_addr2name_family);
+ATF_TC(capnet__limits_deprecated_addr2name_family);
+ATF_TC_HEAD(capnet__limits_deprecated_addr2name_family, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_addr2name_family, tc)
{
cap_channel_t *capnet;
@@ -661,7 +708,11 @@ ATF_TC_BODY(capnet__limits_deprecated_addr2name_family, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_addr2name);
+ATF_TC(capnet__limits_deprecated_addr2name);
+ATF_TC_HEAD(capnet__limits_deprecated_addr2name, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_addr2name, tc)
{
cap_channel_t *capnet;
@@ -713,7 +764,11 @@ ATF_TC_BODY(capnet__limits_deprecated_addr2name, tc)
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_name2addr_mode);
+ATF_TC(capnet__limits_name2addr_mode);
+ATF_TC_HEAD(capnet__limits_name2addr_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_name2addr_mode, tc)
{
cap_channel_t *capnet;
@@ -745,7 +800,11 @@ ATF_TC_BODY(capnet__limits_name2addr_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_name2addr_hosts);
+ATF_TC(capnet__limits_name2addr_hosts);
+ATF_TC_HEAD(capnet__limits_name2addr_hosts, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_name2addr_hosts, tc)
{
cap_channel_t *capnet;
@@ -783,10 +842,26 @@ ATF_TC_BODY(capnet__limits_name2addr_hosts, tc)
limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR);
ATF_REQUIRE(cap_net_limit(limit) != 0);
+ /* Try to extend the limit. */
+ limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR);
+ ATF_REQUIRE(limit != NULL);
+ cap_net_limit_name2addr(limit, TEST_DOMAIN_1, NULL);
+ ATF_REQUIRE(cap_net_limit(limit) != 0);
+
+ limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR);
+ ATF_REQUIRE(limit != NULL);
+ cap_net_limit_name2addr(limit, TEST_DOMAIN_0, NULL);
+ cap_net_limit_name2addr(limit, TEST_DOMAIN_1, NULL);
+ ATF_REQUIRE(cap_net_limit(limit) != 0);
+
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_name2addr_hosts_servnames_strict);
+ATF_TC(capnet__limits_name2addr_hosts_servnames_strict);
+ATF_TC_HEAD(capnet__limits_name2addr_hosts_servnames_strict, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_name2addr_hosts_servnames_strict, tc)
{
cap_channel_t *capnet;
@@ -818,7 +893,11 @@ ATF_TC_BODY(capnet__limits_name2addr_hosts_servnames_strict, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_name2addr_hosts_servnames_mix);
+ATF_TC(capnet__limits_name2addr_hosts_servnames_mix);
+ATF_TC_HEAD(capnet__limits_name2addr_hosts_servnames_mix, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_name2addr_hosts_servnames_mix, tc)
{
cap_channel_t *capnet;
@@ -847,7 +926,7 @@ ATF_TC_BODY(capnet__limits_name2addr_hosts_servnames_mix, tc)
ATF_REQUIRE(test_getaddrinfo(capnet, AF_INET, TEST_DOMAIN_1, "snmp") ==
ENOTCAPABLE);
- /* Limit to HTTTP servname only. */
+ /* Limit to HTTP servname only. */
limit = cap_net_limit_init(capnet, CAPNET_NAME2ADDR);
ATF_REQUIRE(limit != NULL);
cap_net_limit_name2addr(limit, NULL, "http");
@@ -871,7 +950,11 @@ ATF_TC_BODY(capnet__limits_name2addr_hosts_servnames_mix, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_name2addr_family);
+ATF_TC(capnet__limits_name2addr_family);
+ATF_TC_HEAD(capnet__limits_name2addr_family, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_name2addr_family, tc)
{
cap_channel_t *capnet;
@@ -930,7 +1013,11 @@ ATF_TC_BODY(capnet__limits_name2addr_family, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_name2addr_mode);
+ATF_TC(capnet__limits_deprecated_name2addr_mode);
+ATF_TC_HEAD(capnet__limits_deprecated_name2addr_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_name2addr_mode, tc)
{
cap_channel_t *capnet;
@@ -961,7 +1048,11 @@ ATF_TC_BODY(capnet__limits_deprecated_name2addr_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_name2addr_hosts);
+ATF_TC(capnet__limits_deprecated_name2addr_hosts);
+ATF_TC_HEAD(capnet__limits_deprecated_name2addr_hosts, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_name2addr_hosts, tc)
{
cap_channel_t *capnet;
@@ -1000,7 +1091,11 @@ ATF_TC_BODY(capnet__limits_deprecated_name2addr_hosts, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_name2addr_family);
+ATF_TC(capnet__limits_deprecated_name2addr_family);
+ATF_TC_HEAD(capnet__limits_deprecated_name2addr_family, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_name2addr_family, tc)
{
cap_channel_t *capnet;
@@ -1054,7 +1149,11 @@ ATF_TC_BODY(capnet__limits_deprecated_name2addr_family, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_bind_mode);
+ATF_TC(capnet__limits_bind_mode);
+ATF_TC_HEAD(capnet__limits_bind_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_bind_mode, tc)
{
cap_channel_t *capnet;
@@ -1086,7 +1185,11 @@ ATF_TC_BODY(capnet__limits_bind_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_bind);
+ATF_TC(capnet__limits_bind);
+ATF_TC_HEAD(capnet__limits_bind, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_bind, tc)
{
cap_channel_t *capnet;
@@ -1111,7 +1214,11 @@ ATF_TC_BODY(capnet__limits_bind, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_connect_mode);
+ATF_TC(capnet__limits_connect_mode);
+ATF_TC_HEAD(capnet__limits_connect_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_connect_mode, tc)
{
cap_channel_t *capnet;
@@ -1143,7 +1250,11 @@ ATF_TC_BODY(capnet__limits_connect_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_connect_dns_mode);
+ATF_TC(capnet__limits_connect_dns_mode);
+ATF_TC_HEAD(capnet__limits_connect_dns_mode, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_connect_dns_mode, tc)
{
cap_channel_t *capnet;
@@ -1175,7 +1286,11 @@ ATF_TC_BODY(capnet__limits_connect_dns_mode, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_connect);
+ATF_TC(capnet__limits_connect);
+ATF_TC_HEAD(capnet__limits_connect, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_connect, tc)
{
cap_channel_t *capnet;
@@ -1219,7 +1334,11 @@ ATF_TC_BODY(capnet__limits_connect, tc)
cap_close(capnet);
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_connecttodns);
+ATF_TC(capnet__limits_connecttodns);
+ATF_TC_HEAD(capnet__limits_connecttodns, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_connecttodns, tc)
{
cap_channel_t *capnet;
@@ -1268,7 +1387,11 @@ ATF_TC_BODY(capnet__limits_connecttodns, tc)
}
-ATF_TC_WITHOUT_HEAD(capnet__limits_deprecated_connecttodns);
+ATF_TC(capnet__limits_deprecated_connecttodns);
+ATF_TC_HEAD(capnet__limits_deprecated_connecttodns, tc)
+{
+ atf_tc_set_md_var(tc, "require.config", "allow_network_access");
+}
ATF_TC_BODY(capnet__limits_deprecated_connecttodns, tc)
{
cap_channel_t *capnet;
diff --git a/lib/libcasper/services/cap_netdb/Makefile b/lib/libcasper/services/cap_netdb/Makefile
index 36c57103b414..853052e78d04 100644
--- a/lib/libcasper/services/cap_netdb/Makefile
+++ b/lib/libcasper/services/cap_netdb/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -29,3 +28,6 @@ MLINKS+=cap_netdb.3 libcap_netdb.3
MLINKS+=cap_netdb.3 cap_getprotobyname.3
.include <bsd.lib.mk>
+
+# GCC 13 complains incorrectly about free after failed realloc: GCC bug #110501
+CFLAGS.cap_netdb.c+= ${NO_WUSE_AFTER_FREE}
diff --git a/lib/libcasper/services/cap_netdb/Makefile.depend b/lib/libcasper/services/cap_netdb/Makefile.depend
index e69de29bb2d1..02bae00eb04d 100644
--- a/lib/libcasper/services/cap_netdb/Makefile.depend
+++ b/lib/libcasper/services/cap_netdb/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcompiler_rt \
+ lib/libnv \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libcasper/services/cap_netdb/cap_netdb.3 b/lib/libcasper/services/cap_netdb/cap_netdb.3
index 1f08ff275067..1f587c2057e7 100644
--- a/lib/libcasper/services/cap_netdb/cap_netdb.3
+++ b/lib/libcasper/services/cap_netdb/cap_netdb.3
@@ -21,7 +21,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 29, 2022
+.Dd December 6, 2023
.Dt CAP_NETDB 3
.Os
.Sh NAME
@@ -43,6 +43,10 @@ is equivalent to
except that the connection to the
.Nm system.netdb
service needs to be provided.
+It is reentrant but not thread-safe.
+That is, it may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh EXAMPLES
The following example first opens a capability to casper and then uses this
capability to create the
diff --git a/lib/libcasper/services/cap_netdb/tests/Makefile b/lib/libcasper/services/cap_netdb/tests/Makefile
index a2f90206488f..bc5e04578323 100644
--- a/lib/libcasper/services/cap_netdb/tests/Makefile
+++ b/lib/libcasper/services/cap_netdb/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
ATF_TESTS_C= netdb_test
diff --git a/lib/libcasper/services/cap_netdb/tests/netdb_test.c b/lib/libcasper/services/cap_netdb/tests/netdb_test.c
index d4498e68ace0..5b984a8f6bd2 100644
--- a/lib/libcasper/services/cap_netdb/tests/netdb_test.c
+++ b/lib/libcasper/services/cap_netdb/tests/netdb_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/capsicum.h>
#include <sys/nv.h>
diff --git a/lib/libcasper/services/cap_pwd/Makefile b/lib/libcasper/services/cap_pwd/Makefile
index be6b4b21070f..a1e97845c736 100644
--- a/lib/libcasper/services/cap_pwd/Makefile
+++ b/lib/libcasper/services/cap_pwd/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -40,3 +39,6 @@ MLINKS+=cap_pwd.3 cap_pwd_limit_fields.3
MLINKS+=cap_pwd.3 cap_pwd_limit_users.3
.include <bsd.lib.mk>
+
+# GCC 13 complains incorrectly about free after failed realloc: GCC bug #110501
+CFLAGS.cap_pwd.c+= ${NO_WUSE_AFTER_FREE}
diff --git a/lib/libcasper/services/cap_pwd/cap_pwd.3 b/lib/libcasper/services/cap_pwd/cap_pwd.3
index 7417d177a678..b66a0cd083ba 100644
--- a/lib/libcasper/services/cap_pwd/cap_pwd.3
+++ b/lib/libcasper/services/cap_pwd/cap_pwd.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 5, 2020
+.Dd December 6, 2023
.Dt CAP_PWD 3
.Os
.Sh NAME
@@ -158,6 +158,11 @@ The
and
.Fa nuids
variables provide numbers of limited names and uids.
+.Pp
+All of these functions are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh EXAMPLES
The following example first opens a capability to casper and then uses this
capability to create the
diff --git a/lib/libcasper/services/cap_pwd/cap_pwd.c b/lib/libcasper/services/cap_pwd/cap_pwd.c
index 263bc4cfd582..1b5963d8be3d 100644
--- a/lib/libcasper/services/cap_pwd/cap_pwd.c
+++ b/lib/libcasper/services/cap_pwd/cap_pwd.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/nv.h>
diff --git a/lib/libcasper/services/cap_pwd/cap_pwd.h b/lib/libcasper/services/cap_pwd/cap_pwd.h
index 35e0e177bc62..496beea26392 100644
--- a/lib/libcasper/services/cap_pwd/cap_pwd.h
+++ b/lib/libcasper/services/cap_pwd/cap_pwd.h
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libcasper/services/cap_pwd/tests/Makefile b/lib/libcasper/services/cap_pwd/tests/Makefile
index dcda3ad94828..79df81416d45 100644
--- a/lib/libcasper/services/cap_pwd/tests/Makefile
+++ b/lib/libcasper/services/cap_pwd/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
TAP_TESTS_C= pwd_test
diff --git a/lib/libcasper/services/cap_pwd/tests/Makefile.depend b/lib/libcasper/services/cap_pwd/tests/Makefile.depend
index 11aba52f82cf..e03864c8ad46 100644
--- a/lib/libcasper/services/cap_pwd/tests/Makefile.depend
+++ b/lib/libcasper/services/cap_pwd/tests/Makefile.depend
@@ -1,6 +1,14 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_pwd \
+ lib/libcompiler_rt \
+ lib/libnv \
.include <dirdeps.mk>
diff --git a/lib/libcasper/services/cap_pwd/tests/pwd_test.c b/lib/libcasper/services/cap_pwd/tests/pwd_test.c
index e56c037536e2..68bb00650350 100644
--- a/lib/libcasper/services/cap_pwd/tests/pwd_test.c
+++ b/lib/libcasper/services/cap_pwd/tests/pwd_test.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/capsicum.h>
#include <sys/nv.h>
diff --git a/lib/libcasper/services/cap_sysctl/Makefile b/lib/libcasper/services/cap_sysctl/Makefile
index 73da70acaeb6..522313df4ffc 100644
--- a/lib/libcasper/services/cap_sysctl/Makefile
+++ b/lib/libcasper/services/cap_sysctl/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libcasper/services/cap_sysctl/cap_sysctl.3 b/lib/libcasper/services/cap_sysctl/cap_sysctl.3
index c007c04aa3b7..2c7a491a1f8b 100644
--- a/lib/libcasper/services/cap_sysctl/cap_sysctl.3
+++ b/lib/libcasper/services/cap_sysctl/cap_sysctl.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 1, 2022
+.Dd December 6, 2023
.Dt CAP_SYSCTL 3
.Os
.Sh NAME
@@ -64,6 +64,15 @@ except that they are implemented by the
service and require a corresponding
.Xr libcasper 3
capability.
+.Pp
+All of these functions, with the exceptions of
+.Fn cap_sysctl_limit_init
+and
+.Fn cap_sysctl_limit_mib ,
+are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh LIMITS
By default, the
.Nm
diff --git a/lib/libcasper/services/cap_sysctl/cap_sysctl.c b/lib/libcasper/services/cap_sysctl/cap_sysctl.c
index 7d7f280fd00b..c99fd74cb169 100644
--- a/lib/libcasper/services/cap_sysctl/cap_sysctl.c
+++ b/lib/libcasper/services/cap_sysctl/cap_sysctl.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013, 2018 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -32,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/cnv.h>
#include <sys/dnv.h>
diff --git a/lib/libcasper/services/cap_sysctl/cap_sysctl.h b/lib/libcasper/services/cap_sysctl/cap_sysctl.h
index fd7d051f21c8..51243128a683 100644
--- a/lib/libcasper/services/cap_sysctl/cap_sysctl.h
+++ b/lib/libcasper/services/cap_sysctl/cap_sysctl.h
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libcasper/services/cap_sysctl/tests/Makefile b/lib/libcasper/services/cap_sysctl/tests/Makefile
index 820018513621..85bb0d28c389 100644
--- a/lib/libcasper/services/cap_sysctl/tests/Makefile
+++ b/lib/libcasper/services/cap_sysctl/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
ATF_TESTS_C= sysctl_test
diff --git a/lib/libcasper/services/cap_sysctl/tests/Makefile.depend b/lib/libcasper/services/cap_sysctl/tests/Makefile.depend
index 11aba52f82cf..1938a0318d2c 100644
--- a/lib/libcasper/services/cap_sysctl/tests/Makefile.depend
+++ b/lib/libcasper/services/cap_sysctl/tests/Makefile.depend
@@ -1,6 +1,15 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/atf/libatf-c \
+ lib/libc \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_sysctl \
+ lib/libcompiler_rt \
+ lib/libnv \
.include <dirdeps.mk>
diff --git a/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c b/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
index 2e5ec83e1c82..300333f11790 100644
--- a/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
+++ b/lib/libcasper/services/cap_sysctl/tests/sysctl_test.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013, 2018 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -32,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/capsicum.h>
#include <sys/sysctl.h>
diff --git a/lib/libcasper/services/cap_syslog/Makefile b/lib/libcasper/services/cap_syslog/Makefile
index 4c20f697019f..88979d8bed23 100644
--- a/lib/libcasper/services/cap_syslog/Makefile
+++ b/lib/libcasper/services/cap_syslog/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libcasper/services/cap_syslog/cap_syslog.3 b/lib/libcasper/services/cap_syslog/cap_syslog.3
index 7e5376c5ca89..4d6463ef3f81 100644
--- a/lib/libcasper/services/cap_syslog/cap_syslog.3
+++ b/lib/libcasper/services/cap_syslog/cap_syslog.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 5, 2020
+.Dd December 6, 2023
.Dt CAP_SYSLOG 3
.Os
.Sh NAME
@@ -63,6 +63,11 @@ are respectively equivalent to
except that the connection to the
.Nm system.syslog
service needs to be provided.
+.Pp
+All of these functions are reentrant but not thread-safe.
+That is, they may be called from separate threads only with different
+.Vt cap_channel_t
+arguments or with synchronization.
.Sh EXAMPLES
The following example first opens a capability to casper and then uses this
capability to create the
diff --git a/lib/libcasper/services/tests/Makefile b/lib/libcasper/services/tests/Makefile
index b8996030aafc..29b1b564beca 100644
--- a/lib/libcasper/services/tests/Makefile
+++ b/lib/libcasper/services/tests/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/lib/libcasper/tests/Makefile b/lib/libcasper/tests/Makefile
index b8996030aafc..29b1b564beca 100644
--- a/lib/libcasper/tests/Makefile
+++ b/lib/libcasper/tests/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/tests
KYUAFILE= yes
diff --git a/lib/libcbor/Makefile b/lib/libcbor/Makefile
index 5ae2c34a5963..ddc064562fc5 100644
--- a/lib/libcbor/Makefile
+++ b/lib/libcbor/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=ssh
LIB= cbor
PRIVATELIB=
@@ -30,6 +29,7 @@ SRCS+= cbor/internal/unicode.c
CFLAGS+= -I${DIST}/src -I${.CURDIR}
WARNS?= 2
+IGNORE_PRAGMA=
MAN=
.include <bsd.lib.mk>
diff --git a/lib/libcbor/Makefile.depend b/lib/libcbor/Makefile.depend
new file mode 100644
index 000000000000..9add648af17b
--- /dev/null
+++ b/lib/libcbor/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libclang_rt/Makefile b/lib/libclang_rt/Makefile
index 40fd7dfab8fb..7d9ad9191b74 100644
--- a/lib/libclang_rt/Makefile
+++ b/lib/libclang_rt/Makefile
@@ -1,75 +1,96 @@
+SD_ASAN+= asan
+SD_ASAN+= asan-preinit
+SD_ASAN+= asan_cxx
+SD_ASAN+= asan_dynamic
+SD_ASAN+= asan_static
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
-SUBDIR+= include
-SUBDIR+= asan
-SUBDIR+= asan-preinit
-SUBDIR+= asan_cxx
-SUBDIR+= asan_dynamic
-SUBDIR+= asan_static
-SUBDIR+= cfi
-SUBDIR+= cfi_diag
-SUBDIR+= safestack
-SUBDIR+= stats
-SUBDIR+= stats_client
-SUBDIR+= ubsan_minimal
-SUBDIR+= ubsan_standalone
-SUBDIR+= ubsan_standalone_cxx
-.endif # amd64 || i386
+SD_CFI+= cfi
+SD_CFI+= cfi_diag
-.if ${MACHINE_CPUARCH} == "amd64"
-SUBDIR+= dd
-SUBDIR+= fuzzer
-SUBDIR+= fuzzer_interceptors
-SUBDIR+= fuzzer_no_main
-SUBDIR+= msan
-SUBDIR+= msan_cxx
-SUBDIR+= tsan
-SUBDIR+= tsan_cxx
-SUBDIR+= xray
-SUBDIR+= xray-basic
-SUBDIR+= xray-fdr
-SUBDIR+= xray-profiling
-.endif # amd64
+SD_DD+= dd
-.if ${MACHINE_ARCH} == "powerpc64" || ${MACHINE_ARCH} == "powerpc64le"
-SUBDIR+= include
-SUBDIR+= asan
-SUBDIR+= asan-preinit
-SUBDIR+= asan_cxx
-SUBDIR+= asan_dynamic
-SUBDIR+= asan_static
-SUBDIR+= msan
-SUBDIR+= msan_cxx
-SUBDIR+= stats
-SUBDIR+= stats_client
-SUBDIR+= tsan
-SUBDIR+= tsan_cxx
-SUBDIR+= ubsan_minimal
-SUBDIR+= ubsan_standalone
-SUBDIR+= ubsan_standalone_cxx
-.endif # powerpc64 || powerpc64le
+SD_FUZZER+= fuzzer
+SD_FUZZER+= fuzzer_interceptors
+SD_FUZZER+= fuzzer_no_main
-.if ${MACHINE_ARCH} == "powerpc64le"
-SUBDIR+= xray
-SUBDIR+= xray-basic
-SUBDIR+= xray-fdr
-SUBDIR+= xray-profiling
-.endif # powerpc64le
+SD_INCLUDE+= include
-.if ${MACHINE_CPUARCH} == "riscv"
-SUBDIR+= include
-SUBDIR+= asan
-SUBDIR+= asan-preinit
-SUBDIR+= asan_cxx
-SUBDIR+= asan_dynamic
-SUBDIR+= stats
-SUBDIR+= stats_client
-SUBDIR+= ubsan_minimal
-SUBDIR+= ubsan_standalone
-SUBDIR+= ubsan_standalone_cxx
-.endif # riscv
+SD_MSAN+= msan
+SD_MSAN+= msan_cxx
-SUBDIR+= profile
+SD_PROFILE+= profile
+
+SD_SAFESTACK+= safestack
+
+SD_STATS+= stats
+SD_STATS+= stats_client
+
+SD_TSAN+= tsan
+SD_TSAN+= tsan_cxx
+
+SD_UBSAN+= ubsan_minimal
+SD_UBSAN+= ubsan_standalone
+SD_UBSAN+= ubsan_standalone_cxx
+
+SD_XRAY+= xray
+SD_XRAY+= xray-basic
+SD_XRAY+= xray-fdr
+SD_XRAY+= xray-profiling
+
+.if ${MACHINE_CPUARCH} == "aarch64"
+SUBDIR+= ${SD_ASAN}
+SUBDIR+= ${SD_CFI}
+SUBDIR+= ${SD_FUZZER}
+SUBDIR+= ${SD_MSAN}
+SUBDIR+= ${SD_SAFESTACK}
+SUBDIR+= ${SD_STATS}
+SUBDIR+= ${SD_TSAN}
+SUBDIR+= ${SD_UBSAN}
+SUBDIR+= ${SD_XRAY}
+.elif ${MACHINE_CPUARCH} == "amd64"
+SUBDIR+= ${SD_ASAN}
+SUBDIR+= ${SD_CFI}
+SUBDIR+= ${SD_DD}
+SUBDIR+= ${SD_FUZZER}
+SUBDIR+= ${SD_MSAN}
+SUBDIR+= ${SD_SAFESTACK}
+SUBDIR+= ${SD_STATS}
+SUBDIR+= ${SD_TSAN}
+SUBDIR+= ${SD_UBSAN}
+SUBDIR+= ${SD_XRAY}
+.elif ${MACHINE_CPUARCH} == "arm"
+# nothing for 32-bit arm yet
+.elif ${MACHINE_CPUARCH} == "i386"
+SUBDIR+= ${SD_ASAN}
+SUBDIR+= ${SD_CFI}
+SUBDIR+= ${SD_SAFESTACK}
+SUBDIR+= ${SD_STATS}
+SUBDIR+= ${SD_UBSAN}
+.elif ${MACHINE_CPUARCH} == "powerpc"
+. if ${MACHINE_ARCH} == "powerpc64"
+SUBDIR+= ${SD_ASAN}
+SUBDIR+= ${SD_MSAN}
+SUBDIR+= ${SD_STATS}
+SUBDIR+= ${SD_TSAN}
+SUBDIR+= ${SD_UBSAN}
+. elif ${MACHINE_ARCH} == "powerpc64le"
+SUBDIR+= ${SD_ASAN}
+SUBDIR+= ${SD_MSAN}
+SUBDIR+= ${SD_STATS}
+SUBDIR+= ${SD_TSAN}
+SUBDIR+= ${SD_UBSAN}
+SUBDIR+= ${SD_XRAY}
+. else
+# nothing for other powerpc yet
+. endif
+.elif ${MACHINE_CPUARCH} == "riscv"
+SUBDIR+= ${SD_ASAN}
+SUBDIR+= ${SD_STATS}
+SUBDIR+= ${SD_UBSAN}
+.endif
+
+SUBDIR+= ${SD_INCLUDE}
+SUBDIR+= ${SD_PROFILE}
SUBDIR_PARALLEL=
diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc
index 4832815643ae..c472e8b741be 100644
--- a/lib/libclang_rt/Makefile.inc
+++ b/lib/libclang_rt/Makefile.inc
@@ -1,6 +1,6 @@
-
.include <bsd.compiler.mk>
+PACKAGE= clang
CRTSRC= ${SRCTOP}/contrib/llvm-project/compiler-rt
.include "compiler-rt-vars.mk"
@@ -10,7 +10,6 @@ LIBDIR= ${SANITIZER_LIBDIR}
SHLIBDIR= ${LIBDIR}
NO_PIC=
-MK_PROFILE= no
MK_ASAN:= no
MK_SSP= no
MK_UBSAN:= no
@@ -34,4 +33,4 @@ CXXFLAGS+= -fvisibility-inlines-hidden
CXXFLAGS+= -fvisibility=hidden
CFLAGS+= -I${CRTSRC}/include
CFLAGS+= -I${CRTSRC}/lib
-CXXSTD= c++14
+CXXSTD= c++17
diff --git a/lib/libclang_rt/asan-preinit/Makefile b/lib/libclang_rt/asan-preinit/Makefile
index ce99dfa2d50c..1f2fade866ac 100644
--- a/lib/libclang_rt/asan-preinit/Makefile
+++ b/lib/libclang_rt/asan-preinit/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.asan-preinit-${CRTARCH}
diff --git a/lib/libclang_rt/asan/Makefile b/lib/libclang_rt/asan/Makefile
index b7fd59988dfa..b87d7a0bb1ad 100644
--- a/lib/libclang_rt/asan/Makefile
+++ b/lib/libclang_rt/asan/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.asan-${CRTARCH}
@@ -19,7 +18,6 @@ SRCS+= asan/asan_memory_profile.cpp
SRCS+= asan/asan_poisoning.cpp
SRCS+= asan/asan_posix.cpp
SRCS+= asan/asan_preinit.cpp
-SRCS+= asan/asan_premap_shadow.cpp
SRCS+= asan/asan_report.cpp
SRCS+= asan/asan_rtl.cpp
SRCS+= asan/asan_shadow_setup.cpp
@@ -28,7 +26,7 @@ SRCS+= asan/asan_stats.cpp
SRCS+= asan/asan_suppressions.cpp
SRCS+= asan/asan_thread.cpp
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
+SRCS+= lsan/lsan_common.cpp
SRCS+= sanitizer_common/sancov_flags.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
@@ -38,7 +36,7 @@ SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_coverage_libcdep_new.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -49,13 +47,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -65,9 +62,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/asan/Makefile.depend b/lib/libclang_rt/asan/Makefile.depend
index df8ef0ca0c02..2427fe0ab42b 100644
--- a/lib/libclang_rt/asan/Makefile.depend
+++ b/lib/libclang_rt/asan/Makefile.depend
@@ -5,7 +5,8 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/libc++ \
- lib/ncurses/ncursesw \
+ lib/libmd \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/asan_cxx/Makefile b/lib/libclang_rt/asan_cxx/Makefile
index c26690aedfb1..804e6ffd43db 100644
--- a/lib/libclang_rt/asan_cxx/Makefile
+++ b/lib/libclang_rt/asan_cxx/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.asan_cxx-${CRTARCH}
diff --git a/lib/libclang_rt/asan_dynamic/Makefile b/lib/libclang_rt/asan_dynamic/Makefile
index 16accaf2dc34..198a61bfbb6a 100644
--- a/lib/libclang_rt/asan_dynamic/Makefile
+++ b/lib/libclang_rt/asan_dynamic/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
SHLIB_NAME= libclang_rt.asan-${CRTARCH}.so
@@ -22,7 +21,6 @@ SRCS+= asan/asan_memory_profile.cpp
SRCS+= asan/asan_poisoning.cpp
SRCS+= asan/asan_posix.cpp
SRCS+= asan/asan_preinit.cpp
-SRCS+= asan/asan_premap_shadow.cpp
SRCS+= asan/asan_report.cpp
SRCS+= asan/asan_rtl.cpp
SRCS+= asan/asan_shadow_setup.cpp
@@ -31,7 +29,7 @@ SRCS+= asan/asan_stats.cpp
SRCS+= asan/asan_suppressions.cpp
SRCS+= asan/asan_thread.cpp
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
+SRCS+= lsan/lsan_common.cpp
SRCS+= sanitizer_common/sancov_flags.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
@@ -41,7 +39,7 @@ SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_coverage_libcdep_new.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -52,13 +50,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -68,9 +65,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/asan_dynamic/Makefile.depend b/lib/libclang_rt/asan_dynamic/Makefile.depend
index 0bbb1c4aee2a..04eb25a6e4f8 100644
--- a/lib/libclang_rt/asan_dynamic/Makefile.depend
+++ b/lib/libclang_rt/asan_dynamic/Makefile.depend
@@ -1,7 +1,6 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
include/arpa \
include/xlocale \
@@ -10,8 +9,9 @@ DIRDEPS = \
lib/libc++ \
lib/libcompiler_rt \
lib/libcxxrt \
+ lib/libmd \
lib/msun \
- lib/ncurses/ncursesw \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/asan_static/Makefile b/lib/libclang_rt/asan_static/Makefile
index 099ef64b37e2..158228051d9f 100644
--- a/lib/libclang_rt/asan_static/Makefile
+++ b/lib/libclang_rt/asan_static/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.asan_static-${CRTARCH}
diff --git a/lib/libclang_rt/cfi/Makefile b/lib/libclang_rt/cfi/Makefile
index b0462d321988..d101ff0296c4 100644
--- a/lib/libclang_rt/cfi/Makefile
+++ b/lib/libclang_rt/cfi/Makefile
@@ -1,17 +1,15 @@
-
.include <bsd.init.mk>
LIB= clang_rt.cfi-${CRTARCH}
SRCS+= cfi/cfi.cpp
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -22,15 +20,15 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/cfi_diag/Makefile b/lib/libclang_rt/cfi_diag/Makefile
index fdf0030015ef..0ac9a46c7a96 100644
--- a/lib/libclang_rt/cfi_diag/Makefile
+++ b/lib/libclang_rt/cfi_diag/Makefile
@@ -1,11 +1,9 @@
-
.include <bsd.init.mk>
LIB= clang_rt.cfi_diag-${CRTARCH}
SRCS+= cfi/cfi.cpp
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= sanitizer_common/sancov_flags.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
@@ -15,7 +13,7 @@ SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_coverage_libcdep_new.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -26,13 +24,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -42,9 +39,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/compiler-rt-vars.mk b/lib/libclang_rt/compiler-rt-vars.mk
index eeef2752d326..bfe11196b23b 100644
--- a/lib/libclang_rt/compiler-rt-vars.mk
+++ b/lib/libclang_rt/compiler-rt-vars.mk
@@ -1,11 +1,11 @@
-CLANG_SUBDIR=clang/16
+CLANG_SUBDIR=clang/19
CLANGDIR= /usr/lib/${CLANG_SUBDIR}
SANITIZER_LIBDIR= ${CLANGDIR}/lib/freebsd
SANITIZER_SHAREDIR= ${CLANGDIR}/share
# armv[67] is a bit special since we allow a soft-floating version via
# CPUTYPE matching *soft*. This variant may not actually work though.
-.if ${MACHINE_ARCH:Marmv[67]*} != "" && \
+.if ${MACHINE_CPUARCH} == "arm" && \
(!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "")
CRTARCH?= armhf
.else
diff --git a/lib/libclang_rt/dd/Makefile b/lib/libclang_rt/dd/Makefile
index b0e6cec2fc13..c0f0b3d3694e 100644
--- a/lib/libclang_rt/dd/Makefile
+++ b/lib/libclang_rt/dd/Makefile
@@ -1,16 +1,14 @@
-
.include <bsd.init.mk>
LIB= clang_rt.dd-${CRTARCH}
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -21,15 +19,15 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/fuzzer/Makefile b/lib/libclang_rt/fuzzer/Makefile
index 73e69616d8a1..00287482f3f2 100644
--- a/lib/libclang_rt/fuzzer/Makefile
+++ b/lib/libclang_rt/fuzzer/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.fuzzer-${CRTARCH}
diff --git a/lib/libclang_rt/fuzzer_interceptors/Makefile b/lib/libclang_rt/fuzzer_interceptors/Makefile
index 52f8425e429a..bb58f71bf685 100644
--- a/lib/libclang_rt/fuzzer_interceptors/Makefile
+++ b/lib/libclang_rt/fuzzer_interceptors/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.fuzzer_interceptors-${CRTARCH}
diff --git a/lib/libclang_rt/fuzzer_no_main/Makefile b/lib/libclang_rt/fuzzer_no_main/Makefile
index 088f0f2e79ab..7f88a585dea2 100644
--- a/lib/libclang_rt/fuzzer_no_main/Makefile
+++ b/lib/libclang_rt/fuzzer_no_main/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.fuzzer_no_main-${CRTARCH}
diff --git a/lib/libclang_rt/include/Makefile b/lib/libclang_rt/include/Makefile
index ab881db3da76..7fe850fca57d 100644
--- a/lib/libclang_rt/include/Makefile
+++ b/lib/libclang_rt/include/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
.PATH: ${CRTSRC}/include/sanitizer
diff --git a/lib/libclang_rt/msan/Makefile b/lib/libclang_rt/msan/Makefile
index 85dae8b906fa..1c1911f2236f 100644
--- a/lib/libclang_rt/msan/Makefile
+++ b/lib/libclang_rt/msan/Makefile
@@ -1,13 +1,12 @@
-
.include <bsd.init.mk>
LIB= clang_rt.msan-${CRTARCH}
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= msan/msan.cpp
SRCS+= msan/msan_allocator.cpp
SRCS+= msan/msan_chained_origin_depot.cpp
+SRCS+= msan/msan_dl.cpp
SRCS+= msan/msan_interceptors.cpp
SRCS+= msan/msan_linux.cpp
SRCS+= msan/msan_poisoning.cpp
@@ -22,7 +21,7 @@ SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_coverage_libcdep_new.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -33,13 +32,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -49,9 +47,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/msan_cxx/Makefile b/lib/libclang_rt/msan_cxx/Makefile
index 59ad2120111f..3e024e7c6c79 100644
--- a/lib/libclang_rt/msan_cxx/Makefile
+++ b/lib/libclang_rt/msan_cxx/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.msan_cxx-${CRTARCH}
diff --git a/lib/libclang_rt/profile/Makefile b/lib/libclang_rt/profile/Makefile
index ac4e9d66d332..d03b640b025d 100644
--- a/lib/libclang_rt/profile/Makefile
+++ b/lib/libclang_rt/profile/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.profile-${CRTARCH}
diff --git a/lib/libclang_rt/safestack/Makefile b/lib/libclang_rt/safestack/Makefile
index 75246a1295c6..8c99724ec3db 100644
--- a/lib/libclang_rt/safestack/Makefile
+++ b/lib/libclang_rt/safestack/Makefile
@@ -1,10 +1,8 @@
-
.include <bsd.init.mk>
LIB= clang_rt.safestack-${CRTARCH}
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= safestack/safestack.cpp
.include <bsd.lib.mk>
diff --git a/lib/libclang_rt/safestack/Makefile.depend b/lib/libclang_rt/safestack/Makefile.depend
index df8ef0ca0c02..37aec7f3693e 100644
--- a/lib/libclang_rt/safestack/Makefile.depend
+++ b/lib/libclang_rt/safestack/Makefile.depend
@@ -2,10 +2,8 @@
DIRDEPS = \
include \
- include/arpa \
include/xlocale \
lib/libc++ \
- lib/ncurses/ncursesw \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/stats/Makefile b/lib/libclang_rt/stats/Makefile
index a8902e15caf0..7124ab7c9682 100644
--- a/lib/libclang_rt/stats/Makefile
+++ b/lib/libclang_rt/stats/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.stats-${CRTARCH}
@@ -10,7 +9,7 @@ SRCS+= sanitizer_common/sanitizer_chained_origin_depot.cpp
SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -21,13 +20,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -37,9 +35,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/stats/Makefile.depend b/lib/libclang_rt/stats/Makefile.depend
index df8ef0ca0c02..2427fe0ab42b 100644
--- a/lib/libclang_rt/stats/Makefile.depend
+++ b/lib/libclang_rt/stats/Makefile.depend
@@ -5,7 +5,8 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/libc++ \
- lib/ncurses/ncursesw \
+ lib/libmd \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/stats_client/Makefile b/lib/libclang_rt/stats_client/Makefile
index 010763a9e25a..775152fc77ab 100644
--- a/lib/libclang_rt/stats_client/Makefile
+++ b/lib/libclang_rt/stats_client/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.stats_client-${CRTARCH}
diff --git a/lib/libclang_rt/tsan/Makefile b/lib/libclang_rt/tsan/Makefile
index 12b358fee3d2..573688dfac1e 100644
--- a/lib/libclang_rt/tsan/Makefile
+++ b/lib/libclang_rt/tsan/Makefile
@@ -1,10 +1,8 @@
-
.include <bsd.init.mk>
LIB= clang_rt.tsan-${CRTARCH}
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= sanitizer_common/sancov_flags.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
@@ -14,7 +12,7 @@ SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_coverage_libcdep_new.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -25,13 +23,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -41,9 +38,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
@@ -53,6 +52,7 @@ SRCS+= tsan/rtl/tsan_external.cpp
SRCS+= tsan/rtl/tsan_fd.cpp
SRCS+= tsan/rtl/tsan_flags.cpp
SRCS+= tsan/rtl/tsan_ignoreset.cpp
+SRCS+= tsan/rtl/tsan_interceptors_memintrinsics.cpp
SRCS+= tsan/rtl/tsan_interceptors_posix.cpp
SRCS+= tsan/rtl/tsan_interface.cpp
SRCS+= tsan/rtl/tsan_interface_ann.cpp
diff --git a/lib/libclang_rt/tsan_cxx/Makefile b/lib/libclang_rt/tsan_cxx/Makefile
index b556699c9115..a95ee30701d8 100644
--- a/lib/libclang_rt/tsan_cxx/Makefile
+++ b/lib/libclang_rt/tsan_cxx/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.tsan_cxx-${CRTARCH}
diff --git a/lib/libclang_rt/ubsan_minimal/Makefile b/lib/libclang_rt/ubsan_minimal/Makefile
index a19748dc73b8..9a56a1896889 100644
--- a/lib/libclang_rt/ubsan_minimal/Makefile
+++ b/lib/libclang_rt/ubsan_minimal/Makefile
@@ -1,8 +1,9 @@
-
.include <bsd.init.mk>
LIB= clang_rt.ubsan_minimal-${CRTARCH}
+CFLAGS+= -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS
+
SRCS+= ubsan_minimal/ubsan_minimal_handlers.cpp
.include <bsd.lib.mk>
diff --git a/lib/libclang_rt/ubsan_standalone/Makefile b/lib/libclang_rt/ubsan_standalone/Makefile
index 8ec424798add..935c03d2005f 100644
--- a/lib/libclang_rt/ubsan_standalone/Makefile
+++ b/lib/libclang_rt/ubsan_standalone/Makefile
@@ -1,10 +1,8 @@
-
.include <bsd.init.mk>
LIB= clang_rt.ubsan_standalone-${CRTARCH}
SRCS+= interception/interception_linux.cpp
-SRCS+= interception/interception_type_test.cpp
SRCS+= sanitizer_common/sancov_flags.cpp
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
@@ -14,7 +12,7 @@ SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_coverage_libcdep_new.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -25,13 +23,12 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_stack_store.cpp
SRCS+= sanitizer_common/sanitizer_stackdepot.cpp
SRCS+= sanitizer_common/sanitizer_stacktrace.cpp
@@ -41,9 +38,11 @@ SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libbacktrace.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+SRCS+= sanitizer_common/sanitizer_symbolizer_markup.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_symbolizer_report.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libclang_rt/ubsan_standalone/Makefile.depend b/lib/libclang_rt/ubsan_standalone/Makefile.depend
index df8ef0ca0c02..2427fe0ab42b 100644
--- a/lib/libclang_rt/ubsan_standalone/Makefile.depend
+++ b/lib/libclang_rt/ubsan_standalone/Makefile.depend
@@ -5,7 +5,8 @@ DIRDEPS = \
include/arpa \
include/xlocale \
lib/libc++ \
- lib/ncurses/ncursesw \
+ lib/libmd \
+ lib/ncurses/tinfo \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/ubsan_standalone_cxx/Makefile b/lib/libclang_rt/ubsan_standalone_cxx/Makefile
index bfca7e1bd693..f533df169ab0 100644
--- a/lib/libclang_rt/ubsan_standalone_cxx/Makefile
+++ b/lib/libclang_rt/ubsan_standalone_cxx/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.init.mk>
LIB= clang_rt.ubsan_standalone_cxx-${CRTARCH}
diff --git a/lib/libclang_rt/ubsan_standalone_cxx/Makefile.depend b/lib/libclang_rt/ubsan_standalone_cxx/Makefile.depend
index 11aba52f82cf..e57fef3d9b24 100644
--- a/lib/libclang_rt/ubsan_standalone_cxx/Makefile.depend
+++ b/lib/libclang_rt/ubsan_standalone_cxx/Makefile.depend
@@ -1,6 +1,8 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ include \
+ lib/libc++ \
.include <dirdeps.mk>
diff --git a/lib/libclang_rt/xray-basic/Makefile b/lib/libclang_rt/xray-basic/Makefile
index 0e0798f4f6ff..8e4d97497b85 100644
--- a/lib/libclang_rt/xray-basic/Makefile
+++ b/lib/libclang_rt/xray-basic/Makefile
@@ -1,8 +1,9 @@
-
.include <bsd.init.mk>
LIB= clang_rt.xray-basic-${CRTARCH}
+CFLAGS+= -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS
+
SRCS+= xray/xray_basic_flags.cpp
SRCS+= xray/xray_basic_logging.cpp
diff --git a/lib/libclang_rt/xray-fdr/Makefile b/lib/libclang_rt/xray-fdr/Makefile
index f279339183f5..50822c79d155 100644
--- a/lib/libclang_rt/xray-fdr/Makefile
+++ b/lib/libclang_rt/xray-fdr/Makefile
@@ -1,8 +1,9 @@
-
.include <bsd.init.mk>
LIB= clang_rt.xray-fdr-${CRTARCH}
+CFLAGS+= -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS
+
SRCS+= xray/xray_fdr_flags.cpp
SRCS+= xray/xray_fdr_logging.cpp
diff --git a/lib/libclang_rt/xray-profiling/Makefile b/lib/libclang_rt/xray-profiling/Makefile
index c9ee93f73fe6..0aa0dbb602ee 100644
--- a/lib/libclang_rt/xray-profiling/Makefile
+++ b/lib/libclang_rt/xray-profiling/Makefile
@@ -1,8 +1,9 @@
-
.include <bsd.init.mk>
LIB= clang_rt.xray-profiling-${CRTARCH}
+CFLAGS+= -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS
+
SRCS+= xray/xray_profile_collector.cpp
SRCS+= xray/xray_profiling.cpp
SRCS+= xray/xray_profiling_flags.cpp
diff --git a/lib/libclang_rt/xray/Makefile b/lib/libclang_rt/xray/Makefile
index e69e86651124..d9497f8ecee9 100644
--- a/lib/libclang_rt/xray/Makefile
+++ b/lib/libclang_rt/xray/Makefile
@@ -1,14 +1,15 @@
-
.include <bsd.init.mk>
LIB= clang_rt.xray-${CRTARCH}
+CFLAGS+= -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS
+
SRCS+= sanitizer_common/sanitizer_allocator.cpp
SRCS+= sanitizer_common/sanitizer_allocator_checks.cpp
SRCS+= sanitizer_common/sanitizer_common.cpp
SRCS+= sanitizer_common/sanitizer_common_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_deadlock_detector1.cpp
-SRCS+= sanitizer_common/sanitizer_deadlock_detector2.cpp
+SRCS+= sanitizer_common/sanitizer_dl.cpp
SRCS+= sanitizer_common/sanitizer_errno.cpp
SRCS+= sanitizer_common/sanitizer_file.cpp
SRCS+= sanitizer_common/sanitizer_flag_parser.cpp
@@ -19,15 +20,15 @@ SRCS+= sanitizer_common/sanitizer_linux.cpp
SRCS+= sanitizer_common/sanitizer_linux_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_mutex.cpp
SRCS+= sanitizer_common/sanitizer_platform_limits_freebsd.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_linux.cpp
-SRCS+= sanitizer_common/sanitizer_platform_limits_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix.cpp
SRCS+= sanitizer_common/sanitizer_posix_libcdep.cpp
SRCS+= sanitizer_common/sanitizer_printf.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_bsd.cpp
SRCS+= sanitizer_common/sanitizer_procmaps_common.cpp
+SRCS+= sanitizer_common/sanitizer_range.cpp
SRCS+= sanitizer_common/sanitizer_suppressions.cpp
SRCS+= sanitizer_common/sanitizer_termination.cpp
+SRCS+= sanitizer_common/sanitizer_thread_arg_retval.cpp
SRCS+= sanitizer_common/sanitizer_thread_registry.cpp
SRCS+= sanitizer_common/sanitizer_tls_get_addr.cpp
SRCS+= sanitizer_common/sanitizer_type_traits.cpp
diff --git a/lib/libcom_err/Makefile b/lib/libcom_err/Makefile
index 72b715bbf83b..f070fd534469 100644
--- a/lib/libcom_err/Makefile
+++ b/lib/libcom_err/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= kerberos-lib
LIB= com_err
@@ -8,7 +7,7 @@ MAN= com_err.3
COM_ERRDIR= ${SRCTOP}/contrib/com_err
CFLAGS+= -I${COM_ERRDIR}
-LDFLAGS= -Wl,--no-undefined
+LDFLAGS+= -Wl,--no-undefined
VERSION_MAP= ${COM_ERRDIR}/version-script.map
.include <bsd.lib.mk>
diff --git a/lib/libcompat/4.1/ftime.3 b/lib/libcompat/4.1/ftime.3
deleted file mode 100644
index 48eb465aed31..000000000000
--- a/lib/libcompat/4.1/ftime.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1980, 1991, 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.
-.\"
-.\" @(#)ftime.3 8.1 (Berkeley) 6/4/93
-.\"
-.Dd August 4, 2018
-.Dt FTIME 3
-.Os
-.Sh NAME
-.Nm ftime
-.Nd get date and time
-.Sh LIBRARY
-.Lb libcompat
-.Sh SYNOPSIS
-.In sys/types.h
-.In sys/timeb.h
-.Ft int
-.Fn ftime "struct timeb *tp"
-.Sh DESCRIPTION
-.Bf -symbolic
-This interface is obsoleted by
-.Xr gettimeofday 2 .
-.Ef
-.Pp
-The
-.Fn ftime
-routine fills in a structure pointed to by its argument,
-as defined by
-.In sys/timeb.h :
-.Bd -literal -offset indent
-/*
- * Structure returned by ftime system call
- */
-struct timeb
-{
- time_t time;
- unsigned short millitm;
- short timezone;
- short dstflag;
-};
-.Ed
-.Pp
-The structure contains the time since the epoch in seconds,
-up to 1000 milliseconds of more-precise interval,
-The kernel no longer maintains the timezone and dstflag info, so 0 is
-always returned for these fields.
-.Sh SEE ALSO
-.Xr gettimeofday 2 ,
-.Xr settimeofday 2 ,
-.Xr ctime 3 ,
-.Xr time 3
-.Sh HISTORY
-The
-.Nm
-function appeared in
-.At v7 .
diff --git a/lib/libcompat/4.1/ftime.c b/lib/libcompat/4.1/ftime.c
deleted file mode 100644
index 5ea57bca40fd..000000000000
--- a/lib/libcompat/4.1/ftime.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 1994 Christopher G. Demetriou
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christopher G. Demetriou.
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/timeb.h>
-
-int
-ftime(struct timeb *tbp)
-{
- struct timezone tz;
- struct timeval t;
-
- if (gettimeofday(&t, &tz) < 0)
- return (-1);
- tbp->millitm = t.tv_usec / 1000;
- tbp->time = t.tv_sec;
- tbp->timezone = tz.tz_minuteswest;
- tbp->dstflag = tz.tz_dsttime;
-
- return (0);
-}
diff --git a/lib/libcompat/4.3/re_comp.3 b/lib/libcompat/4.3/re_comp.3
index 3826665ba65e..504519a77459 100644
--- a/lib/libcompat/4.3/re_comp.3
+++ b/lib/libcompat/4.3/re_comp.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)re_comp.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt RE_COMP 3
.Os
diff --git a/lib/libcompat/4.3/re_comp.c b/lib/libcompat/4.3/re_comp.c
index dfbfb82f0889..a45f06769c57 100644
--- a/lib/libcompat/4.3/re_comp.c
+++ b/lib/libcompat/4.3/re_comp.c
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)regex.c 5.1 (Berkeley) 3/29/92");
/*
* Compatibility routines that implement the old re_comp/re_exec interface in
diff --git a/lib/libcompat/4.3/rexec.3 b/lib/libcompat/4.3/rexec.3
index 8b24d19b3f83..165e7002ebf3 100644
--- a/lib/libcompat/4.3/rexec.3
+++ b/lib/libcompat/4.3/rexec.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rexec.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt REXEC 3
.Os
diff --git a/lib/libcompat/4.3/rexec.c b/lib/libcompat/4.3/rexec.c
index 3dac5ff18da3..b2f37a09c0fb 100644
--- a/lib/libcompat/4.3/rexec.c
+++ b/lib/libcompat/4.3/rexec.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)rexec.c 8.1 (Berkeley) 6/4/93");
#include <sys/types.h>
#include <sys/uio.h>
@@ -51,7 +49,6 @@ __SCCSID("@(#)rexec.c 8.1 (Berkeley) 6/4/93");
#include <unistd.h>
int rexecoptions;
-char *getpass(), *getlogin();
/*
* Options and other state info.
@@ -132,8 +129,7 @@ token()
}
static int
-ruserpass(host, aname, apass, aacct)
- char *host, **aname, **apass, **aacct;
+ruserpass(char *host, char **aname, char **apass, char **aacct)
{
char *hdir, buf[BUFSIZ], *tmp;
char myname[MAXHOSTNAMELEN], *mydomain;
@@ -291,11 +287,7 @@ bad:
}
int
-rexec(ahost, rport, name, pass, cmd, fd2p)
- char **ahost;
- int rport;
- char *name, *pass, *cmd;
- int *fd2p;
+rexec(char **ahost, int rport, char *name, char *pass, char *cmd, int *fd2p)
{
struct sockaddr_in sin, sin2, from;
struct hostent *hp;
diff --git a/lib/libcompat/4.4/cuserid.c b/lib/libcompat/4.4/cuserid.c
index a27b009878eb..188330927897 100644
--- a/lib/libcompat/4.4/cuserid.c
+++ b/lib/libcompat/4.4/cuserid.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)cuserid.c 8.1 (Berkeley) 6/4/93");
#include <pwd.h>
#include <stdio.h>
diff --git a/lib/libcompat/Makefile b/lib/libcompat/Makefile
index 7c99556e7513..2612568a9da7 100644
--- a/lib/libcompat/Makefile
+++ b/lib/libcompat/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
PACKAGE=lib${LIB}
LIB= compat
CFLAGS+=-I${SRCTOP}/lib/libc/locale
@@ -7,12 +5,7 @@ NO_PIC=
WARNS?= 0
-.PATH: ${.CURDIR}/4.1 ${.CURDIR}/4.3 ${.CURDIR}/4.4
-
-# compat 4.1 sources
-SRCS+= ftime.c
-
-MAN+= 4.1/ftime.3
+.PATH: ${.CURDIR}/4.3 ${.CURDIR}/4.4
# compat 4.3 sources
SRCS+= re_comp.c rexec.c
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile
index 1ba94bc5eec8..08467bbec310 100644
--- a/lib/libcompiler_rt/Makefile
+++ b/lib/libcompiler_rt/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= lib${LIB}
@@ -22,7 +21,7 @@ MK_WERROR.gcc= no
.if ${MACHINE_CPUARCH} == "aarch64"
. for pat in cas swp ldadd ldclr ldeor ldset
. for size in 1 2 4 8 16
-. for model in 1 2 3 4
+. for model in 1 2 3 4 5
. if ${pat} == "cas" || ${size} != "16"
# Use .for to define lse_name, to get a special loop-local variable
. for lse_name in outline_atomic_${pat}${size}_${model}.S
@@ -41,8 +40,5 @@ ${lse_name}: lse.S
.if ${MK_INSTALLLIB} != "no"
SYMLINKS+= libcompiler_rt.a ${LIBDIR}/libgcc.a
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+= libcompiler_rt_p.a ${LIBDIR}/libgcc_p.a
-.endif
.include <bsd.lib.mk>
diff --git a/lib/libcompiler_rt/Makefile.inc b/lib/libcompiler_rt/Makefile.inc
index ab457105d384..57cfdee95541 100644
--- a/lib/libcompiler_rt/Makefile.inc
+++ b/lib/libcompiler_rt/Makefile.inc
@@ -1,5 +1,6 @@
+.include <bsd.compiler.mk>
-CRTARCH= ${MACHINE_CPUARCH:C/amd64/x86_64/}
+CRTARCH= ${MACHINE_CPUARCH:C/amd64/x86_64/:C/powerpc/ppc/}
CRTSRC= ${SRCTOP}/contrib/llvm-project/compiler-rt/lib/builtins
@@ -35,9 +36,7 @@ SRCF+= divmodsi4
SRCF+= divmodti4
SRCF+= divsc3
SRCF+= divsi3
-SRCF+= divtc3
SRCF+= divti3
-SRCF+= divxc3
SRCF+= enable_execute_stack
SRCF+= extendhfsf2
SRCF+= ffsdi2
@@ -53,21 +52,12 @@ SRCF+= fixunsdfti
SRCF+= fixunssfdi
SRCF+= fixunssfsi
SRCF+= fixunssfti
-SRCF+= fixunsxfdi
-SRCF+= fixunsxfsi
-SRCF+= fixunsxfti
-SRCF+= fixxfdi
-SRCF+= fixxfti
-SRCF+= floatditf
SRCF+= floattidf
SRCF+= floattisf
-SRCF+= floattixf
-SRCF+= floatunditf
SRCF+= floatunsidf
SRCF+= floatunsisf
SRCF+= floatuntidf
SRCF+= floatuntisf
-SRCF+= floatuntixf
SRCF+= int_util
SRCF+= lshrdi3
SRCF+= lshrti3
@@ -80,12 +70,10 @@ SRCF+= mulodi4
SRCF+= mulosi4
SRCF+= muloti4
SRCF+= mulsc3
-SRCF+= multc3
SRCF+= multi3
SRCF+= mulvdi3
SRCF+= mulvsi3
SRCF+= mulvti3
-SRCF+= mulxc3
SRCF+= negdf2
SRCF+= negdi2
SRCF+= negsf2
@@ -101,8 +89,6 @@ SRCF+= popcountsi2
SRCF+= popcountti2
SRCF+= powidf2
SRCF+= powisf2
-SRCF+= powitf2
-SRCF+= powixf2
SRCF+= subvdi3
SRCF+= subvsi3
SRCF+= subvti3
@@ -132,23 +118,51 @@ SRCF+= atomic
.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
SRCS+= floatdidf.c
SRCS+= floatdisf.c
-SRCS+= floatdixf.c
SRCS+= floatundidf.c
SRCS+= floatundisf.c
-SRCS+= floatundixf.c
.else
SRCF+= floatdidf
SRCF+= floatdisf
-SRCF+= floatdixf
SRCF+= floatundidf
SRCF+= floatundisf
+.endif
+
+#
+# 80-bit long double functions, only used on x86.
+#
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+SRCF+= divxc3
+SRCF+= fixxfdi
+SRCF+= fixxfti
+SRCF+= fixunsxfdi
+SRCF+= fixunsxfsi
+SRCF+= fixunsxfti
+SRCF+= floattixf
+SRCF+= floatuntixf
+SRCF+= mulxc3
+SRCF+= powixf2
+
+# Avoid using SSE2 instructions on i386, if unsupported.
+.if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
+SRCS+= floatdixf.c
+SRCS+= floatundixf.c
+.else
+SRCF+= floatdixf
SRCF+= floatundixf
.endif
+.endif
+
+# 128-bit float is an amd64 feature
+.if ${MACHINE_CPUARCH} == "amd64"
+SRCF+= extendxftf2
+SRCF+= trunctfxf2
+.endif
# __cpu_model support, only used on aarch64 and x86
-.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
- ${MACHINE_CPUARCH} == "i386"
-SRCF+= cpu_model
+.if ${MACHINE_CPUARCH} == "aarch64"
+SRCS+= cpu_model/aarch64.c
+.elif ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+SRCS+= cpu_model/x86.c
.endif
# The fp_mode implementation for amd64 and i386 is shared, while other
@@ -163,9 +177,11 @@ SRCF+= fp_mode
# 128-bit quad precision long double support,
# only used on some architectures.
#
-.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
+.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
+ ${MACHINE_CPUARCH} == "riscv"
SRCF+= addtf3
SRCF+= comparetf2
+SRCF+= divtc3
SRCF+= divtf3
SRCF+= extenddftf2
SRCF+= extendhftf2
@@ -176,11 +192,15 @@ SRCF+= fixtfti
SRCF+= fixunstfdi
SRCF+= fixunstfsi
SRCF+= fixunstfti
+SRCF+= floatditf
SRCF+= floatsitf
SRCF+= floattitf
+SRCF+= floatunditf
SRCF+= floatunsitf
SRCF+= floatuntitf
+SRCF+= multc3
SRCF+= multf3
+SRCF+= powitf2
SRCF+= subtf3
SRCF+= trunctfdf2
SRCF+= trunctfhf2
@@ -188,7 +208,7 @@ SRCF+= trunctfsf2
.endif
# These are already shipped by libc.a on some architectures.
-.if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "riscv"
+.if ${MACHINE_CPUARCH} != "riscv"
SRCF+= adddf3
SRCF+= addsf3
SRCF+= divdf3
@@ -205,9 +225,42 @@ SRCF+= subsf3
SRCF+= truncdfsf2
.endif
-.if ${MACHINE_CPUARCH} != "arm"
SRCF+= comparedf2
SRCF+= comparesf2
+
+# Helper to reduce complexity of _Float16 and __bf16 statements below.
+.if ${MACHINE_CPUARCH} == "aarch64" || \
+ ${MACHINE_CPUARCH} == "amd64" || \
+ (${MACHINE_CPUARCH} == "i386" && !empty(MACHINE_CPU:Msse2))
+CRT_COMMON_F16_ARCH=t
+.endif
+
+#
+# _Float16 support, only on some architectures, and with certain compiler
+# versions.
+#
+.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \
+ (defined(CRT_COMMON_F16_ARCH) || \
+ ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "riscv")) || \
+ ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 120000) && \
+ (defined(CRT_COMMON_F16_ARCH)))
+CFLAGS+= -DCOMPILER_RT_HAS_FLOAT16
+.endif
+
+#
+# __bf16 support, only on some architectures, and with certain compiler
+# versions.
+#
+.if ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000) && \
+ (defined(CRT_COMMON_F16_ARCH))) || \
+ ((${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 180000) && \
+ ${MACHINE_CPUARCH} == "riscv") || \
+ ((${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 130000) && \
+ (defined(CRT_COMMON_F16_ARCH)))
+CFLAGS+= -DCOMPILER_RT_HAS_BFLOAT16
+SRCF+= extendbfsf2
+SRCF+= truncdfbf2
+SRCF+= truncsfbf2
.endif
# FreeBSD-specific atomic intrinsics.
@@ -219,10 +272,7 @@ CFLAGS+= -DEMIT_SYNC_ATOMICS
.endif
.for file in ${SRCF}
-.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \
- && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)
-SRCS+= ${file}vfp.S
-. elif exists(${CRTSRC}/${CRTARCH}/${file}.S)
+. if exists(${CRTSRC}/${CRTARCH}/${file}.S)
SRCS+= ${file}.S
. else
SRCS+= ${file}.c
@@ -230,7 +280,15 @@ SRCS+= ${file}.c
.endfor
.if ${MACHINE_CPUARCH} == "arm"
+SRCS+= aeabi_cdcmp.S
+SRCS+= aeabi_cdcmpeq_check_nan.c
+SRCS+= aeabi_cfcmp.S
+SRCS+= aeabi_cfcmpeq_check_nan.c
+SRCS+= aeabi_dcmp.S
SRCS+= aeabi_div0.c
+SRCS+= aeabi_drsub.c
+SRCS+= aeabi_fcmp.S
+SRCS+= aeabi_frsub.c
SRCS+= aeabi_idivmod.S
SRCS+= aeabi_ldivmod.S
SRCS+= aeabi_memcmp.S
@@ -239,6 +297,7 @@ SRCS+= aeabi_memmove.S
SRCS+= aeabi_memset.S
SRCS+= aeabi_uidivmod.S
SRCS+= aeabi_uldivmod.S
+
SRCS+= switch16.S
SRCS+= switch32.S
SRCS+= switch8.S
diff --git a/lib/libcrypt/Makefile b/lib/libcrypt/Makefile
index 9511bba81e26..e939bae1bc25 100644
--- a/lib/libcrypt/Makefile
+++ b/lib/libcrypt/Makefile
@@ -1,6 +1,3 @@
-#
-#
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -10,12 +7,11 @@ PACKAGE= runtime
SHLIB_MAJOR= 5
LIB= crypt
-.PATH: ${SRCTOP}/lib/libmd ${SRCTOP}/sys/crypto/sha2
SRCS= crypt.c misc.c \
- crypt-md5.c md5c.c \
- crypt-nthash.c md4c.c \
- crypt-sha256.c sha256c.c \
- crypt-sha512.c sha512c.c
+ crypt-md5.c \
+ crypt-nthash.c \
+ crypt-sha256.c \
+ crypt-sha512.c
MAN= crypt.3
MLINKS= crypt.3 crypt_get_format.3 crypt.3 crypt_r.3 \
crypt.3 crypt_set_format.3
@@ -29,17 +25,6 @@ SRCS+= crypt-des.c crypt-blowfish.c blowfish.c
CFLAGS+= -I${.CURDIR} -DHAS_DES -DHAS_BLOWFISH
.endif
-.for sym in MD4Init MD4Final MD4Update MD4Pad \
- MD5Init MD5Final MD5Update MD5Pad \
- SHA224_Init SHA224_Final SHA224_Update \
- SHA256_Init SHA256_Final SHA256_Update \
- SHA512_224_Init SHA512_224_Final SHA512_224_Update \
- SHA512_256_Init SHA512_256_Final SHA512_256_Update \
- SHA384_Init SHA384_Final SHA384_Update \
- SHA512_Init SHA512_Final SHA512_Update
-CFLAGS+= -D${sym}=__${sym}
-.endfor
-
WARNS?= 2
PRECIOUSLIB=
@@ -47,4 +32,22 @@ PRECIOUSLIB=
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
+LIBADD+= md
+SHLIB_LDSCRIPT= libcrypt.ldscript
+STATIC_LDSCRIPT= libcrypt.aldscript
+CLEANFILES+= libcrypt.ald
+
+libcrypt.ald: ${.CURDIR}/${STATIC_LDSCRIPT}
+ sed -e 's,@@LIB@@,${LIB},g' \
+ -e 's,@@STATICLIB_SUFFIX@@,${_STATICLIB_SUFFIX},g' \
+ ${.ALLSRC} > ${.TARGET}
+
+all: ${STATIC_LDSCRIPT} libcrypt.ald
+
+install-libcrypt.a: libcrypt.ald
+ ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+ ${_INSTALLFLAGS} libcrypt.ald ${DESTDIR}${_LIBDIR}/lib${LIB}.a
+
+realinstall: install-libcrypt.a
+
.include <bsd.lib.mk>
diff --git a/lib/libcrypt/crypt-md5.c b/lib/libcrypt/crypt-md5.c
index 3fb80c1ba540..609fbbf67b77 100644
--- a/lib/libcrypt/crypt-md5.c
+++ b/lib/libcrypt/crypt-md5.c
@@ -26,13 +26,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <err.h>
#include <md5.h>
#include <stdio.h>
#include <string.h>
+#include <strings.h>
#include <unistd.h>
#include "crypt.h"
@@ -85,7 +85,7 @@ crypt_md5(const char *pw, const char *salt, char *buffer)
(u_int)(pl > MD5_SIZE ? MD5_SIZE : pl));
/* Don't leave anything around in vm they could use. */
- memset(final, 0, sizeof(final));
+ explicit_bzero(final, sizeof(final));
/* Then something really weird... */
for (i = strlen(pw); i; i >>= 1)
@@ -141,7 +141,7 @@ crypt_md5(const char *pw, const char *salt, char *buffer)
*buffer = '\0';
/* Don't leave anything around in vm they could use. */
- memset(final, 0, sizeof(final));
+ explicit_bzero(final, sizeof(final));
return (0);
}
diff --git a/lib/libcrypt/crypt-nthash.c b/lib/libcrypt/crypt-nthash.c
index 28c832dd6f9f..774fe3437c25 100644
--- a/lib/libcrypt/crypt-nthash.c
+++ b/lib/libcrypt/crypt-nthash.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -57,17 +56,17 @@ crypt_nthash(const char *pw, const char *salt __unused, char *buffer)
u_char hash[MD4_SIZE];
const char *s;
MD4_CTX ctx;
-
- bzero(unipw, sizeof(unipw));
+
+ bzero(unipw, sizeof(unipw));
/* convert to unicode (thanx Archie) */
unipwLen = 0;
for (s = pw; unipwLen < sizeof(unipw) / 2 && *s; s++)
unipw[unipwLen++] = htons(*s << 8);
-
+
/* Compute MD4 of Unicode password */
- MD4Init(&ctx);
+ MD4Init(&ctx);
MD4Update(&ctx, (u_char *)unipw, unipwLen*sizeof(u_int16_t));
- MD4Final(hash, &ctx);
+ MD4Final(hash, &ctx);
buffer = stpcpy(buffer, magic);
*buffer++ = '$';
diff --git a/lib/libcrypt/crypt-sha256.c b/lib/libcrypt/crypt-sha256.c
index 35c36bf93f3d..6da1d518b12d 100644
--- a/lib/libcrypt/crypt-sha256.c
+++ b/lib/libcrypt/crypt-sha256.c
@@ -41,6 +41,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include "crypt.h"
@@ -234,9 +235,9 @@ crypt_sha256(const char *key, const char *salt, char *buffer)
* the SHA256 implementation as well. */
SHA256_Init(&ctx);
SHA256_Final(alt_result, &ctx);
- memset(temp_result, '\0', sizeof(temp_result));
- memset(p_bytes, '\0', key_len);
- memset(s_bytes, '\0', salt_len);
+ explicit_bzero(temp_result, sizeof(temp_result));
+ explicit_bzero(p_bytes, key_len);
+ explicit_bzero(s_bytes, salt_len);
return (0);
}
diff --git a/lib/libcrypt/crypt-sha512.c b/lib/libcrypt/crypt-sha512.c
index 640398afadc4..b760623b5d8d 100644
--- a/lib/libcrypt/crypt-sha512.c
+++ b/lib/libcrypt/crypt-sha512.c
@@ -41,6 +41,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include "crypt.h"
@@ -246,9 +247,9 @@ crypt_sha512(const char *key, const char *salt, char *buffer)
* the SHA512 implementation as well. */
SHA512_Init(&ctx);
SHA512_Final(alt_result, &ctx);
- memset(temp_result, '\0', sizeof(temp_result));
- memset(p_bytes, '\0', key_len);
- memset(s_bytes, '\0', salt_len);
+ explicit_bzero(temp_result, sizeof(temp_result));
+ explicit_bzero(p_bytes, key_len);
+ explicit_bzero(s_bytes, salt_len);
return (0);
}
diff --git a/lib/libcrypt/crypt.c b/lib/libcrypt/crypt.c
index b4d0743df6cf..aaf3552f95ff 100644
--- a/lib/libcrypt/crypt.c
+++ b/lib/libcrypt/crypt.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
diff --git a/lib/libcrypt/libcrypt.aldscript b/lib/libcrypt/libcrypt.aldscript
new file mode 100644
index 000000000000..cfc8020dd9e3
--- /dev/null
+++ b/lib/libcrypt/libcrypt.aldscript
@@ -0,0 +1 @@
+INPUT(-l@@LIB@@@@STATICLIB_SUFFIX@@ -lmd)
diff --git a/lib/libcrypt/libcrypt.ldscript b/lib/libcrypt/libcrypt.ldscript
new file mode 100644
index 000000000000..a0b20fa43fe8
--- /dev/null
+++ b/lib/libcrypt/libcrypt.ldscript
@@ -0,0 +1 @@
+INPUT(@@SHLIB@@ AS_NEEDED(-lmd))
diff --git a/lib/libcrypt/misc.c b/lib/libcrypt/misc.c
index ce55f5234fa7..e5db6b5dd838 100644
--- a/lib/libcrypt/misc.c
+++ b/lib/libcrypt/misc.c
@@ -29,7 +29,6 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include "crypt.h"
diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile
index 8e97c95f95f2..f64fafe3c8cb 100644
--- a/lib/libcrypt/tests/Makefile
+++ b/lib/libcrypt/tests/Makefile
@@ -1,4 +1,3 @@
-
ATF_TESTS_C+= crypt_tests
NETBSD_ATF_TESTS_C+= crypt_test
diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile
index 48a724dd42f2..0f203b3a7cb1 100644
--- a/lib/libcxxrt/Makefile
+++ b/lib/libcxxrt/Makefile
@@ -1,9 +1,11 @@
-
PACKAGE= clibs
+SHLIBDIR?= /lib
+
+.include <src.opts.mk>
+
SRCDIR= ${SRCTOP}/contrib/libcxxrt
SHLIB_MAJOR= 1
-SHLIBDIR?= /lib
.PATH: ${SRCDIR}
@@ -21,7 +23,31 @@ SRCS+= typeinfo.cc
WARNS?= 0
CFLAGS+= -isystem ${SRCDIR} -nostdinc++
-CXXSTD?= c++14
-VERSION_MAP= ${.CURDIR}/Version.map
+
+.if exists(Version.map.${MACHINE})
+VERSION_MAP= ${.CURDIR}/Version.map.${MACHINE}
+.else
+.if ${MACHINE_ABI:Mlong32}
+VERSION_MAP= Version-32.map
+.else
+VERSION_MAP= Version-64.map
+.endif
+
+Version-32.map: Version.map
+ sed 's/%%NEW_DELETE_TYPE%%/int/' ${.ALLSRC} > ${.TARGET}
+
+Version-64.map: Version.map
+ sed 's/%%NEW_DELETE_TYPE%%/long/' ${.ALLSRC} > ${.TARGET}
+.endif
.include <bsd.lib.mk>
+
+# gcc13 doesn't support _Float16 on riscv, powerpc64, and x86 or __int128
+# on i386. Disable checks for missing symbols to allow this to link.
+#
+# XXX: This is a hack that hides an ABI divergence between clang and gcc.
+.if ${COMPILER_TYPE} == "gcc" && \
+ (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
+ ${MACHINE_ARCH:Mpowerpc64*} || ${MACHINE_ARCH} == "riscv64")
+LDFLAGS+= -Wl,--undefined-version
+.endif
diff --git a/lib/libcxxrt/Version.map b/lib/libcxxrt/Version.map
index 0d2dccbe2670..02cce34c234f 100644
--- a/lib/libcxxrt/Version.map
+++ b/lib/libcxxrt/Version.map
@@ -10,12 +10,10 @@ CXXABI_1.3 {
__cxa_bad_cast;
__cxa_bad_typeid;
__cxa_begin_catch;
- __cxa_begin_cleanup;
__cxa_call_unexpected;
__cxa_current_exception_type;
__cxa_demangle;
__cxa_end_catch;
- __cxa_end_cleanup;
__cxa_free_exception;
__cxa_get_globals;
__cxa_get_globals_fast;
@@ -26,42 +24,20 @@ CXXABI_1.3 {
__cxa_rethrow;
__cxa_throw;
__cxa_throw_bad_array_new_length;
- __cxa_type_match;
- __cxa_vec_cctor;
- __cxa_vec_cleanup;
- __cxa_vec_ctor;
- __cxa_vec_delete2;
- __cxa_vec_delete3;
- __cxa_vec_delete;
- __cxa_vec_dtor;
- __cxa_vec_new2;
- __cxa_vec_new3;
- __cxa_vec_new;
__dynamic_cast;
- __gxx_personality_sj0;
__gxx_personality_v0;
extern "C++" {
# Type info classes and their destructors
- "__cxxabiv1::__array_type_info";
"__cxxabiv1::__array_type_info::~__array_type_info()";
- "__cxxabiv1::__class_type_info";
"__cxxabiv1::__class_type_info::~__class_type_info()";
- "__cxxabiv1::__enum_type_info";
"__cxxabiv1::__enum_type_info::~__enum_type_info()";
- "__cxxabiv1::__function_type_info::";
"__cxxabiv1::__function_type_info::~__function_type_info()";
- "__cxxabiv1::__fundamental_type_info";
"__cxxabiv1::__fundamental_type_info::~__fundamental_type_info()";
- "__cxxabiv1::__pbase_type_info";
"__cxxabiv1::__pbase_type_info::~__pbase_type_info()";
- "__cxxabiv1::__pointer_to_member_type_info";
"__cxxabiv1::__pointer_to_member_type_info::~__pointer_to_member_type_info()";
- "__cxxabiv1::__pointer_type_info";
"__cxxabiv1::__pointer_type_info::~__pointer_type_info()";
- "__cxxabiv1::__si_class_type_info";
"__cxxabiv1::__si_class_type_info::~__si_class_type_info()";
- "__cxxabiv1::__vmi_class_type_info";
"__cxxabiv1::__vmi_class_type_info::~__vmi_class_type_info()";
# vtables typeinfo classes.
@@ -224,10 +200,6 @@ CXXABI_1.3 {
_ZTIDi;_ZTIPDi;_ZTIPKDi;
# char32_t
_ZTIDs;_ZTIPDs;_ZTIPKDs;
- # IEEE 754r decimal floating point
- _ZTIDd;_ZTIPDd;_ZTIPKDd;
- _ZTIDe;_ZTIPDe;_ZTIPKDe;
- _ZTIDf;_ZTIPDf;_ZTIPKDf;
# IEEE 754r half-precision floating point
_ZTIDh;_ZTIPDh;_ZTIPKDh;
@@ -238,10 +210,6 @@ CXXABI_1.3 {
_ZTSDi;_ZTSPDi;_ZTSPKDi;
# char32_t
_ZTSDs;_ZTSPDs;_ZTSPKDs;
- # IEEE 754r decimal floating point
- _ZTSDd;_ZTSPDd;_ZTSPKDd;
- _ZTSDe;_ZTSPDe;_ZTSPKDe;
- _ZTSDf;_ZTSPDf;_ZTSPKDf;
# IEEE 754r half-precision floating point
_ZTSDh;_ZTSPDh;_ZTSPKDh;
@@ -276,13 +244,19 @@ CXXABI_1.3.9 {
"typeinfo name for unsigned __int128 const*";
"typeinfo name for unsigned __int128";
"typeinfo name for unsigned __int128*";
- "operator delete[](void*, unsigned int)";
- "operator delete(void*, unsigned int)";
- "operator delete[](void*, unsigned long)";
- "operator delete(void*, unsigned long)";
+ "operator delete[](void*, unsigned %%NEW_DELETE_TYPE%%)";
+ "operator delete(void*, unsigned %%NEW_DELETE_TYPE%%)";
};
} CXXABI_1.3.6;
+CXXABI_1.3.11 {
+ __cxa_init_primary_exception;
+} CXXABI_1.3.9;
+
+CXXABI_1.3.15 {
+ __cxa_call_terminate;
+} CXXABI_1.3.11;
+
CXXRT_1.0 {
extern "C++" {
@@ -321,12 +295,9 @@ GLIBCXX_3.4 {
extern "C++" {
"operator delete[](void*)";
"operator delete(void*)";
- "operator new[](unsigned int)";
- "operator new(unsigned int)";
- "operator new(unsigned int, std::nothrow_t const&)";
- "operator new[](unsigned long)";
- "operator new(unsigned long)";
- "operator new(unsigned long, std::nothrow_t const&)";
+ "operator new[](unsigned %%NEW_DELETE_TYPE%%)";
+ "operator new(unsigned %%NEW_DELETE_TYPE%%)";
+ "operator new(unsigned %%NEW_DELETE_TYPE%%, std::nothrow_t const&)";
"std::unexpected()";
"std::get_terminate()";
diff --git a/lib/libcxxrt/Version.map.arm b/lib/libcxxrt/Version.map.arm
new file mode 100644
index 000000000000..aef918149b79
--- /dev/null
+++ b/lib/libcxxrt/Version.map.arm
@@ -0,0 +1,366 @@
+# Define the same version as the libsupc++ from gcc 4.2.1 so that we can use
+# libcxxrt as a drop-in replacement.
+
+CXXABI_1.3 {
+
+ global:
+
+ # ABI functions with C linkage
+ __cxa_allocate_exception;
+ __cxa_bad_cast;
+ __cxa_bad_typeid;
+ __cxa_begin_catch;
+ __cxa_call_unexpected;
+ __cxa_current_exception_type;
+ __cxa_demangle;
+ __cxa_end_catch;
+ __cxa_end_cleanup;
+ __cxa_free_exception;
+ __cxa_get_globals;
+ __cxa_get_globals_fast;
+ __cxa_guard_abort;
+ __cxa_guard_acquire;
+ __cxa_guard_release;
+ __cxa_pure_virtual;
+ __cxa_rethrow;
+ __cxa_throw;
+ __cxa_throw_bad_array_new_length;
+ __dynamic_cast;
+ __gxx_personality_v0;
+
+ extern "C++" {
+ # Type info classes and their destructors
+ "__cxxabiv1::__array_type_info::~__array_type_info()";
+ "__cxxabiv1::__class_type_info::~__class_type_info()";
+ "__cxxabiv1::__enum_type_info::~__enum_type_info()";
+ "__cxxabiv1::__function_type_info::~__function_type_info()";
+ "__cxxabiv1::__fundamental_type_info::~__fundamental_type_info()";
+ "__cxxabiv1::__pbase_type_info::~__pbase_type_info()";
+ "__cxxabiv1::__pointer_to_member_type_info::~__pointer_to_member_type_info()";
+ "__cxxabiv1::__pointer_type_info::~__pointer_type_info()";
+ "__cxxabiv1::__si_class_type_info::~__si_class_type_info()";
+ "__cxxabiv1::__vmi_class_type_info::~__vmi_class_type_info()";
+
+ # vtables typeinfo classes.
+ "vtable for __cxxabiv1::__array_type_info";
+ "vtable for __cxxabiv1::__class_type_info";
+ "vtable for __cxxabiv1::__enum_type_info";
+ "vtable for __cxxabiv1::__function_type_info";
+ "vtable for __cxxabiv1::__fundamental_type_info";
+ "vtable for __cxxabiv1::__pbase_type_info";
+ "vtable for __cxxabiv1::__pointer_to_member_type_info";
+ "vtable for __cxxabiv1::__pointer_type_info";
+ "vtable for __cxxabiv1::__si_class_type_info";
+ "vtable for __cxxabiv1::__vmi_class_type_info";
+
+ # Type info for built-in types
+ "typeinfo for bool const*";
+ "typeinfo for bool";
+ "typeinfo for char const*";
+ "typeinfo for char";
+ "typeinfo for double const*";
+ "typeinfo for double";
+ "typeinfo for float const*";
+ "typeinfo for float";
+ "typeinfo for int const*";
+ "typeinfo for int";
+ "typeinfo for long const*";
+ "typeinfo for long double const*";
+ "typeinfo for long double";
+ "typeinfo for long long const*";
+ "typeinfo for long long";
+ "typeinfo for long";
+ "typeinfo for short const*";
+ "typeinfo for short";
+ "typeinfo for signed char const*";
+ "typeinfo for signed char";
+ "typeinfo for unsigned char const*";
+ "typeinfo for unsigned char";
+ "typeinfo for unsigned int const*";
+ "typeinfo for unsigned int";
+ "typeinfo for unsigned long const*";
+ "typeinfo for unsigned long long const*";
+ "typeinfo for unsigned long long";
+ "typeinfo for unsigned long";
+ "typeinfo for unsigned short const*";
+ "typeinfo for unsigned short";
+ "typeinfo for void const*";
+ "typeinfo for void";
+ "typeinfo for wchar_t const*";
+ "typeinfo for wchar_t";
+
+ "typeinfo for bool*";
+ "typeinfo for wchar_t*";
+ "typeinfo for short*";
+ "typeinfo for char*";
+ "typeinfo for unsigned char*";
+ "typeinfo for long long*";
+ "typeinfo for unsigned short*";
+ "typeinfo for long*";
+ "typeinfo for double*";
+ "typeinfo for unsigned long*";
+ "typeinfo for unsigned long long*";
+ "typeinfo for int*";
+ "typeinfo for long double*";
+ "typeinfo for signed char*";
+ "typeinfo for void*";
+ "typeinfo for unsigned int*";
+ "typeinfo for float*";
+
+ "typeinfo for __cxxabiv1::__array_type_info";
+ "typeinfo for __cxxabiv1::__class_type_info";
+ "typeinfo for __cxxabiv1::__enum_type_info";
+ "typeinfo for __cxxabiv1::__function_type_info";
+ "typeinfo for __cxxabiv1::__fundamental_type_info";
+ "typeinfo for __cxxabiv1::__pbase_type_info";
+ "typeinfo for __cxxabiv1::__pointer_to_member_type_info";
+ "typeinfo for __cxxabiv1::__pointer_type_info";
+ "typeinfo for __cxxabiv1::__si_class_type_info";
+ "typeinfo for __cxxabiv1::__vmi_class_type_info";
+
+ # Typeinfo names.
+
+ "typeinfo name for unsigned char const*";
+ "typeinfo name for long const*";
+ "typeinfo name for double const*";
+ "typeinfo name for unsigned long long const*";
+ "typeinfo name for unsigned short const*";
+ "typeinfo name for char const*";
+ "typeinfo name for long long const*";
+ "typeinfo name for short const*";
+ "typeinfo name for unsigned int const*";
+ "typeinfo name for float const*";
+ "typeinfo name for bool const*";
+ "typeinfo name for wchar_t const*";
+ "typeinfo name for int const*";
+ "typeinfo name for unsigned long const*";
+ "typeinfo name for void const*";
+ "typeinfo name for long double const*";
+ "typeinfo name for signed char const*";
+ "typeinfo name for wchar_t";
+ "typeinfo name for short";
+ "typeinfo name for char";
+ "typeinfo name for float";
+ "typeinfo name for void";
+ "typeinfo name for unsigned int";
+ "typeinfo name for bool";
+ "typeinfo name for signed char";
+ "typeinfo name for long double";
+ "typeinfo name for int";
+ "typeinfo name for unsigned long long";
+ "typeinfo name for unsigned long";
+ "typeinfo name for unsigned char";
+ "typeinfo name for long";
+ "typeinfo name for long long";
+ "typeinfo name for unsigned short";
+ "typeinfo name for double";
+
+ "typeinfo name for bool*";
+ "typeinfo name for wchar_t*";
+ "typeinfo name for short*";
+ "typeinfo name for char*";
+ "typeinfo name for unsigned char*";
+ "typeinfo name for long long*";
+ "typeinfo name for unsigned short*";
+ "typeinfo name for long*";
+ "typeinfo name for double*";
+ "typeinfo name for unsigned long*";
+ "typeinfo name for unsigned long long*";
+ "typeinfo name for int*";
+ "typeinfo name for long double*";
+ "typeinfo name for signed char*";
+ "typeinfo name for void*";
+ "typeinfo name for unsigned int*";
+ "typeinfo name for float*";
+
+ "typeinfo name for __cxxabiv1::__array_type_info";
+ "typeinfo name for __cxxabiv1::__class_type_info";
+ "typeinfo name for __cxxabiv1::__enum_type_info";
+ "typeinfo name for __cxxabiv1::__function_type_info";
+ "typeinfo name for __cxxabiv1::__fundamental_type_info";
+ "typeinfo name for __cxxabiv1::__pbase_type_info";
+ "typeinfo name for __cxxabiv1::__pointer_to_member_type_info";
+ "typeinfo name for __cxxabiv1::__pointer_type_info";
+ "typeinfo name for __cxxabiv1::__si_class_type_info";
+ "typeinfo name for __cxxabiv1::__vmi_class_type_info";
+
+ "std::type_info::type_info(std::type_info const&)";
+ "std::type_info::operator=(std::type_info const&)";
+
+
+ # Extensions
+ "pathscale::set_terminate(void (*)())";
+ "pathscale::set_unexpected(void (*)())";
+ "pathscale::set_use_thread_local_handlers(bool)";
+ };
+
+ # C++11 typeinfo not understood by ld.bfd 2.17.50
+ # std::nullptr_t
+ _ZTIDn;_ZTIPDn;_ZTIPKDn;
+ # char16_t
+ _ZTIDi;_ZTIPDi;_ZTIPKDi;
+ # char32_t
+ _ZTIDs;_ZTIPDs;_ZTIPKDs;
+ # IEEE 754r half-precision floating point
+ _ZTIDh;_ZTIPDh;_ZTIPKDh;
+
+ # C++11 typeinfo name not understood by ld.bfd 2.17.50
+ # std::nullptr_t
+ _ZTSDn;_ZTSPDn;_ZTSPKDn;
+ # char16_t
+ _ZTSDi;_ZTSPDi;_ZTSPKDi;
+ # char32_t
+ _ZTSDs;_ZTSPDs;_ZTSPKDs;
+ # IEEE 754r half-precision floating point
+ _ZTSDh;_ZTSPDh;_ZTSPKDh;
+
+ local:
+ *;
+};
+
+CXXABI_1.3.1 {
+ __cxa_get_exception_ptr;
+} CXXABI_1.3;
+
+CXXABI_1.3.5 {
+ extern "C++" {
+ "typeinfo for __int128 const*";
+ "typeinfo for __int128";
+ "typeinfo for __int128*";
+ "typeinfo for unsigned __int128 const*";
+ "typeinfo for unsigned __int128";
+ "typeinfo for unsigned __int128*";
+ };
+} CXXABI_1.3.1;
+
+CXXABI_1.3.6 {
+ __cxa_deleted_virtual;
+} CXXABI_1.3.5;
+
+CXXABI_1.3.9 {
+ extern "C++" {
+ "typeinfo name for __int128 const*";
+ "typeinfo name for __int128";
+ "typeinfo name for __int128*";
+ "typeinfo name for unsigned __int128 const*";
+ "typeinfo name for unsigned __int128";
+ "typeinfo name for unsigned __int128*";
+ "operator delete[](void*, unsigned int)";
+ "operator delete(void*, unsigned int)";
+ };
+} CXXABI_1.3.6;
+
+CXXABI_1.3.11 {
+ __cxa_init_primary_exception;
+} CXXABI_1.3.9;
+
+CXXABI_1.3.15 {
+ __cxa_call_terminate;
+} CXXABI_1.3.11;
+
+CXXRT_1.0 {
+
+ extern "C++" {
+ "std::type_info::name() const";
+ "std::type_info::before(std::type_info const&) const";
+ "std::type_info::operator==(std::type_info const&) const";
+ "std::type_info::operator!=(std::type_info const&) const";
+ "std::bad_cast::bad_cast(std::bad_cast const&)";
+ "std::bad_cast::bad_cast()";
+ "std::bad_cast::operator=(std::bad_cast const&)";
+ "std::bad_typeid::bad_typeid(std::bad_typeid const&)";
+ "std::bad_typeid::bad_typeid()";
+ "std::bad_typeid::operator=(std::bad_typeid const&)";
+ "std::exception::exception(std::exception const&)";
+ "std::exception::exception()";
+ "std::exception::operator=(std::exception const&)";
+ "std::bad_alloc::bad_alloc(std::bad_alloc const&)";
+ "std::bad_alloc::bad_alloc()";
+ "std::bad_alloc::operator=(std::bad_alloc const&)";
+ "std::bad_array_new_length::bad_array_new_length(std::bad_array_new_length const&)";
+ "std::bad_array_new_length::bad_array_new_length()";
+ "std::bad_array_new_length::operator=(std::bad_array_new_length const&)";
+
+ };
+ __cxa_allocate_dependent_exception;
+ __cxa_current_primary_exception;
+ __cxa_decrement_exception_refcount;
+ __cxa_free_dependent_exception;
+ __cxa_increment_exception_refcount;
+ __cxa_rethrow_primary_exception;
+
+} CXXABI_1.3.6;
+
+
+GLIBCXX_3.4 {
+ extern "C++" {
+ "operator delete[](void*)";
+ "operator delete(void*)";
+ "operator new[](unsigned int)";
+ "operator new(unsigned int)";
+ "operator new(unsigned int, std::nothrow_t const&)";
+
+ "std::unexpected()";
+ "std::get_terminate()";
+ "std::get_unexpected()";
+ "std::uncaught_exception()";
+ "std::terminate()";
+
+ "std::type_info::~type_info()";
+ "std::bad_cast::~bad_cast()";
+ "std::bad_typeid::~bad_typeid()";
+ "std::exception::~exception()";
+ "std::bad_alloc::~bad_alloc()";
+ "std::bad_array_new_length::~bad_array_new_length()";
+
+ "std::exception::what() const";
+
+ std::set_new_handler*;
+ std::set_terminate*;
+ std::set_unexpected*;
+ std::type_info::__*;
+
+ "vtable for std::bad_alloc";
+ "vtable for std::bad_cast";
+ "vtable for std::bad_typeid";
+ "vtable for std::exception";
+ "vtable for std::type_info";
+ "vtable for std::bad_array_new_length";
+
+ "typeinfo for std::bad_alloc";
+ "typeinfo for std::bad_typeid";
+ "typeinfo for std::bad_cast";
+ "typeinfo for std::exception";
+ "typeinfo for std::type_info";
+ "typeinfo for std::bad_array_new_length";
+ "typeinfo name for std::bad_alloc";
+ "typeinfo name for std::bad_typeid";
+ "typeinfo name for std::bad_cast";
+ "typeinfo name for std::exception";
+ "typeinfo name for std::type_info";
+ "typeinfo name for std::bad_array_new_length";
+
+ };
+};
+
+GLIBCXX_3.4.9 {
+ extern "C++" {
+ "std::bad_typeid::what() const";
+ "std::bad_cast::what() const";
+ "std::bad_alloc::what() const";
+ "std::bad_array_new_length::what() const";
+ };
+} GLIBCXX_3.4;
+
+GLIBCXX_3.4.20 {
+ extern "C++" {
+ "std::get_new_handler()";
+ };
+} GLIBCXX_3.4.9;
+
+GLIBCXX_3.4.22 {
+ extern "C++" {
+ "std::uncaught_exceptions()";
+ };
+} GLIBCXX_3.4.20;
+
diff --git a/lib/libder/Makefile b/lib/libder/Makefile
new file mode 100644
index 000000000000..bdd2225f0ff3
--- /dev/null
+++ b/lib/libder/Makefile
@@ -0,0 +1,13 @@
+
+LIB= der
+INTERNALLIB=
+
+.PATH: ${SRCTOP}/contrib/libder/libder
+SRCS+= libder.c \
+ libder_error.c \
+ libder_obj.c \
+ libder_read.c \
+ libder_type.c \
+ libder_write.c
+
+.include <bsd.lib.mk>
diff --git a/lib/libdevctl/Makefile b/lib/libdevctl/Makefile
index 4e1993428d80..6e32151aeb12 100644
--- a/lib/libdevctl/Makefile
+++ b/lib/libdevctl/Makefile
@@ -1,4 +1,3 @@
-
LIB= devctl
SRCS= devctl.c
INCS= devctl.h
diff --git a/lib/libdevctl/devctl.3 b/lib/libdevctl/devctl.3
index a6823a0b3c6a..c8a4704825c2 100644
--- a/lib/libdevctl/devctl.3
+++ b/lib/libdevctl/devctl.3
@@ -209,7 +209,7 @@ method to construct the path.
The
.Fa buffer
pointer is updated with an allocated buffer that must be freed with
-.Xr free .
+.Xr free 3 .
.Pp
The
.Fn devctl_freeze
diff --git a/lib/libdevctl/devctl.c b/lib/libdevctl/devctl.c
index 20483e08da64..bc82d8b7b470 100644
--- a/lib/libdevctl/devctl.c
+++ b/lib/libdevctl/devctl.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/bus.h>
#include <errno.h>
diff --git a/lib/libdevdctl/Makefile b/lib/libdevdctl/Makefile
index 619c15a9285e..32cede96df4e 100644
--- a/lib/libdevdctl/Makefile
+++ b/lib/libdevdctl/Makefile
@@ -1,4 +1,3 @@
-
LIB_CXX= devdctl
INCS= consumer.h \
event.h \
diff --git a/lib/libdevdctl/consumer.h b/lib/libdevdctl/consumer.h
index 8ff14392ceb8..d0d814cff1f9 100644
--- a/lib/libdevdctl/consumer.h
+++ b/lib/libdevdctl/consumer.h
@@ -98,7 +98,7 @@ public:
/**
* Open a connection to devd's unix domain socket.
*
- * \return True if the connection attempt is successsful. Otherwise
+ * \return True if the connection attempt is successful. Otherwise
* false.
*/
bool ConnectToDevd();
diff --git a/lib/libdevdctl/tests/Makefile b/lib/libdevdctl/tests/Makefile
index a8019b468284..a77fff5c6108 100644
--- a/lib/libdevdctl/tests/Makefile
+++ b/lib/libdevdctl/tests/Makefile
@@ -1,4 +1,3 @@
-
TESTSDIR= ${TESTSBASE}/lib/libdevdctl
.PATH: ${.CURDIR:H}
diff --git a/lib/libdevinfo/Makefile b/lib/libdevinfo/Makefile
index e11e7a61af2d..b74806e42672 100644
--- a/lib/libdevinfo/Makefile
+++ b/lib/libdevinfo/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= devmatch
LIB= devinfo
SRCS= devinfo.c
@@ -15,7 +14,7 @@ MLINKS+=devinfo.3 devinfo_foreach_device_resource.3
MLINKS+=devinfo.3 devinfo_foreach_rman_resource.3
MLINKS+=devinfo.3 devinfo_foreach_rman.3
-SHLIB_MAJOR= 6
+SHLIB_MAJOR= 7
WARNS?= 3
diff --git a/lib/libdevinfo/devinfo.c b/lib/libdevinfo/devinfo.c
index 115e7ea76602..65a26d871371 100644
--- a/lib/libdevinfo/devinfo.c
+++ b/lib/libdevinfo/devinfo.c
@@ -420,7 +420,7 @@ devinfo_handle_to_device(devinfo_handle_t handle)
*/
if (handle == DEVINFO_ROOT_DEVICE) {
TAILQ_FOREACH(dd, &devinfo_dev, dd_link)
- if (dd->dd_dev.dd_parent == DEVINFO_ROOT_DEVICE)
+ if (dd->dd_dev.dd_parent == 0)
return(&dd->dd_dev);
return(NULL);
}
diff --git a/lib/libdevinfo/devinfo.h b/lib/libdevinfo/devinfo.h
index 32af3a0398a9..0d02a75195d3 100644
--- a/lib/libdevinfo/devinfo.h
+++ b/lib/libdevinfo/devinfo.h
@@ -30,12 +30,11 @@
#ifndef _DEVINFO_H_INCLUDED
#define _DEVINFO_H_INCLUDED
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/bus.h>
typedef __uintptr_t devinfo_handle_t;
-#define DEVINFO_ROOT_DEVICE ((devinfo_handle_t)0)
+#define DEVINFO_ROOT_DEVICE ((devinfo_handle_t)-1)
typedef enum device_state devinfo_state_t;
diff --git a/lib/libdevstat/Makefile b/lib/libdevstat/Makefile
index 0f3caef96b87..1531717d2fef 100644
--- a/lib/libdevstat/Makefile
+++ b/lib/libdevstat/Makefile
@@ -1,4 +1,3 @@
-
LIB= devstat
SHLIBDIR?= /lib
# Bump DEVSTAT_USER_API_VER in devstat.h every time this is incremented.
diff --git a/lib/libdevstat/devstat.3 b/lib/libdevstat/devstat.3
index 20f5fdd5649c..d0eaff359e15 100644
--- a/lib/libdevstat/devstat.3
+++ b/lib/libdevstat/devstat.3
@@ -428,6 +428,8 @@ Floppy devices
Integrated Drive Electronics devices
.It Li SCSI
Small Computer System Interface devices
+.It Li NVME
+NVM Express Interface devices
.It Li other
Any other device interface
.El
diff --git a/lib/libdevstat/devstat.c b/lib/libdevstat/devstat.c
index 7465613da4f1..879e6e09b3a9 100644
--- a/lib/libdevstat/devstat.c
+++ b/lib/libdevstat/devstat.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/errno.h>
@@ -75,6 +74,7 @@ struct devstat_match_table match_table[] = {
{"scsi", DEVSTAT_TYPE_IF_SCSI, DEVSTAT_MATCH_IF},
{"ide", DEVSTAT_TYPE_IF_IDE, DEVSTAT_MATCH_IF},
{"other", DEVSTAT_TYPE_IF_OTHER, DEVSTAT_MATCH_IF},
+ {"nvme", DEVSTAT_TYPE_IF_NVME, DEVSTAT_MATCH_IF},
{"worm", DEVSTAT_TYPE_WORM, DEVSTAT_MATCH_TYPE},
{"sa", DEVSTAT_TYPE_SEQUENTIAL,DEVSTAT_MATCH_TYPE},
{"pass", DEVSTAT_TYPE_PASS, DEVSTAT_MATCH_PASS},
diff --git a/lib/libdiff/Makefile b/lib/libdiff/Makefile
new file mode 100644
index 000000000000..8541ff424de2
--- /dev/null
+++ b/lib/libdiff/Makefile
@@ -0,0 +1,20 @@
+.include <src.opts.mk>
+
+LIB= diff
+INTERNALLIB= # API not published or supported.
+
+.PATH: ${SRCTOP}/contrib/libdiff/compat
+.PATH: ${SRCTOP}/contrib/libdiff/lib
+
+SRCS= diff_atomize_text.c diff_main.c diff_myers.c \
+ diff_patience.c diff_output.c diff_output_plain.c \
+ diff_output_unidiff.c diff_output_edscript.c recallocarray.c
+
+WARNS=
+CFLAGS+= -I${SRCTOP}/contrib/libdiff/compat/include
+CFLAGS+= -I${SRCTOP}/contrib/libdiff/include
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.lib.mk>
diff --git a/lib/libdiff/tests/Makefile b/lib/libdiff/tests/Makefile
new file mode 100644
index 000000000000..278ad7c95dcf
--- /dev/null
+++ b/lib/libdiff/tests/Makefile
@@ -0,0 +1,8 @@
+PACKAGE= tests
+
+ATF_TESTS_C= libdiff_test
+
+CFLAGS = -I${SRCTOP}/contrib/libdiff/lib -I${SRCTOP}/contrib/libdiff/include
+LIBADD = diff
+
+.include <bsd.test.mk>
diff --git a/lib/libdiff/tests/libdiff_test.c b/lib/libdiff/tests/libdiff_test.c
new file mode 100644
index 000000000000..e82a36f3d38a
--- /dev/null
+++ b/lib/libdiff/tests/libdiff_test.c
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2024 Klara, Inc.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <arraylist.h>
+#include <diff_main.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITH_CLEANUP(diff_atomize_truncated);
+ATF_TC_HEAD(diff_atomize_truncated, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Verify that the atomizer "
+ "does not crash when an input file is truncated");
+}
+ATF_TC_BODY(diff_atomize_truncated, tc)
+{
+ char line[128];
+ struct diff_config cfg = { .atomize_func = diff_atomize_text_by_line };
+ struct diff_data d = { };
+ const char *fn = atf_tc_get_ident(tc);
+ FILE *f;
+ unsigned char *p;
+ size_t size = 65536;
+
+ ATF_REQUIRE((f = fopen(fn, "w+")) != NULL);
+ line[sizeof(line) - 1] = '\n';
+ for (unsigned int i = 0; i <= size / sizeof(line); i++) {
+ memset(line, 'a' + i % 26, sizeof(line) - 1);
+ ATF_REQUIRE(fwrite(line, sizeof(line), 1, f) == 1);
+ }
+ ATF_REQUIRE(fsync(fileno(f)) == 0);
+ rewind(f);
+ ATF_REQUIRE(truncate(fn, size / 2) == 0);
+ ATF_REQUIRE((p = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fileno(f), 0)) != MAP_FAILED);
+ ATF_REQUIRE(diff_atomize_file(&d, &cfg, f, p, size, 0) == 0);
+ ATF_REQUIRE((size_t)d.len <= size / 2);
+ ATF_REQUIRE((size_t)d.len >= size / 2 - sizeof(line));
+ ATF_REQUIRE(d.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED);
+}
+ATF_TC_CLEANUP(diff_atomize_truncated, tc)
+{
+ unlink(atf_tc_get_ident(tc));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, diff_atomize_truncated);
+ return atf_no_error();
+}
diff --git a/lib/libdl/Makefile b/lib/libdl/Makefile
index 3432e244a5d1..d958dec85990 100644
--- a/lib/libdl/Makefile
+++ b/lib/libdl/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=clibs
LIB=dl
SHLIB_MAJOR=1
diff --git a/lib/libdl/Makefile.depend b/lib/libdl/Makefile.depend
index 6ef78fac5cbf..e0d18fcef3a4 100644
--- a/lib/libdl/Makefile.depend
+++ b/lib/libdl/Makefile.depend
@@ -6,6 +6,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libsys \
.include <dirdeps.mk>
diff --git a/lib/libdl/Symbol.map b/lib/libdl/Symbol.map
index 67d26c1f1dfe..f0e03c4940ce 100644
--- a/lib/libdl/Symbol.map
+++ b/lib/libdl/Symbol.map
@@ -17,3 +17,12 @@ FBSD_1.0 {
FBSD_1.3 {
fdlopen;
};
+
+FBSD_1.8 {
+ rtld_get_var;
+ rtld_set_var;
+};
+
+FBSDprivate_1.0 {
+ _dl_iterate_phdr_locked;
+};
diff --git a/lib/libdpv/Makefile b/lib/libdpv/Makefile
index 80b3e8620042..31f1186fa31b 100644
--- a/lib/libdpv/Makefile
+++ b/lib/libdpv/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= dpv
LIB= dpv
SHLIB_MAJOR= 3
diff --git a/lib/libdpv/dialogrc.c b/lib/libdpv/dialogrc.c
index fb4552e2db80..2ac745964e15 100644
--- a/lib/libdpv/dialogrc.c
+++ b/lib/libdpv/dialogrc.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <err.h>
diff --git a/lib/libdpv/dprompt.c b/lib/libdpv/dprompt.c
index b891d4c779fa..66f785ac86a1 100644
--- a/lib/libdpv/dprompt.c
+++ b/lib/libdpv/dprompt.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#define _BSD_SOURCE /* to get dprintf() prototype in stdio.h below */
diff --git a/lib/libedit/Makefile b/lib/libedit/Makefile
index f316c5d249a2..f0254c1f42bc 100644
--- a/lib/libedit/Makefile
+++ b/lib/libedit/Makefile
@@ -1,5 +1,4 @@
# $NetBSD: Makefile,v 1.56 2016/03/02 19:24:20 christos Exp $
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
PACKAGE=clibs
@@ -9,7 +8,6 @@ EDITDIR= ${SRCTOP}/contrib/libedit
SHLIB_MAJOR= 8
SHLIBDIR?= /lib
-WARNS?= 3
LIB= edit
LIBADD= tinfow
diff --git a/lib/libedit/Makefile.depend b/lib/libedit/Makefile.depend
index dd06faaab7bf..c6788a7857d3 100644
--- a/lib/libedit/Makefile.depend
+++ b/lib/libedit/Makefile.depend
@@ -1,6 +1,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/libedit/readline/Makefile b/lib/libedit/readline/Makefile
index 0f771e647458..b717846de0a5 100644
--- a/lib/libedit/readline/Makefile
+++ b/lib/libedit/readline/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/contrib/libedit/readline
INCS= readline.h history.h tilde.h
diff --git a/lib/libefivar/FreeBSD-update b/lib/libefivar/FreeBSD-update
index 375f9ceb9536..52d0db4021ef 100644
--- a/lib/libefivar/FreeBSD-update
+++ b/lib/libefivar/FreeBSD-update
@@ -6,7 +6,7 @@ efivar-dp-parse.c is a copy of MdePkg/Library/UefiDevicePathLib/DevicePathFromTe
These files are first mechnaically processed with
-sed -e "s/L'/'/;"'s/L"/"/g;s/%g/%36s/g;s/%a/%s/g;s/^VOID/static VOID/g;s/ *$//g'
+sed -e "s/L'/'/g;"'s/L"/"/g;s/%g/%36s/g;s/%a/%s/g;s/^VOID/static VOID/g;s/ *$//g'
for several reasons. We're moving from wide rotuines to narrow routines. The
UTC-2 this code is written for is a bad match for wchar_t which is an int. It's
diff --git a/lib/libefivar/efivar-dp-format.c b/lib/libefivar/efivar-dp-format.c
index d97603c41dcb..f2dcf1b91c01 100644
--- a/lib/libefivar/efivar-dp-format.c
+++ b/lib/libefivar/efivar-dp-format.c
@@ -28,7 +28,6 @@
* this file is taken from EDK2 and rototilled.
*/
-#include <sys/cdefs.h>
#include <efivar.h>
#include <stdio.h>
#include <string.h>
@@ -478,23 +477,41 @@ DevPathToTextAcpiEx (
)
{
ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx;
- CHAR8 *HIDStr;
- CHAR8 *UIDStr;
- CHAR8 *CIDStr;
char HIDText[11];
char CIDText[11];
-
- AcpiEx = DevPath;
- HIDStr = (CHAR8 *)(((UINT8 *)AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
- UIDStr = HIDStr + AsciiStrLen (HIDStr) + 1;
- CIDStr = UIDStr + AsciiStrLen (UIDStr) + 1;
+ UINTN CurrentLength;
+ CHAR8 *CurrentPos;
+ UINTN NextStringOffset;
+ CHAR8 *Strings[3];
+ UINT8 HidStrIndex;
+ UINT8 UidStrIndex;
+ UINT8 CidStrIndex;
+ UINT8 StrIndex;
+
+ HidStrIndex = 0;
+ UidStrIndex = 1;
+ CidStrIndex = 2;
+ AcpiEx = DevPath;
+ Strings[HidStrIndex] = NULL;
+ Strings[UidStrIndex] = NULL;
+ Strings[CidStrIndex] = NULL;
+ CurrentLength = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH);
+ CurrentPos = (CHAR8 *)(((UINT8 *)AcpiEx) + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
+ StrIndex = 0;
+ while (CurrentLength < AcpiEx->Header.Length[0] && StrIndex < ARRAY_SIZE (Strings)) {
+ Strings[StrIndex] = CurrentPos;
+ NextStringOffset = AsciiStrLen (CurrentPos) + 1;
+ CurrentLength += NextStringOffset;
+ CurrentPos += NextStringOffset;
+ StrIndex++;
+ }
if (DisplayOnly) {
if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A03) ||
((EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A03) && (EISA_ID_TO_NUM (AcpiEx->HID) != 0x0A08)))
{
- if (AcpiEx->UID == 0) {
- UefiDevicePathLibCatPrint (Str, "PciRoot(%s)", UIDStr);
+ if (Strings[UidStrIndex] != NULL) {
+ UefiDevicePathLibCatPrint (Str, "PciRoot(%s)", Strings[UidStrIndex]);
} else {
UefiDevicePathLibCatPrint (Str, "PciRoot(0x%x)", AcpiEx->UID);
}
@@ -503,8 +520,8 @@ DevPathToTextAcpiEx (
}
if ((EISA_ID_TO_NUM (AcpiEx->HID) == 0x0A08) || (EISA_ID_TO_NUM (AcpiEx->CID) == 0x0A08)) {
- if (AcpiEx->UID == 0) {
- UefiDevicePathLibCatPrint (Str, "PcieRoot(%s)", UIDStr);
+ if (Strings[UidStrIndex] != NULL) {
+ UefiDevicePathLibCatPrint (Str, "PcieRoot(%s)", Strings[UidStrIndex]);
} else {
UefiDevicePathLibCatPrint (Str, "PcieRoot(0x%x)", AcpiEx->UID);
}
@@ -535,7 +552,10 @@ DevPathToTextAcpiEx (
(AcpiEx->CID >> 16) & 0xFFFF
);
- if ((*HIDStr == '\0') && (*CIDStr == '\0') && (*UIDStr != '\0')) {
+ if (((Strings[HidStrIndex] != NULL) && (*Strings[HidStrIndex] == '\0')) &&
+ ((Strings[CidStrIndex] != NULL) && (*Strings[CidStrIndex] == '\0')) &&
+ ((Strings[UidStrIndex] != NULL) && (*Strings[UidStrIndex] != '\0')))
+ {
//
// use AcpiExp()
//
@@ -544,7 +564,7 @@ DevPathToTextAcpiEx (
Str,
"AcpiExp(%s,0,%s)",
HIDText,
- UIDStr
+ Strings[UidStrIndex]
);
} else {
UefiDevicePathLibCatPrint (
@@ -552,28 +572,25 @@ DevPathToTextAcpiEx (
"AcpiExp(%s,%s,%s)",
HIDText,
CIDText,
- UIDStr
+ Strings[UidStrIndex]
);
}
} else {
if (DisplayOnly) {
- //
- // display only
- //
- if (AcpiEx->HID == 0) {
- UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDStr);
+ if (Strings[HidStrIndex] != NULL) {
+ UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", Strings[HidStrIndex]);
} else {
UefiDevicePathLibCatPrint (Str, "AcpiEx(%s,", HIDText);
}
- if (AcpiEx->CID == 0) {
- UefiDevicePathLibCatPrint (Str, "%s,", CIDStr);
+ if (Strings[CidStrIndex] != NULL) {
+ UefiDevicePathLibCatPrint (Str, "%s,", Strings[CidStrIndex]);
} else {
UefiDevicePathLibCatPrint (Str, "%s,", CIDText);
}
- if (AcpiEx->UID == 0) {
- UefiDevicePathLibCatPrint (Str, "%s)", UIDStr);
+ if (Strings[UidStrIndex] != NULL) {
+ UefiDevicePathLibCatPrint (Str, "%s)", Strings[UidStrIndex]);
} else {
UefiDevicePathLibCatPrint (Str, "0x%x)", AcpiEx->UID);
}
@@ -584,9 +601,9 @@ DevPathToTextAcpiEx (
HIDText,
CIDText,
AcpiEx->UID,
- HIDStr,
- CIDStr,
- UIDStr
+ Strings[HidStrIndex] != NULL ? Strings[HidStrIndex] : '\0',
+ Strings[CidStrIndex] != NULL ? Strings[CidStrIndex] : '\0',
+ Strings[UidStrIndex] != NULL ? Strings[UidStrIndex] : '\0'
);
}
}
@@ -1886,7 +1903,11 @@ DevPathToTextUri (
Uri = DevPath;
UriLength = DevicePathNodeLength (Uri) - sizeof (URI_DEVICE_PATH);
UriStr = AllocatePool (UriLength + 1);
- ASSERT (UriStr != NULL);
+
+ if (UriStr == NULL) {
+ ASSERT (UriStr != NULL);
+ return;
+ }
CopyMem (UriStr, Uri->Uri, UriLength);
UriStr[UriLength] = '\0';
@@ -1922,7 +1943,7 @@ DevPathToTextHardDrive (
case SIGNATURE_TYPE_MBR:
UefiDevicePathLibCatPrint (
Str,
- "HD(%d,%s,0x%08x,",
+ "HD(%d,%s,0x%08x",
Hd->PartitionNumber,
"MBR",
// *((UINT32 *)(&(Hd->Signature[0])))
@@ -1933,7 +1954,7 @@ DevPathToTextHardDrive (
case SIGNATURE_TYPE_GUID:
UefiDevicePathLibCatPrint (
Str,
- "HD(%d,%s,%36s,",
+ "HD(%d,%s,%36s",
Hd->PartitionNumber,
"GPT",
G(&(Hd->Signature[0]))
@@ -1943,14 +1964,18 @@ DevPathToTextHardDrive (
default:
UefiDevicePathLibCatPrint (
Str,
- "HD(%d,%d,0,",
+ "HD(%d,%d,0",
Hd->PartitionNumber,
Hd->SignatureType
);
break;
}
- UefiDevicePathLibCatPrint (Str, "0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
+ if (DisplayOnly) {
+ UefiDevicePathLibCatPrint (Str, ")");
+ } else {
+ UefiDevicePathLibCatPrint (Str, ",0x%lx,0x%lx)", Hd->PartitionStart, Hd->PartitionSize);
+ }
}
/**
diff --git a/lib/libefivar/efivar-dp-parse.c b/lib/libefivar/efivar-dp-parse.c
index f68c9798fb2e..51c134692f1e 100644
--- a/lib/libefivar/efivar-dp-parse.c
+++ b/lib/libefivar/efivar-dp-parse.c
@@ -28,7 +28,6 @@
* this file is taken from EDK2 and rototilled.
*/
-#include <sys/cdefs.h>
#include <ctype.h>
#include <efivar.h>
#include <stdio.h>
@@ -337,14 +336,14 @@ IsHexStr (
//
// skip preceeding white space
//
- while ((*Str != 0) && *Str == ' ') {
+ while (*Str == ' ') {
Str++;
}
//
// skip preceeding zeros
//
- while ((*Str != 0) && *Str == '0') {
+ while (*Str == '0') {
Str++;
}
@@ -461,7 +460,10 @@ DevPathFromTextGenericPath (
(UINT16)(sizeof (EFI_DEVICE_PATH_PROTOCOL) + DataLength)
);
- StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength);
+ if (Node != NULL) {
+ StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength);
+ }
+
return Node;
}
@@ -529,8 +531,10 @@ DevPathFromTextPci (
(UINT16)sizeof (PCI_DEVICE_PATH)
);
- Pci->Function = (UINT8)Strtoi (FunctionStr);
- Pci->Device = (UINT8)Strtoi (DeviceStr);
+ if (Pci != NULL) {
+ Pci->Function = (UINT8)Strtoi (FunctionStr);
+ Pci->Device = (UINT8)Strtoi (DeviceStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Pci;
}
@@ -559,7 +563,9 @@ DevPathFromTextPcCard (
(UINT16)sizeof (PCCARD_DEVICE_PATH)
);
- Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr);
+ if (Pccard != NULL) {
+ Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Pccard;
}
@@ -592,9 +598,11 @@ DevPathFromTextMemoryMapped (
(UINT16)sizeof (MEMMAP_DEVICE_PATH)
);
- MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr);
- Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
- Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
+ if (MemMap != NULL) {
+ MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr);
+ Strtoi64 (StartingAddressStr, &MemMap->StartingAddress);
+ Strtoi64 (EndingAddressStr, &MemMap->EndingAddress);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)MemMap;
}
@@ -638,8 +646,10 @@ ConvertFromTextVendor (
(UINT16)(sizeof (VENDOR_DEVICE_PATH) + Length)
);
- StrToGuid (GuidStr, &Vendor->Guid);
- StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length);
+ if (Vendor != NULL) {
+ StrToGuid (GuidStr, &Vendor->Guid);
+ StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
@@ -688,7 +698,10 @@ DevPathFromTextCtrl (
HW_CONTROLLER_DP,
(UINT16)sizeof (CONTROLLER_DEVICE_PATH)
);
- Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr);
+
+ if (Controller != NULL) {
+ Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Controller;
}
@@ -719,11 +732,13 @@ DevPathFromTextBmc (
(UINT16)sizeof (BMC_DEVICE_PATH)
);
- BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr);
- WriteUnaligned64 (
- (UINT64 *)(&BmcDp->BaseAddress),
- StrHexToUint64 (BaseAddressStr)
- );
+ if (BmcDp != NULL) {
+ BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr);
+ WriteUnaligned64 (
+ (UINT64 *)(&BmcDp->BaseAddress),
+ StrHexToUint64 (BaseAddressStr)
+ );
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)BmcDp;
}
@@ -791,8 +806,10 @@ DevPathFromTextAcpi (
(UINT16)sizeof (ACPI_HID_DEVICE_PATH)
);
- Acpi->HID = EisaIdFromText (HIDStr);
- Acpi->UID = (UINT32)Strtoi (UIDStr);
+ if (Acpi != NULL) {
+ Acpi->HID = EisaIdFromText (HIDStr);
+ Acpi->UID = (UINT32)Strtoi (UIDStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
}
@@ -823,8 +840,10 @@ ConvertFromTextAcpi (
(UINT16)sizeof (ACPI_HID_DEVICE_PATH)
);
- Acpi->HID = EFI_PNP_ID (PnPId);
- Acpi->UID = (UINT32)Strtoi (UIDStr);
+ if (Acpi != NULL) {
+ Acpi->HID = EFI_PNP_ID (PnPId);
+ Acpi->UID = (UINT32)Strtoi (UIDStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Acpi;
}
@@ -971,14 +990,16 @@ DevPathFromTextAcpiEx (
Length
);
- AcpiEx->HID = EisaIdFromText (HIDStr);
- AcpiEx->CID = EisaIdFromText (CIDStr);
- AcpiEx->UID = (UINT32)Strtoi (UIDStr);
+ if (AcpiEx != NULL) {
+ AcpiEx->HID = EisaIdFromText (HIDStr);
+ AcpiEx->CID = EisaIdFromText (CIDStr);
+ AcpiEx->UID = (UINT32)Strtoi (UIDStr);
- AsciiStr = (CHAR8 *)((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
- StrToAscii (HIDSTRStr, &AsciiStr);
- StrToAscii (UIDSTRStr, &AsciiStr);
- StrToAscii (CIDSTRStr, &AsciiStr);
+ AsciiStr = (CHAR8 *)((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));
+ StrToAscii (HIDSTRStr, &AsciiStr);
+ StrToAscii (UIDSTRStr, &AsciiStr);
+ StrToAscii (CIDSTRStr, &AsciiStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx;
}
@@ -1014,6 +1035,10 @@ DevPathFromTextAcpiExp (
Length
);
+ if (AcpiEx == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx;
+ }
+
AcpiEx->HID = EisaIdFromText (HIDStr);
//
// According to UEFI spec, the CID parameter is optional and has a default value of 0.
@@ -1070,7 +1095,10 @@ DevPathFromTextAcpiAdr (
ACPI_ADR_DP,
(UINT16)sizeof (ACPI_ADR_DEVICE_PATH)
);
- ASSERT (AcpiAdr != NULL);
+ if (AcpiAdr == NULL) {
+ ASSERT (AcpiAdr != NULL);
+ return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr;
+ }
for (Index = 0; ; Index++) {
DisplayDeviceStr = GetNextParamStr (&TextDeviceNode);
@@ -1085,7 +1113,12 @@ DevPathFromTextAcpiAdr (
Length + sizeof (UINT32),
AcpiAdr
);
- ASSERT (AcpiAdr != NULL);
+
+ if (AcpiAdr == NULL) {
+ ASSERT (AcpiAdr != NULL);
+ return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr;
+ }
+
SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));
}
@@ -1137,6 +1170,10 @@ DevPathFromTextAta (
(UINT16)sizeof (ATAPI_DEVICE_PATH)
);
+ if (Atapi == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)Atapi;
+ }
+
PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode);
SlaveMasterStr = GetNextParamStr (&TextDeviceNode);
LunStr = GetNextParamStr (&TextDeviceNode);
@@ -1188,8 +1225,10 @@ DevPathFromTextScsi (
(UINT16)sizeof (SCSI_DEVICE_PATH)
);
- Scsi->Pun = (UINT16)Strtoi (PunStr);
- Scsi->Lun = (UINT16)Strtoi (LunStr);
+ if (Scsi != NULL) {
+ Scsi->Pun = (UINT16)Strtoi (PunStr);
+ Scsi->Lun = (UINT16)Strtoi (LunStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Scsi;
}
@@ -1220,9 +1259,11 @@ DevPathFromTextFibre (
(UINT16)sizeof (FIBRECHANNEL_DEVICE_PATH)
);
- Fibre->Reserved = 0;
- Strtoi64 (WWNStr, &Fibre->WWN);
- Strtoi64 (LunStr, &Fibre->Lun);
+ if (Fibre != NULL) {
+ Fibre->Reserved = 0;
+ Strtoi64 (WWNStr, &Fibre->WWN);
+ Strtoi64 (LunStr, &Fibre->Lun);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Fibre;
}
@@ -1253,12 +1294,14 @@ DevPathFromTextFibreEx (
(UINT16)sizeof (FIBRECHANNELEX_DEVICE_PATH)
);
- FibreEx->Reserved = 0;
- Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN));
- Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun));
+ if (FibreEx != NULL) {
+ FibreEx->Reserved = 0;
+ Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN));
+ Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun));
- *(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN));
- *(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun));
+ *(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN));
+ *(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun));
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)FibreEx;
}
@@ -1287,8 +1330,10 @@ DevPathFromText1394 (
(UINT16)sizeof (F1394_DEVICE_PATH)
);
- F1394DevPath->Reserved = 0;
- F1394DevPath->Guid = StrHexToUint64 (GuidStr);
+ if (F1394DevPath != NULL) {
+ F1394DevPath->Reserved = 0;
+ F1394DevPath->Guid = StrHexToUint64 (GuidStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)F1394DevPath;
}
@@ -1319,8 +1364,10 @@ DevPathFromTextUsb (
(UINT16)sizeof (USB_DEVICE_PATH)
);
- Usb->ParentPortNumber = (UINT8)Strtoi (PortStr);
- Usb->InterfaceNumber = (UINT8)Strtoi (InterfaceStr);
+ if (Usb != NULL) {
+ Usb->ParentPortNumber = (UINT8)Strtoi (PortStr);
+ Usb->InterfaceNumber = (UINT8)Strtoi (InterfaceStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Usb;
}
@@ -1349,7 +1396,9 @@ DevPathFromTextI2O (
(UINT16)sizeof (I2O_DEVICE_PATH)
);
- I2ODevPath->Tid = (UINT32)Strtoi (TIDStr);
+ if (I2ODevPath != NULL) {
+ I2ODevPath->Tid = (UINT32)Strtoi (TIDStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)I2ODevPath;
}
@@ -1386,11 +1435,13 @@ DevPathFromTextInfiniband (
(UINT16)sizeof (INFINIBAND_DEVICE_PATH)
);
- InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr);
- StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid);
- Strtoi64 (SidStr, &InfiniBand->ServiceId);
- Strtoi64 (TidStr, &InfiniBand->TargetPortId);
- Strtoi64 (DidStr, &InfiniBand->DeviceId);
+ if (InfiniBand != NULL) {
+ InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr);
+ StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid);
+ Strtoi64 (SidStr, &InfiniBand->ServiceId);
+ Strtoi64 (TidStr, &InfiniBand->TargetPortId);
+ Strtoi64 (DidStr, &InfiniBand->DeviceId);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)InfiniBand;
}
@@ -1437,7 +1488,10 @@ DevPathFromTextVenPcAnsi (
MSG_VENDOR_DP,
(UINT16)sizeof (VENDOR_DEVICE_PATH)
);
- CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
+
+ if (Vendor != NULL) {
+ CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
@@ -1463,7 +1517,10 @@ DevPathFromTextVenVt100 (
MSG_VENDOR_DP,
(UINT16)sizeof (VENDOR_DEVICE_PATH)
);
- CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
+
+ if (Vendor != NULL) {
+ CopyGuid (&Vendor->Guid, &gEfiVT100Guid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
@@ -1489,7 +1546,10 @@ DevPathFromTextVenVt100Plus (
MSG_VENDOR_DP,
(UINT16)sizeof (VENDOR_DEVICE_PATH)
);
- CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
+
+ if (Vendor != NULL) {
+ CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
@@ -1515,7 +1575,10 @@ DevPathFromTextVenUtf8 (
MSG_VENDOR_DP,
(UINT16)sizeof (VENDOR_DEVICE_PATH)
);
- CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
+
+ if (Vendor != NULL) {
+ CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vendor;
}
@@ -1544,13 +1607,15 @@ DevPathFromTextUartFlowCtrl (
(UINT16)sizeof (UART_FLOW_CONTROL_DEVICE_PATH)
);
- CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
- if (StrCmp (ValueStr, "XonXoff") == 0) {
- UartFlowControl->FlowControlMap = 2;
- } else if (StrCmp (ValueStr, "Hardware") == 0) {
- UartFlowControl->FlowControlMap = 1;
- } else {
- UartFlowControl->FlowControlMap = 0;
+ if (UartFlowControl != NULL) {
+ CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid);
+ if (StrCmp (ValueStr, "XonXoff") == 0) {
+ UartFlowControl->FlowControlMap = 2;
+ } else if (StrCmp (ValueStr, "Hardware") == 0) {
+ UartFlowControl->FlowControlMap = 1;
+ } else {
+ UartFlowControl->FlowControlMap = 0;
+ }
}
return (EFI_DEVICE_PATH_PROTOCOL *)UartFlowControl;
@@ -1596,6 +1661,10 @@ DevPathFromTextSAS (
(UINT16)sizeof (SAS_DEVICE_PATH)
);
+ if (Sas == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)Sas;
+ }
+
CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid);
Strtoi64 (AddressStr, &Sas->SasAddress);
Strtoi64 (LunStr, &Sas->Lun);
@@ -1692,6 +1761,10 @@ DevPathFromTextSasEx (
(UINT16)sizeof (SASEX_DEVICE_PATH)
);
+ if (SasEx == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)SasEx;
+ }
+
Strtoi64 (AddressStr, &SasAddress);
Strtoi64 (LunStr, &Lun);
WriteUnaligned64 ((UINT64 *)&SasEx->SasAddress, SwapBytes64 (SasAddress));
@@ -1776,12 +1849,14 @@ DevPathFromTextNVMe (
(UINT16)sizeof (NVME_NAMESPACE_DEVICE_PATH)
);
- Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr);
- Uuid = (UINT8 *)&Nvme->NamespaceUuid;
+ if (Nvme != NULL) {
+ Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr);
+ Uuid = (UINT8 *)&Nvme->NamespaceUuid;
- Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
- while (Index-- != 0) {
- Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, '-'));
+ Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
+ while (Index-- != 0) {
+ Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, '-'));
+ }
}
return (EFI_DEVICE_PATH_PROTOCOL *)Nvme;
@@ -1813,8 +1888,10 @@ DevPathFromTextUfs (
(UINT16)sizeof (UFS_DEVICE_PATH)
);
- Ufs->Pun = (UINT8)Strtoi (PunStr);
- Ufs->Lun = (UINT8)Strtoi (LunStr);
+ if (Ufs != NULL) {
+ Ufs->Pun = (UINT8)Strtoi (PunStr);
+ Ufs->Lun = (UINT8)Strtoi (LunStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Ufs;
}
@@ -1843,7 +1920,9 @@ DevPathFromTextSd (
(UINT16)sizeof (SD_DEVICE_PATH)
);
- Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
+ if (Sd != NULL) {
+ Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Sd;
}
@@ -1872,7 +1951,9 @@ DevPathFromTextEmmc (
(UINT16)sizeof (EMMC_DEVICE_PATH)
);
- Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
+ if (Emmc != NULL) {
+ Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Emmc;
}
@@ -1899,7 +1980,9 @@ DevPathFromTextDebugPort (
(UINT16)sizeof (VENDOR_DEVICE_PATH)
);
- CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
+ if (Vend != NULL) {
+ CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vend;
}
@@ -1931,14 +2014,16 @@ DevPathFromTextMAC (
(UINT16)sizeof (MAC_ADDR_DEVICE_PATH)
);
- MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr);
+ if (MACDevPath != NULL) {
+ MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr);
- Length = sizeof (EFI_MAC_ADDRESS);
- if ((MACDevPath->IfType == 0x01) || (MACDevPath->IfType == 0x00)) {
- Length = 6;
- }
+ Length = sizeof (EFI_MAC_ADDRESS);
+ if ((MACDevPath->IfType == 0x01) || (MACDevPath->IfType == 0x00)) {
+ Length = 6;
+ }
- StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
+ StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)MACDevPath;
}
@@ -2002,6 +2087,10 @@ DevPathFromTextIPv4 (
(UINT16)sizeof (IPv4_DEVICE_PATH)
);
+ if (IPv4 == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)IPv4;
+ }
+
StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL);
IPv4->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr);
if (StrCmp (TypeStr, "Static") == 0) {
@@ -2059,6 +2148,10 @@ DevPathFromTextIPv6 (
(UINT16)sizeof (IPv6_DEVICE_PATH)
);
+ if (IPv6 == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)IPv6;
+ }
+
StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL);
IPv6->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr);
if (StrCmp (TypeStr, "Static") == 0) {
@@ -2114,6 +2207,10 @@ DevPathFromTextUart (
(UINT16)sizeof (UART_DEVICE_PATH)
);
+ if (Uart == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)Uart;
+ }
+
if (StrCmp (BaudStr, "DEFAULT") == 0) {
Uart->BaudRate = 115200;
} else {
@@ -2195,6 +2292,10 @@ ConvertFromTextUsbClass (
(UINT16)sizeof (USB_CLASS_DEVICE_PATH)
);
+ if (UsbClass == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)UsbClass;
+ }
+
VIDStr = GetNextParamStr (&TextDeviceNode);
PIDStr = GetNextParamStr (&TextDeviceNode);
if (UsbClassText->ClassExist) {
@@ -2653,19 +2754,22 @@ DevPathFromTextUsbWwid (
MSG_USB_WWID_DP,
(UINT16)(sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16))
);
- UsbWwid->VendorId = (UINT16)Strtoi (VIDStr);
- UsbWwid->ProductId = (UINT16)Strtoi (PIDStr);
- UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr);
- //
- // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
- // Therefore, the '\0' will not be copied.
- //
- CopyMem (
- (UINT8 *)UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
- SerialNumberStr,
- SerialNumberStrLen * sizeof (CHAR16)
- );
+ if (UsbWwid != NULL) {
+ UsbWwid->VendorId = (UINT16)Strtoi (VIDStr);
+ UsbWwid->ProductId = (UINT16)Strtoi (PIDStr);
+ UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr);
+
+ //
+ // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr.
+ // Therefore, the '\0' will not be copied.
+ //
+ CopyMem (
+ (UINT8 *)UsbWwid + sizeof (USB_WWID_DEVICE_PATH),
+ SerialNumberStr,
+ SerialNumberStrLen * sizeof (CHAR16)
+ );
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)UsbWwid;
}
@@ -2694,7 +2798,9 @@ DevPathFromTextUnit (
(UINT16)sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH)
);
- LogicalUnit->Lun = (UINT8)Strtoi (LunStr);
+ if (LogicalUnit != NULL) {
+ LogicalUnit->Lun = (UINT8)Strtoi (LunStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)LogicalUnit;
}
@@ -2738,6 +2844,10 @@ DevPathFromTextiSCSI (
(UINT16)(sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr))
);
+ if (ISCSIDevPath == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)ISCSIDevPath;
+ }
+
AsciiStr = ISCSIDevPath->TargetName;
StrToAscii (NameStr, &AsciiStr);
@@ -2800,7 +2910,9 @@ DevPathFromTextVlan (
(UINT16)sizeof (VLAN_DEVICE_PATH)
);
- Vlan->VlanId = (UINT16)Strtoi (VlanStr);
+ if (Vlan != NULL) {
+ Vlan->VlanId = (UINT16)Strtoi (VlanStr);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Vlan;
}
@@ -2828,12 +2940,16 @@ DevPathFromTextBluetooth (
MSG_BLUETOOTH_DP,
(UINT16)sizeof (BLUETOOTH_DEVICE_PATH)
);
- StrHexToBytes (
- BluetoothStr,
- sizeof (BLUETOOTH_ADDRESS) * 2,
- BluetoothDp->BD_ADDR.Address,
- sizeof (BLUETOOTH_ADDRESS)
- );
+
+ if (BluetoothDp != NULL) {
+ StrHexToBytes (
+ BluetoothStr,
+ sizeof (BLUETOOTH_ADDRESS) * 2,
+ BluetoothDp->BD_ADDR.Address,
+ sizeof (BLUETOOTH_ADDRESS)
+ );
+ }
+
return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothDp;
}
@@ -2863,7 +2979,7 @@ DevPathFromTextWiFi (
(UINT16)sizeof (WIFI_DEVICE_PATH)
);
- if (NULL != SSIdStr) {
+ if ((NULL != SSIdStr) && (NULL != WiFiDp)) {
DataLen = StrLen (SSIdStr);
if (StrLen (SSIdStr) > 32) {
SSIdStr[32] = '\0';
@@ -2903,13 +3019,16 @@ DevPathFromTextBluetoothLE (
(UINT16)sizeof (BLUETOOTH_LE_DEVICE_PATH)
);
- BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr);
- StrHexToBytes (
- BluetoothLeAddrStr,
- sizeof (BluetoothLeDp->Address.Address) * 2,
- BluetoothLeDp->Address.Address,
- sizeof (BluetoothLeDp->Address.Address)
- );
+ if (BluetoothLeDp != NULL) {
+ BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr);
+ StrHexToBytes (
+ BluetoothLeAddrStr,
+ sizeof (BluetoothLeDp->Address.Address) * 2,
+ BluetoothLeDp->Address.Address,
+ sizeof (BluetoothLeDp->Address.Address)
+ );
+ }
+
return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothLeDp;
}
@@ -3031,7 +3150,7 @@ DevPathFromTextUri (
(UINT16)(sizeof (URI_DEVICE_PATH) + UriLength)
);
- while (UriLength-- != 0) {
+ while (Uri != NULL && UriLength-- != 0) {
Uri->Uri[UriLength] = (CHAR8)UriStr[UriLength];
}
@@ -3088,6 +3207,10 @@ DevPathFromTextHD (
(UINT16)sizeof (HARDDRIVE_DEVICE_PATH)
);
+ if (Hd == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)Hd;
+ }
+
Hd->PartitionNumber = (UINT32)Strtoi (PartitionStr);
ZeroMem (Hd->Signature, 16);
@@ -3142,9 +3265,11 @@ DevPathFromTextCDROM (
(UINT16)sizeof (CDROM_DEVICE_PATH)
);
- CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr);
- Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
- Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
+ if (CDROMDevPath != NULL) {
+ CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr);
+ Strtoi64 (StartStr, &CDROMDevPath->PartitionStart);
+ Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)CDROMDevPath;
}
@@ -3193,7 +3318,9 @@ DevPathFromTextFilePath (
(UINT16)(sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2)
);
- StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
+ if (File != NULL) {
+ StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
+ }
#else
size_t len = (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2);
efi_char *v;
@@ -3202,8 +3329,10 @@ DevPathFromTextFilePath (
MEDIA_FILEPATH_DP,
(UINT16)len
);
- v = File->PathName;
- utf8_to_ucs2(TextDeviceNode, &v, &len);
+ if (File != NULL) {
+ v = File->PathName;
+ utf8_to_ucs2(TextDeviceNode, &v, &len);
+ }
#endif
return (EFI_DEVICE_PATH_PROTOCOL *)File;
@@ -3233,7 +3362,9 @@ DevPathFromTextMedia (
(UINT16)sizeof (MEDIA_PROTOCOL_DEVICE_PATH)
);
- StrToGuid (GuidStr, &Media->Protocol);
+ if (Media != NULL) {
+ StrToGuid (GuidStr, &Media->Protocol);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Media;
}
@@ -3262,7 +3393,9 @@ DevPathFromTextFv (
(UINT16)sizeof (MEDIA_FW_VOL_DEVICE_PATH)
);
- StrToGuid (GuidStr, &Fv->FvName);
+ if (Fv != NULL) {
+ StrToGuid (GuidStr, &Fv->FvName);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Fv;
}
@@ -3291,7 +3424,9 @@ DevPathFromTextFvFile (
(UINT16)sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH)
);
- StrToGuid (GuidStr, &FvFile->FvFileName);
+ if (FvFile != NULL) {
+ StrToGuid (GuidStr, &FvFile->FvFileName);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)FvFile;
}
@@ -3322,8 +3457,10 @@ DevPathFromTextRelativeOffsetRange (
(UINT16)sizeof (MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH)
);
- Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
- Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
+ if (Offset != NULL) {
+ Strtoi64 (StartingOffsetStr, &Offset->StartingOffset);
+ Strtoi64 (EndingOffsetStr, &Offset->EndingOffset);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)Offset;
}
@@ -3360,12 +3497,14 @@ DevPathFromTextRamDisk (
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
);
- Strtoi64 (StartingAddrStr, &StartingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
- Strtoi64 (EndingAddrStr, &EndingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
- RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
- StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
+ if (RamDisk != NULL) {
+ Strtoi64 (StartingAddrStr, &StartingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
+ Strtoi64 (EndingAddrStr, &EndingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
+ RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
+ StrToGuid (TypeGuidStr, &RamDisk->TypeGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
}
@@ -3401,12 +3540,14 @@ DevPathFromTextVirtualDisk (
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
);
- Strtoi64 (StartingAddrStr, &StartingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
- Strtoi64 (EndingAddrStr, &EndingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
- RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
- CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
+ if (RamDisk != NULL) {
+ Strtoi64 (StartingAddrStr, &StartingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
+ Strtoi64 (EndingAddrStr, &EndingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
+ RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
+ CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
}
@@ -3442,12 +3583,14 @@ DevPathFromTextVirtualCd (
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
);
- Strtoi64 (StartingAddrStr, &StartingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
- Strtoi64 (EndingAddrStr, &EndingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
- RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
- CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
+ if (RamDisk != NULL) {
+ Strtoi64 (StartingAddrStr, &StartingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
+ Strtoi64 (EndingAddrStr, &EndingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
+ RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
+ CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
}
@@ -3483,12 +3626,14 @@ DevPathFromTextPersistentVirtualDisk (
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
);
- Strtoi64 (StartingAddrStr, &StartingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
- Strtoi64 (EndingAddrStr, &EndingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
- RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
- CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
+ if (RamDisk != NULL) {
+ Strtoi64 (StartingAddrStr, &StartingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
+ Strtoi64 (EndingAddrStr, &EndingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
+ RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
+ CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
}
@@ -3524,12 +3669,14 @@ DevPathFromTextPersistentVirtualCd (
(UINT16)sizeof (MEDIA_RAM_DISK_DEVICE_PATH)
);
- Strtoi64 (StartingAddrStr, &StartingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
- Strtoi64 (EndingAddrStr, &EndingAddr);
- WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
- RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
- CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
+ if (RamDisk != NULL) {
+ Strtoi64 (StartingAddrStr, &StartingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr);
+ Strtoi64 (EndingAddrStr, &EndingAddr);
+ WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr);
+ RamDisk->Instance = (UINT16)Strtoi (InstanceStr);
+ CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid);
+ }
return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk;
}
@@ -3580,6 +3727,10 @@ DevPathFromTextBBS (
(UINT16)(sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr))
);
+ if (Bbs == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)Bbs;
+ }
+
if (StrCmp (TypeStr, "Floppy") == 0) {
Bbs->DeviceType = BBS_TYPE_FLOPPY;
} else if (StrCmp (TypeStr, "HD") == 0) {
@@ -3632,6 +3783,11 @@ DevPathFromTextSata (
MSG_SATA_DP,
(UINT16)sizeof (SATA_DEVICE_PATH)
);
+
+ if (Sata == NULL) {
+ return (EFI_DEVICE_PATH_PROTOCOL *)Sata;
+ }
+
Sata->HBAPortNumber = (UINT16)Strtoi (Param1);
//
@@ -3832,29 +3988,54 @@ UefiDevicePathLibConvertTextToDevicePath (
}
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
- ASSERT (DevicePath != NULL);
+
+ if (DevicePath == NULL) {
+ ASSERT (DevicePath != NULL);
+ return NULL;
+ }
+
SetDevicePathEndNode (DevicePath);
DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath);
+ if (DevicePathStr == NULL) {
+ return NULL;
+ }
+
Str = DevicePathStr;
while ((DeviceNodeStr = GetNextDeviceNodeStr (&Str, &IsInstanceEnd)) != NULL) {
DeviceNode = UefiDevicePathLibConvertTextToDeviceNode (DeviceNodeStr);
NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
- FreePool (DevicePath);
- FreePool (DeviceNode);
+ if (DevicePath != NULL) {
+ FreePool (DevicePath);
+ }
+
+ if (DeviceNode != NULL) {
+ FreePool (DeviceNode);
+ }
+
DevicePath = NewDevicePath;
if (IsInstanceEnd) {
DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH);
- ASSERT (DeviceNode != NULL);
+ if (DeviceNode == NULL) {
+ ASSERT (DeviceNode != NULL);
+ return NULL;
+ }
+
SetDevicePathEndNode (DeviceNode);
DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode);
- FreePool (DevicePath);
- FreePool (DeviceNode);
+ if (DevicePath != NULL) {
+ FreePool (DevicePath);
+ }
+
+ if (DeviceNode != NULL) {
+ FreePool (DeviceNode);
+ }
+
DevicePath = NewDevicePath;
}
}
diff --git a/lib/libefivar/efivar-dp-xlate.c b/lib/libefivar/efivar-dp-xlate.c
index 6723cf707f50..1e816cecbb81 100644
--- a/lib/libefivar/efivar-dp-xlate.c
+++ b/lib/libefivar/efivar-dp-xlate.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
diff --git a/lib/libefivar/efivar.c b/lib/libefivar/efivar.c
index fdcffc5403d6..c91bf5ea71bb 100644
--- a/lib/libefivar/efivar.c
+++ b/lib/libefivar/efivar.c
@@ -23,12 +23,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <efivar.h>
#include <sys/efiio.h>
#include <sys/param.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -37,11 +37,11 @@
static int efi_fd = -2;
-#define Z { 0, 0, 0, 0, 0, { 0 } }
+#define Z { 0 }
const efi_guid_t efi_guid_empty = Z;
-static struct uuid_table guid_tbl [] =
+static struct guid_table guid_tbl [] =
{
{ "00000000-0000-0000-0000-000000000000", "zero", Z },
{ "093e0fae-a6c4-4f50-9f1b-d41e2b89c19a", "sha512", Z },
@@ -75,32 +75,39 @@ static struct uuid_table guid_tbl [] =
{ "e2b36190-879b-4a3d-ad8d-f2e7bba32784", "rsa2048_sha256", Z },
{ "ff3e5307-9fd0-48c9-85f1-8ad56c701e01", "sha384", Z },
{ "f46ee6f4-4785-43a3-923d-7f786c3c8479", "lenovo_startup_interrupt", Z },
- { "ffffffff-ffff-ffff-ffff-ffffffffffff", "zzignore-this-guid", Z },
};
-#undef Z
+
+int
+efi_str_to_guid(const char *s, efi_guid_t *guid)
+{
+ uint32_t status;
+
+ /* knows efi_guid_t is binary compatible with uuid_t */
+ uuid_from_string(s, (uuid_t *)guid, &status);
+
+ return (status == uuid_s_ok ? 0 : -1);
+}
static void
efi_guid_tbl_compile(void)
{
size_t i;
- uint32_t status;
- static int done = 0;
+ static bool done = false;
+ struct guid_table *ent;
if (done)
return;
for (i = 0; i < nitems(guid_tbl); i++) {
- uuid_from_string(guid_tbl[i].uuid_str, &guid_tbl[i].guid,
- &status);
- /* all f's is a bad version, so ignore that error */
- if (status != uuid_s_ok && status != uuid_s_bad_version)
- fprintf(stderr, "Can't convert %s to a uuid for %s: %d\n",
- guid_tbl[i].uuid_str, guid_tbl[i].name, (int)status);
+ ent = &guid_tbl[i];
+ if (efi_str_to_guid(ent->uuid_str, &ent->guid) != 0)
+ fprintf(stderr, "Can't convert %s to a guid for %s\n",
+ ent->uuid_str, ent->name);
}
- done = 1;
+ done = true;
}
int
-efi_known_guid(struct uuid_table **tbl)
+efi_known_guid(struct guid_table **tbl)
{
*tbl = guid_tbl;
@@ -121,7 +128,7 @@ efi_open_dev(void)
}
static void
-efi_var_reset(struct efi_var_ioc *var)
+efi_var_reset(struct efi_var_ioctl *var)
{
var->name = NULL;
var->namesize = 0;
@@ -162,7 +169,7 @@ int
efi_get_variable(efi_guid_t guid, const char *name,
uint8_t **data, size_t *data_size, uint32_t *attributes)
{
- struct efi_var_ioc var;
+ struct efi_var_ioctl var;
int rv;
static uint8_t buf[1024*32];
@@ -212,7 +219,7 @@ efi_get_variable_size(efi_guid_t guid, const char *name,
int
efi_get_next_variable_name(efi_guid_t **guid, char **name)
{
- struct efi_var_ioc var;
+ struct efi_var_ioctl var;
int rv;
static efi_char *buf;
static size_t buflen = 256 * sizeof(efi_char);
@@ -287,28 +294,23 @@ done:
int
efi_guid_cmp(const efi_guid_t *guid1, const efi_guid_t *guid2)
{
- uint32_t status;
-
- return uuid_compare(guid1, guid2, &status);
+ return (memcmp(guid1, guid2, sizeof(*guid1)));
}
int
efi_guid_is_zero(const efi_guid_t *guid)
{
- uint32_t status;
-
- return uuid_is_nil(guid, &status);
+ return (memcmp(guid, &efi_guid_empty, sizeof(*guid)) == 0);
}
int
efi_guid_to_name(efi_guid_t *guid, char **name)
{
size_t i;
- uint32_t status;
efi_guid_tbl_compile();
for (i = 0; i < nitems(guid_tbl); i++) {
- if (uuid_equal(guid, &guid_tbl[i].guid, &status)) {
+ if (memcmp(guid, &guid_tbl[i].guid, sizeof(*guid)) == 0) {
*name = strdup(guid_tbl[i].name);
return (0);
}
@@ -332,8 +334,8 @@ efi_guid_to_str(const efi_guid_t *guid, char **sp)
{
uint32_t status;
- /* knows efi_guid_t is a typedef of uuid_t */
- uuid_to_string(guid, sp, &status);
+ /* knows efi_guid_t is binary compatible with uuid_t */
+ uuid_to_string((const uuid_t *)guid, sp, &status);
return (status == uuid_s_ok ? 0 : -1);
}
@@ -357,7 +359,7 @@ int
efi_set_variable(efi_guid_t guid, const char *name,
uint8_t *data, size_t data_size, uint32_t attributes)
{
- struct efi_var_ioc var;
+ struct efi_var_ioctl var;
int rv;
if (efi_open_dev() == -1)
@@ -379,17 +381,6 @@ errout:
}
int
-efi_str_to_guid(const char *s, efi_guid_t *guid)
-{
- uint32_t status;
-
- /* knows efi_guid_t is a typedef of uuid_t */
- uuid_from_string(s, guid, &status);
-
- return (status == uuid_s_ok ? 0 : -1);
-}
-
-int
efi_variables_supported(void)
{
diff --git a/lib/libefivar/efivar.h b/lib/libefivar/efivar.h
index 7551205fda38..e159f4cccd3d 100644
--- a/lib/libefivar/efivar.h
+++ b/lib/libefivar/efivar.h
@@ -46,19 +46,14 @@
#endif
-#ifndef _EFIVAR_EFI_GUID_T_DEF
-#define _EFIVAR_EFI_GUID_T_DEF
-typedef uuid_t efi_guid_t;
-#endif
-
#if BYTE_ORDER == LITTLE_ENDIAN
#define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \
- ((efi_guid_t) {(a), (b), (c), (d) >> 8, (d) & 0xff, \
- { (e0), (e1), (e2), (e3), (e4), (e5) }})
+ ((efi_guid_t) {(a), (b), (c), { (d) >> 8, (d) & 0xff, \
+ (e0), (e1), (e2), (e3), (e4), (e5) }})
#else
#define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \
- ((efi_guid_t) {(a), (b), (c), (d) & 0xff, (d) >> 8, \
- { (e0), (e1), (e2), (e3), (e4), (e5) }})
+ ((efi_guid_t) {(a), (b), (c), { (d) & 0xff, (d) >> 8, \
+ (e0), (e1), (e2), (e3), (e4), (e5) }})
#endif
#define EFI_GLOBAL_GUID EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa0d, \
@@ -85,14 +80,14 @@ int efi_str_to_guid(const char *s, efi_guid_t *guid);
int efi_variables_supported(void);
/* FreeBSD extensions */
-struct uuid_table
+struct guid_table
{
const char *uuid_str;
const char *name;
efi_guid_t guid;
};
-int efi_known_guid(struct uuid_table **);
+int efi_known_guid(struct guid_table **);
extern const efi_guid_t efi_guid_empty;
diff --git a/lib/libefivar/uefi-dplib.h b/lib/libefivar/uefi-dplib.h
index e801b5f26a81..6f76a9763a34 100644
--- a/lib/libefivar/uefi-dplib.h
+++ b/lib/libefivar/uefi-dplib.h
@@ -547,7 +547,7 @@ AllocateCopyPool(size_t l, const void *p)
}
static inline BOOLEAN
-CompareGuid (const GUID *g1, const GUID *g2)
+CompareGuid (const EFI_GUID *g1, const EFI_GUID *g2)
{
uint32_t ignored_status;
@@ -578,7 +578,7 @@ StrHexToBytes(const char *str, size_t len, uint8_t *buf, size_t buflen)
}
static inline void
-StrToGuid(const char *str, GUID *guid)
+StrToGuid(const char *str, EFI_GUID *guid)
{
uint32_t status;
@@ -599,7 +599,7 @@ WriteUnaligned64(void *ptr, uint64_t val)
* Not to mention it's name.... Also, the error GUID is horrific.
*/
static inline const char *
-guid_str(const GUID *g)
+guid_str(const EFI_GUID *g)
{
static char buf[36 + 1];
char *str = NULL;
@@ -614,7 +614,7 @@ guid_str(const GUID *g)
free(str);
return buf;
}
-#define G(x) guid_str((const GUID *)(const void *)x)
+#define G(x) guid_str((const EFI_GUID *)(const void *)x)
#endif
#undef GLOBAL_REMOVE_IF_UNREFERENCED
diff --git a/lib/libefivar/uefi-dputil.c b/lib/libefivar/uefi-dputil.c
index 7969054e2ce2..6e8f3aeca2ce 100644
--- a/lib/libefivar/uefi-dputil.c
+++ b/lib/libefivar/uefi-dputil.c
@@ -28,7 +28,6 @@
* this file is taken from EDK2 and rototilled.
*/
-#include <sys/cdefs.h>
#include <efivar.h>
#include <limits.h>
#include <stdio.h>
diff --git a/lib/libelf/Makefile b/lib/libelf/Makefile
index 9704405a8a36..c15ce2798a91 100644
--- a/lib/libelf/Makefile
+++ b/lib/libelf/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <bsd.own.mk>
diff --git a/lib/libevent1/Makefile b/lib/libevent1/Makefile
index 6ca16cc03c16..9e48707bc444 100644
--- a/lib/libevent1/Makefile
+++ b/lib/libevent1/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
.PATH: ${SRCTOP}/contrib/pf/libevent
diff --git a/lib/libexecinfo/Makefile b/lib/libexecinfo/Makefile
index 3b44ca15bc36..3010a5be5894 100644
--- a/lib/libexecinfo/Makefile
+++ b/lib/libexecinfo/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
.include <src.opts.mk>
diff --git a/lib/libexecinfo/tests/Makefile b/lib/libexecinfo/tests/Makefile
index 5dbf25cf4e17..281074e34a67 100644
--- a/lib/libexecinfo/tests/Makefile
+++ b/lib/libexecinfo/tests/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libexecinfo
diff --git a/lib/libexecinfo/tests/sigtramp_test.c b/lib/libexecinfo/tests/sigtramp_test.c
index b8eecfddf43d..a4943d8d7f4f 100644
--- a/lib/libexecinfo/tests/sigtramp_test.c
+++ b/lib/libexecinfo/tests/sigtramp_test.c
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <sys/cdefs.h>
+
#include <sys/param.h>
#include <sys/wait.h>
diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile
index 08c8604e74c5..92ba6b671488 100644
--- a/lib/libexpat/Makefile
+++ b/lib/libexpat/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
EXPAT= ${SRCTOP}/contrib/expat
diff --git a/lib/libexpat/expat_config.h b/lib/libexpat/expat_config.h
index 369cebcbe451..748f75ee157d 100644
--- a/lib/libexpat/expat_config.h
+++ b/lib/libexpat/expat_config.h
@@ -22,6 +22,9 @@
/* Define to 1 if you have the `arc4random_buf' function. */
#define HAVE_ARC4RANDOM_BUF 1
+/* define if the compiler supports basic C++11 syntax */
+#define HAVE_CXX11 1
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
@@ -80,13 +83,13 @@
#define PACKAGE "expat"
/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "expat-bugs@libexpat.org"
+#define PACKAGE_BUGREPORT "https://github.com/libexpat/libexpat/issues"
/* Define to the full name of this package. */
#define PACKAGE_NAME "expat"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "expat 2.5.0"
+#define PACKAGE_STRING "expat 2.7.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "expat"
@@ -95,7 +98,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "2.5.0"
+#define PACKAGE_VERSION "2.7.1"
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
@@ -103,7 +106,7 @@
#define STDC_HEADERS 1
/* Version number of package */
-#define VERSION "2.5.0"
+#define VERSION "2.7.1"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
@@ -122,7 +125,7 @@
/* #undef XML_ATTR_INFO */
/* Define to specify how much context to retain around the current parse
- point. */
+ point, 0 to disable. */
#define XML_CONTEXT_BYTES 1024
/* Define to include code reading entropy from `/dev/urandom'. */
@@ -131,6 +134,9 @@
/* Define to make parameter entity parsing functionality available. */
#define XML_DTD 1
+/* Define as 1/0 to enable/disable support for general entities. */
+#define XML_GE 1
+
/* Define to make XML Namespaces functionality available. */
#define XML_NS 1
@@ -140,7 +146,4 @@
/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-/* #undef size_t */
-
#endif // ndef EXPAT_CONFIG_H
diff --git a/lib/libexpat/libbsdxml.3 b/lib/libexpat/libbsdxml.3
index e4e55a64dd47..c91184840b70 100644
--- a/lib/libexpat/libbsdxml.3
+++ b/lib/libexpat/libbsdxml.3
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"/
-.Dd November 18, 2022
+.Dd April 7, 2025
.Dt LIBBSDXML 3
.Os
.Sh NAME
@@ -34,7 +34,7 @@
.Sh DESCRIPTION
The
.Nm
-library is a verbatim copy of the eXpat XML library version 2.5.0.
+library is a verbatim copy of the eXpat XML library version 2.7.1.
.Pp
The
.Nm
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
new file mode 100644
index 000000000000..c4ada46c3b2e
--- /dev/null
+++ b/lib/libfdt/Makefile
@@ -0,0 +1,29 @@
+LIB= fdt
+
+INTERNALLIB=
+
+LIBFDTSRCDIR= ${SRCTOP}/sys/contrib/libfdt
+.PATH: ${LIBFDTSRCDIR}
+
+SRCS= \
+ fdt.c \
+ fdt_addresses.c \
+ fdt_empty_tree.c \
+ fdt_overlay.c \
+ fdt_ro.c \
+ fdt_rw.c \
+ fdt_strerror.c \
+ fdt_sw.c \
+ fdt_wip.c
+
+INCS= \
+ fdt.h \
+ libfdt.h \
+ ibfdt_env.h
+
+CFLAGS+= -I${LIBFDTSRCDIR}
+WARNS?= 2
+
+MAN=
+
+.include <bsd.lib.mk>
diff --git a/lib/libfetch/Makefile b/lib/libfetch/Makefile
index 44234db1b19a..37767cb5ec89 100644
--- a/lib/libfetch/Makefile
+++ b/lib/libfetch/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= fetch
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index fd2091791620..786d5647d993 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -29,7 +29,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -278,13 +277,16 @@ conn_t *
fetch_reopen(int sd)
{
conn_t *conn;
+ int flags;
int opt = 1;
/* allocate and fill connection structure */
if ((conn = calloc(1, sizeof(*conn))) == NULL)
return (NULL);
- fcntl(sd, F_SETFD, FD_CLOEXEC);
- setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof opt);
+ flags = fcntl(sd, F_GETFD);
+ if (flags != -1 && (flags & FD_CLOEXEC) == 0)
+ (void)fcntl(sd, F_SETFD, flags | FD_CLOEXEC);
+ (void)setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
conn->sd = sd;
++conn->ref;
return (conn);
@@ -1055,8 +1057,6 @@ fetch_ssl_setup_transport_layer(SSL_CTX *ctx, int verbose)
/*
* Configure peer verification based on environment.
*/
-#define LOCAL_CERT_FILE _PATH_LOCALBASE "/etc/ssl/cert.pem"
-#define BASE_CERT_FILE "/etc/ssl/cert.pem"
static int
fetch_ssl_setup_peer_verification(SSL_CTX *ctx, int verbose)
{
@@ -1066,12 +1066,6 @@ fetch_ssl_setup_peer_verification(SSL_CTX *ctx, int verbose)
if (getenv("SSL_NO_VERIFY_PEER") == NULL) {
ca_cert_file = getenv("SSL_CA_CERT_FILE");
- if (ca_cert_file == NULL &&
- access(LOCAL_CERT_FILE, R_OK) == 0)
- ca_cert_file = LOCAL_CERT_FILE;
- if (ca_cert_file == NULL &&
- access(BASE_CERT_FILE, R_OK) == 0)
- ca_cert_file = BASE_CERT_FILE;
ca_cert_path = getenv("SSL_CA_CERT_PATH");
if (verbose) {
fetch_info("Peer verification enabled");
@@ -1365,7 +1359,7 @@ fetch_read(conn_t *conn, char *buf, size_t len)
}
timersub(&timeout, &now, &delta);
deltams = delta.tv_sec * 1000 +
- delta.tv_usec / 1000;;
+ delta.tv_usec / 1000;
}
errno = 0;
pfd.revents = 0;
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 9082f338f7c1..5f7489799cf6 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 24, 2020
+.Dd October 7, 2023
.Dt FETCH 3
.Os
.Sh NAME
@@ -409,19 +409,6 @@ library,
is currently unimplemented.
.Sh HTTPS SCHEME
Based on HTTP SCHEME.
-By default the peer is verified using the CA bundle located in
-.Pa /usr/local/etc/ssl/cert.pem .
-If this file does not exist,
-.Pa /etc/ssl/cert.pem
-is used instead.
-If neither file exists, and
-.Ev SSL_CA_CERT_PATH
-has not been set,
-OpenSSL's default CA cert and path settings apply.
-The certificate bundle can contain multiple CA certificates.
-A common source of a current CA bundle is
-.Pa \%security/ca_root_nss .
-.Pp
The CA bundle used for peer verification can be changed by setting the
environment variables
.Ev SSL_CA_CERT_FILE
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index 135ee8dad151..97fc04bb09a6 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <netinet/in.h>
@@ -400,7 +399,7 @@ fetchParseURL(const char *URL)
/* hostname */
if (*p == '[') {
- q = p + 1 + strspn(p + 1, ":0123456789ABCDEFabcdef");
+ q = p + 1 + strspn(p + 1, ":0123456789ABCDEFabcdef.");
if (*q++ != ']')
goto ouch;
} else {
@@ -427,7 +426,7 @@ fetchParseURL(const char *URL)
goto ouch;
}
}
- if (n < 1 || n > IPPORT_MAX)
+ if (p != q && (n < 1 || n > IPPORT_MAX))
goto ouch;
u->port = n;
p = q;
@@ -448,7 +447,10 @@ nohost:
goto ouch;
}
u->doc = doc;
- while (*p != '\0') {
+ /* fragments are reserved for client-side processing, see
+ * https://www.rfc-editor.org/rfc/rfc9110.html#section-7.1
+ */
+ while (*p != '\0' && *p != '#') {
if (!isspace((unsigned char)*p)) {
*doc++ = *p++;
} else {
diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c
index 3cb8893f9d46..0d46ce38b5a2 100644
--- a/lib/libfetch/file.c
+++ b/lib/libfetch/file.c
@@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
diff --git a/lib/libfido2/Makefile b/lib/libfido2/Makefile
index 86ac1153f384..10c008967e3d 100644
--- a/lib/libfido2/Makefile
+++ b/lib/libfido2/Makefile
@@ -21,6 +21,7 @@ SRCS+= ecdh.c
SRCS+= eddsa.c
SRCS+= err.c
SRCS+= es256.c
+SRCS+= es384.c
SRCS+= hid_freebsd.c
SRCS+= hid_unix.c
SRCS+= hid.c
@@ -35,9 +36,11 @@ SRCS+= reset.c
SRCS+= rs1.c
SRCS+= rs256.c
SRCS+= time.c
+SRCS+= touch.c
SRCS+= tpm.c
SRCS+= types.c
SRCS+= u2f.c
+SRCS+= util.c
SRCS+= openbsd-compat/freezero.c
SRCS+= openbsd-compat/recallocarray.c
@@ -45,6 +48,7 @@ SRCS+= openbsd-compat/recallocarray.c
CFLAGS+= -I ${DIST}/src -I${SRCTOP}/contrib/libcbor/src -I${.CURDIR}/../libcbor
CFLAGS+= -D_FIDO_INTERNAL
CFLAGS+= -DHAVE_ARC4RANDOM_BUF
+CFLAGS+= -DHAVE_ASPRINTF
CFLAGS+= -DHAVE_CLOCK_GETTIME
CFLAGS+= -DHAVE_DEV_URANDOM
CFLAGS+= -DHAVE_ERR_H
@@ -67,7 +71,7 @@ CFLAGS+= -DHAVE_UNISTD_H
CFLAGS+= -DOPENSSL_API_COMPAT=0x10100000L
CFLAGS+= -DTLS=__thread
CFLAGS+= -D_FIDO_MAJOR=1
-CFLAGS+= -D_FIDO_MINOR=10
+CFLAGS+= -D_FIDO_MINOR=14
CFLAGS+= -D_FIDO_PATCH=0
LIBADD= crypto z
diff --git a/lib/libfido2/Makefile.depend b/lib/libfido2/Makefile.depend
new file mode 100644
index 000000000000..3c28a8a51e2d
--- /dev/null
+++ b/lib/libfido2/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libz \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libfigpar/Makefile b/lib/libfigpar/Makefile
index 350abdf7dfd3..66a1d61c7016 100644
--- a/lib/libfigpar/Makefile
+++ b/lib/libfigpar/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= dpv
LIB= figpar
SHLIB_MAJOR= 0
diff --git a/lib/libfigpar/figpar.c b/lib/libfigpar/figpar.c
index 642291ca7c6b..fbc6aaaba606 100644
--- a/lib/libfigpar/figpar.c
+++ b/lib/libfigpar/figpar.c
@@ -24,11 +24,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <stdlib.h>
@@ -162,11 +160,11 @@ parse_config(struct figpar_config options[], const char *path,
}
/* Get the current offset */
- curpos = lseek(fd, 0, SEEK_CUR) - 1;
- if (curpos == -1) {
+ if ((curpos = lseek(fd, 0, SEEK_CUR)) == -1) {
close(fd);
return (-1);
}
+ curpos--;
/* Find the length of the directive */
for (n = 0; r != 0; n++) {
@@ -188,8 +186,7 @@ parse_config(struct figpar_config options[], const char *path,
}
/* Go back to the beginning of the directive */
- error = (int)lseek(fd, curpos, SEEK_SET);
- if (error == (curpos - 1)) {
+ if (lseek(fd, curpos, SEEK_SET) == -1) {
close(fd);
return (-1);
}
@@ -247,11 +244,11 @@ parse_config(struct figpar_config options[], const char *path,
}
/* Get the current offset */
- curpos = lseek(fd, 0, SEEK_CUR) - 1;
- if (curpos == -1) {
+ if ((curpos = lseek(fd, 0, SEEK_CUR)) == -1) {
close(fd);
return (-1);
}
+ curpos--;
/* Find the end of the value */
quote = 0;
@@ -269,19 +266,18 @@ parse_config(struct figpar_config options[], const char *path,
*/
/* Get the current offset */
- charpos = lseek(fd, 0, SEEK_CUR) - 1;
- if (charpos == -1) {
+ if ((charpos = lseek(fd, 0, SEEK_CUR)) == -1) {
close(fd);
return (-1);
}
+ charpos--;
/*
* Go back so we can read the character before the key
* to check if the character is escaped (which means we
* should continue).
*/
- error = (int)lseek(fd, -2, SEEK_CUR);
- if (error == -3) {
+ if (lseek(fd, -2, SEEK_CUR) == -1) {
close(fd);
return (-1);
}
@@ -293,8 +289,7 @@ parse_config(struct figpar_config options[], const char *path,
*/
for (n = 1; *p == '\\'; n++) {
/* Move back another offset to read */
- error = (int)lseek(fd, -2, SEEK_CUR);
- if (error == -3) {
+ if (lseek(fd, -2, SEEK_CUR) == -1) {
close(fd);
return (-1);
}
@@ -302,8 +297,7 @@ parse_config(struct figpar_config options[], const char *path,
}
/* Move offset back to the key and read it */
- error = (int)lseek(fd, charpos, SEEK_SET);
- if (error == (charpos - 1)) {
+ if (lseek(fd, charpos, SEEK_SET) == -1) {
close(fd);
return (-1);
}
@@ -354,8 +348,7 @@ parse_config(struct figpar_config options[], const char *path,
}
/* Get the current offset */
- charpos = lseek(fd, 0, SEEK_CUR) - 1;
- if (charpos == -1) {
+ if ((charpos = lseek(fd, 0, SEEK_CUR)) == -1) {
close(fd);
return (-1);
}
@@ -366,8 +359,7 @@ parse_config(struct figpar_config options[], const char *path,
n--;
/* Move offset back to the beginning of the value */
- error = (int)lseek(fd, curpos, SEEK_SET);
- if (error == (curpos - 1)) {
+ if (lseek(fd, curpos, SEEK_SET) == -1) {
close(fd);
return (-1);
}
diff --git a/lib/libfigpar/string_m.c b/lib/libfigpar/string_m.c
index ce7948466543..df3def788971 100644
--- a/lib/libfigpar/string_m.c
+++ b/lib/libfigpar/string_m.c
@@ -24,12 +24,9 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
#include <ctype.h>
#include <errno.h>
-#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/libgcc_eh/Makefile b/lib/libgcc_eh/Makefile
index ceac35b518d9..ace27ce69b8f 100644
--- a/lib/libgcc_eh/Makefile
+++ b/lib/libgcc_eh/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= clibs
diff --git a/lib/libgcc_eh/Makefile.inc b/lib/libgcc_eh/Makefile.inc
index 9e194cc875f1..529ef7170485 100644
--- a/lib/libgcc_eh/Makefile.inc
+++ b/lib/libgcc_eh/Makefile.inc
@@ -1,4 +1,3 @@
-
COMPILERRTDIR= ${SRCTOP}/contrib/llvm-project/compiler-rt
UNWINDINCDIR= ${SRCTOP}/contrib/llvm-project/libunwind/include
UNWINDSRCDIR= ${SRCTOP}/contrib/llvm-project/libunwind/src
@@ -17,6 +16,9 @@ SRCS_EXC+= UnwindRegistersSave.S
SRCS_EXC+= libunwind.cpp
SRCS+= ${SRCS_EXC}
+.if ${MACHINE} == "amd64" || ${MACHINE} == "i386" || ${MACHINE} == "powerpc"
+CFLAGS.UnwindLevel1-gcc-ext.c+= -D_LIBUNWIND_SUPPORT_FRAME_APIS
+.endif
.for file in ${SRCS_EXC:M*.c}
CFLAGS.${file}+= -fno-exceptions -funwind-tables
.if ${MK_ASAN} != "no"
@@ -36,7 +38,6 @@ CFLAGS+= -I${UNWINDINCDIR}
CFLAGS+= -D_LIBUNWIND_IS_NATIVE_ONLY
CFLAGS+= -D_LIBUNWIND_USE_FRAME_HEADER_CACHE
CXXFLAGS+= -fno-rtti
-CXXSTD?= c++11
STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC
# Probably need to just move this earlier or use CXXFLAGS
.if ${MK_DIRDEPS_BUILD} == "yes"
diff --git a/lib/libgcc_s/Makefile b/lib/libgcc_s/Makefile
index fdf5a67d8045..992fc930ee9f 100644
--- a/lib/libgcc_s/Makefile
+++ b/lib/libgcc_s/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= clibs
SHLIB_NAME= libgcc_s.so.1
SHLIBDIR?= /lib
diff --git a/lib/libgcc_s/Symbol.map b/lib/libgcc_s/Symbol.map
index 72b083c698ba..e8f7e824adaf 100644
--- a/lib/libgcc_s/Symbol.map
+++ b/lib/libgcc_s/Symbol.map
@@ -1,74 +1,72 @@
/*
*/
+#if defined(__LP64__) || defined(__SIZEOF_INT128__)
+#define CRT_HAS_128BIT
+#endif
+
GCC_3.0 {
__absvdi2;
__absvsi2;
__addvdi3;
__addvsi3;
__ashldi3;
- __ashlti3;
__ashrdi3;
- __ashrti3;
__clear_cache;
__cmpdi2;
- __cmpti2;
+#ifndef __arm__
__deregister_frame;
+#if !defined(__aarch64__) && !defined(__riscv)
__deregister_frame_info;
__deregister_frame_info_bases;
+#endif
+#endif
__divdi3;
- __divti3;
__ffsdi2;
- __ffsti2;
__fixdfdi;
- __fixdfti;
__fixsfdi;
- __fixsfti;
__fixunsdfdi;
+#ifndef __arm__
__fixunsdfsi;
- __fixunsdfti;
+#endif
__fixunssfdi;
+#ifndef __arm__
__fixunssfsi;
- __fixunssfti;
+#endif
+#if defined(__amd64__) || defined(__i386__)
__fixunsxfdi;
__fixunsxfsi;
- __fixunsxfti;
__fixxfdi;
- __fixxfti;
+#endif
__floatdidf;
__floatdisf;
+#if defined(__amd64__) || defined(__i386__)
__floatdixf;
- __floattidf;
- __floattisf;
- __floattixf;
+#endif
__lshrdi3;
- __lshrti3;
__moddi3;
- __modti3;
__muldi3;
- __multi3;
__mulvdi3;
__mulvsi3;
__negdi2;
- __negti2;
__negvdi2;
__negvsi2;
+#ifndef __arm__
__register_frame;
+#if !defined(__aarch64__) && !defined(__riscv)
__register_frame_info;
__register_frame_info_bases;
__register_frame_info_table;
__register_frame_info_table_bases;
__register_frame_table;
+#endif
+#endif
__subvdi3;
__subvsi3;
__ucmpdi2;
- __ucmpti2;
__udivdi3;
__udivmoddi4;
- __udivmodti4;
- __udivti3;
__umoddi3;
- __umodti3;
_Unwind_DeleteException;
_Unwind_Find_FDE;
_Unwind_ForcedUnwind;
@@ -82,6 +80,33 @@ GCC_3.0 {
_Unwind_Resume;
_Unwind_SetGR;
_Unwind_SetIP;
+
+#ifdef CRT_HAS_128BIT
+ __ashlti3;
+ __ashrti3;
+ __cmpti2;
+ __divti3;
+ __ffsti2;
+ __fixdfti;
+ __fixsfti;
+ __fixunsdfti;
+ __fixunssfti;
+ __floattidf;
+ __floattisf;
+ __lshrti3;
+ __modti3;
+ __multi3;
+ __negti2;
+ __ucmpti2;
+ __udivmodti4;
+ __udivti3;
+ __umodti3;
+#ifdef __amd64__
+ __fixunsxfti;
+ __fixxfti;
+ __floattixf;
+#endif
+#endif
};
GCC_3.3 {
@@ -97,16 +122,19 @@ GCC_3.3.1 {
GCC_3.4 {
__clzdi2;
__clzsi2;
- __clzti2;
__ctzdi2;
__ctzsi2;
- __ctzti2;
__paritydi2;
__paritysi2;
- __parityti2;
__popcountdi2;
__popcountsi2;
+
+#ifdef CRT_HAS_128BIT
+ __clzti2;
+ __ctzti2;
+ __parityti2;
__popcountti2;
+#endif
};
GCC_3.4.2 {
@@ -114,33 +142,48 @@ GCC_3.4.2 {
};
GCC_3.4.4 {
+#ifdef CRT_HAS_128BIT
__absvti2;
__addvti3;
__mulvti3;
__negvti2;
__subvti3;
+#endif
};
GCC_4.0.0 {
__divdc3;
__divsc3;
+#if defined(__amd64__) || defined(__i386__)
__divxc3;
+#endif
__muldc3;
__mulsc3;
+#if defined(__amd64__) || defined(__i386__)
__mulxc3;
+#endif
__powidf2;
__powisf2;
+#if defined(__amd64__) || defined(__i386__)
__powixf2;
+#endif
};
GCC_4.2.0 {
__floatundidf;
__floatundisf;
+#if defined(__amd64__) || defined(__i386__)
__floatundixf;
+#endif
+ _Unwind_GetIPInfo;
+
+#ifdef CRT_HAS_128BIT
__floatuntidf;
__floatuntisf;
+#ifdef __amd64__
__floatuntixf;
- _Unwind_GetIPInfo;
+#endif
+#endif
};
GCC_4.3.0 {
@@ -149,6 +192,7 @@ GCC_4.3.0 {
};
GCC_4.6.0 {
+#if defined(__aarch64__) || defined(__riscv)
__addtf3;
__cmptf2;
__divtf3;
@@ -177,4 +221,15 @@ GCC_4.6.0 {
__trunctfdf2;
__trunctfsf2;
__unordtf2;
+#endif
+#if defined(__amd64__)
+ __extendxftf2;
+ __trunctfxf2;
+#endif
+};
+
+GCC_7.0.0 {
+#ifdef __i386__
+ __divmoddi4;
+#endif
};
diff --git a/lib/libgcc_s/Versions.def b/lib/libgcc_s/Versions.def
index d28e9042f744..526387e055df 100644
--- a/lib/libgcc_s/Versions.def
+++ b/lib/libgcc_s/Versions.def
@@ -31,3 +31,6 @@ GCC_4.3.0 {
GCC_4.6.0 {
} GCC_4.3.0;
+
+GCC_7.0.0 {
+} GCC_4.6.0;
diff --git a/lib/libgcc_s/arm/Symbol.map b/lib/libgcc_s/arm/Symbol.map
index 92b54761d810..ea0189eabaa0 100644
--- a/lib/libgcc_s/arm/Symbol.map
+++ b/lib/libgcc_s/arm/Symbol.map
@@ -2,6 +2,74 @@
*/
GCC_3.5 {
+ __aeabi_cdcmple;
+ __aeabi_cdrcmple;
+ __aeabi_cfcmpeq;
+ __aeabi_cfcmple;
+ __aeabi_cfrcmple;
+ __aeabi_d2f;
+ __aeabi_d2h;
+/* __aeabi_d2h_alt; */
+ __aeabi_d2iz;
+ __aeabi_d2lz;
+ __aeabi_d2uiz;
+ __aeabi_d2ulz;
+ __aeabi_dadd;
+ __aeabi_dcmpeq;
+ __aeabi_dcmpge;
+ __aeabi_dcmpgt;
+ __aeabi_dcmple;
+ __aeabi_dcmplt;
+ __aeabi_dcmpun;
+ __aeabi_ddiv;
+ __aeabi_dmul;
+ __aeabi_dneg;
+ __aeabi_drsub;
+ __aeabi_dsub;
+ __aeabi_f2d;
+ __aeabi_f2h;
+/* __aeabi_f2h_alt; */
+ __aeabi_f2iz;
+ __aeabi_f2lz;
+ __aeabi_f2uiz;
+ __aeabi_f2ulz;
+ __aeabi_fadd;
+ __aeabi_fcmpeq;
+ __aeabi_fcmpge;
+ __aeabi_fcmpgt;
+ __aeabi_fcmple;
+ __aeabi_fcmplt;
+ __aeabi_fcmpun;
+ __aeabi_fdiv;
+ __aeabi_fmul;
+ __aeabi_fneg;
+ __aeabi_frsub;
+ __aeabi_fsub;
+ __aeabi_h2f;
+/* __aeabi_h2f_alt; */
+ __aeabi_i2d;
+ __aeabi_i2f;
+ __aeabi_idiv;
+ __aeabi_idiv0;
+ __aeabi_idivmod;
+ __aeabi_l2d;
+ __aeabi_l2f;
+ __aeabi_lasr;
+ __aeabi_lcmp;
+ __aeabi_ldiv0;
+ __aeabi_ldivmod;
+ __aeabi_llsl;
+ __aeabi_llsr;
+ __aeabi_lmul;
+ __aeabi_ui2d;
+ __aeabi_ui2f;
+ __aeabi_uidiv;
+ __aeabi_uidivmod;
+ __aeabi_ul2d;
+ __aeabi_ul2f;
+ __aeabi_ulcmp;
+ __aeabi_uldivmod;
+
_Unwind_Complete;
_Unwind_VRS_Get;
_Unwind_VRS_Set;
diff --git a/lib/libgeom/Makefile b/lib/libgeom/Makefile
index e75261fffa81..ac8a056d25b5 100644
--- a/lib/libgeom/Makefile
+++ b/lib/libgeom/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
LIB= geom
diff --git a/lib/libgeom/geom_stats.c b/lib/libgeom/geom_stats.c
index 7ae5c947b7b1..510636eb9a8b 100644
--- a/lib/libgeom/geom_stats.c
+++ b/lib/libgeom/geom_stats.c
@@ -54,9 +54,12 @@ geom_stats_close(void)
{
if (statsfd == -1)
return;
- munmap(statp, npages * pagesize);
- statp = NULL;
- close (statsfd);
+ if (statp != NULL) {
+ if (munmap(statp, npages * pagesize) != 0)
+ err(1, "munmap");
+ statp = NULL;
+ }
+ close(statsfd);
statsfd = -1;
}
@@ -73,22 +76,18 @@ geom_stats_resync(void)
if (error)
err(1, "DIOCGMEDIASIZE(" _PATH_DEV DEVSTAT_DEVICE_NAME ")");
- munmap(statp, npages * pagesize);
- p = mmap(statp, mediasize, PROT_READ, MAP_SHARED, statsfd, 0);
+ if (statp != NULL && munmap(statp, npages * pagesize) != 0)
+ err(1, "munmap");
+ p = mmap(NULL, mediasize, PROT_READ, MAP_SHARED, statsfd, 0);
if (p == MAP_FAILED)
- err(1, "mmap(/dev/devstat):");
- else {
- statp = p;
- npages = mediasize / pagesize;
- }
+ err(1, "mmap(/dev/devstat)");
+ statp = p;
+ npages = mediasize / pagesize;
}
int
geom_stats_open(void)
{
- int error;
- void *p;
-
if (statsfd != -1)
return (EBUSY);
statsfd = open(_PATH_DEV DEVSTAT_DEVICE_NAME, O_RDONLY);
@@ -96,15 +95,6 @@ geom_stats_open(void)
return (errno);
pagesize = getpagesize();
spp = pagesize / sizeof(struct devstat);
- p = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, statsfd, 0);
- if (p == MAP_FAILED) {
- error = errno;
- close(statsfd);
- statsfd = -1;
- errno = error;
- return (error);
- }
- statp = p;
npages = 1;
geom_stats_resync();
return (0);
diff --git a/lib/libgeom/geom_util.c b/lib/libgeom/geom_util.c
index 48b54bcef9ed..f76afc2a1daf 100644
--- a/lib/libgeom/geom_util.c
+++ b/lib/libgeom/geom_util.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/disk.h>
#include <sys/stat.h>
diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c
index 49cbb0385770..2d2c43e29e77 100644
--- a/lib/libgeom/geom_xml2tree.c
+++ b/lib/libgeom/geom_xml2tree.c
@@ -407,7 +407,7 @@ geom_xml2tree(struct gmesh *gmp, char *p)
free(mt);
return (error);
}
- gmp->lg_ident = calloc(sizeof *gmp->lg_ident, mt->nident + 1);
+ gmp->lg_ident = calloc(mt->nident + 1, sizeof(*gmp->lg_ident));
free(mt);
if (gmp->lg_ident == NULL)
return (ENOMEM);
diff --git a/lib/libgpio/Makefile b/lib/libgpio/Makefile
index f19ec87572de..42f822e97ba0 100644
--- a/lib/libgpio/Makefile
+++ b/lib/libgpio/Makefile
@@ -1,4 +1,3 @@
-
LIB= gpio
SHLIB_MAJOR= 0
diff --git a/lib/libgpio/libgpio.h b/lib/libgpio/libgpio.h
index b493d63dc9e2..35651ecd8cca 100644
--- a/lib/libgpio/libgpio.h
+++ b/lib/libgpio/libgpio.h
@@ -81,8 +81,8 @@ int gpio_pin_set_flags(gpio_handle_t, gpio_config_t *);
/*
* GPIO pin values.
*/
-int gpio_pin_get(gpio_handle_t, gpio_pin_t);
-int gpio_pin_set(gpio_handle_t, gpio_pin_t, int);
+gpio_value_t gpio_pin_get(gpio_handle_t, gpio_pin_t);
+int gpio_pin_set(gpio_handle_t, gpio_pin_t, gpio_value_t);
int gpio_pin_toggle(gpio_handle_t, gpio_pin_t);
/*
* Helper functions to set pin states.
diff --git a/lib/libgssapi/Makefile b/lib/libgssapi/Makefile
index 87ae164faffa..000abc4f5eeb 100644
--- a/lib/libgssapi/Makefile
+++ b/lib/libgssapi/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
LIB= gssapi
SHLIB_MAJOR= 10
diff --git a/lib/libiconv_modules/BIG5/Makefile b/lib/libiconv_modules/BIG5/Makefile
index f236c203678a..ebc0f9d03334 100644
--- a/lib/libiconv_modules/BIG5/Makefile
+++ b/lib/libiconv_modules/BIG5/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= BIG5
SRCS+= citrus_big5.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/DECHanyu/Makefile b/lib/libiconv_modules/DECHanyu/Makefile
index fd09592edda3..ace1b5ca73f1 100644
--- a/lib/libiconv_modules/DECHanyu/Makefile
+++ b/lib/libiconv_modules/DECHanyu/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= DECHanyu
SRCS+= citrus_dechanyu.c
diff --git a/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c b/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
index 9b0deb051d4e..a8576602355a 100644
--- a/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
+++ b/lib/libiconv_modules/DECHanyu/citrus_dechanyu.c
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/EUC/Makefile b/lib/libiconv_modules/EUC/Makefile
index 5e9401f4a8dd..b0f54fe2c88b 100644
--- a/lib/libiconv_modules/EUC/Makefile
+++ b/lib/libiconv_modules/EUC/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= EUC
SRCS+= citrus_euc.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/EUC/citrus_euc.c b/lib/libiconv_modules/EUC/citrus_euc.c
index fbc140a3c913..68ad92ad94cc 100644
--- a/lib/libiconv_modules/EUC/citrus_euc.c
+++ b/lib/libiconv_modules/EUC/citrus_euc.c
@@ -60,7 +60,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/EUCTW/Makefile b/lib/libiconv_modules/EUCTW/Makefile
index a7fecc8acbdc..a357d00b5d8c 100644
--- a/lib/libiconv_modules/EUCTW/Makefile
+++ b/lib/libiconv_modules/EUCTW/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= EUCTW
SRCS+= citrus_euctw.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/EUCTW/citrus_euctw.c b/lib/libiconv_modules/EUCTW/citrus_euctw.c
index f2ce43c643d9..ccabad1cbf5e 100644
--- a/lib/libiconv_modules/EUCTW/citrus_euctw.c
+++ b/lib/libiconv_modules/EUCTW/citrus_euctw.c
@@ -56,7 +56,6 @@
* $Citrus: xpg4dl/FreeBSD/lib/libc/locale/euctw.c,v 1.13 2001/06/21 01:51:44 yamt Exp $
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/GBK2K/Makefile b/lib/libiconv_modules/GBK2K/Makefile
index 7c821c9aaf50..2173f6de00e7 100644
--- a/lib/libiconv_modules/GBK2K/Makefile
+++ b/lib/libiconv_modules/GBK2K/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= GBK2K
SRCS+= citrus_gbk2k.c
CFLAGS.gcc+= --param max-inline-insns-single=16
diff --git a/lib/libiconv_modules/GBK2K/citrus_gbk2k.c b/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
index 83c1ee7e7ef8..11b35cd62f3b 100644
--- a/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
+++ b/lib/libiconv_modules/GBK2K/citrus_gbk2k.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/HZ/Makefile b/lib/libiconv_modules/HZ/Makefile
index f998f3db26cf..109aa9f90104 100644
--- a/lib/libiconv_modules/HZ/Makefile
+++ b/lib/libiconv_modules/HZ/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= HZ
SRCS+= citrus_hz.c
diff --git a/lib/libiconv_modules/ISO2022/Makefile b/lib/libiconv_modules/ISO2022/Makefile
index 422e6c986212..f666cb7bbac0 100644
--- a/lib/libiconv_modules/ISO2022/Makefile
+++ b/lib/libiconv_modules/ISO2022/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= ISO2022
SRCS+= citrus_iso2022.c
CFLAGS.gcc+= --param max-inline-insns-single=128
diff --git a/lib/libiconv_modules/ISO2022/citrus_iso2022.c b/lib/libiconv_modules/ISO2022/citrus_iso2022.c
index a311dbc26e59..126d38316df4 100644
--- a/lib/libiconv_modules/ISO2022/citrus_iso2022.c
+++ b/lib/libiconv_modules/ISO2022/citrus_iso2022.c
@@ -30,7 +30,6 @@
* $Citrus: xpg4dl/FreeBSD/lib/libc/locale/iso2022.c,v 1.23 2001/06/21 01:51:44 yamt Exp $
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/JOHAB/Makefile b/lib/libiconv_modules/JOHAB/Makefile
index 8f7bb07fa8fb..e700f8b7ef4d 100644
--- a/lib/libiconv_modules/JOHAB/Makefile
+++ b/lib/libiconv_modules/JOHAB/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= JOHAB
SRCS+= citrus_johab.c
CFLAGS.gcc+= --param max-inline-insns-single=16
diff --git a/lib/libiconv_modules/JOHAB/citrus_johab.c b/lib/libiconv_modules/JOHAB/citrus_johab.c
index 3551f8199a78..a62a0d29a0a4 100644
--- a/lib/libiconv_modules/JOHAB/citrus_johab.c
+++ b/lib/libiconv_modules/JOHAB/citrus_johab.c
@@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/MSKanji/Makefile b/lib/libiconv_modules/MSKanji/Makefile
index 4294d4dbffbf..11ae1809bb3b 100644
--- a/lib/libiconv_modules/MSKanji/Makefile
+++ b/lib/libiconv_modules/MSKanji/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= MSKanji
SRCS+= citrus_mskanji.c
diff --git a/lib/libiconv_modules/MSKanji/citrus_mskanji.c b/lib/libiconv_modules/MSKanji/citrus_mskanji.c
index 997221dcb3ab..213e086b6d8c 100644
--- a/lib/libiconv_modules/MSKanji/citrus_mskanji.c
+++ b/lib/libiconv_modules/MSKanji/citrus_mskanji.c
@@ -61,8 +61,6 @@
* SUCH DAMAGE.
*/
-
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/Makefile b/lib/libiconv_modules/Makefile
index 9811e59761e1..52344d5a8377 100644
--- a/lib/libiconv_modules/Makefile
+++ b/lib/libiconv_modules/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
SUBDIR= BIG5 DECHanyu EUC EUCTW GBK2K HZ ISO2022 JOHAB MSKanji UES UTF1632 \
diff --git a/lib/libiconv_modules/Makefile.inc b/lib/libiconv_modules/Makefile.inc
index 729c973a0d6a..196f3bde8b32 100644
--- a/lib/libiconv_modules/Makefile.inc
+++ b/lib/libiconv_modules/Makefile.inc
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/lib/libc/iconv
SHLIB_MAJOR= 5
@@ -8,4 +7,3 @@ CFLAGS+= -Dbool=_Bool
SHLIBDIR= /usr/lib${COMPAT_libcompat:U}/i18n
LIBDIR= ${SHLIBDIR}
-MK_PROFILE= no
diff --git a/lib/libiconv_modules/UES/Makefile b/lib/libiconv_modules/UES/Makefile
index 65e4be5f71e2..bcdae77adbdc 100644
--- a/lib/libiconv_modules/UES/Makefile
+++ b/lib/libiconv_modules/UES/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= UES
SRCS+= citrus_ues.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/UTF1632/Makefile b/lib/libiconv_modules/UTF1632/Makefile
index 7033fb22a1ef..88fe285d97a2 100644
--- a/lib/libiconv_modules/UTF1632/Makefile
+++ b/lib/libiconv_modules/UTF1632/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= UTF1632
SRCS+= citrus_utf1632.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/UTF7/Makefile b/lib/libiconv_modules/UTF7/Makefile
index 19aa59181fe6..969e001fc2e3 100644
--- a/lib/libiconv_modules/UTF7/Makefile
+++ b/lib/libiconv_modules/UTF7/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= UTF7
SRCS+= citrus_utf7.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/UTF8/Makefile b/lib/libiconv_modules/UTF8/Makefile
index cb7c4c669263..ec9c85cce4d8 100644
--- a/lib/libiconv_modules/UTF8/Makefile
+++ b/lib/libiconv_modules/UTF8/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= UTF8
SRCS+= citrus_utf8.c
diff --git a/lib/libiconv_modules/UTF8/citrus_utf8.c b/lib/libiconv_modules/UTF8/citrus_utf8.c
index c28cc5323c24..50e6bb0525ea 100644
--- a/lib/libiconv_modules/UTF8/citrus_utf8.c
+++ b/lib/libiconv_modules/UTF8/citrus_utf8.c
@@ -60,7 +60,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/VIQR/Makefile b/lib/libiconv_modules/VIQR/Makefile
index 7300f6fb1c3a..67fc707ab308 100644
--- a/lib/libiconv_modules/VIQR/Makefile
+++ b/lib/libiconv_modules/VIQR/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= VIQR
SRCS+= citrus_viqr.c
diff --git a/lib/libiconv_modules/ZW/Makefile b/lib/libiconv_modules/ZW/Makefile
index d7e24bd24ca3..ca2bd7cc89c4 100644
--- a/lib/libiconv_modules/ZW/Makefile
+++ b/lib/libiconv_modules/ZW/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= ZW
SRCS+= citrus_zw.c
diff --git a/lib/libiconv_modules/ZW/citrus_zw.c b/lib/libiconv_modules/ZW/citrus_zw.c
index 93590e550952..3c650c46d0f4 100644
--- a/lib/libiconv_modules/ZW/citrus_zw.c
+++ b/lib/libiconv_modules/ZW/citrus_zw.c
@@ -29,7 +29,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libiconv_modules/iconv_none/Makefile b/lib/libiconv_modules/iconv_none/Makefile
index bb5b5a790eaf..c0b3b7a776f7 100644
--- a/lib/libiconv_modules/iconv_none/Makefile
+++ b/lib/libiconv_modules/iconv_none/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= iconv_none
SRCS+= citrus_iconv_none.c
diff --git a/lib/libiconv_modules/iconv_std/Makefile b/lib/libiconv_modules/iconv_std/Makefile
index 49c63f14f41f..1ab46cf162ca 100644
--- a/lib/libiconv_modules/iconv_std/Makefile
+++ b/lib/libiconv_modules/iconv_std/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= iconv_std
SRCS+= citrus_iconv_std.c
CFLAGS.gcc+= --param max-inline-insns-single=64
diff --git a/lib/libiconv_modules/mapper_646/Makefile b/lib/libiconv_modules/mapper_646/Makefile
index 3740eff8b75f..6695d1c1c969 100644
--- a/lib/libiconv_modules/mapper_646/Makefile
+++ b/lib/libiconv_modules/mapper_646/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= mapper_646
SRCS= citrus_mapper_646.c
diff --git a/lib/libiconv_modules/mapper_none/Makefile b/lib/libiconv_modules/mapper_none/Makefile
index fd7c22617efa..e0891e957af1 100644
--- a/lib/libiconv_modules/mapper_none/Makefile
+++ b/lib/libiconv_modules/mapper_none/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= mapper_none
SRCS+= citrus_mapper_none.c
diff --git a/lib/libiconv_modules/mapper_parallel/Makefile b/lib/libiconv_modules/mapper_parallel/Makefile
index 36390b580664..823260aca5be 100644
--- a/lib/libiconv_modules/mapper_parallel/Makefile
+++ b/lib/libiconv_modules/mapper_parallel/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR:H}/mapper_serial
SHLIB= mapper_parallel
diff --git a/lib/libiconv_modules/mapper_serial/Makefile b/lib/libiconv_modules/mapper_serial/Makefile
index bc64c58d1605..931d7c0943e2 100644
--- a/lib/libiconv_modules/mapper_serial/Makefile
+++ b/lib/libiconv_modules/mapper_serial/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= mapper_serial
SRCS+= citrus_mapper_serial.c
CFLAGS.gcc+= --param max-inline-insns-single=32
diff --git a/lib/libiconv_modules/mapper_std/Makefile b/lib/libiconv_modules/mapper_std/Makefile
index 8ffd114fe860..2765525f4cec 100644
--- a/lib/libiconv_modules/mapper_std/Makefile
+++ b/lib/libiconv_modules/mapper_std/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= mapper_std
SRCS+= citrus_mapper_std.c
CFLAGS.gcc+= --param max-inline-insns-single=8
diff --git a/lib/libiconv_modules/mapper_zone/Makefile b/lib/libiconv_modules/mapper_zone/Makefile
index e33dea95e67a..55e17d3b2fba 100644
--- a/lib/libiconv_modules/mapper_zone/Makefile
+++ b/lib/libiconv_modules/mapper_zone/Makefile
@@ -1,4 +1,3 @@
-
SHLIB= mapper_zone
SRCS+= citrus_mapper_zone.c
CFLAGS.gcc+= --param max-inline-insns-single=8
diff --git a/lib/libifconfig/Makefile b/lib/libifconfig/Makefile
index 6bdb202bec1d..e8e0651dc0d6 100644
--- a/lib/libifconfig/Makefile
+++ b/lib/libifconfig/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= lib${LIB}
LIB= ifconfig
INTERNALLIB= true
diff --git a/lib/libifconfig/libifconfig.h b/lib/libifconfig/libifconfig.h
index 03a0d0b199b7..b2f0cf9744ea 100644
--- a/lib/libifconfig/libifconfig.h
+++ b/lib/libifconfig/libifconfig.h
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <net/if.h>
+#include <net/if_bridgevar.h> /* for ifbvlan_set_t */
#include <netinet/in.h>
#include <netinet/ip_carp.h>
@@ -64,9 +65,12 @@ struct lagg_reqport;
struct ifconfig_bridge_status {
struct ifbropreq *params; /**< current operational parameters */
struct ifbreq *members; /**< list of bridge members */
+ ifbvlan_set_t *member_vlans; /**< bridge member vlan sets */
size_t members_count; /**< how many member interfaces */
uint32_t cache_size; /**< size of address cache */
uint32_t cache_lifetime; /**< address cache entry lifetime */
+ ifbr_flags_t flags; /**< bridge flags */
+ ether_vlanid_t defpvid; /**< default pvid */
};
struct ifconfig_capabilities {
@@ -287,6 +291,9 @@ struct ifconfig_carp {
uint8_t carpr_key[CARP_KEY_LEN];
struct in_addr carpr_addr;
struct in6_addr carpr_addr6;
+ carp_version_t carpr_version;
+ uint8_t carpr_vrrp_prio;
+ uint16_t carpr_vrrp_adv_inter;
};
int ifconfig_carp_get_vhid(ifconfig_handle_t *h, const char *name,
diff --git a/lib/libifconfig/libifconfig_bridge.c b/lib/libifconfig/libifconfig_bridge.c
index e4db90f373d6..675bf5dd2ff5 100644
--- a/lib/libifconfig/libifconfig_bridge.c
+++ b/lib/libifconfig/libifconfig_bridge.c
@@ -66,40 +66,49 @@ ifconfig_bridge_get_bridge_status(ifconfig_handle_t *h,
{
struct ifbifconf members;
struct ifbrparam cache_param;
- struct _ifconfig_bridge_status *bridge;
- char *buf;
+ struct _ifconfig_bridge_status *bridge = NULL;
+ char *buf = NULL;
+ members.ifbic_buf = NULL;
*bridgep = NULL;
bridge = calloc(1, sizeof(struct _ifconfig_bridge_status));
if (bridge == NULL) {
h->error.errtype = OTHER;
h->error.errcode = ENOMEM;
- return (-1);
+ goto err;
}
bridge->inner.params = &bridge->params;
if (ifconfig_bridge_ioctlwrap(h, name, BRDGGCACHE,
&cache_param, sizeof(cache_param), false) != 0) {
- free(bridge);
- return (-1);
+ goto err;
}
bridge->inner.cache_size = cache_param.ifbrp_csize;
if (ifconfig_bridge_ioctlwrap(h, name, BRDGGTO,
&cache_param, sizeof(cache_param), false) != 0) {
- free(bridge);
- return (-1);
+ goto err;
}
bridge->inner.cache_lifetime = cache_param.ifbrp_ctime;
+ if (ifconfig_bridge_ioctlwrap(h, name, BRDGGFLAGS,
+ &cache_param, sizeof(cache_param), false) != 0) {
+ goto err;
+ }
+ bridge->inner.flags = cache_param.ifbrp_flags;
+
+ if (ifconfig_bridge_ioctlwrap(h, name, BRDGGDEFPVID,
+ &cache_param, sizeof(cache_param), false) != 0) {
+ goto err;
+ }
+ bridge->inner.defpvid = cache_param.ifbrp_defpvid;
+
if (ifconfig_bridge_ioctlwrap(h, name, BRDGPARAM,
&bridge->params, sizeof(bridge->params), false) != 0) {
- free(bridge);
- return (-1);
+ goto err;
}
- members.ifbic_buf = NULL;
for (size_t len = 8192;
(buf = realloc(members.ifbic_buf, len)) != NULL;
len *= 2) {
@@ -107,27 +116,52 @@ ifconfig_bridge_get_bridge_status(ifconfig_handle_t *h,
members.ifbic_len = len;
if (ifconfig_bridge_ioctlwrap(h, name, BRDGGIFS,
&members, sizeof(members), false) != 0) {
- free(buf);
- free(bridge);
- return (-1);
+ goto err;
}
- if (members.ifbic_len <= len)
+ if ((members.ifbic_len + sizeof(*members.ifbic_req)) < len)
break;
}
if (buf == NULL) {
- free(members.ifbic_buf);
- free(bridge);
h->error.errtype = OTHER;
h->error.errcode = ENOMEM;
- return (-1);
+ goto err;
}
bridge->inner.members = members.ifbic_req;
bridge->inner.members_count =
members.ifbic_len / sizeof(*members.ifbic_req);
+ bridge->inner.member_vlans = calloc(bridge->inner.members_count,
+ sizeof(ifbvlan_set_t));
+ if (bridge->inner.member_vlans == NULL) {
+ h->error.errtype = OTHER;
+ h->error.errcode = ENOMEM;
+ goto err;
+ }
+ for (size_t i = 0; i < bridge->inner.members_count; ++i) {
+ struct ifbif_vlan_req vreq;
+ memset(&vreq, 0, sizeof(vreq));
+ strlcpy(vreq.bv_ifname, bridge->inner.members[i].ifbr_ifsname,
+ sizeof(vreq.bv_ifname));
+
+ if (ifconfig_bridge_ioctlwrap(h, name, BRDGGIFVLANSET, &vreq,
+ sizeof(vreq), false) != 0) {
+ goto err;
+ }
+
+ __BIT_COPY(BRVLAN_SETSIZE, &vreq.bv_set,
+ &bridge->inner.member_vlans[i]);
+ }
+
*bridgep = &bridge->inner;
return (0);
+
+err:
+ free(members.ifbic_buf);
+ if (bridge)
+ free(bridge->inner.member_vlans);
+ free(bridge);
+ return (-1);
}
void
diff --git a/lib/libifconfig/libifconfig_carp.c b/lib/libifconfig/libifconfig_carp.c
index 40556eda813f..59faa8def496 100644
--- a/lib/libifconfig/libifconfig_carp.c
+++ b/lib/libifconfig/libifconfig_carp.c
@@ -56,6 +56,9 @@ static struct snl_attr_parser ap_carp_get[] = {
{ .type = CARP_NL_KEY, .off = _OUT(carpr_key), .cb = snl_attr_copy_string, .arg_u32 = CARP_KEY_LEN },
{ .type = CARP_NL_ADDR, .off = _OUT(carpr_addr), .cb = snl_attr_get_in_addr },
{ .type = CARP_NL_ADDR6, .off = _OUT(carpr_addr6), .cb = snl_attr_get_in6_addr },
+ { .type = CARP_NL_VERSION, .off = _OUT(carpr_version), .cb = snl_attr_get_uint8 },
+ { .type = CARP_NL_VRRP_PRIORITY, .off = _OUT(carpr_vrrp_prio), .cb = snl_attr_get_uint8 },
+ { .type = CARP_NL_VRRP_ADV_INTER, .off = _OUT(carpr_vrrp_adv_inter), .cb = snl_attr_get_uint16 },
};
#undef _OUT
@@ -175,6 +178,9 @@ ifconfig_carp_set_info(ifconfig_handle_t *h, const char *name,
snl_add_msg_attr(&nw, CARP_NL_ADDR6, sizeof(carpr->carpr_addr6),
&carpr->carpr_addr6);
snl_add_msg_attr_string(&nw, CARP_NL_KEY, carpr->carpr_key);
+ snl_add_msg_attr_u8(&nw, CARP_NL_VERSION, carpr->carpr_version);
+ snl_add_msg_attr_u8(&nw, CARP_NL_VRRP_PRIORITY, carpr->carpr_vrrp_prio);
+ snl_add_msg_attr_u16(&nw, CARP_NL_VRRP_ADV_INTER, carpr->carpr_vrrp_adv_inter);
hdr = snl_finalize_msg(&nw);
if (hdr == NULL) {
diff --git a/lib/libifconfig/libifconfig_sfp.c b/lib/libifconfig/libifconfig_sfp.c
index 17f130606765..1ba6d231a992 100644
--- a/lib/libifconfig/libifconfig_sfp.c
+++ b/lib/libifconfig/libifconfig_sfp.c
@@ -24,6 +24,8 @@
* SUCH DAMAGE.
*/
+#define _WANT_SFF_8024_ID
+
#include <sys/types.h>
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -181,6 +183,7 @@ get_qsfp_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp)
if (code & SFF_8636_EXT_COMPLIANCE) {
read_i2c(ii, SFF_8436_BASE, SFF_8436_OPTIONS_START, 1,
&sfp->sfp_eth_ext);
+ sfp->sfp_eth_1040g = code;
} else {
/* Check 10/40G Ethernet class only */
sfp->sfp_eth_1040g =
diff --git a/lib/libifconfig/sfp.lua b/lib/libifconfig/sfp.lua
index de738648451a..4a43b2ed780b 100644
--- a/lib/libifconfig/sfp.lua
+++ b/lib/libifconfig/sfp.lua
@@ -330,7 +330,7 @@ enums = {
{0x0A, "RESERVED_0A", "Reserved"},
{0x09, "OBSOLETE", "Obsolete"},
{0x08, "100G_25GAUI_C2M_ACC_1",
- "100G ACC (Active Copper Cable"},
+ "100G ACC (Active Copper Cable)"},
{0x07, "100G_PSM4_P_SMF", "100G PSM4 Parallel SMF"},
{0x06, "100G_CWDM4", "100G CWDM4"},
{0x05, "100GBASE_SR10", "100GBASE-SR10"},
@@ -338,7 +338,7 @@ enums = {
{0x03, "100GBASE_LR4_25GBASE_LR", "100GBASE-LR4 or 25GBASE-LR"},
{0x02, "100GBASE_SR4_25GBASE_SR", "100GBASE-SR4 or 25GBASE-SR"},
{0x01, "100G_25GAUI_C2M_AOC_1",
- "100G AOC (Active Optical Cable"},
+ "100G AOC (Active Optical Cable)"},
{0x00, "UNSPECIFIED", "Unspecified"},
},
},
diff --git a/lib/libipsec/ipsec_dump_policy.c b/lib/libipsec/ipsec_dump_policy.c
index c53aef5e5310..5ad8a84b2052 100644
--- a/lib/libipsec/ipsec_dump_policy.c
+++ b/lib/libipsec/ipsec_dump_policy.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -68,9 +67,9 @@ static char *set_address(char *, size_t, struct sockaddr *);
* When delimiter == NULL, alternatively ' '(space) is applied.
*/
char *
-ipsec_dump_policy(caddr_t policy, char *delimiter)
+ipsec_dump_policy(c_caddr_t policy, const char *delimiter)
{
- struct sadb_x_policy *xpl = (struct sadb_x_policy *)policy;
+ const struct sadb_x_policy *xpl = (const struct sadb_x_policy *)policy;
struct sadb_x_ipsecrequest *xisr;
size_t off, buflen;
char *buf;
diff --git a/lib/libipsec/ipsec_get_policylen.c b/lib/libipsec/ipsec_get_policylen.c
index 611ef7b2ac61..2454d875e1fa 100644
--- a/lib/libipsec/ipsec_get_policylen.c
+++ b/lib/libipsec/ipsec_get_policylen.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -42,7 +41,7 @@
#include "ipsec_strerror.h"
int
-ipsec_get_policylen(caddr_t policy)
+ipsec_get_policylen(c_caddr_t policy)
{
return policy ? PFKEY_EXTLEN(policy) : -1;
}
diff --git a/lib/libipsec/ipsec_set_policy.3 b/lib/libipsec/ipsec_set_policy.3
index 6a40e03af45f..ce4d8d244292 100644
--- a/lib/libipsec/ipsec_set_policy.3
+++ b/lib/libipsec/ipsec_set_policy.3
@@ -41,11 +41,11 @@
.Sh SYNOPSIS
.In netipsec/ipsec.h
.Ft "char *"
-.Fn ipsec_set_policy "char *policy" "int len"
+.Fn ipsec_set_policy "const char *policy" "int len"
.Ft int
-.Fn ipsec_get_policylen "char *buf"
+.Fn ipsec_get_policylen "const char *buf"
.Ft "char *"
-.Fn ipsec_dump_policy "char *buf" "char *delim"
+.Fn ipsec_dump_policy "c_caddr_t *buf" "const char *delim"
.Sh DESCRIPTION
The
.Fn ipsec_set_policy
diff --git a/lib/libipsec/ipsec_strerror.c b/lib/libipsec/ipsec_strerror.c
index 580ef80d2c25..5835dde0d662 100644
--- a/lib/libipsec/ipsec_strerror.c
+++ b/lib/libipsec/ipsec_strerror.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
diff --git a/lib/libipsec/pfkey.c b/lib/libipsec/pfkey.c
index 16d86aca2ef8..d5a033c4c501 100644
--- a/lib/libipsec/pfkey.c
+++ b/lib/libipsec/pfkey.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -1678,7 +1677,8 @@ pfkey_align(struct sadb_msg *msg, caddr_t *mhp)
/* duplicate check */
/* XXX Are there duplication either KEY_AUTH or KEY_ENCRYPT ?*/
- if (mhp[ext->sadb_ext_type] != NULL) {
+ if (mhp[ext->sadb_ext_type] != NULL &&
+ ext->sadb_ext_type != SADB_X_EXT_IF_HW_OFFL /* XXXKIB */) {
__ipsec_errcode = EIPSEC_INVAL_EXTTYPE;
return -1;
}
@@ -1714,6 +1714,9 @@ pfkey_align(struct sadb_msg *msg, caddr_t *mhp)
case SADB_X_EXT_SA_REPLAY:
case SADB_X_EXT_NEW_ADDRESS_SRC:
case SADB_X_EXT_NEW_ADDRESS_DST:
+ case SADB_X_EXT_LFT_CUR_SW_OFFL:
+ case SADB_X_EXT_LFT_CUR_HW_OFFL:
+ case SADB_X_EXT_IF_HW_OFFL:
mhp[ext->sadb_ext_type] = (caddr_t)ext;
break;
default:
diff --git a/lib/libipsec/pfkey_dump.c b/lib/libipsec/pfkey_dump.c
index 11b99c54f288..8dcc21be16e2 100644
--- a/lib/libipsec/pfkey_dump.c
+++ b/lib/libipsec/pfkey_dump.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -44,6 +43,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@@ -202,7 +202,7 @@ pfkey_sadump(struct sadb_msg *m)
caddr_t mhp[SADB_EXT_MAX + 1];
struct sadb_sa *m_sa;
struct sadb_x_sa2 *m_sa2;
- struct sadb_lifetime *m_lftc, *m_lfth, *m_lfts;
+ struct sadb_lifetime *m_lftc, *m_lfth, *m_lfts, *m_lft_sw, *m_lft_hw;
struct sadb_address *m_saddr, *m_daddr, *m_paddr;
struct sadb_key *m_auth, *m_enc;
struct sadb_ident *m_sid, *m_did;
@@ -211,6 +211,10 @@ pfkey_sadump(struct sadb_msg *m)
struct sadb_x_nat_t_type *natt_type;
struct sadb_x_nat_t_port *natt_sport, *natt_dport;
struct sadb_address *natt_oai, *natt_oar;
+ struct sadb_x_if_hw_offl *if_hw_offl;
+ caddr_t p, ep;
+ struct sadb_ext *ext;
+ bool first;
/* check pfkey message. */
if (pfkey_align(m, mhp)) {
@@ -241,7 +245,9 @@ pfkey_sadump(struct sadb_msg *m)
natt_dport = (struct sadb_x_nat_t_port *)mhp[SADB_X_EXT_NAT_T_DPORT];
natt_oai = (struct sadb_address *)mhp[SADB_X_EXT_NAT_T_OAI];
natt_oar = (struct sadb_address *)mhp[SADB_X_EXT_NAT_T_OAR];
-
+ m_lft_sw = (struct sadb_lifetime *)mhp[SADB_X_EXT_LFT_CUR_SW_OFFL];
+ m_lft_hw = (struct sadb_lifetime *)mhp[SADB_X_EXT_LFT_CUR_HW_OFFL];
+ if_hw_offl = (struct sadb_x_if_hw_offl *)mhp[SADB_X_EXT_IF_HW_OFFL];
/* source address */
if (m_saddr == NULL) {
@@ -333,6 +339,27 @@ pfkey_sadump(struct sadb_msg *m)
GETMSGSTR(str_state, m_sa->sadb_sa_state);
printf("\n");
+ /* hw offload interface */
+ if (if_hw_offl != NULL) {
+ p = (caddr_t)m;
+ ep = p + PFKEY_UNUNIT64(m->sadb_msg_len);
+ p += sizeof(struct sadb_msg);
+ printf("\thw offl if: ");
+
+ for (first = true; p < ep; p += PFKEY_EXTLEN(ext)) {
+ ext = (struct sadb_ext *)p;
+ if (ext->sadb_ext_type != SADB_X_EXT_IF_HW_OFFL)
+ continue;
+ if_hw_offl = (struct sadb_x_if_hw_offl *)ext;
+ if (first)
+ first = false;
+ else
+ printf(",");
+ printf("%s", if_hw_offl->sadb_x_if_hw_offl_if);
+ }
+ printf("\n");
+ }
+
/* lifetime */
if (m_lftc != NULL) {
time_t tmp_time = time(0);
@@ -382,7 +409,23 @@ pfkey_sadump(struct sadb_msg *m)
/* XXX DEBUG */
printf("refcnt=%u\n", m->sadb_msg_reserved);
- return;
+ if (m_lft_sw != NULL) {
+ printf("\tsw offl use: %s",
+ str_time(m_lft_sw->sadb_lifetime_usetime));
+ printf("\tsw offl allocated: %lu",
+ (unsigned long)m_lft_sw->sadb_lifetime_allocations);
+ str_lifetime_byte(m_lft_sw, "sw offl");
+ printf("\n");
+ }
+
+ if (m_lft_hw != NULL) {
+ printf("\thw offl use: %s",
+ str_time(m_lft_hw->sadb_lifetime_usetime));
+ printf("\thw offl allocated: %lu",
+ (unsigned long)m_lft_hw->sadb_lifetime_allocations);
+ str_lifetime_byte(m_lft_hw, "hw offl");
+ printf("\n");
+ }
}
void
diff --git a/lib/libipsec/policy_parse.y b/lib/libipsec/policy_parse.y
index f29db2a85d63..35512dcc1f58 100644
--- a/lib/libipsec/policy_parse.y
+++ b/lib/libipsec/policy_parse.y
@@ -51,7 +51,7 @@
*/
%{
-#include <sys/cdefs.h>
+
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -77,16 +77,16 @@ static struct sockaddr *p_src = NULL;
static struct sockaddr *p_dst = NULL;
struct _val;
-extern void yyerror(char *msg);
-static struct sockaddr *parse_sockaddr(struct _val *buf);
+extern void yyerror(const char *msg);
+static struct sockaddr *parse_sockaddr(const struct _val *buf);
static int rule_check(void);
static int init_x_policy(void);
static int set_x_request(struct sockaddr *src, struct sockaddr *dst);
-static int set_sockaddr(struct sockaddr *addr);
+static int set_sockaddr(const struct sockaddr *addr);
static void policy_parse_request_init(void);
-static caddr_t policy_parse(char *msg, int msglen);
+static caddr_t policy_parse(const char *msg, int msglen);
-extern void __policy__strbuffer__init__(char *msg);
+extern void __policy__strbuffer__init__(const char *msg);
extern void __policy__strbuffer__free__(void);
extern int yylex(void);
@@ -211,7 +211,7 @@ addresses
%%
void
-yyerror(char *msg)
+yyerror(const char *msg)
{
fprintf(stderr, "libipsec: %s while parsing \"%s\"\n",
msg, __libipsecyytext);
@@ -220,7 +220,7 @@ yyerror(char *msg)
}
static struct sockaddr *
-parse_sockaddr(struct _val *buf)
+parse_sockaddr(const struct _val *buf)
{
struct addrinfo hints, *res;
char *serv = NULL;
@@ -346,7 +346,7 @@ set_x_request(struct sockaddr *src, struct sockaddr *dst)
}
static int
-set_sockaddr(struct sockaddr *addr)
+set_sockaddr(const struct sockaddr *addr)
{
if (addr == NULL) {
__ipsec_errcode = EIPSEC_NO_ERROR;
@@ -383,7 +383,7 @@ policy_parse_request_init(void)
}
static caddr_t
-policy_parse(char *msg, int msglen)
+policy_parse(const char *msg, int msglen)
{
int error;
pbuf = NULL;
@@ -413,7 +413,7 @@ policy_parse(char *msg, int msglen)
}
caddr_t
-ipsec_set_policy(char *msg, int msglen)
+ipsec_set_policy(const char *msg, int msglen)
{
caddr_t policy;
diff --git a/lib/libipsec/test-policy.c b/lib/libipsec/test-policy.c
index c55d2b3f63b7..6a467c176c66 100644
--- a/lib/libipsec/test-policy.c
+++ b/lib/libipsec/test-policy.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libipt/Makefile b/lib/libipt/Makefile
index 07cdfd0417d9..68809f32da05 100644
--- a/lib/libipt/Makefile
+++ b/lib/libipt/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
SHLIBDIR?= /lib
diff --git a/lib/libipt/Makefile.depend b/lib/libipt/Makefile.depend
new file mode 100644
index 000000000000..6ef78fac5cbf
--- /dev/null
+++ b/lib/libipt/Makefile.depend
@@ -0,0 +1,15 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libiscsiutil/Makefile.depend b/lib/libiscsiutil/Makefile.depend
index e69de29bb2d1..e1cc198eab19 100644
--- a/lib/libiscsiutil/Makefile.depend
+++ b/lib/libiscsiutil/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/libmd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libiscsiutil/libiscsiutil.h b/lib/libiscsiutil/libiscsiutil.h
index bf26a5b8ed66..b50afa1c9409 100644
--- a/lib/libiscsiutil/libiscsiutil.h
+++ b/lib/libiscsiutil/libiscsiutil.h
@@ -95,6 +95,8 @@ struct rchap {
size_t rchap_challenge_len;
};
+__BEGIN_DECLS
+
struct chap *chap_new(void);
char *chap_get_id(const struct chap *chap);
char *chap_get_challenge(const struct chap *chap);
@@ -154,17 +156,26 @@ void text_send_response(struct pdu *request,
void connection_init(struct connection *conn,
const struct connection_ops *ops, bool use_proxy);
+bool valid_iscsi_name(const char *name,
+ void (*warn_fn)(const char *, ...));
+
void log_init(int level);
void log_set_peer_name(const char *name);
void log_set_peer_addr(const char *addr);
void log_err(int, const char *, ...)
__dead2 __printflike(2, 3);
+void log_errc(int, int, const char *, ...)
+ __dead2 __printflike(3, 4);
void log_errx(int, const char *, ...)
__dead2 __printflike(2, 3);
void log_warn(const char *, ...) __printflike(1, 2);
+void log_warnc(int, const char *, ...)
+ __printflike(2, 3);
void log_warnx(const char *, ...) __printflike(1, 2);
void log_debugx(const char *, ...) __printflike(1, 2);
char *checked_strdup(const char *);
+__END_DECLS
+
#endif /* !__LIBISCSIUTIL_H__ */
diff --git a/lib/libiscsiutil/log.c b/lib/libiscsiutil/log.c
index a69c979c3cce..cead4ab2d709 100644
--- a/lib/libiscsiutil/log.c
+++ b/lib/libiscsiutil/log.c
@@ -153,6 +153,18 @@ log_err(int eval, const char *fmt, ...)
}
void
+log_errc(int eval, int code, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ log_common(LOG_CRIT, code, fmt, ap);
+ va_end(ap);
+
+ exit(eval);
+}
+
+void
log_errx(int eval, const char *fmt, ...)
{
va_list ap;
@@ -175,6 +187,16 @@ log_warn(const char *fmt, ...)
}
void
+log_warnc(int code, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ log_common(LOG_WARNING, code, fmt, ap);
+ va_end(ap);
+}
+
+void
log_warnx(const char *fmt, ...)
{
va_list ap;
diff --git a/lib/libiscsiutil/pdu.c b/lib/libiscsiutil/pdu.c
index 276eef68457c..a26fc27ce2c8 100644
--- a/lib/libiscsiutil/pdu.c
+++ b/lib/libiscsiutil/pdu.c
@@ -29,7 +29,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <assert.h>
diff --git a/lib/libiscsiutil/utils.c b/lib/libiscsiutil/utils.c
index e078c7a53a17..ef2d67106da5 100644
--- a/lib/libiscsiutil/utils.c
+++ b/lib/libiscsiutil/utils.c
@@ -28,10 +28,13 @@
* SUCH DAMAGE.
*/
+#include <ctype.h>
#include <string.h>
#include "libiscsiutil.h"
+#define MAX_NAME_LEN 223
+
char *
checked_strdup(const char *s)
{
@@ -42,3 +45,71 @@ checked_strdup(const char *s)
log_err(1, "strdup");
return (c);
}
+
+bool
+valid_iscsi_name(const char *name, void (*warn_fn)(const char *, ...))
+{
+ int i;
+
+ if (strlen(name) >= MAX_NAME_LEN) {
+ warn_fn("overlong name for target \"%s\"; max length allowed "
+ "by iSCSI specification is %d characters",
+ name, MAX_NAME_LEN);
+ return (false);
+ }
+
+ /*
+ * In the cases below, we don't return an error, just in case the admin
+ * was right, and we're wrong.
+ */
+ if (strncasecmp(name, "iqn.", strlen("iqn.")) == 0) {
+ for (i = strlen("iqn."); name[i] != '\0'; i++) {
+ /*
+ * XXX: We should verify UTF-8 normalisation, as defined
+ * by 3.2.6.2: iSCSI Name Encoding.
+ */
+ if (isalnum(name[i]))
+ continue;
+ if (name[i] == '-' || name[i] == '.' || name[i] == ':')
+ continue;
+ warn_fn("invalid character \"%c\" in target name "
+ "\"%s\"; allowed characters are letters, digits, "
+ "'-', '.', and ':'", name[i], name);
+ break;
+ }
+ /*
+ * XXX: Check more stuff: valid date and a valid reversed domain.
+ */
+ } else if (strncasecmp(name, "eui.", strlen("eui.")) == 0) {
+ if (strlen(name) != strlen("eui.") + 16)
+ warn_fn("invalid target name \"%s\"; the \"eui.\" "
+ "should be followed by exactly 16 hexadecimal "
+ "digits", name);
+ for (i = strlen("eui."); name[i] != '\0'; i++) {
+ if (!isxdigit(name[i])) {
+ warn_fn("invalid character \"%c\" in target "
+ "name \"%s\"; allowed characters are 1-9 "
+ "and A-F", name[i], name);
+ break;
+ }
+ }
+ } else if (strncasecmp(name, "naa.", strlen("naa.")) == 0) {
+ if (strlen(name) > strlen("naa.") + 32)
+ warn_fn("invalid target name \"%s\"; the \"naa.\" "
+ "should be followed by at most 32 hexadecimal "
+ "digits", name);
+ for (i = strlen("naa."); name[i] != '\0'; i++) {
+ if (!isxdigit(name[i])) {
+ warn_fn("invalid character \"%c\" in target "
+ "name \"%s\"; allowed characters are 1-9 "
+ "and A-F", name[i], name);
+ break;
+ }
+ }
+ } else {
+ warn_fn("invalid target name \"%s\"; should start with "
+ "either \"iqn.\", \"eui.\", or \"naa.\"",
+ name);
+ }
+ return (true);
+}
diff --git a/lib/libjail/Makefile b/lib/libjail/Makefile
index eef14e89e161..2c7bc157c827 100644
--- a/lib/libjail/Makefile
+++ b/lib/libjail/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
LIB= jail
SHLIBDIR?= /lib
diff --git a/lib/libjail/jail.3 b/lib/libjail/jail.3
index 3c3c24d75dc4..820e378eb625 100644
--- a/lib/libjail/jail.3
+++ b/lib/libjail/jail.3
@@ -270,8 +270,8 @@ A parameter is of an unknown type.
.El
.Sh SEE ALSO
.Xr jail 2 ,
-.Xr jail 3lua ,
.Xr sysctl 3 ,
+.Xr jail 3lua ,
.Xr jail 8
.Sh HISTORY
The
diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c
index 04fd6d3c4250..30282e67866c 100644
--- a/lib/libjail/jail.c
+++ b/lib/libjail/jail.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/jail.h>
#include <sys/linker.h>
@@ -60,6 +59,7 @@ static int jailparam_type(struct jailparam *jp);
static int kldload_param(const char *name);
static char *noname(const char *name);
static char *nononame(const char *name);
+static char *kvname(const char *name);
char jail_errmsg[JAIL_ERRMSGLEN];
@@ -522,6 +522,11 @@ jailparam_set(struct jailparam *jp, unsigned njp, int flags)
jiov[i - 1].iov_len = strlen(nname) + 1;
}
+ } else if (jp[j].jp_flags & JP_KEYVALUE &&
+ jp[j].jp_value == NULL) {
+ /* No value means key removal. */
+ jiov[i].iov_base = NULL;
+ jiov[i].iov_len = 0;
} else {
/*
* Try to fill in missing values with an empty string.
@@ -738,6 +743,12 @@ jailparam_export(struct jailparam *jp)
int i, nval, ival;
char valbuf[INET6_ADDRSTRLEN];
+ if (jp->jp_value == NULL) {
+ snprintf(jail_errmsg, JAIL_ERRMSGLEN,
+ "parameter %s was not imported", jp->jp_name);
+ errno = EINVAL;
+ return (NULL);
+ }
if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) {
value = strdup(jp->jp_value);
if (value == NULL)
@@ -902,22 +913,41 @@ jailparam_type(struct jailparam *jp)
* the "no" counterpart to a boolean.
*/
nname = nononame(name);
- if (nname == NULL) {
- unknown_parameter:
- snprintf(jail_errmsg, JAIL_ERRMSGLEN,
- "unknown parameter: %s", jp->jp_name);
- errno = ENOENT;
- return (-1);
+ if (nname != NULL) {
+ snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", nname);
+ miblen = sizeof(mib) - 2 * sizeof(int);
+ if (sysctl(mib, 2, mib + 2, &miblen, desc.s,
+ strlen(desc.s)) >= 0) {
+ name = alloca(strlen(nname) + 1);
+ strcpy(name, nname);
+ free(nname);
+ jp->jp_flags |= JP_NOBOOL;
+ goto mib_desc;
+ }
+ free(nname);
}
- name = alloca(strlen(nname) + 1);
- strcpy(name, nname);
- free(nname);
- snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", name);
- miblen = sizeof(mib) - 2 * sizeof(int);
- if (sysctl(mib, 2, mib + 2, &miblen, desc.s,
- strlen(desc.s)) < 0)
- goto unknown_parameter;
- jp->jp_flags |= JP_NOBOOL;
+ /*
+ * It might be an assumed sub-node of a fmt='A,keyvalue' sysctl.
+ */
+ nname = kvname(name);
+ if (nname != NULL) {
+ snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", nname);
+ miblen = sizeof(mib) - 2 * sizeof(int);
+ if (sysctl(mib, 2, mib + 2, &miblen, desc.s,
+ strlen(desc.s)) >= 0) {
+ name = alloca(strlen(nname) + 1);
+ strcpy(name, nname);
+ free(nname);
+ jp->jp_flags |= JP_KEYVALUE;
+ goto mib_desc;
+ }
+ free(nname);
+ }
+unknown_parameter:
+ snprintf(jail_errmsg, JAIL_ERRMSGLEN,
+ "unknown parameter: %s", jp->jp_name);
+ errno = ENOENT;
+ return (-1);
}
mib_desc:
mib[1] = 4;
@@ -938,6 +968,12 @@ jailparam_type(struct jailparam *jp)
else if ((desc.i & CTLTYPE) != CTLTYPE_NODE)
goto unknown_parameter;
}
+ /* Make sure it is a valid keyvalue param. */
+ if (jp->jp_flags & JP_KEYVALUE) {
+ if ((desc.i & CTLTYPE) != CTLTYPE_STRING ||
+ strcmp(desc.s, "A,keyvalue") != 0)
+ goto unknown_parameter;
+ }
/* See if this is an array type. */
p = strchr(desc.s, '\0');
isarray = 0;
@@ -1114,3 +1150,26 @@ nononame(const char *name)
strcpy(nname, name + 2);
return (nname);
}
+
+static char *
+kvname(const char *name)
+{
+ const char *p;
+ char *kvname;
+ size_t len;
+
+ p = strchr(name, '.');
+ if (p == NULL)
+ return (NULL);
+
+ len = p - name;
+ kvname = malloc(len + 1);
+ if (kvname == NULL) {
+ strerror_r(errno, jail_errmsg, JAIL_ERRMSGLEN);
+ return (NULL);
+ }
+ strncpy(kvname, name, len);
+ kvname[len] = '\0';
+
+ return (kvname);
+}
diff --git a/lib/libjail/jail.h b/lib/libjail/jail.h
index 27f07cd98802..6ce79b1b0528 100644
--- a/lib/libjail/jail.h
+++ b/lib/libjail/jail.h
@@ -33,6 +33,7 @@
#define JP_BOOL 0x02
#define JP_NOBOOL 0x04
#define JP_JAILSYS 0x08
+#define JP_KEYVALUE 0x10
#define JAIL_ERRMSGLEN 1024
diff --git a/lib/libjail/jail_getid.c b/lib/libjail/jail_getid.c
index 3db11aae84ce..9cc13d84e614 100644
--- a/lib/libjail/jail_getid.c
+++ b/lib/libjail/jail_getid.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/jail.h>
diff --git a/lib/libkiconv/Makefile b/lib/libkiconv/Makefile
index 687e3586b8b0..f359f9215a28 100644
--- a/lib/libkiconv/Makefile
+++ b/lib/libkiconv/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libkldelf/Makefile b/lib/libkldelf/Makefile
new file mode 100644
index 000000000000..0d1716f17fca
--- /dev/null
+++ b/lib/libkldelf/Makefile
@@ -0,0 +1,21 @@
+.include <bsd.own.mk>
+
+PACKAGE= runtime
+LIB= kldelf
+PRIVATELIB= yes
+
+SRCS= ef.c \
+ ef_obj.c \
+ elf.c \
+ ef_aarch64.c \
+ ef_arm.c \
+ ef_amd64.c \
+ ef_i386.c \
+ ef_mips.c \
+ ef_powerpc.c \
+ ef_riscv.c
+WARNS?= 2
+
+LIBADD= elf
+
+.include <bsd.lib.mk>
diff --git a/lib/libkldelf/Makefile.depend b/lib/libkldelf/Makefile.depend
new file mode 100644
index 000000000000..b0aa274151ad
--- /dev/null
+++ b/lib/libkldelf/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libelf \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libkldelf/ef.c b/lib/libkldelf/ef.c
new file mode 100644
index 000000000000..28576df99bf2
--- /dev/null
+++ b/lib/libkldelf/ef.c
@@ -0,0 +1,652 @@
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 2000, Boris Popov
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Boris Popov.
+ * 4. 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 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.
+ */
+
+#include <sys/param.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "kldelf.h"
+
+#define MAXSEGS 16
+struct ef_file {
+ char *ef_name;
+ struct elf_file *ef_efile;
+ GElf_Phdr *ef_ph;
+ void *ef_fpage; /* First block of the file */
+ int ef_fplen; /* length of first block */
+ GElf_Hashelt ef_nbuckets;
+ GElf_Hashelt ef_nchains;
+ GElf_Hashelt *ef_buckets;
+ GElf_Hashelt *ef_chains;
+ GElf_Hashelt *ef_hashtab;
+ caddr_t ef_strtab;
+ long ef_strsz;
+ GElf_Sym *ef_symtab;
+ int ef_nsegs;
+ GElf_Phdr *ef_segs[MAXSEGS];
+ int ef_verbose;
+ GElf_Rel *ef_rel; /* relocation table */
+ long ef_relsz; /* number of entries */
+ GElf_Rela *ef_rela; /* relocation table */
+ long ef_relasz; /* number of entries */
+};
+
+static void ef_print_phdr(GElf_Phdr *);
+static GElf_Off ef_get_offset(elf_file_t, GElf_Addr);
+
+static void ef_close(elf_file_t ef);
+
+static int ef_seg_read_rel(elf_file_t ef, GElf_Addr address, size_t len,
+ void *dest);
+static int ef_seg_read_string(elf_file_t ef, GElf_Addr address, size_t len,
+ char *dest);
+
+static GElf_Addr ef_symaddr(elf_file_t ef, GElf_Size symidx);
+static int ef_lookup_set(elf_file_t ef, const char *name,
+ GElf_Addr *startp, GElf_Addr *stopp, long *countp);
+static int ef_lookup_symbol(elf_file_t ef, const char *name,
+ GElf_Sym **sym, bool see_local);
+
+static struct elf_file_ops ef_file_ops = {
+ .close = ef_close,
+ .seg_read_rel = ef_seg_read_rel,
+ .seg_read_string = ef_seg_read_string,
+ .symaddr = ef_symaddr,
+ .lookup_set = ef_lookup_set,
+ .lookup_symbol = ef_lookup_symbol,
+};
+
+static void
+ef_print_phdr(GElf_Phdr *phdr)
+{
+
+ if ((phdr->p_flags & PF_W) == 0) {
+ printf("text=0x%jx ", (uintmax_t)phdr->p_filesz);
+ } else {
+ printf("data=0x%jx", (uintmax_t)phdr->p_filesz);
+ if (phdr->p_filesz < phdr->p_memsz)
+ printf("+0x%jx",
+ (uintmax_t)(phdr->p_memsz - phdr->p_filesz));
+ printf(" ");
+ }
+}
+
+static GElf_Off
+ef_get_offset(elf_file_t ef, GElf_Addr addr)
+{
+ GElf_Phdr *ph;
+ int i;
+
+ for (i = 0; i < ef->ef_nsegs; i++) {
+ ph = ef->ef_segs[i];
+ if (addr >= ph->p_vaddr && addr < ph->p_vaddr + ph->p_memsz) {
+ return (ph->p_offset + (addr - ph->p_vaddr));
+ }
+ }
+ return (0);
+}
+
+/*
+ * next two functions copied from link_elf.c
+ */
+static int
+ef_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym, bool see_local)
+{
+ unsigned long hash, symnum;
+ GElf_Sym *symp;
+ char *strp;
+
+ /* First, search hashed global symbols */
+ hash = elf_hash(name);
+ symnum = ef->ef_buckets[hash % ef->ef_nbuckets];
+
+ while (symnum != STN_UNDEF) {
+ if (symnum >= ef->ef_nchains) {
+ warnx("ef_lookup_symbol: file %s have corrupted symbol table\n",
+ ef->ef_name);
+ return (ENOENT);
+ }
+
+ symp = ef->ef_symtab + symnum;
+ if (symp->st_name == 0) {
+ warnx("ef_lookup_symbol: file %s have corrupted symbol table\n",
+ ef->ef_name);
+ return (ENOENT);
+ }
+
+ strp = ef->ef_strtab + symp->st_name;
+
+ if (strcmp(name, strp) == 0) {
+ if (symp->st_shndx != SHN_UNDEF ||
+ (symp->st_value != 0 &&
+ GELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
+ if (see_local ||
+ GELF_ST_BIND(symp->st_info) != STB_LOCAL) {
+ *sym = symp;
+ return (0);
+ }
+ } else
+ return (ENOENT);
+ }
+
+ symnum = ef->ef_chains[symnum];
+ }
+
+ return (ENOENT);
+}
+
+static int
+ef_lookup_set(elf_file_t ef, const char *name, GElf_Addr *startp,
+ GElf_Addr *stopp, long *countp)
+{
+ GElf_Sym *sym;
+ char *setsym;
+ int error, len;
+
+ len = strlen(name) + sizeof("__start_set_"); /* sizeof includes \0 */
+ setsym = malloc(len);
+ if (setsym == NULL)
+ return (errno);
+
+ /* get address of first entry */
+ snprintf(setsym, len, "%s%s", "__start_set_", name);
+ error = ef_lookup_symbol(ef, setsym, &sym, true);
+ if (error != 0)
+ goto out;
+ *startp = sym->st_value;
+
+ /* get address of last entry */
+ snprintf(setsym, len, "%s%s", "__stop_set_", name);
+ error = ef_lookup_symbol(ef, setsym, &sym, true);
+ if (error != 0)
+ goto out;
+ *stopp = sym->st_value;
+
+ /* and the number of entries */
+ *countp = (*stopp - *startp) / elf_pointer_size(ef->ef_efile);
+
+out:
+ free(setsym);
+ return (error);
+}
+
+static GElf_Addr
+ef_symaddr(elf_file_t ef, GElf_Size symidx)
+{
+ const GElf_Sym *sym;
+
+ if (symidx >= ef->ef_nchains)
+ return (0);
+ sym = ef->ef_symtab + symidx;
+
+ if (GELF_ST_BIND(sym->st_info) == STB_LOCAL &&
+ sym->st_shndx != SHN_UNDEF && sym->st_value != 0)
+ return (sym->st_value);
+ return (0);
+}
+
+static int
+ef_parse_dynamic(elf_file_t ef, const GElf_Phdr *phdyn)
+{
+ GElf_Shdr *shdr;
+ GElf_Dyn *dyn, *dp;
+ size_t i, ndyn, nshdr, nsym;
+ int error;
+ GElf_Off hash_off, sym_off, str_off;
+ GElf_Off rel_off;
+ GElf_Off rela_off;
+ int rel_sz;
+ int rela_sz;
+ int dynamic_idx;
+
+ /*
+ * The kernel linker parses the PT_DYNAMIC segment to find
+ * various important tables. The gelf API of libelf is
+ * section-oriented and requires extracting data from sections
+ * instead of segments (program headers). As a result,
+ * iterate over section headers to read various tables after
+ * parsing values from PT_DYNAMIC.
+ */
+ error = elf_read_shdrs(ef->ef_efile, &nshdr, &shdr);
+ if (error != 0)
+ return (EFTYPE);
+ dyn = NULL;
+
+ /* Find section for .dynamic. */
+ dynamic_idx = -1;
+ for (i = 0; i < nshdr; i++) {
+ if (shdr[i].sh_type == SHT_DYNAMIC) {
+ /*
+ * PowerPC kernels contain additional sections
+ * beyond .dynamic in PT_DYNAMIC due to a linker
+ * script bug. Permit a section with a smaller
+ * size as a workaround.
+ */
+ if (shdr[i].sh_offset != phdyn->p_offset ||
+ ((elf_machine(ef->ef_efile) == EM_PPC ||
+ elf_machine(ef->ef_efile) == EM_PPC64) ?
+ shdr[i].sh_size > phdyn->p_filesz :
+ shdr[i].sh_size != phdyn->p_filesz)) {
+ warnx(".dynamic section doesn't match phdr");
+ error = EFTYPE;
+ goto out;
+ }
+ if (dynamic_idx != -1) {
+ warnx("multiple SHT_DYNAMIC sections");
+ error = EFTYPE;
+ goto out;
+ }
+ dynamic_idx = i;
+ }
+ }
+
+ error = elf_read_dynamic(ef->ef_efile, dynamic_idx, &ndyn, &dyn);
+ if (error != 0)
+ goto out;
+
+ hash_off = rel_off = rela_off = sym_off = str_off = 0;
+ rel_sz = rela_sz = 0;
+ for (i = 0; i < ndyn; i++) {
+ dp = &dyn[i];
+ if (dp->d_tag == DT_NULL)
+ break;
+
+ switch (dp->d_tag) {
+ case DT_HASH:
+ if (hash_off != 0)
+ warnx("second DT_HASH entry ignored");
+ else
+ hash_off = ef_get_offset(ef, dp->d_un.d_ptr);
+ break;
+ case DT_STRTAB:
+ if (str_off != 0)
+ warnx("second DT_STRTAB entry ignored");
+ else
+ str_off = ef_get_offset(ef, dp->d_un.d_ptr);
+ break;
+ case DT_SYMTAB:
+ if (sym_off != 0)
+ warnx("second DT_SYMTAB entry ignored");
+ else
+ sym_off = ef_get_offset(ef, dp->d_un.d_ptr);
+ break;
+ case DT_SYMENT:
+ if (dp->d_un.d_val != elf_object_size(ef->ef_efile,
+ ELF_T_SYM)) {
+ error = EFTYPE;
+ goto out;
+ }
+ break;
+ case DT_REL:
+ if (rel_off != 0)
+ warnx("second DT_REL entry ignored");
+ else
+ rel_off = ef_get_offset(ef, dp->d_un.d_ptr);
+ break;
+ case DT_RELSZ:
+ if (rel_sz != 0)
+ warnx("second DT_RELSZ entry ignored");
+ else
+ rel_sz = dp->d_un.d_val;
+ break;
+ case DT_RELENT:
+ if (dp->d_un.d_val != elf_object_size(ef->ef_efile,
+ ELF_T_REL)) {
+ error = EFTYPE;
+ goto out;
+ }
+ break;
+ case DT_RELA:
+ if (rela_off != 0)
+ warnx("second DT_RELA entry ignored");
+ else
+ rela_off = ef_get_offset(ef, dp->d_un.d_ptr);
+ break;
+ case DT_RELASZ:
+ if (rela_sz != 0)
+ warnx("second DT_RELSZ entry ignored");
+ else
+ rela_sz = dp->d_un.d_val;
+ break;
+ case DT_RELAENT:
+ if (dp->d_un.d_val != elf_object_size(ef->ef_efile,
+ ELF_T_RELA)) {
+ error = EFTYPE;
+ goto out;
+ }
+ break;
+ }
+ }
+ if (hash_off == 0) {
+ warnx("%s: no .hash section found\n", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (sym_off == 0) {
+ warnx("%s: no .dynsym section found\n", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (str_off == 0) {
+ warnx("%s: no .dynstr section found\n", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+
+ nsym = 0;
+ for (i = 0; i < nshdr; i++) {
+ switch (shdr[i].sh_type) {
+ case SHT_HASH:
+ if (shdr[i].sh_offset != hash_off) {
+ warnx("%s: ignoring SHT_HASH at different offset from DT_HASH",
+ ef->ef_name);
+ break;
+ }
+
+ /*
+ * libelf(3) mentions ELF_T_HASH, but it is
+ * not defined.
+ */
+ if (shdr[i].sh_size < sizeof(*ef->ef_hashtab) * 2) {
+ warnx("hash section too small");
+ error = EFTYPE;
+ goto out;
+ }
+ error = elf_read_data(ef->ef_efile, ELF_T_WORD,
+ shdr[i].sh_offset, shdr[i].sh_size,
+ (void **)&ef->ef_hashtab);
+ if (error != 0) {
+ warnc(error, "can't read hash table");
+ goto out;
+ }
+ ef->ef_nbuckets = ef->ef_hashtab[0];
+ ef->ef_nchains = ef->ef_hashtab[1];
+ if ((2 + ef->ef_nbuckets + ef->ef_nchains) *
+ sizeof(*ef->ef_hashtab) != shdr[i].sh_size) {
+ warnx("inconsistent hash section size");
+ error = EFTYPE;
+ goto out;
+ }
+
+ ef->ef_buckets = ef->ef_hashtab + 2;
+ ef->ef_chains = ef->ef_buckets + ef->ef_nbuckets;
+ break;
+ case SHT_DYNSYM:
+ if (shdr[i].sh_offset != sym_off) {
+ warnx("%s: ignoring SHT_DYNSYM at different offset from DT_SYMTAB",
+ ef->ef_name);
+ break;
+ }
+ error = elf_read_symbols(ef->ef_efile, i, &nsym,
+ &ef->ef_symtab);
+ if (error != 0) {
+ if (ef->ef_verbose)
+ warnx("%s: can't load .dynsym section (0x%jx)",
+ ef->ef_name, (uintmax_t)sym_off);
+ goto out;
+ }
+ break;
+ case SHT_STRTAB:
+ if (shdr[i].sh_offset != str_off)
+ break;
+ error = elf_read_string_table(ef->ef_efile,
+ &shdr[i], &ef->ef_strsz, &ef->ef_strtab);
+ if (error != 0) {
+ warnx("can't load .dynstr section");
+ error = EIO;
+ goto out;
+ }
+ break;
+ case SHT_REL:
+ if (shdr[i].sh_offset != rel_off)
+ break;
+ if (shdr[i].sh_size != rel_sz) {
+ warnx("%s: size mismatch for DT_REL section",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ error = elf_read_rel(ef->ef_efile, i, &ef->ef_relsz,
+ &ef->ef_rel);
+ if (error != 0) {
+ warnx("%s: cannot load DT_REL section",
+ ef->ef_name);
+ goto out;
+ }
+ break;
+ case SHT_RELA:
+ if (shdr[i].sh_offset != rela_off)
+ break;
+ if (shdr[i].sh_size != rela_sz) {
+ warnx("%s: size mismatch for DT_RELA section",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ error = elf_read_rela(ef->ef_efile, i, &ef->ef_relasz,
+ &ef->ef_rela);
+ if (error != 0) {
+ warnx("%s: cannot load DT_RELA section",
+ ef->ef_name);
+ goto out;
+ }
+ break;
+ }
+ }
+
+ if (ef->ef_hashtab == NULL) {
+ warnx("%s: did not find a symbol hash table", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (ef->ef_symtab == NULL) {
+ warnx("%s: did not find a dynamic symbol table", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (nsym != ef->ef_nchains) {
+ warnx("%s: symbol count mismatch", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (ef->ef_strtab == NULL) {
+ warnx("%s: did not find a dynamic string table", ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (rel_off != 0 && ef->ef_rel == NULL) {
+ warnx("%s: did not find a DT_REL relocation table",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+ if (rela_off != 0 && ef->ef_rela == NULL) {
+ warnx("%s: did not find a DT_RELA relocation table",
+ ef->ef_name);
+ error = EFTYPE;
+ goto out;
+ }
+
+ error = 0;
+out:
+ free(dyn);
+ free(shdr);
+ return (error);
+}
+
+static int
+ef_seg_read_rel(elf_file_t ef, GElf_Addr address, size_t len, void *dest)
+{
+ GElf_Off ofs;
+ const GElf_Rela *a;
+ const GElf_Rel *r;
+ int error;
+
+ ofs = ef_get_offset(ef, address);
+ if (ofs == 0) {
+ if (ef->ef_verbose)
+ warnx("ef_seg_read_rel(%s): bad address (%jx)",
+ ef->ef_name, (uintmax_t)address);
+ return (EFAULT);
+ }
+ error = elf_read_raw_data(ef->ef_efile, ofs, dest, len);
+ if (error != 0)
+ return (error);
+
+ for (r = ef->ef_rel; r < &ef->ef_rel[ef->ef_relsz]; r++) {
+ error = elf_reloc(ef->ef_efile, r, ELF_T_REL, 0, address,
+ len, dest);
+ if (error != 0)
+ return (error);
+ }
+ for (a = ef->ef_rela; a < &ef->ef_rela[ef->ef_relasz]; a++) {
+ error = elf_reloc(ef->ef_efile, a, ELF_T_RELA, 0, address,
+ len, dest);
+ if (error != 0)
+ return (error);
+ }
+ return (0);
+}
+
+static int
+ef_seg_read_string(elf_file_t ef, GElf_Addr address, size_t len, char *dest)
+{
+ GElf_Off ofs;
+
+ ofs = ef_get_offset(ef, address);
+ if (ofs == 0) {
+ if (ef->ef_verbose)
+ warnx("ef_seg_read_string(%s): bad offset (%jx:%ju)",
+ ef->ef_name, (uintmax_t)address, (uintmax_t)ofs);
+ return (EFAULT);
+ }
+
+ return (elf_read_raw_string(ef->ef_efile, ofs, dest, len));
+}
+
+int
+ef_open(struct elf_file *efile, int verbose)
+{
+ elf_file_t ef;
+ GElf_Ehdr *hdr;
+ size_t i, nphdr, nsegs;
+ int error;
+ GElf_Phdr *phdr, *phdyn;
+
+ hdr = &efile->ef_hdr;
+ if (hdr->e_phnum == 0 ||
+ hdr->e_phentsize != elf_object_size(efile, ELF_T_PHDR) ||
+ hdr->e_shnum == 0 || hdr->e_shoff == 0 ||
+ hdr->e_shentsize != elf_object_size(efile, ELF_T_SHDR))
+ return (EFTYPE);
+
+ ef = malloc(sizeof(*ef));
+ if (ef == NULL)
+ return (errno);
+
+ efile->ef_ef = ef;
+ efile->ef_ops = &ef_file_ops;
+
+ bzero(ef, sizeof(*ef));
+ ef->ef_verbose = verbose;
+ ef->ef_name = strdup(efile->ef_filename);
+ ef->ef_efile = efile;
+
+ error = elf_read_phdrs(efile, &nphdr, &ef->ef_ph);
+ if (error != 0) {
+ phdr = NULL;
+ goto out;
+ }
+
+ error = EFTYPE;
+ nsegs = 0;
+ phdyn = NULL;
+ phdr = ef->ef_ph;
+ for (i = 0; i < nphdr; i++, phdr++) {
+ if (verbose > 1)
+ ef_print_phdr(phdr);
+ switch (phdr->p_type) {
+ case PT_LOAD:
+ if (nsegs < MAXSEGS)
+ ef->ef_segs[nsegs] = phdr;
+ nsegs++;
+ break;
+ case PT_PHDR:
+ break;
+ case PT_DYNAMIC:
+ phdyn = phdr;
+ break;
+ }
+ }
+ if (verbose > 1)
+ printf("\n");
+ if (phdyn == NULL) {
+ warnx("Skipping %s: not dynamically-linked",
+ ef->ef_name);
+ goto out;
+ }
+
+ if (nsegs > MAXSEGS) {
+ warnx("%s: too many segments", ef->ef_name);
+ goto out;
+ }
+ ef->ef_nsegs = nsegs;
+
+ error = ef_parse_dynamic(ef, phdyn);
+out:
+ if (error != 0)
+ ef_close(ef);
+ return (error);
+}
+
+static void
+ef_close(elf_file_t ef)
+{
+ free(ef->ef_rela);
+ free(ef->ef_rel);
+ free(ef->ef_strtab);
+ free(ef->ef_symtab);
+ free(ef->ef_hashtab);
+ free(ef->ef_ph);
+ if (ef->ef_name)
+ free(ef->ef_name);
+ ef->ef_efile->ef_ops = NULL;
+ ef->ef_efile->ef_ef = NULL;
+ free(ef);
+}
diff --git a/lib/libkldelf/ef_aarch64.c b/lib/libkldelf/ef_aarch64.c
new file mode 100644
index 000000000000..d2db29f22891
--- /dev/null
+++ b/lib/libkldelf/ef_aarch64.c
@@ -0,0 +1,81 @@
+/*-
+ * Copyright (c) 2005 Peter Grehan.
+ * Copyright 1996-1998 John D. Polstra.
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_aarch64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ switch (rtype) {
+ case R_AARCH64_RELATIVE:
+ addr = relbase + addend;
+ le64enc(where, addr);
+ break;
+ case R_AARCH64_ABS64:
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le64enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ break;
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_AARCH64, ef_aarch64_reloc);
diff --git a/lib/libkldelf/ef_amd64.c b/lib/libkldelf/ef_amd64.c
new file mode 100644
index 000000000000..7295835f75b3
--- /dev/null
+++ b/lib/libkldelf/ef_amd64.c
@@ -0,0 +1,113 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Jake Burkholder.
+ * Copyright 1996-1998 John D. Polstra.
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_amd64_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
+ addend = 0;
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
+ break;
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ if (reltype == ELF_T_REL) {
+ /* Addend is 32 bit on 32 bit relocs */
+ switch (rtype) {
+ case R_X86_64_PC32:
+ case R_X86_64_32S:
+ addend = le32dec(where);
+ break;
+ default:
+ addend = le64dec(where);
+ break;
+ }
+ }
+
+ switch (rtype) {
+ case R_X86_64_NONE: /* none */
+ break;
+ case R_X86_64_64: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le64enc(where, addr);
+ break;
+ case R_X86_64_32S: /* S + A sign extend */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le32enc(where, addr);
+ break;
+ case R_X86_64_GLOB_DAT: /* S */
+ addr = EF_SYMADDR(ef, symidx);
+ le64enc(where, addr);
+ break;
+ case R_X86_64_RELATIVE: /* B + A */
+ addr = relbase + addend;
+ le64enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_X86_64, ef_amd64_reloc);
diff --git a/lib/libkldelf/ef_arm.c b/lib/libkldelf/ef_arm.c
new file mode 100644
index 000000000000..657294dc9fb0
--- /dev/null
+++ b/lib/libkldelf/ef_arm.c
@@ -0,0 +1,94 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Jake Burkholder.
+ * Copyright 1996-1998 John D. Polstra.
+ * All rights reserved.
+ * Copyright (c) 2023 Jessica Clarke <jrtc27@FreeBSD.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.
+ *
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_arm_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
+ addend = 0;
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
+ break;
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ if (reltype == ELF_T_REL)
+ addend = le32dec(where);
+
+ switch (rtype) {
+ case R_ARM_ABS32: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le32enc(where, addr);
+ break;
+ case R_ARM_RELATIVE: /* B + A */
+ addr = relbase + addend;
+ le32enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2LSB, EM_ARM, ef_arm_reloc);
diff --git a/lib/libkldelf/ef_i386.c b/lib/libkldelf/ef_i386.c
new file mode 100644
index 000000000000..ae571e2d50f2
--- /dev/null
+++ b/lib/libkldelf/ef_i386.c
@@ -0,0 +1,97 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Jake Burkholder.
+ * Copyright 1996-1998 John D. Polstra.
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_i386_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
+ addend = 0;
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
+ break;
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ if (reltype == ELF_T_REL)
+ addend = le32dec(where);
+
+ switch (rtype) {
+ case R_386_RELATIVE: /* B + A */
+ addr = relbase + addend;
+ le32enc(where, addr);
+ break;
+ case R_386_32: /* S + A - P */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le32enc(where, addr);
+ break;
+ case R_386_GLOB_DAT: /* S */
+ addr = EF_SYMADDR(ef, symidx);
+ le32enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2LSB, EM_386, ef_i386_reloc);
diff --git a/lib/libkldelf/ef_mips.c b/lib/libkldelf/ef_mips.c
new file mode 100644
index 000000000000..99790e11a9c3
--- /dev/null
+++ b/lib/libkldelf/ef_mips.c
@@ -0,0 +1,116 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 John Baldwin <jhb@FreeBSD.org>
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory (Department of Computer Science and
+ * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
+ * DARPA SSITH research programme.
+ *
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_mips_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rel *rel;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_REL:
+ rel = (const GElf_Rel *)reldata;
+ where = (char *)dest + (relbase + rel->r_offset - dataoff);
+ addend = 0;
+ rtype = GELF_R_TYPE(rel->r_info);
+ symidx = GELF_R_SYM(rel->r_info);
+ break;
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ if (reltype == ELF_T_REL) {
+ if (elf_class(ef) == ELFCLASS64) {
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ addend = le64dec(where);
+ else
+ addend = be64dec(where);
+ } else {
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ addend = le32dec(where);
+ else
+ addend = be32dec(where);
+ }
+ }
+
+ switch (rtype) {
+ case R_MIPS_64: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le64enc(where, addr);
+ else
+ be64enc(where, addr);
+ break;
+ case R_MIPS_32: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le32enc(where, addr);
+ else
+ be32enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2LSB, EM_MIPS, ef_mips_reloc);
+ELF_RELOC(ELFCLASS32, ELFDATA2MSB, EM_MIPS, ef_mips_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_MIPS, ef_mips_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2MSB, EM_MIPS, ef_mips_reloc);
diff --git a/lib/libkldelf/ef_obj.c b/lib/libkldelf/ef_obj.c
new file mode 100644
index 000000000000..151bac74b17d
--- /dev/null
+++ b/lib/libkldelf/ef_obj.c
@@ -0,0 +1,474 @@
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 2000, Boris Popov
+ * Copyright (c) 1998-2000 Doug Rabson
+ * Copyright (c) 2004 Peter Wemm
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Boris Popov.
+ * 4. 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 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.
+ */
+
+#include <sys/param.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "kldelf.h"
+
+typedef struct {
+ GElf_Addr addr;
+ GElf_Off offset;
+ GElf_Off size;
+ int flags;
+ int sec; /* Original section */
+ char *name;
+} Elf_progent;
+
+typedef struct {
+ GElf_Rel *rel;
+ long nrel;
+ int sec;
+} Elf_relent;
+
+typedef struct {
+ GElf_Rela *rela;
+ long nrela;
+ int sec;
+} Elf_relaent;
+
+struct ef_file {
+ char *ef_name;
+ struct elf_file *ef_efile;
+
+ Elf_progent *progtab;
+ int nprogtab;
+
+ Elf_relaent *relatab;
+ int nrela;
+
+ Elf_relent *reltab;
+ int nrel;
+
+ GElf_Sym *ddbsymtab; /* The symbol table we are using */
+ size_t ddbsymcnt; /* Number of symbols */
+ caddr_t ddbstrtab; /* String table */
+ long ddbstrcnt; /* number of bytes in string table */
+
+ caddr_t shstrtab; /* Section name string table */
+ long shstrcnt; /* number of bytes in string table */
+
+ int ef_verbose;
+};
+
+static void ef_obj_close(elf_file_t ef);
+
+static int ef_obj_seg_read_rel(elf_file_t ef, GElf_Addr address,
+ size_t len, void *dest);
+static int ef_obj_seg_read_string(elf_file_t ef, GElf_Addr address,
+ size_t len, char *dest);
+
+static GElf_Addr ef_obj_symaddr(elf_file_t ef, GElf_Size symidx);
+static int ef_obj_lookup_set(elf_file_t ef, const char *name,
+ GElf_Addr *startp, GElf_Addr *stopp, long *countp);
+static int ef_obj_lookup_symbol(elf_file_t ef, const char *name,
+ GElf_Sym **sym, bool see_local);
+
+static struct elf_file_ops ef_obj_file_ops = {
+ .close = ef_obj_close,
+ .seg_read_rel = ef_obj_seg_read_rel,
+ .seg_read_string = ef_obj_seg_read_string,
+ .symaddr = ef_obj_symaddr,
+ .lookup_set = ef_obj_lookup_set,
+ .lookup_symbol = ef_obj_lookup_symbol,
+};
+
+static GElf_Off
+ef_obj_get_offset(elf_file_t ef, GElf_Addr addr)
+{
+ Elf_progent *pt;
+ int i;
+
+ for (i = 0; i < ef->nprogtab; i++) {
+ pt = &ef->progtab[i];
+ if (pt->offset == (GElf_Off)-1)
+ continue;
+ if (addr >= pt->addr && addr < pt->addr + pt->size)
+ return (pt->offset + (addr - pt->addr));
+ }
+ return (0);
+}
+
+static int
+ef_obj_lookup_symbol(elf_file_t ef, const char *name, GElf_Sym **sym,
+ bool see_local)
+{
+ GElf_Sym *symp;
+ const char *strp;
+ int i;
+
+ for (i = 0, symp = ef->ddbsymtab; i < ef->ddbsymcnt; i++, symp++) {
+ strp = ef->ddbstrtab + symp->st_name;
+ if (symp->st_shndx != SHN_UNDEF && strcmp(name, strp) == 0) {
+ if (see_local ||
+ GELF_ST_BIND(symp->st_info) != STB_LOCAL) {
+ *sym = symp;
+ return (0);
+ }
+ }
+ }
+ return (ENOENT);
+}
+
+static int
+ef_obj_lookup_set(elf_file_t ef, const char *name, GElf_Addr *startp,
+ GElf_Addr *stopp, long *countp)
+{
+ int i;
+
+ for (i = 0; i < ef->nprogtab; i++) {
+ if ((strncmp(ef->progtab[i].name, "set_", 4) == 0) &&
+ strcmp(ef->progtab[i].name + 4, name) == 0) {
+ *startp = ef->progtab[i].addr;
+ *stopp = ef->progtab[i].addr + ef->progtab[i].size;
+ *countp = (*stopp - *startp) /
+ elf_pointer_size(ef->ef_efile);
+ return (0);
+ }
+ }
+ return (ESRCH);
+}
+
+static GElf_Addr
+ef_obj_symaddr(elf_file_t ef, GElf_Size symidx)
+{
+ const GElf_Sym *sym;
+
+ if (symidx >= ef->ddbsymcnt)
+ return (0);
+ sym = ef->ddbsymtab + symidx;
+
+ if (sym->st_shndx != SHN_UNDEF)
+ return (sym->st_value);
+ return (0);
+}
+
+static int
+ef_obj_seg_read_rel(elf_file_t ef, GElf_Addr address, size_t len, void *dest)
+{
+ GElf_Off secofs;
+ GElf_Rel *r;
+ GElf_Rela *a;
+ GElf_Addr secbase, dataoff;
+ int error, i, sec;
+
+ /* Find out which section contains the data. */
+ sec = -1;
+ for (i = 0; i < ef->nprogtab; i++) {
+ if (address < ef->progtab[i].addr)
+ continue;
+
+ dataoff = address - ef->progtab[i].addr;
+ if (dataoff + len > ef->progtab[i].size)
+ continue;
+
+ sec = ef->progtab[i].sec;
+ secbase = ef->progtab[i].addr;
+ secofs = ef->progtab[i].offset;
+ break;
+ }
+
+ if (sec == -1) {
+ if (ef->ef_verbose)
+ warnx("ef_obj_seg_read_rel(%s): bad address (%jx)",
+ ef->ef_name, (uintmax_t)address);
+ return (EFAULT);
+ }
+
+ if (secofs == (GElf_Off)-1) {
+ memset(dest, 0, len);
+ } else {
+ error = elf_read_raw_data(ef->ef_efile, secofs + dataoff, dest,
+ len);
+ if (error != 0)
+ return (error);
+ }
+
+ /* Now do the relocations. */
+ for (i = 0; i < ef->nrel; i++) {
+ if (ef->reltab[i].sec != sec)
+ continue;
+ for (r = ef->reltab[i].rel;
+ r < &ef->reltab[i].rel[ef->reltab[i].nrel]; r++) {
+ error = elf_reloc(ef->ef_efile, r, ELF_T_REL, secbase,
+ address, len, dest);
+ if (error != 0)
+ return (error);
+ }
+ }
+ for (i = 0; i < ef->nrela; i++) {
+ if (ef->relatab[i].sec != sec)
+ continue;
+ for (a = ef->relatab[i].rela;
+ a < &ef->relatab[i].rela[ef->relatab[i].nrela]; a++) {
+ error = elf_reloc(ef->ef_efile, a, ELF_T_RELA, secbase,
+ address, len, dest);
+ if (error != 0)
+ return (error);
+ }
+ }
+ return (0);
+}
+
+static int
+ef_obj_seg_read_string(elf_file_t ef, GElf_Addr address, size_t len, char *dest)
+{
+ GElf_Off ofs;
+
+ ofs = ef_obj_get_offset(ef, address);
+ if (ofs == 0) {
+ if (ef->ef_verbose)
+ warnx("ef_obj_seg_read_string(%s): bad address (%jx)",
+ ef->ef_name, (uintmax_t)address);
+ return (EFAULT);
+ }
+
+ return (elf_read_raw_string(ef->ef_efile, ofs, dest, len));
+}
+
+int
+ef_obj_open(struct elf_file *efile, int verbose)
+{
+ elf_file_t ef;
+ GElf_Ehdr *hdr;
+ GElf_Shdr *shdr;
+ GElf_Sym *es;
+ GElf_Addr mapbase;
+ size_t i, nshdr;
+ int error, pb, ra, rl;
+ int j, nsym, symstrindex, symtabindex;
+
+ hdr = &efile->ef_hdr;
+ if (hdr->e_type != ET_REL || hdr->e_shnum == 0 || hdr->e_shoff == 0 ||
+ hdr->e_shentsize != elf_object_size(efile, ELF_T_SHDR))
+ return (EFTYPE);
+
+ ef = calloc(1, sizeof(*ef));
+ if (ef == NULL)
+ return (errno);
+
+ efile->ef_ef = ef;
+ efile->ef_ops = &ef_obj_file_ops;
+
+ ef->ef_verbose = verbose;
+ ef->ef_name = strdup(efile->ef_filename);
+ ef->ef_efile = efile;
+
+ error = elf_read_shdrs(efile, &nshdr, &shdr);
+ if (error != 0) {
+ shdr = NULL;
+ goto out;
+ }
+
+ /* Scan the section headers for information and table sizing. */
+ nsym = 0;
+ symtabindex = -1;
+ symstrindex = -1;
+ for (i = 0; i < nshdr; i++) {
+ switch (shdr[i].sh_type) {
+ case SHT_PROGBITS:
+ case SHT_NOBITS:
+ ef->nprogtab++;
+ break;
+ case SHT_SYMTAB:
+ nsym++;
+ symtabindex = i;
+ symstrindex = shdr[i].sh_link;
+ break;
+ case SHT_REL:
+ ef->nrel++;
+ break;
+ case SHT_RELA:
+ ef->nrela++;
+ break;
+ case SHT_STRTAB:
+ break;
+ }
+ }
+
+ if (ef->nprogtab == 0) {
+ warnx("%s: file has no contents", ef->ef_name);
+ goto out;
+ }
+ if (nsym != 1) {
+ warnx("%s: file has no valid symbol table", ef->ef_name);
+ goto out;
+ }
+ if (symstrindex < 0 || symstrindex > nshdr ||
+ shdr[symstrindex].sh_type != SHT_STRTAB) {
+ warnx("%s: file has invalid symbol strings", ef->ef_name);
+ goto out;
+ }
+
+ /* Allocate space for tracking the load chunks */
+ if (ef->nprogtab != 0)
+ ef->progtab = calloc(ef->nprogtab, sizeof(*ef->progtab));
+ if (ef->nrel != 0)
+ ef->reltab = calloc(ef->nrel, sizeof(*ef->reltab));
+ if (ef->nrela != 0)
+ ef->relatab = calloc(ef->nrela, sizeof(*ef->relatab));
+ if ((ef->nprogtab != 0 && ef->progtab == NULL) ||
+ (ef->nrel != 0 && ef->reltab == NULL) ||
+ (ef->nrela != 0 && ef->relatab == NULL)) {
+ warnx("malloc failed");
+ error = ENOMEM;
+ goto out;
+ }
+
+ if (elf_read_symbols(efile, symtabindex, &ef->ddbsymcnt,
+ &ef->ddbsymtab) != 0) {
+ warnx("elf_read_symbols failed");
+ goto out;
+ }
+
+ if (elf_read_string_table(efile, &shdr[symstrindex], &ef->ddbstrcnt,
+ &ef->ddbstrtab) != 0) {
+ warnx("elf_read_string_table failed");
+ goto out;
+ }
+
+ /* Do we have a string table for the section names? */
+ if (hdr->e_shstrndx != 0 &&
+ shdr[hdr->e_shstrndx].sh_type == SHT_STRTAB) {
+ if (elf_read_string_table(efile, &shdr[hdr->e_shstrndx],
+ &ef->shstrcnt, &ef->shstrtab) != 0) {
+ warnx("elf_read_string_table failed");
+ goto out;
+ }
+ }
+
+ /*
+ * Now allocate address space for code/data(progbits) and
+ * bss(nobits) and allocate space for and load relocs.
+ */
+ pb = 0;
+ rl = 0;
+ ra = 0;
+ mapbase = 0;
+ for (i = 0; i < nshdr; i++) {
+ switch (shdr[i].sh_type) {
+ case SHT_PROGBITS:
+ case SHT_NOBITS:
+ mapbase = roundup2(mapbase, shdr[i].sh_addralign);
+ ef->progtab[pb].addr = mapbase;
+ if (shdr[i].sh_type == SHT_PROGBITS) {
+ ef->progtab[pb].name = "<<PROGBITS>>";
+ ef->progtab[pb].offset = shdr[i].sh_offset;
+ } else {
+ ef->progtab[pb].name = "<<NOBITS>>";
+ ef->progtab[pb].offset = (GElf_Off)-1;
+ }
+ ef->progtab[pb].size = shdr[i].sh_size;
+ ef->progtab[pb].sec = i;
+ if (ef->shstrtab && shdr[i].sh_name != 0)
+ ef->progtab[pb].name =
+ ef->shstrtab + shdr[i].sh_name;
+
+ /* Update all symbol values with the offset. */
+ for (j = 0; j < ef->ddbsymcnt; j++) {
+ es = &ef->ddbsymtab[j];
+ if (es->st_shndx != i)
+ continue;
+ es->st_value += ef->progtab[pb].addr;
+ }
+ mapbase += shdr[i].sh_size;
+ pb++;
+ break;
+ case SHT_REL:
+ ef->reltab[rl].sec = shdr[i].sh_info;
+ if (elf_read_rel(efile, i, &ef->reltab[rl].nrel,
+ &ef->reltab[rl].rel) != 0) {
+ warnx("elf_read_rel failed");
+ goto out;
+ }
+ rl++;
+ break;
+ case SHT_RELA:
+ ef->relatab[ra].sec = shdr[i].sh_info;
+ if (elf_read_rela(efile, i, &ef->relatab[ra].nrela,
+ &ef->relatab[ra].rela) != 0) {
+ warnx("elf_read_rela failed");
+ goto out;
+ }
+ ra++;
+ break;
+ }
+ }
+ error = 0;
+out:
+ free(shdr);
+ if (error != 0)
+ ef_obj_close(ef);
+ return (error);
+}
+
+static void
+ef_obj_close(elf_file_t ef)
+{
+ int i;
+
+ if (ef->ef_name)
+ free(ef->ef_name);
+ if (ef->nprogtab != 0)
+ free(ef->progtab);
+ if (ef->nrel != 0) {
+ for (i = 0; i < ef->nrel; i++)
+ if (ef->reltab[i].rel != NULL)
+ free(ef->reltab[i].rel);
+ free(ef->reltab);
+ }
+ if (ef->nrela != 0) {
+ for (i = 0; i < ef->nrela; i++)
+ if (ef->relatab[i].rela != NULL)
+ free(ef->relatab[i].rela);
+ free(ef->relatab);
+ }
+ if (ef->ddbsymtab != NULL)
+ free(ef->ddbsymtab);
+ if (ef->ddbstrtab != NULL)
+ free(ef->ddbstrtab);
+ if (ef->shstrtab != NULL)
+ free(ef->shstrtab);
+ ef->ef_efile->ef_ops = NULL;
+ ef->ef_efile->ef_ef = NULL;
+ free(ef);
+}
diff --git a/lib/libkldelf/ef_powerpc.c b/lib/libkldelf/ef_powerpc.c
new file mode 100644
index 000000000000..33f09c0d69ef
--- /dev/null
+++ b/lib/libkldelf/ef_powerpc.c
@@ -0,0 +1,97 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2005 Peter Grehan.
+ * Copyright 1996-1998 John D. Polstra.
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_ppc_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ switch (rtype) {
+ case R_PPC_RELATIVE: /* word32|doubleword64 B + A */
+ addr = relbase + addend;
+ if (elf_class(ef) == ELFCLASS64) {
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le64enc(where, addr);
+ else
+ be64enc(where, addr);
+ } else
+ be32enc(where, addr);
+ break;
+ case R_PPC_ADDR32: /* word32 S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ be32enc(where, addr);
+ break;
+ case R_PPC64_ADDR64: /* doubleword64 S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ if (elf_encoding(ef) == ELFDATA2LSB)
+ le64enc(where, addr);
+ else
+ be64enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS32, ELFDATA2MSB, EM_PPC, ef_ppc_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_PPC64, ef_ppc_reloc);
+ELF_RELOC(ELFCLASS64, ELFDATA2MSB, EM_PPC64, ef_ppc_reloc);
diff --git a/lib/libkldelf/ef_riscv.c b/lib/libkldelf/ef_riscv.c
new file mode 100644
index 000000000000..bda04bb2c39a
--- /dev/null
+++ b/lib/libkldelf/ef_riscv.c
@@ -0,0 +1,85 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2018 John Baldwin <jhb@FreeBSD.org>
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory (Department of Computer Science and
+ * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
+ * DARPA SSITH research programme.
+ *
+ * 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.
+ */
+
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <gelf.h>
+
+#include "kldelf.h"
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+static int
+ef_riscv_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ char *where;
+ GElf_Addr addr, addend;
+ GElf_Size rtype, symidx;
+ const GElf_Rela *rela;
+
+ switch (reltype) {
+ case ELF_T_RELA:
+ rela = (const GElf_Rela *)reldata;
+ where = (char *)dest + (relbase + rela->r_offset - dataoff);
+ addend = rela->r_addend;
+ rtype = GELF_R_TYPE(rela->r_info);
+ symidx = GELF_R_SYM(rela->r_info);
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ if (where < (char *)dest || where >= (char *)dest + len)
+ return (0);
+
+ switch (rtype) {
+ case R_RISCV_64: /* S + A */
+ addr = EF_SYMADDR(ef, symidx) + addend;
+ le64enc(where, addr);
+ break;
+ case R_RISCV_RELATIVE: /* B + A */
+ addr = relbase + addend;
+ le64enc(where, addr);
+ break;
+ default:
+ warnx("unhandled relocation type %d", (int)rtype);
+ }
+ return (0);
+}
+
+ELF_RELOC(ELFCLASS64, ELFDATA2LSB, EM_RISCV, ef_riscv_reloc);
diff --git a/lib/libkldelf/elf.c b/lib/libkldelf/elf.c
new file mode 100644
index 000000000000..cf43d9bfd5fd
--- /dev/null
+++ b/lib/libkldelf/elf.c
@@ -0,0 +1,695 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2021-2023 John Baldwin <jhb@FreeBSD.org>
+ *
+ * This software was developed by SRI International and the University
+ * of Cambridge Computer Laboratory (Department of Computer Science
+ * and Technology) under Defense Advanced Research Projects Agency
+ * (DARPA) contract HR0011-18-C-0016 ("ECATS"), as part of the DARPA
+ * SSITH research programme and under DARPA Contract No. HR001123C0031
+ * ("MTSS").
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/endian.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gelf.h>
+#include <libelf.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "kldelf.h"
+
+SET_DECLARE(elf_reloc, struct elf_reloc_data);
+
+static elf_reloc_t *
+elf_find_reloc(const GElf_Ehdr *hdr)
+{
+ struct elf_reloc_data **erd;
+
+ SET_FOREACH(erd, elf_reloc) {
+ if (hdr->e_ident[EI_CLASS] == (*erd)->class &&
+ hdr->e_ident[EI_DATA] == (*erd)->data &&
+ hdr->e_machine == (*erd)->machine)
+ return ((*erd)->reloc);
+ }
+ return (NULL);
+}
+
+int
+elf_open_file(struct elf_file *efile, const char *filename, int verbose)
+{
+ int error;
+
+ memset(efile, 0, sizeof(*efile));
+ efile->ef_filename = filename;
+ efile->ef_fd = open(filename, O_RDONLY);
+ if (efile->ef_fd == -1) {
+ if (verbose)
+ warn("open(%s)", filename);
+ return (errno);
+ }
+
+ efile->ef_elf = elf_begin(efile->ef_fd, ELF_C_READ, NULL);
+ if (efile->ef_elf == NULL) {
+ if (verbose)
+ warnx("elf_begin(%s): %s", filename, elf_errmsg(0));
+ elf_close_file(efile);
+ return (EINVAL);
+ }
+
+ if (elf_kind(efile->ef_elf) != ELF_K_ELF) {
+ if (verbose)
+ warnx("%s: not an ELF file", filename);
+ elf_close_file(efile);
+ return (EINVAL);
+ }
+
+ if (gelf_getehdr(efile->ef_elf, &efile->ef_hdr) == NULL) {
+ if (verbose)
+ warnx("gelf_getehdr(%s): %s", filename, elf_errmsg(0));
+ elf_close_file(efile);
+ return (EINVAL);
+ }
+
+ efile->ef_reloc = elf_find_reloc(&efile->ef_hdr);
+ if (efile->ef_reloc == NULL) {
+ if (verbose)
+ warnx("%s: unsupported architecture", filename);
+ elf_close_file(efile);
+ return (EFTYPE);
+ }
+
+ error = ef_open(efile, verbose);
+ if (error != 0) {
+ error = ef_obj_open(efile, verbose);
+ if (error != 0) {
+ if (verbose)
+ warnc(error, "%s: not a valid DSO or object file",
+ filename);
+ elf_close_file(efile);
+ return (error);
+ }
+ }
+
+ efile->ef_pointer_size = elf_object_size(efile, ELF_T_ADDR);
+
+ return (0);
+}
+
+void
+elf_close_file(struct elf_file *efile)
+{
+ if (efile->ef_ops != NULL) {
+ EF_CLOSE(efile);
+ }
+ if (efile->ef_elf != NULL) {
+ elf_end(efile->ef_elf);
+ efile->ef_elf = NULL;
+ }
+ if (efile->ef_fd > 0) {
+ close(efile->ef_fd);
+ efile->ef_fd = -1;
+ }
+}
+
+bool
+elf_compatible(struct elf_file *efile, const GElf_Ehdr *hdr)
+{
+ if (efile->ef_hdr.e_ident[EI_CLASS] != hdr->e_ident[EI_CLASS] ||
+ efile->ef_hdr.e_ident[EI_DATA] != hdr->e_ident[EI_DATA] ||
+ efile->ef_hdr.e_machine != hdr->e_machine)
+ return (false);
+ return (true);
+}
+
+size_t
+elf_object_size(struct elf_file *efile, Elf_Type type)
+{
+ return (gelf_fsize(efile->ef_elf, type, 1, efile->ef_hdr.e_version));
+}
+
+/*
+ * The number of objects of 'type' in region of the file of size
+ * 'file_size'.
+ */
+static size_t
+elf_object_count(struct elf_file *efile, Elf_Type type, size_t file_size)
+{
+ return (file_size / elf_object_size(efile, type));
+}
+
+int
+elf_read_raw_data(struct elf_file *efile, off_t offset, void *dst, size_t len)
+{
+ ssize_t nread;
+
+ nread = pread(efile->ef_fd, dst, len, offset);
+ if (nread == -1)
+ return (errno);
+ if (nread != len)
+ return (EIO);
+ return (0);
+}
+
+int
+elf_read_raw_data_alloc(struct elf_file *efile, off_t offset, size_t len,
+ void **out)
+{
+ void *buf;
+ int error;
+
+ buf = malloc(len);
+ if (buf == NULL)
+ return (ENOMEM);
+ error = elf_read_raw_data(efile, offset, buf, len);
+ if (error != 0) {
+ free(buf);
+ return (error);
+ }
+ *out = buf;
+ return (0);
+}
+
+int
+elf_read_raw_string(struct elf_file *efile, off_t offset, char *dst, size_t len)
+{
+ ssize_t nread;
+
+ nread = pread(efile->ef_fd, dst, len, offset);
+ if (nread == -1)
+ return (errno);
+ if (nread == 0)
+ return (EIO);
+
+ /* A short read is ok so long as the data contains a terminator. */
+ if (strnlen(dst, nread) == nread)
+ return (EFAULT);
+
+ return (0);
+}
+
+int
+elf_read_data(struct elf_file *efile, Elf_Type type, off_t offset, size_t len,
+ void **out)
+{
+ Elf_Data dst, src;
+ void *buf;
+ int error;
+
+ buf = malloc(len);
+ if (buf == NULL)
+ return (ENOMEM);
+
+ error = elf_read_raw_data(efile, offset, buf, len);
+ if (error != 0) {
+ free(buf);
+ return (error);
+ }
+
+ memset(&dst, 0, sizeof(dst));
+ memset(&src, 0, sizeof(src));
+
+ src.d_buf = buf;
+ src.d_size = len;
+ src.d_type = type;
+ src.d_version = efile->ef_hdr.e_version;
+
+ dst.d_buf = buf;
+ dst.d_size = len;
+ dst.d_version = EV_CURRENT;
+
+ if (gelf_xlatetom(efile->ef_elf, &dst, &src, elf_encoding(efile)) ==
+ NULL) {
+ free(buf);
+ return (ENXIO);
+ }
+
+ if (dst.d_size != len)
+ warnx("elf_read_data: translation of type %u size mismatch",
+ type);
+
+ *out = buf;
+ return (0);
+}
+
+int
+elf_read_relocated_data(struct elf_file *efile, GElf_Addr address, size_t len,
+ void **buf)
+{
+ int error;
+ void *p;
+
+ p = malloc(len);
+ if (p == NULL)
+ return (ENOMEM);
+ error = EF_SEG_READ_REL(efile, address, len, p);
+ if (error != 0) {
+ free(p);
+ return (error);
+ }
+ *buf = p;
+ return (0);
+}
+
+int
+elf_read_phdrs(struct elf_file *efile, size_t *nphdrp, GElf_Phdr **phdrp)
+{
+ GElf_Phdr *phdr;
+ size_t nphdr, i;
+ int error;
+
+ if (elf_getphdrnum(efile->ef_elf, &nphdr) == -1)
+ return (EFTYPE);
+
+ phdr = calloc(nphdr, sizeof(*phdr));
+ if (phdr == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nphdr; i++) {
+ if (gelf_getphdr(efile->ef_elf, i, &phdr[i]) == NULL) {
+ error = EFTYPE;
+ goto out;
+ }
+ }
+
+ *nphdrp = nphdr;
+ *phdrp = phdr;
+ return (0);
+out:
+ free(phdr);
+ return (error);
+}
+
+int
+elf_read_shdrs(struct elf_file *efile, size_t *nshdrp, GElf_Shdr **shdrp)
+{
+ GElf_Shdr *shdr;
+ Elf_Scn *scn;
+ size_t nshdr, i;
+ int error;
+
+ if (elf_getshdrnum(efile->ef_elf, &nshdr) == -1)
+ return (EFTYPE);
+
+ shdr = calloc(nshdr, sizeof(*shdr));
+ if (shdr == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nshdr; i++) {
+ scn = elf_getscn(efile->ef_elf, i);
+ if (scn == NULL) {
+ error = EFTYPE;
+ goto out;
+ }
+ if (gelf_getshdr(scn, &shdr[i]) == NULL) {
+ error = EFTYPE;
+ goto out;
+ }
+ }
+
+ *nshdrp = nshdr;
+ *shdrp = shdr;
+ return (0);
+out:
+ free(shdr);
+ return (error);
+}
+
+int
+elf_read_dynamic(struct elf_file *efile, int section_index, size_t *ndynp,
+ GElf_Dyn **dynp)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Dyn *dyn;
+ long i, ndyn;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ ndyn = elf_object_count(efile, ELF_T_DYN, shdr.sh_size);
+ dyn = calloc(ndyn, sizeof(*dyn));
+ if (dyn == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < ndyn; i++) {
+ if (gelf_getdyn(data, i, &dyn[i]) == NULL) {
+ free(dyn);
+ return (EINVAL);
+ }
+ }
+
+ *ndynp = ndyn;
+ *dynp = dyn;
+ return (0);
+}
+
+int
+elf_read_symbols(struct elf_file *efile, int section_index, size_t *nsymp,
+ GElf_Sym **symp)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Sym *sym;
+ size_t i, nsym;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ nsym = elf_object_count(efile, ELF_T_SYM, shdr.sh_size);
+ sym = calloc(nsym, sizeof(*sym));
+ if (sym == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nsym; i++) {
+ if (gelf_getsym(data, i, &sym[i]) == NULL) {
+ free(sym);
+ return (EINVAL);
+ }
+ }
+
+ *nsymp = nsym;
+ *symp = sym;
+ return (0);
+}
+
+int
+elf_read_string_table(struct elf_file *efile, const GElf_Shdr *shdr,
+ long *strcnt, char **strtab)
+{
+ int error;
+
+ if (shdr->sh_type != SHT_STRTAB)
+ return (EINVAL);
+ error = elf_read_raw_data_alloc(efile, shdr->sh_offset, shdr->sh_size,
+ (void **)strtab);
+ if (error != 0)
+ return (error);
+ *strcnt = shdr->sh_size;
+ return (0);
+}
+
+int
+elf_read_rel(struct elf_file *efile, int section_index, long *nrelp,
+ GElf_Rel **relp)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Rel *rel;
+ long i, nrel;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ nrel = elf_object_count(efile, ELF_T_REL, shdr.sh_size);
+ rel = calloc(nrel, sizeof(*rel));
+ if (rel == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nrel; i++) {
+ if (gelf_getrel(data, i, &rel[i]) == NULL) {
+ free(rel);
+ return (EINVAL);
+ }
+ }
+
+ *nrelp = nrel;
+ *relp = rel;
+ return (0);
+}
+
+int
+elf_read_rela(struct elf_file *efile, int section_index, long *nrelap,
+ GElf_Rela **relap)
+{
+ GElf_Shdr shdr;
+ Elf_Scn *scn;
+ Elf_Data *data;
+ GElf_Rela *rela;
+ long i, nrela;
+
+ scn = elf_getscn(efile->ef_elf, section_index);
+ if (scn == NULL)
+ return (EINVAL);
+ if (gelf_getshdr(scn, &shdr) == NULL)
+ return (EINVAL);
+ data = elf_getdata(scn, NULL);
+ if (data == NULL)
+ return (EINVAL);
+
+ nrela = elf_object_count(efile, ELF_T_RELA, shdr.sh_size);
+ rela = calloc(nrela, sizeof(*rela));
+ if (rela == NULL)
+ return (ENOMEM);
+
+ for (i = 0; i < nrela; i++) {
+ if (gelf_getrela(data, i, &rela[i]) == NULL) {
+ free(rela);
+ return (EINVAL);
+ }
+ }
+
+ *nrelap = nrela;
+ *relap = rela;
+ return (0);
+}
+
+size_t
+elf_pointer_size(struct elf_file *efile)
+{
+ return (efile->ef_pointer_size);
+}
+
+int
+elf_int(struct elf_file *efile, const void *p)
+{
+ if (elf_encoding(efile) == ELFDATA2LSB)
+ return (le32dec(p));
+ else
+ return (be32dec(p));
+}
+
+GElf_Addr
+elf_address_from_pointer(struct elf_file *efile, const void *p)
+{
+ switch (elf_class(efile)) {
+ case ELFCLASS32:
+ if (elf_encoding(efile) == ELFDATA2LSB)
+ return (le32dec(p));
+ else
+ return (be32dec(p));
+ case ELFCLASS64:
+ if (elf_encoding(efile) == ELFDATA2LSB)
+ return (le64dec(p));
+ else
+ return (be64dec(p));
+ default:
+ __unreachable();
+ }
+}
+
+int
+elf_read_string(struct elf_file *efile, GElf_Addr address, void *dst,
+ size_t len)
+{
+ return (EF_SEG_READ_STRING(efile, address, len, dst));
+}
+
+int
+elf_read_linker_set(struct elf_file *efile, const char *name, GElf_Addr **bufp,
+ long *countp)
+{
+ GElf_Addr *buf, start, stop;
+ char *p;
+ void *raw;
+ long i, count;
+ int error;
+
+ error = EF_LOOKUP_SET(efile, name, &start, &stop, &count);
+ if (error != 0)
+ return (error);
+
+ error = elf_read_relocated_data(efile, start,
+ count * elf_pointer_size(efile), &raw);
+ if (error != 0)
+ return (error);
+
+ buf = calloc(count, sizeof(*buf));
+ if (buf == NULL) {
+ free(raw);
+ return (ENOMEM);
+ }
+
+ p = raw;
+ for (i = 0; i < count; i++) {
+ buf[i] = elf_address_from_pointer(efile, p);
+ p += elf_pointer_size(efile);
+ }
+ free(raw);
+
+ *bufp = buf;
+ *countp = count;
+ return (0);
+}
+
+int
+elf_read_mod_depend(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_depend *mdp)
+{
+ int *p;
+ int error;
+
+ error = elf_read_relocated_data(efile, addr, sizeof(int) * 3,
+ (void **)&p);
+ if (error != 0)
+ return (error);
+
+ memset(mdp, 0, sizeof(*mdp));
+ mdp->md_ver_minimum = elf_int(efile, p);
+ mdp->md_ver_preferred = elf_int(efile, p + 1);
+ mdp->md_ver_maximum = elf_int(efile, p + 2);
+ free(p);
+ return (0);
+}
+
+int
+elf_read_mod_version(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_version *mdv)
+{
+ int error, value;
+
+ error = EF_SEG_READ_REL(efile, addr, sizeof(int), &value);
+ if (error != 0)
+ return (error);
+
+ memset(mdv, 0, sizeof(*mdv));
+ mdv->mv_version = elf_int(efile, &value);
+ return (0);
+}
+
+int
+elf_read_mod_metadata(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_metadata *md)
+{
+ char *p;
+ size_t len, offset, pointer_size;
+ int error;
+
+ pointer_size = elf_pointer_size(efile);
+ len = 2 * sizeof(int);
+ len = roundup(len, pointer_size);
+ len += 2 * pointer_size;
+
+ error = elf_read_relocated_data(efile, addr, len, (void **)&p);
+ if (error != 0)
+ return (error);
+
+ memset(md, 0, sizeof(*md));
+ offset = 0;
+ md->md_version = elf_int(efile, p + offset);
+ offset += sizeof(int);
+ md->md_type = elf_int(efile, p + offset);
+ offset += sizeof(int);
+ offset = roundup(offset, pointer_size);
+ md->md_data = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ md->md_cval = elf_address_from_pointer(efile, p + offset);
+ free(p);
+ return (0);
+}
+
+int
+elf_read_mod_pnp_match_info(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_pnp_match_info *pnp)
+{
+ char *p;
+ size_t len, offset, pointer_size;
+ int error;
+
+ pointer_size = elf_pointer_size(efile);
+ len = 3 * pointer_size;
+ len = roundup(len, pointer_size);
+ len += 2 * sizeof(int);
+
+ error = elf_read_relocated_data(efile, addr, len, (void **)&p);
+ if (error != 0)
+ return (error);
+
+ memset(pnp, 0, sizeof(*pnp));
+ offset = 0;
+ pnp->descr = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ pnp->bus = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ pnp->table = elf_address_from_pointer(efile, p + offset);
+ offset += pointer_size;
+ offset = roundup(offset, pointer_size);
+ pnp->entry_len = elf_int(efile, p + offset);
+ offset += sizeof(int);
+ pnp->num_entry = elf_int(efile, p + offset);
+ free(p);
+ return (0);
+}
+
+int
+elf_reloc(struct elf_file *efile, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest)
+{
+ return (efile->ef_reloc(efile, reldata, reltype, relbase, dataoff, len,
+ dest));
+}
+
+int
+elf_lookup_symbol(struct elf_file *efile, const char *name, GElf_Sym **sym,
+ bool see_local)
+{
+ return (EF_LOOKUP_SYMBOL(efile, name, sym, see_local));
+}
diff --git a/lib/libkldelf/kldelf.h b/lib/libkldelf/kldelf.h
new file mode 100644
index 000000000000..4fb5fcc5f5aa
--- /dev/null
+++ b/lib/libkldelf/kldelf.h
@@ -0,0 +1,327 @@
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 2000, Boris Popov
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Boris Popov.
+ * 4. 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 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.
+ */
+
+#ifndef _KLDELF_H_
+#define _KLDELF_H_
+
+#include <sys/linker_set.h>
+#include <stdbool.h>
+
+#define EF_CLOSE(ef) \
+ (ef)->ef_ops->close((ef)->ef_ef)
+#define EF_SEG_READ_REL(ef, address, len, dest) \
+ (ef)->ef_ops->seg_read_rel((ef)->ef_ef, address, len, dest)
+#define EF_SEG_READ_STRING(ef, address, len, dest) \
+ (ef)->ef_ops->seg_read_string((ef)->ef_ef, address, len, dest)
+#define EF_SYMADDR(ef, symidx) \
+ (ef)->ef_ops->symaddr((ef)->ef_ef, symidx)
+#define EF_LOOKUP_SET(ef, name, startp, stopp, countp) \
+ (ef)->ef_ops->lookup_set((ef)->ef_ef, name, startp, stopp, countp)
+#define EF_LOOKUP_SYMBOL(ef, name, sym, see_local) \
+ (ef)->ef_ops->lookup_symbol((ef)->ef_ef, name, sym, see_local)
+
+/* XXX, should have a different name. */
+typedef struct ef_file *elf_file_t;
+
+/* FreeBSD's headers define additional typedef's for ELF structures. */
+typedef Elf64_Size GElf_Size;
+typedef Elf64_Hashelt GElf_Hashelt;
+
+struct elf_file;
+
+struct elf_file_ops {
+ void (*close)(elf_file_t ef);
+ int (*seg_read_rel)(elf_file_t ef, GElf_Addr address, size_t len,
+ void *dest);
+ int (*seg_read_string)(elf_file_t ef, GElf_Addr address, size_t len,
+ char *dest);
+ GElf_Addr (*symaddr)(elf_file_t ef, GElf_Size symidx);
+ int (*lookup_set)(elf_file_t ef, const char *name, GElf_Addr *startp,
+ GElf_Addr *stopp, long *countp);
+ int (*lookup_symbol)(elf_file_t ef, const char *name, GElf_Sym **sym,
+ bool see_local);
+};
+
+typedef int (elf_reloc_t)(struct elf_file *ef, const void *reldata,
+ Elf_Type reltype, GElf_Addr relbase, GElf_Addr dataoff, size_t len,
+ void *dest);
+
+struct elf_reloc_data {
+ unsigned char class;
+ unsigned char data;
+ GElf_Half machine;
+ elf_reloc_t *reloc;
+};
+
+#define ELF_RELOC(_class, _data, _machine, _reloc) \
+ static struct elf_reloc_data __CONCAT(elf_reloc_data_, __LINE__) = { \
+ .class = (_class), \
+ .data = (_data), \
+ .machine = (_machine), \
+ .reloc = (_reloc) \
+ }; \
+ DATA_SET(elf_reloc, __CONCAT(elf_reloc_data_, __LINE__))
+
+struct elf_file {
+ elf_file_t ef_ef;
+ struct elf_file_ops *ef_ops;
+ const char *ef_filename;
+ Elf *ef_elf;
+ elf_reloc_t *ef_reloc;
+ GElf_Ehdr ef_hdr;
+ size_t ef_pointer_size;
+ int ef_fd;
+};
+
+#define elf_machine(ef) ((ef)->ef_hdr.e_machine)
+#define elf_class(ef) ((ef)->ef_hdr.e_ident[EI_CLASS])
+#define elf_encoding(ef) ((ef)->ef_hdr.e_ident[EI_DATA])
+
+/*
+ * "Generic" versions of module metadata structures.
+ */
+struct Gmod_depend {
+ int md_ver_minimum;
+ int md_ver_preferred;
+ int md_ver_maximum;
+};
+
+struct Gmod_version {
+ int mv_version;
+};
+
+struct Gmod_metadata {
+ int md_version; /* structure version MDTV_* */
+ int md_type; /* type of entry MDT_* */
+ GElf_Addr md_data; /* specific data */
+ GElf_Addr md_cval; /* common string label */
+};
+
+struct Gmod_pnp_match_info
+{
+ GElf_Addr descr; /* Description of the table */
+ GElf_Addr bus; /* Name of the bus for this table */
+ GElf_Addr table; /* Pointer to pnp table */
+ int entry_len; /* Length of each entry in the table (may be */
+ /* longer than descr describes). */
+ int num_entry; /* Number of entries in the table */
+};
+
+__BEGIN_DECLS
+
+/*
+ * Attempt to parse an open ELF file as either an executable or DSO
+ * (ef_open) or an object file (ef_obj_open). On success, these
+ * routines initialize the 'ef_ef' and 'ef_ops' members of 'ef'.
+ */
+int ef_open(struct elf_file *ef, int verbose);
+int ef_obj_open(struct elf_file *ef, int verbose);
+
+/*
+ * Direct operations on an ELF file regardless of type. Many of these
+ * use libelf.
+ */
+
+/*
+ * Open an ELF file with libelf. Populates fields other than ef_ef
+ * and ef_ops in '*efile'.
+ */
+int elf_open_file(struct elf_file *efile, const char *filename,
+ int verbose);
+
+/* Close an ELF file. */
+void elf_close_file(struct elf_file *efile);
+
+/* Is an ELF file the same architecture as hdr? */
+bool elf_compatible(struct elf_file *efile, const GElf_Ehdr *hdr);
+
+/* The size of a single object of 'type'. */
+size_t elf_object_size(struct elf_file *efile, Elf_Type type);
+
+/* The size of a pointer in architecture of 'efile'. */
+size_t elf_pointer_size(struct elf_file *efile);
+
+/*
+ * Read and convert an array of a data type from an ELF file. This is
+ * a wrapper around gelf_xlatetom() which reads an array of raw ELF
+ * objects from the file and converts them into host structures using
+ * native endianness. The data is returned in a dynamically-allocated
+ * buffer.
+ */
+int elf_read_data(struct elf_file *efile, Elf_Type type, off_t offset,
+ size_t len, void **out);
+
+/* Reads "raw" data from an ELF file without any translation. */
+int elf_read_raw_data(struct elf_file *efile, off_t offset, void *dst,
+ size_t len);
+
+/*
+ * A wrapper around elf_read_raw_data which returns the data in a
+ * dynamically-allocated buffer.
+ */
+int elf_read_raw_data_alloc(struct elf_file *efile, off_t offset,
+ size_t len, void **out);
+
+/* Reads a single string at the given offset from an ELF file. */
+int elf_read_raw_string(struct elf_file *efile, off_t offset, char *dst,
+ size_t len);
+
+/*
+ * Read relocated data from an ELF file and return it in a
+ * dynamically-allocated buffer. Note that no translation
+ * (byte-swapping for endianness, 32-vs-64) is performed on the
+ * returned data, but any ELF relocations which affect the contents
+ * are applied to the returned data. The address parameter gives the
+ * address of the data buffer if the ELF file were loaded into memory
+ * rather than a direct file offset.
+ */
+int elf_read_relocated_data(struct elf_file *efile, GElf_Addr address,
+ size_t len, void **buf);
+
+/*
+ * Read the program headers from an ELF file and return them in a
+ * dynamically-allocated array of GElf_Phdr objects.
+ */
+int elf_read_phdrs(struct elf_file *efile, size_t *nphdrp,
+ GElf_Phdr **phdrp);
+
+/*
+ * Read the section headers from an ELF file and return them in a
+ * dynamically-allocated array of GElf_Shdr objects.
+ */
+int elf_read_shdrs(struct elf_file *efile, size_t *nshdrp,
+ GElf_Shdr **shdrp);
+
+/*
+ * Read the dynamic table from a section of an ELF file into a
+ * dynamically-allocated array of GElf_Dyn objects.
+ */
+int elf_read_dynamic(struct elf_file *efile, int section_index, size_t *ndynp,
+ GElf_Dyn **dynp);
+
+/*
+ * Read a symbol table from a section of an ELF file into a
+ * dynamically-allocated array of GElf_Sym objects.
+ */
+int elf_read_symbols(struct elf_file *efile, int section_index,
+ size_t *nsymp, GElf_Sym **symp);
+
+/*
+ * Read a string table described by a section header of an ELF file
+ * into a dynamically-allocated buffer.
+ */
+int elf_read_string_table(struct elf_file *efile, const GElf_Shdr *shdr,
+ long *strcnt, char **strtab);
+
+/*
+ * Read a table of relocation objects from a section of an ELF file
+ * into a dynamically-allocated array of GElf_Rel objects.
+ */
+int elf_read_rel(struct elf_file *efile, int section_index, long *nrelp,
+ GElf_Rel **relp);
+
+/*
+ * Read a table of relocation-with-addend objects from a section of an
+ * ELF file into a dynamically-allocated array of GElf_Rela objects.
+ */
+int elf_read_rela(struct elf_file *efile, int section_index, long *nrelap,
+ GElf_Rela **relap);
+
+/*
+ * Read a string from an ELF file and return it in the provided
+ * buffer. If the string is longer than the buffer, this fails with
+ * EFAULT. The address parameter gives the address of the data buffer
+ * if the ELF file were loaded into memory rather than a direct file
+ * offset.
+ */
+int elf_read_string(struct elf_file *efile, GElf_Addr address, void *dst,
+ size_t len);
+
+/* Return the address extracted from a target pointer stored at 'p'. */
+GElf_Addr elf_address_from_pointer(struct elf_file *efile, const void *p);
+
+/*
+ * Read a linker set and return an array of addresses extracted from the
+ * relocated pointers in the linker set.
+ */
+int elf_read_linker_set(struct elf_file *efile, const char *name,
+ GElf_Addr **buf, long *countp);
+
+/*
+ * Read and convert a target 'struct mod_depend' into a host
+ * 'struct Gmod_depend'.
+ */
+int elf_read_mod_depend(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_depend *mdp);
+
+/*
+ * Read and convert a target 'struct mod_version' into a host
+ * 'struct Gmod_version'.
+ */
+int elf_read_mod_version(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_version *mdv);
+
+/*
+ * Read and convert a target 'struct mod_metadata' into a host
+ * 'struct Gmod_metadata'.
+ */
+int elf_read_mod_metadata(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_metadata *md);
+
+/*
+ * Read and convert a target 'struct mod_pnp_match_info' into a host
+ * 'struct Gmod_pnp_match_info'.
+ */
+int elf_read_mod_pnp_match_info(struct elf_file *efile, GElf_Addr addr,
+ struct Gmod_pnp_match_info *pnp);
+
+/*
+ * Apply relocations to the values obtained from the file. `relbase' is the
+ * target relocation address of the section, and `dataoff/len' is the region
+ * that is to be relocated, and has been copied to *dest
+ */
+int elf_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
+ GElf_Addr relbase, GElf_Addr dataoff, size_t len, void *dest);
+
+/*
+ * Find the symbol with the specified symbol name 'name' within the given
+ * 'efile'. 0 is returned when such a symbol is found, otherwise ENOENT is
+ * returned.
+ */
+int elf_lookup_symbol(struct elf_file *efile, const char *name,
+ GElf_Sym **sym, bool see_local);
+
+__END_DECLS
+
+#endif /* _KLDELF_H_*/
diff --git a/lib/libkvm/Makefile b/lib/libkvm/Makefile
index e0c6d705fec1..94a1173010a4 100644
--- a/lib/libkvm/Makefile
+++ b/lib/libkvm/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
LIB= kvm
PACKAGE= runtime
diff --git a/lib/libkvm/kvm.3 b/lib/libkvm/kvm.3
index 1f1b1c3f48b0..33a5d2319d18 100644
--- a/lib/libkvm/kvm.3
+++ b/lib/libkvm/kvm.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd February 5, 2020
.Dt KVM 3
.Os
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index e70e94efaee8..4ed48951a327 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -33,8 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)kvm.c 8.2 (Berkeley) 2/13/94");
#include <sys/param.h>
#include <sys/fnv_hash.h>
diff --git a/lib/libkvm/kvm.h b/lib/libkvm/kvm.h
index 6e56f73f4657..0061eb795ec4 100644
--- a/lib/libkvm/kvm.h
+++ b/lib/libkvm/kvm.h
@@ -27,14 +27,11 @@
* 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.
- *
- * @(#)kvm.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _KVM_H_
#define _KVM_H_
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <nlist.h>
diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c
index cc41d3c8c5c8..acc7ac017a3c 100644
--- a/lib/libkvm/kvm_amd64.c
+++ b/lib/libkvm/kvm_amd64.c
@@ -33,8 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93");
/*
* AMD64 machine dependent routines for kvm. Hopefully, the forthcoming
@@ -111,8 +109,9 @@ _amd64_initvtop(kvm_t *kd)
{
struct kvm_nlist nl[2];
amd64_physaddr_t pa;
- kvaddr_t kernbase;
+ kvaddr_t kernbase, kernphys;
amd64_pml4e_t *PML4;
+ int found = 0;
kd->vmst = (struct vmstate *)_kvm_malloc(kd, sizeof(*kd->vmst));
if (kd->vmst == NULL) {
@@ -125,16 +124,43 @@ _amd64_initvtop(kvm_t *kd)
if (_kvm_read_core_phdrs(kd, &kd->vmst->phnum,
&kd->vmst->phdr) == -1)
return (-1);
+
+ for (size_t i = 0; i < kd->vmst->phnum; i++) {
+ if (kd->vmst->phdr[i].p_type == PT_DUMP_DELTA) {
+ /* Account for the 2M hole at KERNBASE. */
+ kernphys = kd->vmst->phdr[i].p_paddr -
+ kd->vmst->phdr[i].p_align;
+ kernbase = kd->vmst->phdr[i].p_vaddr;
+
+ found = 1;
+ break;
+ }
+ }
}
- nl[0].n_name = "kernbase";
- nl[1].n_name = 0;
+ if (found == 0) {
+ nl[0].n_name = "kernbase";
+ nl[1].n_name = 0;
- if (kvm_nlist2(kd, nl) != 0) {
- _kvm_err(kd, kd->program, "bad namelist - no kernbase");
- return (-1);
+ if (kvm_nlist2(kd, nl) != 0) {
+ _kvm_err(kd, kd->program, "bad namelist - no kernbase");
+ return (-1);
+ }
+
+ nl[0].n_name = "kernphys";
+ nl[1].n_name = 0;
+
+ /* XXX
+ * Relocatable kernels can still be loaded at 2M.
+ */
+ if (kvm_nlist2(kd, nl) != 1) {
+ _kvm_err(kd, kd->program, "cannot determine kernphys");
+ return (-1);
+ }
+
+ kernphys = 0;
+ kernbase = nl[0].n_value;
}
- kernbase = nl[0].n_value;
nl[0].n_name = "KPML4phys";
nl[1].n_name = 0;
@@ -143,8 +169,8 @@ _amd64_initvtop(kvm_t *kd)
_kvm_err(kd, kd->program, "bad namelist - no KPML4phys");
return (-1);
}
- if (kvm_read2(kd, (nl[0].n_value - kernbase), &pa, sizeof(pa)) !=
- sizeof(pa)) {
+ if (kvm_read2(kd, (nl[0].n_value - kernbase + kernphys), &pa,
+ sizeof(pa)) != sizeof(pa)) {
_kvm_err(kd, kd->program, "cannot read KPML4phys");
return (-1);
}
diff --git a/lib/libkvm/kvm_arm.c b/lib/libkvm/kvm_arm.c
index 81d49793591a..b1e00bda7918 100644
--- a/lib/libkvm/kvm_arm.c
+++ b/lib/libkvm/kvm_arm.c
@@ -37,7 +37,6 @@
* ARM machine dependent routines for kvm.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/endian.h>
#include <kvm.h>
diff --git a/lib/libkvm/kvm_cptime.c b/lib/libkvm/kvm_cptime.c
index 5e92b565486c..bf6d10c0c620 100644
--- a/lib/libkvm/kvm_cptime.c
+++ b/lib/libkvm/kvm_cptime.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/pcpu.h>
#include <sys/resource.h>
diff --git a/lib/libkvm/kvm_geterr.3 b/lib/libkvm/kvm_geterr.3
index 3263a3e218f6..659bdcda82d2 100644
--- a/lib/libkvm/kvm_geterr.3
+++ b/lib/libkvm/kvm_geterr.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_geterr.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd March 21, 2017
.Dt KVM_GETERR 3
.Os
diff --git a/lib/libkvm/kvm_getloadavg.3 b/lib/libkvm/kvm_getloadavg.3
index 9bd1970779e6..66fa20a6dc9b 100644
--- a/lib/libkvm/kvm_getloadavg.3
+++ b/lib/libkvm/kvm_getloadavg.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_getloadavg.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd June 4, 1993
.Dt KVM_GETLOADAVG 3
.Os
diff --git a/lib/libkvm/kvm_getloadavg.c b/lib/libkvm/kvm_getloadavg.c
index b3b810752979..cbefa8f0064a 100644
--- a/lib/libkvm/kvm_getloadavg.c
+++ b/lib/libkvm/kvm_getloadavg.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)kvm_getloadavg.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
#include <sys/time.h>
diff --git a/lib/libkvm/kvm_getprocs.3 b/lib/libkvm/kvm_getprocs.3
index 8fc5b6518350..ced683461aa1 100644
--- a/lib/libkvm/kvm_getprocs.3
+++ b/lib/libkvm/kvm_getprocs.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_getprocs.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 22, 2011
.Dt KVM_GETPROCS 3
.Os
diff --git a/lib/libkvm/kvm_getswapinfo.c b/lib/libkvm/kvm_getswapinfo.c
index 3c5019977d50..a713c6752fa7 100644
--- a/lib/libkvm/kvm_getswapinfo.c
+++ b/lib/libkvm/kvm_getswapinfo.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
diff --git a/lib/libkvm/kvm_i386.c b/lib/libkvm/kvm_i386.c
index f63d6888b686..776c486579a1 100644
--- a/lib/libkvm/kvm_i386.c
+++ b/lib/libkvm/kvm_i386.c
@@ -33,8 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93");
/*
* i386 machine dependent routines for kvm. Hopefully, the forthcoming
diff --git a/lib/libkvm/kvm_minidump_powerpc64.c b/lib/libkvm/kvm_minidump_powerpc64.c
index a75e139929d3..caf504cff077 100644
--- a/lib/libkvm/kvm_minidump_powerpc64.c
+++ b/lib/libkvm/kvm_minidump_powerpc64.c
@@ -26,7 +26,6 @@
* From: FreeBSD: src/lib/libkvm/kvm_minidump_riscv.c
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <kvm.h>
diff --git a/lib/libkvm/kvm_minidump_powerpc64_hpt.c b/lib/libkvm/kvm_minidump_powerpc64_hpt.c
index a1471684c88f..1db3d373e169 100644
--- a/lib/libkvm/kvm_minidump_powerpc64_hpt.c
+++ b/lib/libkvm/kvm_minidump_powerpc64_hpt.c
@@ -26,7 +26,6 @@
* From: FreeBSD: src/lib/libkvm/kvm_minidump_riscv.c
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <vm/vm.h>
diff --git a/lib/libkvm/kvm_nlist.3 b/lib/libkvm/kvm_nlist.3
index 14fae51dfd02..b7701828fadb 100644
--- a/lib/libkvm/kvm_nlist.3
+++ b/lib/libkvm/kvm_nlist.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_nlist.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 27, 2015
.Dt KVM_NLIST 3
.Os
diff --git a/lib/libkvm/kvm_open.3 b/lib/libkvm/kvm_open.3
index c1f3ddb6d54a..9a32719d537b 100644
--- a/lib/libkvm/kvm_open.3
+++ b/lib/libkvm/kvm_open.3
@@ -29,9 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_open.3 8.3 (Berkeley) 4/19/94
-.\"
-.Dd March 20, 2017
+.Dd June 22, 2025
.Dt KVM_OPEN 3
.Os
.Sh NAME
@@ -247,7 +245,20 @@ The value passed via
was
.Dv NULL .
.El
+.Sh NOTE
+Full memory dumps taken on 13.x (excluding 13.0) and 14.x amd64 kernels
+will cause both
+.Fn kvm_open
+and
+.Fn kvm_open2
+to fail since they do not provide sufficient information to figure out
+where in physical memory the kernel was loaded.
+Full memory dumps have to be explicitly enabled by setting the
+.Va debug.minidump
+.Xr sysctl 8
+to 0.
.Sh SEE ALSO
+.Xr dumpon 8 ,
.Xr close 2 ,
.Xr open 2 ,
.Xr kvm 3 ,
diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c
index 613fadffe435..a83d927bcfd9 100644
--- a/lib/libkvm/kvm_pcpu.c
+++ b/lib/libkvm/kvm_pcpu.c
@@ -38,7 +38,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/pcpu.h>
#include <sys/sysctl.h>
diff --git a/lib/libkvm/kvm_powerpc.c b/lib/libkvm/kvm_powerpc.c
index 35312cda3525..61db08f3a0ae 100644
--- a/lib/libkvm/kvm_powerpc.c
+++ b/lib/libkvm/kvm_powerpc.c
@@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/kerneldump.h>
diff --git a/lib/libkvm/kvm_powerpc64.c b/lib/libkvm/kvm_powerpc64.c
index 6bf350121143..f0292ec8d757 100644
--- a/lib/libkvm/kvm_powerpc64.c
+++ b/lib/libkvm/kvm_powerpc64.c
@@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/kerneldump.h>
diff --git a/lib/libkvm/kvm_private.c b/lib/libkvm/kvm_private.c
index dbbe68437b4b..a3b650787f53 100644
--- a/lib/libkvm/kvm_private.c
+++ b/lib/libkvm/kvm_private.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/fnv_hash.h>
diff --git a/lib/libkvm/kvm_private.h b/lib/libkvm/kvm_private.h
index 86e9a16bb7c5..0ab16dc58755 100644
--- a/lib/libkvm/kvm_private.h
+++ b/lib/libkvm/kvm_private.h
@@ -31,8 +31,6 @@
* 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.
- *
- * @(#)kvm_private.h 8.1 (Berkeley) 6/4/93
*/
#include <sys/endian.h>
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index 0cd8d754eb04..b2b7c6ecce56 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -33,8 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)kvm_proc.c 8.3 (Berkeley) 9/23/93");
/*
* Proc traversal interface for kvm. ps and w are (probably) the exclusive
@@ -144,11 +142,14 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
if (proc.p_state == PRS_NEW)
continue;
if (KREAD(kd, (u_long)proc.p_ucred, &ucred) == 0) {
+ kp->ki_uid = ucred.cr_uid;
kp->ki_ruid = ucred.cr_ruid;
kp->ki_svuid = ucred.cr_svuid;
kp->ki_rgid = ucred.cr_rgid;
kp->ki_svgid = ucred.cr_svgid;
- kp->ki_cr_flags = ucred.cr_flags;
+ kp->ki_cr_flags = 0;
+ if (ucred.cr_flags & CRED_FLAG_CAPMODE)
+ kp->ki_cr_flags |= KI_CRF_CAPABILITY_MODE;
if (ucred.cr_ngroups > KI_NGROUPS) {
kp->ki_ngroups = KI_NGROUPS;
kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW;
@@ -156,7 +157,6 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
kp->ki_ngroups = ucred.cr_ngroups;
kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups,
kp->ki_ngroups * sizeof(gid_t));
- kp->ki_uid = ucred.cr_uid;
if (ucred.cr_prison != NULL) {
if (KREAD(kd, (u_long)ucred.cr_prison, &pr)) {
_kvm_err(kd, kd->program,
diff --git a/lib/libkvm/kvm_read.3 b/lib/libkvm/kvm_read.3
index fdad3a2af8e3..c3e9c3b31e92 100644
--- a/lib/libkvm/kvm_read.3
+++ b/lib/libkvm/kvm_read.3
@@ -29,8 +29,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kvm_read.3 8.1 (Berkeley) 6/4/93
-.\"
.Dd November 27, 2015
.Dt KVM_READ 3
.Os
diff --git a/lib/libkvm/kvm_vnet.c b/lib/libkvm/kvm_vnet.c
index 03e80d0458f3..a60663d483e1 100644
--- a/lib/libkvm/kvm_vnet.c
+++ b/lib/libkvm/kvm_vnet.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#define _WANT_PRISON
diff --git a/lib/libkvm/tests/Makefile b/lib/libkvm/tests/Makefile
index c3c94c690565..5b4220327670 100644
--- a/lib/libkvm/tests/Makefile
+++ b/lib/libkvm/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
ATF_TESTS_C+= kvm_close_test
diff --git a/lib/libkvm/tests/kvm_geterr_test.c b/lib/libkvm/tests/kvm_geterr_test.c
index 9e70a482656c..01f21dc6a3d5 100644
--- a/lib/libkvm/tests/kvm_geterr_test.c
+++ b/lib/libkvm/tests/kvm_geterr_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libkvm/tests/kvm_open2_test.c b/lib/libkvm/tests/kvm_open2_test.c
index cfa6e214a031..0ad0b47de948 100644
--- a/lib/libkvm/tests/kvm_open2_test.c
+++ b/lib/libkvm/tests/kvm_open2_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libkvm/tests/kvm_open_test.c b/lib/libkvm/tests/kvm_open_test.c
index e3090dc43cfc..977f9ed5c3e2 100644
--- a/lib/libkvm/tests/kvm_open_test.c
+++ b/lib/libkvm/tests/kvm_open_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libkvm/tests/kvm_read_test.c b/lib/libkvm/tests/kvm_read_test.c
index 2945ec96d0b7..38cf337cb7c5 100644
--- a/lib/libkvm/tests/kvm_read_test.c
+++ b/lib/libkvm/tests/kvm_read_test.c
@@ -26,7 +26,6 @@
* From: FreeBSD: src/lib/libkvm/tests/kvm_geterr_test.c
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <errno.h>
diff --git a/lib/libkvm/tests/kvm_test_common.c b/lib/libkvm/tests/kvm_test_common.c
index 36b109aed94f..0eff73cdc20a 100644
--- a/lib/libkvm/tests/kvm_test_common.c
+++ b/lib/libkvm/tests/kvm_test_common.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile
index 68ee26076f6b..71519aa7f70d 100644
--- a/lib/libldns/Makefile
+++ b/lib/libldns/Makefile
@@ -1,4 +1,3 @@
-
# Vendor sources and generated files
LDNSDIR = ${SRCTOP}/contrib/ldns
diff --git a/lib/liblua/Makefile b/lib/liblua/Makefile
index c15174b39726..1fb4a9b85e77 100644
--- a/lib/liblua/Makefile
+++ b/lib/liblua/Makefile
@@ -1,4 +1,3 @@
-
LUASRC?= ${SRCTOP}/contrib/lua/src
.PATH: ${LUASRC}
diff --git a/lib/liblua/Makefile.depend b/lib/liblua/Makefile.depend
new file mode 100644
index 000000000000..ecc8fe860f5e
--- /dev/null
+++ b/lib/liblua/Makefile.depend
@@ -0,0 +1,13 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/liblutok/Makefile b/lib/liblutok/Makefile
index 656cf7850f2e..08737afbb61a 100644
--- a/lib/liblutok/Makefile
+++ b/lib/liblutok/Makefile
@@ -1,4 +1,3 @@
-
LIB_CXX= lutok
INTERNALLIB=
@@ -19,8 +18,4 @@ CFLAGS+= -I${SRCTOP}/contrib/lutok/include \
WARNS?= 3
SHLIB_MAJOR= 0
-# lutok uses auto_ptr
-CFLAGS+= -Wno-deprecated-declarations
-CXXSTD= c++11
-
.include <bsd.lib.mk>
diff --git a/lib/liblutok/Makefile.depend b/lib/liblutok/Makefile.depend
new file mode 100644
index 000000000000..1cb182ef8ce1
--- /dev/null
+++ b/lib/liblutok/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/libc++ \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/liblzma/Makefile b/lib/liblzma/Makefile
index 9e228d277896..27e0521f5884 100644
--- a/lib/liblzma/Makefile
+++ b/lib/liblzma/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
LIB= lzma
LZMADIR= ${SRCTOP}/contrib/xz/src/liblzma
@@ -81,16 +80,13 @@ SRCS+= common.c \
.PATH: ${LZMADIR}/check
-SRCS+= check.c \
- crc32_table.c \
- crc64_table.c
+SRCS+= check.c \
+ crc32_fast.c \
+ crc64_fast.c
.if defined(MACHINE_ARCH) && ${MACHINE_ARCH} == "i386"
SRCS+= crc32_x86.S \
crc64_x86.S
ACFLAGS+= -Wa,--noexecstack
-.else
-SRCS+= crc32_fast.c \
- crc64_fast.c
.endif
.PATH: ${LZMADIR}/lz
@@ -126,6 +122,7 @@ SRCS+= simple_coder.c \
arm.c \
arm64.c \
armthumb.c \
+ riscv.c \
sparc.c
.PATH: ${LZMADIR}
@@ -156,7 +153,6 @@ LIBADD+= md pthread
VERSION_DEF= ${.CURDIR}/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
-CFLAGS+= -DSYMBOL_VERSIONING
CLEANFILES+= liblzma.pc
diff --git a/lib/liblzma/Symbol.map b/lib/liblzma/Symbol.map
index 8e8fc10a2453..0976e26a3c8d 100644
--- a/lib/liblzma/Symbol.map
+++ b/lib/liblzma/Symbol.map
@@ -114,6 +114,19 @@ XZ_5.4 {
lzma_str_to_filters;
};
+XZ_5.6 {
+ lzma_mt_block_size;
+};
+
+XZ_5.8 {
+ lzma_bcj_arm64_encode;
+ lzma_bcj_arm64_decode;
+ lzma_bcj_riscv_encode;
+ lzma_bcj_riscv_decode;
+ lzma_bcj_x86_encode;
+ lzma_bcj_x86_decode;
+};
+
XZprivate_1.0 {
lzma_alloc;
lzma_alloc_zero;
@@ -138,7 +151,6 @@ XZprivate_1.0 {
lzma_index_prealloc;
lzma_lz_decoder_init;
lzma_lz_decoder_memusage;
- lzma_lz_decoder_uncompressed;
lzma_lz_encoder_init;
lzma_lz_encoder_memusage;
lzma_lzma2_block_size;
@@ -174,7 +186,6 @@ XZprivate_1.0 {
lzma_mf_hc3_skip;
lzma_mf_hc4_find;
lzma_mf_hc4_skip;
- lzma_mt_block_size;
lzma_next_end;
lzma_next_filter_init;
lzma_next_filter_update;
diff --git a/lib/liblzma/Versions.def b/lib/liblzma/Versions.def
index dea89514beda..555ef25c8801 100644
--- a/lib/liblzma/Versions.def
+++ b/lib/liblzma/Versions.def
@@ -8,6 +8,12 @@ XZ_5.2 {
XZ_5.4 {
} XZ_5.2;
-XZprivate_1.0 {
+XZ_5.6 {
} XZ_5.4;
+XZ_5.8 {
+} XZ_5.6;
+
+XZprivate_1.0 {
+} XZ_5.8;
+
diff --git a/lib/liblzma/config.h b/lib/liblzma/config.h
index c3fa947ec5fb..963d08c93e7a 100644
--- a/lib/liblzma/config.h
+++ b/lib/liblzma/config.h
@@ -12,6 +12,10 @@
/* FreeBSD - disabled intentionally */
/* #undef ENABLE_NLS */
+/* Define to 1 if ARM64 CRC32 instruction is supported. See configure.ac for
+ details. */
+/* #undef HAVE_ARM64_CRC32 */
+
/* Define to 1 if bswap_16 is available. */
/* #undef HAVE_BSWAP_16 */
@@ -25,14 +29,14 @@
/* #undef HAVE_BYTESWAP_H */
#ifndef WITHOUT_CAPSICUM
-/* Define to 1 if Capsicum is available. */
-#define HAVE_CAPSICUM 1
+/* Define to 1 if you have the 'cap_rights_limit' function. */
+#define HAVE_CAP_RIGHTS_LIMIT 1
#endif
-/* Define to 1 if the system has the type `CC_SHA256_CTX'. */
+/* Define to 1 if the system has the type 'CC_SHA256_CTX'. */
/* #undef HAVE_CC_SHA256_CTX */
-/* Define to 1 if you have the `CC_SHA256_Init' function. */
+/* Define to 1 if you have the 'CC_SHA256_Init' function. */
/* #undef HAVE_CC_SHA256_INIT */
/* Define to 1 if you have the Mac OS X function
@@ -52,10 +56,10 @@
/* Define to 1 if sha256 integrity check is enabled. */
#define HAVE_CHECK_SHA256 1
-/* Define to 1 if you have the `clock_gettime' function. */
+/* Define to 1 if you have the 'clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
-/* Define to 1 if `CLOCK_MONOTONIC' is declared in <time.h>. */
+/* Define to 1 if 'CLOCK_MONOTONIC' is declared in <time.h>. */
#define HAVE_CLOCK_MONOTONIC 1
/* Define to 1 if you have the <CommonCrypto/CommonDigest.h> header file. */
@@ -64,6 +68,12 @@
/* Define to 1 if you have the <cpuid.h> header file. */
#define HAVE_CPUID_H 1
+/* Define to 1 if the 32-bit x86 CRC assembly files are used. */
+/* FreeBSD - only enabled for i386 */
+#if defined(__FreeBSD__) && defined(__i386__)
+#define HAVE_CRC_X86_ASM 1
+#endif
+
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
/* FreeBSD - disabled intentionally */
@@ -96,6 +106,9 @@
/* Define to 1 if powerpc decoder is enabled. */
#define HAVE_DECODER_POWERPC 1
+/* Define to 1 if riscv decoder is enabled. */
+#define HAVE_DECODER_RISCV 1
+
/* Define to 1 if sparc decoder is enabled. */
#define HAVE_DECODER_SPARC 1
@@ -105,6 +118,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
+/* Define to 1 if you have the 'elf_aux_info' function. */
+/* #undef HAVE_ELF_AUX_INFO */
+
/* Define to 1 if any of HAVE_ENCODER_foo have been defined. */
#define HAVE_ENCODERS 1
@@ -132,32 +148,35 @@
/* Define to 1 if powerpc encoder is enabled. */
#define HAVE_ENCODER_POWERPC 1
+/* Define to 1 if riscv encoder is enabled. */
+#define HAVE_ENCODER_RISCV 1
+
/* Define to 1 if sparc encoder is enabled. */
#define HAVE_ENCODER_SPARC 1
/* Define to 1 if x86 encoder is enabled. */
#define HAVE_ENCODER_X86 1
-/* Define to 1 if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
/* Define to 1 if __attribute__((__constructor__)) is supported for functions.
*/
#define HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR 1
-/* Define to 1 if you have the `futimens' function. */
+/* Define to 1 if you have the 'futimens' function. */
#define HAVE_FUTIMENS 1
-/* Define to 1 if you have the `futimes' function. */
+/* Define to 1 if you have the 'futimes' function. */
/* #undef HAVE_FUTIMES */
-/* Define to 1 if you have the `futimesat' function. */
+/* Define to 1 if you have the 'futimesat' function. */
/* #undef HAVE_FUTIMESAT */
+/* Define to 1 if you have the 'getauxval' function. */
+/* #undef HAVE_GETAUXVAL */
+
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
-/* Define to 1 if you have the `getopt_long' function. */
+/* Define to 1 if you have the 'getopt_long' function. */
#define HAVE_GETOPT_LONG 1
/* Define if the GNU gettext() function is already present or preinstalled. */
@@ -176,8 +195,12 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
-/* Define to 1 if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
+/* Define to 1 if Linux Landlock is supported. See configure.ac for details.
+ */
+/* #undef HAVE_LINUX_LANDLOCK */
+
+/* Define to 1 if 64-bit LoongArch CRC32 instructions are supported. */
+/* #undef HAVE_LOONGARCH_CRC32 */
/* Define to 1 if .lz (lzip) decompression support is enabled. */
#define HAVE_LZIP_DECODER 1
@@ -206,34 +229,34 @@
/* Define to 1 if getopt.h declares extern int optreset. */
#define HAVE_OPTRESET 1
-/* Define to 1 if you have the `pledge' function. */
+/* Define to 1 if you have the 'pledge' function. */
/* #undef HAVE_PLEDGE */
-/* Define to 1 if you have the `posix_fadvise' function. */
+/* Define to 1 if you have the 'posix_fadvise' function. */
#define HAVE_POSIX_FADVISE 1
-/* Define to 1 if `program_invocation_name' is declared in <errno.h>. */
+/* Define to 1 if 'program_invocation_name' is declared in <errno.h>. */
/* #undef HAVE_PROGRAM_INVOCATION_NAME */
-/* Define to 1 if you have the `pthread_condattr_setclock' function. */
+/* Define to 1 if you have the 'pthread_condattr_setclock' function. */
#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
/* Have PTHREAD_PRIO_INHERIT. */
#define HAVE_PTHREAD_PRIO_INHERIT 1
-/* Define to 1 if you have the `SHA256Init' function. */
+/* Define to 1 if you have the 'SHA256Init' function. */
/* #undef HAVE_SHA256INIT */
-/* Define to 1 if the system has the type `SHA256_CTX'. */
+/* Define to 1 if the system has the type 'SHA256_CTX'. */
#define HAVE_SHA256_CTX 1
/* Define to 1 if you have the <sha256.h> header file. */
#define HAVE_SHA256_H 1
-/* Define to 1 if you have the `SHA256_Init' function. */
+/* Define to 1 if you have the 'SHA256_Init' function. */
#define HAVE_SHA256_INIT 1
-/* Define to 1 if the system has the type `SHA2_CTX'. */
+/* Define to 1 if the system has the type 'SHA2_CTX'. */
/* #undef HAVE_SHA2_CTX */
/* Define to 1 if you have the <sha2.h> header file. */
@@ -260,19 +283,19 @@
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
-/* Define to 1 if `st_atimensec' is a member of `struct stat'. */
+/* Define to 1 if 'st_atimensec' is a member of 'struct stat'. */
#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1
-/* Define to 1 if `st_atimespec.tv_nsec' is a member of `struct stat'. */
+/* Define to 1 if 'st_atimespec.tv_nsec' is a member of 'struct stat'. */
#define HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 1
-/* Define to 1 if `st_atim.st__tim.tv_nsec' is a member of `struct stat'. */
+/* Define to 1 if 'st_atim.st__tim.tv_nsec' is a member of 'struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC */
-/* Define to 1 if `st_atim.tv_nsec' is a member of `struct stat'. */
+/* Define to 1 if 'st_atim.tv_nsec' is a member of 'struct stat'. */
#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1
-/* Define to 1 if `st_uatime' is a member of `struct stat'. */
+/* Define to 1 if 'st_uatime' is a member of 'struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_UATIME */
/* Define to 1 to if GNU/Linux-specific details are unconditionally wanted for
@@ -282,13 +305,14 @@
must be used together with liblzma_linux.map. */
/* #undef HAVE_SYMBOL_VERSIONS_LINUX */
+/* Define to 1 if you have the 'sysctlbyname' function. */
+/* #undef HAVE_SYSCTLBYNAME */
+
/* Define to 1 if you have the <sys/byteorder.h> header file. */
/* #undef HAVE_SYS_BYTEORDER_H */
-#ifndef WITHOUT_CAPSICUM
-/* Define to 1 if you have the <sys/capsicum.h> header file. */
-#define HAVE_SYS_CAPSICUM_H 1
-#endif
+/* Define to 1 if you have the <sys/cdefs.h> header file. */
+#define HAVE_SYS_CDEFS_H 1
/* Define to 1 if you have the <sys/endian.h> header file. */
/* #undef HAVE_SYS_ENDIAN_H */
@@ -299,13 +323,10 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
-/* Define to 1 if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
-/* Define to 1 if the system has the type `uintptr_t'. */
+/* Define to 1 if the system has the type 'uintptr_t'. */
#define HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
@@ -317,12 +338,15 @@
#define HAVE_USABLE_CLMUL 1
#endif
-/* Define to 1 if you have the `utime' function. */
+/* Define to 1 if you have the 'utime' function. */
/* #undef HAVE_UTIME */
-/* Define to 1 if you have the `utimes' function. */
+/* Define to 1 if you have the 'utimes' function. */
/* #undef HAVE_UTIMES */
+/* Define to 1 if you have the 'vasprintf' function. */
+#define HAVE_VASPRINTF 1
+
/* Define to 1 or 0, depending whether the compiler supports simple visibility
declarations. */
#define HAVE_VISIBILITY 1
@@ -330,13 +354,13 @@
/* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1
-/* Define to 1 if you have the `wcwidth' function. */
+/* Define to 1 if you have the 'wcwidth' function. */
#define HAVE_WCWIDTH 1
-/* Define to 1 if the system has the type `_Bool'. */
+/* Define to 1 if the system has the type '_Bool'. */
#define HAVE__BOOL 1
-/* Define to 1 if you have the `_futime' function. */
+/* Define to 1 if you have the '_futime' function. */
/* #undef HAVE__FUTIME */
/* Define to 1 if _mm_movemask_epi8 is available. */
@@ -379,7 +403,7 @@
#define PACKAGE_NAME "XZ Utils"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "XZ Utils 5.4.4"
+#define PACKAGE_STRING "XZ Utils 5.8.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "xz"
@@ -388,16 +412,16 @@
#define PACKAGE_URL "https://tukaani.org/xz/"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "5.4.4"
+#define PACKAGE_VERSION "5.8.1"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
/* #undef PTHREAD_CREATE_JOINABLE */
-/* The size of `size_t', as computed by sizeof. */
+/* The size of 'size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 8
-/* Define to 1 if all of the C90 standard headers exist (not just the ones
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#define STDC_HEADERS 1
@@ -460,7 +484,7 @@
and might result in broken code. */
/* #undef TUKLIB_USE_UNSAFE_TYPE_PUNNING */
-/* Enable extensions on AIX 3, Interix. */
+/* Enable extensions on AIX, Interix, z/OS. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
@@ -521,11 +545,15 @@
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#endif
+/* Enable extensions specified by C23 Annex F. */
+#ifndef __STDC_WANT_IEC_60559_EXT__
+# define __STDC_WANT_IEC_60559_EXT__ 1
+#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
#endif
-/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
+/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
#endif
@@ -549,7 +577,7 @@
/* Version number of package */
-#define VERSION "5.4.4"
+#define VERSION "5.8.1"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
@@ -567,9 +595,12 @@
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
-/* Define for large files, on AIX-style hosts. */
+/* Define to 1 on platforms where this makes off_t a 64-bit type. */
/* #undef _LARGE_FILES */
+/* Number of bits in time_t, on hosts where this is settable. */
+/* #undef _TIME_BITS */
+
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
@@ -589,6 +620,9 @@
used. */
/* #undef __GETOPT_PREFIX */
+/* Define to 1 on platforms where this makes time_t a 64-bit type. */
+/* #undef __MINGW_USE_VC2005_COMPAT */
+
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
/* #undef int32_t */
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 98fcc7168d79..150ddc686241 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -16,6 +16,7 @@ MAN= libmagic.3 magic.5
SRCS= apprentice.c apptype.c ascmagic.c buffer.c cdf.c cdf_time.c \
compress.c der.c encoding.c fsmagic.c funcs.c is_json.c \
is_csv.c \
+ is_simh.c \
is_tar.c magic.c print.c readcdf.c readelf.c seccomp.c softmagic.c
INCS= magic.h
@@ -58,12 +59,13 @@ magic.mgc: magic
CLEANFILES+= mkmagic
DEPENDOBJS+= mkmagic
build-tools: mkmagic
+# For the non-dirdeps build, HOST_CC is CC by default
mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${INCS} ${BUILD_TOOLS_META}
- ${CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \
+ ${HOST_CC:N${CCACHE_BIN}} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} \
${.ALLSRC:N*.h:O:u} ${LDADD}
.endif
-.if ${MK_DIRDEPS_BUILD} == "yes"
+.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
BTOOLSPATH= ${HOST_OBJTOP}/${RELDIR}
.else
magic.mgc: mkmagic
diff --git a/lib/libmagic/Makefile.depend b/lib/libmagic/Makefile.depend
index 23d04fd83cf1..7bd9e2ca9bef 100644
--- a/lib/libmagic/Makefile.depend
+++ b/lib/libmagic/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libmagic.host \
lib/libz \
+ lib/msun \
.include <dirdeps.mk>
diff --git a/lib/libmagic/config.h b/lib/libmagic/config.h
index 220321c64af7..d642880d6096 100644
--- a/lib/libmagic/config.h
+++ b/lib/libmagic/config.h
@@ -1,6 +1,9 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
+/* FreeBSD */
+#include <osreldate.h>
+
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
@@ -13,36 +16,40 @@
/* Define for ELF core file support */
#define ELFCORE 1
-/* Define to 1 if you have the `asctime_r' function. */
+/* Define to 1 if you have the 'asctime_r' function. */
#define HAVE_ASCTIME_R 1
-/* Define to 1 if you have the `asprintf' function. */
+/* Define to 1 if you have the 'asprintf' function. */
#define HAVE_ASPRINTF 1
/* Define to 1 if you have the <byteswap.h> header file. */
-/* #undef HAVE_BYTESWAP_H */
+#ifndef __APPLE__ /* Cross building tools on macOS */
+#if __FreeBSD_version >= 1400079 || (__FreeBSD_version < 1400000 && __FreeBSD_version >= 1302500)
+#define HAVE_BYTESWAP_H 1
+#endif
+#endif
/* Define to 1 if you have the <bzlib.h> header file. */
/* #undef HAVE_BZLIB_H */
-/* Define to 1 if you have the `ctime_r' function. */
+/* Define to 1 if you have the 'ctime_r' function. */
#define HAVE_CTIME_R 1
/* HAVE_DAYLIGHT */
/* #undef HAVE_DAYLIGHT */
-/* Define to 1 if you have the declaration of `daylight', and to 0 if you
+/* Define to 1 if you have the declaration of 'daylight', and to 0 if you
don't. */
#define HAVE_DECL_DAYLIGHT 0
-/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
+/* Define to 1 if you have the declaration of 'tzname', and to 0 if you don't.
*/
#define HAVE_DECL_TZNAME 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
-/* Define to 1 if you have the `dprintf' function. */
+/* Define to 1 if you have the 'dprintf' function. */
#define HAVE_DPRINTF 1
/* Define to 1 if you have the <err.h> header file. */
@@ -51,57 +58,72 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
-/* Define to 1 if you have the `fmtcheck' function. */
+/* Define to 1 if you have the 'fmtcheck' function. */
#define HAVE_FMTCHECK 1
-/* Define to 1 if you have the `fork' function. */
+/* Define to 1 if you have the 'fork' function. */
#define HAVE_FORK 1
-/* Define to 1 if you have the `freelocale' function. */
+/* Define to 1 if you have the 'freelocale' function. */
#define HAVE_FREELOCALE 1
-/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+/* Define to 1 if fseeko (and ftello) are declared in stdio.h. */
#define HAVE_FSEEKO 1
-/* Define to 1 if you have the `getline' function. */
+/* Define to 1 if you have the 'getline' function. */
#define HAVE_GETLINE 1
/* Define to 1 if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
-/* Define to 1 if you have the `getopt_long' function. */
+/* Define to 1 if you have the 'getopt_long' function. */
#define HAVE_GETOPT_LONG 1
-/* Define to 1 if you have the `getpagesize' function. */
+/* Define to 1 if you have the 'getpagesize' function. */
#define HAVE_GETPAGESIZE 1
-/* Define to 1 if you have the `gmtime_r' function. */
+/* Define to 1 if you have the 'gmtime_r' function. */
#define HAVE_GMTIME_R 1
-/* Define to 1 if the system has the type `intptr_t'. */
+/* Define to 1 if the system has the type 'intptr_t'. */
#define HAVE_INTPTR_T 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
-/* Define to 1 if you have the `bz2' library (-lbz2). */
+/* Define to 1 if you have the 'bz2' library (-lbz2). */
/* #undef HAVE_LIBBZ2 */
-/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* Define to 1 if you have the 'gnurx' library (-lgnurx). */
/* #undef HAVE_LIBGNURX */
-/* Define to 1 if you have the `lzma' library (-llzma). */
+/* Define to 1 if you have the 'lrzip' library (-llrzip). */
+/* #undef HAVE_LIBLRZIP */
+
+/* Define to 1 if you have the 'lz' library (-llz). */
+/* #undef HAVE_LIBLZ */
+
+/* Define to 1 if you have the 'lzma' library (-llzma). */
/* #undef HAVE_LIBLZMA */
-/* Define to 1 if you have the `seccomp' library (-lseccomp). */
+/* Define to 1 if you have the 'seccomp' library (-lseccomp). */
/* #undef HAVE_LIBSECCOMP */
-/* Define to 1 if you have the `z' library (-lz). */
+/* Define to 1 if you have the 'z' library (-lz). */
#define HAVE_LIBZ 1
-/* Define to 1 if you have the `localtime_r' function. */
+/* Define to 1 if you have the 'zstd' library (-lzstd). */
+/* #undef HAVE_LIBZSTD */
+
+/* Define to 1 if you have the 'localtime_r' function. */
#define HAVE_LOCALTIME_R 1
+/* Define to 1 if you have the <Lrzip.h> header file. */
+/* #undef HAVE_LRZIP_H */
+
+/* Define to 1 if you have the <lzlib.h> header file. */
+/* #undef HAVE_LZLIB_H */
+
/* Define to 1 if you have the <lzma.h> header file. */
/* #undef HAVE_LZMA_H */
@@ -111,33 +133,33 @@
/* Define to 1 if <wchar.h> declares mbstate_t. */
#define HAVE_MBSTATE_T 1
-/* Define to 1 if you have the `memmem' function. */
+/* Define to 1 if you have the 'memmem' function. */
#define HAVE_MEMMEM 1
/* Define to 1 if you have the <minix/config.h> header file. */
/* #undef HAVE_MINIX_CONFIG_H */
-/* Define to 1 if you have the `mkostemp' function. */
+/* Define to 1 if you have the 'mkostemp' function. */
#define HAVE_MKOSTEMP 1
-/* Define to 1 if you have the `mkstemp' function. */
+/* Define to 1 if you have the 'mkstemp' function. */
#define HAVE_MKSTEMP 1
-/* Define to 1 if you have a working `mmap' system call. */
+/* Define to 1 if you have a working 'mmap' system call. */
#define HAVE_MMAP 1
-/* Define to 1 if you have the `newlocale' function. */
+/* Define to 1 if you have the 'newlocale' function. */
#define HAVE_NEWLOCALE 1
-/* Define to 1 if you have the `pipe2' function. */
+/* Define to 1 if you have the 'pipe2' function. */
#ifndef __APPLE__ /* Cross building tools on macOS */
#define HAVE_PIPE2 1
#endif
-/* Define to 1 if you have the `posix_spawnp' function. */
+/* Define to 1 if you have the 'posix_spawnp' function. */
#define HAVE_POSIX_SPAWNP 1
-/* Define to 1 if you have the `pread' function. */
+/* Define to 1 if you have the 'pread' function. */
#define HAVE_PREAD 1
/* Have sig_t type */
@@ -155,7 +177,7 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
-/* Define to 1 if you have the `strcasestr' function. */
+/* Define to 1 if you have the 'strcasestr' function. */
#define HAVE_STRCASESTR 1
/* Define to 1 if you have the <strings.h> header file. */
@@ -164,28 +186,28 @@
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
-/* Define to 1 if you have the `strlcat' function. */
+/* Define to 1 if you have the 'strlcat' function. */
#define HAVE_STRLCAT 1
-/* Define to 1 if you have the `strlcpy' function. */
+/* Define to 1 if you have the 'strlcpy' function. */
#define HAVE_STRLCPY 1
-/* Define to 1 if you have the `strndup' function. */
+/* Define to 1 if you have the 'strndup' function. */
#define HAVE_STRNDUP 1
-/* Define to 1 if you have the `strtof' function. */
+/* Define to 1 if you have the 'strtof' function. */
#define HAVE_STRTOF 1
/* HAVE_STRUCT_OPTION */
#define HAVE_STRUCT_OPTION 1
-/* Define to 1 if `st_rdev' is a member of `struct stat'. */
+/* Define to 1 if 'st_rdev' is a member of 'struct stat'. */
#define HAVE_STRUCT_STAT_ST_RDEV 1
-/* Define to 1 if `tm_gmtoff' is a member of `struct tm'. */
+/* Define to 1 if 'tm_gmtoff' is a member of 'struct tm'. */
#define HAVE_STRUCT_TM_TM_GMTOFF 1
-/* Define to 1 if `tm_zone' is a member of `struct tm'. */
+/* Define to 1 if 'tm_zone' is a member of 'struct tm'. */
#define HAVE_STRUCT_TM_TM_ZONE 1
/* Define to 1 if you have the <sys/bswap.h> header file. */
@@ -227,28 +249,28 @@
/* HAVE_TZNAME */
#define HAVE_TZNAME 1
-/* Define to 1 if the system has the type `uintptr_t'. */
+/* Define to 1 if the system has the type 'uintptr_t'. */
#define HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
-/* Define to 1 if you have the `uselocale' function. */
+/* Define to 1 if you have the 'uselocale' function. */
#define HAVE_USELOCALE 1
-/* Define to 1 if you have the `utime' function. */
+/* Define to 1 if you have the 'utime' function. */
#define HAVE_UTIME 1
-/* Define to 1 if you have the `utimes' function. */
+/* Define to 1 if you have the 'utimes' function. */
#define HAVE_UTIMES 1
/* Define to 1 if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
-/* Define to 1 if you have the `vasprintf' function. */
+/* Define to 1 if you have the 'vasprintf' function. */
#define HAVE_VASPRINTF 1
-/* Define to 1 if you have the `vfork' function. */
+/* Define to 1 if you have the 'vfork' function. */
#define HAVE_VFORK 1
/* Define to 1 if you have the <vfork.h> header file. */
@@ -264,13 +286,13 @@
/* Define to 1 if you have the <wctype.h> header file. */
#define HAVE_WCTYPE_H 1
-/* Define to 1 if you have the `wcwidth' function. */
+/* Define to 1 if you have the 'wcwidth' function. */
#define HAVE_WCWIDTH 1
-/* Define to 1 if `fork' works. */
+/* Define to 1 if 'fork' works. */
#define HAVE_WORKING_FORK 1
-/* Define to 1 if `vfork' works. */
+/* Define to 1 if 'vfork' works. */
#define HAVE_WORKING_VFORK 1
/* Define to 1 if you have the <xlocale.h> header file. */
@@ -281,14 +303,26 @@
/* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1
+/* Define to 1 if you have the <zstd_errors.h> header file. */
+/* #undef HAVE_ZSTD_ERRORS_H */
+
+/* Define to 1 if you have the <zstd.h> header file. */
+/* #undef HAVE_ZSTD_H */
+
+/* Enable lrziplib compression support */
+/* #undef LRZIPLIBSUPPORT */
+
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
-/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
+/* Enable lzlib compression support */
+/* #undef LZLIBSUPPORT */
+
+/* Define to 1 if 'major', 'minor', and 'makedev' are declared in <mkdev.h>.
*/
/* #undef MAJOR_IN_MKDEV */
-/* Define to 1 if `major', `minor', and `makedev' are declared in
+/* Define to 1 if 'major', 'minor', and 'makedev' are declared in
<sysmacros.h>. */
/* #undef MAJOR_IN_SYSMACROS */
@@ -302,7 +336,7 @@
#define PACKAGE_NAME "file"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "file 5.43"
+#define PACKAGE_STRING "file 5.46"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "file"
@@ -311,17 +345,17 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "5.43"
+#define PACKAGE_VERSION "5.46"
-/* Define to 1 if all of the C90 standard headers exist (not just the ones
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#define STDC_HEADERS 1
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* Define to 1 if your <sys/time.h> declares 'struct tm'. */
/* #undef TM_IN_SYS_TIME */
-/* Enable extensions on AIX 3, Interix. */
+/* Enable extensions on AIX, Interix, z/OS. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
@@ -382,11 +416,15 @@
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
#endif
+/* Enable extensions specified by C23 Annex F. */
+#ifndef __STDC_WANT_IEC_60559_EXT__
+# define __STDC_WANT_IEC_60559_EXT__ 1
+#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
#endif
-/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
+/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
#endif
@@ -410,7 +448,7 @@
/* Version number of package */
-#define VERSION "5.43"
+#define VERSION "5.46"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
@@ -430,15 +468,21 @@
/* Enable zlib compression support */
#define ZLIBSUPPORT 1
+/* Enable zstdlib compression support */
+/* #undef ZSTDLIBSUPPORT */
+
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
-/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* Define to 1 if necessary to make fseeko visible. */
/* #undef _LARGEFILE_SOURCE */
-/* Define for large files, on AIX-style hosts. */
+/* Define to 1 on platforms where this makes off_t a 64-bit type. */
/* #undef _LARGE_FILES */
+/* Number of bits in time_t, on hosts where this is settable. */
+/* #undef _TIME_BITS */
+
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
@@ -454,6 +498,9 @@
#define below would cause a syntax error. */
/* #undef _UINT8_T */
+/* Define to 1 on platforms where this makes time_t a 64-bit type. */
+/* #undef __MINGW_USE_VC2005_COMPAT */
+
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
/* #undef int32_t */
@@ -469,13 +516,13 @@
/* Define to a type if <wchar.h> does not define. */
/* #undef mbstate_t */
-/* Define to `long int' if <sys/types.h> does not define. */
+/* Define to 'long int' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define as a signed integer type capable of holding a process identifier. */
/* #undef pid_t */
-/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* Define as 'unsigned int' if <stddef.h> doesn't define. */
/* #undef size_t */
/* Define to the type of an unsigned integer type of width exactly 16 bits if
@@ -498,5 +545,5 @@
pointer, if such a type exists, and if the system does not define it. */
/* #undef uintptr_t */
-/* Define as `fork' if `vfork' does not work. */
+/* Define as 'fork' if 'vfork' does not work. */
/* #undef vfork */
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile
index bafcd5b46c19..547a134fc440 100644
--- a/lib/libmd/Makefile
+++ b/lib/libmd/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -6,7 +5,7 @@ SHLIBDIR?= /lib
PACKAGE= runtime
LIB= md
-SHLIB_MAJOR= 6
+SHLIB_MAJOR= 7
SRCS= md4c.c md5c.c md4hl.c md5hl.c \
rmd160c.c rmd160hl.c \
sha0c.c sha0hl.c sha1c.c sha1hl.c \
@@ -20,6 +19,9 @@ INCS= md4.h md5.h ripemd.h sha.h sha224.h sha256.h sha384.h sha512.h \
WARNS?= 0
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
+SYMBOL_MAPS= ${.CURDIR}/Symbol.map
+
MAN+= md4.3 md5.3 ripemd.3 sha.3 sha256.3 sha512.3 skein.3
MLINKS+=md4.3 MD4Init.3 md4.3 MD4Update.3 md4.3 MD4Final.3
MLINKS+=md4.3 MD4End.3 md4.3 MD4File.3 md4.3 MD4FileChunk.3
@@ -106,6 +108,7 @@ CFLAGS+= -DWEAK_REFS
CFLAGS.skein_block.c+= -DSKEIN_LOOP=995
.PATH: ${.CURDIR}/${MACHINE_ARCH} ${SRCTOP}/sys/crypto/sha2
.PATH: ${SRCTOP}/sys/crypto/skein ${SRCTOP}/sys/crypto/skein/${MACHINE_ARCH}
+.PATH: ${SRCTOP}/sys/kern
USE_ASM_SOURCES?=1
.if defined(BOOTSTRAPPING) || ${MK_MACHDEP_OPTIMIZATIONS} == no
@@ -114,9 +117,12 @@ USE_ASM_SOURCES:=0
.endif
.if ${USE_ASM_SOURCES} != 0
-.if exists(${MACHINE_ARCH}/sha.S)
-SRCS+= sha.S
+.if exists(${MACHINE_ARCH}/sha1block.S)
+SRCS+= sha1block.S
CFLAGS+= -DSHA1_ASM
+.if exists(${MACHINE_ARCH}/sha1dispatch.c)
+SRCS+= sha1dispatch.c
+.endif
.endif
.if exists(${MACHINE_ARCH}/rmd160.S)
SRCS+= rmd160.S
@@ -132,7 +138,7 @@ CFLAGS+= -DSKEIN_ASM -DSKEIN_USE_ASM=1792 # list of block functions to replace w
# the assembly vs C versions, and skein_block needs to be rebuilt if it changes.
skein_block.o skein_block.pico: Makefile
.endif
-.if exists(${MACHINE_ARCH}/sha.S) || exists(${MACHINE_ARCH}/rmd160.S) || exists(${MACHINE_ARCH}/skein_block_asm.S)
+.if exists(${MACHINE_ARCH}/rmd160.S) || exists(${MACHINE_ARCH}/skein_block_asm.S)
ACFLAGS+= -DELF -Wa,--noexecstack
.endif
.if ${MACHINE_CPUARCH} == "aarch64"
@@ -234,248 +240,7 @@ md${i}.3: ${.CURDIR}/mdX.3
cat ${.CURDIR}/md${i}.copyright >> ${.TARGET}
.endfor
-md4.ref:
- echo 'MD4 test suite:' > ${.TARGET}
- @echo 'MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0' >> ${.TARGET}
- @echo 'MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24' >> ${.TARGET}
- @echo 'MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d' >> ${.TARGET}
- @echo 'MD4 ("message digest") = d9130a8164549fe818874806e1c7014b' >> ${.TARGET}
- @echo 'MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9' >> ${.TARGET}
- @echo 'MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '043f8582f241db351ce627e153e7f0e4' >> ${.TARGET}
- @echo 'MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- 'e33b4ddc9c38f2199c3e7b164fcc0536' >> ${.TARGET}
-
-md5.ref:
- echo 'MD5 test suite:' > ${.TARGET}
- @echo 'MD5 ("") = d41d8cd98f00b204e9800998ecf8427e' >> ${.TARGET}
- @echo 'MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661' >> ${.TARGET}
- @echo 'MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72' >> ${.TARGET}
- @echo 'MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0' >> ${.TARGET}
- @echo 'MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b' >> ${.TARGET}
- @echo 'MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = d174ab98d277d9f5a5611c2c9f419d9f' >> ${.TARGET}
- @echo 'MD5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a' >> ${.TARGET}
-
-sha0.ref:
- echo 'SHA-0 test suite:' > ${.TARGET}
- @echo 'SHA-0 ("") = f96cea198ad1dd5617ac084a3d92c6107708c0ef' >> ${.TARGET}
- @echo 'SHA-0 ("abc") = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880' >> ${.TARGET}
- @echo 'SHA-0 ("message digest") =' \
- 'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14' >> ${.TARGET}
- @echo 'SHA-0 ("abcdefghijklmnopqrstuvwxyz") =' \
- 'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd' >> ${.TARGET}
- @echo 'SHA-0 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '79e966f7a3a990df33e40e3d7f8f18d2caebadfa' >> ${.TARGET}
- @echo 'SHA-0 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '4aa29d14d171522ece47bee8957e35a41f3e9cff' >> ${.TARGET}
-
-sha1.ref:
- echo 'SHA-1 test suite:' > ${.TARGET}
- @echo 'SHA-1 ("") = da39a3ee5e6b4b0d3255bfef95601890afd80709' >> ${.TARGET}
- @echo 'SHA-1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d' >> ${.TARGET}
- @echo 'SHA-1 ("message digest") =' \
- 'c12252ceda8be8994d5fa0290a47231c1d16aae3' >> ${.TARGET}
- @echo 'SHA-1 ("abcdefghijklmnopqrstuvwxyz") =' \
- '32d10c7b8cf96570ca04ce37f2a19d84240d3a89' >> ${.TARGET}
- @echo 'SHA-1 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '761c457bf73b14d27e9e9265c46f4b4dda11f940' >> ${.TARGET}
- @echo 'SHA-1 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '50abf5706a150990a08b2c5ea40fa0e585554732' >> ${.TARGET}
-
-sha224.ref:
- echo 'SHA-224 test suite:' > ${.TARGET}
- @echo 'SHA-224 ("") = d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f' >> ${.TARGET}
- @echo 'SHA-224 ("abc") =' \
- '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7' >> ${.TARGET}
- @echo 'SHA-224 ("message digest") =' \
- '2cb21c83ae2f004de7e81c3c7019cbcb65b71ab656b22d6d0c39b8eb' >> ${.TARGET}
- @echo 'SHA-224 ("abcdefghijklmnopqrstuvwxyz") =' \
- '45a5f72c39c5cff2522eb3429799e49e5f44b356ef926bcf390dccc2' >> ${.TARGET}
- @echo 'SHA-224 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- 'bff72b4fcb7d75e5632900ac5f90d219e05e97a7bde72e740db393d9' >> ${.TARGET}
- @echo 'SHA-224 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- 'b50aecbe4e9bb0b57bc5f3ae760a8e01db24f203fb3cdcd13148046e' >> ${.TARGET}
-
-sha256.ref:
- echo 'SHA-256 test suite:' > ${.TARGET}
- @echo 'SHA-256 ("") = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' >> ${.TARGET}
- @echo 'SHA-256 ("abc") =' \
- 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' >> ${.TARGET}
- @echo 'SHA-256 ("message digest") =' \
- 'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650' >> ${.TARGET}
- @echo 'SHA-256 ("abcdefghijklmnopqrstuvwxyz") =' \
- '71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73' >> ${.TARGET}
- @echo 'SHA-256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- 'db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0' >> ${.TARGET}
- @echo 'SHA-256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- 'f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e' >> ${.TARGET}
-
-sha384.ref:
- echo 'SHA-384 test suite:' > ${.TARGET}
- @echo 'SHA-384 ("") =' \
- '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' >> ${.TARGET}
- @echo 'SHA-384 ("abc") =' \
- 'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7' >> ${.TARGET}
- @echo 'SHA-384 ("message digest") =' \
- '473ed35167ec1f5d8e550368a3db39be54639f828868e9454c239fc8b52e3c61dbd0d8b4de1390c256dcbb5d5fd99cd5' >> ${.TARGET}
- @echo 'SHA-384 ("abcdefghijklmnopqrstuvwxyz") =' \
- 'feb67349df3db6f5924815d6c3dc133f091809213731fe5c7b5f4999e463479ff2877f5f2936fa63bb43784b12f3ebb4' >> ${.TARGET}
- @echo 'SHA-384 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039c1464ee8732f11a5341a6f41e0c202294736ed64db1a84' >> ${.TARGET}
- @echo 'SHA-384 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- 'b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026' >> ${.TARGET}
-
-sha512.ref:
- echo 'SHA-512 test suite:' > ${.TARGET}
- @echo 'SHA-512 ("") =' \
- 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e' >> ${.TARGET}
- @echo 'SHA-512 ("abc") =' \
- 'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f' >> ${.TARGET}
- @echo 'SHA-512 ("message digest") =' \
- '107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c' >> ${.TARGET}
- @echo 'SHA-512 ("abcdefghijklmnopqrstuvwxyz") =' \
- '4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1' >> ${.TARGET}
- @echo 'SHA-512 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894' >> ${.TARGET}
- @echo 'SHA-512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843' >> ${.TARGET}
-
-sha512t224.ref:
- echo 'SHA-512224 test suite:' > ${.TARGET}
- @echo 'SHA-512224 ("") =' \
- '6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4' >> ${.TARGET}
- @echo 'SHA-512224 ("abc") =' \
- '4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa' >> ${.TARGET}
- @echo 'SHA-512224 ("message digest") =' \
- 'ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564' >> ${.TARGET}
- @echo 'SHA-512224 ("abcdefghijklmnopqrstuvwxyz") =' \
- 'ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8' >> ${.TARGET}
- @echo 'SHA-512224 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- 'a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3' >> ${.TARGET}
- @echo 'SHA-512224 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- 'ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2' >> ${.TARGET}
-
-sha512t256.ref:
- echo 'SHA-512256 test suite:' > ${.TARGET}
- @echo 'SHA-512256 ("") =' \
- 'c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a' >> ${.TARGET}
- @echo 'SHA-512256 ("abc") =' \
- '53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23' >> ${.TARGET}
- @echo 'SHA-512256 ("message digest") =' \
- '0cf471fd17ed69d990daf3433c89b16d63dec1bb9cb42a6094604ee5d7b4e9fb' >> ${.TARGET}
- @echo 'SHA-512256 ("abcdefghijklmnopqrstuvwxyz") =' \
- 'fc3189443f9c268f626aea08a756abe7b726b05f701cb08222312ccfd6710a26' >> ${.TARGET}
- @echo 'SHA-512256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- 'cdf1cc0effe26ecc0c13758f7b4a48e000615df241284185c39eb05d355bb9c8' >> ${.TARGET}
- @echo 'SHA-512256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '2c9fdbc0c90bdd87612ee8455474f9044850241dc105b1e8b94b8ddf5fac9148' >> ${.TARGET}
-
-rmd160.ref:
- echo 'RIPEMD160 test suite:' > ${.TARGET}
- @echo 'RIPEMD160 ("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31' >> ${.TARGET}
- @echo 'RIPEMD160 ("abc") = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc' >> ${.TARGET}
- @echo 'RIPEMD160 ("message digest") =' \
- '5d0689ef49d2fae572b881b123a85ffa21595f36' >> ${.TARGET}
- @echo 'RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") =' \
- 'f71c27109c692c1b56bbdceb5b9d2865b3708dbc' >> ${.TARGET}
- @echo 'RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- 'b0e20b6e3116640286ed3a87a5713079b21f5189' >> ${.TARGET}
- @echo 'RIPEMD160 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '9b752e45573d4b39f4dbd3323cab82bf63326bfb' >> ${.TARGET}
-
-skein256.ref:
- echo 'SKEIN256 test suite:' > ${.TARGET}
- @echo 'SKEIN256 ("") = c8877087da56e072870daa843f176e9453115929094c3a40c463a196c29bf7ba' >> ${.TARGET}
- @echo 'SKEIN256 ("abc") = 258bdec343b9fde1639221a5ae0144a96e552e5288753c5fec76c05fc2fc1870' >> ${.TARGET}
- @echo 'SKEIN256 ("message digest") =' \
- '4d2ce0062b5eb3a4db95bc1117dd8aa014f6cd50fdc8e64f31f7d41f9231e488' >> ${.TARGET}
- @echo 'SKEIN256 ("abcdefghijklmnopqrstuvwxyz") =' \
- '46d8440685461b00e3ddb891b2ecc6855287d2bd8834a95fb1c1708b00ea5e82' >> ${.TARGET}
- @echo 'SKEIN256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '7c5eb606389556b33d34eb2536459528dc0af97adbcd0ce273aeb650f598d4b2' >> ${.TARGET}
- @echo 'SKEIN256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '4def7a7e5464a140ae9c3a80279fbebce4bd00f9faad819ab7e001512f67a10d' >> ${.TARGET}
-
-skein512.ref:
- echo 'SKEIN512 test suite:' > ${.TARGET}
- @echo 'SKEIN512 ("") =' \
- 'bc5b4c50925519c290cc634277ae3d6257212395cba733bbad37a4af0fa06af41fca7903d06564fea7a2d3730dbdb80c1f85562dfcc070334ea4d1d9e72cba7a' >> ${.TARGET}
- @echo 'SKEIN512 ("abc") =' \
- '8f5dd9ec798152668e35129496b029a960c9a9b88662f7f9482f110b31f9f93893ecfb25c009baad9e46737197d5630379816a886aa05526d3a70df272d96e75' >> ${.TARGET}
- @echo 'SKEIN512 ("message digest") =' \
- '15b73c158ffb875fed4d72801ded0794c720b121c0c78edf45f900937e6933d9e21a3a984206933d504b5dbb2368000411477ee1b204c986068df77886542fcc' >> ${.TARGET}
- @echo 'SKEIN512 ("abcdefghijklmnopqrstuvwxyz") =' \
- '23793ad900ef12f9165c8080da6fdfd2c8354a2929b8aadf83aa82a3c6470342f57cf8c035ec0d97429b626c4d94f28632c8f5134fd367dca5cf293d2ec13f8c' >> ${.TARGET}
- @echo 'SKEIN512 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- '0c6bed927e022f5ddcf81877d42e5f75798a9f8fd3ede3d83baac0a2f364b082e036c11af35fe478745459dd8f5c0b73efe3c56ba5bb2009208d5a29cc6e469c' >> ${.TARGET}
- @echo 'SKEIN512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- '2ca9fcffb3456f297d1b5f407014ecb856f0baac8eb540f534b1f187196f21e88f31103128c2f03fcc9857d7a58eb66f9525e2302d88833ee069295537a434ce' >> ${.TARGET}
-
-skein1024.ref:
- echo 'SKEIN1024 test suite:' > ${.TARGET}
- @echo 'SKEIN1024 ("") =' \
- '0fff9563bb3279289227ac77d319b6fff8d7e9f09da1247b72a0a265cd6d2a62645ad547ed8193db48cff847c06494a03f55666d3b47eb4c20456c9373c86297d630d5578ebd34cb40991578f9f52b18003efa35d3da6553ff35db91b81ab890bec1b189b7f52cb2a783ebb7d823d725b0b4a71f6824e88f68f982eefc6d19c6' >> ${.TARGET}
- @echo 'SKEIN1024 ("abc") =' \
- '35a599a0f91abcdb4cb73c19b8cb8d947742d82c309137a7caed29e8e0a2ca7a9ff9a90c34c1908cc7e7fd99bb15032fb86e76df21b72628399b5f7c3cc209d7bb31c99cd4e19465622a049afbb87c03b5ce3888d17e6e667279ec0aa9b3e2712624c01b5f5bbe1a564220bdcf6990af0c2539019f313fdd7406cca3892a1f1f' >> ${.TARGET}
- @echo 'SKEIN1024 ("message digest") =' \
- 'ea891f5268acd0fac97467fc1aa89d1ce8681a9992a42540e53babee861483110c2d16f49e73bac27653ff173003e40cfb08516cd34262e6af95a5d8645c9c1abb3e813604d508b8511b30f9a5c1b352aa0791c7d2f27b2706dccea54bc7de6555b5202351751c3299f97c09cf89c40f67187e2521c0fad82b30edbb224f0458' >> ${.TARGET}
- @echo 'SKEIN1024 ("abcdefghijklmnopqrstuvwxyz") =' \
- 'f23d95c2a25fbcd0e797cd058fec39d3c52d2b5afd7a9af1df934e63257d1d3dcf3246e7329c0f1104c1e51e3d22e300507b0c3b9f985bb1f645ef49835080536becf83788e17fed09c9982ba65c3cb7ffe6a5f745b911c506962adf226e435c42f6f6bc08d288f9c810e807e3216ef444f3db22744441deefa4900982a1371f' >> ${.TARGET}
- @echo 'SKEIN1024 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
- 'cf3889e8a8d11bfd3938055d7d061437962bc5eac8ae83b1b71c94be201b8cf657fdbfc38674997a008c0c903f56a23feb3ae30e012377f1cfa080a9ca7fe8b96138662653fb3335c7d06595bf8baf65e215307532094cfdfa056bd8052ab792a3944a2adaa47b30335b8badb8fe9eb94fe329cdca04e58bbc530f0af709f469' >> ${.TARGET}
- @echo 'SKEIN1024 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
- 'cf21a613620e6c119eca31fdfaad449a8e02f95ca256c21d2a105f8e4157048f9fe1e897893ea18b64e0e37cb07d5ac947f27ba544caf7cbc1ad094e675aed77a366270f7eb7f46543bccfa61c526fd628408058ed00ed566ac35a9761d002e629c4fb0d430b2f4ad016fcc49c44d2981c4002da0eecc42144160e2eaea4855a' >> ${.TARGET}
-
-test: md4.ref md5.ref sha0.ref rmd160.ref sha1.ref sha224.ref sha256.ref sha384.ref \
- sha512.ref sha512t224.ref sha512t256.ref skein256.ref skein512.ref skein1024.ref
- @${ECHO} if any of these test fail, the code produces wrong results
- @${ECHO} and should NOT be used.
- ${CC} ${CFLAGS} ${LDFLAGS} -DMD=4 -o mddriver ${.CURDIR}/mddriver.c libmd.a
- ./mddriver | cmp md4.ref -
- @${ECHO} MD4 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DMD=5 -o mddriver ${.CURDIR}/mddriver.c libmd.a
- ./mddriver | cmp md5.ref -
- @${ECHO} MD5 passed test
- -rm -f mddriver
- ${CC} ${CFLAGS} ${LDFLAGS} -o rmddriver ${.CURDIR}/rmddriver.c libmd.a
- ./rmddriver | cmp rmd160.ref -
- @${ECHO} RIPEMD160 passed test
- -rm -f rmddriver
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=0 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha0.ref -
- @${ECHO} SHA-0 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=1 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha1.ref -
- @${ECHO} SHA-1 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=224 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha224.ref -
- @${ECHO} SHA-224 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=256 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha256.ref -
- @${ECHO} SHA-256 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=384 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha384.ref -
- @${ECHO} SHA-384 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha512.ref -
- @${ECHO} SHA-512 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512224 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha512t224.ref -
- @${ECHO} SHA-512t224 passed test
- -rm -f shadriver
- ${CC} ${CFLAGS} ${LDFLAGS} -DSHA=512256 -o shadriver ${.CURDIR}/shadriver.c libmd.a
- ./shadriver | cmp sha512t256.ref -
- @${ECHO} SHA-512t256 passed test
- -rm -f shadriver
- ${CC} ${CFLAGS} ${LDFLAGS} -DSKEIN=256 -o skeindriver ${.CURDIR}/skeindriver.c libmd.a
- ./skeindriver | cmp skein256.ref -
- @${ECHO} SKEIN256 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSKEIN=512 -o skeindriver ${.CURDIR}/skeindriver.c libmd.a
- ./skeindriver | cmp skein512.ref -
- @${ECHO} SKEIN512 passed test
- ${CC} ${CFLAGS} ${LDFLAGS} -DSKEIN=1024 -o skeindriver ${.CURDIR}/skeindriver.c libmd.a
- ./skeindriver | cmp skein1024.ref -
- @${ECHO} SKEIN1024 passed test
- -rm -f skeindriver
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
.include <bsd.lib.mk>
diff --git a/lib/libmd/Symbol.map b/lib/libmd/Symbol.map
new file mode 100644
index 000000000000..c3ea3a43968f
--- /dev/null
+++ b/lib/libmd/Symbol.map
@@ -0,0 +1,256 @@
+FBSD_1.8 {
+ MD4Data;
+ MD4End;
+ MD4Fd;
+ MD4FdChunk;
+ MD4File;
+ MD4FileChunk;
+ MD4Final;
+ MD4Init;
+ MD4Pad;
+ MD4Update;
+ MD5Data;
+ MD5End;
+ MD5Fd;
+ MD5FdChunk;
+ MD5File;
+ MD5FileChunk;
+ MD5Final;
+ MD5Init;
+ MD5Update;
+ RIPEMD160_Data;
+ RIPEMD160_End;
+ RIPEMD160_Fd;
+ RIPEMD160_FdChunk;
+ RIPEMD160_File;
+ RIPEMD160_FileChunk;
+ RIPEMD160_Final;
+ RIPEMD160_Init;
+ RIPEMD160_Update;
+ SHA1_Data;
+ SHA1_End;
+ SHA1_Fd;
+ SHA1_FdChunk;
+ SHA1_File;
+ SHA1_FileChunk;
+ SHA1_Final;
+ SHA1_Init;
+ SHA1_Update;
+ SHA224_Data;
+ SHA224_End;
+ SHA224_Fd;
+ SHA224_FdChunk;
+ SHA224_File;
+ SHA224_FileChunk;
+ SHA224_Final;
+ SHA224_Init;
+ SHA224_Update;
+ SHA256_Data;
+ SHA256_End;
+ SHA256_Fd;
+ SHA256_FdChunk;
+ SHA256_File;
+ SHA256_FileChunk;
+ SHA256_Final;
+ SHA256_Init;
+ SHA256_Update;
+ SHA384_Data;
+ SHA384_End;
+ SHA384_Fd;
+ SHA384_FdChunk;
+ SHA384_File;
+ SHA384_FileChunk;
+ SHA384_Final;
+ SHA384_Init;
+ SHA384_Update;
+ SHA512_224_Data;
+ SHA512_224_End;
+ SHA512_224_Fd;
+ SHA512_224_FdChunk;
+ SHA512_224_File;
+ SHA512_224_FileChunk;
+ SHA512_224_Final;
+ SHA512_224_Init;
+ SHA512_224_Update;
+ SHA512_256_Data;
+ SHA512_256_End;
+ SHA512_256_Fd;
+ SHA512_256_FdChunk;
+ SHA512_256_File;
+ SHA512_256_FileChunk;
+ SHA512_256_Final;
+ SHA512_256_Init;
+ SHA512_256_Update;
+ SHA512_Data;
+ SHA512_End;
+ SHA512_Fd;
+ SHA512_FdChunk;
+ SHA512_File;
+ SHA512_FileChunk;
+ SHA512_Final;
+ SHA512_Init;
+ SHA512_Update;
+ SHA_Data;
+ SHA_End;
+ SHA_Fd;
+ SHA_FdChunk;
+ SHA_File;
+ SHA_FileChunk;
+ SKEIN1024_Data;
+ SKEIN1024_End;
+ SKEIN1024_Fd;
+ SKEIN1024_FdChunk;
+ SKEIN1024_File;
+ SKEIN1024_FileChunk;
+ SKEIN1024_Final;
+ SKEIN1024_Init;
+ SKEIN1024_Update;
+ SKEIN256_Data;
+ SKEIN256_End;
+ SKEIN256_Fd;
+ SKEIN256_FdChunk;
+ SKEIN256_File;
+ SKEIN256_FileChunk;
+ SKEIN256_Final;
+ SKEIN256_Init;
+ SKEIN256_Update;
+ SKEIN512_Data;
+ SKEIN512_End;
+ SKEIN512_Fd;
+ SKEIN512_FdChunk;
+ SKEIN512_File;
+ SKEIN512_FileChunk;
+ SKEIN512_Final;
+ SKEIN512_Init;
+ SKEIN512_Update;
+};
+
+FBSDprivate_1.0 {
+ _libmd_MD4Data;
+ _libmd_MD4End;
+ _libmd_MD4Fd;
+ _libmd_MD4FdChunk;
+ _libmd_MD4File;
+ _libmd_MD4FileChunk;
+ _libmd_MD4Final;
+ _libmd_MD4Init;
+ _libmd_MD4Pad;
+ _libmd_MD4Update;
+ _libmd_MD5Data;
+ _libmd_MD5End;
+ _libmd_MD5Fd;
+ _libmd_MD5FdChunk;
+ _libmd_MD5File;
+ _libmd_MD5FileChunk;
+ _libmd_MD5Final;
+ _libmd_MD5Init;
+ _libmd_MD5Update;
+ _libmd_RIPEMD160_Data;
+ _libmd_RIPEMD160_End;
+ _libmd_RIPEMD160_Fd;
+ _libmd_RIPEMD160_FdChunk;
+ _libmd_RIPEMD160_File;
+ _libmd_RIPEMD160_FileChunk;
+ _libmd_RIPEMD160_Final;
+ _libmd_RIPEMD160_Init;
+ _libmd_RIPEMD160_Update;
+ _libmd_SHA1_Data;
+ _libmd_SHA1_End;
+ _libmd_SHA1_Fd;
+ _libmd_SHA1_FdChunk;
+ _libmd_SHA1_File;
+ _libmd_SHA1_FileChunk;
+ _libmd_SHA1_Final;
+ _libmd_SHA1_Init;
+ _libmd_SHA1_Update;
+ _libmd_SHA224_Data;
+ _libmd_SHA224_End;
+ _libmd_SHA224_Fd;
+ _libmd_SHA224_FdChunk;
+ _libmd_SHA224_File;
+ _libmd_SHA224_FileChunk;
+ _libmd_SHA224_Final;
+ _libmd_SHA224_Init;
+ _libmd_SHA224_Update;
+ _libmd_SHA256_Data;
+ _libmd_SHA256_End;
+ _libmd_SHA256_Fd;
+ _libmd_SHA256_FdChunk;
+ _libmd_SHA256_File;
+ _libmd_SHA256_FileChunk;
+ _libmd_SHA256_Final;
+ _libmd_SHA256_Init;
+ _libmd_SHA256_Update;
+ _libmd_SHA384_Data;
+ _libmd_SHA384_End;
+ _libmd_SHA384_Fd;
+ _libmd_SHA384_FdChunk;
+ _libmd_SHA384_File;
+ _libmd_SHA384_FileChunk;
+ _libmd_SHA384_Final;
+ _libmd_SHA384_Init;
+ _libmd_SHA384_Update;
+ _libmd_SHA512_224_Data;
+ _libmd_SHA512_224_End;
+ _libmd_SHA512_224_Fd;
+ _libmd_SHA512_224_FdChunk;
+ _libmd_SHA512_224_File;
+ _libmd_SHA512_224_FileChunk;
+ _libmd_SHA512_224_Final;
+ _libmd_SHA512_224_Init;
+ _libmd_SHA512_224_Update;
+ _libmd_SHA512_256_Data;
+ _libmd_SHA512_256_End;
+ _libmd_SHA512_256_Fd;
+ _libmd_SHA512_256_FdChunk;
+ _libmd_SHA512_256_File;
+ _libmd_SHA512_256_FileChunk;
+ _libmd_SHA512_256_Final;
+ _libmd_SHA512_256_Init;
+ _libmd_SHA512_256_Update;
+ _libmd_SHA512_Data;
+ _libmd_SHA512_End;
+ _libmd_SHA512_Fd;
+ _libmd_SHA512_FdChunk;
+ _libmd_SHA512_File;
+ _libmd_SHA512_FileChunk;
+ _libmd_SHA512_Final;
+ _libmd_SHA512_Init;
+ _libmd_SHA512_Update;
+ _libmd_SHA_Data;
+ _libmd_SHA_End;
+ _libmd_SHA_Fd;
+ _libmd_SHA_FdChunk;
+ _libmd_SHA_File;
+ _libmd_SHA_FileChunk;
+ _libmd_SHA_Final;
+ _libmd_SHA_Init;
+ _libmd_SHA_Update;
+ _libmd_SKEIN1024_Data;
+ _libmd_SKEIN1024_End;
+ _libmd_SKEIN1024_Fd;
+ _libmd_SKEIN1024_FdChunk;
+ _libmd_SKEIN1024_File;
+ _libmd_SKEIN1024_FileChunk;
+ _libmd_SKEIN1024_Final;
+ _libmd_SKEIN1024_Init;
+ _libmd_SKEIN1024_Update;
+ _libmd_SKEIN256_Data;
+ _libmd_SKEIN256_End;
+ _libmd_SKEIN256_Fd;
+ _libmd_SKEIN256_FdChunk;
+ _libmd_SKEIN256_File;
+ _libmd_SKEIN256_FileChunk;
+ _libmd_SKEIN256_Final;
+ _libmd_SKEIN256_Init;
+ _libmd_SKEIN256_Update;
+ _libmd_SKEIN512_Data;
+ _libmd_SKEIN512_End;
+ _libmd_SKEIN512_Fd;
+ _libmd_SKEIN512_FdChunk;
+ _libmd_SKEIN512_File;
+ _libmd_SKEIN512_FileChunk;
+ _libmd_SKEIN512_Final;
+ _libmd_SKEIN512_Init;
+ _libmd_SKEIN512_Update;
+};
diff --git a/lib/libmd/aarch64/sha1block.S b/lib/libmd/aarch64/sha1block.S
new file mode 100644
index 000000000000..56a0297efadd
--- /dev/null
+++ b/lib/libmd/aarch64/sha1block.S
@@ -0,0 +1,490 @@
+/*-
+ * Copyright (c) 2024 Robert Clausecker <fuz@freebsd.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * sha1block_sha1 implementation based on sha1-arm.c,
+ * written and placed in public domain by Jeffrey Walton
+ * based on code from ARM, and by Johannes Schneiders, Skip
+ * Hovsmith and Barry O'Rourke for the mbedTLS project.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * Scalar SHA1 implementation.
+ *
+ * Due to the ample register file available on AArch64, the w array is
+ * kept entirely in registers. The saved a-e variables are instead kept
+ * in memory as we don't have that much memory.
+ */
+
+ // sha1block(SHA1_CTX, buf, len)
+ENTRY(_libmd_sha1block_scalar)
+ctx .req x0
+buf .req x1
+len .req x2
+w .req sp
+a .req w3
+b .req w4
+c .req w5
+d .req w6
+e .req w7
+k .req w8
+f .req w9
+tmp .req w10
+w_0 .req w11
+w_1 .req w12
+w_2 .req w13
+w_3 .req w14
+w_4 .req w15
+w_5 .req w16
+w_6 .req w17
+// w18 is the platform register
+w_7 .req w19
+w_8 .req w20
+w_9 .req w21
+w_10 .req w22
+w_11 .req w23
+w_12 .req w24
+w_13 .req w25
+w_14 .req w26
+w_15 .req w27
+
+.macro shuffle w_i, w_i3, w_i8, w_i14
+ eor \w_i, \w_i, \w_i3
+ eor tmp, \w_i8, \w_i14
+ eor \w_i, \w_i, tmp // w[i-16] ^ w[i-14] ^ w[i-8] ^ w[i-3]
+ ror \w_i, \w_i, #31 // w[i] = ... ror #31
+.endm
+
+.macro func1 a, b, c, d, e
+ and f, \c, \b
+ bic tmp, \d, \b
+ orr f, f, tmp
+.endm
+
+.macro func2 a, b, c, d, e
+ eor f, \b, \c
+ eor f, f, \d
+.endm
+
+.macro func3 a, b, c, d, e
+ eor tmp, \b, \c
+ and f, \b, \c
+ and tmp, tmp, \d
+ orr f, f, tmp
+.endm
+
+.macro func4 a, b, c, d, e
+ func2 \a, \b, \c, \d, \e
+.endm
+
+.macro mix a, b, c, d, e, w_i
+ ror \b, \b, #2
+ ror tmp, \a, #27
+ add \e, \e, \w_i
+ add tmp, tmp, k
+ add \e, \e, f
+ add \e, \e, tmp // (a ror 27) + e + f + k + w[i]
+.endm
+
+.macro round1 a, b, c, d, e, w_i
+ func1 \a, \b, \c, \d, \e
+ rev \w_i, \w_i
+ mix \a, \b, \c, \d, \e, \w_i
+.endm
+
+.macro round func, a, b, c, d, e, w_i, w_i3, w_i8, w_i14
+ shuffle \w_i, \w_i3, \w_i8, \w_i14
+ \func \a, \b, \c, \d, \e
+ mix \a, \b, \c, \d, \e, \w_i
+.endm
+
+.macro round1x a, b, c, d, e, w_i, w_i3, w_i8, w_i14
+ round func1, \a, \b, \c, \d, \e, \w_i, \w_i3, \w_i8, \w_i14
+.endm
+
+.macro round2 a, b, c, d, e, w_i, w_i3, w_i8, w_i14
+ round func2, \a, \b, \c, \d, \e, \w_i, \w_i3, \w_i8, \w_i14
+.endm
+
+.macro round3 a, b, c, d, e, w_i, w_i3, w_i8, w_i14
+ round func3, \a, \b, \c, \d, \e, \w_i, \w_i3, \w_i8, \w_i14
+.endm
+
+.macro round4 a, b, c, d, e, w_i, w_i3, w_i8, w_i14
+ round func4, \a, \b, \c, \d, \e, \w_i, \w_i3, \w_i8, \w_i14
+.endm
+
+ ands len, len, #~63 // take length in multiples of block length
+ beq 1f // bail out if input empty
+
+ sub sp, sp, #24+9*8 // allocate stack space
+ str x19, [sp, #24+0*8]
+ stp x20, x21, [sp, #24+1*8]
+ stp x22, x23, [sp, #24+3*8]
+ stp x24, x25, [sp, #24+5*8]
+ stp x26, x27, [sp, #24+7*8]
+
+ ldp a, b, [ctx, #0] // load SHA1 state from context
+ ldp c, d, [ctx, #8]
+ ldr e, [ctx, #16]
+
+0: stp a, b, [sp, #0] // save old SHA1 state
+ stp c, d, [sp, #8]
+ str e, [sp, #16]
+
+ movz k, #0x7999 // round constant 1
+ movk k, #0x5a82, lsl #16
+
+ ldp w_0, w_1, [buf, #0*4]
+ round1 a, b, c, d, e, w_0
+ round1 e, a, b, c, d, w_1
+
+ ldp w_2, w_3, [buf, #2*4]
+ round1 d, e, a, b, c, w_2
+ round1 c, d, e, a, b, w_3
+
+ ldp w_4, w_5, [buf, #4*4]
+ round1 b, c, d, e, a, w_4
+ round1 a, b, c, d, e, w_5
+
+ ldp w_6, w_7, [buf, #6*4]
+ round1 e, a, b, c, d, w_6
+ round1 d, e, a, b, c, w_7
+
+ ldp w_8, w_9, [buf, #8*4]
+ round1 c, d, e, a, b, w_8
+ round1 b, c, d, e, a, w_9
+
+ ldp w_10, w_11, [buf, #10*4]
+ round1 a, b, c, d, e, w_10
+ round1 e, a, b, c, d, w_11
+
+ ldp w_12, w_13, [buf, #12*4]
+ round1 d, e, a, b, c, w_12
+ round1 c, d, e, a, b, w_13
+
+ ldp w_14, w_15, [buf, #14*4]
+ round1 b, c, d, e, a, w_14
+ round1 a, b, c, d, e, w_15
+
+ round1x e, a, b, c, d, w_0, w_13, w_8, w_2
+ round1x d, e, a, b, c, w_1, w_14, w_9, w_3
+ round1x c, d, e, a, b, w_2, w_15, w_10, w_4
+ round1x b, c, d, e, a, w_3, w_0, w_11, w_5
+
+ movz k, #0xeba1 // round constant 2
+ movk k, #0x6ed9, lsl #16
+
+ round2 a, b, c, d, e, w_4, w_1, w_12, w_6
+ round2 e, a, b, c, d, w_5, w_2, w_13, w_7
+ round2 d, e, a, b, c, w_6, w_3, w_14, w_8
+ round2 c, d, e, a, b, w_7, w_4, w_15, w_9
+ round2 b, c, d, e, a, w_8, w_5, w_0, w_10
+
+ round2 a, b, c, d, e, w_9, w_6, w_1, w_11
+ round2 e, a, b, c, d, w_10, w_7, w_2, w_12
+ round2 d, e, a, b, c, w_11, w_8, w_3, w_13
+ round2 c, d, e, a, b, w_12, w_9, w_4, w_14
+ round2 b, c, d, e, a, w_13, w_10, w_5, w_15
+
+ round2 a, b, c, d, e, w_14, w_11, w_6, w_0
+ round2 e, a, b, c, d, w_15, w_12, w_7, w_1
+ round2 d, e, a, b, c, w_0, w_13, w_8, w_2
+ round2 c, d, e, a, b, w_1, w_14, w_9, w_3
+ round2 b, c, d, e, a, w_2, w_15, w_10, w_4
+
+ round2 a, b, c, d, e, w_3, w_0, w_11, w_5
+ round2 e, a, b, c, d, w_4, w_1, w_12, w_6
+ round2 d, e, a, b, c, w_5, w_2, w_13, w_7
+ round2 c, d, e, a, b, w_6, w_3, w_14, w_8
+ round2 b, c, d, e, a, w_7, w_4, w_15, w_9
+
+ movz k, #0xbcdc // round constant 3
+ movk k, #0x8f1b, lsl #16
+
+ round3 a, b, c, d, e, w_8, w_5, w_0, w_10
+ round3 e, a, b, c, d, w_9, w_6, w_1, w_11
+ round3 d, e, a, b, c, w_10, w_7, w_2, w_12
+ round3 c, d, e, a, b, w_11, w_8, w_3, w_13
+ round3 b, c, d, e, a, w_12, w_9, w_4, w_14
+
+ round3 a, b, c, d, e, w_13, w_10, w_5, w_15
+ round3 e, a, b, c, d, w_14, w_11, w_6, w_0
+ round3 d, e, a, b, c, w_15, w_12, w_7, w_1
+ round3 c, d, e, a, b, w_0, w_13, w_8, w_2
+ round3 b, c, d, e, a, w_1, w_14, w_9, w_3
+
+ round3 a, b, c, d, e, w_2, w_15, w_10, w_4
+ round3 e, a, b, c, d, w_3, w_0, w_11, w_5
+ round3 d, e, a, b, c, w_4, w_1, w_12, w_6
+ round3 c, d, e, a, b, w_5, w_2, w_13, w_7
+ round3 b, c, d, e, a, w_6, w_3, w_14, w_8
+
+ round3 a, b, c, d, e, w_7, w_4, w_15, w_9
+ round3 e, a, b, c, d, w_8, w_5, w_0, w_10
+ round3 d, e, a, b, c, w_9, w_6, w_1, w_11
+ round3 c, d, e, a, b, w_10, w_7, w_2, w_12
+ round3 b, c, d, e, a, w_11, w_8, w_3, w_13
+
+ movz k, #0xc1d6 // round constant 4
+ movk k, #0xca62, lsl #16
+
+ round4 a, b, c, d, e, w_12, w_9, w_4, w_14
+ round4 e, a, b, c, d, w_13, w_10, w_5, w_15
+ round4 d, e, a, b, c, w_14, w_11, w_6, w_0
+ round4 c, d, e, a, b, w_15, w_12, w_7, w_1
+ round4 b, c, d, e, a, w_0, w_13, w_8, w_2
+
+ round4 a, b, c, d, e, w_1, w_14, w_9, w_3
+ round4 e, a, b, c, d, w_2, w_15, w_10, w_4
+ round4 d, e, a, b, c, w_3, w_0, w_11, w_5
+ round4 c, d, e, a, b, w_4, w_1, w_12, w_6
+ round4 b, c, d, e, a, w_5, w_2, w_13, w_7
+
+ round4 a, b, c, d, e, w_6, w_3, w_14, w_8
+ round4 e, a, b, c, d, w_7, w_4, w_15, w_9
+ round4 d, e, a, b, c, w_8, w_5, w_0, w_10
+ round4 c, d, e, a, b, w_9, w_6, w_1, w_11
+ round4 b, c, d, e, a, w_10, w_7, w_2, w_12
+
+ round4 a, b, c, d, e, w_11, w_8, w_3, w_13
+ round4 e, a, b, c, d, w_12, w_9, w_4, w_14
+ round4 d, e, a, b, c, w_13, w_10, w_5, w_15
+ round4 c, d, e, a, b, w_14, w_11, w_6, w_0
+ round4 b, c, d, e, a, w_15, w_12, w_7, w_1
+
+ ldp w_0, w_1, [sp, #0] // reload saved SHA1 state
+ ldp w_2, w_3, [sp, #8]
+ ldr w_4, [sp, #16]
+
+ add a, a, w_0
+ add b, b, w_1
+ add c, c, w_2
+ add d, d, w_3
+ add e, e, w_4
+
+ add buf, buf, #64
+ subs len, len, #64
+ bhi 0b
+
+ stp a, b, [ctx, #0] // write updated SHA1 state
+ stp c, d, [ctx, #8]
+ str e, [ctx, #16]
+
+ ldr x19, [sp, #24+0*8]
+ ldp x20, x21, [sp, #24+1*8]
+ ldp x22, x23, [sp, #24+3*8]
+ ldp x24, x25, [sp, #24+5*8]
+ ldp x26, x27, [sp, #24+7*8]
+ add sp, sp, #24+9*8
+
+1: ret
+END(_libmd_sha1block_scalar)
+
+/*
+ * SHA1 implementation using the SHA1 instruction set extension.
+ */
+
+ .arch_extension sha2
+
+ // sha1block(SHA1_CTX, buf, len)
+ENTRY(_libmd_sha1block_sha1)
+ /* ctx, buf, len: same as for sha1block_scalar */
+kaddr .req x3
+abcd .req v0
+abcd_q .req q0 // alias for use with scalar instructions
+abcd_s .req s0
+e0 .req s1
+e0_v .req v1
+e1 .req s2
+abcd_saved .req v3
+e0_saved .req v4
+tmp0 .req v5
+tmp1 .req v6
+msg0 .req v16
+msg1 .req v17
+msg2 .req v18
+msg3 .req v19
+k0 .req v20
+k1 .req v21
+k2 .req v22
+k3 .req v23
+
+ ands len, len, #~63 // take length in multiples of block length
+ beq 1f // bail out if input empty
+
+ ldr abcd_q, [ctx, #0]
+ ldr e0, [ctx, #16]
+
+ adrp kaddr, k1234
+ add kaddr, kaddr, #:lo12:k1234
+ ld4r {k0.4s, k1.4s, k2.4s, k3.4s}, [kaddr]
+
+0: mov abcd_saved.16b, abcd.16b
+ mov e0_saved.16b, e0_v.16b
+
+ ld1 {msg0.4s, msg1.4s, msg2.4s, msg3.4s}, [buf], #64
+ rev32 msg0.16b, msg0.16b
+ rev32 msg1.16b, msg1.16b
+ rev32 msg2.16b, msg2.16b
+ rev32 msg3.16b, msg3.16b
+
+ add tmp0.4s, msg0.4s, k0.4s
+ add tmp1.4s, msg1.4s, k0.4s
+
+ /* rounds 0--3 */
+ sha1h e1, abcd_s
+ sha1c abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg2.4s, k0.4s
+ sha1su0 msg0.4s, msg1.4s, msg2.4s
+
+ /* rounds 4--7 */
+ sha1h e0, abcd_s
+ sha1c abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg3.4s, k0.4s
+ sha1su1 msg0.4s, msg3.4s
+ sha1su0 msg1.4s, msg2.4s, msg3.4s
+
+ /* rounds 8--11 */
+ sha1h e1, abcd_s
+ sha1c abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg0.4s, k0.4s
+ sha1su1 msg1.4s, msg0.4s
+ sha1su0 msg2.4s, msg3.4s, msg0.4s
+
+ /* rounds 12--15 */
+ sha1h e0, abcd_s
+ sha1c abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg1.4s, k1.4s
+ sha1su1 msg2.4s, msg1.4s
+ sha1su0 msg3.4s, msg0.4s, msg1.4s
+
+ /* rounds 16--19 */
+ sha1h e1, abcd_s
+ sha1c abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg2.4s, k1.4s
+ sha1su1 msg3.4s, msg2.4s
+ sha1su0 msg0.4s, msg1.4s, msg2.4s
+
+ /* rounds 20--23 */
+ sha1h e0, abcd_s
+ sha1p abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg3.4s, k1.4s
+ sha1su1 msg0.4s, msg3.4s
+ sha1su0 msg1.4s, msg2.4s, msg3.4s
+
+ /* rounds 24--27 */
+ sha1h e1, abcd_s
+ sha1p abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg0.4s, k1.4s
+ sha1su1 msg1.4s, msg0.4s
+ sha1su0 msg2.4s, msg3.4s, msg0.4s
+
+ /* rounds 28--31 */
+ sha1h e0, abcd_s
+ sha1p abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg1.4s, k1.4s
+ sha1su1 msg2.4s, msg1.4s
+ sha1su0 msg3.4s, msg0.4s, msg1.4s
+
+ /* rounds 32--35 */
+ sha1h e1, abcd_s
+ sha1p abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg2.4s, k2.4s
+ sha1su1 msg3.4s, msg2.4s
+ sha1su0 msg0.4s, msg1.4s, msg2.4s
+
+ /* rounds 36--39 */
+ sha1h e0, abcd_s
+ sha1p abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg3.4s, k2.4s
+ sha1su1 msg0.4s, msg3.4s
+ sha1su0 msg1.4s, msg2.4s, msg3.4s
+
+ /* rounds 40--43 */
+ sha1h e1, abcd_s
+ sha1m abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg0.4s, k2.4s
+ sha1su1 msg1.4s, msg0.4s
+ sha1su0 msg2.4s, msg3.4s, msg0.4s
+
+ /* rounds 44--47 */
+ sha1h e0, abcd_s
+ sha1m abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg1.4s, k2.4s
+ sha1su1 msg2.4s, msg1.4s
+ sha1su0 msg3.4s, msg0.4s, msg1.4s
+
+ /* rounds 48--51 */
+ sha1h e1, abcd_s
+ sha1m abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg2.4s, k2.4s
+ sha1su1 msg3.4s, msg2.4s
+ sha1su0 msg0.4s, msg1.4s, msg2.4s
+
+ /* rounds 52--55 */
+ sha1h e0, abcd_s
+ sha1m abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg3.4s, k3.4s
+ sha1su1 msg0.4s, msg3.4s
+ sha1su0 msg1.4s, msg2.4s, msg3.4s
+
+ /* rounds 56--59 */
+ sha1h e1, abcd_s
+ sha1m abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg0.4s, k3.4s
+ sha1su1 msg1.4s, msg0.4s
+ sha1su0 msg2.4s, msg3.4s, msg0.4s
+
+ /* rounds 60--63 */
+ sha1h e0, abcd_s
+ sha1p abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg1.4s, k3.4s
+ sha1su1 msg2.4s, msg1.4s
+ sha1su0 msg3.4s, msg0.4s, msg1.4s
+
+ /* rounds 64--67 */
+ sha1h e1, abcd_s
+ sha1p abcd_q, e0, tmp0.4s
+ add tmp0.4s, msg2.4s, k3.4s
+ sha1su1 msg3.4s, msg2.4s
+ sha1su0 msg0.4s, msg1.4s, msg2.4s
+
+ /* rounds 68--71 */
+ sha1h e0, abcd_s
+ sha1p abcd_q, e1, tmp1.4s
+ add tmp1.4s, msg3.4s, k3.4s
+ sha1su1 msg0.4s, msg3.4s
+
+ /* rounds 72--75 */
+ sha1h e1, abcd_s
+ sha1p abcd_q, e0, tmp0.4s
+
+ /* rounds 76--79 */
+ sha1h e0, abcd_s
+ sha1p abcd_q, e1, tmp1.4s
+
+ add e0_v.4s, e0_v.4s, e0_saved.4s
+ add abcd.4s, abcd.4s, abcd_saved.4s
+
+ subs len, len, #64
+ bhi 0b
+
+ str abcd_q, [ctx, #0]
+ str e0, [ctx, #16]
+
+1: ret
+END(_libmd_sha1block_sha1)
+
+ .section .rodata
+ .balign 16
+k1234: .4byte 0x5a827999
+ .4byte 0x6ed9eba1
+ .4byte 0x8f1bbcdc
+ .4byte 0xca62c1d6
+ .size k1234, .-k1234
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libmd/aarch64/sha1dispatch.c b/lib/libmd/aarch64/sha1dispatch.c
new file mode 100644
index 000000000000..e34bf0a1a344
--- /dev/null
+++ b/lib/libmd/aarch64/sha1dispatch.c
@@ -0,0 +1,24 @@
+/*-
+ * Copyright (c) 2024 Robert Clausecker <fuz@freebsd.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <machine/ifunc.h>
+#include <sha.h>
+#include <sys/auxv.h>
+
+extern void _libmd_sha1block_scalar(SHA1_CTX *, const void *, size_t);
+extern void _libmd_sha1block_sha1(SHA1_CTX *, const void *, size_t);
+
+DEFINE_IFUNC(, void, sha1_block, (SHA1_CTX *, const void *, size_t))
+{
+ unsigned long hwcap = 0;
+
+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+
+ if (hwcap & HWCAP_SHA1)
+ return (_libmd_sha1block_sha1);
+ else
+ return (_libmd_sha1block_scalar);
+}
diff --git a/lib/libmd/amd64/sha1block.S b/lib/libmd/amd64/sha1block.S
new file mode 100644
index 000000000000..f1291ef2647a
--- /dev/null
+++ b/lib/libmd/amd64/sha1block.S
@@ -0,0 +1,1851 @@
+/*-
+ * Copyright (c) 2013 The Go Authors. All rights reserved.
+ * Copyright (c) 2024 Robert Clausecker <fuz@freebsd.org>
+ *
+ * Adapted from Go's crypto/sha1/sha1block_amd64.s.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * SHA-1 block routine. See sha1c.c for C equivalent.
+ *
+ * There are 80 rounds of 4 types:
+ * - rounds 0-15 are type 1 and load data (round1 macro).
+ * - rounds 16-19 are type 1 and do not load data (round1x macro).
+ * - rounds 20-39 are type 2 and do not load data (round2 macro).
+ * - rounds 40-59 are type 3 and do not load data (round3 macro).
+ * - rounds 60-79 are type 4 and do not load data (round4 macro).
+ *
+ * Each round loads or shuffles the data, then computes a per-round
+ * function of b, c, d, and then mixes the result into and rotates the
+ * five registers a, b, c, d, e holding the intermediate results.
+ *
+ * The register rotation is implemented by rotating the arguments to
+ * the round macros instead of by explicit move instructions.
+ */
+.macro load index
+ mov (\index)*4(%rsi), %r10d
+ bswap %r10d
+ mov %r10d, (\index)*4(%rsp)
+.endm
+
+.macro shuffle index
+ mov ((\index )&0xf)*4(%rsp), %r10d
+ xor ((\index- 3)&0xf)*4(%rsp), %r10d
+ xor ((\index- 8)&0xf)*4(%rsp), %r10d
+ xor ((\index-14)&0xf)*4(%rsp), %r10d
+ rol $1, %r10d
+ mov %r10d, ((\index)&0xf)*4(%rsp)
+.endm
+
+.macro func1 a, b, c, d, e
+ mov \d, %r9d
+ xor \c, %r9d
+ and \b, %r9d
+ xor \d, %r9d
+.endm
+
+.macro func2 a, b, c, d, e
+ mov \b, %r9d
+ xor \c, %r9d
+ xor \d, %r9d
+.endm
+
+.macro func3 a, b, c, d, e
+ mov \b, %r8d
+ or \c, %r8d
+ and \d, %r8d
+ mov \b, %r9d
+ and \c, %r9d
+ or %r8d, %r9d
+.endm
+
+.macro func4 a, b, c, d, e
+ func2 \a, \b, \c, \d, \e
+.endm
+
+.macro mix a, b, c, d, e, const
+ rol $30, \b
+ add %r9d, \e
+ mov \a, %r8d
+ rol $5, %r8d
+ lea \const(\e, %r10d, 1), \e
+ add %r8d, \e
+.endm
+
+.macro round1 a, b, c, d, e, index
+ load \index
+ func1 \a, \b, \c, \d, \e
+ mix \a, \b, \c, \d, \e, 0x5a827999
+.endm
+
+.macro round1x a, b, c, d, e, index
+ shuffle \index
+ func1 \a, \b, \c, \d, \e
+ mix \a, \b, \c, \d, \e, 0x5a827999
+.endm
+
+.macro round2 a, b, c, d, e, index
+ shuffle \index
+ func2 \a, \b, \c, \d, \e
+ mix \a, \b, \c, \d, \e, 0x6ed9eba1
+.endm
+
+.macro round3 a, b, c, d, e, index
+ shuffle \index
+ func3 \a, \b, \c, \d, \e
+ mix \a, \b, \c, \d, \e, 0x8f1bbcdc
+.endm
+
+.macro round4 a, b, c, d, e, index
+ shuffle \index
+ func4 \a, \b, \c, \d, \e
+ mix \a, \b, \c, \d, \e, 0xca62c1d6
+.endm
+
+ // sha1block(SHA1_CTX, buf, len)
+ENTRY(_libmd_sha1block_scalar)
+ push %rbp
+ push %rbx
+ push %r12
+ push %r13
+ push %r14
+ push %r15
+ push %rdi // rdi: SHA1_CTX
+ sub $64+8, %rsp // 64 bytes for round keys
+ // plus alignment
+
+ mov %rdi, %rbp
+ // rsi: buf
+ and $~63, %rdx // rdx: length in blocks
+ lea (%rsi, %rdx, 1), %rdi // rdi: end pointer
+ mov (%rbp), %eax // c->h0
+ mov 4(%rbp), %ebx // c->h1
+ mov 8(%rbp), %ecx // c->h2
+ mov 12(%rbp), %edx // c->h3
+ mov 16(%rbp), %ebp // c->h4
+
+ cmp %rsi, %rdi // any data to process?
+ je .Lend
+
+.Lloop: mov %eax, %r11d
+ mov %ebx, %r12d
+ mov %ecx, %r13d
+ mov %edx, %r14d
+ mov %ebp, %r15d
+
+ round1 %eax, %ebx, %ecx, %edx, %ebp, 0
+ round1 %ebp, %eax, %ebx, %ecx, %edx, 1
+ round1 %edx, %ebp, %eax, %ebx, %ecx, 2
+ round1 %ecx, %edx, %ebp, %eax, %ebx, 3
+ round1 %ebx, %ecx, %edx, %ebp, %eax, 4
+
+ round1 %eax, %ebx, %ecx, %edx, %ebp, 5
+ round1 %ebp, %eax, %ebx, %ecx, %edx, 6
+ round1 %edx, %ebp, %eax, %ebx, %ecx, 7
+ round1 %ecx, %edx, %ebp, %eax, %ebx, 8
+ round1 %ebx, %ecx, %edx, %ebp, %eax, 9
+
+ round1 %eax, %ebx, %ecx, %edx, %ebp, 10
+ round1 %ebp, %eax, %ebx, %ecx, %edx, 11
+ round1 %edx, %ebp, %eax, %ebx, %ecx, 12
+ round1 %ecx, %edx, %ebp, %eax, %ebx, 13
+ round1 %ebx, %ecx, %edx, %ebp, %eax, 14
+
+ round1 %eax, %ebx, %ecx, %edx, %ebp, 15
+ round1x %ebp, %eax, %ebx, %ecx, %edx, 16
+ round1x %edx, %ebp, %eax, %ebx, %ecx, 17
+ round1x %ecx, %edx, %ebp, %eax, %ebx, 18
+ round1x %ebx, %ecx, %edx, %ebp, %eax, 19
+
+ round2 %eax, %ebx, %ecx, %edx, %ebp, 20
+ round2 %ebp, %eax, %ebx, %ecx, %edx, 21
+ round2 %edx, %ebp, %eax, %ebx, %ecx, 22
+ round2 %ecx, %edx, %ebp, %eax, %ebx, 23
+ round2 %ebx, %ecx, %edx, %ebp, %eax, 24
+
+ round2 %eax, %ebx, %ecx, %edx, %ebp, 25
+ round2 %ebp, %eax, %ebx, %ecx, %edx, 26
+ round2 %edx, %ebp, %eax, %ebx, %ecx, 27
+ round2 %ecx, %edx, %ebp, %eax, %ebx, 28
+ round2 %ebx, %ecx, %edx, %ebp, %eax, 29
+
+ round2 %eax, %ebx, %ecx, %edx, %ebp, 30
+ round2 %ebp, %eax, %ebx, %ecx, %edx, 31
+ round2 %edx, %ebp, %eax, %ebx, %ecx, 32
+ round2 %ecx, %edx, %ebp, %eax, %ebx, 33
+ round2 %ebx, %ecx, %edx, %ebp, %eax, 34
+
+ round2 %eax, %ebx, %ecx, %edx, %ebp, 35
+ round2 %ebp, %eax, %ebx, %ecx, %edx, 36
+ round2 %edx, %ebp, %eax, %ebx, %ecx, 37
+ round2 %ecx, %edx, %ebp, %eax, %ebx, 38
+ round2 %ebx, %ecx, %edx, %ebp, %eax, 39
+
+ round3 %eax, %ebx, %ecx, %edx, %ebp, 40
+ round3 %ebp, %eax, %ebx, %ecx, %edx, 41
+ round3 %edx, %ebp, %eax, %ebx, %ecx, 42
+ round3 %ecx, %edx, %ebp, %eax, %ebx, 43
+ round3 %ebx, %ecx, %edx, %ebp, %eax, 44
+
+ round3 %eax, %ebx, %ecx, %edx, %ebp, 45
+ round3 %ebp, %eax, %ebx, %ecx, %edx, 46
+ round3 %edx, %ebp, %eax, %ebx, %ecx, 47
+ round3 %ecx, %edx, %ebp, %eax, %ebx, 48
+ round3 %ebx, %ecx, %edx, %ebp, %eax, 49
+
+ round3 %eax, %ebx, %ecx, %edx, %ebp, 50
+ round3 %ebp, %eax, %ebx, %ecx, %edx, 51
+ round3 %edx, %ebp, %eax, %ebx, %ecx, 52
+ round3 %ecx, %edx, %ebp, %eax, %ebx, 53
+ round3 %ebx, %ecx, %edx, %ebp, %eax, 54
+
+ round3 %eax, %ebx, %ecx, %edx, %ebp, 55
+ round3 %ebp, %eax, %ebx, %ecx, %edx, 56
+ round3 %edx, %ebp, %eax, %ebx, %ecx, 57
+ round3 %ecx, %edx, %ebp, %eax, %ebx, 58
+ round3 %ebx, %ecx, %edx, %ebp, %eax, 59
+
+ round4 %eax, %ebx, %ecx, %edx, %ebp, 60
+ round4 %ebp, %eax, %ebx, %ecx, %edx, 61
+ round4 %edx, %ebp, %eax, %ebx, %ecx, 62
+ round4 %ecx, %edx, %ebp, %eax, %ebx, 63
+ round4 %ebx, %ecx, %edx, %ebp, %eax, 64
+
+ round4 %eax, %ebx, %ecx, %edx, %ebp, 65
+ round4 %ebp, %eax, %ebx, %ecx, %edx, 66
+ round4 %edx, %ebp, %eax, %ebx, %ecx, 67
+ round4 %ecx, %edx, %ebp, %eax, %ebx, 68
+ round4 %ebx, %ecx, %edx, %ebp, %eax, 69
+
+ round4 %eax, %ebx, %ecx, %edx, %ebp, 70
+ round4 %ebp, %eax, %ebx, %ecx, %edx, 71
+ round4 %edx, %ebp, %eax, %ebx, %ecx, 72
+ round4 %ecx, %edx, %ebp, %eax, %ebx, 73
+ round4 %ebx, %ecx, %edx, %ebp, %eax, 74
+
+ round4 %eax, %ebx, %ecx, %edx, %ebp, 75
+ round4 %ebp, %eax, %ebx, %ecx, %edx, 76
+ round4 %edx, %ebp, %eax, %ebx, %ecx, 77
+ round4 %ecx, %edx, %ebp, %eax, %ebx, 78
+ round4 %ebx, %ecx, %edx, %ebp, %eax, 79
+
+ add %r11d, %eax
+ add %r12d, %ebx
+ add %r13d, %ecx
+ add %r14d, %edx
+ add %r15d, %ebp
+
+ add $64, %rsi
+ cmp %rdi, %rsi
+ jb .Lloop
+
+.Lend: add $64+8, %rsp
+ pop %rdi // SHA1_CTX
+ mov %eax, (%rdi)
+ mov %ebx, 4(%rdi)
+ mov %ecx, 8(%rdi)
+ mov %edx, 12(%rdi)
+ mov %ebp, 16(%rdi)
+
+ pop %r15
+ pop %r14
+ pop %r13
+ pop %r12
+ pop %rbx
+ pop %rbp
+ ret
+END(_libmd_sha1block_scalar)
+
+/*
+ * This is the implementation using AVX2, BMI1 and BMI2. It is based on:
+ * "SHA-1 implementation with Intel(R) AVX2 instruction set extensions"
+ * From http://software.intel.com/en-us/articles
+ * (look for improving-the-performance-of-the-secure-hash-algorithm-1)
+ * This implementation is 2x unrolled, and interleaves vector instructions,
+ * used to precompute W, with scalar computation of current round
+ * for optimal scheduling.
+ */
+
+ /* trivial helper macros */
+.macro update_hash a, tb, c, d, e
+ add (%r9), \a
+ mov \a, (%r9)
+ add 4(%r9), \tb
+ mov \tb, 4(%r9)
+ add 8(%r9), \c
+ mov \c, 8(%r9)
+ add 12(%r9), \d
+ mov \d, 12(%r9)
+ add 16(%r9), \e
+ mov \e, 16(%r9)
+.endm
+
+ /* help macros for recalc, which does precomputations */
+.macro precalc0 offset
+ vmovdqu \offset(%r10), %xmm0
+.endm
+
+.macro precalc1 offset
+ vinserti128 $1, \offset(%r13), %ymm0, %ymm0
+.endm
+
+.macro precalc2 yreg
+ vpshufb %ymm10, %ymm0, \yreg
+.endm
+
+.macro precalc4 yreg, k_offset
+ vpaddd \k_offset(%r8), \yreg, %ymm0
+.endm
+
+.macro precalc7 offset
+ vmovdqu %ymm0, (\offset)*2(%r14)
+.endm
+
+/*
+ * Message scheduling pre-compute for rounds 0-15
+ * r13 is a pointer to the even 64-byte block
+ * r10 is a pointer to the odd 64-byte block
+ * r14 is a pointer to the temp buffer
+ * xmm0 is used as a temp register
+ * yreg is clobbered as part of the computation
+ * offset chooses a 16 byte chunk within a block
+ * r8 is a pointer to the constants block
+ * k_offset chooses K constants relevant to this round
+ * xmm10 holds the swap mask
+ */
+.macro precalc00_15 offset, yreg
+ precalc0 \offset
+ precalc1 \offset
+ precalc2 \yreg
+ precalc4 \yreg, 0
+ precalc7 \offset
+.endm
+
+ /* helper macros for precalc16_31 */
+.macro precalc16 reg_sub16, reg_sub12, reg_sub4, reg
+ vpalignr $8, \reg_sub16, \reg_sub12, \reg // w[i - 14]
+ vpsrldq $4, \reg_sub4, %ymm0 // w[i - 3]
+.endm
+
+.macro precalc17 reg_sub16, reg_sub8, reg
+ vpxor \reg_sub8, \reg, \reg
+ vpxor \reg_sub16, %ymm0, %ymm0
+.endm
+
+.macro precalc18 reg
+ vpxor %ymm0, \reg, \reg
+ vpslldq $12, \reg, %ymm9
+.endm
+
+.macro precalc19 reg
+ vpslld $1, \reg, %ymm0
+ vpsrld $31, \reg, \reg
+ .endm
+
+.macro precalc20 reg
+ vpor \reg, %ymm0, %ymm0
+ vpslld $2, %ymm9, \reg
+.endm
+
+.macro precalc21 reg
+ vpsrld $30, %ymm9, %ymm9
+ vpxor \reg, %ymm0, %ymm0
+.endm
+
+.macro precalc23 reg, k_offset, offset
+ vpxor %ymm9, %ymm0, \reg
+ vpaddd \k_offset(%r8), \reg, %ymm0
+ vmovdqu %ymm0, (\offset)(%r14)
+.endm
+
+/*
+ * Message scheduling pre-compute for rounds 16-31
+ * calculating last 32 w[i] values in 8 XMM registers
+ * pre-calculate K+w[i] values and store to mem
+ * for later load by ALU add instruction.
+ * "brute force" vectorization for rounds 16-31 only
+ * due to w[i]->w[i-3] dependency.
+ + clobbers 5 input ymm registers REG_SUB*
+ * uses xmm0 and xmm9 as temp registers
+ * As always, r8 is a pointer to constants block
+ * and r14 is a pointer to temp buffer
+ */
+.macro precalc16_31 reg, reg_sub4, reg_sub8, reg_sub12, reg_sub16, k_offset, offset
+ precalc16 \reg_sub16, \reg_sub12, \reg_sub4, \reg
+ precalc17 \reg_sub16, \reg_sub8, \reg
+ precalc18 \reg
+ precalc19 \reg
+ precalc20 \reg
+ precalc21 \reg
+ precalc23 \reg, \k_offset, \offset
+.endm
+
+ /* helper macros for precalc_32_79 */
+.macro precalc32 reg_sub8, reg_sub4
+ vpalignr $8, \reg_sub8, \reg_sub4, %ymm0
+.endm
+
+.macro precalc33 reg_sub28, reg
+ vpxor \reg_sub28, \reg, \reg
+.endm
+
+.macro precalc34 reg_sub16
+ vpxor \reg_sub16, %ymm0, %ymm0
+.endm
+
+.macro precalc35 reg
+ vpxor %ymm0, \reg, \reg
+.endm
+
+.macro precalc36 reg
+ vpslld $2, \reg, %ymm0
+.endm
+
+.macro precalc37 reg
+ vpsrld $30, \reg, \reg
+ vpor \reg, %ymm0, \reg
+.endm
+
+.macro precalc39 reg, k_offset, offset
+ vpaddd \k_offset(%r8), \reg, %ymm0
+ vmovdqu %ymm0, \offset(%r14)
+.endm
+
+.macro precalc32_79 reg, reg_sub4, reg_sub8, reg_sub16, reg_sub28, k_offset, offset
+ precalc32 \reg_sub8, \reg_sub4
+ precalc33 \reg_sub28, \reg
+ precalc34 \reg_sub16
+ precalc35 \reg
+ precalc36 \reg
+ precalc37 \reg
+ precalc39 \reg, \k_offset, \offset
+.endm
+
+.macro precalc
+ precalc00_15 0x00, %ymm15
+ precalc00_15 0x10, %ymm14
+ precalc00_15 0x20, %ymm13
+ precalc00_15 0x30, %ymm12
+ precalc16_31 %ymm8, %ymm12, %ymm13, %ymm14, %ymm15, 0x00, 0x080
+ precalc16_31 %ymm7, %ymm8, %ymm12, %ymm13, %ymm14, 0x20, 0x0a0
+ precalc16_31 %ymm5, %ymm7, %ymm8, %ymm12, %ymm13, 0x20, 0x0c0
+ precalc16_31 %ymm3, %ymm5, %ymm7, %ymm8, %ymm12, 0x20, 0x0e0
+ precalc32_79 %ymm15, %ymm3, %ymm5, %ymm8, %ymm14, 0x20, 0x100
+ precalc32_79 %ymm14, %ymm15, %ymm3, %ymm7, %ymm13, 0x20, 0x120
+ precalc32_79 %ymm13, %ymm14, %ymm15, %ymm5, %ymm12, 0x40, 0x140
+ precalc32_79 %ymm12, %ymm13, %ymm14, %ymm3, %ymm8, 0x40, 0x160
+ precalc32_79 %ymm8, %ymm12, %ymm13, %ymm15, %ymm7, 0x40, 0x180
+ precalc32_79 %ymm7, %ymm8, %ymm12, %ymm14, %ymm5, 0x40, 0x1a0
+ precalc32_79 %ymm5, %ymm7, %ymm8, %ymm13, %ymm3, 0x40, 0x1c0
+ precalc32_79 %ymm3, %ymm5, %ymm7, %ymm12, %ymm15, 0x60, 0x1e0
+ precalc32_79 %ymm15, %ymm3, %ymm5, %ymm8, %ymm14, 0x60, 0x200
+ precalc32_79 %ymm14, %ymm15, %ymm3, %ymm7, %ymm13, 0x60, 0x220
+ precalc32_79 %ymm13, %ymm14, %ymm15, %ymm5, %ymm12, 0x60, 0x240
+ precalc32_79 %ymm12, %ymm13, %ymm14, %ymm3, %ymm8, 0x60, 0x260
+.endm
+
+/*
+ * Macros calculating individual rounds have general form
+ * calc_round_pre + precalc_round + calc_round_post
+ * calc_round_{pre,post} macros follow
+ */
+.macro calc_f1_pre offset, reg_a, reg_b, reg_c, reg_e
+ add \offset(%r15), \reg_e
+ andn \reg_c, \reg_a, %ebp
+ add \reg_b, \reg_e // add F from the previous round
+ rorx $0x1b, \reg_a, %r12d
+ rorx $2, \reg_a, \reg_b // for the next round
+.endm
+
+/*
+ * Calculate F for the next round
+ */
+.macro calc_f1_post reg_a, reg_b, reg_e
+ and \reg_b, \reg_a // b & c
+ xor %ebp, \reg_a // F1 = (b&c) ^ (~b&d)
+ add %r12d, \reg_e
+.endm
+
+/*
+ * Registers are cyclically rotated:
+ * edx -> eax -> edi -> esi -> ebx -> ecx
+ */
+.macro calc0
+ mov %esi, %ebx // precalculate first round
+ rorx $2, %esi, %esi
+ andn %eax, %ebx, %ebp
+ and %edi, %ebx
+ xor %ebp, %ebx
+ calc_f1_pre 0x0, %ecx, %ebx, %edi, %edx
+ precalc0 0x80
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc1
+ calc_f1_pre 0x4, %edx, %ecx, %esi, %eax
+ precalc1 0x80
+ calc_f1_post %edx, %ebx, %eax
+.endm
+
+.macro calc2
+ calc_f1_pre 0x8, %eax, %edx, %ebx, %edi
+ precalc2 %ymm15
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc3
+ calc_f1_pre 0xc, %edi, %eax, %ecx, %esi
+ calc_f1_post %edi, %edx, %esi
+.endm
+
+.macro calc4
+ calc_f1_pre 0x20, %esi, %edi, %edx, %ebx
+ precalc4 %ymm15, 0x0
+ calc_f1_post %esi, %eax, %ebx
+.endm
+
+.macro calc5
+ calc_f1_pre 0x24, %ebx, %esi, %eax, %ecx
+ calc_f1_post %ebx, %edi, %ecx
+.endm
+
+.macro calc6
+ calc_f1_pre 0x28, %ecx, %ebx, %edi, %edx
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc7
+ calc_f1_pre 0x2c, %edx, %ecx, %esi, %eax
+ precalc7 0x0
+ calc_f1_post %edx, %ebx, %eax
+.endm
+
+.macro calc8
+ calc_f1_pre 0x40, %eax, %edx, %ebx, %edi
+ precalc0 0x90
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc9
+ calc_f1_pre 0x44, %edi, %eax, %ecx, %esi
+ precalc1 0x90
+ calc_f1_post %edi, %edx, %esi
+.endm
+
+.macro calc10
+ calc_f1_pre 0x48, %esi, %edi, %edx, %ebx
+ precalc2 %ymm14
+ calc_f1_post %esi, %eax, %ebx
+.endm
+
+.macro calc11
+ calc_f1_pre 0x4c, %ebx, %esi, %eax, %ecx
+ calc_f1_post %ebx, %edi, %ecx
+.endm
+
+.macro calc12
+ calc_f1_pre 0x60, %ecx, %ebx, %edi, %edx
+ precalc4 %ymm14, 0
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc13
+ calc_f1_pre 0x64, %edx, %ecx, %esi, %eax
+ calc_f1_post %edx, %ebx, %eax
+.endm
+
+.macro calc14
+ calc_f1_pre 0x68, %eax, %edx, %ebx, %edi
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc15
+ calc_f1_pre 0x6c, %edi, %eax, %ecx, %esi
+ precalc7 0x10
+ calc_f1_post %edi, %edx, %esi
+.endm
+
+.macro calc16
+ calc_f1_pre 0x80, %esi, %edi, %edx, %ebx
+ precalc0 0xa0
+ calc_f1_post %esi, %eax, %ebx
+.endm
+
+.macro calc17
+ calc_f1_pre 0x84, %ebx, %esi, %eax, %ecx
+ precalc1 0xa0
+ calc_f1_post %ebx, %edi, %ecx
+.endm
+
+.macro calc18
+ calc_f1_pre 0x88, %ecx, %ebx, %edi, %edx
+ precalc2 %ymm13
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc_f2_pre offset, reg_a, reg_b, reg_e
+ add \offset(%r15), \reg_e
+ add \reg_b, \reg_e // add F from the previous round
+ rorx $0x1b, \reg_a, %r12d
+ rorx $2, \reg_a, \reg_b // for next round
+.endm
+
+.macro calc_f2_post reg_a, reg_b, reg_c, reg_e
+ xor \reg_b, \reg_a
+ add %r12d, \reg_e
+ xor \reg_c, \reg_a
+.endm
+
+.macro calc19
+ calc_f2_pre 0x8c, %edx, %ecx, %eax
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc20
+ calc_f2_pre 0xa0, %eax, %edx, %edi
+ precalc4 %ymm13, 0x0
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc21
+ calc_f2_pre 0xa4, %edi, %eax, %esi
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc22
+ calc_f2_pre 0xa8, %esi, %edi, %ebx
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc23
+ calc_f2_pre 0xac, %ebx, %esi, %ecx
+ precalc7 0x20
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc24
+ calc_f2_pre 0xc0, %ecx, %ebx, %edx
+ precalc0 0xb0
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc25
+ calc_f2_pre 0xc4, %edx, %ecx, %eax
+ precalc1 0xb0
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc26
+ calc_f2_pre 0xc8, %eax, %edx, %edi
+ precalc2 %ymm12
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc27
+ calc_f2_pre 0xcc, %edi, %eax, %esi
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc28
+ calc_f2_pre 0xe0, %esi, %edi, %ebx
+ precalc4 %ymm12, 0x0
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc29
+ calc_f2_pre 0xe4, %ebx, %esi, %ecx
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc30
+ calc_f2_pre 0xe8, %ecx, %ebx, %edx
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc31
+ calc_f2_pre 0xec, %edx, %ecx, %eax
+ precalc7 0x30
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc32
+ calc_f2_pre 0x100, %eax, %edx, %edi
+ precalc16 %ymm15, %ymm14, %ymm12, %ymm8
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc33
+ calc_f2_pre 0x104, %edi, %eax, %esi
+ precalc17 %ymm15, %ymm13, %ymm8
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc34
+ calc_f2_pre 0x108, %esi, %edi, %ebx
+ precalc18 %ymm8
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc35
+ calc_f2_pre 0x10c, %ebx, %esi, %ecx
+ precalc19 %ymm8
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc36
+ calc_f2_pre 0x120, %ecx, %ebx, %edx
+ precalc20 %ymm8
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc37
+ calc_f2_pre 0x124, %edx, %ecx, %eax
+ precalc21 %ymm8
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc38
+ calc_f2_pre 0x128, %eax, %edx, %edi
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc_f3_pre offset, reg_e
+ add \offset(%r15), \reg_e
+.endm
+
+.macro calc_f3_post reg_a, reg_b, reg_c, reg_e, reg_tb
+ add \reg_tb, \reg_e // add F from the previous round
+ mov \reg_b, %ebp
+ or \reg_a, %ebp
+ rorx $0x1b, \reg_a, %r12d
+ rorx $2, \reg_a, \reg_tb
+ and \reg_c, %ebp // calculate F for the next round
+ and \reg_b, \reg_a
+ or %ebp, \reg_a
+ add %r12d, \reg_e
+.endm
+
+.macro calc39
+ calc_f3_pre 0x12c, %esi
+ precalc23 %ymm8, 0x0, 0x80
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc40
+ calc_f3_pre 0x140, %ebx
+ precalc16 %ymm14, %ymm13, %ymm8, %ymm7
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc41
+ calc_f3_pre 0x144, %ecx
+ precalc17 %ymm14, %ymm12, %ymm7
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc42
+ calc_f3_pre 0x148, %edx
+ precalc18 %ymm7
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc43
+ calc_f3_pre 0x14c, %eax
+ precalc19 %ymm7
+ calc_f3_post %edx, %ebx, %esi, %eax, %ecx
+.endm
+
+.macro calc44
+ calc_f3_pre 0x160, %edi
+ precalc20 %ymm7
+ calc_f3_post %eax, %ecx, %ebx, %edi, %edx
+.endm
+
+.macro calc45
+ calc_f3_pre 0x164, %esi
+ precalc21 %ymm7
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc46
+ calc_f3_pre 0x168, %ebx
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc47
+ calc_f3_pre 0x16c, %ecx
+ vpxor %ymm9, %ymm0, %ymm7
+ vpaddd 0x20(%r8), %ymm7, %ymm0
+ vmovdqu %ymm0, 0xa0(%r14)
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc48
+ calc_f3_pre 0x180, %edx
+ precalc16 %ymm13, %ymm12, %ymm7, %ymm5
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc49
+ calc_f3_pre 0x184, %eax
+ precalc17 %ymm13, %ymm8, %ymm5
+ calc_f3_post %edx, %ebx, %esi, %eax, %ecx
+.endm
+
+.macro calc50
+ calc_f3_pre 0x188, %edi
+ precalc18 %ymm5
+ calc_f3_post %eax, %ecx, %ebx, %edi, %edx
+.endm
+
+.macro calc51
+ calc_f3_pre 0x18c, %esi
+ precalc19 %ymm5
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc52
+ calc_f3_pre 0x1a0, %ebx
+ precalc20 %ymm5
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc53
+ calc_f3_pre 0x1a4, %ecx
+ precalc21 %ymm5
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc54
+ calc_f3_pre 0x1a8, %edx
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc55
+ calc_f3_pre 0x1ac, %eax
+ precalc23 %ymm5, 0x20, 0xc0
+ calc_f3_post %edx, %ebx, %esi, %eax, %ecx
+.endm
+
+.macro calc56
+ calc_f3_pre 0x1c0, %edi
+ precalc16 %ymm12, %ymm8, %ymm5, %ymm3
+ calc_f3_post %eax, %ecx, %ebx, %edi, %edx
+.endm
+
+.macro calc57
+ calc_f3_pre 0x1c4, %esi
+ precalc17 %ymm12, %ymm7, %ymm3
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc58
+ calc_f3_pre 0x1c8, %ebx
+ precalc18 %ymm3
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc59
+ calc_f2_pre 0x1cc, %ebx, %esi, %ecx
+ precalc19 %ymm3
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc60
+ calc_f2_pre 0x1e0, %ecx, %ebx, %edx
+ precalc20 %ymm3
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc61
+ calc_f2_pre 0x1e4, %edx, %ecx, %eax
+ precalc21 %ymm3
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc62
+ calc_f2_pre 0x1e8, %eax, %edx, %edi
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc63
+ calc_f2_pre 0x1ec, %edi, %eax, %esi
+ precalc23 %ymm3, 0x20, 0xe0
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc64
+ calc_f2_pre 0x200, %esi, %edi, %ebx
+ precalc32 %ymm5, %ymm3
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc65
+ calc_f2_pre 0x204, %ebx, %esi, %ecx
+ precalc33 %ymm14, %ymm15
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc66
+ calc_f2_pre 0x208, %ecx, %ebx, %edx
+ precalc34 %ymm8
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc67
+ calc_f2_pre 0x20c, %edx, %ecx, %eax
+ precalc35 %ymm15
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc68
+ calc_f2_pre 0x220, %eax, %edx, %edi
+ precalc36 %ymm15
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc69
+ calc_f2_pre 0x224, %edi, %eax, %esi
+ precalc37 %ymm15
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc70
+ calc_f2_pre 0x228, %esi, %edi, %ebx
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc71
+ calc_f2_pre 0x22c, %ebx, %esi, %ecx
+ precalc39 %ymm15, 0x20, 0x100
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc72
+ calc_f2_pre 0x240, %ecx, %ebx, %edx
+ precalc32 %ymm3, %ymm15
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc73
+ calc_f2_pre 0x244, %edx, %ecx, %eax
+ precalc33 %ymm13, %ymm14
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc74
+ calc_f2_pre 0x248, %eax, %edx, %edi
+ precalc34 %ymm7
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc75
+ calc_f2_pre 0x24c, %edi, %eax, %esi
+ precalc35 %ymm14
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc76
+ calc_f2_pre 0x260, %esi, %edi, %ebx
+ precalc36 %ymm14
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc77
+ calc_f2_pre 0x264, %ebx, %esi, %ecx
+ precalc37 %ymm14
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc78
+ calc_f2_pre 0x268, %ecx, %ebx, %edx
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc79
+ add 0x26c(%r15), %eax
+ add %ecx, %eax
+ rorx $0x1b, %edx, %r12d
+ precalc39 %ymm14, 0x20, 0x120
+ add %r12d, %eax
+.endm
+
+/*
+ * Similar to calc0
+ */
+.macro calc80
+ mov %ecx, %edx // precalculate first round
+ rorx $2, %ecx, %ecx
+ andn %esi, %edx, %ebp
+ and %ebx, %edx
+ xor %ebp, %edx
+ calc_f1_pre 0x10, %eax, %edx, %ebx, %edi
+ precalc32 %ymm15, %ymm14
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc81
+ calc_f1_pre 0x14, %edi, %eax, %ecx, %esi
+ precalc33 %ymm12, %ymm13
+ calc_f1_post %edi, %edx, %esi
+.endm
+
+.macro calc82
+ calc_f1_pre 0x18, %esi, %edi, %edx, %ebx
+ precalc34 %ymm5
+ calc_f1_post %esi, %eax, %ebx
+.endm
+
+.macro calc83
+ calc_f1_pre 0x1c, %ebx, %esi, %eax, %ecx
+ precalc35 %ymm13
+ calc_f1_post %ebx, %edi, %ecx
+.endm
+
+.macro calc84
+ calc_f1_pre 0x30, %ecx, %ebx, %edi, %edx
+ precalc36 %ymm13
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc85
+ calc_f1_pre 0x34, %edx, %ecx, %esi, %eax
+ precalc37 %ymm13
+ calc_f1_post %edx, %ebx, %eax
+.endm
+
+.macro calc86
+ calc_f1_pre 0x38, %eax, %edx, %ebx, %edi
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc87
+ calc_f1_pre 0x3c, %edi, %eax, %ecx, %esi
+ precalc39 %ymm13, 0x40, 0x140
+ calc_f1_post %edi, %edx, %esi
+.endm
+
+.macro calc88
+ calc_f1_pre 0x50, %esi, %edi, %edx, %ebx
+ precalc32 %ymm14, %ymm13
+ calc_f1_post %esi, %eax, %ebx
+.endm
+
+.macro calc89
+ calc_f1_pre 0x54, %ebx, %esi, %eax, %ecx
+ precalc33 %ymm8, %ymm12
+ calc_f1_post %ebx, %edi, %ecx
+.endm
+
+.macro calc90
+ calc_f1_pre 0x58, %ecx, %ebx, %edi, %edx
+ precalc34 %ymm3
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc91
+ calc_f1_pre 0x5c, %edx, %ecx, %esi, %eax
+ precalc35 %ymm12
+ calc_f1_post %edx, %ebx, %eax
+.endm
+
+.macro calc92
+ calc_f1_pre 0x70, %eax, %edx, %ebx, %edi
+ precalc36 %ymm12
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc93
+ calc_f1_pre 0x74, %edi, %eax, %ecx, %esi
+ precalc37 %ymm12
+ calc_f1_post %edi, %edx, %esi
+.endm
+
+.macro calc94
+ calc_f1_pre 0x78, %esi, %edi, %edx, %ebx
+ calc_f1_post %esi, %eax, %ebx
+.endm
+
+.macro calc95
+ calc_f1_pre 0x7c, %ebx, %esi, %eax, %ecx
+ precalc39 %ymm12, 0x40, 0x160
+ calc_f1_post %ebx, %edi, %ecx
+.endm
+
+.macro calc96
+ calc_f1_pre 0x90, %ecx, %ebx, %edi, %edx
+ precalc32 %ymm13, %ymm12
+ calc_f1_post %ecx, %esi, %edx
+.endm
+
+.macro calc97
+ calc_f1_pre 0x94, %edx, %ecx, %esi, %eax
+ precalc33 %ymm7, %ymm8
+ calc_f1_post %edx, %ebx, %eax
+.endm
+
+.macro calc98
+ calc_f1_pre 0x98, %eax, %edx, %ebx, %edi
+ precalc34 %ymm15
+ calc_f1_post %eax, %ecx, %edi
+.endm
+
+.macro calc99
+ calc_f2_pre 0x9c, %edi, %eax, %esi
+ precalc35 %ymm8
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc100
+ calc_f2_pre 0xb0, %esi, %edi, %ebx
+ precalc36 %ymm8
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc101
+ calc_f2_pre 0xb4, %ebx, %esi, %ecx
+ precalc37 %ymm8
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc102
+ calc_f2_pre 0xb8, %ecx, %ebx, %edx
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc103
+ calc_f2_pre 0xbc, %edx, %ecx, %eax
+ precalc39 %ymm8, 0x40, 0x180
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc104
+ calc_f2_pre 0xd0, %eax, %edx, %edi
+ precalc32 %ymm12, %ymm8
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc105
+ calc_f2_pre 0xd4, %edi, %eax, %esi
+ precalc33 %ymm5, %ymm7
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc106
+ calc_f2_pre 0xd8, %esi, %edi, %ebx
+ precalc34 %ymm14
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc107
+ calc_f2_pre 0xdc, %ebx, %esi, %ecx
+ precalc35 %ymm7
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc108
+ calc_f2_pre 0xf0, %ecx, %ebx, %edx
+ precalc36 %ymm7
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc109
+ calc_f2_pre 0xf4, %edx, %ecx, %eax
+ precalc37 %ymm7
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc110
+ calc_f2_pre 0xf8, %eax, %edx, %edi
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc111
+ calc_f2_pre 0xfc, %edi, %eax, %esi
+ precalc39 %ymm7, 0x40, 0x1a0
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc112
+ calc_f2_pre 0x110, %esi, %edi, %ebx
+ precalc32 %ymm8, %ymm7
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc113
+ calc_f2_pre 0x114, %ebx, %esi, %ecx
+ precalc33 %ymm3, %ymm5
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc114
+ calc_f2_pre 0x118, %ecx, %ebx, %edx
+ precalc34 %ymm13
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc115
+ calc_f2_pre 0x11c, %edx, %ecx, %eax
+ precalc35 %ymm5
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc116
+ calc_f2_pre 0x130, %eax, %edx, %edi
+ precalc36 %ymm5
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc117
+ calc_f2_pre 0x134, %edi, %eax, %esi
+ precalc37 %ymm5
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc118
+ calc_f2_pre 0x138, %esi, %edi, %ebx
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc119
+ calc_f3_pre 0x13c, %ecx
+ precalc39 %ymm5, 0x40, 0x1c0
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc120
+ calc_f3_pre 0x150, %edx
+ precalc32 %ymm7, %ymm5
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc121
+ calc_f3_pre 0x154, %eax
+ precalc33 %ymm15, %ymm3
+ calc_f3_post %edx, %ebx, %esi, %eax, %ecx
+.endm
+
+.macro calc122
+ calc_f3_pre 0x158, %edi
+ precalc34 %ymm12
+ calc_f3_post %eax, %ecx, %ebx, %edi, %edx
+.endm
+
+.macro calc123
+ calc_f3_pre 0x15c, %esi
+ precalc35 %ymm3
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc124
+ calc_f3_pre 0x170, %ebx
+ precalc36 %ymm3
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc125
+ calc_f3_pre 0x174, %ecx
+ precalc37 %ymm3
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc126
+ calc_f3_pre 0x178, %edx
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc127
+ calc_f3_pre 0x17c, %eax
+ precalc39 %ymm3, 0x60, 0x1e0
+ calc_f3_post %edx, %ebx, %esi, %eax, %ecx
+.endm
+
+.macro calc128
+ calc_f3_pre 0x190, %edi
+ precalc32 %ymm5, %ymm3
+ calc_f3_post %eax, %ecx, %ebx, %edi, %edx
+.endm
+
+.macro calc129
+ calc_f3_pre 0x194, %esi
+ precalc33 %ymm14, %ymm15
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc130
+ calc_f3_pre 0x198, %ebx
+ precalc34 %ymm8
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc131
+ calc_f3_pre 0x19c, %ecx
+ precalc35 %ymm15
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc132
+ calc_f3_pre 0x1b0, %edx
+ precalc36 %ymm15
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc133
+ calc_f3_pre 0x1b4, %eax
+ precalc37 %ymm15
+ calc_f3_post %edx, %ebx, %esi, %eax, %ecx
+.endm
+
+.macro calc134
+ calc_f3_pre 0x1b8, %edi
+ calc_f3_post %eax, %ecx, %ebx, %edi, %edx
+.endm
+
+.macro calc135
+ calc_f3_pre 0x1bc, %esi
+ precalc39 %ymm15, 0x60, 0x200
+ calc_f3_post %edi, %edx, %ecx, %esi, %eax
+.endm
+
+.macro calc136
+ calc_f3_pre 0x1d0, %ebx
+ precalc32 %ymm3, %ymm15
+ calc_f3_post %esi, %eax, %edx, %ebx, %edi
+.endm
+
+.macro calc137
+ calc_f3_pre 0x1d4, %ecx
+ precalc33 %ymm13, %ymm14
+ calc_f3_post %ebx, %edi, %eax, %ecx, %esi
+.endm
+
+.macro calc138
+ calc_f3_pre 0x1d8, %edx
+ precalc34 %ymm7
+ calc_f3_post %ecx, %esi, %edi, %edx, %ebx
+.endm
+
+.macro calc139
+ calc_f2_pre 0x1dc, %edx, %ecx, %eax
+ precalc35 %ymm14
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc140
+ calc_f2_pre 0x1f0, %eax, %edx, %edi
+ precalc36 %ymm14
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc141
+ calc_f2_pre 0x1f4, %edi, %eax, %esi
+ precalc37 %ymm14
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc142
+ calc_f2_pre 0x1f8, %esi, %edi, %ebx
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc143
+ calc_f2_pre 0x1fc, %ebx, %esi, %ecx
+ precalc39 %ymm14, 0x60, 0x220
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc144
+ calc_f2_pre 0x210, %ecx, %ebx, %edx
+ precalc32 %ymm15, %ymm14
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc145
+ calc_f2_pre 0x214, %edx, %ecx, %eax
+ precalc33 %ymm12, %ymm13
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc146
+ calc_f2_pre 0x218, %eax, %edx, %edi
+ precalc34 %ymm5
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc147
+ calc_f2_pre 0x21c, %edi, %eax, %esi
+ precalc35 %ymm13
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc148
+ calc_f2_pre 0x230, %esi, %edi, %ebx
+ precalc36 %ymm13
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc149
+ calc_f2_pre 0x234, %ebx, %esi, %ecx
+ precalc37 %ymm13
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc150
+ calc_f2_pre 0x238, %ecx, %ebx, %edx
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc151
+ calc_f2_pre 0x23c, %edx, %ecx, %eax
+ precalc39 %ymm13, 0x60, 0x240
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc152
+ calc_f2_pre 0x250, %eax, %edx, %edi
+ precalc32 %ymm14, %ymm13
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc153
+ calc_f2_pre 0x254, %edi, %eax, %esi
+ precalc33 %ymm8, %ymm12
+ calc_f2_post %edi, %edx, %ecx, %esi
+.endm
+
+.macro calc154
+ calc_f2_pre 0x258, %esi, %edi, %ebx
+ precalc34 %ymm3
+ calc_f2_post %esi, %eax, %edx, %ebx
+.endm
+
+.macro calc155
+ calc_f2_pre 0x25c, %ebx, %esi, %ecx
+ precalc35 %ymm12
+ calc_f2_post %ebx, %edi, %eax, %ecx
+.endm
+
+.macro calc156
+ calc_f2_pre 0x270, %ecx, %ebx, %edx
+ precalc36 %ymm12
+ calc_f2_post %ecx, %esi, %edi, %edx
+.endm
+
+.macro calc157
+ calc_f2_pre 0x274, %edx, %ecx, %eax
+ precalc37 %ymm12
+ calc_f2_post %edx, %ebx, %esi, %eax
+.endm
+
+.macro calc158
+ calc_f2_pre 0x278, %eax, %edx, %edi
+ calc_f2_post %eax, %ecx, %ebx, %edi
+.endm
+
+.macro calc159
+ add 0x27c(%r15), %esi
+ add %eax, %esi
+ rorx $0x1b, %edi, %r12d
+ precalc39 %ymm12, 0x60, 0x260
+ add %r12d, %esi
+.endm
+
+ // sha1block(SHA1_CTX, buf, len)
+ENTRY(_libmd_sha1block_avx2)
+ push %rbx
+ push %rbp
+ push %r12
+ push %r13
+ push %r14
+ push %r15
+ sub $1408+8, %rsp
+
+ and $~63, %rdx
+ lea k_xmm_ar(%rip), %r8
+ mov %rdi, %r9
+ mov %rsi, %r10
+ lea 64(%rsi), %r13
+ lea 64(%rsi, %rdx), %r11
+ cmp %r11, %r13
+ cmovae %r8, %r13
+ vmovdqu bswap_shufb_ctl(%rip), %ymm10
+
+ mov (%r9), %ecx
+ mov 4(%r9), %esi
+ mov 8(%r9), %edi
+ mov 12(%r9), %eax
+ mov 16(%r9), %edx
+ mov %rsp, %r14
+ lea 2*4*80+32(%rsp), %r15
+ precalc // precalc WK for first 2 blocks
+ xchg %r14, %r15
+
+ // this is unrolled
+.Loop: cmp %r8, %r10 // we use the value of R8 (set below)
+ // as a signal of the last block
+ jne .Lbegin
+ add $1408+8, %rsp
+ pop %r15
+ pop %r14
+ pop %r13
+ pop %r12
+ pop %rbp
+ pop %rbx
+ vzeroupper
+ ret
+
+.Lbegin:
+ calc0
+ calc1
+ calc2
+ calc3
+ calc4
+ calc5
+ calc6
+ calc7
+ calc8
+ calc9
+ calc10
+ calc11
+ calc12
+ calc13
+ calc14
+ calc15
+ calc16
+ calc17
+ calc18
+ calc19
+ calc20
+ calc21
+ calc22
+ calc23
+ calc24
+ calc25
+ calc26
+ calc27
+ calc28
+ calc29
+ calc30
+ calc31
+ calc32
+ calc33
+ calc34
+ calc35
+ calc36
+ calc37
+ calc38
+ calc39
+ calc40
+ calc41
+ calc42
+ calc43
+ calc44
+ calc45
+ calc46
+ calc47
+ calc48
+ calc49
+ calc50
+ calc51
+ calc52
+ calc53
+ calc54
+ calc55
+ calc56
+ calc57
+ calc58
+ calc59
+
+ add $128, %r10 // move to the next even-64-byte block
+ cmp %r11, %r10 // is the current block the last one?
+ cmovae %r8, %r10 // signal the last iteration smartly
+
+ calc60
+ calc61
+ calc62
+ calc63
+ calc64
+ calc65
+ calc66
+ calc67
+ calc68
+ calc69
+ calc70
+ calc71
+ calc72
+ calc73
+ calc74
+ calc75
+ calc76
+ calc77
+ calc78
+ calc79
+
+ update_hash %eax, %edx, %ebx, %esi, %edi
+ cmp %r8, %r10 // is the current block the last one?
+ je .Loop
+ mov %edx, %ecx
+
+ calc80
+ calc81
+ calc82
+ calc83
+ calc84
+ calc85
+ calc86
+ calc87
+ calc88
+ calc89
+ calc90
+ calc91
+ calc92
+ calc93
+ calc94
+ calc95
+ calc96
+ calc97
+ calc98
+ calc99
+ calc100
+ calc101
+ calc102
+ calc103
+ calc104
+ calc105
+ calc106
+ calc107
+ calc108
+ calc109
+ calc110
+ calc111
+ calc112
+ calc113
+ calc114
+ calc115
+ calc116
+ calc117
+ calc118
+ calc119
+ calc120
+ calc121
+ calc122
+ calc123
+ calc124
+ calc125
+ calc126
+ calc127
+ calc128
+ calc129
+ calc130
+ calc131
+ calc132
+ calc133
+ calc134
+ calc135
+ calc136
+ calc137
+ calc138
+ calc139
+
+ add $128, %r13 // move to the next even-64-byte block
+ cmp %r11, %r13 // is the current block the last one?
+ cmovae %r8, %r10
+
+ calc140
+ calc141
+ calc142
+ calc143
+ calc144
+ calc145
+ calc146
+ calc147
+ calc148
+ calc149
+ calc150
+ calc151
+ calc152
+ calc153
+ calc154
+ calc155
+ calc156
+ calc157
+ calc158
+ calc159
+
+ update_hash %esi, %edi, %edx, %ecx, %ebx
+ mov %esi, %r12d // reset state for AVX2 reg permutation
+ mov %edi, %esi
+ mov %edx, %edi
+ mov %ebx, %edx
+ mov %ecx, %eax
+ mov %r12d, %ecx
+ xchg %r14, %r15
+ jmp .Loop
+END(_libmd_sha1block_avx2)
+
+ .section .rodata
+ .balign 32
+k_xmm_ar:
+ .fill 8, 4, 0x5a827999
+ .fill 8, 4, 0x6ed9eba1
+ .fill 8, 4, 0x8f1bbcdc
+ .fill 8, 4, 0xca62c1d6
+ .size k_xmm_ar, .-k_xmm_ar
+
+bswap_shufb_ctl:
+ .4byte 0x00010203
+ .4byte 0x04050607
+ .4byte 0x08090a0b
+ .4byte 0x0c0d0e0f
+ .4byte 0x00010203
+ .4byte 0x04050607
+ .4byte 0x08090a0b
+ .4byte 0x0c0d0e0f
+ .size bswap_shufb_ctl, .-bswap_shufb_ctl
+
+ /*
+ * SHA1 implementation using the Intel SHA extensions (SHANI).
+ *
+ * Imlemented according to the Intel white paper
+ *
+ * S. Gulley, V. Gopal, K. Yap, W. Feghali, J. Guilford,
+ * G. Wolrich: "Intel SHA Extensions: new instruction supporting
+ * the Secure Hash Algorithm on Intel® architecture processors",
+ * July 2013.
+ */
+ // sha1block(SHA1_CTX, buf, len)
+ENTRY(_libmd_sha1block_shani)
+ and $~63, %rdx // round length to block-size multiple
+ lea (%rsi, %rdx, 1), %rcx // end pointer
+ test %rdx, %rdx // nothing to do?
+ je 1f // if so, terminate immediately
+
+ movdqu (%rdi), %xmm6 // h0, h1, h2, h3
+ pxor %xmm7, %xmm7
+ pshufd $0x1b, %xmm6, %xmm6 // h3, h2, h1, h0
+ pinsrd $3, 16(%rdi), %xmm7 // h4 in the highest word of xmm7
+ movdqu shuf_mask(%rip), %xmm4
+
+ // main loop
+0: movdqa %xmm6, %xmm8 // stash ABCD
+ movdqa %xmm7, %xmm9 // stash E
+
+ // rounds 0--3
+ movdqu 0*16(%rsi), %xmm0 // load first message block
+ pshufb %xmm4, %xmm0 // and byte-swap
+ paddd %xmm0, %xmm7 // E += w[0]
+ movdqa %xmm6, %xmm5 // E' = A
+ sha1rnds4 $0, %xmm7, %xmm6 // perform rounds 0--3
+
+ // rounds 4--7
+ movdqu 1*16(%rsi), %xmm1
+ pshufb %xmm4, %xmm1
+ sha1nexte %xmm1, %xmm5
+ movdqa %xmm6, %xmm7
+ sha1rnds4 $0, %xmm5, %xmm6
+ sha1msg1 %xmm1, %xmm0
+
+ // rounds 8--11
+ movdqu 2*16(%rsi), %xmm2
+ pshufb %xmm4, %xmm2
+ sha1nexte %xmm2, %xmm7
+ movdqa %xmm6, %xmm5
+ sha1rnds4 $0, %xmm7, %xmm6
+ sha1msg1 %xmm2, %xmm1
+ pxor %xmm2, %xmm0
+
+.macro midround msg3, msg0, msg1, msg2, e1, e0, k
+ sha1nexte \msg3, \e1
+ movdqa %xmm6, \e0
+ sha1msg2 \msg3, \msg0
+ sha1rnds4 $\k, \e1, %xmm6
+ sha1msg1 \msg3, \msg2
+ pxor \msg3, \msg1
+.endm
+
+ movdqu 3*16(%rsi), %xmm3 // load third message block
+ pshufb %xmm4, %xmm3
+
+ add $4*16, %rsi
+
+ midround %xmm3, %xmm0, %xmm1, %xmm2, %xmm5, %xmm7, 0 // 12--15
+ midround %xmm0, %xmm1, %xmm2, %xmm3, %xmm7, %xmm5, 0 // 16--19
+ midround %xmm1, %xmm2, %xmm3, %xmm0, %xmm5, %xmm7, 1 // 20--23
+ midround %xmm2, %xmm3, %xmm0, %xmm1, %xmm7, %xmm5, 1 // 24--27
+ midround %xmm3, %xmm0, %xmm1, %xmm2, %xmm5, %xmm7, 1 // 28--31
+ midround %xmm0, %xmm1, %xmm2, %xmm3, %xmm7, %xmm5, 1 // 32--35
+ midround %xmm1, %xmm2, %xmm3, %xmm0, %xmm5, %xmm7, 1 // 36--39
+ midround %xmm2, %xmm3, %xmm0, %xmm1, %xmm7, %xmm5, 2 // 40--43
+ midround %xmm3, %xmm0, %xmm1, %xmm2, %xmm5, %xmm7, 2 // 44--47
+ midround %xmm0, %xmm1, %xmm2, %xmm3, %xmm7, %xmm5, 2 // 48--51
+ midround %xmm1, %xmm2, %xmm3, %xmm0, %xmm5, %xmm7, 2 // 52--55
+ midround %xmm2, %xmm3, %xmm0, %xmm1, %xmm7, %xmm5, 2 // 56--59
+ midround %xmm3, %xmm0, %xmm1, %xmm2, %xmm5, %xmm7, 3 // 60--63
+ midround %xmm0, %xmm1, %xmm2, %xmm3, %xmm7, %xmm5, 3 // 64--67
+
+ // rounds 68--71
+ sha1nexte %xmm1, %xmm5
+ movdqa %xmm6, %xmm7
+ sha1msg2 %xmm1, %xmm2
+ sha1rnds4 $3, %xmm5, %xmm6
+ pxor %xmm1, %xmm3
+
+ // rounds 72--75
+ sha1nexte %xmm2, %xmm7
+ movdqa %xmm6, %xmm5
+ sha1msg2 %xmm2, %xmm3
+ sha1rnds4 $3, %xmm7, %xmm6
+
+ // rounds 76--79
+ sha1nexte %xmm3, %xmm5
+ movdqa %xmm6, %xmm7
+ sha1rnds4 $3, %xmm5, %xmm6
+
+ sha1nexte %xmm9, %xmm7 // add saved E
+ paddd %xmm8, %xmm6 // add saved ABCD
+
+ cmp %rsi, %rcx // end reached?
+ jne 0b
+
+ pshufd $0x1b, %xmm6, %xmm6 // restore order of h0--h3
+ movdqu %xmm6, (%rdi) // write h0--h3
+ pextrd $3, %xmm7, 16(%rdi) // write h4
+1: ret
+END(_libmd_sha1block_shani)
+
+ .section .rodata
+ .balign 16
+shuf_mask:
+ .8byte 0x08090a0b0c0d0e0f
+ .8byte 0x0001020304050607
+ .size shuf_mask, .-shuf_mask
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libmd/amd64/sha1dispatch.c b/lib/libmd/amd64/sha1dispatch.c
new file mode 100644
index 000000000000..86509195d56e
--- /dev/null
+++ b/lib/libmd/amd64/sha1dispatch.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2016 The Go Authors. All rights reserved.
+ * Copyright (c) 2024 Robert Clausecker <fuz@freebsd.org>
+ *
+ * Adapted from Go's crypto/sha1/sha1block_amd64.go.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include <machine/specialreg.h>
+#include <sha.h>
+#include <x86/ifunc.h>
+
+extern void _libmd_sha1block_scalar(SHA1_CTX *, const void *, size_t);
+extern void _libmd_sha1block_avx2(SHA1_CTX *, const void *, size_t);
+extern void _libmd_sha1block_shani(SHA1_CTX *, const void *, size_t);
+static void sha1block_avx2_wrapper(SHA1_CTX *, const void *, size_t);
+
+#define AVX2_STDEXT_NEEDED \
+ (CPUID_STDEXT_BMI1 | CPUID_STDEXT_AVX2 | CPUID_STDEXT_BMI2)
+
+DEFINE_UIFUNC(, void, sha1_block, (SHA1_CTX *, const void *, size_t))
+{
+ if (cpu_stdext_feature & CPUID_STDEXT_SHA)
+ return (_libmd_sha1block_shani);
+ if ((cpu_stdext_feature & AVX2_STDEXT_NEEDED) == AVX2_STDEXT_NEEDED)
+ return (sha1block_avx2_wrapper);
+ else
+ return (_libmd_sha1block_scalar);
+}
+
+static void
+sha1block_avx2_wrapper(SHA1_CTX *c, const void *data, size_t len)
+{
+ if (len >= 256) {
+ /*
+ * sha1block_avx2 calculates sha1 for 2 block per iteration.
+ * It also interleaves the precalculation for next the block.
+ * So it may read up-to 192 bytes past the end of p.
+ * We may add checks inside sha1block_avx2, but this will
+ * just turn it into a copy of sha1block_scalar,
+ * so call it directly, instead.
+ */
+ size_t safe_len = len - 128;
+
+ if (safe_len % 128 != 0)
+ safe_len -= 64;
+
+ _libmd_sha1block_avx2(c, data, safe_len);
+ _libmd_sha1block_scalar(c, data + safe_len, len - safe_len);
+ } else
+ _libmd_sha1block_scalar(c, data, len);
+}
diff --git a/lib/libmd/i386/sha.S b/lib/libmd/i386/sha.S
deleted file mode 100644
index 3bb54aa9b251..000000000000
--- a/lib/libmd/i386/sha.S
+++ /dev/null
@@ -1,1951 +0,0 @@
-/* -*- Fundamental -*- Emacs' assembler mode hoses this file */
-#ifndef PIC
-/* Run the C pre-processor over this file with one of the following defined
- * ELF - elf object files,
- * OUT - a.out object files,
- * BSDI - BSDI style a.out object files
- * SOL - Solaris style elf
- */
-
-#define TYPE(a,b) .type a,b
-#define SIZE(a,b) .size a,b
-
-#if defined(OUT) || defined(BSDI)
-#define sha1_block_x86 _sha1_block_x86
-
-#endif
-
-#ifdef OUT
-#define OK 1
-#define ALIGN 4
-#endif
-
-#ifdef BSDI
-#define OK 1
-#define ALIGN 4
-#undef SIZE
-#undef TYPE
-#define SIZE(a,b)
-#define TYPE(a,b)
-#endif
-
-#if defined(ELF) || defined(SOL)
-#define OK 1
-#define ALIGN 4
-#endif
-
-#ifndef OK
-You need to define one of
-ELF - elf systems - linux-elf, NetBSD and DG-UX
-OUT - a.out systems - linux-a.out and FreeBSD
-SOL - solaris systems, which are elf with strange comment lines
-BSDI - a.out with a very primative version of as.
-#endif
-
-/* Let the Assembler begin :-) */
- /* Don't even think of reading this code */
- /* It was automatically generated by sha1-586.pl */
- /* Which is a perl program used to generate the x86 assember for */
- /* any of elf, a.out, BSDI,Win32, or Solaris */
- /* eric <eay@cryptsoft.com> */
-
- .file "sha1-586.s"
- .version "01.01"
-gcc2_compiled.:
-.text
- .p2align ALIGN
-.globl sha1_block_x86
- TYPE(sha1_block_x86,@function)
-sha1_block_x86:
- pushl %esi
- pushl %ebp
- movl 20(%esp), %eax
- movl 16(%esp), %esi
- addl %esi, %eax
- movl 12(%esp), %ebp
- pushl %ebx
- subl $64, %eax
- pushl %edi
- movl 4(%ebp), %ebx
- subl $72, %esp
- movl 12(%ebp), %edx
- movl 16(%ebp), %edi
- movl 8(%ebp), %ecx
- movl %eax, 68(%esp)
- /* First we need to setup the X array */
- movl (%esi), %eax
-.L000start:
- /* First, load the words onto the stack in network byte order */
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, (%esp)
- movl 4(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 4(%esp)
- movl 8(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 8(%esp)
- movl 12(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 12(%esp)
- movl 16(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 16(%esp)
- movl 20(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 20(%esp)
- movl 24(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 24(%esp)
- movl 28(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 28(%esp)
- movl 32(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 32(%esp)
- movl 36(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 36(%esp)
- movl 40(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 40(%esp)
- movl 44(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 44(%esp)
- movl 48(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 48(%esp)
- movl 52(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 52(%esp)
- movl 56(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 56(%esp)
- movl 60(%esi), %eax
-.byte 15
-.byte 200 /* bswapl %eax */
- movl %eax, 60(%esp)
- /* We now have the X array on the stack */
- /* starting at sp-4 */
- movl %esi, 64(%esp)
-
- /* Start processing */
- movl (%ebp), %eax
- /* 00_15 0 */
- movl %ecx, %esi
- movl %eax, %ebp
- xorl %edx, %esi
- roll $5, %ebp
- andl %ebx, %esi
- addl %edi, %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- movl (%esp), %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %edx, %esi
- leal 1518500249(%ebp,%edi,1),%ebp
- movl %ebx, %edi
- addl %ebp, %esi
- xorl %ecx, %edi
- movl %esi, %ebp
- andl %eax, %edi
- roll $5, %ebp
- addl %edx, %ebp
- movl 4(%esp), %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- xorl %ecx, %edi
-.byte 209
-.byte 200 /* rorl $1 %eax */
- leal 1518500249(%ebp,%edx,1),%ebp
- addl %ebp, %edi
- /* 00_15 2 */
- movl %eax, %edx
- movl %edi, %ebp
- xorl %ebx, %edx
- roll $5, %ebp
- andl %esi, %edx
- addl %ecx, %ebp
-.byte 209
-.byte 206 /* rorl $1 %esi */
- movl 8(%esp), %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- xorl %ebx, %edx
- leal 1518500249(%ebp,%ecx,1),%ebp
- movl %esi, %ecx
- addl %ebp, %edx
- xorl %eax, %ecx
- movl %edx, %ebp
- andl %edi, %ecx
- roll $5, %ebp
- addl %ebx, %ebp
- movl 12(%esp), %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- xorl %eax, %ecx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- leal 1518500249(%ebp,%ebx,1),%ebp
- addl %ebp, %ecx
- /* 00_15 4 */
- movl %edi, %ebx
- movl %ecx, %ebp
- xorl %esi, %ebx
- roll $5, %ebp
- andl %edx, %ebx
- addl %eax, %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- movl 16(%esp), %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %esi, %ebx
- leal 1518500249(%ebp,%eax,1),%ebp
- movl %edx, %eax
- addl %ebp, %ebx
- xorl %edi, %eax
- movl %ebx, %ebp
- andl %ecx, %eax
- roll $5, %ebp
- addl %esi, %ebp
- movl 20(%esp), %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- xorl %edi, %eax
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- leal 1518500249(%ebp,%esi,1),%ebp
- addl %ebp, %eax
- /* 00_15 6 */
- movl %ecx, %esi
- movl %eax, %ebp
- xorl %edx, %esi
- roll $5, %ebp
- andl %ebx, %esi
- addl %edi, %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- movl 24(%esp), %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %edx, %esi
- leal 1518500249(%ebp,%edi,1),%ebp
- movl %ebx, %edi
- addl %ebp, %esi
- xorl %ecx, %edi
- movl %esi, %ebp
- andl %eax, %edi
- roll $5, %ebp
- addl %edx, %ebp
- movl 28(%esp), %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- xorl %ecx, %edi
-.byte 209
-.byte 200 /* rorl $1 %eax */
- leal 1518500249(%ebp,%edx,1),%ebp
- addl %ebp, %edi
- /* 00_15 8 */
- movl %eax, %edx
- movl %edi, %ebp
- xorl %ebx, %edx
- roll $5, %ebp
- andl %esi, %edx
- addl %ecx, %ebp
-.byte 209
-.byte 206 /* rorl $1 %esi */
- movl 32(%esp), %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- xorl %ebx, %edx
- leal 1518500249(%ebp,%ecx,1),%ebp
- movl %esi, %ecx
- addl %ebp, %edx
- xorl %eax, %ecx
- movl %edx, %ebp
- andl %edi, %ecx
- roll $5, %ebp
- addl %ebx, %ebp
- movl 36(%esp), %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- xorl %eax, %ecx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- leal 1518500249(%ebp,%ebx,1),%ebp
- addl %ebp, %ecx
- /* 00_15 10 */
- movl %edi, %ebx
- movl %ecx, %ebp
- xorl %esi, %ebx
- roll $5, %ebp
- andl %edx, %ebx
- addl %eax, %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- movl 40(%esp), %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %esi, %ebx
- leal 1518500249(%ebp,%eax,1),%ebp
- movl %edx, %eax
- addl %ebp, %ebx
- xorl %edi, %eax
- movl %ebx, %ebp
- andl %ecx, %eax
- roll $5, %ebp
- addl %esi, %ebp
- movl 44(%esp), %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- xorl %edi, %eax
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- leal 1518500249(%ebp,%esi,1),%ebp
- addl %ebp, %eax
- /* 00_15 12 */
- movl %ecx, %esi
- movl %eax, %ebp
- xorl %edx, %esi
- roll $5, %ebp
- andl %ebx, %esi
- addl %edi, %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- movl 48(%esp), %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %edx, %esi
- leal 1518500249(%ebp,%edi,1),%ebp
- movl %ebx, %edi
- addl %ebp, %esi
- xorl %ecx, %edi
- movl %esi, %ebp
- andl %eax, %edi
- roll $5, %ebp
- addl %edx, %ebp
- movl 52(%esp), %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- xorl %ecx, %edi
-.byte 209
-.byte 200 /* rorl $1 %eax */
- leal 1518500249(%ebp,%edx,1),%ebp
- addl %ebp, %edi
- /* 00_15 14 */
- movl %eax, %edx
- movl %edi, %ebp
- xorl %ebx, %edx
- roll $5, %ebp
- andl %esi, %edx
- addl %ecx, %ebp
-.byte 209
-.byte 206 /* rorl $1 %esi */
- movl 56(%esp), %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- xorl %ebx, %edx
- leal 1518500249(%ebp,%ecx,1),%ebp
- movl %esi, %ecx
- addl %ebp, %edx
- xorl %eax, %ecx
- movl %edx, %ebp
- andl %edi, %ecx
- roll $5, %ebp
- addl %ebx, %ebp
- movl 60(%esp), %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- xorl %eax, %ecx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- leal 1518500249(%ebp,%ebx,1),%ebp
- addl %ebp, %ecx
- /* 16_19 16 */
- nop
- movl (%esp), %ebp
- movl 8(%esp), %ebx
- xorl %ebp, %ebx
- movl 32(%esp), %ebp
- xorl %ebp, %ebx
- movl 52(%esp), %ebp
- xorl %ebp, %ebx
- movl %edi, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %esi, %ebp
- movl %ebx, (%esp)
- andl %edx, %ebp
- leal 1518500249(%ebx,%eax,1),%ebx
- xorl %esi, %ebp
- movl %ecx, %eax
- addl %ebp, %ebx
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- movl 4(%esp), %eax
- movl 12(%esp), %ebp
- xorl %ebp, %eax
- movl 36(%esp), %ebp
- xorl %ebp, %eax
- movl 56(%esp), %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %ebp, %eax
-.byte 209
-.byte 192 /* roll $1 %eax */
- movl %edx, %ebp
- xorl %edi, %ebp
- movl %eax, 4(%esp)
- andl %ecx, %ebp
- leal 1518500249(%eax,%esi,1),%eax
- xorl %edi, %ebp
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %eax
- /* 16_19 18 */
- movl 8(%esp), %ebp
- movl 16(%esp), %esi
- xorl %ebp, %esi
- movl 40(%esp), %ebp
- xorl %ebp, %esi
- movl 60(%esp), %ebp
- xorl %ebp, %esi
- movl %ecx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %edx, %ebp
- movl %esi, 8(%esp)
- andl %ebx, %ebp
- leal 1518500249(%esi,%edi,1),%esi
- xorl %edx, %ebp
- movl %eax, %edi
- addl %ebp, %esi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- movl 12(%esp), %edi
- movl 20(%esp), %ebp
- xorl %ebp, %edi
- movl 44(%esp), %ebp
- xorl %ebp, %edi
- movl (%esp), %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %ebp, %edi
-.byte 209
-.byte 199 /* roll $1 %edi */
- movl %ebx, %ebp
- xorl %ecx, %ebp
- movl %edi, 12(%esp)
- andl %eax, %ebp
- leal 1518500249(%edi,%edx,1),%edi
- xorl %ecx, %ebp
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edi
- /* 20_39 20 */
- movl 16(%esp), %edx
- movl 24(%esp), %ebp
- xorl %ebp, %edx
- movl 48(%esp), %ebp
- xorl %ebp, %edx
- movl 4(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, 16(%esp)
- xorl %ebx, %ebp
- leal 1859775393(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 21 */
- movl 20(%esp), %ecx
- movl 28(%esp), %ebp
- xorl %ebp, %ecx
- movl 52(%esp), %ebp
- xorl %ebp, %ecx
- movl 8(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 20(%esp)
- xorl %eax, %ebp
- leal 1859775393(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 20_39 22 */
- movl 24(%esp), %ebx
- movl 32(%esp), %ebp
- xorl %ebp, %ebx
- movl 56(%esp), %ebp
- xorl %ebp, %ebx
- movl 12(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %edi, %ebp
- movl %ebx, 24(%esp)
- xorl %esi, %ebp
- leal 1859775393(%ebx,%eax,1),%ebx
- movl %ecx, %eax
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %ebp, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- /* 20_39 23 */
- movl 28(%esp), %eax
- movl 36(%esp), %ebp
- xorl %ebp, %eax
- movl 60(%esp), %ebp
- xorl %ebp, %eax
- movl 16(%esp), %ebp
- xorl %ebp, %eax
- movl %ecx, %ebp
-.byte 209
-.byte 192 /* roll $1 %eax */
- xorl %edx, %ebp
- movl %eax, 28(%esp)
- xorl %edi, %ebp
- leal 1859775393(%eax,%esi,1),%eax
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
- /* 20_39 24 */
- movl 32(%esp), %esi
- movl 40(%esp), %ebp
- xorl %ebp, %esi
- movl (%esp), %ebp
- xorl %ebp, %esi
- movl 20(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 32(%esp)
- xorl %edx, %ebp
- leal 1859775393(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 25 */
- movl 36(%esp), %edi
- movl 44(%esp), %ebp
- xorl %ebp, %edi
- movl 4(%esp), %ebp
- xorl %ebp, %edi
- movl 24(%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 36(%esp)
- xorl %ecx, %ebp
- leal 1859775393(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
- /* 20_39 26 */
- movl 40(%esp), %edx
- movl 48(%esp), %ebp
- xorl %ebp, %edx
- movl 8(%esp), %ebp
- xorl %ebp, %edx
- movl 28(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, 40(%esp)
- xorl %ebx, %ebp
- leal 1859775393(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 27 */
- movl 44(%esp), %ecx
- movl 52(%esp), %ebp
- xorl %ebp, %ecx
- movl 12(%esp), %ebp
- xorl %ebp, %ecx
- movl 32(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 44(%esp)
- xorl %eax, %ebp
- leal 1859775393(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 20_39 28 */
- movl 48(%esp), %ebx
- movl 56(%esp), %ebp
- xorl %ebp, %ebx
- movl 16(%esp), %ebp
- xorl %ebp, %ebx
- movl 36(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %edi, %ebp
- movl %ebx, 48(%esp)
- xorl %esi, %ebp
- leal 1859775393(%ebx,%eax,1),%ebx
- movl %ecx, %eax
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %ebp, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- /* 20_39 29 */
- movl 52(%esp), %eax
- movl 60(%esp), %ebp
- xorl %ebp, %eax
- movl 20(%esp), %ebp
- xorl %ebp, %eax
- movl 40(%esp), %ebp
- xorl %ebp, %eax
- movl %ecx, %ebp
-.byte 209
-.byte 192 /* roll $1 %eax */
- xorl %edx, %ebp
- movl %eax, 52(%esp)
- xorl %edi, %ebp
- leal 1859775393(%eax,%esi,1),%eax
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
- /* 20_39 30 */
- movl 56(%esp), %esi
- movl (%esp), %ebp
- xorl %ebp, %esi
- movl 24(%esp), %ebp
- xorl %ebp, %esi
- movl 44(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 56(%esp)
- xorl %edx, %ebp
- leal 1859775393(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 31 */
- movl 60(%esp), %edi
- movl 4(%esp), %ebp
- xorl %ebp, %edi
- movl 28(%esp), %ebp
- xorl %ebp, %edi
- movl 48(%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 60(%esp)
- xorl %ecx, %ebp
- leal 1859775393(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
- /* 20_39 32 */
- movl (%esp), %edx
- movl 8(%esp), %ebp
- xorl %ebp, %edx
- movl 32(%esp), %ebp
- xorl %ebp, %edx
- movl 52(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, (%esp)
- xorl %ebx, %ebp
- leal 1859775393(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 33 */
- movl 4(%esp), %ecx
- movl 12(%esp), %ebp
- xorl %ebp, %ecx
- movl 36(%esp), %ebp
- xorl %ebp, %ecx
- movl 56(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 4(%esp)
- xorl %eax, %ebp
- leal 1859775393(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 20_39 34 */
- movl 8(%esp), %ebx
- movl 16(%esp), %ebp
- xorl %ebp, %ebx
- movl 40(%esp), %ebp
- xorl %ebp, %ebx
- movl 60(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %edi, %ebp
- movl %ebx, 8(%esp)
- xorl %esi, %ebp
- leal 1859775393(%ebx,%eax,1),%ebx
- movl %ecx, %eax
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %ebp, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- /* 20_39 35 */
- movl 12(%esp), %eax
- movl 20(%esp), %ebp
- xorl %ebp, %eax
- movl 44(%esp), %ebp
- xorl %ebp, %eax
- movl (%esp), %ebp
- xorl %ebp, %eax
- movl %ecx, %ebp
-.byte 209
-.byte 192 /* roll $1 %eax */
- xorl %edx, %ebp
- movl %eax, 12(%esp)
- xorl %edi, %ebp
- leal 1859775393(%eax,%esi,1),%eax
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
- /* 20_39 36 */
- movl 16(%esp), %esi
- movl 24(%esp), %ebp
- xorl %ebp, %esi
- movl 48(%esp), %ebp
- xorl %ebp, %esi
- movl 4(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 16(%esp)
- xorl %edx, %ebp
- leal 1859775393(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 37 */
- movl 20(%esp), %edi
- movl 28(%esp), %ebp
- xorl %ebp, %edi
- movl 52(%esp), %ebp
- xorl %ebp, %edi
- movl 8(%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 20(%esp)
- xorl %ecx, %ebp
- leal 1859775393(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
- /* 20_39 38 */
- movl 24(%esp), %edx
- movl 32(%esp), %ebp
- xorl %ebp, %edx
- movl 56(%esp), %ebp
- xorl %ebp, %edx
- movl 12(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, 24(%esp)
- xorl %ebx, %ebp
- leal 1859775393(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 39 */
- movl 28(%esp), %ecx
- movl 36(%esp), %ebp
- xorl %ebp, %ecx
- movl 60(%esp), %ebp
- xorl %ebp, %ecx
- movl 16(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 28(%esp)
- xorl %eax, %ebp
- leal 1859775393(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 40_59 40 */
- movl 32(%esp), %ebx
- movl 40(%esp), %ebp
- xorl %ebp, %ebx
- movl (%esp), %ebp
- xorl %ebp, %ebx
- movl 20(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- orl %edi, %ebp
- movl %ebx, 32(%esp)
- andl %esi, %ebp
- leal 2400959708(%ebx,%eax,1),%ebx
- movl %edx, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- andl %edi, %eax
- orl %eax, %ebp
- movl %ecx, %eax
- roll $5, %eax
- addl %eax, %ebp
- movl 36(%esp), %eax
- addl %ebp, %ebx
- movl 44(%esp), %ebp
- xorl %ebp, %eax
- movl 4(%esp), %ebp
- xorl %ebp, %eax
- movl 24(%esp), %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %ebp, %eax
-.byte 209
-.byte 192 /* roll $1 %eax */
- movl %ecx, %ebp
- movl %eax, 36(%esp)
- orl %edx, %ebp
- leal 2400959708(%eax,%esi,1),%eax
- movl %ecx, %esi
- andl %edi, %ebp
- andl %edx, %esi
- orl %esi, %ebp
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %ebp
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %eax
- /* 40_59 41 */
- /* 40_59 42 */
- movl 40(%esp), %esi
- movl 48(%esp), %ebp
- xorl %ebp, %esi
- movl 8(%esp), %ebp
- xorl %ebp, %esi
- movl 28(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- orl %ecx, %ebp
- movl %esi, 40(%esp)
- andl %edx, %ebp
- leal 2400959708(%esi,%edi,1),%esi
- movl %ebx, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- andl %ecx, %edi
- orl %edi, %ebp
- movl %eax, %edi
- roll $5, %edi
- addl %edi, %ebp
- movl 44(%esp), %edi
- addl %ebp, %esi
- movl 52(%esp), %ebp
- xorl %ebp, %edi
- movl 12(%esp), %ebp
- xorl %ebp, %edi
- movl 32(%esp), %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %ebp, %edi
-.byte 209
-.byte 199 /* roll $1 %edi */
- movl %eax, %ebp
- movl %edi, 44(%esp)
- orl %ebx, %ebp
- leal 2400959708(%edi,%edx,1),%edi
- movl %eax, %edx
- andl %ecx, %ebp
- andl %ebx, %edx
- orl %edx, %ebp
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %ebp
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edi
- /* 40_59 43 */
- /* 40_59 44 */
- movl 48(%esp), %edx
- movl 56(%esp), %ebp
- xorl %ebp, %edx
- movl 16(%esp), %ebp
- xorl %ebp, %edx
- movl 36(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- orl %eax, %ebp
- movl %edx, 48(%esp)
- andl %ebx, %ebp
- leal 2400959708(%edx,%ecx,1),%edx
- movl %esi, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- andl %eax, %ecx
- orl %ecx, %ebp
- movl %edi, %ecx
- roll $5, %ecx
- addl %ecx, %ebp
- movl 52(%esp), %ecx
- addl %ebp, %edx
- movl 60(%esp), %ebp
- xorl %ebp, %ecx
- movl 20(%esp), %ebp
- xorl %ebp, %ecx
- movl 40(%esp), %ebp
-.byte 209
-.byte 206 /* rorl $1 %esi */
- xorl %ebp, %ecx
-.byte 209
-.byte 193 /* roll $1 %ecx */
- movl %edi, %ebp
- movl %ecx, 52(%esp)
- orl %esi, %ebp
- leal 2400959708(%ecx,%ebx,1),%ecx
- movl %edi, %ebx
- andl %eax, %ebp
- andl %esi, %ebx
- orl %ebx, %ebp
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ebp
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ecx
- /* 40_59 45 */
- /* 40_59 46 */
- movl 56(%esp), %ebx
- movl (%esp), %ebp
- xorl %ebp, %ebx
- movl 24(%esp), %ebp
- xorl %ebp, %ebx
- movl 44(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- orl %edi, %ebp
- movl %ebx, 56(%esp)
- andl %esi, %ebp
- leal 2400959708(%ebx,%eax,1),%ebx
- movl %edx, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- andl %edi, %eax
- orl %eax, %ebp
- movl %ecx, %eax
- roll $5, %eax
- addl %eax, %ebp
- movl 60(%esp), %eax
- addl %ebp, %ebx
- movl 4(%esp), %ebp
- xorl %ebp, %eax
- movl 28(%esp), %ebp
- xorl %ebp, %eax
- movl 48(%esp), %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %ebp, %eax
-.byte 209
-.byte 192 /* roll $1 %eax */
- movl %ecx, %ebp
- movl %eax, 60(%esp)
- orl %edx, %ebp
- leal 2400959708(%eax,%esi,1),%eax
- movl %ecx, %esi
- andl %edi, %ebp
- andl %edx, %esi
- orl %esi, %ebp
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %ebp
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %eax
- /* 40_59 47 */
- /* 40_59 48 */
- movl (%esp), %esi
- movl 8(%esp), %ebp
- xorl %ebp, %esi
- movl 32(%esp), %ebp
- xorl %ebp, %esi
- movl 52(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- orl %ecx, %ebp
- movl %esi, (%esp)
- andl %edx, %ebp
- leal 2400959708(%esi,%edi,1),%esi
- movl %ebx, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- andl %ecx, %edi
- orl %edi, %ebp
- movl %eax, %edi
- roll $5, %edi
- addl %edi, %ebp
- movl 4(%esp), %edi
- addl %ebp, %esi
- movl 12(%esp), %ebp
- xorl %ebp, %edi
- movl 36(%esp), %ebp
- xorl %ebp, %edi
- movl 56(%esp), %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %ebp, %edi
-.byte 209
-.byte 199 /* roll $1 %edi */
- movl %eax, %ebp
- movl %edi, 4(%esp)
- orl %ebx, %ebp
- leal 2400959708(%edi,%edx,1),%edi
- movl %eax, %edx
- andl %ecx, %ebp
- andl %ebx, %edx
- orl %edx, %ebp
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %ebp
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edi
- /* 40_59 49 */
- /* 40_59 50 */
- movl 8(%esp), %edx
- movl 16(%esp), %ebp
- xorl %ebp, %edx
- movl 40(%esp), %ebp
- xorl %ebp, %edx
- movl 60(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- orl %eax, %ebp
- movl %edx, 8(%esp)
- andl %ebx, %ebp
- leal 2400959708(%edx,%ecx,1),%edx
- movl %esi, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- andl %eax, %ecx
- orl %ecx, %ebp
- movl %edi, %ecx
- roll $5, %ecx
- addl %ecx, %ebp
- movl 12(%esp), %ecx
- addl %ebp, %edx
- movl 20(%esp), %ebp
- xorl %ebp, %ecx
- movl 44(%esp), %ebp
- xorl %ebp, %ecx
- movl (%esp), %ebp
-.byte 209
-.byte 206 /* rorl $1 %esi */
- xorl %ebp, %ecx
-.byte 209
-.byte 193 /* roll $1 %ecx */
- movl %edi, %ebp
- movl %ecx, 12(%esp)
- orl %esi, %ebp
- leal 2400959708(%ecx,%ebx,1),%ecx
- movl %edi, %ebx
- andl %eax, %ebp
- andl %esi, %ebx
- orl %ebx, %ebp
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ebp
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ecx
- /* 40_59 51 */
- /* 40_59 52 */
- movl 16(%esp), %ebx
- movl 24(%esp), %ebp
- xorl %ebp, %ebx
- movl 48(%esp), %ebp
- xorl %ebp, %ebx
- movl 4(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- orl %edi, %ebp
- movl %ebx, 16(%esp)
- andl %esi, %ebp
- leal 2400959708(%ebx,%eax,1),%ebx
- movl %edx, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- andl %edi, %eax
- orl %eax, %ebp
- movl %ecx, %eax
- roll $5, %eax
- addl %eax, %ebp
- movl 20(%esp), %eax
- addl %ebp, %ebx
- movl 28(%esp), %ebp
- xorl %ebp, %eax
- movl 52(%esp), %ebp
- xorl %ebp, %eax
- movl 8(%esp), %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %ebp, %eax
-.byte 209
-.byte 192 /* roll $1 %eax */
- movl %ecx, %ebp
- movl %eax, 20(%esp)
- orl %edx, %ebp
- leal 2400959708(%eax,%esi,1),%eax
- movl %ecx, %esi
- andl %edi, %ebp
- andl %edx, %esi
- orl %esi, %ebp
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %ebp
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %eax
- /* 40_59 53 */
- /* 40_59 54 */
- movl 24(%esp), %esi
- movl 32(%esp), %ebp
- xorl %ebp, %esi
- movl 56(%esp), %ebp
- xorl %ebp, %esi
- movl 12(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- orl %ecx, %ebp
- movl %esi, 24(%esp)
- andl %edx, %ebp
- leal 2400959708(%esi,%edi,1),%esi
- movl %ebx, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- andl %ecx, %edi
- orl %edi, %ebp
- movl %eax, %edi
- roll $5, %edi
- addl %edi, %ebp
- movl 28(%esp), %edi
- addl %ebp, %esi
- movl 36(%esp), %ebp
- xorl %ebp, %edi
- movl 60(%esp), %ebp
- xorl %ebp, %edi
- movl 16(%esp), %ebp
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- xorl %ebp, %edi
-.byte 209
-.byte 199 /* roll $1 %edi */
- movl %eax, %ebp
- movl %edi, 28(%esp)
- orl %ebx, %ebp
- leal 2400959708(%edi,%edx,1),%edi
- movl %eax, %edx
- andl %ecx, %ebp
- andl %ebx, %edx
- orl %edx, %ebp
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %ebp
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edi
- /* 40_59 55 */
- /* 40_59 56 */
- movl 32(%esp), %edx
- movl 40(%esp), %ebp
- xorl %ebp, %edx
- movl (%esp), %ebp
- xorl %ebp, %edx
- movl 20(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- orl %eax, %ebp
- movl %edx, 32(%esp)
- andl %ebx, %ebp
- leal 2400959708(%edx,%ecx,1),%edx
- movl %esi, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- andl %eax, %ecx
- orl %ecx, %ebp
- movl %edi, %ecx
- roll $5, %ecx
- addl %ecx, %ebp
- movl 36(%esp), %ecx
- addl %ebp, %edx
- movl 44(%esp), %ebp
- xorl %ebp, %ecx
- movl 4(%esp), %ebp
- xorl %ebp, %ecx
- movl 24(%esp), %ebp
-.byte 209
-.byte 206 /* rorl $1 %esi */
- xorl %ebp, %ecx
-.byte 209
-.byte 193 /* roll $1 %ecx */
- movl %edi, %ebp
- movl %ecx, 36(%esp)
- orl %esi, %ebp
- leal 2400959708(%ecx,%ebx,1),%ecx
- movl %edi, %ebx
- andl %eax, %ebp
- andl %esi, %ebx
- orl %ebx, %ebp
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ebp
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ecx
- /* 40_59 57 */
- /* 40_59 58 */
- movl 40(%esp), %ebx
- movl 48(%esp), %ebp
- xorl %ebp, %ebx
- movl 8(%esp), %ebp
- xorl %ebp, %ebx
- movl 28(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- orl %edi, %ebp
- movl %ebx, 40(%esp)
- andl %esi, %ebp
- leal 2400959708(%ebx,%eax,1),%ebx
- movl %edx, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- andl %edi, %eax
- orl %eax, %ebp
- movl %ecx, %eax
- roll $5, %eax
- addl %eax, %ebp
- movl 44(%esp), %eax
- addl %ebp, %ebx
- movl 52(%esp), %ebp
- xorl %ebp, %eax
- movl 12(%esp), %ebp
- xorl %ebp, %eax
- movl 32(%esp), %ebp
-.byte 209
-.byte 202 /* rorl $1 %edx */
- xorl %ebp, %eax
-.byte 209
-.byte 192 /* roll $1 %eax */
- movl %ecx, %ebp
- movl %eax, 44(%esp)
- orl %edx, %ebp
- leal 2400959708(%eax,%esi,1),%eax
- movl %ecx, %esi
- andl %edi, %ebp
- andl %edx, %esi
- orl %esi, %ebp
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %ebp
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %eax
- /* 40_59 59 */
- /* 20_39 60 */
- movl 48(%esp), %esi
- movl 56(%esp), %ebp
- xorl %ebp, %esi
- movl 16(%esp), %ebp
- xorl %ebp, %esi
- movl 36(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 48(%esp)
- xorl %edx, %ebp
- leal 3395469782(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 61 */
- movl 52(%esp), %edi
- movl 60(%esp), %ebp
- xorl %ebp, %edi
- movl 20(%esp), %ebp
- xorl %ebp, %edi
- movl 40(%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 52(%esp)
- xorl %ecx, %ebp
- leal 3395469782(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
- /* 20_39 62 */
- movl 56(%esp), %edx
- movl (%esp), %ebp
- xorl %ebp, %edx
- movl 24(%esp), %ebp
- xorl %ebp, %edx
- movl 44(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, 56(%esp)
- xorl %ebx, %ebp
- leal 3395469782(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 63 */
- movl 60(%esp), %ecx
- movl 4(%esp), %ebp
- xorl %ebp, %ecx
- movl 28(%esp), %ebp
- xorl %ebp, %ecx
- movl 48(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 60(%esp)
- xorl %eax, %ebp
- leal 3395469782(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 20_39 64 */
- movl (%esp), %ebx
- movl 8(%esp), %ebp
- xorl %ebp, %ebx
- movl 32(%esp), %ebp
- xorl %ebp, %ebx
- movl 52(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %edi, %ebp
- movl %ebx, (%esp)
- xorl %esi, %ebp
- leal 3395469782(%ebx,%eax,1),%ebx
- movl %ecx, %eax
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %ebp, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- /* 20_39 65 */
- movl 4(%esp), %eax
- movl 12(%esp), %ebp
- xorl %ebp, %eax
- movl 36(%esp), %ebp
- xorl %ebp, %eax
- movl 56(%esp), %ebp
- xorl %ebp, %eax
- movl %ecx, %ebp
-.byte 209
-.byte 192 /* roll $1 %eax */
- xorl %edx, %ebp
- movl %eax, 4(%esp)
- xorl %edi, %ebp
- leal 3395469782(%eax,%esi,1),%eax
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
- /* 20_39 66 */
- movl 8(%esp), %esi
- movl 16(%esp), %ebp
- xorl %ebp, %esi
- movl 40(%esp), %ebp
- xorl %ebp, %esi
- movl 60(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 8(%esp)
- xorl %edx, %ebp
- leal 3395469782(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 67 */
- movl 12(%esp), %edi
- movl 20(%esp), %ebp
- xorl %ebp, %edi
- movl 44(%esp), %ebp
- xorl %ebp, %edi
- movl (%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 12(%esp)
- xorl %ecx, %ebp
- leal 3395469782(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
- /* 20_39 68 */
- movl 16(%esp), %edx
- movl 24(%esp), %ebp
- xorl %ebp, %edx
- movl 48(%esp), %ebp
- xorl %ebp, %edx
- movl 4(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, 16(%esp)
- xorl %ebx, %ebp
- leal 3395469782(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 69 */
- movl 20(%esp), %ecx
- movl 28(%esp), %ebp
- xorl %ebp, %ecx
- movl 52(%esp), %ebp
- xorl %ebp, %ecx
- movl 8(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 20(%esp)
- xorl %eax, %ebp
- leal 3395469782(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 20_39 70 */
- movl 24(%esp), %ebx
- movl 32(%esp), %ebp
- xorl %ebp, %ebx
- movl 56(%esp), %ebp
- xorl %ebp, %ebx
- movl 12(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %edi, %ebp
- movl %ebx, 24(%esp)
- xorl %esi, %ebp
- leal 3395469782(%ebx,%eax,1),%ebx
- movl %ecx, %eax
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %ebp, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- /* 20_39 71 */
- movl 28(%esp), %eax
- movl 36(%esp), %ebp
- xorl %ebp, %eax
- movl 60(%esp), %ebp
- xorl %ebp, %eax
- movl 16(%esp), %ebp
- xorl %ebp, %eax
- movl %ecx, %ebp
-.byte 209
-.byte 192 /* roll $1 %eax */
- xorl %edx, %ebp
- movl %eax, 28(%esp)
- xorl %edi, %ebp
- leal 3395469782(%eax,%esi,1),%eax
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
- /* 20_39 72 */
- movl 32(%esp), %esi
- movl 40(%esp), %ebp
- xorl %ebp, %esi
- movl (%esp), %ebp
- xorl %ebp, %esi
- movl 20(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 32(%esp)
- xorl %edx, %ebp
- leal 3395469782(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 73 */
- movl 36(%esp), %edi
- movl 44(%esp), %ebp
- xorl %ebp, %edi
- movl 4(%esp), %ebp
- xorl %ebp, %edi
- movl 24(%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 36(%esp)
- xorl %ecx, %ebp
- leal 3395469782(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %ebp, %edx
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
- /* 20_39 74 */
- movl 40(%esp), %edx
- movl 48(%esp), %ebp
- xorl %ebp, %edx
- movl 8(%esp), %ebp
- xorl %ebp, %edx
- movl 28(%esp), %ebp
- xorl %ebp, %edx
- movl %esi, %ebp
-.byte 209
-.byte 194 /* roll $1 %edx */
- xorl %eax, %ebp
- movl %edx, 40(%esp)
- xorl %ebx, %ebp
- leal 3395469782(%edx,%ecx,1),%edx
- movl %edi, %ecx
- roll $5, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ebp, %ecx
-.byte 209
-.byte 206 /* rorl $1 %esi */
- addl %ecx, %edx
- /* 20_39 75 */
- movl 44(%esp), %ecx
- movl 52(%esp), %ebp
- xorl %ebp, %ecx
- movl 12(%esp), %ebp
- xorl %ebp, %ecx
- movl 32(%esp), %ebp
- xorl %ebp, %ecx
- movl %edi, %ebp
-.byte 209
-.byte 193 /* roll $1 %ecx */
- xorl %esi, %ebp
- movl %ecx, 44(%esp)
- xorl %eax, %ebp
- leal 3395469782(%ecx,%ebx,1),%ecx
- movl %edx, %ebx
- roll $5, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebp, %ebx
-.byte 209
-.byte 207 /* rorl $1 %edi */
- addl %ebx, %ecx
- /* 20_39 76 */
- movl 48(%esp), %ebx
- movl 56(%esp), %ebp
- xorl %ebp, %ebx
- movl 16(%esp), %ebp
- xorl %ebp, %ebx
- movl 36(%esp), %ebp
- xorl %ebp, %ebx
- movl %edx, %ebp
-.byte 209
-.byte 195 /* roll $1 %ebx */
- xorl %edi, %ebp
- movl %ebx, 48(%esp)
- xorl %esi, %ebp
- leal 3395469782(%ebx,%eax,1),%ebx
- movl %ecx, %eax
- roll $5, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %ebp, %eax
-.byte 209
-.byte 202 /* rorl $1 %edx */
- addl %eax, %ebx
- /* 20_39 77 */
- movl 52(%esp), %eax
- movl 60(%esp), %ebp
- xorl %ebp, %eax
- movl 20(%esp), %ebp
- xorl %ebp, %eax
- movl 40(%esp), %ebp
- xorl %ebp, %eax
- movl %ecx, %ebp
-.byte 209
-.byte 192 /* roll $1 %eax */
- xorl %edx, %ebp
- movl %eax, 52(%esp)
- xorl %edi, %ebp
- leal 3395469782(%eax,%esi,1),%eax
- movl %ebx, %esi
- roll $5, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %ebp, %esi
-.byte 209
-.byte 201 /* rorl $1 %ecx */
- addl %esi, %eax
- /* 20_39 78 */
- movl 56(%esp), %esi
- movl (%esp), %ebp
- xorl %ebp, %esi
- movl 24(%esp), %ebp
- xorl %ebp, %esi
- movl 44(%esp), %ebp
- xorl %ebp, %esi
- movl %ebx, %ebp
-.byte 209
-.byte 198 /* roll $1 %esi */
- xorl %ecx, %ebp
- movl %esi, 56(%esp)
- xorl %edx, %ebp
- leal 3395469782(%esi,%edi,1),%esi
- movl %eax, %edi
- roll $5, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %ebp, %edi
-.byte 209
-.byte 203 /* rorl $1 %ebx */
- addl %edi, %esi
- /* 20_39 79 */
- movl 60(%esp), %edi
- movl 4(%esp), %ebp
- xorl %ebp, %edi
- movl 28(%esp), %ebp
- xorl %ebp, %edi
- movl 48(%esp), %ebp
- xorl %ebp, %edi
- movl %eax, %ebp
-.byte 209
-.byte 199 /* roll $1 %edi */
- xorl %ebx, %ebp
- movl %edi, 60(%esp)
- xorl %ecx, %ebp
- leal 3395469782(%edi,%edx,1),%edi
- movl %esi, %edx
- roll $5, %edx
- addl %ebp, %edx
- movl 92(%esp), %ebp
-.byte 209
-.byte 200 /* rorl $1 %eax */
- addl %edx, %edi
-.byte 209
-.byte 200 /* rorl $1 %eax */
- /* End processing */
-
- movl 12(%ebp), %edx
- addl %ebx, %edx
- movl 4(%ebp), %ebx
- addl %esi, %ebx
- movl %eax, %esi
- movl (%ebp), %eax
- movl %edx, 12(%ebp)
- addl %edi, %eax
- movl 16(%ebp), %edi
- addl %ecx, %edi
- movl 8(%ebp), %ecx
- addl %esi, %ecx
- movl %eax, (%ebp)
- movl 64(%esp), %esi
- movl %ecx, 8(%ebp)
- addl $64, %esi
- movl 68(%esp), %eax
- movl %edi, 16(%ebp)
- cmpl %esi, %eax
- movl %ebx, 4(%ebp)
- jb .L001end
- movl (%esi), %eax
- jmp .L000start
-.L001end:
- addl $72, %esp
- popl %edi
- popl %ebx
- popl %ebp
- popl %esi
- ret
-.sha1_block_x86_end:
- SIZE(sha1_block_x86,.sha1_block_x86_end-sha1_block_x86)
-.ident "desasm.pl"
-#endif
diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h
index f8d762dbec27..f251fa4821cf 100644
--- a/lib/libmd/md4.h
+++ b/lib/libmd/md4.h
@@ -27,60 +27,7 @@
#ifndef _MD4_H_
#define _MD4_H_
-/* MD4 context. */
-typedef struct MD4Context {
- u_int32_t state[4]; /* state (ABCD) */
- u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
- unsigned char buffer[64]; /* input buffer */
-} MD4_CTX;
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/* Ensure libmd symbols do not clash with libcrypto */
-
-#ifndef MD4Init
-#define MD4Init _libmd_MD4Init
-#endif
-#ifndef MD4Update
-#define MD4Update _libmd_MD4Update
-#endif
-#ifndef MD4Pad
-#define MD4Pad _libmd_MD4Pad
-#endif
-#ifndef MD4Final
-#define MD4Final _libmd_MD4Final
-#endif
-#ifndef MD4End
-#define MD4End _libmd_MD4End
-#endif
-#ifndef MD4Fd
-#define MD4Fd _libmd_MD4Fd
-#endif
-#ifndef MD4FdChunk
-#define MD4FdChunk _libmd_MD4FdChunk
-#endif
-#ifndef MD4File
-#define MD4File _libmd_MD4File
-#endif
-#ifndef MD4FileChunk
-#define MD4FileChunk _libmd_MD4FileChunk
-#endif
-#ifndef MD4Data
-#define MD4Data _libmd_MD4Data
-#endif
-
-void MD4Init(MD4_CTX *);
-void MD4Update(MD4_CTX *, const void *, unsigned int);
-void MD4Pad(MD4_CTX *);
-void MD4Final(unsigned char [16], MD4_CTX *);
-char * MD4End(MD4_CTX *, char *);
-char * MD4Fd(int, char *);
-char * MD4FdChunk(int, char *, off_t, off_t);
-char * MD4File(const char *, char *);
-char * MD4FileChunk(const char *, char *, off_t, off_t);
-char * MD4Data(const void *, unsigned int, char *);
-__END_DECLS
+#include <sys/md4.h>
#endif /* _MD4_H_ */
diff --git a/lib/libmd/md4c.c b/lib/libmd/md4c.c
deleted file mode 100644
index d98221d264fc..000000000000
--- a/lib/libmd/md4c.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm
- */
-
-#include <sys/cdefs.h>
-/*-
- SPDX-License-Identifier: RSA-MD
-
- Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
-
- License to copy and use this software is granted provided that it
- is identified as the "RSA Data Security, Inc. MD4 Message-Digest
- Algorithm" in all material mentioning or referencing this software
- or this function.
-
- License is also granted to make and use derivative works provided
- that such works are identified as "derived from the RSA Data
- Security, Inc. MD4 Message-Digest Algorithm" in all material
- mentioning or referencing the derived work.
-
- RSA Data Security, Inc. makes no representations concerning either
- the merchantability of this software or the suitability of this
- software for any particular purpose. It is provided "as is"
- without express or implied warranty of any kind.
-
- These notices must be retained in any copies of any part of this
- documentation and/or software.
- */
-
-#include <sys/types.h>
-#include <string.h>
-#include "md4.h"
-
-typedef unsigned char *POINTER;
-typedef const unsigned char *CONST_POINTER;
-typedef u_int16_t UINT2;
-typedef u_int32_t UINT4;
-
-#define PROTO_LIST(list) list
-
-/* Constants for MD4Transform routine.
- */
-#define S11 3
-#define S12 7
-#define S13 11
-#define S14 19
-#define S21 3
-#define S22 5
-#define S23 9
-#define S24 13
-#define S31 3
-#define S32 9
-#define S33 11
-#define S34 15
-
-static void MD4Transform PROTO_LIST ((UINT4 [4], const unsigned char [64]));
-static void Encode PROTO_LIST
- ((unsigned char *, UINT4 *, unsigned int));
-static void Decode PROTO_LIST
- ((UINT4 *, const unsigned char *, unsigned int));
-
-static unsigned char PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* F, G and H are basic MD4 functions.
- */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-
-/* ROTATE_LEFT rotates x left n bits.
- */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/* FF, GG and HH are transformations for rounds 1, 2 and 3 */
-/* Rotation is separate from addition to prevent recomputation */
-#define FF(a, b, c, d, x, s) { \
- (a) += F ((b), (c), (d)) + (x); \
- (a) = ROTATE_LEFT ((a), (s)); \
- }
-#define GG(a, b, c, d, x, s) { \
- (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \
- (a) = ROTATE_LEFT ((a), (s)); \
- }
-#define HH(a, b, c, d, x, s) { \
- (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \
- (a) = ROTATE_LEFT ((a), (s)); \
- }
-
-/* MD4 initialization. Begins an MD4 operation, writing a new context.
- */
-void
-MD4Init(MD4_CTX *context)
-{
- context->count[0] = context->count[1] = 0;
-
- /* Load magic initialization constants.
- */
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
-}
-
-/* MD4 block update operation. Continues an MD4 message-digest
- operation, processing another message block, and updating the
- context.
- */
-void
-MD4Update(MD4_CTX *context, const void *in, unsigned int inputLen)
-{
- unsigned int i, idx, partLen;
- const unsigned char *input = in;
-
- /* Compute number of bytes mod 64 */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
- /* Update number of bits */
- if ((context->count[0] += ((UINT4)inputLen << 3))
- < ((UINT4)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((UINT4)inputLen >> 29);
-
- partLen = 64 - idx;
- /* Transform as many times as possible.
- */
- if (inputLen >= partLen) {
- memcpy
- ((POINTER)&context->buffer[idx], (CONST_POINTER)input, partLen);
- MD4Transform (context->state, context->buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD4Transform (context->state, &input[i]);
-
- idx = 0;
- }
- else
- i = 0;
-
- /* Buffer remaining input */
- memcpy
- ((POINTER)&context->buffer[idx], (CONST_POINTER)&input[i],
- inputLen-i);
-}
-
-/* MD4 padding. */
-void
-MD4Pad(MD4_CTX *context)
-{
- unsigned char bits[8];
- unsigned int idx, padLen;
-
- /* Save number of bits */
- Encode (bits, context->count, 8);
-
- /* Pad out to 56 mod 64.
- */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (idx < 56) ? (56 - idx) : (120 - idx);
- MD4Update (context, PADDING, padLen);
-
- /* Append length (before padding) */
- MD4Update (context, bits, 8);
-}
-
-/* MD4 finalization. Ends an MD4 message-digest operation, writing the
- the message digest and zeroizing the context.
- */
-void
-MD4Final(unsigned char digest[16], MD4_CTX *context)
-{
- /* Do padding */
- MD4Pad (context);
-
- /* Store state in digest */
- Encode (digest, context->state, 16);
-
- /* Zeroize sensitive information.
- */
- explicit_bzero(context, sizeof(*context));
-}
-
-/* MD4 basic transformation. Transforms state based on block.
- */
-static void
-MD4Transform(UINT4 state[4], const unsigned char block[64])
-{
- UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
- FF (a, b, c, d, x[ 0], S11); /* 1 */
- FF (d, a, b, c, x[ 1], S12); /* 2 */
- FF (c, d, a, b, x[ 2], S13); /* 3 */
- FF (b, c, d, a, x[ 3], S14); /* 4 */
- FF (a, b, c, d, x[ 4], S11); /* 5 */
- FF (d, a, b, c, x[ 5], S12); /* 6 */
- FF (c, d, a, b, x[ 6], S13); /* 7 */
- FF (b, c, d, a, x[ 7], S14); /* 8 */
- FF (a, b, c, d, x[ 8], S11); /* 9 */
- FF (d, a, b, c, x[ 9], S12); /* 10 */
- FF (c, d, a, b, x[10], S13); /* 11 */
- FF (b, c, d, a, x[11], S14); /* 12 */
- FF (a, b, c, d, x[12], S11); /* 13 */
- FF (d, a, b, c, x[13], S12); /* 14 */
- FF (c, d, a, b, x[14], S13); /* 15 */
- FF (b, c, d, a, x[15], S14); /* 16 */
-
- /* Round 2 */
- GG (a, b, c, d, x[ 0], S21); /* 17 */
- GG (d, a, b, c, x[ 4], S22); /* 18 */
- GG (c, d, a, b, x[ 8], S23); /* 19 */
- GG (b, c, d, a, x[12], S24); /* 20 */
- GG (a, b, c, d, x[ 1], S21); /* 21 */
- GG (d, a, b, c, x[ 5], S22); /* 22 */
- GG (c, d, a, b, x[ 9], S23); /* 23 */
- GG (b, c, d, a, x[13], S24); /* 24 */
- GG (a, b, c, d, x[ 2], S21); /* 25 */
- GG (d, a, b, c, x[ 6], S22); /* 26 */
- GG (c, d, a, b, x[10], S23); /* 27 */
- GG (b, c, d, a, x[14], S24); /* 28 */
- GG (a, b, c, d, x[ 3], S21); /* 29 */
- GG (d, a, b, c, x[ 7], S22); /* 30 */
- GG (c, d, a, b, x[11], S23); /* 31 */
- GG (b, c, d, a, x[15], S24); /* 32 */
-
- /* Round 3 */
- HH (a, b, c, d, x[ 0], S31); /* 33 */
- HH (d, a, b, c, x[ 8], S32); /* 34 */
- HH (c, d, a, b, x[ 4], S33); /* 35 */
- HH (b, c, d, a, x[12], S34); /* 36 */
- HH (a, b, c, d, x[ 2], S31); /* 37 */
- HH (d, a, b, c, x[10], S32); /* 38 */
- HH (c, d, a, b, x[ 6], S33); /* 39 */
- HH (b, c, d, a, x[14], S34); /* 40 */
- HH (a, b, c, d, x[ 1], S31); /* 41 */
- HH (d, a, b, c, x[ 9], S32); /* 42 */
- HH (c, d, a, b, x[ 5], S33); /* 43 */
- HH (b, c, d, a, x[13], S34); /* 44 */
- HH (a, b, c, d, x[ 3], S31); /* 45 */
- HH (d, a, b, c, x[11], S32); /* 46 */
- HH (c, d, a, b, x[ 7], S33); /* 47 */
- HH (b, c, d, a, x[15], S34); /* 48 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information.
- */
- memset ((POINTER)x, 0, sizeof (x));
-}
-
-/* Encodes input (UINT4) into output (unsigned char). Assumes len is
- a multiple of 4.
- */
-static void
-Encode(unsigned char *output, UINT4 *input, unsigned int len)
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4) {
- output[j] = (unsigned char)(input[i] & 0xff);
- output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
- output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
- output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
- }
-}
-
-/* Decodes input (unsigned char) into output (UINT4). Assumes len is
- a multiple of 4.
- */
-static void
-Decode(UINT4 *output, const unsigned char *input, unsigned int len)
-{
- unsigned int i, j;
-
- for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
- (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
-}
-
-#ifdef WEAK_REFS
-/* When building libmd, provide weak references. Note: this is not
- activated in the context of compiling these sources for internal
- use in libcrypt.
- */
-#undef MD4Init
-__weak_reference(_libmd_MD4Init, MD4Init);
-#undef MD4Update
-__weak_reference(_libmd_MD4Update, MD4Update);
-#undef MD4Pad
-__weak_reference(_libmd_MD4Pad, MD4Pad);
-#undef MD4Final
-__weak_reference(_libmd_MD4Final, MD4Final);
-#endif
diff --git a/lib/libmd/md5.h b/lib/libmd/md5.h
index a4a9f47d4d90..fca9d5f6ee6e 100644
--- a/lib/libmd/md5.h
+++ b/lib/libmd/md5.h
@@ -2,45 +2,5 @@
#ifndef _MD5_H_
#define _MD5_H_
-#ifndef _KERNEL
-
-/* Ensure libmd symbols do not clash with libcrypto */
-
-#ifndef MD5Init
-#define MD5Init _libmd_MD5Init
-#endif
-#ifndef MD5Update
-#define MD5Update _libmd_MD5Update
-#endif
-#ifndef MD5Pad
-#define MD5Pad _libmd_MD5Pad
-#endif
-#ifndef MD5Final
-#define MD5Final _libmd_MD5Final
-#endif
-#ifndef MD5Transform
-#define MD5Transform _libmd_MD5Transform
-#endif
-#ifndef MD5End
-#define MD5End _libmd_MD5End
-#endif
-#ifndef MD5Fd
-#define MD5Fd _libmd_MD5Fd
-#endif
-#ifndef MD5FdChunk
-#define MD5FdChunk _libmd_MD5FdChunk
-#endif
-#ifndef MD5File
-#define MD5File _libmd_MD5File
-#endif
-#ifndef MD5FileChunk
-#define MD5FileChunk _libmd_MD5FileChunk
-#endif
-#ifndef MD5Data
-#define MD5Data _libmd_MD5Data
-#endif
-
-#endif
-
#include <sys/md5.h>
#endif /* _MD5_H_ */
diff --git a/lib/libmd/md5c.c b/lib/libmd/md5c.c
deleted file mode 100644
index 5fc904cdc3ac..000000000000
--- a/lib/libmd/md5c.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*-
- * SPDX-License-Identifier: RSA-MD
- *
- * MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
- *
- * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- * rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- *
- * This code is the same as the code published by RSA Inc. It has been
- * edited for clarity and style only.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#ifdef _KERNEL
-#include <sys/systm.h>
-#else
-#include <string.h>
-#endif
-
-#include <machine/endian.h>
-#include <sys/endian.h>
-#include "md5.h"
-
-static void MD5Transform(u_int32_t [4], const unsigned char [64]);
-
-#ifdef _KERNEL
-#define memset(x,y,z) bzero(x,z);
-#define memcpy(x,y,z) bcopy(y, x, z)
-#endif
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-#define Encode memcpy
-#define Decode memcpy
-#else
-
-/*
- * Encodes input (u_int32_t) into output (unsigned char). Assumes len is
- * a multiple of 4.
- */
-
-static void
-Encode (unsigned char *output, u_int32_t *input, unsigned int len)
-{
- unsigned int i;
- u_int32_t *op = (u_int32_t *)output;
-
- for (i = 0; i < len / 4; i++)
- op[i] = htole32(input[i]);
-}
-
-/*
- * Decodes input (unsigned char) into output (u_int32_t). Assumes len is
- * a multiple of 4.
- */
-
-static void
-Decode (u_int32_t *output, const unsigned char *input, unsigned int len)
-{
- unsigned int i;
- const u_int32_t *ip = (const u_int32_t *)input;
-
- for (i = 0; i < len / 4; i++)
- output[i] = le32toh(ip[i]);
-}
-#endif
-
-static unsigned char PADDING[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* F, G, H and I are basic MD5 functions. */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-#define I(x, y, z) ((y) ^ ((x) | (~z)))
-
-/* ROTATE_LEFT rotates x left n bits. */
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
-
-/*
- * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
- * Rotation is separate from addition to prevent recomputation.
- */
-#define FF(a, b, c, d, x, s, ac) { \
- (a) += F ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define GG(a, b, c, d, x, s, ac) { \
- (a) += G ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define HH(a, b, c, d, x, s, ac) { \
- (a) += H ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-#define II(a, b, c, d, x, s, ac) { \
- (a) += I ((b), (c), (d)) + (x) + (u_int32_t)(ac); \
- (a) = ROTATE_LEFT ((a), (s)); \
- (a) += (b); \
- }
-
-/* MD5 initialization. Begins an MD5 operation, writing a new context. */
-
-void
-MD5Init (MD5_CTX *context)
-{
-
- context->count[0] = context->count[1] = 0;
-
- /* Load magic initialization constants. */
- context->state[0] = 0x67452301;
- context->state[1] = 0xefcdab89;
- context->state[2] = 0x98badcfe;
- context->state[3] = 0x10325476;
-}
-
-/*
- * MD5 block update operation. Continues an MD5 message-digest
- * operation, processing another message block, and updating the
- * context.
- */
-
-void
-MD5Update (MD5_CTX *context, const void *in, unsigned int inputLen)
-{
- unsigned int i, idx, partLen;
- const unsigned char *input = in;
-
- /* Compute number of bytes mod 64 */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
-
- /* Update number of bits */
- if ((context->count[0] += ((u_int32_t)inputLen << 3))
- < ((u_int32_t)inputLen << 3))
- context->count[1]++;
- context->count[1] += ((u_int32_t)inputLen >> 29);
-
- partLen = 64 - idx;
-
- /* Transform as many times as possible. */
- if (inputLen >= partLen) {
- memcpy((void *)&context->buffer[idx], (const void *)input,
- partLen);
- MD5Transform (context->state, context->buffer);
-
- for (i = partLen; i + 63 < inputLen; i += 64)
- MD5Transform (context->state, &input[i]);
-
- idx = 0;
- }
- else
- i = 0;
-
- /* Buffer remaining input */
- memcpy ((void *)&context->buffer[idx], (const void *)&input[i],
- inputLen-i);
-}
-
-/*
- * MD5 padding. Adds padding followed by original length.
- */
-
-void
-MD5Pad (MD5_CTX *context)
-{
- unsigned char bits[8];
- unsigned int idx, padLen;
-
- /* Save number of bits */
- Encode (bits, context->count, 8);
-
- /* Pad out to 56 mod 64. */
- idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
- padLen = (idx < 56) ? (56 - idx) : (120 - idx);
- MD5Update (context, PADDING, padLen);
-
- /* Append length (before padding) */
- MD5Update (context, bits, 8);
-}
-
-/*
- * MD5 finalization. Ends an MD5 message-digest operation, writing the
- * the message digest and zeroizing the context.
- */
-
-void
-MD5Final (unsigned char digest[16], MD5_CTX *context)
-{
- /* Do padding. */
- MD5Pad (context);
-
- /* Store state in digest */
- Encode (digest, context->state, 16);
-
- /* Zeroize sensitive information. */
- explicit_bzero(context, sizeof(*context));
-}
-
-/* MD5 basic transformation. Transforms state based on block. */
-
-static void
-MD5Transform (u_int32_t state[4], const unsigned char block[64])
-{
- u_int32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16];
-
- Decode (x, block, 64);
-
- /* Round 1 */
-#define S11 7
-#define S12 12
-#define S13 17
-#define S14 22
- FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
- FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
- FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
- FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
- FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
- FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
- FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
- FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
- FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
- FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
- FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
- FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
- FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
- FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
- FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
- FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
-
- /* Round 2 */
-#define S21 5
-#define S22 9
-#define S23 14
-#define S24 20
- GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
- GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
- GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
- GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
- GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
- GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
- GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
- GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
- GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
- GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
- GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
- GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
- GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
- GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
- GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
- GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
-
- /* Round 3 */
-#define S31 4
-#define S32 11
-#define S33 16
-#define S34 23
- HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
- HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
- HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
- HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
- HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
- HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
- HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
- HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
- HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
- HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
- HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
- HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
- HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
- HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
- HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
- HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
-
- /* Round 4 */
-#define S41 6
-#define S42 10
-#define S43 15
-#define S44 21
- II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
- II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
- II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
- II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
- II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
- II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
- II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
- II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
- II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
- II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
- II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
- II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
- II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
- II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
- II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
- II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
-
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
-
- /* Zeroize sensitive information. */
- memset ((void *)x, 0, sizeof (x));
-}
-
-#ifdef WEAK_REFS
-/* When building libmd, provide weak references. Note: this is not
- activated in the context of compiling these sources for internal
- use in libcrypt.
- */
-#undef MD5Init
-__weak_reference(_libmd_MD5Init, MD5Init);
-#undef MD5Update
-__weak_reference(_libmd_MD5Update, MD5Update);
-#undef MD5Pad
-__weak_reference(_libmd_MD5Pad, MD5Pad);
-#undef MD5Final
-__weak_reference(_libmd_MD5Final, MD5Final);
-#undef MD5Transform
-__weak_reference(_libmd_MD5Transform, MD5Transform);
-#endif
diff --git a/lib/libmd/mdX.3 b/lib/libmd/mdX.3
index 26c8b2b43c81..7c86f28ad628 100644
--- a/lib/libmd/mdX.3
+++ b/lib/libmd/mdX.3
@@ -6,7 +6,7 @@
.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
.\" ----------------------------------------------------------------------------
.\"
-.Dd May 21, 2019
+.Dd March 8, 2022
.Dt MDX 3
.Os
.Sh NAME
@@ -15,6 +15,8 @@
.Nm MDXPad ,
.Nm MDXFinal ,
.Nm MDXEnd ,
+.Nm MDXFd ,
+.Nm MDXFdChunk ,
.Nm MDXFile ,
.Nm MDXFileChunk ,
.Nm MDXData
@@ -35,6 +37,10 @@
.Ft "char *"
.Fn MDXEnd "MDX_CTX *context" "char *buf"
.Ft "char *"
+.Fn MDXFd "int fd" "char *buf"
+.Ft "char *"
+.Fn MDXFdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn MDXFile "const char *filename" "char *buf"
.Ft "char *"
.Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -125,6 +131,19 @@ function calculates the digest of a chunk of data in memory, and uses
.Fn MDXEnd
to return the result.
.Pp
+The
+.Fn MDXFd
+and
+.Fn MDXFdChunk
+functions are identical to their
+.Fn MDXFile
+and
+.Fn MDXFileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
When using
.Fn MDXEnd ,
.Fn MDXFile ,
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index fab5cc325534..68598f192056 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -9,7 +9,6 @@
* ----------------------------------------------------------------------------
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -131,6 +130,10 @@ __weak_reference(_libmd_MDXEnd, MDXEnd);
__weak_reference(_libmd_MDXFile, MDXFile);
#undef MDXFileChunk
__weak_reference(_libmd_MDXFileChunk, MDXFileChunk);
+#undef MDXFd
+__weak_reference(_libmd_MDXFd, MDXFd);
+#undef MDXFdChunk
+__weak_reference(_libmd_MDXFdChunk, MDXFdChunk);
#undef MDXData
__weak_reference(_libmd_MDXData, MDXData);
#endif
diff --git a/lib/libmd/mddriver.c b/lib/libmd/mddriver.c
deleted file mode 100644
index 8427655e80e8..000000000000
--- a/lib/libmd/mddriver.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* MDDRIVER.C - test driver for MD2, MD4 and MD5 */
-
-/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
- * reserved.
- *
- * RSA Data Security, Inc. makes no representations concerning either the
- * merchantability of this software or the suitability of this software for
- * any particular purpose. It is provided "as is" without express or implied
- * warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software. */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-
-/* The following makes MD default to MD5 if it has not already been defined
- * with C compiler flags. */
-#ifndef MD
-#define MD 5
-#endif
-
-#if MD == 2
-#include "md2.h"
-#define MDData MD2Data
-#endif
-#if MD == 4
-#include "md4.h"
-#define MDData MD4Data
-#endif
-#if MD == 5
-#include "md5.h"
-#define MDData MD5Data
-#endif
-
-/* Digests a string and prints the result. */
-static void
-MDString(char *string)
-{
- char buf[33];
-
- printf("MD%d (\"%s\") = %s\n",
- MD, string, MDData(string, strlen(string), buf));
-}
-
-/* Digests a reference suite of strings and prints the results. */
-int
-main(void)
-{
- printf("MD%d test suite:\n", MD);
-
- MDString("");
- MDString("a");
- MDString("abc");
- MDString("message digest");
- MDString("abcdefghijklmnopqrstuvwxyz");
- MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz0123456789");
- MDString("1234567890123456789012345678901234567890"
- "1234567890123456789012345678901234567890");
-
- return 0;
-}
diff --git a/lib/libmd/ripemd.3 b/lib/libmd/ripemd.3
index fcd2ea308791..cad07aac8007 100644
--- a/lib/libmd/ripemd.3
+++ b/lib/libmd/ripemd.3
@@ -8,7 +8,7 @@
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
.\"
-.Dd July 20, 2018
+.Dd March 8, 2022
.Dt RIPEMD 3
.Os
.Sh NAME
@@ -16,6 +16,8 @@
.Nm RIPEMD160_Update ,
.Nm RIPEMD160_Final ,
.Nm RIPEMD160_End ,
+.Nm RIPEMD160_Fd ,
+.Nm RIPEMD160_FdChunk ,
.Nm RIPEMD160_File ,
.Nm RIPEMD160_FileChunk ,
.Nm RIPEMD160_Data
@@ -34,6 +36,10 @@
.Ft "char *"
.Fn RIPEMD160_End "RIPEMD160_CTX *context" "char *buf"
.Ft "char *"
+.Fn RIPEMD160_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn RIPEMD160_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn RIPEMD160_File "const char *filename" "char *buf"
.Ft "char *"
.Fn RIPEMD160_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -106,6 +112,19 @@ function calculates the digest of a chunk of data in memory, and uses
.Fn RIPEMD160_End
to return the result.
.Pp
+The
+.Fn RIPEMD160_Fd
+and
+.Fn RIPEMD160_FdChunk
+functions are identical to their
+.Fn RIPEMD160_File
+and
+.Fn RIPEMD160_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
When using
.Fn RIPEMD160_End ,
.Fn RIPEMD160_File ,
diff --git a/lib/libmd/ripemd.h b/lib/libmd/ripemd.h
index 337f0f6e4669..252483be0a17 100644
--- a/lib/libmd/ripemd.h
+++ b/lib/libmd/ripemd.h
@@ -62,7 +62,6 @@
#ifndef HEADER_RIPEMD_H
#define HEADER_RIPEMD_H
-#include <sys/cdefs.h>
#include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */
#define RIPEMD160_CBLOCK 64
@@ -110,13 +109,10 @@ __BEGIN_DECLS
#ifndef RIPEMD160_Data
#define RIPEMD160_Data _libmd_RIPEMD160_Data
#endif
-
#ifndef RIPEMD160_Transform
-#define RIPEMD160_Transform _libmd_RIPEMD160_Transform
-#endif
-#ifndef RMD160_version
-#define RMD160_version _libmd_RMD160_version
+#define RIPEMD160_Transform _libmd_RIPEMD160_Transform
#endif
+
#ifndef ripemd160_block
#define ripemd160_block _libmd_ripemd160_block
#endif
diff --git a/lib/libmd/rmd160c.c b/lib/libmd/rmd160c.c
index 1384880aacdf..92d6524b25b4 100644
--- a/lib/libmd/rmd160c.c
+++ b/lib/libmd/rmd160c.c
@@ -56,7 +56,6 @@
* [including the GNU Public Licence.]
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
@@ -77,7 +76,7 @@
#undef RMD160_ASM
#endif
-char *RMD160_version="RIPEMD160 part of SSLeay 0.9.0b 11-Oct-1998";
+static char *RMD160_version="RIPEMD160 part of SSLeay 0.9.0b 11-Oct-1998";
#ifdef RMD160_ASM
void ripemd160_block_x86(RIPEMD160_CTX *c, const u_int32_t *p,int num);
@@ -227,7 +226,7 @@ void RIPEMD160_Update(RIPEMD160_CTX *c, const void *in, size_t len)
}
}
-void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b)
+static void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b)
{
u_int32_t p[16];
#if BYTE_ORDER != LITTLE_ENDIAN
@@ -541,10 +540,4 @@ __weak_reference(_libmd_RIPEMD160_Init, RIPEMD160_Init);
__weak_reference(_libmd_RIPEMD160_Update, RIPEMD160_Update);
#undef RIPEMD160_Final
__weak_reference(_libmd_RIPEMD160_Final, RIPEMD160_Final);
-#undef RIPEMD160_Transform
-__weak_reference(_libmd_RIPEMD160_Transform, RIPEMD160_Transform);
-#undef RMD160_version
-__weak_reference(_libmd_RMD160_version, RMD160_version);
-#undef ripemd160_block
-__weak_reference(_libmd_ripemd160_block, ripemd160_block);
#endif
diff --git a/lib/libmd/rmddriver.c b/lib/libmd/rmddriver.c
deleted file mode 100644
index ea6e79eb5581..000000000000
--- a/lib/libmd/rmddriver.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* RIPEMD160DRIVER.C - test driver for RIPEMD160 */
-
-/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
- * reserved.
- *
- * RSA Data Security, Inc. makes no representations concerning either the
- * merchantability of this software or the suitability of this software for
- * any particular purpose. It is provided "as is" without express or implied
- * warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software. */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-
-#include "ripemd.h"
-
-/* Digests a string and prints the result. */
-static void
-RIPEMD160String(char *string)
-{
- char buf[2*20 + 1];
-
- printf("RIPEMD160 (\"%s\") = %s\n",
- string, RIPEMD160_Data(string, strlen(string), buf));
-}
-
-/* Digests a reference suite of strings and prints the results. */
-int
-main(void)
-{
- printf("RIPEMD160 test suite:\n");
-
- RIPEMD160String("");
- RIPEMD160String("abc");
- RIPEMD160String("message digest");
- RIPEMD160String("abcdefghijklmnopqrstuvwxyz");
- RIPEMD160String("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz0123456789");
- RIPEMD160String("1234567890123456789012345678901234567890"
- "1234567890123456789012345678901234567890");
-
- return 0;
-}
diff --git a/lib/libmd/sha.3 b/lib/libmd/sha.3
index 49ee322eacab..e2475f981738 100644
--- a/lib/libmd/sha.3
+++ b/lib/libmd/sha.3
@@ -8,7 +8,7 @@
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
.\"
-.Dd February 6, 2023
+.Dd February 12, 2023
.Dt SHA 3
.Os
.Sh NAME
@@ -16,6 +16,8 @@
.Nm SHA_Update ,
.Nm SHA_Final ,
.Nm SHA_End ,
+.Nm SHA_Fd ,
+.Nm SHA_FdChunk ,
.Nm SHA_File ,
.Nm SHA_FileChunk ,
.Nm SHA_Data ,
@@ -23,6 +25,8 @@
.Nm SHA1_Update ,
.Nm SHA1_Final ,
.Nm SHA1_End ,
+.Nm SHA1_Fd ,
+.Nm SHA1_FdChunk ,
.Nm SHA1_File ,
.Nm SHA1_FileChunk ,
.Nm SHA1_Data
@@ -41,6 +45,10 @@
.Ft "char *"
.Fn SHA_End "SHA_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -55,6 +63,10 @@
.Ft "char *"
.Fn SHA1_End "SHA_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA1_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA1_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA1_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA1_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -130,6 +142,19 @@ calculates the digest of a chunk of data in memory, and uses
.Fn SHA1_End
to return the result.
.Pp
+The
+.Fn SHA1_Fd
+and
+.Fn SHA1_FdChunk
+functions are identical to their
+.Fn SHA1_File
+and
+.Fn SHA1_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
When using
.Fn SHA1_End ,
.Fn SHA1_File ,
diff --git a/lib/libmd/sha.h b/lib/libmd/sha.h
index f5d697ae938d..3d1cd8da3ae2 100644
--- a/lib/libmd/sha.h
+++ b/lib/libmd/sha.h
@@ -58,7 +58,6 @@
#ifndef _SHA_H_
#define _SHA_H_ 1
-#include <sys/cdefs.h>
#include <sys/types.h> /* XXX switch to machine/ansi.h and __ types */
#define SHA_CBLOCK 64
@@ -108,12 +107,6 @@ __BEGIN_DECLS
#define SHA_Data _libmd_SHA_Data
#endif
-#ifndef SHA_Transform
-#define SHA_Transform _libmd_SHA_Transform
-#endif
-#ifndef SHA_version
-#define SHA_version _libmd_SHA_version
-#endif
#ifndef sha_block
#define sha_block _libmd_sha_block
#endif
@@ -145,13 +138,10 @@ __BEGIN_DECLS
#ifndef SHA1_Data
#define SHA1_Data _libmd_SHA1_Data
#endif
-
#ifndef SHA1_Transform
#define SHA1_Transform _libmd_SHA1_Transform
#endif
-#ifndef SHA1_version
-#define SHA1_version _libmd_SHA1_version
-#endif
+
#ifndef sha1_block
#define sha1_block _libmd_sha1_block
#endif
diff --git a/lib/libmd/sha0c.c b/lib/libmd/sha0c.c
index dc31389b6858..a36617b6ca60 100644
--- a/lib/libmd/sha0c.c
+++ b/lib/libmd/sha0c.c
@@ -56,7 +56,6 @@
* [including the GNU Public Licence.]
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdio.h>
@@ -243,7 +242,7 @@ void SHA_Update(SHA_CTX *c, const void *in, size_t len)
p[sw]=l;
}
-void SHA_Transform(SHA_CTX *c, unsigned char *b)
+static void SHA_Transform(SHA_CTX *c, unsigned char *b)
{
u_int32_t p[16];
#if BYTE_ORDER == LITTLE_ENDIAN
diff --git a/lib/libmd/sha1c.c b/lib/libmd/sha1c.c
index 7626473c6f3c..128e0b991742 100644
--- a/lib/libmd/sha1c.c
+++ b/lib/libmd/sha1c.c
@@ -1,477 +1,244 @@
-/* crypto/sha/sha1dgst.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
+/*-
+ * Copyright (c) 2009 The Go Authors. All rights reserved.
+ * Copyright (c) 2024 Robert Clausecker <fuz@freebsd.org>
+ *
+ * Adapted from Go's crypto/sha1/sha1.go.
*
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
* 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 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 cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the routines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``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.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
*/
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <stdio.h>
+#include <assert.h>
+#include <sha.h>
+#include <stdint.h>
#include <string.h>
+#include <strings.h>
+#include <sys/endian.h>
-#if 0
-#include <machine/ansi.h> /* we use the __ variants of bit-sized types */
+#ifdef SHA1_ASM
+extern void sha1_block(SHA1_CTX *, const void *, size_t);
+#else
+static void sha1_block(SHA1_CTX *, const void *, size_t);
#endif
-#include <machine/endian.h>
-#undef SHA_0
-#define SHA_1
-#include "sha.h"
-#include "sha_locl.h"
+#define INIT0 0x67452301
+#define INIT1 0xEFCDAB89
+#define INIT2 0x98BADCFE
+#define INIT3 0x10325476
+#define INIT4 0xC3D2E1F0
-/*
- * The assembly-language code is not position-independent, so don't
- * try to use it in a shared library.
- */
-#ifdef PIC
-#undef SHA1_ASM
-#endif
+#define K0 0x5A827999
+#define K1 0x6ED9EBA1
+#define K2 0x8F1BBCDC
+#define K3 0xCA62C1D6
-char *SHA1_version="SHA1 part of SSLeay 0.9.0b 11-Oct-1998";
+void
+SHA1_Init(SHA1_CTX *c)
+{
+ c->h0 = INIT0;
+ c->h1 = INIT1;
+ c->h2 = INIT2;
+ c->h3 = INIT3;
+ c->h4 = INIT4;
+ c->Nl = 0;
+ c->Nh = 0;
+ c->num = 0;
+}
-/* Implemented from SHA-1 document - The Secure Hash Algorithm
- */
+void
+SHA1_Update(SHA1_CTX *c, const void *data, size_t len)
+{
+ uint64_t nn;
+ const char *p = data;
-#define INIT_DATA_h0 (unsigned long)0x67452301L
-#define INIT_DATA_h1 (unsigned long)0xefcdab89L
-#define INIT_DATA_h2 (unsigned long)0x98badcfeL
-#define INIT_DATA_h3 (unsigned long)0x10325476L
-#define INIT_DATA_h4 (unsigned long)0xc3d2e1f0L
-
-#define K_00_19 0x5a827999L
-#define K_20_39 0x6ed9eba1L
-#define K_40_59 0x8f1bbcdcL
-#define K_60_79 0xca62c1d6L
-
-#ifndef NOPROTO
-# ifdef SHA1_ASM
- void sha1_block_x86(SHA_CTX *c, const u_int32_t *p, int num);
-# define sha1_block sha1_block_x86
-# else
- void sha1_block(SHA_CTX *c, const u_int32_t *p, int num);
-# endif
-#else
-# ifdef SHA1_ASM
- void sha1_block_x86();
-# define sha1_block sha1_block_x86
-# else
- void sha1_block();
-# endif
-#endif
+ nn = (uint64_t)c->Nl | (uint64_t)c->Nh << 32;
+ nn += len;
+ c->Nl = (uint32_t)nn;
+ c->Nh = (uint32_t)(nn >> 32);
+ if (c->num > 0) {
+ size_t n = SHA_CBLOCK - c->num;
-#if BYTE_ORDER == LITTLE_ENDIAN && defined(SHA1_ASM)
-# define M_c2nl c2l
-# define M_p_c2nl p_c2l
-# define M_c2nl_p c2l_p
-# define M_p_c2nl_p p_c2l_p
-# define M_nl2c l2c
-#else
-# define M_c2nl c2nl
-# define M_p_c2nl p_c2nl
-# define M_c2nl_p c2nl_p
-# define M_p_c2nl_p p_c2nl_p
-# define M_nl2c nl2c
-#endif
+ if (n > len)
+ n = len;
+
+ memcpy((char *)c->data + c->num, p, n);
+ c->num += n;
+ if (c->num == SHA_CBLOCK) {
+ sha1_block(c, (void *)c->data, SHA_CBLOCK);
+ c->num = 0;
+ }
+
+ p += n;
+ len -= n;
+ }
+
+ if (len >= SHA_CBLOCK) {
+ size_t n = len & ~(size_t)(SHA_CBLOCK - 1);
+
+ sha1_block(c, p, n);
+ p += n;
+ len -= n;
+ }
-void SHA1_Init(SHA_CTX *c)
- {
- c->h0=INIT_DATA_h0;
- c->h1=INIT_DATA_h1;
- c->h2=INIT_DATA_h2;
- c->h3=INIT_DATA_h3;
- c->h4=INIT_DATA_h4;
- c->Nl=0;
- c->Nh=0;
- c->num=0;
+ if (len > 0) {
+ memcpy(c->data, p, len);
+ c->num = len;
}
+}
void
-SHA1_Update(SHA_CTX *c, const void *in, size_t len)
+SHA1_Final(unsigned char *md, SHA1_CTX *c)
{
- u_int32_t *p;
- int ew,ec,sw,sc;
- u_int32_t l;
- const unsigned char *data = in;
-
- if (len == 0) return;
-
- l=(c->Nl+(len<<3))&0xffffffffL;
- if (l < c->Nl) /* overflow */
- c->Nh++;
- c->Nh+=(len>>29);
- c->Nl=l;
-
- if (c->num != 0)
- {
- p=c->data;
- sw=c->num>>2;
- sc=c->num&0x03;
-
- if ((c->num+len) >= SHA_CBLOCK)
- {
- l= p[sw];
- M_p_c2nl(data,l,sc);
- p[sw++]=l;
- for (; sw<SHA_LBLOCK; sw++)
- {
- M_c2nl(data,l);
- p[sw]=l;
- }
- len-=(SHA_CBLOCK-c->num);
-
- sha1_block(c,p,64);
- c->num=0;
- /* drop through and do the rest */
- }
- else
- {
- c->num+=(int)len;
- if ((sc+len) < 4) /* ugly, add char's to a word */
- {
- l= p[sw];
- M_p_c2nl_p(data,l,sc,len);
- p[sw]=l;
- }
- else
- {
- ew=(c->num>>2);
- ec=(c->num&0x03);
- l= p[sw];
- M_p_c2nl(data,l,sc);
- p[sw++]=l;
- for (; sw < ew; sw++)
- { M_c2nl(data,l); p[sw]=l; }
- if (ec)
- {
- M_c2nl_p(data,l,ec);
- p[sw]=l;
- }
- }
- return;
- }
+ uint64_t len;
+ size_t t;
+ unsigned char tmp[SHA_CBLOCK + sizeof(uint64_t)] = {0x80, 0};
+
+ len = (uint64_t)c->Nl | (uint64_t)c->Nh << 32;
+ t = 64 + 56 - c->Nl % 64;
+ if (t > 64)
+ t -= 64;
+
+ /* length in bits */
+ len <<= 3;
+ be64enc(tmp + t, len);
+ SHA1_Update(c, tmp, t + 8);
+ assert(c->num == 0);
+
+ be32enc(md + 0, c->h0);
+ be32enc(md + 4, c->h1);
+ be32enc(md + 8, c->h2);
+ be32enc(md + 12, c->h3);
+ be32enc(md + 16, c->h4);
+
+ explicit_bzero(c, sizeof(*c));
+}
+
+#ifndef SHA1_ASM
+static void
+/* invariant: len is a multiple of SHA_CBLOCK */
+sha1_block(SHA1_CTX *c, const void *data, size_t len)
+{
+ uint32_t w[16];
+ uint32_t h0 = c->h0, h1 = c->h1, h2 = c->h2, h3 = c->h3, h4 = c->h4;
+ const char *p = data;
+
+ while (len >= SHA_CBLOCK) {
+ size_t i;
+ uint32_t a = h0, b = h1, c = h2, d = h3, e = h4;
+ uint32_t f, t, tmp;
+
+# pragma unroll
+ for (i = 0; i < 16; i++)
+ w[i] = be32dec(p + 4*i);
+
+# pragma unroll
+ for (i = 0; i < 16; i++) {
+ f = b & c | ~b & d;
+ t = (a << 5 | a >> 32 - 5) + f + e + w[i & 0xf] + K0;
+ e = d;
+ d = c;
+ c = b << 30 | b >> 32 - 30;
+ b = a;
+ a = t;
}
- /* We can only do the following code for assember, the reason
- * being that the sha1_block 'C' version changes the values
- * in the 'data' array. The assember code avoids this and
- * copies it to a local array. I should be able to do this for
- * the C version as well....
- */
-#if 1
-#if BYTE_ORDER == BIG_ENDIAN || defined(SHA1_ASM)
- if ((((unsigned int)data)%sizeof(u_int32_t)) == 0)
- {
- sw=len/SHA_CBLOCK;
- if (sw)
- {
- sw*=SHA_CBLOCK;
- sha1_block(c,(u_int32_t *)data,sw);
- data+=sw;
- len-=sw;
- }
+
+# pragma unroll
+ for (; i < 20; i++) {
+ tmp = w[i - 3 & 0xf] ^ w[i - 8 & 0xf] ^ w[i - 14 & 0xf] ^ w[i & 0xf];
+ w[i & 0xf] = tmp << 1 | tmp >> 32 - 1;
+
+ f = b & c | ~b & d;
+ t = (a << 5 | a >> 32 - 5) + f + e + w[i & 0xf] + K0;
+ e = d;
+ d = c;
+ c = b << 30 | b >> 32 - 30;
+ b = a;
+ a = t;
}
-#endif
-#endif
- /* we now can process the input data in blocks of SHA_CBLOCK
- * chars and save the leftovers to c->data. */
- p=c->data;
- while (len >= SHA_CBLOCK)
- {
-#if BYTE_ORDER == BIG_ENDIAN || BYTE_ORDER == LITTLE_ENDIAN
- if (p != (u_int32_t *)data)
- memcpy(p,data,SHA_CBLOCK);
- data+=SHA_CBLOCK;
-# if BYTE_ORDER == LITTLE_ENDIAN
-# ifndef SHA1_ASM /* Will not happen */
- for (sw=(SHA_LBLOCK/4); sw; sw--)
- {
- Endian_Reverse32(p[0]);
- Endian_Reverse32(p[1]);
- Endian_Reverse32(p[2]);
- Endian_Reverse32(p[3]);
- p+=4;
- }
- p=c->data;
-# endif
-# endif
-#else
- for (sw=(SHA_BLOCK/4); sw; sw--)
- {
- M_c2nl(data,l); *(p++)=l;
- M_c2nl(data,l); *(p++)=l;
- M_c2nl(data,l); *(p++)=l;
- M_c2nl(data,l); *(p++)=l;
- }
- p=c->data;
-#endif
- sha1_block(c,p,64);
- len-=SHA_CBLOCK;
+
+# pragma unroll
+ for (; i < 40; i++) {
+ tmp = w[i - 3 & 0xf] ^ w[i - 8 & 0xf] ^ w[i - 14 & 0xf] ^ w[i & 0xf];
+ w[i & 0xf] = tmp << 1 | tmp >> 32 - 1;
+
+ f = b ^ c ^ d;
+ t = (a << 5 | a >> 32 - 5) + f + e + w[i & 0xf] + K1;
+ e = d;
+ d = c;
+ c = b << 30 | b >> 32 - 30;
+ b = a;
+ a = t;
}
- ec=(int)len;
- c->num=ec;
- ew=(ec>>2);
- ec&=0x03;
-
- for (sw=0; sw < ew; sw++)
- { M_c2nl(data,l); p[sw]=l; }
- M_c2nl_p(data,l,ec);
- p[sw]=l;
- }
-void SHA1_Transform(SHA_CTX *c, unsigned char *b)
- {
- u_int32_t p[16];
-#if BYTE_ORDER != BIG_ENDIAN
- u_int32_t *q;
- int i;
-#endif
+# pragma unroll
+ for (; i < 60; i++) {
+ tmp = w[i - 3 & 0xf] ^ w[i - 8 & 0xf] ^ w[i - 14 & 0xf] ^ w[i & 0xf];
+ w[i & 0xf] = tmp << 1 | tmp >> 32 - 1;
+
+ f = (b | c) & d | b & c;
+ t = (a << 5 | a >> 32 - 5) + f + e + w[i & 0xf] + K2;
+ e = d;
+ d = c;
+ c = b << 30 | b >> 32 - 30;
+ b = a;
+ a = t;
+ }
-#if BYTE_ORDER == BIG_ENDIAN || BYTE_ORDER == LITTLE_ENDIAN
- memcpy(p,b,64);
-#if BYTE_ORDER == LITTLE_ENDIAN
- q=p;
- for (i=(SHA_LBLOCK/4); i; i--)
- {
- Endian_Reverse32(q[0]);
- Endian_Reverse32(q[1]);
- Endian_Reverse32(q[2]);
- Endian_Reverse32(q[3]);
- q+=4;
+# pragma unroll
+ for (; i < 80; i++) {
+ tmp = w[i - 3 & 0xf] ^ w[i - 8 & 0xf] ^ w[i - 14 & 0xf] ^ w[i & 0xf];
+ w[i & 0xf] = tmp << 1 | tmp >> 32 - 1;
+
+ f = b ^ c ^ d;
+ t = (a << 5 | a >> 32 - 5) + f + e + w[i & 0xf] + K3;
+ e = d;
+ d = c;
+ c = b << 30 | b >> 32 - 30;
+ b = a;
+ a = t;
}
-#endif
-#else
- q=p;
- for (i=(SHA_LBLOCK/4); i; i--)
- {
- u_int32_t l;
- c2nl(b,l); *(q++)=l;
- c2nl(b,l); *(q++)=l;
- c2nl(b,l); *(q++)=l;
- c2nl(b,l); *(q++)=l;
- }
-#endif
- sha1_block(c,p,64);
- }
-#ifndef SHA1_ASM
+ h0 += a;
+ h1 += b;
+ h2 += c;
+ h3 += d;
+ h4 += e;
-void
-sha1_block(SHA_CTX *c, const u_int32_t *W, int num)
-{
- u_int32_t A,B,C,D,E,T;
- u_int32_t X[16];
-
- A=c->h0;
- B=c->h1;
- C=c->h2;
- D=c->h3;
- E=c->h4;
-
- for (;;)
- {
- BODY_00_15( 0,A,B,C,D,E,T,W);
- BODY_00_15( 1,T,A,B,C,D,E,W);
- BODY_00_15( 2,E,T,A,B,C,D,W);
- BODY_00_15( 3,D,E,T,A,B,C,W);
- BODY_00_15( 4,C,D,E,T,A,B,W);
- BODY_00_15( 5,B,C,D,E,T,A,W);
- BODY_00_15( 6,A,B,C,D,E,T,W);
- BODY_00_15( 7,T,A,B,C,D,E,W);
- BODY_00_15( 8,E,T,A,B,C,D,W);
- BODY_00_15( 9,D,E,T,A,B,C,W);
- BODY_00_15(10,C,D,E,T,A,B,W);
- BODY_00_15(11,B,C,D,E,T,A,W);
- BODY_00_15(12,A,B,C,D,E,T,W);
- BODY_00_15(13,T,A,B,C,D,E,W);
- BODY_00_15(14,E,T,A,B,C,D,W);
- BODY_00_15(15,D,E,T,A,B,C,W);
- BODY_16_19(16,C,D,E,T,A,B,W,W,W,W);
- BODY_16_19(17,B,C,D,E,T,A,W,W,W,W);
- BODY_16_19(18,A,B,C,D,E,T,W,W,W,W);
- BODY_16_19(19,T,A,B,C,D,E,W,W,W,X);
-
- BODY_20_31(20,E,T,A,B,C,D,W,W,W,X);
- BODY_20_31(21,D,E,T,A,B,C,W,W,W,X);
- BODY_20_31(22,C,D,E,T,A,B,W,W,W,X);
- BODY_20_31(23,B,C,D,E,T,A,W,W,W,X);
- BODY_20_31(24,A,B,C,D,E,T,W,W,X,X);
- BODY_20_31(25,T,A,B,C,D,E,W,W,X,X);
- BODY_20_31(26,E,T,A,B,C,D,W,W,X,X);
- BODY_20_31(27,D,E,T,A,B,C,W,W,X,X);
- BODY_20_31(28,C,D,E,T,A,B,W,W,X,X);
- BODY_20_31(29,B,C,D,E,T,A,W,W,X,X);
- BODY_20_31(30,A,B,C,D,E,T,W,X,X,X);
- BODY_20_31(31,T,A,B,C,D,E,W,X,X,X);
- BODY_32_39(32,E,T,A,B,C,D,X);
- BODY_32_39(33,D,E,T,A,B,C,X);
- BODY_32_39(34,C,D,E,T,A,B,X);
- BODY_32_39(35,B,C,D,E,T,A,X);
- BODY_32_39(36,A,B,C,D,E,T,X);
- BODY_32_39(37,T,A,B,C,D,E,X);
- BODY_32_39(38,E,T,A,B,C,D,X);
- BODY_32_39(39,D,E,T,A,B,C,X);
-
- BODY_40_59(40,C,D,E,T,A,B,X);
- BODY_40_59(41,B,C,D,E,T,A,X);
- BODY_40_59(42,A,B,C,D,E,T,X);
- BODY_40_59(43,T,A,B,C,D,E,X);
- BODY_40_59(44,E,T,A,B,C,D,X);
- BODY_40_59(45,D,E,T,A,B,C,X);
- BODY_40_59(46,C,D,E,T,A,B,X);
- BODY_40_59(47,B,C,D,E,T,A,X);
- BODY_40_59(48,A,B,C,D,E,T,X);
- BODY_40_59(49,T,A,B,C,D,E,X);
- BODY_40_59(50,E,T,A,B,C,D,X);
- BODY_40_59(51,D,E,T,A,B,C,X);
- BODY_40_59(52,C,D,E,T,A,B,X);
- BODY_40_59(53,B,C,D,E,T,A,X);
- BODY_40_59(54,A,B,C,D,E,T,X);
- BODY_40_59(55,T,A,B,C,D,E,X);
- BODY_40_59(56,E,T,A,B,C,D,X);
- BODY_40_59(57,D,E,T,A,B,C,X);
- BODY_40_59(58,C,D,E,T,A,B,X);
- BODY_40_59(59,B,C,D,E,T,A,X);
-
- BODY_60_79(60,A,B,C,D,E,T,X);
- BODY_60_79(61,T,A,B,C,D,E,X);
- BODY_60_79(62,E,T,A,B,C,D,X);
- BODY_60_79(63,D,E,T,A,B,C,X);
- BODY_60_79(64,C,D,E,T,A,B,X);
- BODY_60_79(65,B,C,D,E,T,A,X);
- BODY_60_79(66,A,B,C,D,E,T,X);
- BODY_60_79(67,T,A,B,C,D,E,X);
- BODY_60_79(68,E,T,A,B,C,D,X);
- BODY_60_79(69,D,E,T,A,B,C,X);
- BODY_60_79(70,C,D,E,T,A,B,X);
- BODY_60_79(71,B,C,D,E,T,A,X);
- BODY_60_79(72,A,B,C,D,E,T,X);
- BODY_60_79(73,T,A,B,C,D,E,X);
- BODY_60_79(74,E,T,A,B,C,D,X);
- BODY_60_79(75,D,E,T,A,B,C,X);
- BODY_60_79(76,C,D,E,T,A,B,X);
- BODY_60_79(77,B,C,D,E,T,A,X);
- BODY_60_79(78,A,B,C,D,E,T,X);
- BODY_60_79(79,T,A,B,C,D,E,X);
-
- c->h0=(c->h0+E)&0xffffffffL;
- c->h1=(c->h1+T)&0xffffffffL;
- c->h2=(c->h2+A)&0xffffffffL;
- c->h3=(c->h3+B)&0xffffffffL;
- c->h4=(c->h4+C)&0xffffffffL;
-
- num-=64;
- if (num <= 0) break;
-
- A=c->h0;
- B=c->h1;
- C=c->h2;
- D=c->h3;
- E=c->h4;
-
- W+=16;
- }
+ p += SHA_CBLOCK;
+ len -= SHA_CBLOCK;
}
-#endif
-void SHA1_Final(unsigned char *md, SHA_CTX *c)
- {
- int i,j;
- u_int32_t l;
- u_int32_t *p;
- static unsigned char end[4]={0x80,0x00,0x00,0x00};
- unsigned char *cp=end;
-
- /* c->num should definitly have room for at least one more byte. */
- p=c->data;
- j=c->num;
- i=j>>2;
-#ifdef PURIFY
- if ((j&0x03) == 0) p[i]=0;
+ c->h0 = h0;
+ c->h1 = h1;
+ c->h2 = h2;
+ c->h3 = h3;
+ c->h4 = h4;
+}
#endif
- l=p[i];
- M_p_c2nl(cp,l,j&0x03);
- p[i]=l;
- i++;
- /* i is the next 'undefined word' */
- if (c->num >= SHA_LAST_BLOCK)
- {
- for (; i<SHA_LBLOCK; i++)
- p[i]=0;
- sha1_block(c,p,64);
- i=0;
- }
- for (; i<(SHA_LBLOCK-2); i++)
- p[i]=0;
- p[SHA_LBLOCK-2]=c->Nh;
- p[SHA_LBLOCK-1]=c->Nl;
-#if BYTE_ORDER == LITTLE_ENDIAN && defined(SHA1_ASM)
- Endian_Reverse32(p[SHA_LBLOCK-2]);
- Endian_Reverse32(p[SHA_LBLOCK-1]);
-#endif
- sha1_block(c,p,64);
- cp=md;
- l=c->h0; nl2c(l,cp);
- l=c->h1; nl2c(l,cp);
- l=c->h2; nl2c(l,cp);
- l=c->h3; nl2c(l,cp);
- l=c->h4; nl2c(l,cp);
-
- /* Clear the context state */
- explicit_bzero(&c, sizeof(c));
- }
#ifdef WEAK_REFS
/* When building libmd, provide weak references. Note: this is not
@@ -484,22 +251,10 @@ __weak_reference(_libmd_SHA_Init, SHA_Init);
__weak_reference(_libmd_SHA_Update, SHA_Update);
#undef SHA_Final
__weak_reference(_libmd_SHA_Final, SHA_Final);
-#undef SHA_Transform
-__weak_reference(_libmd_SHA_Transform, SHA_Transform);
-#undef SHA_version
-__weak_reference(_libmd_SHA_version, SHA_version);
-#undef sha_block
-__weak_reference(_libmd_sha_block, sha_block);
#undef SHA1_Init
__weak_reference(_libmd_SHA1_Init, SHA1_Init);
#undef SHA1_Update
__weak_reference(_libmd_SHA1_Update, SHA1_Update);
#undef SHA1_Final
__weak_reference(_libmd_SHA1_Final, SHA1_Final);
-#undef SHA1_Transform
-__weak_reference(_libmd_SHA1_Transform, SHA1_Transform);
-#undef SHA1_version
-__weak_reference(_libmd_SHA1_version, SHA1_version);
-#undef sha1_block
-__weak_reference(_libmd_sha1_block, sha1_block);
#endif
diff --git a/lib/libmd/sha256.3 b/lib/libmd/sha256.3
index e22258f40140..406dfd1b357d 100644
--- a/lib/libmd/sha256.3
+++ b/lib/libmd/sha256.3
@@ -8,7 +8,7 @@
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
.\"
-.Dd July 20, 2018
+.Dd March 8, 2022
.Dt SHA256 3
.Os
.Sh NAME
@@ -16,6 +16,8 @@
.Nm SHA224_Update ,
.Nm SHA224_Final ,
.Nm SHA224_End ,
+.Nm SHA224_Fd ,
+.Nm SHA224_FdChunk ,
.Nm SHA224_File ,
.Nm SHA224_FileChunk ,
.Nm SHA224_Data ,
@@ -23,6 +25,8 @@
.Nm SHA256_Update ,
.Nm SHA256_Final ,
.Nm SHA256_End ,
+.Nm SHA256_Fd ,
+.Nm SHA256_FdChunk ,
.Nm SHA256_File ,
.Nm SHA256_FileChunk ,
.Nm SHA256_Data
@@ -41,6 +45,10 @@
.Ft "char *"
.Fn SHA224_End "SHA224_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA224_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA224_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA224_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA224_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -56,6 +64,10 @@
.Ft "char *"
.Fn SHA256_End "SHA256_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA256_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA256_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA256_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -125,6 +137,19 @@ calculates the digest of a chunk of data in memory, and uses
.Fn SHA256_End
to return the result.
.Pp
+The
+.Fn SHA256_Fd
+and
+.Fn SHA256_FdChunk
+functions are identical to their
+.Fn SHA256_File
+and
+.Fn SHA256_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
When using
.Fn SHA256_End ,
.Fn SHA256_File ,
diff --git a/lib/libmd/sha512.3 b/lib/libmd/sha512.3
index a5c478efa9ae..17d0d0988350 100644
--- a/lib/libmd/sha512.3
+++ b/lib/libmd/sha512.3
@@ -8,7 +8,7 @@
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
.\"
-.Dd February 3, 2023
+.Dd February 12, 2023
.Dt SHA512 3
.Os
.Sh NAME
@@ -16,6 +16,8 @@
.Nm SHA512_Update ,
.Nm SHA512_Final ,
.Nm SHA512_End ,
+.Nm SHA512_Fd ,
+.Nm SHA512_FdChunk ,
.Nm SHA512_File ,
.Nm SHA512_FileChunk ,
.Nm SHA512_Data ,
@@ -23,6 +25,8 @@
.Nm SHA384_Update ,
.Nm SHA384_Final ,
.Nm SHA384_End ,
+.Nm SHA384_Fd ,
+.Nm SHA384_FdChunk ,
.Nm SHA384_File ,
.Nm SHA384_FileChunk ,
.Nm SHA384_Data ,
@@ -37,6 +41,8 @@
.Nm SHA512_256_Update ,
.Nm SHA512_256_Final ,
.Nm SHA512_256_End ,
+.Nm SHA512_256_Fd ,
+.Nm SHA512_256_FdChunk ,
.Nm SHA512_256_File ,
.Nm SHA512_256_FileChunk ,
.Nm SHA512_256_Data
@@ -55,6 +61,10 @@
.Ft "char *"
.Fn SHA512_End "SHA512_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA512_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA512_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA512_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -70,6 +80,10 @@
.Ft "char *"
.Fn SHA384_End "SHA384_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA384_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA384_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA384_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA384_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -99,6 +113,10 @@
.Ft "char *"
.Fn SHA512_256_End "SHA512_CTX *context" "char *buf"
.Ft "char *"
+.Fn SHA512_256_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA512_256_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SHA512_256_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SHA512_256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -168,6 +186,19 @@ calculates the digest of a chunk of data in memory, and uses
.Fn SHA512_End
to return the result.
.Pp
+The
+.Fn SHA512_Fd
+and
+.Fn SHA512_FdChunk
+functions are identical to their
+.Fn SHA512_File
+and
+.Fn SHA512_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
When using
.Fn SHA512_End ,
.Fn SHA512_File ,
diff --git a/lib/libmd/shadriver.c b/lib/libmd/shadriver.c
deleted file mode 100644
index 9b0c47e3e753..000000000000
--- a/lib/libmd/shadriver.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* SHADRIVER.C - test driver for SHA-1 (and SHA-2) */
-
-/*-
- * SPDX-License-Identifier: RSA-MD
- *
- * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
- * reserved.
- *
- * RSA Data Security, Inc. makes no representations concerning either the
- * merchantability of this software or the suitability of this software for
- * any particular purpose. It is provided "as is" without express or implied
- * warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software. */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-
-#include "sha.h"
-#include "sha224.h"
-#include "sha256.h"
-#include "sha384.h"
-#include "sha512.h"
-#include "sha512t.h"
-
-/* The following makes SHA default to SHA-1 if it has not already been
- * defined with C compiler flags. */
-#ifndef SHA
-#define SHA 1
-#endif
-
-#if SHA == 1
-#undef SHA_Data
-#define SHA_Data SHA1_Data
-#elif SHA == 224
-#undef SHA_Data
-#define SHA_Data SHA224_Data
-#elif SHA == 256
-#undef SHA_Data
-#define SHA_Data SHA256_Data
-#elif SHA == 384
-#undef SHA_Data
-#define SHA_Data SHA384_Data
-#elif SHA == 512
-#undef SHA_Data
-#define SHA_Data SHA512_Data
-#elif SHA == 512224
-#undef SHA_Data
-#define SHA_Data SHA512_224_Data
-#elif SHA == 512256
-#undef SHA_Data
-#define SHA_Data SHA512_256_Data
-#endif
-
-/* Digests a string and prints the result. */
-static void
-SHAString(char *string)
-{
- char buf[2*64 + 1];
-
- printf("SHA-%d (\"%s\") = %s\n",
- SHA, string, SHA_Data(string, strlen(string), buf));
-}
-
-/* Digests a reference suite of strings and prints the results. */
-int
-main(void)
-{
- printf("SHA-%d test suite:\n", SHA);
-
- SHAString("");
- SHAString("abc");
- SHAString("message digest");
- SHAString("abcdefghijklmnopqrstuvwxyz");
- SHAString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz0123456789");
- SHAString("1234567890123456789012345678901234567890"
- "1234567890123456789012345678901234567890");
-
- return 0;
-}
diff --git a/lib/libmd/skein.3 b/lib/libmd/skein.3
index 1dff9e2c92dc..8fe79a4ad0bf 100644
--- a/lib/libmd/skein.3
+++ b/lib/libmd/skein.3
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 21, 2019
+.Dd March 8, 2022
.Dt SKEIN 3
.Os
.Sh NAME
@@ -31,6 +31,8 @@
.Nm SKEIN256_Update ,
.Nm SKEIN256_Final ,
.Nm SKEIN256_End ,
+.Nm SKEIN256_Fd ,
+.Nm SKEIN256_FdChunk ,
.Nm SKEIN256_File ,
.Nm SKEIN256_FileChunk ,
.Nm SKEIN256_Data ,
@@ -38,6 +40,8 @@
.Nm SKEIN512_Update ,
.Nm SKEIN512_Final ,
.Nm SKEIN512_End ,
+.Nm SKEIN512_Fd ,
+.Nm SKEIN512_FdChunk ,
.Nm SKEIN512_File ,
.Nm SKEIN512_FileChunk ,
.Nm SKEIN512_Data ,
@@ -45,6 +49,8 @@
.Nm SKEIN1024_Update ,
.Nm SKEIN1024_Final ,
.Nm SKEIN1024_End ,
+.Nm SKEIN1024_Fd ,
+.Nm SKEIN1024_FdChunk ,
.Nm SKEIN1024_File ,
.Nm SKEIN1024_FileChunk ,
.Nm SKEIN1024_Data
@@ -63,6 +69,10 @@
.Ft "char *"
.Fn SKEIN256_End "SKEIN256_CTX *context" "char *buf"
.Ft "char *"
+.Fn SKEIN256_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SKEIN256_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SKEIN256_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SKEIN256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -77,6 +87,10 @@
.Ft "char *"
.Fn SKEIN512_End "SKEIN512_CTX *context" "char *buf"
.Ft "char *"
+.Fn SKEIN512_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SKEIN512_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SKEIN512_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SKEIN512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -91,6 +105,10 @@
.Ft "char *"
.Fn SKEIN1024_End "SKEIN1024_CTX *context" "char *buf"
.Ft "char *"
+.Fn SKEIN1024_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SKEIN1024_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
.Fn SKEIN1024_File "const char *filename" "char *buf"
.Ft "char *"
.Fn SKEIN1024_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -160,6 +178,19 @@ calculates the digest of a chunk of data in memory, and uses
.Fn SKEIN256_End
to return the result.
.Pp
+The
+.Fn SKEIN256_Fd
+and
+.Fn SKEIN256_FdChunk
+functions are identical to their
+.Fn SKEIN256_File
+and
+.Fn SKEIN256_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
When using
.Fn SKEIN256_End ,
.Fn SKEIN256_File ,
diff --git a/lib/libmd/skeindriver.c b/lib/libmd/skeindriver.c
deleted file mode 100644
index 9433fdac8c25..000000000000
--- a/lib/libmd/skeindriver.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* SKEINDRIVER.C - test driver for SKEIN */
-
-/*-
- * SPDX-License-Identifier: RSA-MD
- *
- * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
- * reserved.
- *
- * RSA Data Security, Inc. makes no representations concerning either the
- * merchantability of this software or the suitability of this software for
- * any particular purpose. It is provided "as is" without express or implied
- * warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software. */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <time.h>
-#include <string.h>
-
-#include "skein.h"
-
-/* The following makes SKEIN default to SKEIN512 if it has not already been
- * defined with C compiler flags. */
-#ifndef SKEIN
-#define SKEIN 512
-#endif
-
-#if SKEIN == 256
-#undef SKEIN_Data
-#define SKEIN_Data SKEIN256_Data
-#elif SKEIN == 512
-#undef SKEIN_Data
-#define SKEIN_Data SKEIN512_Data
-#elif SKEIN == 1024
-#undef SKEIN_Data
-#define SKEIN_Data SKEIN1024_Data
-#endif
-
-/* Digests a string and prints the result. */
-static void
-SKEINString(char *string)
-{
- char buf[2*128 + 1];
-
- printf("SKEIN%d (\"%s\") = %s\n",
- SKEIN, string, SKEIN_Data(string, strlen(string), buf));
-}
-
-/* Digests a reference suite of strings and prints the results. */
-int
-main(void)
-{
- printf("SKEIN%d test suite:\n", SKEIN);
-
- SKEINString("");
- SKEINString("abc");
- SKEINString("message digest");
- SKEINString("abcdefghijklmnopqrstuvwxyz");
- SKEINString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz0123456789");
- SKEINString("1234567890123456789012345678901234567890"
- "1234567890123456789012345678901234567890");
-
- return 0;
-}
diff --git a/lib/libmd/tests/Makefile b/lib/libmd/tests/Makefile
new file mode 100644
index 000000000000..e11e8e1bf154
--- /dev/null
+++ b/lib/libmd/tests/Makefile
@@ -0,0 +1,255 @@
+# $FreeBSD$
+
+PACKAGE= tests
+
+ATF_TESTS_SH= libmd_test
+
+MDTESTS= md rmd sha skein
+
+MDTESTS_md= md4 md5
+MDTESTS_rmd= rmd160
+MDTESTS_sha= sha0 sha1 sha224 sha256 sha384 sha512 sha512t224 sha512t256
+MDTESTS_skein= skein256 skein512 skein1024
+
+LIBADD= md
+
+.for mdt in ${MDTESTS}
+REFS_${mdt}= ${MDTESTS_${mdt}:C/$/.ref/}
+${PACKAGE}FILES+= ${REFS_${mdt}}
+CLEANFILES+= ${REFS_${mdt}}
+
+# This target is simply convenient for auditing, letting you build all of one
+# digest suite with `make <family>driver`.
+.PHONY: ${mdt}driver
+
+. for mdtc in ${MDTESTS_${mdt}}
+PROGS+= ${mdtc}driver
+DIGESTS+= ${mdtc}
+
+# Avoid obj collision, we'll build the same driver.c multiple times.
+${mdtc}driver.c: ${mdt}driver.c
+ ${CP} ${.CURDIR}/${mdt}driver.c ${.TARGET}
+
+SRCS_${mdtc}driver= ${mdtc}driver.c
+BINDIR_${mdtc}driver= ${TESTSDIR}
+.if ${mdt} == "sha"
+CFLAGS_${mdtc}driver= -DSHA=${mdtc:C/sha//:C/t//}
+.else
+CFLAGS_${mdtc}driver= -D${mdt:tu}=${mdtc:C/${mdt}//}
+.endif
+
+${mdt}driver: ${mdtc}driver
+
+. endfor
+.endfor
+
+CLEANFILES+= libmd_test.sh
+libmd_test.sh: Makefile
+ :> ${.TARGET}
+.for _digest in ${DIGESTS}
+ @echo "atf_test_case ${_digest}" >> ${.TARGET}
+ @echo "${_digest}_body() {" >> ${.TARGET}
+ @echo " atf_check -o file:\$$(atf_get_srcdir)/${_digest}.ref \\" >> \
+ ${.TARGET}
+ @echo " \$$(atf_get_srcdir)/${_digest}driver" >> ${.TARGET}
+ @echo "}" >> ${.TARGET}
+.endfor
+ @echo "atf_init_test_cases() {" >> ${.TARGET}
+.for _digest in ${DIGESTS}
+ @echo " atf_add_test_case ${_digest}" >> ${.TARGET}
+.endfor
+ @echo "}" >> ${.TARGET}
+
+md4.ref:
+ echo 'MD4 test suite:' > ${.TARGET}
+ @echo 'MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0' >> ${.TARGET}
+ @echo 'MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24' >> ${.TARGET}
+ @echo 'MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d' >> ${.TARGET}
+ @echo 'MD4 ("message digest") = d9130a8164549fe818874806e1c7014b' >> ${.TARGET}
+ @echo 'MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9' >> ${.TARGET}
+ @echo 'MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '043f8582f241db351ce627e153e7f0e4' >> ${.TARGET}
+ @echo 'MD4 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ 'e33b4ddc9c38f2199c3e7b164fcc0536' >> ${.TARGET}
+
+md5.ref:
+ echo 'MD5 test suite:' > ${.TARGET}
+ @echo 'MD5 ("") = d41d8cd98f00b204e9800998ecf8427e' >> ${.TARGET}
+ @echo 'MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661' >> ${.TARGET}
+ @echo 'MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72' >> ${.TARGET}
+ @echo 'MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0' >> ${.TARGET}
+ @echo 'MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b' >> ${.TARGET}
+ @echo 'MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = d174ab98d277d9f5a5611c2c9f419d9f' >> ${.TARGET}
+ @echo 'MD5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a' >> ${.TARGET}
+
+sha0.ref:
+ echo 'SHA-0 test suite:' > ${.TARGET}
+ @echo 'SHA-0 ("") = f96cea198ad1dd5617ac084a3d92c6107708c0ef' >> ${.TARGET}
+ @echo 'SHA-0 ("abc") = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880' >> ${.TARGET}
+ @echo 'SHA-0 ("message digest") =' \
+ 'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14' >> ${.TARGET}
+ @echo 'SHA-0 ("abcdefghijklmnopqrstuvwxyz") =' \
+ 'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd' >> ${.TARGET}
+ @echo 'SHA-0 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '79e966f7a3a990df33e40e3d7f8f18d2caebadfa' >> ${.TARGET}
+ @echo 'SHA-0 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '4aa29d14d171522ece47bee8957e35a41f3e9cff' >> ${.TARGET}
+
+sha1.ref:
+ echo 'SHA-1 test suite:' > ${.TARGET}
+ @echo 'SHA-1 ("") = da39a3ee5e6b4b0d3255bfef95601890afd80709' >> ${.TARGET}
+ @echo 'SHA-1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d' >> ${.TARGET}
+ @echo 'SHA-1 ("message digest") =' \
+ 'c12252ceda8be8994d5fa0290a47231c1d16aae3' >> ${.TARGET}
+ @echo 'SHA-1 ("abcdefghijklmnopqrstuvwxyz") =' \
+ '32d10c7b8cf96570ca04ce37f2a19d84240d3a89' >> ${.TARGET}
+ @echo 'SHA-1 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '761c457bf73b14d27e9e9265c46f4b4dda11f940' >> ${.TARGET}
+ @echo 'SHA-1 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '50abf5706a150990a08b2c5ea40fa0e585554732' >> ${.TARGET}
+
+sha224.ref:
+ echo 'SHA-224 test suite:' > ${.TARGET}
+ @echo 'SHA-224 ("") = d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f' >> ${.TARGET}
+ @echo 'SHA-224 ("abc") =' \
+ '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7' >> ${.TARGET}
+ @echo 'SHA-224 ("message digest") =' \
+ '2cb21c83ae2f004de7e81c3c7019cbcb65b71ab656b22d6d0c39b8eb' >> ${.TARGET}
+ @echo 'SHA-224 ("abcdefghijklmnopqrstuvwxyz") =' \
+ '45a5f72c39c5cff2522eb3429799e49e5f44b356ef926bcf390dccc2' >> ${.TARGET}
+ @echo 'SHA-224 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ 'bff72b4fcb7d75e5632900ac5f90d219e05e97a7bde72e740db393d9' >> ${.TARGET}
+ @echo 'SHA-224 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ 'b50aecbe4e9bb0b57bc5f3ae760a8e01db24f203fb3cdcd13148046e' >> ${.TARGET}
+
+sha256.ref:
+ echo 'SHA-256 test suite:' > ${.TARGET}
+ @echo 'SHA-256 ("") = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' >> ${.TARGET}
+ @echo 'SHA-256 ("abc") =' \
+ 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' >> ${.TARGET}
+ @echo 'SHA-256 ("message digest") =' \
+ 'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650' >> ${.TARGET}
+ @echo 'SHA-256 ("abcdefghijklmnopqrstuvwxyz") =' \
+ '71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73' >> ${.TARGET}
+ @echo 'SHA-256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ 'db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0' >> ${.TARGET}
+ @echo 'SHA-256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ 'f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e' >> ${.TARGET}
+
+sha384.ref:
+ echo 'SHA-384 test suite:' > ${.TARGET}
+ @echo 'SHA-384 ("") =' \
+ '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' >> ${.TARGET}
+ @echo 'SHA-384 ("abc") =' \
+ 'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7' >> ${.TARGET}
+ @echo 'SHA-384 ("message digest") =' \
+ '473ed35167ec1f5d8e550368a3db39be54639f828868e9454c239fc8b52e3c61dbd0d8b4de1390c256dcbb5d5fd99cd5' >> ${.TARGET}
+ @echo 'SHA-384 ("abcdefghijklmnopqrstuvwxyz") =' \
+ 'feb67349df3db6f5924815d6c3dc133f091809213731fe5c7b5f4999e463479ff2877f5f2936fa63bb43784b12f3ebb4' >> ${.TARGET}
+ @echo 'SHA-384 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039c1464ee8732f11a5341a6f41e0c202294736ed64db1a84' >> ${.TARGET}
+ @echo 'SHA-384 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ 'b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026' >> ${.TARGET}
+
+sha512.ref:
+ echo 'SHA-512 test suite:' > ${.TARGET}
+ @echo 'SHA-512 ("") =' \
+ 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e' >> ${.TARGET}
+ @echo 'SHA-512 ("abc") =' \
+ 'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f' >> ${.TARGET}
+ @echo 'SHA-512 ("message digest") =' \
+ '107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c' >> ${.TARGET}
+ @echo 'SHA-512 ("abcdefghijklmnopqrstuvwxyz") =' \
+ '4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1' >> ${.TARGET}
+ @echo 'SHA-512 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894' >> ${.TARGET}
+ @echo 'SHA-512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843' >> ${.TARGET}
+
+sha512t224.ref:
+ echo 'SHA-512224 test suite:' > ${.TARGET}
+ @echo 'SHA-512224 ("") =' \
+ '6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4' >> ${.TARGET}
+ @echo 'SHA-512224 ("abc") =' \
+ '4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa' >> ${.TARGET}
+ @echo 'SHA-512224 ("message digest") =' \
+ 'ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564' >> ${.TARGET}
+ @echo 'SHA-512224 ("abcdefghijklmnopqrstuvwxyz") =' \
+ 'ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8' >> ${.TARGET}
+ @echo 'SHA-512224 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ 'a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3' >> ${.TARGET}
+ @echo 'SHA-512224 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ 'ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2' >> ${.TARGET}
+
+sha512t256.ref:
+ echo 'SHA-512256 test suite:' > ${.TARGET}
+ @echo 'SHA-512256 ("") =' \
+ 'c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a' >> ${.TARGET}
+ @echo 'SHA-512256 ("abc") =' \
+ '53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23' >> ${.TARGET}
+ @echo 'SHA-512256 ("message digest") =' \
+ '0cf471fd17ed69d990daf3433c89b16d63dec1bb9cb42a6094604ee5d7b4e9fb' >> ${.TARGET}
+ @echo 'SHA-512256 ("abcdefghijklmnopqrstuvwxyz") =' \
+ 'fc3189443f9c268f626aea08a756abe7b726b05f701cb08222312ccfd6710a26' >> ${.TARGET}
+ @echo 'SHA-512256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ 'cdf1cc0effe26ecc0c13758f7b4a48e000615df241284185c39eb05d355bb9c8' >> ${.TARGET}
+ @echo 'SHA-512256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '2c9fdbc0c90bdd87612ee8455474f9044850241dc105b1e8b94b8ddf5fac9148' >> ${.TARGET}
+
+rmd160.ref:
+ echo 'RIPEMD160 test suite:' > ${.TARGET}
+ @echo 'RIPEMD160 ("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31' >> ${.TARGET}
+ @echo 'RIPEMD160 ("abc") = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc' >> ${.TARGET}
+ @echo 'RIPEMD160 ("message digest") =' \
+ '5d0689ef49d2fae572b881b123a85ffa21595f36' >> ${.TARGET}
+ @echo 'RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") =' \
+ 'f71c27109c692c1b56bbdceb5b9d2865b3708dbc' >> ${.TARGET}
+ @echo 'RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ 'b0e20b6e3116640286ed3a87a5713079b21f5189' >> ${.TARGET}
+ @echo 'RIPEMD160 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '9b752e45573d4b39f4dbd3323cab82bf63326bfb' >> ${.TARGET}
+
+skein256.ref:
+ echo 'SKEIN256 test suite:' > ${.TARGET}
+ @echo 'SKEIN256 ("") = c8877087da56e072870daa843f176e9453115929094c3a40c463a196c29bf7ba' >> ${.TARGET}
+ @echo 'SKEIN256 ("abc") = 258bdec343b9fde1639221a5ae0144a96e552e5288753c5fec76c05fc2fc1870' >> ${.TARGET}
+ @echo 'SKEIN256 ("message digest") =' \
+ '4d2ce0062b5eb3a4db95bc1117dd8aa014f6cd50fdc8e64f31f7d41f9231e488' >> ${.TARGET}
+ @echo 'SKEIN256 ("abcdefghijklmnopqrstuvwxyz") =' \
+ '46d8440685461b00e3ddb891b2ecc6855287d2bd8834a95fb1c1708b00ea5e82' >> ${.TARGET}
+ @echo 'SKEIN256 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '7c5eb606389556b33d34eb2536459528dc0af97adbcd0ce273aeb650f598d4b2' >> ${.TARGET}
+ @echo 'SKEIN256 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '4def7a7e5464a140ae9c3a80279fbebce4bd00f9faad819ab7e001512f67a10d' >> ${.TARGET}
+
+skein512.ref:
+ echo 'SKEIN512 test suite:' > ${.TARGET}
+ @echo 'SKEIN512 ("") =' \
+ 'bc5b4c50925519c290cc634277ae3d6257212395cba733bbad37a4af0fa06af41fca7903d06564fea7a2d3730dbdb80c1f85562dfcc070334ea4d1d9e72cba7a' >> ${.TARGET}
+ @echo 'SKEIN512 ("abc") =' \
+ '8f5dd9ec798152668e35129496b029a960c9a9b88662f7f9482f110b31f9f93893ecfb25c009baad9e46737197d5630379816a886aa05526d3a70df272d96e75' >> ${.TARGET}
+ @echo 'SKEIN512 ("message digest") =' \
+ '15b73c158ffb875fed4d72801ded0794c720b121c0c78edf45f900937e6933d9e21a3a984206933d504b5dbb2368000411477ee1b204c986068df77886542fcc' >> ${.TARGET}
+ @echo 'SKEIN512 ("abcdefghijklmnopqrstuvwxyz") =' \
+ '23793ad900ef12f9165c8080da6fdfd2c8354a2929b8aadf83aa82a3c6470342f57cf8c035ec0d97429b626c4d94f28632c8f5134fd367dca5cf293d2ec13f8c' >> ${.TARGET}
+ @echo 'SKEIN512 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ '0c6bed927e022f5ddcf81877d42e5f75798a9f8fd3ede3d83baac0a2f364b082e036c11af35fe478745459dd8f5c0b73efe3c56ba5bb2009208d5a29cc6e469c' >> ${.TARGET}
+ @echo 'SKEIN512 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ '2ca9fcffb3456f297d1b5f407014ecb856f0baac8eb540f534b1f187196f21e88f31103128c2f03fcc9857d7a58eb66f9525e2302d88833ee069295537a434ce' >> ${.TARGET}
+
+skein1024.ref:
+ echo 'SKEIN1024 test suite:' > ${.TARGET}
+ @echo 'SKEIN1024 ("") =' \
+ '0fff9563bb3279289227ac77d319b6fff8d7e9f09da1247b72a0a265cd6d2a62645ad547ed8193db48cff847c06494a03f55666d3b47eb4c20456c9373c86297d630d5578ebd34cb40991578f9f52b18003efa35d3da6553ff35db91b81ab890bec1b189b7f52cb2a783ebb7d823d725b0b4a71f6824e88f68f982eefc6d19c6' >> ${.TARGET}
+ @echo 'SKEIN1024 ("abc") =' \
+ '35a599a0f91abcdb4cb73c19b8cb8d947742d82c309137a7caed29e8e0a2ca7a9ff9a90c34c1908cc7e7fd99bb15032fb86e76df21b72628399b5f7c3cc209d7bb31c99cd4e19465622a049afbb87c03b5ce3888d17e6e667279ec0aa9b3e2712624c01b5f5bbe1a564220bdcf6990af0c2539019f313fdd7406cca3892a1f1f' >> ${.TARGET}
+ @echo 'SKEIN1024 ("message digest") =' \
+ 'ea891f5268acd0fac97467fc1aa89d1ce8681a9992a42540e53babee861483110c2d16f49e73bac27653ff173003e40cfb08516cd34262e6af95a5d8645c9c1abb3e813604d508b8511b30f9a5c1b352aa0791c7d2f27b2706dccea54bc7de6555b5202351751c3299f97c09cf89c40f67187e2521c0fad82b30edbb224f0458' >> ${.TARGET}
+ @echo 'SKEIN1024 ("abcdefghijklmnopqrstuvwxyz") =' \
+ 'f23d95c2a25fbcd0e797cd058fec39d3c52d2b5afd7a9af1df934e63257d1d3dcf3246e7329c0f1104c1e51e3d22e300507b0c3b9f985bb1f645ef49835080536becf83788e17fed09c9982ba65c3cb7ffe6a5f745b911c506962adf226e435c42f6f6bc08d288f9c810e807e3216ef444f3db22744441deefa4900982a1371f' >> ${.TARGET}
+ @echo 'SKEIN1024 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =' \
+ 'cf3889e8a8d11bfd3938055d7d061437962bc5eac8ae83b1b71c94be201b8cf657fdbfc38674997a008c0c903f56a23feb3ae30e012377f1cfa080a9ca7fe8b96138662653fb3335c7d06595bf8baf65e215307532094cfdfa056bd8052ab792a3944a2adaa47b30335b8badb8fe9eb94fe329cdca04e58bbc530f0af709f469' >> ${.TARGET}
+ @echo 'SKEIN1024 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") =' \
+ 'cf21a613620e6c119eca31fdfaad449a8e02f95ca256c21d2a105f8e4157048f9fe1e897893ea18b64e0e37cb07d5ac947f27ba544caf7cbc1ad094e675aed77a366270f7eb7f46543bccfa61c526fd628408058ed00ed566ac35a9761d002e629c4fb0d430b2f4ad016fcc49c44d2981c4002da0eecc42144160e2eaea4855a' >> ${.TARGET}
+
+.include <bsd.test.mk>
diff --git a/lib/libmd/tests/mddriver.c b/lib/libmd/tests/mddriver.c
new file mode 100644
index 000000000000..1229a4e2929f
--- /dev/null
+++ b/lib/libmd/tests/mddriver.c
@@ -0,0 +1,66 @@
+/* MDDRIVER.C - test driver for MD2, MD4 and MD5 */
+
+/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+
+/* The following makes MD default to MD5 if it has not already been defined
+ * with C compiler flags. */
+#ifndef MD
+#define MD 5
+#endif
+
+#if MD == 2
+#include "md2.h"
+#define MDData MD2Data
+#endif
+#if MD == 4
+#include "md4.h"
+#define MDData MD4Data
+#endif
+#if MD == 5
+#include "md5.h"
+#define MDData MD5Data
+#endif
+
+/* Digests a string and prints the result. */
+static void
+MDString(const char *string)
+{
+ char buf[33];
+
+ printf("MD%d (\"%s\") = %s\n",
+ MD, string, MDData(string, strlen(string), buf));
+}
+
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
+{
+ printf("MD%d test suite:\n", MD);
+
+ MDString("");
+ MDString("a");
+ MDString("abc");
+ MDString("message digest");
+ MDString("abcdefghijklmnopqrstuvwxyz");
+ MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789");
+ MDString("1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890");
+
+ return 0;
+}
diff --git a/lib/libmd/tests/rmddriver.c b/lib/libmd/tests/rmddriver.c
new file mode 100644
index 000000000000..50227dcffb5d
--- /dev/null
+++ b/lib/libmd/tests/rmddriver.c
@@ -0,0 +1,48 @@
+/* RIPEMD160DRIVER.C - test driver for RIPEMD160 */
+
+/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+
+#include "ripemd.h"
+
+/* Digests a string and prints the result. */
+static void
+RIPEMD160String(const char *string)
+{
+ char buf[2*20 + 1];
+
+ printf("RIPEMD160 (\"%s\") = %s\n",
+ string, RIPEMD160_Data(string, strlen(string), buf));
+}
+
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
+{
+ printf("RIPEMD160 test suite:\n");
+
+ RIPEMD160String("");
+ RIPEMD160String("abc");
+ RIPEMD160String("message digest");
+ RIPEMD160String("abcdefghijklmnopqrstuvwxyz");
+ RIPEMD160String("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789");
+ RIPEMD160String("1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890");
+
+ return 0;
+}
diff --git a/lib/libmd/tests/shadriver.c b/lib/libmd/tests/shadriver.c
new file mode 100644
index 000000000000..85cb21185bc8
--- /dev/null
+++ b/lib/libmd/tests/shadriver.c
@@ -0,0 +1,85 @@
+/* SHADRIVER.C - test driver for SHA-1 (and SHA-2) */
+
+/*-
+ * SPDX-License-Identifier: RSA-MD
+ *
+ * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+
+#include "sha.h"
+#include "sha224.h"
+#include "sha256.h"
+#include "sha384.h"
+#include "sha512.h"
+#include "sha512t.h"
+
+/* The following makes SHA default to SHA-1 if it has not already been
+ * defined with C compiler flags. */
+#ifndef SHA
+#define SHA 1
+#endif
+
+#if SHA == 1
+#undef SHA_Data
+#define SHA_Data SHA1_Data
+#elif SHA == 224
+#undef SHA_Data
+#define SHA_Data SHA224_Data
+#elif SHA == 256
+#undef SHA_Data
+#define SHA_Data SHA256_Data
+#elif SHA == 384
+#undef SHA_Data
+#define SHA_Data SHA384_Data
+#elif SHA == 512
+#undef SHA_Data
+#define SHA_Data SHA512_Data
+#elif SHA == 512224
+#undef SHA_Data
+#define SHA_Data SHA512_224_Data
+#elif SHA == 512256
+#undef SHA_Data
+#define SHA_Data SHA512_256_Data
+#endif
+
+/* Digests a string and prints the result. */
+static void
+SHAString(const char *string)
+{
+ char buf[2*64 + 1];
+
+ printf("SHA-%d (\"%s\") = %s\n",
+ SHA, string, SHA_Data(string, strlen(string), buf));
+}
+
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
+{
+ printf("SHA-%d test suite:\n", SHA);
+
+ SHAString("");
+ SHAString("abc");
+ SHAString("message digest");
+ SHAString("abcdefghijklmnopqrstuvwxyz");
+ SHAString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789");
+ SHAString("1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890");
+
+ return 0;
+}
diff --git a/lib/libmd/tests/skeindriver.c b/lib/libmd/tests/skeindriver.c
new file mode 100644
index 000000000000..a28ac8fc2c2a
--- /dev/null
+++ b/lib/libmd/tests/skeindriver.c
@@ -0,0 +1,68 @@
+/* SKEINDRIVER.C - test driver for SKEIN */
+
+/*-
+ * SPDX-License-Identifier: RSA-MD
+ *
+ * Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All rights
+ * reserved.
+ *
+ * RSA Data Security, Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ *
+ * These notices must be retained in any copies of any part of this
+ * documentation and/or software. */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+
+#include "skein.h"
+
+/* The following makes SKEIN default to SKEIN512 if it has not already been
+ * defined with C compiler flags. */
+#ifndef SKEIN
+#define SKEIN 512
+#endif
+
+#if SKEIN == 256
+#undef SKEIN_Data
+#define SKEIN_Data SKEIN256_Data
+#elif SKEIN == 512
+#undef SKEIN_Data
+#define SKEIN_Data SKEIN512_Data
+#elif SKEIN == 1024
+#undef SKEIN_Data
+#define SKEIN_Data SKEIN1024_Data
+#endif
+
+/* Digests a string and prints the result. */
+static void
+SKEINString(const char *string)
+{
+ char buf[2*128 + 1];
+
+ printf("SKEIN%d (\"%s\") = %s\n",
+ SKEIN, string, SKEIN_Data(string, strlen(string), buf));
+}
+
+/* Digests a reference suite of strings and prints the results. */
+int
+main(void)
+{
+ printf("SKEIN%d test suite:\n", SKEIN);
+
+ SKEINString("");
+ SKEINString("abc");
+ SKEINString("message digest");
+ SKEINString("abcdefghijklmnopqrstuvwxyz");
+ SKEINString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz0123456789");
+ SKEINString("1234567890123456789012345678901234567890"
+ "1234567890123456789012345678901234567890");
+
+ return 0;
+}
diff --git a/lib/libmemstat/Makefile b/lib/libmemstat/Makefile
index e60b322e2228..4deeaf3a9520 100644
--- a/lib/libmemstat/Makefile
+++ b/lib/libmemstat/Makefile
@@ -1,4 +1,3 @@
-
WARNS?= 3
LIB= memstat
SHLIB_MAJOR= 3
diff --git a/lib/libmemstat/memstat_malloc.c b/lib/libmemstat/memstat_malloc.c
index 9bc281e1c2b3..81d51b81c5bd 100644
--- a/lib/libmemstat/memstat_malloc.c
+++ b/lib/libmemstat/memstat_malloc.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
diff --git a/lib/libmilter/Makefile b/lib/libmilter/Makefile
index 0b0896fad43d..dd6a481d1a15 100644
--- a/lib/libmilter/Makefile
+++ b/lib/libmilter/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE=sendmail
diff --git a/lib/libmixer/Makefile b/lib/libmixer/Makefile
index 6ca17a9d020d..a0bb37a85fb8 100644
--- a/lib/libmixer/Makefile
+++ b/lib/libmixer/Makefile
@@ -1,4 +1,3 @@
-
LIB= mixer
SRCS= ${LIB}.c
INCS= ${LIB}.h
@@ -22,6 +21,7 @@ MLINKS+= mixer.3 mixer_get_dunit.3
MLINKS+= mixer.3 mixer_set_dunit.3
MLINKS+= mixer.3 mixer_get_mode.3
MLINKS+= mixer.3 mixer_get_nmixers.3
+MLINKS+= mixer.3 mixer_get_path.3
MLINKS+= mixer.3 MIX_ISDEV.3
MLINKS+= mixer.3 MIX_ISMUTE.3
MLINKS+= mixer.3 MIX_ISREC.3
diff --git a/lib/libmixer/Makefile.depend b/lib/libmixer/Makefile.depend
index e69de29bb2d1..40575a605e97 100644
--- a/lib/libmixer/Makefile.depend
+++ b/lib/libmixer/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ usr.bin/awk.host \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libmixer/Symbol.map b/lib/libmixer/Symbol.map
index f16e13d66e4c..2ce39fd058ab 100644
--- a/lib/libmixer/Symbol.map
+++ b/lib/libmixer/Symbol.map
@@ -19,3 +19,7 @@ FBSD_1.7 {
mixer_get_mode;
mixer_get_nmixers;
};
+
+FBSD_1.8 {
+ mixer_get_path;
+};
diff --git a/lib/libmixer/mixer.3 b/lib/libmixer/mixer.3
index af2a8ff135a8..04aa3bd1dca7 100644
--- a/lib/libmixer/mixer.3
+++ b/lib/libmixer/mixer.3
@@ -19,8 +19,7 @@
.\" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
.\" THE SOFTWARE.
.\"
-
-.Dd January 19, 2023
+.Dd August 4, 2024
.Dt MIXER 3
.Os
.Sh NAME
@@ -40,6 +39,7 @@
.Nm mixer_set_dunit ,
.Nm mixer_get_mode ,
.Nm mixer_get_nmixers ,
+.Nm mixer_get_path ,
.Nm MIX_ISDEV ,
.Nm MIX_ISMUTE ,
.Nm MIX_ISREC ,
@@ -86,6 +86,8 @@ Mixer library (libmixer, -lmixer)
.Ft int
.Fn mixer_get_nmixers "void"
.Ft int
+.Fn mixer_get_path "char * buf" "size_t size" "int unit"
+.Ft int
.Fn MIX_ISDEV "struct mixer *m" "int devno"
.Ft int
.Fn MIX_ISMUTE "struct mixer *m" "int devno"
@@ -165,13 +167,15 @@ is always equal to the number of that pcmX device.
For example, if the audio device's number is 0 (i.e pcm0), then
.Ar unit
is 0 as well.
-This number is useful when checking if the mixer's audio card is the default one.
+This number is useful when checking if the mixer's audio card is the default
+one.
.It Fa ndev
Number of devices in
.Ar devs .
.It Fa devmask
Bit mask containing all supported devices for the mixer.
-For example, if device 10 is supported, then the 10th bit in the mask will be set.
+For example, if device 10 is supported, then the 10th bit in the mask will be
+set.
By default,
.Fn mixer_open
stores only the supported devices in devs, so it is very unlikely this mask will
@@ -315,23 +319,27 @@ opens the default mixer (hw.snd.default_unit).
The
.Fn mixer_close
function frees resources and closes the mixer device.
-It is a good practice to always call it when the application is done using the mixer.
+It is a good practice to always call it when the application is done using the
+mixer.
.Ss Manipulating the mixer
The
.Fn mixer_get_dev
and
.Fn mixer_get_dev_byname
-functions select a mixer device, either by its number or by its name respectively.
-The mixer structure keeps a list of all the devices, but only \
-one can be manipulated at a time.
-Each time a new device is to be manipulated, one of the two functions has to be called.
+functions select a mixer device, either by its number or by its name
+respectively.
+The mixer structure keeps a list of all the devices, but only one can be
+manipulated at a time.
+Each time a new device is to be manipulated, one of the two functions has to be
+called.
.Pp
The
.Fn mixer_set_vol
function changes the volume of the selected mixer device.
The
.Ar vol
-parameter is a structure that stores the left and right volumes of a given device.
+parameter is a structure that stores the left and right volumes of a given
+device.
The allowed volume values are between MIX_VOLMIN (0.0) and MIX_VOLMAX (1.0).
.Pp
The
@@ -352,7 +360,8 @@ Toggle the device's mute (e.g mute if unmuted and unmute if muted).
The
.Fn mixer_mod_recsrc
function modifies a recording device.
-The selected device has to be a recording device, otherwise the function will fail.
+The selected device has to be a recording device, otherwise the function will
+fail.
The
.Ar opt
parameter has to be one of the following options:
@@ -379,23 +388,37 @@ controls.
.Pp
The
.Fn mixer_get_mode
-function returns the playback/recording mode of the audio device the mixer \
-belongs to.
-The available values are the following:
-.Bl -tag -width "MIX_STATUS_PLAY | MIX_STATUS_REC" -offset indent
-.It Dv MIX_STATUS_NONE
-Neither playback nor recording.
-.It Dv MIX_STATUS_PLAY
-Playback.
-.It Dv MIX_STATUS_REC
-Recording.
-.It Dv MIX_STATUS_PLAY | MIX_STATUS_REC
-Playback and recording.
+function returns the operating mode of the audio device the mixer belongs to.
+The following values can be OR'ed in case more than one mode is supported:
+.Bl -tag -width "MIX_MODE_MIXER" -offset indent
+.It Dv MIX_MODE_MIXER
+The audio device has a mixer.
+.It Dv MIX_MODE_PLAY
+The audio device supports playback.
+.It Dv MIX_MODE_REC
+The audio device supports recording.
.El
.Pp
The
.Fn mixer_get_nmixers
-function returns the total number of mixer devices in the system.
+function returns the maximum mixer unit number.
+Although this might sound as incorrect behavior, given that one would expect
+"nmixers" to refer to the total number of active mixers, it is more intuitive
+for applications that want to loop through all mixer devices (see the
+.Sx EXAMPLES
+section).
+.Pp
+The
+.Fn mixer_get_path
+function writes the path of the mixer device specified in the
+.Ar unit
+argument to the buffer specified in
+.Ar buf .
+.Ar unit
+can be either -1, in which case
+.Fn mixer_get_path
+will fetch the path of the default mixer, or between 0 and the maximum mixer
+unit.
.Pp
The
.Fn MIX_ISDEV
@@ -467,9 +490,10 @@ The
.Fn mixer_set_mute ,
.Fn mixer_mod_recsrc ,
.Fn mixer_get_dunut ,
-.Fn mixer_set_dunit
+.Fn mixer_set_dunit ,
+.Fn mixer_get_nmixers ,
and
-.Fn mixer_get_nmixers
+.Fn mixer_get_path
functions return 0 or positive values on success and -1 on failure.
.Pp
The
@@ -539,6 +563,22 @@ TAILQ_FOREACH(dp, &m->devs, devs) {
(void)mixer_close(m);
.Ed
+.Ss Loop through all mixer devices in the system
+.Bd -literal
+struct mixer *m;
+char buf[NAME_MAX];
+int n;
+
+if ((n = mixer_get_nmixers()) < 0)
+ errx(1, "no mixers present in the system");
+for (i = 0; i < n; i++) {
+ (void)mixer_get_path(buf, sizeof(buf), i);
+ if ((m = mixer_open(buf)) == NULL)
+ continue;
+ ...
+ (void)mixer_close(m);
+}
+.Ed
.Sh SEE ALSO
.Xr queue 3 ,
.Xr sysctl 3 ,
diff --git a/lib/libmixer/mixer.c b/lib/libmixer/mixer.c
index d78ca6e0fc87..2be3a48eb755 100644
--- a/lib/libmixer/mixer.c
+++ b/lib/libmixer/mixer.c
@@ -87,7 +87,7 @@ mixer_open(const char *name)
dunit:
if ((m->unit = mixer_get_dunit()) < 0)
goto fail;
- (void)snprintf(m->name, sizeof(m->name), "/dev/mixer%d", m->unit);
+ (void)snprintf(m->name, sizeof(m->name), BASEPATH "%d", m->unit);
}
if ((m->fd = open(m->name, O_RDWR)) < 0)
@@ -113,14 +113,14 @@ dunit:
TAILQ_INIT(&m->devs);
for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
- if (!MIX_ISDEV(m, i))
+ if (!MIX_ISDEV(m, i) && !MIX_ISREC(m, i))
continue;
if ((dp = calloc(1, sizeof(struct mix_dev))) == NULL)
goto fail;
dp->parent_mixer = m;
dp->devno = i;
dp->nctl = 0;
- if (_mixer_readvol(dp) < 0)
+ if (MIX_ISDEV(m, i) && _mixer_readvol(dp) < 0)
goto fail;
(void)strlcpy(dp->name, names[i], sizeof(dp->name));
TAILQ_INIT(&dp->ctls);
@@ -493,3 +493,28 @@ mixer_get_nmixers(void)
return (si.nummixers);
}
+
+/*
+ * Get the full path to a mixer device.
+ */
+int
+mixer_get_path(char *buf, size_t size, int unit)
+{
+ size_t n;
+
+ if (!(unit == -1 || (unit >= 0 && unit < mixer_get_nmixers()))) {
+ errno = EINVAL;
+ return (-1);
+ }
+ if (unit == -1)
+ n = strlcpy(buf, BASEPATH, size);
+ else
+ n = snprintf(buf, size, BASEPATH "%d", unit);
+
+ if (n >= size) {
+ errno = ENOMEM;
+ return (-1);
+ }
+
+ return (0);
+}
diff --git a/lib/libmixer/mixer.h b/lib/libmixer/mixer.h
index cb9575c5f012..80a4b5c91a82 100644
--- a/lib/libmixer/mixer.h
+++ b/lib/libmixer/mixer.h
@@ -115,6 +115,7 @@ int mixer_get_dunit(void);
int mixer_set_dunit(struct mixer *, int);
int mixer_get_mode(int);
int mixer_get_nmixers(void);
+int mixer_get_path(char *, size_t, int);
__END_DECLS
diff --git a/lib/libmp/Makefile b/lib/libmp/Makefile
index 532d4bd64bbe..3ef85cee79c0 100644
--- a/lib/libmp/Makefile
+++ b/lib/libmp/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
LIB= mp
diff --git a/lib/libmp/tests/Makefile b/lib/libmp/tests/Makefile
index bb7ad32f42e6..4d66ca659376 100644
--- a/lib/libmp/tests/Makefile
+++ b/lib/libmp/tests/Makefile
@@ -1,4 +1,3 @@
-
TAP_TESTS_C+= legacy_test
WARNS?= 3
diff --git a/lib/libmt/Makefile b/lib/libmt/Makefile
index 92c5469a2c85..44382a923408 100644
--- a/lib/libmt/Makefile
+++ b/lib/libmt/Makefile
@@ -1,4 +1,3 @@
-
LIB= mt
SHLIBDIR?= /lib
SRCS= mtlib.c
diff --git a/lib/libmt/mtlib.c b/lib/libmt/mtlib.c
index edcf747bd808..6175f6b8888a 100644
--- a/lib/libmt/mtlib.c
+++ b/lib/libmt/mtlib.c
@@ -30,7 +30,6 @@
* Authors: Ken Merry (Spectra Logic Corporation)
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
@@ -642,6 +641,7 @@ static struct densities {
{ 0x56, 20670, 525018, "3592B5 (unencrypted)" },
{ 0x57, 21850, 554990, "3592A6 (unencrypted)" },
{ 0x58, 15142, 384607, "LTO-5" },
+ { 0x59, 21850, 554990, "3592A7 (unencrypted)" },
{ 0x5A, 15142, 384607, "LTO-6" },
{ 0x5C, 19107, 485318, "LTO-7" },
{ 0x5D, 19107, 485318, "LTO-M8" },
@@ -654,6 +654,7 @@ static struct densities {
{ 0x75, 20670, 525018, "3592A5 (encrypted)" },
{ 0x76, 20670, 525018, "3592B5 (encrypted)" },
{ 0x77, 21850, 554990, "3592A6 (encrypted)" },
+ { 0x79, 21850, 554990, "3592A7 (encrypted)" },
{ 0x8c, 1789, 45434, "EXB-8500c" },
{ 0x90, 1703, 43245, "EXB-8200c" },
{ 0, 0, 0, NULL }
diff --git a/lib/libnetbsd/Makefile b/lib/libnetbsd/Makefile
index c89b74b12283..1639caf20d6b 100644
--- a/lib/libnetbsd/Makefile
+++ b/lib/libnetbsd/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
PACKAGE=lib${LIB}
diff --git a/lib/libnetbsd/netinet/in.h b/lib/libnetbsd/netinet/in.h
index d77238a005c2..0167707f9f67 100644
--- a/lib/libnetbsd/netinet/in.h
+++ b/lib/libnetbsd/netinet/in.h
@@ -26,8 +26,6 @@
* 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.
- *
- * @(#)in.h 8.3 (Berkeley) 1/3/94
*/
#ifndef _LIBNETBSD_NETINET_IN_H_
diff --git a/lib/libnetbsd/sockaddr_snprintf.c b/lib/libnetbsd/sockaddr_snprintf.c
index 4f70e6a8df2c..3100852d1be1 100644
--- a/lib/libnetbsd/sockaddr_snprintf.c
+++ b/lib/libnetbsd/sockaddr_snprintf.c
@@ -32,7 +32,6 @@
#include "config.h"
#endif
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/lib/libnetbsd/strsuftoll.c b/lib/libnetbsd/strsuftoll.c
index 8acd4216d3b6..df324f096271 100644
--- a/lib/libnetbsd/strsuftoll.c
+++ b/lib/libnetbsd/strsuftoll.c
@@ -62,7 +62,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/time.h>
diff --git a/lib/libnetbsd/util.c b/lib/libnetbsd/util.c
index dcbb0ef389b4..dee9d61dd832 100644
--- a/lib/libnetbsd/util.c
+++ b/lib/libnetbsd/util.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdlib.h>
diff --git a/lib/libnetgraph/debug.c b/lib/libnetgraph/debug.c
index cf8600bea8e5..33e793bdb38e 100644
--- a/lib/libnetgraph/debug.c
+++ b/lib/libnetgraph/debug.c
@@ -38,7 +38,6 @@
* $Whistle: debug.c,v 1.24 1999/01/24 01:15:33 archie Exp $
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
diff --git a/lib/libnetgraph/msg.c b/lib/libnetgraph/msg.c
index fb62b84ed4ef..b87003ae5e4c 100644
--- a/lib/libnetgraph/msg.c
+++ b/lib/libnetgraph/msg.c
@@ -38,7 +38,6 @@
* $Whistle: msg.c,v 1.9 1999/01/20 00:57:23 archie Exp $
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdarg.h>
diff --git a/lib/libnetgraph/sock.c b/lib/libnetgraph/sock.c
index 94bcd730b963..825ddd0297ed 100644
--- a/lib/libnetgraph/sock.c
+++ b/lib/libnetgraph/sock.c
@@ -38,7 +38,6 @@
* $Whistle: sock.c,v 1.12 1999/01/20 00:57:23 archie Exp $
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdarg.h>
diff --git a/lib/libnetmap/Makefile.depend b/lib/libnetmap/Makefile.depend
new file mode 100644
index 000000000000..6ef78fac5cbf
--- /dev/null
+++ b/lib/libnetmap/Makefile.depend
@@ -0,0 +1,15 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libnetmap/nmreq.c b/lib/libnetmap/nmreq.c
index 645f01abc130..2477337d8791 100644
--- a/lib/libnetmap/nmreq.c
+++ b/lib/libnetmap/nmreq.c
@@ -156,11 +156,6 @@ nmreq_header_decode(const char **pifname, struct nmreq_header *h, struct nmctx *
for (pipesep = vpname; pipesep != scan && !index("{}", *pipesep); pipesep++)
;
- if (!nm_is_identifier(vpname, pipesep)) {
- nmctx_ferror(ctx, "%s: invalid port name '%.*s'", *pifname,
- pipesep - vpname, vpname);
- goto fail;
- }
if (pipesep != scan) {
pipesep++;
if (*pipesep == '\0') {
diff --git a/lib/libnv/Makefile b/lib/libnv/Makefile
index c9bf45e02050..f4225df297d6 100644
--- a/lib/libnv/Makefile
+++ b/lib/libnv/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libnv/common_impl.h b/lib/libnv/common_impl.h
index 03de9749aaf6..27af1710540a 100644
--- a/lib/libnv/common_impl.h
+++ b/lib/libnv/common_impl.h
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libnv/msgio.c b/lib/libnv/msgio.c
index 002c626647d9..f6f75241ff06 100644
--- a/lib/libnv/msgio.c
+++ b/lib/libnv/msgio.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/select.h>
diff --git a/lib/libnv/tests/Makefile b/lib/libnv/tests/Makefile
index fc377e38ce83..aea416539c4a 100644
--- a/lib/libnv/tests/Makefile
+++ b/lib/libnv/tests/Makefile
@@ -1,7 +1,16 @@
+.include <src.opts.mk>
ATF_TESTS_C= \
nvlist_send_recv_test
+.PATH: ${SRCTOP}/lib/libnv
+SRCS.nvlist_send_recv_test= msgio.c nvlist_send_recv_test.c
+CFLAGS.nvlist_send_recv_test+=-I${SRCTOP}/sys/contrib/libnv
+CFLAGS.nvlist_send_recv_test+=-I${SRCTOP}/lib/libnv
+.if ${MK_ASAN} != "yes"
+CFLAGS.nvlist_send_recv_test+=-DNO_ASAN
+.endif
+
ATF_TESTS_CXX= \
cnv_tests \
dnv_tests \
diff --git a/lib/libnv/tests/dnv_tests.cc b/lib/libnv/tests/dnv_tests.cc
index b66315713bca..cf478f1bd2a2 100644
--- a/lib/libnv/tests/dnv_tests.cc
+++ b/lib/libnv/tests/dnv_tests.cc
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/dnv.h>
#include <sys/nv.h>
diff --git a/lib/libnv/tests/nv_array_tests.cc b/lib/libnv/tests/nv_array_tests.cc
index f5c448598b22..9acbaef67eba 100644
--- a/lib/libnv/tests/nv_array_tests.cc
+++ b/lib/libnv/tests/nv_array_tests.cc
@@ -1,6 +1,5 @@
/*-
- * Copyright (c) 2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
- * All rights reserved.
+ * Copyright (c) 2015-2024 Mariusz Zaborski <oshogbo@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,10 +23,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/nv.h>
+#include <sys/mman.h>
#include <sys/socket.h>
#include <atf-c++.hpp>
@@ -1162,6 +1161,58 @@ ATF_TEST_CASE_BODY(nvlist_nvlist_array__pack)
free(packed);
}
+
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_string_array_nonull__pack);
+ATF_TEST_CASE_BODY(nvlist_string_array_nonull__pack)
+{
+ nvlist_t *testnvl, *unpacked;
+ const char *somestr[3] = { "a", "b", "XXX" };
+ uint8_t *packed, *twopages, *dataptr, *secondpage;
+ size_t packed_size, page_size;
+ bool found;
+
+ page_size = sysconf(_SC_PAGESIZE);
+ testnvl = nvlist_create(0);
+ ATF_REQUIRE(testnvl != NULL);
+ ATF_REQUIRE_EQ(nvlist_error(testnvl), 0);
+ nvlist_add_string_array(testnvl, "nvl/string", somestr,
+ nitems(somestr));
+ ATF_REQUIRE_EQ(nvlist_error(testnvl), 0);
+
+ packed = (uint8_t *)nvlist_pack(testnvl, &packed_size);
+ ATF_REQUIRE(packed != NULL);
+
+ twopages = (uint8_t *)mmap(NULL, page_size * 2, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ ATF_REQUIRE(twopages != MAP_FAILED);
+ dataptr = &twopages[page_size - packed_size];
+ secondpage = &twopages[page_size];
+
+ memset(twopages, 'A', page_size * 2);
+
+ mprotect(secondpage, page_size, PROT_NONE);
+ memcpy(dataptr, packed, packed_size);
+
+ found = false;
+ for (size_t i = 0; i < packed_size - 3; i++) {
+ if (dataptr[i] == 'X' && dataptr[i + 1] == 'X' &&
+ dataptr[i + 2] == 'X' && dataptr[i + 3] == '\0') {
+ dataptr[i + 3] = 'X';
+ found = true;
+ break;
+ }
+ }
+ ATF_REQUIRE(found == true);
+
+ unpacked = nvlist_unpack(dataptr, packed_size, 0);
+ ATF_REQUIRE(unpacked == NULL);
+
+ nvlist_destroy(testnvl);
+ free(packed);
+ munmap(twopages, page_size * 2);
+}
+
+
ATF_INIT_TEST_CASES(tp)
{
@@ -1191,5 +1242,7 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_descriptor_array__pack)
ATF_ADD_TEST_CASE(tp, nvlist_string_array__pack)
ATF_ADD_TEST_CASE(tp, nvlist_nvlist_array__pack)
+
+ ATF_ADD_TEST_CASE(tp, nvlist_string_array_nonull__pack)
}
diff --git a/lib/libnv/tests/nvlist_add_test.c b/lib/libnv/tests/nvlist_add_test.c
index 4478efadf4e0..28f2b6f45446 100644
--- a/lib/libnv/tests/nvlist_add_test.c
+++ b/lib/libnv/tests/nvlist_add_test.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libnv/tests/nvlist_exists_test.c b/lib/libnv/tests/nvlist_exists_test.c
index 7450256ab760..808692feb85b 100644
--- a/lib/libnv/tests/nvlist_exists_test.c
+++ b/lib/libnv/tests/nvlist_exists_test.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libnv/tests/nvlist_free_test.c b/lib/libnv/tests/nvlist_free_test.c
index c715aef6657b..bb5eeaf7d04c 100644
--- a/lib/libnv/tests/nvlist_free_test.c
+++ b/lib/libnv/tests/nvlist_free_test.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libnv/tests/nvlist_get_test.c b/lib/libnv/tests/nvlist_get_test.c
index d6e4a9b4d65a..f06be569c90d 100644
--- a/lib/libnv/tests/nvlist_get_test.c
+++ b/lib/libnv/tests/nvlist_get_test.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libnv/tests/nvlist_move_test.c b/lib/libnv/tests/nvlist_move_test.c
index 3c99f4582c5e..2ef7ca4de384 100644
--- a/lib/libnv/tests/nvlist_move_test.c
+++ b/lib/libnv/tests/nvlist_move_test.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
diff --git a/lib/libnv/tests/nvlist_send_recv_test.c b/lib/libnv/tests/nvlist_send_recv_test.c
index 25edaa5c3c10..79297dfe2043 100644
--- a/lib/libnv/tests/nvlist_send_recv_test.c
+++ b/lib/libnv/tests/nvlist_send_recv_test.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2013 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Pawel Jakub Dawidek under sponsorship from
* the FreeBSD Foundation.
@@ -27,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
@@ -45,6 +43,9 @@
#include <atf-c.h>
+#include <nv_impl.h>
+#include <msgio.h>
+
#define ALPHABET "abcdefghijklmnopqrstuvwxyz"
#define fd_is_valid(fd) (fcntl((fd), F_GETFL) != -1 || errno != EBADF)
@@ -544,6 +545,192 @@ ATF_TC_BODY(nvlist_send_recv__send_closed_fd__stream, tc)
nvlist_send_recv__send_closed_fd(SOCK_STREAM);
}
+ATF_TC_WITHOUT_HEAD(nvlist_send_recv__overflow_header_size);
+ATF_TC_BODY(nvlist_send_recv__overflow_header_size, tc)
+{
+ nvlist_t *nvl;
+ void *packed;
+ size_t packed_size;
+ struct nvlist_header *header;
+ int fd, socks[2], status;
+ pid_t pid;
+
+#ifdef NO_ASAN
+ atf_tc_skip("This test requires ASAN");
+#endif
+
+ ATF_REQUIRE_EQ(socketpair(PF_UNIX, SOCK_STREAM, 0, socks), 0);
+
+ pid = fork();
+ ATF_REQUIRE(pid >= 0);
+
+ if (pid == 0) {
+ /* Child. */
+ fd = socks[0];
+ close(socks[1]);
+
+ nvl = nvlist_create(0);
+ ATF_REQUIRE(nvl != NULL);
+ ATF_REQUIRE(nvlist_empty(nvl));
+
+ packed = nvlist_pack(nvl, &packed_size);
+ ATF_REQUIRE(packed != NULL);
+ ATF_REQUIRE(packed_size >= sizeof(struct nvlist_header));
+
+ header = (struct nvlist_header *)packed;
+ header->nvlh_size = SIZE_MAX - sizeof(struct nvlist_header) + 2;
+
+ ATF_REQUIRE_EQ(write(fd, packed, packed_size),
+ (ssize_t)sizeof(struct nvlist_header));
+
+ nvlist_destroy(nvl);
+ free(packed);
+
+ exit(0);
+ } else {
+ /* Parent */
+ fd = socks[1];
+ close(socks[0]);
+
+ errno = 0;
+ nvl = nvlist_recv(fd, 0);
+ ATF_REQUIRE(nvl == NULL);
+
+ /*
+ * Make sure it has failed on EINVAL, and not on
+ * errors returned by malloc or recv.
+ */
+ ATF_REQUIRE(errno == EINVAL);
+
+ ATF_REQUIRE(waitpid(pid, &status, 0) == pid);
+ ATF_REQUIRE(status == 0);
+ close(fd);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(nvlist_send_recv__invalid_fd_size);
+ATF_TC_BODY(nvlist_send_recv__invalid_fd_size, tc)
+{
+ nvlist_t *nvl;
+ void *packed;
+ size_t packed_size;
+ struct nvlist_header *header;
+ int fd, socks[2], status;
+ pid_t pid;
+
+ ATF_REQUIRE_EQ(socketpair(PF_UNIX, SOCK_STREAM, 0, socks), 0);
+
+ pid = fork();
+ ATF_REQUIRE(pid >= 0);
+
+ if (pid == 0) {
+ /* Child. */
+ fd = socks[0];
+ close(socks[1]);
+
+ nvl = nvlist_create(0);
+ ATF_REQUIRE(nvl != NULL);
+ ATF_REQUIRE(nvlist_empty(nvl));
+
+ nvlist_add_string(nvl, "nvl/string", "test");
+ ATF_REQUIRE_EQ(nvlist_error(nvl), 0);
+
+ packed = nvlist_pack(nvl, &packed_size);
+ ATF_REQUIRE(packed != NULL);
+ ATF_REQUIRE(packed_size >= sizeof(struct nvlist_header));
+
+ header = (struct nvlist_header *)packed;
+ header->nvlh_descriptors = 0x20;
+
+ ATF_REQUIRE_EQ(write(fd, packed, packed_size),
+ (ssize_t)packed_size);
+
+ nvlist_destroy(nvl);
+ free(packed);
+
+ exit(0);
+ } else {
+ /* Parent */
+ fd = socks[1];
+ close(socks[0]);
+
+ nvl = nvlist_recv(fd, 0);
+ ATF_REQUIRE(nvl == NULL);
+
+ ATF_REQUIRE(waitpid(pid, &status, 0) == pid);
+ ATF_REQUIRE(status == 0);
+ }
+
+ close(fd);
+}
+
+ATF_TC_WITHOUT_HEAD(nvlist_send_recv__overflow_fd_size);
+ATF_TC_BODY(nvlist_send_recv__overflow_fd_size, tc)
+{
+ nvlist_t *nvl;
+ void *packed;
+ size_t packed_size;
+ struct nvlist_header *header;
+ int fd, socks[2], fds[1], status;
+ pid_t pid;
+
+ ATF_REQUIRE_EQ(socketpair(PF_UNIX, SOCK_STREAM, 0, socks), 0);
+
+ pid = fork();
+ ATF_REQUIRE(pid >= 0);
+
+ if (pid == 0) {
+ /* Child. */
+ fd = socks[0];
+ close(socks[1]);
+
+ nvl = nvlist_create(0);
+ ATF_REQUIRE(nvl != NULL);
+ ATF_REQUIRE(nvlist_empty(nvl));
+
+ nvlist_add_string(nvl, "nvl/string", "test");
+ ATF_REQUIRE_EQ(nvlist_error(nvl), 0);
+
+ packed = nvlist_pack(nvl, &packed_size);
+ ATF_REQUIRE(packed != NULL);
+ ATF_REQUIRE(packed_size >= sizeof(struct nvlist_header));
+
+ header = (struct nvlist_header *)packed;
+ header->nvlh_descriptors = 0x4000000000000002;
+
+ ATF_REQUIRE_EQ(write(fd, packed, packed_size),
+ (ssize_t)packed_size);
+
+ fds[0] = dup(STDERR_FILENO);
+ ATF_REQUIRE(fds[0] >= 0);
+ ATF_REQUIRE_EQ(fd_send(fd, fds, 1), 0);
+
+ nvlist_destroy(nvl);
+ free(packed);
+
+ close(fds[0]);
+ close(fd);
+
+ exit(0);
+ } else {
+ /* Parent */
+ fd = socks[1];
+ close(socks[0]);
+
+ nvl = nvlist_recv(fd, 0);
+ ATF_REQUIRE(nvl == NULL);
+
+ /* Make sure that fd was not parsed by nvlist */
+ ATF_REQUIRE(fd_recv(fd, fds, 1) == 0);
+
+ ATF_REQUIRE(waitpid(pid, &status, 0) == pid);
+ ATF_REQUIRE(status == 0);
+
+ close(fds[0]);
+ close(fd);
+ }
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -554,5 +741,9 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, nvlist_send_recv__send_many_fds__dgram);
ATF_TP_ADD_TC(tp, nvlist_send_recv__send_many_fds__stream);
+ ATF_TP_ADD_TC(tp, nvlist_send_recv__overflow_header_size);
+ ATF_TP_ADD_TC(tp, nvlist_send_recv__invalid_fd_size);
+ ATF_TP_ADD_TC(tp, nvlist_send_recv__overflow_fd_size);
+
return (atf_no_error());
}
diff --git a/lib/libnvmf/Makefile b/lib/libnvmf/Makefile
new file mode 100644
index 000000000000..b01f5ab82cac
--- /dev/null
+++ b/lib/libnvmf/Makefile
@@ -0,0 +1,24 @@
+.PATH: ${SRCTOP}/sys/dev/nvmf/controller
+.PATH: ${SRCTOP}/sys/libkern
+
+LIB= nvmf
+INTERNALLIB=
+PACKAGE= nvmf
+
+INCS= libnvmf.h
+
+SRCS= gsb_crc32.c \
+ nvmf_controller.c \
+ nvmf_host.c \
+ nvmf_tcp.c \
+ nvmf_transport.c \
+ nvmft_subr.c
+
+LIBADD= nv
+
+CFLAGS+= -I${SRCTOP}/sys/dev/nvmf/controller
+CFLAGS+= -I${SRCTOP}/sys/dev/nvmf
+
+.include <bsd.lib.mk>
+
+CWARNFLAGS.gsb_crc32.c= -Wno-cast-align
diff --git a/lib/libnvmf/Makefile.depend b/lib/libnvmf/Makefile.depend
new file mode 100644
index 000000000000..15a1f9c07f7c
--- /dev/null
+++ b/lib/libnvmf/Makefile.depend
@@ -0,0 +1,12 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libnvmf/internal.h b/lib/libnvmf/internal.h
new file mode 100644
index 000000000000..300776c1213b
--- /dev/null
+++ b/lib/libnvmf/internal.h
@@ -0,0 +1,120 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022-2024 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#ifndef __LIBNVMF_INTERNAL_H__
+#define __LIBNVMF_INTERNAL_H__
+
+#include <sys/nv.h>
+#include <sys/queue.h>
+
+struct nvmf_transport_ops {
+ /* Association management. */
+ struct nvmf_association *(*allocate_association)(bool controller,
+ const struct nvmf_association_params *params);
+ void (*update_association)(struct nvmf_association *na,
+ const struct nvme_controller_data *cdata);
+ void (*free_association)(struct nvmf_association *na);
+
+ /* Queue pair management. */
+ struct nvmf_qpair *(*allocate_qpair)(struct nvmf_association *na,
+ const struct nvmf_qpair_params *params);
+ void (*free_qpair)(struct nvmf_qpair *qp);
+
+ /* Add params for kernel handoff. */
+ void (*kernel_handoff_params)(struct nvmf_qpair *qp, nvlist_t *nvl);
+ int (*populate_dle)(struct nvmf_qpair *qp,
+ struct nvme_discovery_log_entry *dle);
+
+ /* Capsule operations. */
+ struct nvmf_capsule *(*allocate_capsule)(struct nvmf_qpair *qp);
+ void (*free_capsule)(struct nvmf_capsule *nc);
+ int (*transmit_capsule)(struct nvmf_capsule *nc);
+ int (*receive_capsule)(struct nvmf_qpair *qp,
+ struct nvmf_capsule **ncp);
+ uint8_t (*validate_command_capsule)(const struct nvmf_capsule *nc);
+
+ /* Transferring controller data. */
+ size_t (*capsule_data_len)(const struct nvmf_capsule *nc);
+ int (*receive_controller_data)(const struct nvmf_capsule *nc,
+ uint32_t data_offset, void *buf, size_t len);
+ int (*send_controller_data)(const struct nvmf_capsule *nc,
+ const void *buf, size_t len);
+};
+
+struct nvmf_association {
+ struct nvmf_transport_ops *na_ops;
+ enum nvmf_trtype na_trtype;
+ bool na_controller;
+
+ struct nvmf_association_params na_params;
+
+ /* Each qpair holds a reference on an association. */
+ u_int na_refs;
+
+ char *na_last_error;
+};
+
+struct nvmf_qpair {
+ struct nvmf_association *nq_association;
+ bool nq_admin;
+
+ uint16_t nq_cid; /* host only */
+
+ /*
+ * Queue sizes. This assumes the same size for both the
+ * completion and submission queues within a pair.
+ */
+ u_int nq_qsize;
+
+ /* Flow control management for submission queues. */
+ bool nq_flow_control;
+ uint16_t nq_sqhd;
+ uint16_t nq_sqtail; /* host only */
+
+ /* Value in response to/from CONNECT. */
+ uint16_t nq_cntlid;
+
+ uint32_t nq_kato; /* valid on admin queue only */
+
+ TAILQ_HEAD(, nvmf_capsule) nq_rx_capsules;
+};
+
+struct nvmf_capsule {
+ struct nvmf_qpair *nc_qpair;
+
+ /* Either a SQE or CQE. */
+ union {
+ struct nvme_command nc_sqe;
+ struct nvme_completion nc_cqe;
+ };
+ int nc_qe_len;
+
+ /*
+ * Is SQHD in received capsule valid? False for locally-
+ * synthesized responses.
+ */
+ bool nc_sqhd_valid;
+
+ /* Data buffer. */
+ bool nc_send_data;
+ void *nc_data;
+ size_t nc_data_len;
+
+ TAILQ_ENTRY(nvmf_capsule) nc_link;
+};
+
+extern struct nvmf_transport_ops tcp_ops;
+
+void na_clear_error(struct nvmf_association *na);
+void na_error(struct nvmf_association *na, const char *fmt, ...);
+
+int nvmf_kernel_handoff_params(struct nvmf_qpair *qp, nvlist_t **nvlp);
+int nvmf_populate_dle(struct nvmf_qpair *qp,
+ struct nvme_discovery_log_entry *dle);
+int nvmf_pack_ioc_nvlist(struct nvmf_ioc_nv *nv, nvlist_t *nvl);
+
+#endif /* !__LIBNVMF_INTERNAL_H__ */
diff --git a/lib/libnvmf/libnvmf.h b/lib/libnvmf/libnvmf.h
new file mode 100644
index 000000000000..6b38fd286596
--- /dev/null
+++ b/lib/libnvmf/libnvmf.h
@@ -0,0 +1,387 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022-2024 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#ifndef __LIBNVMF_H__
+#define __LIBNVMF_H__
+
+#include <sys/_nv.h>
+#include <sys/uio.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <dev/nvme/nvme.h>
+#include <dev/nvmf/nvmf.h>
+#include <dev/nvmf/nvmf_proto.h>
+
+struct nvmf_capsule;
+struct nvmf_association;
+struct nvmf_qpair;
+
+/*
+ * Parameters shared by all queue-pairs of an association. Note that
+ * this contains the requested values used to initiate transport
+ * negotiation.
+ */
+struct nvmf_association_params {
+ bool sq_flow_control; /* SQ flow control required. */
+ bool dynamic_controller_model; /* Controller only */
+ uint16_t max_admin_qsize; /* Controller only */
+ uint32_t max_io_qsize; /* Controller only, 0 for discovery */
+ union {
+ struct {
+ uint8_t pda; /* Tx-side PDA. */
+ bool header_digests;
+ bool data_digests;
+ uint32_t maxr2t; /* Host only */
+ uint32_t maxh2cdata; /* Controller only */
+ } tcp;
+ };
+};
+
+/* Parameters specific to a single queue pair of an association. */
+struct nvmf_qpair_params {
+ bool admin; /* Host only */
+ union {
+ struct {
+ int fd;
+ } tcp;
+ };
+};
+
+/* Transport-independent APIs. */
+
+/*
+ * A host should allocate a new association for each association with
+ * a controller. After the admin queue has been allocated and the
+ * controller's data has been fetched, it should be passed to
+ * nvmf_update_association to update internal transport-specific
+ * parameters before allocating I/O queues.
+ *
+ * A controller uses a single association to manage all incoming
+ * queues since it is not known until after parsing the CONNECT
+ * command which transport queues are admin vs I/O and which
+ * controller they are created against.
+ */
+struct nvmf_association *nvmf_allocate_association(enum nvmf_trtype trtype,
+ bool controller, const struct nvmf_association_params *params);
+void nvmf_update_assocation(struct nvmf_association *na,
+ const struct nvme_controller_data *cdata);
+void nvmf_free_association(struct nvmf_association *na);
+
+/* The most recent association-wide error message. */
+const char *nvmf_association_error(const struct nvmf_association *na);
+
+/*
+ * A queue pair represents either an Admin or I/O
+ * submission/completion queue pair.
+ *
+ * Each open qpair holds a reference on its association. Once queue
+ * pairs are allocated, callers can safely free the association to
+ * ease bookkeeping.
+ *
+ * If nvmf_allocate_qpair fails, a detailed error message can be obtained
+ * from nvmf_association_error.
+ */
+struct nvmf_qpair *nvmf_allocate_qpair(struct nvmf_association *na,
+ const struct nvmf_qpair_params *params);
+void nvmf_free_qpair(struct nvmf_qpair *qp);
+
+/*
+ * Capsules are either commands (host -> controller) or responses
+ * (controller -> host). A single data buffer segment may be
+ * associated with a command capsule. Transmitted data is not copied
+ * by this API but instead must be preserved until the capsule is
+ * transmitted and freed.
+ */
+struct nvmf_capsule *nvmf_allocate_command(struct nvmf_qpair *qp,
+ const void *sqe);
+struct nvmf_capsule *nvmf_allocate_response(struct nvmf_qpair *qp,
+ const void *cqe);
+void nvmf_free_capsule(struct nvmf_capsule *nc);
+int nvmf_capsule_append_data(struct nvmf_capsule *nc,
+ void *buf, size_t len, bool send);
+int nvmf_transmit_capsule(struct nvmf_capsule *nc);
+int nvmf_receive_capsule(struct nvmf_qpair *qp, struct nvmf_capsule **ncp);
+const void *nvmf_capsule_sqe(const struct nvmf_capsule *nc);
+const void *nvmf_capsule_cqe(const struct nvmf_capsule *nc);
+
+/* Return a string name for a transport type. */
+const char *nvmf_transport_type(uint8_t trtype);
+
+/*
+ * Validate a NVMe Qualified Name. The second version enforces
+ * stricter checks inline with the specification. The first version
+ * enforces more minimal checks.
+ */
+bool nvmf_nqn_valid(const char *nqn);
+bool nvmf_nqn_valid_strict(const char *nqn);
+
+/* Controller-specific APIs. */
+
+/*
+ * A controller calls this function to check for any
+ * transport-specific errors (invalid fields) in a received command
+ * capsule. The callback returns a generic command status value:
+ * NVME_SC_SUCCESS if no error is found.
+ */
+uint8_t nvmf_validate_command_capsule(const struct nvmf_capsule *nc);
+
+/*
+ * A controller calls this function to query the amount of data
+ * associated with a command capsule.
+ */
+size_t nvmf_capsule_data_len(const struct nvmf_capsule *cc);
+
+/*
+ * A controller calls this function to receive data associated with a
+ * command capsule (e.g. the data for a WRITE command). This can
+ * either return in-capsule data or fetch data from the host
+ * (e.g. using a R2T PDU over TCP). The received command capsule
+ * should be passed in 'nc'. The received data is stored in '*buf'.
+ */
+int nvmf_receive_controller_data(const struct nvmf_capsule *nc,
+ uint32_t data_offset, void *buf, size_t len);
+
+/*
+ * A controller calls this function to send data in response to a
+ * command along with a response capsule. If the data transfer
+ * succeeds, a success response is sent. If the data transfer fails,
+ * an appropriate error status capsule is sent. Regardless, a
+ * response capsule is always sent.
+ */
+int nvmf_send_controller_data(const struct nvmf_capsule *nc,
+ const void *buf, size_t len);
+
+/*
+ * Construct a CQE for a reply to a command capsule in 'nc' with the
+ * completion status 'status'. This is useful when additional CQE
+ * info is required beyond the completion status.
+ */
+void nvmf_init_cqe(void *cqe, const struct nvmf_capsule *nc,
+ uint16_t status);
+
+/*
+ * Construct and send a response capsule to a command capsule with
+ * the supplied CQE.
+ */
+int nvmf_send_response(const struct nvmf_capsule *nc, const void *cqe);
+
+/*
+ * Wait for a single command capsule and return it in *ncp. This can
+ * fail if an invalid capsule is received or an I/O error occurs.
+ */
+int nvmf_controller_receive_capsule(struct nvmf_qpair *qp,
+ struct nvmf_capsule **ncp);
+
+/* Send a response capsule from a controller. */
+int nvmf_controller_transmit_response(struct nvmf_capsule *nc);
+
+/* Construct and send an error response capsule. */
+int nvmf_send_error(const struct nvmf_capsule *cc, uint8_t sc_type,
+ uint8_t sc_status);
+
+/*
+ * Construct and send an error response capsule using a generic status
+ * code.
+ */
+int nvmf_send_generic_error(const struct nvmf_capsule *nc,
+ uint8_t sc_status);
+
+/* Construct and send a simple success response capsule. */
+int nvmf_send_success(const struct nvmf_capsule *nc);
+
+/*
+ * Allocate a new queue pair and wait for the CONNECT command capsule.
+ * If this fails, a detailed error message can be obtained from
+ * nvmf_association_error. On success, the command capsule is saved
+ * in '*ccp' and the connect data is saved in 'data'. The caller
+ * must send an explicit response and free the the command capsule.
+ */
+struct nvmf_qpair *nvmf_accept(struct nvmf_association *na,
+ const struct nvmf_qpair_params *params, struct nvmf_capsule **ccp,
+ struct nvmf_fabric_connect_data *data);
+
+/*
+ * Construct and send a response capsule with the Fabrics CONNECT
+ * invalid parameters error status. If data is true the offset is
+ * relative to the CONNECT data structure, otherwise the offset is
+ * relative to the SQE.
+ */
+void nvmf_connect_invalid_parameters(const struct nvmf_capsule *cc,
+ bool data, uint16_t offset);
+
+/* Construct and send a response capsule for a successful CONNECT. */
+int nvmf_finish_accept(const struct nvmf_capsule *cc, uint16_t cntlid);
+
+/* Compute the initial state of CAP for a controller. */
+uint64_t nvmf_controller_cap(struct nvmf_qpair *qp);
+
+/* Generate a serial number string from a host ID. */
+void nvmf_controller_serial(char *buf, size_t len, u_long hostid);
+
+/*
+ * Populate an Identify Controller data structure for a Discovery
+ * controller.
+ */
+void nvmf_init_discovery_controller_data(struct nvmf_qpair *qp,
+ struct nvme_controller_data *cdata);
+
+/*
+ * Populate an Identify Controller data structure for an I/O
+ * controller.
+ */
+void nvmf_init_io_controller_data(struct nvmf_qpair *qp, const char *serial,
+ const char *subnqn, int nn, uint32_t ioccsz,
+ struct nvme_controller_data *cdata);
+
+/*
+ * Validate if a new value for CC is legal given the existing values of
+ * CAP and CC.
+ */
+bool nvmf_validate_cc(struct nvmf_qpair *qp, uint64_t cap, uint32_t old_cc,
+ uint32_t new_cc);
+
+/* Return the log page id (LID) of a GET_LOG_PAGE command. */
+uint8_t nvmf_get_log_page_id(const struct nvme_command *cmd);
+
+/* Return the requested data length of a GET_LOG_PAGE command. */
+uint64_t nvmf_get_log_page_length(const struct nvme_command *cmd);
+
+/* Return the requested data offset of a GET_LOG_PAGE command. */
+uint64_t nvmf_get_log_page_offset(const struct nvme_command *cmd);
+
+/* Prepare to handoff a controller qpair. */
+int nvmf_handoff_controller_qpair(struct nvmf_qpair *qp,
+ const struct nvmf_fabric_connect_cmd *cmd,
+ const struct nvmf_fabric_connect_data *data, struct nvmf_ioc_nv *nv);
+
+/* Host-specific APIs. */
+
+/*
+ * Connect to an admin or I/O queue. If this fails, a detailed error
+ * message can be obtained from nvmf_association_error.
+ */
+struct nvmf_qpair *nvmf_connect(struct nvmf_association *na,
+ const struct nvmf_qpair_params *params, uint16_t qid, u_int queue_size,
+ const uint8_t hostid[16], uint16_t cntlid, const char *subnqn,
+ const char *hostnqn, uint32_t kato);
+
+/* Return the CNTLID for a queue returned from CONNECT. */
+uint16_t nvmf_cntlid(struct nvmf_qpair *qp);
+
+/*
+ * Send a command to the controller. This can fail with EBUSY if the
+ * submission queue is full.
+ */
+int nvmf_host_transmit_command(struct nvmf_capsule *nc);
+
+/*
+ * Wait for a response to a command. If there are no outstanding
+ * commands in the SQ, fails with EWOULDBLOCK.
+ */
+int nvmf_host_receive_response(struct nvmf_qpair *qp,
+ struct nvmf_capsule **rcp);
+
+/*
+ * Wait for a response to a specific command. The command must have been
+ * succesfully sent previously.
+ */
+int nvmf_host_wait_for_response(struct nvmf_capsule *cc,
+ struct nvmf_capsule **rcp);
+
+/* Build a KeepAlive command. */
+struct nvmf_capsule *nvmf_keepalive(struct nvmf_qpair *qp);
+
+/* Read a controller property. */
+int nvmf_read_property(struct nvmf_qpair *qp, uint32_t offset, uint8_t size,
+ uint64_t *value);
+
+/* Write a controller property. */
+int nvmf_write_property(struct nvmf_qpair *qp, uint32_t offset,
+ uint8_t size, uint64_t value);
+
+/* Construct a 16-byte HostId from kern.hostuuid. */
+int nvmf_hostid_from_hostuuid(uint8_t hostid[16]);
+
+/* Construct a NQN from kern.hostuuid. */
+int nvmf_nqn_from_hostuuid(char nqn[NVMF_NQN_MAX_LEN]);
+
+/* Fetch controller data via IDENTIFY. */
+int nvmf_host_identify_controller(struct nvmf_qpair *qp,
+ struct nvme_controller_data *data);
+
+/* Fetch namespace data via IDENTIFY. */
+int nvmf_host_identify_namespace(struct nvmf_qpair *qp, uint32_t nsid,
+ struct nvme_namespace_data *nsdata);
+
+/*
+ * Fetch discovery log page. The memory for the log page is allocated
+ * by malloc() and returned in *logp. The caller must free the
+ * memory.
+ */
+int nvmf_host_fetch_discovery_log_page(struct nvmf_qpair *qp,
+ struct nvme_discovery_log **logp);
+
+/*
+ * Construct a discovery log page entry that describes the connection
+ * used by a host association's admin queue pair.
+ */
+int nvmf_init_dle_from_admin_qp(struct nvmf_qpair *qp,
+ const struct nvme_controller_data *cdata,
+ struct nvme_discovery_log_entry *dle);
+
+/*
+ * Request a desired number of I/O queues via SET_FEATURES. The
+ * number of actual I/O queues available is returned in *actual on
+ * success.
+ */
+int nvmf_host_request_queues(struct nvmf_qpair *qp, u_int requested,
+ u_int *actual);
+
+/*
+ * Handoff active host association to the kernel. This frees the
+ * qpairs (even on error).
+ */
+int nvmf_handoff_host(const struct nvme_discovery_log_entry *dle,
+ const char *hostnqn, struct nvmf_qpair *admin_qp, u_int num_queues,
+ struct nvmf_qpair **io_queues, const struct nvme_controller_data *cdata,
+ uint32_t reconnect_delay, uint32_t controller_loss_timeout);
+
+/*
+ * Disconnect an active host association previously handed off to the
+ * kernel. *name is either the name of the device (nvmeX) for this
+ * association or the remote subsystem NQN.
+ */
+int nvmf_disconnect_host(const char *host);
+
+/*
+ * Disconnect all active host associations previously handed off to
+ * the kernel.
+ */
+int nvmf_disconnect_all(void);
+
+/*
+ * Fetch reconnect parameters from an existing kernel host to use for
+ * establishing a new association. The caller must destroy the
+ * returned nvlist.
+ */
+int nvmf_reconnect_params(int fd, nvlist_t **nvlp);
+
+/*
+ * Handoff active host association to an existing host in the kernel.
+ * This frees the qpairs (even on error).
+ */
+int nvmf_reconnect_host(int fd, const struct nvme_discovery_log_entry *dle,
+ const char *hostnqn, struct nvmf_qpair *admin_qp, u_int num_queues,
+ struct nvmf_qpair **io_queues, const struct nvme_controller_data *cdata,
+ uint32_t reconnect_delay, uint32_t controller_loss_timeout);
+
+/*
+ * Fetch connection status from an existing kernel host.
+ */
+int nvmf_connection_status(int fd, nvlist_t **nvlp);
+
+#endif /* !__LIBNVMF_H__ */
diff --git a/lib/libnvmf/nvmf_controller.c b/lib/libnvmf/nvmf_controller.c
new file mode 100644
index 000000000000..f26f11633e03
--- /dev/null
+++ b/lib/libnvmf/nvmf_controller.c
@@ -0,0 +1,529 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <sys/utsname.h>
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libnvmf.h"
+#include "internal.h"
+#include "nvmft_subr.h"
+
+bool
+nvmf_nqn_valid_strict(const char *nqn)
+{
+ size_t len;
+
+ if (!nvmf_nqn_valid(nqn))
+ return (false);
+
+ /*
+ * Stricter checks from the spec. Linux does not seem to
+ * require these.
+ */
+ len = strlen(nqn);
+
+ /*
+ * NVMF_NQN_MIN_LEN does not include '.' and require at least
+ * one character of a domain name.
+ */
+ if (len < NVMF_NQN_MIN_LEN + 2)
+ return (false);
+ if (memcmp("nqn.", nqn, strlen("nqn.")) != 0)
+ return (false);
+ nqn += strlen("nqn.");
+
+ /* Next 4 digits must be a year. */
+ for (u_int i = 0; i < 4; i++) {
+ if (!isdigit(nqn[i]))
+ return (false);
+ }
+ nqn += 4;
+
+ /* '-' between year and month. */
+ if (nqn[0] != '-')
+ return (false);
+ nqn++;
+
+ /* 2 digit month. */
+ for (u_int i = 0; i < 2; i++) {
+ if (!isdigit(nqn[i]))
+ return (false);
+ }
+ nqn += 2;
+
+ /* '.' between month and reverse domain name. */
+ if (nqn[0] != '.')
+ return (false);
+ return (true);
+}
+
+void
+nvmf_init_cqe(void *cqe, const struct nvmf_capsule *nc, uint16_t status)
+{
+ struct nvme_completion *cpl = cqe;
+ const struct nvme_command *cmd = nvmf_capsule_sqe(nc);
+
+ memset(cpl, 0, sizeof(*cpl));
+ cpl->cid = cmd->cid;
+ cpl->status = htole16(status);
+}
+
+static struct nvmf_capsule *
+nvmf_simple_response(const struct nvmf_capsule *nc, uint8_t sc_type,
+ uint8_t sc_status)
+{
+ struct nvme_completion cpl;
+ uint16_t status;
+
+ status = NVMEF(NVME_STATUS_SCT, sc_type) |
+ NVMEF(NVME_STATUS_SC, sc_status);
+ nvmf_init_cqe(&cpl, nc, status);
+ return (nvmf_allocate_response(nc->nc_qpair, &cpl));
+}
+
+int
+nvmf_controller_receive_capsule(struct nvmf_qpair *qp,
+ struct nvmf_capsule **ncp)
+{
+ struct nvmf_capsule *nc;
+ int error;
+ uint8_t sc_status;
+
+ *ncp = NULL;
+ error = nvmf_receive_capsule(qp, &nc);
+ if (error != 0)
+ return (error);
+
+ sc_status = nvmf_validate_command_capsule(nc);
+ if (sc_status != NVME_SC_SUCCESS) {
+ nvmf_send_generic_error(nc, sc_status);
+ nvmf_free_capsule(nc);
+ return (EPROTO);
+ }
+
+ *ncp = nc;
+ return (0);
+}
+
+int
+nvmf_controller_transmit_response(struct nvmf_capsule *nc)
+{
+ struct nvmf_qpair *qp = nc->nc_qpair;
+
+ /* Set SQHD. */
+ if (qp->nq_flow_control) {
+ qp->nq_sqhd = (qp->nq_sqhd + 1) % qp->nq_qsize;
+ nc->nc_cqe.sqhd = htole16(qp->nq_sqhd);
+ } else
+ nc->nc_cqe.sqhd = 0;
+
+ return (nvmf_transmit_capsule(nc));
+}
+
+int
+nvmf_send_response(const struct nvmf_capsule *cc, const void *cqe)
+{
+ struct nvmf_capsule *rc;
+ int error;
+
+ rc = nvmf_allocate_response(cc->nc_qpair, cqe);
+ if (rc == NULL)
+ return (ENOMEM);
+ error = nvmf_controller_transmit_response(rc);
+ nvmf_free_capsule(rc);
+ return (error);
+}
+
+int
+nvmf_send_error(const struct nvmf_capsule *cc, uint8_t sc_type,
+ uint8_t sc_status)
+{
+ struct nvmf_capsule *rc;
+ int error;
+
+ rc = nvmf_simple_response(cc, sc_type, sc_status);
+ error = nvmf_controller_transmit_response(rc);
+ nvmf_free_capsule(rc);
+ return (error);
+}
+
+int
+nvmf_send_generic_error(const struct nvmf_capsule *nc, uint8_t sc_status)
+{
+ return (nvmf_send_error(nc, NVME_SCT_GENERIC, sc_status));
+}
+
+int
+nvmf_send_success(const struct nvmf_capsule *nc)
+{
+ return (nvmf_send_generic_error(nc, NVME_SC_SUCCESS));
+}
+
+void
+nvmf_connect_invalid_parameters(const struct nvmf_capsule *cc, bool data,
+ uint16_t offset)
+{
+ struct nvmf_fabric_connect_rsp rsp;
+ struct nvmf_capsule *rc;
+
+ nvmf_init_cqe(&rsp, cc,
+ NVMEF(NVME_STATUS_SCT, NVME_SCT_COMMAND_SPECIFIC) |
+ NVMEF(NVME_STATUS_SC, NVMF_FABRIC_SC_INVALID_PARAM));
+ rsp.status_code_specific.invalid.ipo = htole16(offset);
+ rsp.status_code_specific.invalid.iattr = data ? 1 : 0;
+ rc = nvmf_allocate_response(cc->nc_qpair, &rsp);
+ nvmf_transmit_capsule(rc);
+ nvmf_free_capsule(rc);
+}
+
+struct nvmf_qpair *
+nvmf_accept(struct nvmf_association *na, const struct nvmf_qpair_params *params,
+ struct nvmf_capsule **ccp, struct nvmf_fabric_connect_data *data)
+{
+ static const char hostid_zero[sizeof(data->hostid)];
+ const struct nvmf_fabric_connect_cmd *cmd;
+ struct nvmf_qpair *qp;
+ struct nvmf_capsule *cc, *rc;
+ u_int qsize;
+ int error;
+ uint16_t cntlid;
+ uint8_t sc_status;
+
+ qp = NULL;
+ cc = NULL;
+ rc = NULL;
+ *ccp = NULL;
+ na_clear_error(na);
+ if (!na->na_controller) {
+ na_error(na, "Cannot accept on a host");
+ goto error;
+ }
+
+ qp = nvmf_allocate_qpair(na, params);
+ if (qp == NULL)
+ goto error;
+
+ /* Read the CONNECT capsule. */
+ error = nvmf_receive_capsule(qp, &cc);
+ if (error != 0) {
+ na_error(na, "Failed to receive CONNECT: %s", strerror(error));
+ goto error;
+ }
+
+ sc_status = nvmf_validate_command_capsule(cc);
+ if (sc_status != 0) {
+ na_error(na, "CONNECT command failed to validate: %u",
+ sc_status);
+ rc = nvmf_simple_response(cc, NVME_SCT_GENERIC, sc_status);
+ goto error;
+ }
+
+ cmd = nvmf_capsule_sqe(cc);
+ if (cmd->opcode != NVME_OPC_FABRICS_COMMANDS ||
+ cmd->fctype != NVMF_FABRIC_COMMAND_CONNECT) {
+ na_error(na, "Invalid opcode in CONNECT (%u,%u)", cmd->opcode,
+ cmd->fctype);
+ rc = nvmf_simple_response(cc, NVME_SCT_GENERIC,
+ NVME_SC_INVALID_OPCODE);
+ goto error;
+ }
+
+ if (cmd->recfmt != htole16(0)) {
+ na_error(na, "Unsupported CONNECT record format %u",
+ le16toh(cmd->recfmt));
+ rc = nvmf_simple_response(cc, NVME_SCT_COMMAND_SPECIFIC,
+ NVMF_FABRIC_SC_INCOMPATIBLE_FORMAT);
+ goto error;
+ }
+
+ qsize = le16toh(cmd->sqsize) + 1;
+ if (cmd->qid == 0) {
+ /* Admin queue limits. */
+ if (qsize < NVME_MIN_ADMIN_ENTRIES ||
+ qsize > NVME_MAX_ADMIN_ENTRIES ||
+ qsize > na->na_params.max_admin_qsize) {
+ na_error(na, "Invalid queue size %u", qsize);
+ nvmf_connect_invalid_parameters(cc, false,
+ offsetof(struct nvmf_fabric_connect_cmd, sqsize));
+ goto error;
+ }
+ qp->nq_admin = true;
+ } else {
+ /* I/O queues not allowed for discovery. */
+ if (na->na_params.max_io_qsize == 0) {
+ na_error(na, "I/O queue on discovery controller");
+ nvmf_connect_invalid_parameters(cc, false,
+ offsetof(struct nvmf_fabric_connect_cmd, qid));
+ goto error;
+ }
+
+ /* I/O queue limits. */
+ if (qsize < NVME_MIN_IO_ENTRIES ||
+ qsize > NVME_MAX_IO_ENTRIES ||
+ qsize > na->na_params.max_io_qsize) {
+ na_error(na, "Invalid queue size %u", qsize);
+ nvmf_connect_invalid_parameters(cc, false,
+ offsetof(struct nvmf_fabric_connect_cmd, sqsize));
+ goto error;
+ }
+
+ /* KATO is reserved for I/O queues. */
+ if (cmd->kato != 0) {
+ na_error(na,
+ "KeepAlive timeout specified for I/O queue");
+ nvmf_connect_invalid_parameters(cc, false,
+ offsetof(struct nvmf_fabric_connect_cmd, kato));
+ goto error;
+ }
+ qp->nq_admin = false;
+ }
+ qp->nq_qsize = qsize;
+
+ /* Fetch CONNECT data. */
+ if (nvmf_capsule_data_len(cc) != sizeof(*data)) {
+ na_error(na, "Invalid data payload length for CONNECT: %zu",
+ nvmf_capsule_data_len(cc));
+ nvmf_connect_invalid_parameters(cc, false,
+ offsetof(struct nvmf_fabric_connect_cmd, sgl1));
+ goto error;
+ }
+
+ error = nvmf_receive_controller_data(cc, 0, data, sizeof(*data));
+ if (error != 0) {
+ na_error(na, "Failed to read data for CONNECT: %s",
+ strerror(error));
+ rc = nvmf_simple_response(cc, NVME_SCT_GENERIC,
+ NVME_SC_DATA_TRANSFER_ERROR);
+ goto error;
+ }
+
+ /* The hostid must be non-zero. */
+ if (memcmp(data->hostid, hostid_zero, sizeof(hostid_zero)) == 0) {
+ na_error(na, "HostID in CONNECT data is zero");
+ nvmf_connect_invalid_parameters(cc, true,
+ offsetof(struct nvmf_fabric_connect_data, hostid));
+ goto error;
+ }
+
+ cntlid = le16toh(data->cntlid);
+ if (cmd->qid == 0) {
+ if (na->na_params.dynamic_controller_model) {
+ if (cntlid != NVMF_CNTLID_DYNAMIC) {
+ na_error(na, "Invalid controller ID %#x",
+ cntlid);
+ nvmf_connect_invalid_parameters(cc, true,
+ offsetof(struct nvmf_fabric_connect_data,
+ cntlid));
+ goto error;
+ }
+ } else {
+ if (cntlid > NVMF_CNTLID_STATIC_MAX &&
+ cntlid != NVMF_CNTLID_STATIC_ANY) {
+ na_error(na, "Invalid controller ID %#x",
+ cntlid);
+ nvmf_connect_invalid_parameters(cc, true,
+ offsetof(struct nvmf_fabric_connect_data,
+ cntlid));
+ goto error;
+ }
+ }
+ } else {
+ /* Wildcard Controller IDs are only valid on an Admin queue. */
+ if (cntlid > NVMF_CNTLID_STATIC_MAX) {
+ na_error(na, "Invalid controller ID %#x", cntlid);
+ nvmf_connect_invalid_parameters(cc, true,
+ offsetof(struct nvmf_fabric_connect_data, cntlid));
+ goto error;
+ }
+ }
+
+ /* Simple validation of each NQN. */
+ if (!nvmf_nqn_valid(data->subnqn)) {
+ na_error(na, "Invalid SubNQN %.*s", (int)sizeof(data->subnqn),
+ data->subnqn);
+ nvmf_connect_invalid_parameters(cc, true,
+ offsetof(struct nvmf_fabric_connect_data, subnqn));
+ goto error;
+ }
+ if (!nvmf_nqn_valid(data->hostnqn)) {
+ na_error(na, "Invalid HostNQN %.*s", (int)sizeof(data->hostnqn),
+ data->hostnqn);
+ nvmf_connect_invalid_parameters(cc, true,
+ offsetof(struct nvmf_fabric_connect_data, hostnqn));
+ goto error;
+ }
+
+ if (na->na_params.sq_flow_control ||
+ (cmd->cattr & NVMF_CONNECT_ATTR_DISABLE_SQ_FC) == 0)
+ qp->nq_flow_control = true;
+ else
+ qp->nq_flow_control = false;
+ qp->nq_sqhd = 0;
+ qp->nq_kato = le32toh(cmd->kato);
+ *ccp = cc;
+ return (qp);
+error:
+ if (rc != NULL) {
+ nvmf_transmit_capsule(rc);
+ nvmf_free_capsule(rc);
+ }
+ if (cc != NULL)
+ nvmf_free_capsule(cc);
+ if (qp != NULL)
+ nvmf_free_qpair(qp);
+ return (NULL);
+}
+
+int
+nvmf_finish_accept(const struct nvmf_capsule *cc, uint16_t cntlid)
+{
+ struct nvmf_fabric_connect_rsp rsp;
+ struct nvmf_qpair *qp = cc->nc_qpair;
+ struct nvmf_capsule *rc;
+ int error;
+
+ nvmf_init_cqe(&rsp, cc, 0);
+ if (qp->nq_flow_control)
+ rsp.sqhd = htole16(qp->nq_sqhd);
+ else
+ rsp.sqhd = htole16(0xffff);
+ rsp.status_code_specific.success.cntlid = htole16(cntlid);
+ rc = nvmf_allocate_response(qp, &rsp);
+ if (rc == NULL)
+ return (ENOMEM);
+ error = nvmf_transmit_capsule(rc);
+ nvmf_free_capsule(rc);
+ if (error == 0)
+ qp->nq_cntlid = cntlid;
+ return (error);
+}
+
+uint64_t
+nvmf_controller_cap(struct nvmf_qpair *qp)
+{
+ const struct nvmf_association *na = qp->nq_association;
+
+ return (_nvmf_controller_cap(na->na_params.max_io_qsize,
+ NVMF_CC_EN_TIMEOUT));
+}
+
+bool
+nvmf_validate_cc(struct nvmf_qpair *qp, uint64_t cap, uint32_t old_cc,
+ uint32_t new_cc)
+{
+ const struct nvmf_association *na = qp->nq_association;
+
+ return (_nvmf_validate_cc(na->na_params.max_io_qsize, cap, old_cc,
+ new_cc));
+}
+
+void
+nvmf_init_discovery_controller_data(struct nvmf_qpair *qp,
+ struct nvme_controller_data *cdata)
+{
+ const struct nvmf_association *na = qp->nq_association;
+ struct utsname utsname;
+ char *cp;
+
+ memset(cdata, 0, sizeof(*cdata));
+
+ /*
+ * 5.2 Figure 37 states model name and serial are reserved,
+ * but Linux includes them. Don't bother with serial, but
+ * do set model name.
+ */
+ uname(&utsname);
+ nvmf_strpad(cdata->mn, utsname.sysname, sizeof(cdata->mn));
+ nvmf_strpad(cdata->fr, utsname.release, sizeof(cdata->fr));
+ cp = memchr(cdata->fr, '-', sizeof(cdata->fr));
+ if (cp != NULL)
+ memset(cp, ' ', sizeof(cdata->fr) - (cp - (char *)cdata->fr));
+
+ cdata->ctrlr_id = htole16(qp->nq_cntlid);
+ cdata->ver = htole32(NVME_REV(1, 4));
+ cdata->cntrltype = 2;
+
+ cdata->lpa = NVMEF(NVME_CTRLR_DATA_LPA_EXT_DATA, 1);
+ cdata->elpe = 0;
+
+ cdata->maxcmd = htole16(na->na_params.max_admin_qsize);
+
+ /* Transport-specific? */
+ cdata->sgls = htole32(
+ NVMEF(NVME_CTRLR_DATA_SGLS_TRANSPORT_DATA_BLOCK, 1) |
+ NVMEF(NVME_CTRLR_DATA_SGLS_ADDRESS_AS_OFFSET, 1) |
+ NVMEF(NVME_CTRLR_DATA_SGLS_NVM_COMMAND_SET, 1));
+
+ strlcpy(cdata->subnqn, NVMF_DISCOVERY_NQN, sizeof(cdata->subnqn));
+}
+
+void
+nvmf_init_io_controller_data(struct nvmf_qpair *qp, const char *serial,
+ const char *subnqn, int nn, uint32_t ioccsz,
+ struct nvme_controller_data *cdata)
+{
+ const struct nvmf_association *na = qp->nq_association;
+ struct utsname utsname;
+
+ uname(&utsname);
+
+ memset(cdata, 0, sizeof(*cdata));
+ _nvmf_init_io_controller_data(qp->nq_cntlid, na->na_params.max_io_qsize,
+ serial, utsname.sysname, utsname.release, subnqn, nn, ioccsz,
+ sizeof(struct nvme_completion), cdata);
+}
+
+uint8_t
+nvmf_get_log_page_id(const struct nvme_command *cmd)
+{
+ assert(cmd->opc == NVME_OPC_GET_LOG_PAGE);
+ return (le32toh(cmd->cdw10) & 0xff);
+}
+
+uint64_t
+nvmf_get_log_page_length(const struct nvme_command *cmd)
+{
+ uint32_t numd;
+
+ assert(cmd->opc == NVME_OPC_GET_LOG_PAGE);
+ numd = le32toh(cmd->cdw10) >> 16 | (le32toh(cmd->cdw11) & 0xffff) << 16;
+ return ((numd + 1) * 4);
+}
+
+uint64_t
+nvmf_get_log_page_offset(const struct nvme_command *cmd)
+{
+ assert(cmd->opc == NVME_OPC_GET_LOG_PAGE);
+ return (le32toh(cmd->cdw12) | (uint64_t)le32toh(cmd->cdw13) << 32);
+}
+
+int
+nvmf_handoff_controller_qpair(struct nvmf_qpair *qp,
+ const struct nvmf_fabric_connect_cmd *cmd,
+ const struct nvmf_fabric_connect_data *data, struct nvmf_ioc_nv *nv)
+{
+ nvlist_t *nvl, *nvl_qp;
+ int error;
+
+ error = nvmf_kernel_handoff_params(qp, &nvl_qp);
+ if (error)
+ return (error);
+
+ nvl = nvlist_create(0);
+ nvlist_add_number(nvl, "trtype", qp->nq_association->na_trtype);
+ nvlist_move_nvlist(nvl, "params", nvl_qp);
+ nvlist_add_binary(nvl, "cmd", cmd, sizeof(*cmd));
+ nvlist_add_binary(nvl, "data", data, sizeof(*data));
+
+ error = nvmf_pack_ioc_nvlist(nv, nvl);
+ nvlist_destroy(nvl);
+ return (error);
+}
diff --git a/lib/libnvmf/nvmf_host.c b/lib/libnvmf/nvmf_host.c
new file mode 100644
index 000000000000..3266f8898296
--- /dev/null
+++ b/lib/libnvmf/nvmf_host.c
@@ -0,0 +1,1021 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <sys/nv.h>
+#include <sys/sysctl.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <uuid.h>
+
+#include "libnvmf.h"
+#include "internal.h"
+
+static void
+nvmf_init_sqe(void *sqe, uint8_t opcode)
+{
+ struct nvme_command *cmd = sqe;
+
+ memset(cmd, 0, sizeof(*cmd));
+ cmd->opc = opcode;
+}
+
+static void
+nvmf_init_fabrics_sqe(void *sqe, uint8_t fctype)
+{
+ struct nvmf_capsule_cmd *cmd = sqe;
+
+ nvmf_init_sqe(sqe, NVME_OPC_FABRICS_COMMANDS);
+ cmd->fctype = fctype;
+}
+
+struct nvmf_qpair *
+nvmf_connect(struct nvmf_association *na,
+ const struct nvmf_qpair_params *params, uint16_t qid, u_int queue_size,
+ const uint8_t hostid[16], uint16_t cntlid, const char *subnqn,
+ const char *hostnqn, uint32_t kato)
+{
+ struct nvmf_fabric_connect_cmd cmd;
+ struct nvmf_fabric_connect_data data;
+ const struct nvmf_fabric_connect_rsp *rsp;
+ struct nvmf_qpair *qp;
+ struct nvmf_capsule *cc, *rc;
+ int error;
+ uint16_t sqhd, status;
+
+ qp = NULL;
+ cc = NULL;
+ rc = NULL;
+ na_clear_error(na);
+ if (na->na_controller) {
+ na_error(na, "Cannot connect on a controller");
+ goto error;
+ }
+
+ if (params->admin != (qid == 0)) {
+ na_error(na, "Admin queue must use Queue ID 0");
+ goto error;
+ }
+
+ if (qid == 0) {
+ if (queue_size < NVME_MIN_ADMIN_ENTRIES ||
+ queue_size > NVME_MAX_ADMIN_ENTRIES) {
+ na_error(na, "Invalid queue size %u", queue_size);
+ goto error;
+ }
+ } else {
+ if (queue_size < NVME_MIN_IO_ENTRIES ||
+ queue_size > NVME_MAX_IO_ENTRIES) {
+ na_error(na, "Invalid queue size %u", queue_size);
+ goto error;
+ }
+
+ /* KATO is only for Admin queues. */
+ if (kato != 0) {
+ na_error(na, "Cannot set KATO on I/O queues");
+ goto error;
+ }
+ }
+
+ qp = nvmf_allocate_qpair(na, params);
+ if (qp == NULL)
+ goto error;
+
+ nvmf_init_fabrics_sqe(&cmd, NVMF_FABRIC_COMMAND_CONNECT);
+ cmd.recfmt = 0;
+ cmd.qid = htole16(qid);
+
+ /* N.B. sqsize is 0's based. */
+ cmd.sqsize = htole16(queue_size - 1);
+ if (!na->na_params.sq_flow_control)
+ cmd.cattr |= NVMF_CONNECT_ATTR_DISABLE_SQ_FC;
+ cmd.kato = htole32(kato);
+
+ cc = nvmf_allocate_command(qp, &cmd);
+ if (cc == NULL) {
+ na_error(na, "Failed to allocate command capsule: %s",
+ strerror(errno));
+ goto error;
+ }
+
+ memset(&data, 0, sizeof(data));
+ memcpy(data.hostid, hostid, sizeof(data.hostid));
+ data.cntlid = htole16(cntlid);
+ strlcpy(data.subnqn, subnqn, sizeof(data.subnqn));
+ strlcpy(data.hostnqn, hostnqn, sizeof(data.hostnqn));
+
+ error = nvmf_capsule_append_data(cc, &data, sizeof(data), true);
+ if (error != 0) {
+ na_error(na, "Failed to append data to CONNECT capsule: %s",
+ strerror(error));
+ goto error;
+ }
+
+ error = nvmf_transmit_capsule(cc);
+ if (error != 0) {
+ na_error(na, "Failed to transmit CONNECT capsule: %s",
+ strerror(errno));
+ goto error;
+ }
+
+ error = nvmf_receive_capsule(qp, &rc);
+ if (error != 0) {
+ na_error(na, "Failed to receive CONNECT response: %s",
+ strerror(error));
+ goto error;
+ }
+
+ rsp = (const struct nvmf_fabric_connect_rsp *)&rc->nc_cqe;
+ status = le16toh(rc->nc_cqe.status);
+ if (status != 0) {
+ if (NVME_STATUS_GET_SC(status) == NVMF_FABRIC_SC_INVALID_PARAM)
+ na_error(na,
+ "CONNECT invalid parameter IATTR: %#x IPO: %#x",
+ rsp->status_code_specific.invalid.iattr,
+ rsp->status_code_specific.invalid.ipo);
+ else
+ na_error(na, "CONNECT failed, status %#x", status);
+ goto error;
+ }
+
+ if (rc->nc_cqe.cid != cmd.cid) {
+ na_error(na, "Mismatched CID in CONNECT response");
+ goto error;
+ }
+
+ if (!rc->nc_sqhd_valid) {
+ na_error(na, "CONNECT response without valid SQHD");
+ goto error;
+ }
+
+ sqhd = le16toh(rsp->sqhd);
+ if (sqhd == 0xffff) {
+ if (na->na_params.sq_flow_control) {
+ na_error(na, "Controller disabled SQ flow control");
+ goto error;
+ }
+ qp->nq_flow_control = false;
+ } else {
+ qp->nq_flow_control = true;
+ qp->nq_sqhd = sqhd;
+ qp->nq_sqtail = sqhd;
+ }
+
+ if (rsp->status_code_specific.success.authreq) {
+ na_error(na, "CONNECT response requests authentication\n");
+ goto error;
+ }
+
+ qp->nq_qsize = queue_size;
+ qp->nq_cntlid = le16toh(rsp->status_code_specific.success.cntlid);
+ qp->nq_kato = kato;
+ /* XXX: Save qid in qp? */
+ return (qp);
+
+error:
+ if (rc != NULL)
+ nvmf_free_capsule(rc);
+ if (cc != NULL)
+ nvmf_free_capsule(cc);
+ if (qp != NULL)
+ nvmf_free_qpair(qp);
+ return (NULL);
+}
+
+uint16_t
+nvmf_cntlid(struct nvmf_qpair *qp)
+{
+ return (qp->nq_cntlid);
+}
+
+int
+nvmf_host_transmit_command(struct nvmf_capsule *nc)
+{
+ struct nvmf_qpair *qp = nc->nc_qpair;
+ uint16_t new_sqtail;
+ int error;
+
+ /* Fail if the queue is full. */
+ new_sqtail = (qp->nq_sqtail + 1) % qp->nq_qsize;
+ if (new_sqtail == qp->nq_sqhd)
+ return (EBUSY);
+
+ nc->nc_sqe.cid = htole16(qp->nq_cid);
+
+ /* 4.2 Skip CID of 0xFFFF. */
+ qp->nq_cid++;
+ if (qp->nq_cid == 0xFFFF)
+ qp->nq_cid = 0;
+
+ error = nvmf_transmit_capsule(nc);
+ if (error != 0)
+ return (error);
+
+ qp->nq_sqtail = new_sqtail;
+ return (0);
+}
+
+/* Receive a single capsule and update SQ FC accounting. */
+static int
+nvmf_host_receive_capsule(struct nvmf_qpair *qp, struct nvmf_capsule **ncp)
+{
+ struct nvmf_capsule *nc;
+ int error;
+
+ /* If the SQ is empty, there is no response to wait for. */
+ if (qp->nq_sqhd == qp->nq_sqtail)
+ return (EWOULDBLOCK);
+
+ error = nvmf_receive_capsule(qp, &nc);
+ if (error != 0)
+ return (error);
+
+ if (qp->nq_flow_control) {
+ if (nc->nc_sqhd_valid)
+ qp->nq_sqhd = le16toh(nc->nc_cqe.sqhd);
+ } else {
+ /*
+ * If SQ FC is disabled, just advance the head for
+ * each response capsule received so that we track the
+ * number of outstanding commands.
+ */
+ qp->nq_sqhd = (qp->nq_sqhd + 1) % qp->nq_qsize;
+ }
+ *ncp = nc;
+ return (0);
+}
+
+int
+nvmf_host_receive_response(struct nvmf_qpair *qp, struct nvmf_capsule **ncp)
+{
+ struct nvmf_capsule *nc;
+
+ /* Return the oldest previously received response. */
+ if (!TAILQ_EMPTY(&qp->nq_rx_capsules)) {
+ nc = TAILQ_FIRST(&qp->nq_rx_capsules);
+ TAILQ_REMOVE(&qp->nq_rx_capsules, nc, nc_link);
+ *ncp = nc;
+ return (0);
+ }
+
+ return (nvmf_host_receive_capsule(qp, ncp));
+}
+
+int
+nvmf_host_wait_for_response(struct nvmf_capsule *cc,
+ struct nvmf_capsule **rcp)
+{
+ struct nvmf_qpair *qp = cc->nc_qpair;
+ struct nvmf_capsule *rc;
+ int error;
+
+ /* Check if a response was already received. */
+ TAILQ_FOREACH(rc, &qp->nq_rx_capsules, nc_link) {
+ if (rc->nc_cqe.cid == cc->nc_sqe.cid) {
+ TAILQ_REMOVE(&qp->nq_rx_capsules, rc, nc_link);
+ *rcp = rc;
+ return (0);
+ }
+ }
+
+ /* Wait for a response. */
+ for (;;) {
+ error = nvmf_host_receive_capsule(qp, &rc);
+ if (error != 0)
+ return (error);
+
+ if (rc->nc_cqe.cid != cc->nc_sqe.cid) {
+ TAILQ_INSERT_TAIL(&qp->nq_rx_capsules, rc, nc_link);
+ continue;
+ }
+
+ *rcp = rc;
+ return (0);
+ }
+}
+
+struct nvmf_capsule *
+nvmf_keepalive(struct nvmf_qpair *qp)
+{
+ struct nvme_command cmd;
+
+ if (!qp->nq_admin) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ nvmf_init_sqe(&cmd, NVME_OPC_KEEP_ALIVE);
+
+ return (nvmf_allocate_command(qp, &cmd));
+}
+
+static struct nvmf_capsule *
+nvmf_get_property(struct nvmf_qpair *qp, uint32_t offset, uint8_t size)
+{
+ struct nvmf_fabric_prop_get_cmd cmd;
+
+ nvmf_init_fabrics_sqe(&cmd, NVMF_FABRIC_COMMAND_PROPERTY_GET);
+ switch (size) {
+ case 4:
+ cmd.attrib.size = NVMF_PROP_SIZE_4;
+ break;
+ case 8:
+ cmd.attrib.size = NVMF_PROP_SIZE_8;
+ break;
+ default:
+ errno = EINVAL;
+ return (NULL);
+ }
+ cmd.ofst = htole32(offset);
+
+ return (nvmf_allocate_command(qp, &cmd));
+}
+
+int
+nvmf_read_property(struct nvmf_qpair *qp, uint32_t offset, uint8_t size,
+ uint64_t *value)
+{
+ struct nvmf_capsule *cc, *rc;
+ const struct nvmf_fabric_prop_get_rsp *rsp;
+ uint16_t status;
+ int error;
+
+ if (!qp->nq_admin)
+ return (EINVAL);
+
+ cc = nvmf_get_property(qp, offset, size);
+ if (cc == NULL)
+ return (errno);
+
+ error = nvmf_host_transmit_command(cc);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_wait_for_response(cc, &rc);
+ nvmf_free_capsule(cc);
+ if (error != 0)
+ return (error);
+
+ rsp = (const struct nvmf_fabric_prop_get_rsp *)&rc->nc_cqe;
+ status = le16toh(rc->nc_cqe.status);
+ if (status != 0) {
+ printf("NVMF: PROPERTY_GET failed, status %#x\n", status);
+ nvmf_free_capsule(rc);
+ return (EIO);
+ }
+
+ if (size == 8)
+ *value = le64toh(rsp->value.u64);
+ else
+ *value = le32toh(rsp->value.u32.low);
+ nvmf_free_capsule(rc);
+ return (0);
+}
+
+static struct nvmf_capsule *
+nvmf_set_property(struct nvmf_qpair *qp, uint32_t offset, uint8_t size,
+ uint64_t value)
+{
+ struct nvmf_fabric_prop_set_cmd cmd;
+
+ nvmf_init_fabrics_sqe(&cmd, NVMF_FABRIC_COMMAND_PROPERTY_SET);
+ switch (size) {
+ case 4:
+ cmd.attrib.size = NVMF_PROP_SIZE_4;
+ cmd.value.u32.low = htole32(value);
+ break;
+ case 8:
+ cmd.attrib.size = NVMF_PROP_SIZE_8;
+ cmd.value.u64 = htole64(value);
+ break;
+ default:
+ errno = EINVAL;
+ return (NULL);
+ }
+ cmd.ofst = htole32(offset);
+
+ return (nvmf_allocate_command(qp, &cmd));
+}
+
+int
+nvmf_write_property(struct nvmf_qpair *qp, uint32_t offset, uint8_t size,
+ uint64_t value)
+{
+ struct nvmf_capsule *cc, *rc;
+ uint16_t status;
+ int error;
+
+ if (!qp->nq_admin)
+ return (EINVAL);
+
+ cc = nvmf_set_property(qp, offset, size, value);
+ if (cc == NULL)
+ return (errno);
+
+ error = nvmf_host_transmit_command(cc);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_wait_for_response(cc, &rc);
+ nvmf_free_capsule(cc);
+ if (error != 0)
+ return (error);
+
+ status = le16toh(rc->nc_cqe.status);
+ if (status != 0) {
+ printf("NVMF: PROPERTY_SET failed, status %#x\n", status);
+ nvmf_free_capsule(rc);
+ return (EIO);
+ }
+
+ nvmf_free_capsule(rc);
+ return (0);
+}
+
+int
+nvmf_hostid_from_hostuuid(uint8_t hostid[16])
+{
+ char hostuuid_str[64];
+ uuid_t hostuuid;
+ size_t len;
+ uint32_t status;
+
+ len = sizeof(hostuuid_str);
+ if (sysctlbyname("kern.hostuuid", hostuuid_str, &len, NULL, 0) != 0)
+ return (errno);
+
+ uuid_from_string(hostuuid_str, &hostuuid, &status);
+ switch (status) {
+ case uuid_s_ok:
+ break;
+ case uuid_s_no_memory:
+ return (ENOMEM);
+ default:
+ return (EINVAL);
+ }
+
+ uuid_enc_le(hostid, &hostuuid);
+ return (0);
+}
+
+int
+nvmf_nqn_from_hostuuid(char nqn[NVMF_NQN_MAX_LEN])
+{
+ char hostuuid_str[64];
+ size_t len;
+
+ len = sizeof(hostuuid_str);
+ if (sysctlbyname("kern.hostuuid", hostuuid_str, &len, NULL, 0) != 0)
+ return (errno);
+
+ strlcpy(nqn, NVMF_NQN_UUID_PRE, NVMF_NQN_MAX_LEN);
+ strlcat(nqn, hostuuid_str, NVMF_NQN_MAX_LEN);
+ return (0);
+}
+
+int
+nvmf_host_identify_controller(struct nvmf_qpair *qp,
+ struct nvme_controller_data *cdata)
+{
+ struct nvme_command cmd;
+ struct nvmf_capsule *cc, *rc;
+ int error;
+ uint16_t status;
+
+ if (!qp->nq_admin)
+ return (EINVAL);
+
+ nvmf_init_sqe(&cmd, NVME_OPC_IDENTIFY);
+
+ /* 5.15.1 Use CNS of 0x01 for controller data. */
+ cmd.cdw10 = htole32(1);
+
+ cc = nvmf_allocate_command(qp, &cmd);
+ if (cc == NULL)
+ return (errno);
+
+ error = nvmf_capsule_append_data(cc, cdata, sizeof(*cdata), false);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_transmit_command(cc);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_wait_for_response(cc, &rc);
+ nvmf_free_capsule(cc);
+ if (error != 0)
+ return (error);
+
+ status = le16toh(rc->nc_cqe.status);
+ if (status != 0) {
+ printf("NVMF: IDENTIFY failed, status %#x\n", status);
+ nvmf_free_capsule(rc);
+ return (EIO);
+ }
+
+ nvmf_free_capsule(rc);
+ return (0);
+}
+
+int
+nvmf_host_identify_namespace(struct nvmf_qpair *qp, uint32_t nsid,
+ struct nvme_namespace_data *nsdata)
+{
+ struct nvme_command cmd;
+ struct nvmf_capsule *cc, *rc;
+ int error;
+ uint16_t status;
+
+ if (!qp->nq_admin)
+ return (EINVAL);
+
+ nvmf_init_sqe(&cmd, NVME_OPC_IDENTIFY);
+
+ /* 5.15.1 Use CNS of 0x00 for namespace data. */
+ cmd.cdw10 = htole32(0);
+ cmd.nsid = htole32(nsid);
+
+ cc = nvmf_allocate_command(qp, &cmd);
+ if (cc == NULL)
+ return (errno);
+
+ error = nvmf_capsule_append_data(cc, nsdata, sizeof(*nsdata), false);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_transmit_command(cc);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_wait_for_response(cc, &rc);
+ nvmf_free_capsule(cc);
+ if (error != 0)
+ return (error);
+
+ status = le16toh(rc->nc_cqe.status);
+ if (status != 0) {
+ printf("NVMF: IDENTIFY failed, status %#x\n", status);
+ nvmf_free_capsule(rc);
+ return (EIO);
+ }
+
+ nvmf_free_capsule(rc);
+ return (0);
+}
+
+static int
+nvmf_get_discovery_log_page(struct nvmf_qpair *qp, uint64_t offset, void *buf,
+ size_t len)
+{
+ struct nvme_command cmd;
+ struct nvmf_capsule *cc, *rc;
+ size_t numd;
+ int error;
+ uint16_t status;
+
+ if (len % 4 != 0 || len == 0 || offset % 4 != 0)
+ return (EINVAL);
+
+ numd = (len / 4) - 1;
+ nvmf_init_sqe(&cmd, NVME_OPC_GET_LOG_PAGE);
+ cmd.cdw10 = htole32(numd << 16 | NVME_LOG_DISCOVERY);
+ cmd.cdw11 = htole32(numd >> 16);
+ cmd.cdw12 = htole32(offset);
+ cmd.cdw13 = htole32(offset >> 32);
+
+ cc = nvmf_allocate_command(qp, &cmd);
+ if (cc == NULL)
+ return (errno);
+
+ error = nvmf_capsule_append_data(cc, buf, len, false);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_transmit_command(cc);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_wait_for_response(cc, &rc);
+ nvmf_free_capsule(cc);
+ if (error != 0)
+ return (error);
+
+ status = le16toh(rc->nc_cqe.status);
+ if (NVMEV(NVME_STATUS_SC, status) ==
+ NVMF_FABRIC_SC_LOG_RESTART_DISCOVERY) {
+ nvmf_free_capsule(rc);
+ return (EAGAIN);
+ }
+ if (status != 0) {
+ printf("NVMF: GET_LOG_PAGE failed, status %#x\n", status);
+ nvmf_free_capsule(rc);
+ return (EIO);
+ }
+
+ nvmf_free_capsule(rc);
+ return (0);
+}
+
+int
+nvmf_host_fetch_discovery_log_page(struct nvmf_qpair *qp,
+ struct nvme_discovery_log **logp)
+{
+ struct nvme_discovery_log hdr, *log;
+ size_t payload_len;
+ int error;
+
+ if (!qp->nq_admin)
+ return (EINVAL);
+
+ log = NULL;
+ for (;;) {
+ error = nvmf_get_discovery_log_page(qp, 0, &hdr, sizeof(hdr));
+ if (error != 0) {
+ free(log);
+ return (error);
+ }
+ nvme_discovery_log_swapbytes(&hdr);
+
+ if (hdr.recfmt != 0) {
+ printf("NVMF: Unsupported discovery log format: %d\n",
+ hdr.recfmt);
+ free(log);
+ return (EINVAL);
+ }
+
+ if (hdr.numrec > 1024) {
+ printf("NVMF: Too many discovery log entries: %ju\n",
+ (uintmax_t)hdr.numrec);
+ free(log);
+ return (EFBIG);
+ }
+
+ payload_len = sizeof(log->entries[0]) * hdr.numrec;
+ log = reallocf(log, sizeof(*log) + payload_len);
+ if (log == NULL)
+ return (ENOMEM);
+ *log = hdr;
+ if (hdr.numrec == 0)
+ break;
+
+ error = nvmf_get_discovery_log_page(qp, sizeof(hdr),
+ log->entries, payload_len);
+ if (error == EAGAIN)
+ continue;
+ if (error != 0) {
+ free(log);
+ return (error);
+ }
+
+ /* Re-read the header and check the generation count. */
+ error = nvmf_get_discovery_log_page(qp, 0, &hdr, sizeof(hdr));
+ if (error != 0) {
+ free(log);
+ return (error);
+ }
+ nvme_discovery_log_swapbytes(&hdr);
+
+ if (log->genctr != hdr.genctr)
+ continue;
+
+ for (u_int i = 0; i < log->numrec; i++)
+ nvme_discovery_log_entry_swapbytes(&log->entries[i]);
+ break;
+ }
+ *logp = log;
+ return (0);
+}
+
+int
+nvmf_init_dle_from_admin_qp(struct nvmf_qpair *qp,
+ const struct nvme_controller_data *cdata,
+ struct nvme_discovery_log_entry *dle)
+{
+ int error;
+ uint16_t cntlid;
+
+ memset(dle, 0, sizeof(*dle));
+ error = nvmf_populate_dle(qp, dle);
+ if (error != 0)
+ return (error);
+ if ((cdata->fcatt & 1) == 0)
+ cntlid = NVMF_CNTLID_DYNAMIC;
+ else
+ cntlid = cdata->ctrlr_id;
+ dle->cntlid = htole16(cntlid);
+ memcpy(dle->subnqn, cdata->subnqn, sizeof(dle->subnqn));
+ return (0);
+}
+
+int
+nvmf_host_request_queues(struct nvmf_qpair *qp, u_int requested, u_int *actual)
+{
+ struct nvme_command cmd;
+ struct nvmf_capsule *cc, *rc;
+ int error;
+ uint16_t status;
+
+ if (!qp->nq_admin || requested < 1 || requested > 65535)
+ return (EINVAL);
+
+ /* The number of queues is 0's based. */
+ requested--;
+
+ nvmf_init_sqe(&cmd, NVME_OPC_SET_FEATURES);
+ cmd.cdw10 = htole32(NVME_FEAT_NUMBER_OF_QUEUES);
+
+ /* Same number of completion and submission queues. */
+ cmd.cdw11 = htole32((requested << 16) | requested);
+
+ cc = nvmf_allocate_command(qp, &cmd);
+ if (cc == NULL)
+ return (errno);
+
+ error = nvmf_host_transmit_command(cc);
+ if (error != 0) {
+ nvmf_free_capsule(cc);
+ return (error);
+ }
+
+ error = nvmf_host_wait_for_response(cc, &rc);
+ nvmf_free_capsule(cc);
+ if (error != 0)
+ return (error);
+
+ status = le16toh(rc->nc_cqe.status);
+ if (status != 0) {
+ printf("NVMF: SET_FEATURES failed, status %#x\n", status);
+ nvmf_free_capsule(rc);
+ return (EIO);
+ }
+
+ *actual = (le32toh(rc->nc_cqe.cdw0) & 0xffff) + 1;
+ nvmf_free_capsule(rc);
+ return (0);
+}
+
+static bool
+is_queue_pair_idle(struct nvmf_qpair *qp)
+{
+ if (qp->nq_sqhd != qp->nq_sqtail)
+ return (false);
+ if (!TAILQ_EMPTY(&qp->nq_rx_capsules))
+ return (false);
+ return (true);
+}
+
+static int
+prepare_queues_for_handoff(struct nvmf_ioc_nv *nv,
+ const struct nvme_discovery_log_entry *dle, const char *hostnqn,
+ struct nvmf_qpair *admin_qp, u_int num_queues,
+ struct nvmf_qpair **io_queues, const struct nvme_controller_data *cdata,
+ uint32_t reconnect_delay, uint32_t controller_loss_timeout)
+{
+ const struct nvmf_association *na = admin_qp->nq_association;
+ nvlist_t *nvl, *nvl_qp, *nvl_rparams;
+ u_int i;
+ int error;
+
+ if (num_queues == 0)
+ return (EINVAL);
+
+ /* Ensure trtype matches. */
+ if (dle->trtype != na->na_trtype)
+ return (EINVAL);
+
+ /* All queue pairs must be idle. */
+ if (!is_queue_pair_idle(admin_qp))
+ return (EBUSY);
+ for (i = 0; i < num_queues; i++) {
+ if (!is_queue_pair_idle(io_queues[i]))
+ return (EBUSY);
+ }
+
+ /* Fill out reconnect parameters. */
+ nvl_rparams = nvlist_create(0);
+ nvlist_add_binary(nvl_rparams, "dle", dle, sizeof(*dle));
+ nvlist_add_string(nvl_rparams, "hostnqn", hostnqn);
+ nvlist_add_number(nvl_rparams, "num_io_queues", num_queues);
+ nvlist_add_number(nvl_rparams, "kato", admin_qp->nq_kato);
+ nvlist_add_number(nvl_rparams, "reconnect_delay", reconnect_delay);
+ nvlist_add_number(nvl_rparams, "controller_loss_timeout",
+ controller_loss_timeout);
+ nvlist_add_number(nvl_rparams, "io_qsize", io_queues[0]->nq_qsize);
+ nvlist_add_bool(nvl_rparams, "sq_flow_control",
+ na->na_params.sq_flow_control);
+ switch (na->na_trtype) {
+ case NVMF_TRTYPE_TCP:
+ nvlist_add_bool(nvl_rparams, "header_digests",
+ na->na_params.tcp.header_digests);
+ nvlist_add_bool(nvl_rparams, "data_digests",
+ na->na_params.tcp.data_digests);
+ break;
+ default:
+ __unreachable();
+ }
+ error = nvlist_error(nvl_rparams);
+ if (error != 0) {
+ nvlist_destroy(nvl_rparams);
+ return (error);
+ }
+
+ nvl = nvlist_create(0);
+ nvlist_add_number(nvl, "trtype", na->na_trtype);
+ nvlist_add_number(nvl, "kato", admin_qp->nq_kato);
+ nvlist_add_number(nvl, "reconnect_delay", reconnect_delay);
+ nvlist_add_number(nvl, "controller_loss_timeout",
+ controller_loss_timeout);
+ nvlist_move_nvlist(nvl, "rparams", nvl_rparams);
+
+ /* First, the admin queue. */
+ error = nvmf_kernel_handoff_params(admin_qp, &nvl_qp);
+ if (error) {
+ nvlist_destroy(nvl);
+ return (error);
+ }
+ nvlist_move_nvlist(nvl, "admin", nvl_qp);
+
+ /* Next, the I/O queues. */
+ for (i = 0; i < num_queues; i++) {
+ error = nvmf_kernel_handoff_params(io_queues[i], &nvl_qp);
+ if (error) {
+ nvlist_destroy(nvl);
+ return (error);
+ }
+ nvlist_append_nvlist_array(nvl, "io", nvl_qp);
+ }
+
+ nvlist_add_binary(nvl, "cdata", cdata, sizeof(*cdata));
+
+ error = nvmf_pack_ioc_nvlist(nv, nvl);
+ nvlist_destroy(nvl);
+ return (error);
+}
+
+int
+nvmf_handoff_host(const struct nvme_discovery_log_entry *dle,
+ const char *hostnqn, struct nvmf_qpair *admin_qp, u_int num_queues,
+ struct nvmf_qpair **io_queues, const struct nvme_controller_data *cdata,
+ uint32_t reconnect_delay, uint32_t controller_loss_timeout)
+{
+ struct nvmf_ioc_nv nv;
+ u_int i;
+ int error, fd;
+
+ fd = open("/dev/nvmf", O_RDWR);
+ if (fd == -1) {
+ error = errno;
+ goto out;
+ }
+
+ error = prepare_queues_for_handoff(&nv, dle, hostnqn, admin_qp,
+ num_queues, io_queues, cdata, reconnect_delay,
+ controller_loss_timeout);
+ if (error != 0)
+ goto out;
+
+ if (ioctl(fd, NVMF_HANDOFF_HOST, &nv) == -1)
+ error = errno;
+ free(nv.data);
+
+out:
+ if (fd >= 0)
+ close(fd);
+ for (i = 0; i < num_queues; i++)
+ (void)nvmf_free_qpair(io_queues[i]);
+ (void)nvmf_free_qpair(admin_qp);
+ return (error);
+}
+
+int
+nvmf_disconnect_host(const char *host)
+{
+ int error, fd;
+
+ error = 0;
+ fd = open("/dev/nvmf", O_RDWR);
+ if (fd == -1) {
+ error = errno;
+ goto out;
+ }
+
+ if (ioctl(fd, NVMF_DISCONNECT_HOST, &host) == -1)
+ error = errno;
+
+out:
+ if (fd >= 0)
+ close(fd);
+ return (error);
+}
+
+int
+nvmf_disconnect_all(void)
+{
+ int error, fd;
+
+ error = 0;
+ fd = open("/dev/nvmf", O_RDWR);
+ if (fd == -1) {
+ error = errno;
+ goto out;
+ }
+
+ if (ioctl(fd, NVMF_DISCONNECT_ALL) == -1)
+ error = errno;
+
+out:
+ if (fd >= 0)
+ close(fd);
+ return (error);
+}
+
+static int
+nvmf_read_ioc_nv(int fd, u_long com, nvlist_t **nvlp)
+{
+ struct nvmf_ioc_nv nv;
+ nvlist_t *nvl;
+ int error;
+
+ memset(&nv, 0, sizeof(nv));
+ if (ioctl(fd, com, &nv) == -1)
+ return (errno);
+
+ nv.data = malloc(nv.len);
+ nv.size = nv.len;
+ if (ioctl(fd, com, &nv) == -1) {
+ error = errno;
+ free(nv.data);
+ return (error);
+ }
+
+ nvl = nvlist_unpack(nv.data, nv.len, 0);
+ free(nv.data);
+ if (nvl == NULL)
+ return (EINVAL);
+
+ *nvlp = nvl;
+ return (0);
+}
+
+int
+nvmf_reconnect_params(int fd, nvlist_t **nvlp)
+{
+ return (nvmf_read_ioc_nv(fd, NVMF_RECONNECT_PARAMS, nvlp));
+}
+
+int
+nvmf_reconnect_host(int fd, const struct nvme_discovery_log_entry *dle,
+ const char *hostnqn, struct nvmf_qpair *admin_qp, u_int num_queues,
+ struct nvmf_qpair **io_queues, const struct nvme_controller_data *cdata,
+ uint32_t reconnect_delay, uint32_t controller_loss_timeout)
+{
+ struct nvmf_ioc_nv nv;
+ u_int i;
+ int error;
+
+ error = prepare_queues_for_handoff(&nv, dle, hostnqn, admin_qp,
+ num_queues, io_queues, cdata, reconnect_delay,
+ controller_loss_timeout);
+ if (error != 0)
+ goto out;
+
+ if (ioctl(fd, NVMF_RECONNECT_HOST, &nv) == -1)
+ error = errno;
+ free(nv.data);
+
+out:
+ for (i = 0; i < num_queues; i++)
+ (void)nvmf_free_qpair(io_queues[i]);
+ (void)nvmf_free_qpair(admin_qp);
+ return (error);
+}
+
+int
+nvmf_connection_status(int fd, nvlist_t **nvlp)
+{
+ return (nvmf_read_ioc_nv(fd, NVMF_CONNECTION_STATUS, nvlp));
+}
diff --git a/lib/libnvmf/nvmf_tcp.c b/lib/libnvmf/nvmf_tcp.c
new file mode 100644
index 000000000000..6f41ca7ff502
--- /dev/null
+++ b/lib/libnvmf/nvmf_tcp.c
@@ -0,0 +1,1501 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022-2024 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <sys/endian.h>
+#include <sys/gsb_crc32.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <assert.h>
+#include <errno.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "libnvmf.h"
+#include "internal.h"
+#include "nvmf_tcp.h"
+
+struct nvmf_tcp_qpair;
+
+struct nvmf_tcp_command_buffer {
+ struct nvmf_tcp_qpair *qp;
+
+ void *data;
+ size_t data_len;
+ size_t data_xfered;
+ uint32_t data_offset;
+
+ uint16_t cid;
+ uint16_t ttag;
+
+ LIST_ENTRY(nvmf_tcp_command_buffer) link;
+};
+
+LIST_HEAD(nvmf_tcp_command_buffer_list, nvmf_tcp_command_buffer);
+
+struct nvmf_tcp_association {
+ struct nvmf_association na;
+
+ uint32_t ioccsz;
+};
+
+struct nvmf_tcp_rxpdu {
+ struct nvme_tcp_common_pdu_hdr *hdr;
+ uint32_t data_len;
+};
+
+struct nvmf_tcp_capsule {
+ struct nvmf_capsule nc;
+
+ struct nvmf_tcp_rxpdu rx_pdu;
+ struct nvmf_tcp_command_buffer *cb;
+
+ TAILQ_ENTRY(nvmf_tcp_capsule) link;
+};
+
+struct nvmf_tcp_qpair {
+ struct nvmf_qpair qp;
+ int s;
+
+ uint8_t txpda;
+ uint8_t rxpda;
+ bool header_digests;
+ bool data_digests;
+ uint32_t maxr2t;
+ uint32_t maxh2cdata;
+ uint32_t max_icd; /* Host only */
+ uint16_t next_ttag; /* Controller only */
+
+ struct nvmf_tcp_command_buffer_list tx_buffers;
+ struct nvmf_tcp_command_buffer_list rx_buffers;
+ TAILQ_HEAD(, nvmf_tcp_capsule) rx_capsules;
+};
+
+#define TASSOC(nc) ((struct nvmf_tcp_association *)(na))
+#define TCAP(nc) ((struct nvmf_tcp_capsule *)(nc))
+#define CTCAP(nc) ((const struct nvmf_tcp_capsule *)(nc))
+#define TQP(qp) ((struct nvmf_tcp_qpair *)(qp))
+
+static const char zero_padding[NVME_TCP_PDU_PDO_MAX_OFFSET];
+
+static uint32_t
+compute_digest(const void *buf, size_t len)
+{
+ return (calculate_crc32c(0xffffffff, buf, len) ^ 0xffffffff);
+}
+
+static struct nvmf_tcp_command_buffer *
+tcp_alloc_command_buffer(struct nvmf_tcp_qpair *qp, void *data,
+ uint32_t data_offset, size_t data_len, uint16_t cid, uint16_t ttag,
+ bool receive)
+{
+ struct nvmf_tcp_command_buffer *cb;
+
+ cb = malloc(sizeof(*cb));
+ cb->qp = qp;
+ cb->data = data;
+ cb->data_offset = data_offset;
+ cb->data_len = data_len;
+ cb->data_xfered = 0;
+ cb->cid = cid;
+ cb->ttag = ttag;
+
+ if (receive)
+ LIST_INSERT_HEAD(&qp->rx_buffers, cb, link);
+ else
+ LIST_INSERT_HEAD(&qp->tx_buffers, cb, link);
+ return (cb);
+}
+
+static struct nvmf_tcp_command_buffer *
+tcp_find_command_buffer(struct nvmf_tcp_qpair *qp, uint16_t cid, uint16_t ttag,
+ bool receive)
+{
+ struct nvmf_tcp_command_buffer_list *list;
+ struct nvmf_tcp_command_buffer *cb;
+
+ list = receive ? &qp->rx_buffers : &qp->tx_buffers;
+ LIST_FOREACH(cb, list, link) {
+ if (cb->cid == cid && cb->ttag == ttag)
+ return (cb);
+ }
+ return (NULL);
+}
+
+static void
+tcp_purge_command_buffer(struct nvmf_tcp_qpair *qp, uint16_t cid, uint16_t ttag,
+ bool receive)
+{
+ struct nvmf_tcp_command_buffer *cb;
+
+ cb = tcp_find_command_buffer(qp, cid, ttag, receive);
+ if (cb != NULL)
+ LIST_REMOVE(cb, link);
+}
+
+static void
+tcp_free_command_buffer(struct nvmf_tcp_command_buffer *cb)
+{
+ LIST_REMOVE(cb, link);
+ free(cb);
+}
+
+static int
+nvmf_tcp_write_pdu(struct nvmf_tcp_qpair *qp, const void *pdu, size_t len)
+{
+ ssize_t nwritten;
+ const char *cp;
+
+ cp = pdu;
+ while (len != 0) {
+ nwritten = write(qp->s, cp, len);
+ if (nwritten < 0)
+ return (errno);
+ len -= nwritten;
+ cp += nwritten;
+ }
+ return (0);
+}
+
+static int
+nvmf_tcp_write_pdu_iov(struct nvmf_tcp_qpair *qp, struct iovec *iov,
+ u_int iovcnt, size_t len)
+{
+ ssize_t nwritten;
+
+ for (;;) {
+ nwritten = writev(qp->s, iov, iovcnt);
+ if (nwritten < 0)
+ return (errno);
+
+ len -= nwritten;
+ if (len == 0)
+ return (0);
+
+ while (iov->iov_len <= (size_t)nwritten) {
+ nwritten -= iov->iov_len;
+ iovcnt--;
+ iov++;
+ }
+
+ iov->iov_base = (char *)iov->iov_base + nwritten;
+ iov->iov_len -= nwritten;
+ }
+}
+
+static void
+nvmf_tcp_report_error(struct nvmf_association *na, struct nvmf_tcp_qpair *qp,
+ uint16_t fes, uint32_t fei, const void *rx_pdu, size_t pdu_len, u_int hlen)
+{
+ struct nvme_tcp_term_req_hdr hdr;
+ struct iovec iov[2];
+
+ if (hlen != 0) {
+ if (hlen > NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE)
+ hlen = NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE;
+ if (hlen > pdu_len)
+ hlen = pdu_len;
+ }
+
+ memset(&hdr, 0, sizeof(hdr));
+ hdr.common.pdu_type = na->na_controller ?
+ NVME_TCP_PDU_TYPE_C2H_TERM_REQ : NVME_TCP_PDU_TYPE_H2C_TERM_REQ;
+ hdr.common.hlen = sizeof(hdr);
+ hdr.common.plen = sizeof(hdr) + hlen;
+ hdr.fes = htole16(fes);
+ le32enc(hdr.fei, fei);
+ iov[0].iov_base = &hdr;
+ iov[0].iov_len = sizeof(hdr);
+ iov[1].iov_base = __DECONST(void *, rx_pdu);
+ iov[1].iov_len = hlen;
+
+ (void)nvmf_tcp_write_pdu_iov(qp, iov, nitems(iov), sizeof(hdr) + hlen);
+ close(qp->s);
+ qp->s = -1;
+}
+
+static int
+nvmf_tcp_validate_pdu(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu,
+ size_t pdu_len)
+{
+ const struct nvme_tcp_common_pdu_hdr *ch;
+ uint32_t data_len, fei, plen;
+ uint32_t digest, rx_digest;
+ u_int hlen;
+ int error;
+ uint16_t fes;
+
+ /* Determine how large of a PDU header to return for errors. */
+ ch = pdu->hdr;
+ hlen = ch->hlen;
+ plen = le32toh(ch->plen);
+ if (hlen < sizeof(*ch) || hlen > plen)
+ hlen = sizeof(*ch);
+
+ error = nvmf_tcp_validate_pdu_header(ch,
+ qp->qp.nq_association->na_controller, qp->header_digests,
+ qp->data_digests, qp->rxpda, &data_len, &fes, &fei);
+ if (error != 0) {
+ if (error == ECONNRESET) {
+ close(qp->s);
+ qp->s = -1;
+ } else {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ fes, fei, ch, pdu_len, hlen);
+ }
+ return (error);
+ }
+
+ /* Check header digest if present. */
+ if ((ch->flags & NVME_TCP_CH_FLAGS_HDGSTF) != 0) {
+ digest = compute_digest(ch, ch->hlen);
+ memcpy(&rx_digest, (const char *)ch + ch->hlen,
+ sizeof(rx_digest));
+ if (digest != rx_digest) {
+ printf("NVMe/TCP: Header digest mismatch\n");
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_HDGST_ERROR, rx_digest, ch,
+ pdu_len, hlen);
+ return (EBADMSG);
+ }
+ }
+
+ /* Check data digest if present. */
+ if ((ch->flags & NVME_TCP_CH_FLAGS_DDGSTF) != 0) {
+ digest = compute_digest((const char *)ch + ch->pdo, data_len);
+ memcpy(&rx_digest, (const char *)ch + plen - sizeof(rx_digest),
+ sizeof(rx_digest));
+ if (digest != rx_digest) {
+ printf("NVMe/TCP: Data digest mismatch\n");
+ return (EBADMSG);
+ }
+ }
+
+ pdu->data_len = data_len;
+ return (0);
+}
+
+/*
+ * Read data from a socket, retrying until the data has been fully
+ * read or an error occurs.
+ */
+static int
+nvmf_tcp_read_buffer(int s, void *buf, size_t len)
+{
+ ssize_t nread;
+ char *cp;
+
+ cp = buf;
+ while (len != 0) {
+ nread = read(s, cp, len);
+ if (nread < 0)
+ return (errno);
+ if (nread == 0)
+ return (ECONNRESET);
+ len -= nread;
+ cp += nread;
+ }
+ return (0);
+}
+
+static int
+nvmf_tcp_read_pdu(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvme_tcp_common_pdu_hdr ch;
+ uint32_t plen;
+ int error;
+
+ memset(pdu, 0, sizeof(*pdu));
+ error = nvmf_tcp_read_buffer(qp->s, &ch, sizeof(ch));
+ if (error != 0)
+ return (error);
+
+ plen = le32toh(ch.plen);
+
+ /*
+ * Validate a header with garbage lengths to trigger
+ * an error message without reading more.
+ */
+ if (plen < sizeof(ch) || ch.hlen > plen) {
+ pdu->hdr = &ch;
+ error = nvmf_tcp_validate_pdu(qp, pdu, sizeof(ch));
+ pdu->hdr = NULL;
+ assert(error != 0);
+ return (error);
+ }
+
+ /* Read the rest of the PDU. */
+ pdu->hdr = malloc(plen);
+ memcpy(pdu->hdr, &ch, sizeof(ch));
+ error = nvmf_tcp_read_buffer(qp->s, pdu->hdr + 1, plen - sizeof(ch));
+ if (error != 0)
+ return (error);
+ error = nvmf_tcp_validate_pdu(qp, pdu, plen);
+ if (error != 0) {
+ free(pdu->hdr);
+ pdu->hdr = NULL;
+ }
+ return (error);
+}
+
+static void
+nvmf_tcp_free_pdu(struct nvmf_tcp_rxpdu *pdu)
+{
+ free(pdu->hdr);
+ pdu->hdr = NULL;
+}
+
+static int
+nvmf_tcp_handle_term_req(struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvme_tcp_term_req_hdr *hdr;
+
+ hdr = (void *)pdu->hdr;
+
+ printf("NVMe/TCP: Received termination request: fes %#x fei %#x\n",
+ le16toh(hdr->fes), le32dec(hdr->fei));
+ nvmf_tcp_free_pdu(pdu);
+ return (ECONNRESET);
+}
+
+static int
+nvmf_tcp_save_command_capsule(struct nvmf_tcp_qpair *qp,
+ struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvme_tcp_cmd *cmd;
+ struct nvmf_capsule *nc;
+ struct nvmf_tcp_capsule *tc;
+
+ cmd = (void *)pdu->hdr;
+
+ nc = nvmf_allocate_command(&qp->qp, &cmd->ccsqe);
+ if (nc == NULL)
+ return (ENOMEM);
+
+ tc = TCAP(nc);
+ tc->rx_pdu = *pdu;
+
+ TAILQ_INSERT_TAIL(&qp->rx_capsules, tc, link);
+ return (0);
+}
+
+static int
+nvmf_tcp_save_response_capsule(struct nvmf_tcp_qpair *qp,
+ struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvme_tcp_rsp *rsp;
+ struct nvmf_capsule *nc;
+ struct nvmf_tcp_capsule *tc;
+
+ rsp = (void *)pdu->hdr;
+
+ nc = nvmf_allocate_response(&qp->qp, &rsp->rccqe);
+ if (nc == NULL)
+ return (ENOMEM);
+
+ nc->nc_sqhd_valid = true;
+ tc = TCAP(nc);
+ tc->rx_pdu = *pdu;
+
+ TAILQ_INSERT_TAIL(&qp->rx_capsules, tc, link);
+
+ /*
+ * Once the CQE has been received, no further transfers to the
+ * command buffer for the associated CID can occur.
+ */
+ tcp_purge_command_buffer(qp, rsp->rccqe.cid, 0, true);
+ tcp_purge_command_buffer(qp, rsp->rccqe.cid, 0, false);
+
+ return (0);
+}
+
+/*
+ * Construct and send a PDU that contains an optional data payload.
+ * This includes dealing with digests and the length fields in the
+ * common header.
+ */
+static int
+nvmf_tcp_construct_pdu(struct nvmf_tcp_qpair *qp, void *hdr, size_t hlen,
+ void *data, uint32_t data_len)
+{
+ struct nvme_tcp_common_pdu_hdr *ch;
+ struct iovec iov[5];
+ u_int iovcnt;
+ uint32_t header_digest, data_digest, pad, pdo, plen;
+
+ plen = hlen;
+ if (qp->header_digests)
+ plen += sizeof(header_digest);
+ if (data_len != 0) {
+ pdo = roundup(plen, qp->txpda);
+ pad = pdo - plen;
+ plen = pdo + data_len;
+ if (qp->data_digests)
+ plen += sizeof(data_digest);
+ } else {
+ assert(data == NULL);
+ pdo = 0;
+ pad = 0;
+ }
+
+ ch = hdr;
+ ch->hlen = hlen;
+ if (qp->header_digests)
+ ch->flags |= NVME_TCP_CH_FLAGS_HDGSTF;
+ if (qp->data_digests && data_len != 0)
+ ch->flags |= NVME_TCP_CH_FLAGS_DDGSTF;
+ ch->pdo = pdo;
+ ch->plen = htole32(plen);
+
+ /* CH + PSH */
+ iov[0].iov_base = hdr;
+ iov[0].iov_len = hlen;
+ iovcnt = 1;
+
+ /* HDGST */
+ if (qp->header_digests) {
+ header_digest = compute_digest(hdr, hlen);
+ iov[iovcnt].iov_base = &header_digest;
+ iov[iovcnt].iov_len = sizeof(header_digest);
+ iovcnt++;
+ }
+
+ if (pad != 0) {
+ /* PAD */
+ iov[iovcnt].iov_base = __DECONST(char *, zero_padding);
+ iov[iovcnt].iov_len = pad;
+ iovcnt++;
+ }
+
+ if (data_len != 0) {
+ /* DATA */
+ iov[iovcnt].iov_base = data;
+ iov[iovcnt].iov_len = data_len;
+ iovcnt++;
+
+ /* DDGST */
+ if (qp->data_digests) {
+ data_digest = compute_digest(data, data_len);
+ iov[iovcnt].iov_base = &data_digest;
+ iov[iovcnt].iov_len = sizeof(data_digest);
+ iovcnt++;
+ }
+ }
+
+ return (nvmf_tcp_write_pdu_iov(qp, iov, iovcnt, plen));
+}
+
+static int
+nvmf_tcp_handle_h2c_data(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvme_tcp_h2c_data_hdr *h2c;
+ struct nvmf_tcp_command_buffer *cb;
+ uint32_t data_len, data_offset;
+ const char *icd;
+
+ h2c = (void *)pdu->hdr;
+ if (le32toh(h2c->datal) > qp->maxh2cdata) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_LIMIT_EXCEEDED, 0,
+ pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ cb = tcp_find_command_buffer(qp, h2c->cccid, h2c->ttag, true);
+ if (cb == NULL) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD,
+ offsetof(struct nvme_tcp_h2c_data_hdr, ttag), pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ data_len = le32toh(h2c->datal);
+ if (data_len != pdu->data_len) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD,
+ offsetof(struct nvme_tcp_h2c_data_hdr, datal), pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ data_offset = le32toh(h2c->datao);
+ if (data_offset < cb->data_offset ||
+ data_offset + data_len > cb->data_offset + cb->data_len) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_OUT_OF_RANGE, 0,
+ pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ if (data_offset != cb->data_offset + cb->data_xfered) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ if ((cb->data_xfered + data_len == cb->data_len) !=
+ ((pdu->hdr->flags & NVME_TCP_H2C_DATA_FLAGS_LAST_PDU) != 0)) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ cb->data_xfered += data_len;
+ data_offset -= cb->data_offset;
+ icd = (const char *)pdu->hdr + pdu->hdr->pdo;
+ memcpy((char *)cb->data + data_offset, icd, data_len);
+
+ nvmf_tcp_free_pdu(pdu);
+ return (0);
+}
+
+static int
+nvmf_tcp_handle_c2h_data(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvme_tcp_c2h_data_hdr *c2h;
+ struct nvmf_tcp_command_buffer *cb;
+ uint32_t data_len, data_offset;
+ const char *icd;
+
+ c2h = (void *)pdu->hdr;
+
+ cb = tcp_find_command_buffer(qp, c2h->cccid, 0, true);
+ if (cb == NULL) {
+ /*
+ * XXX: Could be PDU sequence error if cccid is for a
+ * command that doesn't use a command buffer.
+ */
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD,
+ offsetof(struct nvme_tcp_c2h_data_hdr, cccid), pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ data_len = le32toh(c2h->datal);
+ if (data_len != pdu->data_len) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD,
+ offsetof(struct nvme_tcp_c2h_data_hdr, datal), pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ data_offset = le32toh(c2h->datao);
+ if (data_offset < cb->data_offset ||
+ data_offset + data_len > cb->data_offset + cb->data_len) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_OUT_OF_RANGE, 0,
+ pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ if (data_offset != cb->data_offset + cb->data_xfered) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ if ((cb->data_xfered + data_len == cb->data_len) !=
+ ((pdu->hdr->flags & NVME_TCP_C2H_DATA_FLAGS_LAST_PDU) != 0)) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ cb->data_xfered += data_len;
+ data_offset -= cb->data_offset;
+ icd = (const char *)pdu->hdr + pdu->hdr->pdo;
+ memcpy((char *)cb->data + data_offset, icd, data_len);
+
+ if ((pdu->hdr->flags & NVME_TCP_C2H_DATA_FLAGS_SUCCESS) != 0) {
+ struct nvme_completion cqe;
+ struct nvmf_tcp_capsule *tc;
+ struct nvmf_capsule *nc;
+
+ memset(&cqe, 0, sizeof(cqe));
+ cqe.cid = cb->cid;
+
+ nc = nvmf_allocate_response(&qp->qp, &cqe);
+ if (nc == NULL) {
+ nvmf_tcp_free_pdu(pdu);
+ return (ENOMEM);
+ }
+ nc->nc_sqhd_valid = false;
+
+ tc = TCAP(nc);
+ TAILQ_INSERT_TAIL(&qp->rx_capsules, tc, link);
+ }
+
+ nvmf_tcp_free_pdu(pdu);
+ return (0);
+}
+
+/* NB: cid and ttag and little-endian already. */
+static int
+tcp_send_h2c_pdu(struct nvmf_tcp_qpair *qp, uint16_t cid, uint16_t ttag,
+ uint32_t data_offset, void *buf, size_t len, bool last_pdu)
+{
+ struct nvme_tcp_h2c_data_hdr h2c;
+
+ memset(&h2c, 0, sizeof(h2c));
+ h2c.common.pdu_type = NVME_TCP_PDU_TYPE_H2C_DATA;
+ if (last_pdu)
+ h2c.common.flags |= NVME_TCP_H2C_DATA_FLAGS_LAST_PDU;
+ h2c.cccid = cid;
+ h2c.ttag = ttag;
+ h2c.datao = htole32(data_offset);
+ h2c.datal = htole32(len);
+
+ return (nvmf_tcp_construct_pdu(qp, &h2c, sizeof(h2c), buf, len));
+}
+
+/* Sends one or more H2C_DATA PDUs, subject to MAXH2CDATA. */
+static int
+tcp_send_h2c_pdus(struct nvmf_tcp_qpair *qp, uint16_t cid, uint16_t ttag,
+ uint32_t data_offset, void *buf, size_t len, bool last_pdu)
+{
+ char *p;
+
+ p = buf;
+ while (len != 0) {
+ size_t todo;
+ int error;
+
+ todo = len;
+ if (todo > qp->maxh2cdata)
+ todo = qp->maxh2cdata;
+ error = tcp_send_h2c_pdu(qp, cid, ttag, data_offset, p, todo,
+ last_pdu && todo == len);
+ if (error != 0)
+ return (error);
+ p += todo;
+ len -= todo;
+ }
+ return (0);
+}
+
+static int
+nvmf_tcp_handle_r2t(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu)
+{
+ struct nvmf_tcp_command_buffer *cb;
+ struct nvme_tcp_r2t_hdr *r2t;
+ uint32_t data_len, data_offset;
+ int error;
+
+ r2t = (void *)pdu->hdr;
+
+ cb = tcp_find_command_buffer(qp, r2t->cccid, 0, false);
+ if (cb == NULL) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD,
+ offsetof(struct nvme_tcp_r2t_hdr, cccid), pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ data_offset = le32toh(r2t->r2to);
+ if (data_offset != cb->data_xfered) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR, 0, pdu->hdr,
+ le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ /*
+ * XXX: The spec does not specify how to handle R2T tranfers
+ * out of range of the original command.
+ */
+ data_len = le32toh(r2t->r2tl);
+ if (data_offset + data_len > cb->data_len) {
+ nvmf_tcp_report_error(qp->qp.nq_association, qp,
+ NVME_TCP_TERM_REQ_FES_DATA_TRANSFER_OUT_OF_RANGE, 0,
+ pdu->hdr, le32toh(pdu->hdr->plen), pdu->hdr->hlen);
+ nvmf_tcp_free_pdu(pdu);
+ return (EBADMSG);
+ }
+
+ cb->data_xfered += data_len;
+
+ /*
+ * Write out one or more H2C_DATA PDUs containing the
+ * requested data.
+ */
+ error = tcp_send_h2c_pdus(qp, r2t->cccid, r2t->ttag,
+ data_offset, (char *)cb->data + data_offset, data_len, true);
+
+ nvmf_tcp_free_pdu(pdu);
+ return (error);
+}
+
+static int
+nvmf_tcp_receive_pdu(struct nvmf_tcp_qpair *qp)
+{
+ struct nvmf_tcp_rxpdu pdu;
+ int error;
+
+ error = nvmf_tcp_read_pdu(qp, &pdu);
+ if (error != 0)
+ return (error);
+
+ switch (pdu.hdr->pdu_type) {
+ default:
+ __unreachable();
+ break;
+ case NVME_TCP_PDU_TYPE_H2C_TERM_REQ:
+ case NVME_TCP_PDU_TYPE_C2H_TERM_REQ:
+ return (nvmf_tcp_handle_term_req(&pdu));
+ case NVME_TCP_PDU_TYPE_CAPSULE_CMD:
+ return (nvmf_tcp_save_command_capsule(qp, &pdu));
+ case NVME_TCP_PDU_TYPE_CAPSULE_RESP:
+ return (nvmf_tcp_save_response_capsule(qp, &pdu));
+ case NVME_TCP_PDU_TYPE_H2C_DATA:
+ return (nvmf_tcp_handle_h2c_data(qp, &pdu));
+ case NVME_TCP_PDU_TYPE_C2H_DATA:
+ return (nvmf_tcp_handle_c2h_data(qp, &pdu));
+ case NVME_TCP_PDU_TYPE_R2T:
+ return (nvmf_tcp_handle_r2t(qp, &pdu));
+ }
+}
+
+static bool
+nvmf_tcp_validate_ic_pdu(struct nvmf_association *na, struct nvmf_tcp_qpair *qp,
+ const struct nvme_tcp_common_pdu_hdr *ch, size_t pdu_len)
+{
+ const struct nvme_tcp_ic_req *pdu;
+ uint32_t plen;
+ u_int hlen;
+
+ /* Determine how large of a PDU header to return for errors. */
+ hlen = ch->hlen;
+ plen = le32toh(ch->plen);
+ if (hlen < sizeof(*ch) || hlen > plen)
+ hlen = sizeof(*ch);
+
+ /*
+ * Errors must be reported for the lowest incorrect field
+ * first, so validate fields in order.
+ */
+
+ /* Validate pdu_type. */
+
+ /* Controllers only receive PDUs with a PDU direction of 0. */
+ if (na->na_controller != ((ch->pdu_type & 0x01) == 0)) {
+ na_error(na, "NVMe/TCP: Invalid PDU type %u", ch->pdu_type);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 0, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ switch (ch->pdu_type) {
+ case NVME_TCP_PDU_TYPE_IC_REQ:
+ case NVME_TCP_PDU_TYPE_IC_RESP:
+ break;
+ default:
+ na_error(na, "NVMe/TCP: Invalid PDU type %u", ch->pdu_type);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 0, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ /* Validate flags. */
+ if (ch->flags != 0) {
+ na_error(na, "NVMe/TCP: Invalid PDU header flags %#x",
+ ch->flags);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 1, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ /* Validate hlen. */
+ if (ch->hlen != 128) {
+ na_error(na, "NVMe/TCP: Invalid PDU header length %u",
+ ch->hlen);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 2, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ /* Validate pdo. */
+ if (ch->pdo != 0) {
+ na_error(na, "NVMe/TCP: Invalid PDU data offset %u", ch->pdo);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 3, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ /* Validate plen. */
+ if (plen != 128) {
+ na_error(na, "NVMe/TCP: Invalid PDU length %u", plen);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 4, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ /* Validate fields common to both ICReq and ICResp. */
+ pdu = (const struct nvme_tcp_ic_req *)ch;
+ if (le16toh(pdu->pfv) != 0) {
+ na_error(na, "NVMe/TCP: Unsupported PDU version %u",
+ le16toh(pdu->pfv));
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_DATA_UNSUPPORTED_PARAMETER,
+ 8, ch, pdu_len, hlen);
+ return (false);
+ }
+
+ if (pdu->hpda > NVME_TCP_HPDA_MAX) {
+ na_error(na, "NVMe/TCP: Unsupported PDA %u", pdu->hpda);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 10, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ if (pdu->dgst.bits.reserved != 0) {
+ na_error(na, "NVMe/TCP: Invalid digest settings");
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 11, ch, pdu_len,
+ hlen);
+ return (false);
+ }
+
+ return (true);
+}
+
+static bool
+nvmf_tcp_read_ic_req(struct nvmf_association *na, struct nvmf_tcp_qpair *qp,
+ struct nvme_tcp_ic_req *pdu)
+{
+ int error;
+
+ error = nvmf_tcp_read_buffer(qp->s, pdu, sizeof(*pdu));
+ if (error != 0) {
+ na_error(na, "NVMe/TCP: Failed to read IC request: %s",
+ strerror(error));
+ return (false);
+ }
+
+ return (nvmf_tcp_validate_ic_pdu(na, qp, &pdu->common, sizeof(*pdu)));
+}
+
+static bool
+nvmf_tcp_read_ic_resp(struct nvmf_association *na, struct nvmf_tcp_qpair *qp,
+ struct nvme_tcp_ic_resp *pdu)
+{
+ int error;
+
+ error = nvmf_tcp_read_buffer(qp->s, pdu, sizeof(*pdu));
+ if (error != 0) {
+ na_error(na, "NVMe/TCP: Failed to read IC response: %s",
+ strerror(error));
+ return (false);
+ }
+
+ return (nvmf_tcp_validate_ic_pdu(na, qp, &pdu->common, sizeof(*pdu)));
+}
+
+static struct nvmf_association *
+tcp_allocate_association(bool controller,
+ const struct nvmf_association_params *params)
+{
+ struct nvmf_tcp_association *ta;
+
+ if (controller) {
+ /* 7.4.10.3 */
+ if (params->tcp.maxh2cdata < 4096 ||
+ params->tcp.maxh2cdata % 4 != 0)
+ return (NULL);
+ }
+
+ ta = calloc(1, sizeof(*ta));
+
+ return (&ta->na);
+}
+
+static void
+tcp_update_association(struct nvmf_association *na,
+ const struct nvme_controller_data *cdata)
+{
+ struct nvmf_tcp_association *ta = TASSOC(na);
+
+ ta->ioccsz = le32toh(cdata->ioccsz);
+}
+
+static void
+tcp_free_association(struct nvmf_association *na)
+{
+ free(na);
+}
+
+static bool
+tcp_connect(struct nvmf_tcp_qpair *qp, struct nvmf_association *na, bool admin)
+{
+ const struct nvmf_association_params *params = &na->na_params;
+ struct nvmf_tcp_association *ta = TASSOC(na);
+ struct nvme_tcp_ic_req ic_req;
+ struct nvme_tcp_ic_resp ic_resp;
+ uint32_t maxh2cdata;
+ int error;
+
+ if (!admin) {
+ if (ta->ioccsz == 0) {
+ na_error(na, "TCP I/O queues require cdata");
+ return (false);
+ }
+ if (ta->ioccsz < 4) {
+ na_error(na, "Invalid IOCCSZ %u", ta->ioccsz);
+ return (false);
+ }
+ }
+
+ memset(&ic_req, 0, sizeof(ic_req));
+ ic_req.common.pdu_type = NVME_TCP_PDU_TYPE_IC_REQ;
+ ic_req.common.hlen = sizeof(ic_req);
+ ic_req.common.plen = htole32(sizeof(ic_req));
+ ic_req.pfv = htole16(0);
+ ic_req.hpda = params->tcp.pda;
+ if (params->tcp.header_digests)
+ ic_req.dgst.bits.hdgst_enable = 1;
+ if (params->tcp.data_digests)
+ ic_req.dgst.bits.ddgst_enable = 1;
+ ic_req.maxr2t = htole32(params->tcp.maxr2t);
+
+ error = nvmf_tcp_write_pdu(qp, &ic_req, sizeof(ic_req));
+ if (error != 0) {
+ na_error(na, "Failed to write IC request: %s", strerror(error));
+ return (false);
+ }
+
+ if (!nvmf_tcp_read_ic_resp(na, qp, &ic_resp))
+ return (false);
+
+ /* Ensure the controller didn't enable digests we didn't request. */
+ if ((!params->tcp.header_digests &&
+ ic_resp.dgst.bits.hdgst_enable != 0) ||
+ (!params->tcp.data_digests &&
+ ic_resp.dgst.bits.ddgst_enable != 0)) {
+ na_error(na, "Controller enabled unrequested digests");
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_DATA_UNSUPPORTED_PARAMETER,
+ 11, &ic_resp, sizeof(ic_resp), sizeof(ic_resp));
+ return (false);
+ }
+
+ /*
+ * XXX: Is there an upper-bound to enforce here? Perhaps pick
+ * some large value and report larger values as an unsupported
+ * parameter?
+ */
+ maxh2cdata = le32toh(ic_resp.maxh2cdata);
+ if (maxh2cdata < 4096 || maxh2cdata % 4 != 0) {
+ na_error(na, "Invalid MAXH2CDATA %u", maxh2cdata);
+ nvmf_tcp_report_error(na, qp,
+ NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD, 12, &ic_resp,
+ sizeof(ic_resp), sizeof(ic_resp));
+ return (false);
+ }
+
+ qp->rxpda = (params->tcp.pda + 1) * 4;
+ qp->txpda = (ic_resp.cpda + 1) * 4;
+ qp->header_digests = ic_resp.dgst.bits.hdgst_enable != 0;
+ qp->data_digests = ic_resp.dgst.bits.ddgst_enable != 0;
+ qp->maxr2t = params->tcp.maxr2t;
+ qp->maxh2cdata = maxh2cdata;
+ if (admin)
+ /* 7.4.3 */
+ qp->max_icd = 8192;
+ else
+ qp->max_icd = (ta->ioccsz - 4) * 16;
+
+ return (0);
+}
+
+static bool
+tcp_accept(struct nvmf_tcp_qpair *qp, struct nvmf_association *na)
+{
+ const struct nvmf_association_params *params = &na->na_params;
+ struct nvme_tcp_ic_req ic_req;
+ struct nvme_tcp_ic_resp ic_resp;
+ int error;
+
+ if (!nvmf_tcp_read_ic_req(na, qp, &ic_req))
+ return (false);
+
+ memset(&ic_resp, 0, sizeof(ic_resp));
+ ic_resp.common.pdu_type = NVME_TCP_PDU_TYPE_IC_RESP;
+ ic_resp.common.hlen = sizeof(ic_req);
+ ic_resp.common.plen = htole32(sizeof(ic_req));
+ ic_resp.pfv = htole16(0);
+ ic_resp.cpda = params->tcp.pda;
+ if (params->tcp.header_digests && ic_req.dgst.bits.hdgst_enable != 0)
+ ic_resp.dgst.bits.hdgst_enable = 1;
+ if (params->tcp.data_digests && ic_req.dgst.bits.ddgst_enable != 0)
+ ic_resp.dgst.bits.ddgst_enable = 1;
+ ic_resp.maxh2cdata = htole32(params->tcp.maxh2cdata);
+
+ error = nvmf_tcp_write_pdu(qp, &ic_resp, sizeof(ic_resp));
+ if (error != 0) {
+ na_error(na, "Failed to write IC response: %s",
+ strerror(error));
+ return (false);
+ }
+
+ qp->rxpda = (params->tcp.pda + 1) * 4;
+ qp->txpda = (ic_req.hpda + 1) * 4;
+ qp->header_digests = ic_resp.dgst.bits.hdgst_enable != 0;
+ qp->data_digests = ic_resp.dgst.bits.ddgst_enable != 0;
+ qp->maxr2t = le32toh(ic_req.maxr2t);
+ qp->maxh2cdata = params->tcp.maxh2cdata;
+ qp->max_icd = 0; /* XXX */
+ return (0);
+}
+
+static struct nvmf_qpair *
+tcp_allocate_qpair(struct nvmf_association *na,
+ const struct nvmf_qpair_params *qparams)
+{
+ const struct nvmf_association_params *aparams = &na->na_params;
+ struct nvmf_tcp_qpair *qp;
+ int error;
+
+ if (aparams->tcp.pda > NVME_TCP_CPDA_MAX) {
+ na_error(na, "Invalid PDA");
+ return (NULL);
+ }
+
+ qp = calloc(1, sizeof(*qp));
+ qp->s = qparams->tcp.fd;
+ LIST_INIT(&qp->rx_buffers);
+ LIST_INIT(&qp->tx_buffers);
+ TAILQ_INIT(&qp->rx_capsules);
+ if (na->na_controller)
+ error = tcp_accept(qp, na);
+ else
+ error = tcp_connect(qp, na, qparams->admin);
+ if (error != 0) {
+ free(qp);
+ return (NULL);
+ }
+
+ return (&qp->qp);
+}
+
+static void
+tcp_free_qpair(struct nvmf_qpair *nq)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nq);
+ struct nvmf_tcp_capsule *ntc, *tc;
+ struct nvmf_tcp_command_buffer *ncb, *cb;
+
+ TAILQ_FOREACH_SAFE(tc, &qp->rx_capsules, link, ntc) {
+ TAILQ_REMOVE(&qp->rx_capsules, tc, link);
+ nvmf_free_capsule(&tc->nc);
+ }
+ LIST_FOREACH_SAFE(cb, &qp->rx_buffers, link, ncb) {
+ tcp_free_command_buffer(cb);
+ }
+ LIST_FOREACH_SAFE(cb, &qp->tx_buffers, link, ncb) {
+ tcp_free_command_buffer(cb);
+ }
+ free(qp);
+}
+
+static void
+tcp_kernel_handoff_params(struct nvmf_qpair *nq, nvlist_t *nvl)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nq);
+
+ nvlist_add_number(nvl, "fd", qp->s);
+ nvlist_add_number(nvl, "rxpda", qp->rxpda);
+ nvlist_add_number(nvl, "txpda", qp->txpda);
+ nvlist_add_bool(nvl, "header_digests", qp->header_digests);
+ nvlist_add_bool(nvl, "data_digests", qp->data_digests);
+ nvlist_add_number(nvl, "maxr2t", qp->maxr2t);
+ nvlist_add_number(nvl, "maxh2cdata", qp->maxh2cdata);
+ nvlist_add_number(nvl, "max_icd", qp->max_icd);
+}
+
+static int
+tcp_populate_dle(struct nvmf_qpair *nq, struct nvme_discovery_log_entry *dle)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nq);
+ struct sockaddr_storage ss;
+ socklen_t ss_len;
+
+ ss_len = sizeof(ss);
+ if (getpeername(qp->s, (struct sockaddr *)&ss, &ss_len) == -1)
+ return (errno);
+
+ if (getnameinfo((struct sockaddr *)&ss, ss_len, dle->traddr,
+ sizeof(dle->traddr), dle->trsvcid, sizeof(dle->trsvcid),
+ NI_NUMERICHOST | NI_NUMERICSERV) != 0)
+ return (EINVAL);
+
+ return (0);
+}
+
+static struct nvmf_capsule *
+tcp_allocate_capsule(struct nvmf_qpair *qp __unused)
+{
+ struct nvmf_tcp_capsule *nc;
+
+ nc = calloc(1, sizeof(*nc));
+ return (&nc->nc);
+}
+
+static void
+tcp_free_capsule(struct nvmf_capsule *nc)
+{
+ struct nvmf_tcp_capsule *tc = TCAP(nc);
+
+ nvmf_tcp_free_pdu(&tc->rx_pdu);
+ if (tc->cb != NULL)
+ tcp_free_command_buffer(tc->cb);
+ free(tc);
+}
+
+static int
+tcp_transmit_command(struct nvmf_capsule *nc)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nc->nc_qpair);
+ struct nvmf_tcp_capsule *tc = TCAP(nc);
+ struct nvme_tcp_cmd cmd;
+ struct nvme_sgl_descriptor *sgl;
+ int error;
+ bool use_icd;
+
+ use_icd = false;
+ if (nc->nc_data_len != 0 && nc->nc_send_data &&
+ nc->nc_data_len <= qp->max_icd)
+ use_icd = true;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.common.pdu_type = NVME_TCP_PDU_TYPE_CAPSULE_CMD;
+ cmd.ccsqe = nc->nc_sqe;
+
+ /* Populate SGL in SQE. */
+ sgl = &cmd.ccsqe.sgl;
+ memset(sgl, 0, sizeof(*sgl));
+ sgl->address = 0;
+ sgl->length = htole32(nc->nc_data_len);
+ if (use_icd) {
+ /* Use in-capsule data. */
+ sgl->type = NVME_SGL_TYPE_ICD;
+ } else {
+ /* Use a command buffer. */
+ sgl->type = NVME_SGL_TYPE_COMMAND_BUFFER;
+ }
+
+ /* Send command capsule. */
+ error = nvmf_tcp_construct_pdu(qp, &cmd, sizeof(cmd), use_icd ?
+ nc->nc_data : NULL, use_icd ? nc->nc_data_len : 0);
+ if (error != 0)
+ return (error);
+
+ /*
+ * If data will be transferred using a command buffer, allocate a
+ * buffer structure and queue it.
+ */
+ if (nc->nc_data_len != 0 && !use_icd)
+ tc->cb = tcp_alloc_command_buffer(qp, nc->nc_data, 0,
+ nc->nc_data_len, cmd.ccsqe.cid, 0, !nc->nc_send_data);
+
+ return (0);
+}
+
+static int
+tcp_transmit_response(struct nvmf_capsule *nc)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nc->nc_qpair);
+ struct nvme_tcp_rsp rsp;
+
+ memset(&rsp, 0, sizeof(rsp));
+ rsp.common.pdu_type = NVME_TCP_PDU_TYPE_CAPSULE_RESP;
+ rsp.rccqe = nc->nc_cqe;
+
+ return (nvmf_tcp_construct_pdu(qp, &rsp, sizeof(rsp), NULL, 0));
+}
+
+static int
+tcp_transmit_capsule(struct nvmf_capsule *nc)
+{
+ if (nc->nc_qe_len == sizeof(struct nvme_command))
+ return (tcp_transmit_command(nc));
+ else
+ return (tcp_transmit_response(nc));
+}
+
+static int
+tcp_receive_capsule(struct nvmf_qpair *nq, struct nvmf_capsule **ncp)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nq);
+ struct nvmf_tcp_capsule *tc;
+ int error;
+
+ while (TAILQ_EMPTY(&qp->rx_capsules)) {
+ error = nvmf_tcp_receive_pdu(qp);
+ if (error != 0)
+ return (error);
+ }
+ tc = TAILQ_FIRST(&qp->rx_capsules);
+ TAILQ_REMOVE(&qp->rx_capsules, tc, link);
+ *ncp = &tc->nc;
+ return (0);
+}
+
+static uint8_t
+tcp_validate_command_capsule(const struct nvmf_capsule *nc)
+{
+ const struct nvmf_tcp_capsule *tc = CTCAP(nc);
+ const struct nvme_sgl_descriptor *sgl;
+
+ assert(tc->rx_pdu.hdr != NULL);
+
+ sgl = &nc->nc_sqe.sgl;
+ switch (sgl->type) {
+ case NVME_SGL_TYPE_ICD:
+ if (tc->rx_pdu.data_len != le32toh(sgl->length)) {
+ printf("NVMe/TCP: Command Capsule with mismatched ICD length\n");
+ return (NVME_SC_DATA_SGL_LENGTH_INVALID);
+ }
+ break;
+ case NVME_SGL_TYPE_COMMAND_BUFFER:
+ if (tc->rx_pdu.data_len != 0) {
+ printf("NVMe/TCP: Command Buffer SGL with ICD\n");
+ return (NVME_SC_INVALID_FIELD);
+ }
+ break;
+ default:
+ printf("NVMe/TCP: Invalid SGL type in Command Capsule\n");
+ return (NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID);
+ }
+
+ if (sgl->address != 0) {
+ printf("NVMe/TCP: Invalid SGL offset in Command Capsule\n");
+ return (NVME_SC_SGL_OFFSET_INVALID);
+ }
+
+ return (NVME_SC_SUCCESS);
+}
+
+static size_t
+tcp_capsule_data_len(const struct nvmf_capsule *nc)
+{
+ assert(nc->nc_qe_len == sizeof(struct nvme_command));
+ return (le32toh(nc->nc_sqe.sgl.length));
+}
+
+/* NB: cid and ttag are both little-endian already. */
+static int
+tcp_send_r2t(struct nvmf_tcp_qpair *qp, uint16_t cid, uint16_t ttag,
+ uint32_t data_offset, uint32_t data_len)
+{
+ struct nvme_tcp_r2t_hdr r2t;
+
+ memset(&r2t, 0, sizeof(r2t));
+ r2t.common.pdu_type = NVME_TCP_PDU_TYPE_R2T;
+ r2t.cccid = cid;
+ r2t.ttag = ttag;
+ r2t.r2to = htole32(data_offset);
+ r2t.r2tl = htole32(data_len);
+
+ return (nvmf_tcp_construct_pdu(qp, &r2t, sizeof(r2t), NULL, 0));
+}
+
+static int
+tcp_receive_r2t_data(const struct nvmf_capsule *nc, uint32_t data_offset,
+ void *buf, size_t len)
+{
+ struct nvmf_tcp_qpair *qp = TQP(nc->nc_qpair);
+ struct nvmf_tcp_command_buffer *cb;
+ int error;
+ uint16_t ttag;
+
+ /*
+ * Don't bother byte-swapping ttag as it is just a cookie
+ * value returned by the other end as-is.
+ */
+ ttag = qp->next_ttag++;
+
+ error = tcp_send_r2t(qp, nc->nc_sqe.cid, ttag, data_offset, len);
+ if (error != 0)
+ return (error);
+
+ cb = tcp_alloc_command_buffer(qp, buf, data_offset, len,
+ nc->nc_sqe.cid, ttag, true);
+
+ /* Parse received PDUs until the data transfer is complete. */
+ while (cb->data_xfered < cb->data_len) {
+ error = nvmf_tcp_receive_pdu(qp);
+ if (error != 0)
+ break;
+ }
+ tcp_free_command_buffer(cb);
+ return (error);
+}
+
+static int
+tcp_receive_icd_data(const struct nvmf_capsule *nc, uint32_t data_offset,
+ void *buf, size_t len)
+{
+ const struct nvmf_tcp_capsule *tc = CTCAP(nc);
+ const char *icd;
+
+ icd = (const char *)tc->rx_pdu.hdr + tc->rx_pdu.hdr->pdo + data_offset;
+ memcpy(buf, icd, len);
+ return (0);
+}
+
+static int
+tcp_receive_controller_data(const struct nvmf_capsule *nc, uint32_t data_offset,
+ void *buf, size_t len)
+{
+ struct nvmf_association *na = nc->nc_qpair->nq_association;
+ const struct nvme_sgl_descriptor *sgl;
+ size_t data_len;
+
+ if (nc->nc_qe_len != sizeof(struct nvme_command) || !na->na_controller)
+ return (EINVAL);
+
+ sgl = &nc->nc_sqe.sgl;
+ data_len = le32toh(sgl->length);
+ if (data_offset + len > data_len)
+ return (EFBIG);
+
+ if (sgl->type == NVME_SGL_TYPE_ICD)
+ return (tcp_receive_icd_data(nc, data_offset, buf, len));
+ else
+ return (tcp_receive_r2t_data(nc, data_offset, buf, len));
+}
+
+/* NB: cid is little-endian already. */
+static int
+tcp_send_c2h_pdu(struct nvmf_tcp_qpair *qp, uint16_t cid,
+ uint32_t data_offset, const void *buf, size_t len, bool last_pdu,
+ bool success)
+{
+ struct nvme_tcp_c2h_data_hdr c2h;
+
+ memset(&c2h, 0, sizeof(c2h));
+ c2h.common.pdu_type = NVME_TCP_PDU_TYPE_C2H_DATA;
+ if (last_pdu)
+ c2h.common.flags |= NVME_TCP_C2H_DATA_FLAGS_LAST_PDU;
+ if (success)
+ c2h.common.flags |= NVME_TCP_C2H_DATA_FLAGS_SUCCESS;
+ c2h.cccid = cid;
+ c2h.datao = htole32(data_offset);
+ c2h.datal = htole32(len);
+
+ return (nvmf_tcp_construct_pdu(qp, &c2h, sizeof(c2h),
+ __DECONST(void *, buf), len));
+}
+
+static int
+tcp_send_controller_data(const struct nvmf_capsule *nc, const void *buf,
+ size_t len)
+{
+ struct nvmf_association *na = nc->nc_qpair->nq_association;
+ struct nvmf_tcp_qpair *qp = TQP(nc->nc_qpair);
+ const struct nvme_sgl_descriptor *sgl;
+ const char *src;
+ size_t todo;
+ uint32_t data_len, data_offset;
+ int error;
+ bool last_pdu, send_success_flag;
+
+ if (nc->nc_qe_len != sizeof(struct nvme_command) || !na->na_controller)
+ return (EINVAL);
+
+ sgl = &nc->nc_sqe.sgl;
+ data_len = le32toh(sgl->length);
+ if (len != data_len) {
+ nvmf_send_generic_error(nc, NVME_SC_INVALID_FIELD);
+ return (EFBIG);
+ }
+
+ if (sgl->type != NVME_SGL_TYPE_COMMAND_BUFFER) {
+ nvmf_send_generic_error(nc, NVME_SC_INVALID_FIELD);
+ return (EINVAL);
+ }
+
+ /* Use the SUCCESS flag if SQ flow control is disabled. */
+ send_success_flag = !qp->qp.nq_flow_control;
+
+ /*
+ * Write out one or more C2H_DATA PDUs containing the data.
+ * Each PDU is arbitrarily capped at 256k.
+ */
+ data_offset = 0;
+ src = buf;
+ while (len > 0) {
+ if (len > 256 * 1024) {
+ todo = 256 * 1024;
+ last_pdu = false;
+ } else {
+ todo = len;
+ last_pdu = true;
+ }
+ error = tcp_send_c2h_pdu(qp, nc->nc_sqe.cid, data_offset,
+ src, todo, last_pdu, last_pdu && send_success_flag);
+ if (error != 0) {
+ nvmf_send_generic_error(nc,
+ NVME_SC_TRANSIENT_TRANSPORT_ERROR);
+ return (error);
+ }
+ data_offset += todo;
+ src += todo;
+ len -= todo;
+ }
+ if (!send_success_flag)
+ nvmf_send_success(nc);
+ return (0);
+}
+
+struct nvmf_transport_ops tcp_ops = {
+ .allocate_association = tcp_allocate_association,
+ .update_association = tcp_update_association,
+ .free_association = tcp_free_association,
+ .allocate_qpair = tcp_allocate_qpair,
+ .free_qpair = tcp_free_qpair,
+ .kernel_handoff_params = tcp_kernel_handoff_params,
+ .populate_dle = tcp_populate_dle,
+ .allocate_capsule = tcp_allocate_capsule,
+ .free_capsule = tcp_free_capsule,
+ .transmit_capsule = tcp_transmit_capsule,
+ .receive_capsule = tcp_receive_capsule,
+ .validate_command_capsule = tcp_validate_command_capsule,
+ .capsule_data_len = tcp_capsule_data_len,
+ .receive_controller_data = tcp_receive_controller_data,
+ .send_controller_data = tcp_send_controller_data,
+};
diff --git a/lib/libnvmf/nvmf_transport.c b/lib/libnvmf/nvmf_transport.c
new file mode 100644
index 000000000000..b105c17d2efb
--- /dev/null
+++ b/lib/libnvmf/nvmf_transport.c
@@ -0,0 +1,307 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022-2024 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <sys/refcount.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "libnvmf.h"
+#include "internal.h"
+
+struct nvmf_association *
+nvmf_allocate_association(enum nvmf_trtype trtype, bool controller,
+ const struct nvmf_association_params *params)
+{
+ struct nvmf_transport_ops *ops;
+ struct nvmf_association *na;
+
+ switch (trtype) {
+ case NVMF_TRTYPE_TCP:
+ ops = &tcp_ops;
+ break;
+ default:
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ na = ops->allocate_association(controller, params);
+ if (na == NULL)
+ return (NULL);
+
+ na->na_ops = ops;
+ na->na_trtype = trtype;
+ na->na_controller = controller;
+ na->na_params = *params;
+ na->na_last_error = NULL;
+ refcount_init(&na->na_refs, 1);
+ return (na);
+}
+
+void
+nvmf_update_assocation(struct nvmf_association *na,
+ const struct nvme_controller_data *cdata)
+{
+ na->na_ops->update_association(na, cdata);
+}
+
+void
+nvmf_free_association(struct nvmf_association *na)
+{
+ if (refcount_release(&na->na_refs)) {
+ free(na->na_last_error);
+ na->na_ops->free_association(na);
+ }
+}
+
+const char *
+nvmf_association_error(const struct nvmf_association *na)
+{
+ return (na->na_last_error);
+}
+
+void
+na_clear_error(struct nvmf_association *na)
+{
+ free(na->na_last_error);
+ na->na_last_error = NULL;
+}
+
+void
+na_error(struct nvmf_association *na, const char *fmt, ...)
+{
+ va_list ap;
+ char *str;
+
+ if (na->na_last_error != NULL)
+ return;
+ va_start(ap, fmt);
+ vasprintf(&str, fmt, ap);
+ va_end(ap);
+ na->na_last_error = str;
+}
+
+struct nvmf_qpair *
+nvmf_allocate_qpair(struct nvmf_association *na,
+ const struct nvmf_qpair_params *params)
+{
+ struct nvmf_qpair *qp;
+
+ na_clear_error(na);
+ qp = na->na_ops->allocate_qpair(na, params);
+ if (qp == NULL)
+ return (NULL);
+
+ refcount_acquire(&na->na_refs);
+ qp->nq_association = na;
+ qp->nq_admin = params->admin;
+ TAILQ_INIT(&qp->nq_rx_capsules);
+ return (qp);
+}
+
+void
+nvmf_free_qpair(struct nvmf_qpair *qp)
+{
+ struct nvmf_association *na;
+ struct nvmf_capsule *nc, *tc;
+
+ TAILQ_FOREACH_SAFE(nc, &qp->nq_rx_capsules, nc_link, tc) {
+ TAILQ_REMOVE(&qp->nq_rx_capsules, nc, nc_link);
+ nvmf_free_capsule(nc);
+ }
+ na = qp->nq_association;
+ na->na_ops->free_qpair(qp);
+ nvmf_free_association(na);
+}
+
+struct nvmf_capsule *
+nvmf_allocate_command(struct nvmf_qpair *qp, const void *sqe)
+{
+ struct nvmf_capsule *nc;
+
+ nc = qp->nq_association->na_ops->allocate_capsule(qp);
+ if (nc == NULL)
+ return (NULL);
+
+ nc->nc_qpair = qp;
+ nc->nc_qe_len = sizeof(struct nvme_command);
+ memcpy(&nc->nc_sqe, sqe, nc->nc_qe_len);
+
+ /* 4.2 of NVMe base spec: Fabrics always uses SGL. */
+ nc->nc_sqe.fuse &= ~NVMEM(NVME_CMD_PSDT);
+ nc->nc_sqe.fuse |= NVMEF(NVME_CMD_PSDT, NVME_PSDT_SGL);
+ return (nc);
+}
+
+struct nvmf_capsule *
+nvmf_allocate_response(struct nvmf_qpair *qp, const void *cqe)
+{
+ struct nvmf_capsule *nc;
+
+ nc = qp->nq_association->na_ops->allocate_capsule(qp);
+ if (nc == NULL)
+ return (NULL);
+
+ nc->nc_qpair = qp;
+ nc->nc_qe_len = sizeof(struct nvme_completion);
+ memcpy(&nc->nc_cqe, cqe, nc->nc_qe_len);
+ return (nc);
+}
+
+int
+nvmf_capsule_append_data(struct nvmf_capsule *nc, void *buf, size_t len,
+ bool send)
+{
+ if (nc->nc_qe_len == sizeof(struct nvme_completion))
+ return (EINVAL);
+ if (nc->nc_data_len != 0)
+ return (EBUSY);
+
+ nc->nc_data = buf;
+ nc->nc_data_len = len;
+ nc->nc_send_data = send;
+ return (0);
+}
+
+void
+nvmf_free_capsule(struct nvmf_capsule *nc)
+{
+ nc->nc_qpair->nq_association->na_ops->free_capsule(nc);
+}
+
+int
+nvmf_transmit_capsule(struct nvmf_capsule *nc)
+{
+ return (nc->nc_qpair->nq_association->na_ops->transmit_capsule(nc));
+}
+
+int
+nvmf_receive_capsule(struct nvmf_qpair *qp, struct nvmf_capsule **ncp)
+{
+ return (qp->nq_association->na_ops->receive_capsule(qp, ncp));
+}
+
+const void *
+nvmf_capsule_sqe(const struct nvmf_capsule *nc)
+{
+ assert(nc->nc_qe_len == sizeof(struct nvme_command));
+ return (&nc->nc_sqe);
+}
+
+const void *
+nvmf_capsule_cqe(const struct nvmf_capsule *nc)
+{
+ assert(nc->nc_qe_len == sizeof(struct nvme_completion));
+ return (&nc->nc_cqe);
+}
+
+uint8_t
+nvmf_validate_command_capsule(const struct nvmf_capsule *nc)
+{
+ assert(nc->nc_qe_len == sizeof(struct nvme_command));
+
+ if (NVMEV(NVME_CMD_PSDT, nc->nc_sqe.fuse) != NVME_PSDT_SGL)
+ return (NVME_SC_INVALID_FIELD);
+
+ return (nc->nc_qpair->nq_association->na_ops->validate_command_capsule(nc));
+}
+
+size_t
+nvmf_capsule_data_len(const struct nvmf_capsule *nc)
+{
+ return (nc->nc_qpair->nq_association->na_ops->capsule_data_len(nc));
+}
+
+int
+nvmf_receive_controller_data(const struct nvmf_capsule *nc,
+ uint32_t data_offset, void *buf, size_t len)
+{
+ return (nc->nc_qpair->nq_association->na_ops->receive_controller_data(nc,
+ data_offset, buf, len));
+}
+
+int
+nvmf_send_controller_data(const struct nvmf_capsule *nc, const void *buf,
+ size_t len)
+{
+ return (nc->nc_qpair->nq_association->na_ops->send_controller_data(nc,
+ buf, len));
+}
+
+int
+nvmf_kernel_handoff_params(struct nvmf_qpair *qp, nvlist_t **nvlp)
+{
+ nvlist_t *nvl;
+ int error;
+
+ nvl = nvlist_create(0);
+ nvlist_add_bool(nvl, "admin", qp->nq_admin);
+ nvlist_add_bool(nvl, "sq_flow_control", qp->nq_flow_control);
+ nvlist_add_number(nvl, "qsize", qp->nq_qsize);
+ nvlist_add_number(nvl, "sqhd", qp->nq_sqhd);
+ if (!qp->nq_association->na_controller)
+ nvlist_add_number(nvl, "sqtail", qp->nq_sqtail);
+ qp->nq_association->na_ops->kernel_handoff_params(qp, nvl);
+ error = nvlist_error(nvl);
+ if (error != 0) {
+ nvlist_destroy(nvl);
+ return (error);
+ }
+
+ *nvlp = nvl;
+ return (0);
+}
+
+int
+nvmf_populate_dle(struct nvmf_qpair *qp, struct nvme_discovery_log_entry *dle)
+{
+ struct nvmf_association *na = qp->nq_association;
+
+ dle->trtype = na->na_trtype;
+ return (na->na_ops->populate_dle(qp, dle));
+}
+
+const char *
+nvmf_transport_type(uint8_t trtype)
+{
+ static _Thread_local char buf[8];
+
+ switch (trtype) {
+ case NVMF_TRTYPE_RDMA:
+ return ("RDMA");
+ case NVMF_TRTYPE_FC:
+ return ("Fibre Channel");
+ case NVMF_TRTYPE_TCP:
+ return ("TCP");
+ case NVMF_TRTYPE_INTRA_HOST:
+ return ("Intra-host");
+ default:
+ snprintf(buf, sizeof(buf), "0x%02x\n", trtype);
+ return (buf);
+ }
+}
+
+int
+nvmf_pack_ioc_nvlist(struct nvmf_ioc_nv *nv, nvlist_t *nvl)
+{
+ int error;
+
+ memset(nv, 0, sizeof(*nv));
+
+ error = nvlist_error(nvl);
+ if (error)
+ return (error);
+
+ nv->data = nvlist_pack(nvl, &nv->size);
+ if (nv->data == NULL)
+ return (ENOMEM);
+
+ return (0);
+}
diff --git a/lib/libomp/Makefile b/lib/libomp/Makefile
index f2ca913e43f3..6c14c7d21077 100644
--- a/lib/libomp/Makefile
+++ b/lib/libomp/Makefile
@@ -1,3 +1,5 @@
+# z_Linux_asm.S is missing BTI support
+MK_BRANCH_PROTECTION=no
.include <bsd.compiler.mk>
@@ -55,14 +57,29 @@ CFLAGS+= -fdata-sections
CXXFLAGS+= -fvisibility-inlines-hidden
CXXFLAGS+= -fno-exceptions
CXXFLAGS+= -fno-rtti
-CXXSTD= c++11
+CXXSTD= c++17
-.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 90000
+.if ${COMPILER_TYPE} == "clang"
+.if ${MACHINE_CPUARCH} == "i386"
+.if ${COMPILER_VERSION} >= 90000
# When targeting i386, clang 9.0.0 produces a new warning about large atomic
# operations "possibly incurring significant performance penalties", but there
# is not much we can do about it.
CWARNFLAGS+= -Wno-atomic-alignment
.endif
+.if ${COMPILER_VERSION} >= 170000
+# When targeting i386, clang 17.0.0 produces a new warning that __sync
+# builtin operations must have natural alignment, but there is not much we
+# can do about it.
+CWARNFLAGS+= -Wno-sync-alignment
+.endif # COMPILER_VERSION >= 170000
+.endif # MACHINE_CPUARCH == i386
+.if ${COMPILER_VERSION} >= 180000
+# clang 18.0.0 introduces a new warning about variable length arrays in C++,
+# which OpenMP makes use of in several sources.
+CXXWARNFLAGS+= -Wno-vla-cxx-extension
+.endif # COMPILER_VERSION >= 180000
+.endif # COMPILER_TYPE == clang
LDFLAGS+= -Wl,--warn-shared-textrel
LDFLAGS+= -Wl,--gc-sections
diff --git a/lib/libomp/kmp_config.h b/lib/libomp/kmp_config.h
index 7d11e27cc4b1..9caf4b8cdf44 100644
--- a/lib/libomp/kmp_config.h
+++ b/lib/libomp/kmp_config.h
@@ -46,6 +46,8 @@
#define OMPT_SUPPORT LIBOMP_OMPT_SUPPORT
#define LIBOMP_OMPD_SUPPORT 0
#define OMPD_SUPPORT LIBOMP_OMPD_SUPPORT
+#define LIBOMP_OMPX_TASKGRAPH 0
+#define OMPX_TASKGRAPH LIBOMP_OMPX_TASKGRAPH
#define LIBOMP_PROFILING_SUPPORT 0
#define OMP_PROFILING_SUPPORT LIBOMP_PROFILING_SUPPORT
#define LIBOMP_OMPT_OPTIONAL 1
@@ -142,12 +144,16 @@
#define KMP_HAVE_POSIX_MEMALIGN LIBOMP_HAVE_POSIX_MEMALIGN
#define LIBOMP_HAVE__ALIGNED_MALLOC 0
#define KMP_HAVE__ALIGNED_MALLOC LIBOMP_HAVE__ALIGNED_MALLOC
+#define OPENMP_ENABLE_LIBOMPTARGET 0
+#define ENABLE_LIBOMPTARGET OPENMP_ENABLE_LIBOMPTARGET
// Configured cache line based on architecture
-#if KMP_ARCH_PPC64
+#if KMP_ARCH_PPC64 || KMP_ARCH_PPC
# define CACHE_LINE 128
#elif KMP_ARCH_AARCH64_A64FX
# define CACHE_LINE 256
+#elif KMP_ARCH_S390X
+# define CACHE_LINE 256
#else
# define CACHE_LINE 64
#endif
diff --git a/lib/libomp/kmp_i18n_default.inc b/lib/libomp/kmp_i18n_default.inc
index 3751a31cf3bb..a59def0a8560 100644
--- a/lib/libomp/kmp_i18n_default.inc
+++ b/lib/libomp/kmp_i18n_default.inc
@@ -1,5 +1,5 @@
// Do not edit this file! //
-// The file was generated from en_US.txt by message-converter.pl on Tue Apr 11 20:59:17 2023. //
+// The file was generated from en_US.txt by message-converter.py on Sat Jul 27 14:17:03 2024. //
static char const *
__kmp_i18n_default_meta[] =
@@ -414,6 +414,9 @@ __kmp_i18n_default_messages[] =
"KMP_HW_SUBSET ignored: all hardware resources would be filtered, please reduce the filter.",
"KMP_HW_SUBSET ignored: Too many attributes specified. This machine is not a hybrid architecutre.",
"KMP_HW_SUBSET: ignoring %1$s attribute. This machine is not a hybrid architecutre.",
+ "Target memory not available, will use default allocator.",
+ "%1$s ignored: This machine is not a hybrid architecutre. Using \"%2$s\" instead.",
+ "%1$s ignored: %2$s is not available. Using \"%3$s\" instead.",
NULL
};
@@ -421,7 +424,7 @@ static char const *
__kmp_i18n_default_hints[] =
{
NULL,
- "Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see https://bugs.llvm.org/.",
+ "Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see https://github.com/llvm/llvm-project/issues/.",
"Check NLSPATH environment variable, its value is \"%1$s\".",
"Please try changing the shell stack limit or adjusting the OMP_STACKSIZE environment variable.",
"Consider unsetting KMP_DEVICE_THREAD_LIMIT (KMP_ALL_THREADS), KMP_TEAMS_THREAD_LIMIT, and OMP_THREAD_LIMIT (if any are set).",
@@ -466,7 +469,7 @@ __kmp_i18n_sections[] =
{ 5, __kmp_i18n_default_meta },
{ 79, __kmp_i18n_default_strings },
{ 6, __kmp_i18n_default_formats },
- { 298, __kmp_i18n_default_messages },
+ { 301, __kmp_i18n_default_messages },
{ 29, __kmp_i18n_default_hints },
{ 0, NULL }
};
diff --git a/lib/libomp/kmp_i18n_id.inc b/lib/libomp/kmp_i18n_id.inc
index e220b4f75586..027bbe24d970 100644
--- a/lib/libomp/kmp_i18n_id.inc
+++ b/lib/libomp/kmp_i18n_id.inc
@@ -1,5 +1,5 @@
// Do not edit this file! //
-// The file was generated from en_US.txt by message-converter.pl on Tue Apr 11 20:59:17 2023. //
+// The file was generated from en_US.txt by message-converter.py on Sat Jul 27 14:17:03 2024. //
enum kmp_i18n_id {
@@ -408,6 +408,9 @@ enum kmp_i18n_id {
kmp_i18n_msg_AffHWSubsetAllFiltered,
kmp_i18n_msg_AffHWSubsetAttrsNonHybrid,
kmp_i18n_msg_AffHWSubsetIgnoringAttr,
+ kmp_i18n_msg_TargetMemNotAvailable,
+ kmp_i18n_msg_AffIgnoringNonHybrid,
+ kmp_i18n_msg_AffIgnoringNotAvailable,
kmp_i18n_msg_last,
// Set #5, hints.
diff --git a/lib/libomp/omp-tools.h b/lib/libomp/omp-tools.h
index 53defaa5d09e..471f46a9073e 100644
--- a/lib/libomp/omp-tools.h
+++ b/lib/libomp/omp-tools.h
@@ -78,6 +78,8 @@
/* implicit barrier at the end of worksharing */ \
macro (ompt_state_wait_barrier_implicit, 0x013) /* implicit barrier */ \
macro (ompt_state_wait_barrier_explicit, 0x014) /* explicit barrier */ \
+ macro (ompt_state_wait_barrier_implementation, 0x015) /* implementation barrier */ \
+ macro (ompt_state_wait_barrier_teams, 0x016) /* teams barrier */ \
\
/* task wait states (32..63) */ \
macro (ompt_state_wait_taskwait, 0x020) /* waiting at a taskwait */ \
@@ -211,6 +213,10 @@ typedef enum kmp_mutex_impl_t {
* definitions generated from spec
*****************************************************************************/
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
typedef enum ompt_callbacks_t {
ompt_callback_thread_begin = 1,
ompt_callback_thread_end = 2,
@@ -413,13 +419,15 @@ typedef enum ompt_target_map_flag_t {
} ompt_target_map_flag_t;
typedef enum ompt_dependence_type_t {
- ompt_dependence_type_in = 1,
- ompt_dependence_type_out = 2,
- ompt_dependence_type_inout = 3,
- ompt_dependence_type_mutexinoutset = 4,
- ompt_dependence_type_source = 5,
- ompt_dependence_type_sink = 6,
- ompt_dependence_type_inoutset = 7
+ ompt_dependence_type_in = 1,
+ ompt_dependence_type_out = 2,
+ ompt_dependence_type_inout = 3,
+ ompt_dependence_type_mutexinoutset = 4,
+ ompt_dependence_type_source = 5,
+ ompt_dependence_type_sink = 6,
+ ompt_dependence_type_inoutset = 7,
+ ompt_dependence_type_out_all_memory = 34,
+ ompt_dependence_type_inout_all_memory = 35
} ompt_dependence_type_t;
typedef enum ompt_severity_t {
@@ -1402,6 +1410,14 @@ typedef ompt_record_ompt_t *(*ompt_get_record_ompt_t) (
ompt_buffer_cursor_t current
);
+#ifdef _WIN32
+__declspec(dllexport)
+#else
+__attribute__((visibility("default")))
+#endif
+ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
+ const char *runtime_version);
+
#define ompt_id_none 0
#define ompt_data_none {0}
#define ompt_time_none 0
@@ -1412,4 +1428,8 @@ typedef ompt_record_ompt_t *(*ompt_get_record_ompt_t) (
#define ompd_segment_none 0
+#if defined(__cplusplus)
+} // extern "C"
+#endif
+
#endif /* __OMPT__ */
diff --git a/lib/libomp/omp.h b/lib/libomp/omp.h
index 618e09de86de..493e0e86e8dc 100644
--- a/lib/libomp/omp.h
+++ b/lib/libomp/omp.h
@@ -15,6 +15,7 @@
#ifndef __OMP_H
# define __OMP_H
+# include <stddef.h>
# include <stdlib.h>
# include <stdint.h>
@@ -155,6 +156,8 @@
/* OpenMP 5.1 interop */
typedef intptr_t omp_intptr_t;
+ extern void __KAI_KMPC_CONVENTION ompx_dump_mapping_tables(void);
+
/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined properties */
typedef enum omp_interop_property {
omp_ipr_fr_id = -1,
@@ -236,6 +239,11 @@
extern int __KAI_KMPC_CONVENTION omp_target_memcpy_rect_async(void *, const void *, size_t, int, const size_t *,
const size_t *, const size_t *, const size_t *, const size_t *, int, int,
int, omp_depend_t *);
+
+ /* OpenMP 6.0 device memory routines */
+ extern void * __KAI_KMPC_CONVENTION omp_target_memset(void *, int, size_t, int);
+ extern void * __KAI_KMPC_CONVENTION omp_target_memset_async(void *, int, size_t, int, int, omp_depend_t *);
+
/*!
* The `omp_get_mapped_ptr` routine returns the device pointer that is associated with a host pointer for a given device.
*/
@@ -497,7 +505,7 @@
extern int __KAI_KMPC_CONVENTION omp_in_explicit_task(void);
/* LLVM Extensions */
- extern void *llvm_omp_target_dynamic_shared_alloc();
+ extern void *llvm_omp_target_dynamic_shared_alloc(void);
# undef __KAI_KMPC_CONVENTION
# undef __KMP_IMP
diff --git a/lib/libopenbsd/Makefile b/lib/libopenbsd/Makefile
index 24fd62e58873..dca1c08b0aed 100644
--- a/lib/libopenbsd/Makefile
+++ b/lib/libopenbsd/Makefile
@@ -1,9 +1,9 @@
-
PACKAGE=lib${LIB}
LIB= openbsd
SRCS= imsg-buffer.c \
imsg.c \
- ohash.c
+ ohash.c \
+ recallocarray.c
.if !defined(BOOTSTRAPPING)
# Skip getdtablecount.c when bootstrapping since it doesn't compile for Linux
# and is not used by any of the bootstrap tools
diff --git a/lib/libopenbsd/getdtablecount.c b/lib/libopenbsd/getdtablecount.c
index 53ed49342062..96dc58274c05 100644
--- a/lib/libopenbsd/getdtablecount.c
+++ b/lib/libopenbsd/getdtablecount.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <stddef.h>
diff --git a/lib/libopenbsd/recallocarray.c b/lib/libopenbsd/recallocarray.c
new file mode 100644
index 000000000000..11e1fda744c7
--- /dev/null
+++ b/lib/libopenbsd/recallocarray.c
@@ -0,0 +1,82 @@
+/* $OpenBSD: recallocarray.c,v 1.1 2017/03/06 18:44:21 otto Exp $ */
+/*
+ * Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
+
+void *recallocarray(void *, size_t, size_t, size_t);
+
+void *
+recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size)
+{
+ size_t oldsize, newsize;
+ void *newptr;
+
+ if (ptr == NULL)
+ return calloc(newnmemb, size);
+
+ if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ newnmemb > 0 && SIZE_MAX / newnmemb < size) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ newsize = newnmemb * size;
+
+ if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ oldnmemb > 0 && SIZE_MAX / oldnmemb < size) {
+ errno = EINVAL;
+ return NULL;
+ }
+ oldsize = oldnmemb * size;
+
+ /*
+ * Don't bother too much if we're shrinking just a bit,
+ * we do not shrink for series of small steps, oh well.
+ */
+ if (newsize <= oldsize) {
+ size_t d = oldsize - newsize;
+
+ if (d < oldsize / 2 && d < (size_t)getpagesize()) {
+ memset((char *)ptr + newsize, 0, d);
+ return ptr;
+ }
+ }
+
+ newptr = malloc(newsize);
+ if (newptr == NULL)
+ return NULL;
+
+ if (newsize > oldsize) {
+ memcpy(newptr, ptr, oldsize);
+ memset((char *)newptr + oldsize, 0, newsize - oldsize);
+ } else
+ memcpy(newptr, ptr, newsize);
+
+ explicit_bzero(ptr, oldsize);
+ free(ptr);
+
+ return newptr;
+}
diff --git a/lib/libopencsd/Makefile b/lib/libopencsd/Makefile
index d6d648ef1e32..b37a864f7cbb 100644
--- a/lib/libopencsd/Makefile
+++ b/lib/libopencsd/Makefile
@@ -1,9 +1,3 @@
-
-PACKAGE=lib${LIB}
-SHLIBDIR?= /lib
-
-.include <src.opts.mk>
-
OPENCSDSRC= ${SRCTOP}/contrib/opencsd
.PATH: ${OPENCSDSRC}/decoder/source/ete/ \
@@ -122,7 +116,7 @@ APIINCS= \
ocsd_c_api_types.h \
opencsd_c_api.h
-APIINCSDIR=${INCLUDEDIR}/opencsd/c_api/
+APIINCSDIR=${INCLUDEDIR}/opencsd/c_api
ETEINCS= \
ete_decoder.h \
@@ -130,7 +124,7 @@ ETEINCS= \
trc_dcd_mngr_ete.h \
trc_pkt_types_ete.h
-ETEINCSDIR=${INCLUDEDIR}/opencsd/ete/
+ETEINCSDIR=${INCLUDEDIR}/opencsd/ete
ETMV4INCS= \
etmv4_decoder.h \
@@ -143,7 +137,7 @@ ETMV4INCS= \
trc_pkt_proc_etmv4i.h \
trc_pkt_types_etmv4.h
-ETMV4INCSDIR=${INCLUDEDIR}/opencsd/etmv4/
+ETMV4INCSDIR=${INCLUDEDIR}/opencsd/etmv4
ETMV3INCS= \
etmv3_decoder.h \
@@ -154,7 +148,7 @@ ETMV3INCS= \
trc_pkt_proc_etmv3.h \
trc_pkt_types_etmv3.h
-ETMV3INCSDIR=${INCLUDEDIR}/opencsd/etmv3/
+ETMV3INCSDIR=${INCLUDEDIR}/opencsd/etmv3
PTMINCS= \
ptm_decoder.h \
@@ -165,7 +159,7 @@ PTMINCS= \
trc_pkt_proc_ptm.h \
trc_pkt_types_ptm.h
-PTMINCSDIR=${INCLUDEDIR}/opencsd/ptm/
+PTMINCSDIR=${INCLUDEDIR}/opencsd/ptm
STMINCS= \
stm_decoder.h \
@@ -176,13 +170,14 @@ STMINCS= \
trc_pkt_proc_stm.h \
trc_pkt_types_stm.h
-STMINCSDIR=${INCLUDEDIR}/opencsd/stm/
+STMINCSDIR=${INCLUDEDIR}/opencsd/stm
INCSGROUPS=INCS APIINCS ETEINCS ETMV3INCS ETMV4INCS PTMINCS STMINCS
LIBADD= cxxrt
WARNS?= 1
+PRIVATELIB= true
HAS_TESTS=
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
index f7108252b974..dd19eba5c1ec 100644
--- a/lib/libpam/libpam/Makefile
+++ b/lib/libpam/libpam/Makefile
@@ -44,8 +44,6 @@ SHLIB= pam
PACKAGE= runtime
-MK_PROFILE=no
-
SRCS= openpam_asprintf.c \
openpam_borrow_cred.c \
openpam_check_owner_perms.c \
@@ -155,6 +153,7 @@ MAN?= openpam.3 \
MLINKS?= pam.conf.5 pam.d.5
+CFLAGS+= -DLOCALBASE=\"${LOCALBASE:U/usr/local}\"
CFLAGS+= -I${OPENPAM}/include
CFLAGS+= -DLIB_MAJ=${SHLIB_MAJOR}
CFLAGS+= -DHAVE_DLFUNC=1
diff --git a/lib/libpam/modules/Makefile.inc b/lib/libpam/modules/Makefile.inc
index 955ee5224198..2e66aec64f07 100644
--- a/lib/libpam/modules/Makefile.inc
+++ b/lib/libpam/modules/Makefile.inc
@@ -1,8 +1,6 @@
-
PAMDIR= ${SRCTOP}/contrib/openpam
MK_INSTALLLIB= no
-MK_PROFILE= no
CFLAGS+= -I${PAMDIR}/include -I${SRCTOP}/lib/libpam
diff --git a/lib/libpam/modules/modules.inc b/lib/libpam/modules/modules.inc
index ddbb326f0312..f3ab65333f4f 100644
--- a/lib/libpam/modules/modules.inc
+++ b/lib/libpam/modules/modules.inc
@@ -30,3 +30,4 @@ MODULES += pam_ssh
.endif
MODULES += pam_tacplus
MODULES += pam_unix
+MODULES += pam_xdg \ No newline at end of file
diff --git a/lib/libpam/modules/pam_chroot/Makefile b/lib/libpam/modules/pam_chroot/Makefile
index ca4f3cc17443..206f8fa40a09 100644
--- a/lib/libpam/modules/pam_chroot/Makefile
+++ b/lib/libpam/modules/pam_chroot/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_chroot
SRCS= pam_chroot.c
MAN= pam_chroot.8
diff --git a/lib/libpam/modules/pam_chroot/pam_chroot.8 b/lib/libpam/modules/pam_chroot/pam_chroot.8
index e65c513b7b77..1f614264ba8e 100644
--- a/lib/libpam/modules/pam_chroot/pam_chroot.8
+++ b/lib/libpam/modules/pam_chroot/pam_chroot.8
@@ -78,8 +78,8 @@ Specify the chroot directory to use if one could not be derived from
the user's home directory.
.El
.Sh SEE ALSO
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_chroot/pam_chroot.c b/lib/libpam/modules/pam_chroot/pam_chroot.c
index 5cb38e2570b0..346be34683c1 100644
--- a/lib/libpam/modules/pam_chroot/pam_chroot.c
+++ b/lib/libpam/modules/pam_chroot/pam_chroot.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <pwd.h>
diff --git a/lib/libpam/modules/pam_deny/pam_deny.8 b/lib/libpam/modules/pam_deny/pam_deny.8
index 530bae05c1f3..5d70bde200d9 100644
--- a/lib/libpam/modules/pam_deny/pam_deny.8
+++ b/lib/libpam/modules/pam_deny/pam_deny.8
@@ -73,6 +73,6 @@ reasons why the user's
authentication attempt was declined.
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr syslog 3 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
diff --git a/lib/libpam/modules/pam_echo/Makefile b/lib/libpam/modules/pam_echo/Makefile
index 58aae0053be9..532d0a51b58e 100644
--- a/lib/libpam/modules/pam_echo/Makefile
+++ b/lib/libpam/modules/pam_echo/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_echo
SRCS= pam_echo.c
MAN= pam_echo.8
diff --git a/lib/libpam/modules/pam_echo/pam_echo.8 b/lib/libpam/modules/pam_echo/pam_echo.8
index c38d4d8cee55..19c083917bbf 100644
--- a/lib/libpam/modules/pam_echo/pam_echo.8
+++ b/lib/libpam/modules/pam_echo/pam_echo.8
@@ -77,8 +77,8 @@ expands to the character following the
.Cm %
character.
.Sh SEE ALSO
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_exec/Makefile b/lib/libpam/modules/pam_exec/Makefile
index 1902d10789b5..c2327a2860cd 100644
--- a/lib/libpam/modules/pam_exec/Makefile
+++ b/lib/libpam/modules/pam_exec/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_exec
SRCS= pam_exec.c
MAN= pam_exec.8
diff --git a/lib/libpam/modules/pam_exec/pam_exec.8 b/lib/libpam/modules/pam_exec/pam_exec.8
index c77162955730..be5666003557 100644
--- a/lib/libpam/modules/pam_exec/pam_exec.8
+++ b/lib/libpam/modules/pam_exec/pam_exec.8
@@ -148,15 +148,15 @@ Each valid codes numerical value is available as an environment variable
etc).
This is useful in shell scripts for instance.
.Sh SEE ALSO
-.Xr pam_get_item 3 ,
-.Xr pam.conf 5 ,
.Xr pam 3 ,
+.Xr pam_get_item 3 ,
.Xr pam_sm_acct_mgmt 3 ,
.Xr pam_sm_authenticate 3 ,
.Xr pam_sm_chauthtok 3 ,
.Xr pam_sm_close_session 3 ,
.Xr pam_sm_open_session 3 ,
-.Xr pam_sm_setcred 3
+.Xr pam_sm_setcred 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_exec/pam_exec.c b/lib/libpam/modules/pam_exec/pam_exec.c
index c249a654c8be..800a791f04a1 100644
--- a/lib/libpam/modules/pam_exec/pam_exec.c
+++ b/lib/libpam/modules/pam_exec/pam_exec.c
@@ -36,7 +36,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/poll.h>
#include <sys/procdesc.h>
diff --git a/lib/libpam/modules/pam_ftpusers/Makefile b/lib/libpam/modules/pam_ftpusers/Makefile
index e92b752309b5..07d37c8b17a8 100644
--- a/lib/libpam/modules/pam_ftpusers/Makefile
+++ b/lib/libpam/modules/pam_ftpusers/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_ftpusers
SRCS= pam_ftpusers.c
MAN= pam_ftpusers.8
diff --git a/lib/libpam/modules/pam_ftpusers/pam_ftpusers.8 b/lib/libpam/modules/pam_ftpusers/pam_ftpusers.8
index a5c810fd2de5..d5a0f0f1fd2e 100644
--- a/lib/libpam/modules/pam_ftpusers/pam_ftpusers.8
+++ b/lib/libpam/modules/pam_ftpusers/pam_ftpusers.8
@@ -82,9 +82,9 @@ will succeed if and only if the user is not listed in
.Pa /etc/ftpusers .
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr ftpusers 5 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_group/Makefile b/lib/libpam/modules/pam_group/Makefile
index dca723748174..0395b3a8f355 100644
--- a/lib/libpam/modules/pam_group/Makefile
+++ b/lib/libpam/modules/pam_group/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_group
SRCS= pam_group.c
MAN= pam_group.8
diff --git a/lib/libpam/modules/pam_group/pam_group.8 b/lib/libpam/modules/pam_group/pam_group.8
index ed96d45db503..315aaa6cc267 100644
--- a/lib/libpam/modules/pam_group/pam_group.8
+++ b/lib/libpam/modules/pam_group/pam_group.8
@@ -86,8 +86,8 @@ options are mutually exclusive, and that
.Nm
will fail if both are specified.
.Sh SEE ALSO
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_group/pam_group.c b/lib/libpam/modules/pam_group/pam_group.c
index 7c9538b73978..9707a9cd278c 100644
--- a/lib/libpam/modules/pam_group/pam_group.c
+++ b/lib/libpam/modules/pam_group/pam_group.c
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <grp.h>
diff --git a/lib/libpam/modules/pam_guest/Makefile b/lib/libpam/modules/pam_guest/Makefile
index c168513b98ee..7128b513afbc 100644
--- a/lib/libpam/modules/pam_guest/Makefile
+++ b/lib/libpam/modules/pam_guest/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_guest
SRCS= pam_guest.c
MAN= pam_guest.8
diff --git a/lib/libpam/modules/pam_guest/pam_guest.8 b/lib/libpam/modules/pam_guest/pam_guest.8
index 541fd299ba8b..c626187d5b19 100644
--- a/lib/libpam/modules/pam_guest/pam_guest.8
+++ b/lib/libpam/modules/pam_guest/pam_guest.8
@@ -80,10 +80,10 @@ password.
Requires the guest user to type in the guest account name as password.
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr pam_get_item 3 ,
.Xr pam_getenv 3 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_krb5/Makefile b/lib/libpam/modules/pam_krb5/Makefile
index 1c2831facd50..7634930a7202 100644
--- a/lib/libpam/modules/pam_krb5/Makefile
+++ b/lib/libpam/modules/pam_krb5/Makefile
@@ -23,6 +23,58 @@
# SUCH DAMAGE.
#
+.include <src.opts.mk>
+
+.if ${MK_MITKRB5} != "no"
+SRCDIR= ${SRCTOP}/contrib/pam-krb5
+.PATH: ${SRCDIR}/module \
+ ${SRCDIR}/portable \
+ ${SRCDIR}/pam-util \
+ ${SRCDIR}
+
+PACKAGE= kerberos
+LIB= pam_krb5
+LIBADD= com_err krb5
+
+SRCS= account.c \
+ alt-auth.c \
+ args.c \
+ auth.c \
+ cache.c \
+ context.c \
+ dummy.c \
+ fast.c \
+ krb5-extra.c \
+ logging.c \
+ pam-util_options.c \
+ module_options.c \
+ pam_syslog.c \
+ pam_vsyslog.c \
+ password.c \
+ prompting.c \
+ public.c \
+ setcred.c \
+ support.c \
+ vector.c
+
+MAN= pam-krb5.8
+MLINKS= pam-krb5.8 pam_krb5.8
+
+CFLAGS= -I${SRCDIR} \
+ -I${.CURDIR} \
+ -fno-strict-aliasing \
+ -DHAVE_CONFIG_H
+
+WARNS?= 3
+
+CLEANFILES= pam-util_options.c module_options.c
+
+pam-util_options.c: .PHONY
+ cp ${SRCDIR}/pam-util/options.c pam-util_options.c
+
+module_options.c: .PHONY
+ cp ${SRCDIR}/module/options.c module_options.c
+.else
PACKAGE= kerberos
LIB= pam_krb5
@@ -35,4 +87,6 @@ WARNS?= 3
LIBADD+= krb5
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_krb5/config.h b/lib/libpam/modules/pam_krb5/config.h
new file mode 100644
index 000000000000..75695eef66a1
--- /dev/null
+++ b/lib/libpam/modules/pam_krb5/config.h
@@ -0,0 +1,412 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the `asprintf' function. */
+#define HAVE_ASPRINTF 1
+
+/* Define to 1 if you have the declaration of `krb5_kt_free_entry', and to 0
+ if you don't. */
+#define HAVE_DECL_KRB5_KT_FREE_ENTRY 1
+
+/* Define to 1 if you have the declaration of `reallocarray', and to 0 if you
+ don't. */
+#define HAVE_DECL_REALLOCARRAY 1
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <et/com_err.h> header file. */
+/* #undef HAVE_ET_COM_ERR_H */
+
+/* Define to 1 if you have the `explicit_bzero' function. */
+#define HAVE_EXPLICIT_BZERO 1
+
+/* Define to 1 if you have the <hx509_err.h> header file. */
+/* #undef HAVE_HX509_ERR_H */
+
+/* Define to 1 if you have the <ibm_svc/krb5_svc.h> header file. */
+/* #undef HAVE_IBM_SVC_KRB5_SVC_H */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `issetugid' function. */
+#define HAVE_ISSETUGID 1
+
+/* Define to 1 if you have the <k5profile.h> header file. */
+/* #undef HAVE_K5PROFILE_H */
+
+/* Define to enable kadmin client features. */
+#define HAVE_KADM5CLNT 1
+
+/* Define to 1 if you have the `kadm5_init_krb5_context' function. */
+#define HAVE_KADM5_INIT_KRB5_CONTEXT 1
+
+/* Define to 1 if you have the `kadm5_init_with_skey_ctx' function. */
+/* #undef HAVE_KADM5_INIT_WITH_SKEY_CTX */
+
+/* Define to 1 if you have the <kadm5/kadm5_err.h> header file. */
+#define HAVE_KADM5_KADM5_ERR_H 1
+
+/* Define to 1 if you have the <kerberosv5/com_err.h> header file. */
+/* #undef HAVE_KERBEROSV5_COM_ERR_H */
+
+/* Define to 1 if you have the <kerberosv5/krb5.h> header file. */
+/* #undef HAVE_KERBEROSV5_KRB5_H */
+
+/* Define to enable Kerberos features. */
+#define HAVE_KRB5 1
+
+/* Define to 1 if you have the `krb5_appdefault_string' function. */
+#define HAVE_KRB5_APPDEFAULT_STRING 1
+
+/* Define to 1 if you have the `krb5_cc_get_full_name' function. */
+#define HAVE_KRB5_CC_GET_FULL_NAME 1
+
+/* Define to 1 if you have the `krb5_data_free' function. */
+/* #undef HAVE_KRB5_DATA_FREE */
+
+/* Define to 1 if you have the `krb5_free_default_realm' function. */
+#define HAVE_KRB5_FREE_DEFAULT_REALM 1
+
+/* Define to 1 if you have the `krb5_free_error_message' function. */
+#define HAVE_KRB5_FREE_ERROR_MESSAGE 1
+
+/* Define to 1 if you have the `krb5_free_string' function. */
+#define HAVE_KRB5_FREE_STRING 1
+
+/* Define to 1 if you have the `krb5_get_error_message' function. */
+#define HAVE_KRB5_GET_ERROR_MESSAGE 1
+
+/* Define to 1 if you have the `krb5_get_error_string' function. */
+/* #undef HAVE_KRB5_GET_ERROR_STRING */
+
+/* Define to 1 if you have the `krb5_get_err_txt' function. */
+/* #undef HAVE_KRB5_GET_ERR_TXT */
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_alloc' function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC 1
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_free' function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_FREE 1
+
+/* Define if krb5_get_init_creds_opt_free takes two arguments. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_FREE_2_ARGS 1
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_set_anonymous'
+ function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_SET_ANONYMOUS 1
+
+/* Define to 1 if you have the
+ `krb5_get_init_creds_opt_set_change_password_prompt' function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_SET_CHANGE_PASSWORD_PROMPT 1
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_set_default_flags'
+ function. */
+/* #undef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_DEFAULT_FLAGS */
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_set_fast_ccache_name'
+ function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_SET_FAST_CCACHE_NAME 1
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_set_out_ccache'
+ function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_SET_OUT_CCACHE 1
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_set_pa' function. */
+#define HAVE_KRB5_GET_INIT_CREDS_OPT_SET_PA 1
+
+/* Define to 1 if you have the `krb5_get_init_creds_opt_set_pkinit' function.
+ */
+/* #undef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_PKINIT */
+
+/* Define if krb5_get_init_creds_opt_set_pkinit takes 9 arguments. */
+/* #undef HAVE_KRB5_GET_INIT_CREDS_OPT_SET_PKINIT_9_ARGS */
+
+/* Define to 1 if you have the `krb5_get_profile' function. */
+/* #undef HAVE_KRB5_GET_PROFILE */
+
+/* Define to 1 if you have the `krb5_get_prompt_types' function. */
+#define HAVE_KRB5_GET_PROMPT_TYPES 1
+
+/* Define to 1 if you have the <krb5.h> header file. */
+#define HAVE_KRB5_H 1
+
+/* Define if your Kerberos implementation is Heimdal. */
+/* #undef HAVE_KRB5_HEIMDAL */
+
+/* Define to 1 if you have the `krb5_init_secure_context' function. */
+#define HAVE_KRB5_INIT_SECURE_CONTEXT 1
+
+/* Define to 1 if you have the <krb5/krb5.h> header file. */
+#define HAVE_KRB5_KRB5_H 1
+
+/* Define if your Kerberos implementation is MIT. */
+#define HAVE_KRB5_MIT 1
+
+/* Define to 1 if you have the `krb5_principal_get_realm' function. */
+/* #undef HAVE_KRB5_PRINCIPAL_GET_REALM */
+
+/* Define to 1 if you have the `krb5_principal_set_comp_string' function. */
+/* #undef HAVE_KRB5_PRINCIPAL_SET_COMP_STRING */
+
+/* Define to 1 if the system has the type `krb5_realm'. */
+/* #undef HAVE_KRB5_REALM */
+
+/* Define to 1 if you have the `krb5_set_password' function. */
+#define HAVE_KRB5_SET_PASSWORD 1
+
+/* Define to 1 if you have the `krb5_set_trace_filename' function. */
+#define HAVE_KRB5_SET_TRACE_FILENAME 1
+
+/* Define to 1 if you have the `krb5_svc_get_msg' function. */
+/* #undef HAVE_KRB5_SVC_GET_MSG */
+
+/* Define to 1 if you have the `krb5_verify_init_creds_opt_init' function. */
+#define HAVE_KRB5_VERIFY_INIT_CREDS_OPT_INIT 1
+
+/* Define to 1 if you have the `krb5_xfree' function. */
+/* #undef HAVE_KRB5_XFREE */
+
+/* Define to 1 if the system has the type `long long int'. */
+#define HAVE_LONG_LONG_INT 1
+
+/* Define to 1 if you have the <minix/config.h> header file. */
+/* #undef HAVE_MINIX_CONFIG_H */
+
+/* Define to 1 if you have the `mkstemp' function. */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have the `pam_getenv' function. */
+#define HAVE_PAM_GETENV 1
+
+/* Define to 1 if you have the `pam_getenvlist' function. */
+#define HAVE_PAM_GETENVLIST 1
+
+/* Define to 1 if you have the `pam_modutil_getpwnam' function. */
+/* #undef HAVE_PAM_MODUTIL_GETPWNAM */
+
+/* Define to 1 if you have the <pam/pam_appl.h> header file. */
+/* #undef HAVE_PAM_PAM_APPL_H */
+
+/* Define to 1 if you have the <pam/pam_ext.h> header file. */
+/* #undef HAVE_PAM_PAM_EXT_H */
+
+/* Define to 1 if you have the <pam/pam_modutil.h> header file. */
+/* #undef HAVE_PAM_PAM_MODUTIL_H */
+
+/* Define to 1 if you have the `pam_syslog' function. */
+/* #undef HAVE_PAM_SYSLOG */
+
+/* Define to 1 if you have the `pam_vsyslog' function. */
+/* #undef HAVE_PAM_VSYSLOG */
+
+/* Define to 1 if you have the <profile.h> header file. */
+/* #undef HAVE_PROFILE_H */
+
+/* Define to 1 if you have the `reallocarray' function. */
+#define HAVE_REALLOCARRAY 1
+
+/* Define to 1 if you have the `regcomp' function. */
+#define HAVE_REGCOMP 1
+
+/* Define to 1 if you have the <security/pam_appl.h> header file. */
+#define HAVE_SECURITY_PAM_APPL_H 1
+
+/* Define to 1 if you have the <security/pam_ext.h> header file. */
+/* #undef HAVE_SECURITY_PAM_EXT_H */
+
+/* Define to 1 if you have the <security/pam_modutil.h> header file. */
+/* #undef HAVE_SECURITY_PAM_MODUTIL_H */
+
+/* Define to 1 if the system has the type `ssize_t'. */
+#define HAVE_SSIZE_T 1
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strndup' function. */
+#define HAVE_STRNDUP 1
+
+/* Define to 1 if you have the <sys/bittypes.h> header file. */
+/* #undef HAVE_SYS_BITTYPES_H */
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#define HAVE_SYS_SELECT_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if the system has the type `unsigned long long int'. */
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+
+/* Define to 1 if you have the <wchar.h> header file. */
+#define HAVE_WCHAR_H 1
+
+/* Define to 1 if the system has the type `_Bool'. */
+#define HAVE__BOOL 1
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* The name of the PAM module, used by the pam_vsyslog replacement. */
+#define MODULE_NAME "pam_krb5"
+
+/* Name of package */
+#define PACKAGE "pam-krb5"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "eagle@eyrie.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "pam-krb5"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "pam-krb5 4.11"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "pam-krb5"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "4.11"
+
+/* Define to const if PAM uses const in pam_get_item, empty otherwise. */
+#define PAM_CONST const
+
+/* Define to const if PAM uses const in pam_strerror, empty otherwise. */
+#define PAM_STRERROR_CONST const
+
+/* Define to the full path to openssl for some tests. */
+#define PATH_OPENSSL "/usr/bin/openssl"
+
+/* The size of `long', as computed by sizeof. */
+#define SIZEOF_LONG 8
+
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+ required in a freestanding environment). This macro is provided for
+ backward compatibility; new code need not use it. */
+#define STDC_HEADERS 1
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
+/* Enable general extensions on macOS. */
+#ifndef _DARWIN_C_SOURCE
+# define _DARWIN_C_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+/* Enable X/Open compliant socket functions that do not require linking
+ with -lxnet on HP-UX 11.11. */
+#ifndef _HPUX_ALT_XOPEN_SOCKET_API
+# define _HPUX_ALT_XOPEN_SOCKET_API 1
+#endif
+/* Identify the host operating system as Minix.
+ This macro does not affect the system headers' behavior.
+ A future release of Autoconf may stop defining this macro. */
+#ifndef _MINIX
+/* # undef _MINIX */
+#endif
+/* Enable general extensions on NetBSD.
+ Enable NetBSD compatibility extensions on Minix. */
+#ifndef _NETBSD_SOURCE
+# define _NETBSD_SOURCE 1
+#endif
+/* Enable OpenBSD compatibility extensions on NetBSD.
+ Oddly enough, this does nothing on OpenBSD. */
+#ifndef _OPENBSD_SOURCE
+# define _OPENBSD_SOURCE 1
+#endif
+/* Define to 1 if needed for POSIX-compatible behavior. */
+#ifndef _POSIX_SOURCE
+/* # undef _POSIX_SOURCE */
+#endif
+/* Define to 2 if needed for POSIX-compatible behavior. */
+#ifndef _POSIX_1_SOURCE
+/* # undef _POSIX_1_SOURCE */
+#endif
+/* Enable POSIX-compatible threading on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
+# define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
+# define __STDC_WANT_IEC_60559_BFP_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
+# define __STDC_WANT_IEC_60559_DFP_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
+# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
+# define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
+#endif
+/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
+#ifndef __STDC_WANT_LIB_EXT2__
+# define __STDC_WANT_LIB_EXT2__ 1
+#endif
+/* Enable extensions specified by ISO/IEC 24747:2009. */
+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
+# define __STDC_WANT_MATH_SPEC_FUNCS__ 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable X/Open extensions. Define to 500 only if necessary
+ to make mbstate_t available. */
+#ifndef _XOPEN_SOURCE
+/* # undef _XOPEN_SOURCE */
+#endif
+
+
+/* Version number of package */
+#define VERSION "4.11"
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+/* #undef _FILE_OFFSET_BITS */
+
+/* Define for large files, on AIX-style hosts. */
+/* #undef _LARGE_FILES */
diff --git a/lib/libpam/modules/pam_krb5/pam-krb5.8 b/lib/libpam/modules/pam_krb5/pam-krb5.8
new file mode 100644
index 000000000000..3413748c7850
--- /dev/null
+++ b/lib/libpam/modules/pam_krb5/pam-krb5.8
@@ -0,0 +1,1025 @@
+.\" -*- mode: troff; coding: utf-8 -*-
+.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
+.ie n \{\
+. ds C` ""
+. ds C' ""
+'br\}
+.el\{\
+. ds C`
+. ds C'
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\"
+.\" If the F register is >0, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
+.\" entries marked with X<> in POD. Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.\"
+.\" Avoid warning from groff about undefined register 'F'.
+.de IX
+..
+.nr rF 0
+.if \n(.g .if rF .nr rF 1
+.if (\n(rF:(\n(.g==0)) \{\
+. if \nF \{\
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
+..
+. if !\nF==2 \{\
+. nr % 0
+. nr F 2
+. \}
+. \}
+.\}
+.rr rF
+.\" ========================================================================
+.\"
+.IX Title "PAM_KRB5 1"
+.TH PAM_KRB5 1 2025-06-05 "perl v5.40.2" "User Contributed Perl Documentation"
+.\" For nroff, turn off justification. Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH NAME
+pam_krb5 \- Kerberos PAM module
+.SH SYNOPSIS
+.IX Header "SYNOPSIS"
+.Vb 4
+\& auth sufficient pam_krb5.so minimum_uid=1000
+\& session required pam_krb5.so minimum_uid=1000
+\& account required pam_krb5.so minimum_uid=1000
+\& password sufficient pam_krb5.so minimum_uid=1000
+.Ve
+.SH DESCRIPTION
+.IX Header "DESCRIPTION"
+The Kerberos service module for PAM, typically installed at
+\&\fI/lib/security/pam_krb5.so\fR, provides functionality for the four PAM
+operations: authentication, account management, session management, and
+password management. \fIpam_krb5.so\fR is a shared object that is
+dynamically loaded by the PAM subsystem as necessary, based on the system
+PAM configuration. PAM is a system for plugging in external
+authentication and session management modules so that each application
+doesn't have to know the best way to check user authentication or create a
+user session on that system. For details on how to configure PAM on your
+system, see the PAM man page, often \fBpam\fR\|(7).
+.PP
+Here are the actions of this module when called from each group:
+.IP auth 4
+.IX Item "auth"
+Provides implementations of \fBpam_authenticate()\fR and \fBpam_setcred()\fR. The
+former takes the username from the PAM session, prompts for the user's
+password (unless configured to use an already-entered password), and then
+performs a Kerberos initial authentication, storing the obtained
+credentials (if successful) in a temporary ticket cache. The latter,
+depending on the flags it is called with, either takes the contents of the
+temporary ticket cache and writes it out to a persistent ticket cache
+owned by the user or uses the temporary ticket cache to refresh an
+existing user ticket cache.
+.Sp
+Passwords as long or longer than PAM_MAX_RESP_SIZE octets (normally 512
+octets) will be rejected, since excessively long passwords can be used as
+a denial of service attack.
+.Sp
+After doing the initial authentication, the Kerberos PAM module will
+attempt to obtain tickets for a key in the local system keytab and then
+verify those tickets. Unless this step is performed, the authentication
+is vulnerable to KDC spoofing, but it requires that the system have a
+local key and that the PAM module be running as a user that can read the
+keytab file (normally \fI/etc/krb5.keytab\fR. You can point the Kerberos PAM
+module at a different keytab with the \fIkeytab\fR option. If that keytab
+cannot be read or if no keys are found in it, the default (potentially
+insecure) behavior is to skip this check. If you want to instead fail
+authentication if the obtained tickets cannot be checked, set
+\&\f(CW\*(C`verify_ap_req_nofail\*(C'\fR to true in the [libdefaults] section of
+\&\fI/etc/krb5.conf\fR. Note that this will affect applications other than
+this PAM module.
+.Sp
+By default, whenever the user is authenticated, a basic authorization
+check will also be done using \fBkrb5_kuserok()\fR. The default behavior of
+this function is to check the user's account for a \fI.k5login\fR file and,
+if one is present, ensure that the user's principal is listed in that
+file. If \fI.k5login\fR is not present, the default check is to ensure that
+the user's principal is in the default local realm and the user portion of
+the principal matches the account name (this can be changed by configuring
+a custom aname to localname mapping in \fIkrb5.conf\fR; see the Kerberos
+documentation for details). This can be customized with several
+configuration options; see below.
+.Sp
+If the username provided to PAM contains an \f(CW\*(C`@\*(C'\fR and Kerberos can,
+treating the username as a principal, map it to a local account name,
+\&\fBpam_authenticate()\fR will change the PAM user to that local account name.
+This allows users to log in with their Kerberos principal and let Kerberos
+do the mapping to an account. This can be disabled with the
+\&\fIno_update_user\fR option. Be aware, however, that this facility cannot be
+used with OpenSSH. OpenSSH will reject usernames that don't match local
+accounts before this remapping can be done and will pass an invalid
+password to the PAM module. Also be aware that several other common PAM
+modules, such as pam_securetty, expect to be able to look up the user with
+\&\fBgetpwnam()\fR and cannot be called before pam_krb5 when using this feature.
+.Sp
+When \fBpam_setcred()\fR is called to initialize a new ticket cache, the
+environment variable KRB5CCNAME is set to the path to that ticket cache.
+By default, the cache will be named \fI/tmp/krb5cc_UID_RANDOM\fR where UID is
+the user's UID and RANDOM is six randomly-chosen letters. This can be
+configured with the \fIccache\fR and \fIccache_dir\fR options.
+.Sp
+pam\-krb5 does not use the default ticket cache location or
+\&\fIdefault_cc_name\fR in the \f(CW\*(C`[libdefaults]\*(C'\fR section of \fIkrb5.conf\fR. The
+default cache location would share a cache for all sessions of the same
+user, which causes confusing behavior when the user logs out of one of
+multiple sessions.
+.Sp
+If \fBpam_setcred()\fR initializes a new ticket cache, it will also set up that
+ticket cache so that it will be deleted when the PAM session is closed.
+Normally, the calling program (\fBlogin\fR, \fBsshd\fR, etc.) will run the
+user's shell as a sub-process, wait for it to exit, and then close the PAM
+session, thereby cleaning up the user's session.
+.IP session 4
+.IX Item "session"
+Provides implementations of \fBpam_open_session()\fR, which is equivalent to
+calling \fBpam_setcred()\fR with the PAM_ESTABLISH_CRED flag, and
+\&\fBpam_close_session()\fR, which destroys the ticket cache created by
+\&\fBpam_setcred()\fR.
+.IP account 4
+.IX Item "account"
+Provides an implementation of \fBpam_acct_mgmt()\fR. All it does is do the same
+authorization check as performed by the \fBpam_authenticate()\fR implementation
+described above.
+.IP password 4
+.IX Item "password"
+Provides an implementation of \fBpam_chauthtok()\fR, which implements password
+changes. The user is prompted for their existing password (unless
+configured to use an already entered one) and the PAM module then obtains
+credentials for the special Kerberos principal \f(CW\*(C`kadmin/changepw\*(C'\fR. It
+then prompts the user for a new password, twice to ensure that the user
+entered it properly (again, unless configured to use an already entered
+password), and then does a Kerberos password change.
+.Sp
+Passwords as long or longer than PAM_MAX_RESP_SIZE octets (normally 512
+octets) will be rejected, since excessively long passwords can be used as
+a denial of service attack.
+.Sp
+Unlike the normal Unix password module, this module will allow any user to
+change any other user's password if they know the old password. Also,
+unlike the normal Unix password module, root will always be prompted for
+the old password, since root has no special status in Kerberos. (To
+change passwords in Kerberos without knowing the old password, use
+\&\fBkadmin\fR\|(8) instead.)
+.PP
+Both the account and session management calls of the Kerberos PAM module
+will return PAM_IGNORE if called in the context of a PAM session for a
+user who did not authenticate with Kerberos (a return code of \f(CW\*(C`ignore\*(C'\fR in
+the Linux PAM configuration language).
+.PP
+Note that this module assumes the network is available in order to do a
+Kerberos authentication. If the network is not available, some Kerberos
+libraries have timeouts longer than the timeout imposed by the login
+process. This means that using this module incautiously can make it
+impossible to log on to console as root. For this reason, you should
+always use the \fIignore_root\fR or \fIminimum_uid\fR options, list a local
+authentication module such as \fBpam_unix\fR first with a control field of
+\&\f(CW\*(C`sufficient\*(C'\fR so that the Kerberos PAM module will be skipped if local
+password authentication was successful.
+.PP
+This is not the same PAM module as the Kerberos PAM module available from
+Sourceforge, or the one included on Red Hat systems. It supports many of
+the same options, has some additional options, and doesn't support some of
+the options those modules do.
+.SH CONFIGURATION
+.IX Header "CONFIGURATION"
+The Kerberos PAM module takes many options, not all of which are relevant
+to every PAM group; options that are not relevant will be silently
+ignored. Any of these options can be set in the PAM configuration as
+arguments listed after \f(CW\*(C`pam_krb5.so\*(C'\fR. Some of the options can also be
+set in the system \fIkrb5.conf\fR file; if this is possible, it will be noted
+below in the option description.
+.PP
+To set a boolean option in the PAM configuration file, just give the name
+of the option in the arguments. To set an option that takes an argument,
+follow the option name with an equal sign (=) and the value, with no
+separating whitespace. Whitespace in option arguments is not supported in
+the PAM configuration.
+.PP
+To set an option for the PAM module in the system \fIkrb5.conf\fR file, put
+that option in the \f(CW\*(C`[appdefaults]\*(C'\fR section. All options must be followed
+by an equal sign (=) and a value, so for boolean options add \f(CW\*(C`= true\*(C'\fR.
+The Kerberos PAM module will look for options either at the top level of
+the \f(CW\*(C`[appdefaults]\*(C'\fR section or in a subsection named \f(CW\*(C`pam\*(C'\fR, inside or
+outside a section for the realm. For example, the following fragment of a
+\&\fIkrb5.conf\fR file would set \fIforwardable\fR to true, \fIminimum_uid\fR to
+1000, and set \fIignore_k5login\fR only if the realm is EXAMPLE.COM.
+.PP
+.Vb 8
+\& [appdefaults]
+\& forwardable = true
+\& pam = {
+\& minimum_uid = 1000
+\& EXAMPLE.COM = {
+\& ignore_k5login = true
+\& }
+\& }
+.Ve
+.PP
+For more information on the syntax of \fIkrb5.conf\fR, see \fBkrb5.conf\fR\|(5).
+Note that options that depend on the realm will be set only on the basis
+of the default realm, either as configured in \fBkrb5.conf\fR\|(5) or as set by
+the \fIrealm\fR option described below. If the user authenticates to an
+account qualified with a realm, that realm will not be used when
+determining which options will apply.
+.PP
+There is no difference to the PAM module whether options are specified at
+the top level or in a \f(CW\*(C`pam\*(C'\fR section; the \f(CW\*(C`pam\*(C'\fR section is supported in
+case there are options that should be set for the PAM module but not for
+other applications.
+.PP
+If the same option is set in \fIkrb5.conf\fR and in the PAM configuration,
+the latter takes precedent. Note, however, that due to the configuration
+syntax, there's no way to turn off a boolean option in the PAM
+configuration that was turned on in \fIkrb5.conf\fR.
+.PP
+The start of each option description is annotated with the version of
+pam\-krb5 in which that option was added with the current meaning.
+.SS Authorization
+.IX Subsection "Authorization"
+.IP alt_auth_map=<format> 4
+.IX Item "alt_auth_map=<format>"
+[3.12] This functions similarly to the \fIsearch_k5login\fR option. The
+<format> argument is used as the authentication Kerberos principal, with
+any \f(CW%s\fR in <format> replaced with the username. If the username
+contains an \f(CW\*(C`@\*(C'\fR, only the part of the username before the realm is used
+to replace \f(CW%s\fR. If <format> contains a realm, it will be used;
+otherwise, the realm of the username (if any) will be appended to the
+result. There is no quote removal.
+.Sp
+If this option is present, the default behavior is to try this alternate
+principal first and then fall back to the standard behavior if it fails.
+The primary usage is to allow alternative principals to be used for
+authentication in programs like \fBsudo\fR. Most examples will look like:
+.Sp
+.Vb 1
+\& alt_auth_map=%s/root
+.Ve
+.Sp
+which attempts authentication as the root instance of the username first
+and then falls back to the regular username (but see \fIforce_alt_auth\fR and
+\&\fIonly_alt_auth\fR).
+.Sp
+This option also allows a cheap way to attempt authentication in an
+alternative realm first and then fall back to the primary realm. A
+setting like:
+.Sp
+.Vb 1
+\& alt_auth_map=%s@EXAMPLE.COM
+.Ve
+.Sp
+will attempt authentication in the EXAMPLE.COM realm first and then fall
+back on the local default realm. This is more convenient than running the
+module multiple times with multiple default realms set with \fIrealm\fR, but
+it is very limited: only two realms can be tried, and the alternate realm
+is always tried first.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR, although
+normally it doesn't make sense to do that; normally it is used in the PAM
+options of configuration for specific programs. It is only applicable to
+the auth and account groups. If this option is set for the auth group, be
+sure to set it for the account group as well or account authorization may
+fail.
+.IP force_alt_auth 4
+.IX Item "force_alt_auth"
+[3.12] This option is used with \fIalt_auth_map\fR and forces authentication
+as the mapped principal if that principal exists in the KDC. Only if the
+KDC returns principal unknown does the Kerberos PAM module fall back to
+normal authentication. This can be used to force authentication with an
+alternate instance. If \fIalt_auth_map\fR is not set, it has no effect.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP ignore_k5login 4
+.IX Item "ignore_k5login"
+[2.0] Never look for a \fI.k5login\fR file in the user's home directory.
+Instead, only check that the Kerberos principal maps to the local account
+name. The default check is to ensure the realm matches the local realm
+and the user portion of the principal matches the local account name, but
+this can be customized by setting up an aname to localname mapping in
+\&\fIkrb5.conf\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and account groups.
+.IP ignore_root 4
+.IX Item "ignore_root"
+[1.1] Do not do anything if the username is \f(CW\*(C`root\*(C'\fR. The authentication
+and password calls will silently fail (allowing that status to be ignored
+via a control of \f(CW\*(C`optional\*(C'\fR or \f(CW\*(C`sufficient\*(C'\fR), and the account and
+session calls (including pam_setcred) will return PAM_IGNORE, telling the
+PAM library to proceed as if they weren't mentioned in the PAM
+configuration. This option is supported and will remain, but normally you
+want to use \fIminimum_uid\fR instead.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR.
+.IP minimum_uid=<uid> 4
+.IX Item "minimum_uid=<uid>"
+[2.0] Do not do anything if the authenticated account name corresponds to
+a local account and that local account has a UID lower than <uid>. If
+both of those conditions are true, the authentication and password calls
+will silently fail (allowing that status to be ignored via a control of
+\&\f(CW\*(C`optional\*(C'\fR or \f(CW\*(C`sufficient\*(C'\fR), and the account and session calls
+(including pam_setcred) will return PAM_IGNORE, telling the PAM library to
+proceed as if they weren't mentioned in the PAM configuration.
+.Sp
+Using this option is highly recommended if you don't need to use Kerberos
+to authenticate password logins to the root account (which isn't
+recommended since Kerberos requires a network connection). It provides
+some defense in depth against user principals that happen to match a
+system account incorrectly authenticating as that system account.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR.
+.IP only_alt_auth 4
+.IX Item "only_alt_auth"
+[3.12] This option is used with \fIalt_auth_map\fR and forces the use of the
+mapped principal for authentication. It disables fallback to normal
+authentication in all cases and overrides \fIsearch_k5login\fR and
+\&\fIforce_alt_auth\fR. If \fIalt_auth_map\fR is not set, it has no effect and
+the standard authentication behavior is used.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP search_k5login 4
+.IX Item "search_k5login"
+[2.0] Normally, the Kerberos implementation of pam_authenticate attempts
+to obtain tickets for the authenticating username in the local realm. If
+this option is set and the local user has a \fI.k5login\fR file in their home
+directory, the module will instead open and read that \fI.k5login\fR file,
+attempting to use the supplied password to authenticate as each principal
+listed there in turn. If any of those authentications succeed, the user
+will be successfully authenticated; otherwise, authentication will fail.
+This option is useful for allowing password authentication (via console or
+\&\fBsshd\fR without GSS-API support) to shared accounts. If there is no
+\&\fI.k5login\fR file, the behavior is the same as normal. Using this option
+requires that the user's \fI.k5login\fR file be readable at the time of
+authentication.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.SS "Kerberos Behavior"
+.IX Subsection "Kerberos Behavior"
+.IP anon_fast 4
+.IX Item "anon_fast"
+[4.6] Attempt to use Flexible Authentication Secure Tunneling (FAST) by
+first authenticating as the anonymous user (WELLKNOWN/ANONYMOUS) and using
+its credentials as the FAST armor. This requires anonymous PKINIT be
+enabled for the local realm, that PKINIT be configured on the local
+system, and that the Kerberos library support FAST and anonymous PKINIT.
+.Sp
+FAST is a mechanism to protect Kerberos against password guessing attacks
+and provide other security improvements. To work, FAST requires that a
+ticket be obtained with a strong key to protect exchanges with potentially
+weaker user passwords. This option uses anonymous authentication to
+obtain that key and then uses it to protect the subsequent authentication.
+.Sp
+If anonymous PKINIT is not available or fails, FAST will not be used and
+the authentication will proceed as normal.
+.Sp
+To instead use an existing ticket cache for the FAST credentials, use
+\&\fIfast_ccache\fR instead of this option. If both \fIfast_ccache\fR and
+\&\fIanon_fast\fR are set, the ticket cache named by \fIfast_ccache\fR will be
+tried first, and the Kerberos PAM module will fall back on attempting
+anonymous PKINIT if that cache could not be used.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.Sp
+The operation is the same as if using the \fIfast_ccache\fR option, but the
+cache is created and destroyed automatically. If both \fIfast_ccache\fR and
+\&\fIanon_fast\fR options are used, the \fIfast_ccache\fR takes precedent and no
+anonymous authentication is done.
+.IP fast_ccache=<ccache_name> 4
+.IX Item "fast_ccache=<ccache_name>"
+[4.3] The same as \fIanon_fast\fR, but use an existing Kerberos ticket cache
+rather than anonymous PKINIT. This allows use of FAST with a realm that
+doesn't support PKINIT or doesn't support anonymous authentication.
+.Sp
+<ccache_name> should be a credential cache containing a ticket obtained
+using a strong key, such as the randomized key for the host principal of
+the local system. If <ccache_name> names a ticket cache that is readable
+by the authenticating process and has tickets then FAST will be attempted.
+The easiest way to use this option is to use a program like \fBk5start\fR to
+maintain a ticket cache using the host's keytab. This ticket cache should
+normally only be readable by root, so this option will not be able to
+protect authentications done as non-root users (such as screensavers).
+.Sp
+If no credentials are present in the ticket cache, or if the ticket cache
+does not exist or is not readable, FAST will not used and authentication
+will proceed as normal. However, if the credentials in that ticket cache
+are expired, authentication will fail if the KDC supports FAST.
+.Sp
+To use anonymous PKINIT to protect the FAST exchange, use the \fIanon_fast\fR
+option instead. \fIanon_fast\fR is easier to configure, since no existing
+ticket cache is required, but requires PKINIT be available and configured
+and that the local realm support anonymous authentication. If both
+\&\fIfast_ccache\fR and \fIanon_fast\fR are set, the ticket cache named by
+\&\fIfast_ccache\fR will be tried first, and the Kerberos PAM module will fall
+back on attempting anonymous PKINIT if that cache could not be used.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.IP forwardable 4
+.IX Item "forwardable"
+[1.0] Obtain forwardable tickets. If set (to either true or false,
+although it can only be set to false in \fIkrb5.conf\fR), this overrides the
+Kerberos library default set in the [libdefaults] section of \fIkrb5.conf\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP keytab=<path> 4
+.IX Item "keytab=<path>"
+[3.0] Specifies the keytab to use when validating the user's credentials.
+The default is the default system keytab (normally \fI/etc/krb5.keytab\fR),
+which is usually only readable by root. Applications not running as root
+that use this PAM module for authentication may wish to point it to
+another keytab the application can read. The first principal found in the
+keytab will be used as the principal for credential verification.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP realm=<realm> 4
+.IX Item "realm=<realm>"
+[2.2] Set the default Kerberos realm and obtain credentials in that realm,
+rather than in the normal default realm for this system. If this option
+is used, it should be set for all groups being used for consistent
+results. This setting will affect authorization decisions since it
+changes the default realm. This setting will also change the service
+principal used to verify the obtained credentials to be in the specified
+realm.
+.Sp
+If you only want to set the realm assumed for user principals without
+changing the realm for authorization decisions or the service principal
+used to verify credentials, see the \fIuser_realm\fR option.
+.IP renew_lifetime=<lifetime> 4
+.IX Item "renew_lifetime=<lifetime>"
+[2.0] Obtain renewable tickets with a maximum renewable lifetime of
+<lifetime>. <lifetime> should be a Kerberos lifetime string such as
+\&\f(CW\*(C`2d4h10m\*(C'\fR or a time in minutes. If set, this overrides the Kerberos
+library default set in the [libdefaults] section of \fIkrb5.conf\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP ticket_lifetime=<lifetime> 4
+.IX Item "ticket_lifetime=<lifetime>"
+[3.0] Obtain tickets with a maximum lifetime of <lifetime>. <lifetime>
+should be a Kerberos lifetime string such as \f(CW\*(C`2d4h10m\*(C'\fR or a time in
+minutes. If set, this overrides the Kerberos library default set in the
+[libdefaults] section of \fIkrb5.conf\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP user_realm 4
+.IX Item "user_realm"
+[4.6] Obtain credentials in the specified realm rather than in the default
+realm for this system. If this option is used, it should be set for all
+groups being used for consistent results (although the account group
+currently doesn't care about realm). This will not change authorization
+decisions. If the obtained credentials are supposed to allow access to a
+shell account, the user will need an appropriate \fI.k5login\fR file entry or
+the system will have to have a custom aname_to_localname mapping.
+.SS "PAM Behavior"
+.IX Subsection "PAM Behavior"
+.IP clear_on_fail 4
+.IX Item "clear_on_fail"
+[3.9] When changing passwords, PAM first does a preliminary check through
+the complete password stack, and then calls each module again to do the
+password change. After that preliminary check, the order of module
+invocation is fixed. This means that even if the Kerberos password change
+fails (or if one of the other password changes in the stack fails), other
+password PAM modules in the stack will still be called even if the failing
+module is marked required or requisite. When using multiple password PAM
+modules to synchronize passwords between multiple systems when they
+change, this behavior can cause unwanted differences between the
+environments.
+.Sp
+Setting this option provides a way to work around this behavior. If this
+option is set and a Kerberos password change is attempted and fails (due
+to network errors or password strength checking on the KDC, for example),
+this module will clear the stored password in the PAM stack. This will
+force any subsequent modules that have \fIuse_authtok\fR set to fail so that
+those environments won't get out of sync with the password in Kerberos.
+The Kerberos PAM module will not meddle with the stored password if it
+skips the user due to configuration such as minimum_uid.
+.Sp
+Unfortunately, setting this option interferes with other desirable PAM
+configurations, such as attempting to change the password in Kerberos
+first and falling back on the local Unix password database if that fails.
+It therefore isn't the default. Turn it on (and list pam_krb5 first after
+pam_cracklib if used) when synchronizing passwords between multiple
+environments.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the password group.
+.IP debug 4
+.IX Item "debug"
+[1.0] Log more verbose trace and debugging information to syslog at
+LOG_DEBUG priority, including entry and exit from each of the external PAM
+interfaces (except pam_close_session).
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR.
+.IP defer_pwchange 4
+.IX Item "defer_pwchange"
+[3.11] By default, pam\-krb5 lets the Kerberos library handle prompting for
+a password change if an account's password is expired during the auth
+group. If this fails, \fBpam_authenticate()\fR returns an error.
+.Sp
+According to the PAM standard, this is not the correct way to handle
+expired passwords. Instead, \fBpam_authenticate()\fR should return success
+without attempting a password change, and then \fBpam_acct_mgmt()\fR should
+return PAM_NEW_AUTHTOK_REQD, at which point the calling application is
+responsible for either rejecting the authentication or calling
+\&\fBpam_chauthtok()\fR. However, following the standard requires that all
+applications call \fBpam_acct_mgmt()\fR and check its return status; otherwise,
+expired accounts may be able to successfully authenticate. Many
+applications do not do this.
+.Sp
+If this option is set, pam\-krb5 uses the fully correct PAM mechanism for
+handling expired accounts instead of failing in \fBpam_authenticate()\fR. Due
+to the security risk of widespread broken applications, be very careful
+about enabling this option. It should normally only be turned on to solve
+a specific problem (such as using Solaris Kerberos libraries that don't
+support prompting for password changes during authentication), and then
+only for specific applications known to call \fBpam_acct_mgmt()\fR and check its
+return status properly.
+.Sp
+This option is only supported when pam\-krb5 is built with MIT Kerberos.
+If built against Heimdal, this option does nothing and normal expired
+password change handling still happens. (Heimdal is missing the required
+API to implement this option, at least as of version 1.6.)
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP fail_pwchange 4
+.IX Item "fail_pwchange"
+[4.2] By default, pam\-krb5 lets the Kerberos library handle prompting for
+a password change if an account's password is expired during the auth
+group. If this option is set, expired passwords are instead treated as an
+authentication failure identical to an incorrect password. Also see
+\&\fIdefer_pwchange\fR and \fIforce_pwchange\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP force_pwchange 4
+.IX Item "force_pwchange"
+[3.11] If this option is set and authentication fails with a Kerberos
+error indicating the user's password is expired, attempt to immediately
+change their password during the authenticate step. Under normal
+circumstances, this is unnecessary. Most Kerberos libraries will do this
+for you, and setting this option will prompt the user twice to change
+their password if the first attempt (done by the Kerberos library) fails.
+However, some system Kerberos libraries (such as Solaris's) have password
+change prompting disabled in the Kerberos library; on those systems, you
+can set this option to simulate the normal library behavior.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP no_update_user 4
+.IX Item "no_update_user"
+[4.7] Normally, if pam\-krb5 is able to canonicalize the principal to a
+local name using \fBkrb5_aname_to_localname()\fR or similar calls, it changes
+the PAM_USER variable for this PAM session to the canonicalized local
+name. Setting this option disables this behavior and leaves PAM_USER set
+to the initial authentication identity.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth group.
+.IP silent 4
+.IX Item "silent"
+[1.0] Don't show messages and errors from Kerberos, such as warnings of
+expiring passwords, to the user via the prompter. This is equivalent to
+the behavior when the application passes in PAM_SILENT, but can be set in
+the PAM configuration.
+.Sp
+This option is only applicable to the auth and password groups.
+.IP trace=<log\-file> 4
+.IX Item "trace=<log-file>"
+[4.6] Enables Kerberos library trace logging to the specified log file if
+it is supported by the Kerberos library. This is intended for temporary
+debugging. The specified file will be appended to without further
+security checks, so do not specify a file in a publicly writable directory
+like \fI/tmp\fR.
+.SS PKINIT
+.IX Subsection "PKINIT"
+.IP pkinit_anchors=<anchors> 4
+.IX Item "pkinit_anchors=<anchors>"
+[3.0] When doing PKINIT authentication, use <anchors> as the client trust
+anchors. This is normally a reference to a file containing the trusted
+certificate authorities. This option is only used if \fItry_pkinit\fR or
+\&\fIuse_pkinit\fR are set.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.IP pkinit_prompt 4
+.IX Item "pkinit_prompt"
+[3.0] Before attempting PKINIT authentication, prompt the user to insert a
+smart card. You may want to set this option for programs such as
+\&\fBgnome-screensaver\fR that call PAM as soon as the mouse is touched and
+don't give the user an opportunity to enter the smart card first. Any
+information entered at the first prompt is ignored. If \fItry_pkinit\fR is
+set, a user who wishes to use a password instead can just press Enter and
+then enter their password as normal. This option is only used if
+\&\fItry_pkinit\fR or \fIuse_pkinit\fR are set.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.IP pkinit_user=<userid> 4
+.IX Item "pkinit_user=<userid>"
+[3.0] When doing PKINIT authentication, use <userid> as the user ID. The
+value of this string is highly dependent on the type of PKINIT
+implementation you're using, but will generally be something like:
+.Sp
+.Vb 1
+\& PKCS11:/usr/lib/pkcs11/lib/soft\-pkcs11.so
+.Ve
+.Sp
+to specify the module to use with a smart card. It may also point to a
+user certificate or to other types of user IDs. See the Kerberos library
+documentation for more details. This option is only used if \fItry_pkinit\fR
+or \fIuse_pkinit\fR are set.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.IP preauth_opt=<option> 4
+.IX Item "preauth_opt=<option>"
+[3.3] Sets a preauth option (currently only applicable when built with MIT
+Kerberos). <option> is either a key/value pair with the key separated
+from the value by \f(CW\*(C`=\*(C'\fR or a boolean option (in which case it's turned on).
+In \fIkrb5.conf\fR, multiple options should be separated by whitespace. In
+the PAM configuration, this option can be given multiple times to set
+multiple options. In either case, <option> may not contain whitespace.
+.Sp
+The primary use of this option, at least in the near future, will be to
+set options for the MIT Kerberos PKINIT support. For the full list of
+possible options, see the PKINIT plugin documentation. At the time of
+this writing, \f(CW\*(C`X509_user_identity\*(C'\fR is equivalent to \fIpkinit_user\fR and
+\&\f(CW\*(C`X509_anchors\*(C'\fR is equivalent to \fIpkinit_anchors\fR. \f(CW\*(C`flag_DSA_PROTOCOL\*(C'\fR
+can only be set via this option.
+.Sp
+Any settings made with this option are applied after the \fIpkinit_anchors\fR
+and \fIpkinit_user\fR options, so if an equivalent setting is made via
+\&\fIpreauth_opt\fR, it will probably override the other setting.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups. Note that there is no way to
+remove a setting made in \fIkrb5.conf\fR using the PAM configuration, but
+options set in the PAM configuration are applied after options set in
+\&\fIkrb5.conf\fR and therefore may override earlier settings.
+.IP try_pkinit 4
+.IX Item "try_pkinit"
+[3.0] Attempt PKINIT authentication before trying a regular password. You
+will probably also need to set the \fIpkinit_user\fR configuration option.
+If PKINIT fails, the PAM module will fall back on regular password
+authentication. This option is currently only supported if pam\-krb5 was
+built against Heimdal 0.8rc1 or later or MIT Kerberos 1.6.3 or later.
+.Sp
+If this option is set and pam\-krb5 is built against MIT Kerberos, and
+PKINIT fails and the module falls back to password authentication, the
+user's password will not be stored in the PAM stack for subsequent
+modules. This is a bug in the interaction between the module and MIT
+Kerberos that requires some reworking of the PKINIT authentication method
+to fix.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.IP use_pkinit 4
+.IX Item "use_pkinit"
+[3.0, 4.9 for MIT Kerberos] Require PKINIT authentication. You will
+probably also need to set the \fIpkinit_user\fR configuration option. If
+PKINIT fails, authentication will fail. This option is only supported if
+pam\-krb5 was built against Heimdal 0.8rc1 or later or MIT Kerberos 1.12 or
+later.
+.Sp
+Be aware that, with MIT Kerberos, this option is implemented by using a
+responder without a prompter, and thus any informational messages from the
+Kerberos libraries or KDC during authentication will not be displayed.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.SS Prompting
+.IX Subsection "Prompting"
+.IP banner=<banner> 4
+.IX Item "banner=<banner>"
+[3.0] By default, the prompts when a user changes their password are:
+.Sp
+.Vb 3
+\& Current Kerberos password:
+\& Enter new Kerberos password:
+\& Retype new Kerberos password:
+.Ve
+.Sp
+The string "Kerberos" is inserted so that users aren't confused about
+which password they're changing. Setting this option replaces the word
+"Kerberos" with whatever this option is set to. Setting this option to
+the empty string removes the word before "password:" entirely.
+.Sp
+If set in the PAM configuration, <banner> may not contain whitespace. If
+you want a value containing whitespace, set it in \fIkrb5.conf\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the password group.
+.IP expose_account 4
+.IX Item "expose_account"
+[3.0] By default, the Kerberos PAM module password prompt is simply
+"Password:". This avoids leaking any information about the system realm
+or account to principal conversions. If this option is set, the string
+"for <principal>" is added before the colon, where <principal> is the
+user's principal. This string is also added before the colon on prompts
+when changing the user's password.
+.Sp
+Enabling this option with ChallengeResponseAuthentication enabled in
+OpenSSH may cause problems for some ssh clients that only recognize
+"Password:" as a prompt. This option is automatically disabled if
+\&\fIsearch_k5login\fR is enabled since the principal displayed would be
+inaccurate.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and password groups.
+.IP force_first_pass 4
+.IX Item "force_first_pass"
+[4.0] Use the password obtained by a previous authentication or password
+module to authenticate the user without prompting the user again. If no
+previous module obtained the user's password, fail without prompting the
+user. Also see \fItry_first_pass\fR and \fIuse_first_pass\fR for weaker
+versions of this option.
+.Sp
+This option is only applicable to the auth and password groups. For the
+password group, it applies only to the old password. See \fIuse_authtok\fR
+for a similar setting for the new password.
+.IP no_prompt 4
+.IX Item "no_prompt"
+[4.6] Never prompt for the current password. Instead, pass in a NULL
+password to the Kerberos library and let the Kerberos library do the
+prompting. This may be needed if, for example, the Kerberos library is
+configured to use other authentication mechanisms than passwords and needs
+full control over the prompting process.
+.Sp
+The major disadvantage of this option is that it means the PAM module will
+never see the user's password and therefore cannot save it in the PAM
+module data for any subsequent modules. In other words, this option
+cannot be used if another module is in the stack behind the Kerberos PAM
+module and wants to use \fIuse_first_pass\fR. The Kerberos library also
+usually includes the principal in the prompt, and therefore this option
+implies behavior similar to \fIexpose_account\fR. Similar to
+\&\fIexpose_account\fR, this can cause problems with OpenSSH if
+ChallengeResponseAuthentication is enabled, since clients may not
+recognize password prompts other than "Password:".
+.Sp
+Using this option with \fIsearch_k5login\fR would result in a password prompt
+for every principal listed in the user's \fI.k5login\fR file. This is
+probably not desired behavior, although it's not prohibited by the module.
+.Sp
+This option is only applicable to the auth and password groups. For the
+password group, it applies only to the authentication process; the user
+will still be prompted for a new password.
+.IP prompt_principal 4
+.IX Item "prompt_principal"
+[3.6] Before prompting for the user's password (or using the previously
+entered password, if \fItry_first_pass\fR, \fIuse_first_pass\fR, or
+\&\fIforce_first_pass\fR are set), prompt the user for the Kerberos principal
+to use for authentication. This allows the user to authenticate with a
+different principal than the one corresponding to the local username,
+provided that either a \fI.k5login\fR file or local Kerberos principal to
+account mapping authorize that principal to access the local account.
+.Sp
+Be cautious when using this configuration option and don't use it with
+OpenSSH PasswordAuthentication, only ChallengeResponseAuthentication.
+Some PAM-enabled applications expect PAM modules to only prompt for
+passwords and may even blindly give the password to the first prompt, no
+matter what it is. Such applications, in combination with this option,
+may expose the user's password in log messages and Kerberos requests.
+.IP try_first_pass 4
+.IX Item "try_first_pass"
+[1.0] If the authentication module isn't the first on the stack, and a
+previous module obtained the user's password, use that password to
+authenticate the user without prompting them again. If that
+authentication fails, fall back on prompting the user for their password.
+This option has no effect if the authentication module is first in the
+stack or if no previous module obtained the user's password. Also see
+\&\fIuse_first_pass\fR and \fIforce_first_pass\fR for stronger versions of this
+option.
+.Sp
+This option is only applicable to the auth and password groups. For the
+password group, it applies only to the old password.
+.IP use_authtok 4
+.IX Item "use_authtok"
+[4.0] Use the new password obtained by a previous password module when
+changing passwords rather than prompting for the new password. If the new
+password isn't available, fail. This can be used to require passwords be
+checked by another, prior module, such as \fBpam_cracklib\fR.
+.Sp
+This option is only applicable to the password group.
+.IP use_first_pass 4
+.IX Item "use_first_pass"
+[1.0] Use the password obtained by a previous authentication module to
+authenticate the user without prompting the user again. If no previous
+module obtained the user's password for either an authentication or
+password change, fall back on prompting the user. If a previous module
+did obtain the user's password but authentication with that password
+fails, fail without further prompting the user. Also see
+\&\fItry_first_pass\fR and \fIforce_first_pass\fR for other versions of this
+option.
+.Sp
+This option is only applicable to the auth and password groups. For the
+password group, it applies only to the old password. See \fIuse_authtok\fR
+for a similar setting for the new password.
+.SS "Ticket Caches"
+.IX Subsection "Ticket Caches"
+.IP ccache=<pattern> 4
+.IX Item "ccache=<pattern>"
+[2.0] Use <pattern> as the pattern for creating credential cache names.
+<pattern> must be in the form <type>:<residual> where <type> and the
+following colon are optional if a file cache should be used. The special
+token \f(CW%u\fR, anywhere in <pattern>, is replaced with the user's numeric
+UID. The special token \f(CW%p\fR, anywhere in <pattern>, is replaced with the
+current process ID.
+.Sp
+If <pattern> ends in the literal string \f(CW\*(C`XXXXXX\*(C'\fR (six X's), that string
+will be replaced by randomly generated characters and the ticket cache
+will be created using \fBmkstemp\fR\|(3). This is strongly recommended if
+<pattern> points to a world-writable directory.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and session groups.
+.IP ccache_dir=<directory> 4
+.IX Item "ccache_dir=<directory>"
+[1.2] Store both the temporary ticket cache used during authentication and
+user ticket caches in <directory> instead of in \fI/tmp\fR. The algorithm
+for generating the ticket cache name is otherwise unchanged. <directory>
+may be prefixed with \f(CW\*(C`FILE:\*(C'\fR to make the cache type unambiguous (and this
+may be required on systems that use a cache type other than file as the
+default).
+.Sp
+Be aware that pam_krb5 creates and stores a temporary ticket cache file
+owned by root during the login process. If you set \fIccache\fR above to
+avoid using the system \fI/tmp\fR directory for user ticket caches, you may
+also want to set \fIccache_dir\fR to move those temporary caches to some
+other location. This will allow pam_krb5 to continue working even if the
+system \fI/tmp\fR directory is full.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and session groups.
+.IP no_ccache 4
+.IX Item "no_ccache"
+[1.0] Do not create a ticket cache after authentication. This option
+shouldn't be set in general, but is useful as part of the PAM
+configuration for a particular service that uses PAM for authentication
+but isn't creating user sessions and doesn't want the overhead of ever
+writing the user credentials to disk. When using this option, the
+application should only call \fBpam_authenticate()\fR; other functions like
+\&\fBpam_setcred()\fR, \fBpam_start_session()\fR, and \fBpam_acct_mgmt()\fR don't make sense
+with this option. Don't use this option if the application needs PAM
+account and session management calls.
+.Sp
+This option is only applicable to the auth group.
+.IP retain_after_close 4
+.IX Item "retain_after_close"
+[2.3] Normally, the user's ticket cache is destroyed when either \fBpam_end()\fR
+or \fBpam_close_session()\fR is called by the authenticating application so that
+ticket caches aren't left behind after the user logs out. In some cases,
+however, this isn't desirable. (On Solaris 8, for instance, the default
+behavior means login will destroy the ticket cache before running the
+user's shell.) If this option is set, the PAM module will never destroy
+the user's ticket cache. If you set this, you may want to call
+\&\fBkdestroy\fR in the shell's logout configuration or run a temporary file
+removal program to avoid accumulating hundreds of ticket caches in
+\&\fI/tmp\fR.
+.Sp
+This option can be set in \f(CW\*(C`[appdefaults]\*(C'\fR in \fIkrb5.conf\fR and is only
+applicable to the auth and session groups.
+.SH ENVIRONMENT
+.IX Header "ENVIRONMENT"
+.IP KRB5CCNAME 4
+.IX Item "KRB5CCNAME"
+Set by \fBpam_setcred()\fR with the PAM_ESTABLISH_CRED option, and therefore
+also by \fBpam_open_session()\fR, to point to the new credential cache for the
+user. See the \fIccache\fR and \fIccache_dir\fR options. By default, the cache
+name will be prefixed with \f(CW\*(C`FILE:\*(C'\fR to make the cache type unambiguous.
+.IP PAM_KRB5CCNAME 4
+.IX Item "PAM_KRB5CCNAME"
+Set by \fBpam_authenticate()\fR to point to the temporary ticket cache used for
+authentication (unless the \fIno_ccache\fR option was given). \fBpam_setcred()\fR
+then uses that environment variable to locate the temporary cache even if
+it was not called in the same PAM session as \fBpam_authenticate()\fR (a problem
+with \fBsshd\fR running in some modes). This environment variable is only
+used internal to the PAM module.
+.SH FILES
+.IX Header "FILES"
+.IP \fI/tmp/krb5cc_UID_RANDOM\fR 4
+.IX Item "/tmp/krb5cc_UID_RANDOM"
+The default credential cache name. UID is the decimal UID of the local
+user and RANDOM is a random six-character string. The pattern may be
+changed with the \fIccache\fR option and the directory with the \fIccache_dir\fR
+option.
+.IP \fI/tmp/krb5cc_pam_RANDOM\fR 4
+.IX Item "/tmp/krb5cc_pam_RANDOM"
+The credential cache name used for the temporary credential cache created
+by \fBpam_authenticate()\fR. This cache is removed again when the PAM session
+is ended or when \fBpam_setcred()\fR is called and will normally not be
+user-visible. RANDOM is a random six-character string.
+.IP \fI~/.k5login\fR 4
+.IX Item "~/.k5login"
+File containing Kerberos principals that are allowed access to that
+account.
+.SH BUGS
+.IX Header "BUGS"
+If \fItry_pkinit\fR is set and pam\-krb5 is built with MIT Kerberos, the
+user's password is not saved in the PAM data if PKINIT fails and the
+module falls back to password authentication.
+.SH CAVEATS
+.IX Header "CAVEATS"
+Be sure to list this module in the session group as well as the auth group
+when using it for interactive logins. Otherwise, some applications (such
+as OpenSSH) will not set up the user's ticket cache correctly.
+.PP
+The Kerberos library, via pam\-krb5, will prompt the user to change their
+password if their password is expired, but when using OpenSSH, this will
+only work when ChallengeResponseAuthentication is enabled. Unless this
+option is enabled, OpenSSH doesn't pass PAM messages to the user and can
+only respond to a simple password prompt.
+.PP
+If you are using MIT Kerberos, be aware that users whose passwords are
+expired will not be prompted to change their password unless the KDC
+configuration for your realm in [realms] in krb5.conf contains a
+master_kdc setting or, if using DNS SRV records, you have a DNS entry for
+_kerberos\-master as well as _kerberos.
+.PP
+\&\fBpam_authenticate()\fR returns failure when called for an ignored account,
+requiring the system administrator to use \f(CW\*(C`optional\*(C'\fR or \f(CW\*(C`sufficient\*(C'\fR to
+ignore the module and move on to the next module. It's arguably more
+correct to return PAM_IGNORE, which causes the module to be ignored as if
+it weren't in the configuration, but this increases the risk of
+inadvertent security holes when listing pam\-krb5 as the only
+authentication module.
+.PP
+This module treats the empty password as an authentication failure
+rather than attempting to use that password to avoid unwanted prompting
+behavior in the Kerberos libraries. If you have a Kerberos principal that
+intentionally has an empty password, it won't work with this module.
+.PP
+This module will not refresh an existing ticket cache if called with an
+effective UID or GID different than the real UID or GID, since refreshing
+an existing ticket cache requires trusting the KRB5CCNAME environment
+variable and the environment should not be trusted in a setuid context.
+.PP
+Old versions of OpenSSH are known to call pam_authenticate followed by
+pam_setcred(PAM_REINITIALIZE_CRED) without first calling pam_open_session,
+thereby requesting that an existing ticket cache be renewed (similar to
+what a screensaver would want) rather than requesting a new ticket cache
+be created. Since this behavior is indistinguishable at the PAM level
+from a screensaver, pam\-krb5 when used with these old versions of OpenSSH
+will refresh the ticket cache of the OpenSSH daemon rather than setting up
+a new ticket cache for the user. The resulting ticket cache will have the
+correct permissions, but will not be named correctly or referenced in the
+user's environment and will be overwritten by the next user login. The
+best solution to this problem is to upgrade OpenSSH. I'm not sure exactly
+when this problem was fixed, but at the very least OpenSSH 4.3 and later
+do not exhibit it.
+.SH AUTHOR
+.IX Header "AUTHOR"
+pam\-krb5 was originally written by Frank Cusack. Andres Salomon made
+extensive modifications, and then Russ Allbery <eagle@eyrie.org> adopted
+it and made even more extensive modifications. Russ Allbery currently
+maintains the module.
+.SH "COPYRIGHT AND LICENSE"
+.IX Header "COPYRIGHT AND LICENSE"
+Copyright 2005\-2010, 2014, 2020 Russ Allbery <eagle@eyrie.org>
+.PP
+Copyright 2008\-2014 The Board of Trustees of the Leland Stanford Junior
+University
+.PP
+Copying and distribution of this file, with or without modification, are
+permitted in any medium without royalty provided the copyright notice and
+this notice are preserved. This file is offered as-is, without any
+warranty.
+.PP
+SPDX-License-Identifier: FSFAP
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+\&\fBkadmin\fR\|(8), \fBkdestroy\fR\|(1), \fBkrb5.conf\fR\|(5), \fBpam\fR\|(7), \fBpasswd\fR\|(1), \fBsyslog\fR\|(3)
+.PP
+The current version of this module is available from its web page at
+<https://www.eyrie.org/~eagle/software/pam\-krb5/>.
diff --git a/lib/libpam/modules/pam_krb5/pam_krb5.8 b/lib/libpam/modules/pam_krb5/pam_krb5.8
index b59fdbdee9c4..7c1770961272 100644
--- a/lib/libpam/modules/pam_krb5/pam_krb5.8
+++ b/lib/libpam/modules/pam_krb5/pam_krb5.8
@@ -222,9 +222,9 @@ file containing Kerberos principals that are allowed access.
.Sh SEE ALSO
.Xr kdestroy 1 ,
.Xr passwd 1 ,
+.Xr pam 3 ,
.Xr syslog 3 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
.Sh NOTES
Applications should not call
.Fn pam_authenticate
diff --git a/lib/libpam/modules/pam_krb5/pam_krb5.c b/lib/libpam/modules/pam_krb5/pam_krb5.c
index 34f457d07a40..e13c1b794d5b 100644
--- a/lib/libpam/modules/pam_krb5/pam_krb5.c
+++ b/lib/libpam/modules/pam_krb5/pam_krb5.c
@@ -47,7 +47,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
@@ -61,6 +60,10 @@
#include <krb5.h>
#include <com_err.h>
+#ifdef MK_MITKRB5
+/* For MIT KRB5 only. */
+#include <k5-int.h>
+#endif
#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
diff --git a/lib/libpam/modules/pam_ksu/Makefile b/lib/libpam/modules/pam_ksu/Makefile
index c5fd72d9db7d..953ca23d1416 100644
--- a/lib/libpam/modules/pam_ksu/Makefile
+++ b/lib/libpam/modules/pam_ksu/Makefile
@@ -25,10 +25,21 @@
PACKAGE= kerberos
+.include <src.opts.mk>
+
LIB= pam_ksu
SRCS= pam_ksu.c
MAN= pam_ksu.8
+WARNS?= 3
LIBADD+= krb5
+.if ${MK_MITKRB5} != "no"
+WARNS= 2
+CFLAGS+= -I${SRCTOP}/crypto/krb5/src/include
+CFLAGS+= -I${SRCTOP}/krb5/include
+CFLAGS+= -include ${SRCTOP}/crypto/krb5/src/include/k5-int.h
+CFLAGS+= -DMK_MITKRB5=yes
+.endif
+
.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_ksu/pam_ksu.8 b/lib/libpam/modules/pam_ksu/pam_ksu.8
index 36d6936423b1..ace570ea5b5b 100644
--- a/lib/libpam/modules/pam_ksu/pam_ksu.8
+++ b/lib/libpam/modules/pam_ksu/pam_ksu.8
@@ -115,6 +115,6 @@ the user is prompted for another password.
.El
.Sh SEE ALSO
.Xr su 1 ,
+.Xr pam 3 ,
.Xr syslog 3 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
diff --git a/lib/libpam/modules/pam_ksu/pam_ksu.c b/lib/libpam/modules/pam_ksu/pam_ksu.c
index 9a203f694e61..002613188d8c 100644
--- a/lib/libpam/modules/pam_ksu/pam_ksu.c
+++ b/lib/libpam/modules/pam_ksu/pam_ksu.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
@@ -48,6 +48,62 @@ static long get_su_principal(krb5_context, const char *, const char *,
static int auth_krb5(pam_handle_t *, krb5_context, const char *,
krb5_principal);
+#ifdef MK_MITKRB5
+/* For MIT KRB5 only. */
+
+/*
+ * XXX This entire module will need to be rewritten when heimdal
+ * XXX compatidibility is no longer needed.
+ */
+#define KRB5_DEFAULT_CCFILE_ROOT "/tmp/krb5cc_"
+#define KRB5_DEFAULT_CCROOT "FILE:" KRB5_DEFAULT_CCFILE_ROOT
+
+/*
+ * XXX We will replace krb5_build_principal_va() with
+ * XXX krb5_build_principal_alloc_va() when Heimdal is finally
+ * XXX removed.
+ */
+krb5_error_code KRB5_CALLCONV
+krb5_build_principal_va(krb5_context context,
+ krb5_principal princ,
+ unsigned int rlen,
+ const char *realm,
+ va_list ap);
+typedef char *heim_general_string;
+typedef heim_general_string Realm;
+typedef Realm krb5_realm;
+typedef const char *krb5_const_realm;
+
+static krb5_error_code
+krb5_make_principal(krb5_context context, krb5_principal principal,
+ krb5_const_realm realm, ...)
+{
+ krb5_realm temp_realm = NULL;
+ krb5_error_code rc;
+ va_list ap;
+
+ if (realm == NULL) {
+ if ((rc = krb5_get_default_realm(context, &temp_realm)))
+ return (rc);
+ realm=temp_realm;
+ }
+ va_start(ap, realm);
+ /*
+ * XXX Ideally we should be using krb5_build_principal_alloc_va()
+ * XXX here because krb5_build_principal_va() is deprecated. But,
+ * XXX this would require changes elsewhere in the calling code
+ * XXX to call krb5_free_principal() elsewhere to free the
+ * XXX principal. We can do that after Heimdal is removed from
+ * XXX our tree.
+ */
+ rc = krb5_build_principal_va(context, principal, strlen(realm), realm, ap);
+ va_end(ap);
+ if (temp_realm)
+ free(temp_realm);
+ return (rc);
+}
+#endif
+
PAM_EXTERN int
pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
int argc __unused, const char *argv[] __unused)
@@ -217,7 +273,13 @@ get_su_principal(krb5_context context, const char *target_user, const char *curr
if (rv != 0)
return (errno);
if (default_principal == NULL) {
+#ifdef MK_MITKRB5
+ /* For MIT KRB5. */
+ rv = krb5_make_principal(context, default_principal, NULL, current_user, NULL);
+#else
+ /* For Heimdal. */
rv = krb5_make_principal(context, &default_principal, NULL, current_user, NULL);
+#endif
if (rv != 0) {
PAM_LOG("Could not determine default principal name.");
return (rv);
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.8 b/lib/libpam/modules/pam_lastlog/pam_lastlog.8
index 6e5ba8770ada..e924016151fa 100644
--- a/lib/libpam/modules/pam_lastlog/pam_lastlog.8
+++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.8
@@ -84,11 +84,11 @@ Ignore I/O failures.
.Xr last 1 ,
.Xr w 1 ,
.Xr getutxent 3 ,
+.Xr pam 3 ,
.Xr ulog_login 3 ,
.Xr ulog_logout 3 ,
.Xr pam.conf 5 ,
-.Xr lastlogin 8 ,
-.Xr pam 3
+.Xr lastlogin 8
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c
index c6550a5a9a9d..1fbb644e2055 100644
--- a/lib/libpam/modules/pam_login_access/login_access.c
+++ b/lib/libpam/modules/pam_login_access/login_access.c
@@ -13,7 +13,6 @@ static char sccsid[] = "%Z% %M% %I% %E% %U%";
#endif
#endif
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <ctype.h>
diff --git a/lib/libpam/modules/pam_nologin/pam_nologin.8 b/lib/libpam/modules/pam_nologin/pam_nologin.8
index 30f87a65b63e..ff49749e50f1 100644
--- a/lib/libpam/modules/pam_nologin/pam_nologin.8
+++ b/lib/libpam/modules/pam_nologin/pam_nologin.8
@@ -81,8 +81,8 @@ reasons why the user's
login attempt was declined.
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr syslog 3 ,
.Xr login.conf 5 ,
.Xr nologin 5 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
diff --git a/lib/libpam/modules/pam_nologin/pam_nologin.c b/lib/libpam/modules/pam_nologin/pam_nologin.c
index d944c79814a4..16f7ebdc2e7c 100644
--- a/lib/libpam/modules/pam_nologin/pam_nologin.c
+++ b/lib/libpam/modules/pam_nologin/pam_nologin.c
@@ -36,7 +36,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/lib/libpam/modules/pam_passwdqc/Makefile b/lib/libpam/modules/pam_passwdqc/Makefile
index 60d27529dd19..91ce72928a66 100644
--- a/lib/libpam/modules/pam_passwdqc/Makefile
+++ b/lib/libpam/modules/pam_passwdqc/Makefile
@@ -1,4 +1,3 @@
-
SRCDIR= ${SRCTOP}/contrib/pam_modules/pam_passwdqc
.PATH: ${SRCDIR}
diff --git a/lib/libpam/modules/pam_passwdqc/pam_passwdqc.8 b/lib/libpam/modules/pam_passwdqc/pam_passwdqc.8
index f2ec1747d1f8..755e93520427 100644
--- a/lib/libpam/modules/pam_passwdqc/pam_passwdqc.8
+++ b/lib/libpam/modules/pam_passwdqc/pam_passwdqc.8
@@ -248,8 +248,8 @@ is that the former is incompatible with
.El
.Sh SEE ALSO
.Xr getpwnam 3 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_permit/pam_permit.8 b/lib/libpam/modules/pam_permit/pam_permit.8
index f0b2f5527066..270eaee8361d 100644
--- a/lib/libpam/modules/pam_permit/pam_permit.8
+++ b/lib/libpam/modules/pam_permit/pam_permit.8
@@ -68,6 +68,6 @@ debugging information at
level.
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr syslog 3 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
diff --git a/lib/libpam/modules/pam_radius/pam_radius.8 b/lib/libpam/modules/pam_radius/pam_radius.8
index 6b2d1ef1fa55..abc916dcfff6 100644
--- a/lib/libpam/modules/pam_radius/pam_radius.8
+++ b/lib/libpam/modules/pam_radius/pam_radius.8
@@ -123,9 +123,9 @@ The standard RADIUS client configuration file for
.Nm
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr passwd 5 ,
-.Xr radius.conf 5 ,
-.Xr pam 3
+.Xr radius.conf 5
.Sh HISTORY
The
.Nm
diff --git a/lib/libpam/modules/pam_radius/pam_radius.c b/lib/libpam/modules/pam_radius/pam_radius.c
index 418527771446..027916b38138 100644
--- a/lib/libpam/modules/pam_radius/pam_radius.c
+++ b/lib/libpam/modules/pam_radius/pam_radius.c
@@ -38,7 +38,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netdb.h>
diff --git a/lib/libpam/modules/pam_rhosts/Makefile b/lib/libpam/modules/pam_rhosts/Makefile
index af94a24599ab..4cd25fe5dfa5 100644
--- a/lib/libpam/modules/pam_rhosts/Makefile
+++ b/lib/libpam/modules/pam_rhosts/Makefile
@@ -1,4 +1,3 @@
-
LIB= pam_rhosts
SRCS= pam_rhosts.c
MAN= pam_rhosts.8
diff --git a/lib/libpam/modules/pam_rhosts/pam_rhosts.8 b/lib/libpam/modules/pam_rhosts/pam_rhosts.8
index ea005738840c..1f9716b9a0ca 100644
--- a/lib/libpam/modules/pam_rhosts/pam_rhosts.8
+++ b/lib/libpam/modules/pam_rhosts/pam_rhosts.8
@@ -78,9 +78,9 @@ was declined.
do not automatically fail if the target user's UID is 0.
.El
.Sh SEE ALSO
+.Xr pam 3 ,
.Xr hosts.equiv 5 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_rootok/pam_rootok.8 b/lib/libpam/modules/pam_rootok/pam_rootok.8
index d1ab8226e2ca..fd0a6dd3791f 100644
--- a/lib/libpam/modules/pam_rootok/pam_rootok.8
+++ b/lib/libpam/modules/pam_rootok/pam_rootok.8
@@ -69,5 +69,5 @@ authentication attempt was declined.
.El
.Sh SEE ALSO
.Xr getuid 2 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
diff --git a/lib/libpam/modules/pam_securetty/pam_securetty.8 b/lib/libpam/modules/pam_securetty/pam_securetty.8
index b19979000978..582389cf101d 100644
--- a/lib/libpam/modules/pam_securetty/pam_securetty.8
+++ b/lib/libpam/modules/pam_securetty/pam_securetty.8
@@ -84,7 +84,7 @@ authentication attempt was declined.
.El
.Sh SEE ALSO
.Xr getttynam 3 ,
+.Xr pam 3 ,
.Xr syslog 3 ,
.Xr pam.conf 5 ,
-.Xr ttys 5 ,
-.Xr pam 3
+.Xr ttys 5
diff --git a/lib/libpam/modules/pam_securetty/pam_securetty.c b/lib/libpam/modules/pam_securetty/pam_securetty.c
index 4bef10331f2f..4f05961e2737 100644
--- a/lib/libpam/modules/pam_securetty/pam_securetty.c
+++ b/lib/libpam/modules/pam_securetty/pam_securetty.c
@@ -36,7 +36,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
diff --git a/lib/libpam/modules/pam_self/pam_self.8 b/lib/libpam/modules/pam_self/pam_self.8
index c3623998f0be..f875d671286b 100644
--- a/lib/libpam/modules/pam_self/pam_self.8
+++ b/lib/libpam/modules/pam_self/pam_self.8
@@ -80,8 +80,8 @@ do not automatically fail if the current real user ID is 0.
.El
.Sh SEE ALSO
.Xr getuid 2 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.8 b/lib/libpam/modules/pam_ssh/pam_ssh.8
index e63930eb5340..3ef44d8b687b 100644
--- a/lib/libpam/modules/pam_ssh/pam_ssh.8
+++ b/lib/libpam/modules/pam_ssh/pam_ssh.8
@@ -138,8 +138,8 @@ SSH2 Ed25519 key
.El
.Sh SEE ALSO
.Xr ssh-agent 1 ,
-.Xr pam.conf 5 ,
-.Xr pam 3
+.Xr pam 3 ,
+.Xr pam.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.c b/lib/libpam/modules/pam_ssh/pam_ssh.c
index d79676244694..157908b6b910 100644
--- a/lib/libpam/modules/pam_ssh/pam_ssh.c
+++ b/lib/libpam/modules/pam_ssh/pam_ssh.c
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/wait.h>
diff --git a/lib/libpam/modules/pam_tacplus/pam_tacplus.c b/lib/libpam/modules/pam_tacplus/pam_tacplus.c
index 297c1e761d44..dd19d7da0557 100644
--- a/lib/libpam/modules/pam_tacplus/pam_tacplus.c
+++ b/lib/libpam/modules/pam_tacplus/pam_tacplus.c
@@ -36,7 +36,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <pwd.h>
diff --git a/lib/libpam/modules/pam_unix/pam_unix.8 b/lib/libpam/modules/pam_unix/pam_unix.8
index 170cf65f34db..5c2ae5cf52e2 100644
--- a/lib/libpam/modules/pam_unix/pam_unix.8
+++ b/lib/libpam/modules/pam_unix/pam_unix.8
@@ -201,10 +201,10 @@ password database.
.Xr getlogin 2 ,
.Xr crypt 3 ,
.Xr getpwent 3 ,
+.Xr pam 3 ,
.Xr syslog 3 ,
.Xr nsswitch.conf 5 ,
.Xr passwd 5 ,
-.Xr pam 3 ,
.Xr pw 8 ,
.Xr yp 8
.Sh BUGS
diff --git a/lib/libpam/modules/pam_unix/pam_unix.c b/lib/libpam/modules/pam_unix/pam_unix.c
index 3949e6f126ff..88313f6ebae8 100644
--- a/lib/libpam/modules/pam_unix/pam_unix.c
+++ b/lib/libpam/modules/pam_unix/pam_unix.c
@@ -36,7 +36,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/time.h>
diff --git a/lib/libpam/modules/pam_xdg/Makefile b/lib/libpam/modules/pam_xdg/Makefile
new file mode 100644
index 000000000000..df3948987da6
--- /dev/null
+++ b/lib/libpam/modules/pam_xdg/Makefile
@@ -0,0 +1,5 @@
+LIB= pam_xdg
+SRCS= pam_xdg.c
+MAN= pam_xdg.8
+
+.include <bsd.lib.mk>
diff --git a/lib/libpam/modules/pam_xdg/pam_xdg.8 b/lib/libpam/modules/pam_xdg/pam_xdg.8
new file mode 100644
index 000000000000..9b335751a9fb
--- /dev/null
+++ b/lib/libpam/modules/pam_xdg/pam_xdg.8
@@ -0,0 +1,65 @@
+.\" * SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2024 Beckhoff Automation GmbH & Co. KG
+.\"
+.\" * 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.
+.Dd May 20, 2025
+.Dt PAM_XDG 8
+.Os
+.Sh NAME
+.Nm pam_xdg
+.Nd XDG PAM module
+.Sh SYNOPSIS
+.Op Ar service-name
+.Ar module-type
+.Ar control-flag
+.Pa pam_xdg
+.Op Ar arguments
+.Sh DESCRIPTION
+The xdg service module for PAM creates the runtime files base directory
+according to the Cross Desktop Group Base Directory Specification.
+.Pp
+By default the directory is created under
+.Pa /var/run/xdg/ Ns $ Ns Ev USER .
+.Pp
+The following option may be passed to the authentication module:
+.Bl -tag -width "runtime_dir_prefix=directory"
+.It Cm runtime_dir_prefix Ns = Ns Ar directory
+Use an alternate base directory
+.El
+.Sh ENVIRONMENT
+.Bl -tag -width indent
+.It Ev XDG_RUNTIME_DIR
+The location of the runtime files base directory created by this module.
+Note that the module does not set this environment variable.
+.El
+.Sh STANDARDS
+The directory created by this module conforms to the
+.Lk https://specifications.freedesktop.org/basedir-spec XDG Base Directory Specification .
+.Sh SEE ALSO
+.Xr pam 3 ,
+.Xr pam.conf 5
+.Sh AUTHORS
+The
+.Nm
+module and this manual page were written by
+.An Emmanuel Vadot Aq Mt manu@FreeBSD.org .
diff --git a/lib/libpam/modules/pam_xdg/pam_xdg.c b/lib/libpam/modules/pam_xdg/pam_xdg.c
new file mode 100644
index 000000000000..10c6467776a3
--- /dev/null
+++ b/lib/libpam/modules/pam_xdg/pam_xdg.c
@@ -0,0 +1,329 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Beckhoff Automation GmbH & Co. KG
+ *
+ * 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.
+ */
+
+#include <sys/stat.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <pwd.h>
+
+#define PAM_SM_SESSION
+
+#include <security/pam_appl.h>
+#include <security/pam_modules.h>
+#include <security/pam_mod_misc.h>
+
+#define BASE_RUNTIME_DIR_PREFIX "/var/run/xdg"
+#define RUNTIME_DIR_PREFIX runtime_dir_prefix != NULL ? runtime_dir_prefix : BASE_RUNTIME_DIR_PREFIX
+
+#define RUNTIME_DIR_PREFIX_MODE 0711
+#define RUNTIME_DIR_MODE 0700 /* XDG spec */
+
+#define XDG_MAX_SESSION 100 /* Arbitrary limit because we need one */
+
+static int
+_pam_xdg_open(pam_handle_t *pamh, int flags __unused,
+ int argc __unused, const char *argv[] __unused)
+{
+ struct passwd *passwd;
+ const char *user;
+ const char *runtime_dir_prefix;
+ struct stat sb;
+ char *runtime_dir = NULL;
+ char *xdg_session_file;
+ int rv, rt_dir_prefix, rt_dir, session_file, i;
+
+ session_file = -1;
+ rt_dir_prefix = -1;
+ runtime_dir_prefix = openpam_get_option(pamh, "runtime_dir_prefix");
+
+ /* Get user info */
+ rv = pam_get_item(pamh, PAM_USER, (const void **)&user);
+ if (rv != PAM_SUCCESS || user == NULL) {
+ PAM_VERBOSE_ERROR("Can't get user information");
+ goto out;
+ }
+ if ((passwd = getpwnam(user)) == NULL) {
+ PAM_VERBOSE_ERROR("Can't get user information");
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+
+ /* Open or create the base xdg directory */
+ rt_dir_prefix = open(RUNTIME_DIR_PREFIX, O_DIRECTORY | O_NOFOLLOW);
+ if (rt_dir_prefix < 0) {
+ rt_dir_prefix = mkdir(RUNTIME_DIR_PREFIX, RUNTIME_DIR_PREFIX_MODE);
+ if (rt_dir_prefix != 0) {
+ PAM_VERBOSE_ERROR("Can't mkdir %s", RUNTIME_DIR_PREFIX);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ rt_dir_prefix = open(RUNTIME_DIR_PREFIX, O_DIRECTORY | O_NOFOLLOW);
+ }
+
+ /* Open or create the user xdg directory */
+ rt_dir = openat(rt_dir_prefix, user, O_DIRECTORY | O_NOFOLLOW);
+ if (rt_dir < 0) {
+ rt_dir = mkdirat(rt_dir_prefix, user, RUNTIME_DIR_MODE);
+ if (rt_dir != 0) {
+ PAM_VERBOSE_ERROR("mkdir: %s/%s (%d)", RUNTIME_DIR_PREFIX, user, rt_dir);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ rv = fchownat(rt_dir_prefix, user, passwd->pw_uid, passwd->pw_gid, 0);
+ if (rv != 0) {
+ PAM_VERBOSE_ERROR("fchownat: %s/%s (%d)", RUNTIME_DIR_PREFIX, user, rv);
+ rv = unlinkat(rt_dir_prefix, user, AT_REMOVEDIR);
+ if (rv == -1)
+ PAM_VERBOSE_ERROR("unlinkat: %s/%s (%d)", RUNTIME_DIR_PREFIX, user, errno);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ } else {
+ close(rt_dir);
+ /* Check that the already create dir is correctly owned */
+ rv = fstatat(rt_dir_prefix, user, &sb, 0);
+ if (rv == -1) {
+ PAM_VERBOSE_ERROR("fstatat %s/%s failed (%d)", RUNTIME_DIR_PREFIX, user, errno);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ if (sb.st_uid != passwd->pw_uid ||
+ sb.st_gid != passwd->pw_gid) {
+ PAM_VERBOSE_ERROR("%s/%s isn't owned by %d:%d\n", RUNTIME_DIR_PREFIX, user, passwd->pw_uid, passwd->pw_gid);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ /* Test directory mode */
+ if ((sb.st_mode & 0x1FF) != RUNTIME_DIR_MODE) {
+ PAM_VERBOSE_ERROR("%s/%s have wrong mode\n", RUNTIME_DIR_PREFIX, user);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ }
+
+ /* Setup the environment variable */
+ rv = asprintf(&runtime_dir, "XDG_RUNTIME_DIR=%s/%s", RUNTIME_DIR_PREFIX, user);
+ if (rv < 0) {
+ PAM_VERBOSE_ERROR("asprintf failed %d\n", rv);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ rv = pam_putenv(pamh, runtime_dir);
+ if (rv != PAM_SUCCESS) {
+ PAM_VERBOSE_ERROR("pam_putenv: failed (%d)", rv);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+
+ /* Setup the session count file */
+ for (i = 0; i < XDG_MAX_SESSION; i++) {
+ rv = asprintf(&xdg_session_file, "%s/xdg_session.%d", user, i);
+ if (rv < 0) {
+ PAM_VERBOSE_ERROR("asprintf failed %d\n", rv);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ rv = 0;
+ session_file = openat(rt_dir_prefix, xdg_session_file, O_CREAT | O_EXCL, RUNTIME_DIR_MODE);
+ free(xdg_session_file);
+ if (session_file >= 0)
+ break;
+ }
+ if (session_file < 0) {
+ PAM_VERBOSE_ERROR("Too many sessions");
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+
+out:
+ if (session_file >= 0)
+ close(session_file);
+ if (rt_dir_prefix >= 0)
+ close(rt_dir_prefix);
+
+ if (runtime_dir)
+ free(runtime_dir);
+ return (rv);
+}
+
+static int
+remove_dir(int fd)
+{
+ DIR *dirp;
+ struct dirent *dp;
+
+ dirp = fdopendir(fd);
+ if (dirp == NULL)
+ return (-1);
+
+ while ((dp = readdir(dirp)) != NULL) {
+ if (dp->d_type == DT_DIR) {
+ int dirfd;
+
+ if (strcmp(dp->d_name, ".") == 0 ||
+ strcmp(dp->d_name, "..") == 0)
+ continue;
+ dirfd = openat(fd, dp->d_name, 0);
+ remove_dir(dirfd);
+ close(dirfd);
+ unlinkat(fd, dp->d_name, AT_REMOVEDIR);
+ continue;
+ }
+ unlinkat(fd, dp->d_name, 0);
+ }
+ closedir(dirp);
+
+ return (0);
+}
+
+static int
+_pam_xdg_close(pam_handle_t *pamh __unused, int flags __unused,
+ int argc __unused, const char *argv[] __unused)
+{
+ struct passwd *passwd;
+ const char *user;
+ const char *runtime_dir_prefix;
+ struct stat sb;
+ char *xdg_session_file;
+ int rv, rt_dir_prefix, rt_dir, session_file, i;
+
+ rt_dir = -1;
+ rt_dir_prefix = -1;
+ runtime_dir_prefix = openpam_get_option(pamh, "runtime_dir_prefix");
+
+ /* Get user info */
+ rv = pam_get_item(pamh, PAM_USER, (const void **)&user);
+ if (rv != PAM_SUCCESS || user == NULL) {
+ PAM_VERBOSE_ERROR("Can't get user information");
+ goto out;
+ }
+ if ((passwd = getpwnam(user)) == NULL) {
+ PAM_VERBOSE_ERROR("Can't get user information");
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+
+ /* Open the xdg base directory */
+ rt_dir_prefix = open(RUNTIME_DIR_PREFIX, O_DIRECTORY | O_NOFOLLOW);
+ if (rt_dir_prefix < 0) {
+ PAM_VERBOSE_ERROR("open: %s failed (%d)\n", runtime_dir_prefix, rt_dir_prefix);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ /* Check that the already created dir is correctly owned */
+ rv = fstatat(rt_dir_prefix, user, &sb, 0);
+ if (rv == -1) {
+ PAM_VERBOSE_ERROR("fstatat %s/%s failed (%d)", RUNTIME_DIR_PREFIX, user, errno);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ if (sb.st_uid != passwd->pw_uid ||
+ sb.st_gid != passwd->pw_gid) {
+ PAM_VERBOSE_ERROR("%s/%s isn't owned by %d:%d\n", RUNTIME_DIR_PREFIX, user, passwd->pw_uid, passwd->pw_gid);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ /* Test directory mode */
+ if ((sb.st_mode & 0x1FF) != RUNTIME_DIR_MODE) {
+ PAM_VERBOSE_ERROR("%s/%s have wrong mode\n", RUNTIME_DIR_PREFIX, user);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+
+ /* Open the user xdg directory */
+ rt_dir = openat(rt_dir_prefix, user, O_DIRECTORY | O_NOFOLLOW);
+ if (rt_dir < 0) {
+ PAM_VERBOSE_ERROR("openat: %s/%s failed (%d)\n", RUNTIME_DIR_PREFIX, user, rt_dir_prefix);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+
+ /* Get the last session file created */
+ for (i = XDG_MAX_SESSION; i >= 0; i--) {
+ rv = asprintf(&xdg_session_file, "%s/xdg_session.%d", user, i);
+ if (rv < 0) {
+ PAM_VERBOSE_ERROR("asprintf failed %d\n", rv);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ rv = 0;
+ session_file = openat(rt_dir_prefix, xdg_session_file, 0);
+ if (session_file >= 0) {
+ unlinkat(rt_dir_prefix, xdg_session_file, 0);
+ free(xdg_session_file);
+ break;
+ }
+ free(xdg_session_file);
+ }
+ if (session_file < 0) {
+ PAM_VERBOSE_ERROR("Can't find session number\n");
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ close(session_file);
+
+ /* Final cleanup if last user session */
+ if (i == 0) {
+ remove_dir(rt_dir);
+ if (unlinkat(rt_dir_prefix, user, AT_REMOVEDIR) != 0) {
+ PAM_VERBOSE_ERROR("Can't cleanup %s/%s\n", runtime_dir_prefix, user);
+ rv = PAM_SESSION_ERR;
+ goto out;
+ }
+ }
+
+ rv = PAM_SUCCESS;
+out:
+ if (rt_dir >= 0)
+ close(rt_dir);
+ if (rt_dir_prefix >= 0)
+ close(rt_dir_prefix);
+ return (rv);
+}
+
+PAM_EXTERN int
+pam_sm_open_session(pam_handle_t *pamh, int flags,
+ int argc, const char *argv[])
+{
+
+ return (_pam_xdg_open(pamh, flags, argc, argv));
+}
+
+PAM_EXTERN int
+pam_sm_close_session(pam_handle_t *pamh, int flags,
+ int argc, const char *argv[])
+{
+
+ return (_pam_xdg_close(pamh, flags, argc, argv));
+}
+
+PAM_MODULE_ENTRY("pam_xdg");
diff --git a/lib/libpam/pam.d/Makefile b/lib/libpam/pam.d/Makefile
index 218d79e12ab4..a58c37b6c223 100644
--- a/lib/libpam/pam.d/Makefile
+++ b/lib/libpam/pam.d/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= runtime
@@ -7,7 +6,6 @@ NO_OBJ=
CONFGROUPS= CONFS
CONFS= README \
- cron \
imap \
login \
other \
@@ -18,20 +16,21 @@ CONFS= README \
CONFDIR= /etc/pam.d
CONFSMODE_README= 444
+CONFGROUPS+= CRON
+CRON+= cron
+CRONPACKAGE= cron
+
.if ${MK_AT} != "no"
CONFGROUPS+= AT
-AT+= atrun
+AT+= atrun
ATPACKAGE+= at
.endif
.if ${MK_FTP} != "no"
CONFGROUPS+= FTP
-FTP+= ftpd
-FTPPACKAGE= ftp
-
-LINKMODE= ${CONFMODE}
-afterinstallconfig:
- ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}${CONFDIR}/ftpd ${DESTDIR}${CONFDIR}/ftp
+FTP+= ftp ftpd
+# Do not put these in the ftp package, since ports also use them.
+FTPPACKAGE= runtime
.endif
.include <bsd.prog.mk>
diff --git a/lib/libpam/pam.d/ftp b/lib/libpam/pam.d/ftp
new file mode 100644
index 000000000000..1c255441dca6
--- /dev/null
+++ b/lib/libpam/pam.d/ftp
@@ -0,0 +1,13 @@
+#
+# PAM configuration for the "ftp" service. This is not used by the FreeBSD
+# ftpd(8), but is provided for compatibility with FTP servers from ports.
+#
+
+# auth
+auth include ftpd
+
+# account
+account include ftpd
+
+# session
+session include ftpd
diff --git a/lib/libpam/pam.d/system b/lib/libpam/pam.d/system
index 5ba5567ea9c8..0b5ae5c8fff8 100644
--- a/lib/libpam/pam.d/system
+++ b/lib/libpam/pam.d/system
@@ -16,6 +16,7 @@ account required pam_unix.so
# session
#session optional pam_ssh.so want_agent
session required pam_lastlog.so no_fail
+session required pam_xdg.so
# password
#password sufficient pam_krb5.so no_warn try_first_pass
diff --git a/lib/libpam/pam.d/xdm b/lib/libpam/pam.d/xdm
index da4ac9f65c28..7f603ab640fd 100644
--- a/lib/libpam/pam.d/xdm
+++ b/lib/libpam/pam.d/xdm
@@ -16,6 +16,7 @@ account required pam_unix.so
# session
#session required pam_ssh.so want_agent
session required pam_lastlog.so no_fail
+session required pam_xdg.so
# password
password required pam_deny.so
diff --git a/lib/libpathconv/Makefile b/lib/libpathconv/Makefile
index 5d39b84a11c3..2d6d5b47b0bd 100644
--- a/lib/libpathconv/Makefile
+++ b/lib/libpathconv/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE=lib${LIB}
diff --git a/lib/libpathconv/abs2rel.3 b/lib/libpathconv/abs2rel.3
index 634f294800e4..9240ef1662e2 100644
--- a/lib/libpathconv/abs2rel.3
+++ b/lib/libpathconv/abs2rel.3
@@ -93,6 +93,7 @@ The
.Fa size
argument is greater than zero but smaller than the length of the pathname plus 1.
+.El
.Sh SEE ALSO
.Xr rel2abs 3
.Sh AUTHORS
diff --git a/lib/libpathconv/rel2abs.3 b/lib/libpathconv/rel2abs.3
index f889f427450d..1f607fd739e1 100644
--- a/lib/libpathconv/rel2abs.3
+++ b/lib/libpathconv/rel2abs.3
@@ -90,6 +90,7 @@ argument is zero.
The
.Fa size
argument is greater than zero but smaller than the length of the pathname plus 1
+.El
.Sh SEE ALSO
.Xr abs2rel 3
.Sh AUTHORS
diff --git a/lib/libpathconv/tests/Makefile b/lib/libpathconv/tests/Makefile
index 1289999a62fe..92b4bffdfecf 100644
--- a/lib/libpathconv/tests/Makefile
+++ b/lib/libpathconv/tests/Makefile
@@ -1,4 +1,3 @@
-
TAP_TESTS_C+= abs2rel
TAP_TESTS_C+= rel2abs
diff --git a/lib/libpcap/Makefile b/lib/libpcap/Makefile
index 792f0ff24e8a..9ba91504852b 100644
--- a/lib/libpcap/Makefile
+++ b/lib/libpcap/Makefile
@@ -19,7 +19,6 @@ SRCS= bpf_dump.c \
pcap-bpf.c \
pcap-common.c \
pcap-netmap.c \
- pcap-usb-linux-common.c \
pcap-util.c \
pcap.c \
savefile.c \
diff --git a/lib/libpcap/Makefile.depend b/lib/libpcap/Makefile.depend
index 59966dc1a8ec..12b15914f2b6 100644
--- a/lib/libpcap/Makefile.depend
+++ b/lib/libpcap/Makefile.depend
@@ -7,7 +7,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/ofed/include \
usr.bin/yacc.host \
diff --git a/lib/libpcap/Makefile.depend.options b/lib/libpcap/Makefile.depend.options
index 1c4c26ed4a5a..b02b812e2267 100644
--- a/lib/libpcap/Makefile.depend.options
+++ b/lib/libpcap/Makefile.depend.options
@@ -2,6 +2,6 @@
DIRDEPS_OPTIONS= OFED
-DIRDEPS.OFED.yes= lib/ofed/libibverbs lib/ofed/libmlx5
+DIRDEPS.OFED.yes= lib/ofed/include lib/ofed/libibverbs lib/ofed/libmlx5
.include <dirdeps-options.mk>
diff --git a/lib/libpcap/config.h b/lib/libpcap/config.h
index 132b9bb29183..cea0cc4fd7cb 100644
--- a/lib/libpcap/config.h
+++ b/lib/libpcap/config.h
@@ -183,7 +183,7 @@
#define PACKAGE_NAME "pcap"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "pcap 1.10.4"
+#define PACKAGE_STRING "pcap 1.10.5"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "pcap"
@@ -192,7 +192,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.10.4"
+#define PACKAGE_VERSION "1.10.5"
/* target host supports netmap */
#define PCAP_SUPPORT_NETMAP 1
diff --git a/lib/libpfctl/Makefile b/lib/libpfctl/Makefile
index 24684b919430..d301d7850b44 100644
--- a/lib/libpfctl/Makefile
+++ b/lib/libpfctl/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= lib${LIB}
LIB= pfctl
INTERNALLIB= true
diff --git a/lib/libpfctl/Makefile.depend b/lib/libpfctl/Makefile.depend
index e69de29bb2d1..15a1f9c07f7c 100644
--- a/lib/libpfctl/Makefile.depend
+++ b/lib/libpfctl/Makefile.depend
@@ -0,0 +1,12 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index 1eccf3dfbcdf..104777352d8b 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -40,14 +40,27 @@
#include <net/pfvar.h>
#include <netinet/in.h>
+#include <netpfil/pf/pf_nl.h>
+#include <netlink/netlink.h>
+#include <netlink/netlink_generic.h>
+#include <netlink/netlink_snl.h>
+#include <netlink/netlink_snl_generic.h>
+#include <netlink/netlink_snl_route.h>
+
#include <assert.h>
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include "libpfctl.h"
+struct pfctl_handle {
+ int fd;
+ struct snl_state ss;
+};
+
const char* PFCTL_SYNCOOKIES_MODE_NAMES[] = {
"never",
"always",
@@ -57,6 +70,73 @@ const char* PFCTL_SYNCOOKIES_MODE_NAMES[] = {
static int _pfctl_clear_states(int , const struct pfctl_kill *,
unsigned int *, uint64_t);
+struct pfctl_handle *
+pfctl_open(const char *pf_device)
+{
+ struct pfctl_handle *h;
+
+ h = calloc(1, sizeof(struct pfctl_handle));
+ h->fd = -1;
+
+ h->fd = open(pf_device, O_RDWR);
+ if (h->fd < 0)
+ goto error;
+
+ if (!snl_init(&h->ss, NETLINK_GENERIC))
+ goto error;
+
+ return (h);
+error:
+ close(h->fd);
+ snl_free(&h->ss);
+ free(h);
+
+ return (NULL);
+}
+
+void
+pfctl_close(struct pfctl_handle *h)
+{
+ close(h->fd);
+ snl_free(&h->ss);
+ free(h);
+}
+
+int
+pfctl_fd(struct pfctl_handle *h)
+{
+ return (h->fd);
+}
+
+static int
+pfctl_do_netlink_cmd(struct pfctl_handle *h, uint cmd)
+{
+ struct snl_errmsg_data e = {};
+ struct snl_writer nw;
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, cmd);
+
+ hdr = snl_finalize_msg(&nw);
+ if (hdr == NULL)
+ return (ENOMEM);
+ seq_id = hdr->nlmsg_seq;
+
+ snl_send_message(&h->ss, hdr);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
static int
pfctl_do_ioctl(int dev, uint cmd, size_t size, nvlist_t **nvl)
{
@@ -71,8 +151,12 @@ pfctl_do_ioctl(int dev, uint cmd, size_t size, nvlist_t **nvl)
retry:
nv.data = malloc(size);
+ if (nv.data == NULL) {
+ ret = ENOMEM;
+ goto out;
+ }
+
memcpy(nv.data, data, nvlen);
- free(data);
nv.len = nvlen;
nv.size = size;
@@ -90,13 +174,15 @@ retry:
if (ret == 0) {
*nvl = nvlist_unpack(nv.data, nv.len, 0);
if (*nvl == NULL) {
- free(nv.data);
- return (EIO);
+ ret = EIO;
+ goto out;
}
} else {
ret = errno;
}
+out:
+ free(data);
free(nv.data);
return (ret);
@@ -144,9 +230,8 @@ pf_nvuint_32_array(const nvlist_t *nvl, const char *name, size_t maxelems,
size_t elems;
tmp = nvlist_get_number_array(nvl, name, &elems);
- assert(elems <= maxelems);
- for (size_t i = 0; i < elems; i++)
+ for (size_t i = 0; i < elems && i < maxelems; i++)
numbers[i] = tmp[i];
if (nelems)
@@ -170,6 +255,12 @@ pf_nvuint_64_array(const nvlist_t *nvl, const char *name, size_t maxelems,
*nelems = elems;
}
+int
+pfctl_startstop(struct pfctl_handle *h, int start)
+{
+ return (pfctl_do_netlink_cmd(h, start ? PFNL_CMD_START : PFNL_CMD_STOP));
+}
+
static void
_pfctl_get_status_counters(const nvlist_t *nvl,
struct pfctl_status_counters *counters)
@@ -190,6 +281,8 @@ _pfctl_get_status_counters(const nvlist_t *nvl,
struct pfctl_status_counter *c;
c = malloc(sizeof(*c));
+ if (c == NULL)
+ continue;
c->id = ids[i];
c->counter = counts[i];
@@ -199,6 +292,152 @@ _pfctl_get_status_counters(const nvlist_t *nvl,
}
}
+#define _OUT(_field) offsetof(struct pfctl_status_counter, _field)
+static const struct snl_attr_parser ap_counter[] = {
+ { .type = PF_C_COUNTER, .off = _OUT(counter), .cb = snl_attr_get_uint64 },
+ { .type = PF_C_NAME, .off = _OUT(name), .cb = snl_attr_get_string },
+ { .type = PF_C_ID, .off = _OUT(id), .cb = snl_attr_get_uint32 },
+};
+SNL_DECLARE_ATTR_PARSER(counter_parser, ap_counter);
+#undef _OUT
+
+static bool
+snl_attr_get_counters(struct snl_state *ss, struct nlattr *nla,
+ const void *arg __unused, void *target)
+{
+ struct pfctl_status_counter counter = {};
+ struct pfctl_status_counter *c;
+ bool error;
+
+ error = snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), &counter_parser, &counter);
+ if (! error)
+ return (error);
+
+ c = malloc(sizeof(*c));
+ if (c == NULL)
+ return (false);
+
+ c->id = counter.id;
+ c->counter = counter.counter;
+ c->name = strdup(counter.name);
+
+ TAILQ_INSERT_TAIL((struct pfctl_status_counters *)target, c, entry);
+
+ return (error);
+}
+
+struct snl_uint64_array {
+ uint64_t *array;
+ size_t count;
+ size_t max;
+};
+static bool
+snl_attr_get_uint64_element(struct snl_state *ss, struct nlattr *nla,
+ const void *arg, void *target)
+{
+ bool error;
+ uint64_t value;
+ struct snl_uint64_array *t = (struct snl_uint64_array *)target;
+
+ if (t->count >= t->max)
+ return (false);
+
+ error = snl_attr_get_uint64(ss, nla, arg, &value);
+ if (! error)
+ return (error);
+
+ t->array[t->count++] = value;
+
+ return (true);
+}
+
+static const struct snl_attr_parser ap_array[] = {
+ { .cb = snl_attr_get_uint64_element },
+};
+SNL_DECLARE_ATTR_PARSER(array_parser, ap_array);
+static bool
+snl_attr_get_uint64_array(struct snl_state *ss, struct nlattr *nla,
+ const void *arg, void *target)
+{
+ struct snl_uint64_array a = {
+ .array = target,
+ .count = 0,
+ .max = (size_t)arg,
+ };
+ bool error;
+
+ error = snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), &array_parser, &a);
+ if (! error)
+ return (error);
+
+ return (true);
+}
+
+#define _OUT(_field) offsetof(struct pfctl_status, _field)
+static const struct snl_attr_parser ap_getstatus[] = {
+ { .type = PF_GS_IFNAME, .off = _OUT(ifname), .arg_u32 = IFNAMSIZ, .cb = snl_attr_copy_string },
+ { .type = PF_GS_RUNNING, .off = _OUT(running), .cb = snl_attr_get_bool },
+ { .type = PF_GS_SINCE, .off = _OUT(since), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_DEBUG, .off = _OUT(debug), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_HOSTID, .off = _OUT(hostid), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_STATES, .off = _OUT(states), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_SRC_NODES, .off = _OUT(src_nodes), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_REASSEMBLE, .off = _OUT(reass), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_SYNCOOKIES_ACTIVE, .off = _OUT(syncookies_active), .cb = snl_attr_get_uint32 },
+ { .type = PF_GS_COUNTERS, .off = _OUT(counters), .cb = snl_attr_get_counters },
+ { .type = PF_GS_LCOUNTERS, .off = _OUT(lcounters), .cb = snl_attr_get_counters },
+ { .type = PF_GS_FCOUNTERS, .off = _OUT(fcounters), .cb = snl_attr_get_counters },
+ { .type = PF_GS_SCOUNTERS, .off = _OUT(scounters), .cb = snl_attr_get_counters },
+ { .type = PF_GS_CHKSUM, .off = _OUT(pf_chksum), .arg_u32 = PF_MD5_DIGEST_LENGTH, .cb = snl_attr_get_bytes },
+ { .type = PF_GS_BCOUNTERS, .off = _OUT(bcounters), .arg_u32 = 2 * 2, .cb = snl_attr_get_uint64_array },
+ { .type = PF_GS_PCOUNTERS, .off = _OUT(pcounters), .arg_u32 = 2 * 2 * 2, .cb = snl_attr_get_uint64_array },
+};
+SNL_DECLARE_PARSER(getstatus_parser, struct genlmsghdr, snl_f_p_empty, ap_getstatus);
+#undef _OUT
+
+struct pfctl_status *
+pfctl_get_status_h(struct pfctl_handle *h)
+{
+ struct pfctl_status *status;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ struct snl_writer nw;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (NULL);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_STATUS);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ hdr = snl_finalize_msg(&nw);
+ if (hdr == NULL) {
+ return (NULL);
+ }
+
+ seq_id = hdr->nlmsg_seq;
+ if (! snl_send_message(&h->ss, hdr))
+ return (NULL);
+
+ status = calloc(1, sizeof(*status));
+ if (status == NULL)
+ return (NULL);
+ TAILQ_INIT(&status->counters);
+ TAILQ_INIT(&status->lcounters);
+ TAILQ_INIT(&status->fcounters);
+ TAILQ_INIT(&status->scounters);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &getstatus_parser, status))
+ continue;
+ }
+
+ return (status);
+}
+
struct pfctl_status *
pfctl_get_status(int dev)
{
@@ -214,6 +453,7 @@ pfctl_get_status(int dev)
nvl = nvlist_create(0);
if (pfctl_do_ioctl(dev, DIOCGETSTATUSNV, 4096, &nvl)) {
+ nvlist_destroy(nvl);
free(status);
return (NULL);
}
@@ -242,7 +482,7 @@ pfctl_get_status(int dev)
_pfctl_get_status_counters(nvlist_get_nvlist(nvl, "scounters"),
&status->scounters);
- pf_nvuint_64_array(nvl, "pcounters", 2 * 2 * 3,
+ pf_nvuint_64_array(nvl, "pcounters", 2 * 2 * 2,
(uint64_t *)status->pcounters, NULL);
pf_nvuint_64_array(nvl, "bcounters", 2 * 2,
(uint64_t *)status->bcounters, NULL);
@@ -251,6 +491,11 @@ pfctl_get_status(int dev)
return (status);
}
+int
+pfctl_clear_status(struct pfctl_handle *h)
+{
+ return (pfctl_do_netlink_cmd(h, PFNL_CMD_CLEAR_STATUS));
+}
static uint64_t
_pfctl_status_counter(struct pfctl_status_counters *counters, uint64_t id)
@@ -272,6 +517,12 @@ pfctl_status_counter(struct pfctl_status *status, int id)
}
uint64_t
+pfctl_status_lcounter(struct pfctl_status *status, int id)
+{
+ return (_pfctl_status_counter(&status->lcounters, id));
+}
+
+uint64_t
pfctl_status_fcounter(struct pfctl_status *status, int id)
{
return (_pfctl_status_counter(&status->fcounters, id));
@@ -404,40 +655,6 @@ pf_nvrule_addr_to_rule_addr(const nvlist_t *nvl, struct pf_rule_addr *addr)
}
static void
-pfctl_nv_add_mape(nvlist_t *nvparent, const char *name,
- const struct pf_mape_portset *mape)
-{
- nvlist_t *nvl = nvlist_create(0);
-
- nvlist_add_number(nvl, "offset", mape->offset);
- nvlist_add_number(nvl, "psidlen", mape->psidlen);
- nvlist_add_number(nvl, "psid", mape->psid);
- nvlist_add_nvlist(nvparent, name, nvl);
- nvlist_destroy(nvl);
-}
-
-static void
-pfctl_nv_add_pool(nvlist_t *nvparent, const char *name,
- const struct pfctl_pool *pool)
-{
- uint64_t ports[2];
- nvlist_t *nvl = nvlist_create(0);
-
- nvlist_add_binary(nvl, "key", &pool->key, sizeof(pool->key));
- pfctl_nv_add_addr(nvl, "counter", &pool->counter);
- nvlist_add_number(nvl, "tblidx", pool->tblidx);
-
- ports[0] = pool->proxy_port[0];
- ports[1] = pool->proxy_port[1];
- nvlist_add_number_array(nvl, "proxy_port", ports, 2);
- nvlist_add_number(nvl, "opts", pool->opts);
- pfctl_nv_add_mape(nvl, "mape", &pool->mape);
-
- nvlist_add_nvlist(nvparent, name, nvl);
- nvlist_destroy(nvl);
-}
-
-static void
pf_nvmape_to_mape(const nvlist_t *nvl, struct pf_mape_portset *mape)
{
mape->offset = nvlist_get_number(nvl, "offset");
@@ -466,22 +683,6 @@ pf_nvpool_to_pool(const nvlist_t *nvl, struct pfctl_pool *pool)
}
static void
-pfctl_nv_add_uid(nvlist_t *nvparent, const char *name,
- const struct pf_rule_uid *uid)
-{
- uint64_t uids[2];
- nvlist_t *nvl = nvlist_create(0);
-
- uids[0] = uid->uid[0];
- uids[1] = uid->uid[1];
- nvlist_add_number_array(nvl, "uid", uids, 2);
- nvlist_add_number(nvl, "op", uid->op);
-
- nvlist_add_nvlist(nvparent, name, nvl);
- nvlist_destroy(nvl);
-}
-
-static void
pf_nvrule_uid_to_rule_uid(const nvlist_t *nvl, struct pf_rule_uid *uid)
{
pf_nvuint_32_array(nvl, "uid", 2, uid->uid, NULL);
@@ -489,19 +690,6 @@ pf_nvrule_uid_to_rule_uid(const nvlist_t *nvl, struct pf_rule_uid *uid)
}
static void
-pfctl_nv_add_divert(nvlist_t *nvparent, const char *name,
- const struct pfctl_rule *r)
-{
- nvlist_t *nvl = nvlist_create(0);
-
- pfctl_nv_add_addr(nvl, "addr", &r->divert.addr);
- nvlist_add_number(nvl, "port", r->divert.port);
-
- nvlist_add_nvlist(nvparent, name, nvl);
- nvlist_destroy(nvl);
-}
-
-static void
pf_nvdivert_to_divert(const nvlist_t *nvl, struct pfctl_rule *rule)
{
pf_nvaddr_to_addr(nvlist_get_nvlist(nvl, "addr"), &rule->divert.addr);
@@ -542,7 +730,7 @@ pf_nvrule_to_rule(const nvlist_t *nvl, struct pfctl_rule *rule)
strlcpy(rule->overload_tblname, nvlist_get_string(nvl, "overload_tblname"),
PF_TABLE_NAME_SIZE);
- pf_nvpool_to_pool(nvlist_get_nvlist(nvl, "rpool"), &rule->rpool);
+ pf_nvpool_to_pool(nvlist_get_nvlist(nvl, "rpool"), &rule->rdr);
rule->evaluations = nvlist_get_number(nvl, "evaluations");
pf_nvuint_64_array(nvl, "packets", 2, rule->packets, NULL);
@@ -728,12 +916,13 @@ pfctl_get_eth_rulesets_info(int dev, struct pfctl_eth_rulesets_info *ri,
nvlist_add_string(nvl, "path", path);
if ((ret = pfctl_do_ioctl(dev, DIOCGETETHRULESETS, 256, &nvl)) != 0)
- return (ret);
+ goto out;
ri->nr = nvlist_get_number(nvl, "nr");
+out:
nvlist_destroy(nvl);
- return (0);
+ return (ret);
}
int
@@ -750,14 +939,16 @@ pfctl_get_eth_ruleset(int dev, const char *path, int nr,
nvlist_add_number(nvl, "nr", nr);
if ((ret = pfctl_do_ioctl(dev, DIOCGETETHRULESET, 1024, &nvl)) != 0)
- return (ret);
+ goto out;
ri->nr = nvlist_get_number(nvl, "nr");
strlcpy(ri->path, nvlist_get_string(nvl, "path"), MAXPATHLEN);
strlcpy(ri->name, nvlist_get_string(nvl, "name"),
PF_ANCHOR_NAME_SIZE);
- return (0);
+out:
+ nvlist_destroy(nvl);
+ return (ret);
}
int
@@ -773,13 +964,14 @@ pfctl_get_eth_rules_info(int dev, struct pfctl_eth_rules_info *rules,
nvlist_add_string(nvl, "anchor", path);
if ((ret = pfctl_do_ioctl(dev, DIOCGETETHRULES, 1024, &nvl)) != 0)
- return (ret);
+ goto out;
rules->nr = nvlist_get_number(nvl, "nr");
rules->ticket = nvlist_get_number(nvl, "ticket");
+out:
nvlist_destroy(nvl);
- return (0);
+ return (ret);
}
int
@@ -798,7 +990,7 @@ pfctl_get_eth_rule(int dev, uint32_t nr, uint32_t ticket,
nvlist_add_bool(nvl, "clear", clear);
if ((ret = pfctl_do_ioctl(dev, DIOCGETETHRULE, 4096, &nvl)) != 0)
- return (ret);
+ goto out;
pfctl_nveth_rule_to_eth_rule(nvl, rule);
@@ -806,8 +998,9 @@ pfctl_get_eth_rule(int dev, uint32_t nr, uint32_t ticket,
strlcpy(anchor_call, nvlist_get_string(nvl, "anchor_call"),
MAXPATHLEN);
+out:
nvlist_destroy(nvl);
- return (0);
+ return (ret);
}
int
@@ -855,8 +1048,8 @@ pfctl_add_eth_rule(int dev, const struct pfctl_eth_rule *r, const char *anchor,
pfctl_nv_add_rule_addr(nvl, "ipdst", &r->ipdst);
labelcount = 0;
- while (r->label[labelcount][0] != 0 &&
- labelcount < PF_RULE_MAX_LABEL_COUNT) {
+ while (labelcount < PF_RULE_MAX_LABEL_COUNT &&
+ r->label[labelcount][0] != 0) {
nvlist_append_string_array(nvl, "labels",
r->label[labelcount]);
labelcount++;
@@ -891,149 +1084,357 @@ pfctl_add_eth_rule(int dev, const struct pfctl_eth_rule *r, const char *anchor,
return (error);
}
-int
-pfctl_add_rule(int dev, const struct pfctl_rule *r, const char *anchor,
- const char *anchor_call, uint32_t ticket, uint32_t pool_ticket)
+static void
+snl_add_msg_attr_addr_wrap(struct snl_writer *nw, uint32_t type, const struct pf_addr_wrap *addr)
{
- struct pfioc_nv nv;
- uint64_t timeouts[PFTM_MAX];
- uint64_t set_prio[2];
- nvlist_t *nvl, *nvlr;
- size_t labelcount;
- int ret;
+ int off;
- nvl = nvlist_create(0);
- nvlr = nvlist_create(0);
+ off = snl_add_msg_attr_nested(nw, type);
- nvlist_add_number(nvl, "ticket", ticket);
- nvlist_add_number(nvl, "pool_ticket", pool_ticket);
- nvlist_add_string(nvl, "anchor", anchor);
- nvlist_add_string(nvl, "anchor_call", anchor_call);
+ snl_add_msg_attr_ip6(nw, PF_AT_ADDR, &addr->v.a.addr.v6);
+ snl_add_msg_attr_ip6(nw, PF_AT_MASK, &addr->v.a.mask.v6);
+
+ if (addr->type == PF_ADDR_DYNIFTL)
+ snl_add_msg_attr_string(nw, PF_AT_IFNAME, addr->v.ifname);
+ if (addr->type == PF_ADDR_TABLE)
+ snl_add_msg_attr_string(nw, PF_AT_TABLENAME, addr->v.tblname);
+ snl_add_msg_attr_u8(nw, PF_AT_TYPE, addr->type);
+ snl_add_msg_attr_u8(nw, PF_AT_IFLAGS, addr->iflags);
- nvlist_add_number(nvlr, "nr", r->nr);
- pfctl_nv_add_rule_addr(nvlr, "src", &r->src);
- pfctl_nv_add_rule_addr(nvlr, "dst", &r->dst);
+ snl_end_attr_nested(nw, off);
+}
- labelcount = 0;
- while (r->label[labelcount][0] != 0 &&
- labelcount < PF_RULE_MAX_LABEL_COUNT) {
- nvlist_append_string_array(nvlr, "labels",
- r->label[labelcount]);
- labelcount++;
+static void
+snl_add_msg_attr_pool_addr(struct snl_writer *nw, uint32_t type, const struct pf_pooladdr *pa)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr_string(nw, PF_PA_IFNAME, pa->ifname);
+ snl_add_msg_attr_addr_wrap(nw, PF_PA_ADDR, &pa->addr);
+
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_rule_addr(struct snl_writer *nw, uint32_t type, const struct pf_rule_addr *addr)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr_addr_wrap(nw, PF_RAT_ADDR, &addr->addr);
+ snl_add_msg_attr_u16(nw, PF_RAT_SRC_PORT, addr->port[0]);
+ snl_add_msg_attr_u16(nw, PF_RAT_DST_PORT, addr->port[1]);
+ snl_add_msg_attr_u8(nw, PF_RAT_NEG, addr->neg);
+ snl_add_msg_attr_u8(nw, PF_RAT_OP, addr->port_op);
+
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_rule_labels(struct snl_writer *nw, uint32_t type, const char labels[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE])
+{
+ int off, i = 0;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ while (i < PF_RULE_MAX_LABEL_COUNT &&
+ labels[i][0] != 0) {
+ snl_add_msg_attr_string(nw, PF_LT_LABEL, labels[i]);
+ i++;
}
- nvlist_add_number(nvlr, "ridentifier", r->ridentifier);
- nvlist_add_string(nvlr, "ifname", r->ifname);
- nvlist_add_string(nvlr, "qname", r->qname);
- nvlist_add_string(nvlr, "pqname", r->pqname);
- nvlist_add_string(nvlr, "tagname", r->tagname);
- nvlist_add_string(nvlr, "match_tagname", r->match_tagname);
- nvlist_add_string(nvlr, "overload_tblname", r->overload_tblname);
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_mape(struct snl_writer *nw, uint32_t type, const struct pf_mape_portset *me)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr_u8(nw, PF_MET_OFFSET, me->offset);
+ snl_add_msg_attr_u8(nw, PF_MET_PSID_LEN, me->psidlen);
+ snl_add_msg_attr_u16(nw, PF_MET_PSID, me->psid);
- pfctl_nv_add_pool(nvlr, "rpool", &r->rpool);
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_rpool(struct snl_writer *nw, uint32_t type, const struct pfctl_pool *pool)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr(nw, PF_PT_KEY, sizeof(pool->key), &pool->key);
+ snl_add_msg_attr_ip6(nw, PF_PT_COUNTER, &pool->counter.v6);
+ snl_add_msg_attr_u32(nw, PF_PT_TBLIDX, pool->tblidx);
+ snl_add_msg_attr_u16(nw, PF_PT_PROXY_SRC_PORT, pool->proxy_port[0]);
+ snl_add_msg_attr_u16(nw, PF_PT_PROXY_DST_PORT, pool->proxy_port[1]);
+ snl_add_msg_attr_u8(nw, PF_PT_OPTS, pool->opts);
+ snl_add_msg_attr_mape(nw, PF_PT_MAPE, &pool->mape);
- nvlist_add_number(nvlr, "os_fingerprint", r->os_fingerprint);
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_timeouts(struct snl_writer *nw, uint32_t type, const uint32_t *timeouts)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
- nvlist_add_number(nvlr, "rtableid", r->rtableid);
for (int i = 0; i < PFTM_MAX; i++)
- timeouts[i] = r->timeout[i];
- nvlist_add_number_array(nvlr, "timeout", timeouts, PFTM_MAX);
- nvlist_add_number(nvlr, "max_states", r->max_states);
- nvlist_add_number(nvlr, "max_src_nodes", r->max_src_nodes);
- nvlist_add_number(nvlr, "max_src_states", r->max_src_states);
- nvlist_add_number(nvlr, "max_src_conn", r->max_src_conn);
- nvlist_add_number(nvlr, "max_src_conn_rate.limit",
- r->max_src_conn_rate.limit);
- nvlist_add_number(nvlr, "max_src_conn_rate.seconds",
- r->max_src_conn_rate.seconds);
- nvlist_add_number(nvlr, "dnpipe", r->dnpipe);
- nvlist_add_number(nvlr, "dnrpipe", r->dnrpipe);
- nvlist_add_number(nvlr, "dnflags", r->free_flags);
- nvlist_add_number(nvlr, "prob", r->prob);
- nvlist_add_number(nvlr, "cuid", r->cuid);
- nvlist_add_number(nvlr, "cpid", r->cpid);
-
- nvlist_add_number(nvlr, "return_icmp", r->return_icmp);
- nvlist_add_number(nvlr, "return_icmp6", r->return_icmp6);
-
- nvlist_add_number(nvlr, "max_mss", r->max_mss);
- nvlist_add_number(nvlr, "scrub_flags", r->scrub_flags);
-
- pfctl_nv_add_uid(nvlr, "uid", &r->uid);
- pfctl_nv_add_uid(nvlr, "gid", (const struct pf_rule_uid *)&r->gid);
-
- nvlist_add_number(nvlr, "rule_flag", r->rule_flag);
- nvlist_add_number(nvlr, "action", r->action);
- nvlist_add_number(nvlr, "direction", r->direction);
- nvlist_add_number(nvlr, "log", r->log);
- nvlist_add_number(nvlr, "logif", r->logif);
- nvlist_add_number(nvlr, "quick", r->quick);
- nvlist_add_number(nvlr, "ifnot", r->ifnot);
- nvlist_add_number(nvlr, "match_tag_not", r->match_tag_not);
- nvlist_add_number(nvlr, "natpass", r->natpass);
-
- nvlist_add_number(nvlr, "keep_state", r->keep_state);
- nvlist_add_number(nvlr, "af", r->af);
- nvlist_add_number(nvlr, "proto", r->proto);
- nvlist_add_number(nvlr, "type", r->type);
- nvlist_add_number(nvlr, "code", r->code);
- nvlist_add_number(nvlr, "flags", r->flags);
- nvlist_add_number(nvlr, "flagset", r->flagset);
- nvlist_add_number(nvlr, "min_ttl", r->min_ttl);
- nvlist_add_number(nvlr, "allow_opts", r->allow_opts);
- nvlist_add_number(nvlr, "rt", r->rt);
- nvlist_add_number(nvlr, "return_ttl", r->return_ttl);
- nvlist_add_number(nvlr, "tos", r->tos);
- nvlist_add_number(nvlr, "set_tos", r->set_tos);
- nvlist_add_number(nvlr, "anchor_relative", r->anchor_relative);
- nvlist_add_number(nvlr, "anchor_wildcard", r->anchor_wildcard);
-
- nvlist_add_number(nvlr, "flush", r->flush);
-
- nvlist_add_number(nvlr, "prio", r->prio);
- set_prio[0] = r->set_prio[0];
- set_prio[1] = r->set_prio[1];
- nvlist_add_number_array(nvlr, "set_prio", set_prio, 2);
-
- pfctl_nv_add_divert(nvlr, "divert", r);
-
- nvlist_add_nvlist(nvl, "rule", nvlr);
- nvlist_destroy(nvlr);
-
- /* Now do the call. */
- nv.data = nvlist_pack(nvl, &nv.len);
- nv.size = nv.len;
+ snl_add_msg_attr_u32(nw, PF_TT_TIMEOUT, timeouts[i]);
- ret = ioctl(dev, DIOCADDRULENV, &nv);
- if (ret == -1)
- ret = errno;
+ snl_end_attr_nested(nw, off);
+}
- free(nv.data);
- nvlist_destroy(nvl);
+static void
+snl_add_msg_attr_uid(struct snl_writer *nw, uint32_t type, const struct pf_rule_uid *uid)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr_u32(nw, PF_RUT_UID_LOW, uid->uid[0]);
+ snl_add_msg_attr_u32(nw, PF_RUT_UID_HIGH, uid->uid[1]);
+ snl_add_msg_attr_u8(nw, PF_RUT_OP, uid->op);
+
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_threshold(struct snl_writer *nw, uint32_t type, const struct pfctl_threshold *th)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr_u32(nw, PF_TH_LIMIT, th->limit);
+ snl_add_msg_attr_u32(nw, PF_TH_SECONDS, th->seconds);
+
+ snl_end_attr_nested(nw, off);
+}
+
+static void
+snl_add_msg_attr_pf_rule(struct snl_writer *nw, uint32_t type, const struct pfctl_rule *r)
+{
+ int off;
+
+ off = snl_add_msg_attr_nested(nw, type);
+
+ snl_add_msg_attr_rule_addr(nw, PF_RT_SRC, &r->src);
+ snl_add_msg_attr_rule_addr(nw, PF_RT_DST, &r->dst);
+ snl_add_msg_attr_rule_labels(nw, PF_RT_LABELS, r->label);
+ snl_add_msg_attr_u32(nw, PF_RT_RIDENTIFIER, r->ridentifier);
+ snl_add_msg_attr_string(nw, PF_RT_IFNAME, r->ifname);
+ snl_add_msg_attr_string(nw, PF_RT_QNAME, r->qname);
+ snl_add_msg_attr_string(nw, PF_RT_PQNAME, r->pqname);
+ snl_add_msg_attr_string(nw, PF_RT_TAGNAME, r->tagname);
+ snl_add_msg_attr_string(nw, PF_RT_MATCH_TAGNAME, r->match_tagname);
+ snl_add_msg_attr_string(nw, PF_RT_OVERLOAD_TBLNAME, r->overload_tblname);
+ snl_add_msg_attr_rpool(nw, PF_RT_RPOOL_RDR, &r->rdr);
+ snl_add_msg_attr_rpool(nw, PF_RT_RPOOL_NAT, &r->nat);
+ snl_add_msg_attr_rpool(nw, PF_RT_RPOOL_RT, &r->route);
+ snl_add_msg_attr_threshold(nw, PF_RT_PKTRATE, &r->pktrate);
+ snl_add_msg_attr_u32(nw, PF_RT_OS_FINGERPRINT, r->os_fingerprint);
+ snl_add_msg_attr_u32(nw, PF_RT_RTABLEID, r->rtableid);
+ snl_add_msg_attr_timeouts(nw, PF_RT_TIMEOUT, r->timeout);
+ snl_add_msg_attr_u32(nw, PF_RT_MAX_STATES, r->max_states);
+ snl_add_msg_attr_u32(nw, PF_RT_MAX_SRC_NODES, r->max_src_nodes);
+ snl_add_msg_attr_u32(nw, PF_RT_MAX_SRC_STATES, r->max_src_states);
+ snl_add_msg_attr_u32(nw, PF_RT_MAX_SRC_CONN, r->max_src_conn);
+ snl_add_msg_attr_u32(nw, PF_RT_MAX_SRC_CONN_RATE_LIMIT, r->max_src_conn_rate.limit);
+ snl_add_msg_attr_u32(nw, PF_RT_MAX_SRC_CONN_RATE_SECS, r->max_src_conn_rate.seconds);
+ snl_add_msg_attr_u16(nw, PF_RT_MAX_PKT_SIZE, r->max_pkt_size);
+
+ snl_add_msg_attr_u16(nw, PF_RT_DNPIPE, r->dnpipe);
+ snl_add_msg_attr_u16(nw, PF_RT_DNRPIPE, r->dnrpipe);
+ snl_add_msg_attr_u32(nw, PF_RT_DNFLAGS, r->free_flags);
+
+ snl_add_msg_attr_u32(nw, PF_RT_NR, r->nr);
+ snl_add_msg_attr_u32(nw, PF_RT_PROB, r->prob);
+ snl_add_msg_attr_u32(nw, PF_RT_CUID, r->cuid);
+ snl_add_msg_attr_u32(nw, PF_RT_CPID, r->cpid);
+
+ snl_add_msg_attr_u16(nw, PF_RT_RETURN_ICMP, r->return_icmp);
+ snl_add_msg_attr_u16(nw, PF_RT_RETURN_ICMP6, r->return_icmp6);
+ snl_add_msg_attr_u16(nw, PF_RT_MAX_MSS, r->max_mss);
+ snl_add_msg_attr_u16(nw, PF_RT_SCRUB_FLAGS, r->scrub_flags);
+
+ snl_add_msg_attr_uid(nw, PF_RT_UID, &r->uid);
+ snl_add_msg_attr_uid(nw, PF_RT_GID, (const struct pf_rule_uid *)&r->gid);
+ snl_add_msg_attr_string(nw, PF_RT_RCV_IFNAME, r->rcv_ifname);
+ snl_add_msg_attr_bool(nw, PF_RT_RCV_IFNOT, r->rcvifnot);
+
+ snl_add_msg_attr_u32(nw, PF_RT_RULE_FLAG, r->rule_flag);
+ snl_add_msg_attr_u8(nw, PF_RT_ACTION, r->action);
+ snl_add_msg_attr_u8(nw, PF_RT_DIRECTION, r->direction);
+ snl_add_msg_attr_u8(nw, PF_RT_LOG, r->log);
+ snl_add_msg_attr_u8(nw, PF_RT_LOGIF, r->logif);
+ snl_add_msg_attr_u8(nw, PF_RT_QUICK, r->quick);
+ snl_add_msg_attr_u8(nw, PF_RT_IF_NOT, r->ifnot);
+ snl_add_msg_attr_u8(nw, PF_RT_MATCH_TAG_NOT, r->match_tag_not);
+ snl_add_msg_attr_u8(nw, PF_RT_NATPASS, r->natpass);
+ snl_add_msg_attr_u8(nw, PF_RT_KEEP_STATE, r->keep_state);
+ snl_add_msg_attr_u8(nw, PF_RT_AF, r->af);
+ snl_add_msg_attr_u8(nw, PF_RT_PROTO, r->proto);
+ snl_add_msg_attr_u8(nw, PF_RT_TYPE, r->type);
+ snl_add_msg_attr_u8(nw, PF_RT_CODE, r->code);
+ snl_add_msg_attr_u8(nw, PF_RT_FLAGS, r->flags);
+ snl_add_msg_attr_u8(nw, PF_RT_FLAGSET, r->flagset);
+ snl_add_msg_attr_u8(nw, PF_RT_MIN_TTL, r->min_ttl);
+ snl_add_msg_attr_u8(nw, PF_RT_ALLOW_OPTS, r->allow_opts);
+ snl_add_msg_attr_u8(nw, PF_RT_RT, r->rt);
+ snl_add_msg_attr_u8(nw, PF_RT_RETURN_TTL, r->return_ttl);
+ snl_add_msg_attr_u8(nw, PF_RT_TOS, r->tos);
+ snl_add_msg_attr_u8(nw, PF_RT_SET_TOS, r->set_tos);
+
+ snl_add_msg_attr_u8(nw, PF_RT_ANCHOR_RELATIVE, r->anchor_relative);
+ snl_add_msg_attr_u8(nw, PF_RT_ANCHOR_WILDCARD, r->anchor_wildcard);
+ snl_add_msg_attr_u8(nw, PF_RT_FLUSH, r->flush);
+ snl_add_msg_attr_u8(nw, PF_RT_PRIO, r->prio);
+ snl_add_msg_attr_u8(nw, PF_RT_SET_PRIO, r->set_prio[0]);
+ snl_add_msg_attr_u8(nw, PF_RT_SET_PRIO_REPLY, r->set_prio[1]);
+ snl_add_msg_attr_u8(nw, PF_RT_NAF, r->naf);
+
+ snl_add_msg_attr_ip6(nw, PF_RT_DIVERT_ADDRESS, &r->divert.addr.v6);
+ snl_add_msg_attr_u16(nw, PF_RT_DIVERT_PORT, r->divert.port);
+
+ snl_end_attr_nested(nw, off);
+}
+
+int
+pfctl_add_rule(int dev __unused, const struct pfctl_rule *r, const char *anchor,
+ const char *anchor_call, uint32_t ticket, uint32_t pool_ticket)
+{
+ struct pfctl_handle *h;
+ int ret;
+
+ h = pfctl_open(PF_DEVICE);
+ if (h == NULL)
+ return (ENODEV);
+
+ ret = pfctl_add_rule_h(h, r, anchor, anchor_call, ticket, pool_ticket);
+
+ pfctl_close(h);
return (ret);
}
int
-pfctl_get_rules_info(int dev, struct pfctl_rules_info *rules, uint32_t ruleset,
+pfctl_add_rule_h(struct pfctl_handle *h, const struct pfctl_rule *r,
+ const char *anchor, const char *anchor_call, uint32_t ticket,
+ uint32_t pool_ticket)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_ADDRULE);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+ snl_add_msg_attr_u32(&nw, PF_ART_TICKET, ticket);
+ snl_add_msg_attr_u32(&nw, PF_ART_POOL_TICKET, pool_ticket);
+ snl_add_msg_attr_string(&nw, PF_ART_ANCHOR, anchor);
+ snl_add_msg_attr_string(&nw, PF_ART_ANCHOR_CALL, anchor_call);
+
+ snl_add_msg_attr_pf_rule(&nw, PF_ART_RULE, r);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
+#define _IN(_field) offsetof(struct genlmsghdr, _field)
+#define _OUT(_field) offsetof(struct pfctl_rules_info, _field)
+static struct snl_attr_parser ap_getrules[] = {
+ { .type = PF_GR_NR, .off = _OUT(nr), .cb = snl_attr_get_uint32 },
+ { .type = PF_GR_TICKET, .off = _OUT(ticket), .cb = snl_attr_get_uint32 },
+};
+#undef _IN
+#undef _OUT
+SNL_DECLARE_PARSER(getrules_parser, struct genlmsghdr, snl_f_p_empty, ap_getrules);
+
+int
+pfctl_get_rules_info_h(struct pfctl_handle *h, struct pfctl_rules_info *rules, uint32_t ruleset,
const char *path)
{
- struct pfioc_rule pr;
- int ret;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ struct snl_writer nw;
+ uint32_t seq_id;
+ int family_id;
- bzero(&pr, sizeof(pr));
- if (strlcpy(pr.anchor, path, sizeof(pr.anchor)) >= sizeof(pr.anchor))
- return (E2BIG);
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
- pr.rule.action = ruleset;
- ret = ioctl(dev, DIOCGETRULES, &pr);
- if (ret != 0)
- return (ret);
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GETRULES);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
- rules->nr = pr.nr;
- rules->ticket = pr.ticket;
+ snl_add_msg_attr_string(&nw, PF_GR_ANCHOR, path);
+ snl_add_msg_attr_u8(&nw, PF_GR_ACTION, ruleset);
- return (0);
+ hdr = snl_finalize_msg(&nw);
+ if (hdr == NULL)
+ return (ENOMEM);
+
+ seq_id = hdr->nlmsg_seq;
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &getrules_parser, rules))
+ continue;
+ }
+
+ return (e.error);
+}
+
+int
+pfctl_get_rules_info(int dev __unused, struct pfctl_rules_info *rules, uint32_t ruleset,
+ const char *path)
+{
+ struct pfctl_handle *h;
+ int error;
+
+ h = pfctl_open(PF_DEVICE);
+ if (h == NULL)
+ return (ENOTSUP);
+ error = pfctl_get_rules_info_h(h, rules, ruleset, path);
+ pfctl_close(h);
+
+ return (error);
+}
+
+int
+pfctl_get_rule_h(struct pfctl_handle *h, uint32_t nr, uint32_t ticket, const char *anchor,
+ uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call)
+{
+ return (pfctl_get_clear_rule_h(h, nr, ticket, anchor, ruleset, rule,
+ anchor_call, false));
}
int
@@ -1044,7 +1445,306 @@ pfctl_get_rule(int dev, uint32_t nr, uint32_t ticket, const char *anchor,
anchor_call, false));
}
-int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket,
+#define _OUT(_field) offsetof(struct pf_addr_wrap, _field)
+static const struct snl_attr_parser ap_addr_wrap[] = {
+ { .type = PF_AT_ADDR, .off = _OUT(v.a.addr), .cb = snl_attr_get_in6_addr },
+ { .type = PF_AT_MASK, .off = _OUT(v.a.mask), .cb = snl_attr_get_in6_addr },
+ { .type = PF_AT_IFNAME, .off = _OUT(v.ifname), .arg = (void *)IFNAMSIZ,.cb = snl_attr_copy_string },
+ { .type = PF_AT_TABLENAME, .off = _OUT(v.tblname), .arg = (void *)PF_TABLE_NAME_SIZE, .cb = snl_attr_copy_string },
+ { .type = PF_AT_TYPE, .off = _OUT(type), .cb = snl_attr_get_uint8 },
+ { .type = PF_AT_IFLAGS, .off = _OUT(iflags), .cb = snl_attr_get_uint8 },
+ { .type = PF_AT_TBLCNT, .off = _OUT(p.tblcnt), .cb = snl_attr_get_uint32 },
+ { .type = PF_AT_DYNCNT, .off = _OUT(p.dyncnt), .cb = snl_attr_get_uint32 },
+};
+SNL_DECLARE_ATTR_PARSER(addr_wrap_parser, ap_addr_wrap);
+#undef _OUT
+
+#define _OUT(_field) offsetof(struct pf_rule_addr, _field)
+static struct snl_attr_parser ap_rule_addr[] = {
+ { .type = PF_RAT_ADDR, .off = _OUT(addr), .arg = &addr_wrap_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RAT_SRC_PORT, .off = _OUT(port[0]), .cb = snl_attr_get_uint16 },
+ { .type = PF_RAT_DST_PORT, .off = _OUT(port[1]), .cb = snl_attr_get_uint16 },
+ { .type = PF_RAT_NEG, .off = _OUT(neg), .cb = snl_attr_get_uint8 },
+ { .type = PF_RAT_OP, .off = _OUT(port_op), .cb = snl_attr_get_uint8 },
+};
+#undef _OUT
+SNL_DECLARE_ATTR_PARSER(rule_addr_parser, ap_rule_addr);
+
+struct snl_parsed_labels
+{
+ char labels[PF_RULE_MAX_LABEL_COUNT][PF_RULE_LABEL_SIZE];
+ uint32_t i;
+};
+
+static bool
+snl_attr_get_pf_rule_labels(struct snl_state *ss, struct nlattr *nla,
+ const void *arg __unused, void *target)
+{
+ struct snl_parsed_labels *l = (struct snl_parsed_labels *)target;
+ bool ret;
+
+ if (l->i >= PF_RULE_MAX_LABEL_COUNT)
+ return (E2BIG);
+
+ ret = snl_attr_copy_string(ss, nla, (void *)PF_RULE_LABEL_SIZE,
+ l->labels[l->i]);
+ if (ret)
+ l->i++;
+
+ return (ret);
+}
+
+#define _OUT(_field) offsetof(struct nl_parsed_labels, _field)
+static const struct snl_attr_parser ap_labels[] = {
+ { .type = PF_LT_LABEL, .off = 0, .cb = snl_attr_get_pf_rule_labels },
+};
+SNL_DECLARE_ATTR_PARSER(rule_labels_parser, ap_labels);
+#undef _OUT
+
+static bool
+snl_attr_get_nested_pf_rule_labels(struct snl_state *ss, struct nlattr *nla,
+ const void *arg __unused, void *target)
+{
+ struct snl_parsed_labels parsed_labels = { };
+ bool error;
+
+ /* Assumes target points to the beginning of the structure */
+ error = snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), &rule_labels_parser, &parsed_labels);
+ if (! error)
+ return (error);
+
+ memcpy(target, parsed_labels.labels, sizeof(parsed_labels.labels));
+
+ return (true);
+}
+
+#define _OUT(_field) offsetof(struct pf_mape_portset, _field)
+static const struct snl_attr_parser ap_mape_portset[] = {
+ { .type = PF_MET_OFFSET, .off = _OUT(offset), .cb = snl_attr_get_uint8 },
+ { .type = PF_MET_PSID_LEN, .off = _OUT(psidlen), .cb = snl_attr_get_uint8 },
+ {. type = PF_MET_PSID, .off = _OUT(psid), .cb = snl_attr_get_uint16 },
+};
+SNL_DECLARE_ATTR_PARSER(mape_portset_parser, ap_mape_portset);
+#undef _OUT
+
+#define _OUT(_field) offsetof(struct pfctl_pool, _field)
+static const struct snl_attr_parser ap_pool[] = {
+ { .type = PF_PT_KEY, .off = _OUT(key), .arg = (void *)sizeof(struct pf_poolhashkey), .cb = snl_attr_get_bytes },
+ { .type = PF_PT_COUNTER, .off = _OUT(counter), .cb = snl_attr_get_in6_addr },
+ { .type = PF_PT_TBLIDX, .off = _OUT(tblidx), .cb = snl_attr_get_uint32 },
+ { .type = PF_PT_PROXY_SRC_PORT, .off = _OUT(proxy_port[0]), .cb = snl_attr_get_uint16 },
+ { .type = PF_PT_PROXY_DST_PORT, .off = _OUT(proxy_port[1]), .cb = snl_attr_get_uint16 },
+ { .type = PF_PT_OPTS, .off = _OUT(opts), .cb = snl_attr_get_uint8 },
+ { .type = PF_PT_MAPE, .off = _OUT(mape), .arg = &mape_portset_parser, .cb = snl_attr_get_nested },
+};
+SNL_DECLARE_ATTR_PARSER(pool_parser, ap_pool);
+#undef _OUT
+
+struct nl_parsed_timeouts
+{
+ uint32_t timeouts[PFTM_MAX];
+ uint32_t i;
+};
+
+static bool
+snl_attr_get_pf_timeout(struct snl_state *ss, struct nlattr *nla,
+ const void *arg __unused, void *target)
+{
+ struct nl_parsed_timeouts *t = (struct nl_parsed_timeouts *)target;
+ bool ret;
+
+ if (t->i >= PFTM_MAX)
+ return (E2BIG);
+
+ ret = snl_attr_get_uint32(ss, nla, NULL, &t->timeouts[t->i]);
+ if (ret)
+ t->i++;
+
+ return (ret);
+}
+
+#define _OUT(_field) offsetof(struct nl_parsed_timeout, _field)
+static const struct snl_attr_parser ap_timeouts[] = {
+ { .type = PF_TT_TIMEOUT, .off = 0, .cb = snl_attr_get_pf_timeout },
+};
+SNL_DECLARE_ATTR_PARSER(timeout_parser, ap_timeouts);
+#undef _OUT
+
+static bool
+snl_attr_get_nested_timeouts(struct snl_state *ss, struct nlattr *nla,
+ const void *arg __unused, void *target)
+{
+ struct nl_parsed_timeouts parsed_timeouts = { };
+ bool error;
+
+ /* Assumes target points to the beginning of the structure */
+ error = snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), &timeout_parser, &parsed_timeouts);
+ if (! error)
+ return (error);
+
+ memcpy(target, parsed_timeouts.timeouts, sizeof(parsed_timeouts.timeouts));
+
+ return (true);
+}
+
+#define _OUT(_field) offsetof(struct pf_rule_uid, _field)
+static const struct snl_attr_parser ap_rule_uid[] = {
+ { .type = PF_RUT_UID_LOW, .off = _OUT(uid[0]), .cb = snl_attr_get_uint32 },
+ { .type = PF_RUT_UID_HIGH, .off = _OUT(uid[1]), .cb = snl_attr_get_uint32 },
+ { .type = PF_RUT_OP, .off = _OUT(op), .cb = snl_attr_get_uint8 },
+};
+SNL_DECLARE_ATTR_PARSER(rule_uid_parser, ap_rule_uid);
+#undef _OUT
+
+#define _OUT(_field) offsetof(struct pfctl_threshold, _field)
+static const struct snl_attr_parser ap_pfctl_threshold[] = {
+ { .type = PF_TH_LIMIT, .off = _OUT(limit), .cb = snl_attr_get_uint32 },
+ { .type = PF_TH_SECONDS, .off = _OUT(seconds), .cb = snl_attr_get_uint32 },
+ { .type = PF_TH_COUNT, .off = _OUT(count), .cb = snl_attr_get_uint32 },
+};
+SNL_DECLARE_ATTR_PARSER(pfctl_threshold_parser, ap_pfctl_threshold);
+#undef _OUT
+
+struct pfctl_nl_get_rule {
+ struct pfctl_rule r;
+ char anchor_call[MAXPATHLEN];
+};
+#define _OUT(_field) offsetof(struct pfctl_nl_get_rule, _field)
+static struct snl_attr_parser ap_getrule[] = {
+ { .type = PF_RT_SRC, .off = _OUT(r.src), .arg = &rule_addr_parser,.cb = snl_attr_get_nested },
+ { .type = PF_RT_DST, .off = _OUT(r.dst), .arg = &rule_addr_parser,.cb = snl_attr_get_nested },
+ { .type = PF_RT_RIDENTIFIER, .off = _OUT(r.ridentifier), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_LABELS, .off = _OUT(r.label), .arg = &rule_labels_parser,.cb = snl_attr_get_nested_pf_rule_labels },
+ { .type = PF_RT_IFNAME, .off = _OUT(r.ifname), .arg = (void *)IFNAMSIZ, .cb = snl_attr_copy_string },
+ { .type = PF_RT_QNAME, .off = _OUT(r.qname), .arg = (void *)PF_QNAME_SIZE, .cb = snl_attr_copy_string },
+ { .type = PF_RT_PQNAME, .off = _OUT(r.pqname), .arg = (void *)PF_QNAME_SIZE, .cb = snl_attr_copy_string },
+ { .type = PF_RT_TAGNAME, .off = _OUT(r.tagname), .arg = (void *)PF_TAG_NAME_SIZE, .cb = snl_attr_copy_string },
+ { .type = PF_RT_MATCH_TAGNAME, .off = _OUT(r.match_tagname), .arg = (void *)PF_TAG_NAME_SIZE, .cb = snl_attr_copy_string },
+ { .type = PF_RT_OVERLOAD_TBLNAME, .off = _OUT(r.overload_tblname), .arg = (void *)PF_TABLE_NAME_SIZE, .cb = snl_attr_copy_string },
+ { .type = PF_RT_RPOOL_RDR, .off = _OUT(r.rdr), .arg = &pool_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RT_OS_FINGERPRINT, .off = _OUT(r.os_fingerprint), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_RTABLEID, .off = _OUT(r.rtableid), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_TIMEOUT, .off = _OUT(r.timeout), .arg = &timeout_parser, .cb = snl_attr_get_nested_timeouts },
+ { .type = PF_RT_MAX_STATES, .off = _OUT(r.max_states), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_MAX_SRC_NODES, .off = _OUT(r.max_src_nodes), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_MAX_SRC_STATES, .off = _OUT(r.max_src_states), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_MAX_SRC_CONN_RATE_LIMIT, .off = _OUT(r.max_src_conn_rate.limit), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_MAX_SRC_CONN_RATE_SECS, .off = _OUT(r.max_src_conn_rate.seconds), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_DNPIPE, .off = _OUT(r.dnpipe), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_DNRPIPE, .off = _OUT(r.dnrpipe), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_DNFLAGS, .off = _OUT(r.free_flags), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_NR, .off = _OUT(r.nr), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_PROB, .off = _OUT(r.prob), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_CUID, .off = _OUT(r.cuid), .cb = snl_attr_get_uint32 },
+ {. type = PF_RT_CPID, .off = _OUT(r.cpid), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_RETURN_ICMP, .off = _OUT(r.return_icmp), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_RETURN_ICMP6, .off = _OUT(r.return_icmp6), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_MAX_MSS, .off = _OUT(r.max_mss), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_SCRUB_FLAGS, .off = _OUT(r.scrub_flags), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_UID, .off = _OUT(r.uid), .arg = &rule_uid_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RT_GID, .off = _OUT(r.gid), .arg = &rule_uid_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RT_RULE_FLAG, .off = _OUT(r.rule_flag), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_ACTION, .off = _OUT(r.action), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_DIRECTION, .off = _OUT(r.direction), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_LOG, .off = _OUT(r.log), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_LOGIF, .off = _OUT(r.logif), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_QUICK, .off = _OUT(r.quick), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_IF_NOT, .off = _OUT(r.ifnot), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_MATCH_TAG_NOT, .off = _OUT(r.match_tag_not), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_NATPASS, .off = _OUT(r.natpass), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_KEEP_STATE, .off = _OUT(r.keep_state), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_AF, .off = _OUT(r.af), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_PROTO, .off = _OUT(r.proto), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_TYPE, .off = _OUT(r.type), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_CODE, .off = _OUT(r.code), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_FLAGS, .off = _OUT(r.flags), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_FLAGSET, .off = _OUT(r.flagset), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_MIN_TTL, .off = _OUT(r.min_ttl), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_ALLOW_OPTS, .off = _OUT(r.allow_opts), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_RT, .off = _OUT(r.rt), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_RETURN_TTL, .off = _OUT(r.return_ttl), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_TOS, .off = _OUT(r.tos), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_SET_TOS, .off = _OUT(r.set_tos), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_ANCHOR_RELATIVE, .off = _OUT(r.anchor_relative), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_ANCHOR_WILDCARD, .off = _OUT(r.anchor_wildcard), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_FLUSH, .off = _OUT(r.flush), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_PRIO, .off = _OUT(r.prio), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_SET_PRIO, .off = _OUT(r.set_prio[0]), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_SET_PRIO_REPLY, .off = _OUT(r.set_prio[1]), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_DIVERT_ADDRESS, .off = _OUT(r.divert.addr), .cb = snl_attr_get_in6_addr },
+ { .type = PF_RT_DIVERT_PORT, .off = _OUT(r.divert.port), .cb = snl_attr_get_uint16 },
+ { .type = PF_RT_PACKETS_IN, .off = _OUT(r.packets[0]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_PACKETS_OUT, .off = _OUT(r.packets[1]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_BYTES_IN, .off = _OUT(r.bytes[0]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_BYTES_OUT, .off = _OUT(r.bytes[1]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_EVALUATIONS, .off = _OUT(r.evaluations), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_TIMESTAMP, .off = _OUT(r.last_active_timestamp), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_STATES_CUR, .off = _OUT(r.states_cur), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_STATES_TOTAL, .off = _OUT(r.states_tot), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_SRC_NODES, .off = _OUT(r.src_nodes), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_ANCHOR_CALL, .off = _OUT(anchor_call), .arg = (void*)MAXPATHLEN, .cb = snl_attr_copy_string },
+ { .type = PF_RT_RCV_IFNAME, .off = _OUT(r.rcv_ifname), .arg = (void*)IFNAMSIZ, .cb = snl_attr_copy_string },
+ { .type = PF_RT_MAX_SRC_CONN, .off = _OUT(r.max_src_conn), .cb = snl_attr_get_uint32 },
+ { .type = PF_RT_RPOOL_NAT, .off = _OUT(r.nat), .arg = &pool_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RT_NAF, .off = _OUT(r.naf), .cb = snl_attr_get_uint8 },
+ { .type = PF_RT_RPOOL_RT, .off = _OUT(r.route), .arg = &pool_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RT_RCV_IFNOT, .off = _OUT(r.rcvifnot),.cb = snl_attr_get_bool },
+ { .type = PF_RT_SRC_NODES_LIMIT, .off = _OUT(r.src_nodes_type[PF_SN_LIMIT]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_SRC_NODES_NAT, .off = _OUT(r.src_nodes_type[PF_SN_NAT]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_SRC_NODES_ROUTE, .off = _OUT(r.src_nodes_type[PF_SN_ROUTE]), .cb = snl_attr_get_uint64 },
+ { .type = PF_RT_PKTRATE, .off = _OUT(r.pktrate), .arg = &pfctl_threshold_parser, .cb = snl_attr_get_nested },
+ { .type = PF_RT_MAX_PKT_SIZE, .off =_OUT(r.max_pkt_size), .cb = snl_attr_get_uint16 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(getrule_parser, struct genlmsghdr, snl_f_p_empty, ap_getrule);
+
+int
+pfctl_get_clear_rule_h(struct pfctl_handle *h, uint32_t nr, uint32_t ticket,
+ const char *anchor, uint32_t ruleset, struct pfctl_rule *rule,
+ char *anchor_call, bool clear)
+{
+ struct pfctl_nl_get_rule attrs = {};
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ struct snl_writer nw;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GETRULE);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ snl_add_msg_attr_string(&nw, PF_GR_ANCHOR, anchor);
+ snl_add_msg_attr_u8(&nw, PF_GR_ACTION, ruleset);
+ snl_add_msg_attr_u32(&nw, PF_GR_NR, nr);
+ snl_add_msg_attr_u32(&nw, PF_GR_TICKET, ticket);
+ snl_add_msg_attr_u8(&nw, PF_GR_CLEAR, clear);
+
+ hdr = snl_finalize_msg(&nw);
+ if (hdr == NULL)
+ return (ENOMEM);
+
+ seq_id = hdr->nlmsg_seq;
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &getrule_parser, &attrs))
+ continue;
+ }
+
+ memcpy(rule, &attrs.r, sizeof(attrs.r));
+ strlcpy(anchor_call, attrs.anchor_call, MAXPATHLEN);
+
+ return (e.error);
+}
+
+int
+pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket,
const char *anchor, uint32_t ruleset, struct pfctl_rule *rule,
char *anchor_call, bool clear)
{
@@ -1064,7 +1764,7 @@ int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket,
nvlist_add_bool(nvl, "clear_counter", true);
if ((ret = pfctl_do_ioctl(dev, DIOCGETRULENV, 8192, &nvl)) != 0)
- return (ret);
+ goto out;
pf_nvrule_to_rule(nvlist_get_nvlist(nvl, "rule"), rule);
@@ -1072,9 +1772,9 @@ int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket,
strlcpy(anchor_call, nvlist_get_string(nvl, "anchor_call"),
MAXPATHLEN);
+out:
nvlist_destroy(nvl);
-
- return (0);
+ return (ret);
}
int
@@ -1099,144 +1799,257 @@ pfctl_set_keepcounters(int dev, bool keep)
return (ret);
}
-static void
-pfctl_nv_add_state_cmp(nvlist_t *nvl, const char *name,
- const struct pfctl_state_cmp *cmp)
+struct pfctl_creator {
+ uint32_t id;
+};
+#define _IN(_field) offsetof(struct genlmsghdr, _field)
+#define _OUT(_field) offsetof(struct pfctl_creator, _field)
+static struct snl_attr_parser ap_creators[] = {
+ { .type = PF_ST_CREATORID, .off = _OUT(id), .cb = snl_attr_get_uint32 },
+};
+#undef _IN
+#undef _OUT
+SNL_DECLARE_PARSER(creator_parser, struct genlmsghdr, snl_f_p_empty, ap_creators);
+
+static int
+pfctl_get_creators_nl(struct snl_state *ss, uint32_t *creators, size_t *len)
{
- nvlist_t *nv;
- nv = nvlist_create(0);
+ int family_id = snl_get_genl_family(ss, PFNL_FAMILY_NAME);
+ size_t i = 0;
+
+ struct nlmsghdr *hdr;
+ struct snl_writer nw;
+
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GETCREATORS);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+ hdr = snl_finalize_msg(&nw);
+ if (hdr == NULL)
+ return (ENOMEM);
+ uint32_t seq_id = hdr->nlmsg_seq;
+
+ snl_send_message(ss, hdr);
+
+ struct snl_errmsg_data e = {};
+ while ((hdr = snl_read_reply_multi(ss, seq_id, &e)) != NULL) {
+ struct pfctl_creator c;
+ bzero(&c, sizeof(c));
+
+ if (!snl_parse_nlmsg(ss, hdr, &creator_parser, &c))
+ continue;
+
+ creators[i] = c.id;
+ i++;
+ if (i > *len)
+ return (E2BIG);
+ }
- nvlist_add_number(nv, "id", cmp->id);
- nvlist_add_number(nv, "creatorid", htonl(cmp->creatorid));
- nvlist_add_number(nv, "direction", cmp->direction);
+ *len = i;
- nvlist_add_nvlist(nvl, name, nv);
- nvlist_destroy(nv);
+ return (0);
}
-static void
-pf_state_key_export_to_state_key(struct pfctl_state_key *ps,
- const struct pf_state_key_export *s)
+int
+pfctl_get_creatorids(struct pfctl_handle *h, uint32_t *creators, size_t *len)
{
- bcopy(s->addr, ps->addr, sizeof(ps->addr[0]) * 2);
- ps->port[0] = s->port[0];
- ps->port[1] = s->port[1];
+ int error;
+
+ error = pfctl_get_creators_nl(&h->ss, creators, len);
+
+ return (error);
}
-static void
-pf_state_peer_export_to_state_peer(struct pfctl_state_peer *ps,
- const struct pf_state_peer_export *s)
+static inline bool
+snl_attr_get_pfaddr(struct snl_state *ss __unused, struct nlattr *nla,
+ const void *arg __unused, void *target)
{
- /* Ignore scrub. */
- ps->seqlo = s->seqlo;
- ps->seqhi = s->seqhi;
- ps->seqdiff = s->seqdiff;
- /* Ignore max_win & mss */
- ps->state = s->state;
- ps->wscale = s->wscale;
+ memcpy(target, NLA_DATA(nla), NLA_DATA_LEN(nla));
+ return (true);
}
-static void
-pf_state_export_to_state(struct pfctl_state *ps, const struct pf_state_export *s)
-{
- assert(s->version >= PF_STATE_VERSION);
-
- ps->id = s->id;
- strlcpy(ps->ifname, s->ifname, sizeof(ps->ifname));
- strlcpy(ps->orig_ifname, s->orig_ifname, sizeof(ps->orig_ifname));
- strlcpy(ps->rt_ifname, s->rt_ifname, sizeof(ps->rt_ifname));
- pf_state_key_export_to_state_key(&ps->key[0], &s->key[0]);
- pf_state_key_export_to_state_key(&ps->key[1], &s->key[1]);
- pf_state_peer_export_to_state_peer(&ps->src, &s->src);
- pf_state_peer_export_to_state_peer(&ps->dst, &s->dst);
- bcopy(&s->rt_addr, &ps->rt_addr, sizeof(ps->rt_addr));
- ps->rule = ntohl(s->rule);
- ps->anchor = ntohl(s->anchor);
- ps->nat_rule = ntohl(s->nat_rule);
- ps->creation = ntohl(s->creation);
- ps->expire = ntohl(s->expire);
- ps->packets[0] = s->packets[0];
- ps->packets[1] = s->packets[1];
- ps->bytes[0] = s->bytes[0];
- ps->bytes[1] = s->bytes[1];
- ps->creatorid = ntohl(s->creatorid);
- ps->key[0].proto = s->proto;
- ps->key[1].proto = s->proto;
- ps->key[0].af = s->af;
- ps->key[1].af = s->af;
- ps->direction = s->direction;
- ps->state_flags = ntohs(s->state_flags);
- ps->sync_flags = ntohs(s->sync_flags);
- ps->qid = ntohs(s->qid);
- ps->pqid = ntohs(s->pqid);
- ps->dnpipe = ntohs(s->dnpipe);
- ps->dnrpipe = ntohs(s->dnrpipe);
- ps->rtableid = ntohl(s->rtableid);
- ps->min_ttl = s->min_ttl;
- ps->set_tos = s->set_tos;
- ps->max_mss = ntohs(s->max_mss);
- ps->rt = s->rt;
- ps->set_prio[0] = s->set_prio[0];
- ps->set_prio[1] = s->set_prio[1];
+static inline bool
+snl_attr_store_ifname(struct snl_state *ss __unused, struct nlattr *nla,
+ const void *arg __unused, void *target)
+{
+ size_t maxlen = NLA_DATA_LEN(nla);
+
+ if (strnlen((char *)NLA_DATA(nla), maxlen) < maxlen) {
+ strlcpy(target, (char *)NLA_DATA(nla), maxlen);
+ return (true);
+ }
+ return (false);
}
-int
-pfctl_get_states(int dev, struct pfctl_states *states)
+#define _OUT(_field) offsetof(struct pfctl_state_peer, _field)
+static const struct snl_attr_parser nla_p_speer[] = {
+ { .type = PF_STP_SEQLO, .off = _OUT(seqlo), .cb = snl_attr_get_uint32 },
+ { .type = PF_STP_SEQHI, .off = _OUT(seqhi), .cb = snl_attr_get_uint32 },
+ { .type = PF_STP_SEQDIFF, .off = _OUT(seqdiff), .cb = snl_attr_get_uint32 },
+ { .type = PF_STP_STATE, .off = _OUT(state), .cb = snl_attr_get_uint8 },
+ { .type = PF_STP_WSCALE, .off = _OUT(wscale), .cb = snl_attr_get_uint8 },
+};
+SNL_DECLARE_ATTR_PARSER(speer_parser, nla_p_speer);
+#undef _OUT
+
+#define _OUT(_field) offsetof(struct pfctl_state_key, _field)
+static const struct snl_attr_parser nla_p_skey[] = {
+ { .type = PF_STK_ADDR0, .off = _OUT(addr[0]), .cb = snl_attr_get_pfaddr },
+ { .type = PF_STK_ADDR1, .off = _OUT(addr[1]), .cb = snl_attr_get_pfaddr },
+ { .type = PF_STK_PORT0, .off = _OUT(port[0]), .cb = snl_attr_get_uint16 },
+ { .type = PF_STK_PORT1, .off = _OUT(port[1]), .cb = snl_attr_get_uint16 },
+ { .type = PF_STK_AF, .off = _OUT(af), .cb = snl_attr_get_uint8 },
+ { .type = PF_STK_PROTO, .off = _OUT(proto), .cb = snl_attr_get_uint16 },
+};
+SNL_DECLARE_ATTR_PARSER(skey_parser, nla_p_skey);
+#undef _OUT
+
+#define _IN(_field) offsetof(struct genlmsghdr, _field)
+#define _OUT(_field) offsetof(struct pfctl_state, _field)
+static struct snl_attr_parser ap_state[] = {
+ { .type = PF_ST_ID, .off = _OUT(id), .cb = snl_attr_get_uint64 },
+ { .type = PF_ST_CREATORID, .off = _OUT(creatorid), .cb = snl_attr_get_uint32 },
+ { .type = PF_ST_IFNAME, .off = _OUT(ifname), .cb = snl_attr_store_ifname },
+ { .type = PF_ST_ORIG_IFNAME, .off = _OUT(orig_ifname), .cb = snl_attr_store_ifname },
+ { .type = PF_ST_KEY_WIRE, .off = _OUT(key[0]), .arg = &skey_parser, .cb = snl_attr_get_nested },
+ { .type = PF_ST_KEY_STACK, .off = _OUT(key[1]), .arg = &skey_parser, .cb = snl_attr_get_nested },
+ { .type = PF_ST_PEER_SRC, .off = _OUT(src), .arg = &speer_parser, .cb = snl_attr_get_nested },
+ { .type = PF_ST_PEER_DST, .off = _OUT(dst), .arg = &speer_parser, .cb = snl_attr_get_nested },
+ { .type = PF_ST_RT_ADDR, .off = _OUT(rt_addr), .cb = snl_attr_get_pfaddr },
+ { .type = PF_ST_RULE, .off = _OUT(rule), .cb = snl_attr_get_uint32 },
+ { .type = PF_ST_ANCHOR, .off = _OUT(anchor), .cb = snl_attr_get_uint32 },
+ { .type = PF_ST_NAT_RULE, .off = _OUT(nat_rule), .cb = snl_attr_get_uint32 },
+ { .type = PF_ST_CREATION, .off = _OUT(creation), .cb = snl_attr_get_uint32 },
+ { .type = PF_ST_EXPIRE, .off = _OUT(expire), .cb = snl_attr_get_uint32 },
+ { .type = PF_ST_PACKETS0, .off = _OUT(packets[0]), .cb = snl_attr_get_uint64 },
+ { .type = PF_ST_PACKETS1, .off = _OUT(packets[1]), .cb = snl_attr_get_uint64 },
+ { .type = PF_ST_BYTES0, .off = _OUT(bytes[0]), .cb = snl_attr_get_uint64 },
+ { .type = PF_ST_BYTES1, .off = _OUT(bytes[1]), .cb = snl_attr_get_uint64 },
+ { .type = PF_ST_DIRECTION, .off = _OUT(direction), .cb = snl_attr_get_uint8 },
+ { .type = PF_ST_LOG, .off = _OUT(log), .cb = snl_attr_get_uint8 },
+ { .type = PF_ST_STATE_FLAGS, .off = _OUT(state_flags), .cb = snl_attr_get_uint16 },
+ { .type = PF_ST_SYNC_FLAGS, .off = _OUT(sync_flags), .cb = snl_attr_get_uint8 },
+ { .type = PF_ST_RTABLEID, .off = _OUT(rtableid), .cb = snl_attr_get_int32 },
+ { .type = PF_ST_MIN_TTL, .off = _OUT(min_ttl), .cb = snl_attr_get_uint8 },
+ { .type = PF_ST_MAX_MSS, .off = _OUT(max_mss), .cb = snl_attr_get_uint16 },
+ { .type = PF_ST_DNPIPE, .off = _OUT(dnpipe), .cb = snl_attr_get_uint16 },
+ { .type = PF_ST_DNRPIPE, .off = _OUT(dnrpipe), .cb = snl_attr_get_uint16 },
+ { .type = PF_ST_RT, .off = _OUT(rt), .cb = snl_attr_get_uint8 },
+ { .type = PF_ST_RT_IFNAME, .off = _OUT(rt_ifname), .cb = snl_attr_store_ifname },
+ { .type = PF_ST_SRC_NODE_FLAGS, .off = _OUT(src_node_flags), .cb = snl_attr_get_uint8 },
+ { .type = PF_ST_RT_AF, .off = _OUT(rt_af), .cb = snl_attr_get_uint8 },
+};
+#undef _IN
+#undef _OUT
+SNL_DECLARE_PARSER(state_parser, struct genlmsghdr, snl_f_p_empty, ap_state);
+
+static const struct snl_hdr_parser *all_parsers[] = {
+ &state_parser, &skey_parser, &speer_parser,
+ &creator_parser, &getrules_parser
+};
+
+static int
+pfctl_get_states_nl(struct pfctl_state_filter *filter, struct snl_state *ss, pfctl_get_state_fn f, void *arg)
{
- struct pfioc_states_v2 ps;
- struct pf_state_export *p;
- char *inbuf = NULL, *newinbuf = NULL;
- unsigned int len = 0;
- int i, error;
+ SNL_VERIFY_PARSERS(all_parsers);
+ int family_id = snl_get_genl_family(ss, PFNL_FAMILY_NAME);
+ int ret;
- bzero(&ps, sizeof(ps));
- ps.ps_req_version = PF_STATE_VERSION;
+ struct nlmsghdr *hdr;
+ struct snl_writer nw;
- bzero(states, sizeof(*states));
- TAILQ_INIT(&states->states);
+ if (family_id == 0)
+ return (ENOTSUP);
- for (;;) {
- ps.ps_len = len;
- if (len) {
- newinbuf = realloc(inbuf, len);
- if (newinbuf == NULL)
- return (ENOMEM);
- ps.ps_buf = inbuf = newinbuf;
- }
- if ((error = ioctl(dev, DIOCGETSTATESV2, &ps)) < 0) {
- free(inbuf);
- return (error);
- }
- if (ps.ps_len + sizeof(struct pfioc_states_v2) < len)
- break;
- if (len == 0 && ps.ps_len == 0)
- goto out;
- if (len == 0 && ps.ps_len != 0)
- len = ps.ps_len;
- if (ps.ps_len == 0)
- goto out; /* no states */
- len *= 2;
- }
- p = ps.ps_states;
+ snl_init_writer(ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GETSTATES);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+ snl_add_msg_attr_string(&nw, PF_ST_IFNAME, filter->ifname);
+ snl_add_msg_attr_u16(&nw, PF_ST_PROTO, filter->proto);
+ snl_add_msg_attr_u8(&nw, PF_ST_AF, filter->af);
+ snl_add_msg_attr_ip6(&nw, PF_ST_FILTER_ADDR, &filter->addr.v6);
+ snl_add_msg_attr_ip6(&nw, PF_ST_FILTER_MASK, &filter->mask.v6);
- for (i = 0; i < ps.ps_len; i += sizeof(*p), p++) {
- struct pfctl_state *s = malloc(sizeof(*s));
- if (s == NULL) {
- pfctl_free_states(states);
- error = ENOMEM;
- goto out;
- }
+ hdr = snl_finalize_msg(&nw);
+ if (hdr == NULL)
+ return (ENOMEM);
+
+ uint32_t seq_id = hdr->nlmsg_seq;
+
+ snl_send_message(ss, hdr);
- pf_state_export_to_state(s, p);
- TAILQ_INSERT_TAIL(&states->states, s, entry);
+ struct snl_errmsg_data e = {};
+ while ((hdr = snl_read_reply_multi(ss, seq_id, &e)) != NULL) {
+ struct pfctl_state s;
+ bzero(&s, sizeof(s));
+ if (!snl_parse_nlmsg(ss, hdr, &state_parser, &s))
+ continue;
+
+ ret = f(&s, arg);
+ if (ret != 0)
+ return (ret);
}
-out:
- free(inbuf);
+ return (0);
+}
+
+int
+pfctl_get_states_iter(pfctl_get_state_fn f, void *arg)
+{
+ struct pfctl_state_filter filter = {};
+ return (pfctl_get_filtered_states_iter(&filter, f, arg));
+}
+
+int
+pfctl_get_filtered_states_iter(struct pfctl_state_filter *filter, pfctl_get_state_fn f, void *arg)
+{
+ struct snl_state ss = {};
+ int error;
+
+ snl_init(&ss, NETLINK_GENERIC);
+ error = pfctl_get_states_nl(filter, &ss, f, arg);
+ snl_free(&ss);
+
return (error);
}
+static int
+pfctl_append_states(struct pfctl_state *s, void *arg)
+{
+ struct pfctl_state *new;
+ struct pfctl_states *states = (struct pfctl_states *)arg;
+
+ new = malloc(sizeof(*s));
+ if (new == NULL)
+ return (ENOMEM);
+
+ memcpy(new, s, sizeof(*s));
+
+ TAILQ_INSERT_TAIL(&states->states, new, entry);
+
+ return (0);
+}
+
+int
+pfctl_get_states(int dev __unused, struct pfctl_states *states)
+{
+ int ret;
+
+ bzero(states, sizeof(*states));
+ TAILQ_INIT(&states->states);
+
+ ret = pfctl_get_states_iter(pfctl_append_states, states);
+ if (ret != 0) {
+ pfctl_free_states(states);
+ return (ret);
+ }
+
+ return (0);
+}
+
void
pfctl_free_states(struct pfctl_states *states)
{
@@ -1249,47 +2062,109 @@ pfctl_free_states(struct pfctl_states *states)
bzero(states, sizeof(*states));
}
+struct pfctl_nl_clear_states {
+ uint32_t killed;
+};
+#define _OUT(_field) offsetof(struct pfctl_nl_clear_states, _field)
+static struct snl_attr_parser ap_clear_states[] = {
+ { .type = PF_CS_KILLED, .off = _OUT(killed), .cb = snl_attr_get_uint32 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(clear_states_parser, struct genlmsghdr, snl_f_p_empty, ap_clear_states);
+
static int
-_pfctl_clear_states(int dev, const struct pfctl_kill *kill,
- unsigned int *killed, uint64_t ioctlval)
+_pfctl_clear_states_h(struct pfctl_handle *h, const struct pfctl_kill *kill,
+ unsigned int *killed, int cmd)
{
- nvlist_t *nvl;
- int ret;
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct pfctl_nl_clear_states attrs = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, cmd);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ snl_add_msg_attr_u64(&nw, PF_CS_CMP_ID, kill->cmp.id);
+ snl_add_msg_attr_u32(&nw, PF_CS_CMP_CREATORID, htonl(kill->cmp.creatorid));
+ snl_add_msg_attr_u8(&nw, PF_CS_CMP_DIR, kill->cmp.direction);
+ snl_add_msg_attr_u8(&nw, PF_CS_AF, kill->af);
+ snl_add_msg_attr_u8(&nw, PF_CS_PROTO, kill->proto);
+ snl_add_msg_attr_rule_addr(&nw, PF_CS_SRC, &kill->src);
+ snl_add_msg_attr_rule_addr(&nw, PF_CS_DST, &kill->dst);
+ snl_add_msg_attr_rule_addr(&nw, PF_CS_RT_ADDR, &kill->rt_addr);
+ snl_add_msg_attr_string(&nw, PF_CS_IFNAME, kill->ifname);
+ snl_add_msg_attr_string(&nw, PF_CS_LABEL, kill->label);
+ snl_add_msg_attr_bool(&nw, PF_CS_KILL_MATCH, kill->kill_match);
+ snl_add_msg_attr_bool(&nw, PF_CS_NAT, kill->nat);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &clear_states_parser, &attrs))
+ continue;
+ }
- nvl = nvlist_create(0);
+ if (killed)
+ *killed = attrs.killed;
- pfctl_nv_add_state_cmp(nvl, "cmp", &kill->cmp);
- nvlist_add_number(nvl, "af", kill->af);
- nvlist_add_number(nvl, "proto", kill->proto);
- pfctl_nv_add_rule_addr(nvl, "src", &kill->src);
- pfctl_nv_add_rule_addr(nvl, "dst", &kill->dst);
- pfctl_nv_add_rule_addr(nvl, "rt_addr", &kill->rt_addr);
- nvlist_add_string(nvl, "ifname", kill->ifname);
- nvlist_add_string(nvl, "label", kill->label);
- nvlist_add_bool(nvl, "kill_match", kill->kill_match);
-
- if ((ret = pfctl_do_ioctl(dev, ioctlval, 1024, &nvl)) != 0)
- return (ret);
+ return (e.error);
+}
- if (killed)
- *killed = nvlist_get_number(nvl, "killed");
+int
+pfctl_clear_states_h(struct pfctl_handle *h, const struct pfctl_kill *kill,
+ unsigned int *killed)
+{
+ return(_pfctl_clear_states_h(h, kill, killed, PFNL_CMD_CLRSTATES));
+}
- nvlist_destroy(nvl);
+int
+pfctl_kill_states_h(struct pfctl_handle *h, const struct pfctl_kill *kill,
+ unsigned int *killed)
+{
+ return(_pfctl_clear_states_h(h, kill, killed, PFNL_CMD_KILLSTATES));
+}
+
+static int
+_pfctl_clear_states(int dev __unused, const struct pfctl_kill *kill,
+ unsigned int *killed, uint64_t cmd)
+{
+ struct pfctl_handle *h;
+ int ret;
+
+ h = pfctl_open(PF_DEVICE);
+ if (h == NULL)
+ return (ENODEV);
+
+ ret = _pfctl_clear_states_h(h, kill, killed, cmd);
+ pfctl_close(h);
return (ret);
}
int
-pfctl_clear_states(int dev, const struct pfctl_kill *kill,
+pfctl_clear_states(int dev __unused, const struct pfctl_kill *kill,
unsigned int *killed)
{
- return (_pfctl_clear_states(dev, kill, killed, DIOCCLRSTATESNV));
+ return (_pfctl_clear_states(dev, kill, killed, PFNL_CMD_CLRSTATES));
}
int
-pfctl_kill_states(int dev, const struct pfctl_kill *kill, unsigned int *killed)
+pfctl_kill_states(int dev __unused, const struct pfctl_kill *kill, unsigned int *killed)
{
- return (_pfctl_clear_states(dev, kill, killed, DIOCKILLSTATESNV));
+ return (_pfctl_clear_states(dev, kill, killed, PFNL_CMD_KILLSTATES));
}
int
@@ -1318,8 +2193,12 @@ pfctl_clear_rules(int dev, const char *anchorname)
ret = ioctl(dev, DIOCXBEGIN, &trans);
if (ret != 0)
- return (ret);
- return ioctl(dev, DIOCXCOMMIT, &trans);
+ return (errno);
+ ret = ioctl(dev, DIOCXCOMMIT, &trans);
+ if (ret != 0)
+ return (errno);
+
+ return (0);
}
int
@@ -1353,9 +2232,14 @@ pfctl_clear_nat(int dev, const char *anchorname)
ret = ioctl(dev, DIOCXBEGIN, &trans);
if (ret != 0)
- return (ret);
- return ioctl(dev, DIOCXCOMMIT, &trans);
+ return (errno);
+ ret = ioctl(dev, DIOCXCOMMIT, &trans);
+ if (ret != 0)
+ return (errno);
+
+ return (0);
}
+
int
pfctl_clear_eth_rules(int dev, const char *anchorname)
{
@@ -1377,12 +2261,16 @@ pfctl_clear_eth_rules(int dev, const char *anchorname)
ret = ioctl(dev, DIOCXBEGIN, &trans);
if (ret != 0)
- return (ret);
- return ioctl(dev, DIOCXCOMMIT, &trans);
+ return (errno);
+ ret = ioctl(dev, DIOCXCOMMIT, &trans);
+ if (ret != 0)
+ return (errno);
+
+ return (0);
}
static int
-pfctl_get_limit(int dev, const int index, uint *limit)
+_pfctl_get_limit(int dev, const int index, uint *limit)
{
struct pfioc_limit pl;
@@ -1406,10 +2294,13 @@ pfctl_set_syncookies(int dev, const struct pfctl_syncookies *s)
uint state_limit;
uint64_t lim, hi, lo;
- ret = pfctl_get_limit(dev, PF_LIMIT_STATES, &state_limit);
+ ret = _pfctl_get_limit(dev, PF_LIMIT_STATES, &state_limit);
if (ret != 0)
return (ret);
+ if (state_limit == 0)
+ state_limit = INT_MAX;
+
lim = state_limit;
hi = lim * s->highwater / 100;
lo = lim * s->lowwater / 100;
@@ -1432,7 +2323,10 @@ pfctl_set_syncookies(int dev, const struct pfctl_syncookies *s)
ret = ioctl(dev, DIOCSETSYNCOOKIES, &nv);
free(nv.data);
- return (ret);
+ if (ret != 0)
+ return (errno);
+
+ return (0);
}
int
@@ -1443,16 +2337,21 @@ pfctl_get_syncookies(int dev, struct pfctl_syncookies *s)
uint state_limit;
bool enabled, adaptive;
- ret = pfctl_get_limit(dev, PF_LIMIT_STATES, &state_limit);
+ ret = _pfctl_get_limit(dev, PF_LIMIT_STATES, &state_limit);
if (ret != 0)
return (ret);
+ if (state_limit == 0)
+ state_limit = INT_MAX;
+
bzero(s, sizeof(*s));
nvl = nvlist_create(0);
- if ((ret = pfctl_do_ioctl(dev, DIOCGETSYNCOOKIES, 256, &nvl)) != 0)
- return (errno);
+ if ((ret = pfctl_do_ioctl(dev, DIOCGETSYNCOOKIES, 256, &nvl)) != 0) {
+ ret = errno;
+ goto out;
+ }
enabled = nvlist_get_bool(nvl, "enabled");
adaptive = nvlist_get_bool(nvl, "adaptive");
@@ -1468,10 +2367,11 @@ pfctl_get_syncookies(int dev, struct pfctl_syncookies *s)
s->highwater = nvlist_get_number(nvl, "highwater") * 100 / state_limit;
s->lowwater = nvlist_get_number(nvl, "lowwater") * 100 / state_limit;
+ s->halfopen_states = nvlist_get_number(nvl, "halfopen_states");
+out:
nvlist_destroy(nvl);
-
- return (0);
+ return (ret);
}
int
@@ -1537,7 +2437,7 @@ pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
io.pfrio_size = size;
io.pfrio_size2 = (size2 != NULL) ? *size2 : 0;
if (ioctl(dev, DIOCRSETADDRS, &io))
- return (-1);
+ return (errno);
if (nadd != NULL)
*nadd = io.pfrio_nadd;
if (ndel != NULL)
@@ -1565,7 +2465,933 @@ int pfctl_table_get_addrs(int dev, struct pfr_table *tbl, struct pfr_addr *addr,
io.pfrio_esize = sizeof(*addr);
io.pfrio_size = *size;
if (ioctl(dev, DIOCRGETADDRS, &io))
- return (-1);
+ return (errno);
*size = io.pfrio_size;
return (0);
}
+
+int
+pfctl_set_statusif(struct pfctl_handle *h, const char *ifname)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_SET_STATUSIF);
+
+ snl_add_msg_attr_string(&nw, PF_SS_IFNAME, ifname);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
+#define _IN(_field) offsetof(struct genlmsghdr, _field)
+#define _OUT(_field) offsetof(struct pfctl_natlook, _field)
+static struct snl_attr_parser ap_natlook[] = {
+ { .type = PF_NL_SRC_ADDR, .off = _OUT(saddr), .cb = snl_attr_get_in6_addr },
+ { .type = PF_NL_DST_ADDR, .off = _OUT(daddr), .cb = snl_attr_get_in6_addr },
+ { .type = PF_NL_SRC_PORT, .off = _OUT(sport), .cb = snl_attr_get_uint16 },
+ { .type = PF_NL_DST_PORT, .off = _OUT(dport), .cb = snl_attr_get_uint16 },
+};
+#undef _IN
+#undef _OUT
+SNL_DECLARE_PARSER(natlook_parser, struct genlmsghdr, snl_f_p_empty, ap_natlook);
+
+int
+pfctl_natlook(struct pfctl_handle *h, const struct pfctl_natlook_key *k,
+ struct pfctl_natlook *r)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_NATLOOK);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ snl_add_msg_attr_u8(&nw, PF_NL_AF, k->af);
+ snl_add_msg_attr_u8(&nw, PF_NL_DIRECTION, k->direction);
+ snl_add_msg_attr_u8(&nw, PF_NL_PROTO, k->proto);
+ snl_add_msg_attr_ip6(&nw, PF_NL_SRC_ADDR, &k->saddr.v6);
+ snl_add_msg_attr_ip6(&nw, PF_NL_DST_ADDR, &k->daddr.v6);
+ snl_add_msg_attr_u16(&nw, PF_NL_SRC_PORT, k->sport);
+ snl_add_msg_attr_u16(&nw, PF_NL_DST_PORT, k->dport);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &natlook_parser, r))
+ continue;
+ }
+
+ return (e.error);
+}
+
+int
+pfctl_set_debug(struct pfctl_handle *h, uint32_t level)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_SET_DEBUG);
+
+ snl_add_msg_attr_u32(&nw, PF_SD_LEVEL, level);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
+int
+pfctl_set_timeout(struct pfctl_handle *h, uint32_t timeout, uint32_t seconds)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_SET_TIMEOUT);
+
+ snl_add_msg_attr_u32(&nw, PF_TO_TIMEOUT, timeout);
+ snl_add_msg_attr_u32(&nw, PF_TO_SECONDS, seconds);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
+struct pfctl_nl_timeout {
+ uint32_t seconds;
+};
+#define _OUT(_field) offsetof(struct pfctl_nl_timeout, _field)
+static struct snl_attr_parser ap_get_timeout[] = {
+ { .type = PF_TO_SECONDS, .off = _OUT(seconds), .cb = snl_attr_get_uint32 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(get_timeout_parser, struct genlmsghdr, snl_f_p_empty, ap_get_timeout);
+
+int
+pfctl_get_timeout(struct pfctl_handle *h, uint32_t timeout, uint32_t *seconds)
+{
+ struct snl_writer nw;
+ struct pfctl_nl_timeout to = {};
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_TIMEOUT);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ snl_add_msg_attr_u32(&nw, PF_TO_TIMEOUT, timeout);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &get_timeout_parser, &to))
+ continue;
+ }
+
+ if (seconds != NULL)
+ *seconds = to.seconds;
+
+ return (e.error);
+}
+
+int
+pfctl_set_limit(struct pfctl_handle *h, const int index, const uint limit)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_SET_LIMIT);
+
+ snl_add_msg_attr_u32(&nw, PF_LI_INDEX, index);
+ snl_add_msg_attr_u32(&nw, PF_LI_LIMIT, limit);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
+struct pfctl_nl_limit {
+ unsigned int limit;
+};
+#define _OUT(_field) offsetof(struct pfctl_nl_limit, _field)
+static struct snl_attr_parser ap_get_limit[] = {
+ { .type = PF_LI_LIMIT, .off = _OUT(limit), .cb = snl_attr_get_uint32 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(get_limit_parser, struct genlmsghdr, snl_f_p_empty, ap_get_limit);
+
+int
+pfctl_get_limit(struct pfctl_handle *h, const int index, uint *limit)
+{
+ struct snl_writer nw;
+ struct pfctl_nl_limit li = {};
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_LIMIT);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ snl_add_msg_attr_u32(&nw, PF_LI_INDEX, index);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &get_limit_parser, &li))
+ continue;
+ }
+
+ if (limit != NULL)
+ *limit = li.limit;
+
+ return (e.error);
+}
+
+struct pfctl_nl_begin_addrs {
+ uint32_t ticket;
+};
+#define _OUT(_field) offsetof(struct pfctl_nl_begin_addrs, _field)
+static struct snl_attr_parser ap_begin_addrs[] = {
+ { .type = PF_BA_TICKET, .off = _OUT(ticket), .cb = snl_attr_get_uint32 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(begin_addrs_parser, struct genlmsghdr, snl_f_p_empty, ap_begin_addrs);
+
+int
+pfctl_begin_addrs(struct pfctl_handle *h, uint32_t *ticket)
+{
+ struct snl_writer nw;
+ struct pfctl_nl_begin_addrs attrs = {};
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_BEGIN_ADDRS);
+ hdr->nlmsg_flags |= NLM_F_DUMP;
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &begin_addrs_parser, &attrs))
+ continue;
+ }
+
+ if (ticket != NULL)
+ *ticket = attrs.ticket;
+
+ return (e.error);
+}
+
+int
+pfctl_add_addr(struct pfctl_handle *h, const struct pfioc_pooladdr *pa, int which)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_ADD_ADDR);
+
+ snl_add_msg_attr_u32(&nw, PF_AA_ACTION, pa->action);
+ snl_add_msg_attr_u32(&nw, PF_AA_TICKET, pa->ticket);
+ snl_add_msg_attr_u32(&nw, PF_AA_NR, pa->nr);
+ snl_add_msg_attr_u32(&nw, PF_AA_R_NUM, pa->r_num);
+ snl_add_msg_attr_u8(&nw, PF_AA_R_ACTION, pa->r_action);
+ snl_add_msg_attr_u8(&nw, PF_AA_R_LAST, pa->r_last);
+ snl_add_msg_attr_u8(&nw, PF_AA_AF, pa->af);
+ snl_add_msg_attr_string(&nw, PF_AA_ANCHOR, pa->anchor);
+ snl_add_msg_attr_pool_addr(&nw, PF_AA_ADDR, &pa->addr);
+ snl_add_msg_attr_u32(&nw, PF_AA_WHICH, which);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ }
+
+ return (e.error);
+}
+
+static const struct snl_attr_parser ap_get_addrs[] = {
+ { .type = PF_AA_NR, .off = 0, .cb = snl_attr_get_uint32 },
+};
+SNL_DECLARE_PARSER(get_addrs_parser, struct genlmsghdr, snl_f_p_empty, ap_get_addrs);
+
+int
+pfctl_get_addrs(struct pfctl_handle *h, uint32_t ticket, uint32_t r_num,
+ uint8_t r_action, const char *anchor, uint32_t *nr, int which)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_ADDRS);
+
+ snl_add_msg_attr_u32(&nw, PF_AA_TICKET, ticket);
+ snl_add_msg_attr_u32(&nw, PF_AA_R_NUM, r_num);
+ snl_add_msg_attr_u8(&nw, PF_AA_R_ACTION, r_action);
+ snl_add_msg_attr_string(&nw, PF_AA_ANCHOR, anchor);
+ snl_add_msg_attr_u32(&nw, PF_AA_WHICH, which);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &get_addrs_parser, nr))
+ continue;
+ }
+
+ return (e.error);
+}
+
+#define _OUT(_field) offsetof(struct pf_pooladdr, _field)
+static const struct snl_attr_parser ap_pool_addr[] = {
+ { .type = PF_PA_ADDR, .off = _OUT(addr), .arg = &addr_wrap_parser, .cb = snl_attr_get_nested },
+ { .type = PF_PA_IFNAME, .off = _OUT(ifname), .arg_u32 = IFNAMSIZ, .cb = snl_attr_copy_string },
+};
+SNL_DECLARE_ATTR_PARSER(pool_addr_parser, ap_pool_addr);
+#undef _OUT
+
+#define _OUT(_field) offsetof(struct pfioc_pooladdr, _field)
+static const struct snl_attr_parser ap_get_addr[] = {
+ { .type = PF_AA_ACTION, .off = _OUT(action), .cb = snl_attr_get_uint32 },
+ { .type = PF_AA_TICKET, .off = _OUT(ticket), .cb = snl_attr_get_uint32 },
+ { .type = PF_AA_NR, .off = _OUT(nr), .cb = snl_attr_get_uint32 },
+ { .type = PF_AA_R_NUM, .off = _OUT(r_num), .cb = snl_attr_get_uint32 },
+ { .type = PF_AA_R_ACTION, .off = _OUT(r_action), .cb = snl_attr_get_uint8 },
+ { .type = PF_AA_R_LAST, .off = _OUT(r_last), .cb = snl_attr_get_uint8 },
+ { .type = PF_AA_AF, .off = _OUT(af), .cb = snl_attr_get_uint8 },
+ { .type = PF_AA_ANCHOR, .off = _OUT(anchor), .arg_u32 = MAXPATHLEN, .cb = snl_attr_copy_string },
+ { .type = PF_AA_ADDR, .off = _OUT(addr), .arg = &pool_addr_parser, .cb = snl_attr_get_nested },
+};
+SNL_DECLARE_PARSER(get_addr_parser, struct genlmsghdr, snl_f_p_empty, ap_get_addr);
+#undef _OUT
+
+int
+pfctl_get_addr(struct pfctl_handle *h, uint32_t ticket, uint32_t r_num,
+ uint8_t r_action, const char *anchor, uint32_t nr, struct pfioc_pooladdr *pa,
+ int which)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id =snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_ADDR);
+
+ snl_add_msg_attr_u32(&nw, PF_AA_TICKET, ticket);
+ snl_add_msg_attr_u32(&nw, PF_AA_R_NUM, r_num);
+ snl_add_msg_attr_u8(&nw, PF_AA_R_ACTION, r_action);
+ snl_add_msg_attr_string(&nw, PF_AA_ANCHOR, anchor);
+ snl_add_msg_attr_u32(&nw, PF_AA_NR, nr);
+ snl_add_msg_attr_u32(&nw, PF_AA_WHICH, which);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &get_addr_parser, pa))
+ continue;
+ }
+
+ return (e.error);
+}
+
+#define _OUT(_field) offsetof(struct pfioc_ruleset, _field)
+static const struct snl_attr_parser ap_ruleset[] = {
+ { .type = PF_RS_NR, .off = _OUT(nr), .cb = snl_attr_get_uint32 },
+ { .type = PF_RS_NAME, .off = _OUT(name), .arg = (void *)PF_ANCHOR_NAME_SIZE, .cb = snl_attr_copy_string },
+};
+SNL_DECLARE_PARSER(ruleset_parser, struct genlmsghdr, snl_f_p_empty, ap_ruleset);
+#undef _OUT
+
+int
+pfctl_get_rulesets(struct pfctl_handle *h, const char *path, uint32_t *nr)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ struct pfioc_ruleset rs = {};
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_RULESETS);
+
+ snl_add_msg_attr_string(&nw, PF_RS_PATH, path);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &ruleset_parser, &rs))
+ continue;
+ }
+
+ *nr = rs.nr;
+
+ return (e.error);
+}
+
+int
+pfctl_get_ruleset(struct pfctl_handle *h, const char *path, uint32_t nr, struct pfioc_ruleset *rs)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_RULESET);
+
+ snl_add_msg_attr_string(&nw, PF_RS_PATH, path);
+ snl_add_msg_attr_u32(&nw, PF_RS_NR, nr);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &ruleset_parser, rs))
+ continue;
+ }
+
+ return (e.error);
+}
+
+#define _OUT(_field) offsetof(struct pfctl_src_node, _field)
+static struct snl_attr_parser ap_srcnode[] = {
+ { .type = PF_SN_ADDR, .off = _OUT(addr), .cb = snl_attr_get_in6_addr },
+ { .type = PF_SN_RADDR, .off = _OUT(raddr), .cb = snl_attr_get_in6_addr },
+ { .type = PF_SN_RULE_NR, .off = _OUT(rule), .cb = snl_attr_get_uint32 },
+ { .type = PF_SN_BYTES_IN, .off = _OUT(bytes[0]), .cb = snl_attr_get_uint64 },
+ { .type = PF_SN_BYTES_OUT, .off = _OUT(bytes[1]), .cb = snl_attr_get_uint64 },
+ { .type = PF_SN_PACKETS_IN, .off = _OUT(packets[0]), .cb = snl_attr_get_uint64 },
+ { .type = PF_SN_PACKETS_OUT, .off = _OUT(packets[1]), .cb = snl_attr_get_uint64 },
+ { .type = PF_SN_STATES, .off = _OUT(states), .cb = snl_attr_get_uint32 },
+ { .type = PF_SN_CONNECTIONS, .off = _OUT(conn), .cb = snl_attr_get_uint32 },
+ { .type = PF_SN_AF, .off = _OUT(af), .cb = snl_attr_get_uint8 },
+ { .type = PF_SN_RULE_TYPE, .off = _OUT(ruletype), .cb = snl_attr_get_uint8 },
+ { .type = PF_SN_CREATION, .off = _OUT(creation), .cb = snl_attr_get_uint64 },
+ { .type = PF_SN_EXPIRE, .off = _OUT(expire), .cb = snl_attr_get_uint64 },
+ { .type = PF_SN_CONNECTION_RATE, .off = _OUT(conn_rate), .arg = &pfctl_threshold_parser, .cb = snl_attr_get_nested },
+ { .type = PF_SN_RAF, .off = _OUT(raf), .cb = snl_attr_get_uint8 },
+ { .type = PF_SN_NODE_TYPE, .off = _OUT(type), .cb = snl_attr_get_uint8 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(srcnode_parser, struct genlmsghdr, snl_f_p_empty, ap_srcnode);
+
+int
+pfctl_get_srcnodes(struct pfctl_handle *h, pfctl_get_srcnode_fn fn, void *arg)
+{
+ struct snl_writer nw;
+ struct pfctl_src_node sn;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+ int ret;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_SRCNODES);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ bzero(&sn, sizeof(sn));
+ if (!snl_parse_nlmsg(&h->ss, hdr, &srcnode_parser, &sn))
+ continue;
+
+ ret = fn(&sn, arg);
+ if (ret != 0)
+ return (ret);
+ }
+
+ return (e.error);
+}
+
+static struct snl_attr_parser ap_ndel[] = {
+ { .type = PF_T_NBR_DELETED, .off = 0, .cb = snl_attr_get_uint32 },
+};
+SNL_DECLARE_PARSER(ndel_parser, struct genlmsghdr, snl_f_p_empty, ap_ndel);
+
+int
+pfctl_clear_tables(struct pfctl_handle *h, struct pfr_table *filter,
+ int *ndel, int flags)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_CLEAR_TABLES);
+
+ snl_add_msg_attr_string(&nw, PF_T_ANCHOR, filter->pfrt_anchor);
+ snl_add_msg_attr_string(&nw, PF_T_NAME, filter->pfrt_name);
+ snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, filter->pfrt_flags);
+ snl_add_msg_attr_u32(&nw, PF_T_FLAGS, flags);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (!snl_parse_nlmsg(&h->ss, hdr, &ndel_parser, ndel))
+ continue;
+ }
+
+ return (e.error);
+}
+
+static struct snl_attr_parser ap_nadd[] = {
+ { .type = PF_T_NBR_ADDED, .off = 0, .cb = snl_attr_get_uint32 },
+};
+SNL_DECLARE_PARSER(nadd_parser, struct genlmsghdr, snl_f_p_empty, ap_nadd);
+int
+pfctl_add_table(struct pfctl_handle *h, struct pfr_table *table,
+ int *nadd, int flags)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_ADD_TABLE);
+
+ snl_add_msg_attr_string(&nw, PF_T_ANCHOR, table->pfrt_anchor);
+ snl_add_msg_attr_string(&nw, PF_T_NAME, table->pfrt_name);
+ snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, table->pfrt_flags);
+ snl_add_msg_attr_u32(&nw, PF_T_FLAGS, flags);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (!snl_parse_nlmsg(&h->ss, hdr, &nadd_parser, nadd))
+ continue;
+ }
+
+ return (e.error);
+}
+
+int
+pfctl_del_table(struct pfctl_handle *h, struct pfr_table *table,
+ int *ndel, int flags)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_DEL_TABLE);
+
+ snl_add_msg_attr_string(&nw, PF_T_ANCHOR, table->pfrt_anchor);
+ snl_add_msg_attr_string(&nw, PF_T_NAME, table->pfrt_name);
+ snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, table->pfrt_flags);
+ snl_add_msg_attr_u32(&nw, PF_T_FLAGS, flags);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (!snl_parse_nlmsg(&h->ss, hdr, &ndel_parser, ndel))
+ continue;
+ }
+
+ return (e.error);
+}
+
+static bool
+snl_attr_get_uint64_into_int_array(struct snl_state *ss, struct nlattr *nla,
+ const void *arg, void *target)
+{
+ uint64_t *u64target;
+ struct snl_uint64_array a = {
+ .count = 0,
+ .max = (size_t)arg,
+ };
+ bool error;
+
+ u64target = malloc(a.max * sizeof(uint64_t));
+ a.array = u64target;
+
+ error = snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), &array_parser, &a);
+ if (! error)
+ return (error);
+
+ for (size_t i = 0; i < a.count; i++)
+ ((int *)target)[i] = (int)u64target[i];
+
+ free(u64target);
+
+ return (true);
+}
+
+#define _OUT(_field) offsetof(struct pfr_table, _field)
+static const struct snl_attr_parser ap_table[] = {
+ { .type = PF_T_ANCHOR, .off = _OUT(pfrt_anchor), .arg = (void *)MAXPATHLEN, .cb = snl_attr_copy_string },
+ { .type = PF_T_NAME, .off = _OUT(pfrt_name), .arg = (void *)PF_TABLE_NAME_SIZE, .cb =snl_attr_copy_string },
+ { .type = PF_T_TABLE_FLAGS, .off = _OUT(pfrt_flags), .cb = snl_attr_get_uint32 },
+};
+#undef _OUT
+SNL_DECLARE_ATTR_PARSER(table_parser, ap_table);
+#define _OUT(_field) offsetof(struct pfr_tstats, _field)
+static struct snl_attr_parser ap_tstats[] = {
+ { .type = PF_TS_TABLE, .off = _OUT(pfrts_t), .arg = &table_parser, .cb = snl_attr_get_nested },
+ { .type = PF_TS_PACKETS, .off = _OUT(pfrts_packets), .arg = (void *)(PFR_DIR_MAX * PFR_OP_TABLE_MAX), .cb = snl_attr_get_uint64_array},
+ { .type = PF_TS_BYTES, .off = _OUT(pfrts_bytes), .arg = (void *)(PFR_DIR_MAX * PFR_OP_TABLE_MAX), .cb = snl_attr_get_uint64_array },
+ { .type = PF_TS_MATCH, .off = _OUT(pfrts_match), .cb = snl_attr_get_uint64 },
+ {. type = PF_TS_NOMATCH, .off = _OUT(pfrts_nomatch), .cb = snl_attr_get_uint64 },
+ { .type = PF_TS_TZERO, .off = _OUT(pfrts_tzero), .cb = snl_attr_get_uint64 },
+ { .type = PF_TS_REFCNT, .off = _OUT(pfrts_cnt), . arg = (void *)PFR_REFCNT_MAX, .cb = snl_attr_get_uint64_into_int_array },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(tstats_parser, struct genlmsghdr, snl_f_p_empty, ap_tstats);
+
+int
+pfctl_get_tstats(struct pfctl_handle *h, const struct pfr_table *filter,
+ pfctl_get_tstats_fn fn, void *arg)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint32_t seq_id;
+ int family_id;
+ int ret;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_TSTATS);
+
+ snl_add_msg_attr_string(&nw, PF_T_ANCHOR, filter->pfrt_anchor);
+ snl_add_msg_attr_string(&nw, PF_T_NAME, filter->pfrt_name);
+ snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, filter->pfrt_flags);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ struct pfr_tstats tstats = {};
+
+ if (!snl_parse_nlmsg(&h->ss, hdr, &tstats_parser, &tstats))
+ continue;
+
+ ret = fn(&tstats, arg);
+ if (ret != 0)
+ break;
+ }
+
+ return (e.error);
+}
+
+static struct snl_attr_parser ap_tstats_clr[] = {
+ { .type = PF_TS_NZERO, .off = 0, .cb = snl_attr_get_uint64 },
+};
+SNL_DECLARE_PARSER(tstats_clr_parser, struct genlmsghdr, snl_f_p_empty, ap_tstats_clr);
+
+int
+pfctl_clear_tstats(struct pfctl_handle *h, const struct pfr_table *filter,
+ int *nzero, int flags)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint64_t zero;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_CLR_TSTATS);
+
+ snl_add_msg_attr_string(&nw, PF_T_ANCHOR, filter->pfrt_anchor);
+ snl_add_msg_attr_string(&nw, PF_T_NAME, filter->pfrt_name);
+ snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, filter->pfrt_flags);
+ snl_add_msg_attr_u32(&nw, PF_T_FLAGS, flags);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (!snl_parse_nlmsg(&h->ss, hdr, &tstats_clr_parser, &zero))
+ continue;
+ if (nzero)
+ *nzero = (uint32_t)zero;
+ }
+
+ return (e.error);
+}
+
+static struct snl_attr_parser ap_clr_addrs[] = {
+ { .type = PF_T_NBR_DELETED, .off = 0, .cb = snl_attr_get_uint64 },
+};
+SNL_DECLARE_PARSER(clr_addrs_parser, struct genlmsghdr, snl_f_p_empty, ap_clr_addrs);
+
+int
+pfctl_clear_addrs(struct pfctl_handle *h, const struct pfr_table *filter,
+ int *ndel, int flags)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ uint64_t del;
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_CLR_ADDRS);
+
+ snl_add_msg_attr_string(&nw, PF_T_ANCHOR, filter->pfrt_anchor);
+ snl_add_msg_attr_string(&nw, PF_T_NAME, filter->pfrt_name);
+ snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, filter->pfrt_flags);
+ snl_add_msg_attr_u32(&nw, PF_T_FLAGS, flags);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+
+ seq_id = hdr->nlmsg_seq;
+
+ if (!snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (!snl_parse_nlmsg(&h->ss, hdr, &clr_addrs_parser, &del))
+ continue;
+ if (ndel)
+ *ndel = (uint32_t)del;
+ }
+
+ return (e.error);
+}
+
diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h
index 2559fc9c4843..116f9243fda9 100644
--- a/lib/libpfctl/libpfctl.h
+++ b/lib/libpfctl/libpfctl.h
@@ -62,7 +62,7 @@ struct pfctl_status {
struct pfctl_status_counters lcounters;
struct pfctl_status_counters fcounters;
struct pfctl_status_counters scounters;
- uint64_t pcounters[2][2][3];
+ uint64_t pcounters[2][2][2];
uint64_t bcounters[2][2];
};
@@ -143,9 +143,18 @@ struct pfctl_eth_anchor {
int match; /* XXX: used for pfctl black magic */
};
+struct pfctl_pooladdr {
+ struct pf_addr_wrap addr;
+ TAILQ_ENTRY(pfctl_pooladdr) entries;
+ char ifname[IFNAMSIZ];
+ sa_family_t af;
+};
+
+TAILQ_HEAD(pfctl_palist, pfctl_pooladdr);
+
struct pfctl_pool {
- struct pf_palist list;
- struct pf_pooladdr *cur;
+ struct pfctl_palist list;
+ struct pfctl_pooladdr *cur;
struct pf_poolhashkey key;
struct pf_addr counter;
struct pf_mape_portset mape;
@@ -159,6 +168,13 @@ struct pfctl_rules_info {
uint32_t ticket;
};
+struct pfctl_threshold {
+ uint32_t limit;
+ uint32_t seconds;
+ uint32_t count;
+ uint32_t last;
+};
+
struct pfctl_rule {
struct pf_rule_addr src;
struct pf_rule_addr dst;
@@ -174,7 +190,14 @@ struct pfctl_rule {
char overload_tblname[PF_TABLE_NAME_SIZE];
TAILQ_ENTRY(pfctl_rule) entries;
- struct pfctl_pool rpool;
+ struct pfctl_pool nat;
+ union {
+ /* Alias old and new names. */
+ struct pfctl_pool rpool;
+ struct pfctl_pool rdr;
+ };
+ struct pfctl_pool route;
+ struct pfctl_threshold pktrate;
uint64_t evaluations;
uint64_t packets[2];
@@ -197,6 +220,7 @@ struct pfctl_rule {
uint32_t limit;
uint32_t seconds;
} max_src_conn_rate;
+ uint16_t max_pkt_size;
uint32_t qid;
uint32_t pqid;
uint16_t dnpipe;
@@ -210,6 +234,7 @@ struct pfctl_rule {
uint64_t states_cur;
uint64_t states_tot;
uint64_t src_nodes;
+ uint64_t src_nodes_type[PF_SN_MAX];
uint16_t return_icmp;
uint16_t return_icmp6;
@@ -220,6 +245,8 @@ struct pfctl_rule {
struct pf_rule_uid uid;
struct pf_rule_gid gid;
+ char rcv_ifname[IFNAMSIZ];
+ bool rcvifnot;
uint32_t rule_flag;
uint8_t action;
@@ -250,6 +277,7 @@ struct pfctl_rule {
uint8_t flush;
uint8_t prio;
uint8_t set_prio[2];
+ sa_family_t naf;
struct {
struct pf_addr addr;
@@ -310,6 +338,7 @@ struct pfctl_kill {
char ifname[IFNAMSIZ];
char label[PF_RULE_LABEL_SIZE];
bool kill_match;
+ bool nat;
};
struct pfctl_state_peer {
@@ -363,12 +392,13 @@ struct pfctl_state {
uint8_t set_prio[2];
uint8_t rt;
char rt_ifname[IFNAMSIZ];
+ sa_family_t rt_af;
+ uint8_t src_node_flags;
};
TAILQ_HEAD(pfctl_statelist, pfctl_state);
struct pfctl_states {
struct pfctl_statelist states;
- size_t count;
};
enum pfctl_syncookies_mode {
@@ -382,10 +412,39 @@ struct pfctl_syncookies {
enum pfctl_syncookies_mode mode;
uint8_t highwater; /* Percent */
uint8_t lowwater; /* Percent */
+ uint32_t halfopen_states;
};
+struct pfctl_src_node {
+ struct pf_addr addr;
+ struct pf_addr raddr;
+ int rule;
+ uint64_t bytes[2];
+ uint64_t packets[2];
+ uint32_t states;
+ uint32_t conn;
+ sa_family_t af;
+ sa_family_t raf;
+ uint8_t ruletype;
+ uint64_t creation;
+ uint64_t expire;
+ struct pfctl_threshold conn_rate;
+ pf_sn_types_t type;
+};
+
+#define PF_DEVICE "/dev/pf"
+
+struct pfctl_handle;
+struct pfctl_handle *pfctl_open(const char *pf_device);
+void pfctl_close(struct pfctl_handle *);
+int pfctl_fd(struct pfctl_handle *);
+
+int pfctl_startstop(struct pfctl_handle *h, int start);
+struct pfctl_status* pfctl_get_status_h(struct pfctl_handle *h);
struct pfctl_status* pfctl_get_status(int dev);
+int pfctl_clear_status(struct pfctl_handle *h);
uint64_t pfctl_status_counter(struct pfctl_status *status, int id);
+uint64_t pfctl_status_lcounter(struct pfctl_status *status, int id);
uint64_t pfctl_status_fcounter(struct pfctl_status *status, int id);
uint64_t pfctl_status_scounter(struct pfctl_status *status, int id);
void pfctl_free_status(struct pfctl_status *status);
@@ -401,24 +460,52 @@ int pfctl_get_eth_rule(int dev, uint32_t nr, uint32_t ticket,
char *anchor_call);
int pfctl_add_eth_rule(int dev, const struct pfctl_eth_rule *r,
const char *anchor, const char *anchor_call, uint32_t ticket);
+int pfctl_get_rules_info_h(struct pfctl_handle *h,
+ struct pfctl_rules_info *rules, uint32_t ruleset,
+ const char *path);
int pfctl_get_rules_info(int dev, struct pfctl_rules_info *rules,
uint32_t ruleset, const char *path);
int pfctl_get_rule(int dev, uint32_t nr, uint32_t ticket,
const char *anchor, uint32_t ruleset, struct pfctl_rule *rule,
char *anchor_call);
+int pfctl_get_rule_h(struct pfctl_handle *h, uint32_t nr, uint32_t ticket,
+ const char *anchor, uint32_t ruleset, struct pfctl_rule *rule,
+ char *anchor_call);
int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket,
const char *anchor, uint32_t ruleset, struct pfctl_rule *rule,
char *anchor_call, bool clear);
+int pfctl_get_clear_rule_h(struct pfctl_handle *h, uint32_t nr, uint32_t ticket,
+ const char *anchor, uint32_t ruleset, struct pfctl_rule *rule,
+ char *anchor_call, bool clear);
int pfctl_add_rule(int dev, const struct pfctl_rule *r,
const char *anchor, const char *anchor_call, uint32_t ticket,
uint32_t pool_ticket);
+int pfctl_add_rule_h(struct pfctl_handle *h, const struct pfctl_rule *r,
+ const char *anchor, const char *anchor_call, uint32_t ticket,
+ uint32_t pool_ticket);
int pfctl_set_keepcounters(int dev, bool keep);
+int pfctl_get_creatorids(struct pfctl_handle *h, uint32_t *creators, size_t *len);
+
+struct pfctl_state_filter {
+ char ifname[IFNAMSIZ];
+ uint16_t proto;
+ sa_family_t af;
+ struct pf_addr addr;
+ struct pf_addr mask;
+};
+typedef int (*pfctl_get_state_fn)(struct pfctl_state *, void *);
+int pfctl_get_states_iter(pfctl_get_state_fn f, void *arg);
+int pfctl_get_filtered_states_iter(struct pfctl_state_filter *filter, pfctl_get_state_fn f, void *arg);
int pfctl_get_states(int dev, struct pfctl_states *states);
void pfctl_free_states(struct pfctl_states *states);
int pfctl_clear_states(int dev, const struct pfctl_kill *kill,
unsigned int *killed);
int pfctl_kill_states(int dev, const struct pfctl_kill *kill,
unsigned int *killed);
+int pfctl_clear_states_h(struct pfctl_handle *h, const struct pfctl_kill *kill,
+ unsigned int *killed);
+int pfctl_kill_states_h(struct pfctl_handle *h, const struct pfctl_kill *kill,
+ unsigned int *killed);
int pfctl_clear_rules(int dev, const char *anchorname);
int pfctl_clear_nat(int dev, const char *anchorname);
int pfctl_clear_eth_rules(int dev, const char *anchorname);
@@ -433,4 +520,55 @@ int pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
int flags);
int pfctl_table_get_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
*addr, int *size, int flags);
+int pfctl_set_statusif(struct pfctl_handle *h, const char *ifname);
+
+struct pfctl_natlook_key {
+ sa_family_t af;
+ uint8_t direction;
+ uint8_t proto;
+ struct pf_addr saddr;
+ struct pf_addr daddr;
+ uint16_t sport;
+ uint16_t dport;
+};
+struct pfctl_natlook {
+ struct pf_addr saddr;
+ struct pf_addr daddr;
+ uint16_t sport;
+ uint16_t dport;
+};
+int pfctl_natlook(struct pfctl_handle *h,
+ const struct pfctl_natlook_key *k, struct pfctl_natlook *r);
+int pfctl_set_debug(struct pfctl_handle *h, uint32_t level);
+int pfctl_set_timeout(struct pfctl_handle *h, uint32_t timeout, uint32_t seconds);
+int pfctl_get_timeout(struct pfctl_handle *h, uint32_t timeout, uint32_t *seconds);
+int pfctl_set_limit(struct pfctl_handle *h, const int index, const uint limit);
+int pfctl_get_limit(struct pfctl_handle *h, const int index, uint *limit);
+int pfctl_begin_addrs(struct pfctl_handle *h, uint32_t *ticket);
+int pfctl_add_addr(struct pfctl_handle *h, const struct pfioc_pooladdr *pa, int which);
+int pfctl_get_addrs(struct pfctl_handle *h, uint32_t ticket, uint32_t r_num,
+ uint8_t r_action, const char *anchor, uint32_t *nr, int which);
+int pfctl_get_addr(struct pfctl_handle *h, uint32_t ticket, uint32_t r_num,
+ uint8_t r_action, const char *anchor, uint32_t nr, struct pfioc_pooladdr *pa,
+ int which);
+int pfctl_get_rulesets(struct pfctl_handle *h, const char *path, uint32_t *nr);
+int pfctl_get_ruleset(struct pfctl_handle *h, const char *path, uint32_t nr, struct pfioc_ruleset *rs);
+typedef int (*pfctl_get_srcnode_fn)(struct pfctl_src_node*, void *);
+int pfctl_get_srcnodes(struct pfctl_handle *h, pfctl_get_srcnode_fn fn, void *arg);
+
+int pfctl_clear_tables(struct pfctl_handle *h, struct pfr_table *filter,
+ int *ndel, int flags);
+int pfctl_add_table(struct pfctl_handle *h, struct pfr_table *table,
+ int *nadd, int flags);
+int pfctl_del_table(struct pfctl_handle *h, struct pfr_table *table,
+ int *ndel, int flags);
+
+typedef int (*pfctl_get_tstats_fn)(const struct pfr_tstats *t, void *arg);
+int pfctl_get_tstats(struct pfctl_handle *h, const struct pfr_table *filter,
+ pfctl_get_tstats_fn fn, void *arg);
+int pfctl_clear_tstats(struct pfctl_handle *h, const struct pfr_table *filter,
+ int *nzero, int flags);
+int pfctl_clear_addrs(struct pfctl_handle *h, const struct pfr_table *filter,
+ int *ndel, int flags);
+
#endif
diff --git a/lib/libpjdlog/pjdlog.c b/lib/libpjdlog/pjdlog.c
index 5cf0976c7a0e..abfcd066da88 100644
--- a/lib/libpjdlog/pjdlog.c
+++ b/lib/libpjdlog/pjdlog.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile
index 5deff06270f7..8728b0c1c76d 100644
--- a/lib/libpmc/Makefile
+++ b/lib/libpmc/Makefile
@@ -1,4 +1,3 @@
-
LIB_CXX= pmc
SRCS= libpmc.c pmclog.c libpmc_pmu_util.c libpmc_json.cc
@@ -62,6 +61,7 @@ MAN+= pmclog.3
MAN+= pmc.soft.3
# PMC-dependent manual pages
+MAN+= pmc.amd.3
MAN+= pmc.atom.3
MAN+= pmc.atomsilvermont.3
MAN+= pmc.cmn-600.3
@@ -76,8 +76,6 @@ MAN+= pmc.haswellxeon.3
MAN+= pmc.iaf.3
MAN+= pmc.ivybridge.3
MAN+= pmc.ivybridgexeon.3
-MAN+= pmc.k7.3
-MAN+= pmc.k8.3
MAN+= pmc.sandybridge.3
MAN+= pmc.sandybridgeuc.3
MAN+= pmc.sandybridgexeon.3
@@ -113,4 +111,8 @@ MLINKS+= \
pmclog.3 pmclog_feed.3 \
pmclog.3 pmclog_read.3
+# Class aliases
+MLINKS+= \
+ pmc.amd.3 pmc.k8.3
+
.include <bsd.lib.mk>
diff --git a/lib/libpmc/Makefile.inc b/lib/libpmc/Makefile.inc
index 04846e847467..35f9588b6080 100644
--- a/lib/libpmc/Makefile.inc
+++ b/lib/libpmc/Makefile.inc
@@ -1,2 +1 @@
-
WARNS?= 3
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index a7ed1c3d9ac8..10e357f55935 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -26,14 +26,12 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/module.h>
#include <sys/pmc.h>
#include <sys/syscall.h>
-#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <err.h>
@@ -1083,14 +1081,8 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode,
r = spec_copy = strdup(ctrspec);
ctrname = strsep(&r, ",");
if (pmc_pmu_enabled()) {
- if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) {
- /*
- * XXX: pmclog_get_event exploits this to disambiguate
- * PMU from PMC event codes in PMCALLOCATE events.
- */
- assert(pmc_config.pm_ev < PMC_EVENT_FIRST);
+ if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0)
goto found;
- }
}
free(spec_copy);
spec_copy = NULL;
diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c
index 772dec7a9d53..74a93ae963d7 100644
--- a/lib/libpmc/libpmc_pmu_util.c
+++ b/lib/libpmc/libpmc_pmu_util.c
@@ -622,7 +622,6 @@ pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm)
if (pmu_parse_event(&ped, pe->event))
return (ENOENT);
- assert(ped.ped_event >= 0);
pm->pm_ev = idx;
pm->pm_md.pm_event = ped.ped_event;
pm->pm_class = PMC_CLASS_POWER8;
@@ -649,7 +648,6 @@ pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm)
assert(idx >= 0);
pm->pm_ev = idx;
pm->pm_md.pm_md_config = ped.ped_event;
- pm->pm_md.pm_md_flags |= PM_MD_RAW_EVENT;
pm->pm_class = PMC_CLASS_ARMV8;
pm->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE);
@@ -680,5 +678,6 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
return (error);
}
+ pm->pm_flags |= PMC_F_EV_PMU;
return (0);
}
diff --git a/lib/libpmc/pmc.3 b/lib/libpmc/pmc.3
index d2be8f6c3a6d..9a5b599759ff 100644
--- a/lib/libpmc/pmc.3
+++ b/lib/libpmc/pmc.3
@@ -21,7 +21,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 16, 2023
+.Dd June 23, 2023
.Dt PMC 3
.Os
.Sh NAME
@@ -130,9 +130,6 @@ enumeration.
Supported CPUs include:
.Pp
.Bl -tag -width "Li PMC_CPU_ARMV7_CORTEX_A15" -compact
-.It Li PMC_CPU_AMD_K7
-.Tn "AMD Athlon"
-CPUs.
.It Li PMC_CPU_AMD_K8
.Tn "AMD Athlon64"
CPUs.
@@ -227,10 +224,6 @@ performance measurement architecture version 2 and later.
Programmable hardware counters present in CPUs conforming to the
.Tn Intel
performance measurement architecture version 1 and later.
-.It Li PMC_CLASS_K7
-Programmable hardware counters present in
-.Tn "AMD Athlon"
-CPUs.
.It Li PMC_CLASS_K8
Programmable hardware counters present in
.Tn "AMD Athlon64"
@@ -498,8 +491,7 @@ following manual pages:
.It Em "PMC Class" Ta Em "Manual Page"
.It Li PMC_CLASS_IAF Ta Xr pmc.iaf 3
.It Li PMC_CLASS_IAP Ta Xr pmc.atom 3 , Xr pmc.core 3 , Xr pmc.core2 3
-.It Li PMC_CLASS_K7 Ta Xr pmc.k7 3
-.It Li PMC_CLASS_K8 Ta Xr pmc.k8 3
+.It Li PMC_CLASS_K8 Ta Xr pmc.amd 3
.It Li PMC_CLASS_TSC Ta Xr pmc.tsc 3
.El
.Ss Event Name Aliases
@@ -542,6 +534,7 @@ driver, applications are urged to dynamically link with the
library.
Doing otherwise is unsupported.
.Sh SEE ALSO
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
@@ -551,8 +544,6 @@ Doing otherwise is unsupported.
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridge 3 ,
.Xr pmc.ivybridgexeon 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
diff --git a/lib/libpmc/pmc.amd.3 b/lib/libpmc/pmc.amd.3
new file mode 100644
index 000000000000..047b31aa78bb
--- /dev/null
+++ b/lib/libpmc/pmc.amd.3
@@ -0,0 +1,793 @@
+.\" Copyright (c) 2003-2008 Joseph Koshy. 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.
+.\"
+.Dd June 24, 2023
+.Dt PMC.AMD 3
+.Os
+.Sh NAME
+.Nm pmc.amd
+.Nm pmc.k8
+.Nd measurement events for
+.Tn AMD
+.Tn Athlon 64
+(K8 family) CPUs
+.Sh LIBRARY
+.Lb libpmc
+.Sh SYNOPSIS
+.In pmc.h
+.Sh DESCRIPTION
+AMD K8 PMCs are present in the
+.Tn "AMD Athlon64"
+and
+.Tn "AMD Opteron"
+series of CPUs.
+They are documented in the
+.Rs
+.%B "BIOS and Kernel Developer's Guide for the AMD Athlon(tm) 64 and AMD Opteron Processors"
+.%N "Publication No. 26094"
+.%D "April 2004"
+.%Q "Advanced Micro Devices, Inc."
+.Re
+.Ss PMC Features
+AMD K8 PMCs are 48 bits wide.
+Each CPU contains 4 PMCs with the following capabilities:
+.Bl -column "PMC_CAP_INTERRUPT" "Support"
+.It Em Capability Ta Em Support
+.It PMC_CAP_CASCADE Ta \&No
+.It PMC_CAP_EDGE Ta Yes
+.It PMC_CAP_INTERRUPT Ta Yes
+.It PMC_CAP_INVERT Ta Yes
+.It PMC_CAP_READ Ta Yes
+.It PMC_CAP_PRECISE Ta \&No
+.It PMC_CAP_SYSTEM Ta Yes
+.It PMC_CAP_TAGGING Ta \&No
+.It PMC_CAP_THRESHOLD Ta Yes
+.It PMC_CAP_USER Ta Yes
+.It PMC_CAP_WRITE Ta Yes
+.El
+.Ss Event Qualifiers
+Event specifiers for AMD K8 PMCs can have the following optional
+qualifiers:
+.Bl -tag -width indent
+.It Li count= Ns Ar value
+Configure the counter to increment only if the number of configured
+events measured in a cycle is greater than or equal to
+.Ar value .
+.It Li edge
+Configure the counter to only count negated-to-asserted transitions
+of the conditions expressed by the other fields.
+In other words, the counter will increment only once whenever a given
+condition becomes true, irrespective of the number of clocks during
+which the condition remains true.
+.It Li inv
+Invert the sense of comparison when the
+.Dq Li count
+qualifier is present, making the counter to increment when the
+number of events per cycle is less than the value specified by
+the
+.Dq Li count
+qualifier.
+.It Li mask= Ns Ar qualifier
+Many event specifiers for AMD K8 PMCs need to be additionally
+qualified using a mask qualifier.
+These additional qualifiers are event-specific and are documented
+along with their associated event specifiers below.
+.It Li os
+Configure the PMC to count events happening at privilege level 0.
+.It Li usr
+Configure the PMC to count events occurring at privilege levels 1, 2
+or 3.
+.El
+.Pp
+If neither of the
+.Dq Li os
+or
+.Dq Li usr
+qualifiers were specified, the default is to enable both.
+.Ss AMD K8 Event Specifiers
+The event specifiers supported on AMD K8 PMCs are:
+.Bl -tag -width indent
+.It Li k8-bu-cpu-clk-unhalted
+.Pq Event 76H
+Count the number of clock cycles when the CPU is not in the HLT or
+STPCLK states.
+.It Li k8-bu-fill-request-l2-miss Op Li ,mask= Ns Ar qualifier
+.Pq Event 7EH
+Count fill requests that missed in the L2 cache.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li dc-fill
+Count data cache fill requests.
+.It Li ic-fill
+Count instruction cache fill requests.
+.It Li tlb-reload
+Count TLB reloads.
+.El
+.Pp
+The default is to count all types of requests.
+.It Li k8-bu-fill-into-l2 Op Li ,mask= Ns Ar qualifier
+.Pq Event 7FH
+The number of lines written to and from the L2 cache.
+The event may be further qualified by using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li dirty-l2-victim
+Count lines written into L2 cache due to victim writebacks from the
+Icache or Dcache, TLB page table walks or hardware data prefetches.
+.It Li victim-from-l2
+Count writebacks of dirty lines from L2 to the system.
+.El
+.It Li k8-bu-internal-l2-request Op Li ,mask= Ns Ar qualifier
+.Pq Event 7DH
+Count internally generated requests to the L2 cache.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li cancelled
+Count cancelled requests.
+.It Li dc-fill
+Count data cache fill requests.
+.It Li ic-fill
+Count instruction cache fill requests.
+.It Li tag-snoop
+Count tag snoop requests.
+.It Li tlb-reload
+Count TLB reloads.
+.El
+.Pp
+The default is to count all types of requests.
+.It Li k8-dc-access
+.Pq Event 40H
+Count data cache accesses including microcode scratch pad accesses.
+.It Li k8-dc-copyback Op Li ,mask= Ns Ar qualifier
+.Pq Event 44H
+Count data cache copyback operations.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li exclusive
+Count operations for lines in the
+.Dq exclusive
+state.
+.It Li invalid
+Count operations for lines in the
+.Dq invalid
+state.
+.It Li modified
+Count operations for lines in the
+.Dq modified
+state.
+.It Li owner
+Count operations for lines in the
+.Dq owner
+state.
+.It Li shared
+Count operations for lines in the
+.Dq shared
+state.
+.El
+.Pp
+The default is to count operations for lines in all the
+above states.
+.It Li k8-dc-dcache-accesses-by-locks Op Li ,mask= Ns Ar qualifier
+.Pq Event 4CH
+Count data cache accesses by lock instructions.
+This event is only available on processors of revision C or later
+vintage.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li accesses
+Count data cache accesses by lock instructions.
+.It Li misses
+Count data cache misses by lock instructions.
+.El
+.Pp
+The default is to count all accesses.
+.It Li k8-dc-dispatched-prefetch-instructions Op Li ,mask= Ns Ar qualifier
+.Pq Event 4BH
+Count the number of dispatched prefetch instructions.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li load
+Count load operations.
+.It Li nta
+Count non-temporal operations.
+.It Li store
+Count store operations.
+.El
+.Pp
+The default is to count all operations.
+.It Li k8-dc-l1-dtlb-miss-and-l2-dtlb-hit
+.Pq Event 45H
+Count L1 DTLB misses that are L2 DTLB hits.
+.It Li k8-dc-l1-dtlb-miss-and-l2-dtlb-miss
+.Pq Event 46H
+Count L1 DTLB misses that are also misses in the L2 DTLB.
+.It Li k8-dc-microarchitectural-early-cancel-of-an-access
+.Pq Event 49H
+Count microarchitectural early cancels of data cache accesses.
+.It Li k8-dc-microarchitectural-late-cancel-of-an-access
+.Pq Event 48H
+Count microarchitectural late cancels of data cache accesses.
+.It Li k8-dc-misaligned-data-reference
+.Pq Event 47H
+Count misaligned data references.
+.It Li k8-dc-miss
+.Pq Event 41H
+Count data cache misses.
+.It Li k8-dc-one-bit-ecc-error Op Li ,mask= Ns Ar qualifier
+.Pq Event 4AH
+Count one bit ECC errors found by the scrubber.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li scrubber
+Count scrubber detected errors.
+.It Li piggyback
+Count piggyback scrubber errors.
+.El
+.Pp
+The default is to count both kinds of errors.
+.It Li k8-dc-refill-from-l2 Op Li ,mask= Ns Ar qualifier
+.Pq Event 42H
+Count data cache refills from L2 cache.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li exclusive
+Count operations for lines in the
+.Dq exclusive
+state.
+.It Li invalid
+Count operations for lines in the
+.Dq invalid
+state.
+.It Li modified
+Count operations for lines in the
+.Dq modified
+state.
+.It Li owner
+Count operations for lines in the
+.Dq owner
+state.
+.It Li shared
+Count operations for lines in the
+.Dq shared
+state.
+.El
+.Pp
+The default is to count operations for lines in all the
+above states.
+.It Li k8-dc-refill-from-system Op Li ,mask= Ns Ar qualifier
+.Pq Event 43H
+Count data cache refills from system memory.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li exclusive
+Count operations for lines in the
+.Dq exclusive
+state.
+.It Li invalid
+Count operations for lines in the
+.Dq invalid
+state.
+.It Li modified
+Count operations for lines in the
+.Dq modified
+state.
+.It Li owner
+Count operations for lines in the
+.Dq owner
+state.
+.It Li shared
+Count operations for lines in the
+.Dq shared
+state.
+.El
+.Pp
+The default is to count operations for lines in all the
+above states.
+.It Li k8-fp-cycles-with-no-fpu-ops-retired
+.Pq Event 01H
+Count cycles when no FPU ops were retired.
+This event is supported in revision B and later CPUs.
+.It Li k8-fp-dispatched-fpu-fast-flag-ops
+.Pq Event 02H
+Count dispatched FPU ops that use the fast flag interface.
+This event is supported in revision B and later CPUs.
+.It Li k8-fp-dispatched-fpu-ops Op Li ,mask= Ns Ar qualifier
+.Pq Event 00H
+Count the number of dispatched FPU ops.
+This event is supported in revision B and later CPUs.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li add-pipe-excluding-junk-ops
+Count add pipe ops excluding junk ops.
+.It Li add-pipe-junk-ops
+Count junk ops in the add pipe.
+.It Li multiply-pipe-excluding-junk-ops
+Count multiply pipe ops excluding junk ops.
+.It Li multiply-pipe-junk-ops
+Count junk ops in the multiply pipe.
+.It Li store-pipe-excluding-junk-ops
+Count store pipe ops excluding junk ops
+.It Li store-pipe-junk-ops
+Count junk ops in the store pipe.
+.El
+.Pp
+The default is to count all types of ops.
+.It Li k8-fr-decoder-empty
+.Pq Event D0H
+Count cycles when there was nothing to dispatch (i.e., the decoder
+was empty).
+.It Li k8-fr-dispatch-stall-for-segment-load
+.Pq Event D4H
+Count dispatch stalls for segment loads.
+.It Li k8-fr-dispatch-stall-for-serialization
+.Pq Event D3H
+Count dispatch stalls for serialization.
+.It Li k8-fr-dispatch-stall-from-branch-abort-to-retire
+.Pq Event D2H
+Count dispatch stalls from branch abort to retiral.
+.It Li k8-fr-dispatch-stall-when-fpu-is-full
+.Pq Event D7H
+Count dispatch stalls when the FPU is full.
+.It Li k8-fr-dispatch-stall-when-ls-is-full
+.Pq Event D8H
+Count dispatch stalls when the load/store unit is full.
+.It Li k8-fr-dispatch-stall-when-reorder-buffer-is-full
+.Pq Event D5H
+Count dispatch stalls when the reorder buffer is full.
+.It Li k8-fr-dispatch-stall-when-reservation-stations-are-full
+.Pq Event D6H
+Count dispatch stalls when reservation stations are full.
+.It Li k8-fr-dispatch-stall-when-waiting-far-xfer-or-resync-branch-pending
+.Pq Event DAH
+Count dispatch stalls when a far control transfer or a resync branch
+is pending.
+.It Li k8-fr-dispatch-stall-when-waiting-for-all-to-be-quiet
+.Pq Event D9H
+Count dispatch stalls when waiting for all to be quiet.
+.\" XXX What does "waiting for all to be quiet" mean?
+.It Li k8-fr-dispatch-stalls
+.Pq Event D1H
+Count all dispatch stalls.
+.It Li k8-fr-fpu-exceptions Op Li ,mask= Ns Ar qualifier
+.Pq Event DBH
+Count FPU exceptions.
+This event is supported in revision B and later CPUs.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li sse-and-x87-microtraps
+Count SSE and x87 microtraps.
+.It Li sse-reclass-microfaults
+Count SSE reclass microfaults
+.It Li sse-retype-microfaults
+Count SSE retype microfaults
+.It Li x87-reclass-microfaults
+Count x87 reclass microfaults.
+.El
+.Pp
+The default is to count all types of exceptions.
+.It Li k8-fr-interrupts-masked-cycles
+.Pq Event CDH
+Count cycles when interrupts were masked (by CPU RFLAGS field IF was zero).
+.It Li k8-fr-interrupts-masked-while-pending-cycles
+.Pq Event CEH
+Count cycles while interrupts were masked while pending (i.e., cycles
+when INTR was asserted while CPU RFLAGS field IF was zero).
+.It Li k8-fr-number-of-breakpoints-for-dr0
+.Pq Event DCH
+Count the number of breakpoints for DR0.
+.It Li k8-fr-number-of-breakpoints-for-dr1
+.Pq Event DDH
+Count the number of breakpoints for DR1.
+.It Li k8-fr-number-of-breakpoints-for-dr2
+.Pq Event DEH
+Count the number of breakpoints for DR2.
+.It Li k8-fr-number-of-breakpoints-for-dr3
+.Pq Event DFH
+Count the number of breakpoints for DR3.
+.It Li k8-fr-retired-branches
+.Pq Event C2H
+Count retired branches including exceptions and interrupts.
+.It Li k8-fr-retired-branches-mispredicted
+.Pq Event C3H
+Count mispredicted retired branches.
+.It Li k8-fr-retired-far-control-transfers
+.Pq Event C6H
+Count retired far control transfers (which are always mispredicted).
+.It Li k8-fr-retired-fastpath-double-op-instructions Op Li ,mask= Ns Ar qualifier
+.Pq Event CCH
+Count retired fastpath double op instructions.
+This event is supported in revision B and later CPUs.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li low-op-pos-0
+Count instructions with the low op in position 0.
+.It Li low-op-pos-1
+Count instructions with the low op in position 1.
+.It Li low-op-pos-2
+Count instructions with the low op in position 2.
+.El
+.Pp
+The default is to count all types of instructions.
+.It Li k8-fr-retired-fpu-instructions Op Li ,mask= Ns Ar qualifier
+.Pq Event CBH
+Count retired FPU instructions.
+This event is supported in revision B and later CPUs.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li mmx-3dnow
+Count MMX and 3DNow!\& instructions.
+.It Li packed-sse-sse2
+Count packed SSE and SSE2 instructions.
+.It Li scalar-sse-sse2
+Count scalar SSE and SSE2 instructions
+.It Li x87
+Count x87 instructions.
+.El
+.Pp
+The default is to count all types of instructions.
+.It Li k8-fr-retired-near-returns
+.Pq Event C8H
+Count retired near returns.
+.It Li k8-fr-retired-near-returns-mispredicted
+.Pq Event C9H
+Count mispredicted near returns.
+.It Li k8-fr-retired-resyncs
+.Pq Event C7H
+Count retired resyncs (non-control transfer branches).
+.It Li k8-fr-retired-taken-branches
+.Pq Event C4H
+Count retired taken branches.
+.It Li k8-fr-retired-taken-branches-mispredicted
+.Pq Event C5H
+Count retired taken branches that were mispredicted.
+.It Li k8-fr-retired-taken-branches-mispredicted-by-addr-miscompare
+.Pq Event CAH
+Count retired taken branches that were mispredicted only due to an
+address miscompare.
+.It Li k8-fr-retired-taken-hardware-interrupts
+.Pq Event CFH
+Count retired taken hardware interrupts.
+.It Li k8-fr-retired-uops
+.Pq Event C1H
+Count retired uops.
+.It Li k8-fr-retired-x86-instructions
+.Pq Event C0H
+Count retired x86 instructions including exceptions and interrupts.
+.It Li k8-ic-fetch
+.Pq Event 80H
+Count instruction cache fetches.
+.It Li k8-ic-instruction-fetch-stall
+.Pq Event 87H
+Count cycles in stalls due to instruction fetch.
+.It Li k8-ic-l1-itlb-miss-and-l2-itlb-hit
+.Pq Event 84H
+Count L1 ITLB misses that are L2 ITLB hits.
+.It Li k8-ic-l1-itlb-miss-and-l2-itlb-miss
+.Pq Event 85H
+Count ITLB misses that miss in both L1 and L2 ITLBs.
+.It Li k8-ic-microarchitectural-resync-by-snoop
+.Pq Event 86H
+Count microarchitectural resyncs caused by snoops.
+.It Li k8-ic-miss
+.Pq Event 81H
+Count instruction cache misses.
+.It Li k8-ic-refill-from-l2
+.Pq Event 82H
+Count instruction cache refills from L2 cache.
+.It Li k8-ic-refill-from-system
+.Pq Event 83H
+Count instruction cache refills from system memory.
+.It Li k8-ic-return-stack-hits
+.Pq Event 88H
+Count hits to the return stack.
+.It Li k8-ic-return-stack-overflow
+.Pq Event 89H
+Count overflows of the return stack.
+.It Li k8-ls-buffer2-full
+.Pq Event 23H
+Count load/store buffer2 full events.
+.It Li k8-ls-locked-operation Op Li ,mask= Ns Ar qualifier
+.Pq Event 24H
+Count locked operations.
+For revision C and later CPUs, the following qualifiers are supported:
+.Pp
+.Bl -tag -width indent -compact
+.It Li cycles-in-request
+Count the number of cycles in the lock request/grant stage.
+.It Li cycles-to-complete
+Count the number of cycles a lock takes to complete once it is
+non-speculative and is the older load/store operation.
+.It Li locked-instructions
+Count the number of lock instructions executed.
+.El
+.Pp
+The default is to count the number of lock instructions executed.
+.It Li k8-ls-microarchitectural-late-cancel
+.Pq Event 25H
+Count microarchitectural late cancels of operations in the load/store
+unit.
+.It Li k8-ls-microarchitectural-resync-by-self-modifying-code
+.Pq Event 21H
+Count microarchitectural resyncs caused by self-modifying code.
+.It Li k8-ls-microarchitectural-resync-by-snoop
+.Pq Event 22H
+Count microarchitectural resyncs caused by snoops.
+.It Li k8-ls-retired-cflush-instructions
+.Pq Event 26H
+Count retired CFLUSH instructions.
+.It Li k8-ls-retired-cpuid-instructions
+.Pq Event 27H
+Count retired CPUID instructions.
+.It Li k8-ls-segment-register-load Op Li ,mask= Ns Ar qualifier
+.Pq Event 20H
+Count segment register loads.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Bl -tag -width indent -compact
+.It Li cs
+Count CS register loads.
+.It Li ds
+Count DS register loads.
+.It Li es
+Count ES register loads.
+.It Li fs
+Count FS register loads.
+.It Li gs
+Count GS register loads.
+.\" .It Li hs
+.\" Count HS register loads.
+.\" XXX "HS" register?
+.It Li ss
+Count SS register loads.
+.El
+.Pp
+The default is to count all types of loads.
+.It Li k8-nb-ht-bus0-bandwidth Op Li ,mask= Ns Ar qualifier
+.It Li k8-nb-ht-bus1-bandwidth Op Li ,mask= Ns Ar qualifier
+.It Li k8-nb-ht-bus2-bandwidth Op Li ,mask= Ns Ar qualifier
+.Pq Events F6H, F7H and F8H respectively
+Count events on the HyperTransport(tm) buses.
+These events may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li buffer-release
+Count buffer release messages sent.
+.It Li command
+Count command messages sent.
+.It Li data
+Count data messages sent.
+.It Li nop
+Count nop messages sent.
+.El
+.Pp
+The default is to count all types of messages.
+.It Li k8-nb-memory-controller-bypass-saturation Op Li ,mask= Ns Ar qualifier
+.Pq Event E4H
+Count memory controller bypass counter saturation events.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li dram-controller-interface-bypass
+Count DRAM controller interface bypass.
+.It Li dram-controller-queue-bypass
+Count DRAM controller queue bypass.
+.It Li memory-controller-hi-pri-bypass
+Count memory controller high priority bypasses.
+.It Li memory-controller-lo-pri-bypass
+Count memory controller low priority bypasses.
+.El
+.It Li k8-nb-memory-controller-dram-slots-missed
+.Pq Event E2H
+Count memory controller DRAM command slots missed (in MemClks).
+.It Li k8-nb-memory-controller-page-access-event Op Li ,mask= Ns Ar qualifier
+.Pq Event E0H
+Count memory controller page access events.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li page-conflict
+Count page conflicts.
+.It Li page-hit
+Count page hits.
+.It Li page-miss
+Count page misses.
+.El
+.Pp
+The default is to count all types of events.
+.It Li k8-nb-memory-controller-page-table-overflow
+.Pq Event E1H
+Count memory control page table overflow events.
+.It Li k8-nb-memory-controller-turnaround Op Li ,mask= Ns Ar qualifier
+.Pq Event E3H
+Count memory control turnaround events.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.\" XXX doc is unclear whether these are cycle counts or event counts
+.It Li dimm-turnaround
+Count DIMM turnarounds.
+.It Li read-to-write-turnaround
+Count read to write turnarounds.
+.It Li write-to-read-turnaround
+Count write to read turnarounds.
+.El
+.Pp
+The default is to count all types of events.
+.It Li k8-nb-probe-result Op Li ,mask= Ns Ar qualifier
+.Pq Event ECH
+Count probe events.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li probe-hit
+Count all probe hits.
+.It Li probe-hit-dirty-no-memory-cancel
+Count probe hits without memory cancels.
+.It Li probe-hit-dirty-with-memory-cancel
+Count probe hits with memory cancels.
+.It Li probe-miss
+Count probe misses.
+.El
+.It Li k8-nb-sized-commands Op Li ,mask= Ns Ar qualifier
+.Pq Event EBH
+Count sized commands issued.
+This event may be further qualified using
+.Ar qualifier ,
+which is a
+.Ql +
+separated set of the following keywords:
+.Pp
+.Bl -tag -width indent -compact
+.It Li nonpostwrszbyte
+.It Li nonpostwrszdword
+.It Li postwrszbyte
+.It Li postwrszdword
+.It Li rdszbyte
+.It Li rdszdword
+.It Li rdmodwr
+.El
+.Pp
+The default is to count all types of commands.
+.El
+.Ss Event Name Aliases
+The following table shows the mapping between the PMC-independent
+aliases supported by
+.Lb libpmc
+and the underlying hardware events used.
+.Bl -column "branch-mispredicts" "Description"
+.It Em Alias Ta Em Event
+.It Li branches Ta Li k8-fr-retired-taken-branches
+.It Li branch-mispredicts Ta Li k8-fr-retired-taken-branches-mispredicted
+.It Li dc-misses Ta Li k8-dc-miss
+.It Li ic-misses Ta Li k8-ic-miss
+.It Li instructions Ta Li k8-fr-retired-x86-instructions
+.It Li interrupts Ta Li k8-fr-taken-hardware-interrupts
+.It Li unhalted-cycles Ta Li k8-bu-cpu-clk-unhalted
+.El
+.Sh SEE ALSO
+.Xr pmc 3 ,
+.Xr pmc.atom 3 ,
+.Xr pmc.core 3 ,
+.Xr pmc.core2 3 ,
+.Xr pmc.iaf 3 ,
+.Xr pmc.soft 3 ,
+.Xr pmc.tsc 3 ,
+.Xr pmclog 3 ,
+.Xr hwpmc 4
+.Sh HISTORY
+The
+.Nm pmc
+library first appeared in
+.Fx 6.0 .
+.Sh AUTHORS
+The
+.Lb libpmc
+library was written by
+.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
diff --git a/lib/libpmc/pmc.atom.3 b/lib/libpmc/pmc.atom.3
index 34cd4a646e6c..480668e6e6bd 100644
--- a/lib/libpmc/pmc.atom.3
+++ b/lib/libpmc/pmc.atom.3
@@ -1166,12 +1166,11 @@ and the underlying hardware events used on these CPUs.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atomsilvermont 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
diff --git a/lib/libpmc/pmc.atomsilvermont.3 b/lib/libpmc/pmc.atomsilvermont.3
index 975e4310e61a..cacee51d0e0c 100644
--- a/lib/libpmc/pmc.atomsilvermont.3
+++ b/lib/libpmc/pmc.atomsilvermont.3
@@ -504,12 +504,11 @@ The number of times the MSROM starts a flow of UOPS.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
diff --git a/lib/libpmc/pmc.cmn-600.3 b/lib/libpmc/pmc.cmn-600.3
index fc137d2df48e..5b2937703105 100644
--- a/lib/libpmc/pmc.cmn-600.3
+++ b/lib/libpmc/pmc.cmn-600.3
@@ -553,15 +553,13 @@ Average latency to form a TX TLP
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.westmere 3 ,
diff --git a/lib/libpmc/pmc.core.3 b/lib/libpmc/pmc.core.3
index 43a46633806f..b4fa9ab661a4 100644
--- a/lib/libpmc/pmc.core.3
+++ b/lib/libpmc/pmc.core.3
@@ -782,11 +782,10 @@ may not count some transitions.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.core2.3 b/lib/libpmc/pmc.core2.3
index 201867bd9ed8..86604b7ff16c 100644
--- a/lib/libpmc/pmc.core2.3
+++ b/lib/libpmc/pmc.core2.3
@@ -1097,11 +1097,10 @@ and the underlying hardware events used.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
diff --git a/lib/libpmc/pmc.corei7.3 b/lib/libpmc/pmc.corei7.3
index 5f5436745478..32b28eb3db48 100644
--- a/lib/libpmc/pmc.corei7.3
+++ b/lib/libpmc/pmc.corei7.3
@@ -1575,12 +1575,11 @@ Counts number of segment register loads.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.ucf 3 ,
diff --git a/lib/libpmc/pmc.corei7uc.3 b/lib/libpmc/pmc.corei7uc.3
index e062302a4e43..6a059d84a0f9 100644
--- a/lib/libpmc/pmc.corei7uc.3
+++ b/lib/libpmc/pmc.corei7uc.3
@@ -878,12 +878,11 @@ into a power down mode.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.ucf 3 ,
diff --git a/lib/libpmc/pmc.dmc-620.3 b/lib/libpmc/pmc.dmc-620.3
index 568ff3fab6f0..1cd455af1330 100644
--- a/lib/libpmc/pmc.dmc-620.3
+++ b/lib/libpmc/pmc.dmc-620.3
@@ -123,15 +123,13 @@ The following PMC events are available:
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.westmere 3 ,
diff --git a/lib/libpmc/pmc.h b/lib/libpmc/pmc.h
index a9851ecd807b..837cc5a1cc54 100644
--- a/lib/libpmc/pmc.h
+++ b/lib/libpmc/pmc.h
@@ -29,7 +29,6 @@
#ifndef _PMC_H_
#define _PMC_H_
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/pmc.h>
diff --git a/lib/libpmc/pmc.haswell.3 b/lib/libpmc/pmc.haswell.3
index 736440612886..495516cf45a0 100644
--- a/lib/libpmc/pmc.haswell.3
+++ b/lib/libpmc/pmc.haswell.3
@@ -909,6 +909,7 @@ Dirty L2 cache lines evicted by demand.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
@@ -917,8 +918,6 @@ Dirty L2 cache lines evicted by demand.
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridge 3 ,
.Xr pmc.ivybridgexeon 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
diff --git a/lib/libpmc/pmc.haswelluc.3 b/lib/libpmc/pmc.haswelluc.3
index 42d379a0cb9f..a9587c3b5604 100644
--- a/lib/libpmc/pmc.haswelluc.3
+++ b/lib/libpmc/pmc.haswelluc.3
@@ -195,14 +195,13 @@ Number of requests allocated in Coherency Tracker.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.haswell 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
diff --git a/lib/libpmc/pmc.haswellxeon.3 b/lib/libpmc/pmc.haswellxeon.3
index 55ff8d061c3a..e6cf65c5e6dc 100644
--- a/lib/libpmc/pmc.haswellxeon.3
+++ b/lib/libpmc/pmc.haswellxeon.3
@@ -922,6 +922,7 @@ Dirty L2 cache lines evicted by demand.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
@@ -931,8 +932,6 @@ Dirty L2 cache lines evicted by demand.
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridge 3 ,
.Xr pmc.ivybridgexeon 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
diff --git a/lib/libpmc/pmc.iaf.3 b/lib/libpmc/pmc.iaf.3
index b407f4b650c9..eaf45db140f5 100644
--- a/lib/libpmc/pmc.iaf.3
+++ b/lib/libpmc/pmc.iaf.3
@@ -121,11 +121,10 @@ CPU, use the event specifier
.Qq iaf-instr-retired.any,usr,anythread .
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
diff --git a/lib/libpmc/pmc.ivybridge.3 b/lib/libpmc/pmc.ivybridge.3
index 95e4e0800650..1490b896a73c 100644
--- a/lib/libpmc/pmc.ivybridge.3
+++ b/lib/libpmc/pmc.ivybridge.3
@@ -823,14 +823,13 @@ Dirty L2 cache lines evicted by the MLC prefetcher.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridgexeon 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
diff --git a/lib/libpmc/pmc.ivybridgexeon.3 b/lib/libpmc/pmc.ivybridgexeon.3
index 56e901be26ca..415cdf518bd6 100644
--- a/lib/libpmc/pmc.ivybridgexeon.3
+++ b/lib/libpmc/pmc.ivybridgexeon.3
@@ -856,14 +856,13 @@ Dirty L2 cache lines filling the L2.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridge 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
diff --git a/lib/libpmc/pmc.k7.3 b/lib/libpmc/pmc.k7.3
deleted file mode 100644
index 0c2c158cf956..000000000000
--- a/lib/libpmc/pmc.k7.3
+++ /dev/null
@@ -1,260 +0,0 @@
-.\" Copyright (c) 2003-2008 Joseph Koshy. 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.
-.\"
-.Dd October 4, 2008
-.Dt PMC.K7 3
-.Os
-.Sh NAME
-.Nm pmc.k7
-.Nd measurement events for
-.Tn AMD
-.Tn Athlon
-(K7 family) CPUs
-.Sh LIBRARY
-.Lb libpmc
-.Sh SYNOPSIS
-.In pmc.h
-.Sh DESCRIPTION
-AMD K7 PMCs are present in the
-.Tn "AMD Athlon"
-series of CPUs and are documented in:
-.Rs
-.%B "AMD Athlon Processor x86 Code Optimization Guide"
-.%N "Publication No. 22007"
-.%D "February 2002"
-.%Q "Advanced Micro Devices, Inc."
-.Re
-.Ss PMC Features
-AMD K7 PMCs are 48 bits wide.
-Each K7 CPU contains 4 PMCs with the following capabilities:
-.Bl -column "PMC_CAP_INTERRUPT" "Support"
-.It Em Capability Ta Em Support
-.It PMC_CAP_CASCADE Ta \&No
-.It PMC_CAP_EDGE Ta Yes
-.It PMC_CAP_INTERRUPT Ta Yes
-.It PMC_CAP_INVERT Ta Yes
-.It PMC_CAP_READ Ta Yes
-.It PMC_CAP_PRECISE Ta \&No
-.It PMC_CAP_SYSTEM Ta Yes
-.It PMC_CAP_TAGGING Ta \&No
-.It PMC_CAP_THRESHOLD Ta Yes
-.It PMC_CAP_USER Ta Yes
-.It PMC_CAP_WRITE Ta Yes
-.El
-.Ss Event Qualifiers
-Event specifiers for AMD K7 PMCs can have the following optional
-qualifiers:
-.Bl -tag -width indent
-.It Li count= Ns Ar value
-Configure the counter to increment only if the number of configured
-events measured in a cycle is greater than or equal to
-.Ar value .
-.It Li edge
-Configure the counter to only count negated-to-asserted transitions
-of the conditions expressed by the other qualifiers.
-In other words, the counter will increment only once whenever a given
-condition becomes true, irrespective of the number of clocks during
-which the condition remains true.
-.It Li inv
-Invert the sense of comparison when the
-.Dq Li count
-qualifier is present, making the counter to increment when the
-number of events per cycle is less than the value specified by
-the
-.Dq Li count
-qualifier.
-.It Li os
-Configure the PMC to count events happening at privilege level 0.
-.It Li unitmask= Ns Ar mask
-This qualifier is used to further qualify a select few events,
-.Dq Li k7-dc-refills-from-l2 ,
-.Dq Li k7-dc-refills-from-system
-and
-.Dq Li k7-dc-writebacks .
-Here
-.Ar mask
-is a string of the following characters optionally separated by
-.Ql +
-characters:
-.Pp
-.Bl -tag -width indent -compact
-.It Li m
-Count operations for lines in the
-.Dq Modified
-state.
-.It Li o
-Count operations for lines in the
-.Dq Owner
-state.
-.It Li e
-Count operations for lines in the
-.Dq Exclusive
-state.
-.It Li s
-Count operations for lines in the
-.Dq Shared
-state.
-.It Li i
-Count operations for lines in the
-.Dq Invalid
-state.
-.El
-.Pp
-If no
-.Dq Li unitmask
-qualifier is specified, the default is to count events for caches
-lines in any of the above states.
-.It Li usr
-Configure the PMC to count events occurring at privilege levels 1, 2
-or 3.
-.El
-.Pp
-If neither of the
-.Dq Li os
-or
-.Dq Li usr
-qualifiers were specified, the default is to enable both.
-.Ss AMD K7 Event Specifiers
-The event specifiers supported on AMD K7 PMCs are:
-.Bl -tag -width indent
-.It Li k7-dc-accesses
-.Pq Event 40H
-Count data cache accesses.
-.It Li k7-dc-misses
-.Pq Event 41H
-Count data cache misses.
-.It Li k7-dc-refills-from-l2 Op Li ,unitmask= Ns Ar mask
-.Pq Event 42H
-Count data cache refills from L2 cache.
-This event may be further qualified using the
-.Dq Li unitmask
-qualifier.
-.It Li k7-dc-refills-from-system Op Li ,unitmask= Ns Ar mask
-.Pq Event 43H
-Count data cache refills from system memory.
-This event may be further qualified using the
-.Dq Li unitmask
-qualifier.
-.It Li k7-dc-writebacks Op Li ,unitmask= Ns Ar mask
-.Pq Event 44H
-Count data cache writebacks.
-This event may be further qualified using the
-.Dq Li unitmask
-qualifier.
-.It Li k7-hardware-interrupts
-.Pq Event CFH
-Count the number of taken hardware interrupts.
-.It Li k7-ic-fetches
-.Pq Event 80H
-Count instruction cache fetches.
-.It Li k7-ic-misses
-.Pq Event 81H
-Count instruction cache misses.
-.It Li k7-interrupts-masked-cycles
-.Pq Event CDH
-Count the number of cycles when the processor's
-.Va IF
-flag was zero.
-.It Li k7-interrupts-masked-while-pending-cycles
-.Pq Event CEH
-Count the number of cycles interrupts were masked while pending due
-to the processor's
-.Va IF
-flag being zero.
-.It Li k7-l1-and-l2-dtlb-misses
-.Pq Event 46H
-Count L1 and L2 DTLB misses.
-.It Li k7-l1-dtlb-miss-and-l2-dtlb-hits
-.Pq Event 45H
-Count L1 DTLB misses and L2 DTLB hits.
-.It Li k7-l1-itlb-misses
-.Pq Event 84H
-Count L1 ITLB misses that are L2 ITLB hits.
-.It Li k7-l1-l2-itlb-misses
-.Pq Event 85H
-Count L1 (and L2) ITLB misses.
-.It Li k7-misaligned-references
-.Pq Event 47H
-Count misaligned data references.
-.It Li k7-retired-branches
-.Pq Event C2H
-Count all retired branches (conditional, unconditional, exceptions
-and interrupts).
-.It Li k7-retired-branches-mispredicted
-.Pq Event C3H
-Count all mispredicted retired branches.
-.It Li k7-retired-far-control-transfers
-.Pq Event C6H
-Count retired far control transfers.
-.It Li k7-retired-instructions
-.Pq Event C0H
-Count all retired instructions.
-.It Li k7-retired-ops
-.Pq Event C1H
-Count retired ops.
-.It Li k7-retired-resync-branches
-.Pq Event C7H
-Count retired resync branches (non control transfer branches).
-.It Li k7-retired-taken-branches
-.Pq Event C4H
-Count retired taken branches.
-.It Li k7-retired-taken-branches-mispredicted
-.Pq Event C5H
-Count mispredicted taken branches that were retired.
-.El
-.Ss Event Name Aliases
-The following table shows the mapping between the PMC-independent
-aliases supported by
-.Lb libpmc
-and the underlying hardware events used.
-.Bl -column "branch-mispredicts" "Description"
-.It Em Alias Ta Em Event
-.It Li branches Ta Li k7-retired-branches
-.It Li branch-mispredicts Ta Li k7-retired-branches-mispredicted
-.It Li dc-misses Ta Li k7-dc-misses
-.It Li ic-misses Ta Li k7-ic-misses
-.It Li instructions Ta Li k7-retired-instructions
-.It Li interrupts Ta Li k7-hardware-interrupts
-.It Li unhalted-cycles Ta (unsupported)
-.El
-.Sh SEE ALSO
-.Xr pmc 3 ,
-.Xr pmc.atom 3 ,
-.Xr pmc.core 3 ,
-.Xr pmc.core2 3 ,
-.Xr pmc.iaf 3 ,
-.Xr pmc.k8 3 ,
-.Xr pmc.soft 3 ,
-.Xr pmc.tsc 3 ,
-.Xr pmclog 3 ,
-.Xr hwpmc 4
-.Sh HISTORY
-The
-.Nm pmc
-library first appeared in
-.Fx 6.0 .
-.Sh AUTHORS
-The
-.Lb libpmc
-library was written by
-.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
diff --git a/lib/libpmc/pmc.k8.3 b/lib/libpmc/pmc.k8.3
deleted file mode 100644
index 96cc7f5ef058..000000000000
--- a/lib/libpmc/pmc.k8.3
+++ /dev/null
@@ -1,793 +0,0 @@
-.\" Copyright (c) 2003-2008 Joseph Koshy. 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.
-.\"
-.Dd October 4, 2008
-.Dt PMC.K8 3
-.Os
-.Sh NAME
-.Nm pmc.k8
-.Nd measurement events for
-.Tn AMD
-.Tn Athlon 64
-(K8 family) CPUs
-.Sh LIBRARY
-.Lb libpmc
-.Sh SYNOPSIS
-.In pmc.h
-.Sh DESCRIPTION
-AMD K8 PMCs are present in the
-.Tn "AMD Athlon64"
-and
-.Tn "AMD Opteron"
-series of CPUs.
-They are documented in the
-.Rs
-.%B "BIOS and Kernel Developer's Guide for the AMD Athlon(tm) 64 and AMD Opteron Processors"
-.%N "Publication No. 26094"
-.%D "April 2004"
-.%Q "Advanced Micro Devices, Inc."
-.Re
-.Ss PMC Features
-AMD K8 PMCs are 48 bits wide.
-Each CPU contains 4 PMCs with the following capabilities:
-.Bl -column "PMC_CAP_INTERRUPT" "Support"
-.It Em Capability Ta Em Support
-.It PMC_CAP_CASCADE Ta \&No
-.It PMC_CAP_EDGE Ta Yes
-.It PMC_CAP_INTERRUPT Ta Yes
-.It PMC_CAP_INVERT Ta Yes
-.It PMC_CAP_READ Ta Yes
-.It PMC_CAP_PRECISE Ta \&No
-.It PMC_CAP_SYSTEM Ta Yes
-.It PMC_CAP_TAGGING Ta \&No
-.It PMC_CAP_THRESHOLD Ta Yes
-.It PMC_CAP_USER Ta Yes
-.It PMC_CAP_WRITE Ta Yes
-.El
-.Ss Event Qualifiers
-Event specifiers for AMD K8 PMCs can have the following optional
-qualifiers:
-.Bl -tag -width indent
-.It Li count= Ns Ar value
-Configure the counter to increment only if the number of configured
-events measured in a cycle is greater than or equal to
-.Ar value .
-.It Li edge
-Configure the counter to only count negated-to-asserted transitions
-of the conditions expressed by the other fields.
-In other words, the counter will increment only once whenever a given
-condition becomes true, irrespective of the number of clocks during
-which the condition remains true.
-.It Li inv
-Invert the sense of comparison when the
-.Dq Li count
-qualifier is present, making the counter to increment when the
-number of events per cycle is less than the value specified by
-the
-.Dq Li count
-qualifier.
-.It Li mask= Ns Ar qualifier
-Many event specifiers for AMD K8 PMCs need to be additionally
-qualified using a mask qualifier.
-These additional qualifiers are event-specific and are documented
-along with their associated event specifiers below.
-.It Li os
-Configure the PMC to count events happening at privilege level 0.
-.It Li usr
-Configure the PMC to count events occurring at privilege levels 1, 2
-or 3.
-.El
-.Pp
-If neither of the
-.Dq Li os
-or
-.Dq Li usr
-qualifiers were specified, the default is to enable both.
-.Ss AMD K8 Event Specifiers
-The event specifiers supported on AMD K8 PMCs are:
-.Bl -tag -width indent
-.It Li k8-bu-cpu-clk-unhalted
-.Pq Event 76H
-Count the number of clock cycles when the CPU is not in the HLT or
-STPCLK states.
-.It Li k8-bu-fill-request-l2-miss Op Li ,mask= Ns Ar qualifier
-.Pq Event 7EH
-Count fill requests that missed in the L2 cache.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li dc-fill
-Count data cache fill requests.
-.It Li ic-fill
-Count instruction cache fill requests.
-.It Li tlb-reload
-Count TLB reloads.
-.El
-.Pp
-The default is to count all types of requests.
-.It Li k8-bu-fill-into-l2 Op Li ,mask= Ns Ar qualifier
-.Pq Event 7FH
-The number of lines written to and from the L2 cache.
-The event may be further qualified by using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li dirty-l2-victim
-Count lines written into L2 cache due to victim writebacks from the
-Icache or Dcache, TLB page table walks or hardware data prefetches.
-.It Li victim-from-l2
-Count writebacks of dirty lines from L2 to the system.
-.El
-.It Li k8-bu-internal-l2-request Op Li ,mask= Ns Ar qualifier
-.Pq Event 7DH
-Count internally generated requests to the L2 cache.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li cancelled
-Count cancelled requests.
-.It Li dc-fill
-Count data cache fill requests.
-.It Li ic-fill
-Count instruction cache fill requests.
-.It Li tag-snoop
-Count tag snoop requests.
-.It Li tlb-reload
-Count TLB reloads.
-.El
-.Pp
-The default is to count all types of requests.
-.It Li k8-dc-access
-.Pq Event 40H
-Count data cache accesses including microcode scratch pad accesses.
-.It Li k8-dc-copyback Op Li ,mask= Ns Ar qualifier
-.Pq Event 44H
-Count data cache copyback operations.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li exclusive
-Count operations for lines in the
-.Dq exclusive
-state.
-.It Li invalid
-Count operations for lines in the
-.Dq invalid
-state.
-.It Li modified
-Count operations for lines in the
-.Dq modified
-state.
-.It Li owner
-Count operations for lines in the
-.Dq owner
-state.
-.It Li shared
-Count operations for lines in the
-.Dq shared
-state.
-.El
-.Pp
-The default is to count operations for lines in all the
-above states.
-.It Li k8-dc-dcache-accesses-by-locks Op Li ,mask= Ns Ar qualifier
-.Pq Event 4CH
-Count data cache accesses by lock instructions.
-This event is only available on processors of revision C or later
-vintage.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li accesses
-Count data cache accesses by lock instructions.
-.It Li misses
-Count data cache misses by lock instructions.
-.El
-.Pp
-The default is to count all accesses.
-.It Li k8-dc-dispatched-prefetch-instructions Op Li ,mask= Ns Ar qualifier
-.Pq Event 4BH
-Count the number of dispatched prefetch instructions.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li load
-Count load operations.
-.It Li nta
-Count non-temporal operations.
-.It Li store
-Count store operations.
-.El
-.Pp
-The default is to count all operations.
-.It Li k8-dc-l1-dtlb-miss-and-l2-dtlb-hit
-.Pq Event 45H
-Count L1 DTLB misses that are L2 DTLB hits.
-.It Li k8-dc-l1-dtlb-miss-and-l2-dtlb-miss
-.Pq Event 46H
-Count L1 DTLB misses that are also misses in the L2 DTLB.
-.It Li k8-dc-microarchitectural-early-cancel-of-an-access
-.Pq Event 49H
-Count microarchitectural early cancels of data cache accesses.
-.It Li k8-dc-microarchitectural-late-cancel-of-an-access
-.Pq Event 48H
-Count microarchitectural late cancels of data cache accesses.
-.It Li k8-dc-misaligned-data-reference
-.Pq Event 47H
-Count misaligned data references.
-.It Li k8-dc-miss
-.Pq Event 41H
-Count data cache misses.
-.It Li k8-dc-one-bit-ecc-error Op Li ,mask= Ns Ar qualifier
-.Pq Event 4AH
-Count one bit ECC errors found by the scrubber.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li scrubber
-Count scrubber detected errors.
-.It Li piggyback
-Count piggyback scrubber errors.
-.El
-.Pp
-The default is to count both kinds of errors.
-.It Li k8-dc-refill-from-l2 Op Li ,mask= Ns Ar qualifier
-.Pq Event 42H
-Count data cache refills from L2 cache.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li exclusive
-Count operations for lines in the
-.Dq exclusive
-state.
-.It Li invalid
-Count operations for lines in the
-.Dq invalid
-state.
-.It Li modified
-Count operations for lines in the
-.Dq modified
-state.
-.It Li owner
-Count operations for lines in the
-.Dq owner
-state.
-.It Li shared
-Count operations for lines in the
-.Dq shared
-state.
-.El
-.Pp
-The default is to count operations for lines in all the
-above states.
-.It Li k8-dc-refill-from-system Op Li ,mask= Ns Ar qualifier
-.Pq Event 43H
-Count data cache refills from system memory.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li exclusive
-Count operations for lines in the
-.Dq exclusive
-state.
-.It Li invalid
-Count operations for lines in the
-.Dq invalid
-state.
-.It Li modified
-Count operations for lines in the
-.Dq modified
-state.
-.It Li owner
-Count operations for lines in the
-.Dq owner
-state.
-.It Li shared
-Count operations for lines in the
-.Dq shared
-state.
-.El
-.Pp
-The default is to count operations for lines in all the
-above states.
-.It Li k8-fp-cycles-with-no-fpu-ops-retired
-.Pq Event 01H
-Count cycles when no FPU ops were retired.
-This event is supported in revision B and later CPUs.
-.It Li k8-fp-dispatched-fpu-fast-flag-ops
-.Pq Event 02H
-Count dispatched FPU ops that use the fast flag interface.
-This event is supported in revision B and later CPUs.
-.It Li k8-fp-dispatched-fpu-ops Op Li ,mask= Ns Ar qualifier
-.Pq Event 00H
-Count the number of dispatched FPU ops.
-This event is supported in revision B and later CPUs.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li add-pipe-excluding-junk-ops
-Count add pipe ops excluding junk ops.
-.It Li add-pipe-junk-ops
-Count junk ops in the add pipe.
-.It Li multiply-pipe-excluding-junk-ops
-Count multiply pipe ops excluding junk ops.
-.It Li multiply-pipe-junk-ops
-Count junk ops in the multiply pipe.
-.It Li store-pipe-excluding-junk-ops
-Count store pipe ops excluding junk ops
-.It Li store-pipe-junk-ops
-Count junk ops in the store pipe.
-.El
-.Pp
-The default is to count all types of ops.
-.It Li k8-fr-decoder-empty
-.Pq Event D0H
-Count cycles when there was nothing to dispatch (i.e., the decoder
-was empty).
-.It Li k8-fr-dispatch-stall-for-segment-load
-.Pq Event D4H
-Count dispatch stalls for segment loads.
-.It Li k8-fr-dispatch-stall-for-serialization
-.Pq Event D3H
-Count dispatch stalls for serialization.
-.It Li k8-fr-dispatch-stall-from-branch-abort-to-retire
-.Pq Event D2H
-Count dispatch stalls from branch abort to retiral.
-.It Li k8-fr-dispatch-stall-when-fpu-is-full
-.Pq Event D7H
-Count dispatch stalls when the FPU is full.
-.It Li k8-fr-dispatch-stall-when-ls-is-full
-.Pq Event D8H
-Count dispatch stalls when the load/store unit is full.
-.It Li k8-fr-dispatch-stall-when-reorder-buffer-is-full
-.Pq Event D5H
-Count dispatch stalls when the reorder buffer is full.
-.It Li k8-fr-dispatch-stall-when-reservation-stations-are-full
-.Pq Event D6H
-Count dispatch stalls when reservation stations are full.
-.It Li k8-fr-dispatch-stall-when-waiting-far-xfer-or-resync-branch-pending
-.Pq Event DAH
-Count dispatch stalls when a far control transfer or a resync branch
-is pending.
-.It Li k8-fr-dispatch-stall-when-waiting-for-all-to-be-quiet
-.Pq Event D9H
-Count dispatch stalls when waiting for all to be quiet.
-.\" XXX What does "waiting for all to be quiet" mean?
-.It Li k8-fr-dispatch-stalls
-.Pq Event D1H
-Count all dispatch stalls.
-.It Li k8-fr-fpu-exceptions Op Li ,mask= Ns Ar qualifier
-.Pq Event DBH
-Count FPU exceptions.
-This event is supported in revision B and later CPUs.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li sse-and-x87-microtraps
-Count SSE and x87 microtraps.
-.It Li sse-reclass-microfaults
-Count SSE reclass microfaults
-.It Li sse-retype-microfaults
-Count SSE retype microfaults
-.It Li x87-reclass-microfaults
-Count x87 reclass microfaults.
-.El
-.Pp
-The default is to count all types of exceptions.
-.It Li k8-fr-interrupts-masked-cycles
-.Pq Event CDH
-Count cycles when interrupts were masked (by CPU RFLAGS field IF was zero).
-.It Li k8-fr-interrupts-masked-while-pending-cycles
-.Pq Event CEH
-Count cycles while interrupts were masked while pending (i.e., cycles
-when INTR was asserted while CPU RFLAGS field IF was zero).
-.It Li k8-fr-number-of-breakpoints-for-dr0
-.Pq Event DCH
-Count the number of breakpoints for DR0.
-.It Li k8-fr-number-of-breakpoints-for-dr1
-.Pq Event DDH
-Count the number of breakpoints for DR1.
-.It Li k8-fr-number-of-breakpoints-for-dr2
-.Pq Event DEH
-Count the number of breakpoints for DR2.
-.It Li k8-fr-number-of-breakpoints-for-dr3
-.Pq Event DFH
-Count the number of breakpoints for DR3.
-.It Li k8-fr-retired-branches
-.Pq Event C2H
-Count retired branches including exceptions and interrupts.
-.It Li k8-fr-retired-branches-mispredicted
-.Pq Event C3H
-Count mispredicted retired branches.
-.It Li k8-fr-retired-far-control-transfers
-.Pq Event C6H
-Count retired far control transfers (which are always mispredicted).
-.It Li k8-fr-retired-fastpath-double-op-instructions Op Li ,mask= Ns Ar qualifier
-.Pq Event CCH
-Count retired fastpath double op instructions.
-This event is supported in revision B and later CPUs.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li low-op-pos-0
-Count instructions with the low op in position 0.
-.It Li low-op-pos-1
-Count instructions with the low op in position 1.
-.It Li low-op-pos-2
-Count instructions with the low op in position 2.
-.El
-.Pp
-The default is to count all types of instructions.
-.It Li k8-fr-retired-fpu-instructions Op Li ,mask= Ns Ar qualifier
-.Pq Event CBH
-Count retired FPU instructions.
-This event is supported in revision B and later CPUs.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li mmx-3dnow
-Count MMX and 3DNow!\& instructions.
-.It Li packed-sse-sse2
-Count packed SSE and SSE2 instructions.
-.It Li scalar-sse-sse2
-Count scalar SSE and SSE2 instructions
-.It Li x87
-Count x87 instructions.
-.El
-.Pp
-The default is to count all types of instructions.
-.It Li k8-fr-retired-near-returns
-.Pq Event C8H
-Count retired near returns.
-.It Li k8-fr-retired-near-returns-mispredicted
-.Pq Event C9H
-Count mispredicted near returns.
-.It Li k8-fr-retired-resyncs
-.Pq Event C7H
-Count retired resyncs (non-control transfer branches).
-.It Li k8-fr-retired-taken-branches
-.Pq Event C4H
-Count retired taken branches.
-.It Li k8-fr-retired-taken-branches-mispredicted
-.Pq Event C5H
-Count retired taken branches that were mispredicted.
-.It Li k8-fr-retired-taken-branches-mispredicted-by-addr-miscompare
-.Pq Event CAH
-Count retired taken branches that were mispredicted only due to an
-address miscompare.
-.It Li k8-fr-retired-taken-hardware-interrupts
-.Pq Event CFH
-Count retired taken hardware interrupts.
-.It Li k8-fr-retired-uops
-.Pq Event C1H
-Count retired uops.
-.It Li k8-fr-retired-x86-instructions
-.Pq Event C0H
-Count retired x86 instructions including exceptions and interrupts.
-.It Li k8-ic-fetch
-.Pq Event 80H
-Count instruction cache fetches.
-.It Li k8-ic-instruction-fetch-stall
-.Pq Event 87H
-Count cycles in stalls due to instruction fetch.
-.It Li k8-ic-l1-itlb-miss-and-l2-itlb-hit
-.Pq Event 84H
-Count L1 ITLB misses that are L2 ITLB hits.
-.It Li k8-ic-l1-itlb-miss-and-l2-itlb-miss
-.Pq Event 85H
-Count ITLB misses that miss in both L1 and L2 ITLBs.
-.It Li k8-ic-microarchitectural-resync-by-snoop
-.Pq Event 86H
-Count microarchitectural resyncs caused by snoops.
-.It Li k8-ic-miss
-.Pq Event 81H
-Count instruction cache misses.
-.It Li k8-ic-refill-from-l2
-.Pq Event 82H
-Count instruction cache refills from L2 cache.
-.It Li k8-ic-refill-from-system
-.Pq Event 83H
-Count instruction cache refills from system memory.
-.It Li k8-ic-return-stack-hits
-.Pq Event 88H
-Count hits to the return stack.
-.It Li k8-ic-return-stack-overflow
-.Pq Event 89H
-Count overflows of the return stack.
-.It Li k8-ls-buffer2-full
-.Pq Event 23H
-Count load/store buffer2 full events.
-.It Li k8-ls-locked-operation Op Li ,mask= Ns Ar qualifier
-.Pq Event 24H
-Count locked operations.
-For revision C and later CPUs, the following qualifiers are supported:
-.Pp
-.Bl -tag -width indent -compact
-.It Li cycles-in-request
-Count the number of cycles in the lock request/grant stage.
-.It Li cycles-to-complete
-Count the number of cycles a lock takes to complete once it is
-non-speculative and is the older load/store operation.
-.It Li locked-instructions
-Count the number of lock instructions executed.
-.El
-.Pp
-The default is to count the number of lock instructions executed.
-.It Li k8-ls-microarchitectural-late-cancel
-.Pq Event 25H
-Count microarchitectural late cancels of operations in the load/store
-unit.
-.It Li k8-ls-microarchitectural-resync-by-self-modifying-code
-.Pq Event 21H
-Count microarchitectural resyncs caused by self-modifying code.
-.It Li k8-ls-microarchitectural-resync-by-snoop
-.Pq Event 22H
-Count microarchitectural resyncs caused by snoops.
-.It Li k8-ls-retired-cflush-instructions
-.Pq Event 26H
-Count retired CFLUSH instructions.
-.It Li k8-ls-retired-cpuid-instructions
-.Pq Event 27H
-Count retired CPUID instructions.
-.It Li k8-ls-segment-register-load Op Li ,mask= Ns Ar qualifier
-.Pq Event 20H
-Count segment register loads.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Bl -tag -width indent -compact
-.It Li cs
-Count CS register loads.
-.It Li ds
-Count DS register loads.
-.It Li es
-Count ES register loads.
-.It Li fs
-Count FS register loads.
-.It Li gs
-Count GS register loads.
-.\" .It Li hs
-.\" Count HS register loads.
-.\" XXX "HS" register?
-.It Li ss
-Count SS register loads.
-.El
-.Pp
-The default is to count all types of loads.
-.It Li k8-nb-ht-bus0-bandwidth Op Li ,mask= Ns Ar qualifier
-.It Li k8-nb-ht-bus1-bandwidth Op Li ,mask= Ns Ar qualifier
-.It Li k8-nb-ht-bus2-bandwidth Op Li ,mask= Ns Ar qualifier
-.Pq Events F6H, F7H and F8H respectively
-Count events on the HyperTransport(tm) buses.
-These events may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li buffer-release
-Count buffer release messages sent.
-.It Li command
-Count command messages sent.
-.It Li data
-Count data messages sent.
-.It Li nop
-Count nop messages sent.
-.El
-.Pp
-The default is to count all types of messages.
-.It Li k8-nb-memory-controller-bypass-saturation Op Li ,mask= Ns Ar qualifier
-.Pq Event E4H
-Count memory controller bypass counter saturation events.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li dram-controller-interface-bypass
-Count DRAM controller interface bypass.
-.It Li dram-controller-queue-bypass
-Count DRAM controller queue bypass.
-.It Li memory-controller-hi-pri-bypass
-Count memory controller high priority bypasses.
-.It Li memory-controller-lo-pri-bypass
-Count memory controller low priority bypasses.
-.El
-.It Li k8-nb-memory-controller-dram-slots-missed
-.Pq Event E2H
-Count memory controller DRAM command slots missed (in MemClks).
-.It Li k8-nb-memory-controller-page-access-event Op Li ,mask= Ns Ar qualifier
-.Pq Event E0H
-Count memory controller page access events.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li page-conflict
-Count page conflicts.
-.It Li page-hit
-Count page hits.
-.It Li page-miss
-Count page misses.
-.El
-.Pp
-The default is to count all types of events.
-.It Li k8-nb-memory-controller-page-table-overflow
-.Pq Event E1H
-Count memory control page table overflow events.
-.It Li k8-nb-memory-controller-turnaround Op Li ,mask= Ns Ar qualifier
-.Pq Event E3H
-Count memory control turnaround events.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.\" XXX doc is unclear whether these are cycle counts or event counts
-.It Li dimm-turnaround
-Count DIMM turnarounds.
-.It Li read-to-write-turnaround
-Count read to write turnarounds.
-.It Li write-to-read-turnaround
-Count write to read turnarounds.
-.El
-.Pp
-The default is to count all types of events.
-.It Li k8-nb-probe-result Op Li ,mask= Ns Ar qualifier
-.Pq Event ECH
-Count probe events.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li probe-hit
-Count all probe hits.
-.It Li probe-hit-dirty-no-memory-cancel
-Count probe hits without memory cancels.
-.It Li probe-hit-dirty-with-memory-cancel
-Count probe hits with memory cancels.
-.It Li probe-miss
-Count probe misses.
-.El
-.It Li k8-nb-sized-commands Op Li ,mask= Ns Ar qualifier
-.Pq Event EBH
-Count sized commands issued.
-This event may be further qualified using
-.Ar qualifier ,
-which is a
-.Ql +
-separated set of the following keywords:
-.Pp
-.Bl -tag -width indent -compact
-.It Li nonpostwrszbyte
-.It Li nonpostwrszdword
-.It Li postwrszbyte
-.It Li postwrszdword
-.It Li rdszbyte
-.It Li rdszdword
-.It Li rdmodwr
-.El
-.Pp
-The default is to count all types of commands.
-.El
-.Ss Event Name Aliases
-The following table shows the mapping between the PMC-independent
-aliases supported by
-.Lb libpmc
-and the underlying hardware events used.
-.Bl -column "branch-mispredicts" "Description"
-.It Em Alias Ta Em Event
-.It Li branches Ta Li k8-fr-retired-taken-branches
-.It Li branch-mispredicts Ta Li k8-fr-retired-taken-branches-mispredicted
-.It Li dc-misses Ta Li k8-dc-miss
-.It Li ic-misses Ta Li k8-ic-miss
-.It Li instructions Ta Li k8-fr-retired-x86-instructions
-.It Li interrupts Ta Li k8-fr-taken-hardware-interrupts
-.It Li unhalted-cycles Ta Li k8-bu-cpu-clk-unhalted
-.El
-.Sh SEE ALSO
-.Xr pmc 3 ,
-.Xr pmc.atom 3 ,
-.Xr pmc.core 3 ,
-.Xr pmc.core2 3 ,
-.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.soft 3 ,
-.Xr pmc.tsc 3 ,
-.Xr pmclog 3 ,
-.Xr hwpmc 4
-.Sh HISTORY
-The
-.Nm pmc
-library first appeared in
-.Fx 6.0 .
-.Sh AUTHORS
-The
-.Lb libpmc
-library was written by
-.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
diff --git a/lib/libpmc/pmc.sandybridge.3 b/lib/libpmc/pmc.sandybridge.3
index 4f5b6c779efa..77221d985ded 100644
--- a/lib/libpmc/pmc.sandybridge.3
+++ b/lib/libpmc/pmc.sandybridge.3
@@ -902,6 +902,7 @@ Split locks in SQ.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
@@ -909,8 +910,6 @@ Split locks in SQ.
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridge 3 ,
.Xr pmc.ivybridgexeon 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.sandybridgexeon 3 ,
.Xr pmc.soft 3 ,
diff --git a/lib/libpmc/pmc.sandybridgeuc.3 b/lib/libpmc/pmc.sandybridgeuc.3
index 072794bca757..70ce768d9966 100644
--- a/lib/libpmc/pmc.sandybridgeuc.3
+++ b/lib/libpmc/pmc.sandybridgeuc.3
@@ -195,13 +195,12 @@ Counts the number of core-outgoing entries in the coherent tracker queue.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgexeon 3 ,
.Xr pmc.soft 3 ,
diff --git a/lib/libpmc/pmc.sandybridgexeon.3 b/lib/libpmc/pmc.sandybridgexeon.3
index f823537421f0..e7bfc8c71708 100644
--- a/lib/libpmc/pmc.sandybridgexeon.3
+++ b/lib/libpmc/pmc.sandybridgexeon.3
@@ -978,6 +978,7 @@ Split locks in SQ.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
@@ -986,8 +987,6 @@ Split locks in SQ.
.Xr pmc.iaf 3 ,
.Xr pmc.ivybridge 3 ,
.Xr pmc.ivybridgexeon 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.sandybridge 3 ,
.Xr pmc.sandybridgeuc 3 ,
.Xr pmc.soft 3 ,
diff --git a/lib/libpmc/pmc.soft.3 b/lib/libpmc/pmc.soft.3
index ce965caa2f02..08d5af63d02d 100644
--- a/lib/libpmc/pmc.soft.3
+++ b/lib/libpmc/pmc.soft.3
@@ -84,13 +84,12 @@ Write page fault.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.ucf 3 ,
.Xr pmc.westmereuc 3 ,
diff --git a/lib/libpmc/pmc.tsc.3 b/lib/libpmc/pmc.tsc.3
index 59fcdc1898d1..4834d897f90c 100644
--- a/lib/libpmc/pmc.tsc.3
+++ b/lib/libpmc/pmc.tsc.3
@@ -57,12 +57,11 @@ The alias
maps to the TSC.
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.ucf.3 b/lib/libpmc/pmc.ucf.3
index d39b0e8f0db7..a7cea6bb57f9 100644
--- a/lib/libpmc/pmc.ucf.3
+++ b/lib/libpmc/pmc.ucf.3
@@ -81,14 +81,13 @@ offset C0H under device number 0 and Function 0.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.core2 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.westmere 3 ,
diff --git a/lib/libpmc/pmc.westmere.3 b/lib/libpmc/pmc.westmere.3
index 1d7c206f25c3..231bc331894e 100644
--- a/lib/libpmc/pmc.westmere.3
+++ b/lib/libpmc/pmc.westmere.3
@@ -1367,13 +1367,12 @@ Counts number of SID integer 64 bit shift or move operations.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.ucf 3 ,
diff --git a/lib/libpmc/pmc.westmereuc.3 b/lib/libpmc/pmc.westmereuc.3
index d9574be03422..5d6286b0e91e 100644
--- a/lib/libpmc/pmc.westmereuc.3
+++ b/lib/libpmc/pmc.westmereuc.3
@@ -1071,13 +1071,12 @@ disabled.
.El
.Sh SEE ALSO
.Xr pmc 3 ,
+.Xr pmc.amd 3 ,
.Xr pmc.atom 3 ,
.Xr pmc.core 3 ,
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.iaf 3 ,
-.Xr pmc.k7 3 ,
-.Xr pmc.k8 3 ,
.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc.ucf 3 ,
diff --git a/lib/libpmc/pmclog.c b/lib/libpmc/pmclog.c
index a21fe42c9947..22ff50b10ee0 100644
--- a/lib/libpmc/pmclog.c
+++ b/lib/libpmc/pmclog.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/pmc.h>
#include <sys/pmclog.h>
@@ -357,15 +356,10 @@ pmclog_get_event(void *cookie, char **data, ssize_t *len,
PMCLOG_READ64(le,ev->pl_u.pl_a.pl_rate);
/*
- * Could be either a PMC event code or a PMU event index;
- * assume that their encodings don't overlap (i.e. no PMU event
- * table is more than 0x1000 entries) to distinguish them here.
- * Otherwise pmc_pmu_event_get_by_idx will go out of bounds if
- * given a PMC event code when it knows about that CPU.
- *
- * XXX: Ideally we'd have user flags to give us that context.
+ * pl_event could contain either a PMC event code or a PMU
+ * event index.
*/
- if (ev->pl_u.pl_a.pl_event < PMC_EVENT_FIRST)
+ if ((ev->pl_u.pl_a.pl_flags & PMC_F_EV_PMU) != 0)
ev->pl_u.pl_a.pl_evname =
pmc_pmu_event_get_by_idx(ps->ps_cpuid,
ev->pl_u.pl_a.pl_event);
diff --git a/lib/libpmc/pmu-events/Makefile b/lib/libpmc/pmu-events/Makefile
index c21a8dfba2af..3f7fc7e1e543 100644
--- a/lib/libpmc/pmu-events/Makefile
+++ b/lib/libpmc/pmu-events/Makefile
@@ -1,4 +1,3 @@
-
PROG= jevents
SRCS= jevents.c jsmn.c json.c
CFLAGS+= -Wno-cast-qual
diff --git a/lib/libpmc/pmu-events/Makefile.depend b/lib/libpmc/pmu-events/Makefile.depend
new file mode 100644
index 000000000000..11aba52f82cf
--- /dev/null
+++ b/lib/libpmc/pmu-events/Makefile.depend
@@ -0,0 +1,10 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/branch.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/branch.json
new file mode 100644
index 000000000000..208c646c59ca
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/branch.json
@@ -0,0 +1,82 @@
+[
+ {
+ "EventName": "bp_l2_btb_correct",
+ "EventCode": "0x8b",
+ "BriefDescription": "L2 branch prediction overrides existing prediction (speculative)."
+ },
+ {
+ "EventName": "bp_dyn_ind_pred",
+ "EventCode": "0x8e",
+ "BriefDescription": "Dynamic indirect predictions (branch used the indirect predictor to make a prediction)."
+ },
+ {
+ "EventName": "bp_de_redirect",
+ "EventCode": "0x91",
+ "BriefDescription": "Instruction decoder corrects the predicted target and resteers the branch predictor."
+ },
+ {
+ "EventName": "ex_ret_brn",
+ "EventCode": "0xc2",
+ "BriefDescription": "Retired branch instructions (all types of architectural control flow changes, including exceptions and interrupts)."
+ },
+ {
+ "EventName": "ex_ret_brn_misp",
+ "EventCode": "0xc3",
+ "BriefDescription": "Retired branch instructions mispredicted."
+ },
+ {
+ "EventName": "ex_ret_brn_tkn",
+ "EventCode": "0xc4",
+ "BriefDescription": "Retired taken branch instructions (all types of architectural control flow changes, including exceptions and interrupts)."
+ },
+ {
+ "EventName": "ex_ret_brn_tkn_misp",
+ "EventCode": "0xc5",
+ "BriefDescription": "Retired taken branch instructions mispredicted."
+ },
+ {
+ "EventName": "ex_ret_brn_far",
+ "EventCode": "0xc6",
+ "BriefDescription": "Retired far control transfers (far call/jump/return, IRET, SYSCALL and SYSRET, plus exceptions and interrupts). Far control transfers are not subject to branch prediction."
+ },
+ {
+ "EventName": "ex_ret_near_ret",
+ "EventCode": "0xc8",
+ "BriefDescription": "Retired near returns (RET or RET Iw)."
+ },
+ {
+ "EventName": "ex_ret_near_ret_mispred",
+ "EventCode": "0xc9",
+ "BriefDescription": "Retired near returns mispredicted. Each misprediction incurs the same penalty as a mispredicted conditional branch instruction."
+ },
+ {
+ "EventName": "ex_ret_brn_ind_misp",
+ "EventCode": "0xca",
+ "BriefDescription": "Retired indirect branch instructions mispredicted (only EX mispredicts). Each misprediction incurs the same penalty as a mispredicted conditional branch instruction."
+ },
+ {
+ "EventName": "ex_ret_ind_brch_instr",
+ "EventCode": "0xcc",
+ "BriefDescription": "Retired indirect branch instructions."
+ },
+ {
+ "EventName": "ex_ret_cond",
+ "EventCode": "0xd1",
+ "BriefDescription": "Retired conditional branch instructions."
+ },
+ {
+ "EventName": "ex_ret_msprd_brnch_instr_dir_msmtch",
+ "EventCode": "0x1c7",
+ "BriefDescription": "Retired branch instructions mispredicted due to direction mismatch."
+ },
+ {
+ "EventName": "ex_ret_uncond_brnch_instr_mispred",
+ "EventCode": "0x1c8",
+ "BriefDescription": "Retired unconditional indirect branch instructions mispredicted."
+ },
+ {
+ "EventName": "ex_ret_uncond_brnch_instr",
+ "EventCode": "0x1c9",
+ "BriefDescription": "Retired unconditional branch instructions."
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/cache.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/cache.json
new file mode 100644
index 000000000000..e6d710cf3ce2
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/cache.json
@@ -0,0 +1,828 @@
+[
+ {
+ "EventName": "ls_mab_alloc.load_store_allocations",
+ "EventCode": "0x41",
+ "BriefDescription": "Miss Address Buffer (MAB) entries allocated by a Load-Store (LS) pipe for load-store allocations.",
+ "UMask": "0x3f"
+ },
+ {
+ "EventName": "ls_mab_alloc.hardware_prefetcher_allocations",
+ "EventCode": "0x41",
+ "BriefDescription": "Miss Address Buffer (MAB) entries allocated by a Load-Store (LS) pipe for hardware prefetcher allocations.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "ls_mab_alloc.all_allocations",
+ "EventCode": "0x41",
+ "BriefDescription": "Miss Address Buffer (MAB) entries allocated by a Load-Store (LS) pipe for all types of allocations.",
+ "UMask": "0x7f"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.local_l2",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from local L2 cache.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.local_ccx",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from L3 cache or different L2 cache in the same CCX.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.near_cache",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from cache of another CCX when the address was in the same NUMA node.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.dram_io_near",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from either DRAM or MMIO in the same NUMA node.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.far_cache",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from cache of another CCX when the address was in a different NUMA node.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.dram_io_far",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from either DRAM or MMIO in a different NUMA node (same or different socket).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.alternate_memories",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from extension memory.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "ls_dmnd_fills_from_sys.all",
+ "EventCode": "0x43",
+ "BriefDescription": "Demand data cache fills from all types of data sources.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.local_l2",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from local L2 cache.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.local_ccx",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from L3 cache or different L2 cache in the same CCX.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.local_all",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from local L2 cache or L3 cache or different L2 cache in the same CCX.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.near_cache",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from cache of another CCX when the address was in the same NUMA node.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.dram_io_near",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from either DRAM or MMIO in the same NUMA node.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.far_cache",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from cache of another CCX when the address was in a different NUMA node.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.remote_cache",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from cache of another CCX when the address was in the same or a different NUMA node.",
+ "UMask": "0x14"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.dram_io_far",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from either DRAM or MMIO in a different NUMA node (same or different socket).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.dram_io_all",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from either DRAM or MMIO in any NUMA node (same or different socket).",
+ "UMask": "0x48"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.far_all",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from either cache of another CCX, DRAM or MMIO when the address was in a different NUMA node (same or different socket).",
+ "UMask": "0x50"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.all_dram_io",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from either DRAM or MMIO in any NUMA node (same or different socket).",
+ "UMask": "0x48"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.alternate_memories",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from extension memory.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "ls_any_fills_from_sys.all",
+ "EventCode": "0x44",
+ "BriefDescription": "Any data cache fills from all types of data sources.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "ls_pref_instr_disp.prefetch",
+ "EventCode": "0x4b",
+ "BriefDescription": "Software prefetch instructions dispatched (speculative) of type PrefetchT0 (move data to all cache levels), T1 (move data to all cache levels except L1) and T2 (move data to all cache levels except L1 and L2).",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_pref_instr_disp.prefetch_w",
+ "EventCode": "0x4b",
+ "BriefDescription": "Software prefetch instructions dispatched (speculative) of type PrefetchW (move data to L1 cache and mark it modifiable).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_pref_instr_disp.prefetch_nta",
+ "EventCode": "0x4b",
+ "BriefDescription": "Software prefetch instructions dispatched (speculative) of type PrefetchNTA (move data with minimum cache pollution i.e. non-temporal access).",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_pref_instr_disp.all",
+ "EventCode": "0x4b",
+ "BriefDescription": "Software prefetch instructions dispatched (speculative) of all types.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "ls_inef_sw_pref.data_pipe_sw_pf_dc_hit",
+ "EventCode": "0x52",
+ "BriefDescription": "Software prefetches that did not fetch data outside of the processor core as the PREFETCH instruction saw a data cache hit.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_inef_sw_pref.mab_mch_cnt",
+ "EventCode": "0x52",
+ "BriefDescription": "Software prefetches that did not fetch data outside of the processor core as the PREFETCH instruction saw a match on an already allocated Miss Address Buffer (MAB).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_inef_sw_pref.all",
+ "EventCode": "0x52",
+ "BriefDescript6ion": "Software prefetches that did not fetch data outside of the processor core for any reason.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.local_l2",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from local L2 cache.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.local_ccx",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from L3 cache or different L2 cache in the same CCX.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.near_cache",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from cache of another CCX in the same NUMA node.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.dram_io_near",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from either DRAM or MMIO in the same NUMA node.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.far_cache",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from cache of another CCX in a different NUMA node.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.dram_io_far",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from either DRAM or MMIO in a different NUMA node (same or different socket).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.alternate_memories",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from extension memory.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "ls_sw_pf_dc_fills.all",
+ "EventCode": "0x59",
+ "BriefDescription": "Software prefetch data cache fills from all types of data sources.",
+ "UMask": "0xdf"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.local_l2",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from local L2 cache.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.local_ccx",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from L3 cache or different L2 cache in the same CCX.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.near_cache",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from cache of another CCX when the address was in the same NUMA node.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.dram_io_near",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from either DRAM or MMIO in the same NUMA node.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.far_cache",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from cache of another CCX when the address was in a different NUMA node.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.dram_io_far",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from either DRAM or MMIO in a different NUMA node (same or different socket).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.alternate_memories",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from extension memory.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "ls_hw_pf_dc_fills.all",
+ "EventCode": "0x5a",
+ "BriefDescription": "Hardware prefetch data cache fills from all types of data sources.",
+ "UMask": "0xdf"
+ },
+ {
+ "EventName": "ls_alloc_mab_count",
+ "EventCode": "0x5f",
+ "BriefDescription": "In-flight L1 data cache misses i.e. Miss Address Buffer (MAB) allocations each cycle."
+ },
+ {
+ "EventName": "l2_request_g1.group2",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests of non-cacheable type (non-cached data and instructions reads, self-modifying code checks).",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "l2_request_g1.l2_hw_pf",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: from hardware prefetchers to prefetch directly into L2 (hit or miss).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "l2_request_g1.prefetch_l2_cmd",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: prefetch directly into L2.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "l2_request_g1.change_to_x",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: data cache state change to writable, check L2 for current state.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "l2_request_g1.cacheable_ic_read",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: instruction cache reads.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "l2_request_g1.ls_rd_blk_c_s",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: data cache shared reads.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "l2_request_g1.rd_blk_x",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: data cache stores.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "l2_request_g1.rd_blk_l",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests: data cache reads including hardware and software prefetch.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "l2_request_g1.all_dc",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests of common types from L1 data cache (including prefetches).",
+ "UMask": "0xe8"
+ },
+ {
+ "EventName": "l2_request_g1.all_no_prefetch",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests of common types not including prefetches.",
+ "UMask": "0xf9"
+ },
+ {
+ "EventName": "l2_request_g1.all",
+ "EventCode": "0x60",
+ "BriefDescription": "L2 cache requests of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_fill_miss",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: instruction cache request miss in L2.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_fill_hit_s",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: instruction cache hit non-modifiable line in L2.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_fill_hit_x",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: instruction cache hit modifiable line in L2.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_hit_in_l2",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for instruction cache hits.",
+ "UMask": "0x06"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_access_in_l2",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for instruction cache access.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ls_rd_blk_c",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: data cache request miss in L2.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_dc_miss_in_l2",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for data and instruction cache misses.",
+ "UMask": "0x09"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ls_rd_blk_x",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: data cache store or state change hit in L2.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ls_rd_blk_l_hit_s",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: data cache read hit non-modifiable line in L2.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ls_rd_blk_l_hit_x",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: data cache read hit modifiable line in L2.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ls_rd_blk_cs",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) with status: data cache shared read hit in L2.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "l2_cache_req_stat.dc_hit_in_l2",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for data cache hits.",
+ "UMask": "0xf0"
+ },
+ {
+ "EventName": "l2_cache_req_stat.ic_dc_hit_in_l2",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for data and instruction cache hits.",
+ "UMask": "0xf6"
+ },
+ {
+ "EventName": "l2_cache_req_stat.dc_access_in_l2",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for data cache access.",
+ "UMask": "0xf8"
+ },
+ {
+ "EventName": "l2_cache_req_stat.all",
+ "EventCode": "0x64",
+ "BriefDescription": "Core to L2 cache requests (not including L2 prefetch) for data and instruction cache access.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l2_stream",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L2Stream (fetch additional sequential lines into L2 cache).",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l2_next_line",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L2NextLine (fetch the next line into L2 cache).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l2_up_down",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L2UpDown (fetch the next or previous line into L2 cache for all memory accesses).",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l2_burst",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L2Burst (aggressively fetch additional sequential lines into L2 cache).",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l2_stride",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L2Stride (fetch additional lines into L2 cache when each access is at a constant distance from the previous).",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l1_stream",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L1Stream (fetch additional sequential lines into L1 cache).",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l1_stride",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L1Stride (fetch additional lines into L1 cache when each access is a constant distance from the previous).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.l1_region",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of type L1Region (fetch additional lines into L1 cache when the data access for a given instruction tends to be followed by a consistent pattern of other accesses within a localized region).",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "l2_pf_hit_l2.all",
+ "EventCode": "0x70",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which hit in the L2 cache of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l2_stream",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L2Stream (fetch additional sequential lines into L2 cache).",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l2_next_line",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L2NextLine (fetch the next line into L2 cache).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l2_up_down",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L2UpDown (fetch the next or previous line into L2 cache for all memory accesses).",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l2_burst",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L2Burst (aggressively fetch additional sequential lines into L2 cache).",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l2_stride",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L2Stride (fetch additional lines into L2 cache when each access is a constant distance from the previous).",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l1_stream",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L1Stream (fetch additional sequential lines into L1 cache).",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l1_stride",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L1Stride (fetch additional lines into L1 cache when each access is a constant distance from the previous).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.l1_region",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache of type L1Region (fetch additional lines into L1 cache when the data access for a given instruction tends to be followed by a consistent pattern of other accesses within a localized region).",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_hit_l3.all",
+ "EventCode": "0x71",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 cache and hit in the L3 cache cache of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l2_stream",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L2Stream (fetch additional sequential lines into L2 cache).",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l2_next_line",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L2NextLine (fetch the next line into L2 cache).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l2_up_down",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L2UpDown (fetch the next or previous line into L2 cache for all memory accesses).",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l2_burst",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L2Burst (aggressively fetch additional sequential lines into L2 cache).",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l2_stride",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L2Stride (fetch additional lines into L2 cache when each access is a constant distance from the previous).",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l1_stream",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L1Stream (fetch additional sequential lines into L1 cache).",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l1_stride",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L1Stride (fetch additional lines into L1 cache when each access is a constant distance from the previous).",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.l1_region",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of type L1Region (fetch additional lines into L1 cache when the data access for a given instruction tends to be followed by a consistent pattern of other accesses within a localized region).",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "l2_pf_miss_l2_l3.all",
+ "EventCode": "0x72",
+ "BriefDescription": "L2 prefetches accepted by the L2 pipeline which miss the L2 and the L3 caches of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "ic_cache_fill_l2",
+ "EventCode": "0x82",
+ "BriefDescription": "Instruction cache lines (64 bytes) fulfilled from the L2 cache."
+ },
+ {
+ "EventName": "ic_cache_fill_sys",
+ "EventCode": "0x83",
+ "BriefDescription": "Instruction cache lines (64 bytes) fulfilled from system memory or another cache."
+ },
+ {
+ "EventName": "ic_tag_hit_miss.instruction_cache_hit",
+ "EventCode": "0x18e",
+ "BriefDescription": "Instruction cache hits.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "ic_tag_hit_miss.instruction_cache_miss",
+ "EventCode": "0x18e",
+ "BriefDescription": "Instruction cache misses.",
+ "UMask": "0x18"
+ },
+ {
+ "EventName": "ic_tag_hit_miss.all_instruction_cache_accesses",
+ "EventCode": "0x18e",
+ "BriefDescription": "Instruction cache accesses of all types.",
+ "UMask": "0x1f"
+ },
+ {
+ "EventName": "op_cache_hit_miss.op_cache_hit",
+ "EventCode": "0x28f",
+ "BriefDescription": "Op cache hits.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "op_cache_hit_miss.op_cache_miss",
+ "EventCode": "0x28f",
+ "BriefDescription": "Op cache misses.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "op_cache_hit_miss.all_op_cache_accesses",
+ "EventCode": "0x28f",
+ "BriefDescription": "Op cache accesses of all types.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "l3_lookup_state.l3_miss",
+ "EventCode": "0x04",
+ "BriefDescription": "L3 cache misses.",
+ "UMask": "0x01",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_lookup_state.l3_hit",
+ "EventCode": "0x04",
+ "BriefDescription": "L3 cache hits.",
+ "UMask": "0xfe",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_lookup_state.all_coherent_accesses_to_l3",
+ "EventCode": "0x04",
+ "BriefDescription": "L3 cache requests for all coherent accesses.",
+ "UMask": "0xff",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.dram_near",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency when data is sourced from DRAM in the same NUMA node.",
+ "UMask": "0x01",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.dram_far",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency when data is sourced from DRAM in a different NUMA node.",
+ "UMask": "0x02",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.near_cache",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency when data is sourced from another CCX's cache when the address was in the same NUMA node.",
+ "UMask": "0x04",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.far_cache",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency when data is sourced from another CCX's cache when the address was in a different NUMA node.",
+ "UMask": "0x08",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.ext_near",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency when data is sourced from extension memory (CXL) in the same NUMA node.",
+ "UMask": "0x10",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.ext_far",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency when data is sourced from extension memory (CXL) in a different NUMA node.",
+ "UMask": "0x20",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency.all",
+ "EventCode": "0xac",
+ "BriefDescription": "Average sampled latency from all data sources.",
+ "UMask": "0x3f",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.dram_near",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from DRAM in the same NUMA node.",
+ "UMask": "0x01",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.dram_far",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from DRAM in a different NUMA node.",
+ "UMask": "0x02",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.near_cache",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from another CCX's cache when the address was in the same NUMA node.",
+ "UMask": "0x04",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.far_cache",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from another CCX's cache when the address was in a different NUMA node.",
+ "UMask": "0x08",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.ext_near",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from extension memory (CXL) in the same NUMA node.",
+ "UMask": "0x10",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.ext_far",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from extension memory (CXL) in a different NUMA node.",
+ "UMask": "0x20",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ },
+ {
+ "EventName": "l3_xi_sampled_latency_requests.all",
+ "EventCode": "0xad",
+ "BriefDescription": "L3 cache fill requests sourced from all data sources.",
+ "UMask": "0x3f",
+ "EnAllCores": "0x1",
+ "EnAllSlices": "0x1",
+ "SliceId": "0x3",
+ "ThreadMask": "0x3",
+ "Unit": "L3PMC"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/core.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/core.json
new file mode 100644
index 000000000000..a56a41828bd4
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/core.json
@@ -0,0 +1,122 @@
+[
+ {
+ "EventName": "ls_locks.bus_lock",
+ "EventCode": "0x25",
+ "BriefDescription": "Retired Lock instructions which caused a bus lock.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_ret_cl_flush",
+ "EventCode": "0x26",
+ "BriefDescription": "Retired CLFLUSH instructions."
+ },
+ {
+ "EventName": "ls_ret_cpuid",
+ "EventCode": "0x27",
+ "BriefDescription": "Retired CPUID instructions."
+ },
+ {
+ "EventName": "ls_smi_rx",
+ "EventCode": "0x2b",
+ "BriefDescription": "SMIs received."
+ },
+ {
+ "EventName": "ls_int_taken",
+ "EventCode": "0x2c",
+ "BriefDescription": "Interrupts taken."
+ },
+ {
+ "EventName": "ls_not_halted_cyc",
+ "EventCode": "0x76",
+ "BriefDescription": "Core cycles not in halt."
+ },
+ {
+ "EventName": "ex_ret_instr",
+ "EventCode": "0xc0",
+ "BriefDescription": "Retired instructions."
+ },
+ {
+ "EventName": "ex_ret_ops",
+ "EventCode": "0xc1",
+ "BriefDescription": "Retired macro-ops."
+ },
+ {
+ "EventName": "ex_div_busy",
+ "EventCode": "0xd3",
+ "BriefDescription": "Number of cycles the divider is busy."
+ },
+ {
+ "EventName": "ex_div_count",
+ "EventCode": "0xd4",
+ "BriefDescription": "Divide ops executed."
+ },
+ {
+ "EventName": "ex_no_retire.empty",
+ "EventCode": "0xd6",
+ "BriefDescription": "Cycles with no retire due to the lack of valid ops in the retire queue (may be caused by front-end bottlenecks or pipeline redirects).",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ex_no_retire.not_complete",
+ "EventCode": "0xd6",
+ "BriefDescription": "Cycles with no retire while the oldest op is waiting to be executed.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ex_no_retire.other",
+ "EventCode": "0xd6",
+ "BriefDescription": "Cycles with no retire caused by other reasons (retire breaks, traps, faults, etc.).",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "ex_no_retire.thread_not_selected",
+ "EventCode": "0xd6",
+ "BriefDescription": "Cycles with no retire because thread arbitration did not select the thread.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "ex_no_retire.load_not_complete",
+ "EventCode": "0xd6",
+ "BriefDescription": "Cycles with no retire while the oldest op is waiting for load data.",
+ "UMask": "0xa2"
+ },
+ {
+ "EventName": "ex_no_retire.all",
+ "EventCode": "0xd6",
+ "BriefDescription": "Cycles with no retire for any reason.",
+ "UMask": "0x1b"
+ },
+ {
+ "EventName": "ls_not_halted_p0_cyc.p0_freq_cyc",
+ "EventCode": "0x120",
+ "BriefDescription": "Reference cycles (P0 frequency) not in halt .",
+ "UMask": "0x1"
+ },
+ {
+ "EventName": "ex_ret_ucode_instr",
+ "EventCode": "0x1c1",
+ "BriefDescription": "Retired microcoded instructions."
+ },
+ {
+ "EventName": "ex_ret_ucode_ops",
+ "EventCode": "0x1c2",
+ "BriefDescription": "Retired microcode ops."
+ },
+ {
+ "EventName": "ex_tagged_ibs_ops.ibs_tagged_ops",
+ "EventCode": "0x1cf",
+ "BriefDescription": "Ops tagged by IBS.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ex_tagged_ibs_ops.ibs_tagged_ops_ret",
+ "EventCode": "0x1cf",
+ "BriefDescription": "Ops tagged by IBS that retired.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ex_ret_fused_instr",
+ "EventCode": "0x1d0",
+ "BriefDescription": "Retired fused instructions."
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/data-fabric.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/data-fabric.json
new file mode 100644
index 000000000000..cf8f13075e62
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/data-fabric.json
@@ -0,0 +1,1090 @@
+[
+ {
+ "EventName": "local_processor_read_data_beats_cs0",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 0.",
+ "EventCode": "0x1f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs1",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 1.",
+ "EventCode": "0x5f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs2",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 2.",
+ "EventCode": "0x9f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs3",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 3.",
+ "EventCode": "0xdf",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs4",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 4.",
+ "EventCode": "0x11f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs5",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 5.",
+ "EventCode": "0x15f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs6",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 6.",
+ "EventCode": "0x19f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs7",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 7.",
+ "EventCode": "0x1df",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs8",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 8.",
+ "EventCode": "0x21f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs9",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 9.",
+ "EventCode": "0x25f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs10",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 10.",
+ "EventCode": "0x29f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_read_data_beats_cs11",
+ "PublicDescription": "Read data beats (64 bytes) for local processor at Coherent Station (CS) 11.",
+ "EventCode": "0x2df",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs0",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 0.",
+ "EventCode": "0x1f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs1",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 1.",
+ "EventCode": "0x5f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs2",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 2.",
+ "EventCode": "0x9f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs3",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 3.",
+ "EventCode": "0xdf",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs4",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 4.",
+ "EventCode": "0x11f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs5",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 5.",
+ "EventCode": "0x15f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs6",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 6.",
+ "EventCode": "0x19f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs7",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 7.",
+ "EventCode": "0x1df",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs8",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 8.",
+ "EventCode": "0x21f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs9",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 9.",
+ "EventCode": "0x25f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs10",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 10.",
+ "EventCode": "0x29f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_processor_write_data_beats_cs11",
+ "PublicDescription": "Write data beats (64 bytes) for local processor at Coherent Station (CS) 11.",
+ "EventCode": "0x2df",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs0",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 0.",
+ "EventCode": "0x1f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs1",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 1.",
+ "EventCode": "0x5f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs2",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 2.",
+ "EventCode": "0x9f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs3",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 3.",
+ "EventCode": "0xdf",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs4",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 4.",
+ "EventCode": "0x11f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs5",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 5.",
+ "EventCode": "0x15f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs6",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 6.",
+ "EventCode": "0x19f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs7",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 7.",
+ "EventCode": "0x1df",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs8",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 8.",
+ "EventCode": "0x21f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs9",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 9.",
+ "EventCode": "0x25f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs10",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 10.",
+ "EventCode": "0x29f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_read_data_beats_cs11",
+ "PublicDescription": "Read data beats (64 bytes) for remote processor at Coherent Station (CS) 11.",
+ "EventCode": "0x2df",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs0",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 0.",
+ "EventCode": "0x1f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs1",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 1.",
+ "EventCode": "0x5f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs2",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 2.",
+ "EventCode": "0x9f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs3",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 3.",
+ "EventCode": "0xdf",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs4",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 4.",
+ "EventCode": "0x11f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs5",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 5.",
+ "EventCode": "0x15f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs6",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 6.",
+ "EventCode": "0x19f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs7",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 7.",
+ "EventCode": "0x1df",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs8",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 8.",
+ "EventCode": "0x21f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs9",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 9.",
+ "EventCode": "0x25f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs10",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 10.",
+ "EventCode": "0x29f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_processor_write_data_beats_cs11",
+ "PublicDescription": "Write data beats (64 bytes) for remote processor at Coherent Station (CS) 11.",
+ "EventCode": "0x2df",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_read_beats_iom0",
+ "PublicDescription": "Read data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 0.",
+ "EventCode": "0x81f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_read_beats_iom1",
+ "PublicDescription": "Read data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 1.",
+ "EventCode": "0x85f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_read_beats_iom2",
+ "PublicDescription": "Read data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 2.",
+ "EventCode": "0x89f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_read_beats_iom3",
+ "PublicDescription": "Read data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 3.",
+ "EventCode": "0x8df",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_write_beats_iom0",
+ "PublicDescription": "Write data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 0.",
+ "EventCode": "0x81f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_write_beats_iom1",
+ "PublicDescription": "Write data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 1.",
+ "EventCode": "0x85f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_write_beats_iom2",
+ "PublicDescription": "Write data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 2.",
+ "EventCode": "0x89f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_upstream_write_beats_iom3",
+ "PublicDescription": "Write data beats (64 bytes) for local socket upstream DMA at IO Moderator (IOM) 3.",
+ "EventCode": "0x8df",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_read_beats_iom0",
+ "PublicDescription": "Read data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 0.",
+ "EventCode": "0x81f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_read_beats_iom1",
+ "PublicDescription": "Read data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 1.",
+ "EventCode": "0x85f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_read_beats_iom2",
+ "PublicDescription": "Read data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 2.",
+ "EventCode": "0x89f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_read_beats_iom3",
+ "PublicDescription": "Read data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 3.",
+ "EventCode": "0x8df",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_write_beats_iom0",
+ "PublicDescription": "Write data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 0.",
+ "EventCode": "0x81f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_write_beats_iom1",
+ "PublicDescription": "Write data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 1.",
+ "EventCode": "0x85f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_write_beats_iom2",
+ "PublicDescription": "Write data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 2.",
+ "EventCode": "0x89f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_upstream_write_beats_iom3",
+ "PublicDescription": "Write data beats (64 bytes) for remote socket upstream DMA at IO Moderator (IOM) 3.",
+ "EventCode": "0x8df",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 0.",
+ "EventCode": "0x41e",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 1.",
+ "EventCode": "0x45e",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 2.",
+ "EventCode": "0x49e",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 3.",
+ "EventCode": "0x4de",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 4.",
+ "EventCode": "0x51e",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 5.",
+ "EventCode": "0x55e",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 6.",
+ "EventCode": "0x59e",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_inbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for local socket inbound data to CPU Moderator (CCM) 7.",
+ "EventCode": "0x5de",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 0.",
+ "EventCode": "0x41f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 1.",
+ "EventCode": "0x45f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 2.",
+ "EventCode": "0x49f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 3.",
+ "EventCode": "0x4df",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 4.",
+ "EventCode": "0x51f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 5.",
+ "EventCode": "0x55f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 6.",
+ "EventCode": "0x59f",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_inbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for local socket inbound data to CPU Moderator (CCM) 7.",
+ "EventCode": "0x5df",
+ "UMask": "0x7fe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 0.",
+ "EventCode": "0x41e",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 1.",
+ "EventCode": "0x45e",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 2.",
+ "EventCode": "0x49e",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 3.",
+ "EventCode": "0x4de",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 4.",
+ "EventCode": "0x51e",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 5.",
+ "EventCode": "0x55e",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 6.",
+ "EventCode": "0x59e",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf0_outbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for local socket outbound data from CPU Moderator (CCM) 7.",
+ "EventCode": "0x5de",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 0.",
+ "EventCode": "0x41f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 1.",
+ "EventCode": "0x45f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 2.",
+ "EventCode": "0x49f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 3.",
+ "EventCode": "0x4df",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 4.",
+ "EventCode": "0x51f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 5.",
+ "EventCode": "0x55f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 6.",
+ "EventCode": "0x59f",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_inf1_outbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for local socket outbound data from CPU Moderator (CCM) 7.",
+ "EventCode": "0x5df",
+ "UMask": "0x7ff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 0.",
+ "EventCode": "0x41e",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 1.",
+ "EventCode": "0x45e",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 2.",
+ "EventCode": "0x49e",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 3.",
+ "EventCode": "0x4de",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 4.",
+ "EventCode": "0x51e",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 5.",
+ "EventCode": "0x55e",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 6.",
+ "EventCode": "0x59e",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_inbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (32 bytes) at interface 0 for remote socket inbound data to CPU Moderator (CCM) 7.",
+ "EventCode": "0x5de",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 0.",
+ "EventCode": "0x41f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 1.",
+ "EventCode": "0x45f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 2.",
+ "EventCode": "0x49f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 3.",
+ "EventCode": "0x4df",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 4.",
+ "EventCode": "0x51f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 5.",
+ "EventCode": "0x55f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 6.",
+ "EventCode": "0x59f",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_inbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (32 bytes) at interface 1 for remote socket inbound data to CPU Moderator (CCM) 7.",
+ "EventCode": "0x5df",
+ "UMask": "0xbfe",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 0.",
+ "EventCode": "0x41e",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 1.",
+ "EventCode": "0x45e",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 2.",
+ "EventCode": "0x49e",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 3.",
+ "EventCode": "0x4de",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 4.",
+ "EventCode": "0x51e",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 5.",
+ "EventCode": "0x55e",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 6.",
+ "EventCode": "0x59e",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf0_outbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (64 bytes) at interface 0 for remote socket outbound data from CPU Moderator (CCM) 7.",
+ "EventCode": "0x5de",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm0",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 0.",
+ "EventCode": "0x41f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm1",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 1.",
+ "EventCode": "0x45f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm2",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 2.",
+ "EventCode": "0x49f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm3",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 3.",
+ "EventCode": "0x4df",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm4",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 4.",
+ "EventCode": "0x51f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm5",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 5.",
+ "EventCode": "0x55f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm6",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 6.",
+ "EventCode": "0x59f",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "remote_socket_inf1_outbound_data_beats_ccm7",
+ "PublicDescription": "Data beats (64 bytes) at interface 1 for remote socket outbound data from CPU Moderator (CCM) 7.",
+ "EventCode": "0x5df",
+ "UMask": "0xbff",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link0",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 0.",
+ "EventCode": "0xb5f",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link1",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 1.",
+ "EventCode": "0xb9f",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link2",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 2.",
+ "EventCode": "0xbdf",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link3",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 3.",
+ "EventCode": "0xc1f",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link4",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 4.",
+ "EventCode": "0xc5f",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link5",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 5.",
+ "EventCode": "0xc9f",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link6",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 6.",
+ "EventCode": "0xcdf",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ },
+ {
+ "EventName": "local_socket_outbound_data_beats_link7",
+ "PublicDescription": "Data beats (64 bytes) for local socket outbound data from inter-socket xGMI link 7.",
+ "EventCode": "0xd1f",
+ "UMask": "0xf3e",
+ "PerPkg": "1",
+ "Unit": "DFPMC"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/floating-point.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/floating-point.json
new file mode 100644
index 000000000000..cd7328fb7998
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/floating-point.json
@@ -0,0 +1,818 @@
+[
+ {
+ "EventName": "fp_ret_x87_fp_ops.add_sub_ops",
+ "EventCode": "0x02",
+ "BriefDescription": "Retired x87 floating-point add and subtract ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_ret_x87_fp_ops.mul_ops",
+ "EventCode": "0x02",
+ "BriefDescription": "Retired x87 floating-point multiply ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_ret_x87_fp_ops.div_sqrt_ops",
+ "EventCode": "0x02",
+ "BriefDescription": "Retired x87 floating-point divide and square root ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_ret_x87_fp_ops.all",
+ "EventCode": "0x02",
+ "BriefDescription": "Retired x87 floating-point ops of all types.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "fp_ret_sse_avx_ops.add_sub_flops",
+ "EventCode": "0x03",
+ "BriefDescription": "Retired SSE and AVX floating-point add and subtract ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_ret_sse_avx_ops.mult_flops",
+ "EventCode": "0x03",
+ "BriefDescription": "Retired SSE and AVX floating-point multiply ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_ret_sse_avx_ops.div_flops",
+ "EventCode": "0x03",
+ "BriefDescription": "Retired SSE and AVX floating-point divide and square root ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_ret_sse_avx_ops.mac_flops",
+ "EventCode": "0x03",
+ "BriefDescription": "Retired SSE and AVX floating-point multiply-accumulate ops (each operation is counted as 2 ops).",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "fp_ret_sse_avx_ops.bfloat_mac_flops",
+ "EventCode": "0x03",
+ "BriefDescription": "Retired SSE and AVX floating-point bfloat multiply-accumulate ops (each operation is counted as 2 ops).",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "fp_ret_sse_avx_ops.all",
+ "EventCode": "0x03",
+ "BriefDescription": "Retired SSE and AVX floating-point ops of all types.",
+ "UMask": "0x1f"
+ },
+ {
+ "EventName": "fp_retired_ser_ops.x87_ctrl_ret",
+ "EventCode": "0x05",
+ "BriefDescription": "Retired x87 control word mispredict traps due to mispredictions in RC or PC, or changes in exception mask bits.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_retired_ser_ops.x87_bot_ret",
+ "EventCode": "0x05",
+ "BriefDescription": "Retired x87 bottom-executing ops. Bottom-executing ops wait for all older ops to retire before executing.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_retired_ser_ops.sse_ctrl_ret",
+ "EventCode": "0x05",
+ "BriefDescription": "Retired SSE and AVX control word mispredict traps.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_retired_ser_ops.sse_bot_ret",
+ "EventCode": "0x05",
+ "BriefDescription": "Retired SSE and AVX bottom-executing ops. Bottom-executing ops wait for all older ops to retire before executing.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "fp_retired_ser_ops.all",
+ "EventCode": "0x05",
+ "BriefDescription": "Retired SSE and AVX serializing ops of all types.",
+ "UMask": "0x0f"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.x87_uops_retired",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired x87 floating-point ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.mmx_uops_retired",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired MMX floating-point ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.scalar_uops_retired",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired scalar floating-point ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.pack_128_uops_retired",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired packed 128-bit floating-point ops.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.pack_256_uops_retired",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired packed 256-bit floating-point ops.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.pack_512_uops_retired",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired packed 512-bit floating-point ops.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "fp_ops_retired_by_width.all",
+ "EventCode": "0x08",
+ "BriefDescription": "Retired floating-point ops of all widths.",
+ "UMask": "0x3f"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_add",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point add ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_sub",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point subtract ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_mul",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point multiply ops.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_mac",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point multiply-accumulate ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_div",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point divide ops.",
+ "UMask": "0x05"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_sqrt",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point square root ops.",
+ "UMask": "0x06"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_cmp",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point compare ops.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_cvt",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point convert ops.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_blend",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point blend ops.",
+ "UMask": "0x09"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_other",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point ops of other types.",
+ "UMask": "0x0e"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.scalar_all",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired scalar floating-point ops of all types.",
+ "UMask": "0x0f"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_add",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point add ops.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_sub",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point subtract ops.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_mul",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point multiply ops.",
+ "UMask": "0x30"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_mac",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point multiply-accumulate ops.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_div",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point divide ops.",
+ "UMask": "0x50"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_sqrt",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point square root ops.",
+ "UMask": "0x60"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_cmp",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point compare ops.",
+ "UMask": "0x70"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_cvt",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point convert ops.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_blend",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point blend ops.",
+ "UMask": "0x90"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_shuffle",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0xb0"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_logical",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point logical ops.",
+ "UMask": "0xd0"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_other",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point ops of other types.",
+ "UMask": "0xe0"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.vector_all",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired vector floating-point ops of all types.",
+ "UMask": "0xf0"
+ },
+ {
+ "EventName": "fp_ops_retired_by_type.all",
+ "EventCode": "0x0a",
+ "BriefDescription": "Retired floating-point ops of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_add",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer add.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_sub",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer subtract ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_mul",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer multiply ops.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_mac",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer multiply-accumulate ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_cmp",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer compare ops.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_shift",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer shift ops.",
+ "UMask": "0x09"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_mov",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer MOV ops.",
+ "UMask": "0x0a"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_shuffle",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0x0b"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_pack",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer pack ops.",
+ "UMask": "0x0c"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_logical",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer logical ops.",
+ "UMask": "0x0d"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_other",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer multiply ops of other types.",
+ "UMask": "0x0e"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.mmx_all",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired MMX integer ops of all types.",
+ "UMask": "0x0f"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_add",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer add ops.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_sub",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer subtract ops.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_mul",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer multiply ops.",
+ "UMask": "0x30"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_mac",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer multiply-accumulate ops.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_aes",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer AES ops.",
+ "UMask": "0x50"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_sha",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer SHA ops.",
+ "UMask": "0x60"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_cmp",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer compare ops.",
+ "UMask": "0x70"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_clm",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer CLM ops.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_shift",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer shift ops.",
+ "UMask": "0x90"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_mov",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer MOV ops.",
+ "UMask": "0xa0"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_shuffle",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0xb0"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_pack",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer pack ops.",
+ "UMask": "0xc0"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_logical",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer logical ops.",
+ "UMask": "0xd0"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_other",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer ops of other types.",
+ "UMask": "0xe0"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.sse_avx_all",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE and AVX integer ops of all types.",
+ "UMask": "0xf0"
+ },
+ {
+ "EventName": "sse_avx_ops_retired.all",
+ "EventCode": "0x0b",
+ "BriefDescription": "Retired SSE, AVX and MMX integer ops of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_add",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point add ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_sub",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point subtract ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_mul",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point multiply ops.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_mac",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point multiply-accumulate ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_div",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point divide ops.",
+ "UMask": "0x05"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_sqrt",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point square root ops.",
+ "UMask": "0x06"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_cmp",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point compare ops.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_cvt",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point convert ops.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_blend",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point blend ops.",
+ "UMask": "0x09"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_shuffle",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0x0b"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_logical",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point logical ops.",
+ "UMask": "0x0d"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_other",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point ops of other types.",
+ "UMask": "0x0e"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp128_all",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 128-bit packed floating-point ops of all types.",
+ "UMask": "0x0f"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_add",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point add ops.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_sub",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point subtract ops.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_mul",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point multiply ops.",
+ "UMask": "0x30"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_mac",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point multiply-accumulate ops.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_div",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point divide ops.",
+ "UMask": "0x50"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_sqrt",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point square root ops.",
+ "UMask": "0x60"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_cmp",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point compare ops.",
+ "UMask": "0x70"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_cvt",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point convert ops.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_blend",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point blend ops.",
+ "UMask": "0x90"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_shuffle",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0xb0"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_logical",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point logical ops.",
+ "UMask": "0xd0"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_other",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point ops of other types.",
+ "UMask": "0xe0"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.fp256_all",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired 256-bit packed floating-point ops of all types.",
+ "UMask": "0xf0"
+ },
+ {
+ "EventName": "fp_pack_ops_retired.all",
+ "EventCode": "0x0c",
+ "BriefDescription": "Retired packed floating-point ops of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_add",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer add ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_sub",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer subtract ops.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_mul",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer multiply ops.",
+ "UMask": "0x03"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_mac",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer multiply-accumulate ops.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_aes",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer AES ops.",
+ "UMask": "0x05"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_sha",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer SHA ops.",
+ "UMask": "0x06"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_cmp",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer compare ops.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_clm",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer CLM ops.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_shift",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer shift ops.",
+ "UMask": "0x09"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_mov",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer MOV ops.",
+ "UMask": "0x0a"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_shuffle",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0x0b"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_pack",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer pack ops.",
+ "UMask": "0x0c"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_logical",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer logical ops.",
+ "UMask": "0x0d"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_other",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer ops of other types.",
+ "UMask": "0x0e"
+ },
+ {
+ "EventName": "packed_int_op_type.int128_all",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 128-bit packed integer ops of all types.",
+ "UMask": "0x0f"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_add",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer add ops.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_sub",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer subtract ops.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_mul",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer multiply ops.",
+ "UMask": "0x30"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_mac",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer multiply-accumulate ops.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_cmp",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer compare ops.",
+ "UMask": "0x70"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_shift",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer shift ops.",
+ "UMask": "0x90"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_mov",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer MOV ops.",
+ "UMask": "0xa0"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_shuffle",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer shuffle ops (may include instructions not necessarily thought of as including shuffles e.g. horizontal add, dot product, and certain MOV instructions).",
+ "UMask": "0xb0"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_pack",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer pack ops.",
+ "UMask": "0xc0"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_logical",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer logical ops.",
+ "UMask": "0xd0"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_other",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer ops of other types.",
+ "UMask": "0xe0"
+ },
+ {
+ "EventName": "packed_int_op_type.int256_all",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired 256-bit packed integer ops of all types.",
+ "UMask": "0xf0"
+ },
+ {
+ "EventName": "packed_int_op_type.all",
+ "EventCode": "0x0d",
+ "BriefDescription": "Retired packed integer ops of all types.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "fp_disp_faults.x87_fill_fault",
+ "EventCode": "0x0e",
+ "BriefDescription": "Floating-point dispatch faults for x87 fills.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "fp_disp_faults.xmm_fill_fault",
+ "EventCode": "0x0e",
+ "BriefDescription": "Floating-point dispatch faults for XMM fills.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "fp_disp_faults.ymm_fill_fault",
+ "EventCode": "0x0e",
+ "BriefDescription": "Floating-point dispatch faults for YMM fills.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "fp_disp_faults.ymm_spill_fault",
+ "EventCode": "0x0e",
+ "BriefDescription": "Floating-point dispatch faults for YMM spills.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "fp_disp_faults.sse_avx_all",
+ "EventCode": "0x0e",
+ "BriefDescription": "Floating-point dispatch faults of all types for SSE and AVX ops.",
+ "UMask": "0x0e"
+ },
+ {
+ "EventName": "fp_disp_faults.all",
+ "EventCode": "0x0e",
+ "BriefDescription": "Floating-point dispatch faults of all types.",
+ "UMask": "0x0f"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/memory-controller.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/memory-controller.json
new file mode 100644
index 000000000000..55263e5e4f69
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/memory-controller.json
@@ -0,0 +1,101 @@
+[
+ {
+ "EventName": "umc_mem_clk",
+ "PublicDescription": "Number of memory clock cycles.",
+ "EventCode": "0x00",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_act_cmd.all",
+ "PublicDescription": "Number of ACTIVATE commands sent.",
+ "EventCode": "0x05",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_act_cmd.rd",
+ "PublicDescription": "Number of ACTIVATE commands sent for reads.",
+ "EventCode": "0x05",
+ "RdWrMask": "0x1",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_act_cmd.wr",
+ "PublicDescription": "Number of ACTIVATE commands sent for writes.",
+ "EventCode": "0x05",
+ "RdWrMask": "0x2",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_pchg_cmd.all",
+ "PublicDescription": "Number of PRECHARGE commands sent.",
+ "EventCode": "0x06",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_pchg_cmd.rd",
+ "PublicDescription": "Number of PRECHARGE commands sent for reads.",
+ "EventCode": "0x06",
+ "RdWrMask": "0x1",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_pchg_cmd.wr",
+ "PublicDescription": "Number of PRECHARGE commands sent for writes.",
+ "EventCode": "0x06",
+ "RdWrMask": "0x2",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_cas_cmd.all",
+ "PublicDescription": "Number of CAS commands sent.",
+ "EventCode": "0x0a",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_cas_cmd.rd",
+ "PublicDescription": "Number of CAS commands sent for reads.",
+ "EventCode": "0x0a",
+ "RdWrMask": "0x1",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_cas_cmd.wr",
+ "PublicDescription": "Number of CAS commands sent for writes.",
+ "EventCode": "0x0a",
+ "RdWrMask": "0x2",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_data_slot_clks.all",
+ "PublicDescription": "Number of clocks used by the data bus.",
+ "EventCode": "0x14",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_data_slot_clks.rd",
+ "PublicDescription": "Number of clocks used by the data bus for reads.",
+ "EventCode": "0x14",
+ "RdWrMask": "0x1",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ },
+ {
+ "EventName": "umc_data_slot_clks.wr",
+ "PublicDescription": "Number of clocks used by the data bus for writes.",
+ "EventCode": "0x14",
+ "RdWrMask": "0x2",
+ "PerPkg": "1",
+ "Unit": "UMCPMC"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/memory.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/memory.json
new file mode 100644
index 000000000000..cb1517f8f399
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/memory.json
@@ -0,0 +1,174 @@
+[
+ {
+ "EventName": "ls_bad_status2.stli_other",
+ "EventCode": "0x24",
+ "BriefDescription": "Store-to-load conflicts (load unable to complete due to a non-forwardable conflict with an older store).",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_dispatch.ld_dispatch",
+ "EventCode": "0x29",
+ "BriefDescription": "Number of memory load operations dispatched to the load-store unit.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_dispatch.store_dispatch",
+ "EventCode": "0x29",
+ "BriefDescription": "Number of memory store operations dispatched to the load-store unit.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_dispatch.ld_st_dispatch",
+ "EventCode": "0x29",
+ "BriefDescription": "Number of memory load-store operations dispatched to the load-store unit.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_stlf",
+ "EventCode": "0x35",
+ "BriefDescription": "Store-to-load-forward (STLF) hits."
+ },
+ {
+ "EventName": "ls_st_commit_cancel2.st_commit_cancel_wcb_full",
+ "EventCode": "0x37",
+ "BriefDescription": "Non-cacheable store commits cancelled due to the non-cacheable commit buffer being full.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_4k_l2_hit",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB hits for 4k pages.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_coalesced_page_hit",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB hits for coalesced pages. A coalesced page is a 16k page created from four adjacent 4k pages.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_2m_l2_hit",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB hits for 2M pages.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_1g_l2_hit",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB hits for 1G pages.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_4k_l2_miss",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB misses (page-table walks are requested) for 4k pages.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_coalesced_page_miss",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB misses (page-table walks are requested) for coalesced pages. A coalesced page is a 16k page created from four adjacent 4k pages.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_2m_l2_miss",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB misses (page-table walks are requested) for 2M pages.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.tlb_reload_1g_l2_miss",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB misses (page-table walks are requested) for 1G pages.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.all_l2_miss",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses with L2 DTLB misses (page-table walks are requested) for all page sizes.",
+ "UMask": "0xf0"
+ },
+ {
+ "EventName": "ls_l1_d_tlb_miss.all",
+ "EventCode": "0x45",
+ "BriefDescription": "L1 DTLB misses for all page sizes.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "ls_misal_loads.ma64",
+ "EventCode": "0x47",
+ "BriefDescription": "64B misaligned (cacheline crossing) loads.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "ls_misal_loads.ma4k",
+ "EventCode": "0x47",
+ "BriefDescription": "4kB misaligned (page crossing) loads.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "ls_tlb_flush.all",
+ "EventCode": "0x78",
+ "BriefDescription": "All TLB Flushes.",
+ "UMask": "0xff"
+ },
+ {
+ "EventName": "bp_l1_tlb_miss_l2_tlb_hit",
+ "EventCode": "0x84",
+ "BriefDescription": "Instruction fetches that miss in the L1 ITLB but hit in the L2 ITLB."
+ },
+ {
+ "EventName": "bp_l1_tlb_miss_l2_tlb_miss.if4k",
+ "EventCode": "0x85",
+ "BriefDescription": "Instruction fetches that miss in both the L1 and L2 ITLBs (page-table walks are requested) for 4k pages.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "bp_l1_tlb_miss_l2_tlb_miss.if2m",
+ "EventCode": "0x85",
+ "BriefDescription": "Instruction fetches that miss in both the L1 and L2 ITLBs (page-table walks are requested) for 2M pages.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "bp_l1_tlb_miss_l2_tlb_miss.if1g",
+ "EventCode": "0x85",
+ "BriefDescription": "Instruction fetches that miss in both the L1 and L2 ITLBs (page-table walks are requested) for 1G pages.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "bp_l1_tlb_miss_l2_tlb_miss.coalesced_4k",
+ "EventCode": "0x85",
+ "BriefDescription": "Instruction fetches that miss in both the L1 and L2 ITLBs (page-table walks are requested) for coalesced pages. A coalesced page is a 16k page created from four adjacent 4k pages.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "bp_l1_tlb_miss_l2_tlb_miss.all",
+ "EventCode": "0x85",
+ "BriefDescription": "Instruction fetches that miss in both the L1 and L2 ITLBs (page-table walks are requested) for all page sizes.",
+ "UMask": "0x0f"
+ },
+ {
+ "EventName": "bp_l1_tlb_fetch_hit.if4k",
+ "EventCode": "0x94",
+ "BriefDescription": "Instruction fetches that hit in the L1 ITLB for 4k or coalesced pages. A coalesced page is a 16k page created from four adjacent 4k pages.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "bp_l1_tlb_fetch_hit.if2m",
+ "EventCode": "0x94",
+ "BriefDescription": "Instruction fetches that hit in the L1 ITLB for 2M pages.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "bp_l1_tlb_fetch_hit.if1g",
+ "EventCode": "0x94",
+ "BriefDescription": "Instruction fetches that hit in the L1 ITLB for 1G pages.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "bp_l1_tlb_fetch_hit.all",
+ "EventCode": "0x94",
+ "BriefDescription": "Instruction fetches that hit in the L1 ITLB for all page sizes.",
+ "UMask": "0x07"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/other.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/other.json
new file mode 100644
index 000000000000..a02a9c807289
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/other.json
@@ -0,0 +1,138 @@
+[
+ {
+ "EventName": "resyncs_or_nc_redirects",
+ "EventCode": "0x96",
+ "BriefDescription": "Pipeline restarts not caused by branch mispredicts."
+ },
+ {
+ "EventName": "de_op_queue_empty",
+ "EventCode": "0xa9",
+ "BriefDescription": "Cycles when the op queue is empty. Such cycles indicate that the front-end is not delivering instructions fast enough."
+ },
+ {
+ "EventName": "de_src_op_disp.decoder",
+ "EventCode": "0xaa",
+ "BriefDescription": "Ops fetched from instruction cache and dispatched.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "de_src_op_disp.op_cache",
+ "EventCode": "0xaa",
+ "BriefDescription": "Ops fetched from op cache and dispatched.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "de_src_op_disp.loop_buffer",
+ "EventCode": "0xaa",
+ "BriefDescription": "Ops dispatched from loop buffer.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "de_src_op_disp.all",
+ "EventCode": "0xaa",
+ "BriefDescription": "Ops dispatched from any source.",
+ "UMask": "0x07"
+ },
+ {
+ "EventName": "de_dis_ops_from_decoder.any_fp_dispatch",
+ "EventCode": "0xab",
+ "BriefDescription": "Number of ops dispatched to the floating-point unit.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "de_dis_ops_from_decoder.disp_op_type.any_integer_dispatch",
+ "EventCode": "0xab",
+ "BriefDescription": "Number of ops dispatched to the integer execution unit.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.int_phy_reg_file_rsrc_stall",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for integer physical register file tokens.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.load_queue_rsrc_stall",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for Load queue token.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.store_queue_rsrc_stall",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for store queue tokens.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.taken_brnch_buffer_rsrc",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for taken branch buffer tokens.",
+ "UMask": "0x10"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.fp_reg_file_rsrc_stall",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for floating-point register file tokens.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.fp_sch_rsrc_stall",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for floating-point scheduler tokens.",
+ "UMask": "0x40"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls1.fp_flush_recovery_stall",
+ "EventCode": "0xae",
+ "BriefDescription": "Number of cycles dispatch is stalled for floating-point flush recovery.",
+ "UMask": "0x80"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls2.int_sch0_token_stall",
+ "EventCode": "0xaf",
+ "BriefDescription": "Number of cycles dispatch is stalled for integer scheduler queue 0 tokens.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls2.int_sch1_token_stall",
+ "EventCode": "0xaf",
+ "BriefDescription": "Number of cycles dispatch is stalled for integer scheduler queue 1 tokens.",
+ "UMask": "0x02"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls2.int_sch2_token_stall",
+ "EventCode": "0xaf",
+ "BriefDescription": "Number of cycles dispatch is stalled for integer scheduler queue 2 tokens.",
+ "UMask": "0x04"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls2.int_sch3_token_stall",
+ "EventCode": "0xaf",
+ "BriefDescription": "Number of cycles dispatch is stalled for integer scheduler queue 3 tokens.",
+ "UMask": "0x08"
+ },
+ {
+ "EventName": "de_dis_dispatch_token_stalls2.retire_token_stall",
+ "EventCode": "0xaf",
+ "BriefDescription": "Number of cycles dispatch is stalled for retire queue tokens.",
+ "UMask": "0x20"
+ },
+ {
+ "EventName": "de_no_dispatch_per_slot.no_ops_from_frontend",
+ "EventCode": "0x1a0",
+ "BriefDescription": "In each cycle counts dispatch slots left empty because the front-end did not supply ops.",
+ "UMask": "0x01"
+ },
+ {
+ "EventName": "de_no_dispatch_per_slot.backend_stalls",
+ "EventCode": "0x1a0",
+ "BriefDescription": "In each cycle counts ops unable to dispatch because of back-end stalls.",
+ "UMask": "0x1e"
+ },
+ {
+ "EventName": "de_no_dispatch_per_slot.smt_contention",
+ "EventCode": "0x1a0",
+ "BriefDescription": "In each cycle counts ops unable to dispatch because the dispatch cycle was granted to the other SMT thread.",
+ "UMask": "0x60"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/pipeline.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/pipeline.json
new file mode 100644
index 000000000000..4ae8316c7507
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/pipeline.json
@@ -0,0 +1,98 @@
+[
+ {
+ "MetricName": "total_dispatch_slots",
+ "BriefDescription": "Total dispatch slots (upto 6 instructions can be dispatched in each cycle).",
+ "MetricExpr": "6 * ls_not_halted_cyc"
+ },
+ {
+ "MetricName": "frontend_bound",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because the frontend did not supply enough instructions/ops.",
+ "MetricExpr": "d_ratio(de_no_dispatch_per_slot.no_ops_from_frontend, total_dispatch_slots)",
+ "MetricGroup": "PipelineL1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "bad_speculation",
+ "BriefDescription": "Fraction of dispatched ops that did not retire.",
+ "MetricExpr": "d_ratio(de_src_op_disp.all - ex_ret_ops, total_dispatch_slots)",
+ "MetricGroup": "PipelineL1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "backend_bound",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because of backend stalls.",
+ "MetricExpr": "d_ratio(de_no_dispatch_per_slot.backend_stalls, total_dispatch_slots)",
+ "MetricGroup": "PipelineL1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "smt_contention",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because the other thread was selected.",
+ "MetricExpr": "d_ratio(de_no_dispatch_per_slot.smt_contention, total_dispatch_slots)",
+ "MetricGroup": "PipelineL1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "retiring",
+ "BriefDescription": "Fraction of dispatch slots used by ops that retired.",
+ "MetricExpr": "d_ratio(ex_ret_ops, total_dispatch_slots)",
+ "MetricGroup": "PipelineL1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "frontend_bound_latency",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because of a latency bottleneck in the frontend (such as instruction cache or TLB misses).",
+ "MetricExpr": "d_ratio((6 * cpu@de_no_dispatch_per_slot.no_ops_from_frontend\\,cmask\\=0x6@), total_dispatch_slots)",
+ "MetricGroup": "PipelineL2;frontend_bound_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "frontend_bound_bandwidth",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because of a bandwidth bottleneck in the frontend (such as decode or op cache fetch bandwidth).",
+ "MetricExpr": "d_ratio(de_no_dispatch_per_slot.no_ops_from_frontend - (6 * cpu@de_no_dispatch_per_slot.no_ops_from_frontend\\,cmask\\=0x6@), total_dispatch_slots)",
+ "MetricGroup": "PipelineL2;frontend_bound_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "bad_speculation_mispredicts",
+ "BriefDescription": "Fraction of dispatched ops that were flushed due to branch mispredicts.",
+ "MetricExpr": "d_ratio(bad_speculation * ex_ret_brn_misp, ex_ret_brn_misp + resyncs_or_nc_redirects)",
+ "MetricGroup": "PipelineL2;bad_speculation_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "bad_speculation_pipeline_restarts",
+ "BriefDescription": "Fraction of dispatched ops that were flushed due to pipeline restarts (resyncs).",
+ "MetricExpr": "d_ratio(bad_speculation * resyncs_or_nc_redirects, ex_ret_brn_misp + resyncs_or_nc_redirects)",
+ "MetricGroup": "PipelineL2;bad_speculation_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "backend_bound_memory",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because of stalls due to the memory subsystem.",
+ "MetricExpr": "backend_bound * d_ratio(ex_no_retire.load_not_complete, ex_no_retire.not_complete)",
+ "MetricGroup": "PipelineL2;backend_bound_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "backend_bound_cpu",
+ "BriefDescription": "Fraction of dispatch slots that remained unused because of stalls not related to the memory subsystem.",
+ "MetricExpr": "backend_bound * (1 - d_ratio(ex_no_retire.load_not_complete, ex_no_retire.not_complete))",
+ "MetricGroup": "PipelineL2;backend_bound_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "retiring_fastpath",
+ "BriefDescription": "Fraction of dispatch slots used by fastpath ops that retired.",
+ "MetricExpr": "retiring * (1 - d_ratio(ex_ret_ucode_ops, ex_ret_ops))",
+ "MetricGroup": "PipelineL2;retiring_group",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "retiring_microcode",
+ "BriefDescription": "Fraction of dispatch slots used by microcode ops that retired.",
+ "MetricExpr": "retiring * d_ratio(ex_ret_ucode_ops, ex_ret_ops)",
+ "MetricGroup": "PipelineL2;retiring_group",
+ "ScaleUnit": "100%"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/amdzen4/recommended.json b/lib/libpmc/pmu-events/arch/x86/amdzen4/recommended.json
new file mode 100644
index 000000000000..96e06401c6cb
--- /dev/null
+++ b/lib/libpmc/pmu-events/arch/x86/amdzen4/recommended.json
@@ -0,0 +1,418 @@
+[
+ {
+ "MetricName": "branch_misprediction_ratio",
+ "BriefDescription": "Execution-time branch misprediction ratio (non-speculative).",
+ "MetricExpr": "d_ratio(ex_ret_brn_misp, ex_ret_brn)",
+ "MetricGroup": "branch_prediction",
+ "ScaleUnit": "100%"
+ },
+ {
+ "EventName": "all_data_cache_accesses",
+ "EventCode": "0x29",
+ "BriefDescription": "All data cache accesses.",
+ "UMask": "0x07"
+ },
+ {
+ "MetricName": "all_l2_cache_accesses",
+ "BriefDescription": "All L2 cache accesses.",
+ "MetricExpr": "l2_request_g1.all_no_prefetch + l2_pf_hit_l2.all + l2_pf_miss_l2_hit_l3.all + l2_pf_miss_l2_l3.all",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_accesses_from_l1_ic_misses",
+ "BriefDescription": "L2 cache accesses from L1 instruction cache misses (including prefetch).",
+ "MetricExpr": "l2_request_g1.cacheable_ic_read",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_accesses_from_l1_dc_misses",
+ "BriefDescription": "L2 cache accesses from L1 data cache misses (including prefetch).",
+ "MetricExpr": "l2_request_g1.all_dc",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_accesses_from_l2_hwpf",
+ "BriefDescription": "L2 cache accesses from L2 cache hardware prefetcher.",
+ "MetricExpr": "l2_pf_hit_l2.all + l2_pf_miss_l2_hit_l3.all + l2_pf_miss_l2_l3.all",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "all_l2_cache_misses",
+ "BriefDescription": "All L2 cache misses.",
+ "MetricExpr": "l2_cache_req_stat.ic_dc_miss_in_l2 + l2_pf_miss_l2_hit_l3.all + l2_pf_miss_l2_l3.all",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_misses_from_l1_ic_miss",
+ "BriefDescription": "L2 cache misses from L1 instruction cache misses.",
+ "MetricExpr": "l2_cache_req_stat.ic_fill_miss",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_misses_from_l1_dc_miss",
+ "BriefDescription": "L2 cache misses from L1 data cache misses.",
+ "MetricExpr": "l2_cache_req_stat.ls_rd_blk_c",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_misses_from_l2_hwpf",
+ "BriefDescription": "L2 cache misses from L2 cache hardware prefetcher.",
+ "MetricExpr": "l2_pf_miss_l2_hit_l3.all + l2_pf_miss_l2_l3.all",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "all_l2_cache_hits",
+ "BriefDescription": "All L2 cache hits.",
+ "MetricExpr": "l2_cache_req_stat.ic_dc_hit_in_l2 + l2_pf_hit_l2.all",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_hits_from_l1_ic_miss",
+ "BriefDescription": "L2 cache hits from L1 instruction cache misses.",
+ "MetricExpr": "l2_cache_req_stat.ic_hit_in_l2",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_hits_from_l1_dc_miss",
+ "BriefDescription": "L2 cache hits from L1 data cache misses.",
+ "MetricExpr": "l2_cache_req_stat.dc_hit_in_l2",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l2_cache_hits_from_l2_hwpf",
+ "BriefDescription": "L2 cache hits from L2 cache hardware prefetcher.",
+ "MetricExpr": "l2_pf_hit_l2.all",
+ "MetricGroup": "l2_cache"
+ },
+ {
+ "MetricName": "l3_cache_accesses",
+ "BriefDescription": "L3 cache accesses.",
+ "MetricExpr": "l3_lookup_state.all_coherent_accesses_to_l3",
+ "MetricGroup": "l3_cache"
+ },
+ {
+ "MetricName": "l3_misses",
+ "BriefDescription": "L3 misses (including cacheline state change requests).",
+ "MetricExpr": "l3_lookup_state.l3_miss",
+ "MetricGroup": "l3_cache"
+ },
+ {
+ "MetricName": "l3_read_miss_latency",
+ "BriefDescription": "Average L3 read miss latency (in core clocks).",
+ "MetricExpr": "(l3_xi_sampled_latency.all * 10) / l3_xi_sampled_latency_requests.all",
+ "MetricGroup": "l3_cache",
+ "ScaleUnit": "1core clocks"
+ },
+ {
+ "MetricName": "op_cache_fetch_miss_ratio",
+ "BriefDescription": "Op cache miss ratio for all fetches.",
+ "MetricExpr": "d_ratio(op_cache_hit_miss.op_cache_miss, op_cache_hit_miss.all_op_cache_accesses)",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "ic_fetch_miss_ratio",
+ "BriefDescription": "Instruction cache miss ratio for all fetches. An instruction cache miss will not be counted by this metric if it is an OC hit.",
+ "MetricExpr": "d_ratio(ic_tag_hit_miss.instruction_cache_miss, ic_tag_hit_miss.all_instruction_cache_accesses)",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "l1_data_cache_fills_from_memory",
+ "BriefDescription": "L1 data cache fills from DRAM or MMIO in any NUMA node.",
+ "MetricExpr": "ls_any_fills_from_sys.dram_io_all",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_data_cache_fills_from_remote_node",
+ "BriefDescription": "L1 data cache fills from a different NUMA node.",
+ "MetricExpr": "ls_any_fills_from_sys.far_all",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_data_cache_fills_from_same_ccx",
+ "BriefDescription": "L1 data cache fills from within the same CCX.",
+ "MetricExpr": "ls_any_fills_from_sys.local_all",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_data_cache_fills_from_different_ccx",
+ "BriefDescription": "L1 data cache fills from another CCX cache in any NUMA node.",
+ "MetricExpr": "ls_any_fills_from_sys.remote_cache",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "all_l1_data_cache_fills",
+ "BriefDescription": "All L1 data cache fills.",
+ "MetricExpr": "ls_any_fills_from_sys.all",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_demand_data_cache_fills_from_local_l2",
+ "BriefDescription": "L1 demand data cache fills from local L2 cache.",
+ "MetricExpr": "ls_dmnd_fills_from_sys.local_l2",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_demand_data_cache_fills_from_same_ccx",
+ "BriefDescription": "L1 demand data cache fills from within the same CCX.",
+ "MetricExpr": "ls_dmnd_fills_from_sys.local_ccx",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_demand_data_cache_fills_from_near_cache",
+ "BriefDescription": "L1 demand data cache fills from another CCX cache in the same NUMA node.",
+ "MetricExpr": "ls_dmnd_fills_from_sys.near_cache",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_demand_data_cache_fills_from_near_memory",
+ "BriefDescription": "L1 demand data cache fills from DRAM or MMIO in the same NUMA node.",
+ "MetricExpr": "ls_dmnd_fills_from_sys.dram_io_near",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_demand_data_cache_fills_from_far_cache",
+ "BriefDescription": "L1 demand data cache fills from another CCX cache in a different NUMA node.",
+ "MetricExpr": "ls_dmnd_fills_from_sys.far_cache",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_demand_data_cache_fills_from_far_memory",
+ "BriefDescription": "L1 demand data cache fills from DRAM or MMIO in a different NUMA node.",
+ "MetricExpr": "ls_dmnd_fills_from_sys.dram_io_far",
+ "MetricGroup": "l1_dcache"
+ },
+ {
+ "MetricName": "l1_itlb_misses",
+ "BriefDescription": "L1 instruction TLB misses.",
+ "MetricExpr": "bp_l1_tlb_miss_l2_tlb_hit + bp_l1_tlb_miss_l2_tlb_miss.all",
+ "MetricGroup": "tlb"
+ },
+ {
+ "MetricName": "l2_itlb_misses",
+ "BriefDescription": "L2 instruction TLB misses and instruction page walks.",
+ "MetricExpr": "bp_l1_tlb_miss_l2_tlb_miss.all",
+ "MetricGroup": "tlb"
+ },
+ {
+ "MetricName": "l1_dtlb_misses",
+ "BriefDescription": "L1 data TLB misses.",
+ "MetricExpr": "ls_l1_d_tlb_miss.all",
+ "MetricGroup": "tlb"
+ },
+ {
+ "MetricName": "l2_dtlb_misses",
+ "BriefDescription": "L2 data TLB misses and data page walks.",
+ "MetricExpr": "ls_l1_d_tlb_miss.all_l2_miss",
+ "MetricGroup": "tlb"
+ },
+ {
+ "MetricName": "all_tlbs_flushed",
+ "BriefDescription": "All TLBs flushed.",
+ "MetricExpr": "ls_tlb_flush.all",
+ "MetricGroup": "tlb"
+ },
+ {
+ "MetricName": "macro_ops_dispatched",
+ "BriefDescription": "Macro-ops dispatched.",
+ "MetricExpr": "de_src_op_disp.all",
+ "MetricGroup": "decoder"
+ },
+ {
+ "MetricName": "sse_avx_stalls",
+ "BriefDescription": "Mixed SSE/AVX stalls.",
+ "MetricExpr": "fp_disp_faults.sse_avx_all"
+ },
+ {
+ "MetricName": "macro_ops_retired",
+ "BriefDescription": "Macro-ops retired.",
+ "MetricExpr": "ex_ret_ops"
+ },
+ {
+ "MetricName": "dram_read_data_for_local_processor",
+ "BriefDescription": "DRAM read data for local processor.",
+ "MetricExpr": "local_processor_read_data_beats_cs0 + local_processor_read_data_beats_cs1 + local_processor_read_data_beats_cs2 + local_processor_read_data_beats_cs3 + local_processor_read_data_beats_cs4 + local_processor_read_data_beats_cs5 + local_processor_read_data_beats_cs6 + local_processor_read_data_beats_cs7 + local_processor_read_data_beats_cs8 + local_processor_read_data_beats_cs9 + local_processor_read_data_beats_cs10 + local_processor_read_data_beats_cs11",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "dram_write_data_for_local_processor",
+ "BriefDescription": "DRAM write data for local processor.",
+ "MetricExpr": "local_processor_write_data_beats_cs0 + local_processor_write_data_beats_cs1 + local_processor_write_data_beats_cs2 + local_processor_write_data_beats_cs3 + local_processor_write_data_beats_cs4 + local_processor_write_data_beats_cs5 + local_processor_write_data_beats_cs6 + local_processor_write_data_beats_cs7 + local_processor_write_data_beats_cs8 + local_processor_write_data_beats_cs9 + local_processor_write_data_beats_cs10 + local_processor_write_data_beats_cs11",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "dram_read_data_for_remote_processor",
+ "BriefDescription": "DRAM read data for remote processor.",
+ "MetricExpr": "remote_processor_read_data_beats_cs0 + remote_processor_read_data_beats_cs1 + remote_processor_read_data_beats_cs2 + remote_processor_read_data_beats_cs3 + remote_processor_read_data_beats_cs4 + remote_processor_read_data_beats_cs5 + remote_processor_read_data_beats_cs6 + remote_processor_read_data_beats_cs7 + remote_processor_read_data_beats_cs8 + remote_processor_read_data_beats_cs9 + remote_processor_read_data_beats_cs10 + remote_processor_read_data_beats_cs11",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "dram_write_data_for_remote_processor",
+ "BriefDescription": "DRAM write data for remote processor.",
+ "MetricExpr": "remote_processor_write_data_beats_cs0 + remote_processor_write_data_beats_cs1 + remote_processor_write_data_beats_cs2 + remote_processor_write_data_beats_cs3 + remote_processor_write_data_beats_cs4 + remote_processor_write_data_beats_cs5 + remote_processor_write_data_beats_cs6 + remote_processor_write_data_beats_cs7 + remote_processor_write_data_beats_cs8 + remote_processor_write_data_beats_cs9 + remote_processor_write_data_beats_cs10 + remote_processor_write_data_beats_cs11",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "local_socket_upstream_dma_read_data",
+ "BriefDescription": "Local socket upstream DMA read data.",
+ "MetricExpr": "local_socket_upstream_read_beats_iom0 + local_socket_upstream_read_beats_iom1 + local_socket_upstream_read_beats_iom2 + local_socket_upstream_read_beats_iom3",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "local_socket_upstream_dma_write_data",
+ "BriefDescription": "Local socket upstream DMA write data.",
+ "MetricExpr": "local_socket_upstream_write_beats_iom0 + local_socket_upstream_write_beats_iom1 + local_socket_upstream_write_beats_iom2 + local_socket_upstream_write_beats_iom3",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "remote_socket_upstream_dma_read_data",
+ "BriefDescription": "Remote socket upstream DMA read data.",
+ "MetricExpr": "remote_socket_upstream_read_beats_iom0 + remote_socket_upstream_read_beats_iom1 + remote_socket_upstream_read_beats_iom2 + remote_socket_upstream_read_beats_iom3",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "remote_socket_upstream_dma_write_data",
+ "BriefDescription": "Remote socket upstream DMA write data.",
+ "MetricExpr": "remote_socket_upstream_write_beats_iom0 + remote_socket_upstream_write_beats_iom1 + remote_socket_upstream_write_beats_iom2 + remote_socket_upstream_write_beats_iom3",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "local_socket_inbound_data_to_cpu",
+ "BriefDescription": "Local socket inbound data to the CPU (e.g. read data).",
+ "MetricExpr": "local_socket_inf0_inbound_data_beats_ccm0 + local_socket_inf1_inbound_data_beats_ccm0 + local_socket_inf0_inbound_data_beats_ccm1 + local_socket_inf1_inbound_data_beats_ccm1 + local_socket_inf0_inbound_data_beats_ccm2 + local_socket_inf1_inbound_data_beats_ccm2 + local_socket_inf0_inbound_data_beats_ccm3 + local_socket_inf1_inbound_data_beats_ccm3 + local_socket_inf0_inbound_data_beats_ccm4 + local_socket_inf1_inbound_data_beats_ccm4 + local_socket_inf0_inbound_data_beats_ccm5 + local_socket_inf1_inbound_data_beats_ccm5 + local_socket_inf0_inbound_data_beats_ccm6 + local_socket_inf1_inbound_data_beats_ccm6 + local_socket_inf0_inbound_data_beats_ccm7 + local_socket_inf1_inbound_data_beats_ccm7",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "3.0517578125e-5MiB"
+ },
+ {
+ "MetricName": "local_socket_outbound_data_from_cpu",
+ "BriefDescription": "Local socket outbound data from the CPU (e.g. write data).",
+ "MetricExpr": "local_socket_inf0_outbound_data_beats_ccm0 + local_socket_inf1_outbound_data_beats_ccm0 + local_socket_inf0_outbound_data_beats_ccm1 + local_socket_inf1_outbound_data_beats_ccm1 + local_socket_inf0_outbound_data_beats_ccm2 + local_socket_inf1_outbound_data_beats_ccm2 + local_socket_inf0_outbound_data_beats_ccm3 + local_socket_inf1_outbound_data_beats_ccm3 + local_socket_inf0_outbound_data_beats_ccm4 + local_socket_inf1_outbound_data_beats_ccm4 + local_socket_inf0_outbound_data_beats_ccm5 + local_socket_inf1_outbound_data_beats_ccm5 + local_socket_inf0_outbound_data_beats_ccm6 + local_socket_inf1_outbound_data_beats_ccm6 + local_socket_inf0_outbound_data_beats_ccm7 + local_socket_inf1_outbound_data_beats_ccm7",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "remote_socket_inbound_data_to_cpu",
+ "BriefDescription": "Remote socket inbound data to the CPU (e.g. read data).",
+ "MetricExpr": "remote_socket_inf0_inbound_data_beats_ccm0 + remote_socket_inf1_inbound_data_beats_ccm0 + remote_socket_inf0_inbound_data_beats_ccm1 + remote_socket_inf1_inbound_data_beats_ccm1 + remote_socket_inf0_inbound_data_beats_ccm2 + remote_socket_inf1_inbound_data_beats_ccm2 + remote_socket_inf0_inbound_data_beats_ccm3 + remote_socket_inf1_inbound_data_beats_ccm3 + remote_socket_inf0_inbound_data_beats_ccm4 + remote_socket_inf1_inbound_data_beats_ccm4 + remote_socket_inf0_inbound_data_beats_ccm5 + remote_socket_inf1_inbound_data_beats_ccm5 + remote_socket_inf0_inbound_data_beats_ccm6 + remote_socket_inf1_inbound_data_beats_ccm6 + remote_socket_inf0_inbound_data_beats_ccm7 + remote_socket_inf1_inbound_data_beats_ccm7",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "3.0517578125e-5MiB"
+ },
+ {
+ "MetricName": "remote_socket_outbound_data_from_cpu",
+ "BriefDescription": "Remote socket outbound data from the CPU (e.g. write data).",
+ "MetricExpr": "remote_socket_inf0_outbound_data_beats_ccm0 + remote_socket_inf1_outbound_data_beats_ccm0 + remote_socket_inf0_outbound_data_beats_ccm1 + remote_socket_inf1_outbound_data_beats_ccm1 + remote_socket_inf0_outbound_data_beats_ccm2 + remote_socket_inf1_outbound_data_beats_ccm2 + remote_socket_inf0_outbound_data_beats_ccm3 + remote_socket_inf1_outbound_data_beats_ccm3 + remote_socket_inf0_outbound_data_beats_ccm4 + remote_socket_inf1_outbound_data_beats_ccm4 + remote_socket_inf0_outbound_data_beats_ccm5 + remote_socket_inf1_outbound_data_beats_ccm5 + remote_socket_inf0_outbound_data_beats_ccm6 + remote_socket_inf1_outbound_data_beats_ccm6 + remote_socket_inf0_outbound_data_beats_ccm7 + remote_socket_inf1_outbound_data_beats_ccm7",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "local_socket_outbound_data_from_all_links",
+ "BriefDescription": "Outbound data from all links (local socket).",
+ "MetricExpr": "local_socket_outbound_data_beats_link0 + local_socket_outbound_data_beats_link1 + local_socket_outbound_data_beats_link2 + local_socket_outbound_data_beats_link3 + local_socket_outbound_data_beats_link4 + local_socket_outbound_data_beats_link5 + local_socket_outbound_data_beats_link6 + local_socket_outbound_data_beats_link7",
+ "MetricGroup": "data_fabric",
+ "PerPkg": "1",
+ "ScaleUnit": "6.103515625e-5MiB"
+ },
+ {
+ "MetricName": "umc_data_bus_utilization",
+ "BriefDescription": "Memory controller data bus utilization.",
+ "MetricExpr": "d_ratio(umc_data_slot_clks.all / 2, umc_mem_clk)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "umc_cas_cmd_rate",
+ "BriefDescription": "Memory controller CAS command rate.",
+ "MetricExpr": "d_ratio(umc_cas_cmd.all * 1000, umc_mem_clk)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1"
+ },
+ {
+ "MetricName": "umc_cas_cmd_read_ratio",
+ "BriefDescription": "Ratio of memory controller CAS commands for reads.",
+ "MetricExpr": "d_ratio(umc_cas_cmd.rd, umc_cas_cmd.all)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "umc_cas_cmd_write_ratio",
+ "BriefDescription": "Ratio of memory controller CAS commands for writes.",
+ "MetricExpr": "d_ratio(umc_cas_cmd.wr, umc_cas_cmd.all)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "umc_mem_read_bandwidth",
+ "BriefDescription": "Estimated memory read bandwidth.",
+ "MetricExpr": "(umc_cas_cmd.rd * 64) / 1e6 / duration_time",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "1MB/s"
+ },
+ {
+ "MetricName": "umc_mem_write_bandwidth",
+ "BriefDescription": "Estimated memory write bandwidth.",
+ "MetricExpr": "(umc_cas_cmd.wr * 64) / 1e6 / duration_time",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "1MB/s"
+ },
+ {
+ "MetricName": "umc_mem_bandwidth",
+ "BriefDescription": "Estimated combined memory bandwidth.",
+ "MetricExpr": "(umc_cas_cmd.all * 64) / 1e6 / duration_time",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "1MB/s"
+ },
+ {
+ "MetricName": "umc_cas_cmd_read_ratio",
+ "BriefDescription": "Ratio of memory controller CAS commands for reads.",
+ "MetricExpr": "d_ratio(umc_cas_cmd.rd, umc_cas_cmd.all)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1",
+ "ScaleUnit": "100%"
+ },
+ {
+ "MetricName": "umc_cas_cmd_rate",
+ "BriefDescription": "Memory controller CAS command rate.",
+ "MetricExpr": "d_ratio(umc_cas_cmd.all * 1000, umc_mem_clk)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1"
+ },
+ {
+ "MetricName": "umc_activate_cmd_rate",
+ "BriefDescription": "Memory controller ACTIVATE command rate.",
+ "MetricExpr": "d_ratio(umc_act_cmd.all * 1000, umc_mem_clk)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1"
+ },
+ {
+ "MetricName": "umc_precharge_cmd_rate",
+ "BriefDescription": "Memory controller PRECHARGE command rate.",
+ "MetricExpr": "d_ratio(umc_pchg_cmd.all * 1000, umc_mem_clk)",
+ "MetricGroup": "memory_controller",
+ "PerPkg": "1"
+ }
+]
diff --git a/lib/libpmc/pmu-events/arch/x86/mapfile.csv b/lib/libpmc/pmu-events/arch/x86/mapfile.csv
index 6fbaab06bf72..7a9fe8c59cb2 100644
--- a/lib/libpmc/pmu-events/arch/x86/mapfile.csv
+++ b/lib/libpmc/pmu-events/arch/x86/mapfile.csv
@@ -45,8 +45,12 @@ GenuineIntel-6-86,v1,tremontx,core
GenuineIntel-6-96,v1,elkhartlake,core
GenuineIntel-6-97,v1,alderlake,core
GenuineIntel-6-9A,v1,alderlake,core
+GenuineIntel-6-B7,v1,alderlake,core
+GenuineIntel-6-BA,v1,alderlake,core
+GenuineIntel-6-BF,v1,alderlake,core
GenuineIntel-6-8F,v1,sapphirerapids,core
AuthenticAMD-23-[012][0-9A-F],v2,amdzen1,core
AuthenticAMD-23-[[:xdigit:]]+,v1,amdzen2,core
-AuthenticAMD-25-[[:xdigit:]]+,v1,amdzen3,core
+AuthenticAMD-25-[0245][[:xdigit:]],v1,amdzen3,core
+AuthenticAMD-25-[[:xdigit:]]+,v1,amdzen4,core
HygonGenuine-24-00,v2,amdzen1,core
diff --git a/lib/libpmc/pmu-events/jevents.c b/lib/libpmc/pmu-events/jevents.c
index ff7d3b226932..628ed26c6f9d 100644
--- a/lib/libpmc/pmu-events/jevents.c
+++ b/lib/libpmc/pmu-events/jevents.c
@@ -1355,7 +1355,11 @@ err_out:
#include <fts.h>
static int
+#if defined(__linux__) || defined(__APPLE__)
+fts_compare(const FTSENT **a, const FTSENT **b)
+#else
fts_compare(const FTSENT * const *a, const FTSENT * const *b)
+#endif
{
return (strcmp((*a)->fts_name, (*b)->fts_name));
}
diff --git a/lib/libpmcstat/libpmcstat_event.c b/lib/libpmcstat/libpmcstat_event.c
index c964537ad2a1..80daa0fff0fd 100644
--- a/lib/libpmcstat/libpmcstat_event.c
+++ b/lib/libpmcstat/libpmcstat_event.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/pmc.h>
diff --git a/lib/libpmcstat/libpmcstat_image.c b/lib/libpmcstat/libpmcstat_image.c
index f8f76bfc148b..69274dca31e8 100644
--- a/lib/libpmcstat/libpmcstat_image.c
+++ b/lib/libpmcstat/libpmcstat_image.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/param.h>
@@ -194,6 +193,14 @@ pmcstat_image_link(struct pmcstat_process *pp, struct pmcstat_image *image,
assert(image->pi_type != PMCSTAT_IMAGE_UNKNOWN &&
image->pi_type != PMCSTAT_IMAGE_INDETERMINABLE);
+ /*
+ * It's possible to have images with nothing of value in .text
+ * legitimately. We shouldn't have any samples from this image, so
+ * don't bother with a map entry either.
+ */
+ if (image->pi_start == 0 && image->pi_end == 0)
+ return;
+
if ((pcmnew = malloc(sizeof(*pcmnew))) == NULL)
err(EX_OSERR, "ERROR: Cannot create a map entry");
diff --git a/lib/libpmcstat/libpmcstat_logging.c b/lib/libpmcstat/libpmcstat_logging.c
index 3e68824f0f0c..f30170cbbb9d 100644
--- a/lib/libpmcstat/libpmcstat_logging.c
+++ b/lib/libpmcstat/libpmcstat_logging.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/param.h>
diff --git a/lib/libpmcstat/libpmcstat_process.c b/lib/libpmcstat/libpmcstat_process.c
index 6d000fe2fc61..4e104730538e 100644
--- a/lib/libpmcstat/libpmcstat_process.c
+++ b/lib/libpmcstat/libpmcstat_process.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/event.h>
diff --git a/lib/libpmcstat/libpmcstat_string.c b/lib/libpmcstat/libpmcstat_string.c
index dc48617b99b9..7ebf1bf2817a 100644
--- a/lib/libpmcstat/libpmcstat_string.c
+++ b/lib/libpmcstat/libpmcstat_string.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/param.h>
diff --git a/lib/libpmcstat/libpmcstat_symbol.c b/lib/libpmcstat/libpmcstat_symbol.c
index 05040b1f304b..b77124287a74 100644
--- a/lib/libpmcstat/libpmcstat_symbol.c
+++ b/lib/libpmcstat/libpmcstat_symbol.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/event.h>
diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
index 67c4e642ea00..785007188255 100644
--- a/lib/libproc/Makefile
+++ b/lib/libproc/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
LIB= proc
@@ -24,7 +23,7 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
-CFLAGS+= -DHAVE_ISSETUGID -DHAVE_BOOLEAN
+CFLAGS+= -DHAVE_ISSETUGID -DHAVE_BOOLEAN -DHAVE_STRLCAT -DHAVE_STRLCPY
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libctf/common \
-I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common \
-I${SRCTOP}/sys/cddl/compat/opensolaris
diff --git a/lib/libproc/Makefile.inc b/lib/libproc/Makefile.inc
index d3b5cbd3a79b..01b5f23410c8 100644
--- a/lib/libproc/Makefile.inc
+++ b/lib/libproc/Makefile.inc
@@ -1,2 +1 @@
-
.include "../Makefile.inc"
diff --git a/lib/libproc/libproc.h b/lib/libproc/libproc.h
index 38a4faff94d5..a77bdbb35b59 100644
--- a/lib/libproc/libproc.h
+++ b/lib/libproc/libproc.h
@@ -105,8 +105,6 @@ typedef enum {
REG_RVAL2
} proc_reg_t;
-#define SIG2STR_MAX 8
-
typedef struct lwpstatus {
int pr_why;
#define PR_REQUESTED 1 /* not implemented */
diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c
index 25ff3a86291d..8649da178bb9 100644
--- a/lib/libproc/proc_bkpt.c
+++ b/lib/libproc/proc_bkpt.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Rui Paulo under sponsorship from the
* FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
diff --git a/lib/libproc/proc_create.c b/lib/libproc/proc_create.c
index 9acee3682e45..0b10b186b8ca 100644
--- a/lib/libproc/proc_create.c
+++ b/lib/libproc/proc_create.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/user.h>
diff --git a/lib/libproc/proc_regs.c b/lib/libproc/proc_regs.c
index 492fbf712ef5..8d41233ec108 100644
--- a/lib/libproc/proc_regs.c
+++ b/lib/libproc/proc_regs.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Rui Paulo under sponsorship from the
* FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ptrace.h>
diff --git a/lib/libproc/proc_rtld.c b/lib/libproc/proc_rtld.c
index db17c2b02b95..1d6fc732933a 100644
--- a/lib/libproc/proc_rtld.c
+++ b/lib/libproc/proc_rtld.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Rui Paulo under sponsorship from the
* FreeBSD Foundation.
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c
index 1bb34bdaac67..be932b12a24f 100644
--- a/lib/libproc/proc_sym.c
+++ b/lib/libproc/proc_sym.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#ifndef NO_CTF
#include <sys/ctf.h>
diff --git a/lib/libproc/proc_util.c b/lib/libproc/proc_util.c
index 9af627422ef8..a062b9a1f461 100644
--- a/lib/libproc/proc_util.c
+++ b/lib/libproc/proc_util.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
@@ -38,6 +37,7 @@
#include <err.h>
#include <errno.h>
#include <signal.h>
+#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -181,8 +181,12 @@ proc_getwstat(struct proc_handle *phdl)
char *
proc_signame(int sig, char *name, size_t namesz)
{
+ char buf[SIG2STR_MAX];
- strlcpy(name, strsignal(sig), namesz);
+ if (sig2str(sig, buf) == 0)
+ (void)snprintf(name, namesz, "SIG%s", buf);
+ else
+ (void)snprintf(name, namesz, "SIG#%d", sig);
return (name);
}
diff --git a/lib/libproc/tests/Makefile b/lib/libproc/tests/Makefile
index 8e1d7c4d91c7..9467cc634884 100644
--- a/lib/libproc/tests/Makefile
+++ b/lib/libproc/tests/Makefile
@@ -1,4 +1,3 @@
-
ATF_TESTS_C+= proc_test
PROGS= target_prog
diff --git a/lib/libproc/tests/proc_test.c b/lib/libproc/tests/proc_test.c
index ba1535940b81..e7fc90f29905 100644
--- a/lib/libproc/tests/proc_test.c
+++ b/lib/libproc/tests/proc_test.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
index 0c8d1b63488b..e20518910ba3 100644
--- a/lib/libprocstat/Makefile
+++ b/lib/libprocstat/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
LIB= procstat
@@ -53,20 +52,23 @@ MLINKS+=libprocstat.3 procstat_close.3 \
libprocstat.3 procstat_open_kvm.3 \
libprocstat.3 procstat_open_sysctl.3
-# XXX This is a hack.
.if ${MK_CDDL} != "no"
CFLAGS+= -DLIBPROCSTAT_ZFS
SRCS+= zfs.c
-OBJS+= zfs/zfs_defs.o
-SUBDIR= zfs
-zfs/zfs_defs.o: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.o
-zfs/zfs_defs.pico: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.pico
-zfs/zfs_defs.pieo: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.pieo
-zfs/zfs_defs.po: .PHONY
- @cd ${.CURDIR}/zfs && ${MAKE} zfs_defs.po
+ZFSTOP= ${SRCTOP}/sys/contrib/openzfs
+CFLAGS.zfs.c+= -DIN_BASE
+CFLAGS.zfs.c+= -DHAVE_ISSETUGID
+CFLAGS.zfs.c+= -DZFS_DEBUG
+CFLAGS.zfs.c+= -I${ZFSTOP}/include
+CFLAGS.zfs.c+= -I${ZFSTOP}/lib/libspl/include
+CFLAGS.zfs.c+= -I${ZFSTOP}/lib/libspl/include/os/freebsd
+CFLAGS.zfs.c+= -I${ZFSTOP}/include/os/freebsd/zfs
+CFLAGS.zfs.c+= -I${ZFSTOP}/module/icp/include
+CFLAGS.zfs.c+= -I${SRCTOP}/sys
+CFLAGS.zfs.c+= -I${SRCTOP}/sys/modules/zfs
+CFLAGS.zfs.c+= -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h
+CFLAGS.zfs.c+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h
+CFLAGS.zfs.c+= -Wno-cast-qual
.endif
.include <bsd.lib.mk>
diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map
index 4c8a0c7edefb..3d71c3eaae4a 100644
--- a/lib/libprocstat/Symbol.map
+++ b/lib/libprocstat/Symbol.map
@@ -47,4 +47,11 @@ FBSD_1.6 {
FBSD_1.7 {
procstat_getadvlock;
procstat_freeadvlock;
+};
+
+FBSD_1.8 {
+ procstat_get_kqueue_info;
+ procstat_getrlimitusage;
+ procstat_freekqinfo;
+ procstat_freerlimitusage;
}; \ No newline at end of file
diff --git a/lib/libprocstat/cd9660.c b/lib/libprocstat/cd9660.c
index 0d0030715c28..ec37f49df0f6 100644
--- a/lib/libprocstat/cd9660.c
+++ b/lib/libprocstat/cd9660.c
@@ -42,7 +42,6 @@
* conflicts with UFS.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -53,9 +52,8 @@
#include <err.h>
-#define _KERNEL
+#define _WANT_ISO_MNT
#include <isofs/cd9660/iso.h>
-#undef _KERNEL
#include <isofs/cd9660/cd9660_node.h>
#include <kvm.h>
diff --git a/lib/libprocstat/common_kvm.c b/lib/libprocstat/common_kvm.c
index 9d96d935be6a..a129605e7fa0 100644
--- a/lib/libprocstat/common_kvm.c
+++ b/lib/libprocstat/common_kvm.c
@@ -34,7 +34,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/user.h>
#include <sys/stat.h>
diff --git a/lib/libprocstat/core.c b/lib/libprocstat/core.c
index dea078c848eb..b27b35de3bab 100644
--- a/lib/libprocstat/core.c
+++ b/lib/libprocstat/core.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/elf.h>
#include <sys/exec.h>
@@ -58,22 +57,62 @@ struct procstat_core
GElf_Phdr pc_phdr;
};
-static struct psc_type_info {
+static const struct psc_type_info {
unsigned int n_type;
int structsize;
} psc_type_info[PSC_TYPE_MAX] = {
- { .n_type = NT_PROCSTAT_PROC, .structsize = sizeof(struct kinfo_proc) },
- { .n_type = NT_PROCSTAT_FILES, .structsize = sizeof(struct kinfo_file) },
- { .n_type = NT_PROCSTAT_VMMAP, .structsize = sizeof(struct kinfo_vmentry) },
- { .n_type = NT_PROCSTAT_GROUPS, .structsize = sizeof(gid_t) },
- { .n_type = NT_PROCSTAT_UMASK, .structsize = sizeof(u_short) },
- { .n_type = NT_PROCSTAT_RLIMIT, .structsize = sizeof(struct rlimit) * RLIM_NLIMITS },
- { .n_type = NT_PROCSTAT_OSREL, .structsize = sizeof(int) },
- { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) },
- { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) },
- { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) },
- { .n_type = NT_PROCSTAT_AUXV, .structsize = sizeof(Elf_Auxinfo) },
- { .n_type = NT_PTLWPINFO, .structsize = sizeof(struct ptrace_lwpinfo) },
+ [PSC_TYPE_PROC] = {
+ .n_type = NT_PROCSTAT_PROC,
+ .structsize = sizeof(struct kinfo_proc)
+ },
+ [PSC_TYPE_FILES] = {
+ .n_type = NT_PROCSTAT_FILES,
+ .structsize = sizeof(struct kinfo_file)
+ },
+ [PSC_TYPE_VMMAP] = {
+ .n_type = NT_PROCSTAT_VMMAP,
+ .structsize = sizeof(struct kinfo_vmentry)
+ },
+ [PSC_TYPE_GROUPS] = {
+ .n_type = NT_PROCSTAT_GROUPS,
+ .structsize = sizeof(gid_t)
+ },
+ [PSC_TYPE_UMASK] = {
+ .n_type = NT_PROCSTAT_UMASK,
+ .structsize = sizeof(u_short)
+ },
+ [PSC_TYPE_RLIMIT] = {
+ .n_type = NT_PROCSTAT_RLIMIT,
+ .structsize = sizeof(struct rlimit) * RLIM_NLIMITS
+ },
+ [PSC_TYPE_OSREL] = {
+ .n_type = NT_PROCSTAT_OSREL,
+ .structsize = sizeof(int)
+ },
+ [PSC_TYPE_PSSTRINGS] = {
+ .n_type = NT_PROCSTAT_PSSTRINGS,
+ .structsize = sizeof(vm_offset_t)
+ },
+ [PSC_TYPE_ARGV] = {
+ .n_type = NT_PROCSTAT_PSSTRINGS,
+ .structsize = sizeof(vm_offset_t)
+ },
+ [PSC_TYPE_ENVV] = {
+ .n_type = NT_PROCSTAT_PSSTRINGS,
+ .structsize = sizeof(vm_offset_t)
+ },
+ [PSC_TYPE_AUXV] = {
+ .n_type = NT_PROCSTAT_AUXV,
+ .structsize = sizeof(Elf_Auxinfo)
+ },
+ [PSC_TYPE_PTLWPINFO] = {
+ .n_type = NT_PTLWPINFO,
+ .structsize = sizeof(struct ptrace_lwpinfo)
+ },
+ [PSC_TYPE_KQUEUES] = {
+ .n_type = NT_PROCSTAT_KQUEUES,
+ .structsize = sizeof(struct kinfo_knote)
+ },
};
static bool core_offset(struct procstat_core *core, off_t offset);
@@ -119,7 +158,7 @@ procstat_core_open(const char *filename)
warnx("%s is not a CORE file", filename);
goto fail;
}
- if (elf_getphnum(e, &nph) == 0) {
+ if (elf_getphdrnum(e, &nph) == -1) {
warnx("program headers not found");
goto fail;
}
diff --git a/lib/libprocstat/core.h b/lib/libprocstat/core.h
index d6cb60dc9e25..f4276fbdf09e 100644
--- a/lib/libprocstat/core.h
+++ b/lib/libprocstat/core.h
@@ -31,7 +31,7 @@
#define _CORE_H
enum psc_type {
- PSC_TYPE_PROC,
+ PSC_TYPE_PROC = 0,
PSC_TYPE_FILES,
PSC_TYPE_VMMAP,
PSC_TYPE_GROUPS,
@@ -43,6 +43,7 @@ enum psc_type {
PSC_TYPE_ENVV,
PSC_TYPE_AUXV,
PSC_TYPE_PTLWPINFO,
+ PSC_TYPE_KQUEUES,
PSC_TYPE_MAX
};
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index 0af79b6e63a0..eb8137f6c76f 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -35,7 +35,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/elf.h>
#include <sys/time.h>
@@ -51,6 +50,7 @@
#define _WANT_SOCKET
#include <sys/socketvar.h>
#include <sys/domain.h>
+#define _WANT_PROTOSW
#include <sys/protosw.h>
#include <sys/un.h>
#define _WANT_UNPCB
@@ -84,8 +84,6 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#define _WANT_INPCB
-#include <netinet/in_pcb.h>
#include <assert.h>
#include <ctype.h>
@@ -347,7 +345,7 @@ struct filestat_list *
procstat_getfiles(struct procstat *procstat, struct kinfo_proc *kp, int mmapped)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
return (procstat_getfiles_kvm(procstat, kp, mmapped));
case PROCSTAT_SYSCTL:
@@ -627,6 +625,10 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
type = PS_FST_TYPE_EVENTFD;
data = file.f_data;
break;
+ case DTYPE_INOTIFY:
+ type = PS_FST_TYPE_INOTIFY;
+ data = file.f_data;
+ break;
default:
continue;
}
@@ -719,6 +721,7 @@ kinfo_type2fst(int kftype)
{ KF_TYPE_SOCKET, PS_FST_TYPE_SOCKET },
{ KF_TYPE_VNODE, PS_FST_TYPE_VNODE },
{ KF_TYPE_EVENTFD, PS_FST_TYPE_EVENTFD },
+ { KF_TYPE_INOTIFY, PS_FST_TYPE_INOTIFY },
{ KF_TYPE_UNKNOWN, PS_FST_TYPE_UNKNOWN }
};
#define NKFTYPES (sizeof(kftypes2fst) / sizeof(*kftypes2fst))
@@ -1474,7 +1477,6 @@ procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
struct sockstat *sock, char *errbuf)
{
struct domain dom;
- struct inpcb inpcb;
struct protosw proto;
struct socket s;
struct unpcb unpcb;
@@ -1523,28 +1525,15 @@ procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
sock->proto = proto.pr_protocol;
sock->dom_family = dom.dom_family;
sock->so_pcb = (uintptr_t)s.so_pcb;
+ sock->sendq = s.so_snd.sb_ccc;
+ sock->recvq = s.so_rcv.sb_ccc;
+ sock->so_rcv_sb_state = s.so_rcv.sb_state;
+ sock->so_snd_sb_state = s.so_snd.sb_state;
/*
* Protocol specific data.
*/
- switch(dom.dom_family) {
- case AF_INET:
- case AF_INET6:
- if (proto.pr_protocol == IPPROTO_TCP) {
- if (s.so_pcb) {
- if (kvm_read(kd, (u_long)s.so_pcb,
- (char *)&inpcb, sizeof(struct inpcb))
- != sizeof(struct inpcb)) {
- warnx("can't read inpcb at %p",
- (void *)s.so_pcb);
- } else
- sock->inp_ppcb =
- (uintptr_t)inpcb.inp_ppcb;
- sock->sendq = s.so_snd.sb_ccc;
- sock->recvq = s.so_rcv.sb_ccc;
- }
- }
- break;
+ switch (dom.dom_family) {
case AF_UNIX:
if (s.so_pcb) {
if (kvm_read(kd, (u_long)s.so_pcb, (char *)&unpcb,
@@ -1552,11 +1541,7 @@ procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
warnx("can't read unpcb at %p",
(void *)s.so_pcb);
} else if (unpcb.unp_conn) {
- sock->so_rcv_sb_state = s.so_rcv.sb_state;
- sock->so_snd_sb_state = s.so_snd.sb_state;
sock->unp_conn = (uintptr_t)unpcb.unp_conn;
- sock->sendq = s.so_snd.sb_ccc;
- sock->recvq = s.so_rcv.sb_ccc;
}
}
break;
@@ -1600,11 +1585,10 @@ procstat_get_socket_info_sysctl(struct filestat *fst, struct sockstat *sock,
/*
* Protocol specific data.
*/
- switch(sock->dom_family) {
+ switch (sock->dom_family) {
case AF_INET:
case AF_INET6:
if (sock->proto == IPPROTO_TCP) {
- sock->inp_ppcb = kif->kf_un.kf_sock.kf_sock_inpcb;
sock->sendq = kif->kf_un.kf_sock.kf_sock_sendq;
sock->recvq = kif->kf_un.kf_sock.kf_sock_recvq;
}
@@ -1961,7 +1945,7 @@ procstat_getvmmap(struct procstat *procstat, struct kinfo_proc *kp,
unsigned int *cntp)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
warnx("kvm method is not supported");
return (NULL);
@@ -2066,7 +2050,7 @@ gid_t *
procstat_getgroups(struct procstat *procstat, struct kinfo_proc *kp,
unsigned int *cntp)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
return (procstat_getgroups_kvm(procstat->kd, kp, cntp));
case PROCSTAT_SYSCTL:
@@ -2144,7 +2128,7 @@ int
procstat_getumask(struct procstat *procstat, struct kinfo_proc *kp,
unsigned short *maskp)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
return (procstat_getumask_kvm(procstat->kd, kp, maskp));
case PROCSTAT_SYSCTL:
@@ -2234,7 +2218,7 @@ int
procstat_getrlimit(struct procstat *procstat, struct kinfo_proc *kp, int which,
struct rlimit* rlimit)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
return (procstat_getrlimit_kvm(procstat->kd, kp, which,
rlimit));
@@ -2293,7 +2277,7 @@ int
procstat_getpathname(struct procstat *procstat, struct kinfo_proc *kp,
char *pathname, size_t maxlen)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
/* XXX: Return empty string. */
if (maxlen > 0)
@@ -2366,7 +2350,7 @@ procstat_getosrel_core(struct procstat_core *core, int *osrelp)
int
procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp, int *osrelp)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
return (procstat_getosrel_kvm(procstat->kd, kp, osrelp));
case PROCSTAT_SYSCTL:
@@ -2381,7 +2365,7 @@ procstat_getosrel(struct procstat *procstat, struct kinfo_proc *kp, int *osrelp)
#define PROC_AUXV_MAX 256
-#if __ELF_WORD_SIZE == 64
+#ifdef PS_ARCH_HAS_FREEBSD32
static const char *elf32_sv_names[] = {
"Linux ELF32",
"FreeBSD ELF32",
@@ -2392,7 +2376,7 @@ is_elf32_sysctl(pid_t pid)
{
int error, name[4];
size_t len, i;
- static char sv_name[256];
+ char sv_name[32];
name[0] = CTL_KERN;
name[1] = KERN_PROC;
@@ -2414,7 +2398,6 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
{
Elf_Auxinfo *auxv;
Elf32_Auxinfo *auxv32;
- void *ptr;
size_t len;
unsigned int i, count;
int name[4];
@@ -2435,8 +2418,8 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
warn("sysctl: kern.proc.auxv: %d: %d", pid, errno);
goto out;
}
- count = len / sizeof(Elf_Auxinfo);
- auxv = malloc(count * sizeof(Elf_Auxinfo));
+ count = len / sizeof(Elf32_Auxinfo);
+ auxv = malloc(count * sizeof(Elf_Auxinfo));
if (auxv == NULL) {
warn("malloc(%zu)", count * sizeof(Elf_Auxinfo));
goto out;
@@ -2448,15 +2431,24 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
* necessarily true.
*/
auxv[i].a_type = auxv32[i].a_type;
- ptr = &auxv32[i].a_un;
- auxv[i].a_un.a_val = *((uint32_t *)ptr);
+ /*
+ * Don't sign extend values. Existing entries are positive
+ * integers or pointers. Under freebsd32, programs typically
+ * have a full [0, 2^32) address space (perhaps minus the last
+ * page) and treating this as a signed integer would be
+ * confusing since these are not kernel pointers.
+ *
+ * XXX: A more complete translation would be ABI and
+ * type-aware.
+ */
+ auxv[i].a_un.a_val = (uint32_t)auxv32[i].a_un.a_val;
}
*cntp = count;
out:
free(auxv32);
return (auxv);
}
-#endif /* __ELF_WORD_SIZE == 64 */
+#endif /* PS_ARCH_HAS_FREEBSD32 */
static Elf_Auxinfo *
procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp)
@@ -2465,7 +2457,7 @@ procstat_getauxv_sysctl(pid_t pid, unsigned int *cntp)
int name[4];
size_t len;
-#if __ELF_WORD_SIZE == 64
+#ifdef PS_ARCH_HAS_FREEBSD32
if (is_elf32_sysctl(pid))
return (procstat_getauxv32_sysctl(pid, cntp));
#endif
@@ -2506,7 +2498,7 @@ Elf_Auxinfo *
procstat_getauxv(struct procstat *procstat, struct kinfo_proc *kp,
unsigned int *cntp)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
warnx("kvm method is not supported");
return (NULL);
@@ -2620,7 +2612,7 @@ struct kinfo_kstack *
procstat_getkstack(struct procstat *procstat, struct kinfo_proc *kp,
unsigned int *cntp)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
warnx("kvm method is not supported");
return (NULL);
@@ -2749,7 +2741,7 @@ fail:
struct advlock_list *
procstat_getadvlock(struct procstat *procstat)
{
- switch(procstat->type) {
+ switch (procstat->type) {
case PROCSTAT_KVM:
warnx("kvm method is not supported");
return (NULL);
@@ -2777,3 +2769,151 @@ procstat_freeadvlock(struct procstat *procstat __unused,
free(lst);
}
+static rlim_t *
+procstat_getrlimitusage_sysctl(pid_t pid, unsigned *cntp)
+{
+ int error, name[4];
+ rlim_t *val;
+ size_t len;
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_RLIMIT_USAGE;
+ name[3] = pid;
+
+ len = 0;
+ error = sysctl(name, nitems(name), NULL, &len, NULL, 0);
+ if (error == -1)
+ return (NULL);
+ val = malloc(len);
+ if (val == NULL)
+ return (NULL);
+
+ error = sysctl(name, nitems(name), val, &len, NULL, 0);
+ if (error == -1) {
+ free(val);
+ return (NULL);
+ }
+ *cntp = len / sizeof(rlim_t);
+ return (val);
+}
+
+rlim_t *
+procstat_getrlimitusage(struct procstat *procstat, struct kinfo_proc *kp,
+ unsigned int *cntp)
+{
+ switch (procstat->type) {
+ case PROCSTAT_KVM:
+ warnx("kvm method is not supported");
+ return (NULL);
+ case PROCSTAT_SYSCTL:
+ return (procstat_getrlimitusage_sysctl(kp->ki_pid, cntp));
+ case PROCSTAT_CORE:
+ warnx("core method is not supported");
+ return (NULL);
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+}
+
+void
+procstat_freerlimitusage(struct procstat *procstat __unused, rlim_t *resusage)
+{
+ free(resusage);
+}
+
+static struct kinfo_knote *
+procstat_get_kqueue_info_sysctl(pid_t pid, int kqfd, unsigned int *cntp,
+ char *errbuf)
+{
+ int error, name[5];
+ struct kinfo_knote *val;
+ size_t len;
+
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_KQUEUE;
+ name[3] = pid;
+ name[4] = kqfd;
+
+ len = 0;
+ error = sysctl(name, nitems(name), NULL, &len, NULL, 0);
+ if (error == -1) {
+ snprintf(errbuf, _POSIX2_LINE_MAX,
+ "KERN_PROC_KQUEUE.pid<%d>.kq<%d> (size q) failed: %s",
+ pid, kqfd, strerror(errno));
+ return (NULL);
+ }
+ val = malloc(len);
+ if (val == NULL) {
+ snprintf(errbuf, _POSIX2_LINE_MAX, "no memory");
+ return (NULL);
+ }
+
+ error = sysctl(name, nitems(name), val, &len, NULL, 0);
+ if (error == -1) {
+ snprintf(errbuf, _POSIX2_LINE_MAX,
+ "KERN_PROC_KQUEUE.pid<%d>.kq<%d> failed: %s",
+ pid, kqfd, strerror(errno));
+ free(val);
+ return (NULL);
+ }
+ *cntp = len / sizeof(*val);
+ return (val);
+}
+
+struct kinfo_knote *
+procstat_get_kqueue_info(struct procstat *procstat,
+ struct kinfo_proc *kp, int kqfd, unsigned int *count, char *errbuf)
+{
+ struct kinfo_knote *kn, *k, *res, *rn;
+ size_t len, kqn;
+
+ switch (procstat->type) {
+ case PROCSTAT_KVM:
+ warnx("kvm method is not supported");
+ return (NULL);
+ case PROCSTAT_SYSCTL:
+ return (procstat_get_kqueue_info_sysctl(kp->ki_pid, kqfd,
+ count, errbuf));
+ case PROCSTAT_CORE:
+ k = procstat_core_get(procstat->core, PSC_TYPE_KQUEUES,
+ NULL, &len);
+ if (k == NULL) {
+ snprintf(errbuf, _POSIX2_LINE_MAX,
+ "getting NT_PROCSTAT_KQUEUES note failed");
+ *count = 0;
+ return (NULL);
+ }
+ for (kqn = 0, kn = k; kn < k + len / sizeof(*kn); kn++) {
+ if (kn->knt_kq_fd == kqfd)
+ kqn++;
+ }
+ res = calloc(kqn, sizeof(*res));
+ if (res == NULL) {
+ free(k);
+ snprintf(errbuf, _POSIX2_LINE_MAX,
+ "no memory");
+ return (NULL);
+ }
+ for (kn = k, rn = res; kn < k + len / sizeof(*kn); kn++) {
+ if (kn->knt_kq_fd != kqfd)
+ continue;
+ *rn = *kn;
+ rn++;
+ }
+ *count = kqn;
+ free(k);
+ return (res);
+ default:
+ warnx("unknown access method: %d", procstat->type);
+ return (NULL);
+ }
+}
+
+void
+procstat_freekqinfo(struct procstat *procstat __unused, struct kinfo_knote *v)
+{
+ free(v);
+}
diff --git a/lib/libprocstat/libprocstat.h b/lib/libprocstat/libprocstat.h
index 0df01817663e..548747f90171 100644
--- a/lib/libprocstat/libprocstat.h
+++ b/lib/libprocstat/libprocstat.h
@@ -71,6 +71,7 @@
#define PS_FST_TYPE_PROCDESC 13
#define PS_FST_TYPE_DEV 14
#define PS_FST_TYPE_EVENTFD 15
+#define PS_FST_TYPE_INOTIFY 16
/*
* Special descriptor numbers.
@@ -102,9 +103,15 @@
#define PS_FST_FFLAG_EXEC 0x2000
#define PS_FST_FFLAG_HASLOCK 0x4000
+#if !defined(__ILP32__) && !defined(__riscv)
+/* Target architecture supports 32-bit compat */
+#define PS_ARCH_HAS_FREEBSD32 1
+#endif
+
struct kinfo_kstack;
struct kinfo_proc;
struct kinfo_vmentry;
+struct kinfo_knote;
struct procstat;
struct ptrace_lwpinfo;
struct rlimit;
@@ -149,7 +156,6 @@ struct shmstat {
uint16_t mode;
};
struct sockstat {
- uint64_t inp_ppcb;
uint64_t so_addr;
uint64_t so_pcb;
uint64_t unp_conn;
@@ -200,6 +206,7 @@ void procstat_freeauxv(struct procstat *procstat, Elf_Auxinfo *auxv);
#endif
void procstat_freeenvv(struct procstat *procstat);
void procstat_freegroups(struct procstat *procstat, gid_t *groups);
+void procstat_freekqinfo(struct procstat *procstat, struct kinfo_knote *kni);
void procstat_freekstack(struct procstat *procstat,
struct kinfo_kstack *kkstp);
void procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p);
@@ -207,6 +214,7 @@ void procstat_freefiles(struct procstat *procstat,
struct filestat_list *head);
void procstat_freeptlwpinfo(struct procstat *procstat,
struct ptrace_lwpinfo *pl);
+void procstat_freerlimitusage(struct procstat *procstat, rlim_t *resusage);
void procstat_freevmmap(struct procstat *procstat,
struct kinfo_vmentry *vmmap);
struct advlock_list *procstat_getadvlock(struct procstat *procstat);
@@ -214,6 +222,8 @@ struct filestat_list *procstat_getfiles(struct procstat *procstat,
struct kinfo_proc *kp, int mmapped);
struct kinfo_proc *procstat_getprocs(struct procstat *procstat,
int what, int arg, unsigned int *count);
+struct kinfo_knote *procstat_get_kqueue_info(struct procstat *procstat,
+ struct kinfo_proc *kp, int kqfd, unsigned int *count, char *errbuf);
int procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
struct pipestat *pipe, char *errbuf);
int procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
@@ -246,6 +256,8 @@ int procstat_getpathname(struct procstat *procstat, struct kinfo_proc *kp,
char *pathname, size_t maxlen);
int procstat_getrlimit(struct procstat *procstat, struct kinfo_proc *kp,
int which, struct rlimit* rlimit);
+rlim_t *procstat_getrlimitusage(struct procstat *procstat,
+ struct kinfo_proc *kp, unsigned int *cntp);
int procstat_getumask(struct procstat *procstat, struct kinfo_proc *kp,
unsigned short* umask);
struct kinfo_vmentry *procstat_getvmmap(struct procstat *procstat,
diff --git a/lib/libprocstat/libprocstat_compat.c b/lib/libprocstat/libprocstat_compat.c
index 58c4ce0d2558..63eb35678752 100644
--- a/lib/libprocstat/libprocstat_compat.c
+++ b/lib/libprocstat/libprocstat_compat.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/user.h>
#include <sys/socket.h>
@@ -183,7 +182,7 @@ freebsd11_procstat_get_socket_info(struct procstat *procstat, struct filestat *f
r = procstat_get_socket_info(procstat, fst, &sock, errbuf);
if (r != 0)
return (r);
- sock_compat->inp_ppcb = sock.inp_ppcb;
+ sock_compat->inp_ppcb = sock.so_pcb;
sock_compat->so_addr = sock.so_addr;
sock_compat->so_pcb = sock.so_pcb;
sock_compat->unp_conn = sock.unp_conn;
diff --git a/lib/libprocstat/msdosfs.c b/lib/libprocstat/msdosfs.c
index bb1ad65e6b1a..01345bb8d334 100644
--- a/lib/libprocstat/msdosfs.c
+++ b/lib/libprocstat/msdosfs.c
@@ -44,17 +44,15 @@
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/vnode.h>
+#include <sys/mount.h>
#include <netinet/in.h>
-#define _KERNEL
-#include <sys/mount.h>
+#define _WANT_MSDOSFS_INTERNALS
#include <fs/msdosfs/bpb.h>
#include <fs/msdosfs/msdosfsmount.h>
-#undef _KERNEL
-
-#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/direntry.h>
+#include <fs/msdosfs/denode.h>
#include <fs/msdosfs/fat.h>
#include <err.h>
@@ -62,13 +60,6 @@
#include <stdio.h>
#include <stdlib.h>
-/*
- * XXX -
- * VTODE is defined in denode.h only if _KERNEL is defined, but that leads to
- * header explosion
- */
-#define VTODE(vp) ((struct denode *)getvnodedata(vp))
-
#include "libprocstat.h"
#include "common_kvm.h"
diff --git a/lib/libprocstat/smbfs.c b/lib/libprocstat/smbfs.c
index 136cceacb471..cbd32cf8f597 100644
--- a/lib/libprocstat/smbfs.c
+++ b/lib/libprocstat/smbfs.c
@@ -32,9 +32,8 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
-#define _KERNEL
+#define _WANT_MOUNT
#include <sys/mount.h>
-#undef _KERNEL
#include <netinet/in.h>
diff --git a/lib/libprocstat/udf.c b/lib/libprocstat/udf.c
index 9a110950f8b0..3298af6dec5f 100644
--- a/lib/libprocstat/udf.c
+++ b/lib/libprocstat/udf.c
@@ -32,9 +32,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/vnode.h>
-#define _KERNEL
#include <sys/mount.h>
-#undef _KERNEL
#include <netinet/in.h>
diff --git a/lib/libprocstat/zfs.c b/lib/libprocstat/zfs.c
index 422f923ac15c..6dc23d7573fd 100644
--- a/lib/libprocstat/zfs.c
+++ b/lib/libprocstat/zfs.c
@@ -26,37 +26,36 @@
* SUCH DAMAGE.
*/
-#include <stdbool.h>
-
#include <sys/param.h>
-#define _KERNEL
+#define _WANT_MOUNT
#include <sys/mount.h>
-#undef _KERNEL
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/vnode.h>
+#define _WANT_ZNODE
+#include <sys/zfs_context.h>
+#include <sys/zfs_znode.h>
#include <netinet/in.h>
#include <err.h>
#include <kvm.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define ZFS
#include "libprocstat.h"
#include "common_kvm.h"
-#include "zfs_defs.h"
int
zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
{
struct mount mount, *mountptr;
- void *znodeptr;
- char *dataptr;
+ znode_t *kznodeptr, *znode;
size_t len;
int size;
@@ -65,27 +64,30 @@ zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
warnx("error getting sysctl");
return (1);
}
- dataptr = malloc(size);
- if (dataptr == NULL) {
+ znode = malloc(size);
+ if (znode == NULL) {
warnx("error allocating memory for znode storage");
return (1);
}
- if ((size_t)size < offsetof_z_id + sizeof(uint64_t) ||
- (size_t)size < offsetof_z_mode + sizeof(mode_t) ||
- (size_t)size < offsetof_z_size + sizeof(uint64_t)) {
+ if ((size_t)size != sizeof(znode_t))
+ warnx("znode_t size mismatch, data could be wrong");
+
+ if ((size_t)size < offsetof(znode_t, z_id) + sizeof(znode->z_id) ||
+ (size_t)size < offsetof(znode_t, z_mode) + sizeof(znode->z_mode) ||
+ (size_t)size < offsetof(znode_t, z_size) + sizeof(znode->z_size)) {
warnx("znode_t size is too small");
goto bad;
}
- if ((size_t)size != sizeof_znode_t)
- warnx("znode_t size mismatch, data could be wrong");
-
- /* Since we have problems including vnode.h, we'll use the wrappers. */
- znodeptr = getvnodedata(vp);
- if (!kvm_read_all(kd, (unsigned long)znodeptr, dataptr,
- (size_t)size)) {
- warnx("can't read znode at %p", (void *)znodeptr);
+ /*
+ * OpenZFS's libspl provides a dummy sys/vnode.h that shadows ours so
+ * struct vnode is an incomplete type. Use the wrapper until that is
+ * resolved.
+ */
+ kznodeptr = getvnodedata(vp);
+ if (!kvm_read_all(kd, (unsigned long)kznodeptr, znode, (size_t)size)) {
+ warnx("can't read znode at %p", (void *)kznodeptr);
goto bad;
}
@@ -101,12 +103,10 @@ zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
* under .zfs/.
*/
vn->vn_fsid = mount.mnt_stat.f_fsid.val[0];
- vn->vn_fileid = *(uint64_t *)(void *)(dataptr + offsetof_z_id);
- vn->vn_mode = *(mode_t *)(void *)(dataptr + offsetof_z_mode);
- vn->vn_size = *(uint64_t *)(void *)(dataptr + offsetof_z_size);
- free(dataptr);
+ vn->vn_fileid = znode->z_id;
+ vn->vn_mode = znode->z_mode;
+ vn->vn_size = znode->z_size;
return (0);
bad:
- free(dataptr);
return (1);
}
diff --git a/lib/libprocstat/zfs/Makefile b/lib/libprocstat/zfs/Makefile
deleted file mode 100644
index da689fdd3e81..000000000000
--- a/lib/libprocstat/zfs/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-
-.PATH: ${.CURDIR:H}
-
-SRCS= zfs_defs.c
-OBJS= zfs_defs.o
-WARNS?= 1
-
-
-CFLAGS+= -DIN_BASE -D__KERNEL__ -D_KERNEL -I. -I${.CURDIR}
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs
-CFLAGS+= -I${SRCTOP}/sys/contrib/ck/include
-
-CFLAGS+= -I${SRCTOP}/sys -I. -I..
-CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include
-CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
-CFLAGS+= -DHAVE_ISSETUGID -D_SYS_VMEM_H_ -UKLD_TIED -DKLD_MODULE
-
-CFLAGS+= -fno-builtin -nostdlib
-
-all: ${OBJS}
-CLEANFILES= ${OBJS}
-
-.include <bsd.lib.mk>
diff --git a/lib/libprocstat/zfs_defs.c b/lib/libprocstat/zfs_defs.c
deleted file mode 100644
index c03c99249f42..000000000000
--- a/lib/libprocstat/zfs_defs.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-/*
- * Prevent some headers from getting included and fake some types
- * in order to allow this file to compile without bringing in
- * too many kernel build dependencies.
- */
-#define _OPENSOLARIS_SYS_PATHNAME_H_
-#define _OPENSOLARIS_SYS_POLICY_H_
-#define _VNODE_PAGER_
-
-
-enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD,
- VMARKER };
-
-/*
- * Vnode attributes. A field value of VNOVAL represents a field whose value
- * is unavailable (getattr) or which is not to be changed (setattr).
- */
-struct vattr {
- enum vtype va_type; /* vnode type (for create) */
- u_short va_mode; /* files access mode and type */
- u_short va_padding0;
- uid_t va_uid; /* owner user id */
- gid_t va_gid; /* owner group id */
- nlink_t va_nlink; /* number of references to file */
- dev_t va_fsid; /* filesystem id */
- ino_t va_fileid; /* file id */
- u_quad_t va_size; /* file size in bytes */
- long va_blocksize; /* blocksize preferred for i/o */
- struct timespec va_atime; /* time of last access */
- struct timespec va_mtime; /* time of last modification */
- struct timespec va_ctime; /* time file changed */
- struct timespec va_birthtime; /* time file created */
- u_long va_gen; /* generation number of file */
- u_long va_flags; /* flags defined for file */
- dev_t va_rdev; /* device the special file represents */
- u_quad_t va_bytes; /* bytes of disk space held by file */
- u_quad_t va_filerev; /* file modification number */
- u_int va_vaflags; /* operations flags, see below */
- long va_spare; /* remain quad aligned */
-};
-
-#define _WANT_MOUNT
-#include <sys/zfs_context.h>
-#include <sys/zfs_znode.h>
-
-size_t sizeof_znode_t = sizeof(znode_t);
-size_t offsetof_z_id = offsetof(znode_t, z_id);
-size_t offsetof_z_size = offsetof(znode_t, z_size);
-size_t offsetof_z_mode = offsetof(znode_t, z_mode);
-
-/* Keep pcpu.h satisfied. */
-uintptr_t *__start_set_pcpu;
-uintptr_t *__stop_set_pcpu;
diff --git a/lib/libprocstat/zfs_defs.h b/lib/libprocstat/zfs_defs.h
deleted file mode 100644
index de17efba5630..000000000000
--- a/lib/libprocstat/zfs_defs.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2020 Andriy Gapon <avg@FreeBSD.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.
- *
- * 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.
- */
-
-#ifndef _LIBPROCSTAT_ZFS_DEFS_H
-#define _LIBPROCSTAT_ZFS_DEFS_H
-
-extern size_t sizeof_znode_t;
-extern size_t offsetof_z_id;
-extern size_t offsetof_z_size;
-extern size_t offsetof_z_mode;
-
-#endif /* _LIBPROCSTAT_ZFS_DEFS_H */
diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
index 2049468f455f..f45eb923774b 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -321,8 +320,10 @@ is_valid_request(struct rad_handle *h)
hctx = HMAC_CTX_new();
while (pos < len - 2) {
alen = h->in[pos + 1];
- if (alen < 2)
+ if (alen < 2) {
+ HMAC_CTX_free(hctx);
return (0);
+ }
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
if (len - pos < MD5_DIGEST_LENGTH + 2) {
HMAC_CTX_free(hctx);
diff --git a/lib/libregex/Makefile b/lib/libregex/Makefile
index 555559b9db58..beffa476ca98 100644
--- a/lib/libregex/Makefile
+++ b/lib/libregex/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= runtime
diff --git a/lib/libregex/Makefile.depend b/lib/libregex/Makefile.depend
index e69de29bb2d1..6ef78fac5cbf 100644
--- a/lib/libregex/Makefile.depend
+++ b/lib/libregex/Makefile.depend
@@ -0,0 +1,15 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libregex/tests/Makefile b/lib/libregex/tests/Makefile
index 9c4a1aac89e8..7c6820f70a45 100644
--- a/lib/libregex/tests/Makefile
+++ b/lib/libregex/tests/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/regex
diff --git a/lib/librpcsec_gss/Makefile b/lib/librpcsec_gss/Makefile
index eca805e7dae9..a29d9780c1ab 100644
--- a/lib/librpcsec_gss/Makefile
+++ b/lib/librpcsec_gss/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
LIB= rpcsec_gss
SHLIB_MAJOR= 1
@@ -12,7 +11,6 @@ SYMBOL_MAPS= ${.CURDIR}/Symbol.map
CFLAGS+= -I${SRCTOP}/include
CFLAGS+= -I${SRCTOP}/lib/libc_rpc
-MK_PROFILE= no
MAN= rpcsec_gss.3
MAN+= rpc_gss_seccreate.3
diff --git a/lib/librpcsec_gss/Symbol.map b/lib/librpcsec_gss/Symbol.map
index 28f66eefd8ea..6c05937193f6 100644
--- a/lib/librpcsec_gss/Symbol.map
+++ b/lib/librpcsec_gss/Symbol.map
@@ -5,7 +5,6 @@ FBSD_1.1 {
rpc_gss_set_defaults;
rpc_gss_max_data_length;
rpc_gss_get_error;
- rpc_gss_mesh_to_oid;
rpc_gss_oid_to_mech;
rpc_gss_qop_to_num;
rpc_gss_get_mechanisms;
@@ -21,7 +20,5 @@ FBSD_1.1 {
FBSDprivate_1.0 {
__rpc_gss_unwrap;
- __rpc_gss_unwrap_stub;
__rpc_gss_wrap;
- __rpc_gss_wrap_stub;
};
diff --git a/lib/librpcsvc/Makefile b/lib/librpcsvc/Makefile
index 03d146ff05c4..bdd01c91adab 100644
--- a/lib/librpcsvc/Makefile
+++ b/lib/librpcsvc/Makefile
@@ -1,5 +1,3 @@
-# from: @(#)Makefile 5.10 (Berkeley) 6/24/90
-
.include <src.opts.mk>
.PATH: ${SRCTOP}/include/rpcsvc
diff --git a/lib/librpcsvc/rnusers.c b/lib/librpcsvc/rnusers.c
index 19e8e30988a0..47f7b1857c08 100644
--- a/lib/librpcsvc/rnusers.c
+++ b/lib/librpcsvc/rnusers.c
@@ -29,9 +29,6 @@
*/
#include <sys/cdefs.h>
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rnusers.c 1.2 91/03/11 TIRPC 1.0; from 1.7 89/03/24 SMI";
-#endif
/*
* rnusers.c
diff --git a/lib/librpcsvc/rstat.c b/lib/librpcsvc/rstat.c
index 777525dfa90c..92d46009c5e3 100644
--- a/lib/librpcsvc/rstat.c
+++ b/lib/librpcsvc/rstat.c
@@ -29,9 +29,6 @@
*/
#include <sys/cdefs.h>
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rstat.c 1.2 91/03/11 TIRPC 1.0; from 1.6 89/03/24 SMI";
-#endif
/*
* Copyright (c) 1985 by Sun Microsystems, Inc.
diff --git a/lib/librpcsvc/rwall.c b/lib/librpcsvc/rwall.c
index 7d1422a75715..0c7c2e545fc3 100644
--- a/lib/librpcsvc/rwall.c
+++ b/lib/librpcsvc/rwall.c
@@ -29,9 +29,6 @@
*/
#include <sys/cdefs.h>
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)rwall.c 1.2 91/03/11 TIRPC 1.0; from 1.3 89/03/24 SMI";
-#endif
/*
* Copyright (c) 1985 by Sun Microsystems, Inc.
diff --git a/lib/librpcsvc/secretkey.c b/lib/librpcsvc/secretkey.c
index 62148d0c404c..89de42a8b08d 100644
--- a/lib/librpcsvc/secretkey.c
+++ b/lib/librpcsvc/secretkey.c
@@ -29,9 +29,6 @@
*/
#include <sys/cdefs.h>
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)secretkey.c 1.8 91/03/11 Copyr 1986 Sun Micro";
-#endif
/*
* secretkey.c
diff --git a/lib/librss/Makefile b/lib/librss/Makefile
index 57caa2bb81ab..b851485a9239 100644
--- a/lib/librss/Makefile
+++ b/lib/librss/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= lib${LIB}
SHLIBDIR?= /lib
diff --git a/lib/librss/librss.3 b/lib/librss/librss.3
index 655e5ca17984..3964aa36891b 100644
--- a/lib/librss/librss.3
+++ b/lib/librss/librss.3
@@ -109,8 +109,8 @@ socket.
The
.Fn rss_sock_set_recvrss
function enables or disables receiving RSS related information
-as socket options in.
-.2 recvmsg
+as socket options in
+.Xr recvmsg 2
calls.
.Pp
When enabled, UDP datagrams will have a message with the
diff --git a/lib/librss/librss.c b/lib/librss/librss.c
index d52b00fbf276..fe3d36592427 100644
--- a/lib/librss/librss.c
+++ b/lib/librss/librss.c
@@ -24,7 +24,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/lib/librt/Makefile.depend b/lib/librt/Makefile.depend
index 577dc5747f1e..9ae14bd71d4f 100644
--- a/lib/librt/Makefile.depend
+++ b/lib/librt/Makefile.depend
@@ -6,6 +6,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libsys \
lib/libthr \
diff --git a/lib/librt/aio.c b/lib/librt/aio.c
index 346d91d5fae8..b47fb2f7399d 100644
--- a/lib/librt/aio.c
+++ b/lib/librt/aio.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/aio.h>
diff --git a/lib/librt/mq.c b/lib/librt/mq.c
index 48ae0e9009f8..eba52f76c928 100644
--- a/lib/librt/mq.c
+++ b/lib/librt/mq.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/mqueue.h>
@@ -41,18 +40,6 @@
#include "un-namespace.h"
#include "libc_private.h"
-extern int __sys_kmq_notify(int, const struct sigevent *);
-extern int __sys_kmq_open(const char *, int, mode_t,
- const struct mq_attr *);
-extern int __sys_kmq_setattr(int, const struct mq_attr *__restrict,
- struct mq_attr *__restrict);
-extern ssize_t __sys_kmq_timedreceive(int, char *__restrict, size_t,
- unsigned *__restrict, const struct timespec *__restrict);
-extern int __sys_kmq_timedsend(int, const char *, size_t, unsigned,
- const struct timespec *);
-extern int __sys_kmq_unlink(const char *);
-extern int __sys_close(int fd);
-
struct __mq {
int oshandle;
struct sigev_node *node;
diff --git a/lib/librt/tests/Makefile b/lib/librt/tests/Makefile
index 1be361d603c3..abbd439fb9e3 100644
--- a/lib/librt/tests/Makefile
+++ b/lib/librt/tests/Makefile
@@ -1,4 +1,3 @@
-
LIBADD= rt
NETBSD_ATF_TESTS_C= sched_test
diff --git a/lib/librt/timer.c b/lib/librt/timer.c
index bf1dd87b8294..2d83a0ba61c9 100644
--- a/lib/librt/timer.c
+++ b/lib/librt/timer.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/syscall.h>
diff --git a/lib/librtld_db/Makefile b/lib/librtld_db/Makefile
index 7a30d55bec7c..a79a32f57157 100644
--- a/lib/librtld_db/Makefile
+++ b/lib/librtld_db/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
LIB= rtld_db
diff --git a/lib/librtld_db/librtld_db.3 b/lib/librtld_db/librtld_db.3
index 041cc2cfa67b..07e1b67c096b 100644
--- a/lib/librtld_db/librtld_db.3
+++ b/lib/librtld_db/librtld_db.3
@@ -1,6 +1,5 @@
.\"-
.\" Copyright (c) 2010 The FreeBSD Foundation
-.\" All rights reserved.
.\"
.\" This software was developed by Rui Paulo under sponsorship from
.\" the FreeBSD Foundation.
diff --git a/lib/librtld_db/rtld_db.c b/lib/librtld_db/rtld_db.c
index 2546f572780d..0d2adf88e089 100644
--- a/lib/librtld_db/rtld_db.c
+++ b/lib/librtld_db/rtld_db.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Rui Paulo under sponsorship from the
* FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
diff --git a/lib/librtld_db/rtld_db.h b/lib/librtld_db/rtld_db.h
index 24dc18a9a0ba..41aa7409fbf3 100644
--- a/lib/librtld_db/rtld_db.h
+++ b/lib/librtld_db/rtld_db.h
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2010 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Rui Paulo under sponsorship from the
* FreeBSD Foundation.
diff --git a/lib/libsamplerate/Makefile b/lib/libsamplerate/Makefile
new file mode 100644
index 000000000000..256f2087284f
--- /dev/null
+++ b/lib/libsamplerate/Makefile
@@ -0,0 +1,18 @@
+.PATH: ${SRCTOP}/contrib/libsamplerate
+
+LIB= samplerate
+INTERNALLIB=
+
+SRCS= samplerate.c \
+ src_linear.c \
+ src_sinc.c \
+ src_zoh.c
+
+INCS= samplerate.h
+
+CFLAGS+= -DENABLE_SINC_BEST_CONVERTER \
+ -DENABLE_SINC_MEDIUM_CONVERTER \
+ -DENABLE_SINC_FAST_CONVERTER \
+ -I${SRCTOP}/contrib/libsamplerate
+
+.include <bsd.lib.mk>
diff --git a/lib/libsbuf/Makefile b/lib/libsbuf/Makefile
index bf800265031a..cc0fef31be43 100644
--- a/lib/libsbuf/Makefile
+++ b/lib/libsbuf/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
LIB= sbuf
diff --git a/lib/libsbuf/tests/Makefile b/lib/libsbuf/tests/Makefile
index 07b93f67fed6..512ca678cac3 100644
--- a/lib/libsbuf/tests/Makefile
+++ b/lib/libsbuf/tests/Makefile
@@ -1,4 +1,3 @@
-
ATF_TESTS_C+= sbuf_core_test
ATF_TESTS_C+= sbuf_stdio_test
ATF_TESTS_C+= sbuf_string_test
diff --git a/lib/libsbuf/tests/sbuf_core_test.c b/lib/libsbuf/tests/sbuf_core_test.c
index 1ed320316510..14bbc475043a 100644
--- a/lib/libsbuf/tests/sbuf_core_test.c
+++ b/lib/libsbuf/tests/sbuf_core_test.c
@@ -23,9 +23,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sbuf.h>
+
+#include <atf-c.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -33,12 +34,10 @@
#include <string.h>
#include <unistd.h>
-#include <atf-c.h>
-
#include "sbuf_test_common.h"
-static char test_string[] = "this is a test string";
-#define TEST_STRING_CHOP_COUNT 5
+static char test_string[] = "this is a test string";
+#define TEST_STRING_CHOP_COUNT 5
_Static_assert(nitems(test_string) > TEST_STRING_CHOP_COUNT,
"test_string is too short");
@@ -76,8 +75,8 @@ ATF_TC_BODY(sbuf_clear_test, tc)
buf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(buf_len == 0, "sbuf_len (%zd) != 0", buf_len);
- ATF_REQUIRE_STREQ_MSG(sbuf_data(sb), "",
- "sbuf (\"%s\") was not empty", sbuf_data(sb));
+ ATF_REQUIRE_STREQ_MSG(sbuf_data(sb), "", "sbuf (\"%s\") was not empty",
+ sbuf_data(sb));
sbuf_delete(sb);
}
@@ -104,7 +103,6 @@ ATF_TC_BODY(sbuf_done_and_sbuf_finish_test, tc)
static int
drain_ret0(void *arg, const char *data, int len)
{
-
(void)arg;
(void)data;
(void)len;
@@ -145,10 +143,11 @@ ATF_TC_BODY(sbuf_len_test, tc)
buf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(buf_len == (ssize_t)(i * test_string_len),
"sbuf_len (%zd) != %zu", buf_len, i * test_string_len);
- ATF_REQUIRE_MSG(sbuf_cat(sb, test_string) == 0, "sbuf_cat failed");
+ ATF_REQUIRE_MSG(sbuf_cat(sb, test_string) == 0,
+ "sbuf_cat failed");
}
-#ifdef HAVE_SBUF_SET_FLAGS
+#ifdef HAVE_SBUF_SET_FLAGS
sbuf_set_flags(sb, SBUF_INCLUDENUL);
ATF_REQUIRE_MSG((ssize_t)(i * test_string_len + 1) == sbuf_len(sb),
"sbuf_len(..) didn't report the NUL char");
@@ -173,8 +172,8 @@ ATF_TC_BODY(sbuf_new_fixedlen, tc)
child_proc = atf_utils_fork();
if (child_proc == 0) {
- ATF_REQUIRE_EQ_MSG(0, sbuf_finish(&sb), "sbuf_finish failed: %s",
- strerror(errno));
+ ATF_REQUIRE_EQ_MSG(0, sbuf_finish(&sb),
+ "sbuf_finish failed: %s", strerror(errno));
sbuf_putbuf(&sb);
exit(0);
@@ -183,7 +182,8 @@ ATF_TC_BODY(sbuf_new_fixedlen, tc)
sbuf_putc(&sb, ' ');
- ATF_CHECK_EQ_MSG(-1, sbuf_finish(&sb), "failed to return error on overflow");
+ ATF_CHECK_EQ_MSG(-1, sbuf_finish(&sb),
+ "failed to return error on overflow");
sbuf_delete(&sb);
}
@@ -244,7 +244,6 @@ ATF_TC_BODY(sbuf_setpos_test, tc)
ATF_TP_ADD_TCS(tp)
{
-
ATF_TP_ADD_TC(tp, sbuf_clear_test);
ATF_TP_ADD_TC(tp, sbuf_done_and_sbuf_finish_test);
ATF_TP_ADD_TC(tp, sbuf_drain_ret0_test);
@@ -252,15 +251,15 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, sbuf_new_fixedlen);
#if 0
/* TODO */
-#ifdef HAVE_SBUF_CLEAR_FLAGS
+#ifdef HAVE_SBUF_CLEAR_FLAGS
ATF_TP_ADD_TC(tp, sbuf_clear_flags_test);
#endif
-#ifdef HAVE_SBUF_GET_FLAGS
+#ifdef HAVE_SBUF_GET_FLAGS
ATF_TP_ADD_TC(tp, sbuf_get_flags_test);
#endif
ATF_TP_ADD_TC(tp, sbuf_new_positive_test);
ATF_TP_ADD_TC(tp, sbuf_new_negative_test);
-#ifdef HAVE_SBUF_SET_FLAGS
+#ifdef HAVE_SBUF_SET_FLAGS
ATF_TP_ADD_TC(tp, sbuf_set_flags_test);
#endif
#endif
diff --git a/lib/libsbuf/tests/sbuf_stdio_test.c b/lib/libsbuf/tests/sbuf_stdio_test.c
index 5bf32c674901..8d8e01a962b9 100644
--- a/lib/libsbuf/tests/sbuf_stdio_test.c
+++ b/lib/libsbuf/tests/sbuf_stdio_test.c
@@ -23,9 +23,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sbuf.h>
+
+#include <atf-c.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -33,17 +34,15 @@
#include <string.h>
#include <unistd.h>
-#include <atf-c.h>
-
#include "sbuf_test_common.h"
-static char test_string[] = "this is a test string";
+static char test_string[] = "this is a test string";
-#define MESSAGE_FORMAT "message: %s\n"
-#define MESSAGE_SEPARATOR ';'
+#define MESSAGE_FORMAT "message: %s\n"
+#define MESSAGE_SEPARATOR ';'
static int
-sbuf_vprintf_helper(struct sbuf *sb, const char * restrict format, ...)
+sbuf_vprintf_helper(struct sbuf *sb, const char *restrict format, ...)
{
va_list ap;
int rc;
@@ -117,8 +116,8 @@ ATF_TC_BODY(sbuf_printf_test, tc)
struct sbuf *sb;
char *test_string_tmp;
- asprintf(&test_string_tmp, "%s%c" MESSAGE_FORMAT,
- test_string, MESSAGE_SEPARATOR, test_string);
+ asprintf(&test_string_tmp, "%s%c" MESSAGE_FORMAT, test_string,
+ MESSAGE_SEPARATOR, test_string);
ATF_REQUIRE_MSG(test_string_tmp != NULL, "asprintf failed");
sb = sbuf_new_auto();
@@ -177,8 +176,8 @@ ATF_TC_BODY(sbuf_vprintf_test, tc)
char *test_string_tmp;
int rc;
- asprintf(&test_string_tmp, "%s%c" MESSAGE_FORMAT,
- test_string, MESSAGE_SEPARATOR, test_string);
+ asprintf(&test_string_tmp, "%s%c" MESSAGE_FORMAT, test_string,
+ MESSAGE_SEPARATOR, test_string);
ATF_REQUIRE_MSG(test_string_tmp != NULL, "asprintf failed");
sb = sbuf_new_auto();
@@ -204,7 +203,6 @@ ATF_TC_BODY(sbuf_vprintf_test, tc)
ATF_TP_ADD_TCS(tp)
{
-
ATF_TP_ADD_TC(tp, sbuf_printf_drain_null_test);
ATF_TP_ADD_TC(tp, sbuf_printf_drain_test);
ATF_TP_ADD_TC(tp, sbuf_printf_test);
diff --git a/lib/libsbuf/tests/sbuf_string_test.c b/lib/libsbuf/tests/sbuf_string_test.c
index 9deccc572692..fddaaac9886a 100644
--- a/lib/libsbuf/tests/sbuf_string_test.c
+++ b/lib/libsbuf/tests/sbuf_string_test.c
@@ -23,31 +23,35 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sbuf.h>
+
+#include <atf-c.h>
#include <errno.h>
#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <atf-c.h>
-
#include "sbuf_test_common.h"
-static char test_string[] = "this is a test string";
-static char test_whitespace_string[] = " \f\n\r\t\v ";
-static int test_buffer[] = { 0, 1, 2, 3, 4, 5, };
+static char test_string[] = "this is a test string";
+static char test_whitespace_string[] = " \f\n\r\t\v ";
+static int test_buffer[] = {
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+};
static void
check_buffers_equal(const void *sb_buf, const void *test_buf, size_t len)
{
-
if (memcmp(sb_buf, test_buf, len) != 0) {
printf("sbuf:\n");
- hexdump(sb_buf, len, NULL, 0),
- printf("test_buf:\n");
+ hexdump(sb_buf, len, NULL, 0), printf("test_buf:\n");
hexdump(test_buf, len, NULL, 0);
atf_tc_fail("contents of sbuf didn't match test_buf contents");
}
@@ -76,16 +80,16 @@ ATF_TC_BODY(sbuf_bcat_test, tc)
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)sizeof(test_buffer),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, sizeof(test_buffer));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ sizeof(test_buffer));
ATF_CHECK_MSG(sbuf_bcat(sb, test_buffer, sizeof(test_buffer)) == 0,
"sbuf_bcat failed");
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)(2 * sizeof(test_buffer)),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, 2 * sizeof(test_buffer));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ 2 * sizeof(test_buffer));
ATF_REQUIRE_MSG(sbuf_finish(sb) == 0, "sbuf_finish failed: %s",
strerror(errno));
@@ -113,16 +117,16 @@ ATF_TC_BODY(sbuf_bcpy_test, tc)
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)sizeof(test_buffer),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, sizeof(test_buffer));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ sizeof(test_buffer));
ATF_CHECK_MSG(sbuf_bcpy(sb, test_buffer, sizeof(test_buffer)) == 0,
"sbuf_bcpy failed");
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)sizeof(test_buffer),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, sizeof(test_buffer));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ sizeof(test_buffer));
ATF_REQUIRE_MSG(sbuf_finish(sb) == 0, "sbuf_finish failed: %s",
strerror(errno));
@@ -150,15 +154,15 @@ ATF_TC_BODY(sbuf_cat_test, tc)
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)strlen(test_string),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, sizeof(test_string));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ sizeof(test_string));
ATF_CHECK_MSG(sbuf_cat(sb, test_string) == 0, "sbuf_cat failed");
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)strlen(test_string_tmp),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, strlen(test_string_tmp));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ strlen(test_string_tmp));
ATF_REQUIRE_MSG(sbuf_finish(sb) == 0, "sbuf_finish failed: %s",
strerror(errno));
@@ -186,15 +190,15 @@ ATF_TC_BODY(sbuf_cpy_test, tc)
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)strlen(test_string),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, strlen(test_string));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ strlen(test_string));
ATF_CHECK_MSG(sbuf_cpy(sb, test_string) == 0, "sbuf_cpy failed");
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(test_sbuf_len == (ssize_t)strlen(test_string),
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, strlen(test_string));
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ strlen(test_string));
ATF_REQUIRE_MSG(sbuf_finish(sb) == 0, "sbuf_finish failed: %s",
strerror(errno));
@@ -217,7 +221,7 @@ ATF_TC_BODY(sbuf_putc_test, tc)
ATF_REQUIRE_MSG(sb != NULL, "sbuf_new_auto failed: %s",
strerror(errno));
- for (i = 0; i <= strlen(test_string); i++) { /* Include the NUL */
+ for (i = 0; i <= strlen(test_string); i++) { /* Include the NUL */
ATF_REQUIRE_MSG(sbuf_putc(sb, test_string[i]) == 0,
"sbuf_putc failed");
@@ -257,8 +261,8 @@ ATF_TC_BODY(sbuf_trim_test, tc)
strlen(test_whitespace_string));
test_sbuf_len = sbuf_len(sb);
ATF_REQUIRE_MSG(exp_sbuf_len == test_sbuf_len,
- "sbuf_len(..) => %zd (actual) != %zu (expected)",
- test_sbuf_len, exp_sbuf_len);
+ "sbuf_len(..) => %zd (actual) != %zu (expected)", test_sbuf_len,
+ exp_sbuf_len);
ATF_REQUIRE_MSG(sbuf_trim(sb) == 0, "sbuf_trim failed");
@@ -274,7 +278,6 @@ ATF_TC_BODY(sbuf_trim_test, tc)
ATF_TP_ADD_TCS(tp)
{
-
ATF_TP_ADD_TC(tp, sbuf_bcat_test);
ATF_TP_ADD_TC(tp, sbuf_bcpy_test);
ATF_TP_ADD_TC(tp, sbuf_cat_test);
diff --git a/lib/libsecureboot/Makefile b/lib/libsecureboot/Makefile
index 3ae4d5e69a52..85167e57abf2 100644
--- a/lib/libsecureboot/Makefile
+++ b/lib/libsecureboot/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
LIB= secureboot
diff --git a/lib/libsecureboot/Makefile.inc b/lib/libsecureboot/Makefile.inc
index ff40b919bad3..21ad019a0cb5 100644
--- a/lib/libsecureboot/Makefile.inc
+++ b/lib/libsecureboot/Makefile.inc
@@ -1,4 +1,3 @@
-
.if empty(BEARSSL)
.include "../libbearssl/Makefile.inc"
.endif
@@ -58,6 +57,10 @@ _2ndLAST_PEM_USE: .USE
sed -n "`grep -n .-BEGIN ${.ALLSRC:M*.pem} | tail -2 | \
sed 's,:.*,,' | xargs | (read a b; echo $$a,$$(($$b - 1)))`p" ${.ALLSRC:M*.pem} > ${.TARGET}
+# rules to populate the [tv]*.pem files we use to generate ta.h
+# and can add/alter VE_*_LIST as desired.
+.-include "local.trust.mk"
+
# list of hashes we support
VE_HASH_LIST?= SHA256
@@ -74,16 +77,16 @@ VE_SIGNATURE_EXT_LIST?= sig
# needs to be yes for FIPS 140-2 compliance
VE_SELF_TESTS?= no
-# rules to populate the [tv]*.pem files we use to generate ta.h
-# and can add/alter VE_*_LIST as desired.
-.-include "local.trust.mk"
+CFLAGS+= -I.
+.if ${VE_SIGNATURE_EXT_LIST:M*sig} != ""
# this is what we use as our trust anchor
-CFLAGS+= -I. -DTRUST_ANCHOR_STR=ta_PEM
+CFLAGS+= -DTRUST_ANCHOR_STR=ta_PEM
.if ${VE_SELF_TESTS} != "no"
XCFLAGS.vets+= -DVERIFY_CERTS_STR=vc_PEM
.endif
+.endif
# clean these up
VE_HASH_LIST:= ${VE_HASH_LIST:tu:O:u}
diff --git a/lib/libsecureboot/Makefile.libsa.inc b/lib/libsecureboot/Makefile.libsa.inc
index 76e0a91bc20a..7397d0fc1144 100644
--- a/lib/libsecureboot/Makefile.libsa.inc
+++ b/lib/libsecureboot/Makefile.libsa.inc
@@ -1,4 +1,3 @@
-
BRSSL_CFLAGS+= -DNO_STDIO
.include "Makefile.inc"
@@ -46,9 +45,12 @@ manifests.h:
echo '${VE_MANIFEST_LIST:@m@"$m",${.newline}@}'; \
echo 'NULL };' ) > ${.TARGET}
+# only add these if set
XCFLAGS.verify_file+= \
- -DVE_DEBUG_LEVEL=${VE_DEBUG_LEVEL:U0} \
- -DVE_VERBOSE_DEFAULT=${VE_VERBOSE_DEFAULT:U0} \
+ ${VE_DEBUG_LEVEL \
+ VE_VERBOSE_DEFAULT \
+ VE_VERIFY_FLAGS \
+ :L:@v@${$v:S,^,-D$v=,}@}
.if !empty(MANIFEST_SKIP_ALWAYS)
XCFLAGS.verify_file+= -DMANIFEST_SKIP_ALWAYS=\"${MANIFEST_SKIP_ALWAYS}\"
diff --git a/lib/libsecureboot/README.rst b/lib/libsecureboot/README.rst
index 85b949db58cc..f1d3c5679d35 100644
--- a/lib/libsecureboot/README.rst
+++ b/lib/libsecureboot/README.rst
@@ -1,7 +1,8 @@
libsecureboot
*************
-This library depends one way or another on verifying digital signatures.
+This library depends one way or another on verifying detached digital
+signatures.
To do that, the necessary trust anchors need to be available.
The simplest (and most attractive for an embedded system) is to
@@ -16,7 +17,7 @@ provide access to the necessary trust anchors.
That signing server is freely available - see
http://www.crufty.net/sjg/docs/signing-server.htm
-X.509 certificates chains offer a lot of flexibility over time and are
+X.509 certificate chains offer a lot of flexibility over time and are
a great solution for an embedded vendor like Juniper or even
FreeBSD.org, but are probably overkill for personal or small site use.
@@ -74,8 +75,12 @@ header.
Signatures
----------
-We expect ascii armored (``.asc``) detached signatures.
-Eg. signature for ``manifest`` would be in ``manifest.asc``
+We expect ascii armored (``.asc``) detached signatures
+Eg.::
+
+ gpg -a --detach-sign manifest
+
+should produce the expected signature in ``manifest.asc``
We only support version 4 signatures using RSA (the default for ``gpg``).
@@ -108,6 +113,10 @@ Ie. client sends a hash which during signing gets hashed again.
So for Junos we define VE_ECDSA_HASH_AGAIN which causes ``verify_ec``
to hash again.
+Later I added a FakeHash class to the signing server so we could
+generate signatures compatible with our previous RSA scheme and
+others.
+
Otherwise our EC DSA and RSA signatures are the default used by
OpenSSL - an original design goal was that a customer could verify our
signatures using nothing but an ``openssl`` binary.
diff --git a/lib/libsecureboot/h/libsecureboot.h b/lib/libsecureboot/h/libsecureboot.h
index 017558536825..d32df9594332 100644
--- a/lib/libsecureboot/h/libsecureboot.h
+++ b/lib/libsecureboot/h/libsecureboot.h
@@ -29,6 +29,7 @@
#include <sys/param.h>
#ifdef _STANDALONE
+#define _DEBUG_LEVEL_VAR DebugVe
#include <stand.h>
#else
#include <sys/types.h>
diff --git a/lib/libsecureboot/h/verify_file.h b/lib/libsecureboot/h/verify_file.h
index 88d758b27af4..f918ed6d0e38 100644
--- a/lib/libsecureboot/h/verify_file.h
+++ b/lib/libsecureboot/h/verify_file.h
@@ -46,6 +46,7 @@ int verify_prep(int, const char *, off_t, struct stat *, const char *);
void ve_debug_set(int);
char *ve_error_get(void);
void ve_efi_init(void);
+void ve_status_set(int, int);
int ve_status_get(int);
int load_manifest(const char *, const char *, const char *, struct stat *);
int pass_manifest(const char *, const char *);
diff --git a/lib/libsecureboot/local.trust.mk b/lib/libsecureboot/local.trust.mk
index 7b1e5f7ee97b..f2da3d3ac452 100644
--- a/lib/libsecureboot/local.trust.mk
+++ b/lib/libsecureboot/local.trust.mk
@@ -5,65 +5,69 @@
# the signing server (http://www.crufty.net/sjg/blog/signing-server.htm)
# for each key will provide the appropriate certificate chain on request
-# force these for Junos
-#MANIFEST_SKIP_ALWAYS= boot
-VE_HASH_LIST= \
- SHA1 \
- SHA256 \
- SHA384 \
- SHA512
-
-VE_SIGNATURE_LIST= \
- ECDSA \
- RSA
-
-VE_SIGNATURE_EXT_LIST= \
- esig \
- rsig
-
-VE_SELF_TESTS= yes
-
-.if ${MACHINE} == "host" && ${.CURDIR:T} == "tests"
-
-VE_SIGNATURE_LIST+= \
- DEPRECATED_RSA_SHA1
+# allow site control
+.-include "site.trust.mk"
-VE_SIGNATURE_EXT_LIST+= \
- sig
-.endif
+#VE_DEBUG_LEVEL?=3
+#VE_VERBOSE_DEFAULT?=2
-# add OpenPGP support - possibly dormant
-VE_SIGNATURE_LIST+= OPENPGP
-VE_SIGNATURE_EXT_LIST+= asc
+VE_HASH_LIST?= \
+ SHA256 \
+ SHA384 \
-# allow site override of all the above
-.-include "site.trust.mk"
+VE_SELF_TESTS?= yes
-SIGNER ?= ${SB_TOOLS_PATH:U/volume/buildtools/bin}/sign.py
+# client for the signing server above
+SIGNER?= /opt/sigs/sign.py
.if exists(${SIGNER})
-SIGN_HOST ?= ${SB_SITE:Usvl}-junos-signer.juniper.net
-ECDSA_PORT:= ${133%y:L:gmtime}
-SIGN_ECDSA= ${PYTHON} ${SIGNER} -u ${SIGN_HOST}:${ECDSA_PORT} -h sha256
-RSA2_PORT:= ${163%y:L:gmtime}
-SIGN_RSA2= ${PYTHON} ${SIGNER} -u ${SIGN_HOST}:${RSA2_PORT} -h sha256
+OPENPGP_SIGNER?= ${SIGNER:H}/openpgp-sign.py
+OPENPGP_SIGN_FLAGS= -a
+OPENPGP_SIGN_HOST?= localhost
+SIGN_HOST ?= localhost
+
+# A list of name/ext/url tuples.
+# name should be one of ECDSA, OPENPGP or RSA, they can be repeated
+# Order of ext list implies runtime preference so do not sort!
+VE_SIGN_URL_LIST?= \
+ ECDSA/esig/${SIGN_HOST}:${133%y:L:localtime} \
+ RSA/rsig/${SIGN_HOST}:${163%y:L:localtime} \
+ OPENPGP/asc/${OPENPGP_SIGN_HOST}:1234 \
+
+.for sig ext url in ${VE_SIGN_URL_LIST:@x@${x:H:H} ${x:H:T} ${x:T}@}
+SIGN_${sig}:= ${PYTHON} ${${sig}_SIGNER:U${SIGNER}} -u ${url} ${${sig}_SIGN_FLAGS:U-h sha256}
+
+VE_SIGNATURE_LIST+= ${sig}
+VE_SIGNATURE_EXT_LIST+= ${ext}
+
+_SIGN_${sig}_USE: .USE
+ ${SIGN_${sig}} ${.ALLSRC}
+
+_TA_${sig}_USE: .USE
+ ${SIGN_${sig}} -C ${.TARGET}
+
+.if ${sig} == "OPENPGP"
+ta_${sig:tl}.${ext}: _TA_${sig}_USE
+ta_${ext}.h: ta_${sig:tl}.${ext}
+.else
+${ext:S/sig/certs/}.pem: _TA_${sig}_USE
+# the last cert in the chain is the one we want
+ta_${ext}.pem: ${ext:S/sig/certs/}.pem _LAST_PEM_USE
+ta.h: ta_${ext}.pem
+.if ${VE_SELF_TESTS} != "no"
+# we use the 2nd last cert to test verification
+vc_${ext}.pem: ${ext:S/sig/certs/}.pem _2ndLAST_PEM_USE
+ta.h: vc_${ext}.pem
+.endif
+.endif
+.endfor
-# deal with quirk of our .esig format
-XCFLAGS.vets+= -DVE_ECDSA_HASH_AGAIN
+# cleanup duplicates
+VE_SIGNATURE_LIST:= ${VE_SIGNATURE_LIST:O:u}
-.if !empty(OPENPGP_SIGN_URL)
+.if target(ta_asc.h)
XCFLAGS.opgp_key+= -DHAVE_TA_ASC_H
-VE_SIGNATURE_LIST+= OPENPGP
-VE_SIGNATURE_EXT_LIST+= asc
-
-SIGN_OPENPGP= ${PYTHON} ${SIGNER:H}/openpgp-sign.py -a -u ${OPENPGP_SIGN_URL}
-
-ta_openpgp.asc:
- ${SIGN_OPENPGP} -C ${.TARGET}
-
-ta_asc.h: ta_openpgp.asc
-
.if ${VE_SELF_TESTS} != "no"
# for self test
vc_openpgp.asc: ta_openpgp.asc
@@ -74,48 +78,26 @@ ta_asc.h: vc_openpgp.asc
.endif
.endif
-rcerts.pem:
- ${SIGN_RSA2} -C ${.TARGET}
-
-ecerts.pem:
- ${SIGN_ECDSA} -C ${.TARGET}
-
-.if ${VE_SIGNATURE_LIST:tu:MECDSA} != ""
-# the last cert in the chain is the one we want
-ta_ec.pem: ecerts.pem _LAST_PEM_USE
-ta.h: ta_ec.pem
-.if ${VE_SELF_TESTS} != "no"
-# these are for verification self test
-vc_ec.pem: ecerts.pem _2ndLAST_PEM_USE
-ta.h: vc_ec.pem
-.endif
-.endif
-
-.if ${VE_SIGNATURE_LIST:tu:MRSA} != ""
-ta_rsa.pem: rcerts.pem _LAST_PEM_USE
-ta.h: ta_rsa.pem
-.if ${VE_SELF_TESTS} != "no"
-vc_rsa.pem: rcerts.pem _2ndLAST_PEM_USE
-ta.h: vc_rsa.pem
-.endif
-.endif
-
-# we take the mtime of this as our baseline time
-#BUILD_UTC_FILE= ecerts.pem
-#VE_DEBUG_LEVEL=3
-#VE_VERBOSE_DEFAULT=1
-
.else
+VE_SIGNATURE_LIST?= RSA
+
# you need to provide t*.pem or t*.asc files for each trust anchor
+# below assumes they are named ta_${ext}.pem eg ta_esig.pem for ECDSA
.if empty(TRUST_ANCHORS)
-TRUST_ANCHORS!= cd ${.CURDIR} && 'ls' -1 *.pem t*.asc 2> /dev/null
+TRUST_ANCHORS!= cd ${.CURDIR} && 'ls' -1 *.pem t*.asc 2> /dev/null || echo
.endif
.if empty(TRUST_ANCHORS) && ${MK_LOADER_EFI_SECUREBOOT} != "yes"
.error Need TRUST_ANCHORS see ${.PARSEDIR}/README.rst
.endif
+
.if ${TRUST_ANCHORS:T:Mt*.pem} != ""
ta.h: ${TRUST_ANCHORS:M*.pem}
+VE_SIGNATURE_EXT_LIST?= ${TRUST_ANCHORS:T:Mt*.pem:R:S/ta_//}
+.if ${VE_SIGNATURE_EXT_LIST:Mesig} != ""
+VE_SIGNATURE_LIST+= ECDSA
+.endif
.endif
+
.if ${TRUST_ANCHORS:T:Mt*.asc} != ""
VE_SIGNATURE_LIST+= OPENPGP
VE_SIGNATURE_EXT_LIST+= asc
@@ -124,4 +106,3 @@ ta_asc.h: ${TRUST_ANCHORS:M*.asc}
# we take the mtime of this as our baseline time
BUILD_UTC_FILE?= ${TRUST_ANCHORS:[1]}
.endif
-
diff --git a/lib/libsecureboot/openpgp/Makefile.inc b/lib/libsecureboot/openpgp/Makefile.inc
index 0d9a01a80369..3a216d205fe3 100644
--- a/lib/libsecureboot/openpgp/Makefile.inc
+++ b/lib/libsecureboot/openpgp/Makefile.inc
@@ -1,4 +1,3 @@
-
# decode OpenPGP signatures per rfc4880
.PATH: ${.PARSEDIR}
diff --git a/lib/libsecureboot/openpgp/opgp_sig.c b/lib/libsecureboot/openpgp/opgp_sig.c
index a6aa787ee5c0..8846296d7122 100644
--- a/lib/libsecureboot/openpgp/opgp_sig.c
+++ b/lib/libsecureboot/openpgp/opgp_sig.c
@@ -26,8 +26,6 @@
* RCSid:
* from: signer.c,v 1.10 2018/03/23 01:14:30 sjg
*
- * @(#) Copyright (c) 2012 Simon J. Gerraty
- *
* This file is provided in the hope that it will
* be of use. There is absolutely NO WARRANTY.
* Permission to copy, redistribute or otherwise
@@ -341,8 +339,19 @@ openpgp_verify(const char *filename,
mlen = br_sha256_SIZE;
hash_oid = BR_HASH_OID_SHA256;
break;
+ case 9: /* sha384 */
+ md = &br_sha384_vtable;
+ mlen = br_sha384_SIZE;
+ hash_oid = BR_HASH_OID_SHA384;
+ break;
+ case 10: /* sha512 */
+ md = &br_sha512_vtable;
+ mlen = br_sha512_SIZE;
+ hash_oid = BR_HASH_OID_SHA512;
+ break;
default:
warnx("unsupported hash algorithm: %s", hname);
+ rc = -1;
goto oops;
}
md->init(&mctx.vtable);
diff --git a/lib/libsecureboot/tests/Makefile b/lib/libsecureboot/tests/Makefile
index 70e10bb4f984..b3de2b6ce5b9 100644
--- a/lib/libsecureboot/tests/Makefile
+++ b/lib/libsecureboot/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PROG= tvo
diff --git a/lib/libsecureboot/vectx.c b/lib/libsecureboot/vectx.c
index dba728421ce4..2d56830cd81d 100644
--- a/lib/libsecureboot/vectx.c
+++ b/lib/libsecureboot/vectx.c
@@ -306,19 +306,31 @@ vectx_lseek(struct vectx *ctx, off_t off, int whence)
DEBUG_PRINTF(3,
("%s(%s, %ld, %d)\n", __func__, ctx->vec_path, (long)off, whence));
if (whence == SEEK_END && off <= 0) {
- if (ctx->vec_closing && ctx->vec_hashed < ctx->vec_size) {
- DEBUG_PRINTF(3, ("%s: SEEK_END %ld\n",
- __func__,
- (long)(ctx->vec_size - ctx->vec_hashed)));
+ if (ctx->vec_size < 0) {
+ if (ctx->vec_closing) {
+ /* size unknown - read until EOF */
+ do {
+ n = vectx_read(ctx, buf, PAGE_SIZE);
+ if (n < 0)
+ return (n);
+ } while (n > 0);
+ return (ctx->vec_off);
+ }
+ } else {
+ if (ctx->vec_closing && ctx->vec_hashed < ctx->vec_size) {
+ DEBUG_PRINTF(3, ("%s: SEEK_END %ld\n",
+ __func__,
+ (long)(ctx->vec_size - ctx->vec_hashed)));
+ }
+ whence = SEEK_SET;
+ off += ctx->vec_size;
}
- whence = SEEK_SET;
- off += ctx->vec_size;
} else if (whence == SEEK_CUR) {
whence = SEEK_SET;
off += ctx->vec_off;
}
if (whence != SEEK_SET ||
- off > ctx->vec_size) {
+ (off > ctx->vec_size && ctx->vec_size > 0)) {
printf("ERROR: %s: unsupported operation: whence=%d off=%ld -> %ld\n",
__func__, whence, (long)ctx->vec_off, (long)off);
return (-1);
diff --git a/lib/libsecureboot/verify_file.c b/lib/libsecureboot/verify_file.c
index 1e1c714d1fa8..753204a33b6a 100644
--- a/lib/libsecureboot/verify_file.c
+++ b/lib/libsecureboot/verify_file.c
@@ -25,7 +25,7 @@
/*
* Routines to verify files loaded.
*/
-#include <sys/cdefs.h>
+
#include <sys/param.h>
#include <string.h>
#include <sys/queue.h>
@@ -82,7 +82,7 @@ static int Verbose = VE_VERBOSE_DEFAULT;
/**
* @brief set ve status for fd
*/
-static void
+void
ve_status_set(int fd, int ves)
{
if (fd >= 0 && fd < SOPEN_MAX) {
@@ -131,15 +131,21 @@ int
is_verified(struct stat *stp)
{
struct verify_status *vsp;
+ int rc = VE_NOT_CHECKED;
if (stp->st_ino > 0) {
for (vsp = verified_files; vsp != NULL; vsp = vsp->vs_next) {
if (stp->st_dev == vsp->vs_dev &&
- stp->st_ino == vsp->vs_ino)
- return (vsp->vs_status);
+ stp->st_ino == vsp->vs_ino) {
+ rc = vsp->vs_status;
+ break;
+ }
}
}
- return (VE_NOT_CHECKED);
+ DEBUG_PRINTF(4, ("%s: dev=%lld,ino=%llu,status=%d\n",
+ __func__, (long long)stp->st_dev,
+ (unsigned long long)stp->st_ino, rc));
+ return (rc);
}
/* most recent first, since most likely to see repeated calls. */
@@ -156,6 +162,9 @@ add_verify_status(struct stat *stp, int status)
vsp->vs_status = status;
verified_files = vsp;
}
+ DEBUG_PRINTF(4, ("%s: dev=%lld,ino=%llu,status=%d\n",
+ __func__, (long long)stp->st_dev,
+ (unsigned long long)stp->st_ino, status));
}
@@ -270,11 +279,14 @@ severity_guess(const char *filename)
/*
* Some files like *.conf and *.hints may be unsigned,
* a *.tgz is expected to have its own signed manifest.
+ * We allow *.conf to get VE_WANT, but files we expect
+ * to always be unverified get VE_TRY and we will not
+ * report them.
*/
if ((cp = strrchr(filename, '.'))) {
- if (strcmp(cp, ".conf") == 0 ||
- strcmp(cp, ".cookie") == 0 ||
+ if (strcmp(cp, ".cookie") == 0 ||
strcmp(cp, ".hints") == 0 ||
+ strcmp(cp, ".order") == 0 ||
strcmp(cp, ".tgz") == 0)
return (VE_TRY);
if (strcmp(cp, ".4th") == 0 ||
@@ -398,6 +410,8 @@ void
verify_report(const char *path, int severity, int status, struct stat *stp)
{
if (status < 0 || status == VE_FINGERPRINT_IGNORE) {
+ if (Verbose < VE_VERBOSE_ALL && severity < VE_WANT)
+ return;
if (Verbose >= VE_VERBOSE_UNVERIFIED || severity > VE_TRY ||
status <= VE_FINGERPRINT_WRONG) {
if (Verbose == VE_VERBOSE_DEBUG && stp != NULL)
@@ -462,9 +476,10 @@ verify_prep(int fd, const char *filename, off_t off, struct stat *stp,
caller, fd, filename, (long long)off, (long long)stp->st_dev,
(unsigned long long)stp->st_ino));
rc = is_verified(stp);
- DEBUG_PRINTF(4,("verify_prep: is_verified()->%d\n", rc));
if (rc == VE_NOT_CHECKED) {
rc = find_manifest(filename);
+ if (rc == VE_VERIFIED)
+ rc = VE_NOT_CHECKED;
} else {
ve_status_set(fd, rc);
}
@@ -511,7 +526,8 @@ verify_file(int fd, const char *filename, off_t off, int severity,
if (check_verbose) {
check_verbose = 0;
Verbose = getenv_int("VE_VERBOSE", VE_VERBOSE_DEFAULT);
- VerifyFlags = getenv_int("VE_VERIFY_FLAGS", VEF_VERBOSE);
+ VerifyFlags = getenv_int("VE_VERIFY_FLAGS",
+ Verbose ? VEF_VERBOSE : 0);
#ifndef UNIT_TEST
ve_debug_set(getenv_int("VE_DEBUG_LEVEL", VE_DEBUG_LEVEL));
#endif
@@ -523,6 +539,9 @@ verify_file(int fd, const char *filename, off_t off, int severity,
return (0);
if (rc != VE_FINGERPRINT_WRONG && loaded_manifests) {
+ if (rc != VE_NOT_CHECKED)
+ return (rc);
+
if (severity <= VE_GUESS)
severity = severity_guess(filename);
#ifdef VE_PCR_SUPPORT
diff --git a/lib/libsecureboot/vets.c b/lib/libsecureboot/vets.c
index 4a2aba433191..67d27d567485 100644
--- a/lib/libsecureboot/vets.c
+++ b/lib/libsecureboot/vets.c
@@ -200,11 +200,13 @@ ve_utc_set(time_t utc)
}
}
+#ifdef VERIFY_CERTS_STR
static void
free_cert_contents(br_x509_certificate *xc)
{
xfree(xc->data);
}
+#endif
/*
* a bit of a dance to get commonName from a certificate
@@ -372,13 +374,15 @@ ve_trust_anchors_add_buf(unsigned char *buf, size_t len)
size_t num;
num = 0;
- xcs = parse_certificates(buf, len, &num);
- if (xcs != NULL) {
- num = ve_trust_anchors_add(xcs, num);
+ if (len > 0) {
+ xcs = parse_certificates(buf, len, &num);
+ if (xcs != NULL) {
+ num = ve_trust_anchors_add(xcs, num);
#ifdef VE_OPENPGP_SUPPORT
- } else {
- num = openpgp_trust_add_buf(buf, len);
+ } else {
+ num = openpgp_trust_add_buf(buf, len);
#endif
+ }
}
return (num);
}
@@ -398,15 +402,17 @@ ve_trust_anchors_revoke(unsigned char *buf, size_t len)
size_t num;
num = 0;
- xcs = parse_certificates(buf, len, &num);
- if (xcs != NULL) {
- num = ve_forbidden_anchors_add(xcs, num);
+ if (len > 0) {
+ xcs = parse_certificates(buf, len, &num);
+ if (xcs != NULL) {
+ num = ve_forbidden_anchors_add(xcs, num);
#ifdef VE_OPENPGP_SUPPORT
- } else {
- if (buf[len - 1] == '\n')
- buf[len - 1] = '\0';
- num = openpgp_trust_revoke((char *)buf);
+ } else {
+ if (buf[len - 1] == '\n')
+ buf[len - 1] = '\0';
+ num = openpgp_trust_revoke((char *)buf);
#endif
+ }
}
return (num);
}
@@ -568,9 +574,17 @@ verify_signer_xcs(br_x509_certificate *xcs,
ve_error_set("Validation failed, certificate not valid as of %s",
gdate(date, sizeof(date), ve_utc));
break;
- default:
- ve_error_set("Validation failed, err = %d", err);
- break;
+ default: {
+ const char *err_desc = NULL;
+ const char *err_name = find_error_name(err, &err_desc);
+
+ if (err_name == NULL)
+ ve_error_set("Validation failed, err = %d",
+ err);
+ else
+ ve_error_set("Validation failed, %s (%s)",
+ err_desc, err_name);
+ break; }
}
} else {
tpk = mc.vtable->get_pkey(&mc.vtable, &usages);
diff --git a/lib/libsm/Makefile b/lib/libsm/Makefile
index b6485bbc2b0c..448abad59192 100644
--- a/lib/libsm/Makefile
+++ b/lib/libsm/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE=sendmail
diff --git a/lib/libsmb/Makefile b/lib/libsmb/Makefile
index f8fa30e39603..777f2a65e671 100644
--- a/lib/libsmb/Makefile
+++ b/lib/libsmb/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
CONFS= nsmb.conf
diff --git a/lib/libsmdb/Makefile b/lib/libsmdb/Makefile
index fef1466299e7..898af78d6101 100644
--- a/lib/libsmdb/Makefile
+++ b/lib/libsmdb/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
SENDMAIL_DIR=${SRCTOP}/contrib/sendmail
.PATH: ${SENDMAIL_DIR}/libsmdb
diff --git a/lib/libsmutil/Makefile b/lib/libsmutil/Makefile
index 5ef7959c1d45..ef526ff8656d 100644
--- a/lib/libsmutil/Makefile
+++ b/lib/libsmutil/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE=lib${LIB}
diff --git a/lib/libsmutil/Makefile.depend b/lib/libsmutil/Makefile.depend
index f2b0559818dd..f527c2585bed 100644
--- a/lib/libsmutil/Makefile.depend
+++ b/lib/libsmutil/Makefile.depend
@@ -4,6 +4,7 @@ DIRDEPS = \
include \
include/arpa \
include/xlocale \
+ secure/lib/libcrypto \
.include <dirdeps.mk>
diff --git a/lib/libsqlite3/Makefile b/lib/libsqlite3/Makefile
index bb2c939c5cf7..73ba8951a797 100644
--- a/lib/libsqlite3/Makefile
+++ b/lib/libsqlite3/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
PRIVATELIB= yes
LIB= sqlite3
diff --git a/lib/libssp/Makefile b/lib/libssp/Makefile
index b5e2841ba391..d4038b705acb 100644
--- a/lib/libssp/Makefile
+++ b/lib/libssp/Makefile
@@ -1,9 +1,24 @@
-
PACKAGE= clibs
SHLIBDIR?= /lib
SHLIB= ssp
SHLIB_MAJOR= 0
+SSP_SRCS= fgets_chk.c memcpy_chk.c memmove_chk.c memset_chk.c \
+ snprintf_chk.c sprintf_chk.c stpcpy_chk.c stpncpy_chk.c \
+ strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c \
+ vsnprintf_chk.c vsprintf_chk.c
+
+.for i in ${SSP_SRCS}
+SRCS+=${i}
+.endfor
+
+CFLAGS.snprintf_chk.c+= -Wno-unused-parameter
+CFLAGS.sprintf_chk.c+= -Wno-unused-parameter
+CFLAGS.vsnprintf_chk.c+= -Wno-unused-parameter
+CFLAGS.vsprintf_chk.c+= -Wno-unused-parameter
+
+MAN+= ssp.3 __builtin_object_size.3
+
VERSION_DEF= ${.CURDIR}/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
@@ -12,9 +27,7 @@ CFLAGS+= -I${SRCTOP}/lib/libc/include
# _elf_aux_info is exported from libc as elf_aux_info(3), so just that for the
# libssp build instead.
CFLAGS+= -D_elf_aux_info=elf_aux_info
-SRCS= stack_protector.c fortify_stubs.c
-
-CFLAGS.fortify_stubs.c= -Wno-unused-parameter
+SRCS+= libc_stack_protector.c
# Stack protection on libssp symbols should be considered harmful, as we may
# be talking about, for example, the guard setup constructor.
diff --git a/lib/libssp/Makefile.depend b/lib/libssp/Makefile.depend
index e69de29bb2d1..9e22de8ed182 100644
--- a/lib/libssp/Makefile.depend
+++ b/lib/libssp/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/ssp \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libsys \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libssp/Symbol.map b/lib/libssp/Symbol.map
index 5c2e089c6ab8..e401bf9293e2 100644
--- a/lib/libssp/Symbol.map
+++ b/lib/libssp/Symbol.map
@@ -6,11 +6,6 @@ LIBSSP_1.0 {
__stack_chk_fail;
__stack_chk_guard;
- /*
- * Currently unsupported: _FORTIFY_SOURCE symbols. It is believed
- * that these have never been used on FreeBSD, as our headers lack the
- * support that would have generated references to them.
- */
__memcpy_chk;
__memset_chk;
__snprintf_chk;
@@ -23,3 +18,9 @@ LIBSSP_1.0 {
__vsnprintf_chk;
__vsprintf_chk;
};
+
+LIBSSP_1.1 {
+ __fgets_chk;
+ __memmove_chk;
+ __stpncpy_chk;
+};
diff --git a/lib/libssp/Versions.def b/lib/libssp/Versions.def
index be9d9874947b..85682c88a3e0 100644
--- a/lib/libssp/Versions.def
+++ b/lib/libssp/Versions.def
@@ -1,3 +1,8 @@
+# This version was first added to 13.0-current.
LIBSSP_1.0 {
};
+
+# This version was first added to 15.0-current.
+LIBSSP_1.1 {
+} LIBSSP_1.0;
diff --git a/lib/libssp/__builtin_object_size.3 b/lib/libssp/__builtin_object_size.3
new file mode 100644
index 000000000000..23d74792918b
--- /dev/null
+++ b/lib/libssp/__builtin_object_size.3
@@ -0,0 +1,110 @@
+.\" $NetBSD: __builtin_object_size.3,v 1.11 2017/07/03 21:32:49 wiz Exp $
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2007 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.
+.\"
+.\"
+.Dd April 27, 2024
+.Dt __BUILTIN_OBJECT_SIZE 3
+.Os
+.Sh NAME
+.Nm __builtin_object_size
+.Nd return the size of the given object
+.Sh SYNOPSIS
+.Ft size_t
+.Fn __builtin_object_size "void *ptr" "int type"
+.Sh DESCRIPTION
+The
+.Fn __builtin_object_size
+function is a
+.Xr clang 1
+and
+.Xr gcc 1
+built-in function that returns the size of the object referenced by
+.Fa ptr
+if known at compile time.
+If the
+.Fa ptr
+expression has any side effects, then they will not be evaluated.
+.Sh RETURN VALUES
+If the size of the object is not known or the
+.Fa ptr
+expression has side effects, the
+.Fn __builtin_object_size
+function returns:
+.Bl -tag -width (size_t)\-1 -offset indent
+.It Dv (size_t)\-1
+for
+.Fa type
+.Dv 0
+and
+.Dv 1 .
+.It Dv (size_t)0
+for
+.Fa type
+.Dv 2
+and
+.Dv 3 .
+.El
+.Pp
+If the size of the object is known, then the
+.Fn __builtin_object_size
+function returns the maximum size of all the objects that the compiler
+knows can be pointed to by
+.Fa ptr
+when
+.Fa type
+.Dv & 2 == 0 ,
+and the minimum size when
+.Fa type
+.Dv & 2 != 0 .
+.Sh SEE ALSO
+.Xr clang 1 ,
+.Xr gcc 1 ,
+.Xr __builtin_return_address 3 ,
+.Xr attribute 3 ,
+.Xr ssp 3
+.Sh HISTORY
+The
+.Fn __builtin_object_size
+appeared in
+.Tn GCC 4.1 .
+.Sh CAVEATS
+This is a non-standard, compiler-specific extension.
+.Pp
+Note that currently the object size calculation pass is only done at -O1
+or above, meaning that this function always returns \-1 when the optimizer
+is off.
+.Pp
+There are some discussions about always doing the object size pass, but
+the issue is that without the optimization pass data sizes are not going
+to be correct.
+.Pp
+For that reason code fortification (size-checked replacement
+functions) is currently disabled when optimization is off.
diff --git a/lib/libssp/fortify_stubs.c b/lib/libssp/fortify_stubs.c
deleted file mode 100644
index a500a1405aaf..000000000000
--- a/lib/libssp/fortify_stubs.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.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.
- *
- * 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <stdarg.h>
-#include <stdlib.h>
-
-/* Signatures grabbed from LSB Core Specification 4.1 */
-void *__memcpy_chk(void *dst, const void *src, size_t len,
- size_t dstlen);
-void *__memset_chk(void *dst, int c, size_t len, size_t dstlen);
-int __snprintf_chk(char *str, size_t maxlen, int flag, size_t strlen,
- const char *fmt, ...);
-int __sprintf_chk(char *str, int flag, size_t strlen, const char *fmt, ...);
-char *__stpcpy_chk(char *dst, const char *src, size_t dstlen);
-char *__strcat_chk(char *dst, const char *src, size_t dstlen);
-char *__strcpy_chk(char *dst, const char *src, size_t dstlen);
-char *__strncat_chk(char *dst, const char *src, size_t len, size_t dstlen);
-char *__strncpy_chk(char *dst, const char *src, size_t len, size_t dstlen);
-int __vsnprintf_chk(char *str, size_t size, int flags, size_t len,
- const char *format, va_list ap);
-int __vsprintf_chk(char *str, int flag, size_t slen, const char *format,
- va_list ap);
-
-#define ABORT() abort2("_FORTIFY_SOURCE not supported", 0, NULL)
-
-void *
-__memcpy_chk(void *dst, const void *src, size_t len,
- size_t dstlen)
-{
-
- ABORT();
-}
-
-void *
-__memset_chk(void *dst, int c, size_t len, size_t dstlen)
-{
-
- ABORT();
-}
-
-int
-__snprintf_chk(char *str, size_t maxlen, int flag, size_t strlen,
- const char *fmt, ...)
-{
-
- ABORT();
-}
-
-int
-__sprintf_chk(char *str, int flag, size_t strlen, const char *fmt, ...)
-{
-
- ABORT();
-}
-
-char *
-__stpcpy_chk(char *dst, const char *src, size_t dstlen)
-{
-
- ABORT();
-}
-
-char *
-__strcat_chk(char *dst, const char *src, size_t dstlen)
-{
-
- ABORT();
-}
-
-char *
-__strcpy_chk(char *dst, const char *src, size_t dstlen)
-{
-
- ABORT();
-}
-
-char *
-__strncat_chk(char *dst, const char *src, size_t len, size_t dstlen)
-{
-
- ABORT();
-}
-
-char *
-__strncpy_chk(char *dst, const char *src, size_t len, size_t dstlen)
-{
-
- ABORT();
-}
-
-int
-__vsnprintf_chk(char *str, size_t size, int flags, size_t len,
- const char *format, va_list ap)
-{
-
- ABORT();
-}
-
-int
-__vsprintf_chk(char *str, int flag, size_t slen, const char *format,
- va_list ap)
-{
-
- ABORT();
-}
diff --git a/lib/libssp/ssp.3 b/lib/libssp/ssp.3
new file mode 100644
index 000000000000..5b00fe53f9fc
--- /dev/null
+++ b/lib/libssp/ssp.3
@@ -0,0 +1,128 @@
+.\" $NetBSD: ssp.3,v 1.9 2015/12/03 13:11:45 christos Exp $
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2007 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.
+.\"
+.\"
+.Dd December 3, 2015
+.Dt SSP 3
+.Os
+.Sh NAME
+.Nm ssp
+.Nd bounds checked libc functions
+.Sh LIBRARY
+.Lb libssp
+.Sh SYNOPSIS
+.In ssp/stdio.h
+.Ft int
+.Fn sprintf "char *str" "const char *fmt" "..."
+.Ft int
+.Fn vsprintf "char *str" "const char *fmt" "va_list ap"
+.Ft int
+.Fn snprintf "char *str" "size_t len" "const char *fmt" "..."
+.Ft int
+.Fn vsnprintf "char *str" "size_t len" "const char *fmt" "va_list ap"
+.Ft char *
+.Fn fgets "char *str" "int len" "FILE *fp"
+.In ssp/string.h
+.Ft void *
+.Fn memcpy "void *str" "const void *ptr" "size_t len"
+.Ft void *
+.Fn memmove "void *str" "const void *ptr" "size_t len"
+.Ft void *
+.Fn memset "void *str" "int val" "size_t len"
+.Ft char *
+.Fn stpcpy "char *str" "const char *ptr"
+.Ft char *
+.Fn strcpy "char *str" "const char *ptr"
+.Ft char *
+.Fn strcat "char *str" "const char *ptr"
+.Ft char *
+.Fn strncpy "char *str" "const char *ptr" "size_t len"
+.Ft char *
+.Fn strncat "char *str" "const char *ptr" "size_t len"
+.In ssp/strings.h
+.Ft void *
+.Fn bcopy "const void *ptr" "void *str" "size_t len"
+.Ft void *
+.Fn bzero "void *str" "size_t len"
+.In ssp/unistd.h
+.Ft ssize_t
+.Fn read "int fd" "void *str" "size_t len"
+.Ft int
+.Fn readlink "const char * restrict path" "char * restrict str" "size_t len"
+.Ft int
+.Fn getcwd "char *str" "size_t len"
+.Sh DESCRIPTION
+When
+.Dv _FORTIFY_SOURCE
+bounds checking is enabled as described below, the above functions get
+overwritten to use the
+.Xr __builtin_object_size 3
+function to compute the size of
+.Fa str ,
+if known at compile time,
+and perform bounds check on it in order
+to avoid data buffer or stack buffer overflows.
+If an overflow is detected, the routines will call
+.Xr abort 3 .
+.Pp
+To enable these function overrides the following should be added to the
+.Xr clang 1
+or
+.Xr gcc 1
+command line:
+.Dq \-D_FORTIFY_SOURCE=1
+or
+.Dq \-D_FORTIFY_SOURCE=2 .
+.Pp
+If
+.Dv _FORTIFY_SOURCE is set to
+.Dv 1
+the code will compute the maximum possible buffer size for
+.Fa str ,
+and if set to
+.Dv 2
+it will compute the minimum buffer size.
+.Sh SEE ALSO
+.Xr clang 1 ,
+.Xr gcc 1 ,
+.Xr __builtin_object_size 3 ,
+.Xr stdio 3 ,
+.Xr string 3 ,
+.Xr security 7
+.Sh HISTORY
+The
+.Nm
+library appeared in
+.Nx 4.0 .
+This version of the
+.Nm
+library replaced the GNU library of the same name in
+.Fx 12.2 .
diff --git a/lib/libssp_nonshared/Makefile b/lib/libssp_nonshared/Makefile
index 209f969b6c3d..c156d0ae8007 100644
--- a/lib/libssp_nonshared/Makefile
+++ b/lib/libssp_nonshared/Makefile
@@ -1,8 +1,6 @@
-
PACKAGE= clibs
LIB= ssp_nonshared
NO_PIC=
-MK_PROFILE= no
SRCS= libssp_nonshared.c
CFLAGS+= -fPIC
diff --git a/lib/libstats/Makefile b/lib/libstats/Makefile
index d25745b57f76..77a4770ff2f7 100644
--- a/lib/libstats/Makefile
+++ b/lib/libstats/Makefile
@@ -1,4 +1,3 @@
-
LIB= stats
SHLIBDIR?= /lib
SHLIB_MAJOR= 0
diff --git a/lib/libstats/Makefile.depend b/lib/libstats/Makefile.depend
index e69de29bb2d1..6ef78fac5cbf 100644
--- a/lib/libstats/Makefile.depend
+++ b/lib/libstats/Makefile.depend
@@ -0,0 +1,15 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libstdbuf/Makefile b/lib/libstdbuf/Makefile
index aa0ed7b4e18a..102c6745c593 100644
--- a/lib/libstdbuf/Makefile
+++ b/lib/libstdbuf/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
PACKAGE=lib${LIB}
diff --git a/lib/libstdthreads/Makefile b/lib/libstdthreads/Makefile
index 72ebd988df16..49d024052420 100644
--- a/lib/libstdthreads/Makefile
+++ b/lib/libstdthreads/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
LIB= stdthreads
SHLIB_MAJOR= 0
diff --git a/lib/libstdthreads/mtx.c b/lib/libstdthreads/mtx.c
index 719ba6486e41..3027a4e48c8d 100644
--- a/lib/libstdthreads/mtx.c
+++ b/lib/libstdthreads/mtx.c
@@ -43,7 +43,7 @@ int
mtx_init(mtx_t *mtx, int type)
{
pthread_mutexattr_t attr;
- int mt;
+ int mt, res;
switch (type) {
case mtx_plain:
@@ -60,11 +60,12 @@ mtx_init(mtx_t *mtx, int type)
if (pthread_mutexattr_init(&attr) != 0)
return (thrd_error);
- if (pthread_mutexattr_settype(&attr, mt) != 0)
- return (thrd_error);
- if (pthread_mutex_init(mtx, &attr) != 0)
- return (thrd_error);
- return (thrd_success);
+ res = thrd_success;
+ if (pthread_mutexattr_settype(&attr, mt) != 0 ||
+ pthread_mutex_init(mtx, &attr) != 0)
+ res = thrd_error;
+ pthread_mutexattr_destroy(&attr);
+ return (res);
}
int
diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile
new file mode 100644
index 000000000000..b4b4662ae47f
--- /dev/null
+++ b/lib/libsys/Makefile
@@ -0,0 +1,80 @@
+PACKAGE= clibs
+SHLIBDIR?= /lib
+
+.include <src.opts.mk>
+
+LIBC_SRCTOP?= ${.CURDIR}/../libc
+LIBSYS_SRCTOP?= ${.CURDIR}
+
+# Pick the current architecture directory for libsys. In general, this is named
+# MACHINE_CPUARCH, but some ABIs are different enough to require their own
+# libsys, so allow a directory named MACHINE_ARCH to override this (though
+# treat powerpc64le and powerpc64 the same).
+# Note: This is copied from libc/Makefile
+M=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
+.if exists(${LIBC_SRCTOP}/${M})
+LIBC_ARCH=${M}
+.else
+LIBC_ARCH=${MACHINE_CPUARCH}
+.endif
+
+LIB=sys
+SHLIB_MAJOR= 7
+WARNS?= 2
+MK_SSP= no
+
+INCS= libsys.h _libsys.h
+
+CFLAGS+=-DLIBSYS
+
+CFLAGS+=-I${LIBSYS_SRCTOP}/include -I${LIBC_SRCTOP}/include
+CFLAGS+=-I${LIBSYS_SRCTOP}/${LIBC_ARCH}
+CFLAGS+=-I${LIBC_SRCTOP}/${LIBC_ARCH}
+
+.PATH: ${LIBC_SRCTOP}/string
+SRCS+= memcpy.c memset.c strlcpy.c
+
+CLEANFILES+=tags
+INSTALL_PIC_ARCHIVE=
+#XXX? BUILD_NOSSP_PIC_ARCHIVE=
+PRECIOUSLIB=
+
+# Use a more efficient TLS model for libc since we can reasonably assume that
+# it will be loaded during program startup.
+CFLAGS+= -ftls-model=initial-exec
+
+#
+# Link with static libcompiler_rt.a.
+#
+LDFLAGS+= -nodefaultlibs
+LDFLAGS+= -Wl,-Bsymbolic
+LIBADD+= compiler_rt
+
+.if ${MK_SSP} != "no" && \
+ (${LIBC_ARCH} == "i386" || ${LIBC_ARCH:Mpowerpc*} != "")
+LIBADD+= ssp_nonshared
+.endif
+
+# Define (empty) variables so that make doesn't give substitution
+# errors if the included makefiles don't change these:
+MDASM=
+MIASM=
+NOASM=
+
+SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.map
+SRCS+= auxv.c \
+ interposing_table.c
+
+.include "${LIBSYS_SRCTOP}/Makefile.sys"
+
+SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.thr.map
+.PATH: ${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}
+.sinclude "${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}/Makefile.thr"
+.if !${SRCS:M_umtx_op_err.S}
+SRCS+=_umtx_op_err.c
+.endif
+
+VERSION_DEF=${LIBC_SRCTOP}/Versions.def
+SYMBOL_MAPS=${SYM_MAPS}
+
+.include <bsd.lib.mk>
diff --git a/lib/libsys/Makefile.depend b/lib/libsys/Makefile.depend
new file mode 100644
index 000000000000..fcba9c64f270
--- /dev/null
+++ b/lib/libsys/Makefile.depend
@@ -0,0 +1,14 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libcompiler_rt \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libsys/Makefile.sys b/lib/libsys/Makefile.sys
new file mode 100644
index 000000000000..3eb4bf85153d
--- /dev/null
+++ b/lib/libsys/Makefile.sys
@@ -0,0 +1,553 @@
+# Implement symbols common to libc and libsys.
+#
+# When dynamically linked, the libc symbols are filtered by the actual
+# implementations in libsys. When statically linked, both libc and
+# libsys contain full implementations to preserve the API of libc.a.
+#
+# The following variable are programmer-defined:
+#
+# MDASM Override the default syscall implementation in MIASM
+# (from syscall.mk below). Each entry is a source file
+# name (e.g., vfork.S).
+# Generally defined in <arch>/Makefile.sys.
+# NOASM Don't generate system call stubs. Each entry is an
+# object file name (e.g., yeild.o). Don't add more of these.
+# PSEUDO Generate _<sys> and __sys_<sys> symbols, but not <sys>.
+# Each entry is a bare syscall name (e.g., "clock_gettime").
+# INTERPOSED Like PSEUDO, but <sys>.c is added to SRCS.
+# Used for syscalls intercepted by the threading library.
+#
+.PATH: ${LIBSYS_SRCTOP}/${LIBC_ARCH} ${LIBSYS_SRCTOP}
+
+# Include the generated makefile containing the *complete* list
+# of syscall names in MIASM.
+.include "${SRCTOP}/sys/sys/syscall.mk"
+
+# Include machine dependent definitions.
+.include "${LIBSYS_SRCTOP}/${LIBC_ARCH}/Makefile.sys"
+.if ${LIBC_ARCH} == "i386" || ${LIBC_ARCH} == "amd64"
+.include "${LIBSYS_SRCTOP}/x86/Makefile.sys"
+.endif
+
+SRCS+= clock_gettime.c gettimeofday.c __vdso_gettimeofday.c
+
+# Sources common to both syscall interfaces:
+SRCS+= \
+ __error.c \
+ __getosreldate.c \
+ getpagesize.c \
+ getpagesizes.c \
+ libsys_sigwait.c
+
+.if ${LIB} == "c"
+# Trapping stubs in dynamic libc to be filtered by libsys.
+SOBJS+= libc_stubs.pico
+
+# Link the full implementation of ELF auxargs for static libc.
+STATICOBJS+= auxv.o
+
+STATICOBJS+= interposing_table.o
+.endif
+
+PSEUDO= \
+ __realpathat \
+ clock_gettime \
+ exit \
+ getlogin \
+ gettimeofday \
+ sched_getcpu
+
+INTERPOSED = \
+ accept \
+ accept4 \
+ aio_suspend \
+ clock_nanosleep \
+ close \
+ connect \
+ fcntl \
+ fdatasync \
+ fsync \
+ fork \
+ kevent \
+ msync \
+ nanosleep \
+ open \
+ openat \
+ pdfork \
+ poll \
+ ppoll \
+ pselect \
+ ptrace \
+ read \
+ readv \
+ recvfrom \
+ recvmsg \
+ select \
+ sendmsg \
+ sendto \
+ setcontext \
+ sigaction \
+ sigprocmask \
+ sigsuspend \
+ sigtimedwait \
+ sigwait \
+ sigwaitinfo \
+ swapcontext \
+ wait4 \
+ wait6 \
+ write \
+ writev
+
+PSEUDO+= ${INTERPOSED}
+
+# Add machine dependent asm sources:
+SRCS+=${MDASM}
+
+# Look though the complete list of syscalls (MIASM) for names that are
+# not defined with machine dependent implementations (MDASM), not declared
+# without a trival <sys> symbol (PSEUDO). Add each syscall that satisfies
+# these conditions to the ASM list.
+.for _asm in ${MIASM}
+.if !${MDASM:R:M${_asm:R}} && !${NOASM:R:M${_asm:R}} && !${PSEUDO:M${_asm:R}}
+ASM+=$(_asm)
+.endif
+.endfor
+
+SASM= ${ASM:S/.o/.S/}
+
+SPSEUDO= ${PSEUDO:C/^.*$/_&.S/}
+
+SRCS+= ${SASM} ${SPSEUDO}
+
+SYM_MAPS+= ${LIBSYS_SRCTOP}/syscalls.map
+SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.sys.map
+.if exists(${LIBSYS_SRCTOP}/${LIBC_ARCH}/Symbol.sys.map)
+SYM_MAPS+= ${LIBSYS_SRCTOP}/${LIBC_ARCH}/Symbol.sys.map
+.endif
+
+# Generated files
+CLEANFILES+= ${SASM} ${SPSEUDO}
+
+NOTE_GNU_STACK='\t.section .note.GNU-stack,"",%%progbits\n'
+.if ${MACHINE_CPUARCH} == "aarch64"
+FEATURE_NOTE='\#include <sys/elf_common.h>\nGNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)\n'
+.else
+FEATURE_NOTE=''
+.endif
+
+${SASM}:
+ printf '/* %sgenerated by libc/sys/Makefile.inc */\n' @ > ${.TARGET}
+ printf '#include "compat.h"\n' >> ${.TARGET}
+ printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' >> ${.TARGET}
+ printf ${NOTE_GNU_STACK} >>${.TARGET}
+ printf ${FEATURE_NOTE} >> ${.TARGET}
+
+${SPSEUDO}:
+ printf '/* %sgenerated by libc/sys/Makefile.inc */\n' @ > ${.TARGET}
+ printf '#include "compat.h"\n' >> ${.TARGET}
+ printf '#include "SYS.h"\nPSEUDO(${.PREFIX:S/_//})\n' \
+ >> ${.TARGET}
+ printf ${NOTE_GNU_STACK} >>${.TARGET}
+ printf ${FEATURE_NOTE} >> ${.TARGET}
+
+.if ${LIB} == "sys"
+MAN+= abort2.2 \
+ accept.2 \
+ access.2 \
+ acct.2 \
+ adjtime.2 \
+ aio_cancel.2 \
+ aio_error.2 \
+ aio_fsync.2 \
+ aio_mlock.2 \
+ aio_read.2 \
+ aio_return.2 \
+ aio_suspend.2 \
+ aio_waitcomplete.2 \
+ aio_write.2 \
+ auxv.3 \
+ bind.2 \
+ bindat.2 \
+ brk.2 \
+ cap_enter.2 \
+ cap_fcntls_limit.2 \
+ cap_ioctls_limit.2 \
+ cap_rights_limit.2 \
+ chdir.2 \
+ chflags.2 \
+ chmod.2 \
+ chown.2 \
+ chroot.2 \
+ clock_gettime.2 \
+ close.2 \
+ closefrom.2 \
+ connect.2 \
+ connectat.2 \
+ copy_file_range.2 \
+ cpuset.2 \
+ cpuset_getaffinity.2 \
+ cpuset_getdomain.2 \
+ creat.2 \
+ dup.2 \
+ eventfd.2 \
+ execve.2 \
+ _exit.2 \
+ extattr_get_file.2 \
+ fcntl.2 \
+ ffclock.2 \
+ fhlink.2 \
+ fhopen.2 \
+ fhreadlink.2 \
+ flock.2 \
+ fork.2 \
+ fspacectl.2 \
+ fsync.2 \
+ getdirentries.2 \
+ getdtablesize.2 \
+ getfh.2 \
+ getfsstat.2 \
+ getgid.2 \
+ getgroups.2 \
+ getitimer.2 \
+ getlogin.2 \
+ getloginclass.2 \
+ getpeername.2 \
+ getpgrp.2 \
+ getpid.2 \
+ getpriority.2 \
+ getrandom.2 \
+ getrlimit.2 \
+ getrlimitusage.2 \
+ getrusage.2 \
+ getsid.2 \
+ getsockname.2 \
+ getsockopt.2 \
+ gettimeofday.2 \
+ getuid.2 \
+ inotify.2 \
+ intro.2 \
+ ioctl.2 \
+ issetugid.2 \
+ jail.2 \
+ kcmp.2 \
+ kenv.2 \
+ kill.2 \
+ kldfind.2 \
+ kldfirstmod.2 \
+ kldload.2 \
+ kldnext.2 \
+ kldstat.2 \
+ kldsym.2 \
+ kldunload.2 \
+ kqueue.2 \
+ ktrace.2 \
+ link.2 \
+ lio_listio.2 \
+ listen.2 \
+ lseek.2 \
+ madvise.2 \
+ membarrier.2 \
+ mincore.2 \
+ minherit.2 \
+ mkdir.2 \
+ mkfifo.2 \
+ mknod.2 \
+ mlock.2 \
+ mlockall.2 \
+ mmap.2 \
+ modfind.2 \
+ modnext.2 \
+ modstat.2 \
+ mount.2 \
+ mprotect.2 \
+ mq_close.2 \
+ mq_getattr.2 \
+ mq_notify.2 \
+ mq_open.2 \
+ mq_receive.2 \
+ mq_send.2 \
+ mq_setattr.2 \
+ mq_unlink.2 \
+ msgctl.2 \
+ msgget.2 \
+ msgrcv.2 \
+ msgsnd.2 \
+ msync.2 \
+ munmap.2 \
+ nanosleep.2 \
+ nfssvc.2 \
+ ntp_adjtime.2 \
+ open.2 \
+ pathconf.2 \
+ pdfork.2 \
+ pipe.2 \
+ poll.2 \
+ posix_fadvise.2 \
+ posix_fallocate.2 \
+ posix_openpt.2 \
+ procctl.2 \
+ profil.2 \
+ pselect.2 \
+ ptrace.2 \
+ quotactl.2 \
+ rctl_add_rule.2 \
+ read.2 \
+ readlink.2 \
+ reboot.2 \
+ recv.2 \
+ rename.2 \
+ revoke.2 \
+ rfork.2 \
+ rmdir.2 \
+ rtprio.2 \
+ sched_get_priority_max.2 \
+ sched_getcpu.3 \
+ sched_setparam.2 \
+ sched_setscheduler.2 \
+ sched_yield.2 \
+ sctp_generic_recvmsg.2 \
+ sctp_generic_sendmsg.2 \
+ sctp_peeloff.2 \
+ select.2 \
+ semctl.2 \
+ semget.2 \
+ semop.2 \
+ send.2 \
+ setcred.2 \
+ setfib.2 \
+ sendfile.2 \
+ setgroups.2 \
+ setpgid.2 \
+ setregid.2 \
+ setresuid.2 \
+ setreuid.2 \
+ setsid.2 \
+ setuid.2 \
+ shmat.2 \
+ shmctl.2 \
+ shmget.2 \
+ shm_open.2 \
+ shutdown.2 \
+ sigaction.2 \
+ sigaltstack.2 \
+ sigfastblock.2 \
+ sigpending.2 \
+ sigprocmask.2 \
+ sigqueue.2 \
+ sigreturn.2 \
+ sigstack.2 \
+ sigsuspend.2 \
+ sigwait.2 \
+ sigwaitinfo.2 \
+ socket.2 \
+ socketpair.2 \
+ stat.2 \
+ statfs.2 \
+ swapon.2 \
+ symlink.2 \
+ sync.2 \
+ sysarch.2 \
+ syscall.2 \
+ thr_exit.2 \
+ thr_kill.2 \
+ thr_new.2 \
+ thr_self.2 \
+ thr_set_name.2 \
+ thr_suspend.2 \
+ thr_wake.2 \
+ timer_create.2 \
+ timer_delete.2 \
+ timer_settime.2 \
+ timerfd.2 \
+ truncate.2 \
+ umask.2 \
+ undelete.2 \
+ unlink.2 \
+ utimensat.2 \
+ utimes.2 \
+ utrace.2 \
+ uuidgen.2 \
+ vfork.2 \
+ wait.2 \
+ write.2 \
+ _umtx_op.2
+
+MAN+= \
+ getpagesize.3 \
+ getpagesizes.3 \
+ lockf.3 \
+ rfork_thread.3 \
+ sleep.3 \
+ usleep.3
+
+MLINKS+=aio_read.2 aio_readv.2 \
+ aio_read.2 aio_read2.2
+MLINKS+=aio_write.2 aio_writev.2 \
+ aio_write.2 aio_write2.2
+MLINKS+=accept.2 accept4.2
+MLINKS+=access.2 eaccess.2 \
+ access.2 faccessat.2
+MLINKS+=auxv.3 elf_aux_info.3
+MLINKS+=brk.2 sbrk.2
+MLINKS+=cap_enter.2 cap_getmode.2
+MLINKS+=cap_fcntls_limit.2 cap_fcntls_get.2
+MLINKS+=cap_ioctls_limit.2 cap_ioctls_get.2
+MLINKS+=chdir.2 fchdir.2
+MLINKS+=chflags.2 chflagsat.2 \
+ chflags.2 fchflags.2 \
+ chflags.2 lchflags.2
+MLINKS+=chmod.2 fchmod.2 \
+ chmod.2 fchmodat.2 \
+ chmod.2 lchmod.2
+MLINKS+=chown.2 fchown.2 \
+ chown.2 fchownat.2 \
+ chown.2 lchown.2
+MLINKS+=chroot.2 fchroot.2
+MLINKS+=clock_gettime.2 clock_getres.2 \
+ clock_gettime.2 clock_settime.2
+MLINKS+=closefrom.2 close_range.2
+MLINKS+=nanosleep.2 clock_nanosleep.2
+MLINKS+=cpuset.2 cpuset_getid.2 \
+ cpuset.2 cpuset_setid.2
+MLINKS+=cpuset_getaffinity.2 cpuset_setaffinity.2
+MLINKS+=cpuset_getdomain.2 cpuset_setdomain.2
+MLINKS+=dup.2 dup2.2
+MLINKS+=eventfd.2 eventfd_read.3 \
+ eventfd.2 eventfd_write.3
+MLINKS+=execve.2 fexecve.2
+MLINKS+=extattr_get_file.2 extattr.2 \
+ extattr_get_file.2 extattr_delete_fd.2 \
+ extattr_get_file.2 extattr_delete_file.2 \
+ extattr_get_file.2 extattr_delete_link.2 \
+ extattr_get_file.2 extattr_get_fd.2 \
+ extattr_get_file.2 extattr_get_link.2 \
+ extattr_get_file.2 extattr_list_fd.2 \
+ extattr_get_file.2 extattr_list_file.2 \
+ extattr_get_file.2 extattr_list_link.2 \
+ extattr_get_file.2 extattr_set_fd.2 \
+ extattr_get_file.2 extattr_set_file.2 \
+ extattr_get_file.2 extattr_set_link.2
+MLINKS+=ffclock.2 ffclock_getcounter.2 \
+ ffclock.2 ffclock_getestimate.2 \
+ ffclock.2 ffclock_setestimate.2
+MLINKS+=fhlink.2 fhlinkat.2
+MLINKS+=fhopen.2 fhstat.2 fhopen.2 fhstatfs.2
+MLINKS+=fork.2 _Fork.2
+MLINKS+=fsync.2 fdatasync.2
+MLINKS+=getdirentries.2 getdents.2
+MLINKS+=getfh.2 lgetfh.2 \
+ getfh.2 getfhat.2
+MLINKS+=getgid.2 getegid.2
+MLINKS+=getitimer.2 setitimer.2
+MLINKS+=getlogin.2 getlogin_r.3
+MLINKS+=getlogin.2 setlogin.2
+MLINKS+=getloginclass.2 setloginclass.2
+MLINKS+=getpgrp.2 getpgid.2
+MLINKS+=getpid.2 getppid.2
+MLINKS+=getpriority.2 setpriority.2
+MLINKS+=getrlimit.2 setrlimit.2
+MLINKS+=getsockopt.2 setsockopt.2
+MLINKS+=gettimeofday.2 settimeofday.2
+MLINKS+=getuid.2 geteuid.2
+MLINKS+=inotify.2 inotify_init.2 \
+ inotify.2 inotify_init1.2 \
+ inotify.2 inotify_add_watch.2 \
+ inotify.2 inotify_add_watch_at.2 \
+ inotify.2 inotify_rm_watch.2
+MLINKS+=intro.2 errno.2
+MLINKS+=jail.2 jail_attach.2 \
+ jail.2 jail_get.2 \
+ jail.2 jail_remove.2 \
+ jail.2 jail_set.2
+MLINKS+=kldunload.2 kldunloadf.2
+MLINKS+=kqueue.2 kevent.2 \
+ kqueue.2 kqueue1.2 \
+ kqueue.2 kqueuex.2 \
+ kqueue.2 EV_SET.3
+MLINKS+=link.2 linkat.2
+MLINKS+=madvise.2 posix_madvise.2
+MLINKS+=mkdir.2 mkdirat.2
+MLINKS+=mkfifo.2 mkfifoat.2
+MLINKS+=mknod.2 mknodat.2
+MLINKS+=mlock.2 munlock.2
+MLINKS+=mlockall.2 munlockall.2
+MLINKS+=modnext.2 modfnext.2
+MLINKS+=mount.2 nmount.2 \
+ mount.2 unmount.2
+MLINKS+=mq_receive.2 mq_timedreceive.2
+MLINKS+=mq_send.2 mq_timedsend.2
+MLINKS+=ntp_adjtime.2 ntp_gettime.2
+MLINKS+=open.2 openat.2
+MLINKS+=pathconf.2 fpathconf.2
+MLINKS+=pathconf.2 lpathconf.2
+MLINKS+=pdfork.2 pdgetpid.2\
+ pdfork.2 pdkill.2
+MLINKS+=pipe.2 pipe2.2
+MLINKS+=poll.2 ppoll.2
+MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \
+ rctl_add_rule.2 rctl_get_racct.2 \
+ rctl_add_rule.2 rctl_get_rules.2 \
+ rctl_add_rule.2 rctl_remove_rule.2
+MLINKS+=read.2 pread.2 \
+ read.2 preadv.2 \
+ read.2 readv.2
+MLINKS+=readlink.2 readlinkat.2
+MLINKS+=recv.2 recvfrom.2 \
+ recv.2 recvmmsg.2 \
+ recv.2 recvmsg.2
+MLINKS+=rename.2 renameat.2
+MLINKS+=rtprio.2 rtprio_thread.2
+MLINKS+=sched_get_priority_max.2 sched_get_priority_min.2 \
+ sched_get_priority_max.2 sched_rr_get_interval.2
+MLINKS+=sched_setparam.2 sched_getparam.2
+MLINKS+=sched_setscheduler.2 sched_getscheduler.2
+MLINKS+=sctp_generic_sendmsg.2 sctp_generic_sendmsg_iov.2
+MLINKS+=select.2 FD_CLR.3 \
+ select.2 FD_ISSET.3 \
+ select.2 FD_SET.3 \
+ select.2 FD_ZERO.3
+MLINKS+=send.2 sendmmsg.2 \
+ send.2 sendmsg.2 \
+ send.2 sendto.2
+MLINKS+=setpgid.2 setpgrp.2
+MLINKS+=setresuid.2 getresgid.2 \
+ setresuid.2 getresuid.2 \
+ setresuid.2 setresgid.2
+MLINKS+=setuid.2 setegid.2 \
+ setuid.2 seteuid.2 \
+ setuid.2 setgid.2
+MLINKS+=shmat.2 shmdt.2
+MLINKS+=shm_open.2 memfd_create.3 \
+ shm_open.2 shm_create_largepage.3 \
+ shm_open.2 shm_unlink.2 \
+ shm_open.2 shm_rename.2
+MLINKS+=sigwaitinfo.2 sigtimedwait.2
+MLINKS+=stat.2 fstat.2 \
+ stat.2 fstatat.2 \
+ stat.2 lstat.2
+MLINKS+=statfs.2 fstatfs.2
+MLINKS+=swapon.2 swapoff.2
+MLINKS+=symlink.2 symlinkat.2
+MLINKS+=syscall.2 __syscall.2
+MLINKS+=timer_settime.2 timer_getoverrun.2 \
+ timer_settime.2 timer_gettime.2
+MLINKS+=timerfd.2 timerfd_create.2 \
+ timerfd.2 timerfd_gettime.2 \
+ timerfd.2 timerfd_settime.2
+MLINKS+=thr_kill.2 thr_kill2.2
+MLINKS+=truncate.2 ftruncate.2
+MLINKS+=unlink.2 unlinkat.2
+MLINKS+=unlink.2 funlinkat.2
+MLINKS+=utimensat.2 futimens.2
+MLINKS+=utimes.2 futimes.2 \
+ utimes.2 futimesat.2 \
+ utimes.2 lutimes.2
+MLINKS+=wait.2 wait3.2 \
+ wait.2 wait4.2 \
+ wait.2 waitpid.2 \
+ wait.2 waitid.2 \
+ wait.2 wait6.2
+MLINKS+=write.2 pwrite.2 \
+ write.2 pwritev.2 \
+ write.2 writev.2
+.endif # ${LIB} == "sys"
diff --git a/lib/libsys/Symbol.map b/lib/libsys/Symbol.map
new file mode 100644
index 000000000000..eb71c813ae86
--- /dev/null
+++ b/lib/libsys/Symbol.map
@@ -0,0 +1,13 @@
+FBSDprivate_1.0 {
+ __elf_aux_vector;
+ __libsys_errno;
+ __getosreldate;
+ __libsys_interposing_slot;
+ _elf_aux_info;
+ freebsd11_fstat;
+ freebsd11_fstatat;
+ freebsd11_getfsstat;
+ freebsd11_lstat;
+ freebsd11_stat;
+ freebsd11_statfs;
+};
diff --git a/lib/libsys/Symbol.sys.map b/lib/libsys/Symbol.sys.map
new file mode 100644
index 000000000000..45e0160100af
--- /dev/null
+++ b/lib/libsys/Symbol.sys.map
@@ -0,0 +1,396 @@
+/*
+ * It'd be nice to automatically generate the syscall symbols, but we
+ * don't know to what version they will eventually belong to, so for now
+ * it has to be manual.
+ */
+FBSD_1.0 {
+ __acl_aclcheck_fd;
+ __acl_aclcheck_file;
+ __acl_aclcheck_link;
+ __acl_delete_fd;
+ __acl_delete_file;
+ __acl_delete_link;
+ __acl_get_fd;
+ __acl_get_file;
+ __acl_get_link;
+ __acl_set_fd;
+ __acl_set_file;
+ __acl_set_link;
+ __getcwd;
+ __mac_execve;
+ __mac_get_fd;
+ __mac_get_file;
+ __mac_get_link;
+ __mac_get_pid;
+ __mac_get_proc;
+ __mac_set_fd;
+ __mac_set_file;
+ __mac_set_link;
+ __mac_set_proc;
+ __setugid;
+ __syscall;
+ __sysctl;
+ _exit;
+ _umtx_op;
+ abort2;
+ access;
+ acct;
+ adjtime;
+ aio_cancel;
+ aio_error;
+ aio_fsync;
+ aio_read;
+ aio_return;
+ aio_waitcomplete;
+ aio_write;
+ audit;
+ auditctl;
+ auditon;
+ bind;
+ chdir;
+ chflags;
+ chmod;
+ chown;
+ chroot;
+ clock_getres;
+ clock_gettime;
+ clock_settime;
+ dup;
+ dup2;
+ eaccess;
+ execve;
+ extattr_delete_fd;
+ extattr_delete_file;
+ extattr_delete_link;
+ extattr_get_fd;
+ extattr_get_file;
+ extattr_get_link;
+ extattr_list_fd;
+ extattr_list_file;
+ extattr_list_link;
+ extattr_set_fd;
+ extattr_set_file;
+ extattr_set_link;
+ extattrctl;
+ fchdir;
+ fchflags;
+ fchmod;
+ fchown;
+ fhopen;
+ flock;
+ fpathconf;
+ futimes;
+ getaudit;
+ getaudit_addr;
+ getauid;
+ getcontext;
+ getdtablesize;
+ getegid;
+ geteuid;
+ getfh;
+ getgid;
+ getgroups;
+ getitimer;
+ getpagesize;
+ getpeername;
+ getpgid;
+ getpgrp;
+ getpid;
+ getppid;
+ getpriority;
+ getresgid;
+ getresuid;
+ getrlimit;
+ getrusage;
+ getsid;
+ getsockname;
+ getsockopt;
+ gettimeofday;
+ getuid;
+ ioctl;
+ issetugid;
+ jail;
+ jail_attach;
+ kenv;
+ kill;
+ kldfind;
+ kldfirstmod;
+ kldload;
+ kldnext;
+ kldstat;
+ kldsym;
+ kldunload;
+ kldunloadf;
+ kqueue;
+ kmq_notify; /* Do we want these to be public interfaces? */
+ kmq_open; /* librt uses them to provide mq_xxx. */
+ kmq_setattr;
+ kmq_timedreceive;
+ kmq_timedsend;
+ kmq_unlink;
+ ksem_close;
+ ksem_destroy;
+ ksem_getvalue;
+ ksem_init;
+ ksem_open;
+ ksem_post;
+ ksem_timedwait;
+ ksem_trywait;
+ ksem_unlink;
+ ksem_wait;
+ ktrace;
+ lchflags;
+ lchmod;
+ lchown;
+ lgetfh;
+ link;
+ lio_listio;
+ listen;
+ lutimes;
+ mac_syscall;
+ madvise;
+ mincore;
+ minherit;
+ mkdir;
+ mkfifo;
+ mlock;
+ mlockall;
+ modfind;
+ modfnext;
+ modnext;
+ modstat;
+ mount;
+ mprotect;
+ msgget;
+ msgrcv;
+ msgsnd;
+ msgsys;
+ munlock;
+ munlockall;
+ munmap;
+ nfssvc;
+ nmount;
+ ntp_adjtime;
+ ntp_gettime;
+ pathconf;
+ posix_openpt;
+ preadv;
+ profil;
+ pwritev;
+ quotactl;
+ readlink;
+ reboot;
+ rename;
+ revoke;
+ rfork;
+ rmdir;
+ rtprio;
+ rtprio_thread;
+ sched_get_priority_max;
+ sched_get_priority_min;
+ sched_getparam;
+ sched_getscheduler;
+ sched_rr_get_interval;
+ sched_setparam;
+ sched_setscheduler;
+ sched_yield;
+ semget;
+ semop;
+ semsys;
+ sendfile;
+ setaudit;
+ setaudit_addr;
+ setauid;
+ setegid;
+ seteuid;
+ setgid;
+ setgroups;
+ setitimer;
+ setlogin;
+ setpgid;
+ setpriority;
+ setregid;
+ setresgid;
+ setresuid;
+ setreuid;
+ setrlimit;
+ setsid;
+ setsockopt;
+ settimeofday;
+ setuid;
+ shm_unlink;
+ shmat;
+ shmdt;
+ shmget;
+ shmsys;
+ shutdown;
+ sigaltstack;
+ sigpending;
+ sigqueue;
+ sigreturn;
+ socket;
+ socketpair;
+ swapon;
+ symlink;
+ sync;
+ sysarch;
+ syscall;
+ thr_create;
+ thr_exit;
+ thr_kill;
+ thr_kill2;
+ thr_new;
+ thr_self;
+ thr_set_name;
+ thr_suspend;
+ thr_wake;
+ ktimer_create; /* Do we want these to be public interfaces? */
+ ktimer_delete; /* librt uses them to provide timer_xxx. */
+ ktimer_getoverrun;
+ ktimer_gettime;
+ ktimer_settime;
+ umask;
+ undelete;
+ unlink;
+ unmount;
+ utimes;
+ utrace;
+ uuidgen;
+ vfork;
+
+ __error;
+ ftruncate;
+ lseek;
+ mmap;
+ pread;
+ pwrite;
+ truncate;
+};
+
+FBSD_1.1 {
+ __semctl;
+ cpuset;
+ cpuset_getid;
+ cpuset_setid;
+ cpuset_getaffinity;
+ cpuset_setaffinity;
+ faccessat;
+ fchmodat;
+ fchownat;
+ fexecve;
+ futimesat;
+ jail_get;
+ jail_set;
+ jail_remove;
+ linkat;
+ lpathconf;
+ mkdirat;
+ mkfifoat;
+ msgctl;
+ readlinkat;
+ renameat;
+ setfib;
+ shmctl;
+ symlinkat;
+ unlinkat;
+};
+
+FBSD_1.2 {
+ cap_enter;
+ cap_getmode;
+ getloginclass;
+ getpagesizes;
+ pdgetpid;
+ pdkill;
+ posix_fallocate;
+ rctl_get_racct;
+ rctl_get_rules;
+ rctl_get_limits;
+ rctl_add_rule;
+ rctl_remove_rule;
+ setloginclass;
+};
+
+FBSD_1.3 {
+ aio_mlock;
+ bindat;
+ cap_fcntls_get;
+ cap_fcntls_limit;
+ cap_ioctls_get;
+ cap_ioctls_limit;
+ __cap_rights_get;
+ cap_rights_limit;
+ chflagsat;
+ clock_getcpuclockid2;
+ connectat;
+ ffclock_getcounter;
+ ffclock_getestimate;
+ ffclock_setestimate;
+ pipe2;
+ posix_fadvise;
+ procctl;
+};
+
+FBSD_1.4 {
+ futimens;
+ utimensat;
+};
+
+FBSD_1.5 {
+ elf_aux_info;
+ fhstat;
+ fhstatfs;
+ fstat;
+ fstatat;
+ fstatfs;
+ getdirentries;
+ getfsstat;
+ getrandom;
+ mknodat;
+ statfs;
+ cpuset_getdomain;
+ cpuset_setdomain;
+};
+
+FBSD_1.6 {
+ __sysctlbyname;
+ aio_readv;
+ aio_writev;
+ close_range;
+ copy_file_range;
+ fhlink;
+ fhlinkat;
+ fhreadlink;
+ getfhat;
+ funlinkat;
+ shm_rename;
+};
+
+FBSD_1.7 {
+ fspacectl;
+ kqueuex;
+ membarrier;
+ sched_getcpu;
+ swapoff;
+ timerfd_create;
+ timerfd_gettime;
+ timerfd_settime;
+};
+
+FBSD_1.8 {
+ exterrctl;
+ fchroot;
+ getrlimitusage;
+ inotify_add_watch_at;
+ inotify_rm_watch;
+ kcmp;
+ setcred;
+};
+
+FBSDprivate_1.0 {
+ /* Add entries in sort(1) order */
+ __set_error_selector;
+ __sigwait;
+ nlm_syscall;
+ rpctls_syscall;
+};
diff --git a/lib/libsys/Symbol.thr.map b/lib/libsys/Symbol.thr.map
new file mode 100644
index 000000000000..a245de2e547a
--- /dev/null
+++ b/lib/libsys/Symbol.thr.map
@@ -0,0 +1,3 @@
+FBSDprivate_1.0 {
+ _umtx_op_err;
+};
diff --git a/lib/libsys/__error.c b/lib/libsys/__error.c
new file mode 100644
index 000000000000..41016e9a1ed2
--- /dev/null
+++ b/lib/libsys/__error.c
@@ -0,0 +1,57 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
+ * 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 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.
+ */
+
+#include "libc_private.h"
+
+int __libsys_errno;
+#ifdef LIBSYS
+__sym_compat(errno, __libsys_errno, FBSD_1.0);
+#endif
+
+static int *
+__error_unthreaded(void)
+{
+ return (&__libsys_errno);
+}
+
+static int *(*__error_selector)(void) = __error_unthreaded;
+
+void
+__set_error_selector(int *(*arg)(void))
+{
+ __error_selector = arg;
+}
+
+int *
+__error(void)
+{
+ return (__error_selector());
+}
diff --git a/lib/libsys/__getosreldate.c b/lib/libsys/__getosreldate.c
new file mode 100644
index 000000000000..0bb2efd2ba6a
--- /dev/null
+++ b/lib/libsys/__getosreldate.c
@@ -0,0 +1,53 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2007 Peter Wemm
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <errno.h>
+#include <link.h>
+#include "libc_private.h"
+
+/*
+ * This is private to libc. It is intended for wrapping syscall stubs in order
+ * to avoid having to put SIGSYS signal handlers in place to test for presence
+ * of new syscalls. This caches the result in order to be as quick as possible.
+ *
+ * Use getosreldate(3) for public use as it respects the $OSVERSION environment
+ * variable.
+ */
+
+int
+__getosreldate(void)
+{
+ static int osreldate;
+
+ if (osreldate != 0)
+ return (osreldate);
+
+ (void)_elf_aux_info(AT_OSRELDATE, &osreldate, sizeof(osreldate));
+ return (osreldate);
+}
diff --git a/lib/libsys/__vdso_gettimeofday.c b/lib/libsys/__vdso_gettimeofday.c
new file mode 100644
index 000000000000..273eeb58d195
--- /dev/null
+++ b/lib/libsys/__vdso_gettimeofday.c
@@ -0,0 +1,196 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.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.
+ *
+ * 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.
+ */
+
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <strings.h>
+#include <time.h>
+#include <machine/atomic.h>
+#include "libc_private.h"
+
+static int
+tc_delta(const struct vdso_timehands *th, u_int *delta)
+{
+ int error;
+ u_int tc;
+
+ error = __vdso_gettc(th, &tc);
+ if (error == 0)
+ *delta = (tc - th->th_offset_count) & th->th_counter_mask;
+ return (error);
+}
+
+/*
+ * Calculate the absolute or boot-relative time from the
+ * machine-specific fast timecounter and the published timehands
+ * structure read from the shared page.
+ *
+ * The lockless reading scheme is similar to the one used to read the
+ * in-kernel timehands, see sys/kern/kern_tc.c:binuptime(). This code
+ * is based on the kernel implementation.
+ */
+static int
+binuptime(struct bintime *bt, struct vdso_timekeep *tk, bool abs)
+{
+ struct vdso_timehands *th;
+ uint32_t curr, gen;
+ uint64_t scale, x;
+ u_int delta, scale_bits;
+ int error;
+
+ do {
+ if (!tk->tk_enabled)
+ return (ENOSYS);
+
+ curr = atomic_load_acq_32(&tk->tk_current);
+ th = &tk->tk_th[curr];
+ gen = atomic_load_acq_32(&th->th_gen);
+ *bt = th->th_offset;
+ error = tc_delta(th, &delta);
+ if (error == EAGAIN)
+ continue;
+ if (error != 0)
+ return (error);
+ scale = th->th_scale;
+#ifdef _LP64
+ scale_bits = flsl(scale);
+#else
+ scale_bits = flsll(scale);
+#endif
+ if (__predict_false(scale_bits + fls(delta) > 63)) {
+ x = (scale >> 32) * delta;
+ scale &= 0xffffffff;
+ bt->sec += x >> 32;
+ bintime_addx(bt, x << 32);
+ }
+ bintime_addx(bt, scale * delta);
+ if (abs)
+ bintime_add(bt, &th->th_boottime);
+
+ /*
+ * Ensure that the load of th_offset is completed
+ * before the load of th_gen.
+ */
+ atomic_thread_fence_acq();
+ } while (curr != tk->tk_current || gen == 0 || gen != th->th_gen);
+ return (0);
+}
+
+static int
+getnanouptime(struct bintime *bt, struct vdso_timekeep *tk)
+{
+ struct vdso_timehands *th;
+ uint32_t curr, gen;
+
+ do {
+ if (!tk->tk_enabled)
+ return (ENOSYS);
+
+ curr = atomic_load_acq_32(&tk->tk_current);
+ th = &tk->tk_th[curr];
+ gen = atomic_load_acq_32(&th->th_gen);
+ *bt = th->th_offset;
+
+ /*
+ * Ensure that the load of th_offset is completed
+ * before the load of th_gen.
+ */
+ atomic_thread_fence_acq();
+ } while (curr != tk->tk_current || gen == 0 || gen != th->th_gen);
+ return (0);
+}
+
+static struct vdso_timekeep *tk;
+
+#pragma weak __vdso_gettimeofday
+int
+__vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ struct bintime bt;
+ int error;
+
+ if (tz != NULL)
+ return (ENOSYS);
+ if (tk == NULL) {
+ error = __vdso_gettimekeep(&tk);
+ if (error != 0 || tk == NULL)
+ return (ENOSYS);
+ }
+ if (tk->tk_ver != VDSO_TK_VER_CURR)
+ return (ENOSYS);
+ error = binuptime(&bt, tk, true);
+ if (error != 0)
+ return (error);
+ bintime2timeval(&bt, tv);
+ return (0);
+}
+
+#pragma weak __vdso_clock_gettime
+int
+__vdso_clock_gettime(clockid_t clock_id, struct timespec *ts)
+{
+ struct bintime bt;
+ int error;
+
+ if (tk == NULL) {
+ error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk));
+ if (error != 0 || tk == NULL)
+ return (ENOSYS);
+ }
+ if (tk->tk_ver != VDSO_TK_VER_CURR)
+ return (ENOSYS);
+ switch (clock_id) {
+ case CLOCK_REALTIME:
+ case CLOCK_REALTIME_PRECISE:
+ case CLOCK_REALTIME_FAST:
+ case CLOCK_SECOND:
+ error = binuptime(&bt, tk, true);
+ break;
+ case CLOCK_MONOTONIC:
+ case CLOCK_MONOTONIC_PRECISE:
+ case CLOCK_UPTIME:
+ case CLOCK_UPTIME_PRECISE:
+ error = binuptime(&bt, tk, false);
+ break;
+ case CLOCK_MONOTONIC_FAST:
+ case CLOCK_UPTIME_FAST:
+ error = getnanouptime(&bt, tk);
+ break;
+ default:
+ error = ENOSYS;
+ break;
+ }
+ if (error != 0)
+ return (error);
+ bintime2timespec(&bt, ts);
+ if (clock_id == CLOCK_SECOND)
+ ts->tv_nsec = 0;
+ return (0);
+}
diff --git a/lib/libsys/_exit.2 b/lib/libsys/_exit.2
new file mode 100644
index 000000000000..6f038f79f6ea
--- /dev/null
+++ b/lib/libsys/_exit.2
@@ -0,0 +1,122 @@
+.\" Copyright (c) 1980, 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.
+.\"
+.Dd September 8, 2016
+.Dt EXIT 2
+.Os
+.Sh NAME
+.Nm _exit
+.Nd terminate the calling process
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft void
+.Fn _exit "int status"
+.Sh DESCRIPTION
+The
+.Fn _exit
+system call
+terminates a process with the following consequences:
+.Bl -bullet
+.It
+All of the descriptors open in the calling process are closed.
+This may entail delays, for example, waiting for output to drain;
+a process in this state may not be killed, as it is already dying.
+.It
+If the parent process of the calling process has an outstanding
+.Xr wait 2
+call
+or catches the
+.Dv SIGCHLD
+signal,
+it is notified of the calling process's termination and
+the
+.Fa status
+is set as defined by
+.Xr wait 2 .
+.It
+The parent process-ID of all of the calling process's existing child
+processes are set to the process-ID of the calling process's reaper;
+the reaper (normally the initialization process)
+inherits each of these processes
+(see
+.Xr procctl 2 ,
+.Xr init 8
+and the
+.Sx DEFINITIONS
+section of
+.Xr intro 2 ) .
+.It
+If the termination of the process causes any process group
+to become orphaned (usually because the parents of all members
+of the group have now exited; see
+.Dq orphaned process group
+in
+.Xr intro 2 ) ,
+and if any member of the orphaned group is stopped,
+the
+.Dv SIGHUP
+signal and the
+.Dv SIGCONT
+signal are sent to all members of the newly-orphaned process group.
+.It
+If the process is a controlling process (see
+.Xr intro 2 ) ,
+the
+.Dv SIGHUP
+signal is sent to the foreground process group of the controlling terminal,
+and all current access to the controlling terminal is revoked.
+.El
+.Pp
+Most C programs call the library routine
+.Xr exit 3 ,
+which flushes buffers, closes streams, unlinks temporary files, etc.,
+before
+calling
+.Fn _exit .
+.Sh RETURN VALUES
+The
+.Fn _exit
+system call
+can never return.
+.Sh SEE ALSO
+.Xr fork 2 ,
+.Xr sigaction 2 ,
+.Xr wait 2 ,
+.Xr exit 3 ,
+.Xr init 8
+.Sh STANDARDS
+The
+.Fn _exit
+system call is expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn _exit
+function appeared in
+.At v7 .
diff --git a/lib/libsys/_libsys.h b/lib/libsys/_libsys.h
new file mode 100644
index 000000000000..7a1685cca2d1
--- /dev/null
+++ b/lib/libsys/_libsys.h
@@ -0,0 +1,877 @@
+/*
+ * Public system call stubs provided by libsys.
+ *
+ * Do not use directly, include <libsys.h> instead.
+ *
+ * DO NOT EDIT-- this file is automatically @generated.
+ */
+
+#ifndef __LIBSYS_H_
+#define __LIBSYS_H_
+
+#include <sys/_cpuset.h>
+#include <sys/_domainset.h>
+#include <sys/_ffcounter.h>
+#include <sys/_semaphore.h>
+#include <sys/_sigaltstack.h>
+#include <machine/ucontext.h> /* for mcontext_t */
+#include <sys/_ucontext.h>
+#include <sys/wait.h>
+
+struct __siginfo;
+struct __ucontext;
+struct __wrusage;
+struct acl;
+struct aiocb;
+struct auditinfo;
+struct auditinfo_addr;
+struct ffclock_estimate;
+struct fhandle;
+struct iovec;
+struct itimerspec;
+struct itimerval;
+struct jail;
+struct kevent;
+struct kld_file_stat;
+struct mac;
+struct module_stat;
+struct mq_attr;
+struct msghdr;
+struct msqid_ds;
+struct ntptimeval;
+struct pollfd;
+struct rlimit;
+struct rtprio;
+struct rusage;
+struct sched_param;
+struct sctp_sndrcvinfo;
+struct sembuf;
+struct setcred;
+struct sf_hdtr;
+struct shmid_ds;
+struct sigaction;
+struct sigaltstack;
+struct sigevent;
+struct sockaddr;
+struct spacectl_range;
+struct stat;
+struct statfs;
+struct thr_param;
+struct timespec;
+struct timeval;
+struct timex;
+struct timezone;
+struct uuid;
+union semun;
+
+__BEGIN_DECLS
+typedef void (__sys_exit_t)(int);
+typedef int (__sys_fork_t)(void);
+typedef ssize_t (__sys_read_t)(int, void *, size_t);
+typedef ssize_t (__sys_write_t)(int, const void *, size_t);
+typedef int (__sys_open_t)(const char *, int, mode_t);
+typedef int (__sys_close_t)(int);
+typedef int (__sys_wait4_t)(int, int *, int, struct rusage *);
+typedef int (__sys_link_t)(const char *, const char *);
+typedef int (__sys_unlink_t)(const char *);
+typedef int (__sys_chdir_t)(const char *);
+typedef int (__sys_fchdir_t)(int);
+typedef int (__sys_chmod_t)(const char *, mode_t);
+typedef int (__sys_chown_t)(const char *, int, int);
+typedef void * (__sys_break_t)(char *);
+typedef pid_t (__sys_getpid_t)(void);
+typedef int (__sys_mount_t)(const char *, const char *, int, void *);
+typedef int (__sys_unmount_t)(const char *, int);
+typedef int (__sys_setuid_t)(uid_t);
+typedef uid_t (__sys_getuid_t)(void);
+typedef uid_t (__sys_geteuid_t)(void);
+typedef int (__sys_ptrace_t)(int, pid_t, caddr_t, int);
+typedef ssize_t (__sys_recvmsg_t)(int, struct msghdr *, int);
+typedef ssize_t (__sys_sendmsg_t)(int, const struct msghdr *, int);
+typedef ssize_t (__sys_recvfrom_t)(int, void *, size_t, int, struct sockaddr *, __socklen_t *);
+typedef int (__sys_accept_t)(int, struct sockaddr *, __socklen_t *);
+typedef int (__sys_getpeername_t)(int, struct sockaddr *, __socklen_t *);
+typedef int (__sys_getsockname_t)(int, struct sockaddr *, __socklen_t *);
+typedef int (__sys_access_t)(const char *, int);
+typedef int (__sys_chflags_t)(const char *, u_long);
+typedef int (__sys_fchflags_t)(int, u_long);
+typedef int (__sys_sync_t)(void);
+typedef int (__sys_kill_t)(int, int);
+typedef pid_t (__sys_getppid_t)(void);
+typedef int (__sys_dup_t)(u_int);
+typedef gid_t (__sys_getegid_t)(void);
+typedef int (__sys_profil_t)(char *, size_t, size_t, u_int);
+typedef int (__sys_ktrace_t)(const char *, int, int, int);
+typedef gid_t (__sys_getgid_t)(void);
+typedef int (__sys_getlogin_t)(char *, u_int);
+typedef int (__sys_setlogin_t)(const char *);
+typedef int (__sys_acct_t)(const char *);
+typedef int (__sys_sigaltstack_t)(const struct sigaltstack *, struct sigaltstack *);
+typedef int (__sys_ioctl_t)(int, u_long, char *);
+typedef int (__sys_reboot_t)(int);
+typedef int (__sys_revoke_t)(const char *);
+typedef int (__sys_symlink_t)(const char *, const char *);
+typedef ssize_t (__sys_readlink_t)(const char *, char *, size_t);
+typedef int (__sys_execve_t)(const char *, char **, char **);
+typedef mode_t (__sys_umask_t)(mode_t);
+typedef int (__sys_chroot_t)(const char *);
+typedef int (__sys_msync_t)(void *, size_t, int);
+typedef int (__sys_vfork_t)(void);
+typedef int (__sys_munmap_t)(void *, size_t);
+typedef int (__sys_mprotect_t)(void *, size_t, int);
+typedef int (__sys_madvise_t)(void *, size_t, int);
+typedef int (__sys_mincore_t)(const void *, size_t, char *);
+typedef int (__sys_getgroups_t)(int, gid_t *);
+typedef int (__sys_setgroups_t)(int, const gid_t *);
+typedef int (__sys_getpgrp_t)(void);
+typedef int (__sys_setpgid_t)(int, int);
+typedef int (__sys_setitimer_t)(int, const struct itimerval *, struct itimerval *);
+typedef int (__sys_swapon_t)(const char *);
+typedef int (__sys_getitimer_t)(int, struct itimerval *);
+typedef int (__sys_getdtablesize_t)(void);
+typedef int (__sys_dup2_t)(u_int, u_int);
+typedef int (__sys_fcntl_t)(int, int, intptr_t);
+typedef int (__sys_select_t)(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+typedef int (__sys_fsync_t)(int);
+typedef int (__sys_setpriority_t)(int, int, int);
+typedef int (__sys_socket_t)(int, int, int);
+typedef int (__sys_connect_t)(int, const struct sockaddr *, __socklen_t);
+typedef int (__sys_getpriority_t)(int, int);
+typedef int (__sys_bind_t)(int, const struct sockaddr *, __socklen_t);
+typedef int (__sys_setsockopt_t)(int, int, int, const void *, __socklen_t);
+typedef int (__sys_listen_t)(int, int);
+typedef int (__sys_gettimeofday_t)(struct timeval *, struct timezone *);
+typedef int (__sys_getrusage_t)(int, struct rusage *);
+typedef int (__sys_getsockopt_t)(int, int, int, void *, __socklen_t *);
+typedef ssize_t (__sys_readv_t)(int, const struct iovec *, u_int);
+typedef ssize_t (__sys_writev_t)(int, const struct iovec *, u_int);
+typedef int (__sys_settimeofday_t)(const struct timeval *, const struct timezone *);
+typedef int (__sys_fchown_t)(int, int, int);
+typedef int (__sys_fchmod_t)(int, mode_t);
+typedef int (__sys_setreuid_t)(int, int);
+typedef int (__sys_setregid_t)(int, int);
+typedef int (__sys_rename_t)(const char *, const char *);
+typedef int (__sys_flock_t)(int, int);
+typedef int (__sys_mkfifo_t)(const char *, mode_t);
+typedef ssize_t (__sys_sendto_t)(int, const void *, size_t, int, const struct sockaddr *, __socklen_t);
+typedef int (__sys_shutdown_t)(int, int);
+typedef int (__sys_socketpair_t)(int, int, int, int *);
+typedef int (__sys_mkdir_t)(const char *, mode_t);
+typedef int (__sys_rmdir_t)(const char *);
+typedef int (__sys_utimes_t)(const char *, const struct timeval *);
+typedef int (__sys_adjtime_t)(const struct timeval *, struct timeval *);
+typedef int (__sys_setsid_t)(void);
+typedef int (__sys_quotactl_t)(const char *, int, int, void *);
+typedef int (__sys_nlm_syscall_t)(int, int, int, char **);
+typedef int (__sys_nfssvc_t)(int, void *);
+typedef int (__sys_lgetfh_t)(const char *, struct fhandle *);
+typedef int (__sys_getfh_t)(const char *, struct fhandle *);
+typedef int (__sys_sysarch_t)(int, char *);
+typedef int (__sys_rtprio_t)(int, pid_t, struct rtprio *);
+typedef int (__sys_semsys_t)(int, int, int, int, int);
+typedef int (__sys_msgsys_t)(int, int, int, int, int, int);
+typedef int (__sys_shmsys_t)(int, int, int, int);
+typedef int (__sys_setfib_t)(int);
+typedef int (__sys_ntp_adjtime_t)(struct timex *);
+typedef int (__sys_setgid_t)(gid_t);
+typedef int (__sys_setegid_t)(gid_t);
+typedef int (__sys_seteuid_t)(uid_t);
+typedef int (__sys_pathconf_t)(const char *, int);
+typedef int (__sys_fpathconf_t)(int, int);
+typedef int (__sys_getrlimit_t)(u_int, struct rlimit *);
+typedef int (__sys_setrlimit_t)(u_int, struct rlimit *);
+typedef int (__sys___sysctl_t)(const int *, u_int, void *, size_t *, const void *, size_t);
+typedef int (__sys_mlock_t)(const void *, size_t);
+typedef int (__sys_munlock_t)(const void *, size_t);
+typedef int (__sys_undelete_t)(const char *);
+typedef int (__sys_futimes_t)(int, const struct timeval *);
+typedef int (__sys_getpgid_t)(pid_t);
+typedef int (__sys_poll_t)(struct pollfd *, u_int, int);
+typedef int (__sys_semget_t)(key_t, int, int);
+typedef int (__sys_semop_t)(int, struct sembuf *, size_t);
+typedef int (__sys_msgget_t)(key_t, int);
+typedef int (__sys_msgsnd_t)(int, const void *, size_t, int);
+typedef ssize_t (__sys_msgrcv_t)(int, void *, size_t, long, int);
+typedef void * (__sys_shmat_t)(int, const void *, int);
+typedef int (__sys_shmdt_t)(const void *);
+typedef int (__sys_shmget_t)(key_t, size_t, int);
+typedef int (__sys_clock_gettime_t)(clockid_t, struct timespec *);
+typedef int (__sys_clock_settime_t)(clockid_t, const struct timespec *);
+typedef int (__sys_clock_getres_t)(clockid_t, struct timespec *);
+typedef int (__sys_ktimer_create_t)(clockid_t, struct sigevent *, int *);
+typedef int (__sys_ktimer_delete_t)(int);
+typedef int (__sys_ktimer_settime_t)(int, int, const struct itimerspec *, struct itimerspec *);
+typedef int (__sys_ktimer_gettime_t)(int, struct itimerspec *);
+typedef int (__sys_ktimer_getoverrun_t)(int);
+typedef int (__sys_nanosleep_t)(const struct timespec *, struct timespec *);
+typedef int (__sys_ffclock_getcounter_t)(ffcounter *);
+typedef int (__sys_ffclock_setestimate_t)(struct ffclock_estimate *);
+typedef int (__sys_ffclock_getestimate_t)(struct ffclock_estimate *);
+typedef int (__sys_clock_nanosleep_t)(clockid_t, int, const struct timespec *, struct timespec *);
+typedef int (__sys_clock_getcpuclockid2_t)(id_t, int, clockid_t *);
+typedef int (__sys_ntp_gettime_t)(struct ntptimeval *);
+typedef int (__sys_minherit_t)(void *, size_t, int);
+typedef int (__sys_rfork_t)(int);
+typedef int (__sys_issetugid_t)(void);
+typedef int (__sys_lchown_t)(const char *, int, int);
+typedef int (__sys_aio_read_t)(struct aiocb *);
+typedef int (__sys_aio_write_t)(struct aiocb *);
+typedef int (__sys_lio_listio_t)(int, struct aiocb * const *, int, struct sigevent *);
+typedef int (__sys_lchmod_t)(const char *, mode_t);
+typedef int (__sys_lutimes_t)(const char *, const struct timeval *);
+typedef ssize_t (__sys_preadv_t)(int, struct iovec *, u_int, off_t);
+typedef ssize_t (__sys_pwritev_t)(int, struct iovec *, u_int, off_t);
+typedef int (__sys_fhopen_t)(const struct fhandle *, int);
+typedef int (__sys_modnext_t)(int);
+typedef int (__sys_modstat_t)(int, struct module_stat *);
+typedef int (__sys_modfnext_t)(int);
+typedef int (__sys_modfind_t)(const char *);
+typedef int (__sys_kldload_t)(const char *);
+typedef int (__sys_kldunload_t)(int);
+typedef int (__sys_kldfind_t)(const char *);
+typedef int (__sys_kldnext_t)(int);
+typedef int (__sys_kldstat_t)(int, struct kld_file_stat *);
+typedef int (__sys_kldfirstmod_t)(int);
+typedef int (__sys_getsid_t)(pid_t);
+typedef int (__sys_setresuid_t)(uid_t, uid_t, uid_t);
+typedef int (__sys_setresgid_t)(gid_t, gid_t, gid_t);
+typedef ssize_t (__sys_aio_return_t)(struct aiocb *);
+typedef int (__sys_aio_suspend_t)(const struct aiocb * const *, int, const struct timespec *);
+typedef int (__sys_aio_cancel_t)(int, struct aiocb *);
+typedef int (__sys_aio_error_t)(struct aiocb *);
+typedef int (__sys_mlockall_t)(int);
+typedef int (__sys_munlockall_t)(void);
+typedef int (__sys___getcwd_t)(char *, size_t);
+typedef int (__sys_sched_setparam_t)(pid_t, const struct sched_param *);
+typedef int (__sys_sched_getparam_t)(pid_t, struct sched_param *);
+typedef int (__sys_sched_setscheduler_t)(pid_t, int, const struct sched_param *);
+typedef int (__sys_sched_getscheduler_t)(pid_t);
+typedef int (__sys_sched_yield_t)(void);
+typedef int (__sys_sched_get_priority_max_t)(int);
+typedef int (__sys_sched_get_priority_min_t)(int);
+typedef int (__sys_sched_rr_get_interval_t)(pid_t, struct timespec *);
+typedef int (__sys_utrace_t)(const void *, size_t);
+typedef int (__sys_kldsym_t)(int, int, void *);
+typedef int (__sys_jail_t)(struct jail *);
+typedef int (__sys_nnpfs_syscall_t)(int, char *, int, void *, int);
+typedef int (__sys_sigprocmask_t)(int, const sigset_t *, sigset_t *);
+typedef int (__sys_sigsuspend_t)(const sigset_t *);
+typedef int (__sys_sigpending_t)(sigset_t *);
+typedef int (__sys_sigtimedwait_t)(const sigset_t *, struct __siginfo *, const struct timespec *);
+typedef int (__sys_sigwaitinfo_t)(const sigset_t *, struct __siginfo *);
+typedef int (__sys___acl_get_file_t)(const char *, __acl_type_t, struct acl *);
+typedef int (__sys___acl_set_file_t)(const char *, __acl_type_t, struct acl *);
+typedef int (__sys___acl_get_fd_t)(int, __acl_type_t, struct acl *);
+typedef int (__sys___acl_set_fd_t)(int, __acl_type_t, struct acl *);
+typedef int (__sys___acl_delete_file_t)(const char *, __acl_type_t);
+typedef int (__sys___acl_delete_fd_t)(int, __acl_type_t);
+typedef int (__sys___acl_aclcheck_file_t)(const char *, __acl_type_t, struct acl *);
+typedef int (__sys___acl_aclcheck_fd_t)(int, __acl_type_t, struct acl *);
+typedef int (__sys_extattrctl_t)(const char *, int, const char *, int, const char *);
+typedef ssize_t (__sys_extattr_set_file_t)(const char *, int, const char *, void *, size_t);
+typedef ssize_t (__sys_extattr_get_file_t)(const char *, int, const char *, void *, size_t);
+typedef int (__sys_extattr_delete_file_t)(const char *, int, const char *);
+typedef ssize_t (__sys_aio_waitcomplete_t)(struct aiocb **, struct timespec *);
+typedef int (__sys_getresuid_t)(uid_t *, uid_t *, uid_t *);
+typedef int (__sys_getresgid_t)(gid_t *, gid_t *, gid_t *);
+typedef int (__sys_kqueue_t)(void);
+typedef ssize_t (__sys_extattr_set_fd_t)(int, int, const char *, void *, size_t);
+typedef ssize_t (__sys_extattr_get_fd_t)(int, int, const char *, void *, size_t);
+typedef int (__sys_extattr_delete_fd_t)(int, int, const char *);
+typedef int (__sys___setugid_t)(int);
+typedef int (__sys_eaccess_t)(const char *, int);
+typedef int (__sys_afs3_syscall_t)(long, long, long, long, long, long, long);
+typedef int (__sys_nmount_t)(struct iovec *, unsigned int, int);
+typedef int (__sys___mac_get_proc_t)(struct mac *);
+typedef int (__sys___mac_set_proc_t)(struct mac *);
+typedef int (__sys___mac_get_fd_t)(int, struct mac *);
+typedef int (__sys___mac_get_file_t)(const char *, struct mac *);
+typedef int (__sys___mac_set_fd_t)(int, struct mac *);
+typedef int (__sys___mac_set_file_t)(const char *, struct mac *);
+typedef int (__sys_kenv_t)(int, const char *, char *, int);
+typedef int (__sys_lchflags_t)(const char *, u_long);
+typedef int (__sys_uuidgen_t)(struct uuid *, int);
+typedef int (__sys_sendfile_t)(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int);
+typedef int (__sys_mac_syscall_t)(const char *, int, void *);
+typedef int (__sys_ksem_close_t)(semid_t);
+typedef int (__sys_ksem_post_t)(semid_t);
+typedef int (__sys_ksem_wait_t)(semid_t);
+typedef int (__sys_ksem_trywait_t)(semid_t);
+typedef int (__sys_ksem_init_t)(semid_t *, unsigned int);
+typedef int (__sys_ksem_open_t)(semid_t *, const char *, int, mode_t, unsigned int);
+typedef int (__sys_ksem_unlink_t)(const char *);
+typedef int (__sys_ksem_getvalue_t)(semid_t, int *);
+typedef int (__sys_ksem_destroy_t)(semid_t);
+typedef int (__sys___mac_get_pid_t)(pid_t, struct mac *);
+typedef int (__sys___mac_get_link_t)(const char *, struct mac *);
+typedef int (__sys___mac_set_link_t)(const char *, struct mac *);
+typedef ssize_t (__sys_extattr_set_link_t)(const char *, int, const char *, void *, size_t);
+typedef ssize_t (__sys_extattr_get_link_t)(const char *, int, const char *, void *, size_t);
+typedef int (__sys_extattr_delete_link_t)(const char *, int, const char *);
+typedef int (__sys___mac_execve_t)(const char *, char **, char **, struct mac *);
+typedef int (__sys_sigaction_t)(int, const struct sigaction *, struct sigaction *);
+typedef int (__sys_sigreturn_t)(const struct __ucontext *);
+typedef int (__sys_getcontext_t)(struct __ucontext *);
+typedef int (__sys_setcontext_t)(const struct __ucontext *);
+typedef int (__sys_swapcontext_t)(struct __ucontext *, const struct __ucontext *);
+typedef int (__sys___acl_get_link_t)(const char *, __acl_type_t, struct acl *);
+typedef int (__sys___acl_set_link_t)(const char *, __acl_type_t, struct acl *);
+typedef int (__sys___acl_delete_link_t)(const char *, __acl_type_t);
+typedef int (__sys___acl_aclcheck_link_t)(const char *, __acl_type_t, struct acl *);
+typedef int (__sys_sigwait_t)(const sigset_t *, int *);
+typedef int (__sys_thr_create_t)(ucontext_t *, long *, int);
+typedef void (__sys_thr_exit_t)(long *);
+typedef int (__sys_thr_self_t)(long *);
+typedef int (__sys_thr_kill_t)(long, int);
+typedef int (__sys_jail_attach_t)(int);
+typedef ssize_t (__sys_extattr_list_fd_t)(int, int, void *, size_t);
+typedef ssize_t (__sys_extattr_list_file_t)(const char *, int, void *, size_t);
+typedef ssize_t (__sys_extattr_list_link_t)(const char *, int, void *, size_t);
+typedef int (__sys_ksem_timedwait_t)(semid_t, const struct timespec *);
+typedef int (__sys_thr_suspend_t)(const struct timespec *);
+typedef int (__sys_thr_wake_t)(long);
+typedef int (__sys_kldunloadf_t)(int, int);
+typedef int (__sys_audit_t)(const void *, u_int);
+typedef int (__sys_auditon_t)(int, void *, u_int);
+typedef int (__sys_getauid_t)(uid_t *);
+typedef int (__sys_setauid_t)(uid_t *);
+typedef int (__sys_getaudit_t)(struct auditinfo *);
+typedef int (__sys_setaudit_t)(struct auditinfo *);
+typedef int (__sys_getaudit_addr_t)(struct auditinfo_addr *, u_int);
+typedef int (__sys_setaudit_addr_t)(struct auditinfo_addr *, u_int);
+typedef int (__sys_auditctl_t)(const char *);
+typedef int (__sys__umtx_op_t)(void *, int, u_long, void *, void *);
+typedef int (__sys_thr_new_t)(struct thr_param *, int);
+typedef int (__sys_sigqueue_t)(pid_t, int, void *);
+typedef int (__sys_kmq_open_t)(const char *, int, mode_t, const struct mq_attr *);
+typedef int (__sys_kmq_setattr_t)(int, const struct mq_attr *, struct mq_attr *);
+typedef int (__sys_kmq_timedreceive_t)(int, char *, size_t, unsigned *, const struct timespec *);
+typedef int (__sys_kmq_timedsend_t)(int, const char *, size_t, unsigned, const struct timespec *);
+typedef int (__sys_kmq_notify_t)(int, const struct sigevent *);
+typedef int (__sys_kmq_unlink_t)(const char *);
+typedef void (__sys_abort2_t)(const char *, int, void **);
+typedef int (__sys_thr_set_name_t)(long, const char *);
+typedef int (__sys_aio_fsync_t)(int, struct aiocb *);
+typedef int (__sys_rtprio_thread_t)(int, lwpid_t, struct rtprio *);
+typedef int (__sys_sctp_peeloff_t)(int, uint32_t);
+typedef int (__sys_sctp_generic_sendmsg_t)(int, void *, int, const struct sockaddr *, __socklen_t, struct sctp_sndrcvinfo *, int);
+typedef int (__sys_sctp_generic_sendmsg_iov_t)(int, struct iovec *, int, const struct sockaddr *, __socklen_t, struct sctp_sndrcvinfo *, int);
+typedef int (__sys_sctp_generic_recvmsg_t)(int, struct iovec *, int, struct sockaddr *, __socklen_t *, struct sctp_sndrcvinfo *, int *);
+typedef ssize_t (__sys_pread_t)(int, void *, size_t, off_t);
+typedef ssize_t (__sys_pwrite_t)(int, const void *, size_t, off_t);
+typedef void * (__sys_mmap_t)(void *, size_t, int, int, int, off_t);
+typedef off_t (__sys_lseek_t)(int, off_t, int);
+typedef int (__sys_truncate_t)(const char *, off_t);
+typedef int (__sys_ftruncate_t)(int, off_t);
+typedef int (__sys_thr_kill2_t)(pid_t, long, int);
+typedef int (__sys_shm_unlink_t)(const char *);
+typedef int (__sys_cpuset_t)(cpusetid_t *);
+typedef int (__sys_cpuset_setid_t)(cpuwhich_t, id_t, cpusetid_t);
+typedef int (__sys_cpuset_getid_t)(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
+typedef int (__sys_cpuset_getaffinity_t)(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t *);
+typedef int (__sys_cpuset_setaffinity_t)(cpulevel_t, cpuwhich_t, id_t, size_t, const cpuset_t *);
+typedef int (__sys_faccessat_t)(int, const char *, int, int);
+typedef int (__sys_fchmodat_t)(int, const char *, mode_t, int);
+typedef int (__sys_fchownat_t)(int, const char *, uid_t, gid_t, int);
+typedef int (__sys_fexecve_t)(int, char **, char **);
+typedef int (__sys_futimesat_t)(int, const char *, const struct timeval *);
+typedef int (__sys_linkat_t)(int, const char *, int, const char *, int);
+typedef int (__sys_mkdirat_t)(int, const char *, mode_t);
+typedef int (__sys_mkfifoat_t)(int, const char *, mode_t);
+typedef int (__sys_openat_t)(int, const char *, int, mode_t);
+typedef ssize_t (__sys_readlinkat_t)(int, const char *, char *, size_t);
+typedef int (__sys_renameat_t)(int, const char *, int, const char *);
+typedef int (__sys_symlinkat_t)(const char *, int, const char *);
+typedef int (__sys_unlinkat_t)(int, const char *, int);
+typedef int (__sys_posix_openpt_t)(int);
+typedef int (__sys_jail_get_t)(struct iovec *, unsigned int, int);
+typedef int (__sys_jail_set_t)(struct iovec *, unsigned int, int);
+typedef int (__sys_jail_remove_t)(int);
+typedef int (__sys___semctl_t)(int, int, int, union semun *);
+typedef int (__sys_msgctl_t)(int, int, struct msqid_ds *);
+typedef int (__sys_shmctl_t)(int, int, struct shmid_ds *);
+typedef int (__sys_lpathconf_t)(const char *, int);
+typedef int (__sys___cap_rights_get_t)(int, int, cap_rights_t *);
+typedef int (__sys_cap_enter_t)(void);
+typedef int (__sys_cap_getmode_t)(u_int *);
+typedef int (__sys_pdfork_t)(int *, int);
+typedef int (__sys_pdkill_t)(int, int);
+typedef int (__sys_pdgetpid_t)(int, pid_t *);
+typedef int (__sys_pselect_t)(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *);
+typedef int (__sys_getloginclass_t)(char *, size_t);
+typedef int (__sys_setloginclass_t)(const char *);
+typedef int (__sys_rctl_get_racct_t)(const void *, size_t, void *, size_t);
+typedef int (__sys_rctl_get_rules_t)(const void *, size_t, void *, size_t);
+typedef int (__sys_rctl_get_limits_t)(const void *, size_t, void *, size_t);
+typedef int (__sys_rctl_add_rule_t)(const void *, size_t, void *, size_t);
+typedef int (__sys_rctl_remove_rule_t)(const void *, size_t, void *, size_t);
+typedef int (__sys_posix_fallocate_t)(int, off_t, off_t);
+typedef int (__sys_posix_fadvise_t)(int, off_t, off_t, int);
+typedef int (__sys_wait6_t)(idtype_t, id_t, int *, int, struct __wrusage *, struct __siginfo *);
+typedef int (__sys_cap_rights_limit_t)(int, cap_rights_t *);
+typedef int (__sys_cap_ioctls_limit_t)(int, const u_long *, size_t);
+typedef ssize_t (__sys_cap_ioctls_get_t)(int, u_long *, size_t);
+typedef int (__sys_cap_fcntls_limit_t)(int, uint32_t);
+typedef int (__sys_cap_fcntls_get_t)(int, uint32_t *);
+typedef int (__sys_bindat_t)(int, int, const struct sockaddr *, __socklen_t);
+typedef int (__sys_connectat_t)(int, int, const struct sockaddr *, __socklen_t);
+typedef int (__sys_chflagsat_t)(int, const char *, u_long, int);
+typedef int (__sys_accept4_t)(int, struct sockaddr *, __socklen_t *, int);
+typedef int (__sys_pipe2_t)(int *, int);
+typedef int (__sys_aio_mlock_t)(struct aiocb *);
+typedef int (__sys_procctl_t)(idtype_t, id_t, int, void *);
+typedef int (__sys_ppoll_t)(struct pollfd *, u_int, const struct timespec *, const sigset_t *);
+typedef int (__sys_futimens_t)(int, const struct timespec *);
+typedef int (__sys_utimensat_t)(int, const char *, const struct timespec *, int);
+typedef int (__sys_fdatasync_t)(int);
+typedef int (__sys_fstat_t)(int, struct stat *);
+typedef int (__sys_fstatat_t)(int, const char *, struct stat *, int);
+typedef int (__sys_fhstat_t)(const struct fhandle *, struct stat *);
+typedef ssize_t (__sys_getdirentries_t)(int, char *, size_t, off_t *);
+typedef int (__sys_statfs_t)(const char *, struct statfs *);
+typedef int (__sys_fstatfs_t)(int, struct statfs *);
+typedef int (__sys_getfsstat_t)(struct statfs *, long, int);
+typedef int (__sys_fhstatfs_t)(const struct fhandle *, struct statfs *);
+typedef int (__sys_mknodat_t)(int, const char *, mode_t, dev_t);
+typedef int (__sys_kevent_t)(int, const struct kevent *, int, struct kevent *, int, const struct timespec *);
+typedef int (__sys_cpuset_getdomain_t)(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *, int *);
+typedef int (__sys_cpuset_setdomain_t)(cpulevel_t, cpuwhich_t, id_t, size_t, domainset_t *, int);
+typedef int (__sys_getrandom_t)(void *, size_t, unsigned int);
+typedef int (__sys_getfhat_t)(int, char *, struct fhandle *, int);
+typedef int (__sys_fhlink_t)(struct fhandle *, const char *);
+typedef int (__sys_fhlinkat_t)(struct fhandle *, int, const char *);
+typedef int (__sys_fhreadlink_t)(struct fhandle *, char *, size_t);
+typedef int (__sys_funlinkat_t)(int, const char *, int, int);
+typedef ssize_t (__sys_copy_file_range_t)(int, off_t *, int, off_t *, size_t, unsigned int);
+typedef int (__sys___sysctlbyname_t)(const char *, size_t, void *, size_t *, void *, size_t);
+typedef int (__sys_shm_open2_t)(const char *, int, mode_t, int, const char *);
+typedef int (__sys_shm_rename_t)(const char *, const char *, int);
+typedef int (__sys_sigfastblock_t)(int, void *);
+typedef int (__sys___realpathat_t)(int, const char *, char *, size_t, int);
+typedef int (__sys_close_range_t)(u_int, u_int, int);
+typedef int (__sys_rpctls_syscall_t)(uint64_t);
+typedef int (__sys___specialfd_t)(int, const void *, size_t);
+typedef int (__sys_aio_writev_t)(struct aiocb *);
+typedef int (__sys_aio_readv_t)(struct aiocb *);
+typedef int (__sys_fspacectl_t)(int, int, const struct spacectl_range *, int, struct spacectl_range *);
+typedef int (__sys_sched_getcpu_t)(void);
+typedef int (__sys_swapoff_t)(const char *, u_int);
+typedef int (__sys_kqueuex_t)(u_int);
+typedef int (__sys_membarrier_t)(int, unsigned, int);
+typedef int (__sys_timerfd_create_t)(int, int);
+typedef int (__sys_timerfd_gettime_t)(int, struct itimerspec *);
+typedef int (__sys_timerfd_settime_t)(int, int, const struct itimerspec *, struct itimerspec *);
+typedef int (__sys_kcmp_t)(pid_t, pid_t, int, uintptr_t, uintptr_t);
+typedef int (__sys_getrlimitusage_t)(u_int, int, rlim_t *);
+typedef int (__sys_fchroot_t)(int);
+typedef int (__sys_setcred_t)(u_int, const struct setcred *, size_t);
+typedef int (__sys_exterrctl_t)(u_int, u_int, void *);
+typedef int (__sys_inotify_add_watch_at_t)(int, int, const char *, uint32_t);
+typedef int (__sys_inotify_rm_watch_t)(int, int);
+
+void __sys_exit(int rval);
+int __sys_fork(void);
+ssize_t __sys_read(int fd, void * buf, size_t nbyte);
+ssize_t __sys_write(int fd, const void * buf, size_t nbyte);
+int __sys_open(const char * path, int flags, mode_t mode);
+int __sys_close(int fd);
+int __sys_wait4(int pid, int * status, int options, struct rusage * rusage);
+int __sys_link(const char * path, const char * link);
+int __sys_unlink(const char * path);
+int __sys_chdir(const char * path);
+int __sys_fchdir(int fd);
+int __sys_chmod(const char * path, mode_t mode);
+int __sys_chown(const char * path, int uid, int gid);
+void * __sys_break(char * nsize);
+pid_t __sys_getpid(void);
+int __sys_mount(const char * type, const char * path, int flags, void * data);
+int __sys_unmount(const char * path, int flags);
+int __sys_setuid(uid_t uid);
+uid_t __sys_getuid(void);
+uid_t __sys_geteuid(void);
+int __sys_ptrace(int req, pid_t pid, caddr_t addr, int data);
+ssize_t __sys_recvmsg(int s, struct msghdr * msg, int flags);
+ssize_t __sys_sendmsg(int s, const struct msghdr * msg, int flags);
+ssize_t __sys_recvfrom(int s, void * buf, size_t len, int flags, struct sockaddr * from, __socklen_t * fromlenaddr);
+int __sys_accept(int s, struct sockaddr * name, __socklen_t * anamelen);
+int __sys_getpeername(int fdes, struct sockaddr * asa, __socklen_t * alen);
+int __sys_getsockname(int fdes, struct sockaddr * asa, __socklen_t * alen);
+int __sys_access(const char * path, int amode);
+int __sys_chflags(const char * path, u_long flags);
+int __sys_fchflags(int fd, u_long flags);
+int __sys_sync(void);
+int __sys_kill(int pid, int signum);
+pid_t __sys_getppid(void);
+int __sys_dup(u_int fd);
+gid_t __sys_getegid(void);
+int __sys_profil(char * samples, size_t size, size_t offset, u_int scale);
+int __sys_ktrace(const char * fname, int ops, int facs, int pid);
+gid_t __sys_getgid(void);
+int __sys_getlogin(char * namebuf, u_int namelen);
+int __sys_setlogin(const char * namebuf);
+int __sys_acct(const char * path);
+int __sys_sigaltstack(const struct sigaltstack * ss, struct sigaltstack * oss);
+int __sys_ioctl(int fd, u_long com, char * data);
+int __sys_reboot(int opt);
+int __sys_revoke(const char * path);
+int __sys_symlink(const char * path, const char * link);
+ssize_t __sys_readlink(const char * path, char * buf, size_t count);
+int __sys_execve(const char * fname, char ** argv, char ** envv);
+mode_t __sys_umask(mode_t newmask);
+int __sys_chroot(const char * path);
+int __sys_msync(void * addr, size_t len, int flags);
+int __sys_vfork(void);
+int __sys_munmap(void * addr, size_t len);
+int __sys_mprotect(void * addr, size_t len, int prot);
+int __sys_madvise(void * addr, size_t len, int behav);
+int __sys_mincore(const void * addr, size_t len, char * vec);
+int __sys_getgroups(int gidsetsize, gid_t * gidset);
+int __sys_setgroups(int gidsetsize, const gid_t * gidset);
+int __sys_getpgrp(void);
+int __sys_setpgid(int pid, int pgid);
+int __sys_setitimer(int which, const struct itimerval * itv, struct itimerval * oitv);
+int __sys_swapon(const char * name);
+int __sys_getitimer(int which, struct itimerval * itv);
+int __sys_getdtablesize(void);
+int __sys_dup2(u_int from, u_int to);
+int __sys_fcntl(int fd, int cmd, intptr_t arg);
+int __sys_select(int nd, fd_set * in, fd_set * ou, fd_set * ex, struct timeval * tv);
+int __sys_fsync(int fd);
+int __sys_setpriority(int which, int who, int prio);
+int __sys_socket(int domain, int type, int protocol);
+int __sys_connect(int s, const struct sockaddr * name, __socklen_t namelen);
+int __sys_getpriority(int which, int who);
+int __sys_bind(int s, const struct sockaddr * name, __socklen_t namelen);
+int __sys_setsockopt(int s, int level, int name, const void * val, __socklen_t valsize);
+int __sys_listen(int s, int backlog);
+int __sys_gettimeofday(struct timeval * tp, struct timezone * tzp);
+int __sys_getrusage(int who, struct rusage * rusage);
+int __sys_getsockopt(int s, int level, int name, void * val, __socklen_t * avalsize);
+ssize_t __sys_readv(int fd, const struct iovec * iovp, u_int iovcnt);
+ssize_t __sys_writev(int fd, const struct iovec * iovp, u_int iovcnt);
+int __sys_settimeofday(const struct timeval * tv, const struct timezone * tzp);
+int __sys_fchown(int fd, int uid, int gid);
+int __sys_fchmod(int fd, mode_t mode);
+int __sys_setreuid(int ruid, int euid);
+int __sys_setregid(int rgid, int egid);
+int __sys_rename(const char * from, const char * to);
+int __sys_flock(int fd, int how);
+int __sys_mkfifo(const char * path, mode_t mode);
+ssize_t __sys_sendto(int s, const void * buf, size_t len, int flags, const struct sockaddr * to, __socklen_t tolen);
+int __sys_shutdown(int s, int how);
+int __sys_socketpair(int domain, int type, int protocol, int * rsv);
+int __sys_mkdir(const char * path, mode_t mode);
+int __sys_rmdir(const char * path);
+int __sys_utimes(const char * path, const struct timeval * tptr);
+int __sys_adjtime(const struct timeval * delta, struct timeval * olddelta);
+int __sys_setsid(void);
+int __sys_quotactl(const char * path, int cmd, int uid, void * arg);
+int __sys_nlm_syscall(int debug_level, int grace_period, int addr_count, char ** addrs);
+int __sys_nfssvc(int flag, void * argp);
+int __sys_lgetfh(const char * fname, struct fhandle * fhp);
+int __sys_getfh(const char * fname, struct fhandle * fhp);
+int __sys_sysarch(int op, char * parms);
+int __sys_rtprio(int function, pid_t pid, struct rtprio * rtp);
+int __sys_semsys(int which, int a2, int a3, int a4, int a5);
+int __sys_msgsys(int which, int a2, int a3, int a4, int a5, int a6);
+int __sys_shmsys(int which, int a2, int a3, int a4);
+int __sys_setfib(int fibnum);
+int __sys_ntp_adjtime(struct timex * tp);
+int __sys_setgid(gid_t gid);
+int __sys_setegid(gid_t egid);
+int __sys_seteuid(uid_t euid);
+int __sys_pathconf(const char * path, int name);
+int __sys_fpathconf(int fd, int name);
+int __sys_getrlimit(u_int which, struct rlimit * rlp);
+int __sys_setrlimit(u_int which, struct rlimit * rlp);
+int __sys___sysctl(const int * name, u_int namelen, void * old, size_t * oldlenp, const void * new, size_t newlen);
+int __sys_mlock(const void * addr, size_t len);
+int __sys_munlock(const void * addr, size_t len);
+int __sys_undelete(const char * path);
+int __sys_futimes(int fd, const struct timeval * tptr);
+int __sys_getpgid(pid_t pid);
+int __sys_poll(struct pollfd * fds, u_int nfds, int timeout);
+int __sys_semget(key_t key, int nsems, int semflg);
+int __sys_semop(int semid, struct sembuf * sops, size_t nsops);
+int __sys_msgget(key_t key, int msgflg);
+int __sys_msgsnd(int msqid, const void * msgp, size_t msgsz, int msgflg);
+ssize_t __sys_msgrcv(int msqid, void * msgp, size_t msgsz, long msgtyp, int msgflg);
+void * __sys_shmat(int shmid, const void * shmaddr, int shmflg);
+int __sys_shmdt(const void * shmaddr);
+int __sys_shmget(key_t key, size_t size, int shmflg);
+int __sys_clock_gettime(clockid_t clock_id, struct timespec * tp);
+int __sys_clock_settime(clockid_t clock_id, const struct timespec * tp);
+int __sys_clock_getres(clockid_t clock_id, struct timespec * tp);
+int __sys_ktimer_create(clockid_t clock_id, struct sigevent * evp, int * timerid);
+int __sys_ktimer_delete(int timerid);
+int __sys_ktimer_settime(int timerid, int flags, const struct itimerspec * value, struct itimerspec * ovalue);
+int __sys_ktimer_gettime(int timerid, struct itimerspec * value);
+int __sys_ktimer_getoverrun(int timerid);
+int __sys_nanosleep(const struct timespec * rqtp, struct timespec * rmtp);
+int __sys_ffclock_getcounter(ffcounter * ffcount);
+int __sys_ffclock_setestimate(struct ffclock_estimate * cest);
+int __sys_ffclock_getestimate(struct ffclock_estimate * cest);
+int __sys_clock_nanosleep(clockid_t clock_id, int flags, const struct timespec * rqtp, struct timespec * rmtp);
+int __sys_clock_getcpuclockid2(id_t id, int which, clockid_t * clock_id);
+int __sys_ntp_gettime(struct ntptimeval * ntvp);
+int __sys_minherit(void * addr, size_t len, int inherit);
+int __sys_rfork(int flags);
+int __sys_issetugid(void);
+int __sys_lchown(const char * path, int uid, int gid);
+int __sys_aio_read(struct aiocb * aiocbp);
+int __sys_aio_write(struct aiocb * aiocbp);
+int __sys_lio_listio(int mode, struct aiocb * const * acb_list, int nent, struct sigevent * sig);
+int __sys_lchmod(const char * path, mode_t mode);
+int __sys_lutimes(const char * path, const struct timeval * tptr);
+ssize_t __sys_preadv(int fd, struct iovec * iovp, u_int iovcnt, off_t offset);
+ssize_t __sys_pwritev(int fd, struct iovec * iovp, u_int iovcnt, off_t offset);
+int __sys_fhopen(const struct fhandle * u_fhp, int flags);
+int __sys_modnext(int modid);
+int __sys_modstat(int modid, struct module_stat * stat);
+int __sys_modfnext(int modid);
+int __sys_modfind(const char * name);
+int __sys_kldload(const char * file);
+int __sys_kldunload(int fileid);
+int __sys_kldfind(const char * file);
+int __sys_kldnext(int fileid);
+int __sys_kldstat(int fileid, struct kld_file_stat * stat);
+int __sys_kldfirstmod(int fileid);
+int __sys_getsid(pid_t pid);
+int __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid);
+int __sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
+ssize_t __sys_aio_return(struct aiocb * aiocbp);
+int __sys_aio_suspend(const struct aiocb * const * aiocbp, int nent, const struct timespec * timeout);
+int __sys_aio_cancel(int fd, struct aiocb * aiocbp);
+int __sys_aio_error(struct aiocb * aiocbp);
+int __sys_mlockall(int how);
+int __sys_munlockall(void);
+int __sys___getcwd(char * buf, size_t buflen);
+int __sys_sched_setparam(pid_t pid, const struct sched_param * param);
+int __sys_sched_getparam(pid_t pid, struct sched_param * param);
+int __sys_sched_setscheduler(pid_t pid, int policy, const struct sched_param * param);
+int __sys_sched_getscheduler(pid_t pid);
+int __sys_sched_yield(void);
+int __sys_sched_get_priority_max(int policy);
+int __sys_sched_get_priority_min(int policy);
+int __sys_sched_rr_get_interval(pid_t pid, struct timespec * interval);
+int __sys_utrace(const void * addr, size_t len);
+int __sys_kldsym(int fileid, int cmd, void * data);
+int __sys_jail(struct jail * jail);
+int __sys_nnpfs_syscall(int operation, char * a_pathP, int a_opcode, void * a_paramsP, int a_followSymlinks);
+int __sys_sigprocmask(int how, const sigset_t * set, sigset_t * oset);
+int __sys_sigsuspend(const sigset_t * sigmask);
+int __sys_sigpending(sigset_t * set);
+int __sys_sigtimedwait(const sigset_t * set, struct __siginfo * info, const struct timespec * timeout);
+int __sys_sigwaitinfo(const sigset_t * set, struct __siginfo * info);
+int __sys___acl_get_file(const char * path, __acl_type_t type, struct acl * aclp);
+int __sys___acl_set_file(const char * path, __acl_type_t type, struct acl * aclp);
+int __sys___acl_get_fd(int filedes, __acl_type_t type, struct acl * aclp);
+int __sys___acl_set_fd(int filedes, __acl_type_t type, struct acl * aclp);
+int __sys___acl_delete_file(const char * path, __acl_type_t type);
+int __sys___acl_delete_fd(int filedes, __acl_type_t type);
+int __sys___acl_aclcheck_file(const char * path, __acl_type_t type, struct acl * aclp);
+int __sys___acl_aclcheck_fd(int filedes, __acl_type_t type, struct acl * aclp);
+int __sys_extattrctl(const char * path, int cmd, const char * filename, int attrnamespace, const char * attrname);
+ssize_t __sys_extattr_set_file(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
+ssize_t __sys_extattr_get_file(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
+int __sys_extattr_delete_file(const char * path, int attrnamespace, const char * attrname);
+ssize_t __sys_aio_waitcomplete(struct aiocb ** aiocbp, struct timespec * timeout);
+int __sys_getresuid(uid_t * ruid, uid_t * euid, uid_t * suid);
+int __sys_getresgid(gid_t * rgid, gid_t * egid, gid_t * sgid);
+int __sys_kqueue(void);
+ssize_t __sys_extattr_set_fd(int fd, int attrnamespace, const char * attrname, void * data, size_t nbytes);
+ssize_t __sys_extattr_get_fd(int fd, int attrnamespace, const char * attrname, void * data, size_t nbytes);
+int __sys_extattr_delete_fd(int fd, int attrnamespace, const char * attrname);
+int __sys___setugid(int flag);
+int __sys_eaccess(const char * path, int amode);
+int __sys_afs3_syscall(long syscall, long parm1, long parm2, long parm3, long parm4, long parm5, long parm6);
+int __sys_nmount(struct iovec * iovp, unsigned int iovcnt, int flags);
+int __sys___mac_get_proc(struct mac * mac_p);
+int __sys___mac_set_proc(struct mac * mac_p);
+int __sys___mac_get_fd(int fd, struct mac * mac_p);
+int __sys___mac_get_file(const char * path_p, struct mac * mac_p);
+int __sys___mac_set_fd(int fd, struct mac * mac_p);
+int __sys___mac_set_file(const char * path_p, struct mac * mac_p);
+int __sys_kenv(int what, const char * name, char * value, int len);
+int __sys_lchflags(const char * path, u_long flags);
+int __sys_uuidgen(struct uuid * store, int count);
+int __sys_sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr * hdtr, off_t * sbytes, int flags);
+int __sys_mac_syscall(const char * policy, int call, void * arg);
+int __sys_ksem_close(semid_t id);
+int __sys_ksem_post(semid_t id);
+int __sys_ksem_wait(semid_t id);
+int __sys_ksem_trywait(semid_t id);
+int __sys_ksem_init(semid_t * idp, unsigned int value);
+int __sys_ksem_open(semid_t * idp, const char * name, int oflag, mode_t mode, unsigned int value);
+int __sys_ksem_unlink(const char * name);
+int __sys_ksem_getvalue(semid_t id, int * val);
+int __sys_ksem_destroy(semid_t id);
+int __sys___mac_get_pid(pid_t pid, struct mac * mac_p);
+int __sys___mac_get_link(const char * path_p, struct mac * mac_p);
+int __sys___mac_set_link(const char * path_p, struct mac * mac_p);
+ssize_t __sys_extattr_set_link(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
+ssize_t __sys_extattr_get_link(const char * path, int attrnamespace, const char * attrname, void * data, size_t nbytes);
+int __sys_extattr_delete_link(const char * path, int attrnamespace, const char * attrname);
+int __sys___mac_execve(const char * fname, char ** argv, char ** envv, struct mac * mac_p);
+int __sys_sigaction(int sig, const struct sigaction * act, struct sigaction * oact);
+int __sys_sigreturn(const struct __ucontext * sigcntxp);
+int __sys_getcontext(struct __ucontext * ucp);
+int __sys_setcontext(const struct __ucontext * ucp);
+int __sys_swapcontext(struct __ucontext * oucp, const struct __ucontext * ucp);
+int __sys___acl_get_link(const char * path, __acl_type_t type, struct acl * aclp);
+int __sys___acl_set_link(const char * path, __acl_type_t type, struct acl * aclp);
+int __sys___acl_delete_link(const char * path, __acl_type_t type);
+int __sys___acl_aclcheck_link(const char * path, __acl_type_t type, struct acl * aclp);
+int __sys_sigwait(const sigset_t * set, int * sig);
+int __sys_thr_create(ucontext_t * ctx, long * id, int flags);
+void __sys_thr_exit(long * state);
+int __sys_thr_self(long * id);
+int __sys_thr_kill(long id, int sig);
+int __sys_jail_attach(int jid);
+ssize_t __sys_extattr_list_fd(int fd, int attrnamespace, void * data, size_t nbytes);
+ssize_t __sys_extattr_list_file(const char * path, int attrnamespace, void * data, size_t nbytes);
+ssize_t __sys_extattr_list_link(const char * path, int attrnamespace, void * data, size_t nbytes);
+int __sys_ksem_timedwait(semid_t id, const struct timespec * abstime);
+int __sys_thr_suspend(const struct timespec * timeout);
+int __sys_thr_wake(long id);
+int __sys_kldunloadf(int fileid, int flags);
+int __sys_audit(const void * record, u_int length);
+int __sys_auditon(int cmd, void * data, u_int length);
+int __sys_getauid(uid_t * auid);
+int __sys_setauid(uid_t * auid);
+int __sys_getaudit(struct auditinfo * auditinfo);
+int __sys_setaudit(struct auditinfo * auditinfo);
+int __sys_getaudit_addr(struct auditinfo_addr * auditinfo_addr, u_int length);
+int __sys_setaudit_addr(struct auditinfo_addr * auditinfo_addr, u_int length);
+int __sys_auditctl(const char * path);
+int __sys__umtx_op(void * obj, int op, u_long val, void * uaddr1, void * uaddr2);
+int __sys_thr_new(struct thr_param * param, int param_size);
+int __sys_sigqueue(pid_t pid, int signum, void * value);
+int __sys_kmq_open(const char * path, int flags, mode_t mode, const struct mq_attr * attr);
+int __sys_kmq_setattr(int mqd, const struct mq_attr * attr, struct mq_attr * oattr);
+int __sys_kmq_timedreceive(int mqd, char * msg_ptr, size_t msg_len, unsigned * msg_prio, const struct timespec * abs_timeout);
+int __sys_kmq_timedsend(int mqd, const char * msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec * abs_timeout);
+int __sys_kmq_notify(int mqd, const struct sigevent * sigev);
+int __sys_kmq_unlink(const char * path);
+void __sys_abort2(const char * why, int nargs, void ** args);
+int __sys_thr_set_name(long id, const char * name);
+int __sys_aio_fsync(int op, struct aiocb * aiocbp);
+int __sys_rtprio_thread(int function, lwpid_t lwpid, struct rtprio * rtp);
+int __sys_sctp_peeloff(int sd, uint32_t name);
+int __sys_sctp_generic_sendmsg(int sd, void * msg, int mlen, const struct sockaddr * to, __socklen_t tolen, struct sctp_sndrcvinfo * sinfo, int flags);
+int __sys_sctp_generic_sendmsg_iov(int sd, struct iovec * iov, int iovlen, const struct sockaddr * to, __socklen_t tolen, struct sctp_sndrcvinfo * sinfo, int flags);
+int __sys_sctp_generic_recvmsg(int sd, struct iovec * iov, int iovlen, struct sockaddr * from, __socklen_t * fromlenaddr, struct sctp_sndrcvinfo * sinfo, int * msg_flags);
+ssize_t __sys_pread(int fd, void * buf, size_t nbyte, off_t offset);
+ssize_t __sys_pwrite(int fd, const void * buf, size_t nbyte, off_t offset);
+void * __sys_mmap(void * addr, size_t len, int prot, int flags, int fd, off_t pos);
+off_t __sys_lseek(int fd, off_t offset, int whence);
+int __sys_truncate(const char * path, off_t length);
+int __sys_ftruncate(int fd, off_t length);
+int __sys_thr_kill2(pid_t pid, long id, int sig);
+int __sys_shm_unlink(const char * path);
+int __sys_cpuset(cpusetid_t * setid);
+int __sys_cpuset_setid(cpuwhich_t which, id_t id, cpusetid_t setid);
+int __sys_cpuset_getid(cpulevel_t level, cpuwhich_t which, id_t id, cpusetid_t * setid);
+int __sys_cpuset_getaffinity(cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, cpuset_t * mask);
+int __sys_cpuset_setaffinity(cpulevel_t level, cpuwhich_t which, id_t id, size_t cpusetsize, const cpuset_t * mask);
+int __sys_faccessat(int fd, const char * path, int amode, int flag);
+int __sys_fchmodat(int fd, const char * path, mode_t mode, int flag);
+int __sys_fchownat(int fd, const char * path, uid_t uid, gid_t gid, int flag);
+int __sys_fexecve(int fd, char ** argv, char ** envv);
+int __sys_futimesat(int fd, const char * path, const struct timeval * times);
+int __sys_linkat(int fd1, const char * path1, int fd2, const char * path2, int flag);
+int __sys_mkdirat(int fd, const char * path, mode_t mode);
+int __sys_mkfifoat(int fd, const char * path, mode_t mode);
+int __sys_openat(int fd, const char * path, int flag, mode_t mode);
+ssize_t __sys_readlinkat(int fd, const char * path, char * buf, size_t bufsize);
+int __sys_renameat(int oldfd, const char * old, int newfd, const char * new);
+int __sys_symlinkat(const char * path1, int fd, const char * path2);
+int __sys_unlinkat(int fd, const char * path, int flag);
+int __sys_posix_openpt(int flags);
+int __sys_jail_get(struct iovec * iovp, unsigned int iovcnt, int flags);
+int __sys_jail_set(struct iovec * iovp, unsigned int iovcnt, int flags);
+int __sys_jail_remove(int jid);
+int __sys___semctl(int semid, int semnum, int cmd, union semun * arg);
+int __sys_msgctl(int msqid, int cmd, struct msqid_ds * buf);
+int __sys_shmctl(int shmid, int cmd, struct shmid_ds * buf);
+int __sys_lpathconf(const char * path, int name);
+int __sys___cap_rights_get(int version, int fd, cap_rights_t * rightsp);
+int __sys_cap_enter(void);
+int __sys_cap_getmode(u_int * modep);
+int __sys_pdfork(int * fdp, int flags);
+int __sys_pdkill(int fd, int signum);
+int __sys_pdgetpid(int fd, pid_t * pidp);
+int __sys_pselect(int nd, fd_set * in, fd_set * ou, fd_set * ex, const struct timespec * ts, const sigset_t * sm);
+int __sys_getloginclass(char * namebuf, size_t namelen);
+int __sys_setloginclass(const char * namebuf);
+int __sys_rctl_get_racct(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
+int __sys_rctl_get_rules(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
+int __sys_rctl_get_limits(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
+int __sys_rctl_add_rule(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
+int __sys_rctl_remove_rule(const void * inbufp, size_t inbuflen, void * outbufp, size_t outbuflen);
+int __sys_posix_fallocate(int fd, off_t offset, off_t len);
+int __sys_posix_fadvise(int fd, off_t offset, off_t len, int advice);
+int __sys_wait6(idtype_t idtype, id_t id, int * status, int options, struct __wrusage * wrusage, struct __siginfo * info);
+int __sys_cap_rights_limit(int fd, cap_rights_t * rightsp);
+int __sys_cap_ioctls_limit(int fd, const u_long * cmds, size_t ncmds);
+ssize_t __sys_cap_ioctls_get(int fd, u_long * cmds, size_t maxcmds);
+int __sys_cap_fcntls_limit(int fd, uint32_t fcntlrights);
+int __sys_cap_fcntls_get(int fd, uint32_t * fcntlrightsp);
+int __sys_bindat(int fd, int s, const struct sockaddr * name, __socklen_t namelen);
+int __sys_connectat(int fd, int s, const struct sockaddr * name, __socklen_t namelen);
+int __sys_chflagsat(int fd, const char * path, u_long flags, int atflag);
+int __sys_accept4(int s, struct sockaddr * name, __socklen_t * anamelen, int flags);
+int __sys_pipe2(int * fildes, int flags);
+int __sys_aio_mlock(struct aiocb * aiocbp);
+int __sys_procctl(idtype_t idtype, id_t id, int com, void * data);
+int __sys_ppoll(struct pollfd * fds, u_int nfds, const struct timespec * ts, const sigset_t * set);
+int __sys_futimens(int fd, const struct timespec * times);
+int __sys_utimensat(int fd, const char * path, const struct timespec * times, int flag);
+int __sys_fdatasync(int fd);
+int __sys_fstat(int fd, struct stat * sb);
+int __sys_fstatat(int fd, const char * path, struct stat * buf, int flag);
+int __sys_fhstat(const struct fhandle * u_fhp, struct stat * sb);
+ssize_t __sys_getdirentries(int fd, char * buf, size_t count, off_t * basep);
+int __sys_statfs(const char * path, struct statfs * buf);
+int __sys_fstatfs(int fd, struct statfs * buf);
+int __sys_getfsstat(struct statfs * buf, long bufsize, int mode);
+int __sys_fhstatfs(const struct fhandle * u_fhp, struct statfs * buf);
+int __sys_mknodat(int fd, const char * path, mode_t mode, dev_t dev);
+int __sys_kevent(int fd, const struct kevent * changelist, int nchanges, struct kevent * eventlist, int nevents, const struct timespec * timeout);
+int __sys_cpuset_getdomain(cpulevel_t level, cpuwhich_t which, id_t id, size_t domainsetsize, domainset_t * mask, int * policy);
+int __sys_cpuset_setdomain(cpulevel_t level, cpuwhich_t which, id_t id, size_t domainsetsize, domainset_t * mask, int policy);
+int __sys_getrandom(void * buf, size_t buflen, unsigned int flags);
+int __sys_getfhat(int fd, char * path, struct fhandle * fhp, int flags);
+int __sys_fhlink(struct fhandle * fhp, const char * to);
+int __sys_fhlinkat(struct fhandle * fhp, int tofd, const char * to);
+int __sys_fhreadlink(struct fhandle * fhp, char * buf, size_t bufsize);
+int __sys_funlinkat(int dfd, const char * path, int fd, int flag);
+ssize_t __sys_copy_file_range(int infd, off_t * inoffp, int outfd, off_t * outoffp, size_t len, unsigned int flags);
+int __sys___sysctlbyname(const char * name, size_t namelen, void * old, size_t * oldlenp, void * new, size_t newlen);
+int __sys_shm_open2(const char * path, int flags, mode_t mode, int shmflags, const char * name);
+int __sys_shm_rename(const char * path_from, const char * path_to, int flags);
+int __sys_sigfastblock(int cmd, void * ptr);
+int __sys___realpathat(int fd, const char * path, char * buf, size_t size, int flags);
+int __sys_close_range(u_int lowfd, u_int highfd, int flags);
+int __sys_rpctls_syscall(uint64_t socookie);
+int __sys___specialfd(int type, const void * req, size_t len);
+int __sys_aio_writev(struct aiocb * aiocbp);
+int __sys_aio_readv(struct aiocb * aiocbp);
+int __sys_fspacectl(int fd, int cmd, const struct spacectl_range * rqsr, int flags, struct spacectl_range * rmsr);
+int __sys_sched_getcpu(void);
+int __sys_swapoff(const char * name, u_int flags);
+int __sys_kqueuex(u_int flags);
+int __sys_membarrier(int cmd, unsigned flags, int cpu_id);
+int __sys_timerfd_create(int clockid, int flags);
+int __sys_timerfd_gettime(int fd, struct itimerspec * curr_value);
+int __sys_timerfd_settime(int fd, int flags, const struct itimerspec * new_value, struct itimerspec * old_value);
+int __sys_kcmp(pid_t pid1, pid_t pid2, int type, uintptr_t idx1, uintptr_t idx2);
+int __sys_getrlimitusage(u_int which, int flags, rlim_t * res);
+int __sys_fchroot(int fd);
+int __sys_setcred(u_int flags, const struct setcred * wcred, size_t size);
+int __sys_exterrctl(u_int op, u_int flags, void * ptr);
+int __sys_inotify_add_watch_at(int fd, int dfd, const char * path, uint32_t mask);
+int __sys_inotify_rm_watch(int fd, int wd);
+__END_DECLS
+
+#endif /* __LIBSYS_H_ */
diff --git a/lib/libsys/_umtx_op.2 b/lib/libsys/_umtx_op.2
new file mode 100644
index 000000000000..c590f8e8e0c8
--- /dev/null
+++ b/lib/libsys/_umtx_op.2
@@ -0,0 +1,1541 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd November 23, 2020
+.Dt _UMTX_OP 2
+.Os
+.Sh NAME
+.Nm _umtx_op
+.Nd interface for implementation of userspace threading synchronization primitives
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/umtx.h
+.Ft int
+.Fn _umtx_op "void *obj" "int op" "u_long val" "void *uaddr" "void *uaddr2"
+.Sh DESCRIPTION
+The
+.Fn _umtx_op
+system call provides kernel support for userspace implementation of
+the threading synchronization primitives.
+The
+.Lb libthr
+uses the syscall to implement
+.St -p1003.1-2001
+pthread locks, like mutexes, condition variables and so on.
+.Ss STRUCTURES
+The operations, performed by the
+.Fn _umtx_op
+syscall, operate on userspace objects which are described
+by the following structures.
+Reserved fields and paddings are omitted.
+All objects require ABI-mandated alignment, but this is not currently
+enforced consistently on all architectures.
+.Pp
+The following flags are defined for flag fields of all structures:
+.Bl -tag -width indent
+.It Dv USYNC_PROCESS_SHARED
+Allow selection of the process-shared sleep queue for the thread sleep
+container, when the lock ownership cannot be granted immediately,
+and the operation must sleep.
+The process-shared or process-private sleep queue is selected based on
+the attributes of the memory mapping which contains the first byte of
+the structure, see
+.Xr mmap 2 .
+Otherwise, if the flag is not specified, the process-private sleep queue
+is selected regardless of the memory mapping attributes, as an optimization.
+.Pp
+See the
+.Sx SLEEP QUEUES
+subsection below for more details on sleep queues.
+.El
+.Bl -hang -offset indent
+.It Sy Mutex
+.Bd -literal
+struct umutex {
+ volatile lwpid_t m_owner;
+ uint32_t m_flags;
+ uint32_t m_ceilings[2];
+ uintptr_t m_rb_lnk;
+};
+.Ed
+.Pp
+The
+.Dv m_owner
+field is the actual lock.
+It contains either the thread identifier of the lock owner in the
+locked state, or zero when the lock is unowned.
+The highest bit set indicates that there is contention on the lock.
+The constants are defined for special values:
+.Bl -tag -width indent
+.It Dv UMUTEX_UNOWNED
+Zero, the value stored in the unowned lock.
+.It Dv UMUTEX_CONTESTED
+The contention indicator.
+.It Dv UMUTEX_RB_OWNERDEAD
+A thread owning the robust mutex terminated.
+The mutex is in unlocked state.
+.It Dv UMUTEX_RB_NOTRECOV
+The robust mutex is in a non-recoverable state.
+It cannot be locked until reinitialized.
+.El
+.Pp
+The
+.Dv m_flags
+field may contain the following umutex-specific flags, in addition to
+the common flags:
+.Bl -tag -width indent
+.It Dv UMUTEX_PRIO_INHERIT
+Mutex implements
+.Em Priority Inheritance
+protocol.
+.It Dv UMUTEX_PRIO_PROTECT
+Mutex implements
+.Em Priority Protection
+protocol.
+.It Dv UMUTEX_ROBUST
+Mutex is robust, as described in the
+.Sx ROBUST UMUTEXES
+section below.
+.It Dv UMUTEX_NONCONSISTENT
+Robust mutex is in a transient non-consistent state.
+Not used by kernel.
+.El
+.Pp
+In the manual page, mutexes not having
+.Dv UMUTEX_PRIO_INHERIT
+and
+.Dv UMUTEX_PRIO_PROTECT
+flags set, are called normal mutexes.
+Each type of mutex
+.Pq normal, priority-inherited, and priority-protected
+has a separate sleep queue associated
+with the given key.
+.Pp
+For priority protected mutexes, the
+.Dv m_ceilings
+array contains priority ceiling values.
+The
+.Dv m_ceilings[0]
+is the ceiling value for the mutex, as specified by
+.St -p1003.1-2008
+for the
+.Em Priority Protected
+mutex protocol.
+The
+.Dv m_ceilings[1]
+is used only for the unlock of a priority protected mutex, when
+unlock is done in an order other than the reversed lock order.
+In this case,
+.Dv m_ceilings[1]
+must contain the ceiling value for the last locked priority protected
+mutex, for proper priority reassignment.
+If, instead, the unlocking mutex was the last priority propagated
+mutex locked by the thread,
+.Dv m_ceilings[1]
+should contain \-1.
+This is required because kernel does not maintain the ordered lock list.
+.It Sy Condition variable
+.Bd -literal
+struct ucond {
+ volatile uint32_t c_has_waiters;
+ uint32_t c_flags;
+ uint32_t c_clockid;
+};
+.Ed
+.Pp
+A non-zero
+.Dv c_has_waiters
+value indicates that there are in-kernel waiters for the condition,
+executing the
+.Dv UMTX_OP_CV_WAIT
+request.
+.Pp
+The
+.Dv c_flags
+field contains flags.
+Only the common flags
+.Pq Dv USYNC_PROCESS_SHARED
+are defined for ucond.
+.Pp
+The
+.Dv c_clockid
+member provides the clock identifier to use for timeout, when the
+.Dv UMTX_OP_CV_WAIT
+request has both the
+.Dv CVWAIT_CLOCKID
+flag and the timeout specified.
+Valid clock identifiers are a subset of those for
+.Xr clock_gettime 2 :
+.Bl -bullet -compact
+.It
+.Dv CLOCK_MONOTONIC
+.It
+.Dv CLOCK_MONOTONIC_FAST
+.It
+.Dv CLOCK_MONOTONIC_PRECISE
+.It
+.Dv CLOCK_PROF
+.It
+.Dv CLOCK_REALTIME
+.It
+.Dv CLOCK_REALTIME_FAST
+.It
+.Dv CLOCK_REALTIME_PRECISE
+.It
+.Dv CLOCK_SECOND
+.It
+.Dv CLOCK_TAI
+.It
+.Dv CLOCK_UPTIME
+.It
+.Dv CLOCK_UPTIME_FAST
+.It
+.Dv CLOCK_UPTIME_PRECISE
+.It
+.Dv CLOCK_VIRTUAL
+.El
+.It Sy Reader/writer lock
+.Bd -literal
+struct urwlock {
+ volatile int32_t rw_state;
+ uint32_t rw_flags;
+ uint32_t rw_blocked_readers;
+ uint32_t rw_blocked_writers;
+};
+.Ed
+.Pp
+The
+.Dv rw_state
+field is the actual lock.
+It contains both the flags and counter of the read locks which were
+granted.
+Names of the
+.Dv rw_state
+bits are following:
+.Bl -tag -width indent
+.It Dv URWLOCK_WRITE_OWNER
+Write lock was granted.
+.It Dv URWLOCK_WRITE_WAITERS
+There are write lock waiters.
+.It Dv URWLOCK_READ_WAITERS
+There are read lock waiters.
+.It Dv URWLOCK_READER_COUNT(c)
+Returns the count of currently granted read locks.
+.El
+.Pp
+At any given time there may be only one thread to which the writer lock
+is granted on the
+.Vt struct rwlock ,
+and no threads are granted read lock.
+Or, at the given time, up to
+.Dv URWLOCK_MAX_READERS
+threads may be granted the read lock simultaneously, but write lock is
+not granted to any thread.
+.Pp
+The following flags for the
+.Dv rw_flags
+member of
+.Vt struct urwlock
+are defined, in addition to the common flags:
+.Bl -tag -width indent
+.It Dv URWLOCK_PREFER_READER
+If specified, immediately grant read lock requests when
+.Dv urwlock
+is already read-locked, even in presence of unsatisfied write
+lock requests.
+By default, if there is a write lock waiter, further read requests are
+not granted, to prevent unfair write lock waiter starvation.
+.El
+.Pp
+The
+.Dv rw_blocked_readers
+and
+.Dv rw_blocked_writers
+members contain the count of threads which are sleeping in kernel,
+waiting for the associated request type to be granted.
+The fields are used by kernel to update the
+.Dv URWLOCK_READ_WAITERS
+and
+.Dv URWLOCK_WRITE_WAITERS
+flags of the
+.Dv rw_state
+lock after requesting thread was woken up.
+.It Sy Semaphore
+.Bd -literal
+struct _usem2 {
+ volatile uint32_t _count;
+ uint32_t _flags;
+};
+.Ed
+.Pp
+The
+.Dv _count
+word represents a counting semaphore.
+A non-zero value indicates an unlocked (posted) semaphore, while zero
+represents the locked state.
+The maximal supported semaphore count is
+.Dv USEM_MAX_COUNT .
+.Pp
+The
+.Dv _count
+word, besides the counter of posts (unlocks), also contains the
+.Dv USEM_HAS_WAITERS
+bit, which indicates that locked semaphore has waiting threads.
+.Pp
+The
+.Dv USEM_COUNT()
+macro, applied to the
+.Dv _count
+word, returns the current semaphore counter, which is the number of posts
+issued on the semaphore.
+.Pp
+The following bits for the
+.Dv _flags
+member of
+.Vt struct _usem2
+are defined, in addition to the common flags:
+.Bl -tag -width indent
+.It Dv USEM_NAMED
+Flag is ignored by kernel.
+.El
+.It Sy Timeout parameter
+.Bd -literal
+struct _umtx_time {
+ struct timespec _timeout;
+ uint32_t _flags;
+ uint32_t _clockid;
+};
+.Ed
+.Pp
+Several
+.Fn _umtx_op
+operations allow the blocking time to be limited, failing the request
+if it cannot be satisfied in the specified time period.
+The timeout is specified by passing either the address of
+.Vt struct timespec ,
+or its extended variant,
+.Vt struct _umtx_time ,
+as the
+.Fa uaddr2
+argument of
+.Fn _umtx_op .
+They are distinguished by the
+.Fa uaddr
+value, which must be equal to the size of the structure pointed to by
+.Fa uaddr2 ,
+casted to
+.Vt uintptr_t .
+.Pp
+The
+.Dv _timeout
+member specifies the time when the timeout should occur.
+Legal values for clock identifier
+.Dv _clockid
+are shared with the
+.Fa clock_id
+argument to the
+.Xr clock_gettime 2
+function,
+and use the same underlying clocks.
+The specified clock is used to obtain the current time value.
+Interval counting is always performed by the monotonic wall clock.
+.Pp
+The
+.Dv _flags
+argument allows the following flags to further define the timeout behaviour:
+.Bl -tag -width indent
+.It Dv UMTX_ABSTIME
+The
+.Dv _timeout
+value is the absolute time.
+The thread will be unblocked and the request failed when specified
+clock value is equal or exceeds the
+.Dv _timeout.
+.Pp
+If the flag is absent, the timeout value is relative, that is the amount
+of time, measured by the monotonic wall clock from the moment of the request
+start.
+.El
+.El
+.Ss SLEEP QUEUES
+When a locking request cannot be immediately satisfied, the thread is
+typically put to
+.Em sleep ,
+which is a non-runnable state terminated by the
+.Em wake
+operation.
+Lock operations include a
+.Em try
+variant which returns an error rather than sleeping if the lock cannot
+be obtained.
+Also,
+.Fn _umtx_op
+provides requests which explicitly put the thread to sleep.
+.Pp
+Wakes need to know which threads to make runnable, so sleeping threads
+are grouped into containers called
+.Em sleep queues .
+A sleep queue is identified by a key, which for
+.Fn _umtx_op
+is defined as the physical address of some variable.
+Note that the
+.Em physical
+address is used, which means that same variable mapped multiple
+times will give one key value.
+This mechanism enables the construction of
+.Em process-shared
+locks.
+.Pp
+A related attribute of the key is shareability.
+Some requests always interpret keys as private for the current process,
+creating sleep queues with the scope of the current process even if
+the memory is shared.
+Others either select the shareability automatically from the
+mapping attributes, or take additional input as the
+.Dv USYNC_PROCESS_SHARED
+common flag.
+This is done as optimization, allowing the lock scope to be limited
+regardless of the kind of backing memory.
+.Pp
+Only the address of the start byte of the variable specified as key is
+important for determining corresponding sleep queue.
+The size of the variable does not matter, so, for example, sleep on the same
+address interpreted as
+.Vt uint32_t
+and
+.Vt long
+on a little-endian 64-bit platform would collide.
+.Pp
+The last attribute of the key is the object type.
+The sleep queue to which a sleeping thread is assigned is an individual
+one for simple wait requests, mutexes, rwlocks, condvars and other
+primitives, even when the physical address of the key is same.
+.Pp
+When waking up a limited number of threads from a given sleep queue,
+the highest priority threads that have been blocked for the longest on
+the queue are selected.
+.Ss ROBUST UMUTEXES
+The
+.Em robust umutexes
+are provided as a substrate for a userspace library to implement
+.Tn POSIX
+robust mutexes.
+A robust umutex must have the
+.Dv UMUTEX_ROBUST
+flag set.
+.Pp
+On thread termination, the kernel walks two lists of mutexes.
+The two lists head addresses must be provided by a prior call to
+.Dv UMTX_OP_ROBUST_LISTS
+request.
+The lists are singly-linked.
+The link to next element is provided by the
+.Dv m_rb_lnk
+member of the
+.Vt struct umutex .
+.Pp
+Robust list processing is aborted if the kernel finds a mutex
+with any of the following conditions:
+.Bl -dash -offset indent -compact
+.It
+the
+.Dv UMUTEX_ROBUST
+flag is not set
+.It
+not owned by the current thread, except when the mutex is pointed to
+by the
+.Dv robust_inactive
+member of the
+.Vt struct umtx_robust_lists_params ,
+registered for the current thread
+.It
+the combination of mutex flags is invalid
+.It
+read of the umutex memory faults
+.It
+the list length limit described in
+.Xr libthr 3
+is reached.
+.El
+.Pp
+Every mutex in both lists is unlocked as if the
+.Dv UMTX_OP_MUTEX_UNLOCK
+request is performed on it, but instead of the
+.Dv UMUTEX_UNOWNED
+value, the
+.Dv m_owner
+field is written with the
+.Dv UMUTEX_RB_OWNERDEAD
+value.
+When a mutex in the
+.Dv UMUTEX_RB_OWNERDEAD
+state is locked by kernel due to the
+.Dv UMTX_OP_MUTEX_TRYLOCK
+and
+.Dv UMTX_OP_MUTEX_LOCK
+requests, the lock is granted and
+.Er EOWNERDEAD
+error is returned.
+.Pp
+Also, the kernel handles the
+.Dv UMUTEX_RB_NOTRECOV
+value of
+.Dv the m_owner
+field specially, always returning the
+.Er ENOTRECOVERABLE
+error for lock attempts, without granting the lock.
+.Ss OPERATIONS
+The following operations, requested by the
+.Fa op
+argument to the function, are implemented:
+.Bl -tag -width indent
+.It Dv UMTX_OP_WAIT
+Wait.
+The arguments for the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to a variable of type
+.Vt long .
+.It Fa val
+Current value of the
+.Dv *obj .
+.El
+.Pp
+The current value of the variable pointed to by the
+.Fa obj
+argument is compared with the
+.Fa val .
+If they are equal, the requesting thread is put to interruptible sleep
+until woken up or the optionally specified timeout expires.
+.Pp
+The comparison and sleep are atomic.
+In other words, if another thread writes a new value to
+.Dv *obj
+and then issues
+.Dv UMTX_OP_WAKE ,
+the request is guaranteed to not miss the wakeup,
+which might otherwise happen between comparison and blocking.
+.Pp
+The physical address of memory where the
+.Fa *obj
+variable is located, is used as a key to index sleeping threads.
+.Pp
+The read of the current value of the
+.Dv *obj
+variable is not guarded by barriers.
+In particular, it is the user's duty to ensure the lock acquire
+and release memory semantics, if the
+.Dv UMTX_OP_WAIT
+and
+.Dv UMTX_OP_WAKE
+requests are used as a substrate for implementing a simple lock.
+.Pp
+The request is not restartable.
+An unblocked signal delivered during the wait always results in sleep
+interruption and
+.Er EINTR
+error.
+.Pp
+Optionally, a timeout for the request may be specified.
+.It Dv UMTX_OP_WAKE
+Wake the threads possibly sleeping due to
+.Dv UMTX_OP_WAIT .
+The arguments for the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to a variable, used as a key to find sleeping threads.
+.It Fa val
+Up to
+.Fa val
+threads are woken up by this request.
+Specify
+.Dv INT_MAX
+to wake up all waiters.
+.El
+.It Dv UMTX_OP_MUTEX_TRYLOCK
+Try to lock umutex.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the umutex.
+.El
+.Pp
+Operates same as the
+.Dv UMTX_OP_MUTEX_LOCK
+request, but returns
+.Er EBUSY
+instead of sleeping if the lock cannot be obtained immediately.
+.It Dv UMTX_OP_MUTEX_LOCK
+Lock umutex.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the umutex.
+.El
+.Pp
+Locking is performed by writing the current thread id into the
+.Dv m_owner
+word of the
+.Vt struct umutex .
+The write is atomic, preserves the
+.Dv UMUTEX_CONTESTED
+contention indicator, and provides the acquire barrier for
+lock entrance semantic.
+.Pp
+If the lock cannot be obtained immediately because another thread owns
+the lock, the current thread is put to sleep, with
+.Dv UMUTEX_CONTESTED
+bit set before.
+Upon wake up, the lock conditions are re-tested.
+.Pp
+The request adheres to the priority protection or inheritance protocol
+of the mutex, specified by the
+.Dv UMUTEX_PRIO_PROTECT
+or
+.Dv UMUTEX_PRIO_INHERIT
+flag, respectively.
+.Pp
+Optionally, a timeout for the request may be specified.
+.Pp
+A request with a timeout specified is not restartable.
+An unblocked signal delivered during the wait always results in sleep
+interruption and
+.Er EINTR
+error.
+A request without timeout specified is always restarted after return
+from a signal handler.
+.It Dv UMTX_OP_MUTEX_UNLOCK
+Unlock umutex.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the umutex.
+.El
+.Pp
+Unlocks the mutex, by writing
+.Dv UMUTEX_UNOWNED
+(zero) value into
+.Dv m_owner
+word of the
+.Vt struct umutex .
+The write is done with a release barrier, to provide lock leave semantic.
+.Pp
+If there are threads sleeping in the sleep queue associated with the
+umutex, one thread is woken up.
+If more than one thread sleeps in the sleep queue, the
+.Dv UMUTEX_CONTESTED
+bit is set together with the write of the
+.Dv UMUTEX_UNOWNED
+value into
+.Dv m_owner .
+.Pp
+The request adheres to the priority protection or inheritance protocol
+of the mutex, specified by the
+.Dv UMUTEX_PRIO_PROTECT
+or
+.Dv UMUTEX_PRIO_INHERIT
+flag, respectively.
+See description of the
+.Dv m_ceilings
+member of the
+.Vt struct umutex
+structure for additional details of the request operation on the
+priority protected protocol mutex.
+.It Dv UMTX_OP_SET_CEILING
+Set ceiling for the priority protected umutex.
+The arguments to the request are:
+.Bl -tag -width "uaddr"
+.It Fa obj
+Pointer to the umutex.
+.It Fa val
+New ceiling value.
+.It Fa uaddr
+Address of a variable of type
+.Vt uint32_t .
+If not
+.Dv NULL
+and the update was successful, the previous ceiling value is
+written to the location pointed to by
+.Fa uaddr .
+.El
+.Pp
+The request locks the umutex pointed to by the
+.Fa obj
+parameter, waiting for the lock if not immediately available.
+After the lock is obtained, the new ceiling value
+.Fa val
+is written to the
+.Dv m_ceilings[0]
+member of the
+.Vt struct umutex,
+after which the umutex is unlocked.
+.Pp
+The locking does not adhere to the priority protect protocol,
+to conform to the
+.Tn POSIX
+requirements for the
+.Xr pthread_mutex_setprioceiling 3
+interface.
+.It Dv UMTX_OP_CV_WAIT
+Wait for a condition.
+The arguments to the request are:
+.Bl -tag -width "uaddr2"
+.It Fa obj
+Pointer to the
+.Vt struct ucond .
+.It Fa val
+Request flags, see below.
+.It Fa uaddr
+Pointer to the umutex.
+.It Fa uaddr2
+Optional pointer to a
+.Vt struct timespec
+for timeout specification.
+.El
+.Pp
+The request must be issued by the thread owning the mutex pointed to
+by the
+.Fa uaddr
+argument.
+The
+.Dv c_hash_waiters
+member of the
+.Vt struct ucond ,
+pointed to by the
+.Fa obj
+argument, is set to an arbitrary non-zero value, after which the
+.Fa uaddr
+mutex is unlocked (following the appropriate protocol), and
+the current thread is put to sleep on the sleep queue keyed by
+the
+.Fa obj
+argument.
+The operations are performed atomically.
+It is guaranteed to not miss a wakeup from
+.Dv UMTX_OP_CV_SIGNAL
+or
+.Dv UMTX_OP_CV_BROADCAST
+sent between mutex unlock and putting the current thread on the sleep queue.
+.Pp
+Upon wakeup, if the timeout expired and no other threads are sleeping in
+the same sleep queue, the
+.Dv c_hash_waiters
+member is cleared.
+After wakeup, the
+.Fa uaddr
+umutex is not relocked.
+.Pp
+The following flags are defined:
+.Bl -tag -width "CVWAIT_CLOCKID"
+.It Dv CVWAIT_ABSTIME
+Timeout is absolute.
+.It Dv CVWAIT_CLOCKID
+Clockid is provided.
+.El
+.Pp
+Optionally, a timeout for the request may be specified.
+Unlike other requests, the timeout value is specified directly by a
+.Vt struct timespec ,
+pointed to by the
+.Fa uaddr2
+argument.
+If the
+.Dv CVWAIT_CLOCKID
+flag is provided, the timeout uses the clock from the
+.Dv c_clockid
+member of the
+.Vt struct ucond ,
+pointed to by
+.Fa obj
+argument.
+Otherwise,
+.Dv CLOCK_REALTIME
+is used, regardless of the clock identifier possibly specified in the
+.Vt struct _umtx_time .
+If the
+.Dv CVWAIT_ABSTIME
+flag is supplied, the timeout specifies absolute time value, otherwise
+it denotes a relative time interval.
+.Pp
+The request is not restartable.
+An unblocked signal delivered during
+the wait always results in sleep interruption and
+.Er EINTR
+error.
+.It Dv UMTX_OP_CV_SIGNAL
+Wake up one condition waiter.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to
+.Vt struct ucond .
+.El
+.Pp
+The request wakes up at most one thread sleeping on the sleep queue keyed
+by the
+.Fa obj
+argument.
+If the woken up thread was the last on the sleep queue, the
+.Dv c_has_waiters
+member of the
+.Vt struct ucond
+is cleared.
+.It Dv UMTX_OP_CV_BROADCAST
+Wake up all condition waiters.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to
+.Vt struct ucond .
+.El
+.Pp
+The request wakes up all threads sleeping on the sleep queue keyed by the
+.Fa obj
+argument.
+The
+.Dv c_has_waiters
+member of the
+.Vt struct ucond
+is cleared.
+.It Dv UMTX_OP_WAIT_UINT
+Same as
+.Dv UMTX_OP_WAIT ,
+but the type of the variable pointed to by
+.Fa obj
+is
+.Vt u_int
+.Pq a 32-bit integer .
+.It Dv UMTX_OP_RW_RDLOCK
+Read-lock a
+.Vt struct rwlock
+lock.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the lock (of type
+.Vt struct rwlock )
+to be read-locked.
+.It Fa val
+Additional flags to augment locking behaviour.
+The valid flags in the
+.Fa val
+argument are:
+.Bl -tag -width indent
+.It Dv URWLOCK_PREFER_READER
+.El
+.El
+.Pp
+The request obtains the read lock on the specified
+.Vt struct rwlock
+by incrementing the count of readers in the
+.Dv rw_state
+word of the structure.
+If the
+.Dv URWLOCK_WRITE_OWNER
+bit is set in the word
+.Dv rw_state ,
+the lock was granted to a writer which has not yet relinquished
+its ownership.
+In this case the current thread is put to sleep until it makes sense to
+retry.
+.Pp
+If the
+.Dv URWLOCK_PREFER_READER
+flag is set either in the
+.Dv rw_flags
+word of the structure, or in the
+.Fa val
+argument of the request, the presence of the threads trying to obtain
+the write lock on the same structure does not prevent the current thread
+from trying to obtain the read lock.
+Otherwise, if the flag is not set, and the
+.Dv URWLOCK_WRITE_WAITERS
+flag is set in
+.Dv rw_state ,
+the current thread does not attempt to obtain read-lock.
+Instead it sets the
+.Dv URWLOCK_READ_WAITERS
+in the
+.Dv rw_state
+word and puts itself to sleep on corresponding sleep queue.
+Upon wakeup, the locking conditions are re-evaluated.
+.Pp
+Optionally, a timeout for the request may be specified.
+.Pp
+The request is not restartable.
+An unblocked signal delivered during the wait always results in sleep
+interruption and
+.Er EINTR
+error.
+.It Dv UMTX_OP_RW_WRLOCK
+Write-lock a
+.Vt struct rwlock
+lock.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the lock (of type
+.Vt struct rwlock )
+to be write-locked.
+.El
+.Pp
+The request obtains a write lock on the specified
+.Vt struct rwlock ,
+by setting the
+.Dv URWLOCK_WRITE_OWNER
+bit in the
+.Dv rw_state
+word of the structure.
+If there is already a write lock owner, as indicated by the
+.Dv URWLOCK_WRITE_OWNER
+bit being set, or there are read lock owners, as indicated
+by the read-lock counter, the current thread does not attempt to
+obtain the write-lock.
+Instead it sets the
+.Dv URWLOCK_WRITE_WAITERS
+in the
+.Dv rw_state
+word and puts itself to sleep on corresponding sleep queue.
+Upon wakeup, the locking conditions are re-evaluated.
+.Pp
+Optionally, a timeout for the request may be specified.
+.Pp
+The request is not restartable.
+An unblocked signal delivered during the wait always results in sleep
+interruption and
+.Er EINTR
+error.
+.It Dv UMTX_OP_RW_UNLOCK
+Unlock rwlock.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the lock (of type
+.Vt struct rwlock )
+to be unlocked.
+.El
+.Pp
+The unlock type (read or write) is determined by the
+current lock state.
+Note that the
+.Vt struct rwlock
+does not save information about the identity of the thread which
+acquired the lock.
+.Pp
+If there are pending writers after the unlock, and the
+.Dv URWLOCK_PREFER_READER
+flag is not set in the
+.Dv rw_flags
+member of the
+.Fa *obj
+structure, one writer is woken up, selected as described in the
+.Sx SLEEP QUEUES
+subsection.
+If the
+.Dv URWLOCK_PREFER_READER
+flag is set, a pending writer is woken up only if there is
+no pending readers.
+.Pp
+If there are no pending writers, or, in the case that the
+.Dv URWLOCK_PREFER_READER
+flag is set, then all pending readers are woken up by unlock.
+.It Dv UMTX_OP_WAIT_UINT_PRIVATE
+Same as
+.Dv UMTX_OP_WAIT_UINT ,
+but unconditionally select the process-private sleep queue.
+.It Dv UMTX_OP_WAKE_PRIVATE
+Same as
+.Dv UMTX_OP_WAKE ,
+but unconditionally select the process-private sleep queue.
+.It Dv UMTX_OP_MUTEX_WAIT
+Wait for mutex availability.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Address of the mutex.
+.El
+.Pp
+Similarly to the
+.Dv UMTX_OP_MUTEX_LOCK ,
+put the requesting thread to sleep if the mutex lock cannot be obtained
+immediately.
+The
+.Dv UMUTEX_CONTESTED
+bit is set in the
+.Dv m_owner
+word of the mutex to indicate that there is a waiter, before the thread
+is added to the sleep queue.
+Unlike the
+.Dv UMTX_OP_MUTEX_LOCK
+request, the lock is not obtained.
+.Pp
+The operation is not implemented for priority protected and
+priority inherited protocol mutexes.
+.Pp
+Optionally, a timeout for the request may be specified.
+.Pp
+A request with a timeout specified is not restartable.
+An unblocked signal delivered during the wait always results in sleep
+interruption and
+.Er EINTR
+error.
+A request without a timeout automatically restarts if the signal disposition
+requested restart via the
+.Dv SA_RESTART
+flag in
+.Vt struct sigaction
+member
+.Dv sa_flags .
+.It Dv UMTX_OP_NWAKE_PRIVATE
+Wake up a batch of sleeping threads.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the array of pointers.
+.It Fa val
+Number of elements in the array pointed to by
+.Fa obj .
+.El
+.Pp
+For each element in the array pointed to by
+.Fa obj ,
+wakes up all threads waiting on the
+.Em private
+sleep queue with the key
+being the byte addressed by the array element.
+.It Dv UMTX_OP_MUTEX_WAKE
+Check if a normal umutex is unlocked and wake up a waiter.
+The arguments for the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the umutex.
+.El
+.Pp
+If the
+.Dv m_owner
+word of the mutex pointed to by the
+.Fa obj
+argument indicates unowned mutex, which has its contention indicator bit
+.Dv UMUTEX_CONTESTED
+set, clear the bit and wake up one waiter in the sleep queue associated
+with the byte addressed by the
+.Fa obj ,
+if any.
+Only normal mutexes are supported by the request.
+The sleep queue is always one for a normal mutex type.
+.Pp
+This request is deprecated in favor of
+.Dv UMTX_OP_MUTEX_WAKE2
+since mutexes using it cannot synchronize their own destruction.
+That is, the
+.Dv m_owner
+word has already been set to
+.Dv UMUTEX_UNOWNED
+when this request is made,
+so that another thread can lock, unlock and destroy the mutex
+(if no other thread uses the mutex afterwards).
+Clearing the
+.Dv UMUTEX_CONTESTED
+bit may then modify freed memory.
+.It Dv UMTX_OP_MUTEX_WAKE2
+Check if a umutex is unlocked and wake up a waiter.
+The arguments for the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the umutex.
+.It Fa val
+The umutex flags.
+.El
+.Pp
+The request does not read the
+.Dv m_flags
+member of the
+.Vt struct umutex ;
+instead, the
+.Fa val
+argument supplies flag information, in particular, to determine the
+sleep queue where the waiters are found for wake up.
+.Pp
+If the mutex is unowned, one waiter is woken up.
+.Pp
+If the mutex memory cannot be accessed, all waiters are woken up.
+.Pp
+If there is more than one waiter on the sleep queue, or there is only
+one waiter but the mutex is owned by a thread, the
+.Dv UMUTEX_CONTESTED
+bit is set in the
+.Dv m_owner
+word of the
+.Vt struct umutex .
+.It Dv UMTX_OP_SEM2_WAIT
+Wait until semaphore is available.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the semaphore (of type
+.Vt struct _usem2 ) .
+.It Fa uaddr
+Size of the memory passed in via the
+.Fa uaddr2
+argument.
+.It Fa uaddr2
+Optional pointer to a structure of type
+.Vt struct _umtx_time ,
+which may be followed by a structure of type
+.Vt struct timespec .
+.El
+.Pp
+Put the requesting thread onto a sleep queue if the semaphore counter
+is zero.
+If the thread is put to sleep, the
+.Dv USEM_HAS_WAITERS
+bit is set in the
+.Dv _count
+word to indicate waiters.
+The function returns either due to
+.Dv _count
+indicating the semaphore is available (non-zero count due to post),
+or due to a wakeup.
+The return does not guarantee that the semaphore is available,
+nor does it consume the semaphore lock on successful return.
+.Pp
+Optionally, a timeout for the request may be specified.
+.Pp
+A request with non-absolute timeout value is not restartable.
+An unblocked signal delivered during such wait results in sleep
+interruption and
+.Er EINTR
+error.
+.Pp
+If
+.Dv UMTX_ABSTIME
+was not set, and the operation was interrupted and the caller passed in a
+.Fa uaddr2
+large enough to hold a
+.Vt struct timespec
+following the initial
+.Vt struct _umtx_time ,
+then the
+.Vt struct timespec
+is updated to contain the unslept amount.
+.It Dv UMTX_OP_SEM2_WAKE
+Wake up waiters on semaphore lock.
+The arguments to the request are:
+.Bl -tag -width "obj"
+.It Fa obj
+Pointer to the semaphore (of type
+.Vt struct _usem2 ) .
+.El
+.Pp
+The request wakes up one waiter for the semaphore lock.
+The function does not increment the semaphore lock count.
+If the
+.Dv USEM_HAS_WAITERS
+bit was set in the
+.Dv _count
+word, and the last sleeping thread was woken up, the bit is cleared.
+.It Dv UMTX_OP_SHM
+Manage anonymous
+.Tn POSIX
+shared memory objects (see
+.Xr shm_open 2 ) ,
+which can be attached to a byte of physical memory, mapped into the
+process address space.
+The objects are used to implement process-shared locks in
+.Dv libthr .
+.Pp
+The
+.Fa val
+argument specifies the sub-request of the
+.Dv UMTX_OP_SHM
+request:
+.Bl -tag -width indent
+.It Dv UMTX_SHM_CREAT
+Creates the anonymous shared memory object, which can be looked up
+with the specified key
+.Fa uaddr .
+If the object associated with the
+.Fa uaddr
+key already exists, it is returned instead of creating a new object.
+The object's size is one page.
+On success, the file descriptor referencing the object is returned.
+The descriptor can be used for mapping the object using
+.Xr mmap 2 ,
+or for other shared memory operations.
+.It Dv UMTX_SHM_LOOKUP
+Same as
+.Dv UMTX_SHM_CREATE
+request, but if there is no shared memory object associated with
+the specified key
+.Fa uaddr ,
+an error is returned, and no new object is created.
+.It Dv UMTX_SHM_DESTROY
+De-associate the shared object with the specified key
+.Fa uaddr .
+The object is destroyed after the last open file descriptor is closed
+and the last mapping for it is destroyed.
+.It Dv UMTX_SHM_ALIVE
+Checks whether there is a live shared object associated with the
+supplied key
+.Fa uaddr .
+Returns zero if there is, and an error otherwise.
+This request is an optimization of the
+.Dv UMTX_SHM_LOOKUP
+request.
+It is cheaper when only the liveness of the associated object is asked
+for, since no file descriptor is installed in the process fd table
+on success.
+.El
+.Pp
+The
+.Fa uaddr
+argument specifies the virtual address, which backing physical memory
+byte identity is used as a key for the anonymous shared object
+creation or lookup.
+.It Dv UMTX_OP_ROBUST_LISTS
+Register the list heads for the current thread's robust mutex lists.
+The arguments to the request are:
+.Bl -tag -width "uaddr"
+.It Fa val
+Size of the structure passed in the
+.Fa uaddr
+argument.
+.It Fa uaddr
+Pointer to the structure of type
+.Vt struct umtx_robust_lists_params .
+.El
+.Pp
+The structure is defined as
+.Bd -literal
+struct umtx_robust_lists_params {
+ uintptr_t robust_list_offset;
+ uintptr_t robust_priv_list_offset;
+ uintptr_t robust_inact_offset;
+};
+.Ed
+.Pp
+The
+.Dv robust_list_offset
+member contains address of the first element in the list of locked
+robust shared mutexes.
+The
+.Dv robust_priv_list_offset
+member contains address of the first element in the list of locked
+robust private mutexes.
+The private and shared robust locked lists are split to allow fast
+termination of the shared list on fork, in the child.
+.Pp
+The
+.Dv robust_inact_offset
+contains a pointer to the mutex which might be locked in nearby future,
+or might have been just unlocked.
+It is typically set by the lock or unlock mutex implementation code
+around the whole operation, since lists can be only changed race-free
+when the thread owns the mutex.
+The kernel inspects the
+.Dv robust_inact_offset
+in addition to walking the shared and private lists.
+Also, the mutex pointed to by
+.Dv robust_inact_offset
+is handled more loosely at the thread termination time,
+than other mutexes on the list.
+That mutex is allowed to be not owned by the current thread,
+in which case list processing is continued.
+See
+.Sx ROBUST UMUTEXES
+subsection for details.
+.It Dv UMTX_OP_GET_MIN_TIMEOUT
+Writes out the current value of minimal umtx operations timeout,
+in nanoseconds, into the long integer variable pointed to by
+.Fa uaddr1 .
+.It Dv UMTX_OP_SET_MIN_TIMEOUT
+Set the minimal amount of time, in nanoseconds, the thread is required
+to sleep for umtx operations specifying a timeout using absolute clocks.
+The value is taken from the
+.Fa val
+argument of the call.
+Zero means no minimum.
+.El
+.Pp
+The
+.Fa op
+argument may be a bitwise OR of a single command from above with one or more of
+the following flags:
+.Bl -tag -width indent
+.It Dv UMTX_OP__I386
+Request i386 ABI compatibility from the native
+.Nm
+system call.
+Specifically, this implies that:
+.Bl -hang -offset indent
+.It
+.Fa obj
+arguments that point to a word, point to a 32-bit integer.
+.It
+The
+.Dv UMTX_OP_NWAKE_PRIVATE
+.Fa obj
+argument is a pointer to an array of 32-bit pointers.
+.It
+The
+.Dv m_rb_lnk
+member of
+.Vt struct umutex
+is a 32-bit pointer.
+.It
+.Vt struct timespec
+uses a 32-bit time_t.
+.El
+.Pp
+.Dv UMTX_OP__32BIT
+has no effect if this flag is set.
+This flag is valid for all architectures, but it is ignored on i386.
+.It Dv UMTX_OP__32BIT
+Request non-i386, 32-bit ABI compatibility from the native
+.Nm
+system call.
+Specifically, this implies that:
+.Bl -hang -offset indent
+.It
+.Fa obj
+arguments that point to a word, point to a 32-bit integer.
+.It
+The
+.Dv UMTX_OP_NWAKE_PRIVATE
+.Fa obj
+argument is a pointer to an array of 32-bit pointers.
+.It
+The
+.Dv m_rb_lnk
+member of
+.Vt struct umutex
+is a 32-bit pointer.
+.It
+.Vt struct timespec
+uses a 64-bit time_t.
+.El
+.Pp
+This flag has no effect if
+.Dv UMTX_OP__I386
+is set.
+This flag is valid for all architectures.
+.El
+.Pp
+Note that if any 32-bit ABI compatibility is being requested, then care must be
+taken with robust lists.
+A single thread may not mix 32-bit compatible robust lists with native
+robust lists.
+The first
+.Dv UMTX_OP_ROBUST_LISTS
+call in a given thread determines which ABI that thread will use for robust
+lists going forward.
+.Sh RETURN VALUES
+If successful,
+all requests, except
+.Dv UMTX_SHM_CREAT
+and
+.Dv UMTX_SHM_LOOKUP
+sub-requests of the
+.Dv UMTX_OP_SHM
+request, will return zero.
+The
+.Dv UMTX_SHM_CREAT
+and
+.Dv UMTX_SHM_LOOKUP
+return a shared memory file descriptor on success.
+On error \-1 is returned, and the
+.Va errno
+variable is set to indicate the error.
+.Sh ERRORS
+The
+.Fn _umtx_op
+operations can fail with the following errors:
+.Bl -tag -width "[ETIMEDOUT]"
+.It Bq Er EFAULT
+One of the arguments point to invalid memory.
+.It Bq Er EINVAL
+The clock identifier, specified for the
+.Vt struct _umtx_time
+timeout parameter, or in the
+.Dv c_clockid
+member of
+.Vt struct ucond,
+is invalid.
+.It Bq Er EINVAL
+The type of the mutex, encoded by the
+.Dv m_flags
+member of
+.Vt struct umutex ,
+is invalid.
+.It Bq Er EINVAL
+The
+.Dv m_owner
+member of the
+.Vt struct umutex
+has changed the lock owner thread identifier during unlock.
+.It Bq Er EINVAL
+The
+.Dv timeout.tv_sec
+or
+.Dv timeout.tv_nsec
+member of
+.Vt struct _umtx_time
+is less than zero, or
+.Dv timeout.tv_nsec
+is greater than 1000000000.
+.It Bq Er EINVAL
+The
+.Fa op
+argument specifies invalid operation.
+.It Bq Er EINVAL
+The
+.Fa uaddr
+argument for the
+.Dv UMTX_OP_SHM
+request specifies invalid operation.
+.It Bq Er EINVAL
+The
+.Dv UMTX_OP_SET_CEILING
+request specifies non priority protected mutex.
+.It Bq Er EINVAL
+The new ceiling value for the
+.Dv UMTX_OP_SET_CEILING
+request, or one or more of the values read from the
+.Dv m_ceilings
+array during lock or unlock operations, is greater than
+.Dv RTP_PRIO_MAX .
+.It Bq Er EPERM
+Unlock attempted on an object not owned by the current thread.
+.It Bq Er EOWNERDEAD
+The lock was requested on an umutex where the
+.Dv m_owner
+field was set to the
+.Dv UMUTEX_RB_OWNERDEAD
+value, indicating terminated robust mutex.
+The lock was granted to the caller, so this error in fact
+indicates success with additional conditions.
+.It Bq Er ENOTRECOVERABLE
+The lock was requested on an umutex which
+.Dv m_owner
+field is equal to the
+.Dv UMUTEX_RB_NOTRECOV
+value, indicating abandoned robust mutex after termination.
+The lock was not granted to the caller.
+.It Bq Er ENOTTY
+The shared memory object, associated with the address passed to the
+.Dv UMTX_SHM_ALIVE
+sub-request of
+.Dv UMTX_OP_SHM
+request, was destroyed.
+.It Bq Er ESRCH
+For the
+.Dv UMTX_SHM_LOOKUP ,
+.Dv UMTX_SHM_DESTROY ,
+and
+.Dv UMTX_SHM_ALIVE
+sub-requests of the
+.Dv UMTX_OP_SHM
+request, there is no shared memory object associated with the provided key.
+.It Bq Er ENOMEM
+The
+.Dv UMTX_SHM_CREAT
+sub-request of the
+.Dv UMTX_OP_SHM
+request cannot be satisfied, because allocation of the shared memory object
+would exceed the
+.Dv RLIMIT_UMTXP
+resource limit, see
+.Xr setrlimit 2 .
+.It Bq Er EAGAIN
+The maximum number of readers
+.Dv ( URWLOCK_MAX_READERS )
+were already granted ownership of the given
+.Vt struct rwlock
+for read.
+.It Bq Er EBUSY
+A try mutex lock operation was not able to obtain the lock.
+.It Bq Er ETIMEDOUT
+The request specified a timeout in the
+.Fa uaddr
+and
+.Fa uaddr2
+arguments, and timed out before obtaining the lock or being woken up.
+.It Bq Er EINTR
+A signal was delivered during wait, for a non-restartable operation.
+Operations with timeouts are typically non-restartable, but timeouts
+specified in absolute time may be restartable.
+.It Bq Er ERESTART
+A signal was delivered during wait, for a restartable operation.
+Mutex lock requests without timeout specified are restartable.
+The error is not returned to userspace code since restart
+is handled by usual adjustment of the instruction counter.
+.El
+.Sh SEE ALSO
+.Xr clock_gettime 2 ,
+.Xr mmap 2 ,
+.Xr setrlimit 2 ,
+.Xr shm_open 2 ,
+.Xr sigaction 2 ,
+.Xr thr_exit 2 ,
+.Xr thr_kill 2 ,
+.Xr thr_kill2 2 ,
+.Xr thr_new 2 ,
+.Xr thr_self 2 ,
+.Xr thr_set_name 2 ,
+.Xr signal 3
+.Sh STANDARDS
+The
+.Fn _umtx_op
+system call is non-standard and is used by the
+.Lb libthr
+to implement
+.St -p1003.1-2001
+.Xr pthread 3
+functionality.
+.Sh BUGS
+A window between a unlocking robust mutex and resetting the pointer in the
+.Dv robust_inact_offset
+member of the registered
+.Vt struct umtx_robust_lists_params
+allows another thread to destroy the mutex, thus making the kernel inspect
+freed or reused memory.
+The
+.Li libthr
+implementation is only vulnerable to this race when operating on
+a shared mutex.
+A possible fix for the current implementation is to strengthen the checks
+for shared mutexes before terminating them, in particular, verifying
+that the mutex memory is mapped from a shared memory object allocated
+by the
+.Dv UMTX_OP_SHM
+request.
+This is not done because it is believed that the race is adequately
+covered by other consistency checks, while adding the check would
+prevent alternative implementations of
+.Li libpthread .
diff --git a/lib/libsys/_umtx_op_err.c b/lib/libsys/_umtx_op_err.c
new file mode 100644
index 000000000000..8281b8af7110
--- /dev/null
+++ b/lib/libsys/_umtx_op_err.c
@@ -0,0 +1,39 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2005 David Xu <davidxu@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 unmodified, 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.
+ */
+
+#include <sys/types.h>
+#include <sys/errno.h>
+#include <sys/umtx.h>
+
+int
+_umtx_op_err(void *obj, int op, u_long val, void *uaddr, void *uaddr2)
+{
+ if (_umtx_op(obj, op, val, uaddr, uaddr2) == -1)
+ return (errno);
+ return (0);
+}
diff --git a/lib/libsys/aarch64/Makefile.sys b/lib/libsys/aarch64/Makefile.sys
new file mode 100644
index 000000000000..04b95602c580
--- /dev/null
+++ b/lib/libsys/aarch64/Makefile.sys
@@ -0,0 +1,7 @@
+MIASM:= ${MIASM:Nfreebsd[467]_*}
+
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
+MDASM= cerror.S \
+ vfork.S
diff --git a/lib/libsys/aarch64/SYS.h b/lib/libsys/aarch64/SYS.h
new file mode 100644
index 000000000000..a2ff7af18b18
--- /dev/null
+++ b/lib/libsys/aarch64/SYS.h
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * Copyright (c) 2015 The FreeBSD Foundation
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ mov x8, SYS_ ## name; \
+ svc 0
+
+#ifndef _SYSCALL_BODY
+/*
+ * Conditional jumps can only go up to one megabyte in either
+ * direction, and cerror can be located anywhere, so we have
+ * to jump around to use more capable unconditional branch
+ * instruction.
+ */
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ b.cs 1f; \
+ ret; \
+1: b cerror
+#endif
+
+#define PSEUDO(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
+
+#define RSYSCALL(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
diff --git a/lib/libsys/aarch64/__vdso_gettc.c b/lib/libsys/aarch64/__vdso_gettc.c
new file mode 100644
index 000000000000..5c5963d0e757
--- /dev/null
+++ b/lib/libsys/aarch64/__vdso_gettc.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <machine/cpufunc.h>
+#include <errno.h>
+#include "libc_private.h"
+
+static inline uint64_t
+cp15_cntvct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrs %0, cntvct_el0" : "=r" (reg));
+ return (reg);
+}
+
+static inline uint64_t
+cp15_cntpct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrs %0, cntpct_el0" : "=r" (reg));
+ return (reg);
+}
+
+#pragma weak __vdso_gettc
+int
+__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+
+ if (th->th_algo != VDSO_TH_ALGO_ARM_GENTIM)
+ return (ENOSYS);
+ __asm __volatile("isb" : : : "memory");
+ *tc = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libsys/aarch64/cerror.S b/lib/libsys/aarch64/cerror.S
new file mode 100644
index 000000000000..85e75af8ec0d
--- /dev/null
+++ b/lib/libsys/aarch64/cerror.S
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ *
+ * 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.
+ *
+ */
+
+#include <machine/asm.h>
+#include <sys/elf_common.h>
+
+ENTRY(cerror)
+ .hidden cerror
+ sub sp, sp, #16
+ stp x0, lr, [sp]
+ bl _C_LABEL(__error)
+ ldp x1, lr, [sp]
+ str w1, [x0]
+ movn x0, #0
+ movn x1, #0
+ add sp, sp, #16
+ ret
+END(cerror)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libsys/aarch64/vfork.S b/lib/libsys/aarch64/vfork.S
new file mode 100644
index 000000000000..03ae5a6325ba
--- /dev/null
+++ b/lib/libsys/aarch64/vfork.S
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ *
+ * 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.
+ *
+ */
+
+#include <machine/asm.h>
+#include <sys/elf_common.h>
+#include "SYS.h"
+
+ENTRY(__sys_vfork)
+ WEAK_REFERENCE(__sys_vfork, vfork)
+ WEAK_REFERENCE(__sys_vfork, _vfork)
+ mov x2, lr
+ _SYSCALL(vfork)
+ b.cs cerror
+ sub x1, x1, #1
+ and x0, x0, x1
+ mov lr, x2
+ ret
+END(__sys_vfork)
+
+GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
diff --git a/lib/libc/sys/abort2.2 b/lib/libsys/abort2.2
index 8073d5d747cc..8073d5d747cc 100644
--- a/lib/libc/sys/abort2.2
+++ b/lib/libsys/abort2.2
diff --git a/lib/libsys/accept.2 b/lib/libsys/accept.2
new file mode 100644
index 000000000000..2da2af066a5b
--- /dev/null
+++ b/lib/libsys/accept.2
@@ -0,0 +1,248 @@
+.\" Copyright (c) 1983, 1990, 1991, 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.
+.\"
+.Dd May 17, 2025
+.Dt ACCEPT 2
+.Os
+.Sh NAME
+.Nm accept ,
+.Nm accept4
+.Nd accept a connection on a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen"
+.Ft int
+.Fn accept4 "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "int flags"
+.Sh DESCRIPTION
+The argument
+.Fa s
+is a socket that has been created with
+.Xr socket 2 ,
+bound to an address with
+.Xr bind 2 ,
+and is listening for connections after a
+.Xr listen 2 .
+The
+.Fn accept
+system call extracts the first connection request on the
+queue of pending connections, creates a new socket,
+and allocates a new file descriptor for the socket which
+inherits the state of the
+.Dv O_NONBLOCK
+and
+.Dv O_ASYNC
+properties and the destination of
+.Dv SIGIO
+and
+.Dv SIGURG
+signals from the original socket
+.Fa s .
+.Pp
+The
+.Fn accept4
+system call is similar,
+but the
+.Dv O_NONBLOCK
+property of the new socket is instead determined by the
+.Dv SOCK_NONBLOCK
+flag in the
+.Fa flags
+argument,
+the
+.Dv O_ASYNC
+property is cleared,
+the signal destination is cleared
+and the close-on-exec flag on the new file descriptor can be set via the
+.Dv SOCK_CLOEXEC
+flag in the
+.Fa flags
+argument.
+Similarly, the
+.Dv O_CLOFORK
+property can be set via the
+.Dv SOCK_CLOFORK
+flag in the
+.Fa flags
+argument.
+.Pp
+If no pending connections are
+present on the queue, and the original socket
+is not marked as non-blocking,
+.Fn accept
+blocks the caller until a connection is present.
+If the original socket
+is marked non-blocking and no pending
+connections are present on the queue,
+.Fn accept
+returns an error as described below.
+The accepted socket
+may not be used
+to accept more connections.
+The original socket
+.Fa s
+remains open.
+.Pp
+The argument
+.Fa addr
+is a result argument that is filled-in with
+the address of the connecting entity,
+as known to the communications layer.
+The exact format of the
+.Fa addr
+argument is determined by the domain in which the communication
+is occurring.
+A null pointer may be specified for
+.Fa addr
+if the address information is not desired;
+in this case,
+.Fa addrlen
+is not used and should also be null.
+Otherwise, the
+.Fa addrlen
+argument
+is a value-result argument; it should initially contain the
+amount of space pointed to by
+.Fa addr ;
+on return it will contain the actual length (in bytes) of the
+address returned.
+This call
+is used with connection-based socket types, currently with
+.Dv SOCK_STREAM .
+.Pp
+It is possible to
+.Xr select 2
+a socket for the purposes of doing an
+.Fn accept
+by selecting it for read.
+.Pp
+For certain protocols which require an explicit confirmation,
+such as
+.Tn ISO
+or
+.Tn DATAKIT ,
+.Fn accept
+can be thought of
+as merely dequeueing the next connection
+request and not implying confirmation.
+Confirmation can be implied by a normal read or write on the new
+file descriptor, and rejection can be implied by closing the
+new socket.
+.Pp
+For some applications, performance may be enhanced by using an
+.Xr accept_filter 9
+to pre-process incoming connections.
+.Pp
+When using
+.Fn accept ,
+portable programs should not rely on the
+.Dv O_NONBLOCK
+and
+.Dv O_ASYNC
+properties and the signal destination being inherited,
+but should set them explicitly using
+.Xr fcntl 2 ;
+.Fn accept4
+sets these properties consistently,
+but may not be fully portable across
+.Ux
+platforms.
+.Sh RETURN VALUES
+These calls return \-1 on error.
+If they succeed, they return a non-negative
+integer that is a descriptor for the accepted socket.
+.Sh ERRORS
+The
+.Fn accept
+and
+.Fn accept4
+system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The descriptor is invalid.
+.It Bq Er EINTR
+The
+.Fn accept
+operation was interrupted.
+.It Bq Er EMFILE
+The per-process descriptor table is full.
+.It Bq Er ENFILE
+The system file table is full.
+.It Bq Er ENOTSOCK
+The descriptor references a file, not a socket.
+.It Bq Er EINVAL
+.Xr listen 2
+has not been called on the socket descriptor.
+.It Bq Er EFAULT
+The
+.Fa addr
+argument is not in a writable part of the
+user address space.
+.It Bo Er EWOULDBLOCK Bc or Bq Er EAGAIN
+The socket is marked non-blocking and no connections
+are present to be accepted.
+.It Bq Er ECONNABORTED
+A connection arrived, but it was closed while waiting
+on the listen queue.
+.El
+.Pp
+The
+.Fn accept4
+system call will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa flags
+argument is invalid.
+.El
+.Sh SEE ALSO
+.Xr bind 2 ,
+.Xr connect 2 ,
+.Xr getpeername 2 ,
+.Xr getsockname 2 ,
+.Xr listen 2 ,
+.Xr select 2 ,
+.Xr socket 2 ,
+.Xr accept_filter 9
+.Sh HISTORY
+The
+.Fn accept
+system call appeared in
+.Bx 4.2 .
+.Pp
+The
+.Fn accept4
+system call appeared in
+.Fx 10.0 .
+.Pp
+The
+.Dv SOCK_CLOFORK
+flag appeared in
+.Fx 15.0 .
diff --git a/lib/libsys/access.2 b/lib/libsys/access.2
new file mode 100644
index 000000000000..94a13dcc4dcf
--- /dev/null
+++ b/lib/libsys/access.2
@@ -0,0 +1,277 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd August 11, 2024
+.Dt ACCESS 2
+.Os
+.Sh NAME
+.Nm access ,
+.Nm eaccess ,
+.Nm faccessat
+.Nd check accessibility of a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn access "const char *path" "int mode"
+.Ft int
+.Fn eaccess "const char *path" "int mode"
+.Ft int
+.Fn faccessat "int fd" "const char *path" "int mode" "int flag"
+.Sh DESCRIPTION
+The
+.Fn access ,
+.Fn eaccess
+and
+.Fn faccessat
+system calls report whether an attempt to access the file designated
+by their
+.Fa path
+in the manner described by their
+.Fa mode
+argument is likely to succeed.
+The value of
+.Fa mode
+is either the bitwise-inclusive OR of the desired permissions
+.Po
+.Dv R_OK
+for read permission,
+.Dv W_OK
+for write permission, and
+.Dv X_OK
+for execute / search permission
+.Pc
+or
+.Dv F_OK
+to simply check whether the file exists.
+.Pp
+For a number of reasons, these system calls cannot be relied upon to
+give a correct and definitive answer.
+They can at best provide an early indication of the expected outcome,
+to be confirmed by actually attempting the operation.
+For existence checks, either
+.Xr stat 2
+or
+.Xr lstat 2
+should be used instead.
+See also
+.Sx SECURITY CONSIDERATIONS
+below.
+.Pp
+The
+.Fn eaccess
+system call uses
+the effective user ID and the group access list
+to authorize the request;
+the
+.Fn access
+system call uses
+the real user ID in place of the effective user ID,
+the real group ID in place of the effective group ID,
+and the rest of the group access list.
+.Pp
+See the
+.Sx DEFINITIONS
+section of
+.Xr intro 2
+for additional information on file access permissions and real
+vs. effective user and group IDs.
+.Pp
+The
+.Fn faccessat
+system call is equivalent to
+.Fn access
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the file whose accessibility is to be determined is
+located relative to the directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn faccessat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn access .
+Values for
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from the following
+list, defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_EACCESS
+The checks are performed using the effective user and group IDs,
+like
+.Fn eaccess ,
+instead of the real user and group ID, like
+.Fn access .
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa path
+argument is an empty string, operate on the file or directory
+referenced by the descriptor
+.Fa fd .
+If
+.Fa fd
+is equal to
+.Dv AT_FDCWD ,
+operate on the current working directory.
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, access of the symbolic link is evaluated.
+.El
+.Pp
+Even if a process's real or effective user has appropriate privileges
+and indicates success for
+.Dv X_OK ,
+the file may not actually have execute permission bits set.
+Likewise for
+.Dv R_OK
+and
+.Dv W_OK .
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn access ,
+.Fn eaccess ,
+and
+.Fn faccessat
+system calls may fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The value of the
+.Fa mode
+argument is invalid.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EROFS
+Write access is requested for a file on a read-only file system.
+.It Bq Er ETXTBSY
+Write access is requested for a pure procedure (shared text)
+file presently being executed.
+.It Bq Er EACCES
+Permission bits of the file mode do not permit the requested
+access, or search permission is denied on a component of the
+path prefix.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+Also, the
+.Fn faccessat
+system call may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is
+neither
+.Dv AT_FDCWD
+nor a valid file descriptor.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode.
+.El
+.Sh SEE ALSO
+.Xr chmod 2 ,
+.Xr intro 2 ,
+.Xr stat 2
+.Sh STANDARDS
+The
+.Fn access
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn faccessat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn access
+function appeared in
+.At v7 .
+The
+.Fn faccessat
+system call appeared in
+.Fx 8.0 .
+.Sh SECURITY CONSIDERATIONS
+The
+.Fn access ,
+.Fn eaccess ,
+and
+.Fn faccessat
+system calls are subject to time-of-check-to-time-of-use races and
+should not be relied upon for file permission enforcement purposes.
+Instead, applications should perform the desired action using the
+requesting user's credentials.
diff --git a/lib/libsys/acct.2 b/lib/libsys/acct.2
new file mode 100644
index 000000000000..1fbc24e8fe81
--- /dev/null
+++ b/lib/libsys/acct.2
@@ -0,0 +1,130 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt ACCT 2
+.Os
+.Sh NAME
+.Nm acct
+.Nd enable or disable process accounting
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn acct "const char *file"
+.Sh DESCRIPTION
+The
+.Fn acct
+system call enables or disables the collection of system accounting
+records.
+If the argument
+.Fa file
+is a null pointer, accounting is disabled.
+If
+.Fa file
+is an
+.Em existing
+pathname (null-terminated), record collection is enabled and for
+every process initiated which terminates under normal
+conditions an accounting record is appended to
+.Fa file .
+Abnormal conditions of termination are reboots
+or other fatal system problems.
+Records for processes which never terminate cannot be
+produced by
+.Fn acct .
+.Pp
+For more information on the record structure used by
+.Fn acct ,
+see
+.In sys/acct.h
+and
+.Xr acct 5 .
+.Pp
+This call is permitted only to the super-user.
+.Sh NOTES
+Accounting is automatically disabled when the file system the
+accounting file resides on runs out of space; it is enabled when
+space once again becomes available.
+The values controlling this behaviour can be modified using the following
+.Xr sysctl 8
+variables:
+.Bl -tag -width ".Va kern.acct_chkfreq"
+.It Va kern.acct_chkfreq
+Specifies the frequency (in seconds) with which free disk
+space should be checked.
+.It Va kern.acct_resume
+The percentage of free disk space above which process
+accounting will resume.
+.It Va kern.acct_suspend
+The percentage of free disk space below which process
+accounting will suspend.
+.El
+.Sh RETURN VALUES
+On error -1 is returned.
+The file must exist and the call may be exercised only by the super-user.
+.Sh ERRORS
+The
+.Fn acct
+system call will fail if one of the following is true:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The caller is not the super-user.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix,
+or the path name is not a regular file.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa file
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Sh SEE ALSO
+.Xr acct 5 ,
+.Xr accton 8 ,
+.Xr sa 8
+.Sh HISTORY
+The
+.Fn acct
+function appeared in
+.At v7 .
diff --git a/lib/libsys/adjtime.2 b/lib/libsys/adjtime.2
new file mode 100644
index 000000000000..ee8befe09ca9
--- /dev/null
+++ b/lib/libsys/adjtime.2
@@ -0,0 +1,106 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd May 13, 2021
+.Dt ADJTIME 2
+.Os
+.Sh NAME
+.Nm adjtime
+.Nd "correct the time to allow synchronization of the system clock"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/time.h
+.Ft int
+.Fn adjtime "const struct timeval *delta" "struct timeval *olddelta"
+.Sh DESCRIPTION
+The
+.Fn adjtime
+system call
+makes small adjustments to the system time, as returned by
+.Xr gettimeofday 2 ,
+advancing or retarding it
+by the time specified by the timeval
+.Fa delta .
+If
+.Fa delta
+is negative, the clock is
+slowed down by incrementing it more slowly than normal until
+the correction is complete.
+If
+.Fa delta
+is positive, a larger increment than normal
+is used.
+The skew used to perform the correction is generally a fraction of one percent.
+Thus, the time is always
+a monotonically increasing function.
+A time correction from an earlier call to
+.Fn adjtime
+may not be finished when
+.Fn adjtime
+is called again.
+If
+.Fa olddelta
+is not a null pointer,
+the structure pointed to will contain, upon return, the
+number of microseconds still to be corrected
+from the earlier call.
+.Pp
+This call may be used by time servers that synchronize the clocks
+of computers in a local area network.
+Such time servers would slow down the clocks of some machines
+and speed up the clocks of others to bring them to the average network time.
+.Pp
+The
+.Fn adjtime
+system call
+is restricted to the super-user.
+.Sh RETURN VALUES
+.Rv -std adjtime
+.Sh ERRORS
+The
+.Fn adjtime
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+An argument points outside the process's allocated address space.
+.It Bq Er EPERM
+The process's effective user ID is not that of the super-user.
+.El
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr gettimeofday 2
+.Rs
+.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
+.%A R. Gusella
+.%A S. Zatti
+.Re
+.Sh HISTORY
+The
+.Fn adjtime
+system call appeared in
+.Bx 4.3 .
diff --git a/lib/libc/sys/aio_cancel.2 b/lib/libsys/aio_cancel.2
index 42d074054716..42d074054716 100644
--- a/lib/libc/sys/aio_cancel.2
+++ b/lib/libsys/aio_cancel.2
diff --git a/lib/libc/sys/aio_error.2 b/lib/libsys/aio_error.2
index 69eb7cd90ee2..69eb7cd90ee2 100644
--- a/lib/libc/sys/aio_error.2
+++ b/lib/libsys/aio_error.2
diff --git a/lib/libsys/aio_fsync.2 b/lib/libsys/aio_fsync.2
new file mode 100644
index 000000000000..46fc5d95bcfd
--- /dev/null
+++ b/lib/libsys/aio_fsync.2
@@ -0,0 +1,181 @@
+.\" Copyright (c) 2013 Sergey Kandaurov
+.\" 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.
+.\"
+.Dd November 15, 2023
+.Dt AIO_FSYNC 2
+.Os
+.Sh NAME
+.Nm aio_fsync
+.Nd asynchronous file synchronization (REALTIME)
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In aio.h
+.Ft int
+.Fn aio_fsync "int op" "struct aiocb *iocb"
+.Sh DESCRIPTION
+The
+.Fn aio_fsync
+system call allows the calling process to move all modified data
+associated with the descriptor
+.Fa iocb->aio_fildes
+to a permanent storage device.
+The call returns immediately after the synchronization request has been
+enqueued to the descriptor; the synchronization may or may not have
+completed at the time the call returns.
+.Pp
+The
+.Fa op
+argument can be set to
+.Dv O_SYNC
+to cause all currently queued I/O operations to be completed
+as if by a call to
+.Xr fsync 2 ,
+or
+.Dv O_DSYNC
+for the behavior of
+.Xr fdatasync 2 .
+.Pp
+The
+.Fa iocb
+pointer may be subsequently used as an argument to
+.Fn aio_return
+and
+.Fn aio_error
+in order to determine return or error status for the enqueued operation
+while it is in progress.
+.Pp
+If the request could not be enqueued (generally due to invalid arguments),
+the call returns without having enqueued the request.
+.Pp
+The
+.Fa iocb->aio_sigevent
+structure can be used to request notification of the operation's
+completion as described in
+.Xr aio 4 .
+.Sh RESTRICTIONS
+The Asynchronous I/O Control Block structure pointed to by
+.Fa iocb
+must remain valid until the
+operation has completed.
+.Pp
+The asynchronous I/O control buffer
+.Fa iocb
+should be zeroed before the
+.Fn aio_fsync
+call to avoid passing bogus context information to the kernel.
+.Pp
+Modification of the Asynchronous I/O Control Block structure is not allowed
+while the request is queued.
+.Sh RETURN VALUES
+.Rv -std aio_fsync
+.Sh ERRORS
+The
+.Fn aio_fsync
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The request was not queued because of system resource limitations.
+.It Bq Er EINVAL
+The asynchronous notification method in
+.Fa iocb->aio_sigevent.sigev_notify
+is invalid or not supported.
+.It Bq Er EOPNOTSUPP
+Asynchronous file synchronization operations on the file descriptor
+.Fa iocb->aio_fildes
+are unsafe and unsafe asynchronous I/O operations are disabled.
+.It Bq Er EINVAL
+A value of the
+.Fa op
+argument is not set to
+.Dv O_SYNC
+or
+.Dv O_DSYNC .
+.El
+.Pp
+The following conditions may be synchronously detected when the
+.Fn aio_fsync
+system call is made, or asynchronously, at any time thereafter.
+If they are detected at call time,
+.Fn aio_fsync
+returns -1 and sets
+.Va errno
+appropriately; otherwise the
+.Fn aio_return
+system call must be called, and will return -1, and
+.Fn aio_error
+must be called to determine the actual value that would have been
+returned in
+.Va errno .
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa iocb->aio_fildes
+argument
+is not a valid descriptor.
+.It Bq Er EINVAL
+This implementation does not support synchronized I/O for this file.
+.El
+.Pp
+If the request is successfully enqueued, but subsequently cancelled
+or an error occurs, the value returned by the
+.Fn aio_return
+system call is per the
+.Xr read 2
+and
+.Xr write 2
+system calls, and the value returned by the
+.Fn aio_error
+system call is one of the error returns from the
+.Xr read 2
+or
+.Xr write 2
+system calls.
+.Sh SEE ALSO
+.Xr aio_cancel 2 ,
+.Xr aio_error 2 ,
+.Xr aio_read 2 ,
+.Xr aio_return 2 ,
+.Xr aio_suspend 2 ,
+.Xr aio_waitcomplete 2 ,
+.Xr aio_write 2 ,
+.Xr fsync 2 ,
+.Xr sigevent 3 ,
+.Xr siginfo 3 ,
+.Xr aio 4
+.Sh STANDARDS
+The
+.Fn aio_fsync
+system call is expected to conform to the
+.St -p1003.1
+standard.
+.Sh HISTORY
+The
+.Fn aio_fsync
+system call first appeared in
+.Fx 7.0 .
+The
+.Dv O_DSYNC
+option appeared in
+.Fx 13.0 .
diff --git a/lib/libc/sys/aio_mlock.2 b/lib/libsys/aio_mlock.2
index 02d54304c631..02d54304c631 100644
--- a/lib/libc/sys/aio_mlock.2
+++ b/lib/libsys/aio_mlock.2
diff --git a/lib/libsys/aio_read.2 b/lib/libsys/aio_read.2
new file mode 100644
index 000000000000..45779fff94c4
--- /dev/null
+++ b/lib/libsys/aio_read.2
@@ -0,0 +1,290 @@
+.\" Copyright (c) 1998 Terry Lambert
+.\" 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.
+.\"
+.Dd March 27, 2025
+.Dt AIO_READ 2
+.Os
+.Sh NAME
+.Nm aio_read ,
+.Nm aio_read2 ,
+.Nm aio_readv
+.Nd asynchronous read from a file (REALTIME)
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In aio.h
+.Ft int
+.Fn aio_read "struct aiocb *iocb"
+.Ft int
+.Fn aio_read2 "struct aiocb *iocb" "int flags"
+.In sys/uio.h
+.Ft int
+.Fn aio_readv "struct aiocb *iocb"
+.Sh DESCRIPTION
+The
+.Fn aio_read ,
+.Fn aio_read2
+and
+.Fn aio_readv
+system calls allow the calling process to read
+from the descriptor
+.Fa iocb->aio_fildes .
+The syscalls return immediately after the read request has
+been enqueued to the descriptor; the read may or may not have
+completed at the time the call returns.
+.Pp
+For the
+.Fn aio_read
+and
+.Fn aio_readv
+calls, the read begins at the offset
+.Fa iocb->aio_offset .
+.Pp
+The
+.Fn aio_read
+call will read
+.Fa iocb->aio_nbytes
+into the buffer pointed to by
+.Fa iocb->aio_buf ,
+whereas
+.Fn aio_readv
+reads the data into the
+.Fa iocb->aio_iovcnt
+buffers specified by the members of the
+.Fa iocb->aio_iov
+array.
+For
+.Fn aio_readv
+the
+.Fa iovec
+structure is defined in
+.Xr readv 2 .
+.Pp
+The
+.Fn aio_read2
+call takes the
+.Fa flags
+argument.
+If
+.Fa flags
+is passed as zero, the call behaves identically to
+.Fn aio_read .
+The following flags can be specified by logical or:
+.Bl -tag -width AIO_OP2_VECTORED
+.It AIO_OP2_FOFFSET
+The read occurs at the file descriptor offset,
+which is advanced by the operation as done by the
+.Xr read 2
+syscall.
+The
+.Fa iocb->aio_offset
+field is ignored.
+.It AIO_OP2_VECTORED
+Similar to
+.Fn aio_readv ,
+the read buffers are specified by the
+.Fa aiocb->aio_iov
+array.
+.El
+.Pp
+The
+.Fa iocb
+pointer may be subsequently used as an argument to
+.Fn aio_return
+and
+.Fn aio_error
+in order to determine return or error status for the enqueued operation
+while it is in progress.
+.Pp
+If the request could not be enqueued (generally due to invalid arguments),
+then the call returns without having enqueued the request.
+.Pp
+If the request is successfully enqueued, the value of
+.Fa iocb->aio_offset
+can be modified during the request as context, so this value must
+not be referenced after the request is enqueued.
+.Pp
+The
+.Fa iocb->aio_sigevent
+structure can be used to request notification of the operation's
+completion as described in
+.Xr aio 4 .
+.Sh RESTRICTIONS
+The Asynchronous I/O Control Block structure pointed to by
+.Fa iocb
+and the buffer that the
+.Fa iocb->aio_buf
+member of that structure references must remain valid until the
+operation has completed.
+.Pp
+The asynchronous I/O control buffer
+.Fa iocb
+should be zeroed before the system
+calls to avoid passing bogus context information to the kernel.
+.Pp
+Modifications of the Asynchronous I/O Control Block structure or the
+buffer contents are not allowed while the request is queued.
+.Pp
+If the file offset in
+.Fa iocb->aio_offset
+is past the offset maximum for
+.Fa iocb->aio_fildes ,
+no I/O will occur.
+.Sh RETURN VALUES
+.Rv -std aio_read aio_read2 aio_readv
+.Sh DIAGNOSTICS
+None.
+.Sh ERRORS
+The
+.Fn aio_read ,
+.Fn aio_read2 ,
+and
+.Fn aio_readv
+system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The request was not queued because of system resource limitations.
+.It Bq Er EFAULT
+Part of
+.Fa aio_iov
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The asynchronous notification method in
+.Fa iocb->aio_sigevent.sigev_notify
+is invalid or not supported.
+.It Bq Er EOPNOTSUPP
+Asynchronous read operations on the file descriptor
+.Fa iocb->aio_fildes
+are unsafe and unsafe asynchronous I/O operations are disabled.
+.El
+.Pp
+The following conditions may be synchronously detected when the
+.Fn aio_read
+or
+.Fn aio_readv
+system call is made, or asynchronously, at any time thereafter.
+If they
+are detected at call time,
+The calls return -1 and set
+.Va errno
+appropriately; otherwise the
+.Fn aio_return
+system call must be called, and will return -1, and
+.Fn aio_error
+must be called to determine the actual value that would have been
+returned in
+.Va errno .
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa iocb->aio_fildes
+argument
+is invalid.
+.It Bq Er EINVAL
+The offset
+.Fa iocb->aio_offset
+is not valid, the priority specified by
+.Fa iocb->aio_reqprio
+is not a valid priority, or the number of bytes specified by
+.Fa iocb->aio_nbytes
+is not valid.
+.It Bq Er EOVERFLOW
+The file is a regular file,
+.Fa iocb->aio_nbytes
+is greater than zero, the starting offset in
+.Fa iocb->aio_offset
+is before the end of the file, but is at or beyond the
+.Fa iocb->aio_fildes
+offset maximum.
+.El
+.Pp
+If the request is successfully enqueued, but subsequently cancelled
+or an error occurs, the value returned by the
+.Fn aio_return
+system call is per the
+.Xr read 2
+system call, and the value returned by the
+.Fn aio_error
+system call is either one of the error returns from the
+.Xr read 2
+system call, or one of:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa iocb->aio_fildes
+argument
+is invalid for reading.
+.It Bq Er ECANCELED
+The request was explicitly cancelled via a call to
+.Fn aio_cancel .
+.It Bq Er EINVAL
+The offset
+.Fa iocb->aio_offset
+would be invalid.
+.El
+.Sh SEE ALSO
+.Xr aio_cancel 2 ,
+.Xr aio_error 2 ,
+.Xr aio_return 2 ,
+.Xr aio_suspend 2 ,
+.Xr aio_waitcomplete 2 ,
+.Xr aio_write 2 ,
+.Xr sigevent 3 ,
+.Xr siginfo 3 ,
+.Xr aio 4
+.Sh STANDARDS
+The
+.Fn aio_read
+system call is expected to conform to the
+.St -p1003.1
+standard.
+The
+.Fn aio_read2
+and
+.Fn aio_readv
+system calls are
+.Fx
+extensions,
+and should not be used in portable code.
+.Sh HISTORY
+The
+.Fn aio_read
+system call first appeared in
+.Fx 3.0 .
+The
+.Fn aio_readv
+system call first appeared in
+.Fx 13.0 .
+The
+.Fn aio_read2
+system call first appeared in
+.Fx 14.1 .
+.Sh AUTHORS
+This
+manual page was written by
+.An Terry Lambert Aq Mt terry@whistle.com .
+.Sh BUGS
+Invalid information in
+.Fa iocb->_aiocb_private
+may confuse the kernel.
diff --git a/lib/libc/sys/aio_return.2 b/lib/libsys/aio_return.2
index 499b85ef20d8..499b85ef20d8 100644
--- a/lib/libc/sys/aio_return.2
+++ b/lib/libsys/aio_return.2
diff --git a/lib/libc/sys/aio_suspend.2 b/lib/libsys/aio_suspend.2
index c46b0292c34e..c46b0292c34e 100644
--- a/lib/libc/sys/aio_suspend.2
+++ b/lib/libsys/aio_suspend.2
diff --git a/lib/libsys/aio_waitcomplete.2 b/lib/libsys/aio_waitcomplete.2
new file mode 100644
index 000000000000..e7f993e0b796
--- /dev/null
+++ b/lib/libsys/aio_waitcomplete.2
@@ -0,0 +1,135 @@
+.\" Copyright (c) 1999 Christopher M Sedore.
+.\" 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 ``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.
+.\"
+.Dd March 27, 2025
+.Dt AIO_WAITCOMPLETE 2
+.Os
+.Sh NAME
+.Nm aio_waitcomplete
+.Nd wait for the next completion of an aio request
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In aio.h
+.Ft ssize_t
+.Fn aio_waitcomplete "struct aiocb **iocbp" "struct timespec *timeout"
+.Sh DESCRIPTION
+The
+.Fn aio_waitcomplete
+system call waits for completion of an asynchronous I/O request.
+Upon completion,
+.Fn aio_waitcomplete
+returns the result of the function and sets
+.Fa iocbp
+to point to the structure associated with the original request.
+If an asynchronous I/O request is completed before
+.Fn aio_waitcomplete
+is called, it returns immediately with the completed request.
+.Pp
+If
+.Fa timeout
+is a non-NULL pointer, it specifies a maximum interval to wait for a
+asynchronous I/O request to complete.
+If
+.Fa timeout
+is a NULL pointer,
+.Fn aio_waitcomplete
+waits indefinitely.
+To effect a poll, the
+.Fa timeout
+argument should be non-NULL, pointing to a zero-valued timeval structure.
+.Pp
+The
+.Fn aio_waitcomplete
+system call also serves the function of
+.Fn aio_return ,
+thus
+.Fn aio_return
+should not be called for the control block returned in
+.Fa iocbp .
+.Sh RETURN VALUES
+If an asynchronous I/O request has completed,
+.Fa iocbp
+is set to point to the control block passed with the original request,
+and the status is returned as described in
+.Xr read 2 ,
+.Xr write 2 ,
+or
+.Xr fsync 2 .
+On failure,
+.Fn aio_waitcomplete
+returns
+.Dv -1 ,
+sets iocbp to
+.Dv NULL
+and sets
+.Va errno
+to indicate the error condition.
+.Sh ERRORS
+The
+.Fn aio_waitcomplete
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The process has not yet called
+.Fn aio_read
+or
+.Fn aio_write .
+.It Bq Er EINTR
+A signal was delivered before the timeout expired and before any
+asynchronous I/O requests completed.
+.It Bq Er EINVAL
+The specified time limit is invalid.
+.It Bq Er EWOULDBLOCK
+.It Bq Er EINPROGRESS
+The specified time limit expired before any asynchronous I/O requests
+completed.
+.El
+.Sh SEE ALSO
+.Xr aio_cancel 2 ,
+.Xr aio_error 2 ,
+.Xr aio_read 2 ,
+.Xr aio_return 2 ,
+.Xr aio_suspend 2 ,
+.Xr aio_write 2 ,
+.Xr fsync 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr aio 4
+.Sh STANDARDS
+The
+.Fn aio_waitcomplete
+system call is a
+.Fx Ns -specific
+extension.
+.Sh HISTORY
+The
+.Fn aio_waitcomplete
+system call first appeared in
+.Fx 4.0 .
+.Sh AUTHORS
+The
+.Fn aio_waitcomplete
+system call and this manual page were written by
+.An Christopher M Sedore Aq Mt cmsedore@maxwell.syr.edu .
diff --git a/lib/libsys/aio_write.2 b/lib/libsys/aio_write.2
new file mode 100644
index 000000000000..107e347ac335
--- /dev/null
+++ b/lib/libsys/aio_write.2
@@ -0,0 +1,291 @@
+.\" Copyright (c) 1999 Softweyr LLC.
+.\" 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 Softweyr LLC 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 Softweyr LLC 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.
+.\"
+.Dd March 27, 2025
+.Dt AIO_WRITE 2
+.Os
+.Sh NAME
+.Nm aio_write ,
+.Nm aio_write2 ,
+.Nm aio_writev
+.Nd asynchronous write to a file (REALTIME)
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In aio.h
+.Ft int
+.Fn aio_write "struct aiocb *iocb"
+.Ft int
+.Fn aio_write2 "struct aiocb *iocb" "int flags"
+.In sys/uio.h
+.Ft int
+.Fn aio_writev "struct aiocb *iocb"
+.Sh DESCRIPTION
+The
+.Fn aio_write ,
+.Fn aio_write2 ,
+and
+.Fn aio_writev
+system calls allow the calling process to write
+to the descriptor
+.Fa iocb->aio_fildes .
+The syscalls return immediately after the write request has been enqueued
+to the descriptor; the write may or may not have completed at the time
+the call returns.
+.Pp
+The
+.Fn aio_write
+call will write
+.Fa iocb->aio_nbytes
+from the buffer pointed to by
+.Fa iocb->aio_buf ,
+whereas
+.Fn aio_writev
+gathers the data from the
+.Fa iocb->aio_iovcnt
+buffers specified by the members of the
+.Fa iocb->aio_iov
+array.
+.Pp
+If the request could not be enqueued, generally due
+to invalid arguments, the call returns without having enqueued the
+request.
+.Pp
+For
+.Fn aio_writev
+the
+.Fa iovec
+structure is defined in
+.Xr writev 2 .
+.Pp
+If
+.Dv O_APPEND
+is set for
+.Fa iocb->aio_fildes ,
+write operations append to the file in the same order as the calls were
+made.
+If
+.Dv O_APPEND
+is not set for the file descriptor, the write operation for
+.Fn aio_write
+will occur at
+the absolute position from the beginning of the file plus
+.Fa iocb->aio_offset .
+.Pp
+The
+.Fn aio_write2
+call takes the
+.Fa flags
+argument.
+If
+.Fa flags
+is passed as zero, the call behaves identically to
+.Fn aio_write .
+The following flags can be specified by logical or:
+.Bl -tag -width AIO_OP2_VECTORED
+.It AIO_OP2_FOFFSET
+The write for non
+.Dv O_APPEND
+file descriptors occurs at the file descriptor offset,
+which is advanced by the operation as done by the
+.Xr write 2
+syscall.
+The
+.Fa iocb->aio_offset
+field is ignored.
+.It AIO_OP2_VECTORED
+Similar to
+.Fn aio_writev ,
+the write buffers are specified by the
+.Fa aiocb->aio_iov
+array.
+.El
+.Pp
+The
+.Fa iocb
+pointer may be subsequently used as an argument to
+.Fn aio_return
+and
+.Fn aio_error
+in order to determine return or error status for the enqueued operation
+while it is in progress.
+.Pp
+If the request is successfully enqueued, the value of
+.Fa iocb->aio_offset
+can be modified during the request as context, so this value must not
+be referenced after the request is enqueued.
+.Pp
+The
+.Fa iocb->aio_sigevent
+structure can be used to request notification of the operation's
+completion as described in
+.Xr aio 4 .
+.Sh RESTRICTIONS
+The Asynchronous I/O Control Block structure pointed to by
+.Fa iocb
+and the buffer that the
+.Fa iocb->aio_buf
+member of that structure references must remain valid until the
+operation has completed.
+.Pp
+The asynchronous I/O control buffer
+.Fa iocb
+should be zeroed before the
+system calls to avoid passing bogus context information to the kernel.
+.Pp
+Modifications of the Asynchronous I/O Control Block structure or the
+buffer contents are not allowed while the request is queued.
+.Pp
+If the file offset in
+.Fa iocb->aio_offset
+is past the offset maximum for
+.Fa iocb->aio_fildes ,
+no I/O will occur.
+.Sh RETURN VALUES
+.Rv -std aio_write aio_writev
+.Sh ERRORS
+The
+.Fn aio_write ,
+.Fn aio_write2 ,
+and
+.Fn aio_writev
+system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The request was not queued because of system resource limitations.
+.It Bq Er EFAULT
+Part of
+.Fa aio_iov
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The asynchronous notification method in
+.Fa iocb->aio_sigevent.sigev_notify
+is invalid or not supported.
+.It Bq Er EOPNOTSUPP
+Asynchronous write operations on the file descriptor
+.Fa iocb->aio_fildes
+are unsafe and unsafe asynchronous I/O operations are disabled.
+.El
+.Pp
+The following conditions may be synchronously detected when the
+.Fn aio_write ,
+.Fn aio_write2 ,
+or
+.Fn aio_writev
+system call is made, or asynchronously, at any time thereafter.
+If they
+are detected at call time, the calls return -1 and set
+.Va errno
+appropriately; otherwise the
+.Fn aio_return
+system call must be called, and will return -1, and
+.Fn aio_error
+must be called to determine the actual value that would have been
+returned in
+.Va errno .
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa iocb->aio_fildes
+argument
+is invalid, or is not opened for writing.
+.It Bq Er EINVAL
+The offset
+.Fa iocb->aio_offset
+is not valid, the priority specified by
+.Fa iocb->aio_reqprio
+is not a valid priority, or the number of bytes specified by
+.Fa iocb->aio_nbytes
+is not valid.
+.El
+.Pp
+If the request is successfully enqueued, but subsequently canceled
+or an error occurs, the value returned by the
+.Fn aio_return
+system call is per the
+.Xr write 2
+system call, and the value returned by the
+.Fn aio_error
+system call is either one of the error returns from the
+.Xr write 2
+system call, or one of:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa iocb->aio_fildes
+argument
+is invalid for writing.
+.It Bq Er ECANCELED
+The request was explicitly canceled via a call to
+.Fn aio_cancel .
+.It Bq Er EINVAL
+The offset
+.Fa iocb->aio_offset
+would be invalid.
+.El
+.Sh SEE ALSO
+.Xr aio_cancel 2 ,
+.Xr aio_error 2 ,
+.Xr aio_return 2 ,
+.Xr aio_suspend 2 ,
+.Xr aio_waitcomplete 2 ,
+.Xr sigevent 3 ,
+.Xr siginfo 3 ,
+.Xr aio 4
+.Sh STANDARDS
+The
+.Fn aio_write
+system call
+is expected to conform to the
+.St -p1003.1
+standard.
+.Pp
+The
+.Fn aio_write2
+and
+.Fn aio_writev
+system calls are
+.Fx
+extensions,
+and should not be used in portable code.
+.Sh HISTORY
+The
+.Fn aio_write
+system call first appeared in
+.Fx 3.0 .
+The
+.Fn aio_writev
+system call first appeared in
+.Fx 13.0 .
+The
+.Fn aio_write2
+system call first appeared in
+.Fx 14.1 .
+.Sh AUTHORS
+This manual page was written by
+.An Wes Peters Aq Mt wes@softweyr.com .
+.Sh BUGS
+Invalid information in
+.Fa iocb->_aiocb_private
+may confuse the kernel.
diff --git a/lib/libsys/amd64/Makefile.sys b/lib/libsys/amd64/Makefile.sys
new file mode 100644
index 000000000000..8134bdc422a6
--- /dev/null
+++ b/lib/libsys/amd64/Makefile.sys
@@ -0,0 +1,9 @@
+SRCS+= \
+ amd64_get_fsbase.c \
+ amd64_get_gsbase.c \
+ amd64_set_fsbase.c \
+ amd64_set_gsbase.c \
+ amd64_set_tlsbase.c \
+ rfork_thread.S
+
+MDASM= vfork.S cerror.S getcontext.S
diff --git a/lib/libsys/amd64/Makefile.thr b/lib/libsys/amd64/Makefile.thr
new file mode 100644
index 000000000000..52e861709faf
--- /dev/null
+++ b/lib/libsys/amd64/Makefile.thr
@@ -0,0 +1 @@
+SRCS+= _umtx_op_err.S
diff --git a/lib/libsys/amd64/SYS.h b/lib/libsys/amd64/SYS.h
new file mode 100644
index 000000000000..e27bb2cf9a93
--- /dev/null
+++ b/lib/libsys/amd64/SYS.h
@@ -0,0 +1,59 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ mov $SYS_##name, %eax; \
+ movq %rcx, %r10; \
+ syscall
+
+#ifndef _SYSCALL_BODY
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ jb HIDENAME(cerror); \
+ ret
+#endif
+
+#define RSYSCALL(name) ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+ END(__sys_##name)
+
+#define PSEUDO(name) ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+ END(__sys_##name)
diff --git a/lib/libsys/amd64/Symbol.sys.map b/lib/libsys/amd64/Symbol.sys.map
new file mode 100644
index 000000000000..11e0507b6613
--- /dev/null
+++ b/lib/libsys/amd64/Symbol.sys.map
@@ -0,0 +1,22 @@
+FBSD_1.0 {
+ rfork_thread;
+ amd64_get_fsbase;
+ amd64_get_gsbase;
+ amd64_set_fsbase;
+ amd64_set_gsbase;
+};
+
+FBSD_1.6 {
+ x86_pkru_get_perm;
+ x86_pkru_set_perm;
+ x86_pkru_protect_range;
+ x86_pkru_unprotect_range;
+};
+
+FBSD_1.8 {
+ amd64_set_tlsbase;
+};
+
+FBSDprivate_1.0 {
+ _vfork;
+};
diff --git a/lib/libthr/arch/amd64/amd64/_umtx_op_err.S b/lib/libsys/amd64/_umtx_op_err.S
index c5fb2f26d6f6..c5fb2f26d6f6 100644
--- a/lib/libthr/arch/amd64/amd64/_umtx_op_err.S
+++ b/lib/libsys/amd64/_umtx_op_err.S
diff --git a/lib/libsys/amd64/amd64_get_fsbase.c b/lib/libsys/amd64/amd64_get_fsbase.c
new file mode 100644
index 000000000000..00f16a5e404f
--- /dev/null
+++ b/lib/libsys/amd64/amd64_get_fsbase.c
@@ -0,0 +1,63 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Peter Wemm
+ * Copyright (c) 2017, 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <x86/ifunc.h>
+#include "libc_private.h"
+
+static int
+amd64_get_fsbase_cpu(void **addr)
+{
+
+ *addr = (void *)rdfsbase();
+ return (0);
+}
+
+static int
+amd64_get_fsbase_syscall(void **addr)
+{
+
+ return (sysarch(AMD64_GET_FSBASE, addr));
+}
+
+DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **))
+{
+
+ if (__getosreldate() >= P_OSREL_WRFSBASE &&
+ (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
+ return (amd64_get_fsbase_cpu);
+ return (amd64_get_fsbase_syscall);
+}
diff --git a/lib/libsys/amd64/amd64_get_gsbase.c b/lib/libsys/amd64/amd64_get_gsbase.c
new file mode 100644
index 000000000000..ef135b1eed7f
--- /dev/null
+++ b/lib/libsys/amd64/amd64_get_gsbase.c
@@ -0,0 +1,63 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Peter Wemm
+ * Copyright (c) 2017, 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <x86/ifunc.h>
+#include "libc_private.h"
+
+static int
+amd64_get_gsbase_cpu(void **addr)
+{
+
+ *addr = (void *)rdgsbase();
+ return (0);
+}
+
+static int
+amd64_get_gsbase_syscall(void **addr)
+{
+
+ return (sysarch(AMD64_GET_GSBASE, addr));
+}
+
+DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **))
+{
+
+ if (__getosreldate() >= P_OSREL_WRFSBASE &&
+ (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
+ return (amd64_get_gsbase_cpu);
+ return (amd64_get_gsbase_syscall);
+}
diff --git a/lib/libsys/amd64/amd64_set_fsbase.c b/lib/libsys/amd64/amd64_set_fsbase.c
new file mode 100644
index 000000000000..f1690fde6e17
--- /dev/null
+++ b/lib/libsys/amd64/amd64_set_fsbase.c
@@ -0,0 +1,63 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Peter Wemm
+ * Copyright (c) 2017, 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <x86/ifunc.h>
+#include "libc_private.h"
+
+static int
+amd64_set_fsbase_cpu(void *addr)
+{
+
+ wrfsbase((uintptr_t)addr);
+ return (0);
+}
+
+static int
+amd64_set_fsbase_syscall(void *addr)
+{
+
+ return (sysarch(AMD64_SET_FSBASE, &addr));
+}
+
+DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *))
+{
+
+ if (__getosreldate() >= P_OSREL_WRFSBASE &&
+ (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
+ return (amd64_set_fsbase_cpu);
+ return (amd64_set_fsbase_syscall);
+}
diff --git a/lib/libsys/amd64/amd64_set_gsbase.c b/lib/libsys/amd64/amd64_set_gsbase.c
new file mode 100644
index 000000000000..756bbae18844
--- /dev/null
+++ b/lib/libsys/amd64/amd64_set_gsbase.c
@@ -0,0 +1,63 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2003 Peter Wemm
+ * Copyright (c) 2017, 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <x86/ifunc.h>
+#include "libc_private.h"
+
+static int
+amd64_set_gsbase_cpu(void *addr)
+{
+
+ wrgsbase((uintptr_t)addr);
+ return (0);
+}
+
+static int
+amd64_set_gsbase_syscall(void *addr)
+{
+
+ return (sysarch(AMD64_SET_GSBASE, &addr));
+}
+
+DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *))
+{
+
+ if (__getosreldate() >= P_OSREL_WRFSBASE &&
+ (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
+ return (amd64_set_gsbase_cpu);
+ return (amd64_set_gsbase_syscall);
+}
diff --git a/lib/libsys/amd64/amd64_set_tlsbase.c b/lib/libsys/amd64/amd64_set_tlsbase.c
new file mode 100644
index 000000000000..a28441fbfc5d
--- /dev/null
+++ b/lib/libsys/amd64/amd64_set_tlsbase.c
@@ -0,0 +1,51 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <x86/ifunc.h>
+#include "libc_private.h"
+
+static int
+amd64_set_tlsbase_syscall(void *addr)
+{
+ return (sysarch(AMD64_SET_TLSBASE, &addr));
+}
+
+DEFINE_UIFUNC(, int, amd64_set_tlsbase, (void *))
+{
+ if (__getosreldate() >= P_OSREL_TLSBASE)
+ return (amd64_set_tlsbase_syscall);
+ return (amd64_set_fsbase);
+}
diff --git a/lib/libsys/amd64/cerror.S b/lib/libsys/amd64/cerror.S
new file mode 100644
index 000000000000..68273a5c971f
--- /dev/null
+++ b/lib/libsys/amd64/cerror.S
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+ .globl HIDENAME(cerror)
+ .hidden HIDENAME(cerror)
+
+ /*
+ * The __error() function is thread aware. For non-threaded
+ * programs and the initial thread in threaded programs,
+ * it returns a pointer to the global errno variable.
+ */
+ .globl CNAME(__error)
+ .type CNAME(__error),@function
+HIDENAME(cerror):
+ pushq %rax
+ call PIC_PLT(CNAME(__error))
+ popq %rcx
+ movl %ecx,(%rax)
+ movq $-1,%rax
+ movq $-1,%rdx
+ ret
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/amd64/getcontext.S b/lib/libsys/amd64/getcontext.S
new file mode 100644
index 000000000000..c3a856c879f8
--- /dev/null
+++ b/lib/libsys/amd64/getcontext.S
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2003 Peter Wemm <peter@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.
+ */
+
+#include <machine/asm.h>
+#include <SYS.h>
+
+/*
+ * This has to be magic to handle the multiple returns.
+ * Otherwise, the setcontext() syscall will return here and we'll
+ * pop off the return address and go to the *setcontext* call.
+ */
+ WEAK_REFERENCE(__sys_getcontext, _getcontext)
+ WEAK_REFERENCE(__sys_getcontext, getcontext)
+ENTRY(__sys_getcontext)
+ movq (%rsp),%rsi /* save getcontext return address */
+ _SYSCALL(getcontext)
+ jb HIDENAME(cerror)
+ addq $8,%rsp /* remove stale (setcontext) return address */
+ jmp *%rsi /* restore return address */
+END(__sys_getcontext)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/amd64/rfork_thread.S b/lib/libsys/amd64/rfork_thread.S
new file mode 100644
index 000000000000..a70551631f1b
--- /dev/null
+++ b/lib/libsys/amd64/rfork_thread.S
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
+ * Copyright (c) 2003 Alan L. Cox <alc@cs.rice.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 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.
+ */
+
+#include <machine/asm.h>
+/*
+ * With thanks to John Dyson for the original version of this.
+ */
+
+#include <SYS.h>
+
+/*
+ * %edi %rsi %rdx %rcx
+ * rfork_thread(flags, stack_addr, start_fnc, start_arg);
+ *
+ * flags: Flags to rfork system call. See rfork(2).
+ * stack_addr: Top of stack for thread.
+ * start_fnc: Address of thread function to call in child.
+ * start_arg: Argument to pass to the thread function in child.
+ */
+
+ENTRY(rfork_thread)
+ pushq %rbx
+ pushq %r12
+ movq %rdx, %rbx
+ movq %rcx, %r12
+
+ /*
+ * Prepare and execute the thread creation syscall
+ */
+ _SYSCALL(rfork)
+ jb 2f
+
+ /*
+ * Check to see if we are in the parent or child
+ */
+ cmpl $0, %edx
+ jnz 1f
+ popq %r12
+ popq %rbx
+ ret
+
+ /*
+ * If we are in the child (new thread), then
+ * set-up the call to the internal subroutine. If it
+ * returns, then call __exit.
+ */
+1:
+ movq %rsi, %rsp
+ movq %r12, %rdi
+ call *%rbx
+ movl %eax, %edi
+
+ /*
+ * Exit system call
+ */
+ _SYSCALL(exit)
+
+ /*
+ * Branch here if the thread creation fails:
+ */
+2:
+ popq %r12
+ popq %rbx
+ jmp HIDENAME(cerror)
+END(rfork_thread)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/amd64/vfork.S b/lib/libsys/amd64/vfork.S
new file mode 100644
index 000000000000..e3c5f701dcff
--- /dev/null
+++ b/lib/libsys/amd64/vfork.S
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+ WEAK_REFERENCE(__sys_vfork, _vfork)
+ WEAK_REFERENCE(__sys_vfork, vfork)
+ENTRY(__sys_vfork)
+ popq %rsi /* fetch return address (%rsi preserved) */
+ _SYSCALL(vfork)
+ jb 1f
+ jmp *%rsi
+1:
+ pushq %rsi
+ jmp HIDENAME(cerror)
+END(__sys_vfork)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/arm/Makefile.sys b/lib/libsys/arm/Makefile.sys
new file mode 100644
index 000000000000..27d78978a2f4
--- /dev/null
+++ b/lib/libsys/arm/Makefile.sys
@@ -0,0 +1,6 @@
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
+MDASM= \
+ cerror.S \
+ vfork.S
diff --git a/lib/libsys/arm/SYS.h b/lib/libsys/arm/SYS.h
new file mode 100644
index 000000000000..187851c67543
--- /dev/null
+++ b/lib/libsys/arm/SYS.h
@@ -0,0 +1,70 @@
+/* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */
+
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+#include <sys/syscall.h>
+
+#define _SYSCALL(x) \
+ mov ip, r7; \
+ ldr r7, =SYS_ ## x; \
+ swi 0; \
+ mov r7, ip
+
+#define CERROR _C_LABEL(cerror)
+
+#ifndef _SYSCALL_BODY
+#define _SYSCALL_BODY(x) \
+ _SYSCALL(x); \
+ it cs; \
+ bcs PIC_SYM(CERROR, PLT); \
+ RET
+#endif
+
+#define PSEUDO(x) \
+ ENTRY(__CONCAT(__sys_, x)); \
+ .weak _C_LABEL(__CONCAT(_,x)); \
+ .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \
+ _SYSCALL_BODY(x)
+
+#define RSYSCALL(x) \
+ ENTRY(__CONCAT(__sys_, x)); \
+ .weak _C_LABEL(x); \
+ .set _C_LABEL(x), _C_LABEL(__CONCAT(__sys_,x)); \
+ .weak _C_LABEL(__CONCAT(_,x)); \
+ .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \
+ _SYSCALL_BODY(x); \
+
+ .globl CERROR
diff --git a/lib/libsys/arm/Symbol.sys.map b/lib/libsys/arm/Symbol.sys.map
new file mode 100644
index 000000000000..a9445ae7ba23
--- /dev/null
+++ b/lib/libsys/arm/Symbol.sys.map
@@ -0,0 +1,3 @@
+FBSDprivate_1.0 {
+ _vfork;
+};
diff --git a/lib/libsys/arm/__vdso_gettc.c b/lib/libsys/arm/__vdso_gettc.c
new file mode 100644
index 000000000000..cb4bdec1e8ef
--- /dev/null
+++ b/lib/libsys/arm/__vdso_gettc.c
@@ -0,0 +1,81 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2015 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <machine/cpufunc.h>
+#include <machine/acle-compat.h>
+#include <errno.h>
+#include "libc_private.h"
+
+static inline uint64_t
+cp15_cntvct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrrc\tp15, 1, %Q0, %R0, c14" : "=r" (reg));
+ return (reg);
+}
+
+static inline uint64_t
+cp15_cntpct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrrc\tp15, 0, %Q0, %R0, c14" : "=r" (reg));
+ return (reg);
+}
+
+#pragma weak __vdso_gettc
+int
+__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+
+ if (th->th_algo != VDSO_TH_ALGO_ARM_GENTIM)
+ return (ENOSYS);
+ /*
+ * Userspace gettimeofday() is only enabled on ARMv7 CPUs, but
+ * libc is compiled for ARMv6. Due to clang issues, .arch
+ * armv7-a directive does not work.
+ */
+ __asm __volatile(".word\t0xf57ff06f" : : : "memory"); /* isb */
+ *tc = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libsys/arm/cerror.S b/lib/libsys/arm/cerror.S
new file mode 100644
index 000000000000..7a9947fe7df3
--- /dev/null
+++ b/lib/libsys/arm/cerror.S
@@ -0,0 +1,48 @@
+/* $NetBSD: cerror.S,v 1.5 2003/08/07 16:42:04 agc Exp $ */
+
+/*-
+ * Copyright (c) 1990 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+.globl _C_LABEL(__error)
+.type _C_LABEL(__error),%function
+
+ASENTRY(CERROR)
+ stmfd sp!, {r4, lr}
+ mov r4, r0
+ bl PIC_SYM(_C_LABEL(__error), PLT)
+ str r4, [r0]
+ mvn r0, #0x00000000
+ mvn r1, #0x00000000
+ ldmfd sp!, {r4, pc}
+END(CERROR)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/arm/vfork.S b/lib/libsys/arm/vfork.S
new file mode 100644
index 000000000000..ef9a426c6de5
--- /dev/null
+++ b/lib/libsys/arm/vfork.S
@@ -0,0 +1,58 @@
+/* $NetBSD: Ovfork.S,v 1.6 2003/08/07 16:42:03 agc Exp $ */
+
+/*-
+ * Copyright (c) 1990 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+/*
+ * pid = vfork();
+ *
+ * On return from the SWI:
+ * r1 == 0 in parent process, r1 == 1 in child process.
+ * r0 == pid of child in parent, r0 == pid of parent in child.
+ */
+ .text
+ .align 0
+
+ENTRY(__sys_vfork)
+ .weak _C_LABEL(vfork);
+ .set _C_LABEL(vfork), _C_LABEL(__sys_vfork);
+ .weak _C_LABEL(_vfork);
+ .set _C_LABEL(_vfork), _C_LABEL(__sys_vfork);
+ mov r2, r14
+ _SYSCALL(vfork)
+ bcs PIC_SYM(CERROR, PLT)
+ sub r1, r1, #1 /* r1 == 0xffffffff if parent, 0 if child */
+ and r0, r0, r1 /* r0 == 0 if child, else unchanged */
+ mov r15, r2
+END(__sys_vfork)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/auxv.3 b/lib/libsys/auxv.3
new file mode 100644
index 000000000000..b3b741937ac7
--- /dev/null
+++ b/lib/libsys/auxv.3
@@ -0,0 +1,111 @@
+.\"
+.\" Copyright (c) 2019 Ian Lepore <ian@freebsd.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.
+.\"
+.\" 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.
+.\"
+.Dd June 24, 2025
+.Dt ELF_AUX_INFO 3
+.Os
+.Sh NAME
+.Nm elf_aux_info
+.Nd extract data from the elf auxiliary vector of the current process
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/auxv.h
+.Ft int
+.Fn elf_aux_info "int aux" "void *buf" "int buflen"
+.Sh DESCRIPTION
+The
+.Fn elf_aux_info
+function retrieves the auxiliary info vector requested in
+.Va aux .
+The information is stored into the provided buffer if it will fit.
+The following values, defined in
+.In sys/elf_common.h
+can be requested (corresponding buffer sizes are specified in parenthesis):
+.Bl -tag -width AT_OSRELDATE
+.It AT_CANARY
+The canary value for SSP (arbitrary sized buffer, as many bytes are
+returned as it fits into it, rest is zeroed).
+.It AT_EXECPATH
+The path of executed program
+.Dv (MAXPATHLEN).
+This may not be present if the process was initialized by
+.Xr fexecve 2
+and the namecache no longer contains the file's name.
+.It AT_HWCAP
+CPU / hardware feature flags
+.Dv (sizeof(u_long)).
+.It AT_HWCAP2
+CPU / hardware feature flags
+.Dv (sizeof(u_long)).
+.It AT_HWCAP3
+CPU / hardware feature flags
+.Dv (sizeof(u_long)).
+.It AT_HWCAP4
+CPU / hardware feature flags
+.Dv (sizeof(u_long)).
+.It AT_NCPUS
+Number of CPUs
+.Dv (sizeof(int)).
+.It AT_OSRELDATE
+The
+.Dv OSRELDATE
+of the kernel or jail the program is running on
+.Dv (sizeof(int)).
+.It AT_PAGESIZES
+Vector of page sizes (arbitrary sized buffer, as many elements of the
+.Dv pagesizes
+array are returned as it fits).
+.It AT_PAGESZ
+Page size in bytes
+.Dv (sizeof(int)).
+.It AT_TIMEKEEP
+Pointer to VDSO timehands (for library internal use,
+.Dv sizeof(void *)).
+.It AT_USRSTACKBASE
+Top of the user stack for main thread.
+.It AT_USRSTACKLIM
+Limit for grow of the user stack for main thread.
+.El
+.Sh RETURN VALUES
+Returns zero on success, or an error number on failure.
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EINVAL
+An unknown item was requested.
+.It Bq Er EINVAL
+The provided buffer was not the right size for the requested item.
+.It Bq Er ENOENT
+The requested item is not available.
+.El
+.Sh HISTORY
+The
+.Fn elf_aux_info
+function appeared in
+.Fx 12.0 .
+.Sh BUGS
+Only a small subset of available auxiliary info vector items are
+accessible with this function.
+Some items require a "right-sized" buffer while others just require a
+"big enough" buffer.
diff --git a/lib/libsys/auxv.c b/lib/libsys/auxv.c
new file mode 100644
index 000000000000..80702c66ba22
--- /dev/null
+++ b/lib/libsys/auxv.c
@@ -0,0 +1,444 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2010, 2012 Konstantin Belousov <kib@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 ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "namespace.h"
+#include <elf.h>
+#include <errno.h>
+#include <link.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/auxv.h>
+#include "un-namespace.h"
+#include "libc_private.h"
+#include <machine/atomic.h>
+
+extern int _DYNAMIC;
+#pragma weak _DYNAMIC
+
+void *__elf_aux_vector;
+
+#ifndef PIC
+static pthread_once_t aux_vector_once = PTHREAD_ONCE_INIT;
+
+static void
+init_aux_vector_once(void)
+{
+ Elf_Addr *sp;
+
+ sp = (Elf_Addr *)environ;
+ while (*sp++ != 0)
+ ;
+ __elf_aux_vector = (Elf_Auxinfo *)sp;
+}
+
+void
+__init_elf_aux_vector(void)
+{
+
+ if (&_DYNAMIC != NULL)
+ return;
+ _once(&aux_vector_once, init_aux_vector_once);
+}
+#endif
+
+static int aux_once;
+static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags;
+static int hwcap_present, hwcap2_present, hwcap3_present, hwcap4_present;
+static char *canary, *pagesizes, *execpath;
+static void *ps_strings, *timekeep;
+static u_long hwcap, hwcap2, hwcap3, hwcap4;
+static void *fxrng_seed_version;
+static u_long usrstackbase, usrstacklim;
+
+#ifdef __powerpc__
+static int powerpc_new_auxv_format = 0;
+static void _init_aux_powerpc_fixup(void);
+int _powerpc_elf_aux_info(int, void *, int);
+#endif
+
+/*
+ * This function might be called and actual body executed more than
+ * once in multithreading environment. Due to this, it is and must
+ * continue to be idempotent. All stores are atomic (no store
+ * tearing), because we only assign to int/long/ptr.
+ */
+static void
+init_aux(void)
+{
+ Elf_Auxinfo *aux;
+
+ if (atomic_load_acq_int(&aux_once))
+ return;
+ for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
+ switch (aux->a_type) {
+ case AT_BSDFLAGS:
+ bsdflags = aux->a_un.a_val;
+ break;
+
+ case AT_CANARY:
+ canary = (char *)(aux->a_un.a_ptr);
+ break;
+
+ case AT_CANARYLEN:
+ canary_len = aux->a_un.a_val;
+ break;
+
+ case AT_EXECPATH:
+ execpath = (char *)(aux->a_un.a_ptr);
+ break;
+
+ case AT_HWCAP:
+ hwcap_present = 1;
+ hwcap = (u_long)(aux->a_un.a_val);
+ break;
+
+ case AT_HWCAP2:
+ hwcap2_present = 1;
+ hwcap2 = (u_long)(aux->a_un.a_val);
+ break;
+
+ case AT_HWCAP3:
+ hwcap3_present = 1;
+ hwcap3 = (u_long)(aux->a_un.a_val);
+ break;
+
+ case AT_HWCAP4:
+ hwcap4_present = 1;
+ hwcap4 = (u_long)(aux->a_un.a_val);
+ break;
+
+ case AT_PAGESIZES:
+ pagesizes = (char *)(aux->a_un.a_ptr);
+ break;
+
+ case AT_PAGESIZESLEN:
+ pagesizes_len = aux->a_un.a_val;
+ break;
+
+ case AT_PAGESZ:
+ pagesize = aux->a_un.a_val;
+ break;
+
+ case AT_OSRELDATE:
+ osreldate = aux->a_un.a_val;
+ break;
+
+ case AT_NCPUS:
+ ncpus = aux->a_un.a_val;
+ break;
+
+ case AT_TIMEKEEP:
+ timekeep = aux->a_un.a_ptr;
+ break;
+
+ case AT_PS_STRINGS:
+ ps_strings = aux->a_un.a_ptr;
+ break;
+
+ case AT_FXRNG:
+ fxrng_seed_version = aux->a_un.a_ptr;
+ break;
+
+ case AT_USRSTACKBASE:
+ usrstackbase = aux->a_un.a_val;
+ break;
+
+ case AT_USRSTACKLIM:
+ usrstacklim = aux->a_un.a_val;
+ break;
+#ifdef __powerpc__
+ /*
+ * Since AT_STACKPROT is always set, and the common
+ * value 23 is mutually exclusive with the legacy powerpc
+ * value 21, the existence of AT_STACKPROT proves we are
+ * on the common format.
+ */
+ case AT_STACKPROT: /* 23 */
+ powerpc_new_auxv_format = 1;
+ break;
+#endif
+ }
+ }
+#ifdef __powerpc__
+ if (!powerpc_new_auxv_format)
+ _init_aux_powerpc_fixup();
+#endif
+
+ atomic_store_rel_int(&aux_once, 1);
+}
+
+#ifdef __powerpc__
+static void
+_init_aux_powerpc_fixup(void)
+{
+ Elf_Auxinfo *aux;
+
+ /*
+ * Before 1300070, PowerPC platforms had nonstandard numbering for
+ * the aux vector. When running old binaries, the kernel will pass
+ * the vector using the old numbering. Reload affected variables.
+ */
+ for (aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
+ switch (aux->a_type) {
+ case AT_OLD_CANARY:
+ canary = (char *)(aux->a_un.a_ptr);
+ break;
+ case AT_OLD_CANARYLEN:
+ canary_len = aux->a_un.a_val;
+ break;
+ case AT_OLD_EXECPATH:
+ execpath = (char *)(aux->a_un.a_ptr);
+ break;
+ case AT_OLD_PAGESIZES:
+ pagesizes = (char *)(aux->a_un.a_ptr);
+ break;
+ case AT_OLD_PAGESIZESLEN:
+ pagesizes_len = aux->a_un.a_val;
+ break;
+ case AT_OLD_OSRELDATE:
+ osreldate = aux->a_un.a_val;
+ break;
+ case AT_OLD_NCPUS:
+ ncpus = aux->a_un.a_val;
+ break;
+ }
+ }
+}
+
+int
+_powerpc_elf_aux_info(int aux, void *buf, int buflen)
+{
+
+ /*
+ * If we are in the old auxv format, we need to translate the aux
+ * parameter of elf_aux_info() calls into the common auxv format.
+ * Internal libc calls always use the common format, and they
+ * directly call _elf_aux_info instead of using the weak symbol.
+ */
+ if (!powerpc_new_auxv_format) {
+ switch (aux) {
+ case AT_OLD_EXECPATH:
+ aux = AT_EXECPATH;
+ break;
+ case AT_OLD_CANARY:
+ aux = AT_CANARY;
+ break;
+ case AT_OLD_CANARYLEN:
+ aux = AT_CANARYLEN;
+ break;
+ case AT_OLD_OSRELDATE:
+ aux = AT_OSRELDATE;
+ break;
+ case AT_OLD_NCPUS:
+ aux = AT_NCPUS;
+ break;
+ case AT_OLD_PAGESIZES:
+ aux = AT_PAGESIZES;
+ break;
+ case AT_OLD_PAGESIZESLEN:
+ aux = AT_PAGESIZESLEN;
+ break;
+ case AT_OLD_STACKPROT:
+ aux = AT_STACKPROT;
+ break;
+ }
+ }
+ return _elf_aux_info(aux, buf, buflen);
+}
+__weak_reference(_powerpc_elf_aux_info, elf_aux_info);
+#else
+__weak_reference(_elf_aux_info, elf_aux_info);
+#endif
+
+int
+_elf_aux_info(int aux, void *buf, int buflen)
+{
+ int res;
+
+#ifndef PIC
+ __init_elf_aux_vector();
+#endif
+ if (__elf_aux_vector == NULL)
+ return (ENOSYS);
+ init_aux(); /* idempotent */
+
+ if (buflen < 0)
+ return (EINVAL);
+
+ switch (aux) {
+ case AT_CANARY:
+ if (canary != NULL && canary_len >= buflen) {
+ memcpy(buf, canary, buflen);
+ memset(canary, 0, canary_len);
+ canary = NULL;
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_EXECPATH:
+ if (execpath == NULL)
+ res = ENOENT;
+ else if (buf == NULL)
+ res = EINVAL;
+ else {
+ if (strlcpy(buf, execpath, buflen) >=
+ (unsigned int)buflen)
+ res = EINVAL;
+ else
+ res = 0;
+ }
+ break;
+ case AT_HWCAP:
+ if (hwcap_present && buflen == sizeof(u_long)) {
+ *(u_long *)buf = hwcap;
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_HWCAP2:
+ if (hwcap2_present && buflen == sizeof(u_long)) {
+ *(u_long *)buf = hwcap2;
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_HWCAP3:
+ if (hwcap3_present && buflen == sizeof(u_long)) {
+ *(u_long *)buf = hwcap3;
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_HWCAP4:
+ if (hwcap4_present && buflen == sizeof(u_long)) {
+ *(u_long *)buf = hwcap4;
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_PAGESIZES:
+ if (pagesizes != NULL && pagesizes_len >= buflen) {
+ memcpy(buf, pagesizes, buflen);
+ res = 0;
+ } else
+ res = ENOENT;
+ break;
+ case AT_PAGESZ:
+ if (buflen == sizeof(int)) {
+ if (pagesize != 0) {
+ *(int *)buf = pagesize;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_OSRELDATE:
+ if (buflen == sizeof(int)) {
+ if (osreldate != 0) {
+ *(int *)buf = osreldate;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_NCPUS:
+ if (buflen == sizeof(int)) {
+ if (ncpus != 0) {
+ *(int *)buf = ncpus;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_TIMEKEEP:
+ if (buflen == sizeof(void *)) {
+ if (timekeep != NULL) {
+ *(void **)buf = timekeep;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_BSDFLAGS:
+ if (buflen == sizeof(int)) {
+ *(int *)buf = bsdflags;
+ res = 0;
+ } else
+ res = EINVAL;
+ break;
+ case AT_PS_STRINGS:
+ if (buflen == sizeof(void *)) {
+ if (ps_strings != NULL) {
+ *(void **)buf = ps_strings;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_FXRNG:
+ if (buflen == sizeof(void *)) {
+ if (fxrng_seed_version != NULL) {
+ *(void **)buf = fxrng_seed_version;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_USRSTACKBASE:
+ if (buflen == sizeof(u_long)) {
+ if (usrstackbase != 0) {
+ *(u_long *)buf = usrstackbase;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ case AT_USRSTACKLIM:
+ if (buflen == sizeof(u_long)) {
+ if (usrstacklim != 0) {
+ *(u_long *)buf = usrstacklim;
+ res = 0;
+ } else
+ res = ENOENT;
+ } else
+ res = EINVAL;
+ break;
+ default:
+ res = ENOENT;
+ break;
+ }
+ return (res);
+}
diff --git a/lib/libsys/bind.2 b/lib/libsys/bind.2
new file mode 100644
index 000000000000..46325b31bd74
--- /dev/null
+++ b/lib/libsys/bind.2
@@ -0,0 +1,138 @@
+.\" Copyright (c) 1983, 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.
+.\"
+.Dd March 30, 2020
+.Dt BIND 2
+.Os
+.Sh NAME
+.Nm bind
+.Nd assign a local protocol address to a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft int
+.Fn bind "int s" "const struct sockaddr *addr" "socklen_t addrlen"
+.Sh DESCRIPTION
+The
+.Fn bind
+system call
+assigns the local protocol address to a socket.
+When a socket is created
+with
+.Xr socket 2
+it exists in an address family space but has no protocol address assigned.
+The
+.Fn bind
+system call requests that
+.Fa addr
+be assigned to the socket.
+.Sh NOTES
+Binding an address in the UNIX domain creates a socket in the file
+system that must be deleted by the caller when it is no longer
+needed (using
+.Xr unlink 2 ) .
+.Pp
+The rules used in address binding vary between communication domains.
+Consult the manual entries in section 4 for detailed information.
+.Pp
+For maximum portability, you should always zero the socket address structure
+before populating it and passing it to
+.Fn bind .
+.Sh RETURN VALUES
+.Rv -std bind
+.Sh ERRORS
+The
+.Fn bind
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+Kernel resources to complete the request are
+temporarily unavailable.
+.It Bq Er EBADF
+The
+.Fa s
+argument
+is not a valid descriptor.
+.It Bq Er EINVAL
+The socket is already bound to an address, and the protocol does not support
+binding to a new address; or the socket has been shut down.
+.It Bq Er EINVAL
+The
+.Fa addrlen
+argument is not a valid length for the address family.
+.It Bq Er ENOTSOCK
+The
+.Fa s
+argument
+is not a socket.
+.It Bq Er EADDRNOTAVAIL
+The specified address is not available from the local machine.
+.It Bq Er EADDRINUSE
+The specified address is already in use.
+.It Bq Er EAFNOSUPPORT
+Addresses in the specified address family cannot be used with this socket.
+.It Bq Er EACCES
+The requested address is protected, and the current user
+has inadequate permission to access it.
+.It Bq Er EFAULT
+The
+.Fa addr
+argument is not in a valid part of the user
+address space.
+.El
+.Pp
+The following errors are specific to binding addresses in the UNIX domain.
+.Bl -tag -width EADDRNOTAVA
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A prefix component of the path name does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EIO
+An I/O error occurred while making the directory entry or allocating the inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The name would reside on a read-only file system.
+.It Bq Er EISDIR
+An empty pathname was specified.
+.El
+.Sh SEE ALSO
+.Xr connect 2 ,
+.Xr getsockname 2 ,
+.Xr listen 2 ,
+.Xr socket 2
+.Sh HISTORY
+The
+.Fn bind
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libc/sys/bindat.2 b/lib/libsys/bindat.2
index a31ef2715db9..a31ef2715db9 100644
--- a/lib/libc/sys/bindat.2
+++ b/lib/libsys/bindat.2
diff --git a/lib/libsys/brk.2 b/lib/libsys/brk.2
new file mode 100644
index 000000000000..a90c8bbe9536
--- /dev/null
+++ b/lib/libsys/brk.2
@@ -0,0 +1,187 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd June 2, 2018
+.Dt BRK 2
+.Os
+.Sh NAME
+.Nm brk ,
+.Nm sbrk
+.Nd change data segment size
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn brk "const void *addr"
+.Ft void *
+.Fn sbrk "intptr_t incr"
+.Sh DESCRIPTION
+.Bf -symbolic
+The
+.Fn brk
+and
+.Fn sbrk
+functions are legacy interfaces from before the
+advent of modern virtual memory management.
+They are deprecated and not present on the arm64 or riscv architectures.
+The
+.Xr mmap 2
+interface should be used to allocate pages instead.
+.Ef
+.Pp
+The
+.Fn brk
+and
+.Fn sbrk
+functions are used to change the amount of memory allocated in a
+process's data segment.
+They do this by moving the location of the
+.Dq break .
+The break is the first address after the end of the process's
+uninitialized data segment (also known as the
+.Dq BSS ) .
+.Pp
+The
+.Fn brk
+function
+sets the break to
+.Fa addr .
+.Pp
+The
+.Fn sbrk
+function raises the break by
+.Fa incr
+bytes, thus allocating at least
+.Fa incr
+bytes of new memory in the data segment.
+If
+.Fa incr
+is negative,
+the break is lowered by
+.Fa incr
+bytes.
+.Sh NOTES
+While the actual process data segment size maintained by the kernel will only
+grow or shrink in page sizes, these functions allow setting the break
+to unaligned values (i.e., it may point to any address inside the last
+page of the data segment).
+.Pp
+The current value of the program break may be determined by calling
+.Fn sbrk 0 .
+See also
+.Xr end 3 .
+.Pp
+The
+.Xr getrlimit 2
+system call may be used to determine
+the maximum permissible size of the
+data segment.
+It will not be possible to set the break
+beyond
+.Dq Va etext No + Va rlim.rlim_max
+where the
+.Va rlim.rlim_max
+value is returned from a call to
+.Fn getrlimit RLIMIT_DATA &rlim .
+(See
+.Xr end 3
+for the definition of
+.Va etext ) .
+.Sh RETURN VALUES
+.Rv -std brk
+.Pp
+The
+.Fn sbrk
+function returns the prior break value if successful;
+otherwise the value
+.Po Vt "void *" Pc Ns \-1
+is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn brk
+and
+.Fn sbrk
+functions
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The requested break value was beyond the beginning of the data segment.
+.It Bq Er ENOMEM
+The data segment size limit, as set by
+.Xr setrlimit 2 ,
+was exceeded.
+.It Bq Er ENOMEM
+Insufficient space existed in the swap area
+to support the expansion of the data segment.
+.El
+.Sh SEE ALSO
+.Xr execve 2 ,
+.Xr getrlimit 2 ,
+.Xr mmap 2 ,
+.Xr end 3 ,
+.Xr free 3 ,
+.Xr malloc 3
+.Sh HISTORY
+The
+.Fn brk
+function appeared in
+.At v7 .
+.Fx 11.0
+introduced the arm64 and riscv architectures which do not support
+.Fn brk
+or
+.Fn sbrk .
+.Sh BUGS
+Mixing
+.Fn brk
+or
+.Fn sbrk
+with
+.Xr malloc 3 ,
+.Xr free 3 ,
+or similar functions will result in non-portable program behavior.
+.Pp
+Setting the break may fail due to a temporary lack of
+swap space.
+It is not possible to distinguish this
+from a failure caused by exceeding the maximum size of
+the data segment without consulting
+.Xr getrlimit 2 .
+.Pp
+.Fn sbrk
+is sometimes used to monitor heap use by calling with an argument of 0.
+The result is unlikely to reflect actual utilization in combination with an
+.Xr mmap 2
+based malloc.
+.Pp
+.Fn brk
+and
+.Fn sbrk
+are not thread-safe.
diff --git a/lib/libc/sys/cap_enter.2 b/lib/libsys/cap_enter.2
index 90c089ae9b07..90c089ae9b07 100644
--- a/lib/libc/sys/cap_enter.2
+++ b/lib/libsys/cap_enter.2
diff --git a/lib/libc/sys/cap_fcntls_limit.2 b/lib/libsys/cap_fcntls_limit.2
index 299594e9be66..299594e9be66 100644
--- a/lib/libc/sys/cap_fcntls_limit.2
+++ b/lib/libsys/cap_fcntls_limit.2
diff --git a/lib/libc/sys/cap_ioctls_limit.2 b/lib/libsys/cap_ioctls_limit.2
index c9d468ba8fac..c9d468ba8fac 100644
--- a/lib/libc/sys/cap_ioctls_limit.2
+++ b/lib/libsys/cap_ioctls_limit.2
diff --git a/lib/libsys/cap_rights_limit.2 b/lib/libsys/cap_rights_limit.2
new file mode 100644
index 000000000000..8372d07f6a5c
--- /dev/null
+++ b/lib/libsys/cap_rights_limit.2
@@ -0,0 +1,164 @@
+.\"
+.\" Copyright (c) 2008-2010 Robert N. M. Watson
+.\" Copyright (c) 2012-2013 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This software was developed at the University of Cambridge Computer
+.\" Laboratory with support from a grant from Google, Inc.
+.\"
+.\" Portions of this documentation were written by Pawel Jakub Dawidek
+.\" under sponsorship from the FreeBSD Foundation.
+.\"
+.\" 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.
+.\"
+.Dd April 27, 2024
+.Dt CAP_RIGHTS_LIMIT 2
+.Os
+.Sh NAME
+.Nm cap_rights_limit
+.Nd limit capability rights
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/capsicum.h
+.Ft int
+.Fn cap_rights_limit "int fd" "const cap_rights_t *rights"
+.Sh DESCRIPTION
+When a file descriptor is created by a function such as
+.Xr fhopen 2 ,
+.Xr kqueue 2 ,
+.Xr mq_open 2 ,
+.Xr open 2 ,
+.Xr pdfork 2 ,
+.Xr pipe 2 ,
+.Xr shm_open 2 ,
+.Xr socket 2
+or
+.Xr socketpair 2 ,
+it is assigned all capability rights; for
+.Xr accept 2 ,
+.Xr accept4 2
+or
+.Xr openat 2 ,
+it inherits capability rights from the "parent" file descriptor.
+Those rights can be reduced (but never expanded) by using the
+.Fn cap_rights_limit
+system call.
+Once capability rights are reduced, operations on the file descriptor will be
+limited to those permitted by
+.Fa rights .
+.Pp
+The
+.Fa rights
+argument should be prepared using
+.Xr cap_rights_init 3
+family of functions.
+.Pp
+Capability rights assigned to a file descriptor can be obtained with the
+.Xr cap_rights_get 3
+function.
+.Pp
+The complete list of the capability rights can be found in the
+.Xr rights 4
+manual page.
+.Sh RETURN VALUES
+.Rv -std
+.Sh EXAMPLES
+The following example demonstrates how to limit file descriptor capability
+rights to allow reading only.
+.Bd -literal
+cap_rights_t setrights;
+char buf[1];
+int fd;
+
+fd = open("/tmp/foo", O_RDWR);
+if (fd < 0)
+ err(1, "open() failed");
+
+if (cap_enter() < 0)
+ err(1, "cap_enter() failed");
+
+cap_rights_init(&setrights, CAP_READ);
+if (cap_rights_limit(fd, &setrights) < 0)
+ err(1, "cap_rights_limit() failed");
+
+buf[0] = 'X';
+
+if (write(fd, buf, sizeof(buf)) > 0)
+ errx(1, "write() succeeded!");
+
+if (read(fd, buf, sizeof(buf)) < 0)
+ err(1, "read() failed");
+.Ed
+.Sh ERRORS
+.Fn cap_rights_limit
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument is not a valid active descriptor.
+.It Bq Er EINVAL
+An invalid right has been requested in
+.Fa rights .
+.It Bq Er ENOSYS
+The running kernel was compiled without
+.Cd "options CAPABILITY_MODE" .
+.It Bq Er ENOTCAPABLE
+The
+.Fa rights
+argument contains capability rights not present for the given file descriptor.
+Capability rights list can only be reduced, never expanded.
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr accept4 2 ,
+.Xr cap_enter 2 ,
+.Xr fhopen 2 ,
+.Xr kqueue 2 ,
+.Xr mq_open 2 ,
+.Xr open 2 ,
+.Xr openat 2 ,
+.Xr pdfork 2 ,
+.Xr pipe 2 ,
+.Xr read 2 ,
+.Xr shm_open 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2 ,
+.Xr write 2 ,
+.Xr cap_rights_get 3 ,
+.Xr cap_rights_init 3 ,
+.Xr err 3 ,
+.Xr capsicum 4 ,
+.Xr rights 4
+.Sh HISTORY
+The
+.Fn cap_rights_limit
+function first appeared in
+.Fx 8.3 .
+Support for capabilities and capabilities mode was developed as part of the
+.Tn TrustedBSD
+Project.
+.Sh AUTHORS
+This function was created by
+.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net
+under sponsorship of the FreeBSD Foundation.
diff --git a/lib/libsys/chdir.2 b/lib/libsys/chdir.2
new file mode 100644
index 000000000000..991529f11f3d
--- /dev/null
+++ b/lib/libsys/chdir.2
@@ -0,0 +1,131 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt CHDIR 2
+.Os
+.Sh NAME
+.Nm chdir ,
+.Nm fchdir
+.Nd change current working directory
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn chdir "const char *path"
+.Ft int
+.Fn fchdir "int fd"
+.Sh DESCRIPTION
+The
+.Fa path
+argument points to the pathname of a directory.
+The
+.Fn chdir
+system call
+causes the named directory
+to become the current working directory, that is,
+the starting point for path searches of pathnames not beginning with
+a slash,
+.Ql / .
+.Pp
+The
+.Fn fchdir
+system call
+causes the directory referenced by
+.Fa fd
+to become the current working directory,
+the starting point for path searches of pathnames not beginning with
+a slash,
+.Ql / .
+.Pp
+In order for a directory to become the current directory,
+a process must have execute (search) access to the directory.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn chdir
+system call
+will fail and the current working directory will be unchanged if
+one or more of the following are true:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named directory does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EACCES
+Search permission is denied for any component of
+the path name.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+The
+.Fn fchdir
+system call
+will fail and the current working directory will be unchanged if
+one or more of the following are true:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Search permission is denied for the directory referenced by the
+file descriptor.
+.It Bq Er ENOTDIR
+The file descriptor does not reference a directory.
+.It Bq Er EBADF
+The argument
+.Fa fd
+is not a valid file descriptor.
+.El
+.Sh SEE ALSO
+.Xr chroot 2
+.Sh STANDARDS
+The
+.Fn chdir
+system call is expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn chdir
+system call appeared in
+.At v1 .
+The
+.Fn fchdir
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/chflags.2 b/lib/libsys/chflags.2
new file mode 100644
index 000000000000..ec190df7fb19
--- /dev/null
+++ b/lib/libsys/chflags.2
@@ -0,0 +1,356 @@
+.\" Copyright (c) 1989, 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.
+.\"
+.Dd March 30, 2021
+.Dt CHFLAGS 2
+.Os
+.Sh NAME
+.Nm chflags ,
+.Nm lchflags ,
+.Nm fchflags ,
+.Nm chflagsat
+.Nd set file flags
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.In unistd.h
+.Ft int
+.Fn chflags "const char *path" "unsigned long flags"
+.Ft int
+.Fn lchflags "const char *path" "unsigned long flags"
+.Ft int
+.Fn fchflags "int fd" "unsigned long flags"
+.Ft int
+.Fn chflagsat "int fd" "const char *path" "unsigned long flags" "int atflag"
+.Sh DESCRIPTION
+The file whose name
+is given by
+.Fa path
+or referenced by the descriptor
+.Fa fd
+has its flags changed to
+.Fa flags .
+.Pp
+The
+.Fn lchflags
+system call is like
+.Fn chflags
+except in the case where the named file is a symbolic link,
+in which case
+.Fn lchflags
+will change the flags of the link itself,
+rather than the file it points to.
+.Pp
+The
+.Fn chflagsat
+is equivalent to either
+.Fn chflags
+or
+.Fn lchflags
+depending on the
+.Fa atflag
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the file to be changed is determined relative to the directory
+associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+The values for the
+.Fa atflag
+are constructed by a bitwise-inclusive OR of flags from the following list,
+defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, then the flags of the symbolic link are changed.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa path
+argument is an empty string, operate on the file or directory
+referenced by the descriptor
+.Fa fd .
+If
+.Fa fd
+is equal to
+.Dv AT_FDCWD ,
+operate on the current working directory.
+.El
+.Pp
+If
+.Fn chflagsat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used.
+If also
+.Fa atflag
+is zero, the behavior is identical to a call to
+.Fn chflags .
+.Pp
+The flags specified are formed by
+.Em or Ns 'ing
+the following values
+.Pp
+.Bl -tag -width ".Dv SF_IMMUTABLE" -compact -offset indent
+.It Dv SF_APPEND
+The file may only be appended to.
+.It Dv SF_ARCHIVED
+The file has been archived.
+This flag means the opposite of the DOS, Windows and CIFS
+FILE_ATTRIBUTE_ARCHIVE attribute.
+This flag has been deprecated, and may be removed in a future release.
+.It Dv SF_IMMUTABLE
+The file may not be changed.
+.It Dv SF_NOUNLINK
+The file may not be renamed or deleted.
+.It Dv SF_SNAPSHOT
+The file is a snapshot file.
+.It Dv UF_APPEND
+The file may only be appended to.
+.It Dv UF_ARCHIVE
+The file needs to be archived.
+This flag has the same meaning as the DOS, Windows and CIFS
+FILE_ATTRIBUTE_ARCHIVE attribute.
+Filesystems in FreeBSD may or may not have special handling for this flag.
+For instance, ZFS tracks changes to files and will set this bit when a
+file is updated.
+UFS only stores the flag, and relies on the application to change it when
+needed.
+.It Dv UF_HIDDEN
+The file may be hidden from directory listings at the application's
+discretion.
+The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_HIDDEN attribute.
+.It Dv UF_IMMUTABLE
+The file may not be changed.
+.It Dv UF_NODUMP
+Do not dump the file.
+.It Dv UF_NOUNLINK
+The file may not be renamed or deleted.
+.It Dv UF_OFFLINE
+The file is offline, or has the Windows and CIFS FILE_ATTRIBUTE_OFFLINE
+attribute.
+Filesystems in FreeBSD store and display this flag, but do not provide any
+special handling when it is set.
+.It Dv UF_OPAQUE
+The directory is opaque when viewed through a union stack.
+.It Dv UF_READONLY
+The file is read only, and may not be written or appended.
+Filesystems may use this flag to maintain compatibility with the DOS, Windows
+and CIFS FILE_ATTRIBUTE_READONLY attribute.
+.It Dv UF_REPARSE
+The file contains a Windows reparse point and has the Windows and CIFS
+FILE_ATTRIBUTE_REPARSE_POINT attribute.
+.It Dv UF_SPARSE
+The file has the Windows FILE_ATTRIBUTE_SPARSE_FILE attribute.
+This may also be used by a filesystem to indicate a sparse file.
+.It Dv UF_SYSTEM
+The file has the DOS, Windows and CIFS FILE_ATTRIBUTE_SYSTEM attribute.
+Filesystems in FreeBSD may store and display this flag, but do not provide
+any special handling when it is set.
+.El
+.Pp
+If one of
+.Dv SF_IMMUTABLE , SF_APPEND ,
+or
+.Dv SF_NOUNLINK
+is set a non-super-user cannot change any flags and even the super-user
+can change flags only if securelevel is 0.
+(See
+.Xr init 8
+for details.)
+.Pp
+The
+.Dv UF_IMMUTABLE , UF_APPEND , UF_NOUNLINK , UF_NODUMP ,
+and
+.Dv UF_OPAQUE
+flags may be set or unset by either the owner of a file or the super-user.
+.Pp
+The
+.Dv SF_IMMUTABLE , SF_APPEND , SF_NOUNLINK ,
+and
+.Dv SF_ARCHIVED
+flags may only be set or unset by the super-user.
+Attempts to toggle these flags by non-super-users are rejected.
+These flags may be set at any time, but normally may only be unset when
+the system is in single-user mode.
+(See
+.Xr init 8
+for details.)
+.Pp
+The implementation of all flags is filesystem-dependent.
+See the description of the
+.Dv UF_ARCHIVE
+flag above for one example of the differences in behavior.
+Care should be exercised when writing applications to account for
+support or lack of support of these flags in various filesystems.
+.Pp
+The
+.Dv SF_SNAPSHOT
+flag is maintained by the system and cannot be toggled.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn chflags
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The effective user ID does not match the owner of the file and
+the effective user ID is not the super-user.
+.It Bq Er EPERM
+One of
+.Dv SF_IMMUTABLE , SF_APPEND ,
+or
+.Dv SF_NOUNLINK
+is set and the user is either not the super-user or
+securelevel is greater than 0.
+.It Bq Er EPERM
+A non-super-user attempted to toggle one of
+.Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND ,
+or
+.Dv SF_NOUNLINK .
+.It Bq Er EPERM
+An attempt was made to toggle the
+.Dv SF_SNAPSHOT
+flag.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EOPNOTSUPP
+The underlying file system does not support file flags, or
+does not support all of the flags set in
+.Fa flags .
+.El
+.Pp
+The
+.Fn fchflags
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The descriptor is not valid.
+.It Bq Er EINVAL
+The
+.Fa fd
+argument
+refers to a socket, not to a file.
+.It Bq Er EPERM
+The effective user ID does not match the owner of the file and
+the effective user ID is not the super-user.
+.It Bq Er EPERM
+One of
+.Dv SF_IMMUTABLE , SF_APPEND ,
+or
+.Dv SF_NOUNLINK
+is set and the user is either not the super-user or
+securelevel is greater than 0.
+.It Bq Er EPERM
+A non-super-user attempted to toggle one of
+.Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND ,
+or
+.Dv SF_NOUNLINK .
+.It Bq Er EPERM
+An attempt was made to toggle the
+.Dv SF_SNAPSHOT
+flag.
+.It Bq Er EROFS
+The file resides on a read-only file system.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EOPNOTSUPP
+The underlying file system does not support file flags, or
+does not support all of the flags set in
+.Fa flags .
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Sh SEE ALSO
+.Xr chflags 1 ,
+.Xr fflagstostr 3 ,
+.Xr strtofflags 3 ,
+.Xr init 8 ,
+.Xr mount_unionfs 8
+.Sh HISTORY
+The
+.Fn chflags
+and
+.Fn fchflags
+system calls first appeared in
+.Bx 4.4 .
+The
+.Fn lchflags
+system call first appeared in
+.Fx 5.0 .
+The
+.Fn chflagsat
+system call first appeared in
+.Fx 10.0 .
diff --git a/lib/libsys/chmod.2 b/lib/libsys/chmod.2
new file mode 100644
index 000000000000..2db182a95fcc
--- /dev/null
+++ b/lib/libsys/chmod.2
@@ -0,0 +1,364 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd October 31, 2024
+.Dt CHMOD 2
+.Os
+.Sh NAME
+.Nm chmod ,
+.Nm fchmod ,
+.Nm lchmod ,
+.Nm fchmodat
+.Nd change mode of file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.Ft int
+.Fn chmod "const char *path" "mode_t mode"
+.Ft int
+.Fn fchmod "int fd" "mode_t mode"
+.Ft int
+.Fn lchmod "const char *path" "mode_t mode"
+.Ft int
+.Fn fchmodat "int fd" "const char *path" "mode_t mode" "int flag"
+.Sh DESCRIPTION
+The file permission bits of the file named specified by
+.Fa path
+or referenced by the file descriptor
+.Fa fd
+are changed to
+.Fa mode .
+The
+.Fn chmod
+system call verifies that the process owner (user) either owns
+the file specified by
+.Fa path
+(or
+.Fa fd ) ,
+or
+is the super-user.
+The
+.Fn chmod
+system call follows symbolic links to operate on the target of the link
+rather than the link itself.
+.Pp
+The
+.Fn lchmod
+system call is similar to
+.Fn chmod
+but does not follow symbolic links.
+.Pp
+The
+.Fn fchmodat
+is equivalent to either
+.Fn chmod
+or
+.Fn lchmod
+depending on the
+.Fa flag
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the file to be changed is determined relative to the directory
+associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+The values for the
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from the following list, defined
+in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, then the mode of the symbolic link is changed.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa path
+argument is an empty string, operate on the file or directory
+referenced by the descriptor
+.Fa fd .
+If
+.Fa fd
+is equal to
+.Dv AT_FDCWD ,
+operate on the current working directory.
+.El
+.Pp
+If
+.Fn fchmodat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used.
+If also
+.Fa flag
+is zero, the behavior is identical to a call to
+.Fn chmod .
+.Pp
+A mode is created from
+.Em or'd
+permission bit masks
+defined in
+.In sys/stat.h :
+.Pp
+.Bd -literal -offset indent -compact
+#define S_IRWXU 0000700 /* RWX mask for owner */
+#define S_IRUSR 0000400 /* R for owner */
+#define S_IWUSR 0000200 /* W for owner */
+#define S_IXUSR 0000100 /* X for owner */
+
+#define S_IRWXG 0000070 /* RWX mask for group */
+#define S_IRGRP 0000040 /* R for group */
+#define S_IWGRP 0000020 /* W for group */
+#define S_IXGRP 0000010 /* X for group */
+
+#define S_IRWXO 0000007 /* RWX mask for other */
+#define S_IROTH 0000004 /* R for other */
+#define S_IWOTH 0000002 /* W for other */
+#define S_IXOTH 0000001 /* X for other */
+
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+#define S_ISVTX 0001000 /* sticky bit */
+.Ed
+.Pp
+The non-standard
+.Dv S_ISTXT
+is a synonym for
+.Dv S_ISVTX .
+.Pp
+The
+.Fx
+VM system totally ignores the sticky bit
+.Pq Dv S_ISVTX
+for executables.
+On UFS-based file systems (FFS, LFS) the sticky
+bit may only be set upon directories.
+.Pp
+If mode
+.Dv S_ISVTX
+(the `sticky bit') is set on a directory,
+an unprivileged user may not delete or rename
+files of other users in that directory.
+The sticky bit may be
+set by any user on a directory which the user owns or has appropriate
+permissions.
+For more details of the properties of the sticky bit, see
+.Xr sticky 7 .
+.Pp
+If mode ISUID (set UID) is set on a directory,
+and the MNT_SUIDDIR option was used in the mount of the file system,
+then the owner of any new files and sub-directories
+created within this directory are set
+to be the same as the owner of that directory.
+If this function is enabled, new directories will inherit
+the bit from their parents.
+Execute bits are removed from
+the file, and it will not be given to root.
+This behavior does not change the
+requirements for the user to be allowed to write the file, but only the eventual
+owner after it has been created.
+Group inheritance is not affected.
+.Pp
+This feature is designed for use on fileservers serving PC users via
+ftp, SAMBA, or netatalk.
+It provides security holes for shell users and as
+such should not be used on shell machines, especially on home directories.
+This option requires the SUIDDIR
+option in the kernel to work.
+Only UFS file systems support this option.
+For more details of the suiddir mount option, see
+.Xr mount 8 .
+.Pp
+Writing or changing the owner of a file
+turns off the set-user-id and set-group-id bits
+unless the user is the super-user.
+This makes the system somewhat more secure
+by protecting set-user-id (set-group-id) files
+from remaining set-user-id (set-group-id) if they are modified,
+at the expense of a degree of compatibility.
+.Pp
+While it is normally an error to invoke
+.Fn fchmod
+on a socket, it is possible to do so on
+.Dv AF_LOCAL
+sockets before they are bound to a file name; see
+.Xr unix 4 .
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn chmod
+system call
+will fail and the file mode will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The effective user ID does not match the owner of the file and
+the effective user ID is not the super-user.
+.It Bq Er EPERM
+The effective user ID is not the super-user, the effective user ID do match the
+owner of the file, but the group ID of the file does not match the effective
+group ID nor one of the supplementary group IDs.
+.It Bq Er EPERM
+The named file has its immutable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFTYPE
+The effective user ID is not the super-user, the mode includes the sticky bit
+.Dv ( S_ISVTX ) ,
+and path does not refer to a directory.
+.El
+.Pp
+The
+.Fn fchmod
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The descriptor is not valid.
+.It Bq Er EINVAL
+The
+.Fa fd
+argument
+refers to a socket, not to a file.
+.It Bq Er EROFS
+The file resides on a read-only file system.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+In addition to the
+.Fn chmod
+errors,
+.Fn fchmodat
+fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Fa AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Sh SEE ALSO
+.Xr chmod 1 ,
+.Xr chflags 2 ,
+.Xr chown 2 ,
+.Xr open 2 ,
+.Xr stat 2 ,
+.Xr sticky 7
+.Sh STANDARDS
+The
+.Fn chmod
+system call is expected to conform to
+.St -p1003.1-90 ,
+except for the return of
+.Er EFTYPE .
+The
+.Dv S_ISVTX
+bit on directories is expected to conform to
+.St -susv3 .
+The
+.Fn fchmodat
+system call is expected to conform to
+.St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Fn chmod
+function appeared in
+.At v1 .
+The
+.Fn fchmod
+system call appeared in
+.Bx 4.2 .
+The
+.Fn lchmod
+system call appeared in
+.Fx 3.0 .
+The
+.Fn fchmodat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/chown.2 b/lib/libsys/chown.2
new file mode 100644
index 000000000000..2e5ab7750d72
--- /dev/null
+++ b/lib/libsys/chown.2
@@ -0,0 +1,298 @@
+.\" Copyright (c) 1980, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd March 30, 2021
+.Dt CHOWN 2
+.Os
+.Sh NAME
+.Nm chown ,
+.Nm fchown ,
+.Nm lchown ,
+.Nm fchownat
+.Nd change owner and group of a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn chown "const char *path" "uid_t owner" "gid_t group"
+.Ft int
+.Fn fchown "int fd" "uid_t owner" "gid_t group"
+.Ft int
+.Fn lchown "const char *path" "uid_t owner" "gid_t group"
+.Ft int
+.Fn fchownat "int fd" "const char *path" "uid_t owner" "gid_t group" "int flag"
+.Sh DESCRIPTION
+The owner ID and group ID of the file
+named by
+.Fa path
+or referenced by
+.Fa fd
+is changed as specified by the arguments
+.Fa owner
+and
+.Fa group .
+The owner of a file may change the
+.Fa group
+to a group of which
+he or she is a member,
+but the change
+.Fa owner
+capability is restricted to the super-user.
+.Pp
+The
+.Fn chown
+system call
+clears the set-user-id and set-group-id bits
+on the file
+to prevent accidental or mischievous creation of
+set-user-id and set-group-id programs if not executed
+by the super-user.
+The
+.Fn chown
+system call
+follows symbolic links to operate on the target of the link
+rather than the link itself.
+.Pp
+The
+.Fn fchown
+system call
+is particularly useful when used in conjunction
+with the file locking primitives (see
+.Xr flock 2 ) .
+.Pp
+The
+.Fn lchown
+system call is similar to
+.Fn chown
+but does not follow symbolic links.
+.Pp
+The
+.Fn fchownat
+system call is equivalent to the
+.Fn chown
+and
+.Fn lchown
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the file to be changed is determined relative to the directory
+associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+.Pp
+Values for
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from the following
+list, defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, ownership of the symbolic link is changed.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa path
+argument is an empty string, operate on the file or directory
+referenced by the descriptor
+.Fa fd .
+If
+.Fa fd
+is equal to
+.Dv AT_FDCWD ,
+operate on the current working directory.
+.El
+.Pp
+If
+.Fn fchownat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is identical
+to a call to
+.Fn chown
+or
+.Fn lchown
+respectively, depending on whether or not the
+.Dv AT_SYMLINK_NOFOLLOW
+bit is set in the
+.Fa flag
+argument.
+.Pp
+One of the owner or group id's
+may be left unchanged by specifying it as -1.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn chown
+and
+.Fn lchown
+will fail and the file will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The operation would change the ownership, but the effective user ID is not the
+super-user.
+.It Bq Er EPERM
+The named file has its immutable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+The
+.Fn fchown
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+does not refer to a valid descriptor.
+.It Bq Er EINVAL
+The
+.Fa fd
+argument
+refers to a socket, not a file.
+.It Bq Er EPERM
+The effective user ID is not the super-user.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+In addition to the errors specified for
+.Fn chown
+and
+.Fn lchown ,
+the
+.Fn fchownat
+system call may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Sh SEE ALSO
+.Xr chgrp 1 ,
+.Xr chflags 2 ,
+.Xr chmod 2 ,
+.Xr flock 2 ,
+.Xr chown 8
+.Sh STANDARDS
+The
+.Fn chown
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn fchownat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn chown
+function appeared in
+.At v1 .
+The
+.Fn fchown
+system call appeared in
+.Bx 4.2 .
+.Pp
+The
+.Fn chown
+system call was changed to follow symbolic links in
+.Bx 4.4 .
+The
+.Fn lchown
+system call was added in
+.Fx 3.0
+to compensate for the loss of functionality.
+.Pp
+The
+.Fn fchownat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/chroot.2 b/lib/libsys/chroot.2
new file mode 100644
index 000000000000..3347df5cceee
--- /dev/null
+++ b/lib/libsys/chroot.2
@@ -0,0 +1,215 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd August 2, 2025
+.Dt CHROOT 2
+.Os
+.Sh NAME
+.Nm chroot ,
+.Nm fchroot
+.Nd change root directory
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn chroot "const char *dirname"
+.Ft int
+.Fn fchroot "int fd"
+.Sh DESCRIPTION
+The
+.Fa dirname
+argument
+is the address of the pathname of a directory, terminated by an ASCII NUL.
+The
+.Fn chroot
+system call causes
+.Fa dirname
+to become the root directory,
+that is, the starting point for path searches of pathnames
+beginning with
+.Ql / .
+.Pp
+In order for a directory to become the root directory
+a process must have execute (search) access for that directory.
+.Pp
+It should be noted that
+.Fn chroot
+has no effect on the process's current directory.
+.Pp
+This call is restricted to the super-user, unless the
+.Ql security.bsd.unprivileged_chroot
+sysctl variable is set to 1
+and the process has enabled the
+.Dv PROC_NO_NEW_PRIVS_CTL
+.Xr procctl 2 .
+.Pp
+Depending on the setting of the
+.Ql kern.chroot_allow_open_directories
+sysctl variable, open filedescriptors which reference directories
+will make the
+.Fn chroot
+fail as follows:
+.Pp
+If
+.Ql kern.chroot_allow_open_directories
+is set to zero,
+.Fn chroot
+will always fail with
+.Er EPERM
+if there are any directories open.
+.Pp
+If
+.Ql kern.chroot_allow_open_directories
+is set to one (the default),
+.Fn chroot
+will fail with
+.Er EPERM
+if there are any directories open and the
+process is already subject to the
+.Fn chroot
+system call.
+.Pp
+Any other value for
+.Ql kern.chroot_allow_open_directories
+will bypass the check for open directories,
+mimicking the historic insecure behavior of
+.Fn chroot
+still present on other systems.
+.Pp
+The
+.Fn fchroot
+system call is identical to
+.Fn chroot
+except it takes a file descriptor instead of path.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn chroot
+and
+.Fn fchroot
+system calls
+will fail and the root directory will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The effective user ID is not the super-user and the
+.Ql security.bsd.unprivileged_chroot
+sysctl is 0.
+.It Bq Er EPERM
+The effective user ID is not the super-user and the
+process has not enabled the
+.Dv PROC_NO_NEW_PRIVS_CTL
+.Xr procctl 2 .
+.It Bq Er EPERM
+One or more filedescriptors are open directories and the
+.Ql kern.chroot_allow_open_directories
+sysctl is not set to permit this.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+The
+.Fn chroot
+system call
+will fail and the root directory will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path name is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named directory does not exist.
+.It Bq Er EACCES
+Search permission is denied for any component of the path name.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EFAULT
+The
+.Fa dirname
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+The
+.Fn fchroot
+system call
+will fail and the root directory will be unchanged if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Search permission is denied for the directory referenced by the
+file descriptor.
+.It Bq Er EBADF
+The argument
+.Fa fd
+is not a valid file descriptor.
+.It Bq Er ENOTDIR
+The file descriptor does not reference a directory.
+.El
+.Sh SEE ALSO
+.Xr chdir 2 ,
+.Xr jail 2
+.Sh HISTORY
+The
+.Fn chroot
+system call appeared in
+.At v7 .
+It was marked as
+.Dq legacy
+in
+.St -susv2 ,
+and was removed in subsequent standards.
+The
+.Fn fchroot
+system call first appeared in
+.Fx 15.0 .
+.Sh BUGS
+If the process is able to change its working directory to the target
+directory, but another access control check fails (such as a check for
+open directories, or a MAC check), it is possible that this system
+call may return an error, with the working directory of the process
+left changed.
+.Sh SECURITY CONSIDERATIONS
+The system has many hardcoded paths to files which it may load after
+the process starts.
+It is generally recommended to drop privileges immediately after a
+successful
+.Nm
+call,
+and restrict write access to a limited subtree of the
+.Nm
+root.
+For instance,
+setup the sandbox so that the sandboxed user will have no write
+access to any well-known system directories.
+.Pp
+For complete isolation from the rest of the system, use
+.Xr jail 2
+instead.
diff --git a/lib/libsys/clock_gettime.2 b/lib/libsys/clock_gettime.2
new file mode 100644
index 000000000000..89551d0f720b
--- /dev/null
+++ b/lib/libsys/clock_gettime.2
@@ -0,0 +1,241 @@
+.\" $OpenBSD: clock_gettime.2,v 1.4 1997/05/08 20:21:16 kstailey Exp $
+.\"
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd August 10, 2024
+.Dt CLOCK_GETTIME 2
+.Os
+.Sh NAME
+.Nm clock_gettime ,
+.Nm clock_settime ,
+.Nm clock_getres
+.Nd get/set/calibrate date and time
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In time.h
+.Ft int
+.Fn clock_gettime "clockid_t clock_id" "struct timespec *tp"
+.Ft int
+.Fn clock_settime "clockid_t clock_id" "const struct timespec *tp"
+.Ft int
+.Fn clock_getres "clockid_t clock_id" "struct timespec *tp"
+.Sh DESCRIPTION
+The
+.Fn clock_gettime
+and
+.Fn clock_settime
+system calls allow the calling process to retrieve or set the value
+used by a clock which is specified by
+.Fa clock_id .
+.Pp
+The
+.Fa clock_id
+argument can be a value obtained from
+.Xr clock_getcpuclockid 3
+or
+.Xr pthread_getcpuclockid 3
+as well as the following values:
+.Pp
+.Bl -tag -width indent -compact
+.It Dv CLOCK_REALTIME
+.It Dv CLOCK_REALTIME_PRECISE
+.It Dv CLOCK_REALTIME_FAST
+.It Dv CLOCK_REALTIME_COARSE
+Increments in SI seconds like a wall clock.
+It uses a 1970 epoch and implements the UTC timescale.
+The count of physical SI seconds since 1970, adjusted by subtracting the number
+of positive leap seconds and adding the number of negative leap seconds.
+Behavior during a leap second is not defined by and POSIX standard.
+.It Dv CLOCK_MONOTONIC
+.It Dv CLOCK_MONOTONIC_PRECISE
+.It Dv CLOCK_MONOTONIC_FAST
+.It Dv CLOCK_MONOTONIC_COARSE
+.It Dv CLOCK_BOOTTIME
+Increments in SI seconds, even while the system is suspended.
+Its epoch is unspecified.
+The count is not adjusted by leap seconds.
+.Fx implements
+.It Dv CLOCK_UPTIME
+.It Dv CLOCK_UPTIME_PRECISE
+.It Dv CLOCK_UPTIME_FAST
+Increments monotonically in SI seconds while the machine is running.
+The count is not adjusted by leap seconds.
+The epoch is unspecified.
+.It Dv CLOCK_VIRTUAL
+Increments only when
+the CPU is running in user mode on behalf of the calling process.
+.It Dv CLOCK_PROF
+Increments when the CPU is running in user or kernel mode.
+.It Dv CLOCK_SECOND
+Returns the current second without performing a full time counter
+query, using an in-kernel cached value of the current second.
+.It Dv CLOCK_PROCESS_CPUTIME_ID
+Returns the execution time of the calling process.
+.It Dv CLOCK_THREAD_CPUTIME_ID
+Returns the execution time of the calling thread.
+.It Dv CLOCK_TAI
+Increments in SI seconds like a wall clock.
+It uses a 1970 epoch and implements the TAI timescale.
+Similar to
+.Dv CLOCK_REALTIME ,
+but without leap seconds.
+It will increase monotonically during a leap second.
+Will return
+.Er EINVAL
+if the current offset between TAI and UTC is not known,
+which may be the case early in boot before NTP or other time daemon has
+synchronized.
+.El
+.Pp
+The clock IDs
+.Dv CLOCK_BOOTTIME ,
+.Dv CLOCK_REALTIME ,
+.Dv CLOCK_TAI ,
+.Dv CLOCK_MONOTONIC ,
+and
+.Dv CLOCK_UPTIME
+perform a full time counter query.
+The clock IDs with the _FAST suffix, i.e.,
+.Dv CLOCK_REALTIME_FAST ,
+.Dv CLOCK_MONOTONIC_FAST ,
+and
+.Dv CLOCK_UPTIME_FAST ,
+do not perform
+a full time counter query, so their accuracy is one timer tick.
+Similarly,
+.Dv CLOCK_REALTIME_PRECISE ,
+.Dv CLOCK_MONOTONIC_PRECISE ,
+and
+.Dv CLOCK_UPTIME_PRECISE
+are used to get the most exact value as possible, at the expense of
+execution time.
+The clock IDs
+.Dv CLOCK_REALTIME_COARSE
+and
+.Dv CLOCK_MONOTONIC_COARSE
+are aliases of corresponding IDs with _FAST suffix for compatibility with other
+systems.
+Finally,
+.Dv CLOCK_BOOTTIME
+is an alias for
+.Dv CLOCK_MONOTONIC
+for compatibility with other systems and is unrelated to the
+.Fa kern.boottime
+.Xr sysctl 8 .
+.Pp
+The structure pointed to by
+.Fa tp
+is defined in
+.In sys/timespec.h
+as:
+.Bd -literal
+struct timespec {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* and nanoseconds */
+};
+.Ed
+.Pp
+Only the super-user may set the time of day, using only
+.Dv CLOCK_REALTIME .
+If the system
+.Xr securelevel 7
+is greater than 1 (see
+.Xr init 8 ) ,
+the time may only be advanced.
+This limitation is imposed to prevent a malicious super-user
+from setting arbitrary time stamps on files.
+The system time can still be adjusted backwards using the
+.Xr adjtime 2
+system call even when the system is secure.
+.Pp
+The resolution (granularity) of a clock is returned by the
+.Fn clock_getres
+system call.
+This value is placed in a (non-NULL)
+.Fa *tp .
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The following error codes may be set in
+.Va errno :
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa clock_id
+or
+.Fa timespec
+argument
+was not a valid value.
+.It Bq Er EPERM
+A user other than the super-user attempted to set the time.
+.El
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr adjtime 2 ,
+.Xr clock_getcpuclockid 3 ,
+.Xr ctime 3 ,
+.Xr pthread_getcpuclockid 3
+.Sh STANDARDS
+The
+.Fn clock_gettime ,
+.Fn clock_settime ,
+and
+.Fn clock_getres
+system calls conform to
+.St -p1003.1-2008 .
+The clock IDs
+.Dv CLOCK_BOOTTIME ,
+.Dv CLOCK_MONOTONIC_FAST ,
+.Dv CLOCK_MONOTONIC_PRECISE ,
+.Dv CLOCK_REALTIME_FAST ,
+.Dv CLOCK_REALTIME_PRECISE ,
+.Dv CLOCK_SECOND ,
+.Dv CLOCK_TAI ,
+.Dv CLOCK_UPTIME ,
+.Dv CLOCK_UPTIME_FAST ,
+and
+.Dv CLOCK_UPTIME_PRECISE
+are
+.Fx
+extensions to the POSIX interface.
+.Pp
+UTC is defined by ITU-R TF.460-6, Standard-frequency and time-signal emissions.
+However, the
+.Vt time_t
+type is a simple count that does not provide a unique encoding for leap seconds,
+nor a specification for what values should be used to encode a leap second.
+.Pp
+.Sh HISTORY
+The
+.Fn clock_gettime ,
+.Fn clock_settime ,
+and
+.Fn clock_getres
+system calls first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/clock_gettime.c b/lib/libsys/clock_gettime.c
new file mode 100644
index 000000000000..069e70beaa1b
--- /dev/null
+++ b/lib/libsys/clock_gettime.c
@@ -0,0 +1,55 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.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.
+ *
+ * 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.
+ */
+
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include <time.h>
+#include "libc_private.h"
+
+int __clock_gettime(clockid_t, struct timespec *ts);
+
+__weak_reference(__clock_gettime, clock_gettime);
+
+int
+__clock_gettime(clockid_t clock_id, struct timespec *ts)
+{
+ int error;
+
+ if (__vdso_clock_gettime != NULL && __vdso_gettc != NULL)
+ error = __vdso_clock_gettime(clock_id, ts);
+ else
+ error = ENOSYS;
+ if (error == ENOSYS) {
+ error = __sys_clock_gettime(clock_id, ts);
+ } else if (error != 0) {
+ errno = error;
+ error = -1;
+ }
+ return (error);
+}
diff --git a/lib/libsys/close.2 b/lib/libsys/close.2
new file mode 100644
index 000000000000..91a7a902d70d
--- /dev/null
+++ b/lib/libsys/close.2
@@ -0,0 +1,138 @@
+.\" Copyright (c) 1980, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd December 18, 2024
+.Dt CLOSE 2
+.Os
+.Sh NAME
+.Nm close
+.Nd delete a descriptor
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn close "int fd"
+.Sh DESCRIPTION
+The
+.Fn close
+system call deletes a descriptor from the per-process object
+reference table.
+If this is the last reference to the underlying object, the
+object will be deactivated.
+For example, on the last close of a file
+the current
+.Em seek
+pointer associated with the file is lost;
+on the last close of a
+.Xr socket 2
+associated naming information and queued data are discarded;
+on the last close of a file holding an advisory lock
+the lock is released (see further
+.Xr flock 2 ) .
+However, the semantics of System V and
+.St -p1003.1-88
+dictate that all
+.Xr fcntl 2
+advisory record locks associated with a file for a given process
+are removed when
+.Em any
+file descriptor for that file is closed by that process.
+.Pp
+When a process exits,
+all associated file descriptors are freed, but since there is
+a limit on active descriptors per processes, the
+.Fn close
+system call
+is useful when a large quantity of file descriptors are being handled.
+.Pp
+When a process forks (see
+.Xr fork 2 ) ,
+all descriptors for the new child process reference the same
+objects as they did in the parent before the fork.
+If a new process is then to be run using
+.Xr execve 2 ,
+the process would normally inherit these descriptors.
+Most
+of the descriptors can be rearranged with
+.Xr dup2 2
+or deleted with
+.Fn close
+before the
+.Xr execve 2
+is attempted, but if some of these descriptors will still
+be needed if the execve fails, it is necessary to arrange for them
+to be closed if the execve succeeds.
+For this reason, the call
+.Dq Li fcntl(d, F_SETFD, FD_CLOEXEC)
+is provided,
+which arranges that a descriptor will be closed after a successful
+execve; the call
+.Dq Li fcntl(d, F_SETFD, 0)
+restores the default,
+which is to not close the descriptor.
+.Sh RETURN VALUES
+.Rv -std close
+.Sh ERRORS
+The
+.Fn close
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not an active descriptor.
+.It Bq Er EINTR
+An interrupt was received.
+.It Bq Er ENOSPC
+The underlying object did not fit, cached data was lost.
+.El
+.Pp
+In case of any error except
+.Er EBADF ,
+the supplied file descriptor is deallocated and therefore is no longer valid.
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr closefrom 2 ,
+.Xr execve 2 ,
+.Xr fcntl 2 ,
+.Xr flock 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2
+.Sh STANDARDS
+The
+.Fn close
+system call is expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn close
+function appeared in
+.At v1 .
diff --git a/lib/libsys/closefrom.2 b/lib/libsys/closefrom.2
new file mode 100644
index 000000000000..1885a6fdeaa8
--- /dev/null
+++ b/lib/libsys/closefrom.2
@@ -0,0 +1,99 @@
+.\" Copyright (c) 2009 Hudson River Trading LLC
+.\" Written by: John H. Baldwin <jhb@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.
+.\"
+.Dd May 17, 2025
+.Dt CLOSEFROM 2
+.Os
+.Sh NAME
+.Nm closefrom ,
+.Nm close_range
+.Nd delete open file descriptors
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft void
+.Fn closefrom "int lowfd"
+.Ft int
+.Fn close_range "u_int lowfd" "u_int highfd" "int flags"
+.Sh DESCRIPTION
+The
+.Fn closefrom
+system call deletes all open file descriptors greater than or equal to
+.Fa lowfd
+from the per-process object reference table.
+Any errors encountered while closing file descriptors are ignored.
+.Pp
+The
+.Fn close_range
+system call deletes all open file descriptors between
+.Fa lowfd
+and
+.Fa highfd
+inclusive, clamped to the range of open file descriptors.
+Any errors encountered while closing file descriptors are ignored.
+Supported
+.Fa flags :
+.Bl -tag -width ".Dv CLOSE_RANGE_CLOEXEC"
+.It Dv CLOSE_RANGE_CLOEXEC
+Set the close-on-exec flag on descriptors in the range instead of closing them.
+.It Dv CLOSE_RANGE_CLOFORK
+Set the close-on-fork flag on descriptors in the range instead of closing them.
+.El
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn close_range
+returns a value
+of 0.
+Otherwise, a value of -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn close_range
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa highfd
+argument is lower than the
+.Fa lowfd
+argument.
+.It Bq Er EINVAL
+An invalid flag was set.
+.El
+.Sh SEE ALSO
+.Xr close 2
+.Sh HISTORY
+The
+.Fn closefrom
+function first appeared in
+.Fx 8.0 .
+.Pp
+The
+.Dv CLOSE_RANGE_CLOFORK
+flag appeared in
+.Fx 15.0 .
diff --git a/lib/libsys/connect.2 b/lib/libsys/connect.2
new file mode 100644
index 000000000000..ac36cf8b15b3
--- /dev/null
+++ b/lib/libsys/connect.2
@@ -0,0 +1,182 @@
+.\" Copyright (c) 1983, 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.
+.\"
+.Dd August 18, 2016
+.Dt CONNECT 2
+.Os
+.Sh NAME
+.Nm connect
+.Nd initiate a connection on a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft int
+.Fn connect "int s" "const struct sockaddr *name" "socklen_t namelen"
+.Sh DESCRIPTION
+The
+.Fa s
+argument
+is a socket.
+If it is of type
+.Dv SOCK_DGRAM ,
+this call specifies the peer with which the socket is to be associated;
+this address is that to which datagrams are to be sent,
+and the only address from which datagrams are to be received.
+If the socket is of type
+.Dv SOCK_STREAM ,
+this call attempts to make a connection to
+another socket.
+The other socket is specified by
+.Fa name ,
+which is an address in the communications space of the socket.
+.Fa namelen
+indicates the amount of space pointed to by
+.Fa name ,
+in bytes; the
+.Fa sa_len
+member of
+.Fa name
+is ignored.
+Each communications space interprets the
+.Fa name
+argument in its own way.
+Generally, stream sockets may successfully
+.Fn connect
+only once; datagram sockets may use
+.Fn connect
+multiple times to change their association.
+Datagram sockets may dissolve the association
+by connecting to an invalid address, such as a null address.
+.Sh RETURN VALUES
+.Rv -std connect
+.Sh ERRORS
+The
+.Fn connect
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa s
+argument
+is not a valid descriptor.
+.It Bq Er EINVAL
+The
+.Fa namelen
+argument is not a valid length for the address family.
+.It Bq Er ENOTSOCK
+The
+.Fa s
+argument
+is a descriptor for a file, not a socket.
+.It Bq Er EADDRNOTAVAIL
+The specified address is not available on this machine.
+.It Bq Er EAFNOSUPPORT
+Addresses in the specified address family cannot be used with this socket.
+.It Bq Er EISCONN
+The socket is already connected.
+.It Bq Er ETIMEDOUT
+Connection establishment timed out without establishing a connection.
+.It Bq Er ECONNREFUSED
+The attempt to connect was forcefully rejected.
+.It Bq Er ECONNRESET
+The connection was reset by the remote host.
+.It Bq Er ENETUNREACH
+The network is not reachable from this host.
+.It Bq Er EHOSTUNREACH
+The remote host is not reachable from this host.
+.It Bq Er EADDRINUSE
+The address is already in use.
+.It Bq Er EFAULT
+The
+.Fa name
+argument specifies an area outside
+the process address space.
+.It Bq Er EINPROGRESS
+The socket is non-blocking
+and the connection cannot
+be completed immediately.
+It is possible to
+.Xr select 2
+for completion by selecting the socket for writing.
+.It Bq Er EINTR
+The connection attempt was interrupted by the delivery of a signal.
+The connection will be established in the background,
+as in the case of
+.Er EINPROGRESS .
+.It Bq Er EALREADY
+A previous connection attempt has not yet been completed.
+.It Bq Er EACCES
+An attempt is made to connect to a broadcast address (obtained through the
+.Dv INADDR_BROADCAST
+constant or the
+.Dv INADDR_NONE
+return value) through a socket that does not provide broadcast functionality.
+.It Bq Er EAGAIN
+An auto-assigned port number was requested but no auto-assigned ports
+are available.
+Increasing the port range specified by
+.Xr sysctl 3
+MIB variables
+.Va net.inet.ip.portrange.first
+and
+.Va net.inet.ip.portrange.last
+may alleviate the problem.
+.El
+.Pp
+The following errors are specific to connecting names in the UNIX domain.
+These errors may not apply in future versions of the UNIX IPC domain.
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named socket does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+Write access to the named socket is denied.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+Write access to the named socket is denied.
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr getpeername 2 ,
+.Xr getsockname 2 ,
+.Xr select 2 ,
+.Xr socket 2 ,
+.Xr sysctl 3 ,
+.Xr sysctl 8
+.Sh HISTORY
+The
+.Fn connect
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libc/sys/connectat.2 b/lib/libsys/connectat.2
index 64fd805549b7..64fd805549b7 100644
--- a/lib/libc/sys/connectat.2
+++ b/lib/libsys/connectat.2
diff --git a/lib/libsys/copy_file_range.2 b/lib/libsys/copy_file_range.2
new file mode 100644
index 000000000000..bcd9170842d5
--- /dev/null
+++ b/lib/libsys/copy_file_range.2
@@ -0,0 +1,218 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2019 Rick Macklem
+.\"
+.\" 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.
+.\"
+.Dd December 28, 2023
+.Dt COPY_FILE_RANGE 2
+.Os
+.Sh NAME
+.Nm copy_file_range
+.Nd kernel copy of a byte range from one regular file to another
+or within one regular file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In unistd.h
+.Ft ssize_t
+.Fo copy_file_range
+.Fa "int infd"
+.Fa "off_t *inoffp"
+.Fa "int outfd"
+.Fa "off_t *outoffp"
+.Fa "size_t len"
+.Fa "unsigned int flags"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn copy_file_range
+system call
+copies up to
+.Fa len
+bytes from
+.Fa infd
+to
+.Fa outfd
+in the kernel.
+It may do this using a file system specific technique if
+.Fa infd
+and
+.Fa outfd
+are on the same file system.
+If
+.Fa infd
+and
+.Fa outfd
+refer to the same file, the byte ranges defined by
+the input file offset, output file offset and
+.Fa len
+cannot overlap.
+The
+.Fa infd
+argument must be opened for reading and the
+.Fa outfd
+argument must be opened for writing, but not
+.Dv O_APPEND .
+If
+.Fa inoffp
+or
+.Fa outoffp
+is
+.Dv NULL ,
+the file offset for
+.Fa infd
+or
+.Fa outfd
+respectively will be used and updated by
+the number of bytes copied.
+If
+.Fa inoffp
+or
+.Fa outoffp
+is not
+.Dv NULL ,
+the byte offset pointed to by
+.Fa inoffp
+or
+.Fa outoffp
+respectively will be used/updated and the file offset for
+.Fa infd
+or
+.Fa outfd
+respectively will not be affected.
+The
+.Fa flags
+argument must be 0.
+.Pp
+This system call attempts to maintain holes in the output file for
+the byte range being copied.
+However, this does not always work well.
+It is recommended that sparse files be copied in a loop using
+.Xr lseek 2
+with
+.Dv SEEK_HOLE ,
+.Dv SEEK_DATA
+arguments and this system call for the
+data ranges found.
+.Pp
+For best performance, call
+.Fn copy_file_range
+with the largest
+.Fa len
+value possible.
+It is interruptible on most file systems,
+so there is no penalty for using very large len values, even SSIZE_MAX.
+.Pp
+.Sh RETURN VALUES
+If it succeeds, the call returns the number of bytes copied, which can be fewer
+than
+.Fa len .
+Returning fewer bytes than
+.Fa len
+does not necessarily indicate that EOF was reached.
+However, a return of zero for a non-zero
+.Fa len
+argument indicates that the offset for
+.Fa infd
+is at or beyond EOF.
+.Fn copy_file_range
+should be used in a loop until copying of the desired byte range has been
+completed.
+If an error has occurred, a \-1 is returned and the error code is placed in
+the global variable
+.Va errno .
+.Sh ERRORS
+The
+.Fn copy_file_range
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+If
+.Fa infd
+is not open for reading or
+.Fa outfd
+is not open for writing, or opened for writing with
+.Dv O_APPEND ,
+or if
+.Fa infd
+and
+.Fa outfd
+refer to the same file.
+.It Bq Er EFBIG
+If the copy exceeds the process's file size limit or the maximum file size
+for the file system
+.Fa outfd
+resides on.
+.It Bq Er EINTR
+A signal interrupted the system call
+before it could be completed.
+This may happen for files on some NFS mounts.
+When this happens, the values pointed to by
+.Fa inoffp
+and
+.Fa outoffp
+are reset to the initial values for the system call.
+.It Bq Er EINVAL
+.Fa infd
+and
+.Fa outfd
+refer to the same file and the byte ranges overlap.
+.It Bq Er EINVAL
+The
+.Fa flags
+argument is not zero.
+.It Bq Er EINVAL
+Either
+.Fa infd
+or
+.Fa outfd
+refers to a file object that is not a regular file.
+.It Bq Er EIO
+An I/O error occurred while reading/writing the files.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from a file system.
+.It Bq Er EISDIR
+If either
+.Fa infd
+or
+.Fa outfd
+refers to a directory.
+.It Bq Er ENOSPC
+File system that stores
+.Fa outfd
+is full.
+.El
+.Sh SEE ALSO
+.Xr lseek 2
+.Sh STANDARDS
+The
+.Fn copy_file_range
+system call is expected to be compatible with the Linux system call of
+the same name.
+.Sh HISTORY
+The
+.Fn copy_file_range
+function appeared in
+.Fx 13.0 .
diff --git a/lib/libc/sys/cpuset.2 b/lib/libsys/cpuset.2
index 3d47f1b4fdfb..3d47f1b4fdfb 100644
--- a/lib/libc/sys/cpuset.2
+++ b/lib/libsys/cpuset.2
diff --git a/lib/libc/sys/cpuset_getaffinity.2 b/lib/libsys/cpuset_getaffinity.2
index 850ec2a28e03..850ec2a28e03 100644
--- a/lib/libc/sys/cpuset_getaffinity.2
+++ b/lib/libsys/cpuset_getaffinity.2
diff --git a/lib/libc/sys/cpuset_getdomain.2 b/lib/libsys/cpuset_getdomain.2
index e082dc98939d..e082dc98939d 100644
--- a/lib/libc/sys/cpuset_getdomain.2
+++ b/lib/libsys/cpuset_getdomain.2
diff --git a/lib/libsys/creat.2 b/lib/libsys/creat.2
new file mode 100644
index 000000000000..c15c68e445c0
--- /dev/null
+++ b/lib/libsys/creat.2
@@ -0,0 +1,59 @@
+.\" Copyright (c) 1989, 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.
+.\"
+.Dd September 4, 2019
+.Dt CREAT 2
+.Os
+.Sh NAME
+.Nm creat
+.Nd create a new file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.Ft int
+.Fn creat "const char *path" "mode_t mode"
+.Sh DESCRIPTION
+.Bf -symbolic
+This interface is made obsolete by:
+.Ef
+.Xr open 2 .
+.Pp
+The
+.Fn creat
+function
+is the same as:
+.Bd -literal -offset indent
+open(path, O_CREAT | O_TRUNC | O_WRONLY, mode);
+.Ed
+.Sh SEE ALSO
+.Xr open 2
+.Sh HISTORY
+The
+.Fn creat
+function appeared in
+.At v1 .
diff --git a/lib/libsys/dup.2 b/lib/libsys/dup.2
new file mode 100644
index 000000000000..524fd7688670
--- /dev/null
+++ b/lib/libsys/dup.2
@@ -0,0 +1,168 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd December 1, 2017
+.Dt DUP 2
+.Os
+.Sh NAME
+.Nm dup ,
+.Nm dup2
+.Nd duplicate an existing file descriptor
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn dup "int oldd"
+.Ft int
+.Fn dup2 "int oldd" "int newd"
+.Sh DESCRIPTION
+The
+.Fn dup
+system call
+duplicates an existing object descriptor and returns its value to
+the calling process
+.Fa ( newd
+=
+.Fn dup oldd ) .
+The argument
+.Fa oldd
+is a small non-negative integer index in
+the per-process descriptor table.
+The new descriptor returned by the call
+is the lowest numbered descriptor
+currently not in use by the process.
+.Pp
+The object referenced by the descriptor does not distinguish
+between
+.Fa oldd
+and
+.Fa newd
+in any way.
+Thus if
+.Fa newd
+and
+.Fa oldd
+are duplicate references to an open
+file,
+.Xr read 2 ,
+.Xr write 2
+and
+.Xr lseek 2
+calls all move a single pointer into the file,
+and append mode, non-blocking I/O and asynchronous I/O options
+are shared between the references.
+If a separate pointer into the file is desired, a different
+object reference to the file must be obtained by issuing an
+additional
+.Xr open 2
+system call.
+The close-on-exec flag on the new file descriptor is unset.
+.Pp
+In
+.Fn dup2 ,
+the value of the new descriptor
+.Fa newd
+is specified.
+If this descriptor is already in use and
+.Fa oldd
+\*(Ne
+.Fa newd ,
+the descriptor is first deallocated as if the
+.Xr close 2
+system call had been used.
+If
+.Fa oldd
+is not a valid descriptor, then
+.Fa newd
+is not closed.
+If
+.Fa oldd
+==
+.Fa newd
+and
+.Fa oldd
+is a valid descriptor, then
+.Fn dup2
+is successful, and does nothing.
+.Sh RETURN VALUES
+These calls return the new file descriptor if successful;
+otherwise the value -1 is returned and
+the external variable
+.Va errno
+is set to indicate the cause of the error.
+.Sh ERRORS
+The
+.Fn dup
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa oldd
+argument
+is not a valid active descriptor
+.It Bq Er EMFILE
+Too many descriptors are active.
+.El
+.Pp
+The
+.Fn dup2
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa oldd
+argument is not a valid active descriptor or the
+.Fa newd
+argument is negative or exceeds the maximum allowable descriptor number
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr close 2 ,
+.Xr fcntl 2 ,
+.Xr getdtablesize 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2 ,
+.Xr dup3 3
+.Sh STANDARDS
+The
+.Fn dup
+and
+.Fn dup2
+system calls are expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn dup
+function appeared in
+.At v3 .
+The
+.Fn dup2
+function appeared in
+.At v7 .
diff --git a/lib/libc/sys/eventfd.2 b/lib/libsys/eventfd.2
index d472b48f1daa..d472b48f1daa 100644
--- a/lib/libc/sys/eventfd.2
+++ b/lib/libsys/eventfd.2
diff --git a/lib/libsys/execve.2 b/lib/libsys/execve.2
new file mode 100644
index 000000000000..dc85b9321e48
--- /dev/null
+++ b/lib/libsys/execve.2
@@ -0,0 +1,382 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd July 02, 2025
+.Dt EXECVE 2
+.Os
+.Sh NAME
+.Nm execve ,
+.Nm fexecve
+.Nd execute a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn execve "const char *path" "char *const argv[]" "char *const envp[]"
+.Ft int
+.Fn fexecve "int fd" "char *const argv[]" "char *const envp[]"
+.Sh DESCRIPTION
+The
+.Fn execve
+system call
+transforms the calling process into a new process.
+The new process is constructed from an ordinary file,
+whose name is pointed to by
+.Fa path ,
+called the
+.Em new process file .
+The
+.Fn fexecve
+system call is equivalent to
+.Fn execve
+except that the file to be executed is determined by the file
+descriptor
+.Fa fd
+instead of a
+.Fa path .
+This file is either an executable object file,
+or a file of data for an interpreter.
+An executable object file consists of an identifying header,
+followed by pages of data representing the initial program (text)
+and initialized data pages.
+Additional pages may be specified
+by the header to be initialized with zero data; see
+.Xr elf 5
+and
+.Xr a.out 5 .
+.Pp
+An interpreter file begins with a line of the form:
+.Pp
+.Bd -ragged -offset indent -compact
+.Sy \&#!
+.Em interpreter
+.Bq Em arg
+.Ed
+.Pp
+When an interpreter file is
+.Sy execve Ap d ,
+the system actually
+.Sy execve Ap s
+the specified
+.Em interpreter .
+If the optional
+.Em arg
+is specified, it becomes the first argument to the
+.Em interpreter ,
+and the name of the originally
+.Sy execve Ap d
+file becomes the second argument;
+otherwise, the name of the originally
+.Sy execve Ap d
+file becomes the first argument.
+The original arguments are shifted over to
+become the subsequent arguments.
+The zeroth argument is set to the specified
+.Em interpreter .
+.Pp
+The argument
+.Fa argv
+is a pointer to a null-terminated array of
+character pointers to null-terminated character strings.
+These strings construct the argument list to be made available to the new
+process.
+At least one argument must be present in
+the array; by custom, the first element should be
+the name of the executed program (for example, the last component of
+.Fa path ) .
+.Pp
+The argument
+.Fa envp
+is also a pointer to a null-terminated array of
+character pointers to null-terminated strings.
+A pointer to this array is normally stored in the global variable
+.Va environ .
+These strings pass information to the
+new process that is not directly an argument to the command (see
+.Xr environ 7 ) .
+.Pp
+File descriptors open in the calling process image remain open in
+the new process image, except for those for which the close-on-exec
+flag is set (see
+.Xr close 2
+and
+.Xr fcntl 2 ) .
+Descriptors that remain open are unaffected by
+.Fn execve ,
+except those with the close-on-fork flag
+.Dv FD_CLOFORK
+which is cleared from all file descriptors.
+If any of the standard descriptors (0, 1, and/or 2) are closed at the
+time
+.Fn execve
+is called, and the process will gain privilege as a result of set-id
+semantics, those descriptors will be re-opened automatically.
+No programs, whether privileged or not, should assume that these descriptors
+will remain closed across a call to
+.Fn execve .
+.Pp
+Signals set to be ignored in the calling process are set to be ignored in
+the
+new process.
+Signals which are set to be caught in the calling process image
+are set to default action in the new process image.
+Blocked signals remain blocked regardless of changes to the signal action.
+The signal stack is reset to be undefined (see
+.Xr sigaction 2
+for more information).
+.Pp
+If the set-user-ID mode bit of the new process image file is set
+(see
+.Xr chmod 2 ) ,
+the effective user ID of the new process image is set to the owner ID
+of the new process image file.
+If the set-group-ID mode bit of the new process image file is set,
+the effective group ID of the new process image is set to the group ID
+of the new process image file.
+(The effective group ID is the first element of the group list.)
+The real user ID, real group ID and
+other group IDs of the new process image remain the same as the calling
+process image.
+After any set-user-ID and set-group-ID processing,
+the effective user ID is recorded as the saved set-user-ID,
+and the effective group ID is recorded as the saved set-group-ID.
+These values may be used in changing the effective IDs later (see
+.Xr setuid 2 ) .
+.Pp
+The set-ID bits are not honored if the respective file system has the
+.Cm nosuid
+option enabled or if the new process file is an interpreter file.
+Syscall
+tracing is disabled if effective IDs are changed.
+.Pp
+The new process also inherits the following attributes from
+the calling process:
+.Pp
+.Bl -column parent_process_ID -offset indent -compact
+.It process ID Ta see Xr getpid 2
+.It parent process ID Ta see Xr getppid 2
+.It process group ID Ta see Xr getpgrp 2
+.It access groups Ta see Xr getgroups 2
+.It working directory Ta see Xr chdir 2
+.It root directory Ta see Xr chroot 2
+.It control terminal Ta see Xr termios 4
+.It resource usages Ta see Xr getrusage 2
+.It interval timers Ta see Xr getitimer 2
+.It resource limits Ta see Xr getrlimit 2
+.It file mode mask Ta see Xr umask 2
+.It signal mask Ta see Xr sigaction 2 ,
+.Xr sigprocmask 2
+.El
+.Pp
+When a program is executed as a result of an
+.Fn execve
+system call, it is entered as follows:
+.Bd -literal -offset indent
+main(argc, argv, envp)
+int argc;
+char **argv, **envp;
+.Ed
+.Pp
+where
+.Fa argc
+is the number of elements in
+.Fa argv
+(the ``arg count'')
+and
+.Fa argv
+points to the array of character pointers
+to the arguments themselves.
+.Pp
+The
+.Fn fexecve
+ignores the file offset of
+.Fa fd .
+Since execute permission is checked by
+.Fn fexecve ,
+the file descriptor
+.Fa fd
+need not have been opened with the
+.Dv O_EXEC
+flag.
+However, if the file to be executed denies read permission for the process
+preparing to do the exec, the only way to provide the
+.Fa fd
+to
+.Fn fexecve
+is to use the
+.Dv O_EXEC
+flag when opening
+.Fa fd .
+Note that the file to be executed can not be open for writing.
+.Sh RETURN VALUES
+As the
+.Fn execve
+system call overlays the current process image
+with a new process image the successful call
+has no process to return to.
+If
+.Fn execve
+does return to the calling process an error has occurred; the
+return value will be -1 and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn execve
+system call
+will fail and return to the calling process if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOEXEC
+When invoking an interpreted script, the length of the first line,
+inclusive of the
+.Sy \&#!
+prefix and terminating newline, exceeds
+.Dv MAXSHELLCMDLEN
+characters.
+.It Bq Er ENOENT
+The new process file does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+The new process file is not an ordinary file.
+.It Bq Er EACCES
+The new process file mode denies execute permission.
+.It Bq Er EINVAL
+.Fa argv
+did not contain at least one element.
+.It Bq Er ENOEXEC
+The new process file has the appropriate access
+permission, but has an invalid magic number in its header.
+.It Bq Er ETXTBSY
+The new process file is a pure procedure (shared text)
+file that is currently open for writing by some process.
+.It Bq Er ENOMEM
+The new process requires more virtual memory than
+is allowed by the imposed maximum
+.Pq Xr getrlimit 2 .
+.It Bq Er E2BIG
+The number of bytes in the new process' argument list
+is larger than the system-imposed limit.
+This limit is specified by the
+.Xr sysctl 3
+MIB variable
+.Dv KERN_ARGMAX .
+.It Bq Er EFAULT
+The new process file is not as long as indicated by
+the size values in its header.
+.It Bq Er EFAULT
+The
+.Fa path ,
+.Fa argv ,
+or
+.Fa envp
+arguments
+point
+to an illegal address.
+.It Bq Er EIO
+An I/O error occurred while reading from the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+In addition, the
+.Fn fexecve
+will fail and return to the calling process if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument is not a valid file descriptor open for executing.
+.El
+.Sh SEE ALSO
+.Xr ktrace 1 ,
+.Xr _exit 2 ,
+.Xr fork 2 ,
+.Xr open 2 ,
+.Xr execl 3 ,
+.Xr exit 3 ,
+.Xr sysctl 3 ,
+.Xr fdescfs 4 ,
+.Xr a.out 5 ,
+.Xr elf 5 ,
+.Xr environ 7 ,
+.Xr mount 8
+.Sh STANDARDS
+The
+.Fn execve
+system call conforms to
+.St -p1003.1-2001 ,
+with the exception of reopening descriptors 0, 1, and/or 2 in certain
+circumstances.
+A future update of the Standard is expected to require this behavior,
+and it may become the default for non-privileged processes as well.
+.\" NB: update this caveat when TC1 is blessed.
+The support for executing interpreted programs is an extension.
+The
+.Fn fexecve
+system call conforms to The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn execve
+system call appeared in
+.At v7 .
+The
+.Fn fexecve
+system call appeared in
+.Fx 8.0 .
+.Sh CAVEATS
+If a program is
+.Em setuid
+to a non-super-user, but is executed when
+the real
+.Em uid
+is ``root'', then the program has some of the powers
+of a super-user as well.
+.Pp
+When executing an interpreted program through
+.Fn fexecve ,
+kernel supplies
+.Pa /dev/fd/n
+as a second argument to the interpreter,
+where
+.Ar n
+is the file descriptor passed in the
+.Fa fd
+argument to
+.Fn fexecve .
+For this construction to work correctly, the
+.Xr fdescfs 4
+filesystem shall be mounted on
+.Pa /dev/fd .
diff --git a/lib/libc/sys/extattr_get_file.2 b/lib/libsys/extattr_get_file.2
index f66c64160d55..f66c64160d55 100644
--- a/lib/libc/sys/extattr_get_file.2
+++ b/lib/libsys/extattr_get_file.2
diff --git a/lib/libsys/fcntl.2 b/lib/libsys/fcntl.2
new file mode 100644
index 000000000000..d67c38cfbc6c
--- /dev/null
+++ b/lib/libsys/fcntl.2
@@ -0,0 +1,848 @@
+.\" Copyright (c) 1983, 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.
+.\"
+.Dd June 24, 2025
+.Dt FCNTL 2
+.Os
+.Sh NAME
+.Nm fcntl
+.Nd file control
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.Ft int
+.Fn fcntl "int fd" "int cmd" "..."
+.Sh DESCRIPTION
+The
+.Fn fcntl
+system call provides for control over descriptors.
+The argument
+.Fa fd
+is a descriptor to be operated on by
+.Fa cmd
+as described below.
+Depending on the value of
+.Fa cmd ,
+.Fn fcntl
+can take an additional third argument
+.Fa arg .
+Unless otherwise noted below for a specific operation,
+.Fa arg
+has type
+.Vt int .
+.Bl -tag -width F_DUP2FD_CLOEXEC
+.It Dv F_DUPFD
+Return a new descriptor as follows:
+.Pp
+.Bl -bullet -compact -offset 4n
+.It
+Lowest numbered available descriptor greater than or equal to
+.Fa arg .
+.It
+Same object references as the original descriptor.
+.It
+New descriptor shares the same file offset if the object
+was a file.
+.It
+Same access mode (read, write or read/write).
+.It
+Same file status flags (i.e., both file descriptors
+share the same file status flags).
+.It
+The close-on-exec flag
+.Dv FD_CLOEXEC
+associated with the new file descriptor is cleared, so the file descriptor is
+to remain open across
+.Xr execve 2
+system calls.
+.It
+The fork-on-exec flag
+.Dv FD_CLOFORK
+associated with the new file descriptor is cleared, so the file descriptor is
+to remain open across
+.Xr fork 2
+system calls.
+.It
+The
+.Dv FD_RESOLVE_BENEATH
+flag, described below, will be set if it was set on the original
+descriptor.
+.El
+.It Dv F_DUPFD_CLOEXEC
+Like
+.Dv F_DUPFD ,
+but the
+.Dv FD_CLOEXEC
+flag associated with the new file descriptor is set, so the file descriptor
+is closed when
+.Xr execve 2
+system call executes.
+.It Dv F_DUPFD_CLOFORK
+Like
+.Dv F_DUPFD ,
+but the
+.Dv FD_CLOFORK
+flag associated with the new file descriptor is set, so the file descriptor
+is closed when
+.Xr fork 2
+system call executes.
+.It Dv F_DUP2FD
+It is functionally equivalent to
+.Bd -literal -offset indent
+dup2(fd, arg)
+.Ed
+.It Dv F_DUP2FD_CLOEXEC
+Like
+.Dv F_DUP2FD ,
+but the
+.Dv FD_CLOEXEC
+flag associated with the new file descriptor is set.
+.Pp
+The
+.Dv F_DUP2FD
+and
+.Dv F_DUP2FD_CLOEXEC
+constants are not portable, so they should not be used if
+portability is needed.
+Use
+.Fn dup2
+instead of
+.Dv F_DUP2FD .
+.It Dv F_DUP3FD
+Used to implement the
+.Fn dup3
+call.
+Do not use it.
+.It Dv F_GETFD
+Get the flags associated with the file descriptor
+.Fa fd .
+The following flags are defined:
+.Bl -tag -width FD_RESOLVE_BENEATH
+.It Dv FD_CLOEXEC
+The file will be closed upon execution of
+.Fn exec
+.Fa ( arg
+is ignored).
+Otherwise, the file descriptor will remain open.
+.It Dv FD_CLOFORK
+The file will be closed upon execution of the
+.Fn fork
+family of system calls.
+.It Dv FD_RESOLVE_BENEATH
+All path name lookups relative to that file descriptor
+will behave as if the lookup had
+.Dv O_RESOLVE_BENEATH
+or
+.Dv AT_RESOLVE_BENEATH
+semantics.
+It is not permitted to call
+.Xr fchdir 2
+or
+.Xr fchroot 2
+on such a file descriptor.
+The
+.Dv FD_RESOLVE_BENEATH
+flag is sticky, meaning that it is preserved by
+.Xr dup 2
+and similar operations, and opening a directory with
+.Xr openat 2
+where the directory descriptor has the flag set causes the new directory
+descriptor to also have the flag set.
+.El
+.It Dv F_SETFD
+Set flags associated with
+.Fa fd .
+The available flags are
+.Dv FD_CLOEXEC ,
+.Dv FD_CLOFORK
+and
+.Dv FD_RESOLVE_BENEATH .
+The
+.Dv FD_RESOLVE_BENEATH
+flag cannot be cleared once set.
+.It Dv F_GETFL
+Get descriptor status flags, as described below
+.Fa ( arg
+is ignored).
+.It Dv F_SETFL
+Set descriptor status flags to
+.Fa arg .
+.It Dv F_GETOWN
+Get the process ID or process group
+currently receiving
+.Dv SIGIO
+and
+.Dv SIGURG
+signals; process groups are returned
+as negative values
+.Fa ( arg
+is ignored).
+.It Dv F_SETOWN
+Set the process or process group
+to receive
+.Dv SIGIO
+and
+.Dv SIGURG
+signals;
+process groups are specified by supplying
+.Fa arg
+as negative, otherwise
+.Fa arg
+is interpreted as a process ID.
+.It Dv F_READAHEAD
+Set or clear the read ahead amount for sequential access to the third
+argument,
+.Fa arg ,
+which is rounded up to the nearest block size.
+A zero value in
+.Fa arg
+turns off read ahead, a negative value restores the system default.
+.It Dv F_RDAHEAD
+Equivalent to Darwin counterpart which sets read ahead amount of 128KB
+when the third argument,
+.Fa arg
+is non-zero.
+A zero value in
+.Fa arg
+turns off read ahead.
+.It Dv F_ADD_SEALS
+Add seals to the file as described below, if the underlying filesystem supports
+seals.
+.It Dv F_GET_SEALS
+Get seals associated with the file, if the underlying filesystem supports seals.
+.It Dv F_ISUNIONSTACK
+Check if the vnode is part of a union stack (either the "union" flag from
+.Xr mount 2
+or unionfs).
+This is a hack not intended to be used outside of libc.
+.It Dv F_KINFO
+Fills a
+.Vt struct kinfo_file
+for the file referenced by the specified file descriptor.
+The
+.Fa arg
+argument should point to the storage for
+.Vt struct kinfo_file .
+The
+.Va kf_structsize
+member of the passed structure must be initialized with the sizeof of
+.Vt struct kinfo_file ,
+to allow for the interface versioning and evolution.
+.El
+.Pp
+The flags for the
+.Dv F_GETFL
+and
+.Dv F_SETFL
+commands are as follows:
+.Bl -tag -width O_NONBLOCKX
+.It Dv O_NONBLOCK
+Non-blocking I/O; if no data is available to a
+.Xr read 2
+system call, or if a
+.Xr write 2
+operation would block,
+the read or write call returns -1 with the error
+.Er EAGAIN .
+.It Dv O_APPEND
+Force each write to append at the end of file;
+corresponds to the
+.Dv O_APPEND
+flag of
+.Xr open 2 .
+.It Dv O_DIRECT
+Minimize or eliminate the cache effects of reading and writing.
+The system
+will attempt to avoid caching the data you read or write.
+If it cannot
+avoid caching the data, it will minimize the impact the data has on the cache.
+Use of this flag can drastically reduce performance if not used with care.
+.It Dv O_ASYNC
+Enable the
+.Dv SIGIO
+signal to be sent to the process group
+when I/O is possible, e.g.,
+upon availability of data to be read.
+.It Dv O_SYNC
+Enable synchronous writes.
+Corresponds to the
+.Dv O_SYNC
+flag of
+.Xr open 2 .
+.Dv O_FSYNC
+is an historical synonym for
+.Dv O_SYNC .
+.It Dv O_DSYNC
+Enable synchronous data writes.
+Corresponds to the
+.Dv O_DSYNC
+flag of
+.Xr open 2 .
+.El
+.Pp
+The seals that may be applied with
+.Dv F_ADD_SEALS
+are as follows:
+.Bl -tag -width F_SEAL_SHRINK
+.It Dv F_SEAL_SEAL
+Prevent any further seals from being applied to the file.
+.It Dv F_SEAL_SHRINK
+Prevent the file from being shrunk with
+.Xr ftruncate 2 .
+.It Dv F_SEAL_GROW
+Prevent the file from being enlarged with
+.Xr ftruncate 2 .
+.It Dv F_SEAL_WRITE
+Prevent any further
+.Xr write 2
+calls to the file.
+Any writes in progress will finish before
+.Fn fcntl
+returns.
+If any writeable mappings exist, F_ADD_SEALS will fail and return
+.Dv EBUSY .
+.El
+.Pp
+Seals are on a per-inode basis and require support by the underlying filesystem.
+If the underlying filesystem does not support seals,
+.Dv F_ADD_SEALS
+and
+.Dv F_GET_SEALS
+will fail and return
+.Dv EINVAL .
+.Pp
+Several operations are available for doing advisory file locking;
+they all operate on the following structure:
+.Bd -literal
+struct flock {
+ off_t l_start; /* starting offset */
+ off_t l_len; /* len = 0 means until end of file */
+ pid_t l_pid; /* lock owner */
+ short l_type; /* lock type: read/write, etc. */
+ short l_whence; /* type of l_start */
+ int l_sysid; /* remote system id or zero for local */
+};
+.Ed
+These advisory file locking operations take a pointer to
+.Vt struct flock
+as the third argument
+.Fa arg .
+The commands available for advisory record locking are as follows:
+.Bl -tag -width F_SETLKWX
+.It Dv F_GETLK
+Get the first lock that blocks the lock description pointed to by the
+third argument,
+.Fa arg ,
+taken as a pointer to a
+.Fa "struct flock"
+(see above).
+The information retrieved overwrites the information passed to
+.Fn fcntl
+in the
+.Fa flock
+structure.
+If no lock is found that would prevent this lock from being created,
+the structure is left unchanged by this system call except for the
+lock type which is set to
+.Dv F_UNLCK .
+.It Dv F_SETLK
+Set or clear a file segment lock according to the lock description
+pointed to by the third argument,
+.Fa arg ,
+taken as a pointer to a
+.Fa "struct flock"
+(see above).
+.Dv F_SETLK
+is used to establish shared (or read) locks
+.Pq Dv F_RDLCK
+or exclusive (or write) locks,
+.Pq Dv F_WRLCK ,
+as well as remove either type of lock
+.Pq Dv F_UNLCK .
+If a shared or exclusive lock cannot be set,
+.Fn fcntl
+returns immediately with
+.Er EAGAIN .
+.It Dv F_SETLKW
+This command is the same as
+.Dv F_SETLK
+except that if a shared or exclusive lock is blocked by other locks,
+the process waits until the request can be satisfied.
+If a signal that is to be caught is received while
+.Fn fcntl
+is waiting for a region, the
+.Fn fcntl
+will be interrupted if the signal handler has not specified the
+.Dv SA_RESTART
+(see
+.Xr sigaction 2 ) .
+.El
+.Pp
+When a shared lock has been set on a segment of a file,
+other processes can set shared locks on that segment
+or a portion of it.
+A shared lock prevents any other process from setting an exclusive
+lock on any portion of the protected area.
+A request for a shared lock fails if the file descriptor was not
+opened with read access.
+.Pp
+An exclusive lock prevents any other process from setting a shared lock or
+an exclusive lock on any portion of the protected area.
+A request for an exclusive lock fails if the file was not
+opened with write access.
+.Pp
+The value of
+.Fa l_whence
+is
+.Dv SEEK_SET ,
+.Dv SEEK_CUR ,
+or
+.Dv SEEK_END
+to indicate that the relative offset,
+.Fa l_start
+bytes, will be measured from the start of the file,
+current position, or end of the file, respectively.
+The value of
+.Fa l_len
+is the number of consecutive bytes to be locked.
+If
+.Fa l_len
+is negative,
+.Fa l_start
+means end edge of the region.
+The
+.Fa l_pid
+and
+.Fa l_sysid
+fields are only used with
+.Dv F_GETLK
+to return the process ID of the process holding a blocking lock and
+the system ID of the system that owns that process.
+Locks created by the local system will have a system ID of zero.
+After a successful
+.Dv F_GETLK
+request, the value of
+.Fa l_whence
+is
+.Dv SEEK_SET .
+.Pp
+Locks may start and extend beyond the current end of a file,
+but may not start or extend before the beginning of the file.
+A lock is set to extend to the largest possible value of the
+file offset for that file if
+.Fa l_len
+is set to zero.
+If
+.Fa l_whence
+and
+.Fa l_start
+point to the beginning of the file, and
+.Fa l_len
+is zero, the entire file is locked.
+If an application wishes only to do entire file locking, the
+.Xr flock 2
+system call is much more efficient.
+.Pp
+There is at most one type of lock set for each byte in the file.
+Before a successful return from an
+.Dv F_SETLK
+or an
+.Dv F_SETLKW
+request when the calling process has previously existing locks
+on bytes in the region specified by the request,
+the previous lock type for each byte in the specified
+region is replaced by the new lock type.
+As specified above under the descriptions
+of shared locks and exclusive locks, an
+.Dv F_SETLK
+or an
+.Dv F_SETLKW
+request fails or blocks respectively when another process has existing
+locks on bytes in the specified region and the type of any of those
+locks conflicts with the type specified in the request.
+.Pp
+The queuing for
+.Dv F_SETLKW
+requests on local files is fair;
+that is, while the thread is blocked,
+subsequent requests conflicting with its requests will not be granted,
+even if these requests do not conflict with existing locks.
+.Pp
+This interface follows the completely stupid semantics of System V and
+.St -p1003.1-88
+that require that all locks associated with a file for a given process are
+removed when
+.Em any
+file descriptor for that file is closed by that process.
+This semantic means that applications must be aware of any files that
+a subroutine library may access.
+For example if an application for updating the password file locks the
+password file database while making the update, and then calls
+.Xr getpwnam 3
+to retrieve a record,
+the lock will be lost because
+.Xr getpwnam 3
+opens, reads, and closes the password database.
+The database close will release all locks that the process has
+associated with the database, even if the library routine never
+requested a lock on the database.
+Another minor semantic problem with this interface is that
+locks are not inherited by a child process created using the
+.Xr fork 2
+system call.
+The
+.Xr flock 2
+interface has much more rational last close semantics and
+allows locks to be inherited by child processes.
+The
+.Xr flock 2
+system call is recommended for applications that want to ensure the integrity
+of their locks when using library routines or wish to pass locks
+to their children.
+.Pp
+The
+.Fn fcntl ,
+.Xr flock 2 ,
+and
+.Xr lockf 3
+locks are compatible.
+Processes using different locking interfaces can cooperate
+over the same file safely.
+However, only one of such interfaces should be used within
+the same process.
+If a file is locked by a process through
+.Xr flock 2 ,
+any record within the file will be seen as locked
+from the viewpoint of another process using
+.Fn fcntl
+or
+.Xr lockf 3 ,
+and vice versa.
+Note that
+.Fn fcntl F_GETLK
+returns \-1 in
+.Fa l_pid
+if the process holding a blocking lock previously locked the
+file descriptor by
+.Xr flock 2 .
+.Pp
+All locks associated with a file for a given process are
+removed when the process terminates.
+.Pp
+All locks obtained before a call to
+.Xr execve 2
+remain in effect until the new program releases them.
+If the new program does not know about the locks, they will not be
+released until the program exits.
+.Pp
+A potential for deadlock occurs if a process controlling a locked region
+is put to sleep by attempting to lock the locked region of another process.
+This implementation detects that sleeping until a locked region is unlocked
+would cause a deadlock and fails with an
+.Er EDEADLK
+error.
+.Sh RETURN VALUES
+Upon successful completion, the value returned depends on
+.Fa cmd
+as follows:
+.Bl -tag -width F_GETOWNX -offset indent
+.It Dv F_DUPFD
+A new file descriptor.
+.It Dv F_DUP2FD
+A file descriptor equal to
+.Fa arg .
+.It Dv F_GETFD
+Value of flags.
+.It Dv F_GETFL
+Value of flags.
+.It Dv F_GETOWN
+Value of file descriptor owner.
+.It other
+Value other than -1.
+.El
+.Pp
+Otherwise, a value of -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn fcntl
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The argument
+.Fa cmd
+is
+.Dv F_SETLK ,
+the type of lock
+.Pq Fa l_type
+is a shared lock
+.Pq Dv F_RDLCK
+or exclusive lock
+.Pq Dv F_WRLCK ,
+and the segment of a file to be locked is already
+exclusive-locked by another process;
+or the type is an exclusive lock and some portion of the
+segment of a file to be locked is already shared-locked or
+exclusive-locked by another process.
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid open file descriptor.
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_DUP2FD ,
+and
+.Fa arg
+is not a valid file descriptor.
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_SETLK
+or
+.Dv F_SETLKW ,
+the type of lock
+.Pq Fa l_type
+is a shared lock
+.Pq Dv F_RDLCK ,
+and
+.Fa fd
+is not a valid file descriptor open for reading.
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_SETLK
+or
+.Dv F_SETLKW ,
+the type of lock
+.Pq Fa l_type
+is an exclusive lock
+.Pq Dv F_WRLCK ,
+and
+.Fa fd
+is not a valid file descriptor open for writing.
+.It Bq Er EBUSY
+The argument
+.Fa cmd
+is
+.Dv F_ADD_SEALS ,
+attempting to set
+.Dv F_SEAL_WRITE ,
+and writeable mappings of the file exist.
+.It Bq Er EDEADLK
+The argument
+.Fa cmd
+is
+.Dv F_SETLKW ,
+and a deadlock condition was detected.
+.It Bq Er EINTR
+The argument
+.Fa cmd
+is
+.Dv F_SETLKW ,
+and the system call was interrupted by a signal.
+.It Bq Er EINVAL
+The
+.Fa cmd
+argument
+is
+.Dv F_DUPFD
+and
+.Fa arg
+is negative or greater than the maximum allowable number
+(see
+.Xr getdtablesize 2 ) .
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_GETLK ,
+.Dv F_SETLK
+or
+.Dv F_SETLKW
+and the data to which
+.Fa arg
+points is not valid.
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_ADD_SEALS
+or
+.Dv F_GET_SEALS ,
+and the underlying filesystem does not support sealing.
+.Pp
+The argument
+.Fa cmd
+is invalid.
+.It Bq Er EMFILE
+The argument
+.Fa cmd
+is
+.Dv F_DUPFD
+and the maximum number of file descriptors permitted for the
+process are already in use,
+or no file descriptors greater than or equal to
+.Fa arg
+are available.
+.It Bq Er ENOTTY
+The
+.Fa fd
+argument is not a valid file descriptor for the requested operation.
+This may be the case if
+.Fa fd
+is a device node, or a descriptor returned by
+.Xr kqueue 2 .
+.It Bq Er ENOLCK
+The argument
+.Fa cmd
+is
+.Dv F_SETLK
+or
+.Dv F_SETLKW ,
+and satisfying the lock or unlock request would result in the
+number of locked regions in the system exceeding a system-imposed limit.
+.It Bq Er EOPNOTSUPP
+The argument
+.Fa cmd
+is
+.Dv F_GETLK ,
+.Dv F_SETLK
+or
+.Dv F_SETLKW
+and
+.Fa fd
+refers to a file for which locking is not supported.
+.It Bq Er EOVERFLOW
+The argument
+.Fa cmd
+is
+.Dv F_GETLK ,
+.Dv F_SETLK
+or
+.Dv F_SETLKW
+and an
+.Fa off_t
+calculation overflowed.
+.It Bq Er EPERM
+The
+.Fa cmd
+argument
+is
+.Dv F_SETOWN
+and
+the process ID or process group given as an argument is in a
+different session than the caller.
+.Pp
+The
+.Fa cmd
+argument
+is
+.Dv F_ADD_SEALS
+and the
+.Dv F_SEAL_SEAL
+seal has already been set.
+.It Bq Er ESRCH
+The
+.Fa cmd
+argument
+is
+.Dv F_SETOWN
+and
+the process ID given as argument is not in use.
+.El
+.Pp
+In addition, if
+.Fa fd
+refers to a descriptor open on a terminal device (as opposed to a
+descriptor open on a socket), a
+.Fa cmd
+of
+.Dv F_SETOWN
+can fail for the same reasons as in
+.Xr tcsetpgrp 3 ,
+and a
+.Fa cmd
+of
+.Dv F_GETOWN
+for the reasons as stated in
+.Xr tcgetpgrp 3 .
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr dup2 2 ,
+.Xr execve 2 ,
+.Xr flock 2 ,
+.Xr getdtablesize 2 ,
+.Xr open 2 ,
+.Xr sigaction 2 ,
+.Xr lockf 3 ,
+.Xr tcgetpgrp 3 ,
+.Xr tcsetpgrp 3
+.Sh STANDARDS
+The
+.Dv F_DUP2FD
+and
+.Dv F_DUP3FD
+constants are not portable.
+They are provided for compatibility with AIX and Solaris.
+.Pp
+Per
+.St -susv4 ,
+a call with
+.Dv F_SETLKW
+should fail with
+.Bq Er EINTR
+after any caught signal
+and should continue waiting during thread suspension such as a stop signal.
+However, in this implementation a call with
+.Dv F_SETLKW
+is restarted after catching a signal with a
+.Dv SA_RESTART
+handler or a thread suspension such as a stop signal.
+.Sh HISTORY
+The
+.Fn fcntl
+system call appeared in
+.Bx 4.2 .
+.Pp
+The
+.Dv F_DUP2FD
+constant first appeared in
+.Fx 7.1 .
+.Pp
+The
+.Dv F_DUPFD_CLOFORK
+and
+.Dv F_DUP3FD
+flags appeared in
+.Fx 15.0 .
diff --git a/lib/libc/sys/ffclock.2 b/lib/libsys/ffclock.2
index 2e34c5cd8e9d..2e34c5cd8e9d 100644
--- a/lib/libc/sys/ffclock.2
+++ b/lib/libsys/ffclock.2
diff --git a/lib/libsys/fhlink.2 b/lib/libsys/fhlink.2
new file mode 100644
index 000000000000..b7f7d02dd136
--- /dev/null
+++ b/lib/libsys/fhlink.2
@@ -0,0 +1,254 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2018 Gandi
+.\"
+.\" 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.
+.\"
+.Dd November 30, 2022
+.Dt FHLINK 2
+.Os
+.Sh NAME
+.Nm fhlink ,
+.Nm fhlinkat
+.Nd make a hard file link
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn fhlink "fhandle_t *fhp" "const char *to"
+.Ft int
+.Fn fhlinkat "fhandle_t *fhp" "int tofd" "const char *to"
+.Sh DESCRIPTION
+The
+.Fn fhlink
+system call
+atomically creates the specified directory entry (hard link)
+.Fa to
+with the attributes of the underlying object pointed at by
+.Fa fhp .
+If the link is successful: the link count of the underlying object
+is incremented;
+.Fa fhp
+and
+.Fa to
+share equal access and rights
+to the
+underlying object.
+.Pp
+If
+.Fa fhp
+is removed, the file
+.Fa to
+is not deleted and the link count of the
+underlying object is
+decremented.
+.Pp
+The object pointed at by the
+.Fa fhp
+argument
+must exist for the hard link to
+succeed and
+both
+.Fa fhp
+and
+.Fa to
+must be in the same file system.
+The
+.Fa fhp
+argument
+may not be a directory.
+.Pp
+The
+.Fn fhlinkat
+system call is equivalent to
+.Fa fhlink
+except in the case where
+.Fa to
+is a relative paths.
+In this case a relative path
+.Fa to
+is interpreted relative to
+the directory associated with the file descriptor
+.Fa tofd
+instead of the current working directory.
+.Pp
+If
+.Fn fhlinkat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa tofd
+parameter, the current working directory is used for the
+.Fa to
+argument.
+If
+.Fa tofd
+has value
+.Dv AT_FDCWD ,
+the behavior is identical to a call to
+.Fn link .
+Unless
+.Fa flag
+contains the
+.Dv AT_SYMLINK_FOLLOW
+flag, if
+.Fa fhp
+names a symbolic link, a new link is created for the symbolic link
+.Fa fhp
+and not its target.
+.Sh RETURN VALUES
+.Rv -std link
+.Sh ERRORS
+The
+.Fn fhlink
+system call
+will fail and no link will be created if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of
+.Fa to
+prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of
+.Fa to
+exceeded 255 characters,
+or entire length of
+.Fa to
+name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of
+.Fa to
+prefix does not exist.
+.It Bq Er EOPNOTSUPP
+The file system containing the file pointed at by
+.Fa fhp
+does not support links.
+.It Bq Er EMLINK
+The link count of the file pointed at by
+.Fa fhp
+would exceed 32767.
+.It Bq Er EACCES
+A component of
+.Fa to
+prefix denies search permission.
+.It Bq Er EACCES
+The requested link requires writing in a directory with a mode
+that denies write permission.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating one of the pathnames.
+.It Bq Er ENOENT
+The file pointed at by
+.Fa fhp
+does not exist.
+.It Bq Er EEXIST
+The link named by
+.Fa to
+does exist.
+.It Bq Er EPERM
+The file pointed at by
+.Fa fhp
+is a directory.
+.It Bq Er EPERM
+The file pointed at by
+.Fa fhp
+has its immutable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EPERM
+The parent directory of the file named by
+.Fa to
+has its immutable flag set.
+.It Bq Er EXDEV
+The link named by
+.Fa to
+and the file pointed at by
+.Fa fhp
+are on different file systems.
+.It Bq Er ENOSPC
+The directory in which the entry for the new link is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er EDQUOT
+The directory in which the entry for the new link
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to
+the file system to make the directory entry.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The requested link requires writing in a directory on a read-only file
+system.
+.It Bq Er EFAULT
+One of the pathnames specified
+is outside the process's allocated address space.
+.It Bq Er ESTALE
+The file handle
+.Fa fhp
+is no longer valid
+.El
+.Pp
+In addition to the errors returned by the
+.Fn fhlink ,
+the
+.Fn fhlinkat
+system call may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fhp
+or
+.Fa to
+argument does not specify an absolute path and the
+.Fa tofd
+argument, is not
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa fhp
+or
+.Fa to
+argument is not an absolute path and
+.Fa tofd
+is not
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr fhopen 2 ,
+.Xr fhreadlink 2 ,
+.Xr fhstat 2
+.Sh HISTORY
+The
+.Fn fhlink
+and
+.Fn fhlinkat
+system calls first appeared in
+.Fx 12.1 .
diff --git a/lib/libsys/fhopen.2 b/lib/libsys/fhopen.2
new file mode 100644
index 000000000000..b281ac3d8949
--- /dev/null
+++ b/lib/libsys/fhopen.2
@@ -0,0 +1,160 @@
+.\" $NetBSD: fhopen.2,v 1.1 1999/06/30 01:32:15 wrstuden Exp $
+.\"
+.\" Copyright (c) 1999 National Aeronautics & Space Administration
+.\" All rights reserved.
+.\"
+.\" This software was written by William Studenmund of the
+.\" Numerical Aerospace Simulation Facility, NASA Ames Research Center.
+.\"
+.\" 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 National Aeronautics & Space Administration
+.\" 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 NATIONAL AERONAUTICS & SPACE ADMINISTRATION
+.\" ``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 ADMINISTRATION OR CONTRIB-
+.\" UTORS 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.
+.\"
+.Dd July 20, 2025
+.Dt FHOPEN 2
+.Os
+.Sh NAME
+.Nm fhopen ,
+.Nm fhstat ,
+.Nm fhstatfs
+.Nd access file via file handle
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/mount.h
+.In sys/stat.h
+.Ft int
+.Fn fhopen "const fhandle_t *fhp" "int flags"
+.Ft int
+.Fn fhstat "const fhandle_t *fhp" "struct stat *sb"
+.Ft int
+.Fn fhstatfs "const fhandle_t *fhp" "struct statfs *buf"
+.Sh DESCRIPTION
+These system calls provide a means to access a file given the file handle
+.Fa fhp .
+As this method bypasses directory access restrictions, these calls are
+restricted to the superuser.
+.Pp
+The
+.Fn fhopen
+system call
+opens the file referenced by
+.Fa fhp
+for reading and/or writing as specified by the argument
+.Fa flags
+and returns the file descriptor to the calling process.
+The
+.Fa flags
+argument
+is specified by
+.Em or Ns 'ing
+together the flags used for the
+.Xr open 2
+system call.
+All said flags are valid except for
+.Dv O_CREAT .
+If the file handle refers to a named attribute or named attribute
+directory, the
+.Dv O_NAMEDATTR
+flag must be specified.
+.Pp
+The
+.Fn fhstat
+and
+.Fn fhstatfs
+system calls
+provide the functionality of the
+.Xr fstat 2
+and
+.Xr fstatfs 2
+calls except that they return information for the file referred to by
+.Fa fhp
+rather than an open file.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn fhopen
+returns the file descriptor for the opened file;
+otherwise the value \-1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Pp
+.Rv -std fhstat fhstatfs
+.Sh ERRORS
+In addition to the errors returned by
+.Xr open 2 ,
+.Xr fstat 2 ,
+and
+.Xr fstatfs 2
+respectively,
+.Fn fhopen ,
+.Fn fhstat ,
+and
+.Fn fhstatfs
+will return
+.Bl -tag -width Er
+.It Bq Er EINVAL
+Calling
+.Fn fhopen
+with
+.Dv O_CREAT
+set.
+.It Bq Er ENOATTR
+The file handle does not refer to a named attribute or named attribute
+directory although the
+.Dv O_NAMEDATTR
+flag was specified.
+.It Bq Er ENOATTR
+The file handle refers to a named attribute or named attribute directory
+although the
+.Dv O_NAMEDATTR
+flag was not specified.
+.It Bq Er ESTALE
+The file handle
+.Fa fhp
+is no longer valid.
+.El
+.Sh SEE ALSO
+.Xr fstat 2 ,
+.Xr fstatfs 2 ,
+.Xr getfh 2 ,
+.Xr open 2 ,
+.Xr named_attribute 7
+.Sh HISTORY
+The
+.Fn fhopen ,
+.Fn fhstat ,
+and
+.Fn fhstatfs
+system calls first appeared in
+.Nx 1.5
+and were adapted to
+.Fx 4.0
+by
+.An Alfred Perlstein .
+.Sh AUTHORS
+This manual page was written by
+.An William Studenmund
+for
+.Nx .
diff --git a/lib/libsys/fhreadlink.2 b/lib/libsys/fhreadlink.2
new file mode 100644
index 000000000000..4855f4d8ec67
--- /dev/null
+++ b/lib/libsys/fhreadlink.2
@@ -0,0 +1,96 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2018 Gandi
+.\"
+.\" 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.
+.\"
+.Dd November 30, 2022
+.Dt FHREADLINK 2
+.Os
+.Sh NAME
+.Nm fhreadlink
+.Nd read value of a symbolic link
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/mount.h
+.Ft int
+.Fn fhreadlink "fhandle_t *fhp" "char *buf" "size_t bufsize"
+.Sh DESCRIPTION
+The
+.Fn fhreadlink
+system call
+places the contents of the symbolic link
+.Fa fhp
+in the buffer
+.Fa buf ,
+which has size
+.Fa bufsiz .
+The
+.Fn fhreadlink
+system call does not append a
+.Dv NUL
+character to
+.Fa buf .
+.Pp
+.Sh RETURN VALUES
+The call returns the count of characters placed in the buffer
+if it succeeds, or a \-1 if an error occurs, placing the error
+code in the global variable
+.Va errno .
+.Sh ERRORS
+The
+.Fn fhreadlink
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the file handle
+.Fa fhp .
+.It Bq Er EINVAL
+The named file is not a symbolic link.
+.It Bq Er EIO
+An I/O error occurred while reading from the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+The
+.Fa buf
+argument
+extends outside the process's allocated address space.
+.It Bq Er ESTALE
+The file handle
+.Fa fhp
+is no longer valid
+.El
+.Sh SEE ALSO
+.Xr fhlink 2 ,
+.Xr fhstat 2 ,
+.Xr readlink 2
+.Sh HISTORY
+The
+.Fn fhreadlink
+system call first appeared in
+.Fx 12.1 .
diff --git a/lib/libsys/flock.2 b/lib/libsys/flock.2
new file mode 100644
index 000000000000..f1a989a1d484
--- /dev/null
+++ b/lib/libsys/flock.2
@@ -0,0 +1,170 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd November 9, 2011
+.Dt FLOCK 2
+.Os
+.Sh NAME
+.Nm flock
+.Nd "apply or remove an advisory lock on an open file"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/file.h
+.Fd "#define LOCK_SH 0x01 /* shared file lock */"
+.Fd "#define LOCK_EX 0x02 /* exclusive file lock */"
+.Fd "#define LOCK_NB 0x04 /* do not block when locking */"
+.Fd "#define LOCK_UN 0x08 /* unlock file */"
+.Ft int
+.Fn flock "int fd" "int operation"
+.Sh DESCRIPTION
+The
+.Fn flock
+system call applies or removes an
+.Em advisory
+lock on the file associated with the file descriptor
+.Fa fd .
+A lock is applied by specifying an
+.Fa operation
+argument that is one of
+.Dv LOCK_SH
+or
+.Dv LOCK_EX
+with the optional addition of
+.Dv LOCK_NB .
+To unlock
+an existing lock
+.Dv operation
+should be
+.Dv LOCK_UN .
+.Pp
+Advisory locks allow cooperating processes to perform
+consistent operations on files, but do not guarantee
+consistency (i.e., processes may still access files
+without using advisory locks possibly resulting in
+inconsistencies).
+.Pp
+The locking mechanism allows two types of locks:
+.Em shared
+locks and
+.Em exclusive
+locks.
+At any time multiple shared locks may be applied to a file,
+but at no time are multiple exclusive, or both shared and exclusive,
+locks allowed simultaneously on a file.
+.Pp
+A shared lock may be
+.Em upgraded
+to an exclusive lock, and vice versa, simply by specifying
+the appropriate lock type; this results in the previous
+lock being released and the new lock applied (possibly
+after other processes have gained and released the lock).
+.Pp
+Requesting a lock on an object that is already locked
+normally causes the caller to be blocked until the lock may be
+acquired.
+If
+.Dv LOCK_NB
+is included in
+.Fa operation ,
+then this will not happen; instead the call will fail and
+the error
+.Er EWOULDBLOCK
+will be returned.
+.Sh NOTES
+Locks are on files, not file descriptors.
+That is, file descriptors
+duplicated through
+.Xr dup 2
+or
+.Xr fork 2
+do not result in multiple instances of a lock, but rather multiple
+references to a single lock.
+If a process holding a lock on a file
+forks and the child explicitly unlocks the file, the parent will
+lose its lock.
+.Pp
+The
+.Fn flock ,
+.Xr fcntl 2 ,
+and
+.Xr lockf 3
+locks are compatible.
+Processes using different locking interfaces can cooperate
+over the same file safely.
+However, only one of such interfaces should be used within
+the same process.
+If a file is locked by a process through
+.Fn flock ,
+any record within the file will be seen as locked
+from the viewpoint of another process using
+.Xr fcntl 2
+or
+.Xr lockf 3 ,
+and vice versa.
+.Pp
+Processes blocked awaiting a lock may be awakened by signals.
+.Sh RETURN VALUES
+.Rv -std flock
+.Sh ERRORS
+The
+.Fn flock
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EWOULDBLOCK
+The file is locked and the
+.Dv LOCK_NB
+option was specified.
+.It Bq Er EBADF
+The argument
+.Fa fd
+is an invalid descriptor.
+.It Bq Er EINVAL
+The argument
+.Fa fd
+refers to an object other than a file.
+.It Bq Er EOPNOTSUPP
+The argument
+.Fa fd
+refers to an object that does not support file locking.
+.It Bq Er ENOLCK
+A lock was requested, but no locks are available.
+.El
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr dup 2 ,
+.Xr execve 2 ,
+.Xr fcntl 2 ,
+.Xr fork 2 ,
+.Xr open 2 ,
+.Xr flopen 3 ,
+.Xr lockf 3
+.Sh HISTORY
+The
+.Fn flock
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/fork.2 b/lib/libsys/fork.2
new file mode 100644
index 000000000000..e59b208a9ff5
--- /dev/null
+++ b/lib/libsys/fork.2
@@ -0,0 +1,278 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd May 17, 2024
+.Dt FORK 2
+.Os
+.Sh NAME
+.Nm fork
+.Nd create a new process
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft pid_t
+.Fn fork void
+.Ft pid_t
+.Fn _Fork void
+.Sh DESCRIPTION
+The
+.Fn fork
+function causes creation of a new process.
+The new process (child process) is an exact copy of the
+calling process (parent process) except for the following:
+.Bl -bullet -offset indent
+.It
+The child process has a unique process ID.
+.It
+The child process has a different parent
+process ID (i.e., the process ID of the parent process).
+.It
+The child process has its own copy of the parent's descriptors,
+except for descriptors returned by
+.Xr kqueue 2 ,
+which are not inherited from the parent process.
+These descriptors reference the same underlying objects, so that,
+for instance, file pointers in file objects are shared between
+the child and the parent, so that an
+.Xr lseek 2
+on a descriptor in the child process can affect a subsequent
+.Xr read 2
+or
+.Xr write 2
+by the parent.
+This descriptor copying is also used by the shell to
+establish standard input and output for newly created processes
+as well as to set up pipes.
+Any file descriptors that were marked with the close-on-fork flag,
+.Dv FD_CLOFORK
+.Po see
+.Fn fcntl 2
+and
+.Dv O_CLOFORK
+in
+.Fn open 2
+.Pc ,
+will not be present in the child process, but remain open in the parent.
+.It
+The child process' resource utilizations
+are set to 0; see
+.Xr setrlimit 2 .
+.It
+All interval timers are cleared; see
+.Xr setitimer 2 .
+.It
+The robust mutexes list (see
+.Xr pthread_mutexattr_setrobust 3 )
+is cleared for the child.
+.It
+The atfork handlers established with the
+.Xr pthread_atfork 3
+function are called as appropriate before fork in the parent process,
+and after the child is created, in parent and child.
+.It
+The child process has only one thread,
+corresponding to the calling thread in the parent process.
+If the process has more than one thread,
+locks and other resources held by the other threads are not released
+and therefore only async-signal-safe functions
+(see
+.Xr sigaction 2 )
+are guaranteed to work in the child process until a call to
+.Xr execve 2
+or a similar function.
+The
+.Fx
+implementation of
+.Fn fork
+provides a usable
+.Xr malloc 3 ,
+and
+.Xr rtld 1
+services in the child process.
+.El
+.Pp
+The
+.Fn fork
+function is not async-signal safe and creates a cancellation point
+in the parent process.
+It cannot be safely used from signal handlers, and the atfork handlers
+established by
+.Xr pthread_atfork 3
+do not need to be async-signal safe either.
+.Pp
+The
+.Fn _Fork
+function creates a new process, similarly to
+.Fn fork ,
+but it is async-signal safe.
+.Fn _Fork
+does not call atfork handlers, and does not create a cancellation point.
+It can be used safely from signal handlers, but then no userspace
+services (
+.Xr malloc 3
+or
+.Xr rtld 1 )
+are available in the child if forked from multi-threaded parent.
+In particular, if using dynamic linking, all dynamic symbols used by the
+child after
+.Fn _Fork
+must be pre-resolved.
+Note: resolving can be done globally by specifying the
+.Ev LD_BIND_NOW
+environment variable to the dynamic linker, or per-binary by passing the
+.Fl z Ar now
+option to the static linker
+.Xr ld 1 ,
+or by using each symbol before the
+.Fn _Fork
+call to force the binding.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn fork
+and
+.Fn _Fork
+return a value
+of 0 to the child process and return the process ID of the child
+process to the parent process.
+Otherwise, a value of -1 is returned
+to the parent process, no child process is created, and the global
+variable
+.Va errno
+is set to indicate the error.
+.Sh EXAMPLES
+The following example shows a common pattern of how
+.Fn fork
+is used in practice.
+.Bd -literal -offset indent
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+ pid_t pid;
+
+ /*
+ * If child is expected to use stdio(3), state of
+ * the reused io streams must be synchronized between
+ * parent and child, to avoid double output and other
+ * possible issues.
+ */
+ fflush(stdout);
+
+ switch (pid = fork()) {
+ case -1:
+ err(1, "Failed to fork");
+ case 0:
+ printf("Hello from child process!\en");
+
+ /*
+ * Since we wrote into stdout, child needs to use
+ * exit(3) and not _exit(2). This causes handlers
+ * registered with atexit(3) to be called twice,
+ * once in parent, and once in the child. If such
+ * behavior is undesirable, consider
+ * terminating child with _exit(2) or _Exit(3).
+ */
+ exit(0);
+ default:
+ break;
+ }
+
+ printf("Hello from parent process (child's PID: %d)!\en", pid);
+
+ return (0);
+}
+.Ed
+.Pp
+The output of such a program is along the lines of:
+.Bd -literal -offset indent
+Hello from parent process (child's PID: 27804)!
+Hello from child process!
+.Ed
+.Sh ERRORS
+The
+.Fn fork
+system call will fail and no child process will be created if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The system-imposed limit on the total
+number of processes under execution would be exceeded.
+The limit is given by the
+.Xr sysctl 3
+MIB variable
+.Dv KERN_MAXPROC .
+(The limit is actually ten less than this
+except for the super user).
+.It Bq Er EAGAIN
+The user is not the super user, and
+the system-imposed limit
+on the total number of
+processes under execution by a single user would be exceeded.
+The limit is given by the
+.Xr sysctl 3
+MIB variable
+.Dv KERN_MAXPROCPERUID .
+.It Bq Er EAGAIN
+The user is not the super user, and
+the soft resource limit corresponding to the
+.Fa resource
+argument
+.Dv RLIMIT_NPROC
+would be exceeded (see
+.Xr getrlimit 2 ) .
+.It Bq Er ENOMEM
+There is insufficient swap space for the new process.
+.El
+.Sh SEE ALSO
+.Xr execve 2 ,
+.Xr rfork 2 ,
+.Xr setitimer 2 ,
+.Xr setrlimit 2 ,
+.Xr sigaction 2 ,
+.Xr vfork 2 ,
+.Xr wait 2 ,
+.Xr pthread_atfork 3
+.Sh STANDARDS
+The
+.Fn fork
+and
+.Fn _Fork
+functions conform to
+.St -p1003.1-2024 .
+.Sh HISTORY
+The
+.Fn fork
+function appeared in
+.At v1 .
+The
+.Fn _Fork
+function appeared in
+.Fx 13.1 .
diff --git a/lib/libc/sys/fspacectl.2 b/lib/libsys/fspacectl.2
index 911c24101785..911c24101785 100644
--- a/lib/libc/sys/fspacectl.2
+++ b/lib/libsys/fspacectl.2
diff --git a/lib/libsys/fsync.2 b/lib/libsys/fsync.2
new file mode 100644
index 000000000000..d05c078af1e6
--- /dev/null
+++ b/lib/libsys/fsync.2
@@ -0,0 +1,130 @@
+.\" Copyright (c) 1983, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" Parts of this documentation were written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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.
+.\"
+.Dd March 30, 2020
+.Dt FSYNC 2
+.Os
+.Sh NAME
+.Nm fdatasync ,
+.Nm fsync
+.Nd "synchronise changes to a file"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn fdatasync "int fd"
+.Ft int
+.Fn fsync "int fd"
+.Sh DESCRIPTION
+The
+.Fn fsync
+system call
+causes all modified data and attributes of the file referenced by
+the file descriptor
+.Fa fd
+to be moved to a permanent storage device.
+This normally results in all in-core modified copies
+of buffers for the associated file to be written to a disk.
+.Pp
+The
+.Fn fdatasync
+system call causes all modified data of
+.Fa fd
+to be moved to a permanent storage device.
+Unlike
+.Fn fsync ,
+the system call does not guarantee that file attributes or
+metadata necessary to access the file are committed to the permanent storage.
+.Pp
+The
+.Fn fsync
+system call
+should be used by programs that require a file to be
+in a known state, for example, in building a simple transaction
+facility.
+If the file metadata has already been committed, using
+.Fn fdatasync
+can be more efficient than
+.Fn fsync .
+.Pp
+Both
+.Fn fdatasync
+and
+.Fn fsync
+calls are cancellation points.
+.Sh RETURN VALUES
+.Rv -std fsync
+.Sh ERRORS
+The
+.Fn fsync
+and
+.Fn fdatasync
+calls fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid descriptor.
+.It Bq Er EINVAL
+The
+.Fa fd
+argument
+refers to a socket, not to a file.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Sh SEE ALSO
+.Xr fsync 1 ,
+.Xr sync 2 ,
+.Xr syncer 4 ,
+.Xr sync 8
+.Sh HISTORY
+The
+.Fn fsync
+system call appeared in
+.Bx 4.2 .
+The
+.Fn fdatasync
+system call appeared in
+.Fx 11.1 .
+.Sh BUGS
+The
+.Fn fdatasync
+system call currently does not guarantee that enqueued
+.Xr aio 4
+requests for the file referenced by
+.Fa fd
+are completed before the syscall returns.
diff --git a/lib/libsys/getdirentries.2 b/lib/libsys/getdirentries.2
new file mode 100644
index 000000000000..202ae133f548
--- /dev/null
+++ b/lib/libsys/getdirentries.2
@@ -0,0 +1,211 @@
+.\" Copyright (c) 1989, 1991, 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.
+.\"
+.Dd July 8, 2025
+.Dt GETDIRENTRIES 2
+.Os
+.Sh NAME
+.Nm getdirentries ,
+.Nm getdents
+.Nd "get directory entries in a file system independent format"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In dirent.h
+.Ft ssize_t
+.Fn getdirentries "int fd" "char *buf" "size_t nbytes" "off_t *basep"
+.Ft ssize_t
+.Fn getdents "int fd" "char *buf" "size_t nbytes"
+.Sh DESCRIPTION
+The
+.Fn getdirentries
+and
+.Fn getdents
+system calls read directory entries from the directory
+referenced by the file descriptor
+.Fa fd
+into the buffer pointed to by
+.Fa buf ,
+in a file system independent format.
+Up to
+.Fa nbytes
+of data will be transferred.
+The
+.Fa nbytes
+argument must be greater than or equal to the
+block size associated with the file,
+see
+.Xr stat 2 .
+Some file systems may not support these system calls
+with buffers smaller than this size.
+.Pp
+The data in the buffer is a series of
+.Vt dirent
+structures each containing the following entries:
+.Bd -literal -offset indent
+ino_t d_fileno;
+off_t d_off;
+uint16_t d_reclen;
+uint8_t d_type;
+uint16_t d_namlen;
+char d_name[MAXNAMLEN + 1]; /* see below */
+.Ed
+.Pp
+The
+.Fa d_fileno
+entry is a number which is unique for each
+distinct file in the file system.
+Files that are linked by hard links (see
+.Xr link 2 )
+have the same
+.Fa d_fileno .
+The
+.Fa d_off
+field returns a cookie which, if non-zero, can be used with
+.Xr lseek 2
+to position the directory descriptor to the next entry.
+The
+.Fa d_reclen
+entry is the length, in bytes, of the directory record.
+The
+.Fa d_type
+entry is the type of the file pointed to by the directory record.
+The file type values are defined in
+.Fa <sys/dirent.h> .
+The
+.Fa d_name
+entry contains a null terminated file name.
+The
+.Fa d_namlen
+entry specifies the length of the file name excluding the null byte.
+Thus the actual size of
+.Fa d_name
+may vary from 1 to
+.Dv MAXNAMLEN
+\&+ 1.
+.Pp
+Entries may be separated by extra space.
+The
+.Fa d_reclen
+entry may be used as an offset from the start of a
+.Fa dirent
+structure to the next structure, if any.
+.Pp
+The actual number of bytes transferred is returned.
+The current position pointer associated with
+.Fa fd
+is set to point to the next block of entries.
+The pointer may not advance by the number of bytes returned by
+.Fn getdirentries
+or
+.Fn getdents .
+A value of zero is returned when
+the end of the directory has been reached.
+.Pp
+If the
+.Fa basep
+pointer value is non-NULL,
+the
+.Fn getdirentries
+system call writes the position of the block read into the location pointed to by
+.Fa basep .
+Alternatively, the current position pointer may be set and retrieved by
+.Xr lseek 2 .
+The current position pointer should only be set to a value returned by
+.Xr lseek 2 ,
+a value returned in the location pointed to by
+.Fa basep
+.Po Fn getdirentries
+only
+.Pc ,
+a value returned in the
+.Fa d_off
+field if it is non-zero,
+or zero.
+.Sh IMPLEMENTATION NOTES
+The
+.Fa d_off
+field is currently set to 0 by the NFS client, since the
+directory offset cookies returned by an NFS server cannot
+be used by
+.Xr lseek 2
+at this time.
+.Sh RETURN VALUES
+If successful, the number of bytes actually transferred is returned.
+Otherwise, -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn getdirentries
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid file descriptor open for reading.
+.It Bq Er EFAULT
+Either
+.Fa buf
+or non-NULL
+.Fa basep
+point outside the allocated address space.
+.It Bq Er EINVAL
+The value of
+.Fa nbytes
+is too small for returning a directory entry or block of entries,
+or the current position pointer is invalid.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ENOENT
+Directory unlinked but still open.
+.It Bq Er ENOTDIR
+The file referenced by
+.Fa fd
+is not a directory.
+.El
+.Sh SEE ALSO
+.Xr lseek 2 ,
+.Xr open 2 ,
+.Xr directory 3 ,
+.Xr dir 5
+.Sh HISTORY
+The
+.Fn getdirentries
+system call first appeared in
+.Bx 4.4 .
+The
+.Fn getdents
+system call first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/getdtablesize.2 b/lib/libsys/getdtablesize.2
new file mode 100644
index 000000000000..c4504bcd7a35
--- /dev/null
+++ b/lib/libsys/getdtablesize.2
@@ -0,0 +1,59 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd April 24, 2013
+.Dt GETDTABLESIZE 2
+.Os
+.Sh NAME
+.Nm getdtablesize
+.Nd get file descriptor limit
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn getdtablesize void
+.Sh DESCRIPTION
+The
+.Fn getdtablesize
+system call returns the maximum number of file descriptors
+that the current process may open.
+The maximum file descriptor number that the system may assign
+is the return value minus one.
+Existing file descriptor numbers may be higher
+if the limit was lowered after they were opened.
+.Sh SEE ALSO
+.Xr close 2 ,
+.Xr closefrom 2 ,
+.Xr dup 2 ,
+.Xr getrlimit 2 ,
+.Xr sysconf 3
+.Sh HISTORY
+The
+.Fn getdtablesize
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/getfh.2 b/lib/libsys/getfh.2
new file mode 100644
index 000000000000..d16a34da4f28
--- /dev/null
+++ b/lib/libsys/getfh.2
@@ -0,0 +1,232 @@
+.\" Copyright (c) 1989, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\" Copyright (c) 2018 Gandi
+.\"
+.\" 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.
+.\"
+.Dd November 30, 2022
+.Dt GETFH 2
+.Os
+.Sh NAME
+.Nm getfh ,
+.Nm lgetfh ,
+.Nm getfhat
+.Nd get file handle
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/mount.h
+.Ft int
+.Fn getfh "const char *path" "fhandle_t *fhp"
+.Ft int
+.Fn lgetfh "const char *path" "fhandle_t *fhp"
+.Ft int
+.Fn getfhat "int fd" "const char *path" "fhandle_t *fhp" "int flag"
+.Sh DESCRIPTION
+The
+.Fn getfh
+system call
+returns a file handle for the specified file or directory
+in the file handle pointed to by
+.Fa fhp .
+.Pp
+The
+.Fn lgetfh
+system call is like
+.Fn getfh
+except in the case where the named file is a symbolic link,
+in which case
+.Fn lgetfh
+returns information about the link,
+while
+.Fn getfh
+returns information about the file the link references.
+.Pp
+The
+.Fn getfhat
+system call is equivalent to
+.Fn getfh
+and
+.Fn lgetfh
+except when the
+.Fa path
+specifies a relative path.
+For
+.Fn getfhat
+and relative
+.Fa path ,
+the status is retrieved from a file relative to
+the directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+.Pp
+The values for the
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from this list,
+defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, the status of the symbolic link is returned.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.El
+.Pp
+If
+.Fn getfhat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn getfth
+or
+.Fn lgetfh
+respectively, depending on whether or not the
+.Dv AT_SYMLINK_NOFOLLOW
+bit is set in
+.Fa flag .
+.Pp
+When
+.Fn getfhat
+is called with an absolute
+.Fa path ,
+it ignores the
+.Fa fd
+argument.
+.Pp
+These system calls are restricted to the superuser.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn getfh
+and
+.Fn lgetfh
+system calls
+fail if one or more of the following are true:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The caller does not have appropriate privilege to perform the operation.
+.It Bq Er ENOTDIR
+A component of the path prefix of
+.Fa path
+is not a directory.
+.It Bq Er ENAMETOOLONG
+The length of a component of
+.Fa path
+exceeds 255 characters,
+or the length of
+.Fa path
+exceeds 1023 characters.
+.It Bq Er ENOENT
+The file referred to by
+.Fa path
+does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix of
+.Fa path .
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating
+.Fa path .
+.It Bq Er EFAULT
+The
+.Fa fhp
+argument
+points to an invalid address.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points to an invalid address.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ESTALE
+The file handle
+.Fa fhp
+is no longer valid.
+.El
+.Pp
+In addition to the errors returned by
+.Fn getfh ,
+and
+.Fn lgetfh ,
+the
+.Fn getfhat
+system call may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument, is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr fhopen 2 ,
+.Xr open 2 ,
+.Xr stat 2
+.Sh HISTORY
+The
+.Fn getfh
+system call first appeared in
+.Bx 4.4 .
+The
+.Fn lgetfh
+system call first appeared in
+.Fx 5.3 .
+The
+.Fn getfhat
+system call first appeared in
+.Fx 12.1 .
diff --git a/lib/libsys/getfsstat.2 b/lib/libsys/getfsstat.2
new file mode 100644
index 000000000000..91a3a10117dc
--- /dev/null
+++ b/lib/libsys/getfsstat.2
@@ -0,0 +1,129 @@
+.\" Copyright (c) 1989, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt GETFSSTAT 2
+.Os
+.Sh NAME
+.Nm getfsstat
+.Nd get list of all mounted file systems
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/ucred.h
+.In sys/mount.h
+.Ft int
+.Fn getfsstat "struct statfs *buf" "long bufsize" "int mode"
+.Sh DESCRIPTION
+The
+.Fn getfsstat
+system call
+returns information about all mounted file systems.
+The
+.Fa buf
+argument
+is a pointer to
+.Vt statfs
+structures, as described in
+.Xr statfs 2 .
+.Pp
+Fields that are undefined for a particular file system are set to -1.
+The buffer is filled with an array of
+.Fa statfs
+structures, one for each mounted file system
+up to the byte count specified by
+.Fa bufsize .
+Note, the
+.Fa bufsize
+argument is the number of bytes that
+.Fa buf
+can hold, not the count of statfs structures it will hold.
+.Pp
+If
+.Fa buf
+is given as NULL,
+.Fn getfsstat
+returns just the number of mounted file systems.
+.Pp
+Normally
+.Fa mode
+should be specified as
+.Dv MNT_WAIT .
+If
+.Fa mode
+is set to
+.Dv MNT_NOWAIT ,
+.Fn getfsstat
+will return the information it has available without requesting
+an update from each file system.
+Thus, some of the information will be out of date, but
+.Fn getfsstat
+will not block waiting for information from a file system that is
+unable to respond.
+It will also skip any file system that is in the process of being
+unmounted, even if the unmount would eventually fail.
+.Sh RETURN VALUES
+Upon successful completion, the number of
+.Fa statfs
+structures is returned.
+Otherwise, -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn getfsstat
+system call
+fails if one or more of the following are true:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa buf
+argument
+points to an invalid address.
+.It Bq Er EINVAL
+.Fa mode
+is set to a value other than
+.Dv MNT_WAIT
+or
+.Dv MNT_NOWAIT .
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Sh SEE ALSO
+.Xr statfs 2 ,
+.Xr fstab 5 ,
+.Xr mount 8
+.Sh HISTORY
+The
+.Fn getfsstat
+system call first appeared in
+.Bx 4.4 .
diff --git a/lib/libsys/getgid.2 b/lib/libsys/getgid.2
new file mode 100644
index 000000000000..ea10e8322d1f
--- /dev/null
+++ b/lib/libsys/getgid.2
@@ -0,0 +1,82 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd May 1, 2020
+.Dt GETGID 2
+.Os
+.Sh NAME
+.Nm getgid ,
+.Nm getegid
+.Nd get group process identification
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft gid_t
+.Fn getgid void
+.Ft gid_t
+.Fn getegid void
+.Sh DESCRIPTION
+The
+.Fn getgid
+system call returns the real group ID of the calling process,
+.Fn getegid
+returns the effective group ID of the calling process.
+.Pp
+The real group ID is specified at login time.
+.Pp
+The real group ID is the group of the user who invoked the program.
+As the effective group ID gives the process additional permissions
+during the execution of
+.Dq Em set-group-ID
+mode processes,
+.Fn getgid
+is used to determine the real-user-id of the calling process.
+.Sh ERRORS
+The
+.Fn getgid
+and
+.Fn getegid
+system calls are always successful, and no return value is reserved to
+indicate an error.
+.Sh SEE ALSO
+.Xr getuid 2 ,
+.Xr issetugid 2 ,
+.Xr setgid 2 ,
+.Xr setregid 2
+.Sh STANDARDS
+The
+.Fn getgid
+and
+.Fn getegid
+system calls are expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn getgid
+function appeared in
+.At v4 .
diff --git a/lib/libsys/getgroups.2 b/lib/libsys/getgroups.2
new file mode 100644
index 000000000000..91cca2748ec2
--- /dev/null
+++ b/lib/libsys/getgroups.2
@@ -0,0 +1,104 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd January 21, 2011
+.Dt GETGROUPS 2
+.Os
+.Sh NAME
+.Nm getgroups
+.Nd get group access list
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn getgroups "int gidsetlen" "gid_t *gidset"
+.Sh DESCRIPTION
+The
+.Fn getgroups
+system call
+gets the current group access list of the user process
+and stores it in the array
+.Fa gidset .
+The
+.Fa gidsetlen
+argument
+indicates the number of entries that may be placed in
+.Fa gidset .
+The
+.Fn getgroups
+system call
+returns the actual number of groups returned in
+.Fa gidset .
+At least one and as many as {NGROUPS_MAX}+1 values may be returned.
+If
+.Fa gidsetlen
+is zero,
+.Fn getgroups
+returns the number of supplementary group IDs associated with
+the calling process without modifying the array pointed to by
+.Fa gidset .
+.Pp
+The value of
+.Dv {NGROUPS_MAX}
+should be obtained using
+.Xr sysconf 3
+to avoid hard-coding it into the executable.
+.Sh RETURN VALUES
+A successful call returns the number of groups in the group set.
+A value of -1 indicates that an error occurred, and the error
+code is stored in the global variable
+.Va errno .
+.Sh ERRORS
+The possible errors for
+.Fn getgroups
+are:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The argument
+.Fa gidsetlen
+is smaller than the number of groups in the group set.
+.It Bq Er EFAULT
+The argument
+.Fa gidset
+specifies
+an invalid address.
+.El
+.Sh SEE ALSO
+.Xr setgroups 2 ,
+.Xr initgroups 3 ,
+.Xr sysconf 3
+.Sh STANDARDS
+The
+.Fn getgroups
+system call conforms to
+.St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Fn getgroups
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/getitimer.2 b/lib/libsys/getitimer.2
new file mode 100644
index 000000000000..2d137d00d8c1
--- /dev/null
+++ b/lib/libsys/getitimer.2
@@ -0,0 +1,192 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd May 1, 2020
+.Dt GETITIMER 2
+.Os
+.Sh NAME
+.Nm getitimer ,
+.Nm setitimer
+.Nd get/set value of interval timer
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/time.h
+.Fd "#define ITIMER_REAL 0"
+.Fd "#define ITIMER_VIRTUAL 1"
+.Fd "#define ITIMER_PROF 2"
+.Ft int
+.Fn getitimer "int which" "struct itimerval *value"
+.Ft int
+.Fn setitimer "int which" "const struct itimerval *value" "struct itimerval *ovalue"
+.Sh DESCRIPTION
+The system provides each process with three interval timers,
+defined in
+.In sys/time.h .
+The
+.Fn getitimer
+system call returns the current value for the timer specified in
+.Fa which
+in the structure at
+.Fa value .
+The
+.Fn setitimer
+system call sets a timer to the specified
+.Fa value
+(returning the previous value of the timer if
+.Fa ovalue
+is not a null pointer).
+.Pp
+A timer value is defined by the
+.Fa itimerval
+structure:
+.Bd -literal -offset indent
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+.Ed
+.Pp
+If
+.Fa it_value
+is non-zero, it indicates the time to the next timer expiration.
+If
+.Fa it_interval
+is non-zero, it specifies a value to be used in reloading
+.Fa it_value
+when the timer expires.
+Setting
+.Fa it_value
+to 0 disables a timer, regardless of the value of
+.Fa it_interval .
+Setting
+.Fa it_interval
+to 0 causes a timer to be disabled after its next expiration (assuming
+.Fa it_value
+is non-zero).
+.Pp
+Time values smaller than the resolution of the
+system clock are rounded up to this resolution
+(typically 10 milliseconds).
+.Pp
+The
+.Dv ITIMER_REAL
+timer decrements in real time.
+A
+.Dv SIGALRM
+signal is
+delivered when this timer expires.
+.Pp
+The
+.Dv ITIMER_VIRTUAL
+timer decrements in process virtual time.
+It runs only when the process is executing.
+A
+.Dv SIGVTALRM
+signal
+is delivered when it expires.
+.Pp
+The
+.Dv ITIMER_PROF
+timer decrements both in process virtual time and
+when the system is running on behalf of the process.
+It is designed
+to be used by interpreters in statistically profiling the execution
+of interpreted programs.
+Each time the
+.Dv ITIMER_PROF
+timer expires, the
+.Dv SIGPROF
+signal is
+delivered.
+Because this signal may interrupt in-progress
+system calls, programs using this timer must be prepared to
+restart interrupted system calls.
+.Pp
+The maximum number of seconds allowed for
+.Fa it_interval
+and
+.Fa it_value
+in
+.Fn setitimer
+is 100000000.
+.Sh NOTES
+Three macros for manipulating time values are defined in
+.In sys/time.h .
+The
+.Fn timerclear
+macro
+sets a time value to zero,
+.Fn timerisset
+tests if a time value is non-zero, and
+.Fn timercmp
+compares two time values.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn getitimer
+and
+.Fn setitimer
+system calls
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa value
+argument specified a bad address.
+.It Bq Er EINVAL
+The
+.Fa value
+argument specified a time that was too large
+to be handled.
+.El
+.Sh SEE ALSO
+.Xr gettimeofday 2 ,
+.Xr select 2 ,
+.Xr sigaction 2 ,
+.Xr clocks 7
+.Sh STANDARDS
+The
+.Fn getitimer
+and
+.Fn setitimer
+functions conform to
+.St -p1003.1-2001 .
+The later
+.St -p1003.1-2008
+revision however marked both functions as obsolescent,
+recommending the use of
+.Xr timer_gettime 2
+and
+.Xr timer_settime 2
+instead.
+.Sh HISTORY
+The
+.Fn getitimer
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/getlogin.2 b/lib/libsys/getlogin.2
new file mode 100644
index 000000000000..86583f6ae846
--- /dev/null
+++ b/lib/libsys/getlogin.2
@@ -0,0 +1,201 @@
+.\" Copyright (c) 1989, 1991, 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.
+.\"
+.Dd September 9, 2020
+.Dt GETLOGIN 2
+.Os
+.Sh NAME
+.Nm getlogin ,
+.Nm getlogin_r ,
+.Nm setlogin
+.Nd get/set login name
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft char *
+.Fn getlogin void
+.In sys/param.h
+.Ft int
+.Fn getlogin_r "char *name" "size_t len"
+.Ft int
+.Fn setlogin "const char *name"
+.Sh DESCRIPTION
+The
+.Fn getlogin
+routine
+returns the login name of the user associated with the current session,
+as previously set by
+.Fn setlogin .
+The name is normally associated with a login shell
+at the time a session is created,
+and is inherited by all processes descended from the login shell.
+(This is true even if some of those processes assume another user ID,
+for example when
+.Xr su 1
+is used).
+.Pp
+The
+.Fn getlogin_r
+function
+provides the same service as
+.Fn getlogin
+except the caller must provide the buffer
+.Fa name
+with length
+.Fa len
+bytes
+to hold the result.
+The buffer should be at least
+.Dv MAXLOGNAME
+bytes in length.
+.Pp
+The
+.Fn setlogin
+system call
+sets the login name of the user associated with the current session to
+.Fa name .
+This system call is restricted to the super-user, and
+is normally used only when a new session is being created on behalf
+of the named user
+(for example, at login time, or when a remote shell is invoked).
+.Pp
+.Em NOTE :
+There is only one login name per session.
+.Pp
+It is
+.Em CRITICALLY
+important to ensure that
+.Fn setlogin
+is only ever called after the process has taken adequate steps to ensure
+that it is detached from its parent's session.
+Making a
+.Fn setsid
+system call is the
+.Em ONLY
+way to do this.
+The
+.Xr daemon 3
+function calls
+.Fn setsid
+which is an ideal way of detaching from a controlling terminal and
+forking into the background.
+.Pp
+In particular, doing a
+.Fn ioctl ttyfd TIOCNOTTY ...\&
+or
+.Fn setpgrp ...\&
+is
+.Em NOT
+sufficient.
+.Pp
+Once a parent process does a
+.Fn setsid
+system call, it is acceptable for some child of that process to then do a
+.Fn setlogin
+even though it is not the session leader, but beware that ALL processes
+in the session will change their login name at the same time, even the
+parent.
+.Pp
+This is not the same as the traditional UNIX behavior of inheriting privilege.
+.Pp
+Since the
+.Fn setlogin
+system call is restricted to the super-user, it is assumed that (like
+all other privileged programs) the programmer has taken adequate
+precautions to prevent security violations.
+.Sh RETURN VALUES
+If a call to
+.Fn getlogin
+succeeds, it returns a pointer to a null-terminated string in a static buffer,
+or
+.Dv NULL
+if the name has not been set.
+The
+.Fn getlogin_r
+function
+returns zero if successful, or the error number upon failure.
+.Pp
+.Rv -std setlogin
+.Sh ERRORS
+The following errors may be returned by these calls:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa name
+argument gave an
+invalid address.
+.It Bq Er EINVAL
+The
+.Fa name
+argument
+pointed to a string that was too long.
+Login names are limited to
+.Dv MAXLOGNAME
+(from
+.In sys/param.h )
+characters, currently 33 including null.
+.It Bq Er EPERM
+The caller tried to set the login name and was not the super-user.
+.It Bq Er ERANGE
+The size of the buffer is smaller than the result to be returned.
+.El
+.Sh SEE ALSO
+.Xr setsid 2 ,
+.Xr daemon 3
+.Sh STANDARDS
+The
+.Fn getlogin
+system call
+and
+the
+.Fn getlogin_r
+function
+conform to
+.St -p1003.1-96 .
+.Sh HISTORY
+The
+.Fn getlogin
+system call first appeared in
+.Bx 4.4 .
+The return value of
+.Fn getlogin_r
+was changed from earlier versions of
+.Fx
+to be conformant with
+.St -p1003.1-96 .
+.Sh BUGS
+In earlier versions of the system,
+.Fn getlogin
+failed unless the process was associated with a login terminal.
+The current implementation (using
+.Fn setlogin )
+allows getlogin to succeed even when the process has no controlling terminal.
+In earlier versions of the system, the value returned by
+.Fn getlogin
+could not be trusted without checking the user ID.
+Portable programs should probably still make this check.
diff --git a/lib/libc/sys/getloginclass.2 b/lib/libsys/getloginclass.2
index e44428aeece5..e44428aeece5 100644
--- a/lib/libc/sys/getloginclass.2
+++ b/lib/libsys/getloginclass.2
diff --git a/lib/libsys/getpagesize.3 b/lib/libsys/getpagesize.3
new file mode 100644
index 000000000000..4828e654265b
--- /dev/null
+++ b/lib/libsys/getpagesize.3
@@ -0,0 +1,67 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd October 17, 2022
+.Dt GETPAGESIZE 3
+.Os
+.Sh NAME
+.Nm getpagesize
+.Nd get system page size
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn getpagesize void
+.Sh DESCRIPTION
+The
+.Fn getpagesize
+function
+returns the number of bytes in a page.
+Page granularity is the granularity of many of the memory
+management calls.
+.Pp
+The page size is a system
+page size and may not be the same as the underlying
+hardware page size.
+.Pp
+.St -p1003.1-2001
+removed
+.Nm .
+Portable applications should use
+.Ql sysconf(_SC_PAGESIZE)
+instead.
+.Sh SEE ALSO
+.Xr pagesize 1 ,
+.Xr sbrk 2 ,
+.Xr getpagesizes 3 ,
+.Xr sysconf 3
+.Sh HISTORY
+The
+.Fn getpagesize
+function appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/getpagesize.c b/lib/libsys/getpagesize.c
new file mode 100644
index 000000000000..23d2c6ea5eda
--- /dev/null
+++ b/lib/libsys/getpagesize.c
@@ -0,0 +1,51 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1989, 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.
+ */
+
+#include <sys/param.h>
+#include <sys/auxv.h>
+
+#include "libc_private.h"
+
+/*
+ * NB: This function may be called from malloc(3) at initialization
+ * NB: so must not result in a malloc(3) related call!
+ */
+
+int
+getpagesize(void)
+{
+ int value;
+
+ if (_elf_aux_info(AT_PAGESZ, &value, sizeof(value)) != 0)
+ value = PAGE_SIZE;
+
+ return (value);
+}
diff --git a/lib/libc/gen/getpagesizes.3 b/lib/libsys/getpagesizes.3
index e00a1be7c550..e00a1be7c550 100644
--- a/lib/libc/gen/getpagesizes.3
+++ b/lib/libsys/getpagesizes.3
diff --git a/lib/libsys/getpagesizes.c b/lib/libsys/getpagesizes.c
new file mode 100644
index 000000000000..7f481f84177a
--- /dev/null
+++ b/lib/libsys/getpagesizes.c
@@ -0,0 +1,75 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2009 Alan L. Cox <alc@cs.rice.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 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.
+ */
+
+#include <sys/param.h>
+#include <sys/auxv.h>
+#include <sys/errno.h>
+
+#include "libc_private.h"
+
+/*
+ * Retrieves page size information from the system. Specifically, returns the
+ * number of distinct page sizes that are supported by the system, if
+ * "pagesize" is NULL and "nelem" is 0. Otherwise, assigns up to "nelem" of
+ * the system-supported page sizes to consecutive elements of the array
+ * referenced by "pagesize", and returns the number of such page sizes that it
+ * assigned to the array. These page sizes are expressed in bytes.
+ *
+ * The implementation of this function does not directly or indirectly call
+ * malloc(3) or any other dynamic memory allocator that may itself call this
+ * function.
+ */
+int
+getpagesizes(size_t pagesize[], int nelem)
+{
+ static u_long ps[MAXPAGESIZES];
+ static int nops;
+ int i;
+
+ if (nelem < 0 || (nelem > 0 && pagesize == NULL)) {
+ errno = EINVAL;
+ return (-1);
+ }
+ /* Cache the result */
+ if (nops == 0) {
+ if (_elf_aux_info(AT_PAGESIZES, ps, sizeof(ps)) != 0)
+ ps[0] = PAGE_SIZE;
+ /* Count the number of page sizes that are supported. */
+ nops = nitems(ps);
+ while (nops > 0 && ps[nops - 1] == 0)
+ nops--;
+ }
+ if (pagesize == NULL)
+ return (nops);
+ /* Return up to "nelem" page sizes from the cached result. */
+ if (nelem > nops)
+ nelem = nops;
+ for (i = 0; i < nelem; i++)
+ pagesize[i] = ps[i];
+ return (nelem);
+}
diff --git a/lib/libsys/getpeername.2 b/lib/libsys/getpeername.2
new file mode 100644
index 000000000000..983436dd3230
--- /dev/null
+++ b/lib/libsys/getpeername.2
@@ -0,0 +1,95 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd June 4, 1993
+.Dt GETPEERNAME 2
+.Os
+.Sh NAME
+.Nm getpeername
+.Nd get name of connected peer
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fn getpeername "int s" "struct sockaddr * restrict name" "socklen_t * restrict namelen"
+.Sh DESCRIPTION
+The
+.Fn getpeername
+system call
+returns the name of the peer connected to
+socket
+.Fa s .
+The
+.Fa namelen
+argument should be initialized to indicate
+the amount of space pointed to by
+.Fa name .
+On return it contains the actual size of the name
+returned (in bytes).
+The name is truncated if the buffer provided is too small.
+.Sh RETURN VALUES
+.Rv -std getpeername
+.Sh ERRORS
+The call succeeds unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The argument
+.Fa s
+is not a valid descriptor.
+.It Bq Er ECONNRESET
+The connection has been reset by the peer.
+.It Bq Er EINVAL
+The value of the
+.Fa namelen
+argument is not valid.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is a file, not a socket.
+.It Bq Er ENOTCONN
+The socket is not connected.
+.It Bq Er ENOBUFS
+Insufficient resources were available in the system
+to perform the operation.
+.It Bq Er EFAULT
+The
+.Fa name
+argument points to memory not in a valid part of the
+process address space.
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr bind 2 ,
+.Xr getsockname 2 ,
+.Xr socket 2
+.Sh HISTORY
+The
+.Fn getpeername
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/getpgrp.2 b/lib/libsys/getpgrp.2
new file mode 100644
index 000000000000..3b69d8486941
--- /dev/null
+++ b/lib/libsys/getpgrp.2
@@ -0,0 +1,139 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd June 4, 1993
+.Dt GETPGRP 2
+.Os
+.Sh NAME
+.Nm getpgrp
+.Nd get process group
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft pid_t
+.Fn getpgrp void
+.Ft pid_t
+.Fn getpgid "pid_t pid"
+.Sh DESCRIPTION
+The process group of the current process is returned by
+.Fn getpgrp .
+The process group of the process identified by
+.Fa pid
+is returned by
+.Fn getpgid .
+If
+.Fa pid
+is zero,
+.Fn getpgid
+returns the process group of the current process.
+.Pp
+Process groups are used for distribution of signals, and
+by terminals to arbitrate requests for their input: processes
+that have the same process group as the terminal are foreground
+and may read, while others will block with a signal if they attempt
+to read.
+.Pp
+This system call is thus used by programs such as
+.Xr csh 1
+to create
+process groups
+in implementing job control.
+The
+.Fn tcgetpgrp
+and
+.Fn tcsetpgrp
+calls
+are used to get/set the process group of the control terminal.
+.Sh RETURN VALUES
+The
+.Fn getpgrp
+system call always succeeds.
+Upon successful completion, the
+.Fn getpgid
+system call returns the process group of the specified process;
+otherwise, it returns a value of \-1 and sets
+.Va errno
+to indicate the error.
+.Sh COMPATIBILITY
+This version of
+.Fn getpgrp
+differs from past Berkeley versions by not taking a
+.Fa "pid_t pid"
+argument.
+This incompatibility is required by
+.St -p1003.1-90 .
+.Pp
+From the
+.St -p1003.1-90
+Rationale:
+.Pp
+.Bx 4.3
+provides a
+.Fn getpgrp
+system call that returns the process group ID for a specified process.
+Although this function is used to support job control, all known
+job-control shells always specify the calling process with this
+function.
+Thus, the simpler
+.At V
+.Fn getpgrp
+suffices, and the added complexity of the
+.Bx 4.3
+.Fn getpgrp
+has been omitted from POSIX.1.
+The old functionality is available from the
+.Fn getpgid
+system call.
+.Sh ERRORS
+The
+.Fn getpgid
+system call
+will succeed unless:
+.Bl -tag -width Er
+.It Bq Er ESRCH
+there is no process whose process ID equals
+.Fa pid
+.El
+.Sh SEE ALSO
+.Xr getsid 2 ,
+.Xr setpgid 2 ,
+.Xr termios 4
+.Sh STANDARDS
+The
+.Fn getpgrp
+system call is expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn getpgrp
+system call appeared in
+.Bx 4.0 .
+The
+.Fn getpgid
+system call is derived from its usage in
+.At V.4 .
diff --git a/lib/libsys/getpid.2 b/lib/libsys/getpid.2
new file mode 100644
index 000000000000..4dc1940091e7
--- /dev/null
+++ b/lib/libsys/getpid.2
@@ -0,0 +1,87 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd December 15, 2015
+.Dt GETPID 2
+.Os
+.Sh NAME
+.Nm getpid ,
+.Nm getppid
+.Nd get parent or calling process identification
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft pid_t
+.Fn getpid void
+.Ft pid_t
+.Fn getppid void
+.Sh DESCRIPTION
+The
+.Fn getpid
+system call
+returns
+the process ID of
+the calling process.
+Though the ID is guaranteed to be unique, it should
+.Em NOT
+be used for constructing temporary file names, for
+security reasons; see
+.Xr mkstemp 3
+instead.
+.Pp
+The
+.Fn getppid
+system call
+returns the process ID of the parent
+of the calling process.
+.Sh ERRORS
+The
+.Fn getpid
+and
+.Fn getppid
+system calls are always successful, and no return value is reserved to
+indicate an error.
+.Sh SEE ALSO
+.Xr fork 2 ,
+.Xr getpgrp 2 ,
+.Xr kill 2 ,
+.Xr setpgid 2 ,
+.Xr setsid 2 ,
+.Xr exec 3
+.Sh STANDARDS
+The
+.Fn getpid
+and
+.Fn getppid
+system calls are expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn getpid
+function appeared in
+.At v7 .
diff --git a/lib/libsys/getpriority.2 b/lib/libsys/getpriority.2
new file mode 100644
index 000000000000..a044f1c628c8
--- /dev/null
+++ b/lib/libsys/getpriority.2
@@ -0,0 +1,147 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd June 4, 1993
+.Dt GETPRIORITY 2
+.Os
+.Sh NAME
+.Nm getpriority ,
+.Nm setpriority
+.Nd get/set program scheduling priority
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/time.h
+.In sys/resource.h
+.Ft int
+.Fn getpriority "int which" "int who"
+.Ft int
+.Fn setpriority "int which" "int who" "int prio"
+.Sh DESCRIPTION
+The scheduling
+priority of the process, process group, or user, as indicated by
+.Fa which
+and
+.Fa who
+is obtained with the
+.Fn getpriority
+system call and set with the
+.Fn setpriority
+system call.
+The
+.Fa which
+argument
+is one of
+.Dv PRIO_PROCESS ,
+.Dv PRIO_PGRP ,
+or
+.Dv PRIO_USER ,
+and
+.Fa who
+is interpreted relative to
+.Fa which
+(a process identifier for
+.Dv PRIO_PROCESS ,
+process group
+identifier for
+.Dv PRIO_PGRP ,
+and a user ID for
+.Dv PRIO_USER ) .
+A zero value of
+.Fa who
+denotes the current process, process group, or user.
+The
+.Fa prio
+argument
+is a value in the range -20 to 20.
+The default priority is 0;
+lower priorities cause more favorable scheduling.
+.Pp
+The
+.Fn getpriority
+system call returns the highest priority (lowest numerical value)
+enjoyed by any of the specified processes.
+The
+.Fn setpriority
+system call sets the priorities of all of the specified processes
+to the specified value.
+Only the super-user may lower priorities.
+.Sh RETURN VALUES
+Since
+.Fn getpriority
+can legitimately return the value -1, it is necessary
+to clear the external variable
+.Va errno
+prior to the
+call, then check it afterward to determine
+if a -1 is an error or a legitimate value.
+.Pp
+.Rv -std setpriority
+.Sh ERRORS
+The
+.Fn getpriority
+and
+.Fn setpriority
+system calls
+will fail if:
+.Bl -tag -width Er
+.It Bq Er ESRCH
+No process was located using the
+.Fa which
+and
+.Fa who
+values specified.
+.It Bq Er EINVAL
+The
+.Fa which
+argument
+was not one of
+.Dv PRIO_PROCESS ,
+.Dv PRIO_PGRP ,
+or
+.Dv PRIO_USER .
+.El
+.Pp
+In addition to the errors indicated above,
+.Fn setpriority
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+A process was located, but neither its effective nor real user
+ID matched the effective user ID of the caller.
+.It Bq Er EACCES
+A non super-user attempted to lower a process priority.
+.El
+.Sh SEE ALSO
+.Xr nice 1 ,
+.Xr fork 2 ,
+.Xr renice 8
+.Sh HISTORY
+The
+.Fn getpriority
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libc/sys/getrandom.2 b/lib/libsys/getrandom.2
index 37b5ce7d22be..37b5ce7d22be 100644
--- a/lib/libc/sys/getrandom.2
+++ b/lib/libsys/getrandom.2
diff --git a/lib/libsys/getrlimit.2 b/lib/libsys/getrlimit.2
new file mode 100644
index 000000000000..d54dc703ada0
--- /dev/null
+++ b/lib/libsys/getrlimit.2
@@ -0,0 +1,242 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd July 25, 2024
+.Dt GETRLIMIT 2
+.Os
+.Sh NAME
+.Nm getrlimit ,
+.Nm setrlimit
+.Nd control maximum system resource consumption
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/time.h
+.In sys/resource.h
+.Ft int
+.Fn getrlimit "int resource" "struct rlimit *rlp"
+.Ft int
+.Fn setrlimit "int resource" "const struct rlimit *rlp"
+.Sh DESCRIPTION
+Limits on the consumption of system resources by the current process
+and each process it creates may be obtained with the
+.Fn getrlimit
+system call, and set with the
+.Fn setrlimit
+system call.
+.Pp
+The
+.Fa resource
+argument is one of the following:
+.Bl -tag -width RLIMIT_FSIZEAA
+.It Dv RLIMIT_AS
+The maximum amount (in bytes) of virtual memory the process is
+allowed to map.
+.It Dv RLIMIT_CORE
+The largest size (in bytes)
+.Xr core 5
+file that may be created.
+.It Dv RLIMIT_CPU
+The maximum amount of cpu time (in seconds) to be used by
+each process.
+.It Dv RLIMIT_DATA
+The maximum size (in bytes) of the data segment for a process;
+this defines how far a program may extend its break with the
+.Xr sbrk 2
+function.
+.It Dv RLIMIT_FSIZE
+The largest size (in bytes) file that may be created.
+.It Dv RLIMIT_KQUEUES
+The maximum number of kqueues this user id is allowed to create.
+.It Dv RLIMIT_MEMLOCK
+The maximum size (in bytes) which a process may lock into memory
+using the
+.Xr mlock 2
+system call.
+.It Dv RLIMIT_NOFILE
+The maximum number of open files for this process.
+.It Dv RLIMIT_NPROC
+The maximum number of simultaneous processes for this user id.
+.It Dv RLIMIT_NPTS
+The maximum number of pseudo-terminals this user id is allowed to create.
+.It Dv RLIMIT_PIPEBUF
+The maximum total size of in-kernel buffers for bi-directional pipes/fifos
+that this user id is allowed to consume.
+The buffers for kernel FIFOs created on the first open of a filesystem
+object created by
+.Pq Xr mkfifo 2
+are also charged to the user ID of the process opening it,
+not the FIFO's filesystem owner.
+Despite somewhat unexpected, this is in fact fair, since user of the fifo
+is not necessary its creator.
+.It Dv RLIMIT_RSS
+When there is memory pressure and swap is available, prioritize eviction of
+a process' resident pages beyond this amount (in bytes).
+When memory is not under pressure, this rlimit is effectively ignored.
+.Pp
+Processes that exceed their set
+.Dv RLIMIT_RSS
+are not signalled or halted.
+The limit is merely a hint to the VM daemon to prefer to deactivate pages from
+processes that have exceeded their set
+.Dv RLIMIT_RSS .
+.It Dv RLIMIT_SBSIZE
+The maximum size (in bytes) of socket buffer usage for this user.
+This limits the amount of network memory, and hence the amount of
+mbufs, that this user may hold at any time.
+.It Dv RLIMIT_STACK
+The maximum size (in bytes) of the stack segment for a process;
+this defines how far a program's stack segment may be extended.
+Stack extension is performed automatically by the system.
+.It Dv RLIMIT_SWAP
+The maximum size (in bytes) of the swap space that may be reserved or
+used by all of this user id's processes.
+This limit is enforced only if bit 1 of the
+.Va vm.overcommit
+sysctl is set.
+Please see
+.Xr tuning 7
+for a complete description of this sysctl.
+.It Dv RLIMIT_UMTXP
+The limit of the number of process-shared posix thread library objects
+allocated by user id.
+.It Dv RLIMIT_VMEM
+An alias for
+.Dv RLIMIT_AS .
+.El
+.Pp
+A resource limit is specified as a soft limit and a hard limit.
+When a soft limit is exceeded, a process might or might not receive a signal.
+For example, signals are generated when the cpu time or file size is exceeded,
+but not if the address space or RSS limit is exceeded.
+A program that exceeds the soft limit is allowed to continue execution until it
+reaches the hard limit, or modifies its own resource limit.
+Even reaching the hard limit does not necessarily halt a process.
+For example, if the RSS hard limit is exceeded, nothing happens.
+.Pp
+The
+.Vt rlimit
+structure is used to specify the hard and soft limits on a resource.
+.Bd -literal -offset indent
+struct rlimit {
+ rlim_t rlim_cur; /* current (soft) limit */
+ rlim_t rlim_max; /* maximum value for rlim_cur */
+};
+.Ed
+.Pp
+Only the super-user may raise the maximum limits.
+Other users
+may only alter
+.Fa rlim_cur
+within the range from 0 to
+.Fa rlim_max
+or (irreversibly) lower
+.Fa rlim_max .
+.Pp
+An
+.Dq infinite
+value for a limit is defined as
+.Dv RLIM_INFINITY .
+.Pp
+Because this information is stored in the per-process information,
+this system call must be executed directly by the shell if it
+is to affect all future processes created by the shell;
+.Ic limit
+is thus a built-in command to
+.Xr csh 1 .
+.Pp
+The system refuses to extend the data or stack space when the limits
+would be exceeded in the normal way: a
+.Xr brk 2
+function fails if the data space limit is reached.
+When the stack limit is reached, the process receives
+a segmentation fault
+.Pq Dv SIGSEGV ;
+if this signal is not
+caught by a handler using the signal stack, this signal
+will kill the process.
+.Pp
+A file I/O operation that would create a file larger that the process'
+soft limit will cause the write to fail and a signal
+.Dv SIGXFSZ
+to be
+generated; this normally terminates the process, but may be caught.
+When
+the soft cpu time limit is exceeded, a
+.Dv SIGXCPU
+signal is sent to the
+offending process.
+.Pp
+When most operations would allocate more virtual memory than allowed by the
+soft limit of
+.Dv RLIMIT_AS ,
+the operation fails with
+.Dv ENOMEM
+and no signal is raised.
+A notable exception is stack extension, described above.
+If stack extension would allocate more virtual memory than allowed by the soft
+limit of
+.Dv RLIMIT_AS ,
+a
+.Dv SIGSEGV
+signal will be delivered.
+The caller is free to raise the soft address space limit up to the hard limit
+and retry the allocation.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn getrlimit
+and
+.Fn setrlimit
+system calls
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The address specified for
+.Fa rlp
+is invalid.
+.It Bq Er EPERM
+The limit specified to
+.Fn setrlimit
+would have
+raised the maximum limit value, and the caller is not the super-user.
+.El
+.Sh SEE ALSO
+.Xr csh 1 ,
+.Xr quota 1 ,
+.Xr quotactl 2 ,
+.Xr sigaction 2 ,
+.Xr sigaltstack 2 ,
+.Xr sysctl 3 ,
+.Xr ulimit 3
+.Sh HISTORY
+The
+.Fn getrlimit
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/getrlimitusage.2 b/lib/libsys/getrlimitusage.2
new file mode 100644
index 000000000000..e2114def56c2
--- /dev/null
+++ b/lib/libsys/getrlimitusage.2
@@ -0,0 +1,100 @@
+.\" Copyright (c) 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd September 27, 2024
+.Dt GETRLIMITUSAGE 2
+.Os
+.Sh NAME
+.Nm getrlimitusage
+.Nd Query usage of the current process' limited resources
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/resource.h
+.Ft int
+.Fn getrlimitusage "unsigned which" "int flags" "rlim_t *res"
+.Sh DESCRIPTION
+The
+.Nm
+system call allows the process to query current consumption of the resources
+limited by the
+.Xr setrlimit 2
+call.
+.Pp
+The
+.Fa which
+argument specifies the resource, same as for
+.Xr getrlimit 2
+and
+.Xr setrlimit 2
+calls, see their man page for the list of enforced resource types.
+.Pp
+The
+.Fa flags
+argument modifies the behavior of the call in the following ways:
+.Bl -tag -width GETRLIMITUSAGE_XXXXXX
+.It Va GETRLIMITUSAGE_EUID
+Query the resource usage for user identified by effective UID of the process,
+instead of the real UID (which is default for accounting).
+.El
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn getrlimitusage
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The address specified for
+.Fa res
+is invalid.
+.It Bq Er EINVAL
+The resource specified to
+.Fn getrlimitusage
+in the
+.Fa which
+argument is unknown.
+.It Bq Er ENXIO
+The resource specified to
+.Fn getrlimitusage
+in the
+.Fa which
+argument is not accounted, but only enforced in specific situations.
+Examples of such resources are
+.Va RLIMIT_FSIZE
+and
+.Va RLIMIT_CORE .
+.El
+.Sh SEE ALSO
+.Xr procstat 1 ,
+.Xr getrlimit 2 ,
+.Xr setrlimit 2
+.Sh HISTORY
+The
+.Fn getrlimitusage
+system call appeared in
+.Bx 15.0 .
diff --git a/lib/libsys/getrusage.2 b/lib/libsys/getrusage.2
new file mode 100644
index 000000000000..f47960db0c6a
--- /dev/null
+++ b/lib/libsys/getrusage.2
@@ -0,0 +1,183 @@
+.\" Copyright (c) 1985, 1991, 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.
+.\"
+.Dd May 1, 2010
+.Dt GETRUSAGE 2
+.Os
+.Sh NAME
+.Nm getrusage
+.Nd get information about resource utilization
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/time.h
+.In sys/resource.h
+.Fd "#define RUSAGE_SELF 0"
+.Fd "#define RUSAGE_CHILDREN -1"
+.Fd "#define RUSAGE_THREAD 1"
+.Ft int
+.Fn getrusage "int who" "struct rusage *rusage"
+.Sh DESCRIPTION
+The
+.Fn getrusage
+system call
+returns information describing the resources utilized by the current
+thread, the current process, or all its terminated child processes.
+The
+.Fa who
+argument is either
+.Dv RUSAGE_THREAD ,
+.Dv RUSAGE_SELF ,
+or
+.Dv RUSAGE_CHILDREN .
+The buffer to which
+.Fa rusage
+points will be filled in with
+the following structure:
+.Bd -literal
+struct rusage {
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+ long ru_maxrss; /* max resident set size */
+ long ru_ixrss; /* integral shared text memory size */
+ long ru_idrss; /* integral unshared data size */
+ long ru_isrss; /* integral unshared stack size */
+ long ru_minflt; /* page reclaims */
+ long ru_majflt; /* page faults */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary context switches */
+};
+.Ed
+.Pp
+The fields are interpreted as follows:
+.Bl -tag -width ru_minfltaa
+.It Fa ru_utime
+the total amount of time spent executing in user mode.
+.It Fa ru_stime
+the total amount of time spent in the system executing on behalf
+of the process(es).
+.It Fa ru_maxrss
+the maximum resident set size utilized (in kilobytes).
+.It Fa ru_ixrss
+an
+.Dq integral
+value indicating the amount of memory used
+by the text segment
+that was also shared among other processes.
+This value is expressed
+in units of kilobytes * ticks-of-execution.
+Ticks are statistics clock ticks.
+The statistics clock has a frequency of
+.Fn sysconf _SC_CLK_TCK
+ticks per second.
+.It Fa ru_idrss
+an integral value of the amount of unshared memory residing in the
+data segment of a process (expressed in units of
+kilobytes * ticks-of-execution).
+.It Fa ru_isrss
+an integral value of the amount of unshared memory residing in the
+stack segment of a process (expressed in units of
+kilobytes * ticks-of-execution).
+.It Fa ru_minflt
+the number of page faults serviced without any I/O activity; here
+I/O activity is avoided by
+.Dq reclaiming
+a page frame from
+the list of pages awaiting reallocation.
+.It Fa ru_majflt
+the number of page faults serviced that required I/O activity.
+.It Fa ru_nswap
+the number of times a process was
+.Dq swapped
+out of main
+memory.
+.It Fa ru_inblock
+the number of times the file system had to perform input.
+.It Fa ru_oublock
+the number of times the file system had to perform output.
+.It Fa ru_msgsnd
+the number of IPC messages sent.
+.It Fa ru_msgrcv
+the number of IPC messages received.
+.It Fa ru_nsignals
+the number of signals delivered.
+.It Fa ru_nvcsw
+the number of times a context switch resulted due to a process
+voluntarily giving up the processor before its time slice was
+completed (usually to await availability of a resource).
+.It Fa ru_nivcsw
+the number of times a context switch resulted due to a higher
+priority process becoming runnable or because the current process
+exceeded its time slice.
+.El
+.Sh NOTES
+The numbers
+.Fa ru_inblock
+and
+.Fa ru_oublock
+account only for real
+I/O; data supplied by the caching mechanism is charged only
+to the first process to read or write the data.
+.Sh RETURN VALUES
+.Rv -std getrusage
+.Sh ERRORS
+The
+.Fn getrusage
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa who
+argument is not a valid value.
+.It Bq Er EFAULT
+The address specified by the
+.Fa rusage
+argument is not in a valid part of the process address space.
+.El
+.Sh SEE ALSO
+.Xr gettimeofday 2 ,
+.Xr wait 2 ,
+.Xr clocks 7
+.Sh HISTORY
+The
+.Fn getrusage
+system call appeared in
+.Bx 4.2 .
+The
+.Dv RUSAGE_THREAD
+facility first appeared in
+.Fx 8.1 .
+.Sh BUGS
+There is no way to obtain information about a child process
+that has not yet terminated.
diff --git a/lib/libc/sys/getsid.2 b/lib/libsys/getsid.2
index ad7dbb887a08..ad7dbb887a08 100644
--- a/lib/libc/sys/getsid.2
+++ b/lib/libsys/getsid.2
diff --git a/lib/libsys/getsockname.2 b/lib/libsys/getsockname.2
new file mode 100644
index 000000000000..bee672695812
--- /dev/null
+++ b/lib/libsys/getsockname.2
@@ -0,0 +1,95 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd June 4, 1993
+.Dt GETSOCKNAME 2
+.Os
+.Sh NAME
+.Nm getsockname
+.Nd get socket name
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fn getsockname "int s" "struct sockaddr * restrict name" "socklen_t * restrict namelen"
+.Sh DESCRIPTION
+The
+.Fn getsockname
+system call
+returns the current
+.Fa name
+for the specified socket.
+The
+.Fa namelen
+argument should be initialized to indicate
+the amount of space pointed to by
+.Fa name .
+On return it contains the actual size of the name
+returned (in bytes).
+.Sh RETURN VALUES
+.Rv -std getsockname
+.Sh ERRORS
+The call succeeds unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The argument
+.Fa s
+is not a valid descriptor.
+.It Bq Er ECONNRESET
+The connection has been reset by the peer.
+.It Bq Er EINVAL
+The value of the
+.Fa namelen
+argument is not valid.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is a file, not a socket.
+.It Bq Er ENOBUFS
+Insufficient resources were available in the system
+to perform the operation.
+.It Bq Er EFAULT
+The
+.Fa name
+argument points to memory not in a valid part of the
+process address space.
+.El
+.Sh SEE ALSO
+.Xr bind 2 ,
+.Xr getpeername 2 ,
+.Xr socket 2
+.Sh HISTORY
+The
+.Fn getsockname
+system call appeared in
+.Bx 4.2 .
+.Sh BUGS
+Names bound to sockets in the UNIX domain are inaccessible;
+.Fn getsockname
+returns a zero length name.
diff --git a/lib/libsys/getsockopt.2 b/lib/libsys/getsockopt.2
new file mode 100644
index 000000000000..3867824681d7
--- /dev/null
+++ b/lib/libsys/getsockopt.2
@@ -0,0 +1,696 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd November 25, 2024
+.Dt GETSOCKOPT 2
+.Os
+.Sh NAME
+.Nm getsockopt ,
+.Nm setsockopt
+.Nd get and set options on sockets
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fn getsockopt "int s" "int level" "int optname" "void * restrict optval" "socklen_t * restrict optlen"
+.Ft int
+.Fn setsockopt "int s" "int level" "int optname" "const void *optval" "socklen_t optlen"
+.Sh DESCRIPTION
+The
+.Fn getsockopt
+and
+.Fn setsockopt
+system calls
+manipulate the
+.Em options
+associated with a socket.
+Options may exist at multiple
+protocol levels; they are always present at the uppermost
+.Dq socket
+level.
+.Pp
+When manipulating socket options the level at which the
+option resides and the name of the option must be specified.
+To manipulate options at the socket level,
+.Fa level
+is specified as
+.Dv SOL_SOCKET .
+To manipulate options at any
+other level the protocol number of the appropriate protocol
+controlling the option is supplied.
+For example,
+to indicate that an option is to be interpreted by the
+.Tn TCP
+protocol,
+.Fa level
+should be set to the protocol number of
+.Tn TCP ;
+see
+.Xr getprotoent 3 .
+.Pp
+The
+.Fa optval
+and
+.Fa optlen
+arguments
+are used to access option values for
+.Fn setsockopt .
+For
+.Fn getsockopt
+they identify a buffer in which the value for the
+requested option(s) are to be returned.
+For
+.Fn getsockopt ,
+.Fa optlen
+is a value-result argument, initially containing the
+size of the buffer pointed to by
+.Fa optval ,
+and modified on return to indicate the actual size of
+the value returned.
+If no option value is
+to be supplied or returned,
+.Fa optval
+may be NULL.
+.Pp
+The
+.Fa optname
+argument
+and any specified options are passed uninterpreted to the appropriate
+protocol module for interpretation.
+The include file
+.In sys/socket.h
+contains definitions for
+socket level options, described below.
+Options at other protocol levels vary in format and
+name; consult the appropriate entries in
+section
+4 of the manual.
+.Pp
+Most socket-level options utilize an
+.Vt int
+argument for
+.Fa optval .
+For
+.Fn setsockopt ,
+the argument should be non-zero to enable a boolean option,
+or zero if the option is to be disabled.
+.Dv SO_LINGER
+uses a
+.Vt "struct linger"
+argument, defined in
+.In sys/socket.h ,
+which specifies the desired state of the option and the
+linger interval (see below).
+.Dv SO_SNDTIMEO
+and
+.Dv SO_RCVTIMEO
+use a
+.Vt "struct timeval"
+argument, defined in
+.In sys/time.h .
+.Pp
+The following options are recognized at the socket level.
+For protocol-specific options, see protocol manual pages,
+e.g.
+.Xr ip 4
+or
+.Xr tcp 4 .
+Except as noted, each may be examined with
+.Fn getsockopt
+and set with
+.Fn setsockopt .
+.Bl -column SO_ACCEPTFILTER -offset indent
+.It Dv SO_DEBUG Ta "enables recording of debugging information"
+.It Dv SO_REUSEADDR Ta "enables local address reuse"
+.It Dv SO_REUSEPORT Ta "enables duplicate address and port bindings"
+.It Dv SO_REUSEPORT_LB Ta "enables duplicate address and port bindings with load balancing"
+.It Dv SO_KEEPALIVE Ta "enables keep connections alive"
+.It Dv SO_DONTROUTE Ta "enables routing bypass for outgoing messages"
+.It Dv SO_LINGER Ta "linger on close if data present"
+.It Dv SO_BROADCAST Ta "enables permission to transmit broadcast messages"
+.It Dv SO_OOBINLINE Ta "enables reception of out-of-band data in band"
+.It Dv SO_SNDBUF Ta "set buffer size for output"
+.It Dv SO_RCVBUF Ta "set buffer size for input"
+.It Dv SO_SNDLOWAT Ta "set minimum count for output"
+.It Dv SO_RCVLOWAT Ta "set minimum count for input"
+.It Dv SO_SNDTIMEO Ta "set timeout value for output"
+.It Dv SO_RCVTIMEO Ta "set timeout value for input"
+.It Dv SO_ACCEPTFILTER Ta "set accept filter on listening socket"
+.It Dv SO_NOSIGPIPE Ta
+controls generation of
+.Dv SIGPIPE
+for the socket
+.It Dv SO_TIMESTAMP Ta "enables reception of a timestamp with datagrams"
+.It Dv SO_BINTIME Ta "enables reception of a timestamp with datagrams"
+.It Dv SO_ACCEPTCONN Ta "get listening status of the socket (get only)"
+.It Dv SO_DOMAIN Ta "get the domain of the socket (get only)"
+.It Dv SO_TYPE Ta "get the type of the socket (get only)"
+.It Dv SO_PROTOCOL Ta "get the protocol number for the socket (get only)"
+.It Dv SO_PROTOTYPE Ta "SunOS alias for the Linux SO_PROTOCOL (get only)"
+.It Dv SO_ERROR Ta "get and clear error on the socket (get only)"
+.It Dv SO_RERROR Ta "enables receive error reporting"
+.It Dv SO_FIB Ta "get or set the associated FIB (routing table) for the socket"
+.El
+.Pp
+The following options are recognized in
+.Fx :
+.Bl -column SO_LISTENINCQLEN -offset indent
+.It Dv SO_LABEL Ta "get MAC label of the socket (get only)"
+.It Dv SO_PEERLABEL Ta "get socket's peer's MAC label (get only)"
+.It Dv SO_LISTENQLIMIT Ta "get backlog limit of the socket (get only)"
+.It Dv SO_LISTENQLEN Ta "get complete queue length of the socket (get only)"
+.It Dv SO_LISTENINCQLEN Ta "get incomplete queue length of the socket (get only)"
+.It Dv SO_USER_COOKIE Ta "set the 'so_user_cookie' value for the socket (uint32_t, set only)"
+.It Dv SO_TS_CLOCK Ta "set specific format of timestamp returned by SO_TIMESTAMP"
+.It Dv SO_MAX_PACING_RATE Ta "set the maximum transmit rate in bytes per second for the socket"
+.It Dv SO_NO_OFFLOAD Ta "disables protocol offloads"
+.It Dv SO_NO_DDP Ta "disables direct data placement offload"
+.It Dv SO_SPLICE Ta "splice two sockets together"
+.El
+.Pp
+.Dv SO_DEBUG
+enables debugging in the underlying protocol modules.
+.Pp
+.Dv SO_REUSEADDR
+indicates that the rules used in validating addresses supplied
+in a
+.Xr bind 2
+system call should allow reuse of local addresses.
+.Pp
+.Dv SO_REUSEPORT
+allows completely duplicate bindings by multiple processes
+if they all set
+.Dv SO_REUSEPORT
+before binding the port.
+This option permits multiple instances of a program to each
+receive UDP/IP multicast or broadcast datagrams destined for the bound port.
+.Pp
+.Dv SO_REUSEPORT_LB
+allows completely duplicate bindings by multiple sockets
+if they all set
+.Dv SO_REUSEPORT_LB
+before binding the port.
+Incoming TCP and UDP connections are distributed among the participating
+listening sockets based on a hash function of local port number, and foreign IP
+address and port number.
+A maximum of 256 sockets can be bound to the same load-balancing group.
+.Pp
+.Dv SO_KEEPALIVE
+enables the
+periodic transmission of messages on a connected socket.
+Should the
+connected party fail to respond to these messages, the connection is
+considered broken and processes using the socket are notified via a
+.Dv SIGPIPE
+signal when attempting to send data.
+.Pp
+.Dv SO_DONTROUTE
+indicates that outgoing messages should
+bypass the standard routing facilities.
+Instead, messages are directed
+to the appropriate network interface according to the network portion
+of the destination address.
+.Pp
+.Dv SO_LINGER
+controls the action taken when unsent messages
+are queued on socket and a
+.Xr close 2
+is performed.
+If the socket promises reliable delivery of data and
+.Dv SO_LINGER
+is set,
+the system will block the process on the
+.Xr close 2
+attempt until it is able to transmit the data or until it decides it
+is unable to deliver the information (a timeout period, termed the
+linger interval, is specified in seconds in the
+.Fn setsockopt
+system call when
+.Dv SO_LINGER
+is requested).
+If
+.Dv SO_LINGER
+is disabled and a
+.Xr close 2
+is issued, the system will process the close in a manner that allows
+the process to continue as quickly as possible.
+.Pp
+The option
+.Dv SO_BROADCAST
+requests permission to send broadcast datagrams
+on the socket.
+Broadcast was a privileged operation in earlier versions of the system.
+.Pp
+With protocols that support out-of-band data, the
+.Dv SO_OOBINLINE
+option
+requests that out-of-band data be placed in the normal data input queue
+as received; it will then be accessible with
+.Xr recv 2
+or
+.Xr read 2
+calls without the
+.Dv MSG_OOB
+flag.
+Some protocols always behave as if this option is set.
+.Pp
+.Dv SO_SNDBUF
+and
+.Dv SO_RCVBUF
+are options to adjust the normal
+buffer sizes allocated for output and input buffers, respectively.
+The buffer size may be increased for high-volume connections,
+or may be decreased to limit the possible backlog of incoming data.
+The system places an absolute maximum on these values, which is accessible
+through the
+.Xr sysctl 3
+MIB variable
+.Dq Li kern.ipc.maxsockbuf .
+.Pp
+.Dv SO_SNDLOWAT
+is an option to set the minimum count for output operations.
+Most output operations process all of the data supplied
+by the call, delivering data to the protocol for transmission
+and blocking as necessary for flow control.
+Nonblocking output operations will process as much data as permitted
+subject to flow control without blocking, but will process no data
+if flow control does not allow the smaller of the low water mark value
+or the entire request to be processed.
+A
+.Xr select 2
+operation testing the ability to write to a socket will return true
+only if the low water mark amount could be processed.
+The default value for
+.Dv SO_SNDLOWAT
+is set to a convenient size for network efficiency, often 1024.
+.Pp
+.Dv SO_RCVLOWAT
+is an option to set the minimum count for input operations.
+In general, receive calls will block until any (non-zero) amount of data
+is received, then return with the smaller of the amount available or the amount
+requested.
+The default value for
+.Dv SO_RCVLOWAT
+is 1.
+If
+.Dv SO_RCVLOWAT
+is set to a larger value, blocking receive calls normally
+wait until they have received the smaller of the low water mark value
+or the requested amount.
+Receive calls may still return less than the low water mark if an error
+occurs, a signal is caught, or the type of data next in the receive queue
+is different from that which was returned.
+.Pp
+.Dv SO_SNDTIMEO
+is an option to set a timeout value for output operations.
+It accepts a
+.Vt "struct timeval"
+argument with the number of seconds and microseconds
+used to limit waits for output operations to complete.
+If a send operation has blocked for this much time,
+it returns with a partial count
+or with the error
+.Er EWOULDBLOCK
+if no data were sent.
+In the current implementation, this timer is restarted each time additional
+data are delivered to the protocol,
+implying that the limit applies to output portions ranging in size
+from the low water mark to the high water mark for output.
+.Pp
+.Dv SO_RCVTIMEO
+is an option to set a timeout value for input operations.
+It accepts a
+.Vt "struct timeval"
+argument with the number of seconds and microseconds
+used to limit waits for input operations to complete.
+In the current implementation, this timer is restarted each time additional
+data are received by the protocol,
+and thus the limit is in effect an inactivity timer.
+If a receive operation has been blocked for this much time without
+receiving additional data, it returns with a short count
+or with the error
+.Er EWOULDBLOCK
+if no data were received.
+.Pp
+.Dv SO_FIB
+can be used to over-ride the default FIB (routing table) for the given socket.
+The value must be from 0 to one less than the number returned from
+the sysctl
+.Em net.fibs .
+.Pp
+.Dv SO_USER_COOKIE
+can be used to set the uint32_t so_user_cookie field in the socket.
+The value is an uint32_t, and can be used in the kernel code that
+manipulates traffic related to the socket.
+The default value for the field is 0.
+As an example, the value can be used as the skipto target or
+pipe number in
+.Nm ipfw/dummynet .
+.Pp
+.Dv SO_ACCEPTFILTER
+places an
+.Xr accept_filter 9
+on the socket,
+which will filter incoming connections
+on a listening stream socket before being presented for
+.Xr accept 2 .
+Once more,
+.Xr listen 2
+must be called on the socket before
+trying to install the filter on it,
+or else the
+.Fn setsockopt
+system call will fail.
+.Bd -literal
+struct accept_filter_arg {
+ char af_name[16];
+ char af_arg[256-16];
+};
+.Ed
+.Pp
+The
+.Fa optval
+argument
+should point to a
+.Fa struct accept_filter_arg
+that will select and configure the
+.Xr accept_filter 9 .
+The
+.Fa af_name
+argument
+should be filled with the name of the accept filter
+that the application wishes to place on the listening socket.
+The optional argument
+.Fa af_arg
+can be passed to the accept
+filter specified by
+.Fa af_name
+to provide additional configuration options at attach time.
+Passing in an
+.Fa optval
+of NULL will remove the filter.
+.Pp
+The
+.Dv SO_NOSIGPIPE
+option controls generation of the
+.Dv SIGPIPE
+signal normally sent
+when writing to a connected socket where the other end has been
+closed returns with the error
+.Er EPIPE .
+.Pp
+If the
+.Dv SO_TIMESTAMP
+or
+.Dv SO_BINTIME
+option is enabled on a
+.Dv SOCK_DGRAM
+socket, the
+.Xr recvmsg 2
+call may return a timestamp corresponding to when the datagram was received.
+However, it may not, for example due to a resource shortage.
+The
+.Va msg_control
+field in the
+.Vt msghdr
+structure points to a buffer that contains a
+.Vt cmsghdr
+structure followed by a
+.Vt "struct timeval"
+for
+.Dv SO_TIMESTAMP
+and
+.Vt "struct bintime"
+for
+.Dv SO_BINTIME .
+The
+.Vt cmsghdr
+fields have the following values for TIMESTAMP by default:
+.Bd -literal
+ cmsg_len = CMSG_LEN(sizeof(struct timeval));
+ cmsg_level = SOL_SOCKET;
+ cmsg_type = SCM_TIMESTAMP;
+.Ed
+.Pp
+and for
+.Dv SO_BINTIME :
+.Bd -literal
+ cmsg_len = CMSG_LEN(sizeof(struct bintime));
+ cmsg_level = SOL_SOCKET;
+ cmsg_type = SCM_BINTIME;
+.Ed
+.Pp
+Additional timestamp types are available by following
+.Dv SO_TIMESTAMP
+with
+.Dv SO_TS_CLOCK ,
+which requests a specific timestamp format to be returned instead of
+.Dv SCM_TIMESTAMP when
+.Dv SO_TIMESTAMP is enabled.
+These
+.Dv SO_TS_CLOCK
+values are recognized in
+.Fx :
+.Bl -column SO_TS_CLOCK -offset indent
+.It Dv SO_TS_REALTIME_MICRO Ta "realtime (SCM_TIMESTAMP, struct timeval), default"
+.It Dv SO_TS_BINTIME Ta "realtime (SCM_BINTIME, struct bintime)"
+.It Dv SO_TS_REALTIME Ta "realtime (SCM_REALTIME, struct timespec)"
+.It Dv SO_TS_MONOTONIC Ta "monotonic time (SCM_MONOTONIC, struct timespec)"
+.El
+.Pp
+.Dv SO_ACCEPTCONN ,
+.Dv SO_TYPE ,
+.Dv SO_PROTOCOL
+(and its alias
+.Dv SO_PROTOTYPE )
+and
+.Dv SO_ERROR
+are options used only with
+.Fn getsockopt .
+.Dv SO_ACCEPTCONN
+returns whether the socket is currently accepting connections,
+that is, whether or not the
+.Xr listen 2
+system call was invoked on the socket.
+.Dv SO_TYPE
+returns the type of the socket, such as
+.Dv SOCK_STREAM ;
+it is useful for servers that inherit sockets on startup.
+.Dv SO_PROTOCOL
+returns the protocol number for the socket, for
+.Dv AF_INET
+and
+.Dv AF_INET6
+address families.
+.Dv SO_ERROR
+returns any pending error on the socket and clears
+the error status.
+It may be used to check for asynchronous errors on connected
+datagram sockets or for other asynchronous errors.
+.Dv SO_RERROR
+indicates that receive buffer overflows should be handled as errors.
+Historically receive buffer overflows have been ignored and programs
+could not tell if they missed messages or messages had been truncated
+because of overflows.
+Since programs historically do not expect to get receive overflow errors,
+this behavior is not the default.
+.Pp
+.Dv SO_LABEL
+returns the MAC label of the socket.
+.Dv SO_PEERLABEL
+returns the MAC label of the socket's peer.
+Note that your kernel must be compiled with MAC support.
+See
+.Xr mac 3
+for more information.
+.Pp
+.Dv SO_LISTENQLIMIT
+returns the maximal number of queued connections, as set by
+.Xr listen 2 .
+.Dv SO_LISTENQLEN
+returns the number of unaccepted complete connections.
+.Dv SO_LISTENINCQLEN
+returns the number of unaccepted incomplete connections.
+.Pp
+.Dv SO_MAX_PACING_RATE
+instruct the socket and underlying network adapter layers to limit the
+transfer rate to the given unsigned 32-bit value in bytes per second.
+.Pp
+.Dv SO_NO_OFFLOAD
+disables support for protocol offloads.
+At present, this prevents TCP sockets from using TCP offload engines.
+.Dv SO_NO_DDP
+disables support for a specific TCP offload known as direct data
+placement (DDP).
+DDP is an offload supported by Chelsio network adapters that permits
+reassembled TCP data streams to be received via zero-copy in
+user-supplied buffers using
+.Xr aio_read 2 .
+.Pp
+.Dv SO_SPLICE ,
+when passed to
+.Fn setsockopt ,
+splices two sockets together using the following
+.Fa optval :
+.Bd -literal
+struct so_splice {
+ int sp_fd;
+ off_t sp_max;
+ struct timeval sp_idle;
+};
+.Ed
+.Pp
+Data received on
+.Fa s
+will automatically be transmitted via the socket specified in
+.Fa sp_fd
+without any intervention by userspace.
+That is, the data will be transmitted via
+.Fa sp_fd
+as if userspace had called
+.Xr send 2
+directly.
+Splicing is a one-way operation; a given pair of sockets may be
+spliced in one or both directions.
+Currently only connected
+.Xr tcp 4
+sockets may be spliced together.
+If
+.Fa sp_max
+is greater than zero, the socket pair will automatically be unspliced
+once that number of bytes have been transmitted.
+If
+.Fa sp_idle
+is non-zero, the socket pair will automatically be unspliced once the
+specified amount of time has elapsed since the initial call to
+.Fn setsockopt .
+If
+.Fa sp_fd
+is -1, the socket will be unspliced immediately.
+A successful
+.Xr select 2 ,
+.Xr poll 2 ,
+or
+.Xr kqueue 2
+operation testing the ability to read from the source socket indicates
+that the splicing has terminated and at least one byte is available for
+reading.
+When one of the sockets gets closed, splicing ends.
+.Pp
+When passed to
+.Fn getsockopt ,
+the
+.Dv SO_SPLICE
+option returns a 64-bit integer containing the number of bytes transmitted by
+the most recent splice.
+That is, while the socket is spliced, the value returned will be the number
+of bytes spliced so far.
+When unsplicing, this value is saved and is returned until the socket is closed
+or spliced again.
+For example, if a splice transmits 100 bytes and is then unspliced, a subsequent
+.Nm getsockopt
+call will return 100 until the socket is spliced again.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn getsockopt
+and
+.Fn setsockopt
+system calls succeed unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The argument
+.Fa s
+is not a valid descriptor.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is a file, not a socket.
+.It Bq Er ENOPROTOOPT
+The option is unknown at the level indicated.
+.It Bq Er EFAULT
+The address pointed to by
+.Fa optval
+is not in a valid part of the process address space.
+For
+.Fn getsockopt ,
+this error may also be returned if
+.Fa optlen
+is not in a valid part of the process address space.
+.It Bq Er EINVAL
+Installing an
+.Xr accept_filter 9
+on a non-listening socket was attempted.
+.It Bq Er ENOMEM
+A memory allocation failed that was required to service the request.
+.El
+.Pp
+The
+.Fn setsockopt
+system call may also return the following error:
+.Bl -tag -width Er
+.It Bq Er ENOBUFS
+Insufficient resources were available in the system
+to perform the operation.
+.El
+.Sh SEE ALSO
+.Xr ioctl 2 ,
+.Xr listen 2 ,
+.Xr recvmsg 2 ,
+.Xr socket 2 ,
+.Xr getprotoent 3 ,
+.Xr mac 3 ,
+.Xr sysctl 3 ,
+.Xr ip 4 ,
+.Xr ip6 4 ,
+.Xr sctp 4 ,
+.Xr tcp 4 ,
+.Xr protocols 5 ,
+.Xr sysctl 8 ,
+.Xr accept_filter 9 ,
+.Xr bintime 9
+.Sh HISTORY
+The
+.Fn getsockopt
+and
+.Fn setsockopt
+system calls appeared in
+.Bx 4.2 .
+The
+.Dv SO_SPLICE
+option originated in
+.Ox 4.9
+and first appeared in
+.Fx 14.3 .
+The
+.Fx
+implementation aims to be source-compatible.
+.Sh BUGS
+Several of the socket options should be handled at lower levels of the system.
diff --git a/lib/libsys/gettimeofday.2 b/lib/libsys/gettimeofday.2
new file mode 100644
index 000000000000..4fcd4b52312b
--- /dev/null
+++ b/lib/libsys/gettimeofday.2
@@ -0,0 +1,149 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd April 28, 2024
+.Dt GETTIMEOFDAY 2
+.Os
+.Sh NAME
+.Nm gettimeofday ,
+.Nm settimeofday
+.Nd get/set date and time
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/time.h
+.Ft int
+.Fn gettimeofday "struct timeval *tp" "struct timezone *tzp"
+.Ft int
+.Fn settimeofday "const struct timeval *tp" "const struct timezone *tzp"
+.Sh DESCRIPTION
+.Em Note :
+The
+.Nm gettimeofday
+function
+.Po but not
+.Nm settimeofday Pc
+is obsolescent.
+See the
+.Sx STANDARDS
+section for more details.
+.Pp
+The system's notion of the current Greenwich time and the current time
+zone is obtained with the
+.Fn gettimeofday
+system call, and set with the
+.Fn settimeofday
+system call.
+The time is expressed in seconds and microseconds
+since midnight (0 hour), January 1, 1970.
+The resolution of the system
+clock is hardware dependent, and the time may be updated continuously or
+in
+.Dq ticks .
+If
+.Fa tp
+or
+.Fa tzp
+is NULL, the associated time
+information will not be returned or set.
+.Pp
+The structures pointed to by
+.Fa tp
+and
+.Fa tzp
+are defined in
+.In sys/time.h
+as:
+.Bd -literal
+struct timeval {
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* and microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+.Ed
+.Pp
+The
+.Vt timezone
+structure indicates the local time zone
+(measured in minutes of time westward from Greenwich),
+and a flag that, if nonzero, indicates that
+Daylight Saving time applies locally during
+the appropriate part of the year.
+The kernel generally does not track these values and they
+are usually returned as zero.
+Use
+.Xr localtime 3
+to find the offset for the currently active timezone.
+.Pp
+Only the super-user may set the time of day or time zone.
+If the system is running at securelevel >= 2 (see
+.Xr init 8 ) ,
+the time may only be advanced or retarded by a maximum of one second.
+This limitation is imposed to prevent a malicious super-user
+from setting arbitrary time stamps on files.
+The system time can be adjusted backwards without restriction using the
+.Xr adjtime 2
+system call even when the system is secure.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The following error codes may be set in
+.Va errno :
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The supplied
+.Fa timeval
+value is invalid.
+.It Bq Er EPERM
+A user other than the super-user attempted to set the time.
+.El
+.Sh SEE ALSO
+.Xr date 1 ,
+.Xr adjtime 2 ,
+.Xr clock_gettime 2 ,
+.Xr ctime 3 ,
+.Xr timeradd 3 ,
+.Xr clocks 7
+.Sh STANDARDS
+The
+.Nm gettimeofday
+function is considered obsolescent and its usage discouraged by
+.\" XXX: This should be replaced in the future when an appropriate argument to
+.\" the St macro is available: -p1003.1-2017
+.No IEEE Std 1003.1-2008, 2017 Edition (\\(LqPOSIX.1\\(Rq) .
+Applications should use the
+.Xr clock_gettime 2
+function instead.
+.Sh HISTORY
+The
+.Fn gettimeofday
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/gettimeofday.c b/lib/libsys/gettimeofday.c
new file mode 100644
index 000000000000..bc7990aa0457
--- /dev/null
+++ b/lib/libsys/gettimeofday.c
@@ -0,0 +1,51 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.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.
+ *
+ * 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.
+ */
+
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include "libc_private.h"
+
+int __gettimeofday(struct timeval *tv, struct timezone *tz);
+
+__weak_reference(__gettimeofday, gettimeofday);
+
+int
+__gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+ int error;
+
+ error = __vdso_gettimeofday(tv, tz);
+ if (error == ENOSYS) {
+ error = __sys_gettimeofday(tv, tz);
+ } else if (error != 0) {
+ errno = error;
+ error = -1;
+ }
+ return (error);
+}
diff --git a/lib/libsys/getuid.2 b/lib/libsys/getuid.2
new file mode 100644
index 000000000000..4d3a6f88c272
--- /dev/null
+++ b/lib/libsys/getuid.2
@@ -0,0 +1,88 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd December 1, 2017
+.Dt GETUID 2
+.Os
+.Sh NAME
+.Nm getuid ,
+.Nm geteuid
+.Nd get user identification
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft uid_t
+.Fn getuid void
+.Ft uid_t
+.Fn geteuid void
+.Sh DESCRIPTION
+The
+.Fn getuid
+system call returns the real user ID of the calling process.
+The
+.Fn geteuid
+system call
+returns the effective user ID of the calling process.
+.Pp
+The real user ID is that of the user who has invoked the program.
+As the effective user ID
+gives the process additional permissions during
+execution of
+.Dq Em set-user-ID
+mode processes,
+.Fn getuid
+is used to determine the real-user-id of the calling process.
+.Sh ERRORS
+The
+.Fn getuid
+and
+.Fn geteuid
+system calls are always successful, and no return value is reserved to
+indicate an error.
+.Sh SEE ALSO
+.Xr getgid 2 ,
+.Xr issetugid 2 ,
+.Xr setgid 2 ,
+.Xr setreuid 2 ,
+.Xr setuid 2
+.Sh STANDARDS
+The
+.Fn geteuid
+and
+.Fn getuid
+system calls are expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn getuid
+function appeared in
+.At v1 .
+The
+.Fn geteuid
+function appeared in
+.At v4 .
diff --git a/lib/libsys/i386/Makefile.sys b/lib/libsys/i386/Makefile.sys
new file mode 100644
index 000000000000..2957dc548cf8
--- /dev/null
+++ b/lib/libsys/i386/Makefile.sys
@@ -0,0 +1,15 @@
+SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \
+ i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c \
+ i386_clr_watch.c i386_set_watch.c i386_vm86.c \
+ rfork_thread.S
+
+MDASM= vfork.S cerror.S getcontext.S syscall.S
+
+.if ${LIB} == "sys"
+MAN+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2
+MAN+= i386_set_watch.3
+
+MLINKS+=i386_get_ioperm.2 i386_set_ioperm.2
+MLINKS+=i386_get_ldt.2 i386_set_ldt.2
+MLINKS+=i386_set_watch.3 i386_clr_watch.3
+.endif # ${LIB} == "sys"
diff --git a/lib/libsys/i386/Makefile.thr b/lib/libsys/i386/Makefile.thr
new file mode 100644
index 000000000000..52e861709faf
--- /dev/null
+++ b/lib/libsys/i386/Makefile.thr
@@ -0,0 +1 @@
+SRCS+= _umtx_op_err.S
diff --git a/lib/libsys/i386/SYS.h b/lib/libsys/i386/SYS.h
new file mode 100644
index 000000000000..f5e0565452da
--- /dev/null
+++ b/lib/libsys/i386/SYS.h
@@ -0,0 +1,58 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ mov $SYS_##name, %eax; \
+ int $0x80
+
+#ifndef _SYSCALL_BODY
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ jb HIDENAME(cerror); \
+ ret
+#endif
+
+#define RSYSCALL(name) ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+ END(__sys_##name)
+
+#define PSEUDO(name) ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+ END(__sys_##name)
diff --git a/lib/libsys/i386/Symbol.sys.map b/lib/libsys/i386/Symbol.sys.map
new file mode 100644
index 000000000000..6b3169336a3f
--- /dev/null
+++ b/lib/libsys/i386/Symbol.sys.map
@@ -0,0 +1,25 @@
+FBSD_1.0 {
+ i386_clr_watch;
+ i386_get_fsbase;
+ i386_get_gsbase;
+ i386_get_ioperm;
+ i386_get_ldt;
+ i386_set_fsbase;
+ i386_set_gsbase;
+ i386_set_ioperm;
+ i386_set_ldt;
+ i386_set_watch;
+ i386_vm86;
+ rfork_thread;
+};
+
+FBSD_1.6 {
+ x86_pkru_get_perm;
+ x86_pkru_protect_range;
+ x86_pkru_set_perm;
+ x86_pkru_unprotect_range;
+};
+
+FBSDprivate_1.0 {
+ _vfork;
+};
diff --git a/lib/libthr/arch/i386/i386/_umtx_op_err.S b/lib/libsys/i386/_umtx_op_err.S
index 460bd72604aa..460bd72604aa 100644
--- a/lib/libthr/arch/i386/i386/_umtx_op_err.S
+++ b/lib/libsys/i386/_umtx_op_err.S
diff --git a/lib/libsys/i386/cerror.S b/lib/libsys/i386/cerror.S
new file mode 100644
index 000000000000..6e7015edabc4
--- /dev/null
+++ b/lib/libsys/i386/cerror.S
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+ .globl HIDENAME(cerror)
+ .hidden HIDENAME(cerror)
+
+ /*
+ * The __error() function is thread aware. For non-threaded
+ * programs and the initial thread in threaded programs,
+ * it returns a pointer to the global errno variable.
+ */
+ .globl CNAME(__error)
+ .type CNAME(__error),@function
+HIDENAME(cerror):
+#ifdef PIC
+ PIC_PROLOGUE
+ pushl %eax
+ call PIC_PLT(CNAME(__error))
+ popl %ecx
+ PIC_EPILOGUE
+#else
+ pushl %eax
+ call CNAME(__error)
+ popl %ecx
+#endif
+ movl %ecx,(%eax)
+ movl $-1,%eax
+ movl $-1,%edx
+ ret
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/i386/getcontext.S b/lib/libsys/i386/getcontext.S
new file mode 100644
index 000000000000..d6b5dcd58669
--- /dev/null
+++ b/lib/libsys/i386/getcontext.S
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2003 Peter Wemm <peter@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.
+ */
+
+#include <machine/asm.h>
+#include <SYS.h>
+
+/*
+ * This has to be magic to handle the multiple returns.
+ * Otherwise, the setcontext() syscall will return here and we'll
+ * pop off the return address and go to the *setcontext* call.
+ */
+ WEAK_REFERENCE(__sys_getcontext, _getcontext)
+ WEAK_REFERENCE(__sys_getcontext, getcontext)
+ENTRY(__sys_getcontext)
+ movl (%esp),%ecx /* save getcontext return address */
+ _SYSCALL(getcontext)
+ jb HIDENAME(cerror)
+ addl $4,%esp /* remove stale (setcontext) return address */
+ jmp *%ecx /* restore return address */
+END(__sys_getcontext)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/i386/i386_clr_watch.c b/lib/libsys/i386/i386_clr_watch.c
new file mode 100644
index 000000000000..f01b340d81e0
--- /dev/null
+++ b/lib/libsys/i386/i386_clr_watch.c
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2000 Brian S. Dean <bsd@bsdhome.com>
+ * 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 BRIAN S. DEAN ``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 BRIAN S. DEAN BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#include <machine/reg.h>
+#include <machine/sysarch.h>
+
+int
+i386_clr_watch(int watchnum, struct dbreg * d)
+{
+
+ if (watchnum < 0 || watchnum >= 4)
+ return -1;
+
+ DBREG_DRX(d,7) = DBREG_DRX(d,7) & ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
+ DBREG_DRX(d,watchnum) = 0;
+
+ return 0;
+}
diff --git a/lib/libsys/i386/i386_get_fsbase.c b/lib/libsys/i386/i386_get_fsbase.c
new file mode 100644
index 000000000000..b60c6af5ff55
--- /dev/null
+++ b/lib/libsys/i386/i386_get_fsbase.c
@@ -0,0 +1,36 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2005 Peter Wemm
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_get_fsbase(void **addr)
+{
+
+ return (sysarch(I386_GET_FSBASE, addr));
+}
diff --git a/lib/libsys/i386/i386_get_gsbase.c b/lib/libsys/i386/i386_get_gsbase.c
new file mode 100644
index 000000000000..fd8187d83437
--- /dev/null
+++ b/lib/libsys/i386/i386_get_gsbase.c
@@ -0,0 +1,36 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2005 Peter Wemm
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_get_gsbase(void **addr)
+{
+
+ return (sysarch(I386_GET_GSBASE, addr));
+}
diff --git a/lib/libc/i386/sys/i386_get_ioperm.2 b/lib/libsys/i386/i386_get_ioperm.2
index decdf8379ac3..decdf8379ac3 100644
--- a/lib/libc/i386/sys/i386_get_ioperm.2
+++ b/lib/libsys/i386/i386_get_ioperm.2
diff --git a/lib/libsys/i386/i386_get_ioperm.c b/lib/libsys/i386/i386_get_ioperm.c
new file mode 100644
index 000000000000..6adfe2bedf6c
--- /dev/null
+++ b/lib/libsys/i386/i386_get_ioperm.c
@@ -0,0 +1,47 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 1998 Jonathan Lemon
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_get_ioperm(unsigned int start, unsigned int *length, int *enable)
+{
+ struct i386_ioperm_args p;
+ int error;
+
+ p.start = start;
+ p.length = *length;
+ p.enable = *enable;
+
+ error = sysarch(I386_GET_IOPERM, &p);
+
+ *length = p.length;
+ *enable = p.enable;
+
+ return (error);
+}
diff --git a/lib/libsys/i386/i386_get_ldt.2 b/lib/libsys/i386/i386_get_ldt.2
new file mode 100644
index 000000000000..0884fd8cfea1
--- /dev/null
+++ b/lib/libsys/i386/i386_get_ldt.2
@@ -0,0 +1,136 @@
+.\" Copyright (c) 1980, 1991 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.
+.\"
+.Dd October 14, 2006
+.Dt I386_GET_LDT 2
+.Os
+.Sh NAME
+.Nm i386_get_ldt ,
+.Nm i386_set_ldt
+.Nd manage i386 per-process Local Descriptor Table entries
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In machine/segments.h
+.In machine/sysarch.h
+.Ft int
+.Fn i386_get_ldt "int start_sel" "union descriptor *descs" "int num_sels"
+.Ft int
+.Fn i386_set_ldt "int start_sel" "union descriptor *descs" "int num_sels"
+.Sh DESCRIPTION
+The
+.Fn i386_get_ldt
+system call
+returns a list of the i386 descriptors in the current process'
+LDT.
+The
+.Fn i386_set_ldt
+system call
+sets a list of i386 descriptors in the current process'
+LDT.
+For both routines,
+.Fa start_sel
+specifies the index of the selector in the LDT at which to begin and
+.Fa descs
+points to an array of
+.Fa num_sels
+descriptors to be set or returned.
+.Pp
+Each entry in the
+.Fa descs
+array can be either a segment_descriptor or gate_descriptor and are defined in
+.In i386/segments.h .
+These structures are defined by the architecture
+as disjoint bit-fields, so care must be taken in constructing them.
+.Pp
+If
+.Fa start_sel
+is
+.Em LDT_AUTO_ALLOC ,
+.Fa num_sels
+is 1 and the descriptor pointed to by
+.Fa descs
+is legal, then
+.Fn i386_set_ldt
+will allocate a descriptor and return its
+selector number.
+.Pp
+If
+.Fa num_descs
+is 1,
+.Fa start_sels
+is valid, and
+.Fa descs
+is NULL, then
+.Fn i386_set_ldt
+will free that descriptor
+(making it available to be reallocated again later).
+.Pp
+If
+.Fa num_descs
+is 0,
+.Fa start_sels
+is 0 and
+.Fa descs
+is NULL then, as a special case,
+.Fn i386_set_ldt
+will free all descriptors.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn i386_get_ldt
+returns the number of descriptors currently in the LDT.
+The
+.Fn i386_set_ldt
+system call
+returns the first selector set on success.
+If the kernel allocated a descriptor in the LDT,
+the allocated index is returned.
+Otherwise, a value of -1 is returned and the global
+variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn i386_get_ldt
+and
+.Fn i386_set_ldt
+system calls
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+An inappropriate value was used for
+.Fa start_sel
+or
+.Fa num_sels .
+.It Bq Er EACCES
+The caller attempted to use a descriptor that would
+circumvent protection or cause a failure.
+.El
+.Sh SEE ALSO
+i386 Microprocessor Programmer's Reference Manual, Intel
+.Sh WARNING
+You can really hose your process using this.
diff --git a/lib/libsys/i386/i386_get_ldt.c b/lib/libsys/i386/i386_get_ldt.c
new file mode 100644
index 000000000000..8021476434d6
--- /dev/null
+++ b/lib/libsys/i386/i386_get_ldt.c
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1993 John Brezak
+ * 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. 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.
+ */
+
+#include <sys/cdefs.h>
+#include <machine/segments.h>
+#include <machine/sysarch.h>
+
+int
+i386_get_ldt(int start, union descriptor *descs, int num)
+{
+ struct i386_ldt_args p;
+
+ p.start = start;
+ p.descs = descs;
+ p.num = num;
+
+ return sysarch(I386_GET_LDT, &p);
+}
diff --git a/lib/libsys/i386/i386_set_fsbase.c b/lib/libsys/i386/i386_set_fsbase.c
new file mode 100644
index 000000000000..8420f492a5d5
--- /dev/null
+++ b/lib/libsys/i386/i386_set_fsbase.c
@@ -0,0 +1,36 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2005 Peter Wemm
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_set_fsbase(void *addr)
+{
+
+ return (sysarch(I386_SET_FSBASE, &addr));
+}
diff --git a/lib/libsys/i386/i386_set_gsbase.c b/lib/libsys/i386/i386_set_gsbase.c
new file mode 100644
index 000000000000..779b2e74eb3f
--- /dev/null
+++ b/lib/libsys/i386/i386_set_gsbase.c
@@ -0,0 +1,36 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2005 Peter Wemm
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_set_gsbase(void *addr)
+{
+
+ return (sysarch(I386_SET_GSBASE, &addr));
+}
diff --git a/lib/libsys/i386/i386_set_ioperm.c b/lib/libsys/i386/i386_set_ioperm.c
new file mode 100644
index 000000000000..b65f62fe44bb
--- /dev/null
+++ b/lib/libsys/i386/i386_set_ioperm.c
@@ -0,0 +1,41 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 1998 Jonathan Lemon
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_set_ioperm(unsigned int start, unsigned int length, int enable)
+{
+ struct i386_ioperm_args p;
+
+ p.start = start;
+ p.length = length;
+ p.enable = enable;
+
+ return (sysarch(I386_SET_IOPERM, &p));
+}
diff --git a/lib/libsys/i386/i386_set_ldt.c b/lib/libsys/i386/i386_set_ldt.c
new file mode 100644
index 000000000000..ac363e45d769
--- /dev/null
+++ b/lib/libsys/i386/i386_set_ldt.c
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1993 John Brezak
+ * 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. 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.
+ */
+
+#include <sys/cdefs.h>
+#include <machine/segments.h>
+#include <machine/sysarch.h>
+
+int
+i386_set_ldt(int start, union descriptor *descs, int num)
+{
+ struct i386_ldt_args p;
+
+ p.start = start;
+ p.descs = descs;
+ p.num = num;
+
+ return sysarch(I386_SET_LDT, &p);
+}
diff --git a/lib/libsys/i386/i386_set_watch.3 b/lib/libsys/i386/i386_set_watch.3
new file mode 100644
index 000000000000..265c21119c53
--- /dev/null
+++ b/lib/libsys/i386/i386_set_watch.3
@@ -0,0 +1,116 @@
+.\" Copyright (c) 2000 Brian S. Dean
+.\" All rights reserved.
+.\"
+.\" This man-page is based on a similar man-page by Jonathan Lemon
+.\" which is copyrighted under the following conditions:
+.\"
+.\" 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.
+.\"
+.Dd August 24, 2000
+.Dt I386_SET_WATCH 3
+.Os
+.Sh NAME
+.Nm i386_clr_watch ,
+.Nm i386_set_watch
+.Nd manage i386 debug register values
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In machine/reg.h
+.In machine/sysarch.h
+.Ft int
+.Fn i386_clr_watch "int watchnum" "struct dbreg *d"
+.Ft int
+.Fn i386_set_watch "int watchnum" "unsigned int watchaddr" "int size" "int access" "struct dbreg *d"
+.Sh DESCRIPTION
+The
+.Fn i386_clr_watch
+function
+will disable the indicated watch point within the specified debug
+register set.
+.Pp
+The
+.Fn i386_set_watch
+function
+will set up the specified debug registers as indicated by the
+arguments.
+The
+.Fa watchnum
+argument specifies which watch register is used, 0, 1, 2, 3, or \-1.
+If
+.Fa watchnum
+is \-1, a free watch register is found and used.
+If there are no free
+watch registers, an error code of \-1 is returned.
+The
+.Fa watchaddr
+argument
+specifies the watch address,
+.Fa size
+specifies the size in bytes of the area to be watched (1, 2, or 4 bytes),
+and
+.Fa access
+specifies the type of watch point:
+.Pp
+.Bd -literal -offset indent -compact
+DBREG_DR7_EXEC An execution breakpoint.
+DBREG_DR7_WRONLY Break only when the watch area is written to.
+DBREG_DR7_RDWR Break when the watch area is read from or written
+ to.
+.Ed
+.Pp
+Note that these functions do not actually set or clear breakpoints;
+they manipulate the indicated debug register set.
+You must use
+.Xr ptrace 2
+to retrieve and install the debug register values for a process.
+.Sh RETURN VALUES
+On success, the
+.Fn i386_clr_watch
+function returns 0.
+On error, \-1 returned which indicates that
+.Fa watchnum
+is invalid (not in the range of 0-3).
+If the specified watchnum was already disabled, no error is returned.
+.Pp
+On success, the
+.Fn i386_set_watch
+function returns the
+.Fa watchnum
+argument, or the watchnum actually used in the case where the specified
+.Fa watchnum
+was \-1.
+On error, the
+.Fn i386_set_watch
+function returns \-1 indicating that the watchpoint could not established
+because either no more watchpoints are available, or
+.Fa watchnum ,
+.Fa size ,
+or
+.Fa access
+is invalid.
+.Sh SEE ALSO
+.Xr ptrace 2 ,
+.Xr procfs 4
+.Sh AUTHORS
+This man page was written by
+.An Brian S. Dean .
diff --git a/lib/libsys/i386/i386_set_watch.c b/lib/libsys/i386/i386_set_watch.c
new file mode 100644
index 000000000000..acdcd79720e3
--- /dev/null
+++ b/lib/libsys/i386/i386_set_watch.c
@@ -0,0 +1,83 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2000 Brian S. Dean <bsd@bsdhome.com>
+ * 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 BRIAN S. DEAN ``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 BRIAN S. DEAN BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#include <machine/reg.h>
+#include <machine/sysarch.h>
+
+int
+i386_set_watch(int watchnum, unsigned int watchaddr, int size,
+ int access, struct dbreg * d)
+{
+ int i;
+ unsigned int mask;
+
+ if (watchnum == -1) {
+ for (i = 0, mask = 0x3; i < 4; i++, mask <<= 2)
+ if ((DBREG_DRX(d,7) & mask) == 0)
+ break;
+ if (i < 4)
+ watchnum = i;
+ else
+ return -1;
+ }
+
+ switch (access) {
+ case DBREG_DR7_EXEC:
+ size = 1; /* size must be 1 for an execution breakpoint */
+ /* fall through */
+ case DBREG_DR7_WRONLY:
+ case DBREG_DR7_RDWR:
+ break;
+ default : return -1; break;
+ }
+
+ /*
+ * we can watch a 1, 2, or 4 byte sized location
+ */
+ switch (size) {
+ case 1 : mask = 0x00; break;
+ case 2 : mask = 0x01 << 2; break;
+ case 4 : mask = 0x03 << 2; break;
+ default : return -1; break;
+ }
+
+ mask |= access;
+
+ /* clear the bits we are about to affect */
+ DBREG_DRX(d,7) &= ~((0x3 << (watchnum*2)) | (0x0f << (watchnum*4+16)));
+
+ /* set drN register to the address, N=watchnum */
+ DBREG_DRX(d,watchnum) = watchaddr;
+
+ /* enable the watchpoint */
+ DBREG_DRX(d,7) |= (0x2 << (watchnum*2)) | (mask << (watchnum*4+16));
+
+ return watchnum;
+}
diff --git a/lib/libc/i386/sys/i386_vm86.2 b/lib/libsys/i386/i386_vm86.2
index bbfb5a9b2ebc..bbfb5a9b2ebc 100644
--- a/lib/libc/i386/sys/i386_vm86.2
+++ b/lib/libsys/i386/i386_vm86.2
diff --git a/lib/libsys/i386/i386_vm86.c b/lib/libsys/i386/i386_vm86.c
new file mode 100644
index 000000000000..fab2a3080ccd
--- /dev/null
+++ b/lib/libsys/i386/i386_vm86.c
@@ -0,0 +1,40 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 1998 Jonathan Lemon
+ * 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.
+ */
+
+#include <machine/sysarch.h>
+
+int
+i386_vm86(int fcn, void *data)
+{
+ struct i386_vm86_args p;
+
+ p.sub_op = fcn;
+ p.sub_args = (char *)data;
+
+ return (sysarch(I386_VM86, &p));
+}
diff --git a/lib/libsys/i386/rfork_thread.S b/lib/libsys/i386/rfork_thread.S
new file mode 100644
index 000000000000..b37f16c930e8
--- /dev/null
+++ b/lib/libsys/i386/rfork_thread.S
@@ -0,0 +1,111 @@
+/*-
+ * Copyright (c) 2000 Peter Wemm <peter@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.
+ */
+
+#include <machine/asm.h>
+/*
+ * With thanks to John Dyson for the original version of this.
+ */
+
+#include <SYS.h>
+
+/*
+ * 8 12 16 20
+ * rfork_thread(flags, stack_addr, start_fnc, start_arg);
+ *
+ * flags: Flags to rfork system call. See rfork(2).
+ * stack_addr: Top of stack for thread.
+ * start_fnc: Address of thread function to call in child.
+ * start_arg: Argument to pass to the thread function in child.
+ */
+
+ENTRY(rfork_thread)
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+
+ /*
+ * Push thread info onto the new thread's stack
+ */
+ movl 12(%ebp), %esi # get stack addr
+
+ subl $4, %esi
+ movl 20(%ebp), %eax # get start argument
+ movl %eax, (%esi)
+
+ subl $4, %esi
+ movl 16(%ebp), %eax # get start thread address
+ movl %eax, (%esi)
+
+ /*
+ * Prepare and execute the thread creation syscall
+ */
+ pushl 8(%ebp)
+ pushl $0
+ _SYSCALL(rfork)
+ jb 2f
+
+ /*
+ * Check to see if we are in the parent or child
+ */
+ cmpl $0, %edx
+ jnz 1f
+ addl $8, %esp
+ popl %esi
+ movl %ebp, %esp
+ popl %ebp
+ ret
+ .p2align 2
+
+ /*
+ * If we are in the child (new thread), then
+ * set-up the call to the internal subroutine. If it
+ * returns, then call __exit.
+ */
+1:
+ movl %esi,%esp
+ popl %eax
+ call *%eax
+ addl $4, %esp
+
+ /*
+ * Exit system call
+ */
+ pushl %eax
+ pushl $0
+ _SYSCALL(exit)
+
+ /*
+ * Branch here if the thread creation fails:
+ */
+2:
+ addl $8, %esp
+ popl %esi
+ movl %ebp, %esp
+ popl %ebp
+ jmp HIDENAME(cerror)
+END(rfork_thread)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/i386/syscall.S b/lib/libsys/i386/syscall.S
new file mode 100644
index 000000000000..bed7156e28ac
--- /dev/null
+++ b/lib/libsys/i386/syscall.S
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+ENTRY(syscall)
+ pop %ecx /* rta */
+ pop %eax /* syscall number */
+ push %ecx
+ int $0x80
+ push %ecx /* need to push a word to keep stack frame intact
+ upon return; the word must be the return address. */
+ jb HIDENAME(cerror)
+ ret
+END(syscall)
+
+PSEUDO(syscall)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/i386/vfork.S b/lib/libsys/i386/vfork.S
new file mode 100644
index 000000000000..3399b8b752de
--- /dev/null
+++ b/lib/libsys/i386/vfork.S
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+#include "SYS.h"
+
+ WEAK_REFERENCE(__sys_vfork, _vfork)
+ WEAK_REFERENCE(__sys_vfork, vfork)
+ENTRY(__sys_vfork)
+ popl %ecx /* my rta into ecx */
+ _SYSCALL(vfork)
+ jb 1f
+ jmp *%ecx
+1:
+ pushl %ecx
+ jmp HIDENAME(cerror)
+END(__sys_vfork)
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/lib/libsys/inotify.2 b/lib/libsys/inotify.2
new file mode 100644
index 000000000000..f94509d6f59e
--- /dev/null
+++ b/lib/libsys/inotify.2
@@ -0,0 +1,379 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Klara, Inc.
+.\"
+.Dd May 19, 2025
+.Dt INOTIFY 2
+.Os
+.Sh NAME
+.Nm inotify_init ,
+.Nm inotify_init1 ,
+.Nm inotify_add_watch ,
+.Nm inotify_add_watch_at ,
+.Nm inotify_rm_watch
+.Nd monitor file system events
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/inotify.h
+.Ft int
+.Fo inotify_init
+.Fc
+.Ft int
+.Fo inotify_init1
+.Fa "int flags"
+.Fc
+.Ft int
+.Fo inotify_add_watch
+.Fa "int fd"
+.Fa "const char *pathname"
+.Fa "uint32_t mask"
+.Fc
+.Ft int
+.Fo inotify_add_watch_at
+.Fa "int fd"
+.Fa "int dfd"
+.Fa "const char *pathname"
+.Fa "uint32_t mask"
+.Fc
+.Ft int
+.Fo inotify_rm_watch
+.Fa "int fd"
+.Fa "uint32_t wd"
+.Fc
+.Bd -literal
+struct inotify_event {
+ int wd; /* Watch descriptor */
+ uint32_t mask; /* Event and flags */
+ uint32_t cookie; /* Unique ID which links rename events */
+ uint32_t len; /* Name field size, including nul bytes */
+ char name[0]; /* Filename (nul-terminated) */
+};
+.Ed
+.Sh DESCRIPTION
+The inotify system calls provide an interface to monitor file system events.
+They aim to be compatible with the Linux inotify interface.
+The provided functionality is similar to the
+.Dv EVFILT_VNODE
+filter of the
+.Xr kevent 2
+system call, but further allows monitoring of a directory without needing to
+open each object in that directory.
+This avoids races and reduces the number of file descriptors needed to monitor
+a large file hierarchy.
+.Pp
+inotify allows one or more file system objects, generally files or directories,
+to be watched for events, such as file open or close.
+Watched objects are associated with a file descriptor returned
+by
+.Fn inotify_init
+or
+.Fn inotify_init1 .
+When an event occurs, a record describing the event becomes available for
+reading from the inotify file descriptor.
+Each inotify descriptor thus refers to a queue of events waiting to be read.
+inotify descriptors are inherited across
+.Xr fork 2
+calls and may be passed to other processes via
+.Xr unix 4
+sockets.
+.Pp
+The
+.Fn inotify_init1
+system call accepts two flags.
+The
+.Dv IN_NONBLOCK
+flag causes the inotify descriptor to be opened in non-blocking mode, such that
+.Xr read 2
+calls will not block if no records are available to consume, and will instead
+return
+.Er EWOULDBLOCK .
+The
+.Dv IN_CLOEXEC
+flag causes the inotify descriptor to be closed automatically when
+.Xr execve 2
+is called.
+.Pp
+To watch a file or directory, the
+.Fn inotify_add_watch
+or
+.Fn inotify_add_watch_at
+system calls must be used.
+They take a path and a mask of events to watch for, and return a
+.Dq watch descriptor ,
+a non-negative integer which uniquely identifies the watched object within the
+inotify descriptor.
+.Pp
+The
+.Fn inotify_rm_watch
+system call removes a watch from an inotify descriptor.
+.Pp
+When watching a directory, objects within the directory are monitored for events
+as well as the directory itself.
+A record describing an inotify event consists of a
+.Dq struct inotify_event
+followed by the name of the object in the directory being watched.
+If the watched object itself generates an event, no name is present.
+Extra nul bytes may follow the file name in order to provide alignment for a
+subsequent record.
+.Pp
+The following events are defined:
+.Bl -tag -width IN_CLOSE_NOWRITE
+.It Dv IN_ACCESS
+A file's contents were accessed, e.g., by
+.Xr read 2
+.Xr copy_file_range 2 ,
+.Xr sendfile 2 ,
+or
+.Xr getdirentries 2 .
+.It Dv IN_ATTRIB
+A file's metadata was changed, e.g., by
+.Xr chmod 2
+or
+.Xr unlink 2 .
+.It Dv IN_CLOSE_WRITE
+A file that was previously opened for writing was closed.
+.It Dv IN_CLOSE_NOWRITE
+A file that was previously opened read-only was closed.
+.It Dv IN_CREATE
+A file within a watched directory was created, e.g., by
+.Xr open 2 ,
+.Xr mkdir 2 ,
+.Xr symlink 2 ,
+.Xr mknod 2 ,
+or
+.Xr bind 2 .
+.It Dv IN_DELETE
+A file or directory within a watched directory was removed.
+.It Dv IN_DELETE_SELF
+The watched file or directory itself was deleted.
+This event is generated only when the link count of the file drops
+to zero.
+.It Dv IN_MODIFY
+A file's contents were modified, e.g., by
+.Xr write 2
+or
+.Xr copy_file_range 2 .
+.It Dv IN_MOVE_SELF
+The watched file or directory itself was renamed.
+.It Dv IN_MOVED_FROM
+A file or directory was moved from a watched directory.
+.It Dv IN_MOVED_TO
+A file or directory was moved into a watched directory.
+A
+.Xr rename 2
+call thus may generate two events, one for the old name and one for the new
+name.
+These are linked together by the
+.Ar cookie
+field in the inotify record, which can be compared to link the two records
+to the same event.
+.It Dv IN_OPEN
+A file was opened.
+.El
+.Pp
+Some additional flags may be set in inotify event records:
+.Bl -tag -width IN_Q_OVERFLOW
+.It Dv IN_IGNORED
+When a watch is removed from a file, for example because it was created with the
+.Dv IN_ONESHOT
+flag, the file was deleted, or the watch was explicitly removed with
+.Xr inotify_rm_watch 2 ,
+an event with this mask is generated to indicate that the watch will not
+generate any more events.
+Once this event is generated, the watch is automatically removed, and in
+particular should not be removed manually with
+.Xr inotify_rm_watch 2 .
+.It Dv IN_ISDIR
+When the subject of an event is a directory, this flag is set in the
+.Ar mask
+.It Dv IN_Q_OVERFLOW
+One or more events were dropped, for example because of a kernel memory allocation
+failure or because the event queue size hit a limit.
+.It Dv IN_UNMOUNT
+The filesystem containing the watched object was unmounted.
+.El
+.Pp
+A number of flags may also be specified in the
+.Ar mask
+given to
+.Fn inotify_add_watch
+and
+.Fn inotify_add_watch_at :
+.Bl -tag -width IN_DONT_FOLLOW
+.It Dv IN_DONT_FOLLOW
+If
+.Ar pathname
+is a symbolic link, do not follow it.
+.It Dv IN_EXCL_UNLINK
+This currently has no effect, see the
+.Sx BUGS
+section.
+.In Dv IN_MASK_ADD
+When adding a watch to an object, and that object is already watched by the
+same inotify descriptor, by default the mask of the existing watch is
+overwritten.
+When
+.Dv IN_MASK_ADD
+is specified, the mask of the existing watch is instead logically ORed with
+the new mask.
+.In Dv IN_MASK_CREATE
+When
+.Fn inotify_add watch
+is used to add a watch to an object,
+.Dv IN_MASK_CREATE
+is specified, and that object is already watched by the same inotify descriptor,
+return an error instead of updating the existing watch.
+.In Dv IN_ONESHOT
+Monitor the object for a single event, after which the watch is automatically
+removed.
+As part of removal, a
+.Dv IN_IGNORED
+event is generated.
+.In Dv IN_ONLYDIR
+When creating a watch, fail with
+.Er ENOTDIR
+if the path does not refer to a directory.
+.El
+.Sh SYSCTL VARIABLES
+The following variables are available as both
+.Xr sysctl 8
+variables and
+.Xr loader 8
+tunables:
+.Bl -tag -width 15
+.It Va vfs.inotify.max_events
+The maximum number of inotify records that can be queued for a single
+inotify descriptor.
+Records in excess of this limit are discarded, and a single event with
+mask equal to
+.Dv IN_Q_OVERFLOW
+will be present in the queue.
+.It Va vfs.inotify.max_user_instances
+The maximum number of inotify descriptors that can be created by a single
+user.
+.It Va vfs.inotify.max_user_watches
+The maximum number of inotify watches per user.
+.El
+.Sh EXAMPLES
+See the example program in
+.Pa /usr/share/examples/inotify/inotify.c .
+.Sh ERRORS
+The
+.Fn inotify_init
+and
+.Fn inotify_init1
+functions will fail if:
+.Bl -tag -width Er
+.It Bq Er ENFILE
+The system limit on the total number of open files has been reached.
+.It Bq Er EMFILE
+A per-process limit on the number of open files has been reached.
+.It Bq Er EMFILE
+The system limit on the number of inotify descriptors has been reached.
+.It Bq Er EINVAL
+An unrecognized flag was passed to
+.Fn inotify_init1 .
+.El
+.Pp
+The
+.Fn inotify_add_watch
+and
+.Fn inotify_add_watch_at
+system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Ar fd
+parameter is not a valid file descriptor.
+.It Bq Er EINVAL
+The
+.Ar fd
+parameter is not an inotify descriptor.
+.It Bq Er EINVAL
+The
+.Ar mask
+parameter does not specify an event, or
+the
+.Dv IN_MASK_CREATE
+and
+.Dv IN_MASK_ADD
+flags are both set, or an unrecognized flag was passed.
+.It Bq Er ENOTDIR
+The
+.Ar pathname
+parameter refers to a file that is not a directory, and the
+.Dv IN_ONLYDIR
+flag was specified.
+.It Bq Er ENOSPC
+The per-user limit on the total number of inotify watches has been reached.
+.It Bq Er ECAPMODE
+The process is in capability mode and
+.Fn inotify_add_watch
+was called, or
+.Fn inotify_add_watch_at
+was called with
+.Dv AT_FDCWD
+as the directory file descriptor
+.Ar dfd .
+.It Bq Er ENOTCAPABLE
+The process is in capability mode and
+.Ar pathname
+contains a
+.Dq ..
+component leading to a directory outside the directory hierarchy specified
+by
+.Ar dfd .
+.El
+.Pp
+The
+.Fn inotify_rm_watch
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Ar fd
+parameter is not a valid file descriptor.
+.It Bq Er EINVAL
+The
+.Ar fd
+parameter is not an inotify descriptor.
+.It Bq Er EINVAL
+The
+.Ar wd
+parameter is not a valid watch descriptor.
+.El
+.Sh SEE ALSO
+.Xr kevent 2 ,
+.Xr capsicum 4
+.Sh STANDARDS
+The
+.Nm
+interface originates from Linux and is non-standard.
+This implementation aims to be compatible with that of Linux and is based
+on the documentation available at
+.Pa https://man7.org/linux/man-pages/man7/inotify.7.html .
+.Sh HISTORY
+The inotify system calls first appeared in
+.Fx 15.0 .
+.Sh BUGS
+If a file in a watched directory has multiple hard links,
+an access via any hard link for that file will generate an event, even
+if the accessed link belongs to an unwatched directory.
+This is not the case for the Linux implementation, where only accesses
+via the hard link in the watched directory will generate an event.
+.Pp
+If a watched directory contains multiple hard links of a file, an event
+on one of the hard links will generate an inotify record for each link
+in the directory.
+.Pp
+When a file is unlinked, no more events will be generated for that file,
+even if it continues to be accessed.
+By default, the Linux implementation will continue to generate events in
+this case.
+Thus, the
+.Fx
+implementation behaves as though
+.Dv IN_EXCL_UNLINK
+is always set.
diff --git a/lib/libsys/interposing_table.c b/lib/libsys/interposing_table.c
new file mode 100644
index 000000000000..31cdb1511ab8
--- /dev/null
+++ b/lib/libsys/interposing_table.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2014 The FreeBSD Foundation.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include "libc_private.h"
+
+#define SLOT(a, b) \
+ [INTERPOS_##a] = (interpos_func_t)b
+static interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
+ SLOT(accept, __sys_accept),
+ SLOT(accept4, __sys_accept4),
+ SLOT(aio_suspend, __sys_aio_suspend),
+ SLOT(close, __sys_close),
+ SLOT(connect, __sys_connect),
+ SLOT(fcntl, __sys_fcntl),
+ SLOT(fsync, __sys_fsync),
+ SLOT(fork, __sys_fork),
+ SLOT(msync, __sys_msync),
+ SLOT(nanosleep, __sys_nanosleep),
+ SLOT(openat, __sys_openat),
+ SLOT(poll, __sys_poll),
+ SLOT(pselect, __sys_pselect),
+ SLOT(read, __sys_read),
+ SLOT(readv, __sys_readv),
+ SLOT(recvfrom, __sys_recvfrom),
+ SLOT(recvmsg, __sys_recvmsg),
+ SLOT(select, __sys_select),
+ SLOT(sendmsg, __sys_sendmsg),
+ SLOT(sendto, __sys_sendto),
+ SLOT(setcontext, __sys_setcontext),
+ SLOT(sigaction, __sys_sigaction),
+ SLOT(sigprocmask, __sys_sigprocmask),
+ SLOT(sigsuspend, __sys_sigsuspend),
+ SLOT(sigwait, __libsys_sigwait),
+ SLOT(sigtimedwait, __sys_sigtimedwait),
+ SLOT(sigwaitinfo, __sys_sigwaitinfo),
+ SLOT(swapcontext, __sys_swapcontext),
+ SLOT(wait4, __sys_wait4),
+ SLOT(write, __sys_write),
+ SLOT(writev, __sys_writev),
+ SLOT(kevent, __sys_kevent),
+ SLOT(wait6, __sys_wait6),
+ SLOT(ppoll, __sys_ppoll),
+ SLOT(fdatasync, __sys_fdatasync),
+ SLOT(clock_nanosleep, __sys_clock_nanosleep),
+ SLOT(pdfork, __sys_pdfork),
+};
+#undef SLOT
+
+interpos_func_t *
+__libsys_interposing_slot(int interposno)
+{
+ return (&__libsys_interposing[interposno]);
+}
diff --git a/lib/libsys/intro.2 b/lib/libsys/intro.2
new file mode 100644
index 000000000000..008936b278ae
--- /dev/null
+++ b/lib/libsys/intro.2
@@ -0,0 +1,764 @@
+.\"-
+.\" SPDX-License-Identifier: BSD-3-Clause
+.\"
+.\" Copyright (c) 1980, 1983, 1986, 1991, 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.
+.\"
+.Dd April 19, 2024
+.Dt INTRO 2
+.Os
+.Sh NAME
+.Nm intro ,
+.Nm errno
+.Nd introduction to system calls and their error numbers
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/syscall.h
+.In errno.h
+.Sh DESCRIPTION
+This section contains the system calls which comprise the
+.Fx
+programming environment.
+This page also provides an overview of common definitions and concepts
+relevant to system calls, where to find a table of the system calls
+currently available on your system, and their error returns.
+.\".Pp
+.\".Sy System call restart
+.\".Pp
+.\"(more later...)
+.Sh DEFINITIONS
+.Bl -tag -width Ds
+.It Process ID
+Each active process in the system is uniquely identified by a non-negative
+integer called a process ID.
+The range of this ID is from 0 to 99999.
+.It Parent process ID
+A new process is created by a currently active process
+.Pq see Xr fork 2 .
+The parent process ID of a process is initially the process ID of its creator.
+If the creating process exits,
+the parent process ID of each child is set to the ID of the calling process's
+reaper
+.Pq see Xr procctl 2 ,
+normally
+.Xr init 8 .
+.It Process Group
+Each active process is a member of a process group that is identified by
+a non-negative integer called the process group ID.
+This is the process
+ID of the group leader.
+This grouping permits the signaling of related processes
+.Pq see Xr termios 4
+and the job control mechanisms of
+.Xr csh 1 .
+.It Session
+A session is a set of one or more process groups.
+A session is created by a successful call to
+.Xr setsid 2 ,
+which causes the caller to become the only member of the only process
+group in the new session.
+.It Session leader
+A process that has created a new session by a successful call to
+.Xr setsid 2 ,
+is known as a session leader.
+Only a session leader may acquire a terminal as its controlling terminal
+.Pq see Xr termios 4 .
+.It Controlling process
+A session leader with a controlling terminal is a controlling process.
+.It Controlling terminal
+A terminal that is associated with a session is known as the controlling
+terminal for that session and its members.
+.It Terminal Process Group ID
+A terminal may be acquired by a session leader as its controlling terminal.
+Once a terminal is associated with a session, any of the process groups
+within the session may be placed into the foreground by setting
+the terminal process group ID to the ID of the process group.
+This facility is used
+to arbitrate between multiple jobs contending for the same terminal
+.Pq see Xr csh 1 and Xr tty 4 .
+.It Orphaned Process Group
+A process group is considered to be
+.Em orphaned
+if it is not under the control of a job control shell.
+More precisely, a process group is orphaned
+when none of its members has a parent process that is in the same session
+as the group,
+but is in a different process group.
+Note that when a process exits, the parent process for its children
+is normally changed to be
+.Xr init 8 ,
+which is in a separate session.
+Not all members of an orphaned process group are necessarily orphaned
+processes
+.Pq those whose creating process has exited .
+The process group of a session leader is orphaned by definition.
+.It Real User ID and Real Group ID
+Each user on the system is identified by a positive integer
+termed the real user ID.
+.Pp
+Each user is also a member of one or more groups.
+One of these groups is distinguished from others and
+used in implementing accounting facilities.
+The positive
+integer corresponding to this distinguished group is termed
+the real group ID.
+.Pp
+All processes have a real user ID and real group ID.
+These are initialized from the equivalent attributes
+of the process that created it.
+.It Effective User Id, Effective Group Id, and Group Access List
+Access to system resources is governed by two values:
+the effective user ID, and the group access list.
+The first member of the group access list is also known as the
+effective group ID.
+In POSIX.1, the group access list is known as the set of supplementary
+group IDs, and it is unspecified whether the effective group ID is
+a member of the list.
+.Pp
+The effective user ID and effective group ID are initially the
+process's real user ID and real group ID respectively.
+Either
+may be modified through execution of a set-user-ID or set-group-ID file
+.Pq possibly by one its ancestors
+.Pq see Xr execve 2 .
+By convention, the effective group ID
+.Pq the first member of the group access list
+is duplicated, so that the execution of a set-group-ID program
+does not result in the loss of the original
+.Pq real
+group ID.
+.Pp
+The group access list is a set of group IDs
+used only in determining resource accessibility.
+Access checks
+are performed as described below in ``File Access Permissions''.
+.It Saved Set User ID and Saved Set Group ID
+When a process executes a new file, the effective user ID is set
+to the owner of the file if the file is set-user-ID, and the effective
+group ID
+.Pq first element of the group access list
+is set to the group of the file if the file is set-group-ID.
+The effective user ID of the process is then recorded as the saved set-user-ID,
+and the effective group ID of the process is recorded as the saved set-group-ID.
+These values may be used to regain those values as the effective user
+or group ID after reverting to the real ID
+.Pq see Xr setuid 2 .
+In POSIX.1, the saved set-user-ID and saved set-group-ID are optional,
+and are used in setuid and setgid, but this does not work as desired
+for the super-user.
+.It Super-user
+A process is recognized as a
+.Em super-user
+process and is granted special privileges if its effective user ID is 0.
+.It Descriptor
+An integer assigned by the system when a file is referenced
+by
+.Xr open 2
+or
+.Xr dup 2 ,
+or when a socket is created by
+.Xr pipe 2 ,
+.Xr socket 2
+or
+.Xr socketpair 2 ,
+which uniquely identifies an access path to that file or socket from
+a given process or any of its children.
+.It File Name
+Names consisting of up to
+.Brq Dv NAME_MAX
+characters may be used to name
+an ordinary file, special file, or directory.
+.Pp
+These characters may be arbitrary eight-bit values,
+excluding
+.Dv NUL
+.Pq ASCII 0
+and the
+.Ql \&/
+character
+.Pq slash, ASCII 47 .
+.Pp
+Note that it is generally unwise to use
+.Ql \&* ,
+.Ql \&? ,
+.Ql \&[
+or
+.Ql \&]
+as part of
+file names because of the special meaning attached to these characters
+by the shell.
+.It Path Name
+A path name is a
+.Dv NUL Ns -terminated
+character string starting with an
+optional slash
+.Ql \&/ ,
+followed by zero or more directory names separated
+by slashes, optionally followed by a file name.
+The total length of a path name must be less than
+.Brq Dv PATH_MAX
+characters.
+On some systems, this limit may be infinite.
+.Pp
+If a path name begins with a slash, the path search begins at the
+.Em root
+directory.
+Otherwise, the search begins from the current working directory.
+A slash by itself names the root directory.
+An empty
+pathname refers to the current directory.
+.It Directory
+A directory is a special type of file that contains entries
+that are references to other files.
+Directory entries are called links.
+By convention, a directory
+contains at least two links,
+.Ql .\&
+and
+.Ql \&.. ,
+referred to as
+.Em dot
+and
+.Em dot-dot
+respectively.
+Dot refers to the directory itself and
+dot-dot refers to its parent directory.
+.It Root Directory and Current Working Directory
+Each process has associated with it a concept of a root directory
+and a current working directory for the purpose of resolving path
+name searches.
+A process's root directory need not be the root
+directory of the root file system.
+.It File Access Permissions
+Every file in the file system has a set of access permissions.
+These permissions are used in determining whether a process
+may perform a requested operation on the file
+.Pq such as opening a file for writing .
+Access permissions are established at the
+time a file is created.
+They may be changed at some later time
+through the
+.Xr chmod 2
+call.
+.Pp
+File access is broken down according to whether a file may be: read,
+written, or executed.
+Directory files use the execute
+permission to control if the directory may be searched.
+.Pp
+File access permissions are interpreted by the system as
+they apply to three different classes of users: the owner
+of the file, those users in the file's group, anyone else.
+Every file has an independent set of access permissions for
+each of these classes.
+When an access check is made, the system
+decides if permission should be granted by checking the access
+information applicable to the caller.
+.Pp
+Read, write, and execute/search permissions on
+a file are granted to a process if:
+.Pp
+The process's effective user ID is that of the super-user.
+Note that even the super-user cannot execute a non-executable file.
+.Pp
+The process's effective user ID matches the user ID of the owner
+of the file and the owner permissions allow the access.
+.Pp
+The process's effective user ID does not match the user ID of the
+owner of the file, and either the process's effective
+group ID matches the group ID
+of the file, or the group ID of the file is in
+the process's group access list,
+and the group permissions allow the access.
+.Pp
+Neither the effective user ID nor effective group ID
+and group access list of the process
+match the corresponding user ID and group ID of the file,
+but the permissions for ``other users'' allow access.
+.Pp
+Otherwise, permission is denied.
+.It Sockets and Address Families
+A socket is an endpoint for communication between processes.
+Each socket has queues for sending and receiving data.
+.Pp
+Sockets are typed according to their communications properties.
+These properties include whether messages sent and received
+at a socket require the name of the partner, whether communication
+is reliable, the format used in naming message recipients, etc.
+.Pp
+Each instance of the system supports some
+collection of socket types; consult
+.Xr socket 2
+for more information about the types available and
+their properties.
+.Pp
+Each instance of the system supports some number of sets of
+communications protocols.
+Each protocol set supports addresses
+of a certain format.
+An Address Family is the set of addresses
+for a specific group of protocols.
+Each socket has an address
+chosen from the address family in which the socket was created.
+.El
+.Sh FILES
+.Bl -inset -compact
+.It Pa /usr/include/sys/syscall.h
+Table of currently available system calls.
+.El
+.Sh ERRORS
+Nearly all of the system calls provide an error number referenced via
+the external identifier
+.Nm errno .
+This identifier is defined in
+.In sys/errno.h
+as:
+.Pp
+.Dl extern int * __error();
+.Dl #define errno (* __error())
+.Pp
+The
+.Va __error()
+function returns a pointer to a field in the thread specific structure for
+threads other than the initial thread.
+For the initial thread and
+non-threaded processes,
+.Va __error()
+returns a pointer to a global
+.Nm errno
+variable that is compatible with the previous definition.
+.Pp
+When a system call detects an error,
+it returns an integer value
+indicating failure
+.Pq usually -1
+and sets the variable
+.Nm errno
+accordingly.
+This allows interpretation of the failure on receiving
+-1 and to take action accordingly.
+Successful calls never set
+.Nm errno ;
+once set, it remains until another error occurs.
+It should only be examined after an error.
+Note that a number of system calls overload the meanings of these
+error numbers, and that the meanings must be interpreted according
+to the type and circumstances of the call.
+.Pp
+The following is a complete list of the errors and their
+names as given in
+.In sys/errno.h .
+.Bl -hang -width Ds
+.It Er 0 Em "Undefined error: 0" .
+Not used.
+.It Er 1 EPERM Em "Operation not permitted" .
+An attempt was made to perform an operation limited to processes
+with appropriate privileges or to the owner of a file or other
+resources.
+.It Er 2 ENOENT Em "No such file or directory" .
+A component of a specified pathname did not exist, or the
+pathname was an empty string.
+.It Er 3 ESRCH Em "No such process" .
+No process could be found corresponding to that specified by the given
+process ID.
+.It Er 4 EINTR Em "Interrupted system call" .
+An asynchronous signal
+.Pq such as Dv SIGINT or Dv SIGQUIT
+was caught by the process during the execution of an interruptible
+function.
+If the signal handler performs a normal return, the
+interrupted system call will seem to have returned the error condition.
+.It Er 5 EIO Em "Input/output error" .
+Some physical input or output error occurred.
+This error will not be reported until a subsequent operation on the same file
+descriptor and may be lost
+.Pq over written
+by any subsequent errors.
+.It Er 6 ENXIO Em "Device not configured" .
+Input or output on a special file referred to a device that did not
+exist, or
+made a request beyond the limits of the device.
+This error may also occur when, for example,
+a tape drive is not online or no disk pack is
+loaded on a drive.
+.It Er 7 E2BIG Em "Argument list too long" .
+The number of bytes used for the argument and environment
+list of the new process exceeded the current limit
+.Pq Dv NCARGS in In sys/param.h .
+.It Er 8 ENOEXEC Em "Exec format error" .
+A request was made to execute a file
+that, although it has the appropriate permissions,
+was not in the format required for an
+executable file.
+.It Er 9 EBADF Em "Bad file descriptor" .
+A file descriptor argument was out of range, referred to no open file,
+or a read
+.Pq write
+request was made to a file that was only open for writing
+.Pq reading .
+.It Er 10 ECHILD Em "\&No child processes" .
+A
+.Xr wait 2 or Xr waitpid 2
+function was executed by a process that had no existing or unwaited-for
+child processes.
+.It Er 11 EDEADLK Em "Resource deadlock avoided" .
+An attempt was made to lock a system resource that
+would have resulted in a deadlock situation.
+.It Er 12 ENOMEM Em "Cannot allocate memory" .
+The new process image required more memory than was allowed by the hardware
+or by system-imposed memory management constraints.
+A lack of swap space is normally temporary; however,
+a lack of core is not.
+Soft limits may be increased to their corresponding hard limits.
+.It Er 13 EACCES Em "Permission denied" .
+An attempt was made to access a file in a way forbidden
+by its file access permissions.
+.It Er 14 EFAULT Em "Bad address" .
+The system detected an invalid address in attempting to
+use an argument of a call.
+.It Er 15 ENOTBLK Em "Block device required" .
+A block device operation was attempted on a non-block device or file.
+.It Er 16 EBUSY Em "Device busy" .
+An attempt to use a system resource which was in use at the time
+in a manner which would have conflicted with the request.
+.It Er 17 EEXIST Em "File exists" .
+An existing file was mentioned in an inappropriate context,
+for instance, as the new link name in a
+.Xr link 2
+system call.
+.It Er 18 EXDEV Em "Cross-device link" .
+A hard link to a file on another file system
+was attempted.
+.It Er 19 ENODEV Em "Operation not supported by device" .
+An attempt was made to apply an inappropriate
+function to a device,
+for example,
+trying to read a write-only device such as a printer.
+.It Er 20 ENOTDIR Em "Not a directory" .
+A component of the specified pathname existed, but it was
+not a directory, when a directory was expected.
+.It Er 21 EISDIR Em "Is a directory" .
+An attempt was made to open a directory with write mode specified.
+.It Er 22 EINVAL Em "Invalid argument" .
+Some invalid argument was supplied.
+For example, specifying an undefined signal to a
+.Xr signal 3
+function or a
+.Xr kill 2
+system call.
+.It Er 23 ENFILE Em "Too many open files in system" .
+Maximum number of open files allowable on the system
+has been reached and requests for an open cannot be satisfied
+until at least one has been closed.
+.It Er 24 EMFILE Em "Too many open files" .
+Maximum number of file descriptors allowable in the process
+has been reached and requests for an open cannot be satisfied
+until at least one has been closed.
+The
+.Xr getdtablesize 2
+system call will obtain the current limit.
+.It Er 25 ENOTTY Em "Inappropriate ioctl for device" .
+A control function
+.Pq see Xr ioctl 2
+was attempted for a file or
+special device for which the operation was inappropriate.
+.It Er 26 ETXTBSY Em "Text file busy" .
+The new process was a pure procedure
+.Pq shared text
+file which was open for writing by another process, or
+while the pure procedure file was being executed an
+.Xr open 2
+call requested write access.
+.It Er 27 EFBIG Em "File too large" .
+The size of a file exceeded the maximum.
+.It Er 28 ENOSPC Em "No space left on device" .
+A
+.Xr write 2
+to an ordinary file, the creation of a
+directory or symbolic link, or the creation of a directory
+entry failed because no more disk blocks were available
+on the file system, or the allocation of an inode for a newly
+created file failed because no more inodes were available
+on the file system.
+.It Er 29 ESPIPE Em "Illegal seek" .
+An
+.Xr lseek 2
+system call was issued on a socket, pipe or FIFO.
+.It Er 30 EROFS Em "Read-only file system" .
+An attempt was made to modify a file or directory
+on a file system that was read-only at the time.
+.It Er 31 EMLINK Em "Too many links" .
+Maximum allowable hard links to a single file has been exceeded.
+This limit is a filesystem dependent variable
+.Po
+.Va UFS_LINK_MAX No on Xr ufs 4 ,
+.Va FUSE_LINK_MAX No on Xr fusefs 4 , and
+.Va TMPFS_MAX No on Xr tmpfs 4
+.Pc .
+.It Er 32 EPIPE Em "Broken pipe" .
+A write on a pipe, socket or FIFO for which there is no process to read
+the data.
+.It Er 33 EDOM Em "Numerical argument out of domain" .
+A numerical input argument was outside the defined domain of the mathematical
+function.
+.It Er 34 ERANGE Em "Result too large" .
+A numerical result of the function was too large to fit in the
+available space
+.Pq perhaps exceeded precision .
+.It Er 35 EAGAIN Em "Resource temporarily unavailable" .
+This is a temporary condition and later calls to the
+same routine may complete normally.
+.It Er 36 EINPROGRESS Em "Operation now in progress" .
+An operation that takes a long time to complete, such as
+.Xr connect 2 ,
+was attempted on a non-blocking object
+.Pq see Xr fcntl 2 .
+.It Er 37 EALREADY Em "Operation already in progress" .
+An operation was attempted on a non-blocking object that already
+had an operation in progress.
+.It Er 38 ENOTSOCK Em "Socket operation on non-socket" .
+Self-explanatory.
+.It Er 39 EDESTADDRREQ Em "Destination address required" .
+A required address was omitted from an operation on a socket.
+.It Er 40 EMSGSIZE Em "Message too long" .
+A message sent on a socket was larger than the internal message buffer
+or some other network limit.
+.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" .
+A protocol was specified that does not support the semantics of the
+socket type requested.
+For example, you cannot use the ARPA Internet UDP protocol with type
+.Dv SOCK_STREAM .
+.It Er 42 ENOPROTOOPT Em "Protocol not available" .
+A bad option or level was specified in a
+.Xr getsockopt 2
+or
+.Xr setsockopt 2
+call.
+.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" .
+The protocol has not been configured into the
+system or no implementation for it exists.
+.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" .
+The support for the socket type has not been configured into the
+system or no implementation for it exists.
+.It Er 45 EOPNOTSUPP Em "Operation not supported" .
+The attempted operation is not supported for the type of object referenced.
+Usually this occurs when a file descriptor refers to a file or socket
+that cannot support this operation,
+for example, trying to
+.Em accept
+a connection on a datagram socket.
+.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" .
+The protocol family has not been configured into the
+system or no implementation for it exists.
+.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" .
+An address incompatible with the requested protocol was used.
+For example, you should not necessarily expect to be able to use
+NS addresses with ARPA Internet protocols.
+.It Er 48 EADDRINUSE Em "Address already in use" .
+Only one usage of each address is normally permitted.
+.It Er 49 EADDRNOTAVAIL Em "Can't assign requested address" .
+Normally results from an attempt to create a socket with an
+address not on this machine.
+.It Er 50 ENETDOWN Em "Network is down" .
+A socket operation encountered a dead network.
+.It Er 51 ENETUNREACH Em "Network is unreachable" .
+A socket operation was attempted to an unreachable network.
+.It Er 52 ENETRESET Em "Network dropped connection on reset" .
+The host you were connected to crashed and rebooted.
+.It Er 53 ECONNABORTED Em "Software caused connection abort" .
+A connection abort was caused internal to your host machine.
+.It Er 54 ECONNRESET Em "Connection reset by peer" .
+A connection was forcibly closed by a peer.
+This normally
+results from a loss of the connection on the remote socket
+due to a timeout or a reboot.
+.It Er 55 ENOBUFS Em "\&No buffer space available" .
+An operation on a socket or pipe was not performed because
+the system lacked sufficient buffer space or because a queue was full.
+.It Er 56 EISCONN Em "Socket is already connected" .
+A
+.Xr connect 2
+request was made on an already connected socket; or,
+a
+.Xr sendto 2
+or
+.Xr sendmsg 2
+request on a connected socket specified a destination
+when already connected.
+.It Er 57 ENOTCONN Em "Socket is not connected" .
+An request to send or receive data was disallowed because
+the socket was not connected and
+.Pq when sending on a datagram socket
+no address was supplied.
+.It Er 58 ESHUTDOWN Em "Can't send after socket shutdown" .
+A request to send data was disallowed because the socket
+had already been shut down with a previous
+.Xr shutdown 2
+call.
+.It Er 60 ETIMEDOUT Em "Operation timed out" .
+A
+.Xr connect 2
+or
+.Xr send 2
+request failed because the connected party did not
+properly respond after a period of time.
+The timeout period is dependent on the communication protocol.
+.It Er 61 ECONNREFUSED Em "Connection refused" .
+No connection could be made because the target machine actively
+refused it.
+This usually results from trying to connect
+to a service that is inactive on the foreign host.
+.It Er 62 ELOOP Em "Too many levels of symbolic links" .
+A path name lookup involved more than 32
+.Pq Dv MAXSYMLINKS
+symbolic links.
+.It Er 63 ENAMETOOLONG Em "File name too long" .
+A component of a path name exceeded
+.Brq Dv NAME_MAX
+characters, or an entire
+path name exceeded
+.Brq Dv PATH_MAX
+characters.
+See also the description of
+.Dv _PC_NO_TRUNC in Xr pathconf 2 .
+.It Er 64 EHOSTDOWN Em "Host is down" .
+A socket operation failed because the destination host was down.
+.It Er 65 EHOSTUNREACH Em "No route to host" .
+A socket operation was attempted to an unreachable host.
+.It Er 66 ENOTEMPTY Em "Directory not empty" .
+A directory with entries other than
+.Ql .\&
+and
+.Ql ..\&
+was supplied to a remove directory or rename call.
+.It Er 67 EPROCLIM Em "Too many processes" .
+.It Er 68 EUSERS Em "Too many users" .
+The quota system ran out of table entries.
+.It Er 69 EDQUOT Em "Disc quota exceeded" .
+A
+.Xr write 2
+to an ordinary file, the creation of a
+directory or symbolic link, or the creation of a directory
+entry failed because the user's quota of disk blocks was
+exhausted, or the allocation of an inode for a newly
+created file failed because the user's quota of inodes
+was exhausted.
+.It Er 70 ESTALE Em "Stale NFS file handle" .
+An attempt was made to access an open file
+.Pq on an NFS file system
+which is now unavailable as referenced by the file descriptor.
+This may indicate the file was deleted on the NFS server or some
+other catastrophic event occurred.
+.It Er 72 EBADRPC Em "RPC struct is bad" .
+Exchange of RPC information was unsuccessful.
+.It Er 73 ERPCMISMATCH Em "RPC version wrong" .
+The version of RPC on the remote peer is not compatible with
+the local version.
+.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" .
+The requested program is not registered on the remote host.
+.It Er 75 EPROGMISMATCH Em "Program version wrong" .
+The requested version of the program is not available
+on the remote host
+.Pq RPC .
+.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" .
+An RPC call was attempted for a procedure which does not exist
+in the remote program.
+.It Er 77 ENOLCK Em "No locks available" .
+A system-imposed limit on the number of simultaneous file
+locks was reached.
+.It Er 78 ENOSYS Em "Function not implemented" .
+Attempted a system call that is not available on this
+system.
+.It Er 79 EFTYPE Em "Inappropriate file type or format" .
+The file was the wrong type for the operation, or a data file had
+the wrong format.
+.It Er 80 EAUTH Em "Authentication error" .
+Attempted to use an invalid authentication ticket to mount a
+NFS file system.
+.It Er 81 ENEEDAUTH Em "Need authenticator" .
+An authentication ticket must be obtained before the given NFS
+file system may be mounted.
+.It Er 82 EIDRM Em "Identifier removed" .
+An IPC identifier was removed while the current process was waiting on it.
+.It Er 83 ENOMSG Em "No message of desired type" .
+An IPC message queue does not contain a message of the desired type, or a
+message catalog does not contain the requested message.
+.It Er 84 EOVERFLOW Em "Value too large to be stored in data type" .
+A numerical result of the function was too large to be stored in the caller
+provided space.
+.It Er 85 ECANCELED Em "Operation canceled" .
+The scheduled operation was canceled.
+.It Er 86 EILSEQ Em "Illegal byte sequence" .
+While decoding a multibyte character the function came along an
+invalid or an incomplete sequence of bytes or the given wide
+character is invalid.
+.It Er 87 ENOATTR Em "Attribute not found" .
+The specified extended attribute does not exist.
+.It Er 88 EDOOFUS Em "Programming error" .
+A function or API is being abused in a way which could only be detected
+at run-time.
+.It Er 89 EBADMSG Em "Bad message" .
+A corrupted message was detected.
+.It Er 90 EMULTIHOP Em "Multihop attempted" .
+This error code is unused, but present for compatibility with other systems.
+.It Er 91 ENOLINK Em "Link has been severed" .
+This error code is unused, but present for compatibility with other systems.
+.It Er 92 EPROTO Em "Protocol error" .
+A device or socket encountered an unrecoverable protocol error.
+.It Er 93 ENOTCAPABLE Em "Capabilities insufficient" .
+An operation on a capability file descriptor requires greater privilege than
+the capability allows.
+.It Er 94 ECAPMODE Em "Not permitted in capability mode" .
+The system call or operation is not permitted for capability mode processes.
+.It Er 95 ENOTRECOVERABLE Em "State not recoverable" .
+The state protected by a robust mutex is not recoverable.
+.It Er 96 EOWNERDEAD Em "Previous owner died" .
+The owner of a robust mutex terminated while holding the mutex lock.
+.It Er 97 EINTEGRITY Em "Integrity check failed" .
+An integrity check such as a check-hash or a cross-correlation failed.
+The integrity error falls in the kernel I/O stack between
+.Er EINVAL
+that identifies errors in parameters to a system call and
+.Er EIO
+that identifies errors with the underlying storage media.
+It is typically raised by intermediate kernel layers such as a
+filesystem or an in-kernel GEOM subsystem when they detect inconsistencies.
+Uses include allowing the
+.Xr mount 8
+command to return a different exit value to automate the running of
+.Xr fsck 8
+during a system boot.
+.El
+.Sh SEE ALSO
+.Xr intro 3 ,
+.Xr perror 3
+.Sh HISTORY
+The
+.Nm Ns Pq 2
+manual page first appeared in
+.At v5 .
diff --git a/lib/libsys/ioctl.2 b/lib/libsys/ioctl.2
new file mode 100644
index 000000000000..e96c5c48d097
--- /dev/null
+++ b/lib/libsys/ioctl.2
@@ -0,0 +1,151 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd September 11, 2013
+.Dt IOCTL 2
+.Os
+.Sh NAME
+.Nm ioctl
+.Nd control device
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/ioctl.h
+.Ft int
+.Fn ioctl "int fd" "unsigned long request" ...
+.Sh DESCRIPTION
+The
+.Fn ioctl
+system call manipulates the underlying device parameters of special files.
+In particular, many operating
+characteristics of character special files (e.g.\& terminals)
+may be controlled with
+.Fn ioctl
+requests.
+The argument
+.Fa fd
+must be an open file descriptor.
+.Pp
+The third argument to
+.Fn ioctl
+is traditionally named
+.Va "char *argp" .
+Most uses of
+.Fn ioctl ,
+however, require the third argument to be a
+.Vt caddr_t
+or an
+.Vt int .
+.Pp
+An
+.Fn ioctl
+.Fa request
+has encoded in it whether the argument is an
+.Dq in
+argument
+or
+.Dq out
+argument, and the size of the argument
+.Fa argp
+in bytes.
+Macros and defines used in specifying an ioctl
+.Fa request
+are located in the file
+.In sys/ioctl.h .
+.Sh GENERIC IOCTLS
+Some generic ioctls are not implemented for all types of file
+descriptors.
+These include:
+.Bl -tag -width "xxxxxx"
+.It Dv FIONREAD int
+Get the number of bytes that are immediately available for reading.
+.It Dv FIONWRITE int
+Get the number of bytes in the descriptor's send queue.
+These bytes are data which has been written to the descriptor but
+which are being held by the kernel for further processing.
+The nature of the required processing depends on the underlying device.
+For TCP sockets, these bytes have not yet been acknowledged by the
+other side of the connection.
+.It Dv FIONSPACE int
+Get the free space in the descriptor's send queue.
+This value is the size of the send queue minus the number of bytes
+being held in the queue.
+Note: while this value represents the number of bytes that may be
+added to the queue, other resource limitations may cause a write
+not larger than the send queue's space to be blocked.
+One such limitation would be a lack of network buffers for a write
+to a network connection.
+.El
+.Sh RETURN VALUES
+If an error has occurred, a value of -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn ioctl
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid descriptor.
+.It Bq Er ENOTTY
+The
+.Fa fd
+argument
+is not associated with a character
+special device.
+.It Bq Er ENOTTY
+The specified request does not apply to the kind
+of object that the descriptor
+.Fa fd
+references.
+.It Bq Er EINVAL
+The
+.Fa request
+or
+.Fa argp
+argument
+is not valid.
+.It Bq Er EFAULT
+The
+.Fa argp
+argument
+points outside the process's allocated address space.
+.El
+.Sh SEE ALSO
+.Xr execve 2 ,
+.Xr fcntl 2 ,
+.Xr intro 4 ,
+.Xr tty 4
+.Sh HISTORY
+The
+.Fn ioctl
+function appeared in
+.At v7 .
diff --git a/lib/libc/sys/issetugid.2 b/lib/libsys/issetugid.2
index 148fba563f71..148fba563f71 100644
--- a/lib/libc/sys/issetugid.2
+++ b/lib/libsys/issetugid.2
diff --git a/lib/libsys/jail.2 b/lib/libsys/jail.2
new file mode 100644
index 000000000000..8f8b9925c712
--- /dev/null
+++ b/lib/libsys/jail.2
@@ -0,0 +1,414 @@
+.\" Copyright (c) 1999 Poul-Henning Kamp.
+.\" Copyright (c) 2009 James Gritton.
+.\" 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.
+.\"
+.Dd November 29, 2023
+.Dt JAIL 2
+.Os
+.Sh NAME
+.Nm jail ,
+.Nm jail_get ,
+.Nm jail_set ,
+.Nm jail_remove ,
+.Nm jail_attach
+.Nd create and manage system jails
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/jail.h
+.Ft int
+.Fn jail "struct jail *jail"
+.Ft int
+.Fn jail_attach "int jid"
+.Ft int
+.Fn jail_remove "int jid"
+.In sys/uio.h
+.Ft int
+.Fn jail_get "struct iovec *iov" "u_int niov" "int flags"
+.Ft int
+.Fn jail_set "struct iovec *iov" "u_int niov" "int flags"
+.Sh DESCRIPTION
+The
+.Fn jail
+system call sets up a jail and locks the current process in it.
+.Pp
+The argument is a pointer to a structure describing the prison:
+.Bd -literal -offset indent
+struct jail {
+ uint32_t version;
+ char *path;
+ char *hostname;
+ char *jailname;
+ unsigned int ip4s;
+ unsigned int ip6s;
+ struct in_addr *ip4;
+ struct in6_addr *ip6;
+};
+.Ed
+.Pp
+.Dq Li version
+defines the version of the API in use.
+.Dv JAIL_API_VERSION
+is defined for the current version.
+.Pp
+The
+.Dq Li path
+pointer should be set to the directory which is to be the root of the
+prison.
+.Pp
+The
+.Dq Li hostname
+pointer can be set to the hostname of the prison.
+This can be changed
+from the inside of the prison.
+.Pp
+The
+.Dq Li jailname
+pointer is an optional name that can be assigned to the jail
+for example for management purposes.
+.Pp
+The
+.Dq Li ip4s
+and
+.Dq Li ip6s
+give the numbers of IPv4 and IPv6 addresses that will be passed
+via their respective pointers.
+.Pp
+The
+.Dq Li ip4
+and
+.Dq Li ip6
+pointers can be set to an arrays of IPv4 and IPv6 addresses to be assigned to
+the prison, or NULL if none.
+IPv4 addresses must be in network byte order.
+.Pp
+This is equivalent to, and deprecated in favor of, the
+.Fn jail_set
+system call (see below), with the parameters
+.Va path ,
+.Va host.hostname ,
+.Va name ,
+.Va ip4.addr ,
+and
+.Va ip6.addr ,
+and with the
+.Dv JAIL_ATTACH
+flag.
+.Pp
+The
+.Fn jail_set
+system call creates a new jail, or modifies an existing one, and optionally
+locks the current process in it.
+Jail parameters are passed as an array of name-value pairs in the array
+.Fa iov ,
+containing
+.Fa niov
+elements.
+Parameter names are a null-terminated string, and values may be strings,
+integers, or other arbitrary data.
+Some parameters are boolean, and do not have a value (their length is zero)
+but are set by the name alone with or without a
+.Dq no
+prefix, e.g.
+.Va persist
+or
+.Va nopersist .
+Any parameters not set will be given default values, generally based on
+the current environment.
+.Pp
+Jails have a set of core parameters, and modules can add their own jail
+parameters.
+The current set of available parameters, and their formats, can be
+retrieved via the
+.Va security.jail.param
+sysctl MIB entry.
+Notable parameters include those mentioned in the
+.Fn jail
+description above, as well as
+.Va jid
+and
+.Va name ,
+which identify the jail being created or modified.
+See
+.Xr jail 8
+for more information on the core jail parameters.
+.Pp
+The
+.Fa flags
+arguments consists of one or more of the following flags:
+.Bl -tag -width indent
+.It Dv JAIL_CREATE
+Create a new jail.
+If a
+.Va jid
+or
+.Va name
+parameters exists, they must not refer to an existing jail.
+.It Dv JAIL_UPDATE
+Modify an existing jail.
+One of the
+.Va jid
+or
+.Va name
+parameters must exist, and must refer to an existing jail.
+If both
+.Dv JAIL_CREATE
+and
+.Dv JAIL_UPDATE
+are set, a jail will be created if it does not yet exist, and modified if it
+does exist.
+.It Dv JAIL_ATTACH
+In addition to creating or modifying the jail, attach the current process to
+it, as with the
+.Fn jail_attach
+system call.
+.It Dv JAIL_DYING
+This is deprecated in
+.Fn jail_set
+and has no effect.
+.El
+.Pp
+The
+.Fn jail_get
+system call retrieves jail parameters, using the same name-value list as
+.Fn jail_set
+in the
+.Fa iov
+and
+.Fa niov
+arguments.
+The jail to read can be specified by either
+.Va jid
+or
+.Va name
+by including those parameters in the list.
+If they are included but are not intended to be the search key, they
+should be cleared (zero and the empty string respectively).
+.Pp
+The special parameter
+.Va lastjid
+can be used to retrieve a list of all jails.
+It will fetch the jail with the jid above and closest to the passed value.
+The first jail (usually but not always jid 1) can be found by passing a
+.Va lastjid
+of zero.
+.Pp
+The
+.Fa flags
+arguments consists of one or more following flags:
+.Bl -tag -width indent
+.It Dv JAIL_DYING
+Allow getting a jail that is in the process of being removed.
+.El
+.Pp
+The
+.Fn jail_attach
+system call attaches the current process to an existing jail,
+identified by
+.Fa jid .
+It changes the process's root and current directories to the jail's
+.Va path
+directory.
+.Pp
+The
+.Fn jail_remove
+system call removes the jail identified by
+.Fa jid .
+It will kill all processes belonging to the jail, and remove any children
+of that jail.
+.Sh RETURN VALUES
+If successful,
+.Fn jail ,
+.Fn jail_set ,
+and
+.Fn jail_get
+return a non-negative integer, termed the jail identifier (JID).
+They return \-1 on failure, and set
+.Va errno
+to indicate the error.
+.Pp
+.Rv -std jail_attach jail_remove
+.Sh ERRORS
+The
+.Fn jail
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+This process is not allowed to create a jail, either because it is not
+the super-user, or because it would exceed the jail's
+.Va children.max
+limit.
+.It Bq Er EFAULT
+.Fa jail
+points to an address outside the allocated address space of the process.
+.It Bq Er EINVAL
+The version number of the argument is not correct.
+.It Bq Er EAGAIN
+No free JID could be found.
+.El
+.Pp
+The
+.Fn jail_set
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+This process is not allowed to create a jail, either because it is not
+the super-user, or because it would exceed the jail's
+.Va children.max
+limit.
+.It Bq Er EPERM
+A jail parameter was set to a less restrictive value then the current
+environment.
+.It Bq Er EFAULT
+.Fa Iov ,
+or one of the addresses contained within it,
+points to an address outside the allocated address space of the process.
+.It Bq Er ENOENT
+The jail referred to by a
+.Va jid
+or
+.Va name
+parameter does not exist, and the
+.Dv JAIL_CREATE
+flag is not set.
+.It Bq Er ENOENT
+The jail referred to by a
+.Va jid
+is not accessible by the process, because the process is in a different
+jail.
+.It Bq Er EEXIST
+The jail referred to by a
+.Va jid
+or
+.Va name
+parameter exists, and the
+.Dv JAIL_UPDATE
+flag is not set.
+.It Bq Er EINVAL
+A supplied parameter is the wrong size.
+.It Bq Er EINVAL
+A supplied parameter is out of range.
+.It Bq Er EINVAL
+A supplied string parameter is not null-terminated.
+.It Bq Er EINVAL
+A supplied parameter name does not match any known parameters.
+.It Bq Er EINVAL
+One of the
+.Dv JAIL_CREATE
+or
+.Dv JAIL_UPDATE
+flags is not set.
+.It Bq Er ENAMETOOLONG
+A supplied string parameter is longer than allowed.
+.It Bq Er EAGAIN
+There are no jail IDs left.
+.El
+.Pp
+The
+.Fn jail_get
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+.Fa Iov ,
+or one of the addresses contained within it,
+points to an address outside the allocated address space of the process.
+.It Bq Er ENOENT
+The jail referred to by a
+.Va jid
+or
+.Va name
+parameter does not exist.
+.It Bq Er ENOENT
+The jail referred to by a
+.Va jid
+is not accessible by the process, because the process is in a different
+jail.
+.It Bq Er ENOENT
+The
+.Va lastjid
+parameter is greater than the highest current jail ID.
+.It Bq Er EINVAL
+A supplied parameter is the wrong size.
+.It Bq Er EINVAL
+A supplied parameter name does not match any known parameters.
+.El
+.Pp
+The
+.Fn jail_attach
+and
+.Fn jail_remove
+system calls
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+A user other than the super-user attempted to attach to or remove a jail.
+.It Bq Er EINVAL
+The jail specified by
+.Fa jid
+does not exist.
+.El
+.Pp
+Further
+.Fn jail ,
+.Fn jail_set ,
+and
+.Fn jail_attach
+call
+.Xr chroot 2
+internally, so they can fail for all the same reasons.
+Please consult the
+.Xr chroot 2
+manual page for details.
+.Sh SEE ALSO
+.Xr chdir 2 ,
+.Xr chroot 2 ,
+.Xr jail 8
+.Sh HISTORY
+The
+.Fn jail
+system call appeared in
+.Fx 4.0 .
+The
+.Fn jail_attach
+system call appeared in
+.Fx 5.1 .
+The
+.Fn jail_set ,
+.Fn jail_get ,
+and
+.Fn jail_remove
+system calls appeared in
+.Fx 8.0 .
+.Sh AUTHORS
+The jail feature was written by
+.An Poul-Henning Kamp
+for R&D Associates
+who contributed it to
+.Fx .
+.An James Gritton
+added the extensible jail parameters and hierarchical jails.
diff --git a/lib/libsys/kcmp.2 b/lib/libsys/kcmp.2
new file mode 100644
index 000000000000..5491e09b918b
--- /dev/null
+++ b/lib/libsys/kcmp.2
@@ -0,0 +1,230 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Mark Johnston <markj@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd January 23, 2024
+.Dt KCMP 2
+.Os
+.Sh NAME
+.Nm kcmp
+.Nd compare two kernel objects
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn kcmp "pid_t pid1" "pid_t pid2" "int type" "uintptr_t idx1" "uintptr_t idx2"
+.Sh DESCRIPTION
+The
+.Nm
+system call allows the caller to determine whether the two processes with
+PIDs
+.Fa pid1
+and
+.Fa pid2
+reference the same kernel object.
+The
+.Fa type
+parameter specifies the type of object, and
+.Fa idx1
+and
+.Fa idx2
+are identifiers which refer to some object in the context of process
+.Fa pid1
+and
+.Fa pid2 ,
+respectively.
+.Pp
+The following values for
+.Fa type
+may be specified:
+.Bl -tag -width KCMP_FILE
+.It Dv KCMP_FILE
+Compare two file descriptions referred to by file descriptors
+.Fa idx1
+and
+.Fa idx2 .
+They may be equivalent if, for example, one of the descriptors was
+created by applying
+.Xr dup 2
+to the other descriptor.
+.It Dv KCMP_FILEOBJ
+Perform a
+.Dq deep comparison
+of the file descriptions referred to by file descriptors
+.Fa idx1
+and
+.Fa idx2 .
+This tests whether the underlying object referred to by the file descriptions
+is the same.
+For example, if the same filesystem path is opened twice, the kernel will create
+two separate file descriptions to back the two file descriptors, but they will
+refer to the same underlying object, a
+.Xr vnode 9 .
+When compared using the
+.Dv KCMP_FILE
+type, these descriptors will be different, but using the
+.Dv KCMP_FILEOBJ
+type, they will be equal (assuming that the path was not unlinked in between
+the two opens).
+.It Dv KCMP_FILES
+Determine whether the two processes share the same file descriptor table.
+This will be the case if one of the processes was created by
+.Xr rfork 2
+without specifying the
+.Dv RFFDG
+flag.
+The
+.Fa idx1
+and
+.Fa idx2
+parameters are ignored.
+.It Dv KCMP_SIGHAND
+Determine whether the two processes share the same signal handler table.
+This will be the case if one of the processes was created using the
+.Dv RFSIGSHARE
+flag to
+.Xr rfork 2 .
+The
+.Fa idx1
+and
+.Fa idx2
+parameters are ignored.
+.It Dv KCMP_VM
+Determine whether the two processes share a virtual memory address space.
+This may be the case if one of the processes created the other using
+.Xr vfork 2
+or
+.Xr rfork 2
+with the
+.Dv RFMEM
+flag.
+The
+.Fa idx1
+and
+.Fa idx2
+parameters are ignored.
+.El
+The caller of
+.Nm
+must have permission to debug both processes, otherwise the system call
+will fail.
+.Sh RETURN VALUES
+If
+.Fa idx1
+and
+.Fa idx2
+refer to the same object,
+.Nm
+returns 0.
+If the object referred to by
+.Fa pid1
+and
+.Fa idx1
+is less or greater than the object referred to by
+.Fa pid2
+and
+.Fa idx2 ,
+.Nm
+returns the values 1 and 2, respectively.
+The order is defined internally by the kernel and is stable until the system
+reboots.
+If the two objects cannot be compared for some reason,
+.Nm
+returns 3.
+For example, if
+.Fa type
+is
+.Dv KCMP_FILEOBJ
+and
+.Fa idx1
+and
+.Fa idx2
+are different descriptor types, e.g., a socket and a file, then
+.Nm
+will return 3.
+.Pp
+If an error occurs, the value -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+.Nm
+may fail with the following errors:
+.Bl -tag -width Er
+.It Bq Er ENODEV
+.Dv KCMP_FILEOBJ
+was specified and
+.Fa idx1
+refers to a file descriptor which does not implement a comparison operator.
+.It Bq Er EINVAL
+The value of
+.Fa type
+is invalid.
+.It Bq Er EBADF
+One of the file descriptors referred to by
+.Fa idx1
+or
+.Fa idx2
+is not valid.
+.It Bq Er ESRCH
+One of the processes referred to by
+.Fa pid1
+or
+.Fa pid2
+does not exist or is not visible (e.g., due to jail restrictions).
+.It Bq Er EPERM
+The caller does not have permission to access one of the processes referred to
+by
+.Fa pid1
+or
+.Fa pid2 .
+.El
+.Sh SEE ALSO
+.Xr dup 2 ,
+.Xr fcntl 2 ,
+.Xr fork 2 ,
+.Xr rfork 2 ,
+.Xr vfork 2
+.Sh STANDARDS
+The
+.Nm
+system call originated in Linux.
+This implementation aims to be source-compatible with the Linux implementation.
+.Fx
+implements only a subset of the possible values for
+.Fa type
+supported in Linux.
+More values may be added in the future.
+The
+.Dv KCMP_FILEOBJ
+type is a FreeBSD extension.
+.Sh HISTORY
+The
+.Nm
+function was introduced in
+.Fx 14.1 .
diff --git a/lib/libc/sys/kenv.2 b/lib/libsys/kenv.2
index 9f179ff2faa6..9f179ff2faa6 100644
--- a/lib/libc/sys/kenv.2
+++ b/lib/libsys/kenv.2
diff --git a/lib/libsys/kill.2 b/lib/libsys/kill.2
new file mode 100644
index 000000000000..bc2f3e03a726
--- /dev/null
+++ b/lib/libsys/kill.2
@@ -0,0 +1,156 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd December 1, 2019
+.Dt KILL 2
+.Os
+.Sh NAME
+.Nm kill
+.Nd send signal to a process
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In signal.h
+.Ft int
+.Fn kill "pid_t pid" "int sig"
+.Sh DESCRIPTION
+The
+.Fn kill
+system call sends the signal given by
+.Fa sig
+to
+.Fa pid ,
+a
+process or a group of processes.
+The
+.Fa sig
+argument
+may be one of the signals specified in
+.Xr sigaction 2
+or it may be 0, in which case
+error checking is performed but no
+signal is actually sent.
+This can be used to check the validity of
+.Fa pid .
+.Pp
+For a process to have permission to send a signal to a process designated
+by
+.Fa pid ,
+the user must be the super-user, or
+the real or saved user ID of the receiving process must match
+the real or effective user ID of the sending process.
+A single exception is the signal SIGCONT, which may always be sent
+to any process with the same session ID as the sender.
+In addition, if the
+.Va security.bsd.conservative_signals
+.Xr sysctl 9
+is set to 1, the user is not a super-user, and
+the receiver is set-uid, then
+only job control and terminal control signals may
+be sent (in particular, only SIGKILL, SIGINT, SIGTERM, SIGALRM,
+SIGSTOP, SIGTTIN, SIGTTOU, SIGTSTP, SIGHUP, SIGUSR1, SIGUSR2).
+.Bl -tag -width Ds
+.It \&If Fa pid No \&is greater than zero :
+The
+.Fa sig
+signal
+is sent to the process whose ID is equal to
+.Fa pid .
+.It \&If Fa pid No \&is zero :
+The
+.Fa sig
+signal
+is sent to all processes whose group ID is equal
+to the process group ID of the sender, and for which the
+process has permission;
+this is a variant of
+.Xr killpg 2 .
+.It \&If Fa pid No \&is -1 :
+If the user has super-user privileges,
+the signal is sent to all processes excluding
+system processes
+(with
+.Dv P_SYSTEM
+flag set),
+process with ID 1
+(usually
+.Xr init 8 ) ,
+and the process sending the signal.
+If the user is not the super user, the signal is sent to all processes
+which the caller has permissions to, excluding the process sending the signal.
+No error is returned if any process could be signaled.
+.El
+.Pp
+If the process number is negative but not -1,
+the signal is sent to all processes whose process group ID
+is equal to the absolute value of the process number.
+This is a variant of
+.Xr killpg 2 .
+.Sh RETURN VALUES
+.Rv -std kill
+.Sh ERRORS
+The
+.Fn kill
+system call
+will fail and no signal will be sent if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa sig
+argument
+is not a valid signal number.
+.It Bq Er ESRCH
+No process or process group can be found corresponding to that specified by
+.Fa pid .
+.It Bq Er EPERM
+The sending process does not have permission to send
+.Va sig
+to any receiving process.
+.El
+.Sh SEE ALSO
+.Xr getpgrp 2 ,
+.Xr getpid 2 ,
+.Xr killpg 2 ,
+.Xr sigaction 2 ,
+.Xr sigqueue 2 ,
+.Xr raise 3 ,
+.Xr init 8
+.Sh STANDARDS
+The
+.Fn kill
+system call is expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+A version of the
+.Fn kill
+function appeared in
+.At v3 .
+The signal number was added to the
+.Fn kill
+function in
+.At v4 .
diff --git a/lib/libsys/kldfind.2 b/lib/libsys/kldfind.2
new file mode 100644
index 000000000000..5ede0d1e1464
--- /dev/null
+++ b/lib/libsys/kldfind.2
@@ -0,0 +1,83 @@
+.\"
+.\" Copyright (c) 1999 Chris Costello
+.\" 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.
+.\"
+.Dd March 3, 1999
+.Dt KLDFIND 2
+.Os
+.Sh NAME
+.Nm kldfind
+.Nd returns the fileid of a kld file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldfind "const char *file"
+.Sh DESCRIPTION
+The
+.Fn kldfind
+system call
+returns the fileid of the kld file referenced by
+.Fa file .
+.Sh RETURN VALUES
+The
+.Fn kldfind
+system call
+returns the fileid of the kld file referenced by
+.Fa file .
+Upon error,
+.Fn kldfind
+returns -1 and sets
+.Va errno
+to indicate the error.
+.Sh ERRORS
+.Va errno
+is set to the following if
+.Fn kldfind
+fails:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The data required for this operation could not be read from the kernel space.
+.It Bq Er ENOENT
+The file specified is not loaded in the kernel.
+.El
+.Sh SEE ALSO
+.Xr kldfirstmod 2 ,
+.Xr kldload 2 ,
+.Xr kldnext 2 ,
+.Xr kldstat 2 ,
+.Xr kldsym 2 ,
+.Xr kldunload 2 ,
+.Xr modfind 2 ,
+.Xr modfnext 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4 ,
+.Xr kldstat 8
+.Sh HISTORY
+The
+.Nm kld
+interface first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/kldfirstmod.2 b/lib/libsys/kldfirstmod.2
new file mode 100644
index 000000000000..b6dbab2c94b7
--- /dev/null
+++ b/lib/libsys/kldfirstmod.2
@@ -0,0 +1,73 @@
+.\"
+.\" Copyright (c) 1999 Chris Costello
+.\" 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.
+.\"
+.Dd March 3, 1999
+.Dt KLDFIRSTMOD 2
+.Os
+.Sh NAME
+.Nm kldfirstmod
+.Nd "return first module id from the kld file specified"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldfirstmod "int fileid"
+.Sh DESCRIPTION
+The
+.Fn kldfirstmod
+system call returns the module id pertaining to the first module referenced by
+.Fa fileid .
+.Sh RETURN VALUES
+The
+.Fn kldfirstmod
+will return the id of the first module referenced by
+.Fa fileid
+or 0 if there are no references.
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er ENOENT
+The kld file referenced by
+.Fa fileid
+was not found.
+.El
+.Sh SEE ALSO
+.Xr kldfind 2 ,
+.Xr kldload 2 ,
+.Xr kldnext 2 ,
+.Xr kldstat 2 ,
+.Xr kldsym 2 ,
+.Xr kldunload 2 ,
+.Xr modfind 2 ,
+.Xr modfnext 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4 ,
+.Xr kldstat 8
+.Sh HISTORY
+The
+.Nm kld
+interface first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/kldload.2 b/lib/libsys/kldload.2
new file mode 100644
index 000000000000..63a13c328d58
--- /dev/null
+++ b/lib/libsys/kldload.2
@@ -0,0 +1,93 @@
+.\"
+.\" Copyright (c) 1999 Chris Costello
+.\" 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.
+.\"
+.Dd March 3, 1999
+.Dt KLDLOAD 2
+.Os
+.Sh NAME
+.Nm kldload
+.Nd load KLD files into the kernel
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldload "const char *file"
+.Sh DESCRIPTION
+The
+.Fn kldload
+system call
+loads a kld file into the kernel using the kernel linker.
+.Sh RETURN VALUES
+The
+.Fn kldload
+system call
+returns the fileid of the kld file which was loaded into the kernel.
+If an error occurs,
+.Fn kldload
+will return -1 and set
+.Va errno
+to indicate the error.
+.Sh ERRORS
+The named file is loaded unless:
+.Bl -tag -width Er
+.It Bq Er EPERM
+You do not have access to read the file or link it with the kernel.
+You should be the root user to be able to use the
+.Nm kld
+system calls.
+.It Bq Er EFAULT
+Bad address encountered when adding kld info into the kernel space.
+.It Bq Er ENOMEM
+There is no memory to load the file into the kernel.
+.It Bq Er ENOENT
+The file was not found.
+.It Bq Er ENOEXEC
+The file format of
+.Fa file
+was unrecognized.
+.It Bq Er EEXIST
+The supplied
+.Fa file
+has already been loaded.
+.El
+.Sh SEE ALSO
+.Xr kldfind 2 ,
+.Xr kldfirstmod 2 ,
+.Xr kldnext 2 ,
+.Xr kldstat 2 ,
+.Xr kldsym 2 ,
+.Xr kldunload 2 ,
+.Xr modfind 2 ,
+.Xr modfnext 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4 ,
+.Xr kldload 8
+.Sh HISTORY
+The
+.Nm kld
+interface first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/kldnext.2 b/lib/libsys/kldnext.2
new file mode 100644
index 000000000000..28b14dfc3035
--- /dev/null
+++ b/lib/libsys/kldnext.2
@@ -0,0 +1,86 @@
+.\"
+.\" Copyright (c) 1999 Chris Costello
+.\" 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.
+.\"
+.Dd February 22, 2006
+.Dt KLDNEXT 2
+.Os
+.Sh NAME
+.Nm kldnext
+.Nd return the fileid of the next kld file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldnext "int fileid"
+.Sh DESCRIPTION
+The
+.Fn kldnext
+system call
+returns the fileid of the next kld file (that is, the one after
+.Fa fileid )
+or 0 if
+.Fa fileid
+is the last file loaded.
+To get the fileid of the first kld file, pass
+.Fa fileid
+of 0 to
+.Fn kldnext .
+.Sh RETURN VALUES
+The
+.Fn kldnext
+system call
+returns the fileid of the next kld file or 0 if successful.
+Otherwise
+.Fn kldnext
+returns the value \-1 and sets the global variable
+.Va errno
+to indicate the error.
+.Sh ERRORS
+The only error set by
+.Fn kldnext
+is
+.Er ENOENT ,
+which is set when
+.Fa fileid
+refers to a kld file that does not exist (is not loaded).
+.Sh SEE ALSO
+.Xr kldfind 2 ,
+.Xr kldfirstmod 2 ,
+.Xr kldload 2 ,
+.Xr kldstat 2 ,
+.Xr kldsym 2 ,
+.Xr kldunload 2 ,
+.Xr modfind 2 ,
+.Xr modfnext 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4 ,
+.Xr kldstat 8
+.Sh HISTORY
+The
+.Nm kld
+interface first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/kldstat.2 b/lib/libsys/kldstat.2
new file mode 100644
index 000000000000..111323a0da8d
--- /dev/null
+++ b/lib/libsys/kldstat.2
@@ -0,0 +1,130 @@
+.\"
+.\" Copyright (c) 1999 Chris Costello
+.\" 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.
+.\"
+.Dd March 28, 2012
+.Dt KLDSTAT 2
+.Os
+.Sh NAME
+.Nm kldstat
+.Nd get status of kld file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldstat "int fileid" "struct kld_file_stat *stat"
+.Sh DESCRIPTION
+The
+.Fn kldstat
+system call writes the info for the file referred to by
+.Fa fileid
+into
+.Fa stat .
+.Bd -literal
+struct kld_file_stat {
+ int version; /* set to sizeof(struct kld_file_stat) */
+ char name[MAXPATHLEN];
+ int refs;
+ int id;
+ caddr_t address;
+ size_t size;
+ char pathname[MAXPATHLEN];
+};
+.Ed
+.Bl -tag -width XXXaddress
+.It version
+This field is set to the size of the structure mentioned above by the code
+calling
+.Fn kldstat ,
+and not
+.Fn kldstat
+itself.
+.It name
+The name of the file referred to by
+.Fa fileid .
+.It refs
+The number of modules referenced by
+.Fa fileid .
+.It id
+The id of the file specified in
+.Fa fileid .
+.It address
+The load address of the kld file.
+.It size
+The amount of memory in bytes allocated by the file.
+.It pathname
+The full name of the file referred to by
+.Fa fileid ,
+including the path.
+.El
+.Sh RETURN VALUES
+.Rv -std kldstat
+.Sh ERRORS
+The information for the file referred to by
+.Fa fileid
+is filled into the structure pointed to by
+.Fa stat
+unless:
+.Bl -tag -width Er
+.It Bq Er ENOENT
+The file was not found (probably not loaded).
+.It Bq Er EINVAL
+The version specified in the
+.Fa version
+field of stat is not the proper version.
+You would need to rebuild world, the
+kernel, or your application, if this error occurs, given that you did properly
+fill in the
+.Fa version
+field.
+.It Bq Er EFAULT
+There was a problem copying one, some, or all of the fields into
+.Fa stat
+in the
+.Xr copyout 9
+function.
+.El
+.Sh SEE ALSO
+.Xr kldfind 2 ,
+.Xr kldfirstmod 2 ,
+.Xr kldload 2 ,
+.Xr kldnext 2 ,
+.Xr kldsym 2 ,
+.Xr kldunload 2 ,
+.Xr modfind 2 ,
+.Xr modfnext 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4 ,
+.Xr kldstat 8
+.Sh HISTORY
+The
+.Nm kld
+interface first appeared in
+.Fx 3.0 .
+.Sh BUGS
+The pathname may not be accurate if the file system mounts have
+changed since the module was loaded, or if this function is called
+within a chrooted environment.
diff --git a/lib/libsys/kldsym.2 b/lib/libsys/kldsym.2
new file mode 100644
index 000000000000..641fc26c38ec
--- /dev/null
+++ b/lib/libsys/kldsym.2
@@ -0,0 +1,118 @@
+.\" Copyright (c) 2001 Chris Costello <chris@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.
+.\"
+.Dd October 17, 2016
+.Dt KLDSYM 2
+.Os
+.Sh NAME
+.Nm kldsym
+.Nd look up address by symbol name in a KLD
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldsym "int fileid" "int cmd" "void *data"
+.Sh DESCRIPTION
+The
+.Fn kldsym
+system call returns the address of the symbol specified in
+.Fa data
+in the module specified by
+.Fa fileid .
+If
+.Fa fileid
+is 0, all loaded modules are searched.
+Currently, the only
+.Fa cmd
+implemented is
+.Dv KLDSYM_LOOKUP .
+.Pp
+The
+.Fa data
+argument is of the following structure:
+.Bd -literal -offset indent
+struct kld_sym_lookup {
+ int version; /* sizeof(struct kld_sym_lookup) */
+ char *symname; /* Symbol name we are looking up */
+ u_long symvalue;
+ size_t symsize;
+};
+.Ed
+.Pp
+The
+.Va version
+member is to be set
+by the code calling
+.Fn kldsym
+to
+.Fn sizeof "struct kld_sym_lookup" .
+The next two members,
+.Va version
+and
+.Va symname ,
+are specified by the user.
+The last two,
+.Va symvalue
+and
+.Va symsize ,
+are filled in by
+.Fn kldsym
+and contain the address associated with
+.Va symname
+and the size of the data it points to, respectively.
+.Sh RETURN VALUES
+.Rv -std kldsym
+.Sh ERRORS
+The
+.Fn kldsym
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+Invalid value in
+.Fa data->version
+or
+.Fa cmd .
+.It Bq Er ENOENT
+The
+.Fa fileid
+argument
+is invalid,
+or the specified symbol could not be found.
+.El
+.Sh SEE ALSO
+.Xr kldfind 2 ,
+.Xr kldfirstmod 2 ,
+.Xr kldload 2 ,
+.Xr kldnext 2 ,
+.Xr kldunload 2 ,
+.Xr modfind 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4
+.Sh HISTORY
+The
+.Fn kldsym
+system call first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/kldunload.2 b/lib/libsys/kldunload.2
new file mode 100644
index 000000000000..c89f869e9eeb
--- /dev/null
+++ b/lib/libsys/kldunload.2
@@ -0,0 +1,91 @@
+.\"
+.\" Copyright (c) 1999 Chris Costello
+.\" 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.
+.\"
+.Dd December 25, 2008
+.Dt KLDUNLOAD 2
+.Os
+.Sh NAME
+.Nm kldunload , kldunloadf
+.Nd unload kld files
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/linker.h
+.Ft int
+.Fn kldunload "int fileid"
+.Ft int
+.Fn kldunloadf "int fileid" "int flags"
+.Sh DESCRIPTION
+The
+.Fn kldunload
+system call
+unloads a kld file from the kernel that was previously linked via
+.Xr kldload 2 .
+.Pp
+The
+.Fn kldunloadf
+system call accepts an additional flags argument, which may be one of
+.Dv LINKER_UNLOAD_NORMAL ,
+giving the same behavior as
+.Fn kldunload ,
+or
+.Dv LINKER_UNLOAD_FORCE ,
+which causes the unload to ignore a failure to quiesce the module.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The file referred to by
+.Fa fileid
+is unloaded unless:
+.Bl -tag -width Er
+.It Bq Er EPERM
+You do not have access to unlink the file from the kernel.
+.It Bq Er ENOENT
+The file was not found.
+.It Bq Er EBUSY
+You attempted to unload a file linked by the kernel.
+.It Bq Er EINVAL
+The
+.Fn kldunloadf
+system call was passed invalid flags.
+.El
+.Sh SEE ALSO
+.Xr kldfind 2 ,
+.Xr kldfirstmod 2 ,
+.Xr kldload 2 ,
+.Xr kldnext 2 ,
+.Xr kldstat 2 ,
+.Xr kldsym 2 ,
+.Xr modfind 2 ,
+.Xr modfnext 2 ,
+.Xr modnext 2 ,
+.Xr modstat 2 ,
+.Xr kld 4 ,
+.Xr kldunload 8
+.Sh HISTORY
+The
+.Nm kld
+interface first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/kqueue.2 b/lib/libsys/kqueue.2
new file mode 100644
index 000000000000..d6e949baa24c
--- /dev/null
+++ b/lib/libsys/kqueue.2
@@ -0,0 +1,904 @@
+.\" Copyright (c) 2000 Jonathan Lemon
+.\" 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 ``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.
+.\"
+.Dd March 26, 2023
+.Dt KQUEUE 2
+.Os
+.Sh NAME
+.Nm kqueue ,
+.Nm kevent
+.Nd kernel event notification mechanism
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/event.h
+.Ft int
+.Fn kqueue "void"
+.Ft int
+.Fn kqueuex "u_int flags"
+.Ft int
+.Fn kqueue1 "int flags"
+.Ft int
+.Fo kevent
+.Fa "int kq"
+.Fa "const struct kevent *changelist"
+.Fa "int nchanges"
+.Fa "struct kevent *eventlist"
+.Fa "int nevents"
+.Fa "const struct timespec *timeout"
+.Fc
+.Fn EV_SET "kev" ident filter flags fflags data udata
+.Sh DESCRIPTION
+The
+.Fn kqueue
+system call
+provides a generic method of notifying the user when an event
+happens or a condition holds, based on the results of small
+pieces of kernel code termed filters.
+A kevent is identified by the (ident, filter) pair; there may only
+be one unique kevent per kqueue.
+.Pp
+The filter is executed upon the initial registration of a kevent
+in order to detect whether a preexisting condition is present, and is also
+executed whenever an event is passed to the filter for evaluation.
+If the filter determines that the condition should be reported,
+then the kevent is placed on the kqueue for the user to retrieve.
+.Pp
+The filter is also run when the user attempts to retrieve the kevent
+from the kqueue.
+If the filter indicates that the condition that triggered
+the event no longer holds, the kevent is removed from the kqueue and
+is not returned.
+.Pp
+Multiple events which trigger the filter do not result in multiple
+kevents being placed on the kqueue; instead, the filter will aggregate
+the events into a single struct kevent.
+Calling
+.Fn close
+on a file descriptor will remove any kevents that reference the descriptor.
+.Pp
+The
+.Fn kqueue
+system call
+creates a new kernel event queue and returns a descriptor.
+The queue is not inherited by a child created with
+.Xr fork 2 .
+However, if
+.Xr rfork 2
+is called without the
+.Dv RFFDG
+flag, then the descriptor table is shared,
+which will allow sharing of the kqueue between two processes.
+.Pp
+The
+.Fn kqueuex
+system call also creates a new kernel event queue, and additionally takes
+a
+.Fa flags
+argument, which is a bitwise-inclusive OR of the following flags:
+.Bl -tag -width "KQUEUE_CLOEXEC"
+.It Dv KQUEUE_CLOEXEC
+The returned file descriptor is automatically closed on
+.Xr execve 2
+.El
+.Pp
+The
+.Fn kqueue
+system call is equivalent to calling
+.Fn kqueuex
+with
+.Fa flags
+set to 0.
+.Pp
+The
+.Fn kqueue1
+function exists for compatibility with
+.Nx .
+The
+.Fa flags
+argument accepts zero or more of the following values:
+.Bl -tag -width O_CLOEXEC
+.It Dv O_CLOEXEC
+The returned file descriptor is automatically closed on
+.Xr execve 2
+.El
+.Pp
+The
+.Fn kevent
+system call
+is used to register events with the queue, and return any pending
+events to the user.
+The
+.Fa changelist
+argument
+is a pointer to an array of
+.Va kevent
+structures, as defined in
+.In sys/event.h .
+All changes contained in the
+.Fa changelist
+are applied before any pending events are read from the queue.
+The
+.Fa nchanges
+argument
+gives the size of
+.Fa changelist .
+The
+.Fa eventlist
+argument
+is a pointer to an array of kevent structures.
+The
+.Fa nevents
+argument
+determines the size of
+.Fa eventlist .
+When
+.Fa nevents
+is zero,
+.Fn kevent
+will return immediately even if there is a
+.Fa timeout
+specified unlike
+.Xr select 2 .
+If
+.Fa timeout
+is a non-NULL pointer, it specifies a maximum interval to wait
+for an event, which will be interpreted as a struct timespec.
+If
+.Fa timeout
+is a NULL pointer,
+.Fn kevent
+waits indefinitely.
+To effect a poll, the
+.Fa timeout
+argument should be non-NULL, pointing to a zero-valued
+.Va timespec
+structure.
+The same array may be used for the
+.Fa changelist
+and
+.Fa eventlist .
+.Pp
+The
+.Fn EV_SET
+macro is provided for ease of initializing a
+kevent structure.
+.Pp
+The
+.Va kevent
+structure is defined as:
+.Bd -literal
+struct kevent {
+ uintptr_t ident; /* identifier for this event */
+ short filter; /* filter for event */
+ u_short flags; /* action flags for kqueue */
+ u_int fflags; /* filter flag value */
+ int64_t data; /* filter data value */
+ void *udata; /* opaque user data identifier */
+ uint64_t ext[4]; /* extensions */
+};
+.Ed
+.Pp
+The fields of
+.Fa struct kevent
+are:
+.Bl -tag -width "Fa filter"
+.It Fa ident
+Value used to identify this event.
+The exact interpretation is determined by the attached filter,
+but often is a file descriptor.
+.It Fa filter
+Identifies the kernel filter used to process this event.
+The pre-defined
+system filters are described below.
+.It Fa flags
+Actions to perform on the event.
+.It Fa fflags
+Filter-specific flags.
+.It Fa data
+Filter-specific data value.
+.It Fa udata
+Opaque user-defined value passed through the kernel unchanged.
+.It Fa ext
+Extended data passed to and from kernel.
+The meaning of the
+.Fa ext[0]
+and
+.Fa ext[1]
+members is defined by the filter.
+If a filter does not use them,
+these members are passed through the kernel unchanged.
+The
+.Fa ext[2]
+and
+.Fa ext[3]
+members are always passed through the kernel unchanged,
+providing additional user-defined values.
+.El
+.Pp
+The
+.Va flags
+field can contain the following values:
+.Bl -tag -width EV_KEEPUDATA
+.It Dv EV_ADD
+Adds the event to the kqueue.
+Re-adding an existing event
+will modify the parameters of the original event, and not result
+in a duplicate entry.
+Adding an event automatically enables it,
+unless overridden by the EV_DISABLE flag.
+.It Dv EV_ENABLE
+Permit
+.Fn kevent
+to return the event if it is triggered.
+.It Dv EV_DISABLE
+Disable the event so
+.Fn kevent
+will not return it.
+The filter itself is not disabled.
+.It Dv EV_DISPATCH
+Disable the event source immediately after delivery of an event.
+See
+.Dv EV_DISABLE
+above.
+.It Dv EV_DELETE
+Removes the event from the kqueue.
+Events which are attached to
+file descriptors are automatically deleted on the last close of
+the descriptor.
+.It Dv EV_RECEIPT
+This flag is useful for making bulk changes to a kqueue without draining
+any pending events.
+When passed as input, it forces
+.Dv EV_ERROR
+to always be returned.
+When a filter is successfully added the
+.Va data
+field will be zero.
+Note that if this flag is encountered and there is no remaining space in
+.Fa eventlist
+to hold the
+.Dv EV_ERROR
+event, then subsequent changes will not get processed.
+.It Dv EV_ONESHOT
+Return only the first occurrence of the filter
+being triggered.
+After the user retrieves the event from the kqueue,
+it is deleted.
+.It Dv EV_CLEAR
+Reset the state of the event after it is retrieved by the user.
+This is useful for filters which report state transitions
+instead of the current state.
+Note that some filters may automatically
+set this flag internally.
+.It Dv EV_EOF
+Filters may set this flag to indicate filter-specific EOF condition.
+.It Dv EV_ERROR
+See
+.Sx RETURN VALUES
+below.
+.It Dv EV_KEEPUDATA
+Preserve the
+.Fa udata
+associated with an existing event.
+This allows other aspects of the event to be modified without requiring the
+caller to know the
+.Fa udata
+value previously registered with the event.
+This is especially useful with
+.Dv NOTE_TRIGGER
+or
+.Dv EV_ENABLE .
+This flag may not be used with
+.Dv EV_ADD .
+.El
+.Pp
+The predefined system filters are listed below.
+Arguments may be passed to and from the filter via the
+.Va fflags
+and
+.Va data
+fields in the kevent structure.
+.Bl -tag -width "Dv EVFILT_PROCDESC"
+.It Dv EVFILT_READ
+Takes a descriptor as the identifier, and returns whenever
+there is data available to read.
+The behavior of the filter is slightly different depending
+on the descriptor type.
+.Bl -tag -width 2n
+.It Sockets
+Sockets which have previously been passed to
+.Xr listen 2
+return when there is an incoming connection pending.
+.Va data
+contains the size of the listen backlog.
+.Pp
+Other socket descriptors return when there is data to be read,
+subject to the
+.Dv SO_RCVLOWAT
+value of the socket buffer.
+This may be overridden with a per-filter low water mark at the
+time the filter is added by setting the
+.Dv NOTE_LOWAT
+flag in
+.Va fflags ,
+and specifying the new low water mark in
+.Va data .
+On return,
+.Va data
+contains the number of bytes of protocol data available to read.
+.Pp
+If the read direction of the socket has shutdown, then the filter
+also sets
+.Dv EV_EOF
+in
+.Va flags ,
+and returns the socket error (if any) in
+.Va fflags .
+It is possible for EOF to be returned (indicating the connection is gone)
+while there is still data pending in the socket buffer.
+.It Vnodes
+Returns when the file pointer is not at the end of file.
+.Va data
+contains the offset from current position to end of file,
+and may be negative.
+.Pp
+This behavior is different from
+.Xr poll 2 ,
+where read events are triggered for regular files unconditionally.
+This event can be triggered unconditionally by setting the
+.Dv NOTE_FILE_POLL
+flag in
+.Va fflags .
+.It "Fifos, Pipes"
+Returns when the there is data to read;
+.Va data
+contains the number of bytes available.
+.Pp
+When the last writer disconnects, the filter will set
+.Dv EV_EOF
+in
+.Va flags .
+This will be cleared by the filter when a new writer connects,
+at which point the
+filter will resume waiting for data to become available before
+returning.
+.It "BPF devices"
+Returns when the BPF buffer is full, the BPF timeout has expired, or
+when the BPF has
+.Dq immediate mode
+enabled and there is any data to read;
+.Va data
+contains the number of bytes available.
+.It Eventfds
+Returns when the counter is greater than 0;
+.Va data
+contains the counter value, which must be cast to
+.Vt uint64_t .
+.It Kqueues
+Returns when pending events are present on the queue;
+.Va data
+contains the number of events available.
+.El
+.It Dv EVFILT_WRITE
+Takes a descriptor as the identifier, and returns whenever
+it is possible to write to the descriptor.
+For sockets, pipes
+and fifos,
+.Va data
+will contain the amount of space remaining in the write buffer.
+The filter will set
+.Dv EV_EOF
+when the reader disconnects, and for the fifo case, this will be cleared
+when a new reader connects.
+Note that this filter is not supported for vnodes.
+.Pp
+For sockets, the low water mark and socket error handling is
+identical to the
+.Dv EVFILT_READ
+case.
+.Pp
+For eventfds,
+.Va data
+will contain the maximum value that can be added to the counter
+without blocking.
+.Pp
+For BPF devices, when the descriptor is attached to an interface the filter
+always indicates that it is possible to write and
+.Va data
+will contain the MTU size of the underlying interface.
+.It Dv EVFILT_EMPTY
+Takes a descriptor as the identifier, and returns whenever
+there is no remaining data in the write buffer.
+.It Dv EVFILT_AIO
+Events for this filter are not registered with
+.Fn kevent
+directly but are registered via the
+.Va aio_sigevent
+member of an asynchronous I/O request when it is scheduled via an
+asynchronous I/O system call such as
+.Fn aio_read .
+The filter returns under the same conditions as
+.Fn aio_error .
+For more details on this filter see
+.Xr sigevent 3 and
+.Xr aio 4 .
+.It Dv EVFILT_VNODE
+Takes a file descriptor as the identifier and the events to watch for in
+.Va fflags ,
+and returns when one or more of the requested events occurs on the descriptor.
+The events to monitor are:
+.Bl -tag -width "Dv NOTE_CLOSE_WRITE"
+.It Dv NOTE_ATTRIB
+The file referenced by the descriptor had its attributes changed.
+.It Dv NOTE_CLOSE
+A file descriptor referencing the monitored file, was closed.
+The closed file descriptor did not have write access.
+.It Dv NOTE_CLOSE_WRITE
+A file descriptor referencing the monitored file, was closed.
+The closed file descriptor had write access.
+.Pp
+This note, as well as
+.Dv NOTE_CLOSE ,
+are not activated when files are closed forcibly by
+.Xr unmount 2 or
+.Xr revoke 2 .
+Instead,
+.Dv NOTE_REVOKE
+is sent for such events.
+.It Dv NOTE_DELETE
+The
+.Fn unlink
+system call was called on the file referenced by the descriptor.
+.It Dv NOTE_EXTEND
+For regular file, the file referenced by the descriptor was extended.
+.Pp
+For directory, reports that a directory entry was added or removed,
+as the result of rename operation.
+The
+.Dv NOTE_EXTEND
+event is not reported when a name is changed inside the directory.
+.It Dv NOTE_LINK
+The link count on the file changed.
+In particular, the
+.Dv NOTE_LINK
+event is reported if a subdirectory was created or deleted inside
+the directory referenced by the descriptor.
+.It Dv NOTE_OPEN
+The file referenced by the descriptor was opened.
+.It Dv NOTE_READ
+A read occurred on the file referenced by the descriptor.
+.It Dv NOTE_RENAME
+The file referenced by the descriptor was renamed.
+.It Dv NOTE_REVOKE
+Access to the file was revoked via
+.Xr revoke 2
+or the underlying file system was unmounted.
+.It Dv NOTE_WRITE
+A write occurred on the file referenced by the descriptor.
+.El
+.Pp
+On return,
+.Va fflags
+contains the events which triggered the filter.
+.It Dv EVFILT_PROC
+Takes the process ID to monitor as the identifier and the events to watch for
+in
+.Va fflags ,
+and returns when the process performs one or more of the requested events.
+If a process can normally see another process, it can attach an event to it.
+The events to monitor are:
+.Bl -tag -width "Dv NOTE_TRACKERR"
+.It Dv NOTE_EXIT
+The process has exited.
+The exit status will be stored in
+.Va data
+in the same format as the status returned by
+.Xr wait 2 .
+.It Dv NOTE_FORK
+The process has called
+.Fn fork .
+.It Dv NOTE_EXEC
+The process has executed a new process via
+.Xr execve 2
+or a similar call.
+.It Dv NOTE_TRACK
+Follow a process across
+.Fn fork
+calls.
+The parent process registers a new kevent to monitor the child process
+using the same
+.Va fflags
+as the original event.
+The child process will signal an event with
+.Dv NOTE_CHILD
+set in
+.Va fflags
+and the parent PID in
+.Va data .
+.Pp
+If the parent process fails to register a new kevent
+.Pq usually due to resource limitations ,
+it will signal an event with
+.Dv NOTE_TRACKERR
+set in
+.Va fflags ,
+and the child process will not signal a
+.Dv NOTE_CHILD
+event.
+.El
+.Pp
+On return,
+.Va fflags
+contains the events which triggered the filter.
+.It Dv EVFILT_PROCDESC
+Takes the process descriptor created by
+.Xr pdfork 2
+to monitor as the identifier and the events to watch for in
+.Va fflags ,
+and returns when the associated process performs one or more of the
+requested events.
+The events to monitor are:
+.Bl -tag -width "Dv NOTE_EXIT"
+.It Dv NOTE_EXIT
+The process has exited.
+The exit status will be stored in
+.Va data .
+.El
+.Pp
+On return,
+.Va fflags
+contains the events which triggered the filter.
+.It Dv EVFILT_SIGNAL
+Takes the signal number to monitor as the identifier and returns
+when the given signal is delivered to the process.
+This coexists with the
+.Fn signal
+and
+.Fn sigaction
+facilities, and has a lower precedence.
+The filter will record
+all attempts to deliver a signal to a process, even if the signal has
+been marked as
+.Dv SIG_IGN ,
+except for the
+.Dv SIGCHLD
+signal, which, if ignored, will not be recorded by the filter.
+Event notification happens after normal
+signal delivery processing.
+.Va data
+returns the number of times the signal has occurred since the last call to
+.Fn kevent .
+This filter automatically sets the
+.Dv EV_CLEAR
+flag internally.
+.It Dv EVFILT_TIMER
+Establishes an arbitrary timer identified by
+.Va ident .
+When adding a timer,
+.Va data
+specifies the moment to fire the timer (for
+.Dv NOTE_ABSTIME )
+or the timeout period.
+The timer will be periodic unless
+.Dv EV_ONESHOT
+or
+.Dv NOTE_ABSTIME
+is specified.
+On return,
+.Va data
+contains the number of times the timeout has expired since the last call to
+.Fn kevent .
+For non-monotonic timers, this filter automatically sets the
+.Dv EV_CLEAR
+flag internally.
+.Pp
+The filter accepts the following flags in the
+.Va fflags
+argument:
+.Bl -tag -width "Dv NOTE_MSECONDS"
+.It Dv NOTE_SECONDS
+.Va data
+is in seconds.
+.It Dv NOTE_MSECONDS
+.Va data
+is in milliseconds.
+.It Dv NOTE_USECONDS
+.Va data
+is in microseconds.
+.It Dv NOTE_NSECONDS
+.Va data
+is in nanoseconds.
+.It Dv NOTE_ABSTIME
+The specified expiration time is absolute.
+.El
+.Pp
+If
+.Va fflags
+is not set, the default is milliseconds.
+On return,
+.Va fflags
+contains the events which triggered the filter.
+.Pp
+Periodic timers with a specified timeout of 0 will be silently adjusted to
+timeout after 1 of the time units specified by the requested precision in
+.Va fflags .
+If an absolute time is specified that has already passed, then it is treated as
+if the current time were specified and the event will fire as soon as possible.
+.Pp
+If an existing timer is re-added, the existing timer will be
+effectively canceled (throwing away any undelivered record of previous
+timer expiration) and re-started using the new parameters contained in
+.Va data
+and
+.Va fflags .
+.Pp
+There is a system wide limit on the number of timers
+which is controlled by the
+.Va kern.kq_calloutmax
+sysctl.
+.It Dv EVFILT_USER
+Establishes a user event identified by
+.Va ident
+which is not associated with any kernel mechanism but is triggered by
+user level code.
+The lower 24 bits of the
+.Va fflags
+may be used for user defined flags and manipulated using the following:
+.Bl -tag -width "Dv NOTE_FFLAGSMASK"
+.It Dv NOTE_FFNOP
+Ignore the input
+.Va fflags .
+.It Dv NOTE_FFAND
+Bitwise AND
+.Va fflags .
+.It Dv NOTE_FFOR
+Bitwise OR
+.Va fflags .
+.It Dv NOTE_FFCOPY
+Copy
+.Va fflags .
+.It Dv NOTE_FFCTRLMASK
+Control mask for
+.Va fflags .
+.It Dv NOTE_FFLAGSMASK
+User defined flag mask for
+.Va fflags .
+.El
+.Pp
+A user event is triggered for output with the following:
+.Bl -tag -width "Dv NOTE_FFLAGSMASK"
+.It Dv NOTE_TRIGGER
+Cause the event to be triggered.
+.El
+.Pp
+On return,
+.Va fflags
+contains the users defined flags in the lower 24 bits.
+.El
+.Sh CANCELLATION BEHAVIOUR
+If
+.Fa nevents
+is non-zero, i.e., the function is potentially blocking, the call
+is a cancellation point.
+Otherwise, i.e., if
+.Fa nevents
+is zero, the call is not cancellable.
+Cancellation can only occur before any changes are made to the kqueue,
+or when the call was blocked and no changes to the queue were requested.
+.Sh RETURN VALUES
+The
+.Fn kqueue
+system call
+creates a new kernel event queue and returns a file descriptor.
+If there was an error creating the kernel event queue, a value of -1 is
+returned and errno set.
+.Pp
+The
+.Fn kevent
+system call
+returns the number of events placed in the
+.Fa eventlist ,
+up to the value given by
+.Fa nevents .
+If an error occurs while processing an element of the
+.Fa changelist
+and there is enough room in the
+.Fa eventlist ,
+then the event will be placed in the
+.Fa eventlist
+with
+.Dv EV_ERROR
+set in
+.Va flags
+and the system error in
+.Va data .
+Otherwise,
+.Dv -1
+will be returned, and
+.Dv errno
+will be set to indicate the error condition.
+If the time limit expires, then
+.Fn kevent
+returns 0.
+.Sh EXAMPLES
+.Bd -literal -compact
+#include <sys/event.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ struct kevent event; /* Event we want to monitor */
+ struct kevent tevent; /* Event triggered */
+ int kq, fd, ret;
+
+ if (argc != 2)
+ err(EXIT_FAILURE, "Usage: %s path\en", argv[0]);
+ fd = open(argv[1], O_RDONLY);
+ if (fd == -1)
+ err(EXIT_FAILURE, "Failed to open '%s'", argv[1]);
+
+ /* Create kqueue. */
+ kq = kqueue();
+ if (kq == -1)
+ err(EXIT_FAILURE, "kqueue() failed");
+
+ /* Initialize kevent structure. */
+ EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE,
+ 0, NULL);
+ /* Attach event to the kqueue. */
+ ret = kevent(kq, &event, 1, NULL, 0, NULL);
+ if (ret == -1)
+ err(EXIT_FAILURE, "kevent register");
+
+ for (;;) {
+ /* Sleep until something happens. */
+ ret = kevent(kq, NULL, 0, &tevent, 1, NULL);
+ if (ret == -1) {
+ err(EXIT_FAILURE, "kevent wait");
+ } else if (ret > 0) {
+ if (tevent.flags & EV_ERROR)
+ errx(EXIT_FAILURE, "Event error: %s", strerror(event.data));
+ else
+ printf("Something was written in '%s'\en", argv[1]);
+ }
+ }
+
+ /* kqueues are destroyed upon close() */
+ (void)close(kq);
+ (void)close(fd);
+}
+.Ed
+.Sh ERRORS
+The
+.Fn kqueue
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er ENOMEM
+The kernel failed to allocate enough memory for the kernel queue.
+.It Bq Er ENOMEM
+The
+.Dv RLIMIT_KQUEUES
+rlimit
+(see
+.Xr getrlimit 2 )
+for the current user would be exceeded.
+.It Bq Er EMFILE
+The per-process descriptor table is full.
+.It Bq Er ENFILE
+The system file table is full.
+.El
+.Pp
+The
+.Fn kevent
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+The process does not have permission to register a filter.
+.It Bq Er EFAULT
+There was an error reading or writing the
+.Va kevent
+structure.
+.It Bq Er EBADF
+The specified descriptor is invalid.
+.It Bq Er EINTR
+A signal was delivered before the timeout expired and before any
+events were placed on the kqueue for return.
+.It Bq Er EINTR
+A cancellation request was delivered to the thread, but not yet handled.
+.It Bq Er EINVAL
+The specified time limit or filter is invalid.
+.It Bq Er EINVAL
+The specified length of the event or change lists is negative.
+.It Bq Er ENOENT
+The event could not be found to be modified or deleted.
+.It Bq Er ENOMEM
+No memory was available to register the event
+or, in the special case of a timer, the maximum number of
+timers has been exceeded.
+This maximum is configurable via the
+.Va kern.kq_calloutmax
+sysctl.
+.It Bq Er ESRCH
+The specified process to attach to does not exist.
+.El
+.Pp
+When
+.Fn kevent
+call fails with
+.Er EINTR
+error, all changes in the
+.Fa changelist
+have been applied.
+.Sh SEE ALSO
+.Xr aio_error 2 ,
+.Xr aio_read 2 ,
+.Xr aio_return 2 ,
+.Xr poll 2 ,
+.Xr read 2 ,
+.Xr select 2 ,
+.Xr sigaction 2 ,
+.Xr write 2 ,
+.Xr pthread_setcancelstate 3 ,
+.Xr signal 3
+.Rs
+.%A Jonathan Lemon
+.%T "Kqueue: A Generic and Scalable Event Notification Facility"
+.%I USENIX Association
+.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference
+.%D June 25-30, 2001
+.\".http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf
+.Re
+.Sh HISTORY
+The
+.Fn kqueue
+and
+.Fn kevent
+system calls first appeared in
+.Fx 4.1 .
+The
+.Fn kqueuex
+system call
+and
+.Fn kevent1
+function first appeared in
+.Fx 14.0 .
+.Sh AUTHORS
+The
+.Fn kqueue
+system and this manual page were written by
+.An Jonathan Lemon Aq Mt jlemon@FreeBSD.org .
+.Sh BUGS
+.Pp
+In versions older than
+.Fx 12.0 ,
+.In sys/event.h
+failed to parse without including
+.In sys/types.h
+manually.
diff --git a/lib/libsys/ktrace.2 b/lib/libsys/ktrace.2
new file mode 100644
index 000000000000..c12caca438fe
--- /dev/null
+++ b/lib/libsys/ktrace.2
@@ -0,0 +1,204 @@
+.\" Copyright (c) 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.
+.\"
+.Dd November 2, 2022
+.Dt KTRACE 2
+.Os
+.Sh NAME
+.Nm ktrace
+.Nd process tracing
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/time.h
+.In sys/uio.h
+.In sys/ktrace.h
+.Ft int
+.Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid"
+.Sh DESCRIPTION
+The
+.Fn ktrace
+system call enables or disables tracing of one or more processes.
+Users may only trace their own processes.
+Only the super-user can trace setuid or setgid programs.
+.Pp
+The
+.Fa tracefile
+argument
+gives the pathname of the file to be used for tracing.
+The file must exist and be a regular file writable by the calling process.
+All trace records are always appended to the file,
+so the file must be truncated to zero length to discard
+previous trace data.
+If tracing points are being disabled (see KTROP_CLEAR below),
+.Fa tracefile
+may be NULL.
+.Pp
+The
+.Fa ops
+argument specifies the requested ktrace operation.
+The defined operations are:
+.Bl -column KTRFLAG_DESCENDXXX -offset indent
+.It KTROP_SET Ta "Enable trace points specified in"
+.Fa trpoints .
+.It KTROP_CLEAR Ta "Disable trace points specified in"
+.Fa trpoints .
+.It KTROP_CLEARFILE Ta "Stop all tracing."
+.It KTRFLAG_DESCEND Ta "The tracing change should apply to the"
+specified process and all its current children.
+.El
+.Pp
+The
+.Fa trpoints
+argument specifies the trace points of interest.
+The defined trace points are:
+.Bl -column KTRFAC_PROCCTORXXX -offset indent
+.It KTRFAC_SYSCALL Ta "Trace system calls."
+.It KTRFAC_SYSRET Ta "Trace return values from system calls."
+.It KTRFAC_NAMEI Ta "Trace name lookup operations."
+.It KTRFAC_GENIO Ta "Trace all I/O (note that this option can"
+generate much output).
+.It KTRFAC_PSIG Ta "Trace posted signals."
+.It KTRFAC_CSW Ta "Trace context switch points."
+.It KTRFAC_USER Ta "Trace application-specific events."
+.It KTRFAC_STRUCT Ta "Trace certain data structures."
+.It KTRFAC_SYSCTL Ta "Trace sysctls."
+.It KTRFAC_PROCCTOR Ta "Trace process construction."
+.It KTRFAC_PROCDTOR Ta "Trace process destruction."
+.It KTRFAC_CAPFAIL Ta "Trace capability failures."
+.It KTRFAC_FAULT Ta "Trace page faults."
+.It KTRFAC_FAULTEND Ta "Trace the end of page faults."
+.It KTRFAC_STRUCT_ARRAY Ta "Trace arrays of certain data structures."
+.It KTRFAC_INHERIT Ta "Inherit tracing to future children."
+.El
+.Pp
+Each tracing event outputs a record composed of a generic header
+followed by a trace point specific structure.
+The generic header is:
+.Bd -literal
+struct ktr_header {
+ int ktr_len; /* length of buf */
+ short ktr_type; /* trace record type */
+ pid_t ktr_pid; /* process id */
+ char ktr_comm[MAXCOMLEN+1]; /* command name */
+ struct timeval ktr_time; /* timestamp */
+ long ktr_tid; /* thread id */
+};
+.Ed
+.Pp
+The
+.Va ktr_len
+field specifies the length of the
+.Va ktr_type
+data that follows this header.
+The
+.Va ktr_pid
+and
+.Va ktr_comm
+fields specify the process and command generating the record.
+The
+.Va ktr_time
+field gives the time (with microsecond resolution)
+that the record was generated.
+The
+.Va ktr_tid
+field holds a thread id.
+.Pp
+The generic header is followed by
+.Va ktr_len
+bytes of a
+.Va ktr_type
+record.
+The type specific records are defined in the
+.In sys/ktrace.h
+include file.
+.Sh SYSCTL TUNABLES
+The following
+.Xr sysctl 8
+tunables influence the behaviour of
+.Fn ktrace :
+.Bl -tag -width indent
+.It Va kern.ktrace.genio_size
+bounds the amount of data a traced I/O request will log
+to the trace file.
+.It Va kern.ktrace.request_pool
+bounds the number of trace events being logged at a time.
+.El
+.Pp
+Sysctl tunables that control process debuggability (as determined by
+.Xr p_candebug 9 )
+also affect the operation of
+.Fn ktrace .
+.Sh RETURN VALUES
+.Rv -std ktrace
+.Sh ERRORS
+The
+.Fn ktrace
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named tracefile does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ENOSYS
+The kernel was not compiled with
+.Nm
+support.
+.El
+.Pp
+A thread may be unable to log one or more tracing events due to a
+temporary shortage of resources.
+This condition is remembered by the kernel, and the next tracing request
+that succeeds will have the flag
+.Li KTR_DROP
+set in its
+.Va ktr_type
+field.
+.Sh SEE ALSO
+.Xr kdump 1 ,
+.Xr ktrace 1 ,
+.Xr utrace 2 ,
+.Xr sysctl 8 ,
+.Xr p_candebug 9
+.Sh HISTORY
+The
+.Fn ktrace
+system call first appeared in
+.Bx 4.4 .
diff --git a/lib/libsys/libc_stubs.c b/lib/libsys/libc_stubs.c
new file mode 100644
index 000000000000..41d69a9355c3
--- /dev/null
+++ b/lib/libsys/libc_stubs.c
@@ -0,0 +1,11 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 SRI International
+ */
+
+#define STUB_FUNC(f) \
+ void (f)(void); \
+ void (f)(void) { __builtin_trap(); }
+
+STUB_FUNC(elf_aux_info);
diff --git a/lib/libsys/libsys.h b/lib/libsys/libsys.h
new file mode 100644
index 000000000000..4ac7cfc14256
--- /dev/null
+++ b/lib/libsys/libsys.h
@@ -0,0 +1,25 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 SRI International
+ *
+ * This software was developed by SRI International, the University of
+ * Cambridge Computer Laboratory (Department of Computer Science and
+ * Technology), and Capabilities Limited under Defense Advanced Research
+ * Projects Agency (DARPA) Contract No. FA8750-24-C-B047 ("DEC").
+ */
+
+#ifndef _LIBSYS_H_
+#define _LIBSYS_H_
+
+#include <sys/types.h>
+
+#include <_libsys.h>
+
+typedef int (__sys_syscall_t)(int number, ...);
+typedef int (__sys___syscall_t)(int64_t number, ...);
+
+int __sys_syscall(int number, ...);
+off_t __sys___syscall(int64_t number, ...);
+
+#endif /* _LIBSYS_H_ */
diff --git a/lib/libsys/libsys_sigwait.c b/lib/libsys/libsys_sigwait.c
new file mode 100644
index 000000000000..ce1a416d76b3
--- /dev/null
+++ b/lib/libsys/libsys_sigwait.c
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2010 davidxu@freebsd.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.
+ *
+ * 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.
+ */
+
+#include <errno.h>
+#include <signal.h>
+#include "libc_private.h"
+
+/* XXX: why does this symbol exist? */
+__weak_reference(__libsys_sigwait, __sigwait);
+
+int
+__libsys_sigwait(const sigset_t *set, int *sig)
+{
+ int ret;
+
+ /* POSIX does not allow EINTR to be returned */
+ do {
+ ret = __sys_sigwait(set, sig);
+ } while (ret == EINTR);
+ return (ret);
+}
diff --git a/lib/libsys/link.2 b/lib/libsys/link.2
new file mode 100644
index 000000000000..e4122156678b
--- /dev/null
+++ b/lib/libsys/link.2
@@ -0,0 +1,316 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd March 30, 2021
+.Dt LINK 2
+.Os
+.Sh NAME
+.Nm link ,
+.Nm linkat
+.Nd make a hard file link
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn link "const char *name1" "const char *name2"
+.Ft int
+.Fo linkat
+.Fa "int fd1" "const char *name1" "int fd2" "const char *name2" "int flag"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn link
+system call
+atomically creates the specified directory entry (hard link)
+.Fa name2
+with the attributes of the underlying object pointed at by
+.Fa name1 .
+If the link is successful: the link count of the underlying object
+is incremented;
+.Fa name1
+and
+.Fa name2
+share equal access and rights
+to the
+underlying object.
+.Pp
+If
+.Fa name1
+is removed, the file
+.Fa name2
+is not deleted and the link count of the
+underlying object is
+decremented.
+.Pp
+The object pointed at by the
+.Fa name1
+argument
+must exist for the hard link to
+succeed and
+both
+.Fa name1
+and
+.Fa name2
+must be in the same file system.
+The
+.Fa name1
+argument
+may not be a directory.
+.Pp
+The
+.Fn linkat
+system call is equivalent to
+.Fa link
+except in the case where either
+.Fa name1
+or
+.Fa name2
+or both are relative paths.
+In this case a relative path
+.Fa name1
+is interpreted relative to
+the directory associated with the file descriptor
+.Fa fd1
+instead of the current working directory and similarly for
+.Fa name2
+and the file descriptor
+.Fa fd2 .
+.Pp
+Values for
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from the following
+list, defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_FOLLOW
+If
+.Fa name1
+names a symbolic link, a new link for the target of the symbolic link is
+created.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd1
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa name1
+argument is an empty string, link the file referenced by the descriptor
+.Fa fd1 .
+The operation requires that the calling process has the
+.Dv PRIV_VFS_FHOPEN
+privilege, effectively being executed with effective user
+.Dv root .
+.El
+.Pp
+If
+.Fn linkat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd1
+or
+.Fa fd2
+parameter, the current working directory is used for the respective
+.Fa name
+argument.
+If both
+.Fa fd1
+and
+.Fa fd2
+have value
+.Dv AT_FDCWD ,
+the behavior is identical to a call to
+.Fn link .
+Unless
+.Fa flag
+contains the
+.Dv AT_SYMLINK_FOLLOW
+flag, if
+.Fa name1
+names a symbolic link, a new link is created for the symbolic link
+.Fa name1
+and not its target.
+.Sh RETURN VALUES
+.Rv -std link
+.Sh ERRORS
+The
+.Fn link
+system call
+will fail and no link will be created if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of either path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of either pathname exceeded 255 characters,
+or entire length of either path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of either path prefix does not exist.
+.It Bq Er EOPNOTSUPP
+The file system containing the file named by
+.Fa name1
+does not support links.
+.It Bq Er EMLINK
+The link count of the file named by
+.Fa name1
+would exceed 32767.
+.It Bq Er EACCES
+A component of either path prefix denies search permission.
+.It Bq Er EACCES
+The requested link requires writing in a directory with a mode
+that denies write permission.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating one of the pathnames.
+.It Bq Er ENOENT
+The file named by
+.Fa name1
+does not exist.
+.It Bq Er EEXIST
+The link named by
+.Fa name2
+does exist.
+.It Bq Er EPERM
+The file named by
+.Fa name1
+is a directory.
+.It Bq Er EPERM
+The file named by
+.Fa name1
+has its immutable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EPERM
+The parent directory of the file named by
+.Fa name2
+has its immutable flag set.
+.It Bq Er EXDEV
+The link named by
+.Fa name2
+and the file named by
+.Fa name1
+are on different file systems.
+.It Bq Er ENOSPC
+The directory in which the entry for the new link is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er EDQUOT
+The directory in which the entry for the new link
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to
+the file system to make the directory entry.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The requested link requires writing in a directory on a read-only file
+system.
+.It Bq Er EFAULT
+One of the pathnames specified
+is outside the process's allocated address space.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn link ,
+the
+.Fn linkat
+system call may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa name1
+or
+.Fa name2
+argument does not specify an absolute path and the
+.Fa fd1
+or
+.Fa fd2
+argument, respectively, is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa name1
+or
+.Fa name2
+argument is not an absolute path and
+.Fa fd1
+or
+.Fa fd2 ,
+respectively, is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa name1
+is not strictly relative to the starting directory.
+For example,
+.Fa name1
+is absolute or includes a ".." component that escapes
+the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr readlink 2 ,
+.Xr symlink 2 ,
+.Xr unlink 2
+.Sh STANDARDS
+The
+.Fn link
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn linkat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn link
+function appeared in
+.At v1 .
+The
+.Fn linkat
+system call appeared in
+.Fx 8.0 .
+.Pp
+The
+.Fn link
+system call traditionally allows the super-user to link directories which
+corrupts the file system coherency.
+This implementation no longer permits it.
diff --git a/lib/libsys/lio_listio.2 b/lib/libsys/lio_listio.2
new file mode 100644
index 000000000000..bda65c38b1ac
--- /dev/null
+++ b/lib/libsys/lio_listio.2
@@ -0,0 +1,248 @@
+.\" Copyright (c) 2003 Tim J. Robbins
+.\" 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.
+.\"
+.Dd January 13, 2024
+.Dt LIO_LISTIO 2
+.Os
+.Sh NAME
+.Nm lio_listio
+.Nd "list directed I/O (REALTIME)"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In aio.h
+.Ft int
+.Fo lio_listio
+.Fa "int mode"
+.Fa "struct aiocb * const list[]"
+.Fa "int nent"
+.Fa "struct sigevent *sig"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn lio_listio
+function initiates a list of I/O requests with a single function call.
+The
+.Fa list
+argument is an array of pointers to
+.Vt aiocb
+structures describing each operation to perform,
+with
+.Fa nent
+elements.
+.Dv NULL
+elements are ignored.
+.Pp
+The
+.Va aio_lio_opcode
+field of each
+.Vt aiocb
+specifies the operation to be performed.
+The following operations are supported:
+.Bl -tag -width ".Dv LIO_WRITE"
+.It Dv LIO_READ
+Read data as if by a call to
+.Xr aio_read 2 .
+.It Dv LIO_READV
+Read data as if by a call to
+.Xr aio_readv 2 .
+.It Dv LIO_NOP
+No operation.
+.It Dv LIO_WRITE
+Write data as if by a call to
+.Xr aio_write 2 .
+.It Dv LIO_WRITEV
+Write data as if by a call to
+.Xr aio_writev 2 .
+.El
+.Pp
+If the
+.Dv LIO_READ ,
+.Dv LIO_READV ,
+.Dv LIO_WRITE ,
+.Dv LIO_WRITEV
+opcodes are or-ed with the
+.Dv LIO_FOFFSET
+flag, the corresponding read or write operation uses the current file
+descriptor offset instead of
+.Va aio_offset
+from
+.Vt aiocb .
+.Pp
+If the
+.Fa mode
+argument is
+.Dv LIO_WAIT ,
+.Fn lio_listio
+does not return until all the requested operations have been completed.
+If
+.Fa mode
+is
+.Dv LIO_NOWAIT ,
+.Fa sig
+can be used to request asynchronous notification when all operations have
+completed.
+If
+.Fa sig
+is
+.Dv NULL ,
+no notification is sent.
+.Pp
+For
+.Dv SIGEV_KEVENT
+notifications,
+the posted kevent will contain:
+.Bl -column ".Va filter"
+.It Sy Member Ta Sy Value
+.It Va ident Ta Fa list
+.It Va filter Ta Dv EVFILT_LIO
+.It Va udata Ta
+value stored in
+.Fa sig->sigev_value
+.El
+.Pp
+For
+.Dv SIGEV_SIGNO
+and
+.Dv SIGEV_THREAD_ID
+notifications,
+the information for the queued signal will include
+.Dv SI_ASYNCIO
+in the
+.Va si_code
+field and the value stored in
+.Fa sig->sigev_value
+in the
+.Va si_value
+field.
+.Pp
+For
+.Dv SIGEV_THREAD
+notifications,
+the value stored in
+.Fa sig->sigev_value
+is passed to the
+.Fa sig->sigev_notify_function
+as described in
+.Xr sigevent 3 .
+.Pp
+The order in which the requests are carried out is not specified;
+in particular, there is no guarantee that they will be executed in
+the order 0, 1, ...,
+.Fa nent Ns \-1 .
+.Sh RETURN VALUES
+If
+.Fa mode
+is
+.Dv LIO_WAIT ,
+the
+.Fn lio_listio
+function returns 0 if the operations completed successfully,
+otherwise \-1.
+.Pp
+If
+.Fa mode
+is
+.Dv LIO_NOWAIT ,
+the
+.Fn lio_listio
+function returns 0 if the operations are successfully queued,
+otherwise \-1.
+.Sh ERRORS
+The
+.Fn lio_listio
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+There are not enough resources to enqueue the requests.
+.It Bq Er EAGAIN
+The request would cause the system-wide limit
+.Dv {AIO_MAX}
+to be exceeded.
+.It Bq Er EINVAL
+The
+.Fa mode
+argument is neither
+.Dv LIO_WAIT
+nor
+.Dv LIO_NOWAIT ,
+or
+.Fa nent
+is greater than
+.Dv {AIO_LISTIO_MAX} .
+.It Bq Er EINVAL
+The asynchronous notification method in
+.Fa sig->sigev_notify
+is invalid or not supported.
+.It Bq Er EINTR
+A signal interrupted the system call before it could be completed.
+.It Bq Er EIO
+One or more requests failed.
+.El
+.Pp
+In addition, the
+.Fn lio_listio
+function may fail for any of the reasons listed for
+.Xr aio_read 2
+and
+.Xr aio_write 2 .
+.Pp
+If
+.Fn lio_listio
+succeeds, or fails with an error code of
+.Er EAGAIN , EINTR ,
+or
+.Er EIO ,
+some of the requests may have been initiated.
+The caller should check the error status of each
+.Vt aiocb
+structure individually by calling
+.Xr aio_error 2 .
+.Sh SEE ALSO
+.Xr aio_error 2 ,
+.Xr aio_read 2 ,
+.Xr aio_readv 2 ,
+.Xr aio_write 2 ,
+.Xr aio_writev 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr sigevent 3 ,
+.Xr siginfo 3 ,
+.Xr aio 4
+.Sh STANDARDS
+The
+.Fn lio_listio
+function is expected to conform to
+.St -p1003.1-2001 .
+The
+.Dv LIO_READV
+and
+.Dv LIO_WRITEV
+operations are
+.Fx extensions, and should not be used in portable code.
+.Sh HISTORY
+The
+.Fn lio_listio
+system call first appeared in
+.Fx 3.0 .
diff --git a/lib/libsys/listen.2 b/lib/libsys/listen.2
new file mode 100644
index 000000000000..984da2552862
--- /dev/null
+++ b/lib/libsys/listen.2
@@ -0,0 +1,201 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd April 30, 2023
+.Dt LISTEN 2
+.Os
+.Sh NAME
+.Nm listen
+.Nd listen for connections on a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft int
+.Fn listen "int s" "int backlog"
+.Sh DESCRIPTION
+To accept connections, a socket
+is first created with
+.Xr socket 2 ,
+a willingness to accept incoming connections and
+a queue limit for incoming connections are specified with
+.Fn listen ,
+and then the connections are
+accepted with
+.Xr accept 2 .
+The
+.Fn listen
+system call applies only to sockets of type
+.Dv SOCK_STREAM
+or
+.Dv SOCK_SEQPACKET .
+.Pp
+The
+.Fa backlog
+argument defines the maximum length the queue of
+pending connections may grow to.
+The real maximum queue length will be 1.5 times more than the value
+specified in the
+.Fa backlog
+argument.
+A subsequent
+.Fn listen
+system call on the listening socket allows the caller to change the maximum
+queue length using a new
+.Fa backlog
+argument.
+If a connection
+request arrives with the queue full the client may
+receive an error with an indication of
+.Er ECONNREFUSED ,
+or, in the case of TCP, the connection will be
+silently dropped.
+.Pp
+Current queue lengths of listening sockets can be queried using
+.Xr netstat 1
+command.
+.Pp
+Note that before
+.Fx 4.5
+and the introduction of the syncache,
+the
+.Fa backlog
+argument also determined the length of the incomplete
+connection queue, which held TCP sockets in the process
+of completing TCP's 3-way handshake.
+These incomplete connections
+are now held entirely in the syncache, which is unaffected by
+queue lengths.
+Inflated
+.Fa backlog
+values to help handle denial
+of service attacks are no longer necessary.
+.Pp
+The
+.Xr sysctl 3
+MIB variable
+.Va kern.ipc.soacceptqueue
+specifies a hard limit on
+.Fa backlog ;
+if a value greater than
+.Va kern.ipc.soacceptqueue
+or less than zero is specified,
+.Fa backlog
+is silently forced to
+.Va kern.ipc.soacceptqueue .
+.Pp
+If the listen queue overflows, the kernel will emit a syslog message
+using default priority LOG_DEBUG (7).
+The
+.Xr sysctl 3
+MIB variable
+.Va kern.ipc.sooverprio
+may be used to change this priority to any value in a range of 0..7
+(LOG_EMERG..LOG_DEBUG).
+See
+.Xr syslog 3
+for details.
+It may be set to -1 to disable these messages.
+.Pp
+The variable
+.Va kern.ipc.sooverinterval
+specifies a per-socket limit on how often the kernel will emit these messages.
+.Sh INTERACTION WITH ACCEPT FILTERS
+When accept filtering is used on a socket, a second queue will
+be used to hold sockets that have connected, but have not yet
+met their accept filtering criteria.
+Once the criteria has been
+met, these sockets will be moved over into the completed connection
+queue to be
+.Xr accept 2 Ns ed .
+If this secondary queue is full and a
+new connection comes in, the oldest socket which has not yet met
+its accept filter criteria will be terminated.
+.Pp
+This secondary queue, like the primary listen queue, is sized
+according to the
+.Fa backlog
+argument.
+.Sh RETURN VALUES
+.Rv -std listen
+.Sh ERRORS
+The
+.Fn listen
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The argument
+.Fa s
+is not a valid descriptor.
+.It Bq Er EDESTADDRREQ
+The socket is not bound to a local address, and the protocol does not
+support listening on an unbound socket.
+.It Bq Er EINVAL
+The socket is already connected, or in the process of being connected.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is not a socket.
+.It Bq Er EOPNOTSUPP
+The socket is not of a type that supports the operation
+.Fn listen .
+.El
+.Sh SEE ALSO
+.Xr netstat 1 ,
+.Xr accept 2 ,
+.Xr connect 2 ,
+.Xr socket 2 ,
+.Xr sysctl 3 ,
+.Xr syslog 3 ,
+.Xr sysctl 8 ,
+.Xr accept_filter 9
+.Sh HISTORY
+The
+.Fn listen
+system call appeared in
+.Bx 4.2 .
+The ability to configure the maximum
+.Fa backlog
+at run-time, and to use a negative
+.Fa backlog
+to request the maximum allowable value, was introduced in
+.Fx 2.2 .
+The
+.Va kern.ipc.somaxconn
+.Xr sysctl 3
+has been replaced with
+.Va kern.ipc.soacceptqueue
+in
+.Fx 10.0
+to prevent confusion about its actual functionality.
+The original
+.Xr sysctl 3
+.Va kern.ipc.somaxconn
+is still available but hidden from a
+.Xr sysctl 3
+-a output so that existing applications and scripts continue to work.
diff --git a/lib/libc/gen/lockf.3 b/lib/libsys/lockf.3
index bfd5719dee11..bfd5719dee11 100644
--- a/lib/libc/gen/lockf.3
+++ b/lib/libsys/lockf.3
diff --git a/lib/libsys/lseek.2 b/lib/libsys/lseek.2
new file mode 100644
index 000000000000..6df543d8ce72
--- /dev/null
+++ b/lib/libsys/lseek.2
@@ -0,0 +1,243 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd July 13, 2020
+.Dt LSEEK 2
+.Os
+.Sh NAME
+.Nm lseek
+.Nd reposition read/write file offset
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft off_t
+.Fn lseek "int fildes" "off_t offset" "int whence"
+.Sh DESCRIPTION
+The
+.Fn lseek
+system call repositions the offset of the file descriptor
+.Fa fildes
+to the
+argument
+.Fa offset
+according to the directive
+.Fa whence .
+The argument
+.Fa fildes
+must be an open
+file descriptor.
+The
+.Fn lseek
+system call
+repositions the file position pointer associated with the file
+descriptor
+.Fa fildes
+as follows:
+.Bl -item -offset indent
+.It
+If
+.Fa whence
+is
+.Dv SEEK_SET ,
+the offset is set to
+.Fa offset
+bytes.
+.It
+If
+.Fa whence
+is
+.Dv SEEK_CUR ,
+the offset is set to its current location plus
+.Fa offset
+bytes.
+.It
+If
+.Fa whence
+is
+.Dv SEEK_END ,
+the offset is set to the size of the
+file plus
+.Fa offset
+bytes.
+.It
+If
+.Fa whence
+is
+.Dv SEEK_HOLE ,
+the offset is set to the start of the next hole greater than or equal
+to the supplied
+.Fa offset .
+The definition of a hole is provided below.
+.It
+If
+.Fa whence
+is
+.Dv SEEK_DATA ,
+the offset is set to the start of the next non-hole file region greater
+than or equal to the supplied
+.Fa offset .
+.El
+.Pp
+The
+.Fn lseek
+system call allows the file offset to be set beyond the end
+of the existing end-of-file of the file.
+If data is later written
+at this point, subsequent reads of the data in the gap return
+bytes of zeros (until data is actually written into the gap).
+However, the
+.Fn lseek
+system call does not, by itself, extend the size of a file.
+.Pp
+A
+.Qq hole
+is defined as a contiguous range of bytes in a file, all having the value of
+zero, but not all zeros in a file are guaranteed to be represented as holes
+returned with
+.Dv SEEK_HOLE .
+File systems are allowed to expose ranges of zeros with
+.Dv SEEK_HOLE ,
+but not required to.
+Applications can use
+.Dv SEEK_HOLE
+to optimise their behavior for ranges of zeros, but must not depend on it to
+find all such ranges in a file.
+Each file is presented as having a zero-size virtual hole at the very
+end of the file.
+The existence of a hole at the end of every data region allows for easy
+programming and also provides compatibility to the original implementation
+in Solaris.
+It also causes the current file size (i.e., end-of-file offset) to be returned
+to indicate that there are no more holes past the supplied
+.Fa offset .
+Applications should use
+.Fn fpathconf _PC_MIN_HOLE_SIZE
+or
+.Fn pathconf _PC_MIN_HOLE_SIZE
+to determine if a file system supports
+.Dv SEEK_HOLE .
+See
+.Xr pathconf 2 .
+.Pp
+For file systems that do not supply information about holes, the file will be
+represented as one entire data region.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn lseek
+returns the resulting offset location as measured in bytes from the
+beginning of the file.
+Otherwise,
+a value of -1 is returned and
+.Va errno
+is set to indicate
+the error.
+.Sh ERRORS
+The
+.Fn lseek
+system call
+will fail and the file position pointer will remain unchanged if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fildes
+argument
+is not an open file descriptor.
+.It Bq Er EINVAL
+The
+.Fa whence
+argument
+is not a proper value
+or the resulting file offset would
+be negative for a non-character special file.
+.It Bq Er ENXIO
+For
+.Dv SEEK_DATA ,
+there are no more data regions past the supplied offset.
+Due to existence of the hole at the end of the file, for
+.Dv SEEK_HOLE
+this error is only returned when the
+.Fa offset
+already points to the end-of-file position.
+.It Bq Er EOVERFLOW
+The resulting file offset would be a value which cannot be represented
+correctly in an object of type
+.Fa off_t .
+.It Bq Er ESPIPE
+The
+.Fa fildes
+argument
+is associated with a pipe, socket, or FIFO.
+.El
+.Sh SEE ALSO
+.Xr dup 2 ,
+.Xr open 2 ,
+.Xr pathconf 2
+.Sh STANDARDS
+The
+.Fn lseek
+system call is expected to conform to
+.St -p1003.1-2008 .
+.Pp
+The
+.Dv SEEK_HOLE
+and
+.Dv SEEK_DATA
+directives, along with the
+.Er ENXIO
+error, are extensions to that specification.
+.Sh HISTORY
+The
+.Fn lseek
+function appeared in
+.At v7 .
+.Sh BUGS
+If the
+.Fn lseek
+system call is operating on a device which is incapable of seeking,
+it will request the seek operation and return successfully,
+even though no seek was performed.
+Because the
+.Ar offset
+argument will be stored unconditionally in the file descriptor of that device,
+there is no way to confirm if the seek operation succeeded or not
+(e.g. using the
+.Fn ftell
+function).
+Device types which are known to be incapable of seeking include
+tape drives.
+.Pp
+The
+.Fn lseek
+system call will not detect whether media are present in changeable
+media devices such as DVD or Blu-ray devices.
+A requested seek operation will therefore return sucessfully when no
+medium is present.
+.Pp
+This document's use of
+.Fa whence
+is incorrect English, but is maintained for historical reasons.
diff --git a/lib/libsys/madvise.2 b/lib/libsys/madvise.2
new file mode 100644
index 000000000000..9a6e34416012
--- /dev/null
+++ b/lib/libsys/madvise.2
@@ -0,0 +1,183 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd July 12, 2015
+.Dt MADVISE 2
+.Os
+.Sh NAME
+.Nm madvise , posix_madvise
+.Nd give advice about use of memory
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn madvise "void *addr" "size_t len" "int behav"
+.Ft int
+.Fn posix_madvise "void *addr" "size_t len" "int behav"
+.Sh DESCRIPTION
+The
+.Fn madvise
+system call
+allows a process that has knowledge of its memory behavior
+to describe it to the system.
+The
+.Fn posix_madvise
+interface is identical, except it returns an error number on error and does
+not modify
+.Va errno ,
+and is provided for standards conformance.
+.Pp
+The known behaviors are:
+.Bl -tag -width MADV_SEQUENTIAL
+.It Dv MADV_NORMAL
+Tells the system to revert to the default paging
+behavior.
+.It Dv MADV_RANDOM
+Is a hint that pages will be accessed randomly, and prefetching
+is likely not advantageous.
+.It Dv MADV_SEQUENTIAL
+Causes the VM system to depress the priority of
+pages immediately preceding a given page when it is faulted in.
+.It Dv MADV_WILLNEED
+Causes pages that are in a given virtual address range
+to temporarily have higher priority, and if they are in
+memory, decrease the likelihood of them being freed.
+Additionally,
+the pages that are already in memory will be immediately mapped into
+the process, thereby eliminating unnecessary overhead of going through
+the entire process of faulting the pages in.
+This WILL NOT fault
+pages in from backing store, but quickly map the pages already in memory
+into the calling process.
+.It Dv MADV_DONTNEED
+Allows the VM system to decrease the in-memory priority
+of pages in the specified address range.
+Consequently, future references to this address range are more likely
+to incur a page fault.
+.It Dv MADV_FREE
+Gives the VM system the freedom to free pages,
+and tells the system that information in the specified page range
+is no longer important.
+This is an efficient way of allowing
+.Xr malloc 3
+to free pages anywhere in the address space, while keeping the address space
+valid.
+The next time that the page is referenced, the page might be demand
+zeroed, or might contain the data that was there before the
+.Dv MADV_FREE
+call.
+References made to that address space range will not make the VM system
+page the information back in from backing store until the page is
+modified again.
+.It Dv MADV_NOSYNC
+Request that the system not flush the data associated with this map to
+physical backing store unless it needs to.
+Typically this prevents the
+file system update daemon from gratuitously writing pages dirtied
+by the VM system to physical disk.
+Note that VM/file system coherency is
+always maintained, this feature simply ensures that the mapped data is
+only flush when it needs to be, usually by the system pager.
+.Pp
+This feature is typically used when you want to use a file-backed shared
+memory area to communicate between processes (IPC) and do not particularly
+need the data being stored in that area to be physically written to disk.
+With this feature you get the equivalent performance with mmap that you
+would expect to get with SysV shared memory calls, but in a more controllable
+and less restrictive manner.
+However, note that this feature is not portable
+across UNIX platforms (though some may do the right thing by default).
+For more information see the MAP_NOSYNC section of
+.Xr mmap 2
+.It Dv MADV_AUTOSYNC
+Undoes the effects of MADV_NOSYNC for any future pages dirtied within the
+address range.
+The effect on pages already dirtied is indeterminate - they
+may or may not be reverted.
+You can guarantee reversion by using the
+.Xr msync 2
+or
+.Xr fsync 2
+system calls.
+.It Dv MADV_NOCORE
+Region is not included in a core file.
+.It Dv MADV_CORE
+Include region in a core file.
+.It Dv MADV_PROTECT
+Informs the VM system this process should not be killed when the
+swap space is exhausted.
+The process must have superuser privileges.
+This should be used judiciously in processes that must remain running
+for the system to properly function.
+.El
+.Pp
+Portable programs that call the
+.Fn posix_madvise
+interface should use the aliases
+.Dv POSIX_MADV_NORMAL , POSIX_MADV_SEQUENTIAL ,
+.Dv POSIX_MADV_RANDOM , POSIX_MADV_WILLNEED ,
+and
+.Dv POSIX_MADV_DONTNEED
+rather than the flags described above.
+.Sh RETURN VALUES
+.Rv -std madvise
+.Sh ERRORS
+The
+.Fn madvise
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa behav
+argument is not valid.
+.It Bq Er ENOMEM
+The virtual address range specified by the
+.Fa addr
+and
+.Fa len
+arguments is not valid.
+.It Bq Er EPERM
+.Dv MADV_PROTECT
+was specified and the process does not have superuser privileges.
+.El
+.Sh SEE ALSO
+.Xr mincore 2 ,
+.Xr mprotect 2 ,
+.Xr msync 2 ,
+.Xr munmap 2 ,
+.Xr posix_fadvise 2
+.Sh STANDARDS
+The
+.Fn posix_madvise
+interface conforms to
+.St -p1003.1-2001 .
+.Sh HISTORY
+The
+.Fn madvise
+system call first appeared in
+.Bx 4.4 .
diff --git a/lib/libsys/membarrier.2 b/lib/libsys/membarrier.2
new file mode 100644
index 000000000000..87db620975ef
--- /dev/null
+++ b/lib/libsys/membarrier.2
@@ -0,0 +1,151 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by Ed Maste <emaste@FreeBSD.org>
+.\" under sponsorship from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd October 6, 2024
+.Dt MEMBARRIER 2
+.Os
+.Sh NAME
+.Nm membarrier
+.Nd memory barrier
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/membarrier.h
+.Ft int
+.Fn membarrier "int cmd" "unsigned flags" "int cpu_id"
+.Sh DESCRIPTION
+The
+.Nm
+system call provides a memory barrier, ensuring ordering between memory
+accesses performed by different threads or processes within the same address
+space.
+.Pp
+The following values for
+.Fa cmd
+may be specified:
+.Bl -tag -width Dv
+.It Dv MEMBARRIER_CMD_QUERY
+Query supported commands.
+A bitmask of commands supported by the kernel is returned.
+.It Dv MEMBARRIER_CMD_GLOBAL
+Issue a memory barrier for all threads from all processes.
+.It Dv MEMBARRIER_CMD_SHARED
+This is an alias for
+.Dv MEMBARRIER_CMD_GLOBAL .
+.It Dv MEMBARRIER_CMD_GLOBAL_EXPEDITED
+Execute a memory barrier on all running threads of all processes registered
+with
+.Dv MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED .
+.It Dv MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED
+Register the process to receive
+.Dv MEMBARRIER_CMD_GLOBAL_EXPEDITED
+memory barriers.
+.It Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED
+Execute a memory barrier on each running thread belonging to the same process
+as the thread calling
+.Nm .
+.It Dv MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED
+Register the process to receive
+.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED
+memory barriers.
+.It Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
+In addition to the guarantees provided by
+.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED
+it also executes machine-specific serialization instructions, which
+ensures that all possible speculative and out-of-order activities on the target
+CPU are fenced.
+.It Dv MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE
+Register the process to receive
+.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
+memory barriers.
+.El
+.Pp
+The following
+.Fa cmd
+values are defined for source compatibility but are not yet supported:
+.Pp
+.Bl -tag -width Dv -compact
+.It Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ
+.It Dv MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ
+.El
+.Pp
+The
+.Fa flags
+argument must be 0.
+The
+.Fa cpu_id
+argument is ignored.
+.Sh RETURN VALUES
+If the
+.Fa cmd
+is
+.Dv MEMBARRIER_CMD_QUERY
+a bitmask of supported commands is returned.
+Otherwise, on success,
+.Nm
+returns 0.
+On error, -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+.Nm
+may fail with the following errors:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+.Fa cmd
+does not specify a valid command.
+.It Bq Er EINVAL
+.Fa flags
+is not 0.
+.It Bq Er EPERM
+An attempt was made to use
+.Dv MEMBARRIER_CMD_GLOBAL_EXPEDITED ,
+.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED ,
+or
+.Dv MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE
+by a process that did not previously register use with the corresponding
+.Dv MEMBARRIER_CMD_REGISTER_*
+.Fa cmd .
+.El
+.\" .Sh SEE ALSO
+.Sh STANDARDS
+The
+.Nm
+system call originated in Linux.
+This implementation aims to be source-compatible with the Linux implementation.
+Certain
+.Fa cmd
+and
+.Fa flags
+values are currently not supported by
+.Fx .
+.Sh HISTORY
+The
+.Nm
+function was introduced in
+.Fx 14.1 .
diff --git a/lib/libsys/mincore.2 b/lib/libsys/mincore.2
new file mode 100644
index 000000000000..0cb77d9937ce
--- /dev/null
+++ b/lib/libsys/mincore.2
@@ -0,0 +1,149 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd August 23, 2020
+.Dt MINCORE 2
+.Os
+.Sh NAME
+.Nm mincore
+.Nd determine residency of memory pages
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn mincore "const void *addr" "size_t len" "char *vec"
+.Sh DESCRIPTION
+The
+.Fn mincore
+system call determines whether each of the pages in the region beginning at
+.Fa addr
+and continuing for
+.Fa len
+bytes is resident or mapped, depending on the value of sysctl
+.Va vm.mincore_mapped .
+.\"The beginning address,
+.\".Fa addr ,
+.\"is first rounded down to a multiple of the page size (see
+.\".Xr getpagesize 3 ) .
+.\"The end address,
+.\".Fa addr No + Fa len ,
+.\"is rounded up to a multiple of the page size.
+The status is returned in the
+.Fa vec
+array, one character per page.
+Each character is either 0 if the page is not resident, or a combination of
+the following flags (defined in
+.In sys/mman.h ) :
+.Bl -tag -width ".Dv MINCORE_REFERENCED_OTHER"
+.It Dv MINCORE_INCORE
+Page is in core (resident).
+.It Dv MINCORE_REFERENCED
+Page has been referenced by us.
+.It Dv MINCORE_MODIFIED
+Page has been modified by us.
+.It Dv MINCORE_REFERENCED_OTHER
+Page has been referenced.
+.It Dv MINCORE_MODIFIED_OTHER
+Page has been modified.
+.It Dv MINCORE_PSIND(i)
+Page is part of a large
+.Pq Dq super
+page with size given by index
+.Dv i
+in the array returned by
+.Xr getpagesizes 3 .
+.It Dv MINCORE_SUPER
+A mask of the valid
+.Dv MINCORE_PSIND()
+values.
+If any bits in this mask are set, the page is part of a large
+.Pq Dq super
+page.
+.El
+.Pp
+The information returned by
+.Fn mincore
+may be out of date by the time the system call returns.
+The only way to ensure that a page is resident is to lock it into memory
+with the
+.Xr mlock 2
+system call.
+.Pp
+If the
+.Va vm.mincore_mapped
+sysctl is set to a non-zero value (default), only the current process'
+mappings of the pages in the specified virtual address range are examined.
+This does not preclude the system from returning
+.Dv MINCORE_REFERENCED_OTHER
+and
+.Dv MINCORE_MODIFIED_OTHER
+statuses.
+Otherwise, if the sysctl value is zero, all resident pages backing the
+specified address range are examined, regardless of the mapping state.
+.Sh IMPLEMENTATION NOTES
+Prior to the introduction of
+.Dv MINCORE_PSIND()
+in
+.Fx 13.0 ,
+.Dv MINCORE_SUPER
+consisted of a single bit equal to
+.Dv MINCORE_PSIND(1) .
+In particular, applications compiled using the old value of
+.Dv MINCORE_SUPER
+will not identify large pages with size index 2 as being large pages.
+.Sh RETURN VALUES
+.Rv -std mincore
+.Sh ERRORS
+The
+.Fn mincore
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOMEM
+The virtual address range specified by the
+.Fa addr
+and
+.Fa len
+arguments is not fully mapped.
+.It Bq Er EFAULT
+The
+.Fa vec
+argument points to an illegal address.
+.El
+.Sh SEE ALSO
+.Xr madvise 2 ,
+.Xr mlock 2 ,
+.Xr mprotect 2 ,
+.Xr msync 2 ,
+.Xr munmap 2 ,
+.Xr getpagesize 3 ,
+.Xr getpagesizes 3
+.Sh HISTORY
+The
+.Fn mincore
+system call first appeared in
+.Bx 4.4 .
diff --git a/lib/libsys/minherit.2 b/lib/libsys/minherit.2
new file mode 100644
index 000000000000..7240b8473656
--- /dev/null
+++ b/lib/libsys/minherit.2
@@ -0,0 +1,148 @@
+.\"
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd March 15, 2017
+.Dt MINHERIT 2
+.Os
+.Sh NAME
+.Nm minherit
+.Nd control the inheritance of pages
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn minherit "void *addr" "size_t len" "int inherit"
+.Sh DESCRIPTION
+The
+.Fn minherit
+system call
+changes the specified pages to have the inheritance characteristic
+.Fa inherit .
+Not all implementations will guarantee that the inheritance characteristic
+can be set on a page basis;
+the granularity of changes may be as large as an entire region.
+.Fx
+is capable of adjusting inheritance characteristics on a page basis.
+Inheritance only effects children created by
+.Fn fork .
+It has no effect on
+.Fn exec .
+exec'd processes replace their address space entirely.
+This system call also
+has no effect on the parent's address space (other than to potentially
+share the address space with its children).
+.Pp
+Inheritance is a rather esoteric feature largely superseded by the
+.Dv MAP_SHARED
+feature of
+.Fn mmap .
+However, it is possible to use
+.Fn minherit
+to share a block of memory between parent and child that has been mapped
+.Dv MAP_PRIVATE .
+That is, modifications made by parent or child are shared but
+the original underlying file is left untouched.
+.Bl -tag -width ".Dv INHERIT_SHARE"
+.It Dv INHERIT_SHARE
+This option causes the address space in question to be shared between
+parent and child.
+It has no effect on how the original underlying backing
+store was mapped.
+.It Dv INHERIT_NONE
+This option prevents the address space in question from being inherited
+at all.
+The address space will be unmapped in the child.
+.It Dv INHERIT_COPY
+This option causes the child to inherit the address space as copy-on-write.
+This option also has an unfortunate side effect of causing the parent
+address space to become copy-on-write when the parent forks.
+If the original mapping was
+.Dv MAP_SHARED ,
+it will no longer be shared in the parent
+after the parent forks and there is no way to get the previous
+shared-backing-store mapping without unmapping and remapping the address
+space in the parent.
+.It Dv INHERIT_ZERO
+This option causes the address space in question to be mapped as new
+anonymous pages,
+which would be initialized to all zero bytes,
+in the child process.
+.El
+.Sh RETURN VALUES
+.Rv -std minherit
+.Sh ERRORS
+The
+.Fn minherit
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The virtual address range specified by the
+.Fa addr
+and
+.Fa len
+arguments is not valid.
+.It Bq Er EACCES
+The flags specified by the
+.Fa inherit
+argument were not valid for the pages specified
+by the
+.Fa addr
+and
+.Fa len
+arguments.
+.El
+.Sh SEE ALSO
+.Xr fork 2 ,
+.Xr madvise 2 ,
+.Xr mincore 2 ,
+.Xr mprotect 2 ,
+.Xr msync 2 ,
+.Xr munmap 2 ,
+.Xr rfork 2
+.Sh HISTORY
+The
+.Fn minherit
+system call first appeared in
+.Ox
+and then in
+.Fx 2.2 .
+.Pp
+The
+.Dv INHERIT_ZERO
+support first appeared in
+.Ox 5.6
+and then in
+.Fx 12.0 .
+.Sh BUGS
+Once you set inheritance to
+.Dv MAP_PRIVATE
+or
+.Dv MAP_SHARED ,
+there is no way to recover the original copy-on-write semantics
+short of unmapping and remapping the area.
diff --git a/lib/libsys/mkdir.2 b/lib/libsys/mkdir.2
new file mode 100644
index 000000000000..100f44d1dcf9
--- /dev/null
+++ b/lib/libsys/mkdir.2
@@ -0,0 +1,179 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt MKDIR 2
+.Os
+.Sh NAME
+.Nm mkdir ,
+.Nm mkdirat
+.Nd make a directory file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.Ft int
+.Fn mkdir "const char *path" "mode_t mode"
+.Ft int
+.Fn mkdirat "int fd" "const char *path" "mode_t mode"
+.Sh DESCRIPTION
+The directory
+.Fa path
+is created with the access permissions specified by
+.Fa mode
+and restricted by the
+.Xr umask 2
+of the calling process.
+.Pp
+The directory's owner ID is set to the process's effective user ID.
+The directory's group ID is set to that of the parent directory in
+which it is created.
+.Pp
+The
+.Fn mkdirat
+system call is equivalent to
+.Fn mkdir
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the newly created directory is created relative to the
+directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn mkdirat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn mkdir .
+.Sh RETURN VALUES
+.Rv -std mkdir
+.Sh ERRORS
+The
+.Fn mkdir
+system call
+will fail and no directory will be created if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of the path prefix does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix,
+or write permission is denied
+on the parent directory of the directory to be created.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The parent directory of the directory to be created has its immutable flag set,
+see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EROFS
+The named directory would reside on a read-only file system.
+.It Bq Er EMLINK
+The new directory cannot be created because the parent directory contains
+too many subdirectories.
+.It Bq Er EEXIST
+The named file exists.
+.It Bq Er ENOSPC
+The new directory cannot be created because there is no space left
+on the file system that will contain the directory.
+.It Bq Er ENOSPC
+There are no free inodes on the file system on which the
+directory is being created.
+.It Bq Er EDQUOT
+The new directory cannot be created because the user's
+quota of disk blocks on the file system that will
+contain the directory has been exhausted.
+.It Bq Er EDQUOT
+The user's quota of inodes on the file system on
+which the directory is being created has been exhausted.
+.It Bq Er EIO
+An I/O error occurred while making the directory entry or allocating the inode.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn mkdir ,
+the
+.Fn mkdirat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr chmod 2 ,
+.Xr stat 2 ,
+.Xr umask 2
+.Sh STANDARDS
+The
+.Fn mkdir
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn mkdirat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn mkdirat
+system call appeared in
+.Fx 8.0 .
+The
+.Fn mkdir
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/mkfifo.2 b/lib/libsys/mkfifo.2
new file mode 100644
index 000000000000..3af12fb14b64
--- /dev/null
+++ b/lib/libsys/mkfifo.2
@@ -0,0 +1,180 @@
+.\" Copyright (c) 1990, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt MKFIFO 2
+.Os
+.Sh NAME
+.Nm mkfifo ,
+.Nm mkfifoat
+.Nd make a fifo file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/stat.h
+.Ft int
+.Fn mkfifo "const char *path" "mode_t mode"
+.Ft int
+.Fn mkfifoat "int fd" "const char *path" "mode_t mode"
+.Sh DESCRIPTION
+The
+.Fn mkfifo
+system call
+creates a new fifo file with name
+.Fa path .
+The access permissions are
+specified by
+.Fa mode
+and restricted by the
+.Xr umask 2
+of the calling process.
+.Pp
+The fifo's owner ID is set to the process's effective user ID.
+The fifo's group ID is set to that of the parent directory in
+which it is created.
+.Pp
+The
+.Fn mkfifoat
+system call is equivalent to
+.Fn mkfifo
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the newly created FIFO is created relative to the
+directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn mkfifoat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn mkfifo .
+.Sh RETURN VALUES
+.Rv -std mkfifo
+.Sh ERRORS
+The
+.Fn mkfifo
+system call
+will fail and no fifo will be created if:
+.Bl -tag -width Er
+.It Bq Er ENOTSUP
+The kernel has not been configured to support fifo's.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of the path prefix does not exist.
+.It Bq Er EACCES
+A component of the path prefix denies search permission, or write permission
+is denied on the parent directory of the fifo to be created.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EROFS
+The named file would reside on a read-only file system.
+.It Bq Er EEXIST
+The named file exists.
+.It Bq Er EPERM
+The parent directory of the named file has its immutable flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er ENOSPC
+The directory in which the entry for the new fifo is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er ENOSPC
+There are no free inodes on the file system on which the
+fifo is being created.
+.It Bq Er EDQUOT
+The directory in which the entry for the new fifo
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EDQUOT
+The user's quota of inodes on the file system on
+which the fifo is being created has been exhausted.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while making the directory entry or allocating the inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn mkfifo ,
+the
+.Fn mkfifoat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr chmod 2 ,
+.Xr mknod 2 ,
+.Xr stat 2 ,
+.Xr umask 2
+.Sh STANDARDS
+The
+.Fn mkfifo
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn mkfifoat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn mkfifoat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/mknod.2 b/lib/libsys/mknod.2
new file mode 100644
index 000000000000..f4327262b46b
--- /dev/null
+++ b/lib/libsys/mknod.2
@@ -0,0 +1,181 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt MKNOD 2
+.Os
+.Sh NAME
+.Nm mknod ,
+.Nm mknodat
+.Nd make a special file node
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.Ft int
+.Fn mknod "const char *path" "mode_t mode" "dev_t dev"
+.Ft int
+.Fn mknodat "int fd" "const char *path" "mode_t mode" "dev_t dev"
+.Sh DESCRIPTION
+The file system node
+.Fa path
+is created with the file type and access permissions specified in
+.Fa mode .
+The access permissions are modified by the process's umask value.
+.Pp
+If
+.Fa mode
+indicates a block or character special file,
+.Fa dev
+is a configuration dependent specification denoting a particular device
+on the system.
+Otherwise,
+.Fa dev
+is ignored.
+.Pp
+The
+.Fn mknod
+system call
+requires super-user privileges.
+.Pp
+The
+.Fn mknodat
+system call is equivalent to
+.Fn mknod
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the newly created device node is created relative to the
+directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn mknodat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn mknod .
+.Sh RETURN VALUES
+.Rv -std mknod
+.Sh ERRORS
+The
+.Fn mknod
+system call
+will fail and the file will be not created if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of the path prefix does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The process's effective user ID is not super-user.
+.It Bq Er EIO
+An I/O error occurred while making the directory entry or allocating the inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ENOSPC
+The directory in which the entry for the new node is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er ENOSPC
+There are no free inodes on the file system on which the
+node is being created.
+.It Bq Er EDQUOT
+The directory in which the entry for the new node
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EDQUOT
+The user's quota of inodes on the file system on
+which the node is being created has been exhausted.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EEXIST
+The named file exists.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+Creating anything else than a block or character special
+file (or a
+.Em whiteout )
+is not supported.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn mknod ,
+the
+.Fn mknodat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr chmod 2 ,
+.Xr mkfifo 2 ,
+.Xr stat 2 ,
+.Xr umask 2
+.Sh STANDARDS
+The
+.Fn mknodat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn mknod
+function appeared in
+.At v4 .
+The
+.Fn mknodat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/mlock.2 b/lib/libsys/mlock.2
new file mode 100644
index 000000000000..25346355a68a
--- /dev/null
+++ b/lib/libsys/mlock.2
@@ -0,0 +1,176 @@
+.\" Copyright (c) 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.
+.\"
+.Dd May 13, 2019
+.Dt MLOCK 2
+.Os
+.Sh NAME
+.Nm mlock ,
+.Nm munlock
+.Nd lock (unlock) physical pages in memory
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn mlock "const void *addr" "size_t len"
+.Ft int
+.Fn munlock "const void *addr" "size_t len"
+.Sh DESCRIPTION
+The
+.Fn mlock
+system call
+locks into memory the physical pages associated with the virtual address
+range starting at
+.Fa addr
+for
+.Fa len
+bytes.
+The
+.Fn munlock
+system call unlocks pages previously locked by one or more
+.Fn mlock
+calls.
+For both, the
+.Fa addr
+argument should be aligned to a multiple of the page size.
+If the
+.Fa len
+argument is not a multiple of the page size, it will be rounded up
+to be so.
+The entire range must be allocated.
+.Pp
+After an
+.Fn mlock
+system call, the indicated pages will cause neither a non-resident page
+nor address-translation fault until they are unlocked.
+They may still cause protection-violation faults or TLB-miss faults on
+architectures with software-managed TLBs.
+The physical pages remain in memory until all locked mappings for the pages
+are removed.
+Multiple processes may have the same physical pages locked via their own
+virtual address mappings.
+A single process may likewise have pages multiply-locked via different virtual
+mappings of the same physical pages.
+Unlocking is performed explicitly by
+.Fn munlock
+or implicitly by a call to
+.Fn munmap
+which deallocates the unmapped address range.
+Locked mappings are not inherited by the child process after a
+.Xr fork 2 .
+.Pp
+Since physical memory is a potentially scarce resource, processes are
+limited in how much they can lock down.
+The amount of memory that a single process can
+.Fn mlock
+is limited by both the per-process
+.Dv RLIMIT_MEMLOCK
+resource limit and the
+system-wide
+.Dq wired pages
+limit
+.Va vm.max_user_wired .
+.Va vm.max_user_wired
+applies to the system as a whole, so the amount available to a single
+process at any given time is the difference between
+.Va vm.max_user_wired
+and
+.Va vm.stats.vm.v_user_wire_count .
+.Pp
+If
+.Va security.bsd.unprivileged_mlock
+is set to 0 these calls are only available to the super-user.
+.Sh RETURN VALUES
+.Rv -std
+.Pp
+If the call succeeds, all pages in the range become locked (unlocked);
+otherwise the locked status of all pages in the range remains unchanged.
+.Sh ERRORS
+The
+.Fn mlock
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+.Va security.bsd.unprivileged_mlock
+is set to 0 and the caller is not the super-user.
+.It Bq Er EINVAL
+The address range given wraps around zero.
+.It Bq Er ENOMEM
+Some portion of the indicated address range is not allocated.
+There was an error faulting/mapping a page.
+Locking the indicated range would exceed the per-process or system-wide limits
+for locked memory.
+.El
+The
+.Fn munlock
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+.Va security.bsd.unprivileged_mlock
+is set to 0 and the caller is not the super-user.
+.It Bq Er EINVAL
+The address range given wraps around zero.
+.It Bq Er ENOMEM
+Some or all of the address range specified by the addr and len
+arguments does not correspond to valid mapped pages in the address space
+of the process.
+.It Bq Er ENOMEM
+Locking the pages mapped by the specified range would exceed a limit on
+the amount of memory that the process may lock.
+.El
+.Sh "SEE ALSO"
+.Xr fork 2 ,
+.Xr mincore 2 ,
+.Xr minherit 2 ,
+.Xr mlockall 2 ,
+.Xr mmap 2 ,
+.Xr munlockall 2 ,
+.Xr munmap 2 ,
+.Xr setrlimit 2 ,
+.Xr getpagesize 3
+.Sh HISTORY
+The
+.Fn mlock
+and
+.Fn munlock
+system calls first appeared in
+.Bx 4.4 .
+.Sh BUGS
+Allocating too much wired memory can lead to a memory-allocation deadlock
+which requires a reboot to recover from.
+.Pp
+The per-process and system-wide resource limits of locked memory apply
+to the amount of virtual memory locked, not the amount of locked physical
+pages.
+Hence two distinct locked mappings of the same physical page counts as
+2 pages aginst the system limit, and also against the per-process limit
+if both mappings belong to the same physical map.
+.Pp
+The per-process resource limit is not currently supported.
diff --git a/lib/libc/sys/mlockall.2 b/lib/libsys/mlockall.2
index 58d3a9b0d78a..58d3a9b0d78a 100644
--- a/lib/libc/sys/mlockall.2
+++ b/lib/libsys/mlockall.2
diff --git a/lib/libsys/mmap.2 b/lib/libsys/mmap.2
new file mode 100644
index 000000000000..bc8f1a624a2e
--- /dev/null
+++ b/lib/libsys/mmap.2
@@ -0,0 +1,564 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd August 14, 2023
+.Dt MMAP 2
+.Os
+.Sh NAME
+.Nm mmap
+.Nd allocate memory, or map files or devices into memory
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft void *
+.Fn mmap "void *addr" "size_t len" "int prot" "int flags" "int fd" "off_t offset"
+.Sh DESCRIPTION
+The
+.Fn mmap
+system call causes the pages starting at
+.Fa addr
+and continuing for at most
+.Fa len
+bytes to be mapped from the object described by
+.Fa fd ,
+starting at byte offset
+.Fa offset .
+If
+.Fa len
+is not a multiple of the page size, the mapped region may extend past the
+specified range.
+Any such extension beyond the end of the mapped object will be zero-filled.
+.Pp
+If
+.Fa fd
+references a regular file or a shared memory object, the range of
+bytes starting at
+.Fa offset
+and continuing for
+.Fa len
+bytes must be legitimate for the possible (not necessarily
+current) offsets in the object.
+In particular, the
+.Fa offset
+value cannot be negative.
+If the object is truncated and the process later accesses a page that
+is wholly within the truncated region, the access is aborted and a
+.Dv SIGBUS
+signal is delivered to the process.
+.Pp
+If
+.Fa fd
+references a device file, the interpretation of the
+.Fa offset
+value is device specific and defined by the device driver.
+The virtual memory subsystem does not impose any restrictions on the
+.Fa offset
+value in this case, passing it unchanged to the driver.
+.Pp
+If
+.Fa addr
+is non-zero, it is used as a hint to the system.
+(As a convenience to the system, the actual address of the region may differ
+from the address supplied.)
+If
+.Fa addr
+is zero, an address will be selected by the system.
+The actual starting address of the region is returned.
+A successful
+.Fa mmap
+deletes any previous mapping in the allocated address range.
+.Pp
+The protections (region accessibility) are specified in the
+.Fa prot
+argument by
+.Em or Ns 'ing
+the following values:
+.Pp
+.Bl -tag -width PROT_WRITE -compact
+.It Dv PROT_NONE
+Pages may not be accessed.
+.It Dv PROT_READ
+Pages may be read.
+.It Dv PROT_WRITE
+Pages may be written.
+.It Dv PROT_EXEC
+Pages may be executed.
+.El
+.Pp
+In addition to these protection flags,
+.Fx
+provides the ability to set the maximum protection of a region allocated by
+.Nm
+and later altered by
+.Xr mprotect 2 .
+This is accomplished by
+.Em or Ns 'ing
+one or more
+.Dv PROT_
+values wrapped in the
+.Dv PROT_MAX()
+macro into the
+.Fa prot
+argument.
+.Pp
+The
+.Fa flags
+argument specifies the type of the mapped object, mapping options and
+whether modifications made to the mapped copy of the page are private
+to the process or are to be shared with other references.
+Sharing, mapping type and options are specified in the
+.Fa flags
+argument by
+.Em or Ns 'ing
+the following values:
+.Bl -tag -width MAP_PREFAULT_READ
+.It Dv MAP_32BIT
+Request a region in the first 2GB of the current process's address space.
+If a suitable region cannot be found,
+.Fn mmap
+will fail.
+.It Dv MAP_ALIGNED Ns Pq Fa n
+Align the region on a requested boundary.
+If a suitable region cannot be found,
+.Fn mmap
+will fail.
+The
+.Fa n
+argument specifies the binary logarithm of the desired alignment.
+.It Dv MAP_ALIGNED_SUPER
+Align the region to maximize the potential use of large
+.Pq Dq super
+pages.
+If a suitable region cannot be found,
+.Fn mmap
+will fail.
+The system will choose a suitable page size based on the size of
+mapping.
+The page size used as well as the alignment of the region may both be
+affected by properties of the file being mapped.
+In particular,
+the physical address of existing pages of a file may require a specific
+alignment.
+The region is not guaranteed to be aligned on any specific boundary.
+.It Dv MAP_ANON
+Map anonymous memory not associated with any specific file.
+The file descriptor used for creating
+.Dv MAP_ANON
+must be \-1.
+The
+.Fa offset
+argument must be 0.
+.\".It Dv MAP_FILE
+.\"Mapped from a regular file or character-special device memory.
+.It Dv MAP_ANONYMOUS
+This flag is identical to
+.Dv MAP_ANON
+and is provided for compatibility.
+.It Dv MAP_EXCL
+This flag can only be used in combination with
+.Dv MAP_FIXED .
+Please see the definition of
+.Dv MAP_FIXED
+for the description of its effect.
+.It Dv MAP_FIXED
+Do not permit the system to select a different address than the one
+specified.
+If the specified address cannot be used,
+.Fn mmap
+will fail.
+If
+.Dv MAP_FIXED
+is specified,
+.Fa addr
+must be a multiple of the page size.
+If
+.Dv MAP_EXCL
+is not specified, a successful
+.Dv MAP_FIXED
+request replaces any previous mappings for the process'
+pages in the range from
+.Fa addr
+to
+.Fa addr
++
+.Fa len .
+In contrast, if
+.Dv MAP_EXCL
+is specified, the request will fail if a mapping
+already exists within the range.
+.It Dv MAP_GUARD
+Instead of a mapping, create a guard of the specified size.
+Guards allow a process to create reservations in its address space,
+which can later be replaced by actual mappings.
+.Pp
+.Fa mmap
+will not create mappings in the address range of a guard unless
+the request specifies
+.Dv MAP_FIXED .
+Guards can be destroyed with
+.Xr munmap 2 .
+Any memory access by a thread to the guarded range results
+in the delivery of a
+.Dv SIGSEGV
+signal to that thread.
+.It Dv MAP_NOCORE
+Region is not included in a core file.
+.It Dv MAP_NOSYNC
+Causes data dirtied via this VM map to be flushed to physical media
+only when necessary (usually by the pager) rather than gratuitously.
+Typically this prevents the update daemons from flushing pages dirtied
+through such maps and thus allows efficient sharing of memory across
+unassociated processes using a file-backed shared memory map.
+Without
+this option any VM pages you dirty may be flushed to disk every so often
+(every 30-60 seconds usually) which can create performance problems if you
+do not need that to occur (such as when you are using shared file-backed
+mmap regions for IPC purposes).
+Dirty data will be flushed automatically when all mappings of an object are
+removed and all descriptors referencing the object are closed.
+Note that VM/file system coherency is
+maintained whether you use
+.Dv MAP_NOSYNC
+or not.
+This option is not portable
+across
+.Ux
+platforms (yet), though some may implement the same behavior
+by default.
+.Pp
+.Em WARNING !
+Extending a file with
+.Xr ftruncate 2 ,
+thus creating a big hole, and then filling the hole by modifying a shared
+.Fn mmap
+can lead to severe file fragmentation.
+In order to avoid such fragmentation you should always pre-allocate the
+file's backing store by
+.Fn write Ns ing
+zero's into the newly extended area prior to modifying the area via your
+.Fn mmap .
+The fragmentation problem is especially sensitive to
+.Dv MAP_NOSYNC
+pages, because pages may be flushed to disk in a totally random order.
+.Pp
+The same applies when using
+.Dv MAP_NOSYNC
+to implement a file-based shared memory store.
+It is recommended that you create the backing store by
+.Fn write Ns ing
+zero's to the backing file rather than
+.Fn ftruncate Ns ing
+it.
+You can test file fragmentation by observing the KB/t (kilobytes per
+transfer) results from an
+.Dq Li iostat 1
+while reading a large file sequentially, e.g.,\& using
+.Dq Li dd if=filename of=/dev/null bs=32k .
+.Pp
+The
+.Xr fsync 2
+system call will flush all dirty data and metadata associated with a file,
+including dirty NOSYNC VM data, to physical media.
+The
+.Xr sync 8
+command and
+.Xr sync 2
+system call generally do not flush dirty NOSYNC VM data.
+The
+.Xr msync 2
+system call is usually not needed since
+.Bx
+implements a coherent file system buffer cache.
+However, it may be
+used to associate dirty VM pages with file system buffers and thus cause
+them to be flushed to physical media sooner rather than later.
+.It Dv MAP_PREFAULT_READ
+Immediately update the calling process's lowest-level virtual address
+translation structures, such as its page table, so that every memory
+resident page within the region is mapped for read access.
+Ordinarily these structures are updated lazily.
+The effect of this option is to eliminate any soft faults that would
+otherwise occur on the initial read accesses to the region.
+Although this option does not preclude
+.Fa prot
+from including
+.Dv PROT_WRITE ,
+it does not eliminate soft faults on the initial write accesses to the
+region.
+.It Dv MAP_PRIVATE
+Modifications are private.
+.It Dv MAP_SHARED
+Modifications are shared.
+.It Dv MAP_STACK
+Creates both a mapped region that grows downward on demand and an
+adjoining guard that both reserves address space for the mapped region
+to grow into and limits the mapped region's growth.
+Together, the mapped region and the guard occupy
+.Fa len
+bytes of the address space.
+The guard starts at the returned address, and the mapped region ends at
+the returned address plus
+.Fa len
+bytes.
+Upon access to the guard, the mapped region automatically grows in size,
+and the guard shrinks by an equal amount.
+Essentially, the boundary between the guard and the mapped region moves
+downward so that the access falls within the enlarged mapped region.
+However, the guard will never shrink to less than the number of pages
+specified by the sysctl
+.Dv security.bsd.stack_guard_page ,
+thereby ensuring that a gap for detecting stack overflow always exists
+between the downward growing mapped region and the closest mapped region
+beneath it.
+.Pp
+.Dv MAP_STACK
+implies
+.Dv MAP_ANON
+and
+.Fa offset
+of 0.
+The
+.Fa fd
+argument
+must be -1 and
+.Fa prot
+must include at least
+.Dv PROT_READ
+and
+.Dv PROT_WRITE .
+The size of the guard, in pages, is specified by sysctl
+.Dv security.bsd.stack_guard_page .
+.El
+.Pp
+The
+.Xr close 2
+system call does not unmap pages, see
+.Xr munmap 2
+for further information.
+.Sh NOTES
+Although this implementation does not impose any alignment restrictions on
+the
+.Fa offset
+argument, a portable program must only use page-aligned values.
+.Pp
+Large page mappings require that the pages backing an object be
+aligned in matching blocks in both the virtual address space and RAM.
+The system will automatically attempt to use large page mappings when
+mapping an object that is already backed by large pages in RAM by
+aligning the mapping request in the virtual address space to match the
+alignment of the large physical pages.
+The system may also use large page mappings when mapping portions of an
+object that are not yet backed by pages in RAM.
+The
+.Dv MAP_ALIGNED_SUPER
+flag is an optimization that will align the mapping request to the
+size of a large page similar to
+.Dv MAP_ALIGNED ,
+except that the system will override this alignment if an object already
+uses large pages so that the mapping will be consistent with the existing
+large pages.
+This flag is mostly useful for maximizing the use of large pages on the
+first mapping of objects that do not yet have pages present in RAM.
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn mmap
+returns a pointer to the mapped region.
+Otherwise, a value of
+.Dv MAP_FAILED
+is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn mmap
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+The flag
+.Dv PROT_READ
+was specified as part of the
+.Fa prot
+argument and
+.Fa fd
+was not open for reading.
+The flags
+.Dv MAP_SHARED
+and
+.Dv PROT_WRITE
+were specified as part of the
+.Fa flags
+and
+.Fa prot
+argument and
+.Fa fd
+was not open for writing.
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid open file descriptor.
+.It Bq Er EINVAL
+An invalid (negative) value was passed in the
+.Fa offset
+argument, when
+.Fa fd
+referenced a regular file or shared memory.
+.It Bq Er EINVAL
+An invalid value was passed in the
+.Fa prot
+argument.
+.It Bq Er EINVAL
+An undefined option was set in the
+.Fa flags
+argument.
+.It Bq Er EINVAL
+Both
+.Dv MAP_PRIVATE
+and
+.Dv MAP_SHARED
+were specified.
+.It Bq Er EINVAL
+None of
+.Dv MAP_ANON ,
+.Dv MAP_GUARD ,
+.Dv MAP_PRIVATE ,
+.Dv MAP_SHARED ,
+or
+.Dv MAP_STACK
+was specified.
+At least one of these flags must be included.
+.It Bq Er EINVAL
+.Dv MAP_STACK
+was specified and
+.Va len
+is less than or equal to the guard size.
+.It Bq Er EINVAL
+.Dv MAP_FIXED
+was specified and the
+.Fa addr
+argument was not page aligned, or part of the desired address space
+resides out of the valid address space for a user process.
+.It Bq Er EINVAL
+Both
+.Dv MAP_FIXED
+and
+.Dv MAP_32BIT
+were specified and part of the desired address space resides outside
+of the first 2GB of user address space.
+.It Bq Er EINVAL
+The
+.Fa len
+argument
+was equal to zero.
+.It Bq Er EINVAL
+.Dv MAP_ALIGNED
+was specified and the desired alignment was either larger than the
+virtual address size of the machine or smaller than a page.
+.It Bq Er EINVAL
+.Dv MAP_ANON
+was specified and the
+.Fa fd
+argument was not -1.
+.It Bq Er EINVAL
+.Dv MAP_ANON
+was specified and the
+.Fa offset
+argument was not 0.
+.It Bq Er EINVAL
+Both
+.Dv MAP_FIXED
+and
+.Dv MAP_EXCL
+were specified, but the requested region is already used by a mapping.
+.It Bq Er EINVAL
+.Dv MAP_EXCL
+was specified, but
+.Dv MAP_FIXED
+was not.
+.It Bq Er EINVAL
+.Dv MAP_GUARD
+was specified, but the
+.Fa offset
+argument was not zero, the
+.Fa fd
+argument was not -1, or the
+.Fa prot
+argument was not
+.Dv PROT_NONE .
+.It Bq Er EINVAL
+.Dv MAP_GUARD
+was specified together with one of the flags
+.Dv MAP_ANON ,
+.Dv MAP_PREFAULT ,
+.Dv MAP_PREFAULT_READ ,
+.Dv MAP_PRIVATE ,
+.Dv MAP_SHARED ,
+.Dv MAP_STACK .
+.It Bq Er ENODEV
+.Dv MAP_ANON
+has not been specified and
+.Fa fd
+did not reference a regular or character special file.
+.It Bq Er ENOMEM
+.Dv MAP_FIXED
+was specified and the
+.Fa addr
+argument was not available.
+.Dv MAP_ANON
+was specified and insufficient memory was available.
+.It Bq Er ENOTSUP
+The
+.Fa prot
+argument contains protections which are not a subset of the specified
+maximum protections.
+.El
+.Sh SEE ALSO
+.Xr madvise 2 ,
+.Xr mincore 2 ,
+.Xr minherit 2 ,
+.Xr mlock 2 ,
+.Xr mprotect 2 ,
+.Xr msync 2 ,
+.Xr munlock 2 ,
+.Xr munmap 2 ,
+.Xr getpagesize 3 ,
+.Xr getpagesizes 3
+.Sh HISTORY
+The
+.Nm
+system call was first documented in
+.Bx 4.2
+and implemented in
+.Bx 4.4 .
+.\" XXX: lots of missing history of FreeBSD additions.
+.Pp
+The
+.Dv PROT_MAX
+functionality was introduced in
+.Fx 13 .
diff --git a/lib/libc/sys/modfind.2 b/lib/libsys/modfind.2
index df6c8d6fd1ad..df6c8d6fd1ad 100644
--- a/lib/libc/sys/modfind.2
+++ b/lib/libsys/modfind.2
diff --git a/lib/libc/sys/modnext.2 b/lib/libsys/modnext.2
index 863d28688aaf..863d28688aaf 100644
--- a/lib/libc/sys/modnext.2
+++ b/lib/libsys/modnext.2
diff --git a/lib/libc/sys/modstat.2 b/lib/libsys/modstat.2
index cea7094cd586..cea7094cd586 100644
--- a/lib/libc/sys/modstat.2
+++ b/lib/libsys/modstat.2
diff --git a/lib/libsys/mount.2 b/lib/libsys/mount.2
new file mode 100644
index 000000000000..62e82c0b8184
--- /dev/null
+++ b/lib/libsys/mount.2
@@ -0,0 +1,400 @@
+.\" Copyright (c) 1980, 1989, 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.
+.\"
+.Dd March 30, 2020
+.Dt MOUNT 2
+.Os
+.Sh NAME
+.Nm mount ,
+.Nm nmount ,
+.Nm unmount
+.Nd mount or dismount a file system
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/mount.h
+.Ft int
+.Fn mount "const char *type" "const char *dir" "int flags" "void *data"
+.Ft int
+.Fn unmount "const char *dir" "int flags"
+.In sys/uio.h
+.Ft int
+.Fn nmount "struct iovec *iov" "u_int niov" "int flags"
+.Sh DESCRIPTION
+The
+.Fn mount
+system call grafts
+a file system object onto the system file tree
+at the point
+.Fa dir .
+The argument
+.Fa data
+describes the file system object to be mounted.
+The argument
+.Fa type
+tells the kernel how to interpret
+.Fa data
+(See
+.Fa type
+below).
+The contents of the file system
+become available through the new mount point
+.Fa dir .
+Any files in
+.Fa dir
+at the time
+of a successful mount are swept under the carpet so to speak, and
+are unavailable until the file system is unmounted.
+.Pp
+The
+.Fn nmount
+system call behaves similarly to
+.Fn mount ,
+except that the mount options (file system type name, device to mount,
+mount-point name, etc.) are passed as an array of name-value pairs
+in the array
+.Fa iov ,
+containing
+.Fa niov
+elements.
+The following options are required by all file systems:
+.Bl -column fstype -offset indent
+.It
+.Li fstype Ta file system type name (e.g., Dq Li procfs )
+.It
+.Li fspath Ta mount point pathname (e.g., Dq Li /proc )
+.El
+.Pp
+Depending on the file system type, other options may be
+recognized or required;
+for example, most disk-based file systems require a
+.Dq Li from
+option containing the pathname of a special device
+in addition to the options listed above.
+.Pp
+By default only the super-user may call the
+.Fn mount
+system call.
+This restriction can be removed by setting the
+.Va vfs.usermount
+.Xr sysctl 8
+variable
+to a non-zero value; see the BUGS section for more information.
+.Pp
+The following
+.Fa flags
+may be specified to
+suppress default semantics which affect file system access.
+.Bl -tag -width MNT_SYNCHRONOUS
+.It Dv MNT_RDONLY
+The file system should be treated as read-only;
+even the super-user may not write on it.
+Specifying MNT_UPDATE without this option will upgrade
+a read-only file system to read/write.
+.It Dv MNT_NOEXEC
+Do not allow files to be executed from the file system.
+.It Dv MNT_NOSUID
+Do not honor setuid or setgid bits on files when executing them.
+This flag is set automatically when the caller is not the super-user.
+.It Dv MNT_NOATIME
+Disable update of file access times.
+.It Dv MNT_SNAPSHOT
+Create a snapshot of the file system.
+This is currently only supported on UFS2 file systems, see
+.Xr mksnap_ffs 8
+for more information.
+.It Dv MNT_SUIDDIR
+Directories with the SUID bit set chown new files to their own owner.
+This flag requires the SUIDDIR option to have been compiled into the kernel
+to have any effect.
+See the
+.Xr mount 8
+and
+.Xr chmod 2
+pages for more information.
+.It Dv MNT_SYNCHRONOUS
+All I/O to the file system should be done synchronously.
+.It Dv MNT_ASYNC
+All I/O to the file system should be done asynchronously.
+.It Dv MNT_FORCE
+Force a read-write mount even if the file system appears to be unclean.
+Dangerous.
+Together with
+.Dv MNT_UPDATE
+and
+.Dv MNT_RDONLY ,
+specify that the file system is to be forcibly downgraded to a read-only
+mount even if some files are open for writing.
+.It Dv MNT_NOCLUSTERR
+Disable read clustering.
+.It Dv MNT_NOCLUSTERW
+Disable write clustering.
+.It Dv MNT_NOCOVER
+Do not mount over the root of another mount point.
+.It Dv MNT_EMPTYDIR
+Require an empty directory for the mount point directory.
+.El
+.Pp
+The flag
+.Dv MNT_UPDATE
+indicates that the mount command is being applied
+to an already mounted file system.
+This allows the mount flags to be changed without requiring
+that the file system be unmounted and remounted.
+Some file systems may not allow all flags to be changed.
+For example,
+many file systems will not allow a change from read-write to read-only.
+.Pp
+The flag
+.Dv MNT_RELOAD
+causes the vfs subsystem to update its data structures pertaining to
+the specified already mounted file system.
+.Pp
+The
+.Fa type
+argument names the file system.
+The types of file systems known to the system can be obtained with
+.Xr lsvfs 1 .
+.Pp
+The
+.Fa data
+argument
+is a pointer to a structure that contains the type
+specific arguments to mount.
+The format for these argument structures is described in the
+manual page for each file system.
+By convention file system manual pages are named
+by prefixing ``mount_'' to the name of the file system as returned by
+.Xr lsvfs 1 .
+Thus the
+.Tn NFS
+file system is described by the
+.Xr mount_nfs 8
+manual page.
+It should be noted that a manual page for default
+file systems, known as UFS and UFS2, does not exist.
+.Pp
+The
+.Fn unmount
+system call disassociates the file system from the specified
+mount point
+.Fa dir .
+.Pp
+The
+.Fa flags
+argument may include
+.Dv MNT_FORCE
+to specify that the file system should be forcibly unmounted
+even if files are still active.
+Active special devices continue to work,
+but any further accesses to any other active files result in errors
+even if the file system is later remounted.
+.Pp
+If the
+.Dv MNT_BYFSID
+flag is specified,
+.Fa dir
+should instead be a file system ID encoded as
+.Dq Li FSID : Ns Ar val0 : Ns Ar val1 ,
+where
+.Ar val0
+and
+.Ar val1
+are the contents of the
+.Vt fsid_t
+.Va val[]
+array in decimal.
+The file system that has the specified file system ID will be unmounted.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn mount
+and
+.Fn nmount
+system calls will fail when one of the following occurs:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The caller is neither the super-user nor the owner of
+.Fa dir .
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or the entire length of a path name exceeded 1023 characters.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating a pathname.
+.It Bq Er ENOENT
+A component of
+.Fa dir
+does not exist.
+.It Bq Er ENOTDIR
+A component of
+.Fa name
+is not a directory,
+or a path prefix of
+.Fa special
+is not a directory.
+.It Bq Er EBUSY
+Another process currently holds a reference to
+.Fa dir .
+.It Bq Er EBUSY
+The
+.Dv MNT_NOCOVER
+option was given, and the requested mount point
+is already the root of another mount point.
+.It Bq Er EFAULT
+The
+.Fa dir
+argument
+points outside the process's allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading data from
+.Fa special .
+.It Bq Er EINTEGRITY
+The backing store for
+.Fa special
+detected corrupted data while reading.
+.El
+.Pp
+The following errors can occur for a
+.Em ufs
+file system mount:
+.Bl -tag -width Er
+.It Bq Er ENODEV
+A component of ufs_args
+.Fa fspec
+does not exist.
+.It Bq Er ENOTBLK
+The
+.Fa fspec
+argument
+is not a block device.
+.It Bq Er ENOTEMPTY
+The
+.Dv MNT_EMPTYDIR
+option was specified, and the requested mount point
+is not an empty directory.
+.It Bq Er ENXIO
+The major device number of
+.Fa fspec
+is out of range (this indicates no device driver exists
+for the associated hardware).
+.It Bq Er EBUSY
+.Fa fspec
+is already mounted.
+.It Bq Er EMFILE
+No space remains in the mount table.
+.It Bq Er EINVAL
+The super block for the file system had a bad magic
+number or an out of range block size.
+.It Bq Er EINTEGRITY
+The super block for the file system had a bad check hash.
+The check hash can usually be corrected by running
+.Xr fsck 8 .
+.It Bq Er ENOMEM
+Not enough memory was available to read the cylinder
+group information for the file system.
+.It Bq Er EIO
+An I/O error occurred while reading the super block or
+cylinder group information.
+.It Bq Er EFAULT
+The
+.Fa fspec
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+The following errors can occur for a
+.Em nfs
+file system mount:
+.Bl -tag -width Er
+.It Bq Er ETIMEDOUT
+.Em Nfs
+timed out trying to contact the server.
+.It Bq Er EFAULT
+Some part of the information described by nfs_args
+points outside the process's allocated address space.
+.El
+.Pp
+The
+.Fn unmount
+system call may fail with one of the following errors:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The caller is neither the super-user nor the user who issued the corresponding
+.Fn mount
+call.
+.It Bq Er ENAMETOOLONG
+The length of the path name exceeded 1023 characters.
+.It Bq Er EINVAL
+The requested directory is not in the mount table.
+.It Bq Er ENOENT
+The file system ID specified using
+.Dv MNT_BYFSID
+was not found in the mount table.
+.It Bq Er EINVAL
+The file system ID specified using
+.Dv MNT_BYFSID
+could not be decoded.
+.It Bq Er EINVAL
+The specified file system is the root file system.
+.It Bq Er EBUSY
+A process is holding a reference to a file located
+on the file system.
+.It Bq Er EIO
+An I/O error occurred while writing cached file system information.
+.It Bq Er EFAULT
+The
+.Fa dir
+argument
+points outside the process's allocated address space.
+.El
+.Sh SEE ALSO
+.Xr lsvfs 1 ,
+.Xr mksnap_ffs 8 ,
+.Xr mount 8 ,
+.Xr umount 8
+.Sh HISTORY
+The
+.Fn mount
+and
+.Fn unmount
+functions appeared in
+.At v1 .
+The
+.Fn nmount
+system call first appeared in
+.Fx 5.0 .
+.Sh BUGS
+Some of the error codes need translation to more obvious messages.
+.Pp
+Allowing untrusted users to mount arbitrary media, e.g. by enabling
+.Va vfs.usermount ,
+should not be considered safe.
+Most file systems in
+.Fx
+were not built to safeguard against malicious devices.
diff --git a/lib/libsys/mprotect.2 b/lib/libsys/mprotect.2
new file mode 100644
index 000000000000..42e47b8cdaca
--- /dev/null
+++ b/lib/libsys/mprotect.2
@@ -0,0 +1,128 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd September 7, 2021
+.Dt MPROTECT 2
+.Os
+.Sh NAME
+.Nm mprotect
+.Nd control the protection of pages
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn mprotect "void *addr" "size_t len" "int prot"
+.Sh DESCRIPTION
+The
+.Fn mprotect
+system call
+changes the specified pages to have protection
+.Fa prot .
+.Pp
+The
+.Fa prot
+argument shall be
+.Dv PROT_NONE
+(no permissions at all)
+or the bitwise
+.Em or
+of one or more of the following values:
+.Pp
+.Bl -tag -width ".Dv PROT_WRITE" -compact
+.It Dv PROT_READ
+The pages can be read.
+.It Dv PROT_WRITE
+The pages can be written.
+.It Dv PROT_EXEC
+The pages can be executed.
+.El
+.Pp
+In addition to these standard protection flags,
+the
+.Fx
+implementation of
+.Fn mprotect
+provides the ability to set the maximum protection of a region
+(which prevents
+.Nm
+from adding to the permissions later).
+This is accomplished by bitwise
+.Em or Ns 'ing
+one or more
+.Dv PROT_
+values wrapped in the
+.Dv PROT_MAX()
+macro into the
+.Fa prot
+argument.
+.Sh RETURN VALUES
+.Rv -std mprotect
+.Sh ERRORS
+The
+.Fn mprotect
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+The calling process was not allowed to change
+the protection to the value specified by
+the
+.Fa prot
+argument.
+.It Bq Er EINVAL
+The virtual address range specified by the
+.Fa addr
+and
+.Fa len
+arguments is not valid.
+.It Bq Er EINVAL
+The
+.Fa prot
+argument contains unhandled bits.
+.It Bq Er ENOTSUP
+The
+.Fa prot
+argument contains permissions which are not a subset of the specified
+maximum permissions.
+.El
+.Sh SEE ALSO
+.Xr madvise 2 ,
+.Xr mincore 2 ,
+.Xr msync 2 ,
+.Xr munmap 2
+.Sh HISTORY
+The
+.Fn mprotect
+system call was first documented in
+.Bx 4.2
+and first appeared in
+.Bx 4.4 .
+.Pp
+The
+.Dv PROT_MAX
+functionality was introduced in
+.Fx 13 .
diff --git a/lib/libc/sys/mq_close.2 b/lib/libsys/mq_close.2
index 315e09d2cd16..315e09d2cd16 100644
--- a/lib/libc/sys/mq_close.2
+++ b/lib/libsys/mq_close.2
diff --git a/lib/libc/sys/mq_getattr.2 b/lib/libsys/mq_getattr.2
index b764cfac0fa3..b764cfac0fa3 100644
--- a/lib/libc/sys/mq_getattr.2
+++ b/lib/libsys/mq_getattr.2
diff --git a/lib/libc/sys/mq_notify.2 b/lib/libsys/mq_notify.2
index f2bf7aa6ebf4..f2bf7aa6ebf4 100644
--- a/lib/libc/sys/mq_notify.2
+++ b/lib/libsys/mq_notify.2
diff --git a/lib/libsys/mq_open.2 b/lib/libsys/mq_open.2
new file mode 100644
index 000000000000..4800ab18de59
--- /dev/null
+++ b/lib/libsys/mq_open.2
@@ -0,0 +1,344 @@
+.\" Copyright (c) 2005 David Xu <davidxu@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(s), this list of conditions and the following disclaimer as
+.\" the first lines of this file unmodified other than the possible
+.\" addition of one or more copyright notices.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
+.\"
+.\" Portions of this text are reprinted and reproduced in electronic form
+.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
+.\" Portable Operating System Interface (POSIX), The Open Group Base
+.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
+.\" Electrical and Electronics Engineers, Inc and The Open Group. In the
+.\" event of any discrepancy between this version and the original IEEE and
+.\" The Open Group Standard, the original IEEE and The Open Group Standard is
+.\" the referee document. The original Standard can be obtained online at
+.\" http://www.opengroup.org/unix/online.html.
+.\"
+.Dd May 15, 2024
+.Dt MQ_OPEN 2
+.Os
+.Sh NAME
+.Nm mq_open
+.Nd "open a message queue (REALTIME)"
+.Sh LIBRARY
+.Lb librt
+.Sh SYNOPSIS
+.In mqueue.h
+.Ft mqd_t
+.Fn mq_open "const char *name" "int oflag" "..."
+.Sh DESCRIPTION
+The
+.Fn mq_open
+system call establishes the connection between a process and a message queue
+with a message queue descriptor.
+It creates an open message queue
+description that refers to the message queue, and a message queue descriptor
+that refers to that open message queue description.
+The message queue
+descriptor is used by other functions to refer to that message queue.
+The
+.Fa name
+argument points to a string naming a message queue.
+The
+.Fa name
+argument should conform to the construction rules for a pathname.
+The
+.Fa name
+should begin with a slash character.
+Processes calling
+.Fn mq_open
+with the same value of
+.Fa name
+refers to the same message queue object, as long as that name has not been
+removed.
+If the
+.Fa name
+argument is not the name of an existing message queue and creation is not
+requested,
+.Fn mq_open
+will fail and return an error.
+.Pp
+The
+.Fa oflag
+argument requests the desired receive and/or send access to the message
+queue.
+The requested access permission to receive messages or send messages
+would be granted if the calling process would be granted read or write access,
+respectively, to an equivalently protected file.
+.Pp
+The value of
+.Fa oflag
+is the bitwise-inclusive OR of values from the following list.
+Applications should specify exactly one of the first three values (access
+modes) below in the value of
+.Fa oflag :
+.Bl -tag -width ".Dv O_NONBLOCK"
+.It Dv O_RDONLY
+Open the message queue for receiving messages.
+The process can use the
+returned message queue descriptor with
+.Fn mq_receive ,
+but not
+.Fn mq_send .
+A message queue may be open multiple times in the same or different processes
+for receiving messages.
+.It Dv O_WRONLY
+Open the queue for sending messages.
+The process can use the returned
+message queue descriptor with
+.Fn mq_send
+but not
+.Fn mq_receive .
+A message queue may be open multiple times in the same or different processes
+for sending messages.
+.It Dv O_RDWR
+Open the queue for both receiving and sending messages.
+The process can use
+any of the functions allowed for
+.Dv O_RDONLY
+and
+.Dv O_WRONLY .
+A message queue may be open multiple times in the same or different processes
+for sending messages.
+.El
+.Pp
+Any combination of the remaining flags may be specified in the value of
+.Fa oflag :
+.Bl -tag -width ".Dv O_NONBLOCK"
+.It Dv O_CREAT
+Create a message queue.
+It requires two additional arguments:
+.Fa mode ,
+which is of type
+.Vt mode_t ,
+and
+.Fa attr ,
+which is a pointer to an
+.Vt mq_attr
+structure.
+If the pathname
+.Fa name
+has already been used to create a message queue that still exists, then
+this flag has no effect, except as noted under
+.Dv O_EXCL .
+Otherwise, a message queue will be created without any messages
+in it.
+The user ID of the message queue will be set to the effective user ID
+of the process, and the group ID of the message queue will be set to the
+effective group ID of the process.
+The permission bits of the message queue
+will be set to the value of the
+.Fa mode
+argument, except those set in the file mode creation mask of the process.
+When bits in
+.Fa mode
+other than the file permission bits are specified, the effect is
+unspecified.
+If
+.Fa attr
+is
+.Dv NULL ,
+the message queue is created with implementation-defined default message
+queue attributes.
+If attr is
+.Pf non- Dv NULL
+and the calling process has the
+appropriate privilege on name, the message queue
+.Va mq_maxmsg
+and
+.Va mq_msgsize
+attributes will be set to the values of the corresponding members in the
+.Vt mq_attr
+structure referred to by
+.Fa attr .
+If
+.Fa attr
+is
+.Pf non- Dv NULL ,
+but the calling process does not have the appropriate privilege
+on name, the
+.Fn mq_open
+function will fail and return an error without creating the message queue.
+.It Dv O_EXCL
+If
+.Dv O_EXCL
+and
+.Dv O_CREAT
+are set,
+.Fn mq_open
+will fail if the message queue name exists.
+.It Dv O_NONBLOCK
+Determines whether an
+.Fn mq_send
+or
+.Fn mq_receive
+waits for resources or messages that are not currently available, or fails
+with
+.Va errno
+set to
+.Er EAGAIN ;
+see
+.Xr mq_send 2
+and
+.Xr mq_receive 2
+for details.
+.El
+.Pp
+The
+.Fn mq_open
+system call does not add or remove messages from the queue.
+.Sh NOTES
+.Fx
+implements message queue based on file descriptor.
+The descriptor
+is inherited by child after
+.Xr fork 2 .
+The descriptor is closed in a new image after
+.Xr exec 3 .
+The
+.Xr select 2
+and
+.Xr kevent 2
+system calls are supported for message queue descriptor.
+.Pp
+Please see the
+.Xr mqueuefs 4
+man page for instructions on loading the module or compiling the service into
+the kernel.
+.Pp
+The number of queues available, the maximum number of messages per queue
+and the maximum message size are tunable
+.Xr sysctl 8
+parameters.
+Their defaults are as follows.
+.Bl -column kern.mqueue.maxmsgsize integerxxx
+.It Sy "Name Type Default"
+.It "kern.mqueue.maxmq integer 100"
+.It "kern.mqueue.maxmsgsize integer 16384"
+.It "kern.mqueue.maxmsg integer 100"
+.El
+.Sh RETURN VALUES
+Upon successful completion, the function returns a message queue
+descriptor; otherwise, the function returns
+.Po Vt mqd_t Pc Ns \-1
+and sets the global variable
+.Va errno
+to indicate the error.
+.Sh ERRORS
+The
+.Fn mq_open
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+The message queue exists and the permissions specified by
+.Fa oflag
+are denied, or the message queue does not exist and permission to create the
+message queue is denied.
+.It Bq Er EEXIST
+.Dv O_CREAT
+and
+.Dv O_EXCL
+are set and the named message queue already exists.
+.It Bq Er EINTR
+The
+.Fn mq_open
+function was interrupted by a signal.
+.It Bq Er EINVAL
+The
+.Fn mq_open
+function is not supported for the given name.
+.It Bq Er EINVAL
+.Dv O_CREAT
+was specified in
+.Fa oflag ,
+the value of
+.Fa attr
+is not
+.Dv NULL ,
+and either
+.Va mq_maxmsg
+or
+.Va mq_msgsize
+was less than or equal to zero.
+.It Bq Er EMFILE
+Too many message queue descriptors or file descriptors are currently in use
+by this process.
+.It Bq Er ENAMETOOLONG
+The length of the
+.Fa name
+argument exceeds
+.Brq Dv PATH_MAX
+or a pathname component
+is longer than
+.Brq Dv NAME_MAX .
+.It Bq Er ENFILE
+Too many message queues are currently open in the system.
+.It Bq Er ENOENT
+.Dv O_CREAT
+is not set and the named message queue does not exist.
+.It Bq Er ENOSPC
+There is insufficient space for the creation of the new message queue.
+.El
+.Sh SEE ALSO
+.Xr mq_close 2 ,
+.Xr mq_getattr 2 ,
+.Xr mq_receive 2 ,
+.Xr mq_send 2 ,
+.Xr mq_setattr 2 ,
+.Xr mq_unlink 2 ,
+.Xr mq_timedreceive 3 ,
+.Xr mq_timedsend 3 ,
+.Xr mqueuefs 4
+.Sh STANDARDS
+The
+.Fn mq_open
+system call conforms to
+.St -p1003.1-2004 .
+.Sh HISTORY
+Support for POSIX message queues first appeared in
+.Fx 7.0 .
+.Sh BUGS
+This implementation places strict requirements on the value of
+.Fa name :
+it may begin with a slash
+.Pq Ql /
+and contain no other slash characters.
+.Pp
+The
+.Fa mode
+and
+.Fa attr
+arguments are variadic and may result in different calling conventions
+than might otherwise be expected.
+.Sh COPYRIGHT
+Portions of this text are reprinted and reproduced in electronic form
+from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
+Portable Operating System Interface (POSIX), The Open Group Base
+Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
+Electrical and Electronics Engineers, Inc and The Open Group. In the
+event of any discrepancy between this version and the original IEEE and
+The Open Group Standard, the original IEEE and The Open Group Standard is
+the referee document. The original Standard can be obtained online at
+http://www.opengroup.org/unix/online.html.
diff --git a/lib/libc/sys/mq_receive.2 b/lib/libsys/mq_receive.2
index d210704249d7..d210704249d7 100644
--- a/lib/libc/sys/mq_receive.2
+++ b/lib/libsys/mq_receive.2
diff --git a/lib/libc/sys/mq_send.2 b/lib/libsys/mq_send.2
index 8688f2742a94..8688f2742a94 100644
--- a/lib/libc/sys/mq_send.2
+++ b/lib/libsys/mq_send.2
diff --git a/lib/libc/sys/mq_setattr.2 b/lib/libsys/mq_setattr.2
index 30e0a607c1ea..30e0a607c1ea 100644
--- a/lib/libc/sys/mq_setattr.2
+++ b/lib/libsys/mq_setattr.2
diff --git a/lib/libsys/mq_unlink.2 b/lib/libsys/mq_unlink.2
new file mode 100644
index 000000000000..1bc74b85524f
--- /dev/null
+++ b/lib/libsys/mq_unlink.2
@@ -0,0 +1,119 @@
+.\" Copyright (c) 2021 Fernando Apesteguia <fernape@FreeBSD.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(s), this list of conditions and the following disclaimer as
+.\" the first lines of this file unmodified other than the possible
+.\" addition of one or more copyright notices.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
+.\"
+.\" Portions of this text are reprinted and reproduced in electronic form
+.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
+.\" Portable Operating System Interface (POSIX), The Open Group Base
+.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
+.\" Electrical and Electronics Engineers, Inc and The Open Group. In the
+.\" event of any discrepancy between this version and the original IEEE and
+.\" The Open Group Standard, the original IEEE and The Open Group Standard is
+.\" the referee document. The original Standard can be obtained online at
+.\" http://www.opengroup.org/unix/online.html.
+.\"
+.Dd February 15, 2021
+.Dt MQ_UNLINK 2
+.Os
+.Sh NAME
+.Nm mq_unlink
+.Nd "mq_unlink - remove a message queue (REALTIME)"
+.Sh LIBRARY
+.Lb librt
+.Sh SYNOPSIS
+.In mqueue.h
+.Ft int
+.Fn mq_unlink "const char *name"
+.Sh DESCRIPTION
+The
+.Fn mq_unlink
+function removes the message queue named by the string
+.Fa name .
+If one or more processes have the message queue open when
+.Fn mq_unlink
+is called, destruction of the message queue will be postponed
+until all references to the message queue have been closed.
+However, the
+.Fn mq_unlink
+call need not block until all references have been closed; it may return
+immediately.
+.Pp
+After a successful call to
+.Fn mq_unlink ,
+reuse of the name will subsequently cause
+.Xr mq_open 2
+to behave as if no message queue of this name exists.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn mq_unlink
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCESS
+Permission is denied to unlink the message queue represented by
+.Fa name .
+.It Bq Er EINVAL
+.Fa name
+is invalid.
+.It Bq Er ENAMETOOLONG
+The length of the
+.Fa name
+argument exceeds
+.Brq Dv PATH_MAX
+or
+a pathname component is longer than
+.Brq Dv NAME_MAX .
+.It Bq Er ENOENT
+The message queue does not exist.
+.It Bq Er ENOSYS
+.Xr mqueuefs 4
+module is neither loaded nor included in the kernel.
+.El
+.Sh SEE ALSO
+.Xr mq_open 2
+.Sh STANDARDS
+The
+.Fn mq_unlink
+system call conforms to
+.St -p1003.1-2004 .
+The
+.Bq Er EACCESS
+error code is an extension to the standard.
+.Sh HISTORY
+Support for POSIX message queues first appeared in
+.Fx 7.0 .
+.Sh COPYRIGHT
+Portions of this text are reprinted and reproduced in electronic form
+from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology --
+Portable Operating System Interface (POSIX), The Open Group Base
+Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of
+Electrical and Electronics Engineers, Inc and The Open Group.
+In the event of any discrepancy between this version and the original IEEE and
+The Open Group Standard, the original IEEE and The Open Group Standard is
+the referee document.
+The original Standard can be obtained online at
+http://www.opengroup.org/unix/online.html.
diff --git a/lib/libc/sys/msgctl.2 b/lib/libsys/msgctl.2
index 7556aa5c5cfd..7556aa5c5cfd 100644
--- a/lib/libc/sys/msgctl.2
+++ b/lib/libsys/msgctl.2
diff --git a/lib/libc/sys/msgget.2 b/lib/libsys/msgget.2
index c87f51ef57bf..c87f51ef57bf 100644
--- a/lib/libc/sys/msgget.2
+++ b/lib/libsys/msgget.2
diff --git a/lib/libc/sys/msgrcv.2 b/lib/libsys/msgrcv.2
index d8ca6626d63b..d8ca6626d63b 100644
--- a/lib/libc/sys/msgrcv.2
+++ b/lib/libsys/msgrcv.2
diff --git a/lib/libc/sys/msgsnd.2 b/lib/libsys/msgsnd.2
index 9677c80dc939..9677c80dc939 100644
--- a/lib/libc/sys/msgsnd.2
+++ b/lib/libsys/msgsnd.2
diff --git a/lib/libsys/msync.2 b/lib/libsys/msync.2
new file mode 100644
index 000000000000..3e10a2835bc8
--- /dev/null
+++ b/lib/libsys/msync.2
@@ -0,0 +1,123 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd March 18, 2012
+.Dt MSYNC 2
+.Os
+.Sh NAME
+.Nm msync
+.Nd synchronize a mapped region
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn msync "void *addr" "size_t len" "int flags"
+.Sh DESCRIPTION
+The
+.Fn msync
+system call
+writes any modified pages back to the file system and updates
+the file modification time.
+If
+.Fa len
+is 0, all modified pages within the region containing
+.Fa addr
+will be flushed;
+if
+.Fa len
+is non-zero, only those pages containing
+.Fa addr
+and
+.Fa len-1
+succeeding locations will be examined.
+The
+.Fa flags
+argument may be specified as follows:
+.Pp
+.Bl -tag -width ".Dv MS_INVALIDATE" -compact
+.It Dv MS_ASYNC
+Return immediately
+.It Dv MS_SYNC
+Perform synchronous writes
+.It Dv MS_INVALIDATE
+Invalidate all cached data
+.El
+.Sh RETURN VALUES
+.Rv -std msync
+.Sh ERRORS
+The
+.Fn msync
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBUSY
+Some or all of the pages in the specified region are locked and
+.Dv MS_INVALIDATE
+is specified.
+.It Bq Er EINVAL
+The
+.Fa addr
+argument
+is not a multiple of the hardware page size.
+.It Bq Er ENOMEM
+The addresses in the range starting at
+.Fa addr
+and continuing for
+.Fa len
+bytes are outside the range allowed for the address space of a
+process or specify one or more pages that are not mapped.
+.It Bq Er EINVAL
+The
+.Fa flags
+argument
+was both MS_ASYNC and MS_INVALIDATE.
+Only one of these flags is allowed.
+.It Bq Er EIO
+An error occurred while writing at least one of the pages in
+the specified region.
+.El
+.Sh SEE ALSO
+.Xr madvise 2 ,
+.Xr mincore 2 ,
+.Xr mlock 2 ,
+.Xr mprotect 2 ,
+.Xr munmap 2
+.Sh HISTORY
+The
+.Fn msync
+system call first appeared in
+.Bx 4.4 .
+.Sh BUGS
+The
+.Fn msync
+system call is usually not needed since
+.Bx
+implements a coherent file system buffer cache.
+However, it may be used to associate dirty VM pages with file system
+buffers and thus cause them to be flushed to physical media sooner
+rather than later.
diff --git a/lib/libsys/munmap.2 b/lib/libsys/munmap.2
new file mode 100644
index 000000000000..5c587d652a42
--- /dev/null
+++ b/lib/libsys/munmap.2
@@ -0,0 +1,82 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd January 16, 2025
+.Dt MUNMAP 2
+.Os
+.Sh NAME
+.Nm munmap
+.Nd remove a mapping
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/mman.h
+.Ft int
+.Fn munmap "void *addr" "size_t len"
+.Sh DESCRIPTION
+The
+.Fn munmap
+system call
+deletes the mappings and guards for the specified address range,
+and causes further references to addresses within the range
+to generate invalid memory references.
+.Sh RETURN VALUES
+.Rv -std munmap
+.Sh ERRORS
+The
+.Fn munmap
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa len
+argument was zero, or
+some part of the region being unmapped is outside the
+valid address range for a process.
+.El
+.Sh "SEE ALSO"
+.Xr madvise 2 ,
+.Xr mincore 2 ,
+.Xr mmap 2 ,
+.Xr mprotect 2 ,
+.Xr msync 2 ,
+.Xr getpagesize 3
+.Sh STANDARDS
+The
+.Fn munmap
+system call conforms to
+.St -p1003.1-2024 .
+Portable programs should ensure that
+.Fa addr
+is a multiple of the page size as returned by
+.Xr sysconf 3 .
+.Sh HISTORY
+The
+.Fn munmap
+system call first appeared in
+.Bx 4.4 .
diff --git a/lib/libsys/nanosleep.2 b/lib/libsys/nanosleep.2
new file mode 100644
index 000000000000..290565dbd6e1
--- /dev/null
+++ b/lib/libsys/nanosleep.2
@@ -0,0 +1,255 @@
+.\" $NetBSD: nanosleep.2,v 1.23 2016/11/14 10:40:59 wiz Exp $
+.\"
+.\" Copyright (c) 1986, 1991, 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.
+.\"
+.Dd May 3, 2025
+.Dt NANOSLEEP 2
+.Os
+.Sh NAME
+.Nm nanosleep
+.Nd high resolution sleep
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In time.h
+.Ft int
+.Fo clock_nanosleep
+.Fa "clockid_t clock_id"
+.Fa "int flags"
+.Fa "const struct timespec *rqtp"
+.Fa "struct timespec *rmtp"
+.Fc
+.Ft int
+.Fo nanosleep
+.Fa "const struct timespec *rqtp"
+.Fa "struct timespec *rmtp"
+.Fc
+.Sh DESCRIPTION
+If the
+.Dv TIMER_ABSTIME
+flag is not set in the
+.Fa flags
+argument, then
+.Fn clock_nanosleep
+suspends execution of the calling thread until either the
+time interval specified by the
+.Fa rqtp
+argument has elapsed,
+or a signal is delivered to the calling process and its
+action is to invoke a signal-catching function or to terminate the
+process.
+The clock used to measure the time is specified by the
+.Fa clock_id
+argument.
+.Pp
+If the
+.Dv TIMER_ABSTIME
+flag is set in the
+.Fa flags
+argument, then
+.Fn clock_nanosleep
+suspends execution of the calling thread until either the value
+of the clock specified by the
+.Fa clock_id
+argument reaches the absolute time specified by the
+.Fa rqtp
+argument,
+or a signal is delivered to the calling process and its
+action is to invoke a signal-catching function or to terminate the
+process.
+If, at the time of the call, the time value specified by
+.Fa rqtp
+is less than or equal to the time value of the specified clock, then
+.Fn clock_nanosleep
+returns immediately and the calling thread is not suspended.
+An unmasked signal will terminate the sleep early, regardless of the
+.Dv SA_RESTART
+value on the interrupting signal.
+The
+.Fa rqtp
+and
+.Fa rmtp
+arguments can point to the same object.
+.Pp
+The following
+.Fa clock_id
+values are supported:
+.Pp
+.Bl -item -compact -offset indent
+.It
+CLOCK_MONOTONIC
+.It
+CLOCK_MONOTONIC_FAST
+.It
+CLOCK_MONOTONIC_PRECISE
+.It
+CLOCK_REALTIME
+.It
+CLOCK_REALTIME_FAST
+.It
+CLOCK_REALTIME_PRECISE
+.It
+CLOCK_SECOND
+.It
+CLOCK_TAI
+.It
+CLOCK_UPTIME
+.It
+CLOCK_UPTIME_FAST
+.It
+CLOCK_UPTIME_PRECISE
+.El
+.Pp
+The suspension time may be longer than requested due to the
+scheduling of other activity by the system.
+The clocks with the
+.Dv _FAST
+suffix and the
+.Dv CLOCK_SECOND
+are subject to the allowed time interval deviation specified by the
+.Va kern.timecounter.alloweddeviation
+.Xr sysctl 8
+variable.
+The clocks with the
+.Dv _PRECISE
+suffix are always as precise as possible.
+The
+.Dv CLOCK_MONOTONIC ,
+.Dv CLOCK_REALTIME
+and
+.Dv CLOCK_UPTIME
+are precise by default.
+Setting the
+.Va kern.timecounter.nanosleep_precise
+.Xr sysctl 8
+to a false value would make those clocks to behave like the
+.Dv _FAST
+clocks.
+.Pp
+The
+.Fn nanosleep
+function behaves like
+.Fn clock_nanosleep
+with a
+.Fa clock_id
+argument of
+.Dv CLOCK_REALTIME
+and without the
+.Dv TIMER_ABSTIME
+flag in the
+.Fa flags
+argument.
+.Sh RETURN VALUES
+These functions return zero when the requested time has elapsed.
+.Pp
+If these functions return for any other reason, then
+.Fn clock_nanosleep
+will directly return the error number, and
+.Fn nanosleep
+will return \-1 with the global variable
+.Va errno
+set to indicate the error.
+If a relative sleep is interrupted by a signal and
+.Fa rmtp
+is
+.Pf non- Dv NULL ,
+the timespec structure it references is updated to contain the
+unslept amount (the request time minus the time actually slept).
+.Sh ERRORS
+These functions can fail with the following errors.
+.Bl -tag -width Er
+.It Bq Er EFAULT
+Either
+.Fa rqtp
+or
+.Fa rmtp
+points to memory that is not a valid part of the process
+address space.
+.It Bq Er EINTR
+The function was interrupted by the delivery of a signal.
+.It Bq Er EINVAL
+The
+.Fa rqtp
+argument specified a nanosecond value less than zero
+or greater than or equal to 1000 million.
+.It Bq Er EINVAL
+The
+.Fa flags
+argument contained an invalid flag.
+.It Bq Er EINVAL
+The
+.Fa clock_id
+argument was
+.Dv CLOCK_THREAD_CPUTIME_ID
+or an unrecognized value.
+.It Bq Er ENOTSUP
+The
+.Fa clock_id
+argument was valid but not supported by this implementation of
+.Fn clock_nanosleep .
+.El
+.Sh SEE ALSO
+.Xr clock_gettime 2 ,
+.Xr sigaction 2 ,
+.Xr sleep 3
+.Sh STANDARDS
+These functions conform to
+.St -p1003.1-2008 .
+.Sh HISTORY
+The predecessor of this system call,
+.Fn sleep ,
+appeared in
+.At v3 ,
+but was removed when
+.Xr alarm 3
+was introduced into
+.At v7 .
+The
+.Fn nanosleep
+system call has been available since
+.Nx 1.3
+and was ported to
+.Ox 2.1
+and
+.Fx 3.0 .
+The
+.Fn clock_nanosleep
+system call has been available since
+.Fx 11.1 .
+.Pp
+In
+.Fx 15.0
+the default behavior of
+.Fn clock_nanosleep
+with
+.Dv CLOCK_MONOTONIC ,
+.Dv CLOCK_REALTIME ,
+.Dv CLOCK_UPTIME
+clocks and
+.Fn nanosleep
+has been switched to use precise clock.
diff --git a/lib/libsys/nfssvc.2 b/lib/libsys/nfssvc.2
new file mode 100644
index 000000000000..9a0b2e020b91
--- /dev/null
+++ b/lib/libsys/nfssvc.2
@@ -0,0 +1,255 @@
+.\" Copyright (c) 1989, 1991, 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.
+.\"
+.Dd June 9, 1993
+.Dt NFSSVC 2
+.Os
+.Sh NAME
+.Nm nfssvc
+.Nd NFS services
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/mount.h
+.In sys/time.h
+.In nfs/rpcv2.h
+.In nfsserver/nfs.h
+.In unistd.h
+.Ft int
+.Fn nfssvc "int flags" "void *argstructp"
+.Sh DESCRIPTION
+The
+.Fn nfssvc
+system call is used by the NFS daemons to pass information into and out
+of the kernel and also to enter the kernel as a server daemon.
+The
+.Fa flags
+argument consists of several bits that show what action is to be taken
+once in the kernel and the
+.Fa argstructp
+points to one of three structures depending on which bits are set in
+flags.
+.Pp
+On the client side,
+.Xr nfsiod 8
+calls
+.Fn nfssvc
+with the
+.Fa flags
+argument set to
+.Dv NFSSVC_BIOD
+and
+.Fa argstructp
+set to
+.Dv NULL
+to enter the kernel as a block I/O server daemon.
+For
+.Tn NQNFS ,
+.Xr mount_nfs 8
+calls
+.Fn nfssvc
+with the
+.Dv NFSSVC_MNTD
+flag, optionally or'd with the flags
+.Dv NFSSVC_GOTAUTH
+and
+.Dv NFSSVC_AUTHINFAIL
+along with a pointer to a
+.Bd -literal
+struct nfsd_cargs {
+ char *ncd_dirp; /* Mount dir path */
+ uid_t ncd_authuid; /* Effective uid */
+ int ncd_authtype; /* Type of authenticator */
+ int ncd_authlen; /* Length of authenticator string */
+ u_char *ncd_authstr; /* Authenticator string */
+ int ncd_verflen; /* and the verifier */
+ u_char *ncd_verfstr;
+ NFSKERBKEY_T ncd_key; /* Session key */
+};
+.Ed
+.Pp
+structure.
+The initial call has only the
+.Dv NFSSVC_MNTD
+flag set to specify service for the mount point.
+If the mount point is using Kerberos, then the
+.Xr mount_nfs 8
+utility will return from
+.Fn nfssvc
+with
+.Va errno
+==
+.Er ENEEDAUTH
+whenever the client side requires an ``rcmd''
+authentication ticket for the user.
+The
+.Xr mount_nfs 8
+utility will attempt to get the Kerberos ticket, and if successful will call
+.Fn nfssvc
+with the flags
+.Dv NFSSVC_MNTD
+and
+.Dv NFSSVC_GOTAUTH
+after filling the ticket into the
+ncd_authstr field
+and
+setting the ncd_authlen and ncd_authtype
+fields of the nfsd_cargs structure.
+If
+.Xr mount_nfs 8
+failed to get the ticket,
+.Fn nfssvc
+will be called with the flags
+.Dv NFSSVC_MNTD ,
+.Dv NFSSVC_GOTAUTH
+and
+.Dv NFSSVC_AUTHINFAIL
+to denote a failed authentication attempt.
+.Pp
+On the server side,
+.Fn nfssvc
+is called with the flag
+.Dv NFSSVC_NFSD
+and a pointer to a
+.Bd -literal
+struct nfsd_srvargs {
+ struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
+ uid_t nsd_uid; /* Effective uid mapped to cred */
+ uint32_t nsd_haddr; /* Ip address of client */
+ struct ucred nsd_cr; /* Cred. uid maps to */
+ int nsd_authlen; /* Length of auth string (ret) */
+ u_char *nsd_authstr; /* Auth string (ret) */
+ int nsd_verflen; /* and the verifier */
+ u_char *nsd_verfstr;
+ struct timeval nsd_timestamp; /* timestamp from verifier */
+ uint32_t nsd_ttl; /* credential ttl (sec) */
+ NFSKERBKEY_T nsd_key; /* Session key */
+};
+.Ed
+.Pp
+to enter the kernel as an
+.Xr nfsd 8
+daemon.
+Whenever an
+.Xr nfsd 8
+daemon receives a Kerberos authentication ticket, it will return from
+.Fn nfssvc
+with
+.Va errno
+==
+.Er ENEEDAUTH .
+The
+.Xr nfsd 8
+utility will attempt to authenticate the ticket and generate a set of credentials
+on the server for the ``user id'' specified in the field nsd_uid.
+This is done by first authenticating the Kerberos ticket and then mapping
+the Kerberos principal to a local name and getting a set of credentials for
+that user via
+.Xr getpwnam 3
+and
+.Xr getgrouplist 3 .
+If successful, the
+.Xr nfsd 8
+utility will call
+.Fn nfssvc
+with the
+.Dv NFSSVC_NFSD
+and
+.Dv NFSSVC_AUTHIN
+flags set to pass the credential mapping in nsd_cr into the
+kernel to be cached on the server socket for that client.
+If the authentication failed,
+.Xr nfsd 8
+calls
+.Fn nfssvc
+with the flags
+.Dv NFSSVC_NFSD
+and
+.Dv NFSSVC_AUTHINFAIL
+to denote an authentication failure.
+.Pp
+The master
+.Xr nfsd 8
+server daemon calls
+.Fn nfssvc
+with the flag
+.Dv NFSSVC_ADDSOCK
+and a pointer to a
+.Bd -literal
+struct nfsd_args {
+ int sock; /* Socket to serve */
+ caddr_t name; /* Client address for connection based sockets */
+ int namelen;/* Length of name */
+};
+.Ed
+.Pp
+to pass a server side
+.Tn NFS
+socket into the kernel for servicing by the
+.Xr nfsd 8
+daemons.
+.Sh RETURN VALUES
+Normally
+.Fn nfssvc
+does not return unless the server
+is terminated by a signal when a value of 0 is returned.
+Otherwise, -1 is returned and the global variable
+.Va errno
+is set to specify the error.
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er ENEEDAUTH
+This special error value
+is really used for authentication support, particularly Kerberos,
+as explained above.
+.It Bq Er EPERM
+The caller is not the super-user.
+.El
+.Sh SEE ALSO
+.Xr mount_nfs 8 ,
+.Xr nfsd 8 ,
+.Xr nfsiod 8
+.Sh HISTORY
+The
+.Fn nfssvc
+system call first appeared in
+.Bx 4.4 .
+.Sh BUGS
+The
+.Fn nfssvc
+system call is designed specifically for the
+.Tn NFS
+support daemons and as such is specific to their requirements.
+It should really return values to indicate the need for authentication
+support, since
+.Er ENEEDAUTH
+is not really an error.
+Several fields of the argument structures are assumed to be valid and
+sometimes to be unchanged from a previous call, such that
+.Fn nfssvc
+must be used with extreme care.
diff --git a/lib/libc/sys/ntp_adjtime.2 b/lib/libsys/ntp_adjtime.2
index 5be5194a9c1d..5be5194a9c1d 100644
--- a/lib/libc/sys/ntp_adjtime.2
+++ b/lib/libsys/ntp_adjtime.2
diff --git a/lib/libsys/open.2 b/lib/libsys/open.2
new file mode 100644
index 000000000000..a0e905a8f375
--- /dev/null
+++ b/lib/libsys/open.2
@@ -0,0 +1,880 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd May 17, 2025
+.Dt OPEN 2
+.Os
+.Sh NAME
+.Nm open , openat
+.Nd open or create a file for reading, writing or executing
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.Ft int
+.Fn open "const char *path" "int flags" "..."
+.Ft int
+.Fn openat "int fd" "const char *path" "int flags" "..."
+.Sh DESCRIPTION
+The file name specified by
+.Fa path
+is opened
+for either execution or reading and/or writing as specified by the
+argument
+.Fa flags
+and the file descriptor returned to the calling process.
+The
+.Fa flags
+argument may indicate the file is to be
+created if it does not exist (by specifying the
+.Dv O_CREAT
+flag).
+In this case
+.Fn open
+and
+.Fn openat
+require an additional argument
+.Fa "mode_t mode" ,
+and the file is created with mode
+.Fa mode
+as described in
+.Xr chmod 2
+and modified by the process' umask value (see
+.Xr umask 2 ) .
+.Pp
+The
+.Fn openat
+function is equivalent to the
+.Fn open
+function except in the case where the
+.Fa path
+specifies a relative path.
+For
+.Fn openat
+and relative
+.Fa path ,
+the file to be opened is determined relative to the directory
+associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+The
+.Fa flag
+parameter and the optional fourth parameter correspond exactly to
+the parameters of
+.Fn open .
+If
+.Fn openat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used
+and the behavior is identical to a call to
+.Fn open .
+.Pp
+When
+.Fn openat
+is called with an absolute
+.Fa path ,
+it ignores the
+.Fa fd
+argument.
+.Pp
+In
+.Xr capsicum 4
+capability mode,
+.Fn open
+is not permitted.
+The
+.Fa path
+argument to
+.Fn openat
+must be strictly relative to a file descriptor
+.Fa fd ;
+that is,
+.Fa path
+must not be an absolute path and must not contain ".." components
+which cause the path resolution to escape the directory hierarchy
+starting at
+.Fa fd .
+Additionally, no symbolic link in
+.Fa path
+may target absolute path or contain escaping ".." components.
+.Fa fd
+must not be
+.Dv AT_FDCWD .
+.Pp
+If the
+.Dv vfs.lookup_cap_dotdot
+.Xr sysctl 3
+MIB is set to zero, ".." components in the paths,
+used in capability mode,
+are completely disabled.
+If the
+.Dv vfs.lookup_cap_dotdot_nonlocal
+MIB is set to zero, ".." is not allowed if found on non-local filesystem.
+.Pp
+The
+.Fa flags
+are formed by
+.Em or Ns 'ing
+the following values:
+.Pp
+.Bl -tag -width O_RESOLVE_BENEATH
+.It Dv O_RDONLY
+open for reading only
+.It Dv O_WRONLY
+open for writing only
+.It Dv O_RDWR
+open for reading and writing
+.It Dv O_EXEC
+open for execute only
+.It Dv O_SEARCH
+open for search only
+(an alias for
+.Dv O_EXEC
+typically used with
+.Dv O_DIRECTORY )
+.It Dv O_NONBLOCK
+do not block on open
+.It Dv O_APPEND
+set file pointer to the end of the file before each write
+.It Dv O_CREAT
+create file if it does not exist
+.It Dv O_TRUNC
+truncate size to 0
+.It Dv O_EXCL
+fail if
+.Dv O_CREAT
+is set and the file exists
+.It Dv O_SHLOCK
+atomically obtain a shared lock
+.It Dv O_EXLOCK
+atomically obtain an exclusive lock
+.It Dv O_DIRECT
+read and write directly from the backing store
+.It Dv O_FSYNC
+synchronous data and metadata writes
+.Pq historical synonym for Dv O_SYNC
+.It Dv O_SYNC
+synchronous data and metadata writes
+.It Dv O_DSYNC
+synchronous data writes
+.It Dv O_NOFOLLOW
+do not follow symlinks
+.It Dv O_NOCTTY
+ignored
+.It Dv O_TTY_INIT
+ignored
+.It Dv O_DIRECTORY
+error if file is not a directory
+.It Dv O_CLOEXEC
+automatically close file on
+.Xr execve 2
+.It Dv O_CLOFORK
+automatically close file on any child process created with
+.Fn fork 2
+.It Dv O_VERIFY
+verify the contents of the file with
+.Xr mac_veriexec 4
+.It Dv O_RESOLVE_BENEATH
+.Pq Xr openat 2 only
+path resolution must not cross the
+.Fa fd
+directory
+.It Dv O_PATH
+record only the target path in the opened descriptor
+.It Dv O_EMPTY_PATH
+.Pq Xr openat 2 only
+open file referenced by
+.Fa fd
+if path is empty
+.It Dv O_NAMEDATTR
+open a named attribute or named attribute directory
+.El
+.Pp
+Exactly one of the flags
+.Dv O_RDONLY ,
+.Dv O_WRONLY ,
+.Dv O_RDWR ,
+or
+.Dv O_EXEC
+must be provided.
+.Pp
+Opening a file with
+.Dv O_APPEND
+set causes each write on the resulting file descriptor
+to be appended to the end of the file.
+.Pp
+If
+.Dv O_TRUNC
+is specified and the
+file exists, the file is truncated to zero length.
+.Pp
+If
+.Dv O_CREAT
+is set, but file already exists,
+this flag has no effect except when
+.Dv O_EXCL
+is set too, in this case
+.Fn open
+fails with
+.Er EEXIST .
+This may be used to
+implement a simple exclusive access locking mechanism.
+In all other cases, the file is created
+and the access permission bits (see
+.Xr chmod 2)
+of the file mode
+are set to the value of the third argument taken as
+.Fa "mode_t mode"
+and passed through the
+.Xr umask 2 .
+This argument does not affect whether the file is opened
+for reading, writing, or for both.
+The open' request for a lock on the file, created with
+.Dv O_CREAT ,
+will never fail
+provided that the underlying file system supports locking;
+see also
+.Dv O_SHLOCK
+and
+.Dv O_EXLOCK
+below.
+.Pp
+If
+.Dv O_EXCL
+is set and the last component of the pathname is
+a symbolic link,
+.Fn open
+will fail even if the symbolic
+link points to a non-existent name.
+.Pp
+If
+.Dv O_NONBLOCK
+is specified and the
+.Fn open
+system call would
+block for some reason (for example, waiting for
+carrier on a dialup line),
+.Fn open
+returns immediately.
+The descriptor remains in non-blocking mode for subsequent operations.
+.Pp
+If
+.Dv O_SYNC
+is used in the mask, all writes will
+immediately and synchronously be written to disk.
+.Dv O_FSYNC
+is an historical synonym for
+.Dv O_SYNC .
+.Pp
+If
+.Dv O_DSYNC
+is used in the mask, all data and metadata required to read the data will be
+synchronously written to disk, but changes to metadata such as file access and
+modification timestamps may be written later.
+.Pp
+If
+.Dv O_NOFOLLOW
+is used in the mask and the target file passed to
+.Fn open
+is a symbolic link then the
+.Fn open
+will fail.
+.Pp
+When opening a file, a lock with
+.Xr flock 2
+semantics can be obtained by setting
+.Dv O_SHLOCK
+for a shared lock, or
+.Dv O_EXLOCK
+for an exclusive lock.
+.Pp
+.Dv O_DIRECT
+may be used to minimize or eliminate the cache effects of reading and writing.
+The system will attempt to avoid caching the data you read or write.
+If it cannot avoid caching the data,
+it will minimize the impact the data has on the cache.
+Use of this flag can drastically reduce performance if not used with care.
+The semantics of this flag are filesystem dependent,
+and some filesystems may ignore it entirely.
+.Pp
+.Dv O_NOCTTY
+may be used to ensure the OS does not assign this file as the
+controlling terminal when it opens a tty device.
+This is the default on
+.Fx ,
+but is present for
+POSIX
+compatibility.
+The
+.Fn open
+system call will not assign controlling terminals on
+.Fx .
+.Pp
+.Dv O_TTY_INIT
+may be used to ensure the OS restores the terminal attributes when
+initially opening a TTY.
+This is the default on
+.Fx ,
+but is present for
+POSIX
+compatibility.
+The initial call to
+.Fn open
+on a TTY will always restore default terminal attributes on
+.Fx .
+.Pp
+.Dv O_DIRECTORY
+may be used to ensure the resulting file descriptor refers to a
+directory.
+This flag can be used to prevent applications with elevated privileges
+from opening files which are even unsafe to open with
+.Dv O_RDONLY ,
+such as device nodes.
+.Pp
+.Dv O_CLOEXEC
+may be used to set
+.Dv FD_CLOEXEC
+flag for the newly returned file descriptor.
+.Pp
+.Dv O_CLOFORK
+may be used to set
+.Dv FD_CLOFORK
+flag for the newly returned file descriptor.
+The file will be closed on any child process created with
+.Fn fork 2 ,
+.Fn vfork 2
+or
+.Fn rfork 2
+with the
+.Dv RFFDG
+flag, remaining open in the parent.
+Both the
+.Dv O_CLOEXEC
+and
+.Dv O_CLOFORK
+flags can be modified with the
+.Dv F_SETFD
+.Fn fcntl 2
+command.
+.Pp
+.Dv O_VERIFY
+may be used to indicate to the kernel that the contents of the file should
+be verified before allowing the open to proceed.
+The details of what
+.Dq verified
+means is implementation specific.
+The run-time linker (rtld) uses this flag to ensure shared objects have
+been verified before operating on them.
+.Pp
+.Dv O_RESOLVE_BENEATH
+returns
+.Er ENOTCAPABLE
+if any intermediate component of the specified relative path does not
+reside in the directory hierarchy beneath the starting directory.
+Absolute paths or even the temporal escape from beneath of the starting
+directory is not allowed.
+.Pp
+When a directory
+is opened with
+.Dv O_SEARCH ,
+execute permissions are checked at open time.
+The returned file descriptor
+may not be used for any read operations like
+.Xr getdirentries 2 .
+The primary use of this descriptor is as the lookup descriptor for the
+.Fn *at
+family of functions.
+If
+.Dv O_SEARCH
+was not requested at open time, then the
+.Fn *at
+functions use the current directory permissions for the directory referenced
+by the descriptor at the time of the
+.Fn *at
+call.
+.Pp
+.Dv O_PATH
+returns a file descriptor that can be used as a directory file descriptor for
+.Fn openat
+and other system calls taking a file descriptor argument, like
+.Xr fstatat 2
+and others.
+The other functionality of the returned file descriptor is limited to
+the following descriptor-level operations:
+.Pp
+.Bl -tag -width __acl_aclcheck_fd -offset indent -compact
+.It Xr fcntl 2
+but advisory locking is not allowed
+.It Xr dup 2
+.It Xr close 2
+.It Xr fstat 2
+.It Xr fstatfs 2
+.It Xr fchdir 2
+.It Xr fchroot 2
+.It Xr fexecve 2
+.It Xr funlinkat 2
+can be passed as the third argument
+.It Dv SCM_RIGHTS
+can be passed over a
+.Xr unix 4
+socket using a
+.Dv SCM_RIGHTS
+message
+.It Xr kqueue 2
+only with
+.Dv EVFILT_VNODE
+.It Xr __acl_get_fd 2
+.It Xr __acl_aclcheck_fd 2
+.It Xr extattr 2
+.It Xr capsicum 4
+can be passed to
+.Fn cap_*_limit
+and
+.Fn cap_*_get
+system calls (such as
+.Xr cap_rights_limit 2 ) .
+.El
+.Pp
+Other operations like
+.Xr read 2 ,
+.Xr ftruncate 2 ,
+and any other that operate on file and not on file descriptor (except
+.Xr fstat 2 ) ,
+are not allowed.
+.Pp
+A file descriptor created with the
+.Dv O_PATH
+flag can be opened as a normal (operable) file descriptor by
+specifying it as the
+.Fa fd
+argument to
+.Fn openat
+with an empty
+.Fa path
+and the
+.Dv O_EMPTY_PATH
+flag.
+Such an open behaves as if the current path of the file referenced by
+.Fa fd
+is passed, except that path walk permissions are not checked.
+See also the description of
+.Dv AT_EMPTY_PATH
+flag for
+.Xr fstatat 2
+and related syscalls.
+.Pp
+Conversely, a file descriptor
+.Dv fd
+referencing a filesystem file can be converted to the
+.Dv O_PATH
+type of descriptor by using the following call
+.Dl opath_fd = openat(fd, \[dq]\[dq], O_EMPTY_PATH | O_PATH);
+.Pp
+If successful,
+.Fn open
+returns a non-negative integer, termed a file descriptor.
+It returns \-1 on failure.
+The file descriptor value returned is the lowest numbered descriptor
+currently not in use by the process.
+The file pointer used to mark the current position within the
+file is set to the beginning of the file.
+.Pp
+If a sleeping open of a device node from
+.Xr devfs 4
+is interrupted by a signal, the call always fails with
+.Er EINTR ,
+even if the
+.Dv SA_RESTART
+flag is set for the signal.
+A sleeping open of a fifo (see
+.Xr mkfifo 2 )
+is restarted as normal.
+.Pp
+When a new file is created, it is assigned the group of the directory
+which contains it.
+.Pp
+Unless
+.Dv O_CLOEXEC
+flag was specified,
+the new descriptor is set to remain open across
+.Xr execve 2
+system calls; see
+.Xr close 2 ,
+.Xr fcntl 2
+and the description of the
+.Dv O_CLOEXEC
+flag.
+.Pp
+When the
+.Dv O_NAMEDATTR
+flag is specified for an
+.Fn openat
+where the
+.Fa fd
+argument is for a file object,
+a named attribute for the file object
+is opened and not the file object itself.
+If the
+.Dv O_CREAT
+flag has been specified as well, the named attribute will be
+created if it does not exist.
+When the
+.Dv O_NAMEDATTR
+flag is specified for a
+.Fn open ,
+a named attribute for the current working directory is opened and
+not the current working directory.
+The
+.Fa path
+argument for this
+.Fn openat
+or
+.Fn open
+must be a single component name with no embedded
+.Ql / .
+If the
+.Fa path
+argument is
+.Ql .\&
+then the named attribute directory for the file object is opened.
+(See
+.Xr named_attribute 7
+for more information.)
+.Pp
+The system imposes a limit on the number of file descriptors
+open simultaneously by one process.
+The
+.Xr getdtablesize 2
+system call returns the current system limit.
+.Sh RETURN VALUES
+If successful,
+.Fn open
+and
+.Fn openat
+return a non-negative integer, termed a file descriptor.
+They return \-1 on failure, and set
+.Va errno
+to indicate the error.
+.Sh ERRORS
+The named file is opened unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+.Dv O_CREAT
+is not set and the named file does not exist.
+.It Bq Er ENOENT
+A component of the path name that must exist does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+The required permissions (for reading and/or writing)
+are denied for the given flags.
+.It Bq Er EACCES
+.Dv O_TRUNC
+is specified and write permission is denied.
+.It Bq Er EACCES
+.Dv O_CREAT
+is specified,
+the file does not exist,
+and the directory in which it is to be created
+does not permit writing.
+.It Bq Er EPERM
+.Dv O_CREAT
+is specified, the file does not exist, and the directory in which it is to be
+created has its immutable flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EPERM
+The named file has its immutable flag set and the file is to be modified.
+.It Bq Er EPERM
+The named file has its append-only flag set, the file is to be modified, and
+.Dv O_TRUNC
+is specified or
+.Dv O_APPEND
+is not specified.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EISDIR
+The named file is a directory, and the arguments specify
+it is to be modified.
+.It Bq Er EISDIR
+The named file is a directory, and the flags specified
+.Dv O_CREAT
+without
+.Dv O_DIRECTORY .
+.It Bq Er EROFS
+The named file resides on a read-only file system,
+and the file is to be modified.
+.It Bq Er EROFS
+.Dv O_CREAT
+is specified and the named file would reside on a read-only file system.
+.It Bq Er EMFILE
+The process has already reached its limit for open file descriptors.
+.It Bq Er ENFILE
+The system file table is full.
+.It Bq Er EMLINK
+.Dv O_NOFOLLOW
+was specified and the target is a symbolic link.
+POSIX
+specifies a different error for this case; see the note in
+.Sx STANDARDS
+below.
+.It Bq Er ENXIO
+The named file is a character special or block
+special file, and the device associated with this special file
+does not exist.
+.It Bq Er ENXIO
+.Dv O_NONBLOCK
+is set, the named file is a fifo,
+.Dv O_WRONLY
+is set, and no process has the file open for reading.
+.It Bq Er EINTR
+The
+.Fn open
+operation was interrupted by a signal.
+.It Bq Er EOPNOTSUPP
+.Dv O_SHLOCK
+or
+.Dv O_EXLOCK
+is specified but the underlying file system does not support locking.
+.It Bq Er EOPNOTSUPP
+The named file is a special file mounted through a file system that
+does not support access to it (for example, NFS).
+.It Bq Er EWOULDBLOCK
+.Dv O_NONBLOCK
+and one of
+.Dv O_SHLOCK
+or
+.Dv O_EXLOCK
+is specified and the file is locked.
+.It Bq Er ENOSPC
+.Dv O_CREAT
+is specified,
+the file does not exist,
+and the directory in which the entry for the new file is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er ENOSPC
+.Dv O_CREAT
+is specified,
+the file does not exist,
+and there are no free inodes on the file system on which the
+file is being created.
+.It Bq Er EDQUOT
+.Dv O_CREAT
+is specified,
+the file does not exist,
+and the directory in which the entry for the new file
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EDQUOT
+.Dv O_CREAT
+is specified,
+the file does not exist,
+and the user's quota of inodes on the file system on
+which the file is being created has been exhausted.
+.It Bq Er EIO
+An I/O error occurred while making the directory entry or
+allocating the inode for
+.Dv O_CREAT .
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ETXTBSY
+The file is a pure procedure (shared text) file that is being
+executed and the
+.Fn open
+system call requests write access.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EEXIST
+.Dv O_CREAT
+and
+.Dv O_EXCL
+were specified and the file exists.
+.It Bq Er EOPNOTSUPP
+An attempt was made to open a socket (not currently implemented).
+.It Bq Er EINVAL
+An attempt was made to open a descriptor with an illegal combination
+of
+.Dv O_RDONLY ,
+.Dv O_WRONLY ,
+or
+.Dv O_RDWR ,
+and
+.Dv O_EXEC
+or
+.Dv O_SEARCH .
+.It Bq Er EINVAL
+.Dv O_CREAT
+is specified,
+and the last component of the
+.Fa path
+argument is invalid on the file system on which the file is being created.
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is
+neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTDIR
+.Dv O_DIRECTORY
+is specified and the file is not a directory.
+.It Bq Er ECAPMODE
+.Dv AT_FDCWD
+is specified and the process is in capability mode.
+.It Bq Er ECAPMODE
+.Fn open
+was called and the process is in capability mode.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path and the process is in capability mode.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path and
+.Dv O_RESOLVE_BENEATH
+is specified.
+.It Bq Er ENOTCAPABLE
+.Fa path
+contains a ".." component leading to a directory outside
+of the directory hierarchy specified by
+.Fa fd
+and the process is in capability mode.
+.It Bq Er ENOTCAPABLE
+.Fa path
+contains a ".." component leading to a directory outside
+of the directory hierarchy specified by
+.Fa fd
+and
+.Dv O_RESOLVE_BENEATH
+is specified.
+.It Bq Er ENOTCAPABLE
+.Fa path
+contains a ".." component, the
+.Dv vfs.lookup_cap_dotdot
+.Xr sysctl 3
+is set, and the process is in capability mode.
+.It Bq Er ENOATTR
+.Dv O_NAMEDATTR
+has been specified and the file object is not a named attribute
+directory or named attribute.
+.El
+.Sh SEE ALSO
+.Xr chmod 2 ,
+.Xr close 2 ,
+.Xr dup 2 ,
+.Xr fexecve 2 ,
+.Xr fhopen 2 ,
+.Xr getdtablesize 2 ,
+.Xr getfh 2 ,
+.Xr lgetfh 2 ,
+.Xr lseek 2 ,
+.Xr read 2 ,
+.Xr umask 2 ,
+.Xr write 2 ,
+.Xr fopen 3 ,
+.Xr capsicum 4 ,
+.Xr named_attribute 7
+.Sh STANDARDS
+These functions are specified by
+.St -p1003.1-2008 .
+.Pp
+.Fx
+sets
+.Va errno
+to
+.Er EMLINK instead of
+.Er ELOOP
+as specified by
+POSIX
+when
+.Dv O_NOFOLLOW
+is set in flags and the final component of pathname is a symbolic link
+to distinguish it from the case of too many symbolic link traversals
+in one of its non-final components.
+.Pp
+The Open Group Extended API Set 2 specification, that introduced the
+.Fn *at
+API, required that the test for whether
+.Fa fd
+is searchable is based on whether
+.Fa fd
+is open for searching, not whether the underlying directory currently
+permits searches.
+The present implementation of the
+.Fa openat
+system call is believed to be compatible with
+.\" .St -p1003.1-2017 ,
+.\" XXX: This should be replaced in the future when an appropriate argument to
+.\" the St macro is available: -p1003.1-2017
+.No IEEE Std 1003.1-2008, 2017 Edition ("POSIX.1") ,
+which specifies that behavior for
+.Dv O_SEARCH ,
+in the absence of the flag the implementation checks the current
+permissions of a directory.
+.Sh HISTORY
+The
+.Fn open
+function appeared in
+.At v1 .
+The
+.Fn openat
+function was introduced in
+.Fx 8.0 .
+.Dv O_DSYNC
+appeared in 13.0.
+.Dv O_NAMEDATTR
+appeared in 15.0.
+.Dv O_CLOFORK
+appeared in
+.Fx 15.0 .
+.Sh BUGS
+The
+.Fa mode
+argument is variadic and may result in different calling conventions
+than might otherwise be expected.
diff --git a/lib/libsys/pathconf.2 b/lib/libsys/pathconf.2
new file mode 100644
index 000000000000..79ac8310000d
--- /dev/null
+++ b/lib/libsys/pathconf.2
@@ -0,0 +1,279 @@
+.\" Copyright (c) 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.
+.\"
+.Dd July 5, 2025
+.Dt PATHCONF 2
+.Os
+.Sh NAME
+.Nm pathconf ,
+.Nm lpathconf ,
+.Nm fpathconf
+.Nd get configurable pathname variables
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft long
+.Fn pathconf "const char *path" "int name"
+.Ft long
+.Fn lpathconf "const char *path" "int name"
+.Ft long
+.Fn fpathconf "int fd" "int name"
+.Sh DESCRIPTION
+The
+.Fn pathconf ,
+.Fn lpathconf
+and
+.Fn fpathconf
+system calls provide a method for applications to determine the current
+value of a configurable system limit or option variable associated
+with a pathname or file descriptor.
+.Pp
+For
+.Fn pathconf
+and
+.Fn lpathconf ,
+the
+.Fa path
+argument is the name of a file or directory.
+For
+.Fn fpathconf ,
+the
+.Fa fd
+argument is an open file descriptor.
+The
+.Fa name
+argument specifies the system variable to be queried.
+Symbolic constants for each name value are found in the include file
+.Li <unistd.h> .
+.Pp
+The
+.Fn lpathconf
+system call is like
+.Fn pathconf
+except in the case where the named file is a symbolic link,
+in which case
+.Fn lpathconf
+returns information about the link,
+while
+.Fn pathconf
+returns information about the file the link references.
+.Pp
+The available values are as follows:
+.Bl -tag -width 6n
+.It Li _PC_LINK_MAX
+The maximum file link count.
+.It Li _PC_MAX_CANON
+The maximum number of bytes in terminal canonical input line.
+.It Li _PC_MAX_INPUT
+The minimum maximum number of bytes for which space is available in
+a terminal input queue.
+.It Li _PC_NAME_MAX
+The maximum number of bytes in a file name.
+.It Li _PC_PATH_MAX
+The maximum number of bytes in a pathname.
+.It Li _PC_PIPE_BUF
+The maximum number of bytes which will be written atomically to a pipe.
+.It Li _PC_CHOWN_RESTRICTED
+Return 1 if appropriate privilege is required for the
+.Xr chown 2
+system call, otherwise 0.
+.St -p1003.1-2001
+requires appropriate privilege in all cases, but this behavior was optional
+in prior editions of the standard.
+.It Li _PC_NO_TRUNC
+Return greater than zero if attempts to use pathname components longer than
+.Brq Dv NAME_MAX
+will result in an
+.Bq Er ENAMETOOLONG
+error; otherwise, such components will be truncated to
+.Brq Dv NAME_MAX .
+.St -p1003.1-2001
+requires the error in all cases, but this behavior was optional in prior
+editions of the standard, and some
+.No non- Ns Tn POSIX Ns -compliant
+file systems do not support this behavior.
+.It Li _PC_VDISABLE
+Returns the terminal character disabling value.
+.It Li _PC_ASYNC_IO
+Return 1 if asynchronous I/O is supported, otherwise 0.
+.It Li _PC_PRIO_IO
+Returns 1 if prioritised I/O is supported for this file,
+otherwise 0.
+.It Li _PC_SYNC_IO
+Returns 1 if synchronised I/O is supported for this file, otherwise 0.
+.It Li _PC_ALLOC_SIZE_MIN
+Minimum number of bytes of storage allocated for any portion of a file.
+.It Li _PC_FILESIZEBITS
+Number of bits needed to represent the maximum file size.
+.It Li _PC_REC_INCR_XFER_SIZE
+Recommended increment for file transfer sizes between
+.Dv _PC_REC_MIN_XFER_SIZE
+and
+.Dv _PC_REC_MAX_XFER_SIZE .
+.It Li _PC_REC_MAX_XFER_SIZE
+Maximum recommended file transfer size.
+.It Li _PC_REC_MIN_XFER_SIZE
+Minimum recommended file transfer size.
+.It Li _PC_REC_XFER_ALIGN
+Recommended file transfer buffer alignment.
+.It Li _PC_SYMLINK_MAX
+Maximum number of bytes in a symbolic link.
+.It Li _PC_ACL_EXTENDED
+Returns 1 if an Access Control List (ACL) can be set on the specified
+file, otherwise 0.
+.It Li _PC_ACL_NFS4
+Returns 1 if an NFSv4 ACLs can be set on the specified
+file, otherwise 0.
+.It Li _PC_ACL_PATH_MAX
+Maximum number of ACL entries per file.
+.It Li _PC_CAP_PRESENT
+Returns 1 if a capability state can be set on the specified file,
+otherwise 0.
+.It Li _PC_INF_PRESENT
+Returns 1 if an information label can be set on the specified file,
+otherwise 0.
+.It Li _PC_MAC_PRESENT
+Returns 1 if a Mandatory Access Control (MAC) label can be set on the
+specified file, otherwise 0.
+.It Li _PC_MIN_HOLE_SIZE
+If a file system supports the reporting of holes (see
+.Xr lseek 2 ) ,
+.Fn pathconf
+and
+.Fn fpathconf
+return a positive number that represents the minimum hole size returned in
+bytes.
+The offsets of holes returned will be aligned to this same value.
+A special value of 1 is returned if the file system does not specify the minimum
+hole size but still reports holes.
+.It Li _PC_DEALLOC_PRESENT
+Return 1 if a file system supports hole-punching (see
+.Xr fspacectl 2 ) ,
+otherwise 0.
+.It Li _PC_NAMEDATTR_ENABLED
+Return 1 if named attributes are enabled for the file system, otherwise 0.
+.It Li _PC_HAS_NAMEDATTR
+Return 1 if one or more named attributes exist for the file, otherwise 0.
+.It Li _PC_HAS_HIDDENSYSTEM
+Return 1 if both
+.Dv UF_HIDDEN
+and
+.Dv UF_SYSTEM
+flags can be set by
+.Xr chflags 2 ,
+otherwise 0.
+.El
+.Sh RETURN VALUES
+If the call to
+.Fn pathconf
+or
+.Fn fpathconf
+is not successful, \-1 is returned and
+.Va errno
+is set appropriately.
+Otherwise, if the variable is associated with functionality that does
+not have a limit in the system, \-1 is returned and
+.Va errno
+is not modified.
+Otherwise, the current variable value is returned.
+.Sh ERRORS
+If any of the following conditions occur, the
+.Fn pathconf
+and
+.Fn fpathconf
+system calls shall return -1 and set
+.Va errno
+to the corresponding value.
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The value of the
+.Fa name
+argument is invalid.
+.It Bq Er EINVAL
+The implementation does not support an association of the variable
+name with the associated file.
+.El
+.Pp
+The
+.Fn pathconf
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded
+.Brq Dv NAME_MAX
+characters (but see
+.Dv _PC_NO_TRUNC
+above),
+or an entire path name exceeded
+.Brq Dv PATH_MAX
+characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+The
+.Fn fpathconf
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid open file descriptor.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr lseek 2 ,
+.Xr sysctl 3
+.Sh HISTORY
+The
+.Fn pathconf
+and
+.Fn fpathconf
+system calls first appeared in
+.Bx 4.4 .
+The
+.Fn lpathconf
+system call first appeared in
+.Fx 8.0 .
diff --git a/lib/libc/sys/pdfork.2 b/lib/libsys/pdfork.2
index c5319177f90f..c5319177f90f 100644
--- a/lib/libc/sys/pdfork.2
+++ b/lib/libsys/pdfork.2
diff --git a/lib/libsys/pipe.2 b/lib/libsys/pipe.2
new file mode 100644
index 000000000000..37d6eba420de
--- /dev/null
+++ b/lib/libsys/pipe.2
@@ -0,0 +1,182 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd May 17, 2025
+.Dt PIPE 2
+.Os
+.Sh NAME
+.Nm pipe ,
+.Nm pipe2
+.Nd create descriptor pair for interprocess communication
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn pipe "int fildes[2]"
+.Ft int
+.Fn pipe2 "int fildes[2]" "int flags"
+.Sh DESCRIPTION
+The
+.Fn pipe
+function
+creates a
+.Em pipe ,
+which is an object allowing
+bidirectional data flow,
+and allocates a pair of file descriptors.
+.Pp
+The
+.Fn pipe2
+system call allows control over the attributes of the file descriptors
+via the
+.Fa flags
+argument.
+Values for
+.Fa flags
+are constructed by a bitwise-inclusive OR of flags from the following
+list, defined in
+.In fcntl.h :
+.Bl -tag -width ".Dv O_NONBLOCK"
+.It Dv O_CLOEXEC
+Set the close-on-exec flag for the new file descriptors.
+.It Dv O_CLOFORK
+Set the close-on-fork flag for the new file descriptors.
+.It Dv O_NONBLOCK
+Set the non-blocking flag for the ends of the pipe.
+.El
+.Pp
+If the
+.Fa flags
+argument is 0, the behavior is identical to a call to
+.Fn pipe .
+.Pp
+By convention, the first descriptor is normally used as the
+.Em read end
+of the pipe,
+and the second is normally the
+.Em write end ,
+so that data written to
+.Fa fildes[1]
+appears on (i.e., can be read from)
+.Fa fildes[0] .
+This allows the output of one program to be
+sent
+to another program:
+the source's standard output is set up to be
+the write end of the pipe,
+and the sink's standard input is set up to be
+the read end of the pipe.
+The pipe itself persists until all its associated descriptors are
+closed.
+.Pp
+A pipe that has had an end closed is considered
+.Em widowed .
+Writing on such a pipe causes the writing process to receive
+a
+.Dv SIGPIPE
+signal.
+Widowing a pipe is the only way to deliver end-of-file to a reader:
+after the reader consumes any buffered data, reading a widowed pipe
+returns a zero count.
+.Pp
+The bidirectional nature of this implementation of pipes is not
+portable to older systems, so it is recommended to use the convention
+for using the endpoints in the traditional manner when using a
+pipe in one direction.
+.Sh IMPLEMENTATION NOTES
+The
+.Fn pipe
+function calls the
+.Fn pipe2
+system call.
+As a result, system call traces such as those captured by
+.Xr dtrace 1
+or
+.Xr ktrace 1
+will show calls to
+.Fn pipe2 .
+.Sh RETURN VALUES
+.Rv -std pipe
+.Sh ERRORS
+The
+.Fn pipe
+and
+.Fn pipe2
+system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+.Ar fildes
+argument points to an invalid memory location.
+.It Bq Er EMFILE
+Too many descriptors are active.
+.It Bq Er ENFILE
+The system file table is full.
+.It Bq Er ENOMEM
+Not enough kernel memory to establish a pipe.
+.El
+.Pp
+The
+.Fn pipe2
+system call will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa flags
+argument is invalid.
+.El
+.Sh SEE ALSO
+.Xr sh 1 ,
+.Xr fork 2 ,
+.Xr read 2 ,
+.Xr socketpair 2 ,
+.Xr write 2
+.Sh HISTORY
+The
+.Fn pipe
+function appeared in
+.At v3 .
+.Pp
+Bidirectional pipes were first used on
+.At V.4 .
+.Pp
+The
+.Fn pipe2
+function appeared in
+.Fx 10.0 .
+.Pp
+The
+.Fn pipe
+function became a wrapper around
+.Fn pipe2
+in
+.Fx 11.0 .
+.Pp
+The
+.Dv O_CLOFORK
+flag appeared in
+.Fx 15.0 .
diff --git a/lib/libsys/poll.2 b/lib/libsys/poll.2
new file mode 100644
index 000000000000..6e6ed33f7a6b
--- /dev/null
+++ b/lib/libsys/poll.2
@@ -0,0 +1,294 @@
+.\" $NetBSD: poll.2,v 1.3 1996/09/07 21:53:08 mycroft Exp $
+.\"
+.\" Copyright (c) 1996 Charles M. Hannum. 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. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Charles M. Hannum.
+.\" 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.
+.\"
+.Dd December 11, 2024
+.Dt POLL 2
+.Os
+.Sh NAME
+.Nm poll
+.Nd synchronous I/O multiplexing
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In poll.h
+.Ft int
+.Fn poll "struct pollfd fds[]" "nfds_t nfds" "int timeout"
+.Ft int
+.Fo ppoll
+.Fa "struct pollfd fds[]"
+.Fa "nfds_t nfds"
+.Fa "const struct timespec * restrict timeout"
+.Fa "const sigset_t * restrict newsigmask"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn poll
+system call
+examines a set of file descriptors to see if some of them are ready for
+I/O.
+The
+.Fa fds
+argument is a pointer to an array of pollfd structures as defined in
+.In poll.h
+(shown below).
+The
+.Fa nfds
+argument determines the size of the
+.Fa fds
+array.
+.Bd -literal
+struct pollfd {
+ int fd; /* file descriptor */
+ short events; /* events to look for */
+ short revents; /* events returned */
+};
+.Ed
+.Pp
+The fields of
+.Fa struct pollfd
+are as follows:
+.Bl -tag -width XXXrevents
+.It fd
+File descriptor to poll.
+If fd is equal to -1 then
+.Fa revents
+is cleared (set to zero), and that pollfd is not checked.
+.It events
+Events to poll for.
+(See below.)
+.It revents
+Events which may occur.
+(See below.)
+.El
+.Pp
+The event bitmasks in
+.Fa events
+and
+.Fa revents
+have the following bits:
+.Bl -tag -width XXXPOLLWRNORM
+.It POLLIN
+Data other than high priority data may be read without blocking.
+.It POLLRDNORM
+Normal data may be read without blocking.
+.It POLLRDBAND
+Data with a non-zero priority may be read without blocking.
+.It POLLPRI
+High priority data may be read without blocking.
+.It POLLOUT
+.It POLLWRNORM
+Normal data may be written without blocking.
+.It POLLWRBAND
+Data with a non-zero priority may be written without blocking.
+.It POLLERR
+An exceptional condition has occurred on the device or socket.
+This
+flag is always checked, even if not present in the
+.Fa events
+bitmask.
+.It POLLHUP
+The device or socket has been disconnected.
+This flag is always
+checked, even if not present in the
+.Fa events
+bitmask.
+Note that
+POLLHUP
+and
+POLLOUT
+should never be present in the
+.Fa revents
+bitmask at the same time.
+.It POLLRDHUP
+Remote peer closed connection, or shut down writing.
+Unlike
+POLLHUP,
+POLLRDHUP
+must be present in the
+.Fa events
+bitmask to be reported.
+Applies only to stream sockets.
+.It POLLNVAL
+The file descriptor is not open,
+or in capability mode the file descriptor has insufficient rights.
+This flag is always checked, even
+if not present in the
+.Fa events
+bitmask.
+.El
+.Pp
+If
+.Fa timeout
+is neither zero nor INFTIM (-1), it specifies a maximum interval to
+wait for any file descriptor to become ready, in milliseconds.
+If
+.Fa timeout
+is INFTIM (-1), the poll blocks indefinitely.
+If
+.Fa timeout
+is zero, then
+.Fn poll
+will return without blocking.
+.Pp
+The
+.Fn ppoll
+system call, unlike
+.Fn poll ,
+is used to safely wait until either a set of file descriptors becomes
+ready or until a signal is caught.
+The
+.Fa fds
+and
+.Fa nfds
+arguments are identical to the analogous arguments of
+.Fn poll .
+The
+.Fa timeout
+argument in
+.Fn ppoll
+points to a
+.Vt "const struct timespec"
+which is defined in
+.In sys/timespec.h
+(shown below) rather than the
+.Vt "int timeout"
+used by
+.Fn poll .
+A null pointer may be passed to indicate that
+.Fn ppoll
+should wait indefinitely.
+Finally,
+.Fa newsigmask
+specifies a signal mask which is set while waiting for input.
+When
+.Fn ppoll
+returns, the original signal mask is restored.
+.Bd -literal
+struct timespec {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* and nanoseconds */
+};
+.Ed
+.Sh RETURN VALUES
+The
+.Fn poll
+system call
+returns the number of descriptors that are ready for I/O, or -1 if an
+error occurred.
+If the time limit expires,
+.Fn poll
+returns 0.
+If
+.Fn poll
+returns with an error,
+including one due to an interrupted system call,
+the
+.Fa fds
+array will be unmodified.
+.Sh COMPATIBILITY
+This implementation differs from the historical one in that a given
+file descriptor may not cause
+.Fn poll
+to return with an error.
+In cases where this would have happened in
+the historical implementation (e.g.\& trying to poll a
+.Xr revoke 2 Ns ed
+descriptor), this implementation instead copies the
+.Fa events
+bitmask to the
+.Fa revents
+bitmask.
+Attempting to perform I/O on this descriptor will then
+return an error.
+This behaviour is believed to be more useful.
+.Sh ERRORS
+An error return from
+.Fn poll
+indicates:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa fds
+argument
+points outside the process's allocated address space.
+.It Bq Er EINTR
+A signal was delivered before the time limit expired and
+before any of the selected events occurred.
+.It Bq Er EINVAL
+The specified time limit is invalid.
+One of its components is negative or too large.
+.It Bq Er EINVAL
+The number of pollfd structures specified by
+.Fa nfds
+exceeds the system tunable
+.Va kern.maxfilesperproc
+and
+.Dv FD_SETSIZE .
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr connect 2 ,
+.Xr kqueue 2 ,
+.Xr pselect 2 ,
+.Xr read 2 ,
+.Xr recv 2 ,
+.Xr select 2 ,
+.Xr send 2 ,
+.Xr write 2
+.Sh STANDARDS
+The
+.Fn poll
+function conforms to
+.St -p1003.1-2001 .
+The
+.Fn ppoll
+function conforms to
+.St -p1003.1-2024 .
+The
+POLLRDHUP
+flag is not specified by POSIX, but is compatible with Linux and illumos.
+.Sh HISTORY
+The
+.Fn poll
+function appeared in
+.At V .
+This manual page and the core of the implementation was taken from
+.Nx .
+The
+.Fn ppoll
+function first appeared in
+.Fx 10.2
+.Sh BUGS
+The distinction between some of the fields in the
+.Fa events
+and
+.Fa revents
+bitmasks is really not useful without STREAMS.
+The fields are
+defined for compatibility with existing software.
diff --git a/lib/libsys/posix_fadvise.2 b/lib/libsys/posix_fadvise.2
new file mode 100644
index 000000000000..24cc3601e268
--- /dev/null
+++ b/lib/libsys/posix_fadvise.2
@@ -0,0 +1,140 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt POSIX_FADVISE 2
+.Os
+.Sh NAME
+.Nm posix_fadvise
+.Nd give advice about use of file data
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.Ft int
+.Fn posix_fadvise "int fd" "off_t offset" "off_t len" "int advice"
+.Sh DESCRIPTION
+The
+.Fn posix_fadvise
+system call
+allows a process to describe to the system its data access behavior for an
+open file descriptor
+.Fa fd .
+The advice covers the data starting at offset
+.Fa offset
+and continuing for
+.Fa len
+bytes.
+If
+.Fa len
+is zero,
+all data from
+.Fa offset
+to the end of the file is covered.
+.Pp
+The behavior is specified by the
+.Fa advice
+parameter and may be one of:
+.Bl -tag -width POSIX_FADV_SEQUENTIAL
+.It Dv POSIX_FADV_NORMAL
+Tells the system to revert to the default data access behavior.
+.It Dv POSIX_FADV_RANDOM
+Is a hint that file data will be accessed randomly,
+and prefetching is likely not advantageous.
+.It Dv POSIX_FADV_SEQUENTIAL
+Tells the system that file data will be accessed sequentially.
+This currently does nothing as the default behavior uses heuristics to
+detect sequential behavior.
+.It Dv POSIX_FADV_WILLNEED
+Tells the system that the specified data will be accessed in the near future.
+The system may initiate an asynchronous read of the data if it is not already
+present in memory.
+.It Dv POSIX_FADV_DONTNEED
+Tells the system that the specified data will not be accessed in the near
+future.
+The system may decrease the in-memory priority of clean data within the
+specified range and future access to this data may require a read operation.
+.It Dv POSIX_FADV_NOREUSE
+Tells the system that the specified data will only be accessed once and
+then not reused.
+The system may decrease the in-memory priority of data once it has been
+read or written.
+Future access to this data may require a read operation.
+.El
+.Sh RETURN VALUES
+If successful,
+.Fn posix_fadvise
+returns zero.
+It returns an error on failure, without setting
+.Va errno .
+.Sh ERRORS
+Possible failure conditions:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument is not a valid file descriptor.
+.It Bq Er EINVAL
+The
+.Fa advice
+argument is not valid.
+.It Bq Er EINVAL
+The
+.Fa offset
+or
+.Fa len
+arguments are negative,
+or
+.Fa offset
++
+.Fa len
+is greater than the maximum file size.
+.It Bq Er ENODEV
+The
+.Fa fd
+argument does not refer to a regular file.
+.It Bq Er ESPIPE
+The
+.Fa fd
+argument is associated with a pipe or FIFO.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to a file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Sh SEE ALSO
+.Xr madvise 2
+.Sh STANDARDS
+The
+.Fn posix_fadvise
+interface conforms to
+.St -p1003.1-2001 .
+.Sh HISTORY
+The
+.Fn posix_fadvise
+system call first appeared in
+.Fx 9.1 .
diff --git a/lib/libsys/posix_fallocate.2 b/lib/libsys/posix_fallocate.2
new file mode 100644
index 000000000000..8be075b41331
--- /dev/null
+++ b/lib/libsys/posix_fallocate.2
@@ -0,0 +1,149 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt POSIX_FALLOCATE 2
+.Os
+.Sh NAME
+.Nm posix_fallocate
+.Nd pre-allocate storage for a range in a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.Ft int
+.Fn posix_fallocate "int fd" "off_t offset" "off_t len"
+.Sh DESCRIPTION
+Required storage for the range
+.Fa offset
+to
+.Fa offset +
+.Fa len
+in the file referenced by
+.Fa fd
+is guaranteed to be allocated upon successful return.
+That is, if
+.Fn posix_fallocate
+returns successfully, subsequent writes to the specified file data
+will not fail due to lack of free space on the file system storage
+media.
+Any existing file data in the specified range is unmodified.
+If
+.Fa offset +
+.Fa len
+is beyond the current file size, then
+.Fn posix_fallocate
+will adjust the file size to
+.Fa offset +
+.Fa len .
+Otherwise, the file size will not be changed.
+.Pp
+Space allocated by
+.Fn posix_fallocate
+will be freed by a successful call to
+.Xr creat 2
+or
+.Xr open 2
+that truncates the size of the file.
+Space allocated via
+.Fn posix_fallocate
+may be freed by a successful call to
+.Xr ftruncate 2
+that reduces the file size to a size smaller than
+.Fa offset +
+.Fa len .
+.Sh RETURN VALUES
+If successful,
+.Fn posix_fallocate
+returns zero.
+It returns an error on failure, without setting
+.Va errno .
+.Sh ERRORS
+Possible failure conditions:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument is not a valid file descriptor.
+.It Bq Er EBADF
+The
+.Fa fd
+argument references a file that was opened without write permission.
+.It Bq Er EFBIG
+The value of
+.Fa offset +
+.Fa len
+is greater than the maximum file size.
+.It Bq Er EINTR
+A signal was caught during execution.
+.It Bq Er EINVAL
+The
+.Fa len
+argument was less than or equal to zero, the
+.Fa offset
+argument was less than zero,
+or the operation is not supported by the file system.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to a file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ENODEV
+The
+.Fa fd
+argument does not refer to a file that supports
+.Nm .
+.It Bq Er ENOSPC
+There is insufficient free space remaining on the file system storage
+media.
+.It Bq Er ENOTCAPABLE
+The file descriptor
+.Fa fd
+has insufficient rights.
+.It Bq Er ESPIPE
+The
+.Fa fd
+argument is associated with a pipe or FIFO.
+.El
+.Sh SEE ALSO
+.Xr creat 2 ,
+.Xr ftruncate 2 ,
+.Xr open 2 ,
+.Xr unlink 2
+.Sh STANDARDS
+The
+.Fn posix_fallocate
+system call conforms to
+.St -p1003.1-2004 .
+.Sh HISTORY
+The
+.Fn posix_fallocate
+function appeared in
+.Fx 9.0 .
+.Sh AUTHORS
+.Fn posix_fallocate
+and this manual page were initially written by
+.An Matthew Fleming Aq Mt mdf@FreeBSD.org .
diff --git a/lib/libc/sys/posix_openpt.2 b/lib/libsys/posix_openpt.2
index 667dcbeba33d..667dcbeba33d 100644
--- a/lib/libc/sys/posix_openpt.2
+++ b/lib/libsys/posix_openpt.2
diff --git a/lib/libsys/powerpc/Makefile.sys b/lib/libsys/powerpc/Makefile.sys
new file mode 100644
index 000000000000..9979d5179f51
--- /dev/null
+++ b/lib/libsys/powerpc/Makefile.sys
@@ -0,0 +1,4 @@
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
+MDASM+= cerror.S
diff --git a/lib/libsys/powerpc/Makefile.thr b/lib/libsys/powerpc/Makefile.thr
new file mode 100644
index 000000000000..52e861709faf
--- /dev/null
+++ b/lib/libsys/powerpc/Makefile.thr
@@ -0,0 +1 @@
+SRCS+= _umtx_op_err.S
diff --git a/lib/libsys/powerpc/SYS.h b/lib/libsys/powerpc/SYS.h
new file mode 100644
index 000000000000..04672ed51528
--- /dev/null
+++ b/lib/libsys/powerpc/SYS.h
@@ -0,0 +1,65 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2002 Benno Rice. All rights reserved.
+ * Copyright (c) 2002 David E. O'Brien. 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 author nor the names of any contributors
+ * may 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 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.
+ *
+ * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ .text; \
+ .align 2; \
+ li 0,(SYS_##name); \
+ sc
+
+#ifndef _SYSCALL_BODY
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ bnslr; \
+ b CNAME(HIDENAME(cerror))
+#endif
+
+#define PSEUDO(name) \
+ .text; \
+ .align 2; \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
+
+#define RSYSCALL(name) \
+ .text; \
+ .align 2; \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
diff --git a/lib/libsys/powerpc/__vdso_gettc.c b/lib/libsys/powerpc/__vdso_gettc.c
new file mode 100644
index 000000000000..82b8e2f27384
--- /dev/null
+++ b/lib/libsys/powerpc/__vdso_gettc.c
@@ -0,0 +1,65 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Brandon Bergren <bdragon@FreeBSD.org>
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+
+#include <machine/cpufunc.h>
+#include <machine/spr.h>
+
+#include <errno.h>
+
+#include "libc_private.h"
+
+#pragma weak __vdso_gettc
+int
+__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+
+ if (__predict_false(th->th_algo != VDSO_TH_ALGO_PPC_TB))
+ return (ENOSYS);
+ /*
+ * While the timebase is a 64 bit quantity, we are only interested
+ * in the lower 32 bits of it.
+ */
+ *tc = mfspr(TBR_TBL);
+
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libthr/arch/powerpc/powerpc/_umtx_op_err.S b/lib/libsys/powerpc/_umtx_op_err.S
index a954962515f6..a954962515f6 100644
--- a/lib/libthr/arch/powerpc/powerpc/_umtx_op_err.S
+++ b/lib/libsys/powerpc/_umtx_op_err.S
diff --git a/lib/libc/powerpc/sys/cerror.S b/lib/libsys/powerpc/cerror.S
index 64204c5a1ddf..64204c5a1ddf 100644
--- a/lib/libc/powerpc/sys/cerror.S
+++ b/lib/libsys/powerpc/cerror.S
diff --git a/lib/libsys/powerpc64/Makefile.sys b/lib/libsys/powerpc64/Makefile.sys
new file mode 100644
index 000000000000..9979d5179f51
--- /dev/null
+++ b/lib/libsys/powerpc64/Makefile.sys
@@ -0,0 +1,4 @@
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
+MDASM+= cerror.S
diff --git a/lib/libsys/powerpc64/SYS.h b/lib/libsys/powerpc64/SYS.h
new file mode 100644
index 000000000000..ceb85bb4e361
--- /dev/null
+++ b/lib/libsys/powerpc64/SYS.h
@@ -0,0 +1,73 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2002 Benno Rice. All rights reserved.
+ * Copyright (c) 2002 David E. O'Brien. 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 author nor the names of any contributors
+ * may 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 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.
+ *
+ * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ .text; \
+ .align 2; \
+ li 0,(SYS_##name); \
+ sc
+
+#ifndef _SYSCALL_BODY
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ bnslr; \
+ mflr %r0; \
+ std %r0,16(%r1); \
+ stdu %r1,-48(%r1); \
+ bl CNAME(HIDENAME(cerror)); \
+ nop; \
+ addi %r1,%r1,48; \
+ ld %r0,16(%r1); \
+ mtlr %r0; \
+ blr
+#endif
+
+#define PSEUDO(name) \
+ .text; \
+ .align 2; \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
+
+#define RSYSCALL(name) \
+ .text; \
+ .align 2; \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
diff --git a/lib/libsys/powerpc64/__vdso_gettc.c b/lib/libsys/powerpc64/__vdso_gettc.c
new file mode 100644
index 000000000000..c1de60a5b956
--- /dev/null
+++ b/lib/libsys/powerpc64/__vdso_gettc.c
@@ -0,0 +1,62 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2020 Brandon Bergren <bdragon@FreeBSD.org>
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+
+#include <machine/cpufunc.h>
+
+#include <errno.h>
+
+#include "libc_private.h"
+
+#pragma weak __vdso_gettc
+int
+__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+ u_quad_t tb;
+
+ if (__predict_false(th->th_algo != VDSO_TH_ALGO_PPC_TB))
+ return (ENOSYS);
+
+ __asm __volatile ("mftb %0" : "=r"(tb));
+ *tc = tb;
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libc/powerpc64/sys/cerror.S b/lib/libsys/powerpc64/cerror.S
index 2be58cf8a84b..2be58cf8a84b 100644
--- a/lib/libc/powerpc64/sys/cerror.S
+++ b/lib/libsys/powerpc64/cerror.S
diff --git a/lib/libsys/powerpcspe/Makefile.sys b/lib/libsys/powerpcspe/Makefile.sys
new file mode 100644
index 000000000000..35909d68cd5e
--- /dev/null
+++ b/lib/libsys/powerpcspe/Makefile.sys
@@ -0,0 +1,5 @@
+CFLAGS+= -I${LIBC_SRCTOP}/powerpc
+CFLAGS+= -I${LIBSYS_SRCTOP}/powerpc
+
+.PATH: ${LIBSYS_SRCTOP}/powerpc
+.include "${LIBSYS_SRCTOP}/powerpc/Makefile.sys"
diff --git a/lib/libsys/procctl.2 b/lib/libsys/procctl.2
new file mode 100644
index 000000000000..dfb7931de265
--- /dev/null
+++ b/lib/libsys/procctl.2
@@ -0,0 +1,971 @@
+.\" Copyright (c) 2013 Hudson River Trading LLC
+.\" Written by: John H. Baldwin <jhb@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" Copyright (c) 2014 The FreeBSD Foundation
+.\" Portions of this documentation were written by Konstantin Belousov
+.\" under sponsorship from the FreeBSD Foundation.
+.\"
+.\" 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.
+.\"
+.Dd April 21, 2025
+.Dt PROCCTL 2
+.Os
+.Sh NAME
+.Nm procctl
+.Nd control processes
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/procctl.h
+.Ft int
+.Fn procctl "idtype_t idtype" "id_t id" "int cmd" "void *data"
+.Sh DESCRIPTION
+The
+.Fn procctl
+system call provides for control over processes.
+The
+.Fa idtype
+and
+.Fa id
+arguments specify the set of processes to control.
+If multiple processes match the identifier,
+.Nm
+will make a
+.Dq best effort
+to control as many of the selected processes as possible.
+An error is only returned if no selected processes successfully complete
+the request.
+The following identifier types are supported:
+.Bl -tag -width P_PGID
+.It Dv P_PID
+Control the process with the process ID
+.Fa id .
+.Fa id
+zero is a shortcut for the calling process ID.
+.It Dv P_PGID
+Control processes belonging to the process group with the ID
+.Fa id .
+.El
+.Pp
+The control request to perform is specified by the
+.Fa cmd
+argument.
+.Pp
+All status changing requests
+.Pq Dv *_CTL
+require the caller to have the right to debug the target.
+All status query requests
+.Pq Dv *_STATUS
+require the caller to have the right to observe the target.
+.Pp
+The following commands are supported:
+.Bl -tag -width PROC_LOGSIGEXIT_STATUS
+.It Dv PROC_ASLR_CTL
+Controls Address Space Layout Randomization (ASLR) in program
+images created
+by
+.Xr execve 2
+in the specified process or its descendants that do not either change
+the control or modify it by other means.
+The
+.Fa data
+parameter must point to an integer variable holding one of the following
+values:
+.Bl -tag -width Ds
+.It Dv PROC_ASLR_FORCE_ENABLE
+Request that ASLR is enabled after execution, even if it is disabled
+system-wide.
+.It Dv PROC_ASLR_FORCE_DISABLE
+Request that ASLR is disabled after execution, even if it is enabled
+system-wide.
+.It Dv PROC_ASLR_NOFORCE
+Use the system-wide configured policy for ASLR.
+.El
+.Pp
+Note that the
+.Xr elfctl 1
+.Dq noaslr
+flag takes precedence over this control.
+Executing a binary with this flag set will never use ASLR.
+Similarly, executing a set-user-ID or set-group-ID binary ignores this
+control and only honors the
+.Xr elfctl 1
+flag and system-wide policy.
+.It Dv PROC_ASLR_STATUS
+Returns the current status of ASLR enablement for the target process.
+The
+.Fa data
+parameter must point to an integer variable, where one of the
+following values is written:
+.Bl -tag -width Ds
+.It Dv PROC_ASLR_FORCE_ENABLE
+.It Dv PROC_ASLR_FORCE_DISABLE
+.It Dv PROC_ASLR_NOFORCE
+.El
+.Pp
+If the currently executed image in the process itself has ASLR enabled,
+the
+.Dv PROC_ASLR_ACTIVE
+flag is or-ed with the value listed above.
+.It Dv PROC_LOGSIGEXIT_CTL
+Controls the logging of exits due to signals that would normally cause a core
+dump.
+The
+.Va arg
+parameter must point to an integer variable holding one of the following values:
+.Bl -tag -width PROC_LOGSIGEXIT_CTL_FORCE_DISABLE
+.It Dv PROC_LOGSIGEXIT_CTL_FORCE_ENABLE
+Enables logging of exits due to signals that would normally cause a core dump.
+Logging is done via
+.Xr log 9
+with a log level of
+.Dv LOG_INFO .
+.It Dv PROC_LOGSIGEXIT_CTL_FORCE_DISABLE
+Disables the logging of exits due to signals that would normally cause a core
+dump.
+.It Dv PROC_LOGSIGEXIT_CTL_NOFORCE
+The logging behavior is delegated to the
+.Xr sysctl 3
+MIB variable
+.Va kern.logsigexit .
+.El
+.It Dv PROC_LOGSIGEXIT_STATUS
+Returns the current status of logging for the target process.
+The
+.Va arg
+parameter must point to an integer variable, where one of the following values
+is written:
+.Bl -tag -width PROC_LOGSIGEXIT_CTL_FORCE_DISABLE
+.It Dv PROC_LOGSIGEXIT_CTL_FORCE_ENABLE
+.It Dv PROC_LOGSIGEXIT_CTL_FORCE_DISABLE
+.It Dv PROC_LOGSIGEXIT_CTL_NOFORCE
+.El
+.It Dv PROC_PROTMAX_CTL
+Controls the maximum protection used for
+.Xr mmap 2
+requests in the target process that do not specify
+an explicit maximum protection in the
+.Fa prot
+argument via
+.Dv PROT_MAX .
+The maximum protection limits the permissions a mapping can be assigned by
+.Xr mprotect 2 .
+If an explicit maximum protection is not provided,
+the maximum protection for a new mapping is set to either
+.Dv PROT_READ | PROT_WRITE | PROT_EXEC
+.Pq RWX
+or the protection specified in
+.Fa prot .
+Mappings created with
+.Fa prot
+set to
+.Dv PROT_NONE
+always use RWX maximum protection.
+.Pp
+The
+.Fa data
+parameter must point to an integer variable holding one of the following
+values:
+.Bl -tag -width Ds
+.It Dv PROC_PROTMAX_FORCE_ENABLE
+Use the permissions in
+.Fa prot
+as the implicit maximum protection,
+even if RWX permissions are requested by the sysctl
+.Va vm.imply_prot_max .
+.It Dv PROC_PROTMAX_FORCE_DISABLE
+Use RWX as the implicit maximum protection,
+even if constrained permissions are requested by the sysctl
+.Va vm.imply_prot_max .
+.It Dv PROC_PROTMAX_NOFORCE
+Use the system-wide configured policy for the implicit PROT_MAX control.
+.El
+.Pp
+Note that the
+.Xr elfctl 1
+.Dq noprotmax
+flag takes precedence over this control.
+Executing a binary with this flag set will always use RWX as the implicit
+maximum protection.
+.It Dv PROC_PROTMAX_STATUS
+Returns the current status of the implicit PROT_MAX control for the
+target process.
+The
+.Fa data
+parameter must point to an integer variable, where one of the
+following values is written:
+.Bl -tag -width Ds
+.It Dv PROC_PROTMAX_FORCE_ENABLE
+.It Dv PROC_PROTMAX_FORCE_DISABLE
+.It Dv PROC_PROTMAX_NOFORCE
+.El
+.Pp
+If the currently executed image in the process itself has the implicit PROT_MAX
+control enabled, the
+.Dv PROC_PROTMAX_ACTIVE
+flag is or-ed with the value listed above.
+.It Dv PROC_SPROTECT
+Set process protection state.
+This is used to mark a process as protected from being killed if the system
+exhausts available memory and swap.
+The
+.Fa data
+parameter must point to an integer containing an operation and zero or more
+optional flags.
+The following operations are supported:
+.Bl -tag -width Ds
+.It Dv PPROT_SET
+Mark the selected processes as protected.
+.It Dv PPROT_CLEAR
+Clear the protected state of selected processes.
+.El
+.Pp
+The following optional flags are supported:
+.Bl -tag -width Ds
+.It Dv PPROT_DESCEND
+Apply the requested operation to all child processes of each selected process
+in addition to each selected process.
+.It Dv PPROT_INHERIT
+When used with
+.Dv PPROT_SET ,
+mark all future child processes of each selected process as protected.
+Future child processes will also mark all of their future child processes.
+.El
+.It Dv PROC_REAP_ACQUIRE
+Enable orphaned process reaping for future children of the current process.
+.Pp
+If a parent process exits before one or more of its children processes,
+the remaining children processes are orphaned.
+When an orphaned process exits,
+it is reparented to a reaper process that is responsible for harvesting
+the terminated process via
+.Xr wait 2 .
+When this control is enabled,
+the current process becomes the reaper process for future children and their
+descendants.
+Existing child processes continue to use the reaper assigned when the child
+was created via
+.Xr fork 2 .
+If a reaper process exits,
+all of the processes for whom it was the reaper are reassigned to the reaper
+process's reaper.
+.Pp
+After system initialization,
+.Xr init 8
+is the default reaper.
+.It Dv PROC_REAP_RELEASE
+Disable orphaned process reaping for the current process.
+.Pp
+Any processes for whom the current process was the reaper are reassigned to
+the current process's reaper.
+.It Dv PROC_REAP_STATUS
+Provides a consistent snapshot of information about the reaper
+of the specified process,
+or the process itself if it is a reaper.
+The
+.Fa data
+argument must point to a
+.Vt procctl_reaper_status
+structure which is filled in by the system call on successful return.
+.Bd -literal
+struct procctl_reaper_status {
+ u_int rs_flags;
+ u_int rs_children;
+ u_int rs_descendants;
+ pid_t rs_reaper;
+ pid_t rs_pid;
+};
+.Ed
+.Pp
+The
+.Fa rs_flags
+may have the following flags returned:
+.Bl -tag -width Ds
+.It Dv REAPER_STATUS_OWNED
+The specified process is a reaper.
+When this flag is returned, the specified process
+.Fa id ,
+pid, identifies a reaper, otherwise the
+.Fa rs_reaper
+field of the structure is set to the pid of the reaper
+for the specified process id.
+.It Dv REAPER_STATUS_REALINIT
+The specified process is the root of the reaper tree, i.e.,
+.Xr init 8 .
+.El
+.Pp
+The
+.Fa rs_children
+field returns the number of processes that can be reaped by the reaper that
+are also children of the reaper.
+It is possible to have a child whose reaper is not the specified process,
+since the reaper for existing children is not changed by
+.Dv PROC_REAP_ACQUIRE .
+The
+.Fa rs_descendants
+field returns the total number of processes that can be reaped by the reaper.
+The
+.Fa rs_reaper
+field returns the reaper's pid.
+The
+.Fa rs_pid
+returns the pid of one reaper child if there are any processes that can be
+reapead;
+otherwise, it is set to \-1.
+.It Dv PROC_REAP_GETPIDS
+Queries the list of processes that can be reaped
+by the reaper of the specified process.
+The request takes a pointer to a
+.Vt procctl_reaper_pids
+structure in the
+.Fa data
+parameter.
+.Bd -literal
+struct procctl_reaper_pids {
+ u_int rp_count;
+ struct procctl_reaper_pidinfo *rp_pids;
+};
+.Ed
+.Pp
+When called, the
+.Fa rp_pids
+field must point to an array of
+.Fa rp_count
+.Vt procctl_reaper_pidinfo
+structures.
+The kernel will populate these structures with information about the
+reaper's descendants.
+.Pp
+The
+.Vt "struct procctl_reaper_pidinfo"
+structure provides some information about one of the reaper's descendants.
+Note that for a descendant that is not a child, it may be incorrectly
+identified because of a race in which the original child process exited
+and the exited process's pid was reused for an unrelated process.
+.Bd -literal
+struct procctl_reaper_pidinfo {
+ pid_t pi_pid;
+ pid_t pi_subtree;
+ u_int pi_flags;
+};
+.Ed
+.Pp
+The
+.Fa pi_pid
+field is the process id of the descendant.
+The
+.Fa pi_subtree
+field provides the pid of the direct child of the reaper which is
+the (grand-)parent of the descendant process.
+The
+.Fa pi_flags
+field returns the following flags, further describing the descendant:
+.Bl -tag -width Ds
+.It Dv REAPER_PIDINFO_VALID
+Set to indicate that the
+.Vt procctl_reaper_pidinfo
+structure was filled in by the kernel.
+Zero-filling the
+.Fa rp_pids
+array and testing the
+.Dv REAPER_PIDINFO_VALID
+flag allows the caller to detect the end
+of the returned array.
+.It Dv REAPER_PIDINFO_CHILD
+The
+.Fa pi_pid
+field identifies a direct child of the reaper.
+.It Dv REAPER_PIDINFO_REAPER
+The reported process is itself a reaper.
+The descendants of the subordinate reaper are not reported.
+.It Dv REAPER_PIDINFO_ZOMBIE
+The reported process is in the zombie state, ready to be reaped.
+.It Dv REAPER_PIDINFO_STOPPED
+The reported process is stopped by a SIGSTOP/SIGTSTP signal.
+.It Dv REAPER_PIDINFO_EXITING
+The reported process is in the process of exiting (but not yet a zombie).
+.El
+.It Dv PROC_REAP_KILL
+Request to deliver a signal to some subset of the descendants of the reaper.
+The
+.Fa data
+parameter must point to a
+.Vt procctl_reaper_kill
+structure, which is used both for parameters and status return.
+.Bd -literal
+struct procctl_reaper_kill {
+ int rk_sig;
+ u_int rk_flags;
+ pid_t rk_subtree;
+ u_int rk_killed;
+ pid_t rk_fpid;
+};
+.Ed
+.Pp
+The
+.Fa rk_sig
+field specifies the signal to be delivered.
+Zero is not a valid signal number, unlike for
+.Xr kill 2 .
+The
+.Fa rk_flags
+field further directs the operation.
+It is or-ed from the following flags:
+.Bl -tag -width Ds
+.It Dv REAPER_KILL_CHILDREN
+Deliver the specified signal only to direct children of the reaper.
+.It Dv REAPER_KILL_SUBTREE
+Deliver the specified signal only to descendants that were forked by
+the direct child with pid specified in the
+.Fa rk_subtree
+field.
+.El
+.Pp
+If neither the
+.Dv REAPER_KILL_CHILDREN
+nor the
+.Dv REAPER_KILL_SUBTREE
+flags are specified, all current descendants of the reaper are signalled.
+.Pp
+If a signal was delivered to any process, the return value from the request
+is zero.
+In this case, the
+.Fa rk_killed
+field identifies the number of processes signalled.
+The
+.Fa rk_fpid
+field is set to the pid of the first process for which signal
+delivery failed, e.g., due to permission problems.
+If no such process exists, the
+.Fa rk_fpid
+field is set to \-1.
+.It Dv PROC_TRACE_CTL
+Enable or disable tracing of the specified process(es), according to the
+value of the integer argument.
+Tracing includes inspecting the process via
+.Xr ptrace 2 ,
+.Xr ktrace 2 ,
+debugging sysctls,
+.Xr hwpmc 4 ,
+or
+.Xr dtrace 1
+as well as dumping core.
+Possible values for the
+.Fa data
+argument are:
+.Bl -tag -width Ds
+.It Dv PROC_TRACE_CTL_ENABLE
+Enable tracing, after it was disabled by
+.Dv PROC_TRACE_CTL_DISABLE .
+Only allowed for self.
+.It Dv PROC_TRACE_CTL_DISABLE
+Disable tracing for the specified process.
+Tracing is re-enabled when the process changes the executing
+program with the
+.Xr execve 2
+system call.
+A child inherits the trace settings from the parent on
+.Xr fork 2 .
+.It Dv PROC_TRACE_CTL_DISABLE_EXEC
+Same as
+.Dv PROC_TRACE_CTL_DISABLE ,
+but the setting persists for the process even after
+.Xr execve 2 .
+.El
+.It Dv PROC_TRACE_STATUS
+Returns the current tracing status for the specified process in
+the integer variable pointed to by
+.Fa data .
+If tracing is disabled,
+.Fa data
+is set to \-1.
+If tracing is enabled, but no debugger is attached by the
+.Xr ptrace 2
+system call,
+.Fa data
+is set to 0.
+If a debugger is attached,
+.Fa data
+is set to the pid of the debugger process.
+.It Dv PROC_TRAPCAP_CTL
+Controls the capability mode sandbox actions for the specified
+sandboxed processes
+on a return from any system call which fails with either an
+.Er ENOTCAPABLE
+or
+.Er ECAPMODE
+error.
+If this control is enabled and a system call fails with one of these errors,
+a synchronous
+.Dv SIGTRAP
+signal is delivered to the thread immediately before returning from the
+system call.
+.Pp
+Possible values for the
+.Fa data
+argument are:
+.Bl -tag -width Ds
+.It Dv PROC_TRAPCAP_CTL_ENABLE
+Enable
+.Dv SIGTRAP
+signal delivery on capability mode access violations.
+The enabled mode is inherited by the children of the process,
+and is kept after
+.Xr fexecve 2
+calls.
+.It Dv PROC_TRAPCAP_CTL_DISABLE
+Disable
+.Dv SIGTRAP
+signal delivery on capability mode access violations.
+Note that the global sysctl
+.Dv kern.trap_enotcap
+might still cause the signal to be delivered.
+See
+.Xr capsicum 4 .
+.El
+.Pp
+On signal delivery, the
+.Va si_errno
+member of the
+.Fa siginfo
+signal handler parameter is set to the system call error value,
+and the
+.Va si_code
+member is set to
+.Dv TRAP_CAP .
+The system call number is stored in the
+.Va si_syscall
+field of the
+.Fa siginfo
+signal handler parameter.
+The other system call parameters can be read from the
+.Fa ucontext_t
+but the system call number is typically stored in the register
+that also contains the return value and so is unavailable in the
+signal handler.
+.Pp
+See
+.Xr capsicum 4
+for more information about capability mode.
+.It Dv PROC_TRAPCAP_STATUS
+Return the current status of raising
+.Dv SIGTRAP
+for capability mode access violations by the specified process.
+The integer value pointed to by the
+.Fa data
+argument is set to the
+.Dv PROC_TRAPCAP_CTL_ENABLE
+value if
+.Dv SIGTRAP
+delivery is enabled, and to
+.Dv PROC_TRAPCAP_CTL_DISABLE
+otherwise.
+.Pp
+See the note about sysctl
+.Dv kern.trap_enotcap
+above, which gives independent global control of signal delivery.
+.It Dv PROC_PDEATHSIG_CTL
+Request the delivery of a signal when the parent of the calling
+process exits.
+.Fa idtype
+must be
+.Dv P_PID
+and
+.Fa id
+must be the either caller's pid or zero, with no difference in effect.
+The value is cleared for child processes
+and when executing set-user-ID or set-group-ID binaries.
+.Fa data
+must point to a value of type
+.Vt int
+indicating the signal
+that should be delivered to the caller.
+Use zero to cancel a previously requested signal delivery.
+.It Dv PROC_PDEATHSIG_STATUS
+Query the current signal number that will be delivered when the parent
+of the calling process exits.
+.Fa idtype
+must be
+.Dv P_PID
+and
+.Fa id
+must be the either caller's pid or zero, with no difference in effect.
+.Fa data
+must point to a memory location that can hold a value of type
+.Vt int .
+If signal delivery has not been requested, it will contain zero
+on return.
+.It Dv PROC_STACKGAP_CTL
+Controls stack gaps in the specified process.
+A stack gap is one or more virtual memory pages at the end of the
+growth area for a
+.Dv MAP_STACK
+mapping that is reserved and never backed by memory.
+Instead, the process is guaranteed to receive a synchronous
+.Dv SIGSEGV
+signal for each access to pages in the gap.
+The number of pages reserved for each stack is set by the sysctl
+.Va security.bsd.stack_guard_page .
+.Pp
+Gaps protect against stack overflows by preventing them from corrupting memory
+adjacent to the stack.
+.Pp
+The
+.Fa data
+argument must point to an integer variable containing flags.
+The following flags are allowed:
+.Bl -tag -width Ds
+.It Dv PROC_STACKGAP_ENABLE
+This flag is only accepted for consistency with
+.Dv PROC_STACKGAP_STATUS .
+If stack gaps are enabled, the flag is ignored.
+If stack gaps are disabled, the request fails with
+.Ev EINVAL .
+After gaps are disabled in a process, they can only be re-enabled when an
+.Xr execve 2
+is performed.
+.It Dv PROC_STACKGAP_DISABLE
+Disable stack gaps for the process.
+For existing stacks, the gap is no longer reserved
+and can be filled by memory on access.
+.It Dv PROC_STACKGAP_ENABLE_EXEC
+Enable stack gaps for the new address space constructed by any future
+.Xr execve 2
+in the specified process.
+.It Dv PROC_STACKGAP_DISABLE_EXEC
+Inherit disabled stack gaps state after
+.Xr execve 2 .
+In other words, if the currently executing program has stack gaps disabled,
+they are kept disabled on exec.
+If gaps were enabled, they are kept enabled after exec.
+.El
+.Pp
+The stack gap state is inherited from the parent on
+.Xr fork 2 .
+.It Dv PROC_STACKGAP_STATUS
+Returns the current stack gap state for the specified process.
+.Fa data
+must point to an integer variable, which is used to return a bitmask
+consisting of the following flags:
+.Bl -tag -width Ds
+.It Dv PROC_STACKGAP_ENABLE
+Stack gaps are enabled.
+.It Dv PROC_STACKGAP_DISABLE
+Stack gaps are disabled.
+.It Dv PROC_STACKGAP_ENABLE_EXEC
+Stack gaps are enabled in the process after
+.Xr execve 2 .
+.It Dv PROC_STACKGAP_DISABLE_EXEC
+Stack gaps are disabled in the process after
+.Xr execve 2 .
+.El
+.Pp
+Note that the
+.Xr elfctl 1
+.Dq nostackgap
+flag takes precedence over this setting for individual process address spaces.
+Executing a binary with this flag set will never use stack gaps in the address
+space constructed by
+.Xr execve 2 .
+However, the controls value can still be inherited by child processes, and
+executing a binary without this flag set will revert to the behavior specified
+by the control.
+.It Dv PROC_NO_NEW_PRIVS_CTL
+Allows one to ignore the set-user-ID and set-group-ID bits on the program
+images activated by
+.Xr execve 2
+in the specified process and its future descendants.
+The
+.Fa data
+parameter must point to an integer variable holding the following
+value:
+.Bl -tag -width Ds
+.It Dv PROC_NO_NEW_PRIVS_ENABLE
+Request set-user-ID and set-group-ID bits to be ignored.
+.El
+.Pp
+It is not possible to disable this control once it has been enabled.
+.It Dv PROC_NO_NEW_PRIVS_STATUS
+Returns the current status of set-ID bits enablement for the target process.
+The
+.Fa data
+parameter must point to an integer variable, where one of the
+following values is written:
+.Bl -tag -width Ds
+.It Dv PROC_NO_NEW_PRIVS_ENABLE
+.It Dv PROC_NO_NEW_PRIVS_DISABLE
+.El
+.It Dv PROC_WXMAP_CTL
+Controls the creation of mappings with both write and execute permissions
+in a process's address space.
+The
+.Fa data
+parameter must point to an integer variable holding one of the
+following values:
+.Bl -tag -width Ds
+.It Dv PROC_WX_MAPPINGS_PERMIT
+Enable creation of mappings that have both write and execute
+permissions in the specified process' current and future address spaces.
+.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
+In a new address space created by a future call to
+.Xr execve 2 ,
+disallow creation of mappings that have both write and execute
+permissions.
+.El
+.Pp
+If both flags are set,
+.Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
+takes precedence during
+.Xr execve 2 .
+If neither flag is set,
+mappings with write and execute permissions are only permitted if the
+.Dv kern.elf{32/64}.allow_wx
+sysctl is non-zero or the
+.Xr elfctl 1
+.Dq wxneeded
+flag is set in the ELF control note.
+.Pp
+Once creation of writeable and executable mappings is enabled for a process,
+it is impossible (and pointless) to disable it.
+The only way to ensure the absence of such mappings after they
+were enabled in a given process is to set the
+.Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
+flag and
+.Xr execve 2
+an image.
+.It Dv PROC_WXMAP_STATUS
+Returns the current status of the controls over creation of mappings with
+both write and execute permissions for the specified process.
+The
+.Dv data
+parameter must point to an integer variable, where one of the
+following values is written:
+.Bl -tag -width Ds
+.It Dv PROC_WX_MAPPINGS_PERMIT
+Creation of simultaneously writable and executable mappings are permitted;
+otherwise, the process cannot create such mappings.
+.It Dv PROC_WX_MAPPINGS_DISALLOW_EXEC
+After
+.Xr execve 2 ,
+the new address space will not permit creation of simultaneously
+writable and executable mappings.
+.El
+.Pp
+Additionally, if the address space of the process does not permit
+creation of simultaneously writable and executable mappings and
+it is guaranteed that no such mapping was created since address space
+creation, the
+.Dv PROC_WXORX_ENFORCE
+flag is set in the returned value.
+.El
+.Sh x86 MACHINE-SPECIFIC REQUESTS
+.Bl -tag -width PROC_KPTI_STATUS
+.It Dv PROC_KPTI_CTL
+AMD64 only.
+Controls the Kernel Page Table Isolation (KPTI) option for the children
+of the specified process.
+This control is only meaningful if KPTI has been enabled globally by the
+.Va vm.pmap.kpti
+tunable.
+It is not possible to change the KPTI setting for a running process,
+only for new address spaces constructed by a future
+.Xr execve 2 .
+.Pp
+The
+.Fa data
+parameter must point to an integer variable containing one of the
+following commands:
+.Bl -tag -width Ds
+.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC
+Enable KPTI after
+.Xr execve 2 .
+.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC
+Disable KPTI after
+.Xr execve 2 .
+Only root or a process having the
+.Va PRIV_IO
+privilege can use this option.
+.El
+.It Dv PROC_KPTI_STATUS
+Returns the current KPTI status for the specified process.
+.Fa data
+must point to an integer variable, where one of the
+following values is written:
+.Bl -tag -width Ds
+.It Dv PROC_KPTI_CTL_ENABLE_ON_EXEC
+.It Dv PROC_KPTI_CTL_DISABLE_ON_EXEC
+.El
+.Pp
+The status is or-ed with
+.Va PROC_KPTI_STATUS_ACTIVE
+if KPTI is active for the current address space of the process.
+.El
+.Sh NOTES
+Disabling tracing on a process should not be considered a security
+feature, as it is bypassable both by the kernel and privileged processes
+and via other system mechanisms.
+As such, it should not be utilized to reliably protect cryptographic
+keying material or other confidential data.
+.Pp
+Note that processes can trivially bypass the 'no simultaneously
+writable and executable mappings' policy by first marking some mapping
+as writeable, writing code to it, then removing write and adding
+execute permission.
+This may be legitimately required by some programs such as JIT compilers.
+.Sh RETURN VALUES
+If an error occurs, a value of \-1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn procctl
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa data
+parameter points outside the process's allocated address space.
+.It Bq Er EINVAL
+The
+.Fa cmd
+argument specifies an unsupported command.
+.Pp
+The
+.Fa idtype
+argument specifies an unsupported identifier type.
+.It Bq Er EPERM
+The calling process does not have permission to perform the requested
+operation on any of the selected processes.
+.It Bq Er ESRCH
+No processes matched the requested
+.Fa idtype
+and
+.Fa id .
+.It Bq Er ESRCH
+No descendant processes can be found matching criteria specified in the
+.Dv PROC_REAP_KILL
+request.
+.It Bq Er EINVAL
+An invalid operation or flag was passed in
+.Fa data
+for a
+.Dv PROC_SPROTECT
+command.
+.It Bq Er EPERM
+The
+.Fa idtype
+argument is not equal to
+.Dv P_PID ,
+or
+.Fa id
+is not equal to the pid of the calling process, for
+.Dv PROC_REAP_ACQUIRE
+or
+.Dv PROC_REAP_RELEASE
+requests.
+.It Bq Er EINVAL
+Invalid or undefined flags were passed to a
+.Dv PROC_REAP_KILL
+request.
+.It Bq Er EINVAL
+An invalid or zero signal number was requested for a
+.Dv PROC_REAP_KILL
+request.
+.It Bq Er EINVAL
+A
+.Dv PROC_REAP_RELEASE
+request was issued by the
+.Xr init 8
+process.
+.It Bq Er EBUSY
+A
+.Dv PROC_REAP_ACQUIRE
+request was issued by a process that is already a reaper process.
+.It Bq Er EBUSY
+A
+.Dv PROC_TRACE_CTL
+request was issued for a process being traced.
+.It Bq Er EPERM
+A
+.Dv PROC_TRACE_CTL
+request to re-enable tracing of the process
+.Po Dv PROC_TRACE_CTL_ENABLE Pc ,
+or to disable persistence of
+.Dv PROC_TRACE_CTL_DISABLE
+on
+.Xr execve 2
+specified a target process other than the calling process.
+.It Bq Er EINVAL
+The value of the integer
+.Fa data
+parameter for the
+.Dv PROC_TRACE_CTL
+or
+.Dv PROC_TRAPCAP_CTL
+request is invalid.
+.It Bq Er EINVAL
+The
+.Dv PROC_PDEATHSIG_CTL
+or
+.Dv PROC_PDEATHSIG_STATUS
+request referenced an unsupported
+.Fa id ,
+.Fa idtype
+or invalid signal number.
+.El
+.Sh SEE ALSO
+.Xr dtrace 1 ,
+.Xr elfctl 1 ,
+.Xr proccontrol 1 ,
+.Xr protect 1 ,
+.Xr cap_enter 2 ,
+.Xr kill 2 ,
+.Xr ktrace 2 ,
+.Xr mmap 2 ,
+.Xr mprotect 2 ,
+.Xr ptrace 2 ,
+.Xr wait 2 ,
+.Xr capsicum 4 ,
+.Xr hwpmc 4 ,
+.Xr init 8
+.Sh HISTORY
+The
+.Fn procctl
+function appeared in
+.Fx 9.3 .
+.Pp
+The reaper facility is based on a similar feature in Linux and
+DragonflyBSD, and first appeared in
+.Fx 10.2 .
+.Pp
+The
+.Dv PROC_PDEATHSIG_CTL
+facility is based on the
+.Ql prctl(PR_SET_PDEATHSIG, ...)
+feature in Linux,
+and first appeared in
+.Fx 11.2 .
+.Pp
+ASLR support was added for checklist compliance in
+.Fx 13.0 .
diff --git a/lib/libsys/profil.2 b/lib/libsys/profil.2
new file mode 100644
index 000000000000..025b6b7e7802
--- /dev/null
+++ b/lib/libsys/profil.2
@@ -0,0 +1,119 @@
+.\" Copyright (c) 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Donn Seeley of BSDI.
+.\"
+.\" 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.
+.\"
+.Dd December 1, 2017
+.Dt PROFIL 2
+.Os
+.Sh NAME
+.Nm profil
+.Nd control process profiling
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn profil "char *samples" "size_t size" "vm_offset_t offset" "int scale"
+.Sh DESCRIPTION
+The
+.Fn profil
+system call enables or disables
+program counter profiling of the current process.
+If profiling is enabled,
+then at every profiling clock tick,
+the kernel updates an appropriate count in the
+.Fa samples
+buffer.
+The frequency of the profiling clock is recorded
+in the header in the profiling output file.
+.Pp
+The buffer
+.Fa samples
+contains
+.Fa size
+bytes and is divided into
+a series of 16-bit bins.
+Each bin counts the number of times the program counter
+was in a particular address range in the process
+when a profiling clock tick occurred while profiling was enabled.
+For a given program counter address,
+the number of the corresponding bin is given
+by the relation:
+.Bd -literal -offset indent
+[(pc - offset) / 2] * scale / 65536
+.Ed
+.Pp
+The
+.Fa offset
+argument is the lowest address at which
+the kernel takes program counter samples.
+The
+.Fa scale
+argument ranges from 1 to 65536 and
+can be used to change the span of the bins.
+A scale of 65536 maps each bin to 2 bytes of address range;
+a scale of 32768 gives 4 bytes, 16384 gives 8 bytes and so on.
+Intermediate values provide approximate intermediate ranges.
+A
+.Fa scale
+value of 0 disables profiling.
+.Sh RETURN VALUES
+.Rv -std profil
+.Sh FILES
+.Bl -tag -width /usr/lib/gcrt0.o -compact
+.It Pa /usr/lib/gcrt0.o
+profiling C run-time startup file
+.It Pa gmon.out
+conventional name for profiling output file
+.El
+.Sh ERRORS
+The following error may be reported:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The buffer
+.Fa samples
+contains an invalid address.
+.El
+.Sh SEE ALSO
+.Xr gprof 1
+.Sh HISTORY
+The
+.Fn profil
+functionality first appeared in
+.At v3 .
+.Sh BUGS
+This routine should be named
+.Fn profile .
+.Pp
+The
+.Fa samples
+argument should really be a vector of type
+.Fa "unsigned short" .
+.Pp
+The format of the gmon.out file is undocumented.
diff --git a/lib/libc/sys/pselect.2 b/lib/libsys/pselect.2
index 29e6d8602d4f..29e6d8602d4f 100644
--- a/lib/libc/sys/pselect.2
+++ b/lib/libsys/pselect.2
diff --git a/lib/libsys/ptrace.2 b/lib/libsys/ptrace.2
new file mode 100644
index 000000000000..7aa24a3f820b
--- /dev/null
+++ b/lib/libsys/ptrace.2
@@ -0,0 +1,1451 @@
+.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
+.\"
+.\" This file is in the public domain.
+.Dd June 19, 2025
+.Dt PTRACE 2
+.Os
+.Sh NAME
+.Nm ptrace
+.Nd process tracing and debugging
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/ptrace.h
+.Ft int
+.Fn ptrace "int request" "pid_t pid" "caddr_t addr" "int data"
+.Sh DESCRIPTION
+The
+.Fn ptrace
+system call
+provides tracing and debugging facilities.
+It allows one process
+(the
+.Em tracing
+process)
+to control another
+(the
+.Em traced
+process).
+The tracing process must first attach to the traced process, and then
+issue a series of
+.Fn ptrace
+system calls to control the execution of the process, as well as access
+process memory and register state.
+For the duration of the tracing session, the traced process will be
+.Dq re-parented ,
+with its parent process ID (and resulting behavior)
+changed to the tracing process.
+It is permissible for a tracing process to attach to more than one
+other process at a time.
+When the tracing process has completed its work, it must detach the
+traced process; if a tracing process exits without first detaching all
+processes it has attached, those processes will be killed.
+.Pp
+Most of the time, the traced process runs normally, but when it
+receives a signal
+(see
+.Xr sigaction 2 ) ,
+it stops.
+The tracing process is expected to notice this via
+.Xr wait 2
+or the delivery of a
+.Dv SIGCHLD
+signal, examine the state of the stopped process, and cause it to
+terminate or continue as appropriate.
+The signal may be a normal process signal, generated as a result of
+traced process behavior, or use of the
+.Xr kill 2
+system call; alternatively, it may be generated by the tracing facility
+as a result of attaching, stepping by the tracing
+process,
+or an event in the traced process.
+The tracing process may choose to intercept the signal, using it to
+observe process behavior (such as
+.Dv SIGTRAP ) ,
+or forward the signal to the process if appropriate.
+The
+.Fn ptrace
+system call
+is the mechanism by which all this happens.
+.Pp
+A traced process may report additional signal stops corresponding to
+events in the traced process.
+These additional signal stops are reported as
+.Dv SIGTRAP
+or
+.Dv SIGSTOP
+signals.
+The tracing process can use the
+.Dv PT_LWPINFO
+request to determine which events are associated with a
+.Dv SIGTRAP
+or
+.Dv SIGSTOP
+signal.
+Note that multiple events may be associated with a single signal.
+For example, events indicated by the
+.Dv PL_FLAG_BORN ,
+.Dv PL_FLAG_FORKED ,
+and
+.Dv PL_FLAG_EXEC
+flags are also reported as a system call exit event
+.Pq Dv PL_FLAG_SCX .
+The signal stop for a new child process enabled via
+.Dv PTRACE_FORK
+will report a
+.Dv SIGSTOP
+signal.
+All other additional signal stops use
+.Dv SIGTRAP .
+.Sh DETACH AND TERMINATION
+.Pp
+Normally, exiting tracing process should wait for all pending
+debugging events and then detach from all alive traced processes
+before exiting using
+.Dv PT_DETACH
+request.
+If tracing process exits without detaching, for instance due to abnormal
+termination, the destiny of the traced children processes is determined
+by the
+.Dv kern.kill_on_debugger_exit
+sysctl control.
+.Pp
+If the control is set to the default value 1, such traced processes
+are terminated.
+If set to zero, kernel implicitly detaches traced processes.
+Traced processes are un-stopped if needed, and then continue the execution
+without tracing.
+Kernel drops any
+.Dv SIGTRAP
+signals queued to the traced children, which could be either generated by
+not yet consumed debug events, or sent by other means, the later should
+not be done anyway.
+.Sh SELECTING THE TARGET
+The
+.Fa pid
+argument of the call specifies the target on which to perform
+the requested operation.
+For operations affecting the global process state, the process ID
+is typically passed there.
+Similarly, for operations affecting only a thread, the thread ID
+needs to be passed.
+.Pp
+Still, for global operations, the ID of any thread can be used as the
+target, and system will perform the request on the process owning
+that thread.
+If a thread operation got the process ID as
+.Fa pid ,
+the system randomly selects a thread from among the threads owned
+by the process.
+For single-threaded processes there is no difference between specifying
+process or thread ID as the target.
+.Sh DISABLING PTRACE
+The
+.Nm
+subsystem provides rich facilities to manipulate other processes state.
+Sometimes it may be desirable to disallow it either completely, or limit
+its scope.
+The following controls are provided for this:
+.Bl -tag -width security.bsd.unprivileged_proc_debug
+.It Dv security.bsd.allow_ptrace
+Setting this sysctl to zero makes
+.Nm
+return
+.Er ENOSYS
+always as if the syscall is not implemented by the kernel.
+.It Dv security.bsd.unprivileged_proc_debug
+Setting this sysctl to zero disallows the use of
+.Fn ptrace
+by unprivileged processes.
+.It Dv security.bsd.see_other_uids
+Setting this sysctl to zero prevents
+.Fn ptrace
+requests from targeting processes with a real user identifier different
+from the caller's.
+These requests will fail with error
+.Er ESRCH .
+.It Dv security.bsd.see_other_gids
+Setting this sysctl to zero disallows
+.Fn ptrace
+requests from processes that have no groups in common with the target process,
+considering their sets of real and supplementary groups.
+These requests will fail with error
+.Er ESRCH .
+.It Dv security.bsd.see_jail_proc
+Setting this sysctl to zero disallows
+.Fn ptrace
+requests from processes belonging to a different jail than that of the target
+process, even if the requesting process' jail is an ancestor of the target
+process'.
+These requests will fail with error
+.Er ESRCH .
+.It Dv securelevel and init
+The
+.Xr init 1
+process can only be traced with
+.Nm
+if securelevel is zero.
+.It Dv procctl(2) PROC_TRACE_CTL
+Process can deny attempts to trace itself with
+.Xr procctl 2
+.Dv PROC_TRACE_CTL
+request.
+In this case requests return
+.Xr EPERM
+error.
+.El
+.Sh TRACING EVENTS
+.Pp
+Each traced process has a tracing event mask.
+An event in the traced process only reports a
+signal stop if the corresponding flag is set in the tracing event mask.
+The current set of tracing event flags include:
+.Bl -tag -width "Dv PTRACE_SYSCALL"
+.It Dv PTRACE_EXEC
+Report a stop for a successful invocation of
+.Xr execve 2 .
+This event is indicated by the
+.Dv PL_FLAG_EXEC
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PTRACE_SCE
+Report a stop on each system call entry.
+This event is indicated by the
+.Dv PL_FLAG_SCE
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PTRACE_SCX
+Report a stop on each system call exit.
+This event is indicated by the
+.Dv PL_FLAG_SCX
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PTRACE_SYSCALL
+Report stops for both system call entry and exit.
+.It Dv PTRACE_FORK
+This event flag controls tracing for new child processes of a traced process.
+.Pp
+When this event flag is enabled,
+new child processes will enable tracing and stop before executing their
+first instruction.
+The new child process will include the
+.Dv PL_FLAG_CHILD
+flag in the
+.Va pl_flags
+member of
+.Vt "struct ptrace_lwpinfo" .
+The traced process will report a stop that includes the
+.Dv PL_FLAG_FORKED
+flag.
+The process ID of the new child process will also be present in the
+.Va pl_child_pid
+member of
+.Vt "struct ptrace_lwpinfo" .
+If the new child process was created via
+.Xr vfork 2 ,
+the traced process's stop will also include the
+.Dv PL_FLAG_VFORKED
+flag.
+Note that new child processes will be attached with the default
+tracing event mask;
+they do not inherit the event mask of the traced process.
+.Pp
+When this event flag is not enabled,
+new child processes will execute without tracing enabled.
+.It Dv PTRACE_LWP
+This event flag controls tracing of LWP
+.Pq kernel thread
+creation and destruction.
+When this event is enabled,
+new LWPs will stop and report an event with
+.Dv PL_FLAG_BORN
+set before executing their first instruction,
+and exiting LWPs will stop and report an event with
+.Dv PL_FLAG_EXITED
+set before completing their termination.
+.Pp
+Note that new processes do not report an event for the creation of their
+initial thread,
+and exiting processes do not report an event for the termination of the
+last thread.
+.It Dv PTRACE_VFORK
+Report a stop event when a parent process resumes after a
+.Xr vfork 2 .
+.Pp
+When a thread in the traced process creates a new child process via
+.Xr vfork 2 ,
+the stop that reports
+.Dv PL_FLAG_FORKED
+and
+.Dv PL_FLAG_SCX
+occurs just after the child process is created,
+but before the thread waits for the child process to stop sharing process
+memory.
+If a debugger is not tracing the new child process,
+it must ensure that no breakpoints are enabled in the shared process
+memory before detaching from the new child process.
+This means that no breakpoints are enabled in the parent process either.
+.Pp
+The
+.Dv PTRACE_VFORK
+flag enables a new stop that indicates when the new child process stops
+sharing the process memory of the parent process.
+A debugger can reinsert breakpoints in the parent process and resume it
+in response to this event.
+This event is indicated by setting the
+.Dv PL_FLAG_VFORK_DONE
+flag.
+.El
+.Pp
+The default tracing event mask when attaching to a process via
+.Dv PT_ATTACH ,
+.Dv PT_TRACE_ME ,
+or
+.Dv PTRACE_FORK
+includes only
+.Dv PTRACE_EXEC
+events.
+All other event flags are disabled.
+.Sh PTRACE REQUESTS
+.Pp
+The
+.Fa request
+argument specifies what operation is being performed; the meaning of
+the rest of the arguments depends on the operation, but except for one
+special case noted below, all
+.Fn ptrace
+calls are made by the tracing process, and the
+.Fa pid
+argument specifies the process ID of the traced process
+or a corresponding thread ID.
+The
+.Fa request
+argument
+can be:
+.Bl -tag -width "Dv PT_GET_EVENT_MASK"
+.It Dv PT_TRACE_ME
+This request is the only one used by the traced process; it declares
+that the process expects to be traced by its parent.
+All the other arguments are ignored.
+(If the parent process does not expect to trace the child, it will
+probably be rather confused by the results; once the traced process
+stops, it cannot be made to continue except via
+.Fn ptrace . )
+When a process has used this request and calls
+.Xr execve 2
+or any of the routines built on it
+(such as
+.Xr execv 3 ) ,
+it will stop before executing the first instruction of the new image.
+Also, any setuid or setgid bits on the executable being executed will
+be ignored.
+If the child was created by
+.Xr vfork 2
+system call or
+.Xr rfork 2
+call with the
+.Dv RFMEM
+flag specified, the debugging events are reported to the parent
+only after the
+.Xr execve 2
+is executed.
+.It Dv PT_READ_I , Dv PT_READ_D
+These requests read a single
+.Vt int
+of data from the traced process's address space.
+Traditionally,
+.Fn ptrace
+has allowed for machines with distinct address spaces for instruction
+and data, which is why there are two requests: conceptually,
+.Dv PT_READ_I
+reads from the instruction space and
+.Dv PT_READ_D
+reads from the data space.
+In the current
+.Fx
+implementation, these two requests are completely identical.
+The
+.Fa addr
+argument specifies the address
+(in the traced process's virtual address space)
+at which the read is to be done.
+This address does not have to meet any alignment constraints.
+The value read is returned as the return value from
+.Fn ptrace .
+.It Dv PT_WRITE_I , Dv PT_WRITE_D
+These requests parallel
+.Dv PT_READ_I
+and
+.Dv PT_READ_D ,
+except that they write rather than read.
+The
+.Fa data
+argument supplies the value to be written.
+.It Dv PT_IO
+This request allows reading and writing arbitrary amounts of data in
+the traced process's address space.
+The
+.Fa addr
+argument specifies a pointer to a
+.Vt "struct ptrace_io_desc" ,
+which is defined as follows:
+.Bd -literal
+struct ptrace_io_desc {
+ int piod_op; /* I/O operation */
+ void *piod_offs; /* child offset */
+ void *piod_addr; /* parent offset */
+ size_t piod_len; /* request length */
+};
+
+/*
+ * Operations in piod_op.
+ */
+#define PIOD_READ_D 1 /* Read from D space */
+#define PIOD_WRITE_D 2 /* Write to D space */
+#define PIOD_READ_I 3 /* Read from I space */
+#define PIOD_WRITE_I 4 /* Write to I space */
+.Ed
+.Pp
+The
+.Fa data
+argument is ignored.
+The actual number of bytes read or written is stored in
+.Va piod_len
+upon return.
+.It Dv PT_CONTINUE
+The traced process continues execution.
+The
+.Fa addr
+argument
+is an address specifying the place where execution is to be resumed
+(a new value for the program counter),
+or
+.Po Vt caddr_t Pc Ns 1
+to indicate that execution is to pick up where it left off.
+The
+.Fa data
+argument
+provides a signal number to be delivered to the traced process as it
+resumes execution, or 0 if no signal is to be sent.
+.It Dv PT_STEP
+The traced process is single stepped one instruction.
+The
+.Fa addr
+argument
+should be passed
+.Po Vt caddr_t Pc Ns 1 .
+The
+.Fa data
+argument
+provides a signal number to be delivered to the traced process as it
+resumes execution, or 0 if no signal is to be sent.
+.It Dv PT_KILL
+The traced process terminates, as if
+.Dv PT_CONTINUE
+had been used with
+.Dv SIGKILL
+given as the signal to be delivered.
+.It Dv PT_ATTACH
+This request allows a process to gain control of an otherwise
+unrelated process and begin tracing it.
+It does not need any cooperation from the process to trace.
+In
+this case,
+.Fa pid
+specifies the process ID of the process to trace, and the other
+two arguments are ignored.
+This request requires that the target process must have the same real
+UID as the tracing process, and that it must not be executing a setuid
+or setgid executable.
+(If the tracing process is running as root, these restrictions do not
+apply.)
+The tracing process will see the newly-traced process stop and may
+then control it as if it had been traced all along.
+.It Dv PT_DETACH
+This request is like PT_CONTINUE, except that it does not allow
+specifying an alternate place to continue execution, and after it
+succeeds, the traced process is no longer traced and continues
+execution normally.
+.Pp
+The parent of the traced process will be sent a
+.Dv SIGCHLD
+to indicate that the process has continued from a stopped state regardless of
+whether the process was in a stopped state prior to the corresponding
+.Dv PT_ATTACH
+request.
+A
+.Xr wait 2
+for the traced process would indicate that it had been continued.
+.It Dv PT_GETREGS
+This request reads the traced process's machine registers into the
+.Do
+.Vt "struct reg"
+.Dc
+(defined in
+.In machine/reg.h )
+pointed to by
+.Fa addr .
+.It Dv PT_SETREGS
+This request is the converse of
+.Dv PT_GETREGS ;
+it loads the traced process's machine registers from the
+.Do
+.Vt "struct reg"
+.Dc
+(defined in
+.In machine/reg.h )
+pointed to by
+.Fa addr .
+.It Dv PT_GETFPREGS
+This request reads the traced process's floating-point registers into
+the
+.Do
+.Vt "struct fpreg"
+.Dc
+(defined in
+.In machine/reg.h )
+pointed to by
+.Fa addr .
+.It Dv PT_SETFPREGS
+This request is the converse of
+.Dv PT_GETFPREGS ;
+it loads the traced process's floating-point registers from the
+.Do
+.Vt "struct fpreg"
+.Dc
+(defined in
+.In machine/reg.h )
+pointed to by
+.Fa addr .
+.It Dv PT_GETDBREGS
+This request reads the traced process's debug registers into
+the
+.Do
+.Vt "struct dbreg"
+.Dc
+(defined in
+.In machine/reg.h )
+pointed to by
+.Fa addr .
+.It Dv PT_SETDBREGS
+This request is the converse of
+.Dv PT_GETDBREGS ;
+it loads the traced process's debug registers from the
+.Do
+.Vt "struct dbreg"
+.Dc
+(defined in
+.In machine/reg.h )
+pointed to by
+.Fa addr .
+.It Dv PT_GETREGSET
+This request reads the registers from the traced process.
+The
+.Fa data
+argument specifies the register set to read, with the
+.Fa addr
+argument pointing at a
+.Vt "struct iovec"
+where the
+.Va iov_base
+field points to a register set specific structure to hold the registers,
+and the
+.Va iov_len
+field holds the length of the structure.
+.It Dv PT_SETREGSET
+This request writes to the registers of the traced process.
+The
+.Fa data
+argument specifies the register set to write to, with the
+.Fa addr
+argument pointing at a
+.Vt "struct iovec"
+where the
+.Va iov_base
+field points to a register set specific structure to hold the registers,
+and the
+.Va iov_len
+field holds the length of the structure.
+If
+.Va iov_base
+is NULL the kernel will return the expected length of the register set
+specific structure in the
+.Va iov_len
+field and not change the target register set.
+.It Dv PT_LWPINFO
+This request can be used to obtain information about the kernel thread,
+also known as light-weight process, that caused the traced process to stop.
+The
+.Fa addr
+argument specifies a pointer to a
+.Vt "struct ptrace_lwpinfo" ,
+which is defined as follows:
+.Bd -literal
+struct ptrace_lwpinfo {
+ lwpid_t pl_lwpid;
+ int pl_event;
+ int pl_flags;
+ sigset_t pl_sigmask;
+ sigset_t pl_siglist;
+ siginfo_t pl_siginfo;
+ char pl_tdname[MAXCOMLEN + 1];
+ pid_t pl_child_pid;
+ u_int pl_syscall_code;
+ u_int pl_syscall_narg;
+};
+.Ed
+.Pp
+The
+.Fa data
+argument is to be set to the size of the structure known to the caller.
+This allows the structure to grow without affecting older programs.
+.Pp
+The fields in the
+.Vt "struct ptrace_lwpinfo"
+have the following meaning:
+.Bl -tag -width indent -compact
+.It Va pl_lwpid
+LWP id of the thread
+.It Va pl_event
+Event that caused the stop.
+Currently defined events are:
+.Bl -tag -width "Dv PL_EVENT_SIGNAL" -compact
+.It Dv PL_EVENT_NONE
+No reason given
+.It Dv PL_EVENT_SIGNAL
+Thread stopped due to the pending signal
+.El
+.It Va pl_flags
+Flags that specify additional details about observed stop.
+Currently defined flags are:
+.Bl -tag -width indent -compact
+.It Dv PL_FLAG_SCE
+The thread stopped due to system call entry, right after the kernel is entered.
+The debugger may examine syscall arguments that are stored in memory and
+registers according to the ABI of the current process, and modify them,
+if needed.
+.It Dv PL_FLAG_SCX
+The thread is stopped immediately before syscall is returning to the usermode.
+The debugger may examine system call return values in the ABI-defined registers
+and/or memory.
+.It Dv PL_FLAG_EXEC
+When
+.Dv PL_FLAG_SCX
+is set, this flag may be additionally specified to inform that the
+program being executed by debuggee process has been changed by successful
+execution of a system call from the
+.Fn execve 2
+family.
+.It Dv PL_FLAG_SI
+Indicates that
+.Va pl_siginfo
+member of
+.Vt "struct ptrace_lwpinfo"
+contains valid information.
+.It Dv PL_FLAG_FORKED
+Indicates that the process is returning from a call to
+.Fn fork 2
+that created a new child process.
+The process identifier of the new process is available in the
+.Va pl_child_pid
+member of
+.Vt "struct ptrace_lwpinfo" .
+.It Dv PL_FLAG_CHILD
+The flag is set for first event reported from a new child which is
+automatically attached when
+.Dv PTRACE_FORK
+is enabled.
+.It Dv PL_FLAG_BORN
+This flag is set for the first event reported from a new LWP when
+.Dv PTRACE_LWP
+is enabled.
+It is reported along with
+.Dv PL_FLAG_SCX .
+.It Dv PL_FLAG_EXITED
+This flag is set for the last event reported by an exiting LWP when
+.Dv PTRACE_LWP
+is enabled.
+Note that this event is not reported when the last LWP in a process exits.
+The termination of the last thread is reported via a normal process exit
+event.
+.It Dv PL_FLAG_VFORKED
+Indicates that the thread is returning from a call to
+.Xr vfork 2
+that created a new child process.
+This flag is set in addition to
+.Dv PL_FLAG_FORKED .
+.It Dv PL_FLAG_VFORK_DONE
+Indicates that the thread has resumed after a child process created via
+.Xr vfork 2
+has stopped sharing its address space with the traced process.
+.El
+.It Va pl_sigmask
+The current signal mask of the LWP
+.It Va pl_siglist
+The current pending set of signals for the LWP.
+Note that signals that are delivered to the process would not appear
+on an LWP siglist until the thread is selected for delivery.
+.It Va pl_siginfo
+The siginfo that accompanies the signal pending.
+Only valid for
+.Dv PL_EVENT_SIGNAL
+stop when
+.Dv PL_FLAG_SI
+is set in
+.Va pl_flags .
+.It Va pl_tdname
+The name of the thread.
+.It Va pl_child_pid
+The process identifier of the new child process.
+Only valid for a
+.Dv PL_EVENT_SIGNAL
+stop when
+.Dv PL_FLAG_FORKED
+is set in
+.Va pl_flags .
+.It Va pl_syscall_code
+The ABI-specific identifier of the current system call.
+Note that for indirect system calls this field reports the indirected
+system call.
+Only valid when
+.Dv PL_FLAG_SCE
+or
+.Dv PL_FLAG_SCX
+is set in
+.Va pl_flags .
+.It Va pl_syscall_narg
+The number of arguments passed to the current system call not counting
+the system call identifier.
+Note that for indirect system calls this field reports the arguments
+passed to the indirected system call.
+Only valid when
+.Dv PL_FLAG_SCE
+or
+.Dv PL_FLAG_SCX
+is set in
+.Va pl_flags .
+.El
+.It Dv PT_GETNUMLWPS
+This request returns the number of kernel threads associated with the
+traced process.
+.It Dv PT_GETLWPLIST
+This request can be used to get the current thread list.
+A pointer to an array of type
+.Vt lwpid_t
+should be passed in
+.Fa addr ,
+with the array size specified by
+.Fa data .
+The return value from
+.Fn ptrace
+is the count of array entries filled in.
+.It Dv PT_SETSTEP
+This request will turn on single stepping of the specified process.
+Stepping is automatically disabled when a single step trap is caught.
+.It Dv PT_CLEARSTEP
+This request will turn off single stepping of the specified process.
+.It Dv PT_SUSPEND
+This request will suspend the specified thread.
+.It Dv PT_RESUME
+This request will resume the specified thread.
+.It Dv PT_TO_SCE
+This request will set the
+.Dv PTRACE_SCE
+event flag to trace all future system call entries and continue the process.
+The
+.Fa addr
+and
+.Fa data
+arguments are used the same as for
+.Dv PT_CONTINUE .
+.It Dv PT_TO_SCX
+This request will set the
+.Dv PTRACE_SCX
+event flag to trace all future system call exits and continue the process.
+The
+.Fa addr
+and
+.Fa data
+arguments are used the same as for
+.Dv PT_CONTINUE .
+.It Dv PT_SYSCALL
+This request will set the
+.Dv PTRACE_SYSCALL
+event flag to trace all future system call entries and exits and continue
+the process.
+The
+.Fa addr
+and
+.Fa data
+arguments are used the same as for
+.Dv PT_CONTINUE .
+.It Dv PT_GET_SC_ARGS
+For the thread which is stopped in either
+.Dv PL_FLAG_SCE
+or
+.Dv PL_FLAG_SCX
+state, that is, on entry or exit to a syscall,
+this request fetches the syscall arguments.
+.Pp
+The arguments are copied out into the buffer pointed to by the
+.Fa addr
+pointer, sequentially.
+Each syscall argument is stored as the machine word.
+Kernel copies out as many arguments as the syscall accepts,
+see the
+.Va pl_syscall_narg
+member of the
+.Vt struct ptrace_lwpinfo ,
+but not more than the
+.Fa data
+bytes in total are copied.
+.It Dv PT_GET_SC_RET
+Fetch the system call return values on exit from a syscall.
+This request is only valid for threads stopped in a syscall
+exit (the
+.Dv PL_FLAG_SCX
+state).
+The
+.Fa addr
+argument specifies a pointer to a
+.Vt "struct ptrace_sc_ret" ,
+which is defined as follows:
+.Bd -literal
+struct ptrace_sc_ret {
+ register_t sr_retval[2];
+ int sr_error;
+};
+.Ed
+.Pp
+The
+.Fa data
+argument is set to the size of the structure.
+.Pp
+If the system call completed successfully,
+.Va sr_error
+is set to zero and the return values of the system call are saved in
+.Va sr_retval .
+If the system call failed to execute,
+.Va sr_error
+field is set to a positive
+.Xr errno 2
+value.
+If the system call completed in an unusual fashion,
+.Va sr_error
+is set to a negative value:
+.Bl -tag -width EJUSTRETURN -compact
+.It Dv ERESTART
+System call will be restarted.
+.It Dv EJUSTRETURN
+System call completed sucessfully but did not set a return value
+.Po for example,
+.Xr setcontext 2
+and
+.Xr sigreturn 2
+.Pc .
+.El
+.It Dv PT_FOLLOW_FORK
+This request controls tracing for new child processes of a traced process.
+If
+.Fa data
+is non-zero,
+.Dv PTRACE_FORK
+is set in the traced process's event tracing mask.
+If
+.Fa data
+is zero,
+.Dv PTRACE_FORK
+is cleared from the traced process's event tracing mask.
+.It Dv PT_LWP_EVENTS
+This request controls tracing of LWP creation and destruction.
+If
+.Fa data
+is non-zero,
+.Dv PTRACE_LWP
+is set in the traced process's event tracing mask.
+If
+.Fa data
+is zero,
+.Dv PTRACE_LWP
+is cleared from the traced process's event tracing mask.
+.It Dv PT_GET_EVENT_MASK
+This request reads the traced process's event tracing mask into the
+integer pointed to by
+.Fa addr .
+The size of the integer must be passed in
+.Fa data .
+.It Dv PT_SET_EVENT_MASK
+This request sets the traced process's event tracing mask from the
+integer pointed to by
+.Fa addr .
+The size of the integer must be passed in
+.Fa data .
+.It Dv PT_VM_TIMESTAMP
+This request returns the generation number or timestamp of the memory map of
+the traced process as the return value from
+.Fn ptrace .
+This provides a low-cost way for the tracing process to determine if the
+VM map changed since the last time this request was made.
+.It Dv PT_VM_ENTRY
+This request is used to iterate over the entries of the VM map of the traced
+process.
+The
+.Fa addr
+argument specifies a pointer to a
+.Vt "struct ptrace_vm_entry" ,
+which is defined as follows:
+.Bd -literal
+struct ptrace_vm_entry {
+ int pve_entry;
+ int pve_timestamp;
+ u_long pve_start;
+ u_long pve_end;
+ u_long pve_offset;
+ u_int pve_prot;
+ u_int pve_pathlen;
+ long pve_fileid;
+ uint32_t pve_fsid;
+ char *pve_path;
+};
+.Ed
+.Pp
+The first entry is returned by setting
+.Va pve_entry
+to zero.
+Subsequent entries are returned by leaving
+.Va pve_entry
+unmodified from the value returned by previous requests.
+The
+.Va pve_timestamp
+field can be used to detect changes to the VM map while iterating over the
+entries.
+The tracing process can then take appropriate action, such as restarting.
+By setting
+.Va pve_pathlen
+to a non-zero value on entry, the pathname of the backing object is returned
+in the buffer pointed to by
+.Va pve_path ,
+provided the entry is backed by a vnode.
+The
+.Va pve_pathlen
+field is updated with the actual length of the pathname (including the
+terminating null character).
+The
+.Va pve_offset
+field is the offset within the backing object at which the range starts.
+The range is located in the VM space at
+.Va pve_start
+and extends up to
+.Va pve_end
+(inclusive).
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_COREDUMP
+This request creates a coredump for the stopped program.
+The
+.Fa addr
+argument specifies a pointer to a
+.Vt "struct ptrace_coredump" ,
+which is defined as follows:
+.Bd -literal
+struct ptrace_coredump {
+ int pc_fd;
+ uint32_t pc_flags;
+ off_t pc_limit;
+};
+.Ed
+The fields of the structure are:
+.Bl -tag -width pc_flags
+.It Dv pc_fd
+File descriptor to write the dump to.
+It must refer to a regular file, opened for writing.
+.It Dv pc_flags
+Flags.
+The following flags are defined:
+.Bl -tag -width PC_COMPRESS
+.It Dv PC_COMPRESS
+Request compression of the dump.
+.It Dv PC_ALL
+Include non-dumpable entries into the dump.
+The dumper ignores
+.Dv MAP_NOCORE
+flag of the process map entry, but device mappings are not dumped even with
+.Dv PC_ALL
+set.
+.El
+.It Dv pc_limit
+Maximum size of the coredump.
+Specify zero for no limit.
+.El
+.Pp
+The size of
+.Vt "struct ptrace_coredump"
+must be passed in
+.Fa data .
+.It Dv PT_SC_REMOTE
+Request to execute a syscall in the context of the traced process,
+in the specified thread.
+The
+.Fa addr
+argument must point to the
+.Vt "struct ptrace_sc_remote" ,
+which describes the requested syscall and its arguments, and receives
+the result.
+The size of
+.Vt "struct ptrace_sc_remote"
+must be passed in
+.Fa data.
+.Bd -literal
+struct ptrace_sc_remote {
+ struct ptrace_sc_ret pscr_ret;
+ u_int pscr_syscall;
+ u_int pscr_nargs;
+ u_long *pscr_args;
+};
+.Ed
+The
+.Dv pscr_syscall
+contains the syscall number to execute, the
+.Dv pscr_nargs
+is the number of supplied arguments, which are supplied in the
+.Dv pscr_args
+array.
+Result of the execution is returned in the
+.Dv pscr_ret
+member.
+Note that the request and its result do not affect the returned value from
+the currently executed syscall, if any.
+.El
+.Sh PT_COREDUMP and PT_SC_REMOTE usage
+The process must be stopped before dumping or initiating a remote system call.
+A single thread in the target process is temporarily unsuspended
+in the kernel to perform the action.
+If the
+.Nm
+call fails before a thread is unsuspended, there is no event to
+.Xr waitpid 2
+for.
+If a thread was unsuspended, it will stop again before the
+.Nm
+call returns, and the process must be waited upon using
+.Xr waitpid 2
+to consume the new stop event.
+Since it is hard to deduce whether a thread was unsuspended before
+an error occurred, it is recommended to unconditionally perform
+.Xr waitpid 2
+with
+.Dv WNOHANG
+flag after
+.Dv PT_COREDUMP
+and
+.Dv PT_SC_REMOTE ,
+and silently accept zero result from it.
+.Pp
+For
+.Dv PT_SC_REMOTE ,
+the selected thread must be stopped in the safe place, which is
+currently defined as a syscall exit, or a return from kernel to
+user mode (basically, a signal handler call place).
+Kernel returns
+.Er EBUSY
+status if attempt is made to execute remote syscall at unsafe stop.
+.Pp
+Note that neither
+.Dv kern.trap_enotcap
+sysctl setting, nor the corresponding
+.Xr procctl 2
+flag
+.Dv PROC_TRAPCAP_CTL_ENABLE
+are obeyed during the execution of the syscall by
+.Dv PT_SC_REMOTE .
+In other words,
+.Dv SIGTRAP
+signal is not sent to a process executing in capability mode,
+which violated a mode access restriction.
+.Pp
+Note that due to the mode of execution for the remote syscall, in
+particular, the setting where only one thread is allowed to run,
+the syscall might block on resources owned by suspended threads.
+This might result in the target process deadlock.
+In this situation, the only way out is to kill the target.
+.Sh ARM MACHINE-SPECIFIC REQUESTS
+.Bl -tag -width "Dv PT_SETVFPREGS"
+.It Dv PT_GETVFPREGS
+Return the thread's
+.Dv VFP
+machine state in the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_SETVFPREGS
+Set the thread's
+.Dv VFP
+machine state from the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.El
+.Sh x86 MACHINE-SPECIFIC REQUESTS
+.Bl -tag -width "Dv PT_GETXSTATE_INFO"
+.It Dv PT_GETXMMREGS
+Copy the XMM FPU state into the buffer pointed to by the
+argument
+.Fa addr .
+The buffer has the same layout as the 32-bit save buffer for the
+machine instruction
+.Dv FXSAVE .
+.Pp
+This request is only valid for i386 programs, both on native 32-bit
+systems and on amd64 kernels.
+For 64-bit amd64 programs, the XMM state is reported as part of
+the FPU state returned by the
+.Dv PT_GETFPREGS
+request.
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_SETXMMREGS
+Load the XMM FPU state for the thread from the buffer pointed to
+by the argument
+.Fa addr .
+The buffer has the same layout as the 32-bit load buffer for the
+machine instruction
+.Dv FXRSTOR .
+.Pp
+As with
+.Dv PT_GETXMMREGS ,
+this request is only valid for i386 programs.
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_GETXSTATE_INFO
+Report which XSAVE FPU extensions are supported by the CPU
+and allowed in userspace programs.
+The
+.Fa addr
+argument must point to a variable of type
+.Vt struct ptrace_xstate_info ,
+which contains the information on the request return.
+.Vt struct ptrace_xstate_info
+is defined as follows:
+.Bd -literal
+struct ptrace_xstate_info {
+ uint64_t xsave_mask;
+ uint32_t xsave_len;
+};
+.Ed
+The
+.Dv xsave_mask
+field is a bitmask of the currently enabled extensions.
+The meaning of the bits is defined in the Intel and AMD
+processor documentation.
+The
+.Dv xsave_len
+field reports the length of the XSAVE area for storing the hardware
+state for currently enabled extensions in the format defined by the x86
+.Dv XSAVE
+machine instruction.
+.Pp
+The
+.Fa data
+argument value must be equal to the size of the
+.Vt struct ptrace_xstate_info .
+.It Dv PT_GETXSTATE
+Return the content of the XSAVE area for the thread.
+The
+.Fa addr
+argument points to the buffer where the content is copied, and the
+.Fa data
+argument specifies the size of the buffer.
+The kernel copies out as much content as allowed by the buffer size.
+The buffer layout is specified by the layout of the save area for the
+.Dv XSAVE
+machine instruction.
+.It Dv PT_SETXSTATE
+Load the XSAVE state for the thread from the buffer specified by the
+.Fa addr
+pointer.
+The buffer size is passed in the
+.Fa data
+argument.
+The buffer must be at least as large as the
+.Vt struct savefpu
+(defined in
+.Pa x86/fpu.h )
+to allow the complete x87 FPU and XMM state load.
+It must not be larger than the XSAVE state length, as reported by the
+.Dv xsave_len
+field from the
+.Vt struct ptrace_xstate_info
+of the
+.Dv PT_GETXSTATE_INFO
+request.
+Layout of the buffer is identical to the layout of the load area for the
+.Dv XRSTOR
+machine instruction.
+.It Dv PT_GETFSBASE
+Return the value of the base used when doing segmented
+memory addressing using the %fs segment register.
+The
+.Fa addr
+argument points to an
+.Vt unsigned long
+variable where the base value is stored.
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_GETGSBASE
+Like the
+.Dv PT_GETFSBASE
+request, but returns the base for the %gs segment register.
+.It Dv PT_SETFSBASE
+Set the base for the %fs segment register to the value pointed to
+by the
+.Fa addr
+argument.
+.Fa addr
+must point to the
+.Vt unsigned long
+variable containing the new base.
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_SETGSBASE
+Like the
+.Dv PT_SETFSBASE
+request, but sets the base for the %gs segment register.
+.El
+.Sh PowerPC MACHINE-SPECIFIC REQUESTS
+.Bl -tag -width "Dv PT_SETVRREGS"
+.It Dv PT_GETVRREGS
+Return the thread's
+.Dv ALTIVEC
+machine state in the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_SETVRREGS
+Set the thread's
+.Dv ALTIVEC
+machine state from the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_GETVSRREGS
+Return doubleword 1 of the thread's
+.Dv VSX
+registers VSR0-VSR31 in the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.It Dv PT_SETVSRREGS
+Set doubleword 1 of the thread's
+.Dv VSX
+registers VSR0-VSR31 from the buffer pointed to by
+.Fa addr .
+.Pp
+The
+.Fa data
+argument is ignored.
+.El
+.Pp
+Additionally, other machine-specific requests can exist.
+.Sh RETURN VALUES
+Most requests return 0 on success and \-1 on error.
+Some requests can cause
+.Fn ptrace
+to return
+\-1
+as a non-error value, among them are
+.Dv PT_READ_I
+and
+.Dv PT_READ_D ,
+which return the value read from the process memory on success.
+To disambiguate,
+.Va errno
+can be set to 0 before the call and checked afterwards.
+.Pp
+The current
+.Fn ptrace
+implementation always sets
+.Va errno
+to 0 before calling into the kernel, both for historic reasons and for
+consistency with other operating systems.
+It is recommended to assign zero to
+.Va errno
+explicitly for forward compatibility.
+.Sh ERRORS
+The
+.Fn ptrace
+system call may fail if:
+.Bl -tag -width Er
+.It Bq Er ESRCH
+.Bl -bullet -compact
+.It
+No process having the specified process ID exists.
+.El
+.It Bq Er EINVAL
+.Bl -bullet -compact
+.It
+A process attempted to use
+.Dv PT_ATTACH
+on itself.
+.It
+The
+.Fa request
+argument
+was not one of the legal requests.
+.It
+The signal number
+(in
+.Fa data )
+to
+.Dv PT_CONTINUE
+was neither 0 nor a legal signal number.
+.It
+.Dv PT_GETREGS ,
+.Dv PT_SETREGS ,
+.Dv PT_GETFPREGS ,
+.Dv PT_SETFPREGS ,
+.Dv PT_GETDBREGS ,
+or
+.Dv PT_SETDBREGS
+was attempted on a process with no valid register set.
+(This is normally true only of system processes.)
+.It
+.Dv PT_VM_ENTRY
+was given an invalid value for
+.Fa pve_entry .
+This can also be caused by changes to the VM map of the process.
+.It
+The size (in
+.Fa data )
+provided to
+.Dv PT_LWPINFO
+was less than or equal to zero, or larger than the
+.Vt ptrace_lwpinfo
+structure known to the kernel.
+.It
+The size (in
+.Fa data )
+provided to the x86-specific
+.Dv PT_GETXSTATE_INFO
+request was not equal to the size of the
+.Vt struct ptrace_xstate_info .
+.It
+The size (in
+.Fa data )
+provided to the x86-specific
+.Dv PT_SETXSTATE
+request was less than the size of the x87 plus the XMM save area.
+.It
+The size (in
+.Fa data )
+provided to the x86-specific
+.Dv PT_SETXSTATE
+request was larger than returned in the
+.Dv xsave_len
+member of the
+.Vt struct ptrace_xstate_info
+from the
+.Dv PT_GETXSTATE_INFO
+request.
+.It
+The base value, provided to the amd64-specific requests
+.Dv PT_SETFSBASE
+or
+.Dv PT_SETGSBASE ,
+pointed outside of the valid user address space.
+This error will not occur in 32-bit programs.
+.El
+.It Bq Er EBUSY
+.Bl -bullet -compact
+.It
+.Dv PT_ATTACH
+was attempted on a process that was already being traced.
+.It
+A request attempted to manipulate a process that was being traced by
+some process other than the one making the request.
+.It
+A request
+(other than
+.Dv PT_ATTACH )
+specified a process that was not stopped.
+.El
+.It Bq Er EPERM
+.Bl -bullet -compact
+.It
+A request
+(other than
+.Dv PT_ATTACH )
+attempted to manipulate a process that was not being traced at all.
+.It
+An attempt was made to use
+.Dv PT_ATTACH
+on a process in violation of the requirements listed under
+.Dv PT_ATTACH
+above.
+.El
+.It Bq Er ENOENT
+.Bl -bullet -compact
+.It
+.Dv PT_VM_ENTRY
+previously returned the last entry of the memory map.
+No more entries exist.
+.El
+.It Bq Er ENOMEM
+.Bl -bullet -compact
+.It
+A
+.Dv PT_READ_I,
+.Dv PT_READ_D,
+.Dv PT_WRITE_I, or
+.Dv PT_WRITE_D
+request attempted to access an invalid address, or a memory allocation failure
+occurred when accessing process memory.
+.El
+.It Bq Er ENAMETOOLONG
+.Bl -bullet -compact
+.It
+.Dv PT_VM_ENTRY
+cannot return the pathname of the backing object because the buffer is not big
+enough.
+.Fa pve_pathlen
+holds the minimum buffer size required on return.
+.El
+.El
+.Sh SEE ALSO
+.Xr execve 2 ,
+.Xr sigaction 2 ,
+.Xr wait 2 ,
+.Xr execv 3 ,
+.Xr i386_clr_watch 3 ,
+.Xr i386_set_watch 3
+.Sh HISTORY
+The
+.Fn ptrace
+function appeared in
+.At v6 .
diff --git a/lib/libsys/ptrace.c b/lib/libsys/ptrace.c
new file mode 100644
index 000000000000..65f2ee80d8ea
--- /dev/null
+++ b/lib/libsys/ptrace.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 The FreeBSD Foundation.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <errno.h>
+#include "libc_private.h"
+
+__weak_reference(_ptrace, ptrace);
+
+int
+_ptrace(int request, pid_t pid, caddr_t addr, int data)
+{
+
+ errno = 0;
+ return (__sys_ptrace(request, pid, addr, data));
+}
diff --git a/lib/libsys/quotactl.2 b/lib/libsys/quotactl.2
new file mode 100644
index 000000000000..4169d5ade4f6
--- /dev/null
+++ b/lib/libsys/quotactl.2
@@ -0,0 +1,260 @@
+.\" Copyright (c) 1983, 1990, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Robert Elz at The University of Melbourne.
+.\"
+.\" 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.
+.\"
+.Dd March 30, 2020
+.Dt QUOTACTL 2
+.Os
+.Sh NAME
+.Nm quotactl
+.Nd manipulate file system quotas
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In ufs/ufs/quota.h
+.Ft int
+.Fn quotactl "const char *path" "int cmd" "int id" "void *addr"
+.Sh DESCRIPTION
+The
+.Fn quotactl
+system call enables, disables and
+manipulates file system quotas.
+A quota control command
+given by
+.Fa cmd
+operates on the given filename
+.Fa path
+for the given user or group
+.Fa id .
+(NOTE: One should use the QCMD macro defined in
+.In ufs/ufs/quota.h
+to formulate the value for
+.Fa cmd . )
+The address of an optional command specific data structure,
+.Fa addr ,
+may be given; its interpretation
+is discussed below with each command.
+.Pp
+For commands that use the
+.Fa id
+identifier, it must be either -1 or any positive value.
+The value of -1 indicates that the current UID or GID should be used.
+Any other negative value will return an error.
+.Pp
+Currently quotas are supported only for the
+.Dq ufs
+file system.
+For
+.Dq ufs ,
+a command is composed of a primary command (see below)
+and a command type used to interpret the
+.Fa id .
+Types are supported for interpretation of user identifiers (USRQUOTA)
+and group identifiers (GRPQUOTA).
+The
+.Dq ufs
+specific commands are:
+.Bl -tag -width Q_GETQUOTASIZEx
+.It Dv Q_QUOTAON
+Enable disk quotas for the file system specified by
+.Fa path .
+The command type specifies the type of the quotas being enabled.
+The
+.Fa addr
+argument specifies a file from which to take the quotas.
+The quota file must exist;
+it is normally created with the
+.Xr quotacheck 8
+program.
+The
+.Fa id
+argument is unused.
+Only the super-user may turn quotas on.
+.It Dv Q_QUOTAOFF
+Disable disk quotas for the file system specified by
+.Fa path .
+The command type specifies the type of the quotas being disabled.
+The
+.Fa addr
+and
+.Fa id
+arguments are unused.
+Only the super-user may turn quotas off.
+.It Dv Q_GETQUOTASIZE
+Get the wordsize used to represent the quotas for the user or group
+(as determined by the command type).
+Possible values are 32 for the old-style quota file
+and 64 for the new-style quota file.
+The
+.Fa addr
+argument is a pointer to an integer into which the size is stored.
+The identifier
+.Fa id
+is not used.
+.It Dv Q_GETQUOTA
+Get disk quota limits and current usage for the user or group
+(as determined by the command type) with identifier
+.Fa id .
+The
+.Fa addr
+argument
+is a pointer to a
+.Fa struct dqblk
+structure (defined in
+.In ufs/ufs/quota.h ) .
+.It Dv Q_SETQUOTA
+Set disk quota limits for the user or group
+(as determined by the command type) with identifier
+.Fa id .
+The
+.Fa addr
+argument
+is a pointer to a
+.Fa struct dqblk
+structure (defined in
+.In ufs/ufs/quota.h ) .
+The usage fields of the
+.Fa dqblk
+structure are ignored.
+This system call is restricted to the super-user.
+.It Dv Q_SETUSE
+Set disk usage limits for the user or group
+(as determined by the command type) with identifier
+.Fa id .
+The
+.Fa addr
+argument
+is a pointer to a
+.Fa struct dqblk
+structure (defined in
+.In ufs/ufs/quota.h ) .
+Only the usage fields are used.
+This system call is restricted to the super-user.
+.It Dv Q_SYNC
+Update the on-disk copy of quota usages.
+The command type specifies which type of quotas are to be updated.
+The
+.Fa id
+and
+.Fa addr
+arguments are ignored.
+.El
+.Sh RETURN VALUES
+.Rv -std quotactl
+.Sh ERRORS
+The
+.Fn quotactl
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EOPNOTSUPP
+The kernel has not been compiled with the
+.Dv QUOTA
+option.
+.It Bq Er EUSERS
+The quota table cannot be expanded.
+.It Bq Er EINVAL
+The
+.Fa cmd
+argument
+or the command type is invalid.
+In
+.Dv Q_GETQUOTASIZE ,
+.Dv Q_GETQUOTA ,
+.Dv Q_SETQUOTA ,
+and
+.Dv Q_SETUSE ,
+quotas are not currently enabled for this file system.
+.Pp
+The
+.Fa id
+argument to
+.Dv Q_GETQUOTA ,
+.Dv Q_SETQUOTA
+or
+.Dv Q_SETUSE
+is a negative value.
+.It Bq Er EACCES
+In
+.Dv Q_QUOTAON ,
+the quota file is not a plain file.
+.It Bq Er EACCES
+Search permission is denied for a component of a path prefix.
+.It Bq Er ENOTDIR
+A component of a path prefix was not a directory.
+.It Bq Er ENAMETOOLONG
+A component of either pathname exceeded 255 characters,
+or the entire length of either path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A filename does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating a pathname.
+.It Bq Er EROFS
+In
+.Dv Q_QUOTAON ,
+either the file system on which quotas are to be enabled is mounted read-only
+or the quota file resides on a read-only file system.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing
+to a file containing quotas.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+An invalid
+.Fa addr
+was supplied; the associated structure could not be copied in or out
+of the kernel.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EPERM
+The call was privileged and the caller was not the super-user.
+.El
+.Sh SEE ALSO
+.Xr quota 1 ,
+.Xr fstab 5 ,
+.Xr edquota 8 ,
+.Xr quotacheck 8 ,
+.Xr quotaon 8 ,
+.Xr repquota 8
+.Sh HISTORY
+The
+.Fn quotactl
+system call appeared in
+.Bx 4.3 Reno .
+.Sh BUGS
+There should be some way to integrate this call with the resource
+limit interface provided by
+.Xr setrlimit 2
+and
+.Xr getrlimit 2 .
diff --git a/lib/libc/sys/rctl_add_rule.2 b/lib/libsys/rctl_add_rule.2
index 865c73a48a75..865c73a48a75 100644
--- a/lib/libc/sys/rctl_add_rule.2
+++ b/lib/libsys/rctl_add_rule.2
diff --git a/lib/libsys/read.2 b/lib/libsys/read.2
new file mode 100644
index 000000000000..4c0f3f5b3f1c
--- /dev/null
+++ b/lib/libsys/read.2
@@ -0,0 +1,319 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd March 1, 2024
+.Dt READ 2
+.Os
+.Sh NAME
+.Nm read ,
+.Nm readv ,
+.Nm pread ,
+.Nm preadv
+.Nd read input
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft ssize_t
+.Fn read "int fd" "void *buf" "size_t nbytes"
+.Ft ssize_t
+.Fn pread "int fd" "void *buf" "size_t nbytes" "off_t offset"
+.In sys/uio.h
+.Ft ssize_t
+.Fn readv "int fd" "const struct iovec *iov" "int iovcnt"
+.Ft ssize_t
+.Fn preadv "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset"
+.Sh DESCRIPTION
+The
+.Fn read
+system call
+attempts to read
+.Fa nbytes
+of data from the object referenced by the descriptor
+.Fa fd
+into the buffer pointed to by
+.Fa buf .
+The
+.Fn readv
+system call
+performs the same action, but scatters the input data
+into the
+.Fa iovcnt
+buffers specified by the members of the
+.Fa iov
+array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
+The
+.Fn pread
+and
+.Fn preadv
+system calls
+perform the same functions, but read from the specified position in
+the file without modifying the file pointer.
+.Pp
+For
+.Fn readv
+and
+.Fn preadv ,
+the
+.Fa iovec
+structure is defined as:
+.Pp
+.Bd -literal -offset indent -compact
+struct iovec {
+ void *iov_base; /* Base address. */
+ size_t iov_len; /* Length. */
+};
+.Ed
+.Pp
+Each
+.Fa iovec
+entry specifies the base address and length of an area
+in memory where data should be placed.
+The
+.Fn readv
+system call
+will always fill an area completely before proceeding
+to the next.
+.Pp
+On objects capable of seeking, the
+.Fn read
+starts at a position
+given by the pointer associated with
+.Fa fd
+(see
+.Xr lseek 2 ) .
+Upon return from
+.Fn read ,
+the pointer is incremented by the number of bytes actually read.
+.Pp
+Objects that are not capable of seeking always read from the current
+position.
+The value of the pointer associated with such an
+object is undefined.
+.Pp
+Upon successful completion,
+.Fn read ,
+.Fn readv ,
+.Fn pread
+and
+.Fn preadv
+return the number of bytes actually read and placed in the buffer.
+The system guarantees to read the number of bytes requested if
+the descriptor references a normal file that has that many bytes left
+before the end-of-file, but in no other case.
+.Pp
+In accordance with
+.St -p1003.1-2004 ,
+both
+.Fn read
+and
+.Fn write
+syscalls are atomic with respect to each other in the effects on file
+content, when they operate on regular files.
+If two threads each call one of the
+.Fn read
+or
+.Fn write ,
+syscalls, each call will see either all of the changes of the other call,
+or none of them.
+The
+.Fx
+kernel implements this guarantee by locking the file ranges affected by
+the calls.
+.Sh RETURN VALUES
+If successful, the
+number of bytes actually read is returned.
+Upon reading end-of-file,
+zero is returned.
+Otherwise, a -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn read ,
+.Fn readv ,
+.Fn pread
+and
+.Fn preadv
+system calls
+will succeed unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid file or socket descriptor open for reading.
+.It Bq Er ECONNRESET
+The
+.Fa fd
+argument refers to a socket, and the remote socket end is
+forcibly closed.
+.It Bq Er EFAULT
+The
+.Fa buf
+argument
+points outside the allocated address space.
+.It Bq Er EIO
+An I/O error occurred while reading from the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EBUSY
+Failed to read from a file, e.g. /proc/<pid>/regs while <pid> is not stopped
+.It Bq Er EINTR
+A read from a slow device
+(i.e.\& one that might block for an arbitrary amount of time)
+was interrupted by the delivery of a signal
+before any data arrived.
+.It Bq Er EINVAL
+The pointer associated with
+.Fa fd
+was negative.
+.It Bq Er EAGAIN
+The file was marked for non-blocking I/O,
+and no data were ready to be read.
+.It Bq Er EISDIR
+The file descriptor is associated with a directory.
+Directories may only be read directly by root if the filesystem supports it and
+the
+.Dv security.bsd.allow_read_dir
+sysctl MIB is set to a non-zero value.
+For most scenarios, the
+.Xr readdir 3
+function should be used instead.
+.It Bq Er EOPNOTSUPP
+The file descriptor is associated with a file system and file type that
+do not allow regular read operations on it.
+.It Bq Er EOVERFLOW
+The file descriptor is associated with a regular file,
+.Fa nbytes
+is greater than 0,
+.Fa offset
+is before the end-of-file, and
+.Fa offset
+is greater than or equal to the offset maximum established
+for this file system.
+.It Bq Er EINVAL
+The value
+.Fa nbytes
+is greater than
+.Dv SSIZE_MAX
+(or greater than
+.Dv INT_MAX ,
+if the sysctl
+.Va debug.iosize_max_clamp
+is non-zero).
+.El
+.Pp
+In addition,
+.Fn readv
+and
+.Fn preadv
+may return one of the following errors:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa iovcnt
+argument
+was less than or equal to 0, or greater than
+.Dv IOV_MAX .
+.It Bq Er EINVAL
+One of the
+.Fa iov_len
+values in the
+.Fa iov
+array was negative.
+.It Bq Er EINVAL
+The sum of the
+.Fa iov_len
+values in the
+.Fa iov
+array is greater than
+.Dv SSIZE_MAX
+(or greater than
+.Dv INT_MAX ,
+if the sysctl
+.Va debug.iosize_max_clamp
+is non-zero).
+.It Bq Er EFAULT
+Part of the
+.Fa iov
+array points outside the process's allocated address space.
+.El
+.Pp
+The
+.Fn pread
+and
+.Fn preadv
+system calls may also return the following errors:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa offset
+value was negative.
+.It Bq Er ESPIPE
+The file descriptor is associated with a pipe, socket, or FIFO.
+.El
+.Sh SEE ALSO
+.Xr dup 2 ,
+.Xr fcntl 2 ,
+.Xr getdirentries 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr select 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2 ,
+.Xr write 2 ,
+.Xr fread 3 ,
+.Xr readdir 3
+.Sh STANDARDS
+The
+.Fn read
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn readv
+and
+.Fn pread
+system calls are expected to conform to
+.St -xpg4.2 .
+.Sh HISTORY
+The
+.Fn preadv
+system call appeared in
+.Fx 6.0 .
+The
+.Fn pread
+function appeared in
+.At V.4 .
+The
+.Fn readv
+system call appeared in
+.Bx 4.2 .
+The
+.Fn read
+function appeared in
+.At v1 .
diff --git a/lib/libsys/readlink.2 b/lib/libsys/readlink.2
new file mode 100644
index 000000000000..9c3476697388
--- /dev/null
+++ b/lib/libsys/readlink.2
@@ -0,0 +1,158 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt READLINK 2
+.Os
+.Sh NAME
+.Nm readlink ,
+.Nm readlinkat
+.Nd read value of a symbolic link
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft ssize_t
+.Fn readlink "const char *restrict path" "char *restrict buf" "size_t bufsiz"
+.Ft ssize_t
+.Fo readlinkat
+.Fa "int fd" "const char *restrict path" "char *restrict buf" "size_t bufsize"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn readlink
+system call
+places the contents of the symbolic link
+.Fa path
+in the buffer
+.Fa buf ,
+which has size
+.Fa bufsiz .
+The
+.Fn readlink
+system call does not append a
+.Dv NUL
+character to
+.Fa buf .
+.Pp
+The
+.Fn readlinkat
+system call is equivalent to
+.Fn readlink
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the symbolic link whose content is read relative to the
+directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn readlinkat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn readlink .
+.Sh RETURN VALUES
+The call returns the count of characters placed in the buffer
+if it succeeds, or a \-1 if an error occurs, placing the error
+code in the global variable
+.Va errno .
+.Sh ERRORS
+The
+.Fn readlink
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EINVAL
+The named file is not a symbolic link.
+.It Bq Er EIO
+An I/O error occurred while reading from the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+The
+.Fa buf
+argument
+extends outside the process's allocated address space.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn readlink ,
+the
+.Fn readlinkat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr fhreadlink 2 ,
+.Xr lstat 2 ,
+.Xr stat 2 ,
+.Xr symlink 2 ,
+.Xr symlink 7
+.Sh STANDARDS
+The
+.Fn readlinkat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn readlink
+system call appeared in
+.Bx 4.2 .
+The
+.Fn readlinkat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/reboot.2 b/lib/libsys/reboot.2
new file mode 100644
index 000000000000..f6c7bf6c83cc
--- /dev/null
+++ b/lib/libsys/reboot.2
@@ -0,0 +1,162 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd July 10, 2018
+.Dt REBOOT 2
+.Os
+.Sh NAME
+.Nm reboot
+.Nd reboot system or halt processor
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.In sys/reboot.h
+.Ft int
+.Fn reboot "int howto"
+.Sh DESCRIPTION
+The
+.Fn reboot
+system call
+reboots the system.
+Only the super-user may reboot a machine on demand.
+However, a reboot is invoked
+automatically in the event of unrecoverable system failures.
+.Pp
+The
+.Fa howto
+argument
+is a mask of options; the system call interface allows the following
+options, defined in the include file
+.In sys/reboot.h ,
+to be passed
+to the new kernel or the new bootstrap and init programs.
+.Bl -tag -width RB_POWERCYCLE
+.It Dv RB_AUTOBOOT
+The default, causing the system to reboot in its usual fashion.
+.It Dv RB_ASKNAME
+Normally the system only prompts the user if the loader specified root
+file system has an error.
+This flag forces it to always prompt the user for the root partition.
+.It Dv RB_DFLTROOT
+Use the compiled in root device.
+Normally, the system uses the device from which it was booted
+as the root device if possible.
+(The default behavior is dependent on the ability of the bootstrap program
+to determine the drive from which it was loaded, which is not possible
+on all systems.)
+.It Dv RB_DUMP
+Dump kernel memory before rebooting; see
+.Xr savecore 8
+for more information.
+.It Dv RB_HALT
+The processor is simply halted; no reboot takes place.
+This option should be used with caution.
+.It Dv RB_POWERCYCLE
+After halting, the shutdown code will do what it can to turn
+off the power and then turn the power back on.
+This requires hardware support, usually an auxiliary microprocessor
+that can sequence the power supply.
+At present only the
+.Xr ipmi 4
+driver implements this feature.
+.It Dv RB_POWEROFF
+After halting, the shutdown code will do what it can to turn
+off the power.
+This requires hardware support.
+.It Dv RB_KDB
+Load the symbol table and enable a built-in debugger in the system.
+This option will have no useful function if the kernel is not configured
+for debugging.
+Several other options have different meaning if combined
+with this option, although their use may not be possible
+via the
+.Fn reboot
+system call.
+See
+.Xr ddb 4
+for more information.
+.It Dv RB_NOSYNC
+Normally, the disks are sync'd (see
+.Xr sync 8 )
+before the processor is halted or rebooted.
+This option may be useful if file system changes have been made manually
+or if the processor is on fire.
+.It Dv RB_REROOT
+Instead of rebooting, unmount all filesystems except the one containing
+currently-running executable, and mount root filesystem using the same
+mechanism which is used during normal boot, based on
+vfs.root.mountfrom
+.Xr kenv 1
+variable.
+.It Dv RB_RDONLY
+Initially mount the root file system read-only.
+This is currently the default, and this option has been deprecated.
+.It Dv RB_SINGLE
+Normally, the reboot procedure involves an automatic disk consistency
+check and then multi-user operations.
+.Dv RB_SINGLE
+prevents this, booting the system with a single-user shell
+on the console.
+.Dv RB_SINGLE
+is actually interpreted by the
+.Xr init 8
+program in the newly booted system.
+.El
+.Pp
+When no options are given (i.e.,
+.Dv RB_AUTOBOOT
+is used), the system is
+rebooted from file
+.Dq kernel
+in the root file system of unit 0
+of a disk chosen in a processor specific way.
+An automatic consistency check of the disks is normally performed
+(see
+.Xr fsck 8 ) .
+.Sh RETURN VALUES
+If successful, this call never returns.
+Otherwise, a -1 is returned and an error is returned in the global
+variable
+.Va errno .
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EPERM
+The caller is not the super-user.
+.El
+.Sh SEE ALSO
+.Xr crash 8 ,
+.Xr halt 8 ,
+.Xr init 8 ,
+.Xr reboot 8 ,
+.Xr savecore 8 ,
+.Xr reboot 9
+.Sh HISTORY
+The
+.Fn reboot
+system call appeared in
+.Bx 4.0 .
diff --git a/lib/libsys/recv.2 b/lib/libsys/recv.2
new file mode 100644
index 000000000000..b78cd70b8a1d
--- /dev/null
+++ b/lib/libsys/recv.2
@@ -0,0 +1,402 @@
+.\" Copyright (c) 1983, 1990, 1991, 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.
+.\"
+.Dd May 17, 2025
+.Dt RECV 2
+.Os
+.Sh NAME
+.Nm recv ,
+.Nm recvfrom ,
+.Nm recvmsg ,
+.Nm recvmmsg
+.Nd receive message(s) from a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft ssize_t
+.Fn recv "int s" "void *buf" "size_t len" "int flags"
+.Ft ssize_t
+.Fn recvfrom "int s" "void *buf" "size_t len" "int flags" "struct sockaddr * restrict from" "socklen_t * restrict fromlen"
+.Ft ssize_t
+.Fn recvmsg "int s" "struct msghdr *msg" "int flags"
+.Ft ssize_t
+.Fn recvmmsg "int s" "struct mmsghdr * restrict msgvec" "size_t vlen" "int flags" "const struct timespec * restrict timeout"
+.Sh DESCRIPTION
+The
+.Fn recvfrom ,
+.Fn recvmsg ,
+and
+.Fn recvmmsg
+system calls
+are used to receive messages from a socket,
+and may be used to receive data on a socket whether or not
+it is connection-oriented.
+.Pp
+If
+.Fa from
+is not a null pointer
+and the socket is not connection-oriented,
+the source address of the message is filled in.
+The
+.Fa fromlen
+argument
+is a value-result argument, initialized to the size of
+the buffer associated with
+.Fa from ,
+and modified on return to indicate the actual size of the
+address stored there.
+.Pp
+The
+.Fn recv
+function is normally used only on a
+.Em connected
+socket (see
+.Xr connect 2 )
+and is identical to
+.Fn recvfrom
+with a
+null pointer passed as its
+.Fa from
+argument.
+.Pp
+The
+.Fn recvmmsg
+function is used to receive multiple
+messages at a call.
+Their number is supplied by
+.Fa vlen .
+The messages are placed in the buffers described by
+.Fa msgvec
+vector, after reception.
+The size of each received message is placed in the
+.Fa msg_len
+field of each element of the vector.
+If
+.Fa timeout
+is NULL the call blocks until the data is available for each
+supplied message buffer.
+Otherwise it waits for data for the specified amount of time.
+If the timeout expired and there is no data received,
+a value 0 is returned.
+The
+.Xr ppoll 2
+system call is used to implement the timeout mechanism,
+before first receive is performed.
+.Pp
+The
+.Fn recv ,
+.Fn recvfrom
+and
+.Fn recvmsg
+return the length of the message on successful
+completion, whereas
+.Fn recvmmsg
+returns the number of received messages.
+If a message is too long to fit in the supplied buffer,
+excess bytes may be discarded depending on the type of socket
+the message is received from (see
+.Xr socket 2 ) .
+.Pp
+If no messages are available at the socket, the
+receive call waits for a message to arrive, unless
+the socket is non-blocking (see
+.Xr fcntl 2 )
+in which case the value
+\-1 is returned and the global variable
+.Va errno
+is set to
+.Er EAGAIN .
+The receive calls except
+.Fn recvmmsg
+normally return any data available,
+up to the requested amount,
+rather than waiting for receipt of the full amount requested;
+this behavior is affected by the socket-level options
+.Dv SO_RCVLOWAT
+and
+.Dv SO_RCVTIMEO
+described in
+.Xr getsockopt 2 .
+The
+.Fn recvmmsg
+function implements this behaviour for each message in the vector.
+.Pp
+The
+.Xr select 2
+system call may be used to determine when more data arrives.
+.Pp
+The
+.Fa flags
+argument to a
+.Fn recv
+function is formed by
+.Em or Ap ing
+one or more of the values:
+.Bl -column ".Dv MSG_CMSG_CLOEXEC" -offset indent
+.It Dv MSG_OOB Ta process out-of-band data
+.It Dv MSG_PEEK Ta peek at incoming message
+.It Dv MSG_TRUNC Ta return real packet or datagram length
+.It Dv MSG_WAITALL Ta wait for full request or error
+.It Dv MSG_DONTWAIT Ta do not block
+.It Dv MSG_CMSG_CLOEXEC Ta set received fds close-on-exec
+.It Dv MSG_CMSG_CLOFORK Ta set received fds close-on-fork
+.It Dv MSG_WAITFORONE Ta do not block after receiving the first message
+(only for
+.Fn recvmmsg
+)
+.El
+.Pp
+The
+.Dv MSG_OOB
+flag requests receipt of out-of-band data
+that would not be received in the normal data stream.
+Some protocols place expedited data at the head of the normal
+data queue, and thus this flag cannot be used with such protocols.
+The
+.Dv MSG_PEEK
+flag causes the receive operation to return data
+from the beginning of the receive queue without removing that
+data from the queue.
+Thus, a subsequent receive call will return the same data.
+The
+.Dv MSG_TRUNC
+flag causes the receive operation to return the full length of the packet
+or datagram even if larger than provided buffer. The flag is supported
+on SOCK_DGRAM sockets for
+.Dv AF_INET
+,
+.Dv AF_INET6
+and
+.Dv AF_UNIX
+families.
+The
+.Dv MSG_WAITALL
+flag requests that the operation block until
+the full request is satisfied.
+However, the call may still return less data than requested
+if a signal is caught, an error or disconnect occurs,
+or the next data to be received is of a different type than that returned.
+The
+.Dv MSG_DONTWAIT
+flag requests the call to return when it would block otherwise.
+If no data is available,
+.Va errno
+is set to
+.Er EAGAIN .
+This flag is not available in
+.St -ansiC
+or
+.St -isoC-99
+compilation mode.
+The
+.Dv MSG_WAITFORONE
+flag sets MSG_DONTWAIT after the first message has been received.
+This flag is only relevant for
+.Fn recvmmsg .
+.Pp
+The
+.Fn recvmsg
+system call uses a
+.Fa msghdr
+structure to minimize the number of directly supplied arguments.
+This structure has the following form, as defined in
+.In sys/socket.h :
+.Bd -literal
+struct msghdr {
+ void *msg_name; /* optional address */
+ socklen_t msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ void *msg_control; /* ancillary data, see below */
+ socklen_t msg_controllen;/* ancillary data buffer len */
+ int msg_flags; /* flags on received message */
+};
+.Ed
+.Pp
+Here
+.Fa msg_name
+and
+.Fa msg_namelen
+specify the source address if the socket is unconnected;
+.Fa msg_name
+may be given as a null pointer if no names are desired or required.
+The
+.Fa msg_iov
+and
+.Fa msg_iovlen
+arguments
+describe scatter gather locations, as discussed in
+.Xr read 2 .
+The
+.Fa msg_control
+argument,
+which has length
+.Fa msg_controllen ,
+points to a buffer for other protocol control related messages
+or other miscellaneous ancillary data.
+The messages are of the form:
+.Bd -literal
+struct cmsghdr {
+ socklen_t cmsg_len; /* data byte count, including hdr */
+ int cmsg_level; /* originating protocol */
+ int cmsg_type; /* protocol-specific type */
+/* followed by
+ u_char cmsg_data[]; */
+};
+.Ed
+.Pp
+As an example, the SO_TIMESTAMP socket option returns a reception
+timestamp for UDP packets.
+.Pp
+With
+.Dv AF_UNIX
+domain sockets, ancillary data can be used to pass file descriptors and
+process credentials.
+See
+.Xr unix 4
+for details.
+.Pp
+The
+.Fa msg_flags
+field is set on return according to the message received.
+.Dv MSG_EOR
+indicates end-of-record;
+the data returned completed a record (generally used with sockets of type
+.Dv SOCK_SEQPACKET ) .
+.Dv MSG_TRUNC
+indicates that
+the trailing portion of a datagram was discarded because the datagram
+was larger than the buffer supplied.
+.Dv MSG_CTRUNC
+indicates that some
+control data were discarded due to lack of space in the buffer
+for ancillary data.
+.Dv MSG_OOB
+is returned to indicate that expedited or out-of-band data were received.
+.Pp
+The
+.Fn recvmmsg
+system call uses the
+.Fa mmsghdr
+structure, defined as follows in the
+.In sys/socket.h
+header:
+.Bd -literal
+struct mmsghdr {
+ struct msghdr msg_hdr; /* message header */
+ ssize_t msg_len; /* message length */
+};
+.Ed
+.Pp
+On data reception the
+.Fa msg_len
+field is updated to the length of the received message.
+.Sh RETURN VALUES
+On successful completion, the
+.Fn recv ,
+.Fn recvfrom ,
+and
+.Fn recvmsg
+functions return the number of bytes received, while the
+.Fn recvmmsg
+function returns the number of messages received.
+If no messages are available to be received and the peer has
+performed an orderly shutdown, 0 is returned.
+Otherwise, -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The calls fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The argument
+.Fa s
+is an invalid descriptor.
+.It Bq Er ECONNRESET
+The remote socket end is forcibly closed.
+.It Bq Er ENOTCONN
+The socket is associated with a connection-oriented protocol
+and has not been connected (see
+.Xr connect 2
+and
+.Xr accept 2 ) .
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+does not refer to a socket.
+.It Bq Er EMFILE
+The
+.Fn recvmsg
+system call
+was used to receive rights (file descriptors) that were in flight on the
+connection.
+However, the receiving program did not have enough free file
+descriptor slots to accept them.
+In this case the descriptors are closed, with pending data either discarded
+in the case of the unreliable datagram protocol or preserved in the case of a
+reliable protocol.
+The pending data can be retrieved with another call to
+.Fn recvmsg .
+.It Bq Er EMSGSIZE
+The
+.Fa msg_iovlen
+member of the
+.Fa msghdr
+structure pointed to by
+.Fa msg
+is less than or equal to 0, or is greater than
+.Va IOV_MAX .
+.It Bq Er EAGAIN
+The socket is marked non-blocking and the receive operation
+would block, or
+a receive timeout had been set
+and the timeout expired before data were received.
+.It Bq Er EINTR
+The receive was interrupted by delivery of a signal before
+any data were available.
+.It Bq Er EFAULT
+The receive buffer pointer(s) point outside the process's
+address space.
+.El
+.Sh SEE ALSO
+.Xr fcntl 2 ,
+.Xr getsockopt 2 ,
+.Xr read 2 ,
+.Xr select 2 ,
+.Xr socket 2 ,
+.Xr CMSG_DATA 3 ,
+.Xr unix 4
+.Sh HISTORY
+The
+.Fn recv
+function appeared in
+.Bx 4.2 .
+The
+.Fn recvmmsg
+function appeared in
+.Fx 11.0 .
diff --git a/lib/libsys/recvmmsg.c b/lib/libsys/recvmmsg.c
new file mode 100644
index 000000000000..c03fe98c37ef
--- /dev/null
+++ b/lib/libsys/recvmmsg.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2016 Boris Astardzhiev, Smartcom-Bulgaria AD
+ * 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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <errno.h>
+#include <poll.h>
+#include <stddef.h>
+#include <ssp/ssp.h>
+#include "libc_private.h"
+
+ssize_t
+__ssp_real(recvmmsg)(int s, struct mmsghdr *__restrict msgvec, size_t vlen,
+ int flags, const struct timespec *__restrict timeout)
+{
+ struct pollfd pfd[1];
+ size_t i, rcvd;
+ ssize_t ret;
+ int res;
+ short ev;
+
+ if (timeout != NULL) {
+ pfd[0].fd = s;
+ pfd[0].revents = 0;
+ pfd[0].events = ev = POLLIN | POLLRDNORM | POLLRDBAND |
+ POLLPRI;
+ res = ppoll(&pfd[0], 1, timeout, NULL);
+ if (res == -1 || res == 0)
+ return (res);
+ if (pfd[0].revents & POLLNVAL) {
+ errno = EBADF;
+ return (-1);
+ }
+ if ((pfd[0].revents & ev) == 0) {
+ errno = ETIMEDOUT;
+ return (-1);
+ }
+ }
+
+ ret = __sys_recvmsg(s, &msgvec[0].msg_hdr, flags);
+ if (ret == -1)
+ return (ret);
+
+ msgvec[0].msg_len = ret;
+
+ /*
+ * Do non-blocking receive for second and later messages if
+ * WAITFORONE is set.
+ */
+ if (flags & MSG_WAITFORONE)
+ flags |= MSG_DONTWAIT;
+
+ rcvd = 1;
+ for (i = rcvd; i < vlen; i++, rcvd++) {
+ ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags);
+ if (ret == -1) {
+ /* We have received messages. Let caller know
+ * about the data received, socket error is
+ * returned on next invocation.
+ */
+ return (rcvd);
+ }
+
+ /* Save received bytes. */
+ msgvec[i].msg_len = ret;
+ }
+
+ return (rcvd);
+}
diff --git a/lib/libsys/rename.2 b/lib/libsys/rename.2
new file mode 100644
index 000000000000..4faba81ff509
--- /dev/null
+++ b/lib/libsys/rename.2
@@ -0,0 +1,343 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd August 25, 2024
+.Dt RENAME 2
+.Os
+.Sh NAME
+.Nm rename
+.Nd change the name of a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdio.h
+.Ft int
+.Fn rename "const char *from" "const char *to"
+.Ft int
+.Fn renameat "int fromfd" "const char *from" "int tofd" "const char *to"
+.Sh DESCRIPTION
+The
+.Fn rename
+system call
+causes the link named
+.Fa from
+to be renamed as
+.Fa to .
+If
+.Fa to
+exists, it is first removed.
+Both
+.Fa from
+and
+.Fa to
+must be of the same type (that is, both directories or both
+non-directories), and must reside on the same file system.
+.Pp
+The
+.Fn rename
+system call
+guarantees that if
+.Fa to
+already exists, an instance of
+.Fa to
+will always exist, even if the system should crash in
+the middle of the operation.
+.Pp
+If the final component of
+.Fa from
+is a symbolic link,
+the symbolic link is renamed,
+not the file or directory to which it points.
+.Pp
+If
+.Fa from
+and
+.Fa to
+resolve to the same directory entry, or to different directory
+entries for the same existing file,
+.Fn rename
+returns success without taking any further action.
+.Pp
+The
+.Fn renameat
+system call is equivalent to
+.Fn rename
+except in the case where either
+.Fa from
+or
+.Fa to
+specifies a relative path.
+If
+.Fa from
+is a relative path, the file to be renamed is located
+relative to the directory associated with the file descriptor
+.Fa fromfd
+instead of the current working directory.
+If the
+.Fa to
+is a relative path, the same happens only relative to the directory associated
+with
+.Fa tofd .
+If the
+.Fn renameat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fromfd
+or
+.Fa tofd
+parameter, the current working directory is used in the determination
+of the file for the respective path parameter.
+.\".Sh CAVEAT
+.\"The system can deadlock if a loop in the file system graph is present.
+.\"This loop takes the form of an entry in directory
+.\".Pa a ,
+.\"say
+.\".Pa a/foo ,
+.\"being a hard link to directory
+.\".Pa b ,
+.\"and an entry in
+.\"directory
+.\".Pa b ,
+.\"say
+.\".Pa b/bar ,
+.\"being a hard link
+.\"to directory
+.\".Pa a .
+.\"When such a loop exists and two separate processes attempt to
+.\"perform
+.\".Ql rename a/foo b/bar
+.\"and
+.\".Ql rename b/bar a/foo ,
+.\"respectively,
+.\"the system may deadlock attempting to lock
+.\"both directories for modification.
+.\"Hard links to directories should be
+.\"replaced by symbolic links by the system administrator.
+.Sh RETURN VALUES
+.Rv -std rename
+.Sh ERRORS
+The
+.Fn rename
+system call
+will fail and neither of the argument files will be
+affected if:
+.Bl -tag -width Er
+.It Bq Er ENAMETOOLONG
+A component of either pathname exceeded 255 characters,
+or the entire length of either path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of the
+.Fa from
+path does not exist,
+or a path prefix of
+.Fa to
+does not exist.
+.It Bq Er EACCES
+A component of either path prefix denies search permission.
+.It Bq Er EACCES
+The requested link requires writing in a directory with a mode
+that denies write permission.
+.It Bq Er EACCES
+The directory pointed at by the
+.Fa from
+argument denies write permission, and the operation would move
+it to another parent directory.
+.It Bq Er EPERM
+The file pointed at by the
+.Fa from
+argument has its immutable, undeletable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EPERM
+The parent directory of the file pointed at by the
+.Fa from
+argument has its immutable or append-only flag set.
+.It Bq Er EPERM
+The parent directory of the file pointed at by the
+.Fa to
+argument has its immutable flag set.
+.It Bq Er EPERM
+The directory containing
+.Fa from
+is marked sticky,
+and neither the containing directory nor
+.Fa from
+are owned by the effective user ID.
+.It Bq Er EPERM
+The file pointed at by the
+.Fa to
+argument
+exists,
+the directory containing
+.Fa to
+is marked sticky,
+and neither the containing directory nor
+.Fa to
+are owned by the effective user ID.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating either pathname.
+.It Bq Er ENOTDIR
+A component of either path prefix is not a directory.
+.It Bq Er ENOTDIR
+The
+.Fa from
+argument
+is a directory, but
+.Fa to
+is not a directory.
+.It Bq Er EISDIR
+The
+.Fa to
+argument
+is a directory, but
+.Fa from
+is not a directory.
+.It Bq Er EXDEV
+The link named by
+.Fa to
+and the file named by
+.Fa from
+are on different logical devices (file systems).
+Note that this error
+code will not be returned if the implementation permits cross-device
+links.
+.It Bq Er ENOSPC
+The directory in which the entry for the new name is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er EDQUOT
+The directory in which the entry for the new name
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EIO
+An I/O error occurred while making or updating a directory entry.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The requested link requires writing in a directory on a read-only file
+system.
+.It Bq Er EFAULT
+Path
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The
+.Fa from
+argument
+is a parent directory of
+.Fa to ,
+or an attempt is made to rename
+.Ql .\&
+or
+.Ql \&.. .
+.It Bq Er EINVAL
+The last component of the
+.Fa to
+path is invalid on the target file system.
+.It Bq Er ENOTEMPTY
+The
+.Fa to
+argument
+is a directory and is not empty.
+.It Bq Er ECAPMODE
+.Fn rename
+was called and the process is in capability mode.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn rename ,
+the
+.Fn renameat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa from
+argument does not specify an absolute path and the
+.Fa fromfd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching, or the
+.Fa to
+argument does not specify an absolute path and the
+.Fa tofd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa from
+argument is not an absolute path and
+.Fa fromfd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory, or the
+.Fa to
+argument is not an absolute path and
+.Fa tofd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ECAPMODE
+.Dv AT_FDCWD
+is specified and the process is in capability mode.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path or contained a ".." component leading to a directory
+outside of the directory hierarchy specified by
+.Fa fromfd
+or
+.Fa tofd .
+.It Bq Er ENOTCAPABLE
+The
+.Fa fromfd
+file descriptor lacks the
+.Dv CAP_RENAMEAT_SOURCE
+right, or the
+.Fa tofd
+file descriptor lacks the
+.Dv CAP_RENAMEAT_TARGET
+right.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr open 2 ,
+.Xr symlink 7
+.Sh STANDARDS
+The
+.Fn rename
+system call is expected to conform to
+.St -p1003.1-96 .
+The
+.Fn renameat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn renameat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/revoke.2 b/lib/libsys/revoke.2
new file mode 100644
index 000000000000..f5ae1e92c357
--- /dev/null
+++ b/lib/libsys/revoke.2
@@ -0,0 +1,107 @@
+.\" Copyright (c) 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Berkeley Software Design, 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.
+.\"
+.Dd January 25, 2016
+.Dt REVOKE 2
+.Os
+.Sh NAME
+.Nm revoke
+.Nd revoke file access
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn revoke "const char *path"
+.Sh DESCRIPTION
+The
+.Fn revoke
+system call invalidates all current open file descriptors in the system
+for the file named by
+.Fa path .
+Subsequent operations on any such descriptors
+fail, with the exceptions that a
+.Fn read
+from a character device file which has been revoked
+returns a count of zero (end of file),
+and a
+.Fn close
+system call will succeed.
+If the file is a special file for a device which is open,
+the device close function
+is called as if all open references to the file had been closed
+using a special close method which does not block.
+.Pp
+Access to a file may be revoked only by its owner or the super user.
+The
+.Fn revoke
+system call is currently supported only for block and character special
+device files.
+It is normally used to prepare a terminal device for a new login session,
+preventing any access by a previous user of the terminal.
+.Sh RETURN VALUES
+.Rv -std revoke
+.Sh ERRORS
+Access to the named file is revoked unless one of the following:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1024 characters.
+.It Bq Er ENOENT
+The named file or a component of the path name does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The implementation does not support the
+.Fn revoke
+operation on the named file.
+.It Bq Er EPERM
+The caller is neither the owner of the file nor the super user.
+.El
+.Sh SEE ALSO
+.Xr revoke 1 ,
+.Xr close 2
+.Sh HISTORY
+The
+.Fn revoke
+system call first appeared in
+.Bx 4.3 Reno .
+.Sh BUGS
+The non-blocking close method is only correctly implemented for
+terminal devices.
diff --git a/lib/libc/sys/rfork.2 b/lib/libsys/rfork.2
index 649b2acae6ce..649b2acae6ce 100644
--- a/lib/libc/sys/rfork.2
+++ b/lib/libsys/rfork.2
diff --git a/lib/libc/gen/rfork_thread.3 b/lib/libsys/rfork_thread.3
index 0ade53b8afb6..0ade53b8afb6 100644
--- a/lib/libc/gen/rfork_thread.3
+++ b/lib/libsys/rfork_thread.3
diff --git a/lib/libsys/riscv/Makefile.sys b/lib/libsys/riscv/Makefile.sys
new file mode 100644
index 000000000000..2ff84735f484
--- /dev/null
+++ b/lib/libsys/riscv/Makefile.sys
@@ -0,0 +1,5 @@
+SRCS+= __vdso_gettc.c \
+ sched_getcpu_gen.c
+
+MDASM= cerror.S \
+ vfork.S
diff --git a/lib/libsys/riscv/SYS.h b/lib/libsys/riscv/SYS.h
new file mode 100644
index 000000000000..c2d93c567e2b
--- /dev/null
+++ b/lib/libsys/riscv/SYS.h
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2014 Andrew Turner
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * Portions of this software were developed by SRI International and the
+ * University of Cambridge Computer Laboratory under DARPA/AFRL contract
+ * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * Portions of this software were developed by the University of Cambridge
+ * Computer Laboratory as part of the CTSRD Project, with support from the
+ * UK Higher Education Innovation Fund (HEIF).
+ *
+ * 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.
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#define _SYSCALL(name) \
+ li t0, SYS_ ## name; \
+ ecall
+
+#ifndef _SYSCALL_BODY
+#define _SYSCALL_BODY(name) \
+ _SYSCALL(name); \
+ bnez t0, 1f; \
+ ret; \
+1: la t1, cerror; \
+ jr t1
+#endif
+
+#define PSEUDO(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
+
+#define RSYSCALL(name) \
+ENTRY(__sys_##name); \
+ WEAK_REFERENCE(__sys_##name, name); \
+ WEAK_REFERENCE(__sys_##name, _##name); \
+ _SYSCALL_BODY(name); \
+END(__sys_##name)
diff --git a/lib/libsys/riscv/__vdso_gettc.c b/lib/libsys/riscv/__vdso_gettc.c
new file mode 100644
index 000000000000..5037debef461
--- /dev/null
+++ b/lib/libsys/riscv/__vdso_gettc.c
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 2021 Jessica Clarke
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+
+#include <machine/riscvreg.h>
+
+#include <errno.h>
+
+#include "libc_private.h"
+
+#pragma weak __vdso_gettc
+int
+__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+ if (th->th_algo != VDSO_TH_ALGO_RISCV_RDTIME)
+ return (ENOSYS);
+
+ *tc = csr_read(time);
+ return (0);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libc/riscv/sys/cerror.S b/lib/libsys/riscv/cerror.S
index 34129b1ac8be..34129b1ac8be 100644
--- a/lib/libc/riscv/sys/cerror.S
+++ b/lib/libsys/riscv/cerror.S
diff --git a/lib/libc/riscv/sys/vfork.S b/lib/libsys/riscv/vfork.S
index 62c890badbb8..62c890badbb8 100644
--- a/lib/libc/riscv/sys/vfork.S
+++ b/lib/libsys/riscv/vfork.S
diff --git a/lib/libsys/rmdir.2 b/lib/libsys/rmdir.2
new file mode 100644
index 000000000000..6efeb8f4856f
--- /dev/null
+++ b/lib/libsys/rmdir.2
@@ -0,0 +1,117 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt RMDIR 2
+.Os
+.Sh NAME
+.Nm rmdir
+.Nd remove a directory file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn rmdir "const char *path"
+.Sh DESCRIPTION
+The
+.Fn rmdir
+system call
+removes a directory file
+whose name is given by
+.Fa path .
+The directory must not have any entries other
+than
+.Ql .\&
+and
+.Ql \&.. .
+.Sh RETURN VALUES
+.Rv -std rmdir
+.Sh ERRORS
+The named file is removed unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named directory does not exist.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENOTEMPTY
+The named directory contains files other than
+.Ql .\&
+and
+.Ql ..\&
+in it.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+Write permission is denied on the directory containing the link
+to be removed.
+.It Bq Er EPERM
+The directory to be removed has its immutable, undeletable or append-only flag
+set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EPERM
+The parent directory of the directory to be removed has its immutable or
+append-only flag set.
+.It Bq Er EPERM
+The directory containing the directory to be removed is marked sticky,
+and neither the containing directory nor the directory to be removed
+are owned by the effective user ID.
+.It Bq Er EINVAL
+The last component of the path is
+.Ql .\&
+or
+.Ql .. .
+.It Bq Er EBUSY
+The directory to be removed is the mount point
+for a mounted file system.
+.It Bq Er EIO
+An I/O error occurred while deleting the directory entry
+or deallocating the inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The directory entry to be removed resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.El
+.Sh SEE ALSO
+.Xr mkdir 2 ,
+.Xr unlink 2
+.Sh HISTORY
+The
+.Fn rmdir
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libc/sys/rtprio.2 b/lib/libsys/rtprio.2
index 011ec58d3259..011ec58d3259 100644
--- a/lib/libc/sys/rtprio.2
+++ b/lib/libsys/rtprio.2
diff --git a/lib/libc/sys/sched_get_priority_max.2 b/lib/libsys/sched_get_priority_max.2
index 81cd502469dc..81cd502469dc 100644
--- a/lib/libc/sys/sched_get_priority_max.2
+++ b/lib/libsys/sched_get_priority_max.2
diff --git a/lib/libsys/sched_getcpu.3 b/lib/libsys/sched_getcpu.3
new file mode 100644
index 000000000000..050a8f3facb4
--- /dev/null
+++ b/lib/libsys/sched_getcpu.3
@@ -0,0 +1,51 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by Ed Maste <emaste@FreeBSD.org>
+.\" under sponsorship from the FreeBSD Foundation.
+.\"
+.Dd November 13, 2024
+.Dt SCHED_GETCPU 3
+.Os
+.Sh NAME
+.Nm sched_getcpu
+.Nd get current CPU
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sched.h
+.Ft int
+.Fn sched_getcpu void
+.Sh DESCRIPTION
+The
+.Fn sched_getcpu
+function returns the current CPU on which the calling thread is running.
+.Sh RETURN VALUES
+.Fn sched_getcpu
+returns the 0-based index of the current CPU at the time of the call.
+The value may become invalid immediately after return, unless the thread is
+pinned to a specific CPU.
+CPU numbering is the same as used by
+.Xr cpuset 2
+and CPU affinity calls.
+.Pp
+There are no error values as
+.Fn sched_getcpu
+does not fail.
+.Sh SEE ALSO
+.Xr cpuset 2 ,
+.Xr cpuset_getaffinity 2 ,
+.Xr cpuset_setaffinity 2 ,
+.Xr pthread_getaffinity_np 3 ,
+.Xr pthread_setaffinity_np
+.Sh STANDARDS
+The
+.Nm
+function originated in Linux.
+This implementation aims to be source-compatible with the Linux implementation.
+.Sh HISTORY
+The
+.Nm
+function was introduced in
+.Fx 13.1 .
diff --git a/lib/libc/gen/sched_getcpu_gen.c b/lib/libsys/sched_getcpu_gen.c
index ef1bebc2915a..ef1bebc2915a 100644
--- a/lib/libc/gen/sched_getcpu_gen.c
+++ b/lib/libsys/sched_getcpu_gen.c
diff --git a/lib/libc/sys/sched_setparam.2 b/lib/libsys/sched_setparam.2
index 68b07509ce83..68b07509ce83 100644
--- a/lib/libc/sys/sched_setparam.2
+++ b/lib/libsys/sched_setparam.2
diff --git a/lib/libc/sys/sched_setscheduler.2 b/lib/libsys/sched_setscheduler.2
index f4ddbf7feb03..f4ddbf7feb03 100644
--- a/lib/libc/sys/sched_setscheduler.2
+++ b/lib/libsys/sched_setscheduler.2
diff --git a/lib/libc/sys/sched_yield.2 b/lib/libsys/sched_yield.2
index 61753757a7bf..61753757a7bf 100644
--- a/lib/libc/sys/sched_yield.2
+++ b/lib/libsys/sched_yield.2
diff --git a/lib/libc/sys/sctp_generic_recvmsg.2 b/lib/libsys/sctp_generic_recvmsg.2
index 124a1b7dc956..124a1b7dc956 100644
--- a/lib/libc/sys/sctp_generic_recvmsg.2
+++ b/lib/libsys/sctp_generic_recvmsg.2
diff --git a/lib/libsys/sctp_generic_sendmsg.2 b/lib/libsys/sctp_generic_sendmsg.2
new file mode 100644
index 000000000000..66ce41ee2fcb
--- /dev/null
+++ b/lib/libsys/sctp_generic_sendmsg.2
@@ -0,0 +1,84 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd October 30, 2007
+.Dt SCTP_GENERIC_SENDMSG 2
+.Os
+.Sh NAME
+.Nm sctp_generic_sendmsg ,
+.Nm sctp_generic_sendmsg_iov
+.Nd send data to a peer
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.In netinet/sctp.h
+.Ft int
+.Fn sctp_generic_sendmsg "int s" "void *msg" "int msglen" "struct sockaddr *to" "socklen_t len" "struct sctp_sndrcvinfo *sinfo" "int flags"
+.Ft int
+.Fn sctp_generic_sendmsg_iov "int s" "struct iovec *iov" "int iovlen" "struct sockaddr *to" "struct sctp_sndrcvinfo *sinfo" "int flags"
+.Sh DESCRIPTION
+.Fn sctp_generic_sendmsg
+and
+.Fn sctp_generic_sendmsg_iov
+are the true system calls used by the
+.Xr sctp_sendmsg 3
+and
+.Xr sctp_send 3
+function calls.
+These are more efficient since they are
+true system calls but they are specific to
+.Fx
+and can be expected
+.Em not
+to be present on any other operating
+system.
+For detailed usage please see either the
+.Xr sctp_send 3
+or
+.Xr sctp_sendmsg 3
+function calls.
+.Sh RETURN VALUES
+The call returns the number of bytes written on success and -1 upon failure.
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EBADF
+The argument
+.Fa s
+is not a valid descriptor.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is not a socket.
+.El
+.Sh SEE ALSO
+.Xr sctp_send 3 ,
+.Xr sctp_sendmsg 3 ,
+.Xr sctp_sendmsgx 3 ,
+.Xr sctp_sendx 3 ,
+.Xr sctp 4
diff --git a/lib/libsys/sctp_peeloff.2 b/lib/libsys/sctp_peeloff.2
new file mode 100644
index 000000000000..f31282e555db
--- /dev/null
+++ b/lib/libsys/sctp_peeloff.2
@@ -0,0 +1,78 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd February 2, 2024
+.Dt SCTP_PEELOFF 2
+.Os
+.Sh NAME
+.Nm sctp_peeloff
+.Nd detach an association from a one-to-many socket to its own fd
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.In netinet/sctp.h
+.Ft int
+.Fn sctp_peeloff "int s" "sctp_assoc_t id"
+.Sh DESCRIPTION
+The
+.Fn sctp_peeloff
+system call attempts detach the association specified by
+.Fa id
+into its own separate socket.
+.Sh RETURN VALUES
+The call returns -1 on failure and the new socket descriptor
+upon success.
+.Sh ERRORS
+The
+.Fn sctp_peeloff
+system call can return the following errors:
+.Bl -tag -width Er
+.It Bq Er ENOTCONN
+The
+.Fa id
+given to the call does not map to a valid
+association.
+.It Bq Er E2BIG
+The size of the address list exceeds the amount of
+data provided.
+.It Bq Er EBADF
+The argument
+.Fa s
+is not a valid descriptor.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is not a socket.
+.El
+.Sh SEE ALSO
+.Xr sctp 4
+.Sh STANDARDS
+The
+.Fn sctp_peeloff
+function conforms to RFC 6458.
diff --git a/lib/libsys/select.2 b/lib/libsys/select.2
new file mode 100644
index 000000000000..f79971a5876f
--- /dev/null
+++ b/lib/libsys/select.2
@@ -0,0 +1,225 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd June 25, 2020
+.Dt SELECT 2
+.Os
+.Sh NAME
+.Nm select
+.Nd synchronous I/O multiplexing
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/select.h
+.Ft int
+.Fn select "int nfds" "fd_set *readfds" "fd_set *writefds" "fd_set *exceptfds" "struct timeval *timeout"
+.Fn FD_SET fd &fdset
+.Fn FD_CLR fd &fdset
+.Fn FD_ISSET fd &fdset
+.Fn FD_ZERO &fdset
+.Sh DESCRIPTION
+The
+.Fn select
+system call
+examines the I/O descriptor sets whose addresses are passed in
+.Fa readfds ,
+.Fa writefds ,
+and
+.Fa exceptfds
+to see if some of their descriptors
+are ready for reading, are ready for writing, or have an exceptional
+condition pending, respectively.
+The only exceptional condition detectable is out-of-band
+data received on a socket.
+The first
+.Fa nfds
+descriptors are checked in each set;
+i.e., the descriptors from 0 through
+.Fa nfds Ns No -1
+in the descriptor sets are examined.
+On return,
+.Fn select
+replaces the given descriptor sets
+with subsets consisting of those descriptors that are ready
+for the requested operation.
+The
+.Fn select
+system call
+returns the total number of ready descriptors in all the sets.
+.Pp
+The descriptor sets are stored as bit fields in arrays of integers.
+The following macros are provided for manipulating such descriptor sets:
+.Fn FD_ZERO &fdset
+initializes a descriptor set
+.Fa fdset
+to the null set.
+.Fn FD_SET fd &fdset
+includes a particular descriptor
+.Fa fd
+in
+.Fa fdset .
+.Fn FD_CLR fd &fdset
+removes
+.Fa fd
+from
+.Fa fdset .
+.Fn FD_ISSET fd &fdset
+is non-zero if
+.Fa fd
+is a member of
+.Fa fdset ,
+zero otherwise.
+The behavior of these macros is undefined if
+a descriptor value is less than zero or greater than or equal to
+.Dv FD_SETSIZE ,
+which is normally at least equal
+to the maximum number of descriptors supported by the system.
+.Pp
+If
+.Fa timeout
+is not a null pointer, it specifies the maximum interval to wait for the
+selection to complete.
+System activity can lengthen the interval by
+an indeterminate amount.
+.Pp
+If
+.Fa timeout
+is a null pointer, the select blocks indefinitely.
+.Pp
+To effect a poll, the
+.Fa timeout
+argument should not be a null pointer,
+but it should point to a zero-valued timeval structure.
+.Pp
+Any of
+.Fa readfds ,
+.Fa writefds ,
+and
+.Fa exceptfds
+may be given as null pointers if no descriptors are of interest.
+.Sh RETURN VALUES
+The
+.Fn select
+system call
+returns the number of ready descriptors that are contained in
+the descriptor sets,
+or -1 if an error occurred.
+If the time limit expires,
+.Fn select
+returns 0.
+If
+.Fn select
+returns with an error,
+including one due to an interrupted system call,
+the descriptor sets will be unmodified.
+.Sh ERRORS
+An error return from
+.Fn select
+indicates:
+.Bl -tag -width Er
+.It Bq Er EBADF
+One of the descriptor sets specified an invalid descriptor.
+.It Bq Er EFAULT
+One of the arguments
+.Fa readfds , writefds , exceptfds ,
+or
+.Fa timeout
+points to an invalid address.
+.It Bq Er EINTR
+A signal was delivered before the time limit expired and
+before any of the selected events occurred.
+.It Bq Er EINVAL
+The specified time limit is invalid.
+One of its components is
+negative or too large.
+.It Bq Er EINVAL
+The
+.Fa nfds
+argument
+was invalid.
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr connect 2 ,
+.Xr getdtablesize 2 ,
+.Xr gettimeofday 2 ,
+.Xr kqueue 2 ,
+.Xr poll 2 ,
+.Xr pselect 2 ,
+.Xr read 2 ,
+.Xr recv 2 ,
+.Xr send 2 ,
+.Xr write 2 ,
+.Xr clocks 7
+.Sh NOTES
+The default size of
+.Dv FD_SETSIZE
+is currently 1024.
+In order to accommodate programs which might potentially
+use a larger number of open files with
+.Fn select ,
+it is possible
+to increase this size by having the program define
+.Dv FD_SETSIZE
+before the inclusion of any header which includes
+.In sys/types.h .
+.Pp
+If
+.Fa nfds
+is greater than the number of open files,
+.Fn select
+is not guaranteed to examine the unused file descriptors.
+For historical
+reasons,
+.Fn select
+will always examine the first 256 descriptors.
+.Sh STANDARDS
+The
+.Fn select
+system call and
+.Fn FD_CLR ,
+.Fn FD_ISSET ,
+.Fn FD_SET ,
+and
+.Fn FD_ZERO
+macros conform with
+.St -p1003.1-2001 .
+.Sh HISTORY
+The
+.Fn select
+system call appeared in
+.Bx 4.2 .
+.Sh BUGS
+.St -susv2
+allows systems to modify the original timeout in place.
+Thus, it is unwise to assume that the timeout value will be unmodified
+by the
+.Fn select
+system call.
+.Fx
+does not modify the return value, which can cause problems for applications
+ported from other systems.
diff --git a/lib/libc/sys/semctl.2 b/lib/libsys/semctl.2
index 85657589eca6..85657589eca6 100644
--- a/lib/libc/sys/semctl.2
+++ b/lib/libsys/semctl.2
diff --git a/lib/libc/sys/semget.2 b/lib/libsys/semget.2
index 74fcfeb13c8f..74fcfeb13c8f 100644
--- a/lib/libc/sys/semget.2
+++ b/lib/libsys/semget.2
diff --git a/lib/libc/sys/semop.2 b/lib/libsys/semop.2
index 251d3909c3cd..251d3909c3cd 100644
--- a/lib/libc/sys/semop.2
+++ b/lib/libsys/semop.2
diff --git a/lib/libsys/send.2 b/lib/libsys/send.2
new file mode 100644
index 000000000000..678eef139f4a
--- /dev/null
+++ b/lib/libsys/send.2
@@ -0,0 +1,292 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd April 27, 2020
+.Dt SEND 2
+.Os
+.Sh NAME
+.Nm send ,
+.Nm sendto ,
+.Nm sendmsg ,
+.Nm sendmmsg
+.Nd send message(s) from a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft ssize_t
+.Fn send "int s" "const void *msg" "size_t len" "int flags"
+.Ft ssize_t
+.Fn sendto "int s" "const void *msg" "size_t len" "int flags" "const struct sockaddr *to" "socklen_t tolen"
+.Ft ssize_t
+.Fn sendmsg "int s" "const struct msghdr *msg" "int flags"
+.Ft ssize_t
+.Fn sendmmsg "int s" "struct mmsghdr * restrict msgvec" "size_t vlen" "int flags"
+.Sh DESCRIPTION
+The
+.Fn send
+and
+.Fn sendmmsg
+functions,
+and
+.Fn sendto
+and
+.Fn sendmsg
+system calls
+are used to transmit one or more messages (with the
+.Fn sendmmsg
+call) to
+another socket.
+The
+.Fn send
+function
+may be used only when the socket is in a
+.Em connected
+state.
+The functions
+.Fn sendto ,
+.Fn sendmsg
+and
+.Fn sendmmsg
+may be used at any time if the socket is connectionless-mode.
+If the socket is connection-mode, the protocol
+must support implied connect (currently
+.Xr tcp 4
+is the only protocol with support) or the socket must be in a
+connected state before use.
+.Pp
+The address of the target is given by
+.Fa to
+with
+.Fa tolen
+specifying its size, or the equivalent
+.Fa msg_name
+and
+.Fa msg_namelen
+in
+.Fa struct msghdr .
+If the socket is in a connected state, the target address passed to
+.Fn sendto ,
+.Fn sendmsg
+or
+.Fn sendmmsg
+is ignored.
+The length of the message is given by
+.Fa len .
+If the message is too long to pass atomically through the
+underlying protocol, the error
+.Er EMSGSIZE
+is returned, and
+the message is not transmitted.
+.Pp
+The
+.Fn sendmmsg
+function sends multiple messages at a call.
+They are given by the
+.Fa msgvec
+vector along with
+.Fa vlen
+specifying the vector size.
+The number of octets sent per each message is placed in the
+.Fa msg_len
+field of each processed element of the vector after transmission.
+.Pp
+No indication of failure to deliver is implicit in a
+.Fn send .
+Locally detected errors are indicated by a return value of -1.
+.Pp
+If no messages space is available at the socket to hold
+the message to be transmitted, then
+.Fn send
+normally blocks, unless the socket has been placed in
+non-blocking I/O mode.
+The
+.Xr select 2
+system call may be used to determine when it is possible to
+send more data.
+.Pp
+The
+.Fa flags
+argument may include one or more of the following:
+.Bd -literal
+#define MSG_OOB 0x00001 /* process out-of-band data */
+#define MSG_DONTROUTE 0x00004 /* bypass routing, use direct interface */
+#define MSG_EOR 0x00008 /* data completes record */
+#define MSG_DONTWAIT 0x00080 /* do not block */
+#define MSG_EOF 0x00100 /* data completes transaction */
+#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */
+.Ed
+.Pp
+The flag
+.Dv MSG_OOB
+is used to send
+.Dq out-of-band
+data on sockets that support this notion (e.g.\&
+.Dv SOCK_STREAM ) ;
+the underlying protocol must also support
+.Dq out-of-band
+data.
+.Dv MSG_EOR
+is used to indicate a record mark for protocols which support the
+concept.
+The
+.Dv MSG_DONTWAIT
+flag request the call to return when it would block otherwise.
+.Dv MSG_EOF
+requests that the sender side of a socket be shut down, and that an
+appropriate indication be sent at the end of the specified data;
+this flag is only implemented for
+.Dv SOCK_STREAM
+sockets in the
+.Dv PF_INET
+protocol family.
+.Dv MSG_DONTROUTE
+is usually used only by diagnostic or routing programs.
+.Dv MSG_NOSIGNAL
+is used to prevent
+.Dv SIGPIPE
+generation when writing a socket that
+may be closed.
+.Pp
+See
+.Xr recv 2
+for a description of the
+.Fa msghdr
+structure and the
+.Fa mmsghdr
+structure.
+.Sh RETURN VALUES
+The
+.Fn send ,
+.Fn sendto
+and
+.Fn sendmsg
+calls
+return the number of octets sent.
+The
+.Fn sendmmsg
+call returns the number of messages sent.
+If an error occurred a value of -1 is returned.
+.Sh ERRORS
+The
+.Fn send
+and
+.Fn sendmmsg
+functions and
+.Fn sendto
+and
+.Fn sendmsg
+system calls
+fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+An invalid descriptor was specified.
+.It Bq Er EACCES
+The destination address is a broadcast address, and
+.Dv SO_BROADCAST
+has not been set on the socket.
+.It Bq Er ENOTCONN
+The socket is connection-mode but is not connected.
+.It Bq Er ENOTSOCK
+The argument
+.Fa s
+is not a socket.
+.It Bq Er EFAULT
+An invalid user space address was specified for an argument.
+.It Bq Er EMSGSIZE
+The socket requires that message be sent atomically,
+and the size of the message to be sent made this impossible.
+.It Bq Er EAGAIN
+The socket is marked non-blocking, or
+.Dv MSG_DONTWAIT
+is specified, and the requested operation would block.
+.It Bq Er ENOBUFS
+The system was unable to allocate an internal buffer.
+The operation may succeed when buffers become available.
+.It Bq Er ENOBUFS
+The output queue for a network interface was full.
+This generally indicates that the interface has stopped sending,
+but may be caused by transient congestion.
+.It Bq Er EHOSTUNREACH
+The remote host was unreachable.
+.It Bq Er EISCONN
+A destination address was specified and the socket is already connected.
+.It Bq Er ECONNREFUSED
+The socket received an ICMP destination unreachable message
+from the last message sent.
+This typically means that the
+receiver is not listening on the remote port.
+.It Bq Er EHOSTDOWN
+The remote host was down.
+.It Bq Er ENETDOWN
+The remote network was down.
+.It Bq Er EADDRNOTAVAIL
+The process using a
+.Dv SOCK_RAW
+socket was jailed and the source
+address specified in the IP header did not match the IP
+address bound to the prison.
+.It Bq Er EPIPE
+The socket is unable to send anymore data
+.Dv ( SBS_CANTSENDMORE
+has been set on the socket).
+This typically means that the socket
+is not connected.
+.El
+.Sh SEE ALSO
+.Xr connect 2 ,
+.Xr fcntl 2 ,
+.Xr getsockopt 2 ,
+.Xr recv 2 ,
+.Xr select 2 ,
+.Xr socket 2 ,
+.Xr write 2 ,
+.Xr CMSG_DATA 3
+.Sh HISTORY
+The
+.Fn send
+function appeared in
+.Bx 4.2 .
+The
+.Fn sendmmsg
+function appeared in
+.Fx 11.0 .
+.Sh BUGS
+Because
+.Fn sendmsg
+does not necessarily block until the data has been transferred, it
+is possible to transfer an open file descriptor across an
+.Dv AF_UNIX
+domain socket
+(see
+.Xr recv 2 ) ,
+then
+.Fn close
+it before it has actually been sent, the result being that the receiver
+gets a closed file descriptor.
+It is left to the application to
+implement an acknowledgment mechanism to prevent this from happening.
diff --git a/lib/libsys/sendfile.2 b/lib/libsys/sendfile.2
new file mode 100644
index 000000000000..6000e3e9828f
--- /dev/null
+++ b/lib/libsys/sendfile.2
@@ -0,0 +1,437 @@
+.\" Copyright (c) 2003, David G. Lawrence
+.\" 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 unmodified, 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.
+.\"
+.Dd June 24, 2025
+.Dt SENDFILE 2
+.Os
+.Sh NAME
+.Nm sendfile
+.Nd send a file to a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.In sys/uio.h
+.Ft int
+.Fo sendfile
+.Fa "int fd" "int s" "off_t offset" "size_t nbytes"
+.Fa "struct sf_hdtr *hdtr" "off_t *sbytes" "int flags"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn sendfile
+system call
+sends a regular file or shared memory object specified by descriptor
+.Fa fd
+out a stream socket specified by descriptor
+.Fa s .
+.Pp
+The
+.Fa offset
+argument specifies where to begin in the file.
+Should
+.Fa offset
+fall beyond the end of file, the system will return
+success and report 0 bytes sent as described below.
+The
+.Fa nbytes
+argument specifies how many bytes of the file should be sent, with 0 having the special
+meaning of send until the end of file has been reached.
+.Pp
+An optional header and/or trailer can be sent before and after the file data by specifying
+a pointer to a
+.Vt "struct sf_hdtr" ,
+which has the following structure:
+.Pp
+.Bd -literal -offset indent -compact
+struct sf_hdtr {
+ struct iovec *headers; /* pointer to header iovecs */
+ int hdr_cnt; /* number of header iovecs */
+ struct iovec *trailers; /* pointer to trailer iovecs */
+ int trl_cnt; /* number of trailer iovecs */
+};
+.Ed
+.Pp
+The
+.Fa headers
+and
+.Fa trailers
+pointers, if
+.Pf non- Dv NULL ,
+point to arrays of
+.Vt "struct iovec"
+structures.
+See the
+.Fn writev
+system call for information on the iovec structure.
+The number of iovecs in these
+arrays is specified by
+.Fa hdr_cnt
+and
+.Fa trl_cnt .
+.Pp
+If
+.Pf non- Dv NULL ,
+the system will write the total number of bytes sent on the socket to the
+variable pointed to by
+.Fa sbytes .
+.Pp
+The least significant 16 bits of
+.Fa flags
+argument is a bitmap of these values:
+.Bl -tag -offset indent -width "SF_USER_READAHEAD"
+.It Dv SF_NODISKIO
+This flag causes
+.Nm
+to return
+.Er EBUSY
+instead of blocking when a busy page is encountered.
+This rare situation can happen if some other process is now working
+with the same region of the file.
+It is advised to retry the operation after a short period.
+.Pp
+Note that in older
+.Fx
+versions the
+.Dv SF_NODISKIO
+had slightly different notion.
+The flag prevented
+.Nm
+to run I/O operations in case if an invalid (not cached) page is encountered,
+thus avoiding blocking on I/O.
+Starting with
+.Fx 11
+.Nm
+sending files off the
+.Xr ffs 4
+filesystem does not block on I/O
+(see
+.Sx IMPLEMENTATION NOTES
+), so the condition no longer applies.
+However, it is safe if an application utilizes
+.Dv SF_NODISKIO
+and on
+.Er EBUSY
+performs the same action as it did in
+older
+.Fx
+versions, e.g.,
+.Xr aio_read 2 ,
+.Xr read 2
+or
+.Nm
+in a different context.
+.It Dv SF_NOCACHE
+The data sent to socket will not be cached by the virtual memory system,
+and will be freed directly to the pool of free pages.
+.It Dv SF_USER_READAHEAD
+.Nm
+has some internal heuristics to do readahead when sending data.
+This flag forces
+.Nm
+to override any heuristically calculated readahead and use exactly the
+application specified readahead.
+See
+.Sx SETTING READAHEAD
+for more details on readahead.
+.El
+.Pp
+When using a socket marked for non-blocking I/O,
+.Fn sendfile
+may send fewer bytes than requested.
+In this case, the number of bytes successfully
+written is returned in
+.Fa *sbytes
+(if specified),
+and the error
+.Er EAGAIN
+is returned.
+.Sh SETTING READAHEAD
+.Nm
+uses internal heuristics based on request size and file system layout
+to do readahead.
+Additionally application may request extra readahead.
+The most significant 16 bits of
+.Fa flags
+specify amount of pages that
+.Nm
+may read ahead when reading the file.
+A macro
+.Fn SF_FLAGS
+is provided to combine readahead amount and flags.
+An example showing specifying readahead of 16 pages and
+.Dv SF_NOCACHE
+flag:
+.Pp
+.Bd -literal -offset indent -compact
+ SF_FLAGS(16, SF_NOCACHE)
+.Ed
+.Pp
+.Nm
+will use either application specified readahead or internally calculated,
+whichever is bigger.
+Setting flag
+.Dv SF_USER_READAHEAD
+would turn off any heuristics and set maximum possible readahead length to
+the number of pages specified via flags.
+.Sh IMPLEMENTATION NOTES
+The
+.Fx
+implementation of
+.Fn sendfile
+does not block on disk I/O when it sends a file off the
+.Xr ffs 4
+filesystem.
+The syscall returns success before the actual I/O completes, and data
+is put into the socket later unattended.
+However, the order of data in the socket is preserved, so it is safe
+to do further writes to the socket.
+.Pp
+The
+.Fx
+implementation of
+.Fn sendfile
+is "zero-copy", meaning that it has been optimized so that copying of the file data is avoided.
+.Sh TUNING
+.Ss physical paging buffers
+.Fn sendfile
+uses vnode pager to read file pages into memory.
+The pager uses a pool of physical buffers to run its I/O operations.
+When system runs out of pbufs, sendfile will block and report state
+.Dq Li zonelimit .
+Size of the pool can be tuned with
+.Va vm.vnode_pbufs
+.Xr loader.conf 5
+tunable and can be checked with
+.Xr sysctl 8
+OID of the same name at runtime.
+.Ss sendfile(2) buffers
+On some architectures, this system call internally uses a special
+.Fn sendfile
+buffer
+.Pq Vt "struct sf_buf"
+to handle sending file data to the client.
+If the sending socket is
+blocking, and there are not enough
+.Fn sendfile
+buffers available,
+.Fn sendfile
+will block and report a state of
+.Dq Li sfbufa .
+If the sending socket is non-blocking and there are not enough
+.Fn sendfile
+buffers available, the call will block and wait for the
+necessary buffers to become available before finishing the call.
+.Pp
+The number of
+.Vt sf_buf Ns 's
+allocated should be proportional to the number of nmbclusters used to
+send data to a client via
+.Fn sendfile .
+Tune accordingly to avoid blocking!
+Busy installations that make extensive use of
+.Fn sendfile
+may want to increase these values to be inline with their
+.Va kern.ipc.nmbclusters
+(see
+.Xr tuning 7
+for details).
+.Pp
+The number of
+.Fn sendfile
+buffers available is determined at boot time by either the
+.Va kern.ipc.nsfbufs
+.Xr loader.conf 5
+variable or the
+.Dv NSFBUFS
+kernel configuration tunable.
+The number of
+.Fn sendfile
+buffers scales with
+.Va kern.maxusers .
+The
+.Va kern.ipc.nsfbufsused
+and
+.Va kern.ipc.nsfbufspeak
+read-only
+.Xr sysctl 8
+variables show current and peak
+.Fn sendfile
+buffers usage respectively.
+These values may also be viewed through
+.Nm netstat Fl m .
+.Pp
+If
+.Xr sysctl 8
+OID
+.Va kern.ipc.nsfbufs
+doesn't exist, your architecture does not need to use
+.Fn sendfile
+buffers because their task can be efficiently performed
+by the generic virtual memory structures.
+.Sh RETURN VALUES
+.Rv -std sendfile
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The socket is marked for non-blocking I/O and not all data was sent due to
+the socket buffer being filled.
+If specified, the number of bytes successfully sent will be returned in
+.Fa *sbytes .
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid file descriptor.
+.It Bq Er EBADF
+The
+.Fa s
+argument
+is not a valid socket descriptor.
+.It Bq Er EBUSY
+A busy page was encountered and
+.Dv SF_NODISKIO
+had been specified.
+Partial data may have been sent.
+.It Bq Er EFAULT
+An invalid address was specified for an argument.
+.It Bq Er EINTR
+A signal interrupted
+.Fn sendfile
+before it could be completed.
+If specified, the number
+of bytes successfully sent will be returned in
+.Fa *sbytes .
+.It Bq Er EINVAL
+The
+.Fa fd
+argument
+is not a regular file.
+.It Bq Er EINVAL
+The
+.Fa s
+argument
+is not a SOCK_STREAM type socket.
+.It Bq Er EINVAL
+The
+.Fa offset
+argument
+is negative.
+.It Bq Er EIO
+An error occurred while reading from
+.Fa fd .
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from
+.Fa fd .
+.It Bq Er ENOTCAPABLE
+The
+.Fa fd
+or the
+.Fa s
+argument has insufficient rights.
+.It Bq Er ENOBUFS
+The system was unable to allocate an internal buffer.
+.It Bq Er ENOTCONN
+The
+.Fa s
+argument
+points to an unconnected socket.
+.It Bq Er ENOTSOCK
+The
+.Fa s
+argument
+is not a socket.
+.It Bq Er EOPNOTSUPP
+The file system for descriptor
+.Fa fd
+does not support
+.Fn sendfile .
+.It Bq Er EPIPE
+The socket peer has closed the connection.
+.El
+.Sh SEE ALSO
+.Xr netstat 1 ,
+.Xr open 2 ,
+.Xr send 2 ,
+.Xr socket 2 ,
+.Xr writev 2 ,
+.Xr loader.conf 5 ,
+.Xr tuning 7 ,
+.Xr sysctl 8
+.Rs
+.%A K. Elmeleegy
+.%A A. Chanda
+.%A A. L. Cox
+.%A W. Zwaenepoel
+.%T A Portable Kernel Abstraction for Low-Overhead Ephemeral Mapping Management
+.%J The Proceedings of the 2005 USENIX Annual Technical Conference
+.%P pp 223-236
+.%D 2005
+.Re
+.Sh HISTORY
+The
+.Fn sendfile
+system call
+first appeared in
+.Fx 3.0 .
+This manual page first appeared in
+.Fx 3.1 .
+In
+.Fx 10
+support for sending shared memory descriptors had been introduced.
+In
+.Fx 11
+a non-blocking implementation had been introduced.
+.Sh AUTHORS
+The initial implementation of
+.Fn sendfile
+system call
+and this manual page were written by
+.An David G. Lawrence Aq Mt dg@dglawrence.com .
+The
+.Fx 11
+implementation was written by
+.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org .
+.Sh BUGS
+The
+.Fn sendfile
+system call will not fail, i.e., return
+.Dv -1
+and set
+.Va errno
+to
+.Er EFAULT ,
+if provided an invalid address for
+.Fa sbytes .
+The
+.Fn sendfile
+system call does not support SCTP sockets,
+it will return
+.Dv -1
+and set
+.Va errno
+to
+.Er EINVAL .
diff --git a/lib/libsys/sendmmsg.c b/lib/libsys/sendmmsg.c
new file mode 100644
index 000000000000..41eb62d1e0c8
--- /dev/null
+++ b/lib/libsys/sendmmsg.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Boris Astardzhiev, Smartcom-Bulgaria AD
+ * 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(s), this list of conditions and the following disclaimer as
+ * the first lines of this file unmodified other than the possible
+ * addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "libc_private.h"
+
+ssize_t
+sendmmsg(int s, struct mmsghdr *__restrict msgvec, size_t vlen, int flags)
+{
+ size_t i, sent;
+ ssize_t ret;
+
+ sent = 0;
+ for (i = 0; i < vlen; i++, sent++) {
+ ret = __sys_sendmsg(s, &msgvec[i].msg_hdr, flags);
+ if (ret == -1) {
+ if (sent != 0) {
+ /*
+ * We have sent messages. Let caller
+ * know about the data sent, socket
+ * error is returned on next
+ * invocation.
+ */
+ return (sent);
+ }
+ return (ret);
+ }
+
+ /* Save sent bytes. */
+ msgvec[i].msg_len = ret;
+ }
+
+ return (sent);
+}
diff --git a/lib/libsys/setcred.2 b/lib/libsys/setcred.2
new file mode 100644
index 000000000000..86f61ddfdb30
--- /dev/null
+++ b/lib/libsys/setcred.2
@@ -0,0 +1,290 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright © 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by Olivier Certner <olce.freebsd@certner.fr>
+.\" at Kumacom SARL under sponsorship from the FreeBSD Foundation.
+.\"
+.Dd December 19, 2024
+.Dt SETCRED 2
+.Os
+.Sh NAME
+.Nm setcred
+.Nd set current process credentials atomically
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/ucred.h
+.Ft int
+.Fn setcred "u_int flags" "const struct setcred *wcred" "size_t size"
+.Sh DESCRIPTION
+The
+.Fn setcred
+system call can set any combination of user-accessible credentials of the
+current process in an atomic manner.
+.Pp
+This system call is normally permitted only for processes having the ID of the
+super-user (0) as their effective user ID, or not at all if the
+.Xr sysctl 8
+variable
+.Va security.bsd.suser_enabled
+is zero or some active MAC policy specifically denies these processes.
+.Pp
+Some MAC policies, such as
+.Xr mac_do 4 ,
+may also allow unprivileged users to call it successfully, possibly depending on
+the exact credentials transition requested, once again unless any active MAC
+policy specifically denies that.
+.Pp
+The
+.Fa flags
+argument serves to indicate which process credentials should be changed by the
+call.
+Allowed flags are:
+.Pp
+.Bl -tag -width "SETCREDF_SUPP_GROUPS " -compact
+.It Fa SETCREDF_UID
+Set the effective user ID.
+.It Fa SETCREDF_RUID
+Set the real user ID.
+.It Fa SETCREDF_SVUID
+Set the saved user ID.
+.It Fa SETCREDF_GID
+Set the effective group ID.
+.It Fa SETCREDF_RGID
+Set the real group ID.
+.It Fa SETCREDF_SVGID
+Set the saved group ID.
+.It Fa SETCREDF_SUPP_GROUPS
+Set the supplementary group list.
+.It Fa SETCREDF_MAC_LABEL
+Set the MAC label.
+.El
+.Pp
+The
+.Vt struct setcred
+structure is currently defined as:
+.Bd -literal
+struct setcred {
+ uid_t sc_uid; /* effective user id */
+ uid_t sc_ruid; /* real user id */
+ uid_t sc_svuid; /* saved user id */
+ gid_t sc_gid; /* effective group id */
+ gid_t sc_rgid; /* real group id */
+ gid_t sc_svgid; /* saved group id */
+ u_int sc_pad; /* padding, unused */
+ u_int sc_supp_groups_nb; /* supplementary groups number */
+ gid_t *sc_supp_groups; /* supplementary groups */
+ struct mac *sc_label; /* MAC label */
+};
+.Ed
+.Pp
+Its fields are:
+.Pp
+.Bl -tag -width "sc_supp_groups_nb " -compact
+.It Fa sc_uid
+The ID to set the effective user to, if flag
+.Dv SETCREDF_UID
+is specified.
+.It Fa sc_ruid
+The ID to set the real user to, if flag
+.Dv SETCREDF_RUID
+is specified.
+.It Fa sc_svuid
+The ID to set the saved user to, if flag
+.Dv SETCREDF_SVUID
+is specified.
+.It Fa sc_gid
+The ID to set the effective group to, if flag
+.Dv SETCREDF_GID
+is specified.
+.It Fa sc_rgid
+The ID to set the real group to, if flag
+.Dv SETCREDF_RGID
+is specified.
+.It Fa sc_svgid
+The ID to set the saved group to, if flag
+.Dv SETCREDF_SVGID
+is specified.
+.It Fa sc_supp_groups_nb
+The size of array
+.Fa sc_supp_groups ,
+if flag
+.Dv SETCREDF_SUPP_GROUPS
+is specified.
+It must be less than or equal to
+.Dv {NGROUPS_MAX} .
+.It Fa sc_supp_groups
+An array of IDs to set the supplementary groups to, if flag
+.Dv SETCREDF_SUPP_GROUPS
+is specified.
+Note that all groups in this array will be set as supplementary groups only, in
+contrast to
+.Xr setgroups 2
+which treats the first element specially as the new effective group, not adding
+it to supplementary groups.
+.It Fa sc_label
+A pointer to a valid MAC label structure, e.g., built with the
+.Xr mac_from_text 3
+function, if flag
+.Dv SETCREDF_MAC_LABEL
+is specified.
+.El
+.Pp
+For forward compatibility and security reasons, it is recommended that users
+always initialize objects of type
+.Vt struct setcred
+with the provided initializer:
+.Dv SETCRED_INITIALIZER .
+.Pp
+The
+.Fa size
+argument must be the size of the passed
+.Fa wcred
+structure.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn setcred
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+Unrecognized flags were passed in
+.Fa flags ,
+or the
+.Fa size
+parameter does not match the size of
+.Vt struct setcred ,
+or the field
+.Fa sc_supp_group_nb
+has a value strictly greater than
+.Dv {NGROUPS_MAX}
+.Po if flag
+.Dv SETCREDF_SUPP_GROUPS
+was supplied
+.Pc ,
+or the MAC label pointed to by field
+.Fa sc_label
+is invalid
+.Po if flag
+.Dv SETCREDF_MAC_LABEL
+was supplied
+.Pc .
+.It Bq Er EFAULT
+The
+.Fa wcred
+pointer, or pointers in fields
+.Fa sc_supp_groups
+.Po if flag
+.Dv SETCREDF_SUPP_GROUPS
+was supplied
+.Pc
+or
+.Fa sc_label
+.Po if flag
+.Dv SETCREDF_MAC_LABEL
+was supplied
+.Pc
+point to invalid locations.
+.It Bq Er EPERM
+The user is not the super-user and/or the requested credentials transition is
+not allowed by the system or MAC modules.
+.It Bq Er EOPNOTSUPP
+Some of the requested credentials have a type that the system does not support.
+This currently can occur only if the kernel has been compiled without MAC and
+.Dv SETCREDF_MAC_LABEL
+has been passed.
+.El
+.Sh SEE ALSO
+.Xr issetugid 2 ,
+.Xr setregid 2 ,
+.Xr setreuid 2 ,
+.Xr setuid 2 ,
+.Xr mac_text 3 ,
+.Xr mac 4 ,
+.Xr mac_do 4 ,
+.Xr maclabel 7
+.Sh STANDARDS
+The
+.Fn setcred
+system call is specific to
+.Fx .
+.Pp
+A call to
+.Fn setcred
+usually changes process credentials that are listed by POSIX/SUS standards.
+The changed values then produce the effects with respect to the rest of the
+system that are described in these standards, as if these changes had resulted
+from calling standard or traditional credentials-setting functions.
+Currently, all flags but
+.Dv SETCREDF_MAC_LABEL
+lead to modifying standard credentials.
+.Pp
+The only differences in using
+.Fn setcred
+to change standard credentials instead of standard or traditional functions are:
+.Pp
+.Bl -bullet -compact
+.It
+All requested changes are performed atomically.
+.It
+Only the super-user or an unprivileged user authorized by some MAC module can
+successfully call
+.Fn setcred ,
+even if the standard system calls would have authorized any unprivileged user to
+effect the same changes.
+For example,
+.Fn seteuid
+allows any unprivileged user to change the effective user ID to either the real
+or saved ones, while
+.Fn setcred
+called with flag
+.Dv SETCREDF_UID
+does not.
+.El
+.Sh HISTORY
+The
+.Fn setcred
+system call appeared in
+.Fx 14.3 .
+.Pp
+Traditionally in UNIX, all credential changes beyond shuffles of effective, real
+and saved IDs have been done by setuid binaries that successively call multiple
+credentials-setting system calls and in a specific order.
+For example, to change all user IDs to that of some unprivileged user,
+.Fn setuid
+must be called last so that all other credentials-changing calls can be
+performed successfully beforehand, as they require super-user privileges.
+.Pp
+This piecewise approach causes such a process to transiently hold high privilege
+credentials that are neither the original nor necessarily the desired final
+ones.
+Besides opening a transition window where possible vulnerabilities could have
+catastrophic consequences, it makes it impossible for the kernel to enforce that
+only certain transitions of credentials are allowed.
+.Pp
+The necessity of an atomic, global approach to changing credentials clearly
+appeared while working on extending
+.Xr mac_do 4
+to allow rules to authorize only specific changes of primary or supplementary
+groups, which prompted the addition of
+.Fn setcred .
+.Sh AUTHORS
+The
+.Fn setcred
+system call and this manual page were written by
+.An Olivier Certner Aq Mt olce.freebsd@certner.fr .
+.Sh SECURITY CONSIDERATIONS
+The same considerations as those of standard or traditional credentials-setting
+system calls apply to
+.Fn setcred ,
+except for the lack of atomicity of successive such calls.
+.Pp
+In particular, please consult section
+.Sy SECURITY CONSIDERATIONS
+of the
+.Xr setuid 2
+manual page about the absence of effect of changing standard credentials on
+already open files.
diff --git a/lib/libsys/setfib.2 b/lib/libsys/setfib.2
new file mode 100644
index 000000000000..57e83c0d1adb
--- /dev/null
+++ b/lib/libsys/setfib.2
@@ -0,0 +1,110 @@
+.\" Copyright (c) 2008 Cisco Systems. All rights reserved.
+.\" Author: Julian Elischer
+.\"
+.\" 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. Neither the name of the Cisco Systems nor the names of its employees
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
+.\"
+.Dd January 10, 2025
+.Dt SETFIB 2
+.Os
+.Sh NAME
+.Nm setfib
+.Nd set the default FIB (routing table) for the calling process
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft int
+.Fn setfib "int fib"
+.Sh DESCRIPTION
+The
+.Fn setfib
+system call sets the associated FIB (routing table) for all sockets opened
+subsequent to the call, to be that of the argument
+.Fa fib .
+The
+.Fa fib
+argument
+must be greater than or equal to 0
+and less than the current system maximum which
+may be retrieved by the
+.Va net.fibs
+sysctl.
+The system maximum is set in the kernel configuration file with
+.Bd -ragged -offset indent
+.Cd "options ROUTETABLES=" Ns Em N
+.Ed
+.Pp
+or in
+.Pa /boot/loader.conf
+or
+.Pa /etc/sysctl.conf
+with
+.Pp
+.Dl net.fibs= Ns Qq Em N
+.Pp
+where
+.Em N
+is an integer smaller than 65536.
+Note that the number of FIBs may be increased after booting, but cannot be
+reduced.
+.Pp
+The maximum of 65536 is due to the implementation storing
+the FIB number in a 16-bit field in the
+.Xr mbuf 9
+packet header, however it is not suggested that one use such a large number
+as memory is allocated for every FIB regardless of whether it is used, and
+there are places where all FIBs are iterated over.
+.Pp
+The default FIB of the process will be applied to all protocol families
+that support multiple FIBs, and ignored by those that do not.
+The default FIB for a process may be overridden for a socket with the use
+of the
+.Dv SO_SETFIB
+socket option.
+.Sh RETURN VALUES
+.Rv -std setfib
+.Sh ERRORS
+The
+.Fn setfib
+system call
+will fail and no action will be taken and return
+.Er EINVAL
+if the
+.Fa fib
+argument is greater than the current system maximum.
+.Sh SEE ALSO
+.Xr setfib 1 ,
+.Xr setsockopt 2
+.Sh STANDARDS
+The
+.Fn setfib
+system call is a
+.Fx
+extension however similar extensions
+have been added to many other
+.Ux
+style kernels.
+.Sh HISTORY
+The
+.Fn setfib
+function appeared in
+.Fx 7.1 .
diff --git a/lib/libsys/setgroups.2 b/lib/libsys/setgroups.2
new file mode 100644
index 000000000000..a226aeafea96
--- /dev/null
+++ b/lib/libsys/setgroups.2
@@ -0,0 +1,101 @@
+.\" Copyright (c) 1983, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd January 19, 2018
+.Dt SETGROUPS 2
+.Os
+.Sh NAME
+.Nm setgroups
+.Nd set group access list
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In unistd.h
+.Ft int
+.Fn setgroups "int ngroups" "const gid_t *gidset"
+.Sh DESCRIPTION
+The
+.Fn setgroups
+system call
+sets the group access list of the current user process
+according to the array
+.Fa gidset .
+The
+.Fa ngroups
+argument
+indicates the number of entries in the array and must be no
+more than
+.Dv {NGROUPS_MAX}+1 .
+.Pp
+Only the super-user may set a new group list.
+.Pp
+The first entry of the group array
+.Pq Va gidset[0]
+is used as the effective group-ID for the process.
+This entry is over-written when a setgid program is run.
+To avoid losing access to the privileges of the
+.Va gidset[0]
+entry, it should be duplicated later in the group array.
+By convention,
+this happens because the group value indicated
+in the password file also appears in
+.Pa /etc/group .
+The group value in the password file is placed in
+.Va gidset[0]
+and that value then gets added a second time when the
+.Pa /etc/group
+file is scanned to create the group set.
+.Sh RETURN VALUES
+.Rv -std setgroups
+.Sh ERRORS
+The
+.Fn setgroups
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The caller is not the super-user.
+.It Bq Er EINVAL
+The number specified in the
+.Fa ngroups
+argument is larger than the
+.Dv {NGROUPS_MAX}+1
+limit.
+.It Bq Er EFAULT
+The address specified for
+.Fa gidset
+is outside the process
+address space.
+.El
+.Sh SEE ALSO
+.Xr getgroups 2 ,
+.Xr initgroups 3
+.Sh HISTORY
+The
+.Fn setgroups
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/setpgid.2 b/lib/libsys/setpgid.2
new file mode 100644
index 000000000000..1c0a6ae02727
--- /dev/null
+++ b/lib/libsys/setpgid.2
@@ -0,0 +1,107 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd February 8, 2004
+.Dt SETPGID 2
+.Os
+.Sh NAME
+.Nm setpgid ,
+.Nm setpgrp
+.Nd set process group
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn setpgid "pid_t pid" "pid_t pgrp"
+.Ft int
+.Fn setpgrp "pid_t pid" "pid_t pgrp"
+.Sh DESCRIPTION
+The
+.Fn setpgid
+system call
+sets the process group of the specified process
+.Fa pid
+to the specified
+.Fa pgrp .
+If
+.Fa pid
+is zero, then the call applies to the current process.
+If
+.Fa pgrp
+is zero, then the process id of the process specified by
+.Fa pid
+is used instead.
+.Pp
+If the affected process is not the invoking process, then it must be a
+child of the invoking process, it must not have performed an
+.Xr exec 3
+operation, and both processes must be in the same session.
+The requested process group ID must already exist in the session of
+the caller, or it must be equal to the target process ID.
+.Sh RETURN VALUES
+.Rv -std setpgid
+.Sh COMPATIBILITY
+The
+.Fn setpgrp
+system call
+is identical to
+.Fn setpgid ,
+and is retained for calling convention compatibility with historical
+versions of
+.Bx .
+.Sh ERRORS
+The
+.Fn setpgid
+system call
+will fail and the process group will not be altered if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The requested process group ID is not legal.
+.It Bq Er ESRCH
+The requested process does not exist.
+.It Bq Er ESRCH
+The target process is not the calling process or
+a child of the calling process.
+.It Bq Er EACCES
+The requested process is a child of the calling process,
+but it has performed an
+.Xr exec 3
+operation.
+.It Bq Er EPERM
+The target process is a session leader.
+.It Bq Er EPERM
+The requested process group ID is not in the session of the caller,
+and it is not equal to the process ID of the target process.
+.El
+.Sh SEE ALSO
+.Xr getpgrp 2
+.Sh STANDARDS
+The
+.Fn setpgid
+system call is expected to conform to
+.St -p1003.1-90 .
diff --git a/lib/libsys/setregid.2 b/lib/libsys/setregid.2
new file mode 100644
index 000000000000..f340fb4edb30
--- /dev/null
+++ b/lib/libsys/setregid.2
@@ -0,0 +1,87 @@
+.\" Copyright (c) 1980, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd April 16, 1994
+.Dt SETREGID 2
+.Os
+.Sh NAME
+.Nm setregid
+.Nd set real and effective group ID
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn setregid "gid_t rgid" "gid_t egid"
+.Sh DESCRIPTION
+The real and effective group ID's of the current process
+are set to the arguments.
+If the real group ID is changed, the saved group ID is changed to the
+new value of the effective group ID.
+.Pp
+Unprivileged users may change the real group
+ID to the effective group ID and vice-versa; only the super-user may
+make other changes.
+.Pp
+Supplying a value of -1 for either the real or effective
+group ID forces the system to substitute the current
+ID in place of the -1 argument.
+.Pp
+The
+.Fn setregid
+system call was intended to allow swapping
+the real and effective group IDs
+in set-group-ID programs to temporarily relinquish the set-group-ID value.
+This system call did not work correctly,
+and its purpose is now better served by the use of the
+.Xr setegid 2
+system call.
+.Pp
+When setting the real and effective group IDs to the same value,
+the standard
+.Fn setgid
+system call is preferred.
+.Sh RETURN VALUES
+.Rv -std setregid
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EPERM
+The current process is not the super-user and a change
+other than changing the effective group-id to the real group-id
+was specified.
+.El
+.Sh SEE ALSO
+.Xr getgid 2 ,
+.Xr issetugid 2 ,
+.Xr setegid 2 ,
+.Xr setgid 2 ,
+.Xr setuid 2
+.Sh HISTORY
+The
+.Fn setregid
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libc/sys/setresuid.2 b/lib/libsys/setresuid.2
index 28038dec6637..28038dec6637 100644
--- a/lib/libc/sys/setresuid.2
+++ b/lib/libsys/setresuid.2
diff --git a/lib/libsys/setreuid.2 b/lib/libsys/setreuid.2
new file mode 100644
index 000000000000..cdd55560f7cb
--- /dev/null
+++ b/lib/libsys/setreuid.2
@@ -0,0 +1,87 @@
+.\" Copyright (c) 1980, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd February 8, 2001
+.Dt SETREUID 2
+.Os
+.Sh NAME
+.Nm setreuid
+.Nd set real and effective user ID's
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn setreuid "uid_t ruid" "uid_t euid"
+.Sh DESCRIPTION
+The real and effective user IDs of the
+current process are set according to the arguments.
+If
+.Fa ruid
+or
+.Fa euid
+is -1, the current uid is filled in by the system.
+Unprivileged users may change the real user
+ID to the effective user ID and vice-versa; only the super-user may
+make other changes.
+.Pp
+If the real user ID is changed (i.e.\&
+.Fa ruid
+is not -1) or the effective user ID is changed to something other than
+the real user ID, then the saved user ID will be set to the effective user ID.
+.Pp
+The
+.Fn setreuid
+system call has been used to swap the real and effective user IDs
+in set-user-ID programs to temporarily relinquish the set-user-ID value.
+This purpose is now better served by the use of the
+.Xr seteuid 2
+system call.
+.Pp
+When setting the real and effective user IDs to the same value,
+the standard
+.Fn setuid
+system call is preferred.
+.Sh RETURN VALUES
+.Rv -std setreuid
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EPERM
+The current process is not the super-user and a change
+other than changing the effective user-id to the real user-id
+was specified.
+.El
+.Sh SEE ALSO
+.Xr getuid 2 ,
+.Xr issetugid 2 ,
+.Xr seteuid 2 ,
+.Xr setuid 2
+.Sh HISTORY
+The
+.Fn setreuid
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/setsid.2 b/lib/libsys/setsid.2
new file mode 100644
index 000000000000..3484ef069460
--- /dev/null
+++ b/lib/libsys/setsid.2
@@ -0,0 +1,78 @@
+.\" Copyright (c) 1991, 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.
+.\"
+.Dd June 4, 1993
+.Dt SETSID 2
+.Os
+.Sh NAME
+.Nm setsid
+.Nd create session and set process group ID
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft pid_t
+.Fn setsid void
+.Sh DESCRIPTION
+The
+.Fn setsid
+system call creates a new session.
+The calling process is the session leader of the new session, is the
+process group leader of a new process group and has no controlling
+terminal.
+The calling process is the only process in either the session or the
+process group.
+.Sh RETURN VALUES
+Upon successful completion, the
+.Fn setsid
+system call returns the value of the process group ID of the new process
+group, which is the same as the process ID of the calling process.
+If an error occurs,
+.Fn setsid
+returns -1 and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn setsid
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The calling process is already a process group leader, or the process
+group ID of a process other than the calling process matches the process
+ID of the calling process.
+.El
+.Sh SEE ALSO
+.Xr setpgid 2 ,
+.Xr tcgetpgrp 3 ,
+.Xr tcsetpgrp 3
+.Sh STANDARDS
+The
+.Fn setsid
+system call is expected to be compliant with the
+.St -p1003.1-90
+specification.
diff --git a/lib/libsys/setuid.2 b/lib/libsys/setuid.2
new file mode 100644
index 000000000000..49919b9c328c
--- /dev/null
+++ b/lib/libsys/setuid.2
@@ -0,0 +1,186 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd December 15, 2015
+.Dt SETUID 2
+.Os
+.Sh NAME
+.Nm setuid ,
+.Nm seteuid ,
+.Nm setgid ,
+.Nm setegid
+.Nd set user and group ID
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn setuid "uid_t uid"
+.Ft int
+.Fn seteuid "uid_t euid"
+.Ft int
+.Fn setgid "gid_t gid"
+.Ft int
+.Fn setegid "gid_t egid"
+.Sh DESCRIPTION
+The
+.Fn setuid
+system call
+sets the real and effective
+user IDs and the saved set-user-ID of the current process
+to the specified value.
+.\" Comment out next block for !_POSIX_SAVED_IDS
+.\" The real user ID and the saved set-user-ID are changed only if the
+.\" effective user ID is that of the super user.
+.\" I.e.
+.\" .Fn setuid
+.\" system call is equal to
+.\" .Fn seteuid
+.\" system call if the effective user ID is not that of the super user.
+.\" End of block
+The
+.Fn setuid
+system call is permitted if the specified ID is equal to the real user ID
+.\" Comment out next line for !_POSIX_SAVED_IDS
+.\" or the saved set-user-ID
+.\" Next line is for Appendix B.4.2.2 case.
+or the effective user ID
+of the process, or if the effective user ID is that of the super user.
+.Pp
+The
+.Fn setgid
+system call
+sets the real and effective
+group IDs and the saved set-group-ID of the current process
+to the specified value.
+.\" Comment out next block for !_POSIX_SAVED_IDS
+.\" The real group ID and the saved set-group-ID are changed only if the
+.\" effective user ID is that of the super user.
+.\" I.e.
+.\" .Fn setgid
+.\" system call is equal to
+.\" .Fn setegid
+.\" system call if the effective user ID is not that of the super user.
+.\" End of block
+The
+.Fn setgid
+system call is permitted if the specified ID is equal to the real group ID
+.\" Comment out next line for !_POSIX_SAVED_IDS
+.\" or the saved set-group-ID
+.\" Next line is for Appendix B.4.2.2 case.
+or the effective group ID
+of the process, or if the effective user ID is that of the super user.
+.Pp
+The
+.Fn seteuid
+system call
+.Pq Fn setegid
+sets the effective user ID (group ID) of the
+current process.
+The effective user ID may be set to the value
+of the real user ID or the saved set-user-ID (see
+.Xr intro 2
+and
+.Xr execve 2 ) ;
+in this way, the effective user ID of a set-user-ID executable
+may be toggled by switching to the real user ID, then re-enabled
+by reverting to the set-user-ID value.
+Similarly, the effective group ID may be set to the value
+of the real group ID or the saved set-group-ID.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The user is not the super user and the ID
+specified is not the real, effective ID, or saved ID.
+.El
+.Sh SEE ALSO
+.Xr getgid 2 ,
+.Xr getuid 2 ,
+.Xr issetugid 2 ,
+.Xr setregid 2 ,
+.Xr setreuid 2
+.Sh STANDARDS
+The
+.Fn setuid
+and
+.Fn setgid
+system calls are compliant with the
+.St -p1003.1-90
+specification with
+.Li _POSIX_SAVED_IDS
+.\" Uncomment next line for !_POSIX_SAVED_IDS
+not
+defined with the permitted extensions from Appendix B.4.2.2.
+The
+.Fn seteuid
+and
+.Fn setegid
+system calls are extensions based on the
+.Tn POSIX
+concept of
+.Li _POSIX_SAVED_IDS ,
+and have been proposed for a future revision of the standard.
+.Sh HISTORY
+The
+.Fn setuid
+function appeared in
+.At v1 .
+The
+.Fn setgid
+function appeared in
+.At v4 .
+.Sh SECURITY CONSIDERATIONS
+Read and write permissions to files are determined upon a call to
+.Xr open 2 .
+Once a file descriptor is open, dropping privilege does not affect
+the process's read/write permissions, even if the user ID specified
+has no read or write permissions to the file.
+These files normally remain open in any new process executed,
+resulting in a user being able to read or modify
+potentially sensitive data.
+.Pp
+To prevent these files from remaining open after an
+.Xr exec 3
+call, be sure to set the close-on-exec flag:
+.Bd -literal
+void
+pseudocode(void)
+{
+ int fd;
+ /* ... */
+
+ fd = open("/path/to/sensitive/data", O_RDWR | O_CLOEXEC);
+ if (fd == -1)
+ err(1, "open");
+
+ /* ... */
+ execve(path, argv, environ);
+}
+.Ed
diff --git a/lib/libc/sys/shm_open.2 b/lib/libsys/shm_open.2
index 8bea939690ba..8bea939690ba 100644
--- a/lib/libc/sys/shm_open.2
+++ b/lib/libsys/shm_open.2
diff --git a/lib/libc/sys/shmat.2 b/lib/libsys/shmat.2
index 16d4b930995d..16d4b930995d 100644
--- a/lib/libc/sys/shmat.2
+++ b/lib/libsys/shmat.2
diff --git a/lib/libc/sys/shmctl.2 b/lib/libsys/shmctl.2
index 6c2259981310..6c2259981310 100644
--- a/lib/libc/sys/shmctl.2
+++ b/lib/libsys/shmctl.2
diff --git a/lib/libc/sys/shmget.2 b/lib/libsys/shmget.2
index 9bc742e016a8..9bc742e016a8 100644
--- a/lib/libc/sys/shmget.2
+++ b/lib/libsys/shmget.2
diff --git a/lib/libsys/shutdown.2 b/lib/libsys/shutdown.2
new file mode 100644
index 000000000000..b361527d925c
--- /dev/null
+++ b/lib/libsys/shutdown.2
@@ -0,0 +1,168 @@
+.\" Copyright (c) 2007 Bruce M. Simpson.
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd July 27, 2015
+.Dt SHUTDOWN 2
+.Os
+.Sh NAME
+.Nm shutdown
+.Nd disable sends and/or receives on a socket
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fn shutdown "int s" "int how"
+.Sh DESCRIPTION
+The
+.Fn shutdown
+system call disables sends or receives on a socket.
+The
+.Fa how
+argument specifies the type of shutdown.
+Possible values are:
+.Bl -tag -width ".Dv SHUT_RDWR"
+.It Dv SHUT_RD
+Further receives will be disallowed.
+.It Dv SHUT_WR
+Further sends will be disallowed.
+This may cause actions specific to the protocol family of the socket
+.Fa s
+to happen; see
+.Sx IMPLEMENTATION NOTES .
+.It Dv SHUT_RDWR
+Further sends and receives will be disallowed.
+Implies
+.Dv SHUT_WR .
+.El
+.Pp
+If the file descriptor
+.Fa s
+is associated with a
+.Dv SOCK_STREAM
+socket, all or part of the full-duplex connection will be shut down.
+.\"
+.Sh IMPLEMENTATION NOTES
+The following protocol specific actions apply to the use of
+.Dv SHUT_WR
+(and potentially also
+.Dv SHUT_RDWR ) ,
+based on the properties of the socket associated with the file descriptor
+.Fa s .
+.Bl -column ".Dv PF_INET6" ".Dv SOCK_STREAM" ".Dv IPPROTO_SCTP"
+.It Sy Domain Ta Sy Type Ta Sy Protocol Ta Sy Action
+.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta
+Failure,
+as socket is not connected.
+.It Dv PF_INET Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta
+Failure,
+as socket is not connected.
+.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta
+Send queued data and tear down association.
+.It Dv PF_INET Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta
+Send queued data, wait for ACK, then send FIN.
+.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_SCTP Ta
+Failure,
+as socket is not connected.
+.It Dv PF_INET6 Ta Dv SOCK_DGRAM Ta Dv IPPROTO_UDP Ta
+Failure,
+as socket is not connected.
+.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_SCTP Ta
+Send queued data and tear down association.
+.It Dv PF_INET6 Ta Dv SOCK_STREAM Ta Dv IPPROTO_TCP Ta
+Send queued data, wait for ACK, then send FIN.
+.El
+.\"
+.Sh RETURN VALUES
+.Rv -std shutdown
+.Sh ERRORS
+The
+.Fn shutdown
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa s
+argument is not a valid file descriptor.
+.It Bq Er EINVAL
+The
+.Fa how
+argument is invalid.
+.It Bq Er ENOTCONN
+The
+.Fa s
+argument specifies a socket which is not connected.
+.It Bq Er ENOTSOCK
+The
+.Fa s
+argument does not refer to a socket.
+.El
+.Sh SEE ALSO
+.Xr connect 2 ,
+.Xr socket 2 ,
+.Xr inet 4 ,
+.Xr inet6 4
+.Sh STANDARDS
+The
+.Fn shutdown
+system call is expected to comply with
+.St -p1003.1g-2000 ,
+when finalized.
+.Sh HISTORY
+The
+.Fn shutdown
+system call appeared in
+.Bx 4.2 .
+The
+.Dv SHUT_RD , SHUT_WR ,
+and
+.Dv SHUT_RDWR
+constants appeared in
+.St -p1003.1g-2000 .
+.Sh AUTHORS
+.An -nosplit
+This manual page was updated by
+.An Bruce M. Simpson Aq Mt bms@FreeBSD.org
+to reflect how
+.Fn shutdown
+behaves with
+.Dv PF_INET
+and
+.Dv PF_INET6
+sockets.
+.Sh BUGS
+The ICMP
+.Dq Li "port unreachable"
+message should be generated in response to
+datagrams received on a local port to which
+.Fa s
+is bound
+after
+.Fn shutdown
+is called.
diff --git a/lib/libsys/sigaction.2 b/lib/libsys/sigaction.2
new file mode 100644
index 000000000000..9f49fb38245a
--- /dev/null
+++ b/lib/libsys/sigaction.2
@@ -0,0 +1,792 @@
+.\" Copyright (c) 1980, 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.
+.\"
+.Dd December 1, 2023
+.Dt SIGACTION 2
+.Os
+.Sh NAME
+.Nm sigaction
+.Nd software signal facilities
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Bd -literal
+struct sigaction {
+ void (*sa_handler)(int);
+ void (*sa_sigaction)(int, siginfo_t *, void *);
+ int sa_flags; /* see signal options below */
+ sigset_t sa_mask; /* signal mask to apply */
+};
+.Ed
+.Pp
+.Ft int
+.Fo sigaction
+.Fa "int sig"
+.Fa "const struct sigaction * restrict act"
+.Fa "struct sigaction * restrict oact"
+.Fc
+.Sh DESCRIPTION
+The system defines a set of signals that may be delivered to a process.
+Signal delivery resembles the occurrence of a hardware interrupt:
+the signal is normally blocked from further occurrence, the current thread
+context is saved, and a new one is built.
+A process may specify a
+.Em handler
+to which a signal is delivered, or specify that a signal is to be
+.Em ignored .
+A process may also specify that a default action is to be taken
+by the system when a signal occurs.
+A signal may also be
+.Em blocked
+for a thread,
+in which case it will not be delivered to that thread until it is
+.Em unblocked .
+The action to be taken on delivery is determined at the time
+of delivery.
+Normally, signal handlers execute on the current stack
+of the thread.
+This may be changed, on a per-handler basis,
+so that signals are taken on a special
+.Em "signal stack" .
+.Pp
+Signal routines normally execute with the signal that caused their
+invocation
+.Em blocked ,
+but other signals may yet occur.
+A global
+.Em "signal mask"
+defines the set of signals currently blocked from delivery
+to a thread.
+The signal mask for a thread is initialized
+from that of its parent (normally empty).
+It may be changed with a
+.Xr sigprocmask 2
+or
+.Xr pthread_sigmask 3
+call, or when a signal is delivered to the thread.
+.Pp
+When a signal
+condition arises for a process or thread, the signal is added to a set of
+signals pending for the process or thread.
+Whether the signal is directed at the process in general or at a specific
+thread depends on how it is generated.
+For signals directed at a specific thread,
+if the signal is not currently
+.Em blocked
+by the thread then it is delivered to the thread.
+For signals directed at the process,
+if the signal is not currently
+.Em blocked
+by all threads then it is delivered to one thread that does not have it blocked
+(the selection of which is unspecified).
+Signals may be delivered any time a thread enters the operating system
+(e.g., during a system call, page fault or trap, or clock interrupt).
+If multiple signals are ready to be delivered at the same time,
+any signals that could be caused by traps are delivered first.
+Additional signals may be processed at the same time, with each
+appearing to interrupt the handlers for the previous signals
+before their first instructions.
+The set of pending signals is returned by the
+.Xr sigpending 2
+system call.
+When a caught signal
+is delivered, the current state of the thread is saved,
+a new signal mask is calculated (as described below),
+and the signal handler is invoked.
+The call to the handler
+is arranged so that if the signal handling routine returns
+normally the thread will resume execution in the context
+from before the signal's delivery.
+If the thread wishes to resume in a different context, then it
+must arrange to restore the previous context itself.
+.Pp
+When a signal is delivered to a thread a new signal mask is
+installed for the duration of the process' signal handler
+(or until a
+.Xr sigprocmask 2
+system call is made).
+This mask is formed by taking the union of the current signal mask set,
+the signal to be delivered, and
+the signal mask associated with the handler to be invoked.
+.Pp
+The
+.Fn sigaction
+system call
+assigns an action for a signal specified by
+.Fa sig .
+If
+.Fa act
+is non-NULL, it specifies an action
+.Dv ( SIG_DFL ,
+.Dv SIG_IGN ,
+or a handler routine) and mask to be used when delivering the specified signal.
+If
+.Fa oact
+is non-NULL, the previous handling information for the signal
+is returned to the user.
+.Pp
+The above declaration of
+.Vt "struct sigaction"
+is not literal.
+It is provided only to list the accessible members.
+See
+.In sys/signal.h
+for the actual definition.
+In particular, the storage occupied by
+.Va sa_handler
+and
+.Va sa_sigaction
+overlaps, and it is nonsensical for an application to attempt to use both
+simultaneously.
+.Pp
+Once a signal handler is installed, it normally remains installed
+until another
+.Fn sigaction
+system call is made, or an
+.Xr execve 2
+is performed.
+A signal-specific default action may be reset by
+setting
+.Va sa_handler
+to
+.Dv SIG_DFL .
+The defaults are process termination, possibly with core dump;
+no action; stopping the process; or continuing the process.
+See the signal list below for each signal's default action.
+If
+.Va sa_handler
+is
+.Dv SIG_DFL ,
+the default action for the signal is to discard the signal,
+and if a signal is pending,
+the pending signal is discarded even if the signal is masked.
+If
+.Va sa_handler
+is set to
+.Dv SIG_IGN
+current and pending instances
+of the signal are ignored and discarded.
+.Pp
+Options may be specified by setting
+.Va sa_flags .
+The meaning of the various bits is as follows:
+.Bl -tag -offset indent -width SA_RESETHANDXX
+.It Dv SA_NOCLDSTOP
+If this bit is set when installing a catching function
+for the
+.Dv SIGCHLD
+signal,
+the
+.Dv SIGCHLD
+signal will be generated only when a child process exits,
+not when a child process stops.
+.It Dv SA_NOCLDWAIT
+If this bit is set when calling
+.Fn sigaction
+for the
+.Dv SIGCHLD
+signal, the system will not create zombie processes when children of
+the calling process exit.
+If the calling process subsequently issues a
+.Xr wait 2
+(or equivalent), it blocks until all of the calling process's child
+processes terminate, and then returns a value of \-1 with
+.Va errno
+set to
+.Er ECHILD .
+The same effect of avoiding zombie creation can also be achieved by setting
+.Va sa_handler
+for
+.Dv SIGCHLD
+to
+.Dv SIG_IGN .
+.It Dv SA_ONSTACK
+If this bit is set, the system will deliver the signal to the process
+on a
+.Em "signal stack" ,
+specified by each thread with
+.Xr sigaltstack 2 .
+.It Dv SA_NODEFER
+If this bit is set, further occurrences of the delivered signal are
+not masked during the execution of the handler.
+.It Dv SA_RESETHAND
+If this bit is set, the handler is reset back to
+.Dv SIG_DFL
+at the moment the signal is delivered.
+.It Dv SA_RESTART
+See paragraph below.
+.It Dv SA_SIGINFO
+If this bit is set, the handler function is assumed to be pointed to by the
+.Va sa_sigaction
+member of
+.Vt "struct sigaction"
+and should match the prototype shown above or as below in
+.Sx EXAMPLES .
+This bit should not be set when assigning
+.Dv SIG_DFL
+or
+.Dv SIG_IGN .
+.El
+.Pp
+If a signal is caught during the system calls listed below,
+the call may be forced to terminate
+with the error
+.Er EINTR ,
+the call may return with a data transfer shorter than requested,
+or the call may be restarted.
+Restart of pending calls is requested
+by setting the
+.Dv SA_RESTART
+bit in
+.Va sa_flags .
+The affected system calls include
+.Xr open 2 ,
+.Xr read 2 ,
+.Xr write 2 ,
+.Xr sendto 2 ,
+.Xr recvfrom 2 ,
+.Xr sendmsg 2
+and
+.Xr recvmsg 2
+on a communications channel or a slow device (such as a terminal,
+but not a regular file)
+and during a
+.Xr wait 2
+or
+.Xr ioctl 2 .
+However, calls that have already committed are not restarted,
+but instead return a partial success (for example, a short read count).
+.Pp
+After a
+.Xr pthread_create 3
+the signal mask is inherited by the new thread and
+the set of pending signals and the signal stack for the new thread are empty.
+.Pp
+After a
+.Xr fork 2
+or
+.Xr vfork 2
+all signals, the signal mask, the signal stack,
+and the restart/interrupt flags are inherited by the child.
+.Pp
+The
+.Xr execve 2
+system call reinstates the default
+action for all signals which were caught and
+resets all signals to be caught on the user stack.
+Ignored signals remain ignored;
+the signal mask remains the same;
+signals that restart pending system calls continue to do so.
+.Pp
+The following is a list of all signals
+with names as in the include file
+.In signal.h :
+.Bl -column SIGVTALARMXX "create core imagexxx"
+.It Sy NAME Ta Sy Default Action Ta Sy Description
+.It Dv SIGHUP Ta terminate process Ta terminal line hangup
+.It Dv SIGINT Ta terminate process Ta interrupt program
+.It Dv SIGQUIT Ta create core image Ta quit program
+.It Dv SIGILL Ta create core image Ta illegal instruction
+.It Dv SIGTRAP Ta create core image Ta trace trap
+.It Dv SIGABRT Ta create core image Ta Xr abort 3 call (formerly Dv SIGIOT )
+.It Dv SIGEMT Ta create core image Ta emulate instruction executed
+.It Dv SIGFPE Ta create core image Ta floating-point exception
+.It Dv SIGKILL Ta terminate process Ta kill program
+.It Dv SIGBUS Ta create core image Ta bus error
+.It Dv SIGSEGV Ta create core image Ta segmentation violation
+.It Dv SIGSYS Ta create core image Ta non-existent system call invoked
+.It Dv SIGPIPE Ta terminate process Ta write on a pipe with no reader
+.It Dv SIGALRM Ta terminate process Ta real-time timer expired
+.It Dv SIGTERM Ta terminate process Ta software termination signal
+.It Dv SIGURG Ta discard signal Ta urgent condition present on socket
+.It Dv SIGSTOP Ta stop process Ta stop (cannot be caught or ignored)
+.It Dv SIGTSTP Ta stop process Ta stop signal generated from keyboard
+.It Dv SIGCONT Ta discard signal Ta continue after stop
+.It Dv SIGCHLD Ta discard signal Ta child status has changed
+.It Dv SIGTTIN Ta stop process Ta background read attempted from control terminal
+.It Dv SIGTTOU Ta stop process Ta background write attempted to control terminal
+.It Dv SIGIO Ta discard signal Ta I/O is possible on a descriptor (see Xr fcntl 2 )
+.It Dv SIGXCPU Ta terminate process Ta cpu time limit exceeded (see Xr setrlimit 2 )
+.It Dv SIGXFSZ Ta terminate process Ta file size limit exceeded (see Xr setrlimit 2 )
+.It Dv SIGVTALRM Ta terminate process Ta virtual time alarm (see Xr setitimer 2 )
+.It Dv SIGPROF Ta terminate process Ta profiling timer alarm (see Xr setitimer 2 )
+.It Dv SIGWINCH Ta discard signal Ta window size change
+.It Dv SIGINFO Ta discard signal Ta status request from keyboard
+.It Dv SIGUSR1 Ta terminate process Ta user defined signal 1
+.It Dv SIGUSR2 Ta terminate process Ta user defined signal 2
+.El
+.Sh NOTE
+The
+.Va sa_mask
+field specified in
+.Fa act
+is not allowed to block
+.Dv SIGKILL
+or
+.Dv SIGSTOP .
+Any attempt to do so will be silently ignored.
+.Pp
+The following functions are either reentrant or not interruptible
+by signals and are async-signal safe.
+Therefore applications may
+invoke them, without restriction, from signal-catching functions
+or from a child process after calling
+.Xr fork 2
+in a multi-threaded process:
+.Pp
+Base Interfaces:
+.Pp
+.Fn _Exit ,
+.Fn _exit ,
+.Fn accept ,
+.Fn access ,
+.Fn alarm ,
+.Fn bind ,
+.Fn cfgetispeed ,
+.Fn cfgetospeed ,
+.Fn cfsetispeed ,
+.Fn cfsetospeed ,
+.Fn chdir ,
+.Fn chmod ,
+.Fn chown ,
+.Fn close ,
+.Fn connect ,
+.Fn creat ,
+.Fn dup ,
+.Fn dup2 ,
+.Fn execl ,
+.Fn execle ,
+.Fn execv ,
+.Fn execve ,
+.Fn faccessat ,
+.Fn fchdir ,
+.Fn fchmod ,
+.Fn fchmodat ,
+.Fn fchown ,
+.Fn fchownat ,
+.Fn fcntl ,
+.Fn _Fork ,
+.Fn fstat ,
+.Fn fstatat ,
+.Fn fsync ,
+.Fn ftruncate ,
+.Fn getegid ,
+.Fn geteuid ,
+.Fn getgid ,
+.Fn getgroups ,
+.Fn getpeername ,
+.Fn getpgrp ,
+.Fn getpid ,
+.Fn getppid ,
+.Fn getsockname ,
+.Fn getsockopt ,
+.Fn getuid ,
+.Fn kill ,
+.Fn link ,
+.Fn linkat ,
+.Fn listen ,
+.Fn lseek ,
+.Fn lstat ,
+.Fn mkdir ,
+.Fn mkdirat ,
+.Fn mkfifo ,
+.Fn mkfifoat ,
+.Fn mknod ,
+.Fn mknodat ,
+.Fn open ,
+.Fn openat ,
+.Fn pause ,
+.Fn pipe ,
+.Fn poll ,
+.Fn pselect ,
+.Fn pthread_sigmask ,
+.Fn raise ,
+.Fn read ,
+.Fn readlink ,
+.Fn readlinkat ,
+.Fn recv ,
+.Fn recvfrom ,
+.Fn recvmsg ,
+.Fn rename ,
+.Fn renameat ,
+.Fn rmdir ,
+.Fn select ,
+.Fn send ,
+.Fn sendmsg ,
+.Fn sendto ,
+.Fn setgid ,
+.Fn setpgid ,
+.Fn setsid ,
+.Fn setsockopt ,
+.Fn setuid ,
+.Fn shutdown ,
+.Fn sigaction ,
+.Fn sigaddset ,
+.Fn sigdelset ,
+.Fn sigemptyset ,
+.Fn sigfillset ,
+.Fn sigismember ,
+.Fn signal ,
+.Fn sigpending ,
+.Fn sigprocmask ,
+.Fn sigsuspend ,
+.Fn sleep ,
+.Fn sockatmark ,
+.Fn socket ,
+.Fn socketpair ,
+.Fn stat ,
+.Fn symlink ,
+.Fn symlinkat ,
+.Fn tcdrain ,
+.Fn tcflow ,
+.Fn tcflush ,
+.Fn tcgetattr ,
+.Fn tcgetpgrp ,
+.Fn tcsendbreak ,
+.Fn tcsetattr ,
+.Fn tcsetpgrp ,
+.Fn time ,
+.Fn times ,
+.Fn umask ,
+.Fn uname ,
+.Fn unlink ,
+.Fn unlinkat ,
+.Fn utime ,
+.Fn wait ,
+.Fn waitpid ,
+.Fn write .
+.Pp
+X/Open Systems Interfaces:
+.Pp
+.Fn sigpause ,
+.Fn sigset ,
+.Fn utimes .
+.Pp
+Realtime Interfaces:
+.Pp
+.Fn aio_error ,
+.Fn clock_gettime ,
+.Fn timer_getoverrun ,
+.Fn aio_return ,
+.Fn fdatasync ,
+.Fn sigqueue ,
+.Fn timer_gettime ,
+.Fn aio_suspend ,
+.Fn sem_post ,
+.Fn timer_settime .
+.Pp
+Base Interfaces not specified as async-signal safe by
+.Tn POSIX :
+.Pp
+.Fn fpathconf ,
+.Fn pathconf ,
+.Fn sysconf .
+.Pp
+Base Interfaces not specified as async-signal safe by
+.Tn POSIX ,
+but planned to be:
+.Pp
+.Fn ffs ,
+.Fn htonl ,
+.Fn htons ,
+.Fn memccpy ,
+.Fn memchr ,
+.Fn memcmp ,
+.Fn memcpy ,
+.Fn memmove ,
+.Fn memset ,
+.Fn ntohl ,
+.Fn ntohs ,
+.Fn stpcpy ,
+.Fn stpncpy ,
+.Fn strcat ,
+.Fn strchr ,
+.Fn strcmp ,
+.Fn strcpy ,
+.Fn strcspn ,
+.Fn strlen ,
+.Fn strncat ,
+.Fn strncmp ,
+.Fn strncpy ,
+.Fn strnlen ,
+.Fn strpbrk ,
+.Fn strrchr ,
+.Fn strspn ,
+.Fn strstr ,
+.Fn strtok_r ,
+.Fn wcpcpy ,
+.Fn wcpncpy ,
+.Fn wcscat ,
+.Fn wcschr ,
+.Fn wcscmp ,
+.Fn wcscpy ,
+.Fn wcscspn ,
+.Fn wcslen ,
+.Fn wcsncat ,
+.Fn wcsncmp ,
+.Fn wcsncpy ,
+.Fn wcsnlen ,
+.Fn wcspbrk ,
+.Fn wcsrchr ,
+.Fn wcsspn ,
+.Fn wcsstr ,
+.Fn wcstok ,
+.Fn wmemchr ,
+.Fn wmemcmp ,
+.Fn wmemcpy ,
+.Fn wmemmove ,
+.Fn wmemset .
+.Pp
+Extension Interfaces:
+.Pp
+.Fn accept4 ,
+.Fn bindat ,
+.Fn close_range ,
+.Fn closefrom ,
+.Fn connectat ,
+.Fn eaccess ,
+.Fn ffsl ,
+.Fn ffsll ,
+.Fn flock ,
+.Fn fls ,
+.Fn flsl ,
+.Fn flsll ,
+.Fn futimesat ,
+.Fn pipe2 ,
+.Fn strlcat .
+.Fn strlcpy ,
+.Fn strsep .
+.Pp
+In addition, reading or writing
+.Va errno
+is async-signal safe.
+.Pp
+All functions not in the above lists are considered to be unsafe
+with respect to signals.
+That is to say, the behaviour of such
+functions is undefined when they are called from a signal handler
+that interrupted an unsafe function.
+In general though, signal handlers should do little more than set a
+flag; most other actions are not safe.
+.Pp
+Also, it is good practice to make a copy of the global variable
+.Va errno
+and restore it before returning from the signal handler.
+This protects against the side effect of
+.Va errno
+being set by functions called from inside the signal handler.
+.Sh RETURN VALUES
+.Rv -std sigaction
+.Sh EXAMPLES
+There are three possible prototypes the handler may match:
+.Bl -tag -offset indent -width short
+.It Tn ANSI C :
+.Ft void
+.Fn handler int ;
+.It Traditional BSD style:
+.Ft void
+.Fn handler int "int code" "struct sigcontext *scp" ;
+.It Tn POSIX Dv SA_SIGINFO :
+.Ft void
+.Fn handler int "siginfo_t *info" "ucontext_t *uap" ;
+.El
+.Pp
+The handler function should match the
+.Dv SA_SIGINFO
+prototype if the
+.Dv SA_SIGINFO
+bit is set in
+.Va sa_flags .
+It then should be pointed to by the
+.Va sa_sigaction
+member of
+.Vt "struct sigaction" .
+Note that you should not assign
+.Dv SIG_DFL
+or
+.Dv SIG_IGN
+this way.
+.Pp
+If the
+.Dv SA_SIGINFO
+flag is not set, the handler function should match
+either the
+.Tn ANSI C
+or traditional
+.Bx
+prototype and be pointed to by
+the
+.Va sa_handler
+member of
+.Vt "struct sigaction" .
+In practice,
+.Fx
+always sends the three arguments of the latter and since the
+.Tn ANSI C
+prototype is a subset, both will work.
+The
+.Va sa_handler
+member declaration in
+.Fx
+include files is that of
+.Tn ANSI C
+(as required by
+.Tn POSIX ) ,
+so a function pointer of a
+.Bx Ns -style
+function needs to be casted to
+compile without warning.
+The traditional
+.Bx
+style is not portable and since its capabilities
+are a full subset of a
+.Dv SA_SIGINFO
+handler,
+its use is deprecated.
+.Pp
+The
+.Fa sig
+argument is the signal number, one of the
+.Dv SIG...
+values from
+.In signal.h .
+.Pp
+The
+.Fa code
+argument of the
+.Bx Ns -style
+handler and the
+.Va si_code
+member of the
+.Fa info
+argument to a
+.Dv SA_SIGINFO
+handler contain a numeric code explaining the
+cause of the signal, usually one of the
+.Dv SI_...
+values from
+.In sys/signal.h
+or codes specific to a signal, i.e., one of the
+.Dv FPE_...
+values for
+.Dv SIGFPE .
+.Pp
+The
+.Fa scp
+argument to a
+.Bx Ns -style
+handler points to an instance of
+.Vt "struct sigcontext" .
+.Pp
+The
+.Fa uap
+argument to a
+.Tn POSIX
+.Dv SA_SIGINFO
+handler points to an instance of
+ucontext_t.
+.Sh ERRORS
+The
+.Fn sigaction
+system call
+will fail and no new signal handler will be installed if one
+of the following occurs:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa sig
+argument
+is not a valid signal number.
+.It Bq Er EINVAL
+An attempt is made to ignore or supply a handler for
+.Dv SIGKILL
+or
+.Dv SIGSTOP .
+.El
+.Sh SEE ALSO
+.Xr kill 1 ,
+.Xr kill 2 ,
+.Xr ptrace 2 ,
+.Xr setitimer 2 ,
+.Xr setrlimit 2 ,
+.Xr sigaltstack 2 ,
+.Xr sigpending 2 ,
+.Xr sigprocmask 2 ,
+.Xr sigsuspend 2 ,
+.Xr wait 2 ,
+.Xr fpsetmask 3 ,
+.Xr setjmp 3 ,
+.Xr siginfo 3 ,
+.Xr siginterrupt 3 ,
+.Xr sigsetops 3 ,
+.Xr ucontext 3 ,
+.Xr tty 4
+.Sh STANDARDS
+The
+.Fn sigaction
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Dv SA_ONSTACK
+and
+.Dv SA_RESTART
+flags are Berkeley extensions,
+as are the signals,
+.Dv SIGTRAP ,
+.Dv SIGEMT ,
+.Dv SIGBUS ,
+.Dv SIGSYS ,
+.Dv SIGURG ,
+.Dv SIGIO ,
+.Dv SIGXCPU ,
+.Dv SIGXFSZ ,
+.Dv SIGVTALRM ,
+.Dv SIGPROF ,
+.Dv SIGWINCH ,
+and
+.Dv SIGINFO .
+Those signals are available on most
+.Bx Ns \-derived
+systems.
+The
+.Dv SA_NODEFER
+and
+.Dv SA_RESETHAND
+flags are intended for backwards compatibility with other operating
+systems.
+The
+.Dv SA_NOCLDSTOP ,
+and
+.Dv SA_NOCLDWAIT
+.\" and
+.\" SA_SIGINFO
+flags are featuring options commonly found in other operating systems.
+The flags are approved by
+.St -susv2 ,
+along with the option to avoid zombie creation by ignoring
+.Dv SIGCHLD .
diff --git a/lib/libsys/sigaltstack.2 b/lib/libsys/sigaltstack.2
new file mode 100644
index 000000000000..388e1e58bd94
--- /dev/null
+++ b/lib/libsys/sigaltstack.2
@@ -0,0 +1,159 @@
+.\" Copyright (c) 1983, 1991, 1992, 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.
+.\"
+.Dd May 6, 2010
+.Dt SIGALTSTACK 2
+.Os
+.Sh NAME
+.Nm sigaltstack
+.Nd set and/or get signal stack context
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Bd -literal
+typedef struct {
+ char *ss_sp;
+ size_t ss_size;
+ int ss_flags;
+} stack_t;
+.Ed
+.Ft int
+.Fn sigaltstack "const stack_t * restrict ss" "stack_t * restrict oss"
+.Sh DESCRIPTION
+The
+.Fn sigaltstack
+system call
+allows defining an alternate stack on which signals
+are to be processed for the current thread.
+If
+.Fa ss
+is non-zero,
+it specifies a pointer to and the size of a
+.Em "signal stack"
+on which to deliver signals.
+When a signal's action indicates its handler
+should execute on the signal stack (specified with a
+.Xr sigaction 2
+system call), the system checks to see
+if the thread is currently executing on that stack.
+If the thread is not currently executing on the signal stack,
+the system arranges a switch to the signal stack for the
+duration of the signal handler's execution.
+.Pp
+An active stack cannot be modified.
+.Pp
+If
+.Dv SS_DISABLE
+is set in
+.Fa ss_flags ,
+.Fa ss_sp
+and
+.Fa ss_size
+are ignored and the signal stack will be disabled.
+A disabled stack will cause all signals to be
+taken on the regular user stack.
+If the stack is later re-enabled then all signals that were specified
+to be processed on an alternate stack will resume doing so.
+.Pp
+If
+.Fa oss
+is non-zero, the current signal stack state is returned.
+The
+.Fa ss_flags
+field will contain the value
+.Dv SS_ONSTACK
+if the thread is currently on a signal stack and
+.Dv SS_DISABLE
+if the signal stack is currently disabled.
+.Sh NOTES
+The value
+.Dv SIGSTKSZ
+is defined to be the number of bytes/chars that would be used to cover
+the usual case when allocating an alternate stack area.
+The following code fragment is typically used to allocate an alternate stack.
+.Bd -literal -offset indent
+if ((sigstk.ss_sp = malloc(SIGSTKSZ)) == NULL)
+ /* error return */
+sigstk.ss_size = SIGSTKSZ;
+sigstk.ss_flags = 0;
+if (sigaltstack(&sigstk, NULL) < 0)
+ perror("sigaltstack");
+.Ed
+An alternative approach is provided for programs with signal handlers
+that require a specific amount of stack space other than the default size.
+The value
+.Dv MINSIGSTKSZ
+is defined to be the number of bytes/chars that is required by
+the operating system to implement the alternate stack feature.
+In computing an alternate stack size,
+programs should add
+.Dv MINSIGSTKSZ
+to their stack requirements to allow for the operating system overhead.
+.Pp
+Signal stacks are automatically adjusted for the direction of stack
+growth and alignment requirements.
+Signal stacks may or may not be protected by the hardware and
+are not ``grown'' automatically as is done for the normal stack.
+If the stack overflows and this space is not protected
+unpredictable results may occur.
+.Sh RETURN VALUES
+.Rv -std sigaltstack
+.Sh ERRORS
+The
+.Fn sigaltstack
+system call
+will fail and the signal stack context will remain unchanged
+if one of the following occurs.
+.Bl -tag -width Er
+.It Bq Er EFAULT
+Either
+.Fa ss
+or
+.Fa oss
+points to memory that is not a valid part of the process
+address space.
+.It Bq Er EPERM
+An attempt was made to modify an active stack.
+.It Bq Er EINVAL
+The
+.Fa ss_flags
+field was invalid.
+.It Bq Er ENOMEM
+Size of alternate stack area is less than or equal to
+.Dv MINSIGSTKSZ .
+.El
+.Sh SEE ALSO
+.Xr sigaction 2 ,
+.Xr setjmp 3
+.Sh HISTORY
+The predecessor to
+.Fn sigaltstack ,
+the
+.Fn sigstack
+system call, appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/sigfastblock.2 b/lib/libsys/sigfastblock.2
new file mode 100644
index 000000000000..19d649e63db9
--- /dev/null
+++ b/lib/libsys/sigfastblock.2
@@ -0,0 +1,164 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd December 13, 2019
+.Dt SIGFASTBLOCK 2
+.Os
+.Sh NAME
+.Nm sigfastblock
+.Nd controls signals blocking with a simple memory write
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/signalvar.h
+.Ft int
+.Fn sigfastblock "int cmd" "void *ptr"
+.Sh DESCRIPTION
+.Bf -symbolic
+This function is not intended for a direct usage by applications.
+The functionality is provided for implementing some optimizations in
+.Xr ld-elf.so.1 8
+and
+.Lb libthr .
+.Ef
+.Pp
+The function configures the kernel facility that allows a thread to
+block asynchronous signals delivery with a single write to userspace
+memory, avoiding overhead of system calls like
+.Xr sigprocmask 2
+for establishing critical sections.
+The C runtime uses it to optimize implementation of async-signal-safe
+functionality.
+.Pp
+A thread might register a
+.Dv sigblock
+variable of type
+.Vt int
+as a location which is consulted by kernel when calculating the
+blocked signal mask for delivery of asynchronous signals.
+If the variable indicates that blocking is requested, then the kernel
+effectively operates as if the mask containing all blockable signals was
+supplied to
+.Xr sigprocmask 2 .
+.Pp
+The variable is supposed to be modified only from the owning thread,
+there is no way to guarantee visibility of update from other thread
+to kernel when signals are delivered.
+.Pp
+Lower bits of the sigblock variable are reserved as flags,
+which might be set or cleared by kernel at arbitrary moments.
+Userspace code should use
+.Xr atomic 9
+operations of incrementing and decrementing by
+.Dv SIGFASTBLOCK_INC
+quantity to recursively block or unblock signals delivery.
+.Pp
+If a signal would be delivered when unmasked, kernel might set the
+.Dv SIGFASTBLOCK_PEND
+.Dq pending signal
+flag in the sigblock variable.
+Userspace should perform
+.Dv SIGFASTBLOCK_UNBLOCK
+operation when clearing the variable if it notes the pending signal
+bit is set, which would deliver the pending signals immediately.
+Otherwise, signals delivery might be postponed.
+.Pp
+The
+.Fa cmd
+argument specifies one of the following operations:
+.Bl -tag -width SIGFASTBLOCK_UNSETPTR
+.It Dv SIGFASTBLOCK_SETPTR
+Register the variable of type
+.Vt int
+at location pointed to by the
+.Fa ptr
+argument as sigblock variable for the calling thread.
+.It Dv SIGFASTBLOCK_UNSETPTR
+Unregister the currently registered sigblock location.
+Kernel stops inferring the blocked mask from non-zero value of its
+blocked count.
+New location can be registered after previous one is deregistered.
+.It Dv SIGFASTBLOCK_UNBLOCK
+If there are pending signals which should be delivered to the calling
+thread, they are delivered before returning from the call.
+The sigblock variable should have zero blocking count, and indicate
+that the pending signal exists.
+Effectively this means that the variable should have the value
+.Dv SIGFASTBLOCK_PEND .
+.El
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The operation may fail with the following errors:
+.Bl -tag -width Er
+.It Bq Er EBUSY
+The
+.Dv SIGFASTBLOCK_SETPTR
+attempted while the sigblock address was already registered.
+The
+.Dv SIGFASTBLOCK_UNBLOCK
+was called while sigblock variable value is not equal to
+.Dv SIGFASTBLOCK_PEND .
+.It Bq Er EINVAL
+The variable address passed to
+.Dv SIGFASTBLOCK_SETPTR
+is not aligned naturally.
+The
+.Dv SIGFASTBLOCK_UNSETPTR
+operation was attempted without prior successful call to
+.Dv SIGFASTBLOCK_SETPTR .
+.It Bq Er EFAULT
+Attempt to read or write to the sigblock variable failed.
+Note that kernel generates the
+.Dv SIGSEGV
+signal if an attempt to read from the sigblock variable faulted
+during implicit accesses from syscall entry.
+.El
+.Sh SEE ALSO
+.Xr kill 2 ,
+.Xr signal 2 ,
+.Xr sigprocmask 2 ,
+.Xr libthr 3 ,
+.Xr ld-elf.so.1 8
+.Sh STANDARDS
+The
+.Nm
+function is non-standard, although a similar functionality is a common
+optimization provided by several other systems.
+.Sh HISTORY
+The
+.Nm
+function was introduced in
+.Fx 13.0 .
+.Sh BUGS
+The
+.Nm
+symbol is currently not exported by libc, on purpose.
+Consumers should either use the
+.Dv __sys_fast_sigblock
+symbol from the private libc namespace, or utilize
+.Xr syscall 2 .
diff --git a/lib/libsys/sigpending.2 b/lib/libsys/sigpending.2
new file mode 100644
index 000000000000..412f128778fb
--- /dev/null
+++ b/lib/libsys/sigpending.2
@@ -0,0 +1,74 @@
+.\" Copyright (c) 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" Berkeley Software Design, 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.
+.\"
+.Dd September 6, 2013
+.Dt SIGPENDING 2
+.Os
+.Sh NAME
+.Nm sigpending
+.Nd get pending signals
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Ft int
+.Fn sigpending "sigset_t *set"
+.Sh DESCRIPTION
+The
+.Fn sigpending
+system call returns a mask of the signals pending for delivery
+to the calling thread or the calling process in the location indicated by
+.Fa set .
+Signals may be pending because they are currently masked,
+or transiently before delivery (although the latter case is not
+normally detectable).
+.Sh RETURN VALUES
+.Rv -std sigpending
+.Sh ERRORS
+The
+.Fn sigpending
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa set
+argument specified an invalid address.
+.El
+.Sh SEE ALSO
+.Xr sigaction 2 ,
+.Xr sigprocmask 2 ,
+.Xr sigsuspend 2 ,
+.Xr sigsetops 3
+.Sh STANDARDS
+The
+.Fn sigpending
+system call is expected to conform to
+.St -p1003.1-90 .
diff --git a/lib/libsys/sigprocmask.2 b/lib/libsys/sigprocmask.2
new file mode 100644
index 000000000000..351047a0fa66
--- /dev/null
+++ b/lib/libsys/sigprocmask.2
@@ -0,0 +1,128 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd May 7, 2010
+.Dt SIGPROCMASK 2
+.Os
+.Sh NAME
+.Nm sigprocmask
+.Nd manipulate current signal mask
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Ft int
+.Fo sigprocmask
+.Fa "int how"
+.Fa "const sigset_t * restrict set"
+.Fa "sigset_t * restrict oset"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn sigprocmask
+system call examines and/or changes the current signal mask (those signals
+that are blocked from delivery).
+Signals are blocked if they are members of the current signal mask set.
+.Pp
+If
+.Fa set
+is not null, the action of
+.Fn sigprocmask
+depends on the value of the
+.Fa how
+argument.
+The signal mask is changed as a function of the specified
+.Fa set
+and the current mask.
+The function is specified by
+.Fa how
+using one of the following values from
+.In signal.h :
+.Bl -tag -width SIG_UNBLOCK
+.It Dv SIG_BLOCK
+The new mask is the union of the current mask and the specified
+.Fa set .
+.It Dv SIG_UNBLOCK
+The new mask is the intersection of the current mask
+and the complement of the specified
+.Fa set .
+.It Dv SIG_SETMASK
+The current mask is replaced by the specified
+.Fa set .
+.El
+.Pp
+If
+.Fa oset
+is not null, it is set to
+the previous value of the signal mask.
+When
+.Fa set
+is null,
+the value of
+.Fa how
+is insignificant and the mask remains unset
+providing a way to examine the signal mask without modification.
+.Pp
+The system
+quietly disallows
+.Dv SIGKILL
+or
+.Dv SIGSTOP
+to be blocked.
+.Pp
+In threaded applications,
+.Xr pthread_sigmask 3
+must be used instead of
+.Fn sigprocmask .
+.Sh RETURN VALUES
+.Rv -std sigprocmask
+.Sh ERRORS
+The
+.Fn sigprocmask
+system call will fail and the signal mask will be unchanged if one
+of the following occurs:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa how
+argument
+has a value other than those listed here.
+.El
+.Sh SEE ALSO
+.Xr kill 2 ,
+.Xr sigaction 2 ,
+.Xr sigpending 2 ,
+.Xr sigsuspend 2 ,
+.Xr fpsetmask 3 ,
+.Xr pthread_sigmask 3 ,
+.Xr sigsetops 3
+.Sh STANDARDS
+The
+.Fn sigprocmask
+system call is expected to
+conform to
+.St -p1003.1-90 .
diff --git a/lib/libsys/sigqueue.2 b/lib/libsys/sigqueue.2
new file mode 100644
index 000000000000..2fac63610ac7
--- /dev/null
+++ b/lib/libsys/sigqueue.2
@@ -0,0 +1,178 @@
+.\" Copyright (c) 2005 David Xu <davidxu@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(s), this list of conditions and the following disclaimer as
+.\" the first lines of this file unmodified other than the possible
+.\" addition of one or more copyright notices.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
+.\"
+.Dd April 21, 2024
+.Dt SIGQUEUE 2
+.Os
+.Sh NAME
+.Nm sigqueue
+.Nd "queue a signal to a process (REALTIME)"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Ft int
+.Fn sigqueue "pid_t pid" "int signo" "const union sigval value"
+.Sh DESCRIPTION
+The
+.Fn sigqueue
+system call causes the signal specified by
+.Fa signo
+to be sent with the value specified by
+.Fa value
+to the process specified by
+.Fa pid .
+If
+.Fa signo
+is zero (the null signal), error checking is performed but
+no signal is actually sent.
+The null signal can be used to check the
+validity of PID.
+.Pp
+The conditions required for a process to have permission to queue a
+signal to another process are the same as for the
+.Xr kill 2
+system call.
+The
+.Fn sigqueue
+system call queues a signal to a single process specified by the
+.Fa pid
+argument.
+.Pp
+The
+.Fn sigqueue
+system call returns immediately.
+If the resources were
+available to queue the signal, the signal will be queued and sent to
+the receiving process.
+.Pp
+If the value of
+.Fa pid
+causes
+.Fa signo
+to be generated for the sending process, and if
+.Fa signo
+is not blocked for the calling thread and if no other thread has
+.Fa signo
+unblocked or is waiting in a
+.Fn sigwait
+system call for
+.Fa signo ,
+either
+.Fa signo
+or at least the pending, unblocked signal will be delivered to the
+calling thread before
+.Fn sigqueue
+returns.
+Should any multiple pending signals in the range
+.Dv SIGRTMIN
+to
+.Dv SIGRTMAX
+be selected for delivery, it is the lowest numbered
+one.
+The selection order between realtime and non-realtime signals, or
+between multiple pending non-realtime signals, is unspecified.
+.Pp
+As a
+.Fx
+extension, the value of
+.Fa signo
+can be or-ed with the following flags:
+.Bl -tag -width __SIGQUEUE_TID
+.It Dv __SIGQUEUE_TID
+The
+.Fa pid
+parameter is the thread identifier of a thread in the current process,
+and the specified signal is queued into the specified thread' queue.
+.El
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn sigqueue
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+No resources are available to queue the signal.
+The process has already
+queued
+.Brq Dv SIGQUEUE_MAX
+signals that are still pending at the receiver(s),
+or a system-wide resource limit has been exceeded.
+.It Bq Er EINVAL
+The value of the
+.Fa signo
+argument is an invalid or unsupported signal number.
+.It Bq Er EPERM
+The process does not have the appropriate privilege to send the signal
+to the receiving process.
+.It Bq Er ESRCH
+The process
+.Fa pid
+does not exist.
+.It Bq Er ESRCH
+The thread with id
+.Fa pid
+does not exist in the current process.
+.El
+.Sh SEE ALSO
+.Xr kill 2 ,
+.Xr sigaction 2 ,
+.Xr sigpending 2 ,
+.Xr sigsuspend 2 ,
+.Xr sigtimedwait 2 ,
+.Xr sigwait 2 ,
+.Xr sigwaitinfo 2 ,
+.Xr pause 3 ,
+.Xr pthread_sigmask 3 ,
+.Xr siginfo 3
+.Sh STANDARDS
+The
+.Fn sigqueue
+system call conforms to
+.St -p1003.1-2004 .
+.Sh HISTORY
+Support for
+.Tn POSIX
+realtime signal queue first appeared in
+.Fx 7.0 .
+.Sh CAVEATS
+When using
+.Nm
+to send signals to a process which might have a different ABI
+(for instance, one is 32-bit and the other 64-bit),
+the
+.Va sival_int
+member of
+.Fa value
+can be delivered reliably, but the
+.Va sival_ptr
+may be truncated in endian dependent ways and must not be relied on.
+Further, many pointer integrity schemes disallow sending pointers to other
+processes, and this technique should not be used in programs intended to
+be portable.
diff --git a/lib/libsys/sigreturn.2 b/lib/libsys/sigreturn.2
new file mode 100644
index 000000000000..4effeaa5abc7
--- /dev/null
+++ b/lib/libsys/sigreturn.2
@@ -0,0 +1,86 @@
+.\" Copyright (c) 1985, 1991, 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.
+.\"
+.Dd September 6, 2013
+.Dt SIGRETURN 2
+.Os
+.Sh NAME
+.Nm sigreturn
+.Nd return from signal
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Ft int
+.Fn sigreturn "const ucontext_t *scp"
+.Sh DESCRIPTION
+The
+.Fn sigreturn
+system call
+allows users to atomically unmask, switch stacks,
+and return from a signal context.
+The thread's signal mask and stack status are
+restored from the context structure pointed to by
+.Fa scp .
+The system call does not return;
+the users stack pointer, frame pointer, argument pointer,
+and processor status longword are restored from the context.
+Execution resumes at the specified pc.
+This system call is used by the trampoline code and
+.Xr longjmp 3
+when returning from a signal to the previously executing program.
+.Sh RETURN VALUES
+If successful, the system call does not return.
+Otherwise, a value of -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn sigreturn
+system call
+will fail and the thread context will remain unchanged
+if one of the following occurs.
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The
+.Fa scp
+argument
+points to memory that is not a valid part of the process
+address space.
+.It Bq Er EINVAL
+The process status longword is invalid or would improperly
+raise the privilege level of the process.
+.El
+.Sh SEE ALSO
+.Xr sigaction 2 ,
+.Xr setjmp 3 ,
+.Xr ucontext 3
+.Sh HISTORY
+The
+.Fn sigreturn
+system call appeared in
+.Bx 4.3 .
diff --git a/lib/libsys/sigstack.2 b/lib/libsys/sigstack.2
new file mode 100644
index 000000000000..3e60d4dace6a
--- /dev/null
+++ b/lib/libsys/sigstack.2
@@ -0,0 +1,47 @@
+.\" Copyright (c) 1983, 1992, 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.
+.\"
+.Dd June 4, 1993
+.Dt SIGSTACK 2
+.Os
+.Sh NAME
+.Nm sigstack
+.Nd set and/or get signal stack context
+.Sh LIBRARY
+.Lb libc
+.Sh DESCRIPTION
+The
+.Fn sigstack
+function has been deprecated in favor of the interface described in
+.Xr sigaltstack 2 .
+.Sh SEE ALSO
+.Xr sigaltstack 2
+.Sh HISTORY
+The
+.Fn sigstack
+system call appeared in
+.Bx 4.2 .
diff --git a/lib/libsys/sigsuspend.2 b/lib/libsys/sigsuspend.2
new file mode 100644
index 000000000000..717bd3ff6858
--- /dev/null
+++ b/lib/libsys/sigsuspend.2
@@ -0,0 +1,82 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd August 16, 2013
+.Dt SIGSUSPEND 2
+.Os
+.Sh NAME
+.Nm sigsuspend
+.Nd atomically release blocked signals and wait for interrupt
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In signal.h
+.Ft int
+.Fn sigsuspend "const sigset_t *sigmask"
+.Sh DESCRIPTION
+The
+.Fn sigsuspend
+system call
+temporarily changes the blocked signal mask to the set to which
+.Fa sigmask
+points,
+and then waits for a signal to arrive;
+on return the previous set of masked signals is restored.
+The signal mask set
+is usually empty to indicate that all
+signals are to be unblocked for the duration of the call.
+.Pp
+In normal usage, a signal is blocked using
+.Xr sigprocmask 2
+to begin a critical section, variables modified on the occurrence
+of the signal are examined to determine that there is no work
+to be done, and the process pauses awaiting work by using
+.Fn sigsuspend
+with the previous mask returned by
+.Xr sigprocmask 2 .
+.Sh RETURN VALUES
+The
+.Fn sigsuspend
+system call
+always terminates by being interrupted, returning -1 with
+.Va errno
+set to
+.Er EINTR .
+.Sh SEE ALSO
+.Xr pselect 2 ,
+.Xr sigaction 2 ,
+.Xr sigpending 2 ,
+.Xr sigprocmask 2 ,
+.Xr sigtimedwait 2 ,
+.Xr sigwait 2 ,
+.Xr sigwaitinfo 2 ,
+.Xr sigsetops 3
+.Sh STANDARDS
+The
+.Fn sigsuspend
+system call is expected to conform to
+.St -p1003.1-90 .
diff --git a/lib/libc/sys/sigwait.2 b/lib/libsys/sigwait.2
index cd8a6bd026d4..cd8a6bd026d4 100644
--- a/lib/libc/sys/sigwait.2
+++ b/lib/libsys/sigwait.2
diff --git a/lib/libc/sys/sigwaitinfo.2 b/lib/libsys/sigwaitinfo.2
index 10fc29ce39a7..10fc29ce39a7 100644
--- a/lib/libc/sys/sigwaitinfo.2
+++ b/lib/libsys/sigwaitinfo.2
diff --git a/lib/libsys/sleep.3 b/lib/libsys/sleep.3
new file mode 100644
index 000000000000..b47cdaa4a59a
--- /dev/null
+++ b/lib/libsys/sleep.3
@@ -0,0 +1,80 @@
+.\" Copyright (c) 1986, 1991, 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.
+.\"
+.Dd February 13, 1998
+.Dt SLEEP 3
+.Os
+.Sh NAME
+.Nm sleep
+.Nd suspend thread execution for an interval measured in seconds
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft unsigned int
+.Fn sleep "unsigned int seconds"
+.Sh DESCRIPTION
+The
+.Fn sleep
+function suspends execution of the calling thread until either
+.Fa seconds
+seconds have elapsed or a signal is delivered to the thread and its
+action is to invoke a signal-catching function or to terminate the
+thread or process.
+System activity may lengthen the sleep by an indeterminate amount.
+.Pp
+This function is implemented using
+.Xr nanosleep 2
+by pausing for
+.Fa seconds
+seconds or until a signal occurs.
+Consequently, in this implementation,
+sleeping has no effect on the state of process timers,
+and there is no special handling for SIGALRM.
+.Sh RETURN VALUES
+If the
+.Fn sleep
+function returns because the requested time has elapsed, the value
+returned will be zero.
+If the
+.Fn sleep
+function returns due to the delivery of a signal, the value returned
+will be the unslept amount (the requested time minus the time actually
+slept) in seconds.
+.Sh SEE ALSO
+.Xr nanosleep 2 ,
+.Xr usleep 3
+.Sh STANDARDS
+The
+.Fn sleep
+function conforms to
+.St -p1003.1-90 .
+.Sh HISTORY
+A
+.Fn sleep
+function appeared in
+.At v7 .
diff --git a/lib/libsys/socket.2 b/lib/libsys/socket.2
new file mode 100644
index 000000000000..b211611c6354
--- /dev/null
+++ b/lib/libsys/socket.2
@@ -0,0 +1,358 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd May 17, 2025
+.Dt SOCKET 2
+.Os
+.Sh NAME
+.Nm socket
+.Nd create an endpoint for communication
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/socket.h
+.Ft int
+.Fn socket "int domain" "int type" "int protocol"
+.Sh DESCRIPTION
+The
+.Fn socket
+system call
+creates an endpoint for communication and returns a descriptor.
+.Pp
+The
+.Fa domain
+argument specifies a communications domain within which
+communication will take place; this selects the protocol family
+which should be used.
+These families are defined in the include file
+.In sys/socket.h .
+The currently understood formats are:
+.Pp
+.Bd -literal -offset indent -compact
+PF_LOCAL Host-internal protocols (alias for PF_UNIX),
+PF_UNIX Host-internal protocols,
+PF_INET Internet version 4 protocols,
+PF_INET6 Internet version 6 protocols,
+PF_DIVERT Firewall packet diversion/re-injection,
+PF_ROUTE Internal routing protocol,
+PF_KEY Internal key-management function,
+PF_NETGRAPH Netgraph sockets,
+PF_NETLINK Netlink protocols,
+PF_BLUETOOTH Bluetooth protocols,
+PF_INET_SDP OFED socket direct protocol (IPv4),
+AF_HYPERV HyperV sockets
+.Ed
+.Pp
+Each protocol family is connected to an address family, which has the
+same name except that the prefix is
+.Dq Dv AF_
+in place of
+.Dq Dv PF_ .
+Other protocol families may be also defined, beginning with
+.Dq Dv PF_ ,
+with corresponding address families.
+.Pp
+The socket has the indicated
+.Fa type ,
+which specifies the semantics of communication.
+Currently
+defined types are:
+.Pp
+.Bd -literal -offset indent -compact
+SOCK_STREAM Stream socket,
+SOCK_DGRAM Datagram socket,
+SOCK_RAW Raw-protocol interface,
+SOCK_SEQPACKET Sequenced packet stream
+.Ed
+.Pp
+A
+.Dv SOCK_STREAM
+type provides sequenced, reliable,
+two-way connection based byte streams.
+An out-of-band data transmission mechanism may be supported.
+A
+.Dv SOCK_DGRAM
+socket supports
+datagrams (connectionless, unreliable messages of
+a fixed (typically small) maximum length).
+A
+.Dv SOCK_SEQPACKET
+socket may provide a sequenced, reliable,
+two-way connection-based data transmission path for datagrams
+of fixed maximum length; a consumer may be required to read
+an entire packet with each read system call.
+This facility may have protocol-specific properties.
+.Dv SOCK_RAW
+sockets provide access to internal network protocols and interfaces.
+The
+.Dv SOCK_RAW
+type is available only to the super-user and is described in
+.Xr ip 4
+and
+.Xr ip6 4 .
+.Pp
+Additionally, the following flags are allowed in the
+.Fa type
+argument:
+.Pp
+.Bd -literal -offset indent -compact
+SOCK_CLOEXEC Set close-on-exec on the new descriptor,
+SOCK_CLOFORK Set close-on-fork on the new descriptor,
+SOCK_NONBLOCK Set non-blocking mode on the new socket
+.Ed
+.Pp
+The
+.Fa protocol
+argument
+specifies a particular protocol to be used with the socket.
+Normally only a single protocol exists to support a particular
+socket type within a given protocol family.
+However, it is possible
+that many protocols may exist, in which case a particular protocol
+must be specified in this manner.
+The protocol number to use is
+particular to the
+.Dq "communication domain"
+in which communication
+is to take place; see
+.Xr protocols 5 .
+.Pp
+The
+.Fa protocol
+argument may be set to zero (0) to request the default
+implementation of a socket type for the protocol, if any.
+.Pp
+Sockets of type
+.Dv SOCK_STREAM
+are full-duplex byte streams, similar
+to pipes.
+A stream socket must be in a
+.Em connected
+state before any data may be sent or received
+on it.
+A connection to another socket is created with a
+.Xr connect 2
+system call.
+Once connected, data may be transferred using
+.Xr read 2
+and
+.Xr write 2
+calls or some variant of the
+.Xr send 2
+and
+.Xr recv 2
+functions.
+(Some protocol families, such as the Internet family,
+support the notion of an
+.Dq implied connect ,
+which permits data to be sent piggybacked onto a connect operation by
+using the
+.Xr sendto 2
+system call.)
+When a session has been completed a
+.Xr close 2
+may be performed.
+Out-of-band data may also be transmitted as described in
+.Xr send 2
+and received as described in
+.Xr recv 2 .
+.Pp
+The communications protocols used to implement a
+.Dv SOCK_STREAM
+ensure that data
+is not lost or duplicated.
+If a piece of data for which the
+peer protocol has buffer space cannot be successfully transmitted
+within a reasonable length of time, then
+the connection is considered broken and calls
+will indicate an error with
+-1 returns and with
+.Er ETIMEDOUT
+as the specific code
+in the global variable
+.Va errno .
+The protocols optionally keep sockets
+.Dq warm
+by forcing transmissions
+roughly every minute in the absence of other activity.
+An error is then indicated if no response can be
+elicited on an otherwise
+idle connection for an extended period (e.g.\& 5 minutes).
+By default, a
+.Dv SIGPIPE
+signal is raised if a process sends
+on a broken stream, but this behavior may be inhibited via
+.Xr setsockopt 2 .
+.Pp
+.Dv SOCK_SEQPACKET
+sockets employ the same system calls
+as
+.Dv SOCK_STREAM
+sockets.
+The only difference
+is that
+.Xr read 2
+calls will return only the amount of data requested,
+and any remaining in the arriving packet will be discarded.
+.Pp
+.Dv SOCK_DGRAM
+and
+.Dv SOCK_RAW
+sockets allow sending of datagrams to correspondents
+named in
+.Xr send 2
+calls.
+Datagrams are generally received with
+.Xr recvfrom 2 ,
+which returns the next datagram with its return address.
+.Pp
+An
+.Xr fcntl 2
+system call can be used to specify a process group to receive
+a
+.Dv SIGURG
+signal when the out-of-band data arrives.
+It may also enable non-blocking I/O
+and asynchronous notification of I/O events
+via
+.Dv SIGIO .
+.Pp
+The operation of sockets is controlled by socket level
+.Em options .
+These options are defined in the file
+.In sys/socket.h .
+The
+.Xr setsockopt 2
+and
+.Xr getsockopt 2
+system calls are used to set and get options, respectively.
+.Sh RETURN VALUES
+A -1 is returned if an error occurs, otherwise the return
+value is a descriptor referencing the socket.
+.Sh ERRORS
+The
+.Fn socket
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Permission to create a socket of the specified type and/or protocol
+is denied.
+.It Bq Er EAFNOSUPPORT
+The address family (domain) is not supported or the
+specified domain is not supported by this protocol family.
+.It Bq Er EMFILE
+The per-process descriptor table is full.
+.It Bq Er ENFILE
+The system file table is full.
+.It Bq Er ENOBUFS
+Insufficient buffer space is available.
+The socket cannot be created until sufficient resources are freed.
+.It Bq Er EPERM
+User has insufficient privileges to carry out the requested operation.
+.It Bq Er EPROTONOSUPPORT
+The protocol type or the specified protocol is not supported
+within this domain.
+.It Bq Er EPROTOTYPE
+The socket type is not supported by the protocol.
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr bind 2 ,
+.Xr connect 2 ,
+.Xr getpeername 2 ,
+.Xr getsockname 2 ,
+.Xr getsockopt 2 ,
+.Xr ioctl 2 ,
+.Xr listen 2 ,
+.Xr read 2 ,
+.Xr recv 2 ,
+.Xr select 2 ,
+.Xr send 2 ,
+.Xr shutdown 2 ,
+.Xr socketpair 2 ,
+.Xr write 2 ,
+.Xr CMSG_DATA 3 ,
+.Xr getprotoent 3 ,
+.Xr divert 4 ,
+.Xr ip 4 ,
+.Xr ip6 4 ,
+.Xr netgraph 4 ,
+.Xr protocols 5
+.Rs
+.%T "An Introductory 4.3 BSD Interprocess Communication Tutorial"
+.%B PS1
+.%N 7
+.Re
+.Rs
+.%T "BSD Interprocess Communication Tutorial"
+.%B PS1
+.%N 8
+.Re
+.Sh STANDARDS
+The
+.Fn socket
+function conforms to
+.St -p1003.1-2008 .
+The
+.Tn POSIX
+standard specifies only the
+.Dv AF_INET ,
+.Dv AF_INET6 ,
+and
+.Dv AF_UNIX
+constants for address families, and requires the use of
+.Dv AF_*
+constants for the
+.Fa domain
+argument of
+.Fn socket .
+The
+.Dv SOCK_CLOEXEC
+and
+.Dv SOCK_CLOFORK
+flags are expected to conform to
+.St -p1003.1-2024 .
+.Tn POSIX
+standard.
+The
+.Dv SOCK_RDM
+.Fa type ,
+the
+.Dv PF_*
+constants, and other address families are
+.Fx
+extensions.
+.Sh HISTORY
+The
+.Fn socket
+system call appeared in
+.Bx 4.2 .
+.Pp
+The
+.Dv SOCK_CLOFORK
+flag appeared in
+.Fx 15.0 .
diff --git a/lib/libsys/socketpair.2 b/lib/libsys/socketpair.2
new file mode 100644
index 000000000000..60dec74f9cc2
--- /dev/null
+++ b/lib/libsys/socketpair.2
@@ -0,0 +1,105 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd May 17, 2025
+.Dt SOCKETPAIR 2
+.Os
+.Sh NAME
+.Nm socketpair
+.Nd create a pair of connected sockets
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/socket.h
+.Ft int
+.Fn socketpair "int domain" "int type" "int protocol" "int *sv"
+.Sh DESCRIPTION
+The
+.Fn socketpair
+system call creates an unnamed pair of connected sockets in
+the specified communications
+.Fa domain ,
+of the specified
+.Fa type ,
+and using the optionally specified
+.Fa protocol .
+The descriptors used in referencing the new sockets
+are returned in
+.Fa sv Ns [0]
+and
+.Fa sv Ns [1] .
+The two sockets are indistinguishable.
+.Pp
+The
+.Dv SOCK_CLOEXEC ,
+.Dv SOCK_CLOFORK
+and
+.Dv SOCK_NONBLOCK
+flags in the
+.Fa type
+argument apply to both descriptors.
+.Sh RETURN VALUES
+.Rv -std socketpair
+.Sh ERRORS
+The call succeeds unless:
+.Bl -tag -width Er
+.It Bq Er EMFILE
+Too many descriptors are in use by this process.
+.It Bq Er EAFNOSUPPORT
+The specified address family is not supported on this machine.
+.It Bq Er EPROTONOSUPPORT
+The specified protocol is not supported on this machine.
+.It Bq Er EOPNOTSUPP
+The specified protocol does not support creation of socket pairs.
+.It Bq Er EFAULT
+The address
+.Fa sv
+does not specify a valid part of the
+process address space.
+.El
+.Sh SEE ALSO
+.Xr pipe 2 ,
+.Xr read 2 ,
+.Xr socket 2 ,
+.Xr write 2
+.Sh STANDARDS
+The
+.Fn socketpair
+system call conforms to
+.St -p1003.1-2001
+and
+.St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Fn socketpair
+system call appeared in
+.Bx 4.2 .
+.Sh BUGS
+This call is currently implemented only for the
+.Ux
+domain.
diff --git a/lib/libsys/stat.2 b/lib/libsys/stat.2
new file mode 100644
index 000000000000..bd9005710147
--- /dev/null
+++ b/lib/libsys/stat.2
@@ -0,0 +1,489 @@
+.\" Copyright (c) 1980, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd March 30, 2021
+.Dt STAT 2
+.Os
+.Sh NAME
+.Nm stat ,
+.Nm lstat ,
+.Nm fstat ,
+.Nm fstatat
+.Nd get file status
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.Ft int
+.Fn stat "const char * restrict path" "struct stat * restrict sb"
+.Ft int
+.Fn lstat "const char * restrict path" "struct stat * restrict sb"
+.Ft int
+.Fn fstat "int fd" "struct stat *sb"
+.Ft int
+.Fn fstatat "int fd" "const char *path" "struct stat *sb" "int flag"
+.Sh DESCRIPTION
+The
+.Fn stat
+system call obtains information about the file pointed to by
+.Fa path .
+Read, write or execute
+permission of the named file is not required, but all directories
+listed in the path name leading to the file must be searchable.
+.Pp
+The
+.Fn lstat
+system call is like
+.Fn stat
+except when the named file is a symbolic link,
+in which case
+.Fn lstat
+returns information about the link,
+while
+.Fn stat
+returns information about the file the link references.
+.Pp
+The
+.Fn fstat
+system call obtains the same information about an open file
+known by the file descriptor
+.Fa fd .
+.Pp
+The
+.Fn fstatat
+system call is equivalent to
+.Fn stat
+and
+.Fn lstat
+except when the
+.Fa path
+specifies a relative path.
+For
+.Fn fstatat
+and relative
+.Fa path ,
+the status is retrieved from a file relative to
+the directory associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+.Pp
+The values for the
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from this list,
+defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, the status of the symbolic link is returned.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the starting directory.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa path
+argument is an empty string, operate on the file or directory
+referenced by the descriptor
+.Fa fd .
+If
+.Fa fd
+is equal to
+.Dv AT_FDCWD ,
+operate on the current working directory.
+.El
+.Pp
+If
+.Fn fstatat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn stat
+or
+.Fn lstat
+respectively, depending on whether or not the
+.Dv AT_SYMLINK_NOFOLLOW
+bit is set in
+.Fa flag .
+.Pp
+When
+.Fn fstatat
+is called with an absolute
+.Fa path ,
+it ignores the
+.Fa fd
+argument.
+.Pp
+The
+.Fa sb
+argument is a pointer to a
+.Vt stat
+structure
+as defined by
+.In sys/stat.h
+and into which information is placed concerning the file.
+.Pp
+The fields of
+.Vt "struct stat"
+related to the file system are:
+.Bl -tag -width ".Va st_nlink"
+.It Va st_dev
+Numeric ID of the device containing the file.
+.It Va st_ino
+The file's inode number.
+.It Va st_nlink
+Number of hard links to the file.
+.It Va st_flags
+Flags enabled for the file.
+See
+.Xr chflags 2
+for the list of flags and their description.
+.El
+.Pp
+The
+.Va st_dev
+and
+.Va st_ino
+fields together identify the file uniquely within the system.
+.Pp
+The time-related fields of
+.Vt "struct stat"
+are:
+.Bl -tag -width ".Va st_birthtim"
+.It Va st_atim
+Time when file data was last accessed.
+Changed implicitly by syscalls such as
+.Xr read 2
+and
+.Xr readv 2 ,
+and explicitly by
+.Xr utimes 2 .
+.It Va st_mtim
+Time when file data was last modified.
+Changed implicitly by syscalls such as
+.Xr truncate 2 ,
+.Xr write 2 ,
+and
+.Xr writev 2 ,
+and explicitly by
+.Xr utimes 2 .
+Also, any syscall which modifies directory content changes the
+.Va st_mtim
+for the affected directory.
+For instance,
+.Xr creat 2 ,
+.Xr mkdir 2 ,
+.Xr rename 2 ,
+.Xr link 2 ,
+and
+.Xr unlink 2 .
+.It Va st_ctim
+Time when file status was last changed (inode data modification).
+Changed implicitly by any syscall that affects file metadata, including
+.Va st_mtim ,
+such as
+.Xr chflags 2 ,
+.Xr chmod 2 ,
+.Xr chown 2 ,
+.Xr truncate 2 ,
+.Xr utimes 2 ,
+and
+.Xr write 2 .
+Also, any syscall which modifies directory content changes the
+.Va st_ctim
+for the affected directory.
+For instance,
+.Xr creat 2 ,
+.Xr mkdir 2 ,
+.Xr rename 2 ,
+.Xr link 2 ,
+and
+.Xr unlink 2 .
+.It Va st_birthtim
+Time when the inode was created.
+.El
+.Pp
+These time-related macros are defined for compatibility:
+.Bd -literal
+#define st_atime st_atim.tv_sec
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
+#ifndef _POSIX_SOURCE
+#define st_birthtime st_birthtim.tv_sec
+#endif
+
+#ifndef _POSIX_SOURCE
+#define st_atimespec st_atim
+#define st_mtimespec st_mtim
+#define st_ctimespec st_ctim
+#define st_birthtimespec st_birthtim
+#endif
+.Ed
+.Pp
+Size-related fields of the
+.Vt "struct stat"
+are:
+.Bl -tag -width ".Va st_blksize"
+.It Va st_size
+File size in bytes.
+.It Va st_blksize
+Optimal I/O block size for the file.
+.It Va st_blocks
+Actual number of blocks allocated for the file in 512-byte units.
+As short symbolic links are stored in the inode, this number may
+be zero.
+.El
+.Pp
+The access-related fields of
+.Vt "struct stat"
+are:
+.Bl -tag -width ".Va st_mode"
+.It Va st_uid
+User ID of the file's owner.
+.It Va st_gid
+Group ID of the file.
+.It Va st_mode
+Status of the file (see below).
+.El
+.Pp
+The status information word
+.Fa st_mode
+has these bits:
+.Bd -literal
+#define S_IFMT 0170000 /* type of file mask */
+#define S_IFIFO 0010000 /* named pipe (fifo) */
+#define S_IFCHR 0020000 /* character special */
+#define S_IFDIR 0040000 /* directory */
+#define S_IFBLK 0060000 /* block special */
+#define S_IFREG 0100000 /* regular */
+#define S_IFLNK 0120000 /* symbolic link */
+#define S_IFSOCK 0140000 /* socket */
+#define S_IFWHT 0160000 /* whiteout */
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+#define S_ISVTX 0001000 /* save swapped text even after use */
+#define S_IRWXU 0000700 /* RWX mask for owner */
+#define S_IRUSR 0000400 /* read permission, owner */
+#define S_IWUSR 0000200 /* write permission, owner */
+#define S_IXUSR 0000100 /* execute/search permission, owner */
+#define S_IRWXG 0000070 /* RWX mask for group */
+#define S_IRGRP 0000040 /* read permission, group */
+#define S_IWGRP 0000020 /* write permission, group */
+#define S_IXGRP 0000010 /* execute/search permission, group */
+#define S_IRWXO 0000007 /* RWX mask for other */
+#define S_IROTH 0000004 /* read permission, other */
+#define S_IWOTH 0000002 /* write permission, other */
+#define S_IXOTH 0000001 /* execute/search permission, other */
+.Ed
+.Pp
+For a list of access modes, see
+.In sys/stat.h ,
+.Xr access 2
+and
+.Xr chmod 2 .
+These macros are available to test whether a
+.Va st_mode
+value passed in the
+.Fa m
+argument corresponds to a file of the specified type:
+.Bl -tag -width ".Fn S_ISFIFO m"
+.It Fn S_ISBLK m
+Test for a block special file.
+.It Fn S_ISCHR m
+Test for a character special file.
+.It Fn S_ISDIR m
+Test for a directory.
+.It Fn S_ISFIFO m
+Test for a pipe or FIFO special file.
+.It Fn S_ISLNK m
+Test for a symbolic link.
+.It Fn S_ISREG m
+Test for a regular file.
+.It Fn S_ISSOCK m
+Test for a socket.
+.It Fn S_ISWHT m
+Test for a whiteout.
+.El
+.Pp
+The macros evaluate to a non-zero value if the test is true
+or to the value 0 if the test is false.
+.Sh RETURN VALUES
+.Rv -std
+.Sh COMPATIBILITY
+Previous versions of the system used different types for the
+.Va st_dev ,
+.Va st_uid ,
+.Va st_gid ,
+.Va st_rdev ,
+.Va st_size ,
+.Va st_blksize
+and
+.Va st_blocks
+fields.
+.Sh ERRORS
+The
+.Fn stat
+and
+.Fn lstat
+system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EFAULT
+The
+.Fa sb
+or
+.Fa path
+argument
+points to an invalid address.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er EOVERFLOW
+The file size in bytes cannot be
+represented correctly in the structure pointed to by
+.Fa sb .
+.El
+.Pp
+The
+.Fn fstat
+system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid open file descriptor.
+.It Bq Er EFAULT
+The
+.Fa sb
+argument
+points to an invalid address.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EOVERFLOW
+The file size in bytes cannot be
+represented correctly in the structure pointed to by
+.Fa sb .
+.El
+.Pp
+In addition to the errors returned by the
+.Fn lstat ,
+the
+.Fn fstatat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Sh SEE ALSO
+.Xr access 2 ,
+.Xr chmod 2 ,
+.Xr chown 2 ,
+.Xr fhstat 2 ,
+.Xr statfs 2 ,
+.Xr utimes 2 ,
+.Xr sticky 7 ,
+.Xr symlink 7
+.Sh STANDARDS
+The
+.Fn stat
+and
+.Fn fstat
+system calls are expected to conform to
+.St -p1003.1-90 .
+The
+.Fn fstatat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn stat
+and
+.Fn fstat
+system calls appeared in
+.At v1 .
+The
+.Fn lstat
+system call appeared in
+.Bx 4.2 .
+The
+.Fn fstatat
+system call appeared in
+.Fx 8.0 .
+.Sh BUGS
+Applying
+.Fn fstat
+to a socket
+returns a zeroed buffer,
+except for the blocksize field,
+and a unique device and inode number.
diff --git a/lib/libsys/statfs.2 b/lib/libsys/statfs.2
new file mode 100644
index 000000000000..ab65def11ebb
--- /dev/null
+++ b/lib/libsys/statfs.2
@@ -0,0 +1,272 @@
+.\" Copyright (c) 1989, 1991, 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.
+.\"
+.Dd July 20, 2025
+.Dt STATFS 2
+.Os
+.Sh NAME
+.Nm statfs
+.Nd get file system statistics
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/param.h
+.In sys/mount.h
+.Ft int
+.Fn statfs "const char *path" "struct statfs *buf"
+.Ft int
+.Fn fstatfs "int fd" "struct statfs *buf"
+.Sh DESCRIPTION
+The
+.Fn statfs
+system call
+returns information about a mounted file system.
+The
+.Fa path
+argument
+is the path name of any file within the mounted file system.
+The
+.Fa buf
+argument
+is a pointer to a
+.Vt statfs
+structure defined as follows:
+.Bd -literal
+typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */
+
+/*
+ * filesystem statistics
+ */
+
+#define MFSNAMELEN 16 /* length of type name including null */
+#define MNAMELEN 1024 /* size of on/from name bufs */
+#define STATFS_VERSION 0x20140518 /* current version number */
+
+struct statfs {
+uint32_t f_version; /* structure version number */
+uint32_t f_type; /* type of filesystem */
+uint64_t f_flags; /* copy of mount exported flags */
+uint64_t f_bsize; /* filesystem fragment size */
+uint64_t f_iosize; /* optimal transfer block size */
+uint64_t f_blocks; /* total data blocks in filesystem */
+uint64_t f_bfree; /* free blocks in filesystem */
+int64_t f_bavail; /* free blocks avail to non-superuser */
+uint64_t f_files; /* total file nodes in filesystem */
+int64_t f_ffree; /* free nodes avail to non-superuser */
+uint64_t f_syncwrites; /* count of sync writes since mount */
+uint64_t f_asyncwrites; /* count of async writes since mount */
+uint64_t f_syncreads; /* count of sync reads since mount */
+uint64_t f_asyncreads; /* count of async reads since mount */
+uint64_t f_spare[10]; /* unused spare */
+uint32_t f_namemax; /* maximum filename length */
+uid_t f_owner; /* user that mounted the filesystem */
+fsid_t f_fsid; /* filesystem id */
+char f_charspare[80]; /* spare string space */
+char f_fstypename[MFSNAMELEN]; /* filesystem type name */
+char f_mntfromname[MNAMELEN]; /* mounted filesystem */
+char f_mntonname[MNAMELEN]; /* directory on which mounted */
+};
+.Ed
+.Pp
+The flags that may be returned include:
+.Bl -tag -width MNT_SYNCHRONOUS
+.It Dv MNT_ACLS
+Access Control List (ACL) support enabled.
+.It Dv MNT_ASYNC
+No file system I/O is done synchronously.
+.It Dv MNT_AUTOMOUNTED
+The filesystem was auto-mounted, see
+.Xr autofs 4 .
+.It Dv MNT_DEFEXPORTED
+The file system is exported for both reading and writing to any Internet host.
+.It Dv MNT_GJOURNAL
+Journaling with gjournal is enabled (see
+.Xr gjournal 8 ) .
+.It Dv MNT_EXKERB
+The file system is exported with Kerberos uid mapping.
+.It Dv MNT_EXPORTANON
+The file system maps all remote accesses to the anonymous user.
+.It Dv MNT_EXPORTED
+The file system is exported for both reading and writing.
+.It Dv MNT_EXPUBLIC
+The file system is exported publicly (WebNFS).
+.It Dv MNT_EXRDONLY
+The file system is exported read-only.
+.It Dv MNT_IGNORE
+The file system should not be listed, e.g. by
+.Xr df 1 .
+.It Dv MNT_LOCAL
+The file system resides locally.
+.It Dv MNT_MULTILABEL
+Mandatory Access Control (MAC) support for individual objects
+(see
+.Xr mac 4 ) .
+.It Dv MNT_NAMEDATTR
+The file system supports named attributes as described in
+.Xr named_attribute 7 .
+.It Dv MNT_NFS4ACLS
+ACLs in NFSv4 variant are supported.
+.It Dv MNT_NOATIME
+Updating of file access times is disabled.
+.It Dv MNT_NOCLUSTERR
+Read clustering is disabled.
+.It Dv MNT_NOCLUSTERW
+Write clustering is disabled.
+.It Dv MNT_NOEXEC
+Files may not be executed from the file system.
+.It Dv MNT_NOSUID
+Setuid and setgid bits on files are not honored when they are executed.
+.It Dv MNT_NOSYMFOLLOW
+Symbolic links are not followed.
+.It Dv MNT_SOFTDEP
+Soft updates being done (see
+.Xr ffs 4 ) .
+.It Dv MNT_SUIDDIR
+Special handling of SUID bit on directories.
+.It Dv MNT_SUJ
+Soft-updates with journaling being done.
+.It Dv MNT_SYNCHRONOUS
+All I/O to the file system is done synchronously.
+.It Dv MNT_QUOTA
+The file system has quotas enabled on it.
+.It Dv MNT_RDONLY
+The file system is mounted read-only;
+Even the super-user may not write on it.
+.It Dv MNT_ROOTFS
+Identifies the root file system.
+.It Dv MNT_UNION
+Union with underlying file system.
+.It Dv MNT_UNTRUSTED
+The file system was mounted with the
+.Cm untrusted
+option, which indicates media of unknown provenance or integrity.
+Currently honored by
+.Xr ffs 4 .
+.It Dv MNT_USER
+The file system has been mounted by a user.
+.It Dv MNT_VERIFIED
+The file system is marked as verified, no fingerprint check on
+.Xr execve 2
+is needed, see
+.Xr mac_veriexec 4 .
+.El
+.Pp
+Fields that are undefined for a particular file system are set to -1.
+The
+.Fn fstatfs
+system call
+returns the same information about an open file referenced by descriptor
+.Fa fd .
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn statfs
+system call
+fails if one or more of the following are true:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix of
+.Fa path
+is not a directory.
+.It Bq Er ENAMETOOLONG
+The length of a component of
+.Fa path
+exceeds 255 characters,
+or the length of
+.Fa path
+exceeds 1023 characters.
+.It Bq Er ENOENT
+The file referred to by
+.Fa path
+does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix of
+.Fa path .
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating
+.Fa path .
+.It Bq Er EFAULT
+The
+.Fa buf
+or
+.Fa path
+argument
+points to an invalid address.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Pp
+The
+.Fn fstatfs
+system call
+fails if one or more of the following are true:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid open file descriptor.
+.It Bq Er EFAULT
+The
+.Fa buf
+argument
+points to an invalid address.
+.It Bq Er EIO
+An
+.Tn I/O
+error occurred while reading from or writing to the file system.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.El
+.Sh NOTES
+The fields in the
+.Vt statfs
+structure have been defined to provide the parameters relevant for
+traditional UNIX file systems.
+For some other file systems, values that have similar, but not
+identical, semantics to those described above may be returned.
+An example is msdosfs, which in case of FAT12 or FAT16 file systems
+reports the number of available and of free root directory entries
+instead of inodes
+.Po
+where 1 to 21 such directory entries are required to store
+each file or directory name or disk label
+.Pc .
+.Sh SEE ALSO
+.Xr fhstatfs 2 ,
+.Xr getfsstat 2 ,
+.Xr named_attribute 7
+.Sh HISTORY
+The
+.Fn statfs
+system call first appeared in
+.Bx 4.4 .
diff --git a/lib/libsys/swapon.2 b/lib/libsys/swapon.2
new file mode 100644
index 000000000000..23ed0bc2aa83
--- /dev/null
+++ b/lib/libsys/swapon.2
@@ -0,0 +1,160 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd December 8, 2021
+.Dt SWAPON 2
+.Os
+.Sh NAME
+.Nm swapon , swapoff
+.Nd control devices for interleaved paging/swapping
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In vm/vm_param.h
+.In vm/swap_pager.h
+.Pp
+.In unistd.h
+.Ft int
+.Fn swapon "const char *special"
+.Ft int
+.Fn swapoff "const char *special" "u_int flags"
+.Sh DESCRIPTION
+The
+.Fn swapon
+system call
+makes the block device
+.Fa special
+available to the system for
+allocation for paging and swapping.
+The names of potentially
+available devices are known to the system and defined at system
+configuration time.
+The size of the swap area on
+.Fa special
+is calculated at the time the device is first made available
+for swapping.
+.Pp
+The
+.Fn swapoff
+system call disables paging and swapping on the given device.
+All associated swap metadata are deallocated, and the device
+is made available for other purposes.
+.Pp
+The
+.Fa special
+argument points to the name of the device or file used for swapping.
+The
+.Va flags
+argument takes the following flags:
+.Bl -tag -width SWAPOFF_FORCE
+.It Dv SWAPOFF_FORCE
+Overrides a very conservative check that prevents swapoff
+if the total amount of free memory and remaining swap
+devices space might be unsufficient for the system to continue
+operating.
+.El
+.Sh RETURN VALUES
+If an error has occurred, a value of -1 is returned and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+Both
+.Fn swapon
+and
+.Fn swapoff
+can fail if:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named device does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The caller is not the super-user.
+.It Bq Er EFAULT
+The
+.Fa special
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+Additionally,
+.Fn swapon
+can fail for the following reasons:
+.Bl -tag -width Er
+.It Bq Er ENOTBLK
+The
+.Fa special
+argument
+is not a block device.
+.It Bq Er EBUSY
+The device specified by
+.Fa special
+has already
+been made available for swapping
+.It Bq Er ENXIO
+The major device number of
+.Fa special
+is out of range (this indicates no device driver exists
+for the associated hardware).
+.It Bq Er EIO
+An I/O error occurred while opening the swap device.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system to open the
+swap device.
+.El
+.Pp
+Lastly,
+.Fn swapoff
+can fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The system is not currently swapping to
+.Fa special .
+.It Bq Er ENOMEM
+Not enough virtual memory is available to safely disable
+paging and swapping to the given device.
+.El
+.Sh SEE ALSO
+.Xr config 8 ,
+.Xr swapon 8 ,
+.Xr sysctl 8
+.Sh HISTORY
+The
+.Fn swapon
+system call appeared in
+.Bx 4.0 .
+The
+.Fn swapoff
+system call appeared in
+.Fx 5.1 .
diff --git a/lib/libsys/symlink.2 b/lib/libsys/symlink.2
new file mode 100644
index 000000000000..b5d878aaae50
--- /dev/null
+++ b/lib/libsys/symlink.2
@@ -0,0 +1,207 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd April 15, 2025
+.Dt SYMLINK 2
+.Os
+.Sh NAME
+.Nm symlink ,
+.Nm symlinkat
+.Nd make symbolic link to a file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn symlink "const char *name1" "const char *name2"
+.Ft int
+.Fn symlinkat "const char *name1" "int fd" "const char *name2"
+.Sh DESCRIPTION
+A symbolic link
+.Fa name2
+is created to
+.Fa name1
+.Fa ( name2
+is the name of the
+file created,
+.Fa name1
+is the string
+used in creating the symbolic link).
+Either name may be an arbitrary path name; the files need not
+be on the same file system.
+.Pp
+The
+.Fn symlinkat
+system call is equivalent to
+.Fn symlink
+except in the case where
+.Fa name2
+specifies a relative path.
+In this case the symbolic link is created relative to the directory
+associated with the file descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn symlinkat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fn symlink .
+.Sh RETURN VALUES
+.Rv -std symlink
+.Sh ERRORS
+The symbolic link succeeds unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the
+.Fa name2
+path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of the
+.Fa name2
+pathname exceeded 255 characters,
+or the entire length of either path name exceeded 1023 characters.
+.It Bq Er ENOENT
+A component of the
+.Fa name2
+path prefix does not exist.
+.It Bq Er EOPNOTSUPP
+The file system containing the file named by
+.Fa name2
+does not support symbolic links.
+.It Bq Er EACCES
+A component of the
+.Fa name2
+path prefix denies search permission, or write permission is denied on the
+parent directory of the file to be created.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the
+.Fa name2
+path name.
+.It Bq Er EEXIST
+The path name pointed at by the
+.Fa name2
+argument
+already exists.
+.It Bq Er EPERM
+The parent directory of the file named by
+.Fa name2
+has its immutable flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EIO
+An I/O error occurred while making the directory entry for
+.Fa name2 ,
+allocating the inode for
+.Fa name2 ,
+or writing out the link contents of
+.Fa name2 .
+.It Bq Er EROFS
+The file
+.Fa name2
+would reside on a read-only file system.
+.It Bq Er ENOSPC
+The directory in which the entry for the new symbolic link is being placed
+cannot be extended because there is no space left on the file
+system containing the directory.
+.It Bq Er ENOSPC
+The new symbolic link cannot be created because
+there is no space left on the file
+system that will contain the symbolic link.
+.It Bq Er ENOSPC
+There are no free inodes on the file system on which the
+symbolic link is being created.
+.It Bq Er EDQUOT
+The directory in which the entry for the new symbolic link
+is being placed cannot be extended because the
+user's quota of disk blocks on the file system
+containing the directory has been exhausted.
+.It Bq Er EDQUOT
+The new symbolic link cannot be created because the user's
+quota of disk blocks on the file system that will
+contain the symbolic link has been exhausted.
+.It Bq Er EDQUOT
+The user's quota of inodes on the file system on
+which the symbolic link is being created has been exhausted.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+The
+.Fa name1
+or
+.Fa name2
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn symlink ,
+the
+.Fn symlinkat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa name2
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa name2
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr ln 1 ,
+.Xr chflags 2 ,
+.Xr link 2 ,
+.Xr lstat 2 ,
+.Xr readlink 2 ,
+.Xr unlink 2 ,
+.Xr symlink 7
+.Sh STANDARDS
+The
+.Fn symlinkat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn symlink
+system call appeared in
+.Bx 4.2 .
+The
+.Fn symlinkat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libsys/sync.2 b/lib/libsys/sync.2
new file mode 100644
index 000000000000..d99e4c70e013
--- /dev/null
+++ b/lib/libsys/sync.2
@@ -0,0 +1,74 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd December 1, 2017
+.Dt SYNC 2
+.Os
+.Sh NAME
+.Nm sync
+.Nd "schedule file system updates"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft void
+.Fn sync void
+.Sh DESCRIPTION
+The
+.Fn sync
+system call forces a write of dirty (modified) buffers
+in the block buffer cache out
+to disk.
+The kernel keeps this information in core to reduce
+the number of disk I/O transfers required by the system.
+As information in the cache is lost after a system crash, a
+.Fn sync
+system call is issued
+frequently
+by the kernel process
+.Xr syncer 4
+(about every 30 seconds).
+.Pp
+The
+.Xr fsync 2
+system call
+may be used to synchronize individual file descriptor
+attributes.
+.Sh SEE ALSO
+.Xr fsync 2 ,
+.Xr syncer 4 ,
+.Xr sync 8
+.Sh HISTORY
+The
+.Fn sync
+function appeared in
+.At v3 .
+.Sh BUGS
+The
+.Fn sync
+system call
+may return before the buffers are completely flushed.
diff --git a/lib/libsys/sysarch.2 b/lib/libsys/sysarch.2
new file mode 100644
index 000000000000..6144cd44fb37
--- /dev/null
+++ b/lib/libsys/sysarch.2
@@ -0,0 +1,78 @@
+.\" $NetBSD: sysarch.2,v 1.6 1998/02/25 21:24:57 perry Exp $
+.\"
+.\" Copyright (c) 1980, 1991 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.
+.\"
+.Dd October 11, 1993
+.Dt SYSARCH 2
+.Os
+.Sh NAME
+.Nm sysarch
+.Nd architecture-dependent system call
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In machine/sysarch.h
+.Ft int
+.Fn sysarch "int number" "void *args"
+.Sh DESCRIPTION
+The
+.Fn sysarch
+system call
+performs the architecture-dependent function
+specified by
+.Fa number
+with the arguments specified by the
+.Fa args
+pointer.
+The
+.Fa args
+argument
+is a pointer to a structure defining the actual
+arguments of the function.
+Symbolic constants and argument structures
+for the architecture-dependent
+functions can be found in the header file
+.In machine/sysarch.h .
+.Pp
+The
+.Fn sysarch
+system call should never be called directly by
+user programs.
+Instead, they should access
+its functions using the architecture-dependent
+library.
+.Sh RETURN VALUES
+See the manual pages for specific architecture-dependent system calls
+for information about their return values.
+.Sh SEE ALSO
+.Xr i386_get_ioperm 2 ,
+.Xr i386_get_ldt 2 ,
+.Xr i386_vm86 2
+.Sh HISTORY
+This manual page was taken from
+.Nx .
diff --git a/lib/libsys/syscall.2 b/lib/libsys/syscall.2
new file mode 100644
index 000000000000..24d25a6ce170
--- /dev/null
+++ b/lib/libsys/syscall.2
@@ -0,0 +1,74 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd June 16, 1993
+.Dt SYSCALL 2
+.Os
+.Sh NAME
+.Nm syscall ,
+.Nm __syscall
+.Nd indirect system call
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/syscall.h
+.In unistd.h
+.Ft int
+.Fn syscall "int number" ...
+.Ft off_t
+.Fn __syscall "quad_t number" ...
+.Sh DESCRIPTION
+The
+.Fn syscall
+function
+performs the system call whose assembly language
+interface has the specified
+.Fa number
+with the specified arguments.
+Symbolic constants for system calls can be found in the header file
+.In sys/syscall.h .
+The
+.Fn __syscall
+form should be used when one or more of the arguments is a
+64-bit argument to ensure that argument alignment is correct.
+This system call is useful for testing new system calls that
+do not have entries in the C library.
+.Sh RETURN VALUES
+The return values are defined by the system call being invoked.
+In general, a 0 return value indicates success.
+A -1 return value indicates an error,
+and an error code is stored in
+.Va errno .
+.Sh HISTORY
+The
+.Fn syscall
+function appeared in
+.Bx 4.0 .
+.Sh BUGS
+There is no way to simulate system calls that have multiple return values
+such as
+.Xr pipe 2 .
diff --git a/lib/libsys/syscalls.map b/lib/libsys/syscalls.map
new file mode 100644
index 000000000000..69fce2ea7c63
--- /dev/null
+++ b/lib/libsys/syscalls.map
@@ -0,0 +1,816 @@
+/*
+ * FreeBSD system call symbols.
+ *
+ * DO NOT EDIT-- this file is automatically @generated.
+ */
+
+FBSDprivate_1.0 {
+ _syscall;
+ __sys_syscall;
+ __sys_exit;
+ _fork;
+ __sys_fork;
+ _read;
+ __sys_read;
+ _write;
+ __sys_write;
+ _open;
+ __sys_open;
+ _close;
+ __sys_close;
+ _wait4;
+ __sys_wait4;
+ _link;
+ __sys_link;
+ _unlink;
+ __sys_unlink;
+ _chdir;
+ __sys_chdir;
+ _fchdir;
+ __sys_fchdir;
+ _chmod;
+ __sys_chmod;
+ _chown;
+ __sys_chown;
+ _break;
+ __sys_break;
+ _getpid;
+ __sys_getpid;
+ _mount;
+ __sys_mount;
+ _unmount;
+ __sys_unmount;
+ _setuid;
+ __sys_setuid;
+ _getuid;
+ __sys_getuid;
+ _geteuid;
+ __sys_geteuid;
+ _ptrace;
+ __sys_ptrace;
+ _recvmsg;
+ __sys_recvmsg;
+ _sendmsg;
+ __sys_sendmsg;
+ _recvfrom;
+ __sys_recvfrom;
+ _accept;
+ __sys_accept;
+ _getpeername;
+ __sys_getpeername;
+ _getsockname;
+ __sys_getsockname;
+ _access;
+ __sys_access;
+ _chflags;
+ __sys_chflags;
+ _fchflags;
+ __sys_fchflags;
+ _sync;
+ __sys_sync;
+ _kill;
+ __sys_kill;
+ _getppid;
+ __sys_getppid;
+ _dup;
+ __sys_dup;
+ _getegid;
+ __sys_getegid;
+ _profil;
+ __sys_profil;
+ _ktrace;
+ __sys_ktrace;
+ _getgid;
+ __sys_getgid;
+ _getlogin;
+ __sys_getlogin;
+ _setlogin;
+ __sys_setlogin;
+ _acct;
+ __sys_acct;
+ _sigaltstack;
+ __sys_sigaltstack;
+ _ioctl;
+ __sys_ioctl;
+ _reboot;
+ __sys_reboot;
+ _revoke;
+ __sys_revoke;
+ _symlink;
+ __sys_symlink;
+ _readlink;
+ __sys_readlink;
+ _execve;
+ __sys_execve;
+ _umask;
+ __sys_umask;
+ _chroot;
+ __sys_chroot;
+ _msync;
+ __sys_msync;
+ __sys_vfork;
+ _munmap;
+ __sys_munmap;
+ _mprotect;
+ __sys_mprotect;
+ _madvise;
+ __sys_madvise;
+ _mincore;
+ __sys_mincore;
+ _getgroups;
+ __sys_getgroups;
+ _setgroups;
+ __sys_setgroups;
+ _getpgrp;
+ __sys_getpgrp;
+ _setpgid;
+ __sys_setpgid;
+ _setitimer;
+ __sys_setitimer;
+ _swapon;
+ __sys_swapon;
+ _getitimer;
+ __sys_getitimer;
+ _getdtablesize;
+ __sys_getdtablesize;
+ _dup2;
+ __sys_dup2;
+ _fcntl;
+ __sys_fcntl;
+ _select;
+ __sys_select;
+ _fsync;
+ __sys_fsync;
+ _setpriority;
+ __sys_setpriority;
+ _socket;
+ __sys_socket;
+ _connect;
+ __sys_connect;
+ _getpriority;
+ __sys_getpriority;
+ _bind;
+ __sys_bind;
+ _setsockopt;
+ __sys_setsockopt;
+ _listen;
+ __sys_listen;
+ _gettimeofday;
+ __sys_gettimeofday;
+ _getrusage;
+ __sys_getrusage;
+ _getsockopt;
+ __sys_getsockopt;
+ _readv;
+ __sys_readv;
+ _writev;
+ __sys_writev;
+ _settimeofday;
+ __sys_settimeofday;
+ _fchown;
+ __sys_fchown;
+ _fchmod;
+ __sys_fchmod;
+ _setreuid;
+ __sys_setreuid;
+ _setregid;
+ __sys_setregid;
+ _rename;
+ __sys_rename;
+ _flock;
+ __sys_flock;
+ _mkfifo;
+ __sys_mkfifo;
+ _sendto;
+ __sys_sendto;
+ _shutdown;
+ __sys_shutdown;
+ _socketpair;
+ __sys_socketpair;
+ _mkdir;
+ __sys_mkdir;
+ _rmdir;
+ __sys_rmdir;
+ _utimes;
+ __sys_utimes;
+ _adjtime;
+ __sys_adjtime;
+ _setsid;
+ __sys_setsid;
+ _quotactl;
+ __sys_quotactl;
+ _nlm_syscall;
+ __sys_nlm_syscall;
+ _nfssvc;
+ __sys_nfssvc;
+ _lgetfh;
+ __sys_lgetfh;
+ _getfh;
+ __sys_getfh;
+ _sysarch;
+ __sys_sysarch;
+ _rtprio;
+ __sys_rtprio;
+ _semsys;
+ __sys_semsys;
+ _msgsys;
+ __sys_msgsys;
+ _shmsys;
+ __sys_shmsys;
+ _setfib;
+ __sys_setfib;
+ _ntp_adjtime;
+ __sys_ntp_adjtime;
+ _setgid;
+ __sys_setgid;
+ _setegid;
+ __sys_setegid;
+ _seteuid;
+ __sys_seteuid;
+ _pathconf;
+ __sys_pathconf;
+ _fpathconf;
+ __sys_fpathconf;
+ _getrlimit;
+ __sys_getrlimit;
+ _setrlimit;
+ __sys_setrlimit;
+ ___syscall;
+ __sys___syscall;
+ ___sysctl;
+ __sys___sysctl;
+ _mlock;
+ __sys_mlock;
+ _munlock;
+ __sys_munlock;
+ _undelete;
+ __sys_undelete;
+ _futimes;
+ __sys_futimes;
+ _getpgid;
+ __sys_getpgid;
+ _poll;
+ __sys_poll;
+ _semget;
+ __sys_semget;
+ _semop;
+ __sys_semop;
+ _msgget;
+ __sys_msgget;
+ _msgsnd;
+ __sys_msgsnd;
+ _msgrcv;
+ __sys_msgrcv;
+ _shmat;
+ __sys_shmat;
+ _shmdt;
+ __sys_shmdt;
+ _shmget;
+ __sys_shmget;
+ _clock_gettime;
+ __sys_clock_gettime;
+ _clock_settime;
+ __sys_clock_settime;
+ _clock_getres;
+ __sys_clock_getres;
+ _ktimer_create;
+ __sys_ktimer_create;
+ _ktimer_delete;
+ __sys_ktimer_delete;
+ _ktimer_settime;
+ __sys_ktimer_settime;
+ _ktimer_gettime;
+ __sys_ktimer_gettime;
+ _ktimer_getoverrun;
+ __sys_ktimer_getoverrun;
+ _nanosleep;
+ __sys_nanosleep;
+ _ffclock_getcounter;
+ __sys_ffclock_getcounter;
+ _ffclock_setestimate;
+ __sys_ffclock_setestimate;
+ _ffclock_getestimate;
+ __sys_ffclock_getestimate;
+ _clock_nanosleep;
+ __sys_clock_nanosleep;
+ _clock_getcpuclockid2;
+ __sys_clock_getcpuclockid2;
+ _ntp_gettime;
+ __sys_ntp_gettime;
+ _minherit;
+ __sys_minherit;
+ _rfork;
+ __sys_rfork;
+ _issetugid;
+ __sys_issetugid;
+ _lchown;
+ __sys_lchown;
+ _aio_read;
+ __sys_aio_read;
+ _aio_write;
+ __sys_aio_write;
+ _lio_listio;
+ __sys_lio_listio;
+ _lchmod;
+ __sys_lchmod;
+ _lutimes;
+ __sys_lutimes;
+ _preadv;
+ __sys_preadv;
+ _pwritev;
+ __sys_pwritev;
+ _fhopen;
+ __sys_fhopen;
+ _modnext;
+ __sys_modnext;
+ _modstat;
+ __sys_modstat;
+ _modfnext;
+ __sys_modfnext;
+ _modfind;
+ __sys_modfind;
+ _kldload;
+ __sys_kldload;
+ _kldunload;
+ __sys_kldunload;
+ _kldfind;
+ __sys_kldfind;
+ _kldnext;
+ __sys_kldnext;
+ _kldstat;
+ __sys_kldstat;
+ _kldfirstmod;
+ __sys_kldfirstmod;
+ _getsid;
+ __sys_getsid;
+ _setresuid;
+ __sys_setresuid;
+ _setresgid;
+ __sys_setresgid;
+ _aio_return;
+ __sys_aio_return;
+ _aio_suspend;
+ __sys_aio_suspend;
+ _aio_cancel;
+ __sys_aio_cancel;
+ _aio_error;
+ __sys_aio_error;
+ _mlockall;
+ __sys_mlockall;
+ _munlockall;
+ __sys_munlockall;
+ ___getcwd;
+ __sys___getcwd;
+ _sched_setparam;
+ __sys_sched_setparam;
+ _sched_getparam;
+ __sys_sched_getparam;
+ _sched_setscheduler;
+ __sys_sched_setscheduler;
+ _sched_getscheduler;
+ __sys_sched_getscheduler;
+ _sched_yield;
+ __sys_sched_yield;
+ _sched_get_priority_max;
+ __sys_sched_get_priority_max;
+ _sched_get_priority_min;
+ __sys_sched_get_priority_min;
+ _sched_rr_get_interval;
+ __sys_sched_rr_get_interval;
+ _utrace;
+ __sys_utrace;
+ _kldsym;
+ __sys_kldsym;
+ _jail;
+ __sys_jail;
+ _nnpfs_syscall;
+ __sys_nnpfs_syscall;
+ _sigprocmask;
+ __sys_sigprocmask;
+ _sigsuspend;
+ __sys_sigsuspend;
+ _sigpending;
+ __sys_sigpending;
+ _sigtimedwait;
+ __sys_sigtimedwait;
+ _sigwaitinfo;
+ __sys_sigwaitinfo;
+ ___acl_get_file;
+ __sys___acl_get_file;
+ ___acl_set_file;
+ __sys___acl_set_file;
+ ___acl_get_fd;
+ __sys___acl_get_fd;
+ ___acl_set_fd;
+ __sys___acl_set_fd;
+ ___acl_delete_file;
+ __sys___acl_delete_file;
+ ___acl_delete_fd;
+ __sys___acl_delete_fd;
+ ___acl_aclcheck_file;
+ __sys___acl_aclcheck_file;
+ ___acl_aclcheck_fd;
+ __sys___acl_aclcheck_fd;
+ _extattrctl;
+ __sys_extattrctl;
+ _extattr_set_file;
+ __sys_extattr_set_file;
+ _extattr_get_file;
+ __sys_extattr_get_file;
+ _extattr_delete_file;
+ __sys_extattr_delete_file;
+ _aio_waitcomplete;
+ __sys_aio_waitcomplete;
+ _getresuid;
+ __sys_getresuid;
+ _getresgid;
+ __sys_getresgid;
+ _kqueue;
+ __sys_kqueue;
+ _extattr_set_fd;
+ __sys_extattr_set_fd;
+ _extattr_get_fd;
+ __sys_extattr_get_fd;
+ _extattr_delete_fd;
+ __sys_extattr_delete_fd;
+ ___setugid;
+ __sys___setugid;
+ _eaccess;
+ __sys_eaccess;
+ _afs3_syscall;
+ __sys_afs3_syscall;
+ _nmount;
+ __sys_nmount;
+ ___mac_get_proc;
+ __sys___mac_get_proc;
+ ___mac_set_proc;
+ __sys___mac_set_proc;
+ ___mac_get_fd;
+ __sys___mac_get_fd;
+ ___mac_get_file;
+ __sys___mac_get_file;
+ ___mac_set_fd;
+ __sys___mac_set_fd;
+ ___mac_set_file;
+ __sys___mac_set_file;
+ _kenv;
+ __sys_kenv;
+ _lchflags;
+ __sys_lchflags;
+ _uuidgen;
+ __sys_uuidgen;
+ _sendfile;
+ __sys_sendfile;
+ _mac_syscall;
+ __sys_mac_syscall;
+ _ksem_close;
+ __sys_ksem_close;
+ _ksem_post;
+ __sys_ksem_post;
+ _ksem_wait;
+ __sys_ksem_wait;
+ _ksem_trywait;
+ __sys_ksem_trywait;
+ _ksem_init;
+ __sys_ksem_init;
+ _ksem_open;
+ __sys_ksem_open;
+ _ksem_unlink;
+ __sys_ksem_unlink;
+ _ksem_getvalue;
+ __sys_ksem_getvalue;
+ _ksem_destroy;
+ __sys_ksem_destroy;
+ ___mac_get_pid;
+ __sys___mac_get_pid;
+ ___mac_get_link;
+ __sys___mac_get_link;
+ ___mac_set_link;
+ __sys___mac_set_link;
+ _extattr_set_link;
+ __sys_extattr_set_link;
+ _extattr_get_link;
+ __sys_extattr_get_link;
+ _extattr_delete_link;
+ __sys_extattr_delete_link;
+ ___mac_execve;
+ __sys___mac_execve;
+ _sigaction;
+ __sys_sigaction;
+ _sigreturn;
+ __sys_sigreturn;
+ _getcontext;
+ __sys_getcontext;
+ _setcontext;
+ __sys_setcontext;
+ _swapcontext;
+ __sys_swapcontext;
+ ___acl_get_link;
+ __sys___acl_get_link;
+ ___acl_set_link;
+ __sys___acl_set_link;
+ ___acl_delete_link;
+ __sys___acl_delete_link;
+ ___acl_aclcheck_link;
+ __sys___acl_aclcheck_link;
+ _sigwait;
+ __sys_sigwait;
+ _thr_create;
+ __sys_thr_create;
+ _thr_exit;
+ __sys_thr_exit;
+ _thr_self;
+ __sys_thr_self;
+ _thr_kill;
+ __sys_thr_kill;
+ _jail_attach;
+ __sys_jail_attach;
+ _extattr_list_fd;
+ __sys_extattr_list_fd;
+ _extattr_list_file;
+ __sys_extattr_list_file;
+ _extattr_list_link;
+ __sys_extattr_list_link;
+ _ksem_timedwait;
+ __sys_ksem_timedwait;
+ _thr_suspend;
+ __sys_thr_suspend;
+ _thr_wake;
+ __sys_thr_wake;
+ _kldunloadf;
+ __sys_kldunloadf;
+ _audit;
+ __sys_audit;
+ _auditon;
+ __sys_auditon;
+ _getauid;
+ __sys_getauid;
+ _setauid;
+ __sys_setauid;
+ _getaudit;
+ __sys_getaudit;
+ _setaudit;
+ __sys_setaudit;
+ _getaudit_addr;
+ __sys_getaudit_addr;
+ _setaudit_addr;
+ __sys_setaudit_addr;
+ _auditctl;
+ __sys_auditctl;
+ __umtx_op;
+ __sys__umtx_op;
+ _thr_new;
+ __sys_thr_new;
+ _sigqueue;
+ __sys_sigqueue;
+ _kmq_open;
+ __sys_kmq_open;
+ _kmq_setattr;
+ __sys_kmq_setattr;
+ _kmq_timedreceive;
+ __sys_kmq_timedreceive;
+ _kmq_timedsend;
+ __sys_kmq_timedsend;
+ _kmq_notify;
+ __sys_kmq_notify;
+ _kmq_unlink;
+ __sys_kmq_unlink;
+ _abort2;
+ __sys_abort2;
+ _thr_set_name;
+ __sys_thr_set_name;
+ _aio_fsync;
+ __sys_aio_fsync;
+ _rtprio_thread;
+ __sys_rtprio_thread;
+ _sctp_peeloff;
+ __sys_sctp_peeloff;
+ _sctp_generic_sendmsg;
+ __sys_sctp_generic_sendmsg;
+ _sctp_generic_sendmsg_iov;
+ __sys_sctp_generic_sendmsg_iov;
+ _sctp_generic_recvmsg;
+ __sys_sctp_generic_recvmsg;
+ _pread;
+ __sys_pread;
+ _pwrite;
+ __sys_pwrite;
+ _mmap;
+ __sys_mmap;
+ _lseek;
+ __sys_lseek;
+ _truncate;
+ __sys_truncate;
+ _ftruncate;
+ __sys_ftruncate;
+ _thr_kill2;
+ __sys_thr_kill2;
+ _shm_unlink;
+ __sys_shm_unlink;
+ _cpuset;
+ __sys_cpuset;
+ _cpuset_setid;
+ __sys_cpuset_setid;
+ _cpuset_getid;
+ __sys_cpuset_getid;
+ _cpuset_getaffinity;
+ __sys_cpuset_getaffinity;
+ _cpuset_setaffinity;
+ __sys_cpuset_setaffinity;
+ _faccessat;
+ __sys_faccessat;
+ _fchmodat;
+ __sys_fchmodat;
+ _fchownat;
+ __sys_fchownat;
+ _fexecve;
+ __sys_fexecve;
+ _futimesat;
+ __sys_futimesat;
+ _linkat;
+ __sys_linkat;
+ _mkdirat;
+ __sys_mkdirat;
+ _mkfifoat;
+ __sys_mkfifoat;
+ _openat;
+ __sys_openat;
+ _readlinkat;
+ __sys_readlinkat;
+ _renameat;
+ __sys_renameat;
+ _symlinkat;
+ __sys_symlinkat;
+ _unlinkat;
+ __sys_unlinkat;
+ _posix_openpt;
+ __sys_posix_openpt;
+ _jail_get;
+ __sys_jail_get;
+ _jail_set;
+ __sys_jail_set;
+ _jail_remove;
+ __sys_jail_remove;
+ ___semctl;
+ __sys___semctl;
+ _msgctl;
+ __sys_msgctl;
+ _shmctl;
+ __sys_shmctl;
+ _lpathconf;
+ __sys_lpathconf;
+ ___cap_rights_get;
+ __sys___cap_rights_get;
+ _cap_enter;
+ __sys_cap_enter;
+ _cap_getmode;
+ __sys_cap_getmode;
+ _pdfork;
+ __sys_pdfork;
+ _pdkill;
+ __sys_pdkill;
+ _pdgetpid;
+ __sys_pdgetpid;
+ _pselect;
+ __sys_pselect;
+ _getloginclass;
+ __sys_getloginclass;
+ _setloginclass;
+ __sys_setloginclass;
+ _rctl_get_racct;
+ __sys_rctl_get_racct;
+ _rctl_get_rules;
+ __sys_rctl_get_rules;
+ _rctl_get_limits;
+ __sys_rctl_get_limits;
+ _rctl_add_rule;
+ __sys_rctl_add_rule;
+ _rctl_remove_rule;
+ __sys_rctl_remove_rule;
+ _posix_fallocate;
+ __sys_posix_fallocate;
+ _posix_fadvise;
+ __sys_posix_fadvise;
+ _wait6;
+ __sys_wait6;
+ _cap_rights_limit;
+ __sys_cap_rights_limit;
+ _cap_ioctls_limit;
+ __sys_cap_ioctls_limit;
+ _cap_ioctls_get;
+ __sys_cap_ioctls_get;
+ _cap_fcntls_limit;
+ __sys_cap_fcntls_limit;
+ _cap_fcntls_get;
+ __sys_cap_fcntls_get;
+ _bindat;
+ __sys_bindat;
+ _connectat;
+ __sys_connectat;
+ _chflagsat;
+ __sys_chflagsat;
+ _accept4;
+ __sys_accept4;
+ _pipe2;
+ __sys_pipe2;
+ _aio_mlock;
+ __sys_aio_mlock;
+ _procctl;
+ __sys_procctl;
+ _ppoll;
+ __sys_ppoll;
+ _futimens;
+ __sys_futimens;
+ _utimensat;
+ __sys_utimensat;
+ _fdatasync;
+ __sys_fdatasync;
+ _fstat;
+ __sys_fstat;
+ _fstatat;
+ __sys_fstatat;
+ _fhstat;
+ __sys_fhstat;
+ _getdirentries;
+ __sys_getdirentries;
+ _statfs;
+ __sys_statfs;
+ _fstatfs;
+ __sys_fstatfs;
+ _getfsstat;
+ __sys_getfsstat;
+ _fhstatfs;
+ __sys_fhstatfs;
+ _mknodat;
+ __sys_mknodat;
+ _kevent;
+ __sys_kevent;
+ _cpuset_getdomain;
+ __sys_cpuset_getdomain;
+ _cpuset_setdomain;
+ __sys_cpuset_setdomain;
+ _getrandom;
+ __sys_getrandom;
+ _getfhat;
+ __sys_getfhat;
+ _fhlink;
+ __sys_fhlink;
+ _fhlinkat;
+ __sys_fhlinkat;
+ _fhreadlink;
+ __sys_fhreadlink;
+ _funlinkat;
+ __sys_funlinkat;
+ _copy_file_range;
+ __sys_copy_file_range;
+ ___sysctlbyname;
+ __sys___sysctlbyname;
+ _shm_open2;
+ __sys_shm_open2;
+ _shm_rename;
+ __sys_shm_rename;
+ _sigfastblock;
+ __sys_sigfastblock;
+ ___realpathat;
+ __sys___realpathat;
+ _close_range;
+ __sys_close_range;
+ _rpctls_syscall;
+ __sys_rpctls_syscall;
+ ___specialfd;
+ __sys___specialfd;
+ _aio_writev;
+ __sys_aio_writev;
+ _aio_readv;
+ __sys_aio_readv;
+ _fspacectl;
+ __sys_fspacectl;
+ _sched_getcpu;
+ __sys_sched_getcpu;
+ _swapoff;
+ __sys_swapoff;
+ _kqueuex;
+ __sys_kqueuex;
+ _membarrier;
+ __sys_membarrier;
+ _timerfd_create;
+ __sys_timerfd_create;
+ _timerfd_gettime;
+ __sys_timerfd_gettime;
+ _timerfd_settime;
+ __sys_timerfd_settime;
+ _kcmp;
+ __sys_kcmp;
+ _getrlimitusage;
+ __sys_getrlimitusage;
+ _fchroot;
+ __sys_fchroot;
+ _setcred;
+ __sys_setcred;
+ _exterrctl;
+ __sys_exterrctl;
+ _inotify_add_watch_at;
+ __sys_inotify_add_watch_at;
+ _inotify_rm_watch;
+ __sys_inotify_rm_watch;
+};
diff --git a/lib/libsys/thr_exit.2 b/lib/libsys/thr_exit.2
new file mode 100644
index 000000000000..98c6dd63f7ec
--- /dev/null
+++ b/lib/libsys/thr_exit.2
@@ -0,0 +1,92 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_EXIT 2
+.Os
+.Sh NAME
+.Nm thr_exit
+.Nd terminate current thread
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft void
+.Fn thr_exit "long *state"
+.Sh DESCRIPTION
+.Bf -symbolic
+This function is intended for implementing threading.
+Normal applications should call
+.Xr pthread_exit 3
+instead.
+.Ef
+.Pp
+The
+.Fn thr_exit
+system call terminates the current kernel-scheduled thread.
+.Pp
+If the
+.Fa state
+argument is not
+.Dv NULL ,
+the location pointed to by the argument is
+updated with an arbitrary non-zero value, and an
+.Xr _umtx_op 2
+.Dv UMTX_OP_WAKE
+operation is consequently performed on the location.
+.Pp
+Attempts to terminate the last thread in the process are silently ignored.
+Use
+.Xr _exit 2
+syscall to terminate the process.
+.Sh RETURN VALUES
+The function does not return a value.
+A return from the function indicates that the calling thread was the
+last one in the process.
+.Sh SEE ALSO
+.Xr _exit 2 ,
+.Xr _umtx_op 2 ,
+.Xr thr_kill 2 ,
+.Xr thr_kill2 2 ,
+.Xr thr_new 2 ,
+.Xr thr_self 2 ,
+.Xr thr_set_name 2 ,
+.Xr pthread_exit 3
+.Sh STANDARDS
+The
+.Fn thr_exit
+system call is non-standard and is used by
+.Lb libthr
+to implement
+.St -p1003.1-2001
+.Xr pthread 3
+functionality.
+.Sh HISTORY
+The
+.Fn thr_exit
+system call first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/thr_kill.2 b/lib/libsys/thr_kill.2
new file mode 100644
index 000000000000..3f3cb0af2a00
--- /dev/null
+++ b/lib/libsys/thr_kill.2
@@ -0,0 +1,137 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_KILL 2
+.Os
+.Sh NAME
+.Nm thr_kill
+.Nd send signal to thread
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft int
+.Fn thr_kill "long id" "int sig"
+.Ft int
+.Fn thr_kill2 "pid_t pid" "long id" "int sig"
+.Sh DESCRIPTION
+The
+.Fn thr_kill
+and
+.Fn thr_kill2
+system calls allow sending a signal, specified by the
+.Fa sig
+argument, to some threads in a process.
+For the
+.Fn thr_kill
+function, signalled threads are always limited to the current process.
+For the
+.Fn thr_kill2
+function, the
+.Fa pid
+argument specifies the process with threads to be signalled.
+.Pp
+The
+.Fa id
+argument specifies which threads get the signal.
+If
+.Fa id
+is equal to \-1, all threads in the specified process are signalled.
+Otherwise, only the thread with the thread identifier equal to the
+argument is signalled.
+.Pp
+The
+.Fa sig
+argument defines the delivered signal.
+It must be a valid signal number or zero.
+In the latter case no signal is actually sent, and the call is used to
+verify the liveness of the thread.
+.Pp
+The signal is delivered with
+.Dv siginfo
+.Dv si_code
+set to
+.Dv SI_LWP .
+.Sh RETURN VALUES
+If successful,
+.Fn thr_kill
+and
+.Fn thr_kill2
+will return zero, otherwise \-1 is returned, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn thr_kill
+and
+.Fn thr_kill2
+operations return the following errors:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa sig
+argument is not zero and does not specify valid signal.
+.It Bq Er ESRCH
+The specified process or thread was not found.
+.El
+.Pp
+Additionally, the
+.Fn thr_kill2
+may return the following errors:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The current process does not have sufficient privilege to check existence or
+send a signal to the specified process.
+.El
+.Sh SEE ALSO
+.Xr _umtx_op 2 ,
+.Xr kill 2 ,
+.Xr thr_exit 2 ,
+.Xr thr_new 2 ,
+.Xr thr_self 2 ,
+.Xr thr_set_name 2 ,
+.Xr pthread_kill 3 ,
+.Xr signal 3
+.Sh STANDARDS
+The
+.Fn thr_kill
+and
+.Fn thr_kill2
+system calls are non-standard and are used by the
+.Lb libthr
+to implement
+.St -p1003.1-2001
+.Xr pthread 3
+functionality.
+.Sh HISTORY
+The
+.Fn thr_kill
+and
+.Fn thr_kill2
+system calls first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/thr_new.2 b/lib/libsys/thr_new.2
new file mode 100644
index 000000000000..a04327723c34
--- /dev/null
+++ b/lib/libsys/thr_new.2
@@ -0,0 +1,256 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_NEW 2
+.Os
+.Sh NAME
+.Nm thr_new
+.Nd create new thread of execution
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft int
+.Fn thr_new "struct thr_param *param" "int param_size"
+.Sh DESCRIPTION
+.Bf -symbolic
+This function is intended for implementing threading.
+Normal applications should call
+.Xr pthread_create 3
+instead.
+.Ef
+.Pp
+The
+.Fn thr_new
+system call creates a new kernel-scheduled thread of execution in the context
+of the current process.
+The newly created thread shares all attributes of the process with the
+existing kernel-scheduled threads in the process, but has private processor
+execution state.
+The machine context for the new thread is copied from the creating thread's
+context, including coprocessor state.
+FPU state and specific machine registers are excluded from the copy.
+These are set according to ABI requirements and syscall parameters.
+The FPU state for the new thread is reinitialized to clean.
+.Pp
+The
+.Fa param
+structure supplies parameters affecting the thread creation.
+The structure is defined in the
+.In sys/thr.h
+header as follows
+.Bd -literal
+struct thr_param {
+ void (*start_func)(void *);
+ void *arg;
+ char *stack_base;
+ size_t stack_size;
+ char *tls_base;
+ size_t tls_size;
+ long *child_tid;
+ long *parent_tid;
+ int flags;
+ struct rtprio *rtp;
+};
+.Ed
+and contains the following fields:
+.Bl -tag -width ".Va parent_tid"
+.It Va start_func
+Pointer to the thread entry function.
+The kernel arranges for the new thread to start executing the function
+upon the first return to userspace.
+.It Va arg
+Opaque argument supplied to the entry function.
+.It Va stack_base
+Stack base address.
+The stack must be allocated by the caller.
+On some architectures, the ABI might require that the system put information
+on the stack to ensure the execution environment for
+.Va start_func .
+.It Va stack_size
+Stack size.
+.It Va tls_base
+TLS base address.
+The value of TLS base is loaded into the ABI-defined machine register
+in the new thread context.
+.It Va tls_size
+TLS size.
+.It Va child_tid
+Address to store the new thread identifier, for the child's use.
+.It Va parent_tid
+Address to store the new thread identifier, for the parent's use.
+.Pp
+Both
+.Va child_tid
+and
+.Va parent_tid
+are provided, with the intent that
+.Va child_tid
+is used by the new thread to get its thread identifier without
+issuing the
+.Xr thr_self 2
+syscall, while
+.Va parent_tid
+is used by the thread creator.
+The latter is separate from
+.Va child_tid
+because the new thread might exit and free its thread data before the parent
+has a chance to execute far enough to access it.
+.It Va flags
+Thread creation flags.
+The
+.Va flags
+member may specify the following flags:
+.Bl -tag -width ".Dv THR_SYSTEM_SCOPE"
+.It Dv THR_SUSPENDED
+Create the new thread in the suspended state.
+The flag is not currently implemented.
+.It Dv THR_SYSTEM_SCOPE
+Create the system scope thread.
+The flag is not currently implemented.
+.It Dv THR_C_RUNTIME
+Indicate that the new thread is created by the C language runtime.
+It has architecture-specific meaning.
+.Pp
+On amd64, the flag requests that the specified
+.Fa tls_base
+was loaded into the
+.Va %fsbase
+register before calling a signal handler.
+.El
+.It Va rtp
+Real-time scheduling priority for the new thread.
+May be
+.Dv NULL
+to inherit the priority from the
+creating thread.
+.El
+.Pp
+The
+.Fa param_size
+argument should be set to the size of the
+.Fa param
+structure.
+.Pp
+After the first successful creation of an additional thread,
+the process is marked by the kernel as multi-threaded.
+In particular, the
+.Dv P_HADTHREADS
+flag is set in the process'
+.Dv p_flag
+(visible in the
+.Xr ps 1
+output), and several operations are executed in multi-threaded mode.
+For instance, the
+.Xr execve 2
+system call terminates all threads but the calling one on successful
+execution.
+.Sh RETURN VALUES
+If successful,
+.Fn thr_new
+will return zero, otherwise \-1 is returned, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn thr_new
+operation returns the following errors:
+.Bl -tag -width Er
+.\" When changing this list, consider updating share/man/man3/pthread_create.3,
+.\" since that function can return any of these errors.
+.It Bq Er EFAULT
+The memory pointed to by the
+.Fa param
+argument is not valid.
+.It Bq Er EFAULT
+The memory pointed to by the
+.Fa param
+structure
+.Fa child_tid , parent_tid
+or
+.Fa rtp
+arguments is not valid.
+.It Bq Er EFAULT
+The specified stack base is invalid, or the kernel was unable to put required
+initial data on the stack.
+.It Bq Er EINVAL
+The
+.Fa param_size
+argument specifies a negative value, or the value is greater than the
+largest
+.Fa struct param
+size the kernel can interpret.
+.It Bq Er EINVAL
+The
+.Fa rtp
+member is not
+.Dv NULL
+and specifies invalid scheduling parameters.
+.It Bq Er EINVAL
+The specified TLS base is invalid.
+.It Bq Er EPERM
+The caller does not have permission to set the scheduling parameters or
+scheduling policy.
+.It Bq Er EPROCLIM
+Creation of the new thread would exceed the
+.Dv RACCT_NTHR
+limit, see
+.Xr rctl_get_racct 2 .
+.It Bq Er EPROCLIM
+Creation of the new thread would exceed the
+.Dv kern.threads.max_threads_per_proc
+.Xr sysctl 3
+limit.
+.It Bq Er ENOMEM
+There was not enough kernel memory to allocate the new thread structures.
+.El
+.Sh SEE ALSO
+.Xr ps 1 ,
+.Xr _umtx_op 2 ,
+.Xr execve 2 ,
+.Xr rctl_get_racct 2 ,
+.Xr thr_exit 2 ,
+.Xr thr_kill 2 ,
+.Xr thr_kill2 2 ,
+.Xr thr_self 2 ,
+.Xr thr_set_name 2 ,
+.Xr pthread_create 3
+.Sh STANDARDS
+The
+.Fn thr_new
+system call is non-standard and is used by the
+.Lb libthr
+to implement
+.St -p1003.1-2001
+.Xr pthread 3
+functionality.
+.Sh HISTORY
+The
+.Fn thr_new
+system call first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/thr_self.2 b/lib/libsys/thr_self.2
new file mode 100644
index 000000000000..42d146448c05
--- /dev/null
+++ b/lib/libsys/thr_self.2
@@ -0,0 +1,92 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_SELF 2
+.Os
+.Sh NAME
+.Nm thr_self
+.Nd return thread identifier for the calling thread
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft int
+.Fn thr_self "long *id"
+.Sh DESCRIPTION
+The
+.Fn thr_self
+system call stores the system-wide thread identifier for the current
+kernel-scheduled thread in the variable pointed by the argument
+.Va id .
+.Pp
+The thread identifier is an integer in the range from
+.Dv PID_MAX + 2
+(100001) to
+.Dv INT_MAX .
+The thread identifier is guaranteed to be unique at any given time,
+for each running thread in the system.
+After the thread exits, the identifier may be reused.
+.Sh RETURN VALUES
+If successful,
+.Fn thr_self
+will return zero, otherwise \-1 is returned, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn thr_self
+operation may return the following errors:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The memory pointed to by the
+.Fa id
+argument is not valid.
+.El
+.Sh SEE ALSO
+.Xr _umtx_op 2 ,
+.Xr thr_exit 2 ,
+.Xr thr_kill 2 ,
+.Xr thr_kill2 2 ,
+.Xr thr_new 2 ,
+.Xr thr_set_name 2 ,
+.Xr pthread_getthreadid_np 3 ,
+.Xr pthread_self 3
+.Sh STANDARDS
+The
+.Fn thr_self
+system call is non-standard and is used by
+.Lb libthr
+to implement
+.St -p1003.1-2001
+.Xr pthread 3
+functionality.
+.Sh HISTORY
+The
+.Fn thr_self
+system call first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/thr_set_name.2 b/lib/libsys/thr_set_name.2
new file mode 100644
index 000000000000..38205f7f30b8
--- /dev/null
+++ b/lib/libsys/thr_set_name.2
@@ -0,0 +1,96 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_SET_NAME 2
+.Os
+.Sh NAME
+.Nm thr_set_name
+.Nd set user-visible thread name
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft int
+.Fn thr_set_name "long id" "const char *name"
+.Sh DESCRIPTION
+The
+.Fn thr_set_name
+system call sets the user-visible name for the thread with the identifier
+.Va id
+in the current process to the NUL-terminated string
+.Va name .
+The name will be silently truncated to fit into a buffer of
+.Dv MAXCOMLEN + 1
+bytes.
+The thread name can be seen in the output of the
+.Xr ps 1
+and
+.Xr top 1
+commands, in the kernel debuggers and kernel tracing facility outputs,
+and in userland debuggers and program core files, as notes.
+.Sh RETURN VALUES
+If successful,
+.Fn thr_set_name
+returns zero; otherwise, \-1 is returned, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn thr_set_name
+system call may return the following errors:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The memory pointed to by the
+.Fa name
+argument is not valid.
+.It Bq Er ESRCH
+The thread with the identifier
+.Fa id
+does not exist in the current process.
+.El
+.Sh SEE ALSO
+.Xr ps 1 ,
+.Xr _umtx_op 2 ,
+.Xr thr_exit 2 ,
+.Xr thr_kill 2 ,
+.Xr thr_kill2 2 ,
+.Xr thr_new 2 ,
+.Xr thr_self 2 ,
+.Xr pthread_set_name_np 3 ,
+.Xr ddb 4 ,
+.Xr ktr 9
+.Sh STANDARDS
+The
+.Fn thr_set_name
+system call is non-standard and is used by the
+.Lb libthr .
+.Sh HISTORY
+The
+.Fn thr_set_name
+system call first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/thr_suspend.2 b/lib/libsys/thr_suspend.2
new file mode 100644
index 000000000000..74eacb0daa3c
--- /dev/null
+++ b/lib/libsys/thr_suspend.2
@@ -0,0 +1,131 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_SUSPEND 2
+.Os
+.Sh NAME
+.Nm thr_suspend
+.Nd suspend the calling thread
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft int
+.Fn thr_suspend "struct timespec *timeout"
+.Sh DESCRIPTION
+.Bf -symbolic
+This function is intended for implementing threading.
+Normal applications should use
+.Xr pthread_cond_timedwait 3
+together with
+.Xr pthread_cond_broadcast 3
+for typical safe suspension with cooperation of the thread
+being suspended, or
+.Xr pthread_suspend_np 3
+and
+.Xr pthread_resume_np 3
+in some specific situations, instead.
+.Ef
+.Pp
+The
+.Fn thr_suspend
+system call puts the calling thread in a suspended state, where it is
+not eligible for CPU time.
+This state is exited by another thread calling
+.Xr thr_wake 2 ,
+when the time interval specified by
+.Fa timeout
+has elapsed,
+or by the delivery of a signal to the suspended thread.
+.Pp
+If the
+.Fa timeout
+argument is
+.Dv NULL ,
+the suspended state can be only terminated by explicit
+.Fn thr_wake
+or signal.
+.Pp
+If a wake from
+.Xr thr_wake 2
+was delivered before the
+.Nm
+call, the thread is not put into a suspended state.
+Instead, the call
+returns immediately without an error.
+.Pp
+If a thread previously called
+.Xr thr_wake 2
+with its own thread identifier, which resulted in setting the internal kernel
+flag to immediately abort interruptible sleeps with an
+.Er EINTR
+error
+.Po
+see
+.Xr thr_wake 2
+.Pc ,
+the flag is cleared.
+As with
+.Xr thr_wake 2
+called from another thread, the next
+.Nm
+call does not result in suspension.
+.Sh RETURN VALUES
+.Rv -std thr_suspend
+.Sh ERRORS
+The
+.Fn thr_suspend
+operation returns the following errors:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The memory pointed to by the
+.Fa timeout
+argument is not valid.
+.It Bq Er ETIMEDOUT
+The specified timeout expired.
+.It Bq Er ETIMEDOUT
+The
+.Fa timeout
+argument specified a zero time interval.
+.It Bq Er EINTR
+The sleep was interrupted by a signal.
+.El
+.Sh SEE ALSO
+.Xr ps 1 ,
+.Xr thr_wake 2 ,
+.Xr pthread_resume_np 3 ,
+.Xr pthread_suspend_np 3
+.Sh STANDARDS
+The
+.Fn thr_suspend
+system call is non-standard.
+.Sh HISTORY
+The
+.Fn thr_suspend
+system call first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/thr_wake.2 b/lib/libsys/thr_wake.2
new file mode 100644
index 000000000000..9091a2b0c06e
--- /dev/null
+++ b/lib/libsys/thr_wake.2
@@ -0,0 +1,114 @@
+.\" Copyright (c) 2016 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd May 5, 2020
+.Dt THR_WAKE 2
+.Os
+.Sh NAME
+.Nm thr_wake
+.Nd wake up the suspended thread
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/thr.h
+.Ft int
+.Fn thr_wake "long id"
+.Sh DESCRIPTION
+.Bf -symbolic
+This function is intended for implementing threading.
+Normal applications should use
+.Xr pthread_cond_timedwait 3
+together with
+.Xr pthread_cond_broadcast 3
+for typical safe suspension with cooperation of the thread
+being suspended, or
+.Xr pthread_suspend_np 3
+and
+.Xr pthread_resume_np 3
+in some specific situations, instead.
+.Ef
+.Pp
+Passing the thread identifier of the calling thread
+.Po
+see
+.Xr thr_self 2
+.Pc
+to
+.Fn thr_wake
+sets a thread's flag to cause the next signal-interruptible sleep
+of that thread in the kernel to fail immediately with the
+.Er EINTR
+error.
+The flag is cleared by an interruptible sleep attempt or by a call to
+.Xr thr_suspend 2 .
+This is used by the system threading library to implement cancellation.
+.Pp
+If
+.Fa id
+is not equal to the current thread identifier, the specified thread is
+woken up if suspended by the
+.Xr thr_suspend 2
+system call.
+If the thread is not suspended at the time of the
+.Nm
+call, the wake is remembered and the next attempt of the thread to
+suspend itself with the
+.Xr thr_suspend 2
+results in immediate return with success.
+Only one wake is remembered.
+.Sh RETURN VALUES
+.Rv -std thr_wake
+.Sh ERRORS
+The
+.Fn thr_wake
+operation returns these errors:
+.Bl -tag -width Er
+.It Bq Er ESRCH
+The specified thread was not found or does not belong to the process
+of the calling thread.
+.El
+.Sh SEE ALSO
+.Xr ps 1 ,
+.Xr thr_self 2 ,
+.Xr thr_suspend 2 ,
+.Xr pthread_cancel 3 ,
+.Xr pthread_resume_np 3 ,
+.Xr pthread_suspend_np 3
+.Sh STANDARDS
+The
+.Fn thr_suspend
+system call is non-standard and is used by
+.Lb libthr
+to implement
+.St -p1003.1-2001
+.Xr pthread 3
+functionality.
+.Sh HISTORY
+The
+.Fn thr_suspend
+system call first appeared in
+.Fx 5.2 .
diff --git a/lib/libsys/timer_create.2 b/lib/libsys/timer_create.2
new file mode 100644
index 000000000000..8f6ff2e27c51
--- /dev/null
+++ b/lib/libsys/timer_create.2
@@ -0,0 +1,199 @@
+.\" Copyright (c) 2005 David Xu <davidxu@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(s), this list of conditions and the following disclaimer as
+.\" the first lines of this file unmodified other than the possible
+.\" addition of one or more copyright notices.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
+.\"
+.Dd July 15, 2016
+.Dt TIMER_CREATE 2
+.Os
+.Sh NAME
+.Nm timer_create
+.Nd "create a per-process timer (REALTIME)"
+.Sh LIBRARY
+.Lb librt
+.Sh SYNOPSIS
+.In time.h
+.In signal.h
+.Ft int
+.Fo timer_create
+.Fa "clockid_t clockid" "struct sigevent *restrict evp"
+.Fa "timer_t *restrict timerid"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn timer_create
+system call creates a per-process timer using the specified clock,
+.Fa clock_id ,
+as the timing base.
+The
+.Fn timer_create
+system call returns, in the location referenced by
+.Fa timerid ,
+a timer ID of type
+.Vt timer_t
+used to identify the timer in timer requests.
+This timer ID is unique within the calling process until the timer is deleted.
+The particular clock,
+.Fa clock_id ,
+is defined in
+.In time.h .
+The timer whose ID is returned is in a disarmed state upon return from
+.Fn timer_create .
+.Pp
+The
+.Fa evp
+argument, if
+.Pf non- Dv NULL ,
+points to a
+.Vt sigevent
+structure.
+This structure,
+allocated by the application, defines the asynchronous notification to occur
+when the timer expires.
+.Pp
+If
+.Fa evp->sigev_notify
+is
+.Dv SIGEV_SIGNO
+or
+.Dv SIGEV_THREAD_ID ,
+the signal specified in
+.Fa evp->sigev_signo
+will be sent to the calling process
+.Pq Dv SIGEV_SIGNO
+or to the thread whose LWP ID is
+.Fa evp->sigev_notify_thread_id
+.Pq Dv SIGEV_THREAD_ID .
+The information for the queued signal will include:
+.Bl -column ".Va si_value"
+.It Sy Member Ta Sy Value
+.It Va si_code Ta Dv SI_TIMER
+.It Va si_value Ta
+the value stored in
+.Fa evp->sigev_value
+.It Va si_timerid Ta timer ID
+.It Va si_overrun Ta timer overrun count
+.It Va si_errno Ta
+If timer overrun is
+.Brq Dv DELAYTIMER_MAX ,
+an error code defined in
+.In errno.h
+.El
+.Pp
+If the
+.Fa evp
+argument is
+.Dv NULL ,
+the effect is as if the
+.Fa evp
+argument pointed to a
+.Vt sigevent
+structure with the
+.Va sigev_notify
+member having the value
+.Dv SIGEV_SIGNAL ,
+the
+.Va sigev_signo
+having a default signal number
+.Pq Dv SIGALRM ,
+and the
+.Va sigev_value
+member having
+the value of the timer ID.
+.Pp
+This implementation supports a
+.Fa clock_id
+of
+.Dv CLOCK_REALTIME ,
+.Dv CLOCK_TAI ,
+or
+.Dv CLOCK_MONOTONIC .
+.Pp
+If
+.Fa evp->sigev_notify
+is
+.Dv SIGEV_THREAD
+and
+.Fa sev->sigev_notify_attributes
+is not
+.Dv NULL ,
+if the attribute pointed to by
+.Fa sev->sigev_notify_attributes
+has
+a thread stack address specified by a call to
+.Fn pthread_attr_setstack
+or
+.Fn pthread_attr_setstackaddr ,
+the results are unspecified if the signal is generated more than once.
+.Sh RETURN VALUES
+If the call succeeds,
+.Fn timer_create
+returns zero and updates the location referenced by
+.Fa timerid
+to a
+.Vt timer_t ,
+which can be passed to the per-process timer calls.
+If an error
+occurs, the system call returns a value of \-1
+and the global variable
+.Va errno
+is set to indicate the
+error.
+The value of
+.Fa timerid
+is undefined if an error occurs.
+.Sh ERRORS
+The
+.Fn timer_create
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The calling process has already created all of the timers it is allowed by
+this implementation.
+.It Bq Er EINVAL
+The specified clock ID is not supported.
+.It Bq Er EINVAL
+The specified asynchronous notification method is not supported.
+.It Bq Er EFAULT
+Any arguments point outside the allocated address space or there is a
+memory protection fault.
+.El
+.Sh SEE ALSO
+.Xr clock_getres 2 ,
+.Xr timer_delete 2 ,
+.Xr timer_getoverrun 2 ,
+.Xr sigevent 3 ,
+.Xr siginfo 3
+.Sh STANDARDS
+The
+.Fn timer_create
+system call conforms to
+.St -p1003.1-2004 .
+.Sh HISTORY
+Support for
+.Tn POSIX
+per-process timer first appeared in
+.Fx 7.0 .
diff --git a/lib/libc/sys/timer_delete.2 b/lib/libsys/timer_delete.2
index dbd1a23779ab..dbd1a23779ab 100644
--- a/lib/libc/sys/timer_delete.2
+++ b/lib/libsys/timer_delete.2
diff --git a/lib/libc/sys/timer_settime.2 b/lib/libsys/timer_settime.2
index 08cf2ca17cc7..08cf2ca17cc7 100644
--- a/lib/libc/sys/timer_settime.2
+++ b/lib/libsys/timer_settime.2
diff --git a/lib/libsys/timerfd.2 b/lib/libsys/timerfd.2
new file mode 100644
index 000000000000..ae6cc6f6f49a
--- /dev/null
+++ b/lib/libsys/timerfd.2
@@ -0,0 +1,347 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2023 Jake Freeland <jfree@FreeBSD.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.
+.\"
+.\" 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.
+.\"
+.Dd June 28, 2024
+.Dt TIMERFD 2
+.Os
+.Sh NAME
+.Nm timerfd ,
+.Nm timerfd_create ,
+.Nm timerfd_gettime ,
+.Nm timerfd_settime
+.Nd timers with file descriptor semantics
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/timerfd.h
+.Ft int
+.Fo timerfd_create
+.Fa "int clockid"
+.Fa "int flags"
+.Fc
+.Ft int
+.Fo timerfd_gettime
+.Fa "int fd"
+.Fa "struct itimerspec *curr_value"
+.Fc
+.Ft int
+.Fo timerfd_settime
+.Fa "int fd"
+.Fa "int flags"
+.Fa "const struct itimerspec *new_value"
+.Fa "struct itimerspec *old_value"
+.Fc
+.Sh DESCRIPTION
+The
+.Nm
+system calls operate on timers, identified by special
+.Nm
+file descriptors.
+These calls are analogous to
+.Fn timer_create ,
+.Fn timer_gettime ,
+and
+.Fn timer_settime
+per-process timer functions, but use a
+.Nm
+descriptor in place of
+.Fa timerid .
+.Pp
+All
+.Nm
+descriptors possess traditional file descriptor semantics; they may be passed
+to other processes, preserved across
+.Xr fork 2 ,
+and monitored via
+.Xr kevent 2 ,
+.Xr poll 2 ,
+or
+.Xr select 2 .
+When a
+.Nm
+descriptor is no longer needed, it may be disposed of using
+.Xr close 2 .
+.Bl -tag -width "Fn timerfd_settime"
+.It Fn timerfd_create
+Initialize a
+.Nm
+object and return its file descriptor.
+The
+.Fa clockid
+argument specifies the clock used as a timing base and may be:
+.Pp
+.Bl -tag -width "Dv CLOCK_MONOTONIC" -compact
+.It Dv CLOCK_REALTIME
+Increments as a wall clock should.
+.It Dv CLOCK_BOOTTIME
+.It Dv CLOCK_MONOTONIC
+Increments monotonically in SI seconds.
+.It Dv CLOCK_UPTIME
+Increments monotonically in SI seconds, but is paused while the system is
+suspended.
+.El
+See
+.Xr clock_gettime 2
+for more precise definitions.
+.Pp
+The
+.Fa flags
+argument may contain the result of
+.Em or Ns 'ing
+the following values:
+.Pp
+.Bl -tag -width "Dv TFD_NONBLOCK" -compact
+.It Dv TFD_CLOEXEC
+The newly generated file descriptor will close-on-exec.
+.It Dv TFD_NONBLOCK
+Do not block on read/write operations.
+.El
+.It Fn timerfd_gettime
+Retrieve the current state of the timer denoted by
+.Fa fd .
+The result is stored in
+.Fa curr_value
+as a
+.Dv struct itimerspec .
+The
+.Fa it_value
+and
+.Fa it_interval
+members of
+.Fa curr_value
+represent the relative time until the next expiration and the interval
+reload value last set by
+.Fn timerfd_settime ,
+respectively.
+.It Fn timerfd_settime
+Update the timer denoted by
+.Fa fd
+with the
+.Dv struct itimerspec
+in
+.Fa new_value .
+The
+.Fa it_value
+member of
+.Fa new_value
+should contain the amount of time before the timer expires, or zero if the
+timer should be disarmed.
+The
+.Fa it_interval
+member should contain the reload time if an interval timer is desired.
+.Pp
+The previous timer state will be stored in
+.Fa old_value
+given
+.Fa old_value
+is not
+.Dv NULL .
+.Pp
+The
+.Fa flags
+argument may contain the result of
+.Em or Ns 'ing
+the following values:
+.Pp
+.Bl -tag -width TFD_TIMER_CANCEL_ON_SET -compact
+.It Dv TFD_TIMER_ABSTIME
+Expiration will occur at the absolute time provided in
+.Fa new_value .
+Normally,
+.Fa new_value
+represents a relative time compared to the timer's
+.Fa clockid
+clock.
+.It Dv TFD_TIMER_CANCEL_ON_SET
+If
+.Fa clockid
+has been set to
+.Dv CLOCK_REALTIME
+and the realtime clock has experienced a discontinuous jump,
+then the timer will be canceled and the next
+.Xr read 2
+will fail with
+.Dv ECANCELED .
+.El
+.El
+.Pp
+File operations have the following semantics:
+.Bl -tag -width ioctl
+.It Xr read 2
+Transfer the number of timer expirations that have occurred since the last
+successful
+.Xr read 2
+or
+.Fn timerfd_settime
+into the output buffer of size
+.Vt uint64_t .
+If the expiration counter is zero,
+.Xr read 2
+blocks until a timer expiration occurs unless
+.Dv TFD_NONBLOCK
+is set, where
+.Dv EAGAIN
+is returned.
+.It Xr poll 2
+The file descriptor is readable when its timer expiration counter is greater
+than zero.
+.It Xr ioctl 2
+.Bl -tag -width FIONREAD
+.It Dv FIOASYNC int
+A non-zero input will set the FASYNC flag.
+A zero input will clear the FASYNC flag.
+.It Dv FIONBIO int
+A non-zero input will set the FNONBLOCK flag.
+A zero input will clear the FNONBLOCK flag.
+.El
+.El
+.Sh RETURN VALUES
+The
+.Fn timerfd_create
+system call creates a
+.Nm
+object and returns its file descriptor.
+If an error occurs, -1 is returned and the global variable
+.Fa errno
+is set to indicate the error.
+.Pp
+The
+.Fn timerfd_gettime
+and
+.Fn timerfd_settime
+system calls return 0 on success.
+If an error occurs, -1 is returned and the global variable
+.Fa errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn timerfd_create
+system call fails if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The specified
+.Fa clockid
+is not supported.
+.It Bq Er EINVAL
+The provided
+.Fa flags
+are invalid.
+.It Bq Er EMFILE
+The per-process descriptor table is full.
+.It Bq Er ENFILE
+The system file table is full.
+.It Bq Er ENOMEM
+The kernel failed to allocate enough memory for the timer.
+.El
+.Pp
+Both
+.Fn timerfd_gettime
+and
+.Fn timerfd_settime
+system calls fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The provided
+.Fa fd
+is invalid.
+.It Bq Er EFAULT
+The addresses provided by
+.Fa curr_value ,
+.Fa new_value ,
+or
+.Fa old_value
+are invalid.
+.It Bq Er EINVAL
+The provided
+.Fa fd
+is valid, but was not generated by
+.Fn timerfd_create .
+.El
+.Pp
+The following errors only apply to
+.Fn timerfd_settime :
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The provided
+.Fa flags
+are invalid.
+.It Bq Er EINVAL
+A nanosecond field in the
+.Fa new_value
+argument specified a value less than zero, or greater than or equal to 10^9.
+.It Bq Er ECANCELED
+The timer was created with the clock ID
+.Dv CLOCK_REALTIME ,
+was configured with the
+.Dv TFD_TIMER_CANCEL_ON_SET
+flag, and the system realtime clock experienced a discontinuous change without
+being read.
+.El
+.Pp
+A read from a
+.Nm
+object fails if:
+.Bl -tag -width Er
+.It Bq Er EAGAIN
+The timer's expiration counter is zero and the
+.Nm
+object is set for non-blocking I/O.
+.It Bq Er ECANCELED
+The timer was created with the clock ID
+.Dv CLOCK_REALTIME ,
+was configured with the
+.Dv TFD_TIMER_CANCEL_ON_SET
+flag, and the system realtime clock experienced a discontinuous change.
+.It Bq Er EINVAL
+The size of the read buffer is not large enough to hold the
+.Vt uint64_t
+sized timer expiration counter.
+.El
+.Sh SEE ALSO
+.Xr eventfd 2 ,
+.Xr kqueue 2 ,
+.Xr poll 2 ,
+.Xr read 2 ,
+.Xr timer_create 2 ,
+.Xr timer_gettime 2 ,
+.Xr timer_settime 2
+.Sh STANDARDS
+The
+.Nm
+system calls originated from Linux and are non-standard.
+.Sh HISTORY
+.An -nosplit
+The
+.Nm
+facility was originally ported to
+.Fx Ns 's
+Linux compatibility layer by
+.An Dmitry Chagin Aq Mt dchagin@FreeBSD.org
+in
+.Fx 12.0 .
+It was revised and adapted to be native by
+.An Jake Freeland Aq Mt jfree@FreeBSD.org
+in
+.Fx 14.0 .
diff --git a/lib/libsys/truncate.2 b/lib/libsys/truncate.2
new file mode 100644
index 000000000000..1ab9fc033dd3
--- /dev/null
+++ b/lib/libsys/truncate.2
@@ -0,0 +1,167 @@
+.\" Copyright (c) 1983, 1991, 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.
+.\"
+.Dd March 30, 2020
+.Dt TRUNCATE 2
+.Os
+.Sh NAME
+.Nm truncate ,
+.Nm ftruncate
+.Nd truncate or extend a file to a specified length
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn truncate "const char *path" "off_t length"
+.Ft int
+.Fn ftruncate "int fd" "off_t length"
+.Sh DESCRIPTION
+The
+.Fn truncate
+system call
+causes the file named by
+.Fa path
+or referenced by
+.Fa fd
+to be truncated or extended to
+.Fa length
+bytes in size.
+If the file
+was larger than this size, the extra data
+is lost.
+If the file was smaller than this size,
+it will be extended as if by writing bytes
+with the value zero.
+.Pp
+The
+.Fn ftruncate
+system call causes the file or shared memory object backing the file descriptor
+.Fa fd
+to be truncated or extended to
+.Fa length
+bytes in size.
+The file descriptor must be a valid file descriptor open for writing.
+The file position pointer associated with the file descriptor
+.Fa fd
+will not be modified.
+.Sh RETURN VALUES
+.Rv -std
+If the file to be modified is not a directory or
+a regular file, the
+.Fn truncate
+call has no effect and returns the value 0.
+.Sh ERRORS
+The
+.Fn truncate
+system call
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+The named file is not writable by the user.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The named file has its immutable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EISDIR
+The named file is a directory.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er ETXTBSY
+The file is a pure procedure (shared text) file that is being executed.
+.It Bq Er EFBIG
+The
+.Fa length
+argument was greater than the maximum file size.
+.It Bq Er EINVAL
+The
+.Fa length
+argument was less than 0.
+.It Bq Er EIO
+An I/O error occurred updating the inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.El
+.Pp
+The
+.Fn ftruncate
+system call
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid descriptor.
+.It Bq Er EINVAL
+The
+.Fa fd
+argument
+references a file descriptor that is not a regular file or shared memory object.
+.It Bq Er EINVAL
+The
+.Fa fd
+descriptor
+is not open for writing.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr open 2 ,
+.Xr shm_open 2
+.Sh HISTORY
+The
+.Fn truncate
+and
+.Fn ftruncate
+system calls appeared in
+.Bx 4.2 .
+.Sh BUGS
+These calls should be generalized to allow ranges
+of bytes in a file to be discarded.
+.Pp
+Historically, the use of
+.Fn truncate
+or
+.Fn ftruncate
+to extend a file was not portable, but this behavior became required in
+.St -p1003.1-2008 .
diff --git a/lib/libsys/umask.2 b/lib/libsys/umask.2
new file mode 100644
index 000000000000..05f5ca090e55
--- /dev/null
+++ b/lib/libsys/umask.2
@@ -0,0 +1,85 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd June 4, 1993
+.Dt UMASK 2
+.Os
+.Sh NAME
+.Nm umask
+.Nd set file creation mode mask
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.Ft mode_t
+.Fn umask "mode_t numask"
+.Sh DESCRIPTION
+The
+.Fn umask
+routine sets the process's file mode creation mask to
+.Fa numask
+and returns the previous value of the mask.
+The 9 low-order
+access permission
+bits of
+.Fa numask
+are used by system calls, including
+.Xr open 2 ,
+.Xr mkdir 2 ,
+and
+.Xr mkfifo 2 ,
+to turn off corresponding bits
+requested in file mode.
+(See
+.Xr chmod 2 ) .
+This clearing allows each user to restrict the default access
+to his files.
+.Pp
+The default mask value is S_IWGRP|S_IWOTH (022, write access for the
+owner only).
+Child processes inherit the mask of the calling process.
+.Sh RETURN VALUES
+The previous value of the file mode mask is returned by the call.
+.Sh ERRORS
+The
+.Fn umask
+system call is always successful.
+.Sh SEE ALSO
+.Xr chmod 2 ,
+.Xr mkfifo 2 ,
+.Xr mknod 2 ,
+.Xr open 2
+.Sh STANDARDS
+The
+.Fn umask
+system call is expected to conform to
+.St -p1003.1-90 .
+.Sh HISTORY
+The
+.Fn umask
+function appeared in
+.At v7 .
diff --git a/lib/libsys/undelete.2 b/lib/libsys/undelete.2
new file mode 100644
index 000000000000..ef6b43926fc6
--- /dev/null
+++ b/lib/libsys/undelete.2
@@ -0,0 +1,104 @@
+.\" Copyright (c) 1994
+.\" Jan-Simon Pendry
+.\" 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.
+.\"
+.Dd March 30, 2020
+.Dt UNDELETE 2
+.Os
+.Sh NAME
+.Nm undelete
+.Nd attempt to recover a deleted file
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn undelete "const char *path"
+.Sh DESCRIPTION
+The
+.Fn undelete
+system call attempts to recover the deleted file named by
+.Fa path .
+Currently, this works only when the named object
+is a whiteout in a union file system.
+The system call removes the whiteout causing
+any objects in a lower layer of the
+union stack to become visible once more.
+.Pp
+Eventually, the
+.Fn undelete
+functionality may be expanded to other file systems able to recover
+deleted files such as the log-structured file system.
+.Sh RETURN VALUES
+.Rv -std undelete
+.Sh ERRORS
+The
+.Fn undelete
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er EEXIST
+The path does not reference a whiteout.
+.It Bq Er ENOENT
+The named whiteout does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+Write permission is denied on the directory containing the name
+to be undeleted.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The directory containing the name is marked sticky,
+and the containing directory is not owned by the effective user ID.
+.It Bq Er EINVAL
+The last component of the path is
+.Ql .. .
+.It Bq Er EIO
+An I/O error occurred while updating the directory entry.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The name resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.El
+.Sh SEE ALSO
+.Xr unlink 2 ,
+.Xr mount_unionfs 8
+.Sh HISTORY
+The
+.Fn undelete
+system call first appeared in
+.Bx 4.4 Lite .
diff --git a/lib/libsys/unlink.2 b/lib/libsys/unlink.2
new file mode 100644
index 000000000000..be2b44855daf
--- /dev/null
+++ b/lib/libsys/unlink.2
@@ -0,0 +1,281 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd February 23, 2021
+.Dt UNLINK 2
+.Os
+.Sh NAME
+.Nm unlink ,
+.Nm unlinkat ,
+.Nm funlinkat
+.Nd remove directory entry
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn unlink "const char *path"
+.Ft int
+.Fn unlinkat "int dfd" "const char *path" "int flag"
+.Ft int
+.Fn funlinkat "int dfd" "const char *path" "int fd" "int flag"
+.Sh DESCRIPTION
+The
+.Fn unlink
+system call
+removes the link named by
+.Fa path
+from its directory and decrements the link count of the
+file which was referenced by the link.
+If that decrement reduces the link count of the file
+to zero,
+and no process has the file open, then
+all resources associated with the file are reclaimed.
+If one or more process have the file open when the last link is removed,
+the link is removed, but the removal of the file is delayed until
+all references to it have been closed.
+The
+.Fa path
+argument
+may not be a directory.
+.Pp
+The
+.Fn unlinkat
+system call is equivalent to
+.Fn unlink
+or
+.Fn rmdir
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the directory entry to be removed is determined
+relative to the directory associated with the file descriptor
+.Fa dfd
+instead of the current working directory.
+.Pp
+The values for
+.Fa flag
+are constructed by a bitwise-inclusive OR of flags from the following list,
+defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_REMOVEDIR
+Remove the directory entry specified by
+.Fa fd
+and
+.Fa path
+as a directory, not a normal file.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.El
+.Pp
+If
+.Fn unlinkat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior is
+identical to a call to
+.Fa unlink
+or
+.Fa rmdir
+respectively, depending on whether or not the
+.Dv AT_REMOVEDIR
+bit is set in flag.
+.Pp
+The
+.Fn funlinkat
+system call can be used to unlink an already-opened file, unless that
+file has been replaced since it was opened.
+It is equivalent to
+.Fn unlinkat
+in the case where
+.Fa path
+is already open as the file descriptor
+.Fa fd .
+Otherwise, the path will not be removed and an error will be returned.
+The
+.Fa fd
+can be set the
+.Dv FD_NONE .
+In that case
+.Fn funlinkat
+behaves exactly like
+.Fn unlinkat .
+.Sh RETURN VALUES
+.Rv -std unlink
+.Sh ERRORS
+The
+.Fn unlink
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er EISDIR
+The named file is a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+Write permission is denied on the directory containing the link
+to be removed.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The named file is a directory.
+.It Bq Er EPERM
+The named file has its immutable, undeletable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EPERM
+The parent directory of the named file has its immutable or append-only flag
+set.
+.It Bq Er EPERM
+The directory containing the file is marked sticky,
+and neither the containing directory nor the file to be removed
+are owned by the effective user ID.
+.It Bq Er EIO
+An I/O error occurred while deleting the directory entry
+or deallocating the inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EROFS
+The named file resides on a read-only file system.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er ENOSPC
+On file systems supporting copy-on-write or snapshots, there was not enough
+free space to record metadata for the delete operation of the file.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn unlink ,
+the
+.Fn unlinkat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTEMPTY
+The
+.Fa flag
+parameter has the
+.Dv AT_REMOVEDIR
+bit set and the
+.Fa path
+argument names a directory that is not an empty directory,
+or there are hard links to the directory other than dot or
+a single entry in dot-dot.
+.It Bq Er ENOTDIR
+The
+.Fa flag
+parameter has the
+.Dv AT_REMOVEDIR
+bit set and
+.Fa path
+does not name a directory.
+.It Bq Er EINVAL
+The value of the
+.Fa flag
+argument is not valid.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Pp
+In addition to the errors returned by
+.Fn unlinkat ,
+.Fn funlinkat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EDEADLK
+The file descriptor is not associated with the path.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr close 2 ,
+.Xr link 2 ,
+.Xr rmdir 2 ,
+.Xr symlink 7
+.Sh STANDARDS
+The
+.Fn unlinkat
+system call follows The Open Group Extended API Set 2 specification.
+.Sh HISTORY
+The
+.Fn unlink
+function appeared in
+.At v1 .
+The
+.Fn unlinkat
+system call appeared in
+.Fx 8.0 .
+The
+.Fn funlinkat
+system call appeared in
+.Fx 13.0 .
+.Pp
+The
+.Fn unlink
+system call traditionally allows the super-user to unlink directories which
+can damage the file system integrity.
+This implementation no longer permits it.
diff --git a/lib/libsys/usleep.3 b/lib/libsys/usleep.3
new file mode 100644
index 000000000000..c8c8df24d309
--- /dev/null
+++ b/lib/libsys/usleep.3
@@ -0,0 +1,77 @@
+.\" Copyright (c) 1986, 1991, 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.
+.\"
+.Dd February 11, 2021
+.Dt USLEEP 3
+.Os
+.Sh NAME
+.Nm usleep
+.Nd suspend thread execution for an interval measured in microseconds
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft int
+.Fn usleep "useconds_t microseconds"
+.Sh DESCRIPTION
+The
+.Fn usleep
+function suspends execution of the calling thread until either
+.Fa microseconds
+microseconds have elapsed or a signal is delivered to the thread and its
+action is to invoke a signal-catching function or to terminate the
+process.
+System activity may lengthen the sleep by an indeterminate amount.
+.Pp
+This function is implemented using
+.Xr nanosleep 2
+by pausing for
+.Fa microseconds
+microseconds or until a signal occurs.
+Consequently, in this implementation,
+sleeping has no effect on the state of process timers,
+and there is no special handling for SIGALRM.
+.Sh RETURN VALUES
+.Rv -std usleep
+.Sh ERRORS
+The
+.Fn usleep
+function
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINTR
+A signal was delivered to the calling thread and its
+action was to invoke a signal-catching function.
+.El
+.Sh SEE ALSO
+.Xr nanosleep 2 ,
+.Xr sleep 3
+.Sh HISTORY
+The
+.Fn usleep
+function appeared in
+.Bx 4.3 .
diff --git a/lib/libsys/utimensat.2 b/lib/libsys/utimensat.2
new file mode 100644
index 000000000000..e2c5a8b90939
--- /dev/null
+++ b/lib/libsys/utimensat.2
@@ -0,0 +1,307 @@
+.\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled Exp $
+.\"
+.\" Copyright (c) 1990, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\" Copyright (c) 2012, Jilles Tjoelker
+.\"
+.\" 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.
+.\"
+.Dd June 12, 2022
+.Dt UTIMENSAT 2
+.Os
+.Sh NAME
+.Nm futimens ,
+.Nm utimensat
+.Nd set file access and modification times
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/stat.h
+.Ft int
+.Fn futimens "int fd" "const struct timespec times[2]"
+.Ft int
+.Fo utimensat
+.Fa "int fd"
+.Fa "const char *path"
+.Fa "const struct timespec times[2]"
+.Fa "int flag"
+.Fc
+.Sh DESCRIPTION
+The access and modification times of the file named by
+.Fa path
+or referenced by
+.Fa fd
+are changed as specified by the argument
+.Fa times .
+The inode-change-time of the file is set to the current time.
+.Pp
+If
+.Fa path
+specifies a relative path,
+it is relative to the current working directory if
+.Fa fd
+is
+.Dv AT_FDCWD
+and otherwise relative to the directory associated with the file descriptor
+.Fa fd .
+.Pp
+The
+.Va tv_nsec
+field of a
+.Vt timespec
+structure
+can be set to the special value
+.Dv UTIME_NOW
+to set the current time, or to
+.Dv UTIME_OMIT
+to leave the time unchanged.
+In either case, the
+.Va tv_sec
+field is ignored.
+.Pp
+If
+.Fa times
+is
+.No non- Ns Dv NULL ,
+it is assumed to point to an array of two timespec structures.
+The access time is set to the value of the first element, and the
+modification time is set to the value of the second element.
+For file systems that support file birth (creation) times (such as
+.Dv UFS2 ) ,
+the birth time will be set to the value of the second element
+if the second element is older than the currently set birth time.
+To set both a birth time and a modification time,
+two calls are required; the first to set the birth time
+and the second to set the (presumably newer) modification time.
+Ideally a new system call will be added that allows the setting
+of all three times at once.
+If
+.Fa times
+is
+.Dv NULL ,
+this is equivalent to passing
+a pointer to an array of two timespec structures
+with both
+.Va tv_nsec
+fields set to
+.Dv UTIME_NOW .
+.Pp
+If both
+.Va tv_nsec
+fields are
+.Dv UTIME_OMIT ,
+the timestamps remain unchanged and
+no permissions are needed for the file itself,
+although search permissions may be required for the path prefix.
+The call may or may not succeed if the named file does not exist.
+.Pp
+If both
+.Va tv_nsec
+fields are
+.Dv UTIME_NOW ,
+the caller must be the owner of the file, have permission to
+write the file, or be the super-user.
+.Pp
+For all other values of the timestamps,
+the caller must be the owner of the file or be the super-user.
+.Pp
+The values for the
+.Fa flag
+argument of the
+.Fn utimensat
+system call
+are constructed by a bitwise-inclusive OR of flags from the following list,
+defined in
+.In fcntl.h :
+.Bl -tag -width indent
+.It Dv AT_SYMLINK_NOFOLLOW
+If
+.Fa path
+names a symbolic link, the symbolic link's times are changed.
+By default,
+.Fn utimensat
+changes the times of the file referenced by the symbolic link.
+.It Dv AT_RESOLVE_BENEATH
+Only walk paths below the directory specified by the
+.Ar fd
+descriptor.
+See the description of the
+.Dv O_RESOLVE_BENEATH
+flag in the
+.Xr open 2
+manual page.
+.It Dv AT_EMPTY_PATH
+If the
+.Fa path
+argument is an empty string, operate on the file or directory
+referenced by the descriptor
+.Fa fd .
+If
+.Fa fd
+is equal to
+.Dv AT_FDCWD ,
+operate on the current working directory.
+.El
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+These system calls will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+The
+.Fa times
+argument is
+.Dv NULL ,
+or both
+.Va tv_nsec
+values are
+.Dv UTIME_NOW ,
+and the effective user ID of the process does not
+match the owner of the file, and is not the super-user, and write
+access is denied.
+.It Bq Er EFAULT
+The
+.Fa times
+argument
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The
+.Va tv_nsec
+component of at least one of the values specified by the
+.Fa times
+argument has a value less than 0 or greater than 999999999 and is not equal to
+.Dv UTIME_NOW
+or
+.Dv UTIME_OMIT .
+.It Bq Er EIO
+An I/O error occurred while reading or writing the affected inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er EPERM
+The
+.Fa times
+argument is not
+.Dv NULL
+nor are both
+.Va tv_nsec
+values
+.Dv UTIME_NOW ,
+nor are both
+.Va tv_nsec
+values
+.Dv UTIME_OMIT
+and the calling process's effective user ID
+does not match the owner of the file and is not the super-user.
+.It Bq Er EPERM
+The named file has its immutable or append-only flag set, see the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EROFS
+The file system containing the file is mounted read-only.
+.El
+.Pp
+The
+.Fn futimens
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+does not refer to a valid descriptor.
+.El
+.Pp
+The
+.Fn utimensat
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor.
+.It Bq Er EFAULT
+The
+.Fa path
+argument
+points outside the process's allocated address space.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded
+.Dv NAME_MAX
+characters, or an entire path name exceeded
+.Dv PATH_MAX
+characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.It Bq Er ENOTCAPABLE
+.Fa path
+is an absolute path,
+or contained a ".." component leading to a
+directory outside of the directory hierarchy specified by
+.Fa fd ,
+and the process is in capability mode or the
+.Dv AT_RESOLVE_BENEATH
+flag was specified.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr stat 2 ,
+.Xr symlink 2 ,
+.Xr utimes 2 ,
+.Xr utime 3 ,
+.Xr symlink 7
+.Sh STANDARDS
+The
+.Fn futimens
+and
+.Fn utimensat
+system calls are expected to conform to
+.St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Fn futimens
+and
+.Fn utimensat
+system calls appeared in
+.Fx 10.3 .
diff --git a/lib/libsys/utimes.2 b/lib/libsys/utimes.2
new file mode 100644
index 000000000000..413e107a90c5
--- /dev/null
+++ b/lib/libsys/utimes.2
@@ -0,0 +1,261 @@
+.\" $NetBSD: utimes.2,v 1.13 1999/03/22 19:45:11 garbled 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.
+.\"
+.Dd March 30, 2020
+.Dt UTIMES 2
+.Os
+.Sh NAME
+.Nm utimes ,
+.Nm lutimes ,
+.Nm futimes ,
+.Nm futimesat
+.Nd set file access and modification times
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/time.h
+.Ft int
+.Fn utimes "const char *path" "const struct timeval *times"
+.Ft int
+.Fn lutimes "const char *path" "const struct timeval *times"
+.Ft int
+.Fn futimes "int fd" "const struct timeval *times"
+.Ft int
+.Fn futimesat "int fd" "const char *path" "const struct timeval times[2]"
+.Sh DESCRIPTION
+.Bf -symbolic
+These interfaces are obsoleted by
+.Xr futimens 2
+and
+.Xr utimensat 2
+because they are not accurate to nanoseconds.
+.Ef
+.Pp
+The access and modification times of the file named by
+.Fa path
+or referenced by
+.Fa fd
+are changed as specified by the argument
+.Fa times .
+.Pp
+If
+.Fa times
+is
+.Dv NULL ,
+the access and modification times are set to the current time.
+The caller must be the owner of the file, have permission to
+write the file, or be the super-user.
+.Pp
+If
+.Fa times
+is
+.No non- Ns Dv NULL ,
+it is assumed to point to an array of two timeval structures.
+The access time is set to the value of the first element, and the
+modification time is set to the value of the second element.
+For file systems that support file birth (creation) times (such as
+.Dv UFS2 ) ,
+the birth time will be set to the value of the second element
+if the second element is older than the currently set birth time.
+To set both a birth time and a modification time,
+two calls are required; the first to set the birth time
+and the second to set the (presumably newer) modification time.
+Ideally a new system call will be added that allows the setting
+of all three times at once.
+The caller must be the owner of the file or be the super-user.
+.Pp
+In either case, the inode-change-time of the file is set to the current
+time.
+.Pp
+The
+.Fn lutimes
+system call
+is like
+.Fn utimes
+except in the case where the named file is a symbolic link,
+in which case
+.Fn lutimes
+changes the access and modification times of the link,
+while
+.Fn utimes
+changes the times of the file the link references.
+.Pp
+The
+.Fn futimesat
+system call is equivalent to
+.Fn utimes
+except in the case where
+.Fa path
+specifies a relative path.
+In this case the access and modification time
+is set to that of a file relative to the directory associated with the file
+descriptor
+.Fa fd
+instead of the current working directory.
+If
+.Fn futimesat
+is passed the special value
+.Dv AT_FDCWD
+in the
+.Fa fd
+parameter, the current working directory is used and the behavior
+is identical to a call to
+.Fn utimes .
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+All of the system call will fail if:
+.Bl -tag -width Er
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er EACCES
+The
+.Fa times
+argument is
+.Dv NULL
+and the effective user ID of the process does not
+match the owner of the file, and is not the super-user, and write
+access is denied.
+.It Bq Er EFAULT
+The
+.Fa path
+or
+.Fa times
+argument
+points outside the process's allocated address space.
+.It Bq Er EFAULT
+The
+.Fa times
+argument
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The
+.Va tv_usec
+component of at least one of the values specified by the
+.Fa times
+argument has a value less than 0 or greater than 999999.
+.It Bq Er EIO
+An I/O error occurred while reading or writing the affected inode.
+.It Bq Er EINTEGRITY
+Corrupted data was detected while reading from the file system.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded
+.Dv NAME_MAX
+characters, or an entire path name exceeded
+.Dv PATH_MAX
+characters.
+.It Bq Er ENOENT
+The named file does not exist.
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er EPERM
+The
+.Fa times
+argument is not
+.Dv NULL
+and the calling process's effective user ID
+does not match the owner of the file and is not the super-user.
+.It Bq Er EPERM
+The named file has its immutable or append-only flags set.
+See the
+.Xr chflags 2
+manual page for more information.
+.It Bq Er EROFS
+The file system containing the file is mounted read-only.
+.El
+.Pp
+The
+.Fn futimes
+system call
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+does not refer to a valid descriptor.
+.El
+.Pp
+In addition to the errors returned by the
+.Fn utimes ,
+the
+.Fn futimesat
+may fail if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa path
+argument does not specify an absolute path and the
+.Fa fd
+argument is neither
+.Dv AT_FDCWD
+nor a valid file descriptor open for searching.
+.It Bq Er ENOTDIR
+The
+.Fa path
+argument is not an absolute path and
+.Fa fd
+is neither
+.Dv AT_FDCWD
+nor a file descriptor associated with a directory.
+.El
+.Sh SEE ALSO
+.Xr chflags 2 ,
+.Xr stat 2 ,
+.Xr utimensat 2 ,
+.Xr utime 3
+.Sh STANDARDS
+The
+.Fn utimes
+function is expected to conform to
+.St -xpg4.2 .
+The
+.Fn futimesat
+system call follows The Open Group Extended API Set 2 specification
+but was replaced by
+.Fn utimensat
+in
+.St -p1003.1-2008 .
+.Sh HISTORY
+The
+.Fn utimes
+system call appeared in
+.Bx 4.2 .
+The
+.Fn futimes
+and
+.Fn lutimes
+system calls first appeared in
+.Fx 3.0 .
+The
+.Fn futimesat
+system call appeared in
+.Fx 8.0 .
diff --git a/lib/libc/sys/utrace.2 b/lib/libsys/utrace.2
index f18e65d81a59..f18e65d81a59 100644
--- a/lib/libc/sys/utrace.2
+++ b/lib/libsys/utrace.2
diff --git a/lib/libc/sys/uuidgen.2 b/lib/libsys/uuidgen.2
index aa5362947300..aa5362947300 100644
--- a/lib/libc/sys/uuidgen.2
+++ b/lib/libsys/uuidgen.2
diff --git a/lib/libsys/vfork.2 b/lib/libsys/vfork.2
new file mode 100644
index 000000000000..cb17d02bc8d2
--- /dev/null
+++ b/lib/libsys/vfork.2
@@ -0,0 +1,142 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd May 22, 2016
+.Dt VFORK 2
+.Os
+.Sh NAME
+.Nm vfork
+.Nd create a new process without copying the address space
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft pid_t
+.Fn vfork void
+.Sh DESCRIPTION
+.Bf -symbolic
+Since this function is hard to use correctly from application software,
+it is recommended to use
+.Xr posix_spawn 3
+or
+.Xr fork 2
+instead.
+.Ef
+.Pp
+The
+.Fn vfork
+system call
+can be used to create new processes without fully copying the address
+space of the old process, which is inefficient in a paged
+environment.
+It is useful when the purpose of
+.Xr fork 2
+would have been to create a new system context for an
+.Xr execve 2 .
+The
+.Fn vfork
+system call
+differs from
+.Xr fork 2
+in that the child borrows the parent process's address space and the
+calling thread's stack
+until a call to
+.Xr execve 2
+or an exit (either by a call to
+.Xr _exit 2
+or abnormally).
+The calling thread is suspended while the child is using its resources.
+Other threads continue to run.
+.Pp
+The
+.Fn vfork
+system call
+returns 0 in the child's context and (later) the pid of the child in
+the parent's context.
+.Pp
+Many problems can occur when replacing
+.Xr fork 2
+with
+.Fn vfork .
+For example, it does not work to return while running in the child's context
+from the procedure that called
+.Fn vfork
+since the eventual return from
+.Fn vfork
+would then return to a no longer existent stack frame.
+Also, changing process state which is partially implemented in user space
+such as signal handlers with
+.Xr libthr 3
+will corrupt the parent's state.
+.Pp
+Be careful, also, to call
+.Xr _exit 2
+rather than
+.Xr exit 3
+if you cannot
+.Xr execve 2 ,
+since
+.Xr exit 3
+will flush and close standard I/O channels, and thereby mess up the
+parent processes standard I/O data structures.
+(Even with
+.Xr fork 2
+it is wrong to call
+.Xr exit 3
+since buffered data would then be flushed twice.)
+.Sh RETURN VALUES
+Same as for
+.Xr fork 2 .
+.Sh SEE ALSO
+.Xr _exit 2 ,
+.Xr execve 2 ,
+.Xr fork 2 ,
+.Xr rfork 2 ,
+.Xr sigaction 2 ,
+.Xr wait 2 ,
+.Xr exit 3 ,
+.Xr posix_spawn 3
+.Sh HISTORY
+The
+.Fn vfork
+system call appeared in
+.Bx 3 .
+.Sh BUGS
+To avoid a possible deadlock situation,
+processes that are children in the middle
+of a
+.Fn vfork
+are never sent
+.Dv SIGTTOU
+or
+.Dv SIGTTIN
+signals; rather,
+output or
+.Xr ioctl 2
+calls
+are allowed
+and input attempts result in an end-of-file indication.
diff --git a/lib/libsys/wait.2 b/lib/libsys/wait.2
new file mode 100644
index 000000000000..eeddf77aeac7
--- /dev/null
+++ b/lib/libsys/wait.2
@@ -0,0 +1,693 @@
+.\" Copyright (c) 1980, 1991, 1993, 1994
+.\" 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.
+.\"
+.Dd June 19, 2025
+.Dt WAIT 2
+.Os
+.Sh NAME
+.Nm wait ,
+.Nm waitid ,
+.Nm waitpid ,
+.Nm wait3 ,
+.Nm wait4 ,
+.Nm wait6
+.Nd wait for processes to change status
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/wait.h
+.Ft pid_t
+.Fn wait "int *status"
+.Ft pid_t
+.Fn waitpid "pid_t wpid" "int *status" "int options"
+.In signal.h
+.Ft int
+.Fn waitid "idtype_t idtype" "id_t id" "siginfo_t *info" "int options"
+.In sys/time.h
+.In sys/resource.h
+.Ft pid_t
+.Fn wait3 "int *status" "int options" "struct rusage *rusage"
+.Ft pid_t
+.Fn wait4 "pid_t wpid" "int *status" "int options" "struct rusage *rusage"
+.Ft pid_t
+.Fo wait6
+.Fa "idtype_t idtype" "id_t id"
+.Fa "int *status"
+.Fa "int options"
+.Fa "struct __wrusage *wrusage"
+.Fa "siginfo_t *infop"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn wait
+function suspends execution of its calling thread until
+.Fa status
+information is available for a child process
+or a signal is received.
+On return from a successful
+.Fn wait
+call,
+the
+.Fa status
+area contains information about the process that reported a status change
+as defined below.
+.Pp
+The
+.Fn wait4
+and
+.Fn wait6
+system calls provide a more general interface for programs
+that need to wait for specific child processes,
+that need resource utilization statistics accumulated by child processes,
+or that require options.
+The other wait functions are implemented using either
+.Fn wait4
+or
+.Fn wait6 .
+.Pp
+The
+.Fn wait6
+function is the most general function in this family and its distinct
+features are:
+.Pp
+All of the desired process statuses to be waited on must be explicitly
+specified in
+.Fa options .
+The
+.Fn wait ,
+.Fn waitpid ,
+.Fn wait3 ,
+and
+.Fn wait4
+functions all implicitly wait for exited and trapped processes,
+but the
+.Fn waitid
+and
+.Fn wait6
+functions require the corresponding
+.Dv WEXITED
+and
+.Dv WTRAPPED
+flags to be explicitly specified.
+This allows waiting for processes which have experienced other
+status changes without having to also handle the exit status from
+terminated processes.
+.Pp
+The
+.Fn wait6
+function accepts a
+.Fa wrusage
+argument which points to a structure defined as:
+.Bd -literal
+struct __wrusage {
+ struct rusage wru_self;
+ struct rusage wru_children;
+};
+.Ed
+.Pp
+This allows the calling process to collect resource usage statistics
+from both its own child process as well as from its grand children.
+When no resource usage statistics are needed this pointer can be
+.Dv NULL .
+.Pp
+The last argument
+.Fa infop
+must be either
+.Dv NULL
+or a pointer to a
+.Fa siginfo_t
+structure.
+If
+.Pf non- Dv NULL ,
+the structure is filled with the same data as for a
+.Dv SIGCHLD
+signal delivered when the process changed state.
+.Pp
+The set of child processes to be queried is specified by the arguments
+.Fa idtype
+and
+.Fa id .
+The separate
+.Fa idtype
+and
+.Fa id
+arguments support many other types of
+identifiers in addition to process IDs and process group IDs.
+.Bl -bullet -offset indent
+.It
+If
+.Fa idtype
+is
+.Dv P_PID ,
+.Fn waitid
+and
+.Fn wait6
+wait for the child process with a process ID equal to
+.Dv (pid_t)id .
+.It
+If
+.Fa idtype
+is
+.Dv P_PGID ,
+.Fn waitid
+and
+.Fn wait6
+wait for the child process with a process group ID equal to
+.Dv (pid_t)id .
+.It
+If
+.Fa idtype
+is
+.Dv P_ALL ,
+.Fn waitid
+and
+.Fn wait6
+wait for any child process and the
+.Dv id
+is ignored.
+.It
+If
+.Fa idtype
+is
+.Dv P_PID
+or
+.Dv P_PGID
+and the
+.Dv id
+is zero,
+.Fn waitid
+and
+.Fn wait6
+wait for any child process in the same process group as the caller.
+.El
+.Pp
+Non-standard identifier types supported by this
+implementation of
+.Fn waitid
+and
+.Fn wait6
+are:
+.Bl -tag -width P_JAILID
+.It Dv P_UID
+Wait for processes whose effective user ID is equal to
+.Dv (uid_t) Fa id .
+.It Dv P_GID
+Wait for processes whose effective group ID is equal to
+.Dv (gid_t) Fa id .
+.It Dv P_SID
+Wait for processes whose session ID is equal to
+.Fa id .
+.\" This is just how sessions work, not sure this needs to be documented here
+If the child process started its own session,
+its session ID will be the same as its process ID.
+Otherwise the session ID of a child process will match the caller's session ID.
+.It Dv P_JAILID
+Waits for processes within a jail whose jail identifier is equal to
+.Fa id .
+.El
+.Pp
+For the
+.Fn waitpid
+and
+.Fn wait4
+functions, the single
+.Fa wpid
+argument specifies the set of child processes for which to wait.
+.Bl -bullet -offset indent
+.It
+If
+.Fa wpid
+is -1, the call waits for any child process.
+.It
+If
+.Fa wpid
+is 0,
+the call waits for any child process in the process group of the caller.
+.It
+If
+.Fa wpid
+is greater than zero, the call waits for the process with process ID
+.Fa wpid .
+.It
+If
+.Fa wpid
+is less than -1, the call waits for any process whose process group ID
+equals the absolute value of
+.Fa wpid .
+.El
+.Pp
+The
+.Fa status
+argument is defined below.
+.Pp
+The
+.Fa options
+argument contains the bitwise OR of any of the following options.
+.Bl -tag -width WCONTINUED
+.It Dv WCONTINUED
+Report the status of selected processes that
+have continued from a job control stop by receiving a
+.Dv SIGCONT
+signal.
+.Xr ptrace 2
+can also cause a process to be continued, when a
+.Dv PT_DETACH
+request is issued to detach the debugger.
+.It Dv WNOHANG
+Do not block when
+there are no processes wishing to report status.
+.It Dv WUNTRACED
+Report the status of selected processes which are stopped due to a
+.Dv SIGTTIN , SIGTTOU , SIGTSTP ,
+or
+.Dv SIGSTOP
+signal.
+.It Dv WSTOPPED
+An alias for
+.Dv WUNTRACED .
+.It Dv WTRAPPED
+Report the status of selected processes which are being traced via
+.Xr ptrace 2
+and have trapped or reached a breakpoint.
+This flag is implicitly set for the functions
+.Fn wait ,
+.Fn waitpid ,
+.Fn wait3 ,
+and
+.Fn wait4 .
+.br
+For the
+.Fn waitid
+and
+.Fn wait6
+functions, the flag has to be explicitly included in
+.Fa options
+if status reports from trapped processes are expected.
+.It Dv WEXITED
+Report the status of selected processes which have terminated.
+This flag is implicitly set for the functions
+.Fn wait ,
+.Fn waitpid ,
+.Fn wait3 ,
+and
+.Fn wait4 .
+.br
+For the
+.Fn waitid
+and
+.Fn wait6
+functions, the flag has to be explicitly included in
+.Fa options
+if status reports from terminated processes are expected.
+.It Dv WNOWAIT
+Keep the process whose status is returned in a waitable state.
+The process may be waited for again after this call completes.
+.El
+.sp
+For the
+.Fn waitid
+and
+.Fn wait6
+functions, at least one of the options
+.Dv WEXITED ,
+.Dv WUNTRACED ,
+.Dv WSTOPPED ,
+.Dv WTRAPPED ,
+or
+.Dv WCONTINUED
+must be specified.
+Otherwise there will be no events for the call to report.
+To avoid hanging indefinitely in such a case these functions
+return -1 with
+.Dv errno
+set to
+.Dv EINVAL .
+.Pp
+If
+.Fa rusage
+is non-NULL, a summary of the resources used by the terminated
+process and all its children is returned.
+.Pp
+If
+.Fa wrusage
+is non-NULL, separate summaries are returned for the resources used
+by the terminated process and the resources used by all its children.
+.Pp
+If
+.Fa infop
+is non-NULL, a
+.Dv siginfo_t
+structure is returned with the
+.Fa si_signo
+field set to
+.Dv SIGCHLD
+and the
+.Fa si_pid
+field set to the process ID of the process reporting status.
+For the exited process, the
+.Fa si_status
+field of the
+.Dv siginfo_t
+structure contains the full 32 bit exit status passed to
+.Xr _exit 2 ;
+the
+.Fa status
+argument of other calls only returns 8 lowest bits of the exit status.
+.Pp
+When the
+.Dv WNOHANG
+option is specified and no processes
+wish to report status,
+.Fn waitid
+sets the
+.Fa si_signo
+and
+.Fa si_pid
+fields in
+.Fa infop
+to zero.
+Checking these fields is the only way to know if a status change was reported.
+.Pp
+When the
+.Dv WNOHANG
+option is specified and no processes
+wish to report status,
+.Fn wait4
+and
+.Fn wait6
+return a
+process id
+of 0.
+.Pp
+The
+.Fn wait
+call is the same as
+.Fn wait4
+with a
+.Fa wpid
+value of -1,
+with an
+.Fa options
+value of zero,
+and a
+.Fa rusage
+value of
+.Dv NULL .
+The
+.Fn waitpid
+function is identical to
+.Fn wait4
+with an
+.Fa rusage
+value of
+.Dv NULL .
+The older
+.Fn wait3
+call is the same as
+.Fn wait4
+with a
+.Fa wpid
+value of -1.
+The
+.Fn wait4
+function is identical to
+.Fn wait6
+with the flags
+.Dv WEXITED
+and
+.Dv WTRAPPED
+set in
+.Fa options
+and
+.Fa infop
+set to
+.Dv NULL .
+.Pp
+The following macros may be used to test the current status of the process.
+Exactly one of the following four macros will evaluate to a non-zero
+.Pq true
+value:
+.Bl -tag -width Ds
+.It Fn WIFCONTINUED status
+True if the process has not terminated, and
+has continued after a job control stop or detach of a debugger.
+This macro can be true only if the wait call specified the
+.Dv WCONTINUED
+option.
+.It Fn WIFEXITED status
+True if the process terminated normally by a call to
+.Xr _exit 2
+or
+.Xr exit 3 .
+.It Fn WIFSIGNALED status
+True if the process terminated due to receipt of a signal.
+.It Fn WIFSTOPPED status
+True if the process has not terminated, but has stopped and can be restarted.
+This macro can be true only if the wait call specified the
+.Dv WUNTRACED
+option
+or if the child process is being traced (see
+.Xr ptrace 2 ) .
+.El
+.Pp
+Depending on the values of those macros, the following macros
+produce the remaining status information about the child process:
+.Bl -tag -width Ds
+.It Fn WEXITSTATUS status
+If
+.Fn WIFEXITED status
+is true, evaluates to the low-order 8 bits
+of the argument passed to
+.Xr _exit 2
+or
+.Xr exit 3
+by the child.
+.It Fn WTERMSIG status
+If
+.Fn WIFSIGNALED status
+is true, evaluates to the number of the signal
+that caused the termination of the process.
+.It Fn WCOREDUMP status
+If
+.Fn WIFSIGNALED status
+is true, evaluates as true if the termination
+of the process was accompanied by the creation of a core file
+containing an image of the process when the signal was received.
+.It Fn WSTOPSIG status
+If
+.Fn WIFSTOPPED status
+is true, evaluates to the number of the signal
+that caused the process to stop.
+.El
+.Sh NOTES
+See
+.Xr sigaction 2
+for a list of termination signals.
+A status of 0 indicates normal termination.
+.Pp
+If a parent process terminates without
+waiting for all of its child processes to terminate,
+the remaining child processes are re-assigned to the reaper
+of the exiting process as the parent, see
+.Xr procctl 2
+.Dv PROC_REAP_ACQUIRE .
+If no specific reaper was assigned, the process with ID 1, the init process,
+becomes the parent of the orphaned children by default.
+.Pp
+If a signal is caught while any of the
+.Fn wait
+calls are pending,
+the call may be interrupted or restarted when the signal-catching routine
+returns,
+depending on the options in effect for the signal;
+see discussion of
+.Dv SA_RESTART
+in
+.Xr sigaction 2 .
+.Pp
+The implementation queues one
+.Dv SIGCHLD
+signal for each child process whose
+status has changed; if
+.Fn wait
+returns because the status of a child process is available, the pending
+SIGCHLD signal associated with the process ID of the child process will
+be discarded.
+Any other pending
+.Dv SIGCHLD
+signals remain pending.
+.Pp
+If
+.Dv SIGCHLD
+is blocked and
+.Fn wait
+returns because the status of a child process is available, the pending
+.Dv SIGCHLD
+signal will be cleared unless another status of the child process
+is available.
+.Sh RETURN VALUES
+If
+.Fn wait
+returns due to a stopped, continued,
+or terminated child process, the process ID of the child
+is returned to the calling process.
+Otherwise, a value of \-1
+is returned and
+.Va errno
+is set to indicate the error.
+.Pp
+If
+.Fn wait6 ,
+.Fn wait4 ,
+.Fn wait3 ,
+or
+.Fn waitpid
+returns due to a stopped, continued,
+or terminated child process, the process ID of the child
+is returned to the calling process.
+If there are no children not previously awaited,
+-1 is returned with
+.Va errno
+set to
+.Er ECHILD .
+Otherwise, if
+.Dv WNOHANG
+is specified and there are
+no stopped, continued or exited children,
+0 is returned.
+If an error is detected or a caught signal aborts the call,
+a value of -1
+is returned and
+.Va errno
+is set to indicate the error.
+.Pp
+If
+.Fn waitid
+returns because one or more processes have a state change to report,
+0 is returned.
+If an error is detected,
+a value of -1
+is returned and
+.Va errno
+is set to indicate the error.
+If
+.Dv WNOHANG
+is specified and there are
+no stopped, continued or exited children,
+0 is returned.
+The
+.Fa si_signo
+and
+.Fa si_pid
+fields of
+.Fa infop
+must be checked against zero to determine if a process reported status.
+.Pp
+The
+.Fn wait
+family of functions will only return a child process created with
+.Xr pdfork 2
+if the calling process is not in
+.Xr capsicum 4
+capability mode, and
+.Nm
+has been explicitly given the child's process ID.
+.Sh ERRORS
+The
+.Fn wait
+function
+will fail and return immediately if:
+.Bl -tag -width Er
+.It Bq Er ECHILD
+The calling process has no existing unwaited-for
+child processes.
+.It Bq Er ECHILD
+No status from the terminated child process is available
+because the calling process has asked the system to discard
+such status by ignoring the signal
+.Dv SIGCHLD
+or setting the flag
+.Dv SA_NOCLDWAIT
+for that signal.
+.It Bq Er EFAULT
+The
+.Fa status
+or
+.Fa rusage
+argument points to an illegal address.
+(May not be detected before exit of a child process.)
+.It Bq Er EINTR
+The call was interrupted by a caught signal,
+or the signal did not have the
+.Dv SA_RESTART
+flag set.
+.It Bq Er EINVAL
+An invalid value was specified for
+.Fa options ,
+or
+.Fa idtype
+and
+.Fa id
+do not specify a valid set of processes.
+.El
+.Sh SEE ALSO
+.Xr _exit 2 ,
+.Xr procctl 2 ,
+.Xr ptrace 2 ,
+.Xr sigaction 2 ,
+.Xr exit 3 ,
+.Xr siginfo 3
+.Sh STANDARDS
+The
+.Fn wait ,
+.Fn waitpid ,
+and
+.Fn waitid
+functions are defined by POSIX;
+.Fn wait6 ,
+.Fn wait4 ,
+and
+.Fn wait3
+are not specified by POSIX.
+The
+.Fn WCOREDUMP
+macro
+is an extension to the POSIX interface.
+.Pp
+The ability to use the
+.Dv WNOWAIT
+flag with
+.Fn waitpid
+is an extension;
+.Tn POSIX
+only permits this flag with
+.Fn waitid .
+.Sh HISTORY
+The
+.Fn wait
+function appeared in
+.At v1 .
diff --git a/lib/libsys/write.2 b/lib/libsys/write.2
new file mode 100644
index 000000000000..d2ff41ceead9
--- /dev/null
+++ b/lib/libsys/write.2
@@ -0,0 +1,307 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd February 11, 2021
+.Dt WRITE 2
+.Os
+.Sh NAME
+.Nm write ,
+.Nm writev ,
+.Nm pwrite ,
+.Nm pwritev
+.Nd write output
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Ft ssize_t
+.Fn write "int fd" "const void *buf" "size_t nbytes"
+.Ft ssize_t
+.Fn pwrite "int fd" "const void *buf" "size_t nbytes" "off_t offset"
+.In sys/uio.h
+.Ft ssize_t
+.Fn writev "int fd" "const struct iovec *iov" "int iovcnt"
+.Ft ssize_t
+.Fn pwritev "int fd" "const struct iovec *iov" "int iovcnt" "off_t offset"
+.Sh DESCRIPTION
+The
+.Fn write
+system call
+attempts to write
+.Fa nbytes
+of data to the object referenced by the descriptor
+.Fa fd
+from the buffer pointed to by
+.Fa buf .
+The
+.Fn writev
+system call
+performs the same action, but gathers the output data
+from the
+.Fa iovcnt
+buffers specified by the members of the
+.Fa iov
+array: iov[0], iov[1], ..., iov[iovcnt\|-\|1].
+The
+.Fn pwrite
+and
+.Fn pwritev
+system calls
+perform the same functions, but write to the specified position in
+the file without modifying the file pointer.
+.Pp
+For
+.Fn writev
+and
+.Fn pwritev ,
+the
+.Fa iovec
+structure is defined as:
+.Pp
+.Bd -literal -offset indent -compact
+struct iovec {
+ void *iov_base; /* Base address. */
+ size_t iov_len; /* Length. */
+};
+.Ed
+.Pp
+Each
+.Fa iovec
+entry specifies the base address and length of an area
+in memory from which data should be written.
+The
+.Fn writev
+system call
+will always write a complete area before proceeding
+to the next.
+.Pp
+On objects capable of seeking, the
+.Fn write
+starts at a position
+given by the pointer associated with
+.Fa fd ,
+see
+.Xr lseek 2 .
+Upon return from
+.Fn write ,
+the pointer is incremented by the number of bytes which were written.
+.Pp
+Objects that are not capable of seeking always write from the current
+position.
+The value of the pointer associated with such an object
+is undefined.
+.Pp
+If the real user is not the super-user, then
+.Fn write
+clears the set-user-id bit on a file.
+This prevents penetration of system security
+by a user who
+.Dq captures
+a writable set-user-id file
+owned by the super-user.
+.Pp
+When using non-blocking I/O on objects such as sockets that are subject
+to flow control,
+.Fn write
+and
+.Fn writev
+may write fewer bytes than requested;
+the return value must be noted,
+and the remainder of the operation should be retried when possible.
+.Sh RETURN VALUES
+Upon successful completion the number of bytes which were written
+is returned.
+Otherwise a -1 is returned and the global variable
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn write ,
+.Fn writev ,
+.Fn pwrite
+and
+.Fn pwritev
+system calls
+will fail and the file pointer will remain unchanged if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa fd
+argument
+is not a valid descriptor open for writing.
+.It Bq Er EPIPE
+An attempt is made to write to a pipe that is not open
+for reading by any process.
+.It Bq Er EPIPE
+An attempt is made to write to a socket of type
+.Dv SOCK_STREAM
+that is not connected to a peer socket.
+.It Bq Er EFBIG
+An attempt was made to write a file that exceeds the process's
+file size limit or the maximum file size.
+.It Bq Er EFAULT
+Part of
+.Fa iov
+or data to be written to the file
+points outside the process's allocated address space.
+.It Bq Er EINVAL
+The pointer associated with
+.Fa fd
+was negative.
+.It Bq Er ENOSPC
+There is no free space remaining on the file system
+containing the file.
+.It Bq Er EDQUOT
+The user's quota of disk blocks on the file system
+containing the file has been exhausted.
+.It Bq Er EIO
+An I/O error occurred while reading from or writing to the file system.
+.It Bq Er EINTR
+A signal interrupted the write before it could be completed.
+.It Bq Er EAGAIN
+The file was marked for non-blocking I/O,
+and no data could be written immediately.
+.It Bq Er EINVAL
+The value
+.Fa nbytes
+is greater than
+.Dv SSIZE_MAX
+(or greater than
+.Dv INT_MAX ,
+if the sysctl
+.Va debug.iosize_max_clamp
+is non-zero).
+.It Bq Er EINVAL
+The file descriptor refers to a raw device, and the write
+offset or size is not a multiple of the device's block size.
+.It Bq Er EINTEGRITY
+The backing store for
+.Fa fd
+detected corrupted data while reading.
+(For example, writing a partial filesystem block may require first reading
+the existing block which may trigger this error.)
+.El
+.Pp
+In addition,
+.Fn writev
+and
+.Fn pwritev
+may return one of the following errors:
+.Bl -tag -width Er
+.It Bq Er EDESTADDRREQ
+The destination is no longer available when writing to a
+.Ux
+domain datagram socket on which
+.Xr connect 2
+had been used to set a destination address.
+.It Bq Er EINVAL
+The
+.Fa iovcnt
+argument
+was less than or equal to 0, or greater than
+.Dv IOV_MAX .
+.It Bq Er EINVAL
+One of the
+.Fa iov_len
+values in the
+.Fa iov
+array was negative.
+.It Bq Er EINVAL
+The sum of the
+.Fa iov_len
+values is greater than
+.Dv SSIZE_MAX
+(or greater than
+.Dv INT_MAX ,
+if the sysctl
+.Va debug.iosize_max_clamp
+is non-zero).
+.It Bq Er ENOBUFS
+The mbuf pool has been completely exhausted when writing to a socket.
+.El
+.Pp
+The
+.Fn pwrite
+and
+.Fn pwritev
+system calls may also return the following errors:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa offset
+value was negative.
+.It Bq Er ESPIPE
+The file descriptor is associated with a pipe, socket, or FIFO.
+.El
+.Sh SEE ALSO
+.Xr fcntl 2 ,
+.Xr lseek 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr select 2
+.Sh STANDARDS
+The
+.Fn write
+system call is expected to conform to
+.St -p1003.1-90 .
+The
+.Fn writev
+and
+.Fn pwrite
+system calls are expected to conform to
+.St -xpg4.2 .
+.Sh HISTORY
+The
+.Fn pwritev
+system call appeared in
+.Fx 6.0 .
+The
+.Fn pwrite
+function appeared in
+.At V.4 .
+The
+.Fn writev
+system call appeared in
+.Bx 4.2 .
+The
+.Fn write
+function appeared in
+.At v1 .
+.Sh BUGS
+The
+.Fn pwrite
+system call appends the file without changing the file offset if
+.Dv O_APPEND
+is set, contrary to
+.St -p1003.1-2008
+where
+.Fn pwrite
+writes into
+.Fa offset
+regardless of whether
+.Dv O_APPEND
+is set.
diff --git a/lib/libsys/x86/Makefile.sys b/lib/libsys/x86/Makefile.sys
new file mode 100644
index 000000000000..483d1784bdc9
--- /dev/null
+++ b/lib/libsys/x86/Makefile.sys
@@ -0,0 +1,24 @@
+.PATH: ${LIBSYS_SRCTOP}/x86
+
+SRCS+= \
+ __vdso_gettc.c \
+ pkru.c \
+ sched_getcpu_x86.c
+
+.if ${LIB} == "sys"
+MAN+= \
+ pkru.3
+.endif # ${LIB} == "sys"
+
+# Note: vdso support for hyperv only on amd64
+.if ${MACHINE_CPUARCH} == "amd64" && ${MK_HYPERV} != "no"
+CFLAGS+= -DWANT_HYPERV
+.endif
+# We can't use sanitizer instrumentation on ifuncs called during sanitizer
+# runtime startup.
+.if ${MK_ASAN} != "no"
+CFLAGS.__vdso_gettc.c+=-fno-sanitize=address
+.endif
+.if ${MK_UBSAN} != "no"
+CFLAGS.__vdso_gettc.c+=-fno-sanitize=undefined
+.endif
diff --git a/lib/libsys/x86/__vdso_gettc.c b/lib/libsys/x86/__vdso_gettc.c
new file mode 100644
index 000000000000..ea05f5abf62a
--- /dev/null
+++ b/lib/libsys/x86/__vdso_gettc.c
@@ -0,0 +1,453 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
+ * Copyright (c) 2016, 2017, 2019 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include "namespace.h"
+#include <sys/capsicum.h>
+#include <sys/elf.h>
+#include <sys/fcntl.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include "un-namespace.h"
+#include <machine/atomic.h>
+#include <machine/cpufunc.h>
+#include <machine/pvclock.h>
+#include <machine/specialreg.h>
+#include <dev/acpica/acpi_hpet.h>
+#ifdef WANT_HYPERV
+#include <dev/hyperv/hyperv.h>
+#endif
+#include <x86/ifunc.h>
+#include "libc_private.h"
+
+static inline u_int
+rdtsc_low(const struct vdso_timehands *th)
+{
+ u_int rv;
+
+ __asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
+ : "=a" (rv) : "c" (th->th_x86_shift) : "edx");
+ return (rv);
+}
+
+static inline u_int
+rdtscp_low(const struct vdso_timehands *th)
+{
+ u_int rv;
+
+ __asm __volatile("rdtscp; movl %%edi,%%ecx; shrd %%cl, %%edx, %0"
+ : "=a" (rv) : "D" (th->th_x86_shift) : "ecx", "edx");
+ return (rv);
+}
+
+static u_int
+rdtsc_low_mb_lfence(const struct vdso_timehands *th)
+{
+ lfence();
+ return (rdtsc_low(th));
+}
+
+static u_int
+rdtsc_low_mb_mfence(const struct vdso_timehands *th)
+{
+ mfence();
+ return (rdtsc_low(th));
+}
+
+static u_int
+rdtsc_low_mb_none(const struct vdso_timehands *th)
+{
+ return (rdtsc_low(th));
+}
+
+static u_int
+rdtsc32_mb_lfence(void)
+{
+ lfence();
+ return (rdtsc32());
+}
+
+static uint64_t
+rdtsc_mb_lfence(void)
+{
+ lfence();
+ return (rdtsc());
+}
+
+static u_int
+rdtsc32_mb_mfence(void)
+{
+ mfence();
+ return (rdtsc32());
+}
+
+static uint64_t
+rdtsc_mb_mfence(void)
+{
+ mfence();
+ return (rdtsc());
+}
+
+static u_int
+rdtsc32_mb_none(void)
+{
+ return (rdtsc32());
+}
+
+static uint64_t
+rdtsc_mb_none(void)
+{
+ return (rdtsc());
+}
+
+static u_int
+rdtscp32_(void)
+{
+ return (rdtscp32());
+}
+
+static uint64_t
+rdtscp_(void)
+{
+ return (rdtscp());
+}
+
+struct tsc_selector_tag {
+ u_int (*ts_rdtsc32)(void);
+ uint64_t (*ts_rdtsc)(void);
+ u_int (*ts_rdtsc_low)(const struct vdso_timehands *);
+};
+
+static const struct tsc_selector_tag tsc_selector[] = {
+ [0] = { /* Intel, LFENCE */
+ .ts_rdtsc32 = rdtsc32_mb_lfence,
+ .ts_rdtsc = rdtsc_mb_lfence,
+ .ts_rdtsc_low = rdtsc_low_mb_lfence,
+ },
+ [1] = { /* AMD, MFENCE */
+ .ts_rdtsc32 = rdtsc32_mb_mfence,
+ .ts_rdtsc = rdtsc_mb_mfence,
+ .ts_rdtsc_low = rdtsc_low_mb_mfence,
+ },
+ [2] = { /* No SSE2 */
+ .ts_rdtsc32 = rdtsc32_mb_none,
+ .ts_rdtsc = rdtsc_mb_none,
+ .ts_rdtsc_low = rdtsc_low_mb_none,
+ },
+ [3] = { /* RDTSCP */
+ .ts_rdtsc32 = rdtscp32_,
+ .ts_rdtsc = rdtscp_,
+ .ts_rdtsc_low = rdtscp_low,
+ },
+};
+
+static int
+tsc_selector_idx(u_int cpu_feature)
+{
+ u_int amd_feature, cpu_exthigh, p[4], v[3];
+ static const char amd_id[] = "AuthenticAMD";
+ static const char hygon_id[] = "HygonGenuine";
+ bool amd_cpu;
+
+ if (cpu_feature == 0)
+ return (2); /* should not happen due to RDTSC */
+
+ do_cpuid(0, p);
+ v[0] = p[1];
+ v[1] = p[3];
+ v[2] = p[2];
+ amd_cpu = memcmp(v, amd_id, sizeof(amd_id) - 1) == 0 ||
+ memcmp(v, hygon_id, sizeof(hygon_id) - 1) == 0;
+
+ if (cpu_feature != 0) {
+ do_cpuid(0x80000000, p);
+ cpu_exthigh = p[0];
+ } else {
+ cpu_exthigh = 0;
+ }
+ if (cpu_exthigh >= 0x80000001) {
+ do_cpuid(0x80000001, p);
+ amd_feature = p[3];
+ } else {
+ amd_feature = 0;
+ }
+
+ if ((amd_feature & AMDID_RDTSCP) != 0)
+ return (3);
+ if ((cpu_feature & CPUID_SSE2) == 0)
+ return (2);
+ return (amd_cpu ? 1 : 0);
+}
+
+DEFINE_UIFUNC(static, u_int, __vdso_gettc_rdtsc_low,
+ (const struct vdso_timehands *th))
+{
+ return (tsc_selector[tsc_selector_idx(cpu_feature)].ts_rdtsc_low);
+}
+
+DEFINE_UIFUNC(static, u_int, __vdso_gettc_rdtsc32, (void))
+{
+ return (tsc_selector[tsc_selector_idx(cpu_feature)].ts_rdtsc32);
+}
+
+DEFINE_UIFUNC(static, uint64_t, __vdso_gettc_rdtsc, (void))
+{
+ return (tsc_selector[tsc_selector_idx(cpu_feature)].ts_rdtsc);
+}
+
+#define HPET_DEV_MAP_MAX 10
+static volatile char *hpet_dev_map[HPET_DEV_MAP_MAX];
+
+static void
+__vdso_init_hpet(uint32_t u)
+{
+ static const char devprefix[] = "/dev/hpet";
+ char devname[64], *c, *c1, t;
+ volatile char *new_map, *old_map;
+ unsigned int mode;
+ uint32_t u1;
+ int fd;
+
+ c1 = c = stpcpy(devname, devprefix);
+ u1 = u;
+ do {
+ *c++ = u1 % 10 + '0';
+ u1 /= 10;
+ } while (u1 != 0);
+ *c = '\0';
+ for (c--; c1 != c; c1++, c--) {
+ t = *c1;
+ *c1 = *c;
+ *c = t;
+ }
+
+ old_map = hpet_dev_map[u];
+ if (old_map != NULL)
+ return;
+
+ /*
+ * Explicitely check for the capability mode to avoid
+ * triggering trap_enocap on the device open by absolute path.
+ */
+ if ((cap_getmode(&mode) == 0 && mode != 0) ||
+ (fd = _open(devname, O_RDONLY | O_CLOEXEC)) == -1) {
+ /* Prevent the caller from re-entering. */
+ atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
+ (uintptr_t)old_map, (uintptr_t)MAP_FAILED);
+ return;
+ }
+
+ new_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0);
+ _close(fd);
+ if (atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u],
+ (uintptr_t)old_map, (uintptr_t)new_map) == 0 &&
+ new_map != MAP_FAILED)
+ munmap((void *)new_map, PAGE_SIZE);
+}
+
+#ifdef WANT_HYPERV
+
+#define HYPERV_REFTSC_DEVPATH "/dev/" HYPERV_REFTSC_DEVNAME
+
+/*
+ * NOTE:
+ * We use 'NULL' for this variable to indicate that initialization
+ * is required. And if this variable is 'MAP_FAILED', then Hyper-V
+ * reference TSC can not be used, e.g. in misconfigured jail.
+ */
+static struct hyperv_reftsc *hyperv_ref_tsc;
+
+static void
+__vdso_init_hyperv_tsc(void)
+{
+ int fd;
+ unsigned int mode;
+
+ if (cap_getmode(&mode) == 0 && mode != 0)
+ goto fail;
+
+ fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY | O_CLOEXEC);
+ if (fd < 0)
+ goto fail;
+ hyperv_ref_tsc = mmap(NULL, sizeof(*hyperv_ref_tsc), PROT_READ,
+ MAP_SHARED, fd, 0);
+ _close(fd);
+
+ return;
+fail:
+ /* Prevent the caller from re-entering. */
+ hyperv_ref_tsc = MAP_FAILED;
+}
+
+static int
+__vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc)
+{
+ uint64_t disc, ret, tsc, scale;
+ uint32_t seq;
+ int64_t ofs;
+
+ while ((seq = atomic_load_acq_int(&tsc_ref->tsc_seq)) != 0) {
+ scale = tsc_ref->tsc_scale;
+ ofs = tsc_ref->tsc_ofs;
+
+ mfence(); /* XXXKIB */
+ tsc = rdtsc();
+
+ /* ret = ((tsc * scale) >> 64) + ofs */
+ __asm__ __volatile__ ("mulq %3" :
+ "=d" (ret), "=a" (disc) :
+ "a" (tsc), "r" (scale));
+ ret += ofs;
+
+ atomic_thread_fence_acq();
+ if (tsc_ref->tsc_seq == seq) {
+ *tc = ret;
+ return (0);
+ }
+
+ /* Sequence changed; re-sync. */
+ }
+ return (ENOSYS);
+}
+
+#endif /* WANT_HYPERV */
+
+static struct pvclock_vcpu_time_info *pvclock_timeinfos;
+
+static int
+__vdso_pvclock_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+ uint64_t delta, ns, tsc;
+ struct pvclock_vcpu_time_info *ti;
+ uint32_t cpuid_ti, cpuid_tsc, version;
+ bool stable;
+
+ do {
+ ti = &pvclock_timeinfos[0];
+ version = atomic_load_acq_32(&ti->version);
+ stable = (ti->flags & th->th_x86_pvc_stable_mask) != 0;
+ if (stable) {
+ tsc = __vdso_gettc_rdtsc();
+ } else {
+ (void)rdtscp_aux(&cpuid_ti);
+ ti = &pvclock_timeinfos[cpuid_ti];
+ version = atomic_load_acq_32(&ti->version);
+ tsc = rdtscp_aux(&cpuid_tsc);
+ }
+ delta = tsc - ti->tsc_timestamp;
+ ns = ti->system_time + pvclock_scale_delta(delta,
+ ti->tsc_to_system_mul, ti->tsc_shift);
+ atomic_thread_fence_acq();
+ } while ((ti->version & 1) != 0 || ti->version != version ||
+ (!stable && cpuid_ti != cpuid_tsc));
+ *tc = MAX(ns, th->th_x86_pvc_last_systime);
+ return (0);
+}
+
+static void
+__vdso_init_pvclock_timeinfos(void)
+{
+ struct pvclock_vcpu_time_info *timeinfos;
+ size_t len;
+ int fd, ncpus;
+ unsigned int mode;
+
+ timeinfos = MAP_FAILED;
+ if (_elf_aux_info(AT_NCPUS, &ncpus, sizeof(ncpus)) != 0 ||
+ (cap_getmode(&mode) == 0 && mode != 0) ||
+ (fd = _open("/dev/" PVCLOCK_CDEVNAME, O_RDONLY | O_CLOEXEC)) < 0)
+ goto leave;
+ len = ncpus * sizeof(*pvclock_timeinfos);
+ timeinfos = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
+ _close(fd);
+leave:
+ if (atomic_cmpset_rel_ptr(
+ (volatile uintptr_t *)&pvclock_timeinfos, (uintptr_t)NULL,
+ (uintptr_t)timeinfos) == 0 && timeinfos != MAP_FAILED)
+ (void)munmap((void *)timeinfos, len);
+}
+
+#pragma weak __vdso_gettc
+int
+__vdso_gettc(const struct vdso_timehands *th, u_int *tc)
+{
+ volatile char *map;
+ uint32_t idx;
+
+ switch (th->th_algo) {
+ case VDSO_TH_ALGO_X86_TSC:
+ *tc = th->th_x86_shift > 0 ? __vdso_gettc_rdtsc_low(th) :
+ __vdso_gettc_rdtsc32();
+ return (0);
+ case VDSO_TH_ALGO_X86_HPET:
+ idx = th->th_x86_hpet_idx;
+ if (idx >= HPET_DEV_MAP_MAX)
+ return (ENOSYS);
+ map = (volatile char *)atomic_load_acq_ptr(
+ (volatile uintptr_t *)&hpet_dev_map[idx]);
+ if (map == NULL) {
+ __vdso_init_hpet(idx);
+ map = (volatile char *)atomic_load_acq_ptr(
+ (volatile uintptr_t *)&hpet_dev_map[idx]);
+ }
+ if (map == MAP_FAILED)
+ return (ENOSYS);
+ *tc = *(volatile uint32_t *)(map + HPET_MAIN_COUNTER);
+ return (0);
+#ifdef WANT_HYPERV
+ case VDSO_TH_ALGO_X86_HVTSC:
+ if (hyperv_ref_tsc == NULL)
+ __vdso_init_hyperv_tsc();
+ if (hyperv_ref_tsc == MAP_FAILED)
+ return (ENOSYS);
+ return (__vdso_hyperv_tsc(hyperv_ref_tsc, tc));
+#endif
+ case VDSO_TH_ALGO_X86_PVCLK:
+ if (pvclock_timeinfos == NULL)
+ __vdso_init_pvclock_timeinfos();
+ if (pvclock_timeinfos == MAP_FAILED)
+ return (ENOSYS);
+ return (__vdso_pvclock_gettc(th, tc));
+ default:
+ return (ENOSYS);
+ }
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libsys/x86/pkru.3 b/lib/libsys/x86/pkru.3
new file mode 100644
index 000000000000..95bc66c979ac
--- /dev/null
+++ b/lib/libsys/x86/pkru.3
@@ -0,0 +1,203 @@
+.\" Copyright (c) 2019 The FreeBSD Foundation
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd February 16, 2019
+.Dt PKRU 3
+.Os
+.Sh NAME
+.Nm Protection Key Rights for User pages
+.Nd provide fast user-managed key-based access control for pages
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In machine/sysarch.h
+.Ft int
+.Fn x86_pkru_get_perm "unsigned int keyidx" "int *access" "int *modify"
+.Ft int
+.Fn x86_pkru_set_perm "unsigned int keyidx" "int access" "int modify"
+.Ft int
+.Fo x86_pkru_protect_range
+.Fa "void *addr"
+.Fa "unsigned long len"
+.Fa "unsigned int keyidx"
+.Fa "int flag"
+.Fc
+.Ft int
+.Fn x86_pkru_unprotect_range "void *addr" "unsigned long len"
+.Sh DESCRIPTION
+The protection keys feature provides an additional mechanism, besides the
+normal page permissions as established by
+.Xr mmap 2
+and
+.Xr mprotect 2 ,
+to control access to user-mode addresses.
+The mechanism gives safety measures which can be used to avoid
+incidental read or modification of sensitive memory,
+or as a debugging feature.
+It cannot guard against conscious accesses since permissions
+are user-controllable.
+.Pp
+If supported by hardware, each mapped user linear address
+has an associated 4-bit protection key.
+A new per-thread PKRU hardware register determines, for each protection
+key, whether user-mode addresses with that protection key may be
+read or written.
+.Pp
+Only one key may apply to a given range at a time.
+The default protection key index is zero, it is used even if no key
+was explicitly assigned to the address, or if the key was removed.
+.Pp
+The protection prevents the system from accessing user addresses as well
+as the user applications.
+When a system call was unable to read or write user memory due to key
+protection, it returns the
+.Er EFAULT
+error code.
+Note that some side effects may have occurred if this error is reported.
+.Pp
+Protection keys require that the system uses 4-level paging
+(also called long mode),
+which means that it is only available on amd64 system.
+Both 64-bit and 32-bit applications can use protection keys.
+More information about the hardware feature is provided in the IA32 Software
+Developer's Manual published by Intel Corp.
+.Pp
+The key indexes written into the page table entries are managed by the
+.Fn sysarch
+syscall.
+Per-key permissions are managed using the user-mode instructions
+.Em RDPKRU
+and
+.Em WRPKRU .
+The system provides convenient library helpers for both the syscall and
+the instructions, described below.
+.Pp
+The
+.Fn x86_pkru_protect_range
+function assigns key
+.Fa keyidx
+to the range starting at
+.Fa addr
+and having length
+.Fa len .
+Starting address is truncated to the page start,
+and the end is rounded up to the end of the page.
+After a successful call, the range has the specified key assigned,
+even if the key is zero and it did not change the page table entries.
+.Pp
+The
+.Fa flags
+argument takes the logical OR of the following values:
+.Bl -tag -width
+.It Bq Va AMD64_PKRU_EXCL
+Only assign the key if the range does not have any other keys assigned
+(including the zero key).
+You must first remove any existing key with
+.Fn x86_pkru_unprotect_range
+in order for this request to succeed.
+If the
+.Va AMD64_PKRU_EXCL
+flag is not specified,
+.Fn x86_pkru_protect_range
+replaces any existing key.
+.It Bq Va AMD64_PKRU_PERSIST
+The keys assigned to the range are persistent.
+They are re-established when the current mapping is destroyed
+and a new mapping is created in any sub-range of the specified range.
+You must use a
+.Fn x86_pkru_unprotect_range
+call to forget the key.
+.El
+.Pp
+The
+.Fn x86_pkru_unprotect_range
+function removes any keys assigned to the specified range.
+Existing mappings are changed to use key index zero in page table entries.
+Keys are no longer considered installed for all mappings in the range,
+for the purposes of
+.Fn x86_pkru_protect_range
+with the
+.Va AMD64_PKRU_EXCL
+flag.
+.Pp
+The
+.Fn x86_pkru_get_perm
+function returns access rights for the key specified by the
+.Fa keyidx
+argument.
+If the value pointed to by
+.Fa access
+is zero after the call, no read or write permissions is granted for
+mappings which are assigned the key
+.Fa keyidx .
+If
+.Fa access
+is not zero, read access is permitted.
+The non-zero value of the variable pointed to by the
+.Fa modify
+argument indicates that write access is permitted.
+.Pp
+Conversely, the
+.Fn x86_pkru_set_perm
+establishes the access and modify permissions for the given key index
+as specified by its arguments.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+.Bl -tag -width Er
+.It Bq Er EOPNOTSUPP
+The hardware does not support protection keys.
+.It Bq Er EINVAL
+The supplied key index is invalid (greater than 15).
+.It Bq Er EINVAL
+The supplied
+.Fa flags
+argument for
+.Fn x86_pkru_protect_range
+has reserved bits set.
+.It Bq Er EFAULT
+The supplied address range does not completely fit into the user-managed
+address range.
+.It Bq Er ENOMEM
+The memory shortage prevents the completion of the operation.
+.It Bq Er EBUSY
+The
+.Va AMD64_PKRU_EXCL
+flag was specified for
+.Fn x86_pkru_protect_range
+and the range already has defined protection keys.
+.El
+.Sh SEE ALSO
+.Xr mmap 2 ,
+.Xr mprotect 2 ,
+.Xr munmap 2 ,
+.Xr sysarch 2
+.Sh STANDARDS
+The
+.Nm
+functions are non-standard and first appeared in
+.Fx 13.0 .
diff --git a/lib/libsys/x86/pkru.c b/lib/libsys/x86/pkru.c
new file mode 100644
index 000000000000..b6ae181c131f
--- /dev/null
+++ b/lib/libsys/x86/pkru.c
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 2019 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <machine/cpufunc.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+#include <x86/ifunc.h>
+#include <errno.h>
+#include <string.h>
+
+#define MAX_PKRU_IDX 0xf
+#ifdef __i386__
+#define X86_SET_PKRU I386_SET_PKRU
+#define X86_CLEAR_PKRU I386_CLEAR_PKRU
+#else
+#define X86_SET_PKRU AMD64_SET_PKRU
+#define X86_CLEAR_PKRU AMD64_CLEAR_PKRU
+#endif
+
+static int
+x86_pkru_get_perm_unsup(u_int keyidx, int *access, int *modify)
+{
+
+ errno = EOPNOTSUPP;
+ return (-1);
+}
+
+static int
+x86_pkru_get_perm_hw(u_int keyidx, int *access, int *modify)
+{
+ uint32_t pkru;
+
+ if (keyidx > MAX_PKRU_IDX) {
+ errno = EINVAL;
+ return (-1);
+ }
+ keyidx *= 2;
+ pkru = rdpkru();
+ *access = (pkru & (1 << keyidx)) == 0;
+ *modify = (pkru & (2 << keyidx)) == 0;
+ return (0);
+}
+
+DEFINE_UIFUNC(, int, x86_pkru_get_perm, (u_int, int *, int *))
+{
+
+ return ((cpu_stdext_feature2 & CPUID_STDEXT2_OSPKE) == 0 ?
+ x86_pkru_get_perm_unsup : x86_pkru_get_perm_hw);
+}
+
+static int
+x86_pkru_set_perm_unsup(u_int keyidx, int access, int modify)
+{
+
+ errno = EOPNOTSUPP;
+ return (-1);
+}
+
+static int
+x86_pkru_set_perm_hw(u_int keyidx, int access, int modify)
+{
+ uint32_t pkru;
+
+ if (keyidx > MAX_PKRU_IDX) {
+ errno = EINVAL;
+ return (-1);
+ }
+ keyidx *= 2;
+ pkru = rdpkru();
+ pkru &= ~(3 << keyidx);
+ if (!access)
+ pkru |= 1 << keyidx;
+ if (!modify)
+ pkru |= 2 << keyidx;
+ wrpkru(pkru);
+ return (0);
+}
+
+DEFINE_UIFUNC(, int, x86_pkru_set_perm, (u_int, int, int))
+{
+
+ return ((cpu_stdext_feature2 & CPUID_STDEXT2_OSPKE) == 0 ?
+ x86_pkru_set_perm_unsup : x86_pkru_set_perm_hw);
+}
+
+int
+x86_pkru_protect_range(void *addr, unsigned long len, u_int keyidx, int flags)
+{
+ struct amd64_set_pkru a64pkru;
+
+ memset(&a64pkru, 0, sizeof(a64pkru));
+ a64pkru.addr = addr;
+ a64pkru.len = len;
+ a64pkru.keyidx = keyidx;
+ a64pkru.flags = flags;
+ return (sysarch(X86_SET_PKRU, &a64pkru));
+}
+
+int
+x86_pkru_unprotect_range(void *addr, unsigned long len)
+{
+ struct amd64_set_pkru a64pkru;
+
+ memset(&a64pkru, 0, sizeof(a64pkru));
+ a64pkru.addr = addr;
+ a64pkru.len = len;
+ return (sysarch(X86_CLEAR_PKRU, &a64pkru));
+}
diff --git a/lib/libc/x86/sys/sched_getcpu_x86.c b/lib/libsys/x86/sched_getcpu_x86.c
index 13ba18ef5e36..13ba18ef5e36 100644
--- a/lib/libc/x86/sys/sched_getcpu_x86.c
+++ b/lib/libsys/x86/sched_getcpu_x86.c
diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
index e1d6c7e02ff0..ca020552a6e9 100644
--- a/lib/libsysdecode/Makefile
+++ b/lib/libsysdecode/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
LIB= sysdecode
@@ -85,6 +84,7 @@ MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
sysdecode_mask.3 sysdecode_fileflags.3 \
sysdecode_mask.3 sysdecode_filemode.3 \
sysdecode_mask.3 sysdecode_flock_operation.3 \
+ sysdecode_mask.3 sysdecode_inotifyflags.3 \
sysdecode_mask.3 sysdecode_mlockall_flags.3 \
sysdecode_mask.3 sysdecode_mmap_flags.3 \
sysdecode_mask.3 sysdecode_mmap_prot.3 \
@@ -93,6 +93,7 @@ MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
sysdecode_mask.3 sysdecode_msync_flags.3 \
sysdecode_mask.3 sysdecode_open_flags.3 \
sysdecode_mask.3 sysdecode_pipe2_flags.3 \
+ sysdecode_mask.3 sysdecode_pollfd_events.3 \
sysdecode_mask.3 sysdecode_reboot_howto.3 \
sysdecode_mask.3 sysdecode_rfork_flags.3 \
sysdecode_mask.3 sysdecode_semget_flags.3 \
@@ -126,8 +127,13 @@ CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
DEPENDOBJS+= tables.h tables_linux.h
+.if ${MK_DIRDEPS_BUILD} == "yes"
+MKTABLES_INCLUDEDIR= ${STAGE_INCLUDEDIR}
+.else
+MKTABLES_INCLUDEDIR= ${SYSROOT:U${DESTDIR}}${INCLUDEDIR}
+.endif
tables.h: mktables
- sh ${.CURDIR}/mktables ${SYSROOT:U${DESTDIR}}${INCLUDEDIR} ${.TARGET}
+ sh ${.CURDIR}/mktables ${MKTABLES_INCLUDEDIR} ${.TARGET}
tables_linux.h: mklinuxtables
sh ${.CURDIR}/mklinuxtables ${SRCTOP}/sys ${.TARGET}
diff --git a/lib/libsysdecode/errno.c b/lib/libsysdecode/errno.c
index 75e9ccfe7ccc..366f3d9a6f33 100644
--- a/lib/libsysdecode/errno.c
+++ b/lib/libsysdecode/errno.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/acl.h>
#include <sys/wait.h>
diff --git a/lib/libsysdecode/flags.c b/lib/libsysdecode/flags.c
index 33c778c391ee..f8e26e6a9dae 100644
--- a/lib/libsysdecode/flags.c
+++ b/lib/libsysdecode/flags.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#define L2CAP_SOCKET_CHECKED
#include <sys/types.h>
@@ -31,9 +30,11 @@
#include <sys/capsicum.h>
#include <sys/event.h>
#include <sys/extattr.h>
+#include <sys/inotify.h>
#include <sys/linker.h>
#include <sys/mman.h>
#include <sys/mount.h>
+#include <sys/poll.h>
#include <sys/procctl.h>
#include <sys/ptrace.h>
#include <sys/reboot.h>
@@ -195,7 +196,7 @@ sysdecode_vmprot(FILE *fp, int type, int *rem)
}
static struct name_table sockflags[] = {
- X(SOCK_CLOEXEC) X(SOCK_NONBLOCK) XEND
+ X(SOCK_CLOEXEC) X(SOCK_CLOFORK) X(SOCK_NONBLOCK) XEND
};
bool
@@ -205,16 +206,17 @@ sysdecode_socket_type(FILE *fp, int type, int *rem)
uintmax_t val;
bool printed;
- str = lookup_value(socktype, type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK));
+ str = lookup_value(socktype,
+ type & ~(SOCK_CLOEXEC | SOCK_CLOFORK | SOCK_NONBLOCK));
if (str != NULL) {
fputs(str, fp);
*rem = 0;
printed = true;
} else {
- *rem = type & ~(SOCK_CLOEXEC | SOCK_NONBLOCK);
+ *rem = type & ~(SOCK_CLOEXEC | SOCK_CLOFORK | SOCK_NONBLOCK);
printed = false;
}
- val = type & (SOCK_CLOEXEC | SOCK_NONBLOCK);
+ val = type & (SOCK_CLOEXEC | SOCK_CLOFORK | SOCK_NONBLOCK);
print_mask_part(fp, sockflags, &val, &printed);
return (printed);
}
@@ -350,6 +352,13 @@ sysdecode_getrusage_who(int who)
return (lookup_value(rusage, who));
}
+bool
+sysdecode_inotifyflags(FILE *fp, int flag, int *rem)
+{
+
+ return (print_mask_int(fp, inotifyflags, flag, rem));
+}
+
static struct name_table kevent_user_ffctrl[] = {
X(NOTE_FFNOP) X(NOTE_FFAND) X(NOTE_FFOR) X(NOTE_FFCOPY)
XEND
@@ -555,7 +564,7 @@ sysdecode_nfssvc_flags(int flags)
}
static struct name_table pipe2flags[] = {
- X(O_CLOEXEC) X(O_NONBLOCK) XEND
+ X(O_CLOEXEC) X(O_CLOFORK) X(O_NONBLOCK) XEND
};
bool
@@ -565,6 +574,13 @@ sysdecode_pipe2_flags(FILE *fp, int flags, int *rem)
return (print_mask_0(fp, pipe2flags, flags, rem));
}
+bool
+sysdecode_pollfd_events(FILE *fp, int flags, int *rem)
+{
+
+ return (print_mask_int(fp, pollfdevents, flags, rem));
+}
+
const char *
sysdecode_prio_which(int which)
{
@@ -858,7 +874,7 @@ sysdecode_fcntl_cmd(int cmd)
}
static struct name_table fcntl_fd_arg[] = {
- X(FD_CLOEXEC) X(0) XEND
+ X(FD_CLOEXEC) X(FD_CLOFORK) X(0) XEND
};
bool
diff --git a/lib/libsysdecode/linux.c b/lib/libsysdecode/linux.c
index 318406a9ee40..1ad3b4f89806 100644
--- a/lib/libsysdecode/linux.c
+++ b/lib/libsysdecode/linux.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/proc.h>
#include <stdbool.h>
diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables
index bf0dc34511d3..6b4f79402660 100644
--- a/lib/libsysdecode/mktables
+++ b/lib/libsysdecode/mktables
@@ -98,6 +98,7 @@ gen_table "extattrns" "EXTATTR_NAMESPACE_[A-Z]+[[:space:]]+0x[0-9]+" "sys/
gen_table "fadvisebehav" "POSIX_FADV_[A-Z]+[[:space:]]+[0-9]+" "sys/fcntl.h"
gen_table "openflags" "O_[A-Z]+[[:space:]]+0x[0-9A-Fa-f]+" "sys/fcntl.h" "O_RDONLY|O_RDWR|O_WRONLY"
gen_table "flockops" "LOCK_[A-Z]+[[:space:]]+0x[0-9]+" "sys/fcntl.h"
+gen_table "inotifyflags" "IN_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/inotify.h" "IN_CLOEXEC|IN_NONBLOCK"
gen_table "kldsymcmd" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
gen_table "kldunloadfflags" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h"
gen_table "lio_listiomodes" "LIO_(NO)?WAIT[[:space:]]+[0-9]+" "aio.h"
@@ -114,12 +115,13 @@ gen_table "mountflags" "MNT_[A-Z]+[[:space:]]+0x[0-9]+" "sys/
gen_table "msyncflags" "MS_[A-Z]+[[:space:]]+0x[0-9]+" "sys/mman.h"
gen_table "nfssvcflags" "NFSSVC_[A-Z0-9]+[[:space:]]+0x[0-9]+" "nfs/nfssvc.h"
gen_table "pathconfname" "_PC_[A-Z4_]+[[:space:]]+[0-9]+" "sys/unistd.h"
+gen_table "pollfdevents" "POLL[A-Z]+[[:space:]]+" "sys/poll.h"
gen_table "prio" "PRIO_[A-Z]+[[:space:]]+[0-9]" "sys/resource.h"
gen_table "procctlcmd" "PROC_[A-Z_]+[[:space:]]+[0-9]" "sys/procctl.h" "PROC_TRACE_CTL_"
gen_table "ptraceop" "PT_[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/ptrace.h"
gen_table "quotactlcmds" "Q_[A-Z]+[[:space:]]+0x[0-9]+" "ufs/ufs/quota.h"
gen_table "rebootopt" "RB_[A-Z]+[[:space:]]+0x[0-9]+" "sys/reboot.h"
-gen_table "rforkflags" "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)" "sys/unistd.h"
+gen_table "rforkflags" "RF[A-Z]+[[:space:]]+\([0-9]+[uU]?<<[0-9]+\)" "sys/unistd.h" "RFPPWAIT"
gen_table "rlimit" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/resource.h"
gen_table "rusage" "RUSAGE_[A-Z]+[[:space:]]+[-0-9]+" "sys/resource.h"
gen_table "schedpolicy" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sys/sched.h"
@@ -140,11 +142,11 @@ gen_table "sockopt" "SO_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/
gen_table "sockoptip" "(IP_[[:alnum:]_]+|MCAST_[[:alnum:]_]+_GROUP)[[:space:]]+" "netinet/in.h" "IP_DEFAULT|IP_MIN|IP_MAX|IP_PORTRANGE"
gen_table "sockoptipv6" "IPV6_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet6/in6.h" "IPV6_ADDR_|IPV6_TAG_DIRECT|IPV6_OPTIONS|IPV6_RECVOPTS|IPV6_RECVRETOPTS|IPV6_RECVDSTADDR|IPV6_RETOPTS|IPV6_2292|IPV6_RECVRTHDRDSTOPTS|IPV6_REACHCONF|IPV6_PKTOPTIONS"
gen_table "sockoptsctp" "SCTP_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/sctp.h"
-gen_table "sockopttcp" "TCP_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/tcp.h" "TCP_MIN|TCP_MAX[^S]|TCP_MSS|TCP_[[:alnum:]_]+_MAX|TCP_FASTOPEN_MIN_COOKIE_LEN|TCP_FASTOPEN_PSK_LEN"
+gen_table "sockopttcp" "TCP_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/tcp.h" "TCP_MIN|TCP_MAX[^S]|TCP_MSS|TCP_[[:alnum:]_]+_MAX|TCP_FASTOPEN_MIN_COOKIE_LEN|TCP_FASTOPEN_PSK_LEN|TCP_USE_DDP"
gen_table "sockoptudp" "UDP_[[:alnum:]]+[[:space:]]+[0-9]+" "netinet/udp.h" "UDP_ENCAP_"
gen_table "sockoptudplite" "UDPLITE_[[:alnum:]_]+[[:space:]]+[0-9]+" "netinet/udplite.h"
gen_table "socktype" "SOCK_[A-Z]+[[:space:]]+[1-9]+[0-9]*" "sys/socket.h"
-gen_table "thrcreateflags" "THR_[A-Z]+[[:space:]]+0x[0-9]+" "sys/thr.h"
+gen_table "thrcreateflags" "THR_[A-Z_]+[[:space:]]+0x[0-9]+" "sys/thr.h"
gen_table "umtxop" "UMTX_OP_[[:alnum:]][[:alnum:]_]*[[:space:]]+[0-9]+" "sys/umtx.h"
gen_table "umtxopflags" "UMTX_OP__[[:alnum:]_]+[[:space:]]+[0-9]+" "sys/umtx.h"
gen_table "vmprot" "VM_PROT_[A-Z_]+[[:space:]]+\(\(vm_prot_t\)[[:space:]]+0x[0-9]+\)" "vm/vm.h"
diff --git a/lib/libsysdecode/signal.c b/lib/libsysdecode/signal.c
index 9ae836625315..29666eef3086 100644
--- a/lib/libsysdecode/signal.c
+++ b/lib/libsysdecode/signal.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <signal.h>
#include <stdbool.h>
diff --git a/lib/libsysdecode/support.c b/lib/libsysdecode/support.c
index 2fb048409e26..12c8b8875097 100644
--- a/lib/libsysdecode/support.c
+++ b/lib/libsysdecode/support.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h
index 4c091bb14343..c95d7f71379b 100644
--- a/lib/libsysdecode/sysdecode.h
+++ b/lib/libsysdecode/sysdecode.h
@@ -61,6 +61,7 @@ const char *sysdecode_getfsstat_mode(int _mode);
const char *sysdecode_getrusage_who(int _who);
const char *sysdecode_idtype(int _idtype);
const char *sysdecode_ioctlname(unsigned long _val);
+bool sysdecode_inotifyflags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_ipproto(int _protocol);
void sysdecode_kevent_fflags(FILE *_fp, short _filter, int _fflags,
int _base);
@@ -83,6 +84,7 @@ const char *sysdecode_nfssvc_flags(int _flags);
bool sysdecode_open_flags(FILE *_fp, int _flags, int *_rem);
const char *sysdecode_pathconf_name(int _name);
bool sysdecode_pipe2_flags(FILE *_fp, int _flags, int *_rem);
+bool sysdecode_pollfd_events(FILE *fp, int flags, int *rem);
const char *sysdecode_prio_which(int _which);
const char *sysdecode_procctl_cmd(int _cmd);
const char *sysdecode_ptrace_request(int _request);
diff --git a/lib/libsysdecode/sysdecode_fcntl_arg.3 b/lib/libsysdecode/sysdecode_fcntl_arg.3
index ee3a030a79e4..d5648ce0adc3 100644
--- a/lib/libsysdecode/sysdecode_fcntl_arg.3
+++ b/lib/libsysdecode/sysdecode_fcntl_arg.3
@@ -54,7 +54,8 @@ are determined by
.It Sy Command Ta Fa arg Sy Type Ta Sy Output Format
.It
.It Dv F_SETFD Ta Vt int Ta
-.Dq FD_CLOEXEC
+.Dq FD_CLOEXEC ,
+.Dq FD_CLOFORK
or the value of
.Fa arg
in the indicated
diff --git a/lib/libsysdecode/sysdecode_mask.3 b/lib/libsysdecode/sysdecode_mask.3
index 171a086a5079..efcab331fe29 100644
--- a/lib/libsysdecode/sysdecode_mask.3
+++ b/lib/libsysdecode/sysdecode_mask.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 3, 2022
+.Dd February 29, 2024
.Dt sysdecode_mask 3
.Os
.Sh NAME
@@ -43,6 +43,7 @@
.Nm sysdecode_msync_flags ,
.Nm sysdecode_open_flags ,
.Nm sysdecode_pipe2_flags ,
+.Nm sysdecode_pollfd_events ,
.Nm sysdecode_reboot_howto ,
.Nm sysdecode_rfork_flags ,
.Nm sysdecode_semget_flags ,
@@ -96,6 +97,8 @@
.Ft bool
.Fn sysdecode_pipe2_flags "FILE *fp" "int flags" "int *rem"
.Ft bool
+.Fn sysdecode_pollfd_events "FILE *fp" "int flags" "int *rem"
+.Ft bool
.Fn sysdecode_reboot_howto "FILE *fp" "int howto" "int *rem"
.Ft bool
.Fn sysdecode_rfork_flags "FILE *fp" "int flags" "int *rem"
@@ -191,6 +194,13 @@ and
.Dv F_SETFL
.Xr fcntl 2
commands.
+.It Fn sysdecode_pollfd_events
+The
+.Fa events
+and
+.Fa revents
+members of a
+.Vt struct pollfd .
.It Fn sysdecode_sctp_nxt_flags
The
.Fa nxt_flags
diff --git a/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3 b/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3
index e5995bff8329..4eb25187f0d0 100644
--- a/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3
+++ b/lib/libsysdecode/sysdecode_sctp_sinfo_flags.3
@@ -46,5 +46,5 @@ to the stream
.Fa fp .
In particular, the embedded PR-SCTP policies are handled.
.Sh SEE ALSO
-.Xr sysdecode 3
+.Xr sysdecode 3 ,
.Xr sysdecode_sctp_pr_policy 3
diff --git a/lib/libsysdecode/utrace.c b/lib/libsysdecode/utrace.c
index a03cc66cac03..67ba86bfbf7b 100644
--- a/lib/libsysdecode/utrace.c
+++ b/lib/libsysdecode/utrace.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <dlfcn.h>
#include <stdbool.h>
diff --git a/lib/libtacplus/taclib.c b/lib/libtacplus/taclib.c
index 00bee367ca9f..4150aeb67e9e 100644
--- a/lib/libtacplus/taclib.c
+++ b/lib/libtacplus/taclib.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile
index 24f4e5c104a1..6bc2f5a51de0 100644
--- a/lib/libtelnet/Makefile
+++ b/lib/libtelnet/Makefile
@@ -1,5 +1,3 @@
-# From: @(#)Makefile 8.2 (Berkeley) 12/15/93
-
.include <src.opts.mk>
PACKAGE=lib${LIB}
@@ -21,7 +19,8 @@ CFLAGS+= -DENCRYPTION -DAUTHENTICATION -DSRA
CFLAGS+= -DOPENSSL_API_COMPAT=0x10100000L
.endif
-.if ${MK_KERBEROS_SUPPORT} != "no"
+.if ${MK_KERBEROS_SUPPORT} != "no" && ${MK_MITKRB5} != "yes"
+# MIT KRB5 deprecated and removed 3DES. Therefore no telnet support.
SRCS+= kerberos5.c
CFLAGS+= -DKRB5 -DFORWARD -Dnet_write=telnet_net_write
.endif
diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index dde2a9dce94e..c87be9475390 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -1,17 +1,22 @@
-#
-# All library objects contain FreeBSD revision strings by default; they may be
-# excluded as a space-saving measure. To produce a library that does
-# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
-# below.
-
PACKAGE= clibs
SHLIBDIR?= /lib
+LIBADD= c sys
+.if defined(COMPAT_libcompat)
+# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
+# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
+LDFLAGS+= -Wl,--rpath=/usr/lib${COMPAT_libcompat}
+.endif
+
.include <src.opts.mk>
MK_SSP= no
+# SSP forced off already implies FORTIFY_SOURCE=0, but we must make sure that
+# one cannot turn it back on.
+FORTIFY_SOURCE= 0
LIB=thr
SHLIB_MAJOR= 3
+
NO_WTHREAD_SAFETY=1
NO_WCAST_ALIGN.gcc=1 # for gcc 4.2
CFLAGS+=-DPTHREAD_KERNEL
@@ -26,6 +31,10 @@ CFLAGS+=-I${SRCTOP}/lib/libthread_db
CFLAGS.thr_stack.c+= -Wno-cast-align
CFLAGS.rtld_malloc.c+= -Wno-cast-align
+# Disable compiler builtins so that the compiler does not optimize away rtld's
+# attempts to force early PLT resolution for certain functions that may be
+# replaced by builtins.
+CFLAGS.thr_rtld.c+= -fno-builtin
CFLAGS.thr_symbols.c+= -Wno-missing-variable-declarations
.if ${MK_ASAN} != "no"
# False-positive ASAN error claiming the local "struct sigaction act;" is
@@ -44,6 +53,8 @@ CFLAGS+=-D_PTHREAD_FORCED_UNWIND
.endif
LDFLAGS+=-Wl,-znodelete
+LDFLAGS+=-Wl,-zinitfirst
+LDFLAGS+=-Wl,--auxiliary,libsys.so.7
VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS=${.CURDIR}/pthread.map
@@ -67,15 +78,20 @@ PRECIOUSLIB=
.include "${.CURDIR}/thread/Makefile.inc"
SRCS+= rtld_malloc.c
+LIBSYS_SRCTOP= ${.CURDIR:H}/libsys
+.if exists(${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}/_umtx_op_err.S)
+.PATH: ${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}
+.else
+.PATH: ${LIBSYS_SRCTOP}
+.endif
+OBJS+= _umtx_op_err.o
+
.if ${MK_INSTALLLIB} != "no"
SYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a
.endif
.if !defined(NO_PIC)
SYMLINKS+=lib${LIB}.so ${LIBDIR}/libpthread.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+=lib${LIB}_p.a ${LIBDIR}/libpthread_p.a
-.endif
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/lib/libthr/Makefile.depend b/lib/libthr/Makefile.depend
index 6ef78fac5cbf..e0d18fcef3a4 100644
--- a/lib/libthr/Makefile.depend
+++ b/lib/libthr/Makefile.depend
@@ -6,6 +6,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libsys \
.include <dirdeps.mk>
diff --git a/lib/libthr/arch/aarch64/Makefile.inc b/lib/libthr/arch/aarch64/Makefile.inc
index 8b137891791f..e69de29bb2d1 100644
--- a/lib/libthr/arch/aarch64/Makefile.inc
+++ b/lib/libthr/arch/aarch64/Makefile.inc
@@ -1 +0,0 @@
-
diff --git a/lib/libthr/arch/aarch64/include/pthread_md.h b/lib/libthr/arch/aarch64/include/pthread_md.h
index 75e6abf445ba..4316955f1d3d 100644
--- a/lib/libthr/arch/aarch64/include/pthread_md.h
+++ b/lib/libthr/arch/aarch64/include/pthread_md.h
@@ -49,4 +49,11 @@ _get_curthread(void)
return (_tcb_get()->tcb_thread);
}
+static __inline void
+_thr_resolve_machdep(void)
+{
+}
+
+#define __thr_setup_tsd(thread) _tcb_set((thread)->tcb)
+
#endif /* _PTHREAD_MD_H_ */
diff --git a/lib/libthr/arch/aarch64/include/pthread_tls.h b/lib/libthr/arch/aarch64/include/pthread_tls.h
deleted file mode 100644
index 4e02f8d4e03f..000000000000
--- a/lib/libthr/arch/aarch64/include/pthread_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _ARCH_AARCH64_PTHREAD_TLS_H
-#define _ARCH_AARCH64_PTHREAD_TLS_H
-
-static __inline uintptr_t
-_get_static_tls_base(struct pthread *thr, size_t offset)
-{
- uintptr_t tlsbase;
-
- tlsbase = (uintptr_t)thr->tcb;
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libthr/arch/amd64/Makefile.inc b/lib/libthr/arch/amd64/Makefile.inc
index 24e5dd7c9b03..fe80e1a73cc9 100644
--- a/lib/libthr/arch/amd64/Makefile.inc
+++ b/lib/libthr/arch/amd64/Makefile.inc
@@ -1,8 +1,7 @@
-
-SRCS+= _umtx_op_err.S
-
# With the current compiler and libthr code, using SSE in libthr
# does not provide enough performance improvement to outweigh
# the extra context switch cost. This can measurably impact
# performance when the application also does not use enough SSE.
CFLAGS+=${CFLAGS_NO_SIMD}
+
+SRCS+= thr_machdep.c
diff --git a/lib/libthr/arch/amd64/amd64/thr_machdep.c b/lib/libthr/arch/amd64/amd64/thr_machdep.c
new file mode 100644
index 000000000000..d23e1689779c
--- /dev/null
+++ b/lib/libthr/arch/amd64/amd64/thr_machdep.c
@@ -0,0 +1,48 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ */
+
+#define _WANT_P_OSREL
+#include <sys/param.h>
+#include <errno.h>
+#include <machine/sysarch.h>
+
+#include "libc_private.h"
+#include "thr_private.h"
+
+void
+__thr_setup_tsd(struct pthread *thread)
+{
+ void *base;
+ int error;
+
+ if (__getosreldate() < P_OSREL_TLSBASE) {
+ amd64_set_tlsbase(thread->tcb);
+ return;
+ }
+
+ /*
+ * Make tlsbase handling more compatible with code, like Go
+ * runtime, which wants to manage fsbase itself, and which do
+ * not need assistance in setting fsbase for signal handlers.
+ *
+ * If the main thread did not used amd64_set_tlsbase(), which
+ * means that rtld/libc was not utilized, do not use
+ * amd64_set_tlsbase() either. Also do not mark new threads
+ * as using C runtime with the THR_C_RUNTIME flag.
+ */
+ error = sysarch(AMD64_GET_TLSBASE, &base);
+ if (error != 0 && errno == ESRCH) {
+ __thr_new_flags &= ~THR_C_RUNTIME;
+ amd64_set_fsbase(thread->tcb);
+ } else {
+ amd64_set_tlsbase(thread->tcb);
+ }
+}
diff --git a/lib/libthr/arch/amd64/include/pthread_md.h b/lib/libthr/arch/amd64/include/pthread_md.h
index fa0802e64ebb..02b73d90f006 100644
--- a/lib/libthr/arch/amd64/include/pthread_md.h
+++ b/lib/libthr/arch/amd64/include/pthread_md.h
@@ -47,11 +47,16 @@ _get_curthread(void)
{
struct pthread *thr;
- __asm __volatile("movq %%fs:%1, %0" : "=r" (thr)
- : "m" (*(volatile u_long *)offsetof(struct tcb, tcb_thread)));
+ __asm __volatile("movq %%fs:%c1, %0" : "=r" (thr)
+ : "i" (offsetof(struct tcb, tcb_thread)));
return (thr);
}
-#define HAS__UMTX_OP_ERR 1
+static __inline void
+_thr_resolve_machdep(void)
+{
+}
+
+void __thr_setup_tsd(struct pthread *thread);
#endif
diff --git a/lib/libthr/arch/amd64/include/pthread_tls.h b/lib/libthr/arch/amd64/include/pthread_tls.h
deleted file mode 100644
index 2af0aeda4c85..000000000000
--- a/lib/libthr/arch/amd64/include/pthread_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _ARCH_AMD64_PTHREAD_TLS_H
-#define _ARCH_AMD64_PTHREAD_TLS_H
-
-static __inline uintptr_t
-_get_static_tls_base(struct pthread *thr, size_t offset)
-{
- uintptr_t tlsbase;
-
- tlsbase = (uintptr_t)thr->tcb;
- tlsbase -= offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libthr/arch/arm/Makefile.inc b/lib/libthr/arch/arm/Makefile.inc
new file mode 100644
index 000000000000..4e770cf6b90f
--- /dev/null
+++ b/lib/libthr/arch/arm/Makefile.inc
@@ -0,0 +1,3 @@
+.PATH: ${.CURDIR}/arch/arm
+SRCS+= \
+ thr_rtld_arm.c
diff --git a/lib/libthr/arch/arm/include/pthread_md.h b/lib/libthr/arch/arm/include/pthread_md.h
index d616868bdee4..b90568e249ee 100644
--- a/lib/libthr/arch/arm/include/pthread_md.h
+++ b/lib/libthr/arch/arm/include/pthread_md.h
@@ -48,4 +48,6 @@ _get_curthread(void)
return (NULL);
}
+#define __thr_setup_tsd(thread) _tcb_set((thread)->tcb)
+
#endif /* _PTHREAD_MD_H_ */
diff --git a/lib/libthr/arch/arm/include/pthread_tls.h b/lib/libthr/arch/arm/include/pthread_tls.h
deleted file mode 100644
index 27a07f69f474..000000000000
--- a/lib/libthr/arch/arm/include/pthread_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _ARCH_ARM_PTHREAD_TLS_H
-#define _ARCH_ARM_PTHREAD_TLS_H
-
-static __inline uintptr_t
-_get_static_tls_base(struct pthread *thr, size_t offset)
-{
- uintptr_t tlsbase;
-
- tlsbase = (uintptr_t)thr->tcb;
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libthr/arch/arm/thr_rtld_arm.c b/lib/libthr/arch/arm/thr_rtld_arm.c
new file mode 100644
index 000000000000..35f5fe56cfff
--- /dev/null
+++ b/lib/libthr/arch/arm/thr_rtld_arm.c
@@ -0,0 +1,67 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024, Michal Meloun <mmel@freebsd.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 unmodified, 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "thr_private.h"
+
+int __aeabi_idiv(int , int );
+unsigned __aeabi_uidiv(unsigned, unsigned );
+
+struct {int q; int r;} __aeabi_idivmod(int, int );
+struct {unsigned q; unsigned r;} __aeabi_uidivmod(unsigned, unsigned);
+
+struct {int64_t q; int64_t r;} __aeabi_ldivmod(int64_t, int64_t);
+struct {uint64_t q; uint64_t r;} __aeabi_uldivmod(uint64_t, uint64_t);
+
+void __aeabi_memset(void *dest, size_t n, int c);
+void __aeabi_memclr(void *dest, size_t n);
+void __aeabi_memmove(void *dest, void *src, size_t n);
+void __aeabi_memcpy(void *dest, void *src, size_t n);
+void __aeabi_memcmp(void *dest, void *src, size_t n);
+
+void
+_thr_resolve_machdep(void)
+{
+ char tmp[2];
+
+ __aeabi_idiv(1, 1);
+ __aeabi_uidiv(1, 1);
+
+ __aeabi_idivmod(1, 1);
+ __aeabi_uidivmod(1, 1);
+
+ __aeabi_ldivmod(1, 1);
+ __aeabi_uldivmod(1, 1);
+
+ __aeabi_memset(tmp, 1, 0);
+ __aeabi_memclr(tmp, 1);
+ __aeabi_memmove(tmp, tmp + 1, 1);
+ __aeabi_memcpy(tmp, tmp + 1, 1);
+ __aeabi_memcmp(tmp, tmp + 1, 1);
+}
diff --git a/lib/libthr/arch/i386/Makefile.inc b/lib/libthr/arch/i386/Makefile.inc
index 24e5dd7c9b03..f8013ea914ed 100644
--- a/lib/libthr/arch/i386/Makefile.inc
+++ b/lib/libthr/arch/i386/Makefile.inc
@@ -1,6 +1,3 @@
-
-SRCS+= _umtx_op_err.S
-
# With the current compiler and libthr code, using SSE in libthr
# does not provide enough performance improvement to outweigh
# the extra context switch cost. This can measurably impact
diff --git a/lib/libthr/arch/i386/include/pthread_md.h b/lib/libthr/arch/i386/include/pthread_md.h
index 2a396abe3824..43f84c3d0393 100644
--- a/lib/libthr/arch/i386/include/pthread_md.h
+++ b/lib/libthr/arch/i386/include/pthread_md.h
@@ -47,11 +47,16 @@ _get_curthread(void)
{
struct pthread *thr;
- __asm __volatile("movl %%gs:%1, %0" : "=r" (thr)
- : "m" (*(volatile u_int *)offsetof(struct tcb, tcb_thread)));
+ __asm __volatile("movl %%gs:%c1, %0" : "=r" (thr)
+ : "i" (offsetof(struct tcb, tcb_thread)));
return (thr);
}
-#define HAS__UMTX_OP_ERR 1
+static __inline void
+_thr_resolve_machdep(void)
+{
+}
+
+#define __thr_setup_tsd(thread) _tcb_set((thread)->tcb)
#endif
diff --git a/lib/libthr/arch/i386/include/pthread_tls.h b/lib/libthr/arch/i386/include/pthread_tls.h
deleted file mode 100644
index b2d0f2dbe845..000000000000
--- a/lib/libthr/arch/i386/include/pthread_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _ARCH_I386_PTHREAD_TLS_H
-#define _ARCH_I386_PTHREAD_TLS_H
-
-static __inline uintptr_t
-_get_static_tls_base(struct pthread *thr, size_t offset)
-{
- uintptr_t tlsbase;
-
- tlsbase = (uintptr_t)thr->tcb;
- tlsbase -= offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libthr/arch/powerpc/Makefile.inc b/lib/libthr/arch/powerpc/Makefile.inc
deleted file mode 100644
index 663706b1b364..000000000000
--- a/lib/libthr/arch/powerpc/Makefile.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-
-SRCS+= _umtx_op_err.S
diff --git a/lib/libthr/arch/powerpc/include/pthread_md.h b/lib/libthr/arch/powerpc/include/pthread_md.h
index 14f1703b5460..291f2d9350d9 100644
--- a/lib/libthr/arch/powerpc/include/pthread_md.h
+++ b/lib/libthr/arch/powerpc/include/pthread_md.h
@@ -49,6 +49,11 @@ _get_curthread(void)
return (NULL);
}
-#define HAS__UMTX_OP_ERR 1
+static __inline void
+_thr_resolve_machdep(void)
+{
+}
+
+#define __thr_setup_tsd(thread) _tcb_set((thread)->tcb)
#endif /* _PTHREAD_MD_H_ */
diff --git a/lib/libthr/arch/powerpc/include/pthread_tls.h b/lib/libthr/arch/powerpc/include/pthread_tls.h
deleted file mode 100644
index e53164436018..000000000000
--- a/lib/libthr/arch/powerpc/include/pthread_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _ARCH_POWERPC_PTHREAD_TLS_H
-#define _ARCH_POWERPC_PTHREAD_TLS_H
-
-static __inline uintptr_t
-_get_static_tls_base(struct pthread *thr, size_t offset)
-{
- uintptr_t tlsbase;
-
- tlsbase = (uintptr_t)thr->tcb;
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libthr/arch/riscv/include/pthread_md.h b/lib/libthr/arch/riscv/include/pthread_md.h
index 343f4cae8486..01dcc9c02b8c 100644
--- a/lib/libthr/arch/riscv/include/pthread_md.h
+++ b/lib/libthr/arch/riscv/include/pthread_md.h
@@ -56,4 +56,11 @@ _get_curthread(void)
return (NULL);
}
+static __inline void
+_thr_resolve_machdep(void)
+{
+}
+
+#define __thr_setup_tsd(thread) _tcb_set((thread)->tcb)
+
#endif /* _PTHREAD_MD_H_ */
diff --git a/lib/libthr/arch/riscv/include/pthread_tls.h b/lib/libthr/arch/riscv/include/pthread_tls.h
deleted file mode 100644
index 0af1ddd4cfaf..000000000000
--- a/lib/libthr/arch/riscv/include/pthread_tls.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2019 The FreeBSD Foundation
- *
- * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
- * under sponsorship from the FreeBSD Foundation.
- *
- * 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.
- */
-
-#ifndef _ARCH_RISCV_PTHREAD_TLS_H
-#define _ARCH_RISCV_PTHREAD_TLS_H
-
-static __inline uintptr_t
-_get_static_tls_base(struct pthread *thr, size_t offset)
-{
- uintptr_t tlsbase;
-
- tlsbase = (uintptr_t)thr->tcb;
- tlsbase += offset;
- return (tlsbase);
-}
-
-#endif
diff --git a/lib/libthr/libthr.3 b/lib/libthr/libthr.3
index 7d0c7669654a..b84176abcd32 100644
--- a/lib/libthr/libthr.3
+++ b/lib/libthr/libthr.3
@@ -1,5 +1,5 @@
.\" Copyright (c) 2005 Robert N. M. Watson
-.\" Copyright (c) 2014,2015,2021 The FreeBSD Foundation, Inc.
+.\" Copyright (c) 2014,2015,2021 The FreeBSD Foundation
.\" All rights reserved.
.\"
.\" Part of this documentation was written by
@@ -217,7 +217,7 @@ recycle it at any moment, making this sysctl less useful than it sounds.
.It Dv kern.ipc.umtx_max_robust
The maximal number of robust mutexes allowed for one thread.
The kernel will not unlock more mutexes than specified, see
-.Xr _umtx_op
+.Xr _umtx_op 2
for more details.
The default value is large enough for most useful applications.
.It Dv debug.umtx.robust_faults_verbose
@@ -325,15 +325,15 @@ anyway.
.Sh SEE ALSO
.Xr ktrace 1 ,
.Xr ld-elf.so.1 1 ,
-.Xr getrlimit 2 ,
+.Xr _umtx_op 2 ,
.Xr errno 2 ,
+.Xr getrlimit 2 ,
.Xr thr_exit 2 ,
.Xr thr_kill 2 ,
.Xr thr_kill2 2 ,
.Xr thr_new 2 ,
.Xr thr_self 2 ,
.Xr thr_set_name 2 ,
-.Xr _umtx_op 2 ,
.Xr dlclose 3 ,
.Xr dlopen 3 ,
.Xr getenv 3 ,
diff --git a/lib/libthr/plockstat.d b/lib/libthr/plockstat.d
index de620d893651..39d8946f33d3 100644
--- a/lib/libthr/plockstat.d
+++ b/lib/libthr/plockstat.d
@@ -1,6 +1,5 @@
/*
* Copyright (c) 2010 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Rui Paulo under sponsorship from the
* FreeBSD Foundation.
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index 348fd48df398..3a5353a32dc3 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -136,7 +136,6 @@ FBSDprivate_1.0 {
__pthread_mutex_lock;
__pthread_mutex_timedlock;
__pthread_mutex_trylock;
- __pthread_distribute_static_tls;
_pthread_atfork;
_pthread_barrier_destroy;
_pthread_barrier_init;
@@ -298,6 +297,9 @@ FBSDprivate_1.0 {
/* ABI bug workaround, indicate that pli->rtli_version is valid */
_pli_rtli_version;
+
+ /* Expose stub for libsys filter */
+ _umtx_op_err;
};
FBSD_1.1 {
@@ -334,3 +336,9 @@ FBSD_1.6 {
pthread_peekjoin_np;
pthread_setname_np;
};
+
+FBSD_1.8 {
+ pthread_signals_block_np;
+ pthread_signals_unblock_np;
+ pthread_sigqueue;
+};
diff --git a/lib/libthr/sys/Makefile.inc b/lib/libthr/sys/Makefile.inc
index 7043b2e7c62d..98d7b2ac7bd3 100644
--- a/lib/libthr/sys/Makefile.inc
+++ b/lib/libthr/sys/Makefile.inc
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR}/sys
SRCS+= thr_error.c
diff --git a/lib/libthr/sys/thr_error.c b/lib/libthr/sys/thr_error.c
index 7ce3a84fab6b..ec7a57bf6610 100644
--- a/lib/libthr/sys/thr_error.c
+++ b/lib/libthr/sys/thr_error.c
@@ -39,8 +39,7 @@
#include "libc_private.h"
#include "thr_private.h"
-#undef errno
-extern int errno;
+extern int __libsys_errno;
__weak_reference(__error_threaded, __error);
int *
@@ -53,5 +52,5 @@ __error_threaded(void)
if (curthread != NULL && curthread != _thr_initial)
return (&curthread->error);
}
- return (&errno);
+ return (&__libsys_errno);
}
diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile
index 8b7850b94265..017b740157dc 100644
--- a/lib/libthr/tests/Makefile
+++ b/lib/libthr/tests/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
WARNS?= 3
@@ -34,7 +33,9 @@ NETBSD_ATF_TESTS_SH+= cancel_test
NETBSD_ATF_TESTS_SH+= exit_test
NETBSD_ATF_TESTS_SH+= resolv_test
+ATF_TESTS_C+= atfork_test
ATF_TESTS_C+= umtx_op_test
+ATF_TESTS_C+= pthread_sigqueue_test
LIBADD+= pthread
LIBADD.fpu_test+= m
diff --git a/lib/libthr/tests/atfork_test.c b/lib/libthr/tests/atfork_test.c
new file mode 100644
index 000000000000..cb0fcb7e62db
--- /dev/null
+++ b/lib/libthr/tests/atfork_test.c
@@ -0,0 +1,280 @@
+/*-
+ *
+ * Copyright (C) 2024 Kyle Evans <kevans@FreeBSD.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ */
+
+#include <sys/wait.h>
+#include <errno.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#define EXIT_NOPREPARE 1
+#define EXIT_CALLEDPARENT 2
+#define EXIT_NOCHILD 3
+#define EXIT_BADORDER 4
+
+static int child;
+static int forked;
+static int parent;
+
+/*
+ * We'll disable prefork unless we're specifically running the preinit test to
+ * be sure that we don't mess up any other tests' results.
+ */
+static bool prefork_enabled;
+
+static void
+prefork(void)
+{
+ if (prefork_enabled)
+ forked++;
+}
+
+static void
+registrar(void)
+{
+ pthread_atfork(prefork, NULL, NULL);
+}
+
+static __attribute__((section(".preinit_array"), used))
+void (*preinitfn)(void) = &registrar;
+
+/*
+ * preinit_atfork() just enables the prepare handler that we registered in a
+ * .preinit_array entry and checks that forking actually invoked that callback.
+ * We don't bother testing all three callbacks here because the implementation
+ * doesn't really lend itself to the kind of error where we only have a partial
+ * set of callbacks registered.
+ */
+ATF_TC(preinit_atfork);
+ATF_TC_HEAD(preinit_atfork, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks that atfork callbacks may be registered in .preinit_array functions");
+}
+ATF_TC_BODY(preinit_atfork, tc)
+{
+ pid_t p;
+
+ (void)signal(SIGCHLD, SIG_IGN);
+ prefork_enabled = true;
+ p = fork();
+
+ ATF_REQUIRE(p >= 0);
+ if (p == 0)
+ _exit(0);
+
+ prefork_enabled = false;
+
+ ATF_REQUIRE(forked != 0);
+}
+
+static void
+basic_prepare(void)
+{
+ ATF_REQUIRE(parent == 0);
+ forked++;
+}
+
+static void
+basic_parent(void)
+{
+ ATF_REQUIRE(forked != 0);
+ parent++;
+}
+
+static void
+basic_child(void)
+{
+ if (!forked)
+ _exit(EXIT_NOPREPARE);
+ if (parent != 0)
+ _exit(EXIT_CALLEDPARENT);
+ child++;
+}
+
+/*
+ * In the basic test, we'll register just once and set some globals to confirm
+ * that the prepare/parent callbacks were executed as expected. The child will
+ * use its exit status to communicate to us if the callback was not executed
+ * properly since we cannot assert there. This is a subset of the
+ * multi-callback test, but separated out so that it's more obvious from running
+ * the atfork_test if pthread_atfork() is completely broken or just
+ * out-of-order.
+ */
+ATF_TC(basic_atfork);
+ATF_TC_HEAD(basic_atfork, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks invocation of all three atfork callbacks");
+}
+ATF_TC_BODY(basic_atfork, tc)
+{
+ pid_t p, wpid;
+ int status;
+
+ pthread_atfork(basic_prepare, basic_parent, basic_child);
+
+ p = fork();
+
+ ATF_REQUIRE(p >= 0);
+ if (p == 0)
+ _exit(child != 0 ? 0 : EXIT_NOCHILD);
+
+ /*
+ * The child can't use any of our standard atf-c(3) macros, so we have
+ * to rely on the exit status to convey any shenanigans.
+ */
+ while ((wpid = waitpid(p, &status, 0)) != p) {
+ ATF_REQUIRE_ERRNO(EINTR, wpid == -1);
+ if (wpid == -1)
+ continue;
+ }
+
+ ATF_REQUIRE_MSG(WIFEXITED(status),
+ "child did not exit cleanly, status %x", status);
+
+ status = WEXITSTATUS(status);
+ ATF_REQUIRE_MSG(status == 0, "atfork in child %s",
+ status == EXIT_NOPREPARE ? "did not see `prepare` execute" :
+ (status == EXIT_CALLEDPARENT ? "observed `parent` executing" :
+ (status == EXIT_NOCHILD ? "did not see `child` execute" :
+ "mystery")));
+
+ ATF_REQUIRE(forked != 0);
+ ATF_REQUIRE(parent != 0);
+ ATF_REQUIRE(child == 0);
+}
+
+static void
+multi_assert(bool cond, bool can_assert)
+{
+ if (can_assert)
+ ATF_REQUIRE((cond));
+ else if (!(cond))
+ _exit(EXIT_BADORDER);
+}
+
+static void
+multi_bump(int *var, int bit, bool can_assert)
+{
+ int mask, val;
+
+ mask = (1 << (bit - 1));
+ val = *var;
+
+ /*
+ * Every bit below this one must be set, and none of the upper bits
+ * should be set.
+ */
+ multi_assert((val & mask) == 0, can_assert);
+ if (bit == 1)
+ multi_assert(val == 0, can_assert);
+ else
+ multi_assert((val & ~mask) == (mask - 1), can_assert);
+
+ *var |= mask;
+}
+
+static void
+multi_prepare1(void)
+{
+ /*
+ * The bits are flipped for prepare because it's supposed to be called
+ * in the reverse order of registration.
+ */
+ multi_bump(&forked, 2, true);
+}
+static void
+multi_prepare2(void)
+{
+ multi_bump(&forked, 1, true);
+}
+
+static void
+multi_parent1(void)
+{
+ multi_bump(&parent, 1, true);
+}
+static void
+multi_parent2(void)
+{
+ multi_bump(&parent, 2, true);
+}
+
+static void
+multi_child1(void)
+{
+ multi_bump(&child, 1, false);
+}
+static void
+multi_child2(void)
+{
+ multi_bump(&child, 2, false);
+}
+
+/*
+ * The multi-atfork test works much like the basic one, but it registers
+ * multiple times and enforces an order. The child still does just as strict
+ * of tests as the parent and continues to communicate the results of those
+ * tests back via its exit status.
+ */
+ATF_TC(multi_atfork);
+ATF_TC_HEAD(multi_atfork, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks that multiple callbacks are called in the documented order");
+}
+ATF_TC_BODY(multi_atfork, tc)
+{
+ pid_t p, wpid;
+ int status;
+
+ pthread_atfork(multi_prepare1, multi_parent1, multi_child1);
+ pthread_atfork(multi_prepare2, multi_parent2, multi_child2);
+
+ p = fork();
+
+ ATF_REQUIRE(p >= 0);
+ if (p == 0)
+ _exit(child != 0 ? 0 : EXIT_NOCHILD);
+
+ /*
+ * The child can't use any of our standard atf-c(3) macros, so we have
+ * to rely on the exit status to convey any shenanigans.
+ */
+ while ((wpid = waitpid(p, &status, 0)) != p) {
+ ATF_REQUIRE_ERRNO(EINTR, wpid == -1);
+ if (wpid == -1)
+ continue;
+ }
+
+ ATF_REQUIRE_MSG(WIFEXITED(status),
+ "child did not exit cleanly, status %x", status);
+
+ status = WEXITSTATUS(status);
+ ATF_REQUIRE_MSG(status == 0, "atfork in child %s",
+ status == EXIT_BADORDER ? "called in wrong order" :
+ (status == EXIT_NOCHILD ? "did not see `child` execute" :
+ "mystery"));
+
+ ATF_REQUIRE(forked != 0);
+ ATF_REQUIRE(parent != 0);
+ ATF_REQUIRE(child == 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, preinit_atfork);
+ ATF_TP_ADD_TC(tp, basic_atfork);
+ ATF_TP_ADD_TC(tp, multi_atfork);
+ return (atf_no_error());
+}
diff --git a/lib/libthr/tests/dlopen/Makefile b/lib/libthr/tests/dlopen/Makefile
index acc565056f4a..3427f67025b2 100644
--- a/lib/libthr/tests/dlopen/Makefile
+++ b/lib/libthr/tests/dlopen/Makefile
@@ -1,4 +1,3 @@
-
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen
WARNS?= 2
diff --git a/lib/libthr/tests/dlopen/dso/Makefile b/lib/libthr/tests/dlopen/dso/Makefile
index c2052e82c0ed..74d8ada35ff1 100644
--- a/lib/libthr/tests/dlopen/dso/Makefile
+++ b/lib/libthr/tests/dlopen/dso/Makefile
@@ -1,7 +1,7 @@
-
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread/dlopen/dso
WARNS?= 3
+PACKAGE= tests
SHLIB= h_pthread_dlopen
SHLIB_MAJOR= 1
SHLIB_NAME= h_pthread_dlopen.so.${SHLIB_MAJOR}
diff --git a/lib/libthr/tests/pthread_sigqueue_test.c b/lib/libthr/tests/pthread_sigqueue_test.c
new file mode 100644
index 000000000000..053a8dac4039
--- /dev/null
+++ b/lib/libthr/tests/pthread_sigqueue_test.c
@@ -0,0 +1,120 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright 2024 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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.
+ */
+
+#include <atf-c.h>
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+
+#define NTHREADS 330
+static int value[NTHREADS];
+static pthread_t thr[NTHREADS];
+static pthread_barrier_t barrier;
+
+static void
+handler(int signo __unused, siginfo_t *info, void *data __unused)
+{
+ pthread_t self;
+ int i;
+
+ /*
+ * Formally this is thread-unsafe but we know context from
+ * where the signal is sent.
+ */
+ self = pthread_self();
+ for (i = 0; i < NTHREADS; i++) {
+ if (pthread_equal(self, thr[i])) {
+ value[i] = info->si_value.sival_int;
+ pthread_exit(NULL);
+ }
+ }
+}
+
+static void *
+threadfunc(void *arg __unused)
+{
+ pthread_barrier_wait(&barrier);
+ for (;;)
+ pause();
+}
+
+ATF_TC(pthread_sigqueue);
+ATF_TC_HEAD(pthread_sigqueue, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Checks pthread_sigqueue(3) sigval delivery");
+}
+
+ATF_TC_BODY(pthread_sigqueue, tc)
+{
+ struct sigaction sa;
+ union sigval sv;
+ int error, i;
+
+ error = pthread_barrier_init(&barrier, NULL, NTHREADS + 1);
+ ATF_REQUIRE_EQ(0, error);
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = handler;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+
+ if (sigaction(SIGUSR1, &sa, NULL) != 0)
+ atf_tc_fail("sigaction failed");
+
+ memset(&sv, 0, sizeof(sv));
+
+ for (i = 0; i < NTHREADS; i++) {
+ error = pthread_create(&thr[i], NULL, threadfunc, NULL);
+ ATF_REQUIRE_EQ(0, error);
+ }
+ error = pthread_barrier_wait(&barrier);
+ ATF_REQUIRE(error == 0 || error == PTHREAD_BARRIER_SERIAL_THREAD);
+
+ for (i = 0; i < NTHREADS; i++) {
+ sv.sival_int = i + 1000;
+ error = pthread_sigqueue(thr[i], SIGUSR1, sv);
+ ATF_REQUIRE_EQ(0, error);
+ error = pthread_join(thr[i], NULL);
+ ATF_REQUIRE_EQ(0, error);
+ }
+ for (i = 0; i < NTHREADS; i++)
+ ATF_REQUIRE_EQ(i + 1000, value[i]);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, pthread_sigqueue);
+ return atf_no_error();
+}
diff --git a/lib/libthr/tests/umtx_op_test.c b/lib/libthr/tests/umtx_op_test.c
index 7bffc2d5bfbf..8f964f9a923b 100644
--- a/lib/libthr/tests/umtx_op_test.c
+++ b/lib/libthr/tests/umtx_op_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/umtx.h>
@@ -36,7 +35,7 @@
/*
* This is an implementation detail of _umtx_op(2), pulled from
* sys/kern/kern_umtx.c. The relevant bug observed that requests above the
- * batch side would not function as intended, so it's important that this
+ * batch size would not function as intended, so it's important that this
* reflects the BATCH_SIZE configured there.
*/
#define UMTX_OP_BATCH_SIZE 128
diff --git a/lib/libthr/thread/Makefile.inc b/lib/libthr/thread/Makefile.inc
index 33b95e9dd76d..c7442284bd51 100644
--- a/lib/libthr/thread/Makefile.inc
+++ b/lib/libthr/thread/Makefile.inc
@@ -1,4 +1,3 @@
-
# thr sources
.PATH: ${.CURDIR}/thread
@@ -47,6 +46,7 @@ SRCS+= \
thr_setprio.c \
thr_setschedparam.c \
thr_sig.c \
+ thr_sigqueue.c \
thr_single_np.c \
thr_sleepq.c \
thr_spec.c \
diff --git a/lib/libthr/thread/thr_affinity.c b/lib/libthr/thread/thr_affinity.c
index 89f654ebffc2..78c89e146a79 100644
--- a/lib/libthr/thread/thr_affinity.c
+++ b/lib/libthr/thread/thr_affinity.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread_np.h>
#include <sys/param.h>
diff --git a/lib/libthr/thread/thr_attr.c b/lib/libthr/thread/thr_attr.c
index 9740bed6ebd3..1d0bc8cb7b91 100644
--- a/lib/libthr/thread/thr_attr.c
+++ b/lib/libthr/thread/thr_attr.c
@@ -93,7 +93,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
@@ -113,26 +112,14 @@ __weak_reference(_thr_attr_destroy, pthread_attr_destroy);
int
_thr_attr_destroy(pthread_attr_t *attr)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL)
- /* Invalid argument: */
- ret = EINVAL;
- else {
- if ((*attr)->cpuset != NULL)
- free((*attr)->cpuset);
- /* Free the memory allocated to the attribute object: */
- free(*attr);
+ return (EINVAL);
- /*
- * Leave the attribute pointer NULL now that the memory
- * has been freed:
- */
- *attr = NULL;
- ret = 0;
- }
- return (ret);
+ free((*attr)->cpuset);
+ free(*attr);
+ *attr = NULL;
+ return (0);
}
__weak_reference(_thr_attr_get_np, pthread_attr_get_np);
@@ -141,36 +128,53 @@ __weak_reference(_thr_attr_get_np, _pthread_attr_get_np);
int
_thr_attr_get_np(pthread_t pthread, pthread_attr_t *dstattr)
{
+ struct pthread_attr *dst;
struct pthread *curthread;
- struct pthread_attr attr, *dst;
- int ret;
- size_t kern_size;
+ cpuset_t *cpuset;
+ size_t kern_size;
+ int error;
if (pthread == NULL || dstattr == NULL || (dst = *dstattr) == NULL)
return (EINVAL);
+
kern_size = _get_kern_cpuset_size();
if (dst->cpuset == NULL) {
- dst->cpuset = calloc(1, kern_size);
- dst->cpusetsize = kern_size;
- }
+ if ((cpuset = malloc(kern_size)) == NULL)
+ return (ENOMEM);
+ } else
+ cpuset = dst->cpuset;
+
curthread = _get_curthread();
- if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0)) != 0)
- return (ret);
- attr = pthread->attr;
- if (pthread->flags & THR_FLAGS_DETACHED)
- attr.flags |= PTHREAD_DETACHED;
- ret = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, TID(pthread),
- dst->cpusetsize, dst->cpuset);
- if (ret == -1)
- ret = errno;
- THR_THREAD_UNLOCK(curthread, pthread);
- if (ret == 0) {
- memcpy(&dst->pthread_attr_start_copy,
- &attr.pthread_attr_start_copy,
- offsetof(struct pthread_attr, pthread_attr_end_copy) -
- offsetof(struct pthread_attr, pthread_attr_start_copy));
+ /* Arg 0 is to include dead threads. */
+ if ((error = _thr_find_thread(curthread, pthread, 0)) != 0)
+ goto free_and_exit;
+
+ error = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, TID(pthread),
+ kern_size, cpuset);
+ if (error == -1) {
+ THR_THREAD_UNLOCK(curthread, pthread);
+ error = errno;
+ goto free_and_exit;
}
- return (ret);
+
+ /*
+ * From this point on, we can't fail, so we can start modifying 'dst'.
+ */
+
+ *dst = pthread->attr;
+ if ((pthread->flags & THR_FLAGS_DETACHED) != 0)
+ dst->flags |= PTHREAD_DETACHED;
+
+ THR_THREAD_UNLOCK(curthread, pthread);
+
+ dst->cpuset = cpuset;
+ dst->cpusetsize = kern_size;
+ return (0);
+
+free_and_exit:
+ if (dst->cpuset == NULL)
+ free(cpuset);
+ return (error);
}
__weak_reference(_thr_attr_getdetachstate, pthread_attr_getdetachstate);
@@ -179,22 +183,15 @@ __weak_reference(_thr_attr_getdetachstate, _pthread_attr_getdetachstate);
int
_thr_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL || detachstate == NULL)
- ret = EINVAL;
- else {
- /* Check if the detached flag is set: */
- if ((*attr)->flags & PTHREAD_DETACHED)
- /* Return detached: */
- *detachstate = PTHREAD_CREATE_DETACHED;
- else
- /* Return joinable: */
- *detachstate = PTHREAD_CREATE_JOINABLE;
- ret = 0;
- }
- return (ret);
+ return (EINVAL);
+
+ if (((*attr)->flags & PTHREAD_DETACHED) != 0)
+ *detachstate = PTHREAD_CREATE_DETACHED;
+ else
+ *detachstate = PTHREAD_CREATE_JOINABLE;
+ return (0);
}
__weak_reference(_thr_attr_getguardsize, pthread_attr_getguardsize);
@@ -204,17 +201,12 @@ int
_thr_attr_getguardsize(const pthread_attr_t * __restrict attr,
size_t * __restrict guardsize)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL || guardsize == NULL)
- ret = EINVAL;
- else {
- /* Return the guard size: */
- *guardsize = (*attr)->guardsize_attr;
- ret = 0;
- }
- return (ret);
+ return (EINVAL);
+
+ *guardsize = (*attr)->guardsize_attr;
+ return (0);
}
__weak_reference(_thr_attr_getinheritsched, pthread_attr_getinheritsched);
@@ -224,14 +216,12 @@ int
_thr_attr_getinheritsched(const pthread_attr_t * __restrict attr,
int * __restrict sched_inherit)
{
- int ret = 0;
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else
- *sched_inherit = (*attr)->sched_inherit;
+ if (attr == NULL || *attr == NULL)
+ return (EINVAL);
- return (ret);
+ *sched_inherit = (*attr)->sched_inherit;
+ return (0);
}
__weak_reference(_thr_attr_getschedparam, pthread_attr_getschedparam);
@@ -241,14 +231,12 @@ int
_thr_attr_getschedparam(const pthread_attr_t * __restrict attr,
struct sched_param * __restrict param)
{
- int ret = 0;
- if ((attr == NULL) || (*attr == NULL) || (param == NULL))
- ret = EINVAL;
- else
- param->sched_priority = (*attr)->prio;
+ if (attr == NULL || *attr == NULL || param == NULL)
+ return (EINVAL);
- return (ret);
+ param->sched_priority = (*attr)->prio;
+ return (0);
}
__weak_reference(_thr_attr_getschedpolicy, pthread_attr_getschedpolicy);
@@ -258,14 +246,12 @@ int
_thr_attr_getschedpolicy(const pthread_attr_t * __restrict attr,
int * __restrict policy)
{
- int ret = 0;
- if ((attr == NULL) || (*attr == NULL) || (policy == NULL))
- ret = EINVAL;
- else
- *policy = (*attr)->sched_policy;
+ if (attr == NULL || *attr == NULL || policy == NULL)
+ return (EINVAL);
- return (ret);
+ *policy = (*attr)->sched_policy;
+ return (0);
}
__weak_reference(_thr_attr_getscope, pthread_attr_getscope);
@@ -275,17 +261,13 @@ int
_thr_attr_getscope(const pthread_attr_t * __restrict attr,
int * __restrict contentionscope)
{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (contentionscope == NULL))
- /* Return an invalid argument: */
- ret = EINVAL;
- else
- *contentionscope = (*attr)->flags & PTHREAD_SCOPE_SYSTEM ?
- PTHREAD_SCOPE_SYSTEM : PTHREAD_SCOPE_PROCESS;
+ if (attr == NULL || *attr == NULL || contentionscope == NULL)
+ return (EINVAL);
- return (ret);
+ *contentionscope = ((*attr)->flags & PTHREAD_SCOPE_SYSTEM) != 0 ?
+ PTHREAD_SCOPE_SYSTEM : PTHREAD_SCOPE_PROCESS;
+ return (0);
}
__weak_reference(_pthread_attr_getstack, pthread_attr_getstack);
@@ -294,19 +276,14 @@ int
_pthread_attr_getstack(const pthread_attr_t * __restrict attr,
void ** __restrict stackaddr, size_t * __restrict stacksize)
{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stackaddr == NULL
- || stacksize == NULL )
- ret = EINVAL;
- else {
- /* Return the stack address and size */
- *stackaddr = (*attr)->stackaddr_attr;
- *stacksize = (*attr)->stacksize_attr;
- ret = 0;
- }
- return (ret);
+
+ if (attr == NULL || *attr == NULL || stackaddr == NULL ||
+ stacksize == NULL)
+ return (EINVAL);
+
+ *stackaddr = (*attr)->stackaddr_attr;
+ *stacksize = (*attr)->stacksize_attr;
+ return (0);
}
__weak_reference(_thr_attr_getstackaddr, pthread_attr_getstackaddr);
@@ -315,17 +292,12 @@ __weak_reference(_thr_attr_getstackaddr, _pthread_attr_getstackaddr);
int
_thr_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL || stackaddr == NULL)
- ret = EINVAL;
- else {
- /* Return the stack address: */
- *stackaddr = (*attr)->stackaddr_attr;
- ret = 0;
- }
- return (ret);
+ return (EINVAL);
+
+ *stackaddr = (*attr)->stackaddr_attr;
+ return (0);
}
__weak_reference(_thr_attr_getstacksize, pthread_attr_getstacksize);
@@ -335,17 +307,12 @@ int
_thr_attr_getstacksize(const pthread_attr_t * __restrict attr,
size_t * __restrict stacksize)
{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stacksize == NULL)
- ret = EINVAL;
- else {
- /* Return the stack size: */
- *stacksize = (*attr)->stacksize_attr;
- ret = 0;
- }
- return (ret);
+
+ if (attr == NULL || *attr == NULL || stacksize == NULL)
+ return (EINVAL);
+
+ *stacksize = (*attr)->stacksize_attr;
+ return (0);
}
__weak_reference(_thr_attr_init, pthread_attr_init);
@@ -354,40 +321,30 @@ __weak_reference(_thr_attr_init, _pthread_attr_init);
int
_thr_attr_init(pthread_attr_t *attr)
{
- int ret;
- pthread_attr_t pattr;
+ pthread_attr_t pattr;
_thr_check_init();
- /* Allocate memory for the attribute object: */
- if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL)
- /* Insufficient memory: */
- ret = ENOMEM;
- else {
- /* Initialise the attribute object with the defaults: */
- memcpy(pattr, &_pthread_attr_default, sizeof(struct pthread_attr));
-
- /* Return a pointer to the attribute object: */
- *attr = pattr;
- ret = 0;
- }
- return (ret);
+ if ((pattr = malloc(sizeof(*pattr))) == NULL)
+ return (ENOMEM);
+
+ memcpy(pattr, &_pthread_attr_default, sizeof(*pattr));
+ *attr = pattr;
+ return (0);
}
-__weak_reference(_pthread_attr_setcreatesuspend_np, pthread_attr_setcreatesuspend_np);
+__weak_reference(_pthread_attr_setcreatesuspend_np, \
+ pthread_attr_setcreatesuspend_np);
int
_pthread_attr_setcreatesuspend_np(pthread_attr_t *attr)
{
- int ret;
- if (attr == NULL || *attr == NULL) {
- ret = EINVAL;
- } else {
- (*attr)->suspend = THR_CREATE_SUSPENDED;
- ret = 0;
- }
- return (ret);
+ if (attr == NULL || *attr == NULL)
+ return (EINVAL);
+
+ (*attr)->suspend = THR_CREATE_SUSPENDED;
+ return (0);
}
__weak_reference(_thr_attr_setdetachstate, pthread_attr_setdetachstate);
@@ -396,24 +353,17 @@ __weak_reference(_thr_attr_setdetachstate, _pthread_attr_setdetachstate);
int
_thr_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL ||
(detachstate != PTHREAD_CREATE_DETACHED &&
detachstate != PTHREAD_CREATE_JOINABLE))
- ret = EINVAL;
- else {
- /* Check if detached state: */
- if (detachstate == PTHREAD_CREATE_DETACHED)
- /* Set the detached flag: */
- (*attr)->flags |= PTHREAD_DETACHED;
- else
- /* Reset the detached flag: */
- (*attr)->flags &= ~PTHREAD_DETACHED;
- ret = 0;
- }
- return (ret);
+ return (EINVAL);
+
+ if (detachstate == PTHREAD_CREATE_DETACHED)
+ (*attr)->flags |= PTHREAD_DETACHED;
+ else
+ (*attr)->flags &= ~PTHREAD_DETACHED;
+ return (0);
}
__weak_reference(_thr_attr_setguardsize, pthread_attr_setguardsize);
@@ -422,17 +372,12 @@ __weak_reference(_thr_attr_setguardsize, _pthread_attr_setguardsize);
int
_thr_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
{
- int ret;
- /* Check for invalid arguments. */
if (attr == NULL || *attr == NULL)
- ret = EINVAL;
- else {
- /* Save the stack size. */
- (*attr)->guardsize_attr = guardsize;
- ret = 0;
- }
- return (ret);
+ return (EINVAL);
+
+ (*attr)->guardsize_attr = guardsize;
+ return (0);
}
__weak_reference(_thr_attr_setinheritsched, pthread_attr_setinheritsched);
@@ -441,17 +386,14 @@ __weak_reference(_thr_attr_setinheritsched, _pthread_attr_setinheritsched);
int
_thr_attr_setinheritsched(pthread_attr_t *attr, int sched_inherit)
{
- int ret = 0;
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else if (sched_inherit != PTHREAD_INHERIT_SCHED &&
- sched_inherit != PTHREAD_EXPLICIT_SCHED)
- ret = ENOTSUP;
- else
- (*attr)->sched_inherit = sched_inherit;
+ if (attr == NULL || *attr == NULL ||
+ (sched_inherit != PTHREAD_INHERIT_SCHED &&
+ sched_inherit != PTHREAD_EXPLICIT_SCHED))
+ return (EINVAL);
- return (ret);
+ (*attr)->sched_inherit = sched_inherit;
+ return (0);
}
__weak_reference(_thr_attr_setschedparam, pthread_attr_setschedparam);
@@ -463,18 +405,15 @@ _thr_attr_setschedparam(pthread_attr_t * __restrict attr,
{
int policy;
- if ((attr == NULL) || (*attr == NULL))
+ if (attr == NULL || *attr == NULL || param == NULL)
return (EINVAL);
- if (param == NULL)
- return (ENOTSUP);
-
policy = (*attr)->sched_policy;
if (policy == SCHED_FIFO || policy == SCHED_RR) {
if (param->sched_priority < _thr_priorities[policy-1].pri_min ||
param->sched_priority > _thr_priorities[policy-1].pri_max)
- return (ENOTSUP);
+ return (EINVAL);
} else {
/*
* Ignore it for SCHED_OTHER now, patches for glib ports
@@ -494,17 +433,14 @@ __weak_reference(_thr_attr_setschedpolicy, _pthread_attr_setschedpolicy);
int
_thr_attr_setschedpolicy(pthread_attr_t *attr, int policy)
{
- int ret = 0;
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else if ((policy < SCHED_FIFO) || (policy > SCHED_RR)) {
- ret = ENOTSUP;
- } else {
- (*attr)->sched_policy = policy;
- (*attr)->prio = _thr_priorities[policy-1].pri_default;
- }
- return (ret);
+ if (attr == NULL || *attr == NULL ||
+ policy < SCHED_FIFO || policy > SCHED_RR)
+ return (EINVAL);
+
+ (*attr)->sched_policy = policy;
+ (*attr)->prio = _thr_priorities[policy-1].pri_default;
+ return (0);
}
__weak_reference(_thr_attr_setscope, pthread_attr_setscope);
@@ -513,41 +449,33 @@ __weak_reference(_thr_attr_setscope, _pthread_attr_setscope);
int
_thr_attr_setscope(pthread_attr_t *attr, int contentionscope)
{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL)) {
- /* Return an invalid argument: */
- ret = EINVAL;
- } else if ((contentionscope != PTHREAD_SCOPE_PROCESS) &&
- (contentionscope != PTHREAD_SCOPE_SYSTEM)) {
- ret = EINVAL;
- } else if (contentionscope == PTHREAD_SCOPE_SYSTEM) {
- (*attr)->flags |= contentionscope;
- } else {
+
+ if (attr == NULL || *attr == NULL ||
+ (contentionscope != PTHREAD_SCOPE_PROCESS &&
+ contentionscope != PTHREAD_SCOPE_SYSTEM))
+ return (EINVAL);
+
+ if (contentionscope == PTHREAD_SCOPE_SYSTEM)
+ (*attr)->flags |= PTHREAD_SCOPE_SYSTEM;
+ else
(*attr)->flags &= ~PTHREAD_SCOPE_SYSTEM;
- }
- return (ret);
+ return (0);
}
__weak_reference(_pthread_attr_setstack, pthread_attr_setstack);
int
_pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr,
- size_t stacksize)
+ size_t stacksize)
{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stackaddr == NULL
- || stacksize < PTHREAD_STACK_MIN)
- ret = EINVAL;
- else {
- /* Save the stack address and stack size */
- (*attr)->stackaddr_attr = stackaddr;
- (*attr)->stacksize_attr = stacksize;
- ret = 0;
- }
- return (ret);
+
+ if (attr == NULL || *attr == NULL || stackaddr == NULL ||
+ stacksize < PTHREAD_STACK_MIN)
+ return (EINVAL);
+
+ (*attr)->stackaddr_attr = stackaddr;
+ (*attr)->stacksize_attr = stacksize;
+ return (0);
}
__weak_reference(_thr_attr_setstackaddr, pthread_attr_setstackaddr);
@@ -556,17 +484,12 @@ __weak_reference(_thr_attr_setstackaddr, _pthread_attr_setstackaddr);
int
_thr_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL || stackaddr == NULL)
- ret = EINVAL;
- else {
- /* Save the stack address: */
- (*attr)->stackaddr_attr = stackaddr;
- ret = 0;
- }
- return(ret);
+ return (EINVAL);
+
+ (*attr)->stackaddr_attr = stackaddr;
+ return (0);
}
__weak_reference(_thr_attr_setstacksize, pthread_attr_setstacksize);
@@ -575,17 +498,12 @@ __weak_reference(_thr_attr_setstacksize, _pthread_attr_setstacksize);
int
_thr_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
{
- int ret;
- /* Check for invalid arguments: */
if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN)
- ret = EINVAL;
- else {
- /* Save the stack size: */
- (*attr)->stacksize_attr = stacksize;
- ret = 0;
- }
- return (ret);
+ return (EINVAL);
+
+ (*attr)->stacksize_attr = stacksize;
+ return (0);
}
static size_t
@@ -608,71 +526,70 @@ _get_kern_cpuset_size(void)
}
__weak_reference(_pthread_attr_setaffinity_np, pthread_attr_setaffinity_np);
+
int
_pthread_attr_setaffinity_np(pthread_attr_t *pattr, size_t cpusetsize,
- const cpuset_t *cpusetp)
+ const cpuset_t *cpusetp)
{
pthread_attr_t attr;
- int ret;
+ size_t kern_size;
if (pattr == NULL || (attr = (*pattr)) == NULL)
- ret = EINVAL;
- else {
- if (cpusetsize == 0 || cpusetp == NULL) {
- if (attr->cpuset != NULL) {
- free(attr->cpuset);
- attr->cpuset = NULL;
- attr->cpusetsize = 0;
- }
- return (0);
- }
- size_t kern_size = _get_kern_cpuset_size();
- /* Kernel rejects small set, we check it here too. */
- if (cpusetsize < kern_size)
- return (ERANGE);
- if (cpusetsize > kern_size) {
- /* Kernel checks invalid bits, we check it here too. */
- size_t i;
- for (i = kern_size; i < cpusetsize; ++i) {
- if (((const char *)cpusetp)[i])
- return (EINVAL);
- }
- }
- if (attr->cpuset == NULL) {
- attr->cpuset = calloc(1, kern_size);
- if (attr->cpuset == NULL)
- return (errno);
- attr->cpusetsize = kern_size;
+ return (EINVAL);
+
+ if (cpusetsize == 0 || cpusetp == NULL) {
+ if (attr->cpuset != NULL) {
+ free(attr->cpuset);
+ attr->cpuset = NULL;
+ attr->cpusetsize = 0;
}
- memcpy(attr->cpuset, cpusetp, kern_size);
- ret = 0;
+ return (0);
+ }
+
+ kern_size = _get_kern_cpuset_size();
+ /* Kernel rejects small set, we check it here too. */
+ if (cpusetsize < kern_size)
+ return (ERANGE);
+ if (cpusetsize > kern_size) {
+ /* Kernel checks invalid bits, we check it here too. */
+ size_t i;
+
+ for (i = kern_size; i < cpusetsize; ++i)
+ if (((const char *)cpusetp)[i] != 0)
+ return (EINVAL);
+ }
+ if (attr->cpuset == NULL) {
+ attr->cpuset = malloc(kern_size);
+ if (attr->cpuset == NULL)
+ return (errno);
+ attr->cpusetsize = kern_size;
}
- return (ret);
+ memcpy(attr->cpuset, cpusetp, kern_size);
+ return (0);
}
__weak_reference(_pthread_attr_getaffinity_np, pthread_attr_getaffinity_np);
+
int
_pthread_attr_getaffinity_np(const pthread_attr_t *pattr, size_t cpusetsize,
- cpuset_t *cpusetp)
+ cpuset_t *cpusetp)
{
pthread_attr_t attr;
- int ret = 0;
if (pattr == NULL || (attr = (*pattr)) == NULL)
- ret = EINVAL;
- else {
- /* Kernel rejects small set, we check it here too. */
- size_t kern_size = _get_kern_cpuset_size();
- if (cpusetsize < kern_size)
- return (ERANGE);
- if (attr->cpuset != NULL)
- memcpy(cpusetp, attr->cpuset, MIN(cpusetsize,
- attr->cpusetsize));
- else
- memset(cpusetp, -1, kern_size);
- if (cpusetsize > kern_size)
- memset(((char *)cpusetp) + kern_size, 0,
- cpusetsize - kern_size);
- }
- return (ret);
+ return (EINVAL);
+
+ /* Kernel rejects small set, we check it here too. */
+ size_t kern_size = _get_kern_cpuset_size();
+ if (cpusetsize < kern_size)
+ return (ERANGE);
+ if (attr->cpuset != NULL)
+ memcpy(cpusetp, attr->cpuset, MIN(cpusetsize,
+ attr->cpusetsize));
+ else
+ memset(cpusetp, -1, kern_size);
+ if (cpusetsize > kern_size)
+ memset(((char *)cpusetp) + kern_size, 0,
+ cpusetsize - kern_size);
+ return (0);
}
diff --git a/lib/libthr/thread/thr_autoinit.c b/lib/libthr/thread/thr_autoinit.c
index f18f53517e06..b0b4e601eff7 100644
--- a/lib/libthr/thread/thr_autoinit.c
+++ b/lib/libthr/thread/thr_autoinit.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <pthread.h>
#include "thr_private.h"
diff --git a/lib/libthr/thread/thr_barrier.c b/lib/libthr/thread/thr_barrier.c
index 8f5936409c05..13dec864e2f6 100644
--- a/lib/libthr/thread/thr_barrier.c
+++ b/lib/libthr/thread/thr_barrier.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
diff --git a/lib/libthr/thread/thr_barrierattr.c b/lib/libthr/thread/thr_barrierattr.c
index 7af7e40f9159..6e5de86973f2 100644
--- a/lib/libthr/thread/thr_barrierattr.c
+++ b/lib/libthr/thread/thr_barrierattr.c
@@ -28,7 +28,6 @@
* DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
diff --git a/lib/libthr/thread/thr_cancel.c b/lib/libthr/thread/thr_cancel.c
index 86632e41449b..4189a2640d14 100644
--- a/lib/libthr/thread/thr_cancel.c
+++ b/lib/libthr/thread/thr_cancel.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include "un-namespace.h"
@@ -84,25 +83,25 @@ int
_thr_setcancelstate(int state, int *oldstate)
{
struct pthread *curthread = _get_curthread();
- int oldval;
+ int oldval, val;
- oldval = curthread->cancel_enable;
switch (state) {
case PTHREAD_CANCEL_DISABLE:
- curthread->cancel_enable = 0;
+ val = 0;
break;
case PTHREAD_CANCEL_ENABLE:
- curthread->cancel_enable = 1;
- if (curthread->cancel_async)
- testcancel(curthread);
+ val = 1;
break;
default:
return (EINVAL);
}
- if (oldstate) {
+ oldval = atomic_swap_int(&curthread->cancel_enable, val);
+ if (state == PTHREAD_CANCEL_ENABLE && curthread->cancel_async)
+ testcancel(curthread);
+ if (oldstate != NULL) {
*oldstate = oldval ? PTHREAD_CANCEL_ENABLE :
- PTHREAD_CANCEL_DISABLE;
+ PTHREAD_CANCEL_DISABLE;
}
return (0);
}
@@ -126,9 +125,9 @@ _thr_setcanceltype(int type, int *oldtype)
return (EINVAL);
}
- if (oldtype) {
+ if (oldtype != NULL) {
*oldtype = oldval ? PTHREAD_CANCEL_ASYNCHRONOUS :
- PTHREAD_CANCEL_DEFERRED;
+ PTHREAD_CANCEL_DEFERRED;
}
return (0);
}
@@ -167,9 +166,8 @@ void
_thr_cancel_leave(struct pthread *curthread, int maycancel)
{
curthread->cancel_point = 0;
- if (__predict_false(SHOULD_CANCEL(curthread) &&
- !THR_IN_CRITICAL(curthread) && maycancel))
- _pthread_exit(PTHREAD_CANCELED);
+ if (maycancel)
+ testcancel(curthread);
}
void
diff --git a/lib/libthr/thread/thr_clean.c b/lib/libthr/thread/thr_clean.c
index ba699f0376d8..43fd570fd1df 100644
--- a/lib/libthr/thread/thr_clean.c
+++ b/lib/libthr/thread/thr_clean.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <signal.h>
#include <errno.h>
diff --git a/lib/libthr/thread/thr_concurrency.c b/lib/libthr/thread/thr_concurrency.c
index cc0d1075b92d..64c605f7d058 100644
--- a/lib/libthr/thread/thr_concurrency.c
+++ b/lib/libthr/thread/thr_concurrency.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
diff --git a/lib/libthr/thread/thr_cond.c b/lib/libthr/thread/thr_cond.c
index bec7933537b3..0eb3dac068ca 100644
--- a/lib/libthr/thread/thr_cond.c
+++ b/lib/libthr/thread/thr_cond.c
@@ -30,7 +30,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdlib.h>
#include <errno.h>
@@ -64,6 +63,7 @@ __weak_reference(__thr_cond_wait, pthread_cond_wait);
__weak_reference(__thr_cond_wait, __pthread_cond_wait);
__weak_reference(_thr_cond_wait, _pthread_cond_wait);
__weak_reference(__pthread_cond_timedwait, pthread_cond_timedwait);
+__weak_reference(_thr_cond_timedwait, _pthread_cond_timedwait);
__weak_reference(_thr_cond_init, pthread_cond_init);
__weak_reference(_thr_cond_init, _pthread_cond_init);
__weak_reference(_thr_cond_destroy, pthread_cond_destroy);
diff --git a/lib/libthr/thread/thr_condattr.c b/lib/libthr/thread/thr_condattr.c
index c5f675f0023d..dc56363fc084 100644
--- a/lib/libthr/thread/thr_condattr.c
+++ b/lib/libthr/thread/thr_condattr.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdlib.h>
#include <string.h>
@@ -95,6 +94,7 @@ _pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id)
if (attr == NULL || *attr == NULL)
return (EINVAL);
if (clock_id != CLOCK_REALTIME &&
+ clock_id != CLOCK_TAI &&
clock_id != CLOCK_VIRTUAL &&
clock_id != CLOCK_PROF &&
clock_id != CLOCK_MONOTONIC) {
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c
index 4b9f45ac49de..e56dbcfe30e1 100644
--- a/lib/libthr/thread/thr_create.c
+++ b/lib/libthr/thread/thr_create.c
@@ -27,11 +27,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#define _WANT_P_OSREL
#include "namespace.h"
#include <sys/types.h>
#include <sys/rtprio.h>
#include <sys/signalvar.h>
+#include <sys/exterrvar.h>
#include <errno.h>
#include <link.h>
#include <stdlib.h>
@@ -44,9 +45,13 @@
#include "libc_private.h"
#include "thr_private.h"
+int __getosreldate(void);
+
static int create_stack(struct pthread_attr *pattr);
static void thread_start(struct pthread *curthread);
+int __thr_new_flags = THR_C_RUNTIME;
+
__weak_reference(_pthread_create, pthread_create);
int
@@ -147,7 +152,7 @@ _pthread_create(pthread_t * __restrict thread,
_thr_stack_fix_protection(new_thread);
/* Return thread pointer eariler so that new thread can use it. */
- (*thread) = new_thread;
+ *thread = new_thread;
if (SHOULD_REPORT_EVENT(curthread, TD_CREATE) || cpusetp != NULL) {
THR_THREAD_LOCK(curthread, new_thread);
locked = 1;
@@ -161,7 +166,7 @@ _pthread_create(pthread_t * __restrict thread,
param.tls_size = sizeof(struct tcb);
param.child_tid = &new_thread->tid;
param.parent_tid = &new_thread->tid;
- param.flags = 0;
+ param.flags = __thr_new_flags;
if (new_thread->attr.flags & PTHREAD_SCOPE_SYSTEM)
param.flags |= THR_SYSTEM_SCOPE;
if (new_thread->attr.sched_inherit == PTHREAD_INHERIT_SCHED)
@@ -227,8 +232,8 @@ _pthread_create(pthread_t * __restrict thread,
THR_THREAD_UNLOCK(curthread, new_thread);
}
out:
- if (ret)
- (*thread) = 0;
+ if (ret != 0)
+ *thread = NULL;
return (ret);
}
@@ -286,6 +291,10 @@ thread_start(struct pthread *curthread)
curthread->attr.stacksize_attr;
#endif
+ curthread->uexterr.ver = UEXTERROR_VER;
+ if (__getosreldate() >= P_OSREL_EXTERRCTL)
+ exterrctl(EXTERRCTL_ENABLE, 0, &curthread->uexterr);
+
/* Run the current thread's start routine with argument: */
_pthread_exit(curthread->start_routine(curthread->arg));
diff --git a/lib/libthr/thread/thr_ctrdtr.c b/lib/libthr/thread/thr_ctrdtr.c
index ae8fa38d3cb0..6fa462a81d86 100644
--- a/lib/libthr/thread/thr_ctrdtr.c
+++ b/lib/libthr/thread/thr_ctrdtr.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <rtld_tls.h>
diff --git a/lib/libthr/thread/thr_detach.c b/lib/libthr/thread/thr_detach.c
index 214d5e76262e..c7a60bb26129 100644
--- a/lib/libthr/thread/thr_detach.c
+++ b/lib/libthr/thread/thr_detach.c
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <errno.h>
diff --git a/lib/libthr/thread/thr_equal.c b/lib/libthr/thread/thr_equal.c
index 2a4cc9f6d049..e5b2ab881138 100644
--- a/lib/libthr/thread/thr_equal.c
+++ b/lib/libthr/thread/thr_equal.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include "un-namespace.h"
diff --git a/lib/libthr/thread/thr_event.c b/lib/libthr/thread/thr_event.c
index afe0b307423c..f0b1805894fb 100644
--- a/lib/libthr/thread/thr_event.c
+++ b/lib/libthr/thread/thr_event.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "thr_private.h"
void
diff --git a/lib/libthr/thread/thr_exit.c b/lib/libthr/thread/thr_exit.c
index 001b30f6671a..5a9dcf99fa21 100644
--- a/lib/libthr/thread/thr_exit.c
+++ b/lib/libthr/thread/thr_exit.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#ifdef _PTHREAD_FORCED_UNWIND
diff --git a/lib/libthr/thread/thr_fork.c b/lib/libthr/thread/thr_fork.c
index fc7d77180e8b..aa54b0444cf4 100644
--- a/lib/libthr/thread/thr_fork.c
+++ b/lib/libthr/thread/thr_fork.c
@@ -57,7 +57,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/syscall.h>
#include "namespace.h"
#include <errno.h>
@@ -85,20 +84,24 @@ _thr_atfork(void (*prepare)(void), void (*parent)(void),
struct pthread *curthread;
struct pthread_atfork *af;
- _thr_check_init();
-
if ((af = malloc(sizeof(struct pthread_atfork))) == NULL)
return (ENOMEM);
- curthread = _get_curthread();
af->prepare = prepare;
af->parent = parent;
af->child = child;
- THR_CRITICAL_ENTER(curthread);
- _thr_rwl_wrlock(&_thr_atfork_lock);
- TAILQ_INSERT_TAIL(&_thr_atfork_list, af, qe);
- _thr_rwl_unlock(&_thr_atfork_lock);
- THR_CRITICAL_LEAVE(curthread);
+
+ if (_thr_initial != NULL) {
+ curthread = _get_curthread();
+ THR_CRITICAL_ENTER(curthread);
+ _thr_rwl_wrlock(&_thr_atfork_lock);
+ TAILQ_INSERT_TAIL(&_thr_atfork_list, af, qe);
+ _thr_rwl_unlock(&_thr_atfork_lock);
+ THR_CRITICAL_LEAVE(curthread);
+ } else {
+ TAILQ_INSERT_TAIL(&_thr_atfork_list, af, qe);
+ }
+
return (0);
}
diff --git a/lib/libthr/thread/thr_getcpuclockid.c b/lib/libthr/thread/thr_getcpuclockid.c
index 0281fc626882..dee3a2a9447a 100644
--- a/lib/libthr/thread/thr_getcpuclockid.c
+++ b/lib/libthr/thread/thr_getcpuclockid.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
diff --git a/lib/libthr/thread/thr_getprio.c b/lib/libthr/thread/thr_getprio.c
index 5ab147af212c..d338287342ac 100644
--- a/lib/libthr/thread/thr_getprio.c
+++ b/lib/libthr/thread/thr_getprio.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
diff --git a/lib/libthr/thread/thr_getschedparam.c b/lib/libthr/thread/thr_getschedparam.c
index 557bcc834950..3abe9be6937b 100644
--- a/lib/libthr/thread/thr_getschedparam.c
+++ b/lib/libthr/thread/thr_getschedparam.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/rtprio.h>
diff --git a/lib/libthr/thread/thr_getthreadid_np.c b/lib/libthr/thread/thr_getthreadid_np.c
index 1fe927435b02..ffecd0bc7ea9 100644
--- a/lib/libthr/thread/thr_getthreadid_np.c
+++ b/lib/libthr/thread/thr_getthreadid_np.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include <pthread_np.h>
@@ -37,7 +36,7 @@ __weak_reference(_thr_getthreadid_np, _pthread_getthreadid_np);
__weak_reference(_thr_getthreadid_np, pthread_getthreadid_np);
/*
- * Provide the equivelant to AIX pthread_getthreadid_np() function.
+ * Provide the equivalent to AIX pthread_getthreadid_np() function.
*/
int
_thr_getthreadid_np(void)
diff --git a/lib/libthr/thread/thr_info.c b/lib/libthr/thread/thr_info.c
index 41ab7f0bcf0c..f6bf81203f9c 100644
--- a/lib/libthr/thread/thr_info.c
+++ b/lib/libthr/thread/thr_info.c
@@ -33,7 +33,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/errno.h>
#include <stdlib.h>
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index b59678c3f6c3..64cf7d004070 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#define _WANT_P_OSREL
#include "namespace.h"
#include <sys/param.h>
#include <sys/auxv.h>
@@ -60,6 +60,7 @@
#include "libc_private.h"
#include "thr_private.h"
+int __getosreldate(void);
char *_usrstack;
struct pthread *_thr_initial;
int _libthr_debug;
@@ -272,6 +273,8 @@ static pthread_func_t jmp_table[][2] = {
[PJT_GETTHREADID_NP] = {DUAL_ENTRY(_thr_getthreadid_np)},
[PJT_ATTR_GET_NP] = {DUAL_ENTRY(_thr_attr_get_np)},
[PJT_GETNAME_NP] = {DUAL_ENTRY(_thr_getname_np)},
+ [PJT_SUSPEND_ALL_NP] = {DUAL_ENTRY(_thr_suspend_all_np)},
+ [PJT_RESUME_ALL_NP] = {DUAL_ENTRY(_thr_resume_all_np)},
};
static int init_once = 0;
@@ -333,6 +336,8 @@ _libpthread_init(struct pthread *curthread)
/* Set the initial thread. */
if (curthread == NULL) {
first = 1;
+ /* Force _get_curthread() return NULL until set. */
+ _tcb_get()->tcb_thread = NULL;
/* Create and initialize the initial thread. */
curthread = _thr_alloc(NULL);
if (curthread == NULL)
@@ -349,7 +354,7 @@ _libpthread_init(struct pthread *curthread)
_thread_active_threads = 1;
/* Setup the thread specific data */
- _tcb_set(curthread->tcb);
+ __thr_setup_tsd(curthread);
if (first) {
_thr_initial = curthread;
@@ -430,6 +435,10 @@ init_main_thread(struct pthread *thread)
thread->unwind_stackend = _usrstack;
#endif
+ thread->uexterr.ver = UEXTERROR_VER;
+ if (__getosreldate() >= P_OSREL_EXTERRCTL)
+ exterrctl(EXTERRCTL_ENABLE, EXTERRCTLF_FORCE, &thread->uexterr);
+
/* Others cleared to zero by thr_alloc() */
}
@@ -520,7 +529,6 @@ init_private(void)
env = getenv("LIBPTHREAD_QUEUE_FIFO");
if (env)
_thr_queuefifo = atoi(env);
- TAILQ_INIT(&_thr_atfork_list);
env = getenv("LIBPTHREAD_UMTX_MIN_TIMEOUT");
if (env) {
char *endptr;
diff --git a/lib/libthr/thread/thr_join.c b/lib/libthr/thread/thr_join.c
index 4b48249489f6..53f28daa258d 100644
--- a/lib/libthr/thread/thr_join.c
+++ b/lib/libthr/thread/thr_join.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
diff --git a/lib/libthr/thread/thr_kern.c b/lib/libthr/thread/thr_kern.c
index 05522569fbfb..913b0d3ef44c 100644
--- a/lib/libthr/thread/thr_kern.c
+++ b/lib/libthr/thread/thr_kern.c
@@ -27,7 +27,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/signalvar.h>
#include <sys/rtprio.h>
diff --git a/lib/libthr/thread/thr_kill.c b/lib/libthr/thread/thr_kill.c
index dd7beddd5c33..5fb40b3bc496 100644
--- a/lib/libthr/thread/thr_kill.c
+++ b/lib/libthr/thread/thr_kill.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <signal.h>
diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c
index 72018d94f496..cbf16179f619 100644
--- a/lib/libthr/thread/thr_list.c
+++ b/lib/libthr/thread/thr_list.c
@@ -27,17 +27,17 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/queue.h>
+#include <machine/tls.h>
+
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "libc_private.h"
#include "thr_private.h"
-#include "static_tls.h"
/*#define DEBUG_THREAD_LIST */
#ifdef DEBUG_THREAD_LIST
@@ -150,16 +150,18 @@ _thr_alloc(struct pthread *curthread)
if (thread == NULL) {
if (total_threads > MAX_THREADS)
return (NULL);
- atomic_fetchadd_int(&total_threads, 1);
- thread = calloc(1, sizeof(struct pthread));
+ atomic_add_int(&total_threads, 1);
+ thread = __thr_aligned_alloc_offset(_Alignof(struct pthread),
+ sizeof(struct pthread), 0);
if (thread == NULL) {
- atomic_fetchadd_int(&total_threads, -1);
+ atomic_add_int(&total_threads, -1);
return (NULL);
}
+ memset(thread, 0, sizeof(*thread));
if ((thread->sleepqueue = _sleepq_alloc()) == NULL ||
(thread->wake_addr = _thr_alloc_wake_addr()) == NULL) {
thr_destroy(curthread, thread);
- atomic_fetchadd_int(&total_threads, -1);
+ atomic_add_int(&total_threads, -1);
return (NULL);
}
} else {
@@ -177,7 +179,7 @@ _thr_alloc(struct pthread *curthread)
thread->tcb = tcb;
} else {
thr_destroy(curthread, thread);
- atomic_fetchadd_int(&total_threads, -1);
+ atomic_add_int(&total_threads, -1);
thread = NULL;
}
return (thread);
@@ -203,7 +205,7 @@ _thr_free(struct pthread *curthread, struct pthread *thread)
thread->tcb = NULL;
if ((curthread == NULL) || (free_thread_count >= MAX_CACHED_THREADS)) {
thr_destroy(curthread, thread);
- atomic_fetchadd_int(&total_threads, -1);
+ atomic_add_int(&total_threads, -1);
} else {
/*
* Add the thread to the free thread list, this also avoids
@@ -223,7 +225,7 @@ thr_destroy(struct pthread *curthread __unused, struct pthread *thread)
_sleepq_free(thread->sleepqueue);
if (thread->wake_addr != NULL)
_thr_release_wake_addr(thread->wake_addr);
- free(thread);
+ __thr_free(thread);
}
/*
@@ -361,35 +363,3 @@ _thr_find_thread(struct pthread *curthread, struct pthread *thread,
THREAD_LIST_UNLOCK(curthread);
return (ret);
}
-
-#include "pthread_tls.h"
-
-static void
-thr_distribute_static_tls(uintptr_t tlsbase, void *src, size_t len,
- size_t total_len)
-{
-
- memcpy((void *)tlsbase, src, len);
- memset((char *)tlsbase + len, 0, total_len - len);
-}
-
-void
-__pthread_distribute_static_tls(size_t offset, void *src, size_t len,
- size_t total_len)
-{
- struct pthread *curthread, *thrd;
- uintptr_t tlsbase;
-
- if (!_thr_is_inited()) {
- tlsbase = _libc_get_static_tls_base(offset);
- thr_distribute_static_tls(tlsbase, src, len, total_len);
- return;
- }
- curthread = _get_curthread();
- THREAD_LIST_RDLOCK(curthread);
- TAILQ_FOREACH(thrd, &_thread_list, tle) {
- tlsbase = _get_static_tls_base(thrd, offset);
- thr_distribute_static_tls(tlsbase, src, len, total_len);
- }
- THREAD_LIST_UNLOCK(curthread);
-}
diff --git a/lib/libthr/thread/thr_main_np.c b/lib/libthr/thread/thr_main_np.c
index 9dd8b1820acd..1d34dc21b84c 100644
--- a/lib/libthr/thread/thr_main_np.c
+++ b/lib/libthr/thread/thr_main_np.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include <pthread_np.h>
diff --git a/lib/libthr/thread/thr_malloc.c b/lib/libthr/thread/thr_malloc.c
index d60fbc1b1fe8..48af9d1ea929 100644
--- a/lib/libthr/thread/thr_malloc.c
+++ b/lib/libthr/thread/thr_malloc.c
@@ -2,7 +2,6 @@
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2019 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Konstantin Belousov <kib@FreeBSD.org>
* under sponsorship from the FreeBSD Foundation.
@@ -29,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <rtld_malloc.h>
@@ -122,6 +120,19 @@ __thr_malloc(size_t nbytes)
}
void *
+__thr_aligned_alloc_offset(size_t align, size_t size, size_t offset)
+{
+ struct pthread *curthread;
+ void *res;
+
+ curthread = _get_curthread();
+ thr_malloc_lock(curthread);
+ res = __crt_aligned_alloc_offset(align, size, offset);
+ thr_malloc_unlock(curthread);
+ return (res);
+}
+
+void *
__thr_realloc(void *cp, size_t nbytes)
{
struct pthread *curthread;
diff --git a/lib/libthr/thread/thr_multi_np.c b/lib/libthr/thread/thr_multi_np.c
index cbd3f31fddf0..bac58ca85dca 100644
--- a/lib/libthr/thread/thr_multi_np.c
+++ b/lib/libthr/thread/thr_multi_np.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include <pthread_np.h>
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 5dd624a269e4..32bdc4afe65f 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -38,7 +38,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <stdlib.h>
#include <errno.h>
@@ -620,6 +619,7 @@ __Tthr_mutex_trylock(pthread_mutex_t *mutex)
uint32_t id;
int ret, robust;
+ _thr_check_init();
ret = check_and_init_mutex(mutex, &m);
if (ret != 0)
return (ret);
diff --git a/lib/libthr/thread/thr_mutexattr.c b/lib/libthr/thread/thr_mutexattr.c
index 6d38f164df52..d78aad518ee8 100644
--- a/lib/libthr/thread/thr_mutexattr.c
+++ b/lib/libthr/thread/thr_mutexattr.c
@@ -59,7 +59,6 @@
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <string.h>
#include <stdlib.h>
diff --git a/lib/libthr/thread/thr_once.c b/lib/libthr/thread/thr_once.c
index 065781907771..89b76ee58c1e 100644
--- a/lib/libthr/thread/thr_once.c
+++ b/lib/libthr/thread/thr_once.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include "un-namespace.h"
diff --git a/lib/libthr/thread/thr_printf.c b/lib/libthr/thread/thr_printf.c
index 5304cc00c5c8..e1edffe5acb2 100644
--- a/lib/libthr/thread/thr_printf.c
+++ b/lib/libthr/thread/thr_printf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 3475029f8996..d7b889930365 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -37,10 +37,10 @@
*/
#include <sys/types.h>
#include <sys/time.h>
-#include <sys/cdefs.h>
#include <sys/queue.h>
#include <sys/param.h>
#include <sys/cpuset.h>
+#include <sys/exterrvar.h>
#include <machine/atomic.h>
#include <errno.h>
#include <limits.h>
@@ -261,7 +261,6 @@ struct pthread_atfork {
};
struct pthread_attr {
-#define pthread_attr_start_copy sched_policy
int sched_policy;
int sched_inherit;
int prio;
@@ -271,7 +270,6 @@ struct pthread_attr {
void *stackaddr_attr;
size_t stacksize_attr;
size_t guardsize_attr;
-#define pthread_attr_end_copy cpuset
cpuset_t *cpuset;
size_t cpusetsize;
};
@@ -565,8 +563,12 @@ struct pthread {
/* Deferred threads from pthread_cond_signal. */
unsigned int *defer_waiters[MAX_DEFER_WAITERS];
-#define _pthread_endzero wake_addr
+ /* rtld thread-local dlerror message and seen control */
+ char dlerror_msg[512];
+ int dlerror_seen;
+
+#define _pthread_endzero wake_addr
struct wake_addr *wake_addr;
#define WAKE_ADDR(td) ((td)->wake_addr)
@@ -576,9 +578,7 @@ struct pthread {
/* pthread_set/get_name_np */
char *name;
- /* rtld thread-local dlerror message and seen control */
- char dlerror_msg[512];
- int dlerror_seen;
+ struct uexterror uexterr;
};
#define THR_SHOULD_GC(thrd) \
@@ -779,6 +779,8 @@ extern struct pthread *_single_thread __hidden;
extern bool _thr_after_fork __hidden;
+extern int __thr_new_flags;
+
/*
* Function prototype definitions.
*/
@@ -843,6 +845,8 @@ void _thr_signal_postfork(void) __hidden;
void _thr_signal_postfork_child(void) __hidden;
void _thr_suspend_all_lock(struct pthread *) __hidden;
void _thr_suspend_all_unlock(struct pthread *) __hidden;
+void _thr_suspend_all_np(void) __hidden;
+void _thr_resume_all_np(void) __hidden;
void _thr_try_gc(struct pthread *, struct pthread *) __hidden;
int _rtp_to_schedparam(const struct rtprio *rtp, int *policy,
struct sched_param *param) __hidden;
@@ -867,8 +871,8 @@ int _pthread_mutexattr_setrobust(pthread_mutexattr_t * _Nonnull, int);
/* #include <fcntl.h> */
#ifdef _SYS_FCNTL_H_
#ifndef _LIBC_PRIVATE_H_
-int __sys_fcntl(int, int, ...);
-int __sys_openat(int, const char *, int, ...);
+int __sys_fcntl(int, int, intptr_t);
+int __sys_openat(int, const char *, int, int);
#endif /* _LIBC_PRIVATE_H_ */
#endif /* _SYS_FCNTL_H_ */
@@ -982,8 +986,6 @@ void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
void _thr_stack_fix_protection(struct pthread *thrd);
-void __pthread_distribute_static_tls(size_t offset, void *src, size_t len,
- size_t total_len);
int *__error_threaded(void) __hidden;
void __thr_interpose_libc(void) __hidden;
@@ -1015,6 +1017,7 @@ void __thr_pshared_destroy(void *key) __hidden;
void __thr_pshared_atfork_pre(void) __hidden;
void __thr_pshared_atfork_post(void) __hidden;
+void *__thr_aligned_alloc_offset(size_t align, size_t size, size_t offset);
void *__thr_calloc(size_t num, size_t size);
void __thr_free(void *cp);
void *__thr_malloc(size_t nbytes);
@@ -1105,6 +1108,8 @@ int __Tthr_mutex_lock(pthread_mutex_t *);
int __Tthr_mutex_trylock(pthread_mutex_t *);
bool __thr_get_main_stack_base(char **base);
bool __thr_get_main_stack_lim(size_t *lim);
+int _Tthr_sigqueue(pthread_t pthread, int sig, const union sigval value);
+void _thr_resolve_machdep(void);
__END_DECLS
__NULLABILITY_PRAGMA_POP
diff --git a/lib/libthr/thread/thr_pshared.c b/lib/libthr/thread/thr_pshared.c
index 42b1430907ad..d20d66e21ea3 100644
--- a/lib/libthr/thread/thr_pshared.c
+++ b/lib/libthr/thread/thr_pshared.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/queue.h>
diff --git a/lib/libthr/thread/thr_pspinlock.c b/lib/libthr/thread/thr_pspinlock.c
index 37f14d22909d..4820490ab6af 100644
--- a/lib/libthr/thread/thr_pspinlock.c
+++ b/lib/libthr/thread/thr_pspinlock.c
@@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
diff --git a/lib/libthr/thread/thr_resume_np.c b/lib/libthr/thread/thr_resume_np.c
index 6dac28ab1f4b..c5669fd4f0ff 100644
--- a/lib/libthr/thread/thr_resume_np.c
+++ b/lib/libthr/thread/thr_resume_np.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
@@ -39,7 +38,8 @@
#include "thr_private.h"
__weak_reference(_pthread_resume_np, pthread_resume_np);
-__weak_reference(_pthread_resume_all_np, pthread_resume_all_np);
+__weak_reference(_thr_resume_all_np, pthread_resume_all_np);
+__weak_reference(_thr_resume_all_np, _pthread_resume_all_np);
static void resume_common(struct pthread *thread);
@@ -60,7 +60,7 @@ _pthread_resume_np(pthread_t thread)
}
void
-_pthread_resume_all_np(void)
+_thr_resume_all_np(void)
{
struct pthread *curthread = _get_curthread();
struct pthread *thread;
diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c
index 9026abf941e2..3cfdfc548cf2 100644
--- a/lib/libthr/thread/thr_rtld.c
+++ b/lib/libthr/thread/thr_rtld.c
@@ -26,11 +26,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/*
* A lockless rwlock for rtld.
*/
-#include <sys/cdefs.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <link.h>
@@ -41,8 +39,7 @@
#include "rtld_lock.h"
#include "thr_private.h"
-#undef errno
-extern int errno;
+extern int __libsys_errno;
static int _thr_rtld_clr_flag(int);
static void *_thr_rtld_lock_create(void);
@@ -53,8 +50,11 @@ static int _thr_rtld_set_flag(int);
static void _thr_rtld_wlock_acquire(void *);
struct rtld_lock {
- struct urwlock lock;
- char _pad[CACHE_LINE_SIZE - sizeof(struct urwlock)];
+ struct urwlock lock;
+ struct pthread *wowner;
+ u_int rlocks;
+ char _pad[CACHE_LINE_SIZE - sizeof(struct urwlock) -
+ sizeof(struct pthread *) - sizeof(u_int)];
};
static struct rtld_lock lock_place[MAX_RTLD_LOCKS] __aligned(CACHE_LINE_SIZE);
@@ -98,14 +98,14 @@ _thr_rtld_lock_destroy(void *lock)
if (curthread != _thr_initial) \
errsave = curthread->error; \
else \
- errsave = errno; \
+ errsave = __libsys_errno; \
}
#define RESTORE_ERRNO() { \
if (curthread != _thr_initial) \
curthread->error = errsave; \
else \
- errno = errsave; \
+ __libsys_errno = errsave; \
}
static void
@@ -119,9 +119,13 @@ _thr_rtld_rlock_acquire(void *lock)
SAVE_ERRNO();
l = (struct rtld_lock *)lock;
- THR_CRITICAL_ENTER(curthread);
- while (_thr_rwlock_rdlock(&l->lock, 0, NULL) != 0)
- ;
+ if (l->wowner == curthread) {
+ l->rlocks++;
+ } else {
+ THR_CRITICAL_ENTER(curthread);
+ while (_thr_rwlock_rdlock(&l->lock, 0, NULL) != 0)
+ ;
+ }
curthread->rdlock_count++;
RESTORE_ERRNO();
}
@@ -140,6 +144,7 @@ _thr_rtld_wlock_acquire(void *lock)
THR_CRITICAL_ENTER(curthread);
while (_thr_rwlock_wrlock(&l->lock, NULL) != 0)
;
+ l->wowner = curthread;
RESTORE_ERRNO();
}
@@ -167,6 +172,14 @@ _thr_rtld_lock_release(void *lock)
l->lock.rw_blocked_readers = 0;
l->lock.rw_blocked_writers = 0;
}
+ if ((state & URWLOCK_WRITE_OWNER) != 0) {
+ if (l->rlocks > 0) {
+ l->rlocks--;
+ return;
+ } else {
+ l->wowner = NULL;
+ }
+ }
if (_thr_rwlock_unlock(&l->lock) == 0) {
if ((state & URWLOCK_WRITE_OWNER) == 0)
curthread->rdlock_count--;
@@ -222,22 +235,23 @@ _thr_rtld_init(void)
struct RtldLockInfo li;
struct pthread *curthread;
ucontext_t *uc;
- long dummy = -1;
int uc_len;
+ char dummy[2] = {};
curthread = _get_curthread();
/* force to resolve _umtx_op PLT */
- _umtx_op_err((struct umtx *)&dummy, UMTX_OP_WAKE, 1, 0, 0);
+ _umtx_op_err(&dummy, UMTX_OP_WAKE, 1, 0, 0);
/* force to resolve errno() PLT */
__error();
/* force to resolve memcpy PLT */
- memcpy(&dummy, &dummy, sizeof(dummy));
+ memcpy(&dummy[0], &dummy[1], 1);
mprotect(NULL, 0, 0);
_rtld_get_stack_prot();
+ thr_wake(-1);
li.rtli_version = RTLI_VERSION;
li.lock_create = _thr_rtld_lock_create;
@@ -277,6 +291,9 @@ _thr_rtld_init(void)
_thr_signal_block_check_fast();
_thr_signal_block_setup(curthread);
+ /* resolve machine depended functions, if any */
+ _thr_resolve_machdep();
+
uc_len = __getcontextx_size();
uc = alloca(uc_len);
getcontext(uc);
diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c
index f8d5fa4f673f..084181ba922a 100644
--- a/lib/libthr/thread/thr_rwlock.c
+++ b/lib/libthr/thread/thr_rwlock.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
@@ -60,7 +59,7 @@ __weak_reference(_pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock);
static int init_static(struct pthread *thread, pthread_rwlock_t *rwlock);
static int init_rwlock(pthread_rwlock_t *rwlock, pthread_rwlock_t *rwlock_out);
-static int __always_inline
+static __always_inline int
check_and_init_rwlock(pthread_rwlock_t *rwlock, pthread_rwlock_t *rwlock_out)
{
if (__predict_false(*rwlock == THR_PSHARED_PTR ||
diff --git a/lib/libthr/thread/thr_rwlockattr.c b/lib/libthr/thread/thr_rwlockattr.c
index 068ad7d3acbf..34bbbb20e611 100644
--- a/lib/libthr/thread/thr_rwlockattr.c
+++ b/lib/libthr/thread/thr_rwlockattr.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <stdlib.h>
diff --git a/lib/libthr/thread/thr_self.c b/lib/libthr/thread/thr_self.c
index f5b1ce8fdb98..cbdadb13ccc4 100644
--- a/lib/libthr/thread/thr_self.c
+++ b/lib/libthr/thread/thr_self.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include "un-namespace.h"
diff --git a/lib/libthr/thread/thr_sem.c b/lib/libthr/thread/thr_sem.c
index c7b5ac009a8c..76180604c183 100644
--- a/lib/libthr/thread/thr_sem.c
+++ b/lib/libthr/thread/thr_sem.c
@@ -30,7 +30,6 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/types.h>
#include <sys/queue.h>
diff --git a/lib/libthr/thread/thr_setprio.c b/lib/libthr/thread/thr_setprio.c
index 6ee60ffeb205..fddf664457bd 100644
--- a/lib/libthr/thread/thr_setprio.c
+++ b/lib/libthr/thread/thr_setprio.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include "un-namespace.h"
diff --git a/lib/libthr/thread/thr_setschedparam.c b/lib/libthr/thread/thr_setschedparam.c
index e3e4174c753b..49ec2ae7a7fd 100644
--- a/lib/libthr/thread/thr_setschedparam.c
+++ b/lib/libthr/thread/thr_setschedparam.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <errno.h>
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index e082f0601be1..2cd3de512d1c 100644
--- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/param.h>
#include <sys/auxv.h>
@@ -38,6 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
+#include <pthread_np.h>
#include "un-namespace.h"
#include "libc_private.h"
@@ -164,6 +164,24 @@ _thr_signal_block_setup(struct pthread *curthread)
__sys_sigfastblock(SIGFASTBLOCK_SETPTR, &curthread->fsigblock);
}
+void
+pthread_signals_block_np(void)
+{
+ struct pthread *curthread;
+
+ curthread = _get_curthread();
+ _thr_signal_block(curthread);
+}
+
+void
+pthread_signals_unblock_np(void)
+{
+ struct pthread *curthread;
+
+ curthread = _get_curthread();
+ _thr_signal_unblock(curthread);
+}
+
int
_thr_send_sig(struct pthread *thread, int sig)
{
@@ -186,8 +204,7 @@ thr_remove_thr_signals(const sigset_t *set, sigset_t *newset)
}
static void
-sigcancel_handler(int sig __unused,
- siginfo_t *info __unused, ucontext_t *ucp)
+sigcancel_handler(int sig __unused, siginfo_t *info __unused, ucontext_t *ucp)
{
struct pthread *curthread = _get_curthread();
int err;
@@ -248,7 +265,6 @@ static void
handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp)
{
struct pthread *curthread = _get_curthread();
- ucontext_t uc2;
__siginfohandler_t *sigfunc;
int cancel_point;
int cancel_async;
@@ -308,13 +324,11 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp)
curthread->cancel_point = cancel_point;
curthread->cancel_enable = cancel_enable;
- memcpy(&uc2, ucp, sizeof(uc2));
- SIGDELSET(uc2.uc_sigmask, SIGCANCEL);
+ SIGDELSET(ucp->uc_sigmask, SIGCANCEL);
/* reschedule cancellation */
- check_cancel(curthread, &uc2);
+ check_cancel(curthread, ucp);
errno = err;
- syscall(SYS_sigreturn, &uc2);
}
void
@@ -358,9 +372,11 @@ check_cancel(struct pthread *curthread, ucontext_t *ucp)
* on getting a signal before it agrees to return.
*/
if (curthread->cancel_point) {
- if (curthread->in_sigsuspend && ucp) {
- SIGADDSET(ucp->uc_sigmask, SIGCANCEL);
- curthread->unblock_sigcancel = 1;
+ if (curthread->in_sigsuspend) {
+ if (ucp != NULL) {
+ SIGADDSET(ucp->uc_sigmask, SIGCANCEL);
+ curthread->unblock_sigcancel = 1;
+ }
_thr_send_sig(curthread, SIGCANCEL);
} else
thr_wake(curthread->tid);
@@ -369,8 +385,8 @@ check_cancel(struct pthread *curthread, ucontext_t *ucp)
* asynchronous cancellation mode, act upon
* immediately.
*/
- _pthread_exit_mask(PTHREAD_CANCELED,
- ucp? &ucp->uc_sigmask : NULL);
+ _pthread_exit_mask(PTHREAD_CANCELED, ucp != NULL ?
+ &ucp->uc_sigmask : NULL);
}
}
@@ -401,6 +417,7 @@ check_deferred_signal(struct pthread *curthread)
/* remove signal */
curthread->deferred_siginfo.si_signo = 0;
handle_signal(&act, info.si_signo, &info, uc);
+ syscall(SYS_sigreturn, uc);
}
static void
@@ -408,9 +425,8 @@ check_suspend(struct pthread *curthread)
{
uint32_t cycle;
- if (__predict_true((curthread->flags &
- (THR_FLAGS_NEED_SUSPEND | THR_FLAGS_SUSPENDED))
- != THR_FLAGS_NEED_SUSPEND))
+ if (__predict_true((curthread->flags & (THR_FLAGS_NEED_SUSPEND |
+ THR_FLAGS_SUSPENDED)) != THR_FLAGS_NEED_SUSPEND))
return;
if (curthread == _single_thread)
return;
@@ -667,7 +683,7 @@ _thr_sigmask(int how, const sigset_t *set, sigset_t *oset)
}
int
-_sigsuspend(const sigset_t * set)
+_sigsuspend(const sigset_t *set)
{
sigset_t newset;
@@ -675,7 +691,7 @@ _sigsuspend(const sigset_t * set)
}
int
-__thr_sigsuspend(const sigset_t * set)
+__thr_sigsuspend(const sigset_t *set)
{
struct pthread *curthread;
sigset_t newset;
@@ -701,7 +717,7 @@ __thr_sigsuspend(const sigset_t * set)
int
_sigtimedwait(const sigset_t *set, siginfo_t *info,
- const struct timespec * timeout)
+ const struct timespec *timeout)
{
sigset_t newset;
@@ -716,7 +732,7 @@ _sigtimedwait(const sigset_t *set, siginfo_t *info,
*/
int
__thr_sigtimedwait(const sigset_t *set, siginfo_t *info,
- const struct timespec * timeout)
+ const struct timespec *timeout)
{
struct pthread *curthread = _get_curthread();
sigset_t newset;
diff --git a/lib/libthr/thread/thr_sigqueue.c b/lib/libthr/thread/thr_sigqueue.c
new file mode 100644
index 000000000000..6f7ad8c63bad
--- /dev/null
+++ b/lib/libthr/thread/thr_sigqueue.c
@@ -0,0 +1,79 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
+ * All rights reserved.
+ *
+ * Copyright 2024 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
+ *
+ * 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 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.
+ */
+
+#include "namespace.h"
+#include <errno.h>
+#include <signal.h>
+#include <pthread.h>
+#include "un-namespace.h"
+
+#include "thr_private.h"
+
+__weak_reference(_Tthr_sigqueue, _pthread_sigqueue);
+__weak_reference(_Tthr_sigqueue, pthread_sigqueue);
+
+int
+_Tthr_sigqueue(pthread_t pthread, int sig, const union sigval value)
+{
+ struct pthread *curthread;
+ int e, ret;
+
+ if (sig < 0 || sig > _SIG_MAXSIG)
+ return (EINVAL);
+
+ curthread = _get_curthread();
+ ret = 0;
+
+ if (curthread == pthread) {
+ if (sig > 0) {
+ e = sigqueue(pthread->tid, sig | __SIGQUEUE_TID,
+ value);
+ if (e == -1)
+ ret = errno;
+ }
+ } else if ((ret = _thr_find_thread(curthread, pthread,
+ 0)) == 0) {
+ if (sig > 0) {
+ e = sigqueue(pthread->tid, sig | __SIGQUEUE_TID,
+ value);
+ if (e == -1)
+ ret = errno;
+ }
+ THR_THREAD_UNLOCK(curthread, pthread);
+ }
+
+ return (ret);
+}
diff --git a/lib/libthr/thread/thr_single_np.c b/lib/libthr/thread/thr_single_np.c
index e772fb5d3bb7..3aa7adba954d 100644
--- a/lib/libthr/thread/thr_single_np.c
+++ b/lib/libthr/thread/thr_single_np.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include <pthread_np.h>
diff --git a/lib/libthr/thread/thr_sleepq.c b/lib/libthr/thread/thr_sleepq.c
index b3feef8c9381..9c680acd0ac0 100644
--- a/lib/libthr/thread/thr_sleepq.c
+++ b/lib/libthr/thread/thr_sleepq.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdlib.h>
#include "thr_private.h"
@@ -63,7 +62,7 @@ _sleepq_alloc(void)
{
struct sleepqueue *sq;
- sq = calloc(1, sizeof(struct sleepqueue));
+ sq = __thr_calloc(1, sizeof(struct sleepqueue));
TAILQ_INIT(&sq->sq_blocked);
SLIST_INIT(&sq->sq_freeq);
return (sq);
@@ -72,7 +71,7 @@ _sleepq_alloc(void)
void
_sleepq_free(struct sleepqueue *sq)
{
- free(sq);
+ __thr_free(sq);
}
void
diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c
index ee58bb37f6f7..44a124785085 100644
--- a/lib/libthr/thread/thr_spec.c
+++ b/lib/libthr/thread/thr_spec.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <sys/mman.h>
#include <signal.h>
diff --git a/lib/libthr/thread/thr_spinlock.c b/lib/libthr/thread/thr_spinlock.c
index 13744569b94f..bf3401c92780 100644
--- a/lib/libthr/thread/thr_spinlock.c
+++ b/lib/libthr/thread/thr_spinlock.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <pthread.h>
#include <libc_private.h>
diff --git a/lib/libthr/thread/thr_stack.c b/lib/libthr/thread/thr_stack.c
index 5e888bbfe9b6..d249bb5606fd 100644
--- a/lib/libthr/thread/thr_stack.c
+++ b/lib/libthr/thread/thr_stack.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/auxv.h>
#include <sys/mman.h>
@@ -127,10 +126,7 @@ static char *last_stack = NULL;
static inline size_t
round_up(size_t size)
{
- if (size % _thr_page_size != 0)
- size = ((size / _thr_page_size) + 1) *
- _thr_page_size;
- return size;
+ return (roundup2(size, _thr_page_size));
}
void
diff --git a/lib/libthr/thread/thr_suspend_np.c b/lib/libthr/thread/thr_suspend_np.c
index b594ea562480..cf4e9e8a96b1 100644
--- a/lib/libthr/thread/thr_suspend_np.c
+++ b/lib/libthr/thread/thr_suspend_np.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
@@ -42,7 +41,8 @@ static int suspend_common(struct pthread *, struct pthread *,
int);
__weak_reference(_pthread_suspend_np, pthread_suspend_np);
-__weak_reference(_pthread_suspend_all_np, pthread_suspend_all_np);
+__weak_reference(_thr_suspend_all_np, pthread_suspend_all_np);
+__weak_reference(_thr_suspend_all_np, _pthread_suspend_all_np);
/* Suspend a thread: */
int
@@ -102,7 +102,7 @@ _thr_suspend_all_unlock(struct pthread *curthread)
}
void
-_pthread_suspend_all_np(void)
+_thr_suspend_all_np(void)
{
struct pthread *curthread = _get_curthread();
struct pthread *thread;
diff --git a/lib/libthr/thread/thr_switch_np.c b/lib/libthr/thread/thr_switch_np.c
index cbf959f161e3..59a9a4c7e1a3 100644
--- a/lib/libthr/thread/thr_switch_np.c
+++ b/lib/libthr/thread/thr_switch_np.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <errno.h>
#include <pthread.h>
@@ -41,10 +40,13 @@
#include "thr_private.h"
-
__weak_reference(_pthread_switch_add_np, pthread_switch_add_np);
__weak_reference(_pthread_switch_delete_np, pthread_switch_delete_np);
+typedef void (*pthread_switch_routine_t)(pthread_t, pthread_t);
+int _pthread_switch_add_np(pthread_switch_routine_t routine);
+int _pthread_switch_delete_np(pthread_switch_routine_t routine);
+
int
_pthread_switch_add_np(pthread_switch_routine_t routine __unused)
{
diff --git a/lib/libthr/thread/thr_symbols.c b/lib/libthr/thread/thr_symbols.c
index 7d5adcbbfb0b..f2de1f777558 100644
--- a/lib/libthr/thread/thr_symbols.c
+++ b/lib/libthr/thread/thr_symbols.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <stddef.h>
#include <pthread.h>
diff --git a/lib/libthr/thread/thr_syscalls.c b/lib/libthr/thread/thr_syscalls.c
index d68ca60e5993..188374a30070 100644
--- a/lib/libthr/thread/thr_syscalls.c
+++ b/lib/libthr/thread/thr_syscalls.c
@@ -65,11 +65,10 @@
*
*/
-#include <sys/cdefs.h>
#include "namespace.h"
-#include <sys/types.h>
-#include <sys/mman.h>
#include <sys/param.h>
+#include <sys/exterrvar.h>
+#include <sys/mman.h>
#include <sys/select.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
@@ -189,22 +188,19 @@ __thr_connect(int fd, const struct sockaddr *name, socklen_t namelen)
* if it is canceled.
*/
static int
-__thr_fcntl(int fd, int cmd, ...)
+__thr_fcntl(int fd, int cmd, __intptr_t arg)
{
struct pthread *curthread;
int ret;
- va_list ap;
curthread = _get_curthread();
- va_start(ap, cmd);
if (cmd == F_OSETLKW || cmd == F_SETLKW) {
_thr_cancel_enter(curthread);
- ret = __sys_fcntl(fd, cmd, va_arg(ap, void *));
+ ret = __sys_fcntl(fd, cmd, arg);
_thr_cancel_leave(curthread, ret == -1);
} else {
- ret = __sys_fcntl(fd, cmd, va_arg(ap, void *));
+ ret = __sys_fcntl(fd, cmd, arg);
}
- va_end(ap);
return (ret);
}
@@ -295,23 +291,11 @@ __thr_nanosleep(const struct timespec *time_to_sleep,
* If the thread is canceled, file is not opened.
*/
static int
-__thr_openat(int fd, const char *path, int flags, ...)
+__thr_openat(int fd, const char *path, int flags, int mode)
{
struct pthread *curthread;
- int mode, ret;
- va_list ap;
+ int ret;
-
- /* Check if the file is being created: */
- if ((flags & O_CREAT) != 0) {
- /* Get the creation mode: */
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- } else {
- mode = 0;
- }
-
curthread = _get_curthread();
_thr_cancel_enter(curthread);
ret = __sys_openat(fd, path, flags, mode);
@@ -636,6 +620,15 @@ __thr_writev(int fd, const struct iovec *iov, int iovcnt)
return (ret);
}
+static int
+__thr_uexterr_gettext(char *buf, size_t bufsz)
+{
+ struct pthread *curthread;
+
+ curthread = _get_curthread();
+ return (__uexterr_format(&curthread->uexterr, buf, bufsz));
+}
+
void
__thr_interpose_libc(void)
{
@@ -644,6 +637,16 @@ __thr_interpose_libc(void)
#define SLOT(name) \
*(__libc_interposing_slot(INTERPOS_##name)) = \
(interpos_func_t)__thr_##name;
+ SLOT(system);
+ SLOT(tcdrain);
+ SLOT(spinlock);
+ SLOT(spinunlock);
+ SLOT(map_stacks_exec);
+#undef SLOT
+
+#define SLOT(name) \
+ *(__libc_interposing_slot(INTERPOS_##name)) = \
+ (interpos_func_t)__thr_##name;
SLOT(accept);
SLOT(accept4);
SLOT(aio_suspend);
@@ -672,20 +675,16 @@ __thr_interpose_libc(void)
SLOT(sigtimedwait);
SLOT(sigwaitinfo);
SLOT(swapcontext);
- SLOT(system);
- SLOT(tcdrain);
SLOT(wait4);
SLOT(write);
SLOT(writev);
- SLOT(spinlock);
- SLOT(spinunlock);
SLOT(kevent);
SLOT(wait6);
SLOT(ppoll);
- SLOT(map_stacks_exec);
SLOT(fdatasync);
SLOT(clock_nanosleep);
SLOT(pdfork);
+ SLOT(uexterr_gettext);
#undef SLOT
*(__libc_interposing_slot(
INTERPOS__pthread_mutex_init_calloc_cb)) =
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c
index 37b378e74405..bbc68d0e30c6 100644
--- a/lib/libthr/thread/thr_umtx.c
+++ b/lib/libthr/thread/thr_umtx.c
@@ -26,20 +26,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "thr_private.h"
#include "thr_umtx.h"
-#ifndef HAS__UMTX_OP_ERR
-int _umtx_op_err(void *obj, int op, u_long val, void *uaddr, void *uaddr2)
-{
-
- if (_umtx_op(obj, op, val, uaddr, uaddr2) == -1)
- return (errno);
- return (0);
-}
-#endif
-
void
_thr_umutex_init(struct umutex *mtx)
{
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h
index a56997871ed1..89f70e4ab14f 100644
--- a/lib/libthr/thread/thr_umtx.h
+++ b/lib/libthr/thread/thr_umtx.h
@@ -39,7 +39,6 @@
#endif
#define DEFAULT_URWLOCK {0,0,0,0,{0,0,0,0}}
-int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden;
int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden;
int __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id) __hidden;
int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
diff --git a/lib/libthr/thread/thr_yield.c b/lib/libthr/thread/thr_yield.c
index b391e69cabc1..057fc789de02 100644
--- a/lib/libthr/thread/thr_yield.c
+++ b/lib/libthr/thread/thr_yield.c
@@ -29,7 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "namespace.h"
#include <pthread.h>
#include <sched.h>
diff --git a/lib/libthread_db/Makefile b/lib/libthread_db/Makefile
index 8b2d835531d6..faef7051f46e 100644
--- a/lib/libthread_db/Makefile
+++ b/lib/libthread_db/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}
PACKAGE=lib${LIB}
diff --git a/lib/libthread_db/arch/aarch64/libpthread_md.c b/lib/libthread_db/arch/aarch64/libpthread_md.c
index 17f8345e596b..1ff08e2804fa 100644
--- a/lib/libthread_db/arch/aarch64/libpthread_md.c
+++ b/lib/libthread_db/arch/aarch64/libpthread_md.c
@@ -1,6 +1,5 @@
/*-
* Copyright (c) 2014-2015 The FreeBSD Foundation
- * All rights reserved.
*
* This software was developed by Andrew Turner under
* sponsorship from the FreeBSD Foundation.
@@ -27,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
#include <thread_db.h>
diff --git a/lib/libthread_db/arch/arm/libpthread_md.c b/lib/libthread_db/arch/arm/libpthread_md.c
index 9cb319eead4d..4a619ad8f39f 100644
--- a/lib/libthread_db/arch/arm/libpthread_md.c
+++ b/lib/libthread_db/arch/arm/libpthread_md.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
#include <thread_db.h>
diff --git a/lib/libthread_db/arch/i386/libpthread_md.c b/lib/libthread_db/arch/i386/libpthread_md.c
index b1d74d397d4a..317710567ed6 100644
--- a/lib/libthread_db/arch/i386/libpthread_md.c
+++ b/lib/libthread_db/arch/i386/libpthread_md.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/npx.h>
#include <string.h>
diff --git a/lib/libthread_db/arch/powerpc/libpthread_md.c b/lib/libthread_db/arch/powerpc/libpthread_md.c
index ba91703c690d..2a83549c5c79 100644
--- a/lib/libthread_db/arch/powerpc/libpthread_md.c
+++ b/lib/libthread_db/arch/powerpc/libpthread_md.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
#include <thread_db.h>
diff --git a/lib/libthread_db/arch/riscv/libpthread_md.c b/lib/libthread_db/arch/riscv/libpthread_md.c
index 4835e458b942..93f950c2fdaf 100644
--- a/lib/libthread_db/arch/riscv/libpthread_md.c
+++ b/lib/libthread_db/arch/riscv/libpthread_md.c
@@ -32,7 +32,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
#include <thread_db.h>
diff --git a/lib/libucl/Makefile b/lib/libucl/Makefile
index 98ec1f6993b6..d4ee3e599df4 100644
--- a/lib/libucl/Makefile
+++ b/lib/libucl/Makefile
@@ -1,4 +1,3 @@
-
LIBUCL_DIR= ${SRCTOP}/contrib/libucl
PACKAGE=lib${LIB}
diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile
index e37a285bb509..ab913f834bb3 100644
--- a/lib/libufs/Makefile
+++ b/lib/libufs/Makefile
@@ -1,8 +1,7 @@
-
-PACKAGE= ufs
+PACKAGE= libufs
LIB= ufs
SHLIBDIR?= /lib
-SHLIB_MAJOR= 7
+SHLIB_MAJOR= 8
SRCS= block.c cgroup.c gsb_crc32.c inode.c sblock.c type.c ffs_subr.c
SRCS+= ffs_tables.c
diff --git a/lib/libufs/block.c b/lib/libufs/block.c
index 20002fc4df1b..8bccc18ed3dd 100644
--- a/lib/libufs/block.c
+++ b/lib/libufs/block.c
@@ -27,7 +27,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/disk.h>
@@ -57,19 +56,10 @@ bread(struct uufsd *disk, ufs2_daddr_t blockno, void *data, size_t size)
ERROR(disk, NULL);
- p2 = data;
- /*
- * XXX: various disk controllers require alignment of our buffer
- * XXX: which is stricter than struct alignment.
- * XXX: Bounce the buffer if not 64 byte aligned.
- * XXX: this can be removed if/when the kernel is fixed
- */
- if (((intptr_t)data) & 0x3f) {
- p2 = malloc(size);
- if (p2 == NULL) {
- ERROR(disk, "allocate bounce buffer");
- goto fail;
- }
+ BUF_MALLOC(&p2, data, size);
+ if (p2 == NULL) {
+ ERROR(disk, "allocate bounce buffer");
+ goto fail;
}
cnt = pread(disk->d_fd, p2, size, (off_t)(blockno * disk->d_bsize));
if (cnt == -1) {
@@ -101,7 +91,7 @@ bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
{
ssize_t cnt;
int rv;
- void *p2 = NULL;
+ void *p2;
ERROR(disk, NULL);
@@ -110,24 +100,15 @@ bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
ERROR(disk, "failed to open disk for writing");
return (-1);
}
-
- /*
- * XXX: various disk controllers require alignment of our buffer
- * XXX: which is stricter than struct alignment.
- * XXX: Bounce the buffer if not 64 byte aligned.
- * XXX: this can be removed if/when the kernel is fixed
- */
- if (((intptr_t)data) & 0x3f) {
- p2 = malloc(size);
- if (p2 == NULL) {
- ERROR(disk, "allocate bounce buffer");
- return (-1);
- }
- memcpy(p2, data, size);
- data = p2;
+ BUF_MALLOC(&p2, data, size);
+ if (p2 == NULL) {
+ ERROR(disk, "allocate bounce buffer");
+ return (-1);
}
- cnt = pwrite(disk->d_fd, data, size, (off_t)(blockno * disk->d_bsize));
- if (p2 != NULL)
+ if (p2 != data)
+ memcpy(p2, data, size);
+ cnt = pwrite(disk->d_fd, p2, size, (off_t)(blockno * disk->d_bsize));
+ if (p2 != data)
free(p2);
if (cnt == -1) {
ERROR(disk, "write error to block device");
@@ -137,7 +118,6 @@ bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
ERROR(disk, "short write to block device");
return (-1);
}
-
return (cnt);
}
diff --git a/lib/libufs/cgroup.c b/lib/libufs/cgroup.c
index 5391157826c8..7c7ca0d242b4 100644
--- a/lib/libufs/cgroup.c
+++ b/lib/libufs/cgroup.c
@@ -27,7 +27,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/disklabel.h>
diff --git a/lib/libufs/inode.c b/lib/libufs/inode.c
index fe34fd45b815..863e71867daa 100644
--- a/lib/libufs/inode.c
+++ b/lib/libufs/inode.c
@@ -27,7 +27,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/disklabel.h>
@@ -44,6 +43,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#include <unistd.h>
#include <libufs.h>
@@ -54,6 +54,7 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum)
ino_t min, max;
caddr_t inoblock;
struct fs *fs;
+ struct timespec now;
ERROR(disk, NULL);
@@ -62,17 +63,13 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum)
ERROR(disk, "inode number out of range");
return (-1);
}
- inoblock = disk->d_inoblock;
+ inoblock = (caddr_t)&disk->d_inos[0];
min = disk->d_inomin;
max = disk->d_inomax;
- if (inoblock == NULL) {
- inoblock = malloc(fs->fs_bsize);
- if (inoblock == NULL) {
- ERROR(disk, "unable to allocate inode block");
- return (-1);
- }
- disk->d_inoblock = inoblock;
+ if (clock_gettime(CLOCK_REALTIME_FAST, &now) != 0) {
+ ERROR(disk, "cannot get current time of day");
+ return (-1);
}
if (inum >= min && inum < max)
goto gotit;
@@ -83,6 +80,8 @@ getinode(struct uufsd *disk, union dinodep *dp, ino_t inum)
gotit: switch (disk->d_ufs) {
case 1:
disk->d_dp.dp1 = &((struct ufs1_dinode *)inoblock)[inum - min];
+ if (ffs_oldfscompat_inode_read(fs, disk->d_dp, now.tv_sec))
+ putinode(disk);
if (dp != NULL)
*dp = disk->d_dp;
return (0);
@@ -90,8 +89,12 @@ gotit: switch (disk->d_ufs) {
disk->d_dp.dp2 = &((struct ufs2_dinode *)inoblock)[inum - min];
if (dp != NULL)
*dp = disk->d_dp;
- if (ffs_verify_dinode_ckhash(fs, disk->d_dp.dp2) == 0)
+ if (ffs_verify_dinode_ckhash(fs, disk->d_dp.dp2) == 0) {
+ if (ffs_oldfscompat_inode_read(fs, disk->d_dp,
+ now.tv_sec))
+ putinode(disk);
return (0);
+ }
ERROR(disk, "check-hash failed for inode read from disk");
return (-1);
default:
@@ -107,14 +110,10 @@ putinode(struct uufsd *disk)
struct fs *fs;
fs = &disk->d_fs;
- if (disk->d_inoblock == NULL) {
- ERROR(disk, "No inode block allocated");
- return (-1);
- }
if (disk->d_ufs == 2)
ffs_update_dinode_ckhash(fs, disk->d_dp.dp2);
if (bwrite(disk, fsbtodb(fs, ino_to_fsba(&disk->d_fs, disk->d_inomin)),
- disk->d_inoblock, disk->d_fs.fs_bsize) <= 0)
+ (caddr_t)&disk->d_inos[0], disk->d_fs.fs_bsize) <= 0)
return (-1);
return (0);
}
diff --git a/lib/libufs/libufs.3 b/lib/libufs/libufs.3
index 9547396249de..aa3386ad9771 100644
--- a/lib/libufs/libufs.3
+++ b/lib/libufs/libufs.3
@@ -70,7 +70,7 @@ to a string describing the error.
.Xr ufs_disk_fillout 3 ,
.Xr ufs_disk_fillout_blank 3 ,
.Xr ufs_disk_write 3 ,
-.Xr ffs 7
+.Xr ffs 4
.Sh HISTORY
The
.Xr libufs 3
diff --git a/lib/libufs/libufs.h b/lib/libufs/libufs.h
index 4c6242e9daef..bb92e082a875 100644
--- a/lib/libufs/libufs.h
+++ b/lib/libufs/libufs.h
@@ -29,53 +29,65 @@
#ifndef __LIBUFS_H__
#define __LIBUFS_H__
+#include <stdbool.h>
/*
- * libufs structures.
+ * Various disk controllers require their buffers to be aligned to the size
+ * of a cache line. The LIBUFS_BUFALIGN defines the required alignment size.
+ * The alignment must be a power of 2.
*/
-union dinodep {
- struct ufs1_dinode *dp1;
- struct ufs2_dinode *dp2;
-};
+#define LIBUFS_BUFALIGN 128
/*
* userland ufs disk.
*/
struct uufsd {
- const char *d_name; /* disk name */
- int d_ufs; /* decimal UFS version */
- int d_fd; /* raw device file descriptor */
- long d_bsize; /* device bsize */
- ufs2_daddr_t d_sblock; /* superblock location */
- struct fs_summary_info *d_si; /* Superblock summary info */
- caddr_t d_inoblock; /* inode block */
- uint32_t d_inomin; /* low ino, not ino_t for ABI compat */
- uint32_t d_inomax; /* high ino, not ino_t for ABI compat */
- union dinodep d_dp; /* pointer to currently active inode */
union {
struct fs d_fs; /* filesystem information */
- char d_sb[MAXBSIZE]; /* superblock as buffer */
- } d_sbunion;
+ char d_sb[SBLOCKSIZE]; /* superblock as buffer */
+ } d_sbunion __aligned(LIBUFS_BUFALIGN);
union {
struct cg d_cg; /* cylinder group */
char d_buf[MAXBSIZE]; /* cylinder group storage */
- } d_cgunion;
- int d_ccg; /* current cylinder group */
- int d_lcg; /* last cylinder group (in d_cg) */
+ } d_cgunion __aligned(LIBUFS_BUFALIGN);
+ union {
+ union dinodep d_ino[1]; /* inode block */
+ char d_inos[MAXBSIZE]; /* inode block as buffer */
+ } d_inosunion __aligned(LIBUFS_BUFALIGN);
+ const char *d_name; /* disk name */
const char *d_error; /* human readable disk error */
+ ufs2_daddr_t d_sblock; /* superblock location */
+ struct fs_summary_info *d_si; /* Superblock summary info */
+ union dinodep d_dp; /* pointer to currently active inode */
+ ino_t d_inomin; /* low ino */
+ ino_t d_inomax; /* high ino */
off_t d_sblockloc; /* where to look for the superblock */
- int d_lookupflags; /* flags to superblock lookup */
- int d_mine; /* internal flags */
+ int64_t d_bsize; /* device bsize */
+ int64_t d_lookupflags; /* flags to superblock lookup */
+ int64_t d_mine; /* internal flags */
+ int32_t d_ccg; /* current cylinder group */
+ int32_t d_ufs; /* decimal UFS version */
+ int32_t d_fd; /* raw device file descriptor */
+ int32_t d_lcg; /* last cylinder group (in d_cg) */
+};
+#define d_inos d_inosunion.d_inos
#define d_fs d_sbunion.d_fs
-#define d_sb d_sbunion.d_sb
#define d_cg d_cgunion.d_cg
-};
/*
* libufs macros (internal, non-exported).
*/
#ifdef _LIBUFS
/*
+ * Ensure that the buffer is aligned to the I/O subsystem requirements.
+ */
+#define BUF_MALLOC(newbufpp, data, size) { \
+ if (data != NULL && (((intptr_t)data) & (LIBUFS_BUFALIGN - 1)) == 0) \
+ *newbufpp = (void *)data; \
+ else \
+ *newbufpp = aligned_alloc(LIBUFS_BUFALIGN, size); \
+}
+/*
* Trace steps through libufs, to be used at entry and erroneous return.
*/
static inline void
@@ -109,6 +121,7 @@ void ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
void ffs_fragacct(struct fs *, int, int32_t [], int);
int ffs_isblock(struct fs *, u_char *, ufs1_daddr_t);
int ffs_isfreeblock(struct fs *, u_char *, ufs1_daddr_t);
+bool ffs_oldfscompat_inode_read(struct fs *, union dinodep, time_t);
int ffs_sbsearch(void *, struct fs **, int, char *,
int (*)(void *, off_t, void **, int));
void ffs_setblock(struct fs *, u_char *, ufs1_daddr_t);
diff --git a/lib/libufs/sblock.c b/lib/libufs/sblock.c
index 9f1d8a2485bd..09d478bfe71e 100644
--- a/lib/libufs/sblock.c
+++ b/lib/libufs/sblock.c
@@ -27,7 +27,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/disklabel.h>
@@ -228,7 +227,8 @@ use_pread(void *devfd, off_t loc, void **bufp, int size)
int fd;
fd = *(int *)devfd;
- if ((*bufp = malloc(size)) == NULL)
+ BUF_MALLOC(bufp, NULL, size);
+ if (*bufp == NULL)
return (ENOSPC);
if (pread(fd, *bufp, size, loc) != size)
return (EIO);
diff --git a/lib/libufs/type.c b/lib/libufs/type.c
index 1d0c4c0200eb..557e6cdead63 100644
--- a/lib/libufs/type.c
+++ b/lib/libufs/type.c
@@ -27,7 +27,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/disklabel.h>
@@ -61,10 +60,6 @@ ufs_disk_close(struct uufsd *disk)
ERROR(disk, NULL);
close(disk->d_fd);
disk->d_fd = -1;
- if (disk->d_inoblock != NULL) {
- free(disk->d_inoblock);
- disk->d_inoblock = NULL;
- }
if (disk->d_mine & MINE_NAME) {
free((char *)(uintptr_t)disk->d_name);
disk->d_name = NULL;
@@ -155,10 +150,16 @@ again: if ((ret = stat(name, &st)) < 0) {
return (-1);
}
+ if (((uintptr_t)disk & ~(LIBUFS_BUFALIGN - 1)) != (uintptr_t)disk) {
+ ERROR(disk, "uufsd structure must be aligned to "
+ "LIBUFS_BUFALIGN byte boundry, see ufs_disk_fillout(3)");
+ close(fd);
+ return (-1);
+ }
+
disk->d_bsize = 1;
disk->d_ccg = 0;
disk->d_fd = fd;
- disk->d_inoblock = NULL;
disk->d_inomin = 0;
disk->d_inomax = 0;
disk->d_lcg = 0;
diff --git a/lib/libufs/ufs_disk_close.3 b/lib/libufs/ufs_disk_close.3
index d0d93d05838c..f332a9bb5de9 100644
--- a/lib/libufs/ufs_disk_close.3
+++ b/lib/libufs/ufs_disk_close.3
@@ -9,7 +9,7 @@
.\"
.\" This file is in the public domain.
.\"
-.Dd June 4, 2003
+.Dd November 17, 2023
.Dt UFS_DISK_CLOSE 3
.Os
.Sh NAME
@@ -51,6 +51,13 @@ functions open a disk specified by
.Fa name
and populate the structure pointed to by
.Fa disk .
+The structure referenced by the
+.Fa disk
+pointer must be aligned to at least the alignment specified by
+.Dv LIBUFS_ALIGN
+that is defined in the
+.Lb libufs.h
+header file.
The disk is opened read-only.
The specified
.Fa name
diff --git a/lib/libugidfw/Makefile b/lib/libugidfw/Makefile
index e5a0b2e6cb21..bf3ecd04699e 100644
--- a/lib/libugidfw/Makefile
+++ b/lib/libugidfw/Makefile
@@ -1,4 +1,3 @@
-
LIB= ugidfw
SHLIB_MAJOR= 5
SRCS= ugidfw.c
diff --git a/lib/libulog/Makefile b/lib/libulog/Makefile
index 5c073ef1d6a8..af26b485bf18 100644
--- a/lib/libulog/Makefile
+++ b/lib/libulog/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?=/lib
.include <src.opts.mk>
@@ -29,8 +28,5 @@ SYMLINKS+=libulog.a ${LIBDIR}/libutempter.a
.if !defined(NO_PIC)
SYMLINKS+=libulog.so ${LIBDIR}/libutempter.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+=libulog_p.a ${LIBDIR}/libutempter_p.a
-.endif
.include <bsd.lib.mk>
diff --git a/lib/libulog/ulog_login.c b/lib/libulog/ulog_login.c
index dc08ac7d331d..103543458485 100644
--- a/lib/libulog/ulog_login.c
+++ b/lib/libulog/ulog_login.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/time.h>
#include <paths.h>
@@ -50,7 +49,7 @@ ulog_fill(struct utmpx *utx, const char *line)
utx->ut_pid = getpid();
gettimeofday(&utx->ut_tv, NULL);
- strncpy(utx->ut_line, line, sizeof utx->ut_line);
+ strlcpy(utx->ut_line, line, sizeof utx->ut_line);
SHA1_Init(&c);
SHA1_Update(&c, "libulog", 7);
@@ -67,9 +66,9 @@ ulog_login(const char *line, const char *user, const char *host)
ulog_fill(&utx, line);
utx.ut_type = USER_PROCESS;
- strncpy(utx.ut_user, user, sizeof utx.ut_user);
+ strlcpy(utx.ut_user, user, sizeof utx.ut_user);
if (host != NULL)
- strncpy(utx.ut_host, host, sizeof utx.ut_host);
+ strlcpy(utx.ut_host, host, sizeof utx.ut_host);
pututxline(&utx);
}
diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile
index e6f095a09d10..cdc965c20763 100644
--- a/lib/libunbound/Makefile
+++ b/lib/libunbound/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
# Vendor sources and generated files
LDNSDIR= ${SRCTOP}/contrib/ldns
@@ -24,8 +23,10 @@ SRCS= alloc.c as112.c authzone.c autotrust.c cachedb.c config_file.c \
msgreply.c net_help.c netevent.c outbound_list.c outside_network.c \
packed_rrset.c parse.c parseutil.c proxy_protocol.c \
random.c rbtree.c redis.c \
- regional.c respip.c rpz.c rrdef.c rrset.c rtt.c sbuffer.c slabhash.c \
- str2wire.c tcp_conn_limit.c timehist.c tube.c ub_event_pluggable.c \
+ regional.c respip.c rfc_1982.c rpz.c rrdef.c rrset.c rtt.c sbuffer.c \
+ siphash.c slabhash.c \
+ str2wire.c tcp_conn_limit.c timehist.c timeval_func.c \
+ tube.c ub_event_pluggable.c \
val_anchor.c val_kcache.c val_kentry.c val_neg.c val_nsec.c \
val_nsec3.c val_secalgo.c val_sigcrypt.c val_utils.c validator.c \
view.c winsock_event.c wire2str.c
diff --git a/lib/libunbound/config.h b/lib/libunbound/config.h
index 3b9d7dd1c7f9..a986bfc869a3 100644
--- a/lib/libunbound/config.h
+++ b/lib/libunbound/config.h
@@ -1,6 +1,9 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
+/* apply the fallthrough attribute. */
+#define ATTR_FALLTHROUGH __attribute__((fallthrough));
+
/* apply the noreturn attribute to a function that exits the program */
#define ATTR_NORETURN __attribute__((__noreturn__))
@@ -32,9 +35,6 @@
/* Deprecate RSA 1024 bit length, makes that an unsupported key */
/* #undef DEPRECATE_RSA_1024 */
-/* Deprecate RSA 1024 bit length, makes that an unsupported key */
-/* #undef DEPRECATE_RSA_1024 */
-
/* Define this to enable kernel based UDP source port randomization. */
/* #undef DISABLE_EXPLICIT_PORT_RANDOMISATION */
@@ -61,6 +61,9 @@
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
+/* Whether the C compiler accepts the "fallthrough" attribute */
+#define HAVE_ATTR_FALLTHROUGH 1
+
/* Whether the C compiler accepts the "format" attribute */
#define HAVE_ATTR_FORMAT 1
@@ -793,7 +796,7 @@
#define PACKAGE_NAME "unbound"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "unbound 1.17.1"
+#define PACKAGE_STRING "unbound 1.23.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "unbound"
@@ -802,7 +805,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.17.1"
+#define PACKAGE_VERSION "1.23.0"
/* default pidfile location */
#define PIDFILE "/var/unbound/unbound.pid"
@@ -825,7 +828,7 @@
#define ROOT_CERT_FILE "/var/unbound/icannbundle.pem"
/* version number for resource files */
-#define RSRC_PACKAGE_VERSION 1,17,1,0
+#define RSRC_PACKAGE_VERSION 1,23,0,0
/* Directory to chdir to */
#define RUN_DIR "/var/unbound"
@@ -1536,6 +1539,8 @@ void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
#define UNBOUND_DNS_OVER_TLS_PORT 853
/** default port for DNS over HTTPS traffic. */
#define UNBOUND_DNS_OVER_HTTPS_PORT 443
+/** default port for DNS over QUIC traffic. */
+#define UNBOUND_DNS_OVER_QUIC_PORT 853
/** default port for unbound control traffic, registered port with IANA,
ub-dns-control 8953/tcp unbound dns nameserver control */
#define UNBOUND_CONTROL_PORT 8953
diff --git a/lib/libusb/libusb-1.0.pc.in b/lib/libusb/libusb-1.0.pc.in
index 7dbf746e773e..3a2f27cc52b8 100644
--- a/lib/libusb/libusb-1.0.pc.in
+++ b/lib/libusb/libusb-1.0.pc.in
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libusb-1.0
Description: Library that abstracts ways to access USB devices (v1.0)
-Version: 1.0.13
+Version: 1.0.16
Libs: -L${libdir} -lusb
Cflags: -I${includedir}
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 43afa55380a8..9dc752f0fd7b 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January, 26, 2023
+.Dd July 9, 2025
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -106,6 +106,19 @@ Get the ASCII representation of the error given by the
argument.
This function does not return NULL.
.Pp
+.Ft int
+.Fn libusb_setlocale "const char *locale"
+Set locale for the error message when using
+.Fn libusb_strerror
+to
+.Ft locale .
+Note other
+.Nm
+implementations only support the first two bytes, that means
+.Ql en-US
+is equivalent to
+.Ql en-CA .
+.Pp
.Ft const char *
.Fn libusb_error_name "int code"
Get the ASCII representation of the error enum given by the
@@ -117,7 +130,7 @@ This function does not return NULL.
.Fn libusb_set_debug "libusb_context *ctx" "int level"
Set the debug level to
.Fa level .
-.Pp
+.Sh DEVICE HANDLING AND ENUMERATION
.Ft ssize_t
.Fn libusb_get_device_list "libusb_context *ctx" "libusb_device ***list"
Populate
@@ -220,6 +233,11 @@ Close a device handle.
Get the device contained by devh.
Returns NULL on error.
.Pp
+.Ft libusb_device *
+.Fn libusb_get_parent "libusb_device *dev"
+Get dev's parent device.
+Returns NULL if the device has no parent (i.e. is a root device).
+.Pp
.Ft int
.Fn libusb_get_configuration "libusb_device_handle *devh" "int *config"
Returns the value of the current configuration.
@@ -348,6 +366,23 @@ argument is non-zero the feature is enabled.
Else disabled.
Returns 0 on success and a LIBUSB_ERROR code on
failure.
+.Pp
+.Ft unsigned char *
+.Fn libusb_dev_mem_alloc "libusb_device_handle *devh"
+This function attempts to allocate a DMA memory block from the given
+.Fa devh
+so that we can enjoy the zero-copy transfer from kernel.
+This function is provided for compatibility and is currently unimplemented and always returns NULL.
+.Pp
+.Ft int
+.Fn libusb_dev_mem_free "libusb_device_handle *devh" "unsigned char *buffer" "size_t size"
+This function frees the DMA memory in
+.Fa devh
+from the given
+.Fa buffer
+with
+.Fa size .
+This function is unimplemented and always returns LIBUSB_ERROR_NOT_SUPPORTED.
.Sh USB DESCRIPTORS
.Ft int
.Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc"
@@ -757,6 +792,17 @@ argument can be either of LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED or LIBUSB_HOTPLUG_
.Ft void
.Fn libusb_hotplug_deregister_callback "libusb_context *ctx" "libusb_hotplug_callback_handle handle"
This function unregisters a hotplug filter.
+.Pp
+.Ft void
+.Fn libusb_free_pollfds "const struct libusb_pollfd **pollfds"
+This function releases the memory storage in
+.Fa pollfds ,
+and is safe to call when the argument is NULL.
+.Pp void *
+.Fn libusb_hotplug_get_user_data "struct libusb_context *ctx" "libusb_hotplug_callback_handle callback_handle"
+This function returns the user data from the opaque
+.Fa callback_handle ,
+or returns NULL if no matching handle is found.
.Sh LIBUSB VERSION 0.1 COMPATIBILITY
The library is also compliant with LibUSB version 0.1.12.
.Pp
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index 022b5562a819..1803ff637738 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -122,6 +122,7 @@ enum libusb_transfer_type {
LIBUSB_TRANSFER_TYPE_ISOCHRONOUS = 1,
LIBUSB_TRANSFER_TYPE_BULK = 2,
LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
+ LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
};
enum libusb_standard_request {
@@ -210,12 +211,15 @@ enum libusb_error {
LIBUSB_ERROR_OTHER = -99,
};
+#define LIBUSB_ERROR_COUNT 14
+
enum libusb_speed {
LIBUSB_SPEED_UNKNOWN = 0,
LIBUSB_SPEED_LOW = 1,
LIBUSB_SPEED_FULL = 2,
LIBUSB_SPEED_HIGH = 3,
LIBUSB_SPEED_SUPER = 4,
+ LIBUSB_SPEED_SUPER_PLUS = 5,
};
enum libusb_transfer_status {
@@ -242,17 +246,6 @@ enum libusb_log_level {
LIBUSB_LOG_LEVEL_DEBUG
};
-/* XXX */
-/* libusb_set_debug should take parameters from libusb_log_level
- * above according to
- * http://libusb.sourceforge.net/api-1.0/group__lib.html
- */
-enum libusb_debug_level {
- LIBUSB_DEBUG_NO=0,
- LIBUSB_DEBUG_FUNCTION=1,
- LIBUSB_DEBUG_TRANSFER=2,
-};
-
#define LIBUSB_HOTPLUG_MATCH_ANY -1
typedef enum {
@@ -417,7 +410,10 @@ typedef struct libusb_bos_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wTotalLength;
- uint8_t bNumDeviceCapabilities;
+#ifndef bNumDeviceCapabilities
+#define bNumDeviceCapabilities bNumDeviceCaps
+#endif
+ uint8_t bNumDeviceCaps;
struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap;
struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap;
struct libusb_bos_dev_capability_descriptor **dev_capability;
@@ -482,6 +478,7 @@ int libusb_init(libusb_context ** context);
int libusb_init_context(libusb_context **, const struct libusb_init_option [], int num_options);
void libusb_exit(struct libusb_context *ctx);
int libusb_has_capability(uint32_t capability);
+int libusb_setlocale(const char *locale);
/* Device handling and enumeration */
@@ -502,6 +499,7 @@ int libusb_open(libusb_device * dev, libusb_device_handle ** devh);
libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context * ctx, uint16_t vendor_id, uint16_t product_id);
void libusb_close(libusb_device_handle * devh);
libusb_device *libusb_get_device(libusb_device_handle * devh);
+libusb_device *libusb_get_parent(libusb_device * dev);
int libusb_get_configuration(libusb_device_handle * devh, int *config);
int libusb_set_configuration(libusb_device_handle * devh, int configuration);
int libusb_claim_interface(libusb_device_handle * devh, int interface_number);
@@ -516,6 +514,9 @@ int libusb_detach_kernel_driver(libusb_device_handle * devh, int interface);
int libusb_attach_kernel_driver(libusb_device_handle * devh, int interface);
int libusb_set_auto_detach_kernel_driver(libusb_device_handle *dev, int enable);
int libusb_set_interface_alt_setting(libusb_device_handle * devh, int interface_number, int alternate_setting);
+unsigned char *libusb_dev_mem_alloc(libusb_device_handle *devh);
+int libusb_dev_mem_free(libusb_device_handle *devh, unsigned char *buffer,
+ size_t size);
/* USB Descriptors */
@@ -576,7 +577,8 @@ int libusb_handle_events(libusb_context * ctx);
int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv);
int libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv);
void libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data);
-const struct libusb_pollfd **libusb_get_pollfds(libusb_context * ctx);
+const struct libusb_pollfd **libusb_get_pollfds(libusb_context *ctx);
+void libusb_free_pollfds(const struct libusb_pollfd **pollfds);
/* Synchronous device I/O */
@@ -596,6 +598,8 @@ typedef int (*libusb_hotplug_callback_fn)(libusb_context *ctx,
int libusb_hotplug_register_callback(libusb_context *ctx, libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, libusb_hotplug_callback_handle *handle);
void libusb_hotplug_deregister_callback(libusb_context *ctx, libusb_hotplug_callback_handle handle);
+void *libusb_hotplug_get_user_data(struct libusb_context *ctx,
+ libusb_hotplug_callback_handle callback_handle);
/* Streams support */
diff --git a/lib/libusb/libusb01.c b/lib/libusb/libusb01.c
index 7017016693af..f246e74353a6 100644
--- a/lib/libusb/libusb01.c
+++ b/lib/libusb/libusb01.c
@@ -130,6 +130,8 @@ usb_get_transfer_by_ep_no(usb_dev_handle * dev, uint8_t ep_no)
bufsize = 4096;
} else if (speed == LIBUSB20_SPEED_SUPER) {
bufsize = 65536;
+ } else if (speed == LIBUSB20_SPEED_SUPER_PLUS) {
+ bufsize = 131072;
} else {
bufsize = 16384;
}
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index 6d9c11910ea0..5c116b39ea17 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -3,6 +3,8 @@
*
* Copyright (c) 2009 Sylvestre Gallon. All rights reserved.
* Copyright (c) 2009-2023 Hans Petter Selasky
+ * Copyright (c) 2024 Aymeric Wibo
+ * Copyright (c) 2025 ShengYi Hung
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,15 +32,18 @@
#include LIBUSB_GLOBAL_INCLUDE_FILE
#else
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
#include <poll.h>
#include <pthread.h>
#include <signal.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
+#include <sys/eventfd.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
@@ -46,6 +51,7 @@
#endif
#define libusb_device_handle libusb20_device
+#define LIBUSB_LOG_BUFFER_SIZE 1024
#include "libusb20.h"
#include "libusb20_desc.h"
@@ -80,6 +86,52 @@ static const struct libusb_version libusb_version = {
.describe = "https://www.freebsd.org"
};
+static const struct libusb_language_context libusb_language_ctx[] = {
+ {
+ .lang_name = "en",
+ .err_strs = {
+ [-LIBUSB_SUCCESS] = "Success",
+ [-LIBUSB_ERROR_IO] = "I/O error",
+ [-LIBUSB_ERROR_INVALID_PARAM] = "Invalid parameter",
+ [-LIBUSB_ERROR_ACCESS] = "Permissions error",
+ [-LIBUSB_ERROR_NO_DEVICE] = "No device",
+ [-LIBUSB_ERROR_NOT_FOUND] = "Not found",
+ [-LIBUSB_ERROR_BUSY] = "Device busy",
+ [-LIBUSB_ERROR_TIMEOUT] = "Timeout",
+ [-LIBUSB_ERROR_OVERFLOW] = "Overflow",
+ [-LIBUSB_ERROR_PIPE] = "Pipe error",
+ [-LIBUSB_ERROR_INTERRUPTED] = "Interrupted",
+ [-LIBUSB_ERROR_NO_MEM] = "Out of memory",
+ [-LIBUSB_ERROR_NOT_SUPPORTED] ="Not supported",
+ [LIBUSB_ERROR_COUNT - 1] = "Other error",
+ [LIBUSB_ERROR_COUNT] = "Unknown error",
+ }
+ },
+ {
+ .lang_name = "zh",
+ .err_strs = {
+ [-LIBUSB_SUCCESS] = "æˆåŠŸ",
+ [-LIBUSB_ERROR_IO] = "I/O 錯誤",
+ [-LIBUSB_ERROR_INVALID_PARAM] = "ä¸åˆæ³•çš„åƒæ•¸",
+ [-LIBUSB_ERROR_ACCESS] = "權é™éŒ¯èª¤",
+ [-LIBUSB_ERROR_NO_DEVICE] = "è£ç½®ä¸å­˜åœ¨",
+ [-LIBUSB_ERROR_NOT_FOUND] = "ä¸å­˜åœ¨",
+ [-LIBUSB_ERROR_BUSY] = "è£ç½®å¿™ç¢Œä¸­",
+ [-LIBUSB_ERROR_TIMEOUT] = "逾時",
+ [-LIBUSB_ERROR_OVERFLOW] = "溢ä½",
+ [-LIBUSB_ERROR_PIPE] = "管é“錯誤",
+ [-LIBUSB_ERROR_INTERRUPTED] = "被中斷",
+ [-LIBUSB_ERROR_NO_MEM] = "記憶體ä¸è¶³",
+ [-LIBUSB_ERROR_NOT_SUPPORTED] ="䏿”¯æ´",
+ [LIBUSB_ERROR_COUNT - 1] = "其他錯誤",
+ [LIBUSB_ERROR_COUNT] = "未知錯誤",
+ }
+ },
+};
+
+static const struct libusb_language_context *default_language_context =
+ &libusb_language_ctx[0];
+
const struct libusb_version *
libusb_get_version(void)
{
@@ -118,17 +170,15 @@ libusb_set_nonblocking(int f)
void
libusb_interrupt_event_handler(libusb_context *ctx)
{
- uint8_t dummy;
int err;
if (ctx == NULL)
return;
- dummy = 0;
- err = write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy));
- if (err < (int)sizeof(dummy)) {
+ err = eventfd_write(ctx->event, 1);
+ if (err < 0) {
/* ignore error, if any */
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "Waking up event loop failed!");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_ERROR, "Waking up event loop failed!");
}
}
@@ -145,7 +195,6 @@ libusb_init_context(libusb_context **context,
struct libusb_context *ctx;
pthread_condattr_t attr;
char *debug, *ep;
- int ret;
if (num_options < 0)
return (LIBUSB_ERROR_INVALID_PARAM);
@@ -155,6 +204,7 @@ libusb_init_context(libusb_context **context,
return (LIBUSB_ERROR_INVALID_PARAM);
memset(ctx, 0, sizeof(*ctx));
+ ctx->devd_pipe = -1;
debug = getenv("LIBUSB_DEBUG");
if (debug != NULL) {
@@ -233,19 +283,16 @@ libusb_init_context(libusb_context **context,
ctx->ctx_handler = NO_THREAD;
ctx->hotplug_handler = NO_THREAD;
- ret = pipe(ctx->ctrl_pipe);
- if (ret < 0) {
+ ctx->event = eventfd(0, EFD_NONBLOCK);
+ if (ctx->event < 0) {
pthread_mutex_destroy(&ctx->ctx_lock);
pthread_mutex_destroy(&ctx->hotplug_lock);
pthread_cond_destroy(&ctx->ctx_cond);
free(ctx);
return (LIBUSB_ERROR_OTHER);
}
- /* set non-blocking mode on the control pipe to avoid deadlock */
- libusb_set_nonblocking(ctx->ctrl_pipe[0]);
- libusb_set_nonblocking(ctx->ctrl_pipe[1]);
- libusb10_add_pollfd(ctx, &ctx->ctx_poll, NULL, ctx->ctrl_pipe[0], POLLIN);
+ libusb10_add_pollfd(ctx, &ctx->ctx_poll, NULL, ctx->event, POLLIN);
pthread_mutex_lock(&default_context_lock);
if (usbi_default_context == NULL) {
@@ -256,7 +303,7 @@ libusb_init_context(libusb_context **context,
if (context)
*context = ctx;
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_init complete");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_INFO, "libusb_init complete");
signal(SIGPIPE, SIG_IGN);
@@ -280,6 +327,13 @@ libusb_exit(libusb_context *ctx)
HOTPLUG_LOCK(ctx);
td = ctx->hotplug_handler;
ctx->hotplug_handler = NO_THREAD;
+ if (ctx->usb_event_mode == usb_event_devd) {
+ close(ctx->devd_pipe);
+ ctx->devd_pipe = -1;
+ } else if (ctx->usb_event_mode == usb_event_netlink) {
+ close(ctx->ss.fd);
+ ctx->ss.fd = -1;
+ }
HOTPLUG_UNLOCK(ctx);
pthread_join(td, &ptr);
@@ -288,8 +342,7 @@ libusb_exit(libusb_context *ctx)
/* XXX cleanup devices */
libusb10_remove_pollfd(ctx, &ctx->ctx_poll);
- close(ctx->ctrl_pipe[0]);
- close(ctx->ctrl_pipe[1]);
+ close(ctx->event);
pthread_mutex_destroy(&ctx->ctx_lock);
pthread_mutex_destroy(&ctx->hotplug_lock);
pthread_cond_destroy(&ctx->ctx_cond);
@@ -309,9 +362,9 @@ ssize_t
libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
{
struct libusb20_backend *usb_backend;
- struct libusb20_device *pdev;
+ struct libusb20_device *pdev, *parent_dev;
struct libusb_device *dev;
- int i;
+ int i, j, k;
ctx = GET_CONTEXT(ctx);
@@ -363,6 +416,9 @@ libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
/* set context we belong to */
dev->ctx = ctx;
+ /* assume we have no parent by default */
+ dev->parent_dev = NULL;
+
/* link together the two structures */
dev->os_priv = pdev;
pdev->privLuData = dev;
@@ -372,6 +428,25 @@ libusb_get_device_list(libusb_context *ctx, libusb_device ***list)
}
(*list)[i] = NULL;
+ /* for each device, find its parent */
+ for (j = 0; j < i; j++) {
+ pdev = (*list)[j]->os_priv;
+
+ for (k = 0; k < i; k++) {
+ if (k == j)
+ continue;
+
+ parent_dev = (*list)[k]->os_priv;
+
+ if (parent_dev->bus_number != pdev->bus_number)
+ continue;
+ if (parent_dev->device_address == pdev->parent_address) {
+ (*list)[j]->parent_dev = libusb_ref_device((*list)[k]);
+ break;
+ }
+ }
+ }
+
libusb20_be_free(usb_backend);
return (i);
}
@@ -443,6 +518,8 @@ libusb_get_device_speed(libusb_device *dev)
return (LIBUSB_SPEED_HIGH);
case LIBUSB20_SPEED_SUPER:
return (LIBUSB_SPEED_SUPER);
+ case LIBUSB20_SPEED_SUPER_PLUS:
+ return (LIBUSB_SPEED_SUPER_PLUS);
default:
break;
}
@@ -536,6 +613,7 @@ libusb_unref_device(libusb_device *dev)
CTX_UNLOCK(dev->ctx);
if (dev->refcnt == 0) {
+ libusb_unref_device(dev->parent_dev);
libusb20_dev_free(dev->os_priv);
free(dev);
}
@@ -597,7 +675,7 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id,
if (ctx == NULL)
return (NULL); /* be NULL safe */
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_with_vid_pid enter");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_open_device_with_vid_pid enter");
if ((i = libusb_get_device_list(ctx, &devs)) < 0)
return (NULL);
@@ -621,7 +699,7 @@ libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id,
}
libusb_free_device_list(devs, 1);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_open_device_with_vid_pid leave");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_open_device_with_vid_pid leave");
return (pdev);
}
@@ -812,6 +890,12 @@ libusb_set_interface_alt_setting(struct libusb20_device *pdev,
return (err ? LIBUSB_ERROR_OTHER : 0);
}
+libusb_device *
+libusb_get_parent(libusb_device *dev)
+{
+ return (dev->parent_dev);
+}
+
static struct libusb20_transfer *
libusb10_get_transfer(struct libusb20_device *pdev,
uint8_t endpoint, uint8_t xfer_index)
@@ -1072,6 +1156,9 @@ libusb10_get_buffsize(struct libusb20_device *pdev, libusb_transfer *xfer)
case LIBUSB20_SPEED_SUPER:
ret = 65536;
break;
+ case LIBUSB20_SPEED_SUPER_PLUS:
+ ret = 131072;
+ break;
default:
ret = 16384;
break;
@@ -1443,6 +1530,7 @@ found:
libusb20_tr_set_callback(pxfer0, libusb10_isoc_proxy);
break;
case LIBUSB_TRANSFER_TYPE_BULK:
+ case LIBUSB_TRANSFER_TYPE_BULK_STREAM:
case LIBUSB_TRANSFER_TYPE_INTERRUPT:
libusb20_tr_set_callback(pxfer0, libusb10_bulk_intr_proxy);
break;
@@ -1499,7 +1587,7 @@ libusb_submit_transfer(struct libusb_transfer *uxfer)
dev = libusb_get_device(uxfer->dev_handle);
- DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer enter");
+ DPRINTF(dev->ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_submit_transfer enter");
sxfer = (struct libusb_super_transfer *)(
(uint8_t *)uxfer - sizeof(*sxfer));
@@ -1534,7 +1622,7 @@ libusb_submit_transfer(struct libusb_transfer *uxfer)
CTX_UNLOCK(dev->ctx);
- DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer leave %d", err);
+ DPRINTF(dev->ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_submit_transfer leave %d", err);
return (err);
}
@@ -1563,7 +1651,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
dev = libusb_get_device(devh);
- DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter");
+ DPRINTF(dev->ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_cancel_transfer enter");
sxfer = (struct libusb_super_transfer *)(
(uint8_t *)uxfer - sizeof(*sxfer));
@@ -1624,7 +1712,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
CTX_UNLOCK(dev->ctx);
- DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer leave");
+ DPRINTF(dev->ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_cancel_transfer leave");
return (retval);
}
@@ -1689,38 +1777,26 @@ libusb_le16_to_cpu(uint16_t x)
const char *
libusb_strerror(int code)
{
- switch (code) {
- case LIBUSB_SUCCESS:
- return ("Success");
- case LIBUSB_ERROR_IO:
- return ("I/O error");
- case LIBUSB_ERROR_INVALID_PARAM:
- return ("Invalid parameter");
- case LIBUSB_ERROR_ACCESS:
- return ("Permissions error");
- case LIBUSB_ERROR_NO_DEVICE:
- return ("No device");
- case LIBUSB_ERROR_NOT_FOUND:
- return ("Not found");
- case LIBUSB_ERROR_BUSY:
- return ("Device busy");
- case LIBUSB_ERROR_TIMEOUT:
- return ("Timeout");
- case LIBUSB_ERROR_OVERFLOW:
- return ("Overflow");
- case LIBUSB_ERROR_PIPE:
- return ("Pipe error");
- case LIBUSB_ERROR_INTERRUPTED:
- return ("Interrupted");
- case LIBUSB_ERROR_NO_MEM:
- return ("Out of memory");
- case LIBUSB_ERROR_NOT_SUPPORTED:
- return ("Not supported");
- case LIBUSB_ERROR_OTHER:
- return ("Other error");
- default:
- return ("Unknown error");
- }
+ int entry = -code;
+
+ if (code == LIBUSB_ERROR_OTHER)
+ entry = LIBUSB_ERROR_COUNT - 1;
+ /*
+ * The libusb upstream considers all code out of range a
+ * LIBUSB_ERROR_OTHER. In FreeBSD, it is a special unknown error. We
+ * preserve the FreeBSD implementation as I think it make sense.
+ */
+ if (entry < 0 || entry >= LIBUSB_ERROR_COUNT)
+ entry = LIBUSB_ERROR_COUNT;
+
+ /*
+ * Fall back to English one as the translation may be unimplemented
+ * when adding new error code.
+ */
+ if (default_language_context->err_strs[entry] == NULL)
+ return (libusb_language_ctx[0].err_strs[entry]);
+
+ return (default_language_context->err_strs[entry]);
}
const char *
@@ -1774,3 +1850,71 @@ libusb_has_capability(uint32_t capability)
return (0);
}
}
+
+void
+libusb_log_va_args(struct libusb_context *ctx, enum libusb_log_level level,
+ const char *fmt, ...)
+{
+ static const char *log_prefix[5] = {
+ [LIBUSB_LOG_LEVEL_ERROR] = "LIBUSB_ERROR",
+ [LIBUSB_LOG_LEVEL_WARNING] = "LIBUSB_WARN",
+ [LIBUSB_LOG_LEVEL_INFO] = "LIBUSB_INFO",
+ [LIBUSB_LOG_LEVEL_DEBUG] = "LIBUSB_DEBUG",
+ };
+
+ char buffer[LIBUSB_LOG_BUFFER_SIZE];
+ char new_fmt[LIBUSB_LOG_BUFFER_SIZE];
+ va_list args;
+
+ ctx = GET_CONTEXT(ctx);
+
+ if (ctx->debug < level)
+ return;
+
+ va_start(args, fmt);
+
+ snprintf(new_fmt, sizeof(new_fmt), "%s: %s\n", log_prefix[level], fmt);
+ vsnprintf(buffer, sizeof(buffer), new_fmt, args);
+ fputs(buffer, stdout);
+
+ va_end(args);
+}
+
+/*
+ * Upstream code actually recognizes the first two characters to identify a
+ * language. We do so to provide API compatibility with setlocale.
+ */
+int
+libusb_setlocale(const char *locale)
+{
+ size_t idx;
+ const char *lang;
+
+ if (locale == NULL || strlen(locale) < 2 ||
+ (locale[2] != '\0' && strchr("-_.", locale[2]) == NULL))
+ return (LIBUSB_ERROR_INVALID_PARAM);
+
+ for (idx = 0; idx < nitems(libusb_language_ctx); ++idx) {
+ lang = libusb_language_ctx[idx].lang_name;
+ if (tolower(locale[0]) == lang[0] &&
+ tolower(locale[1]) == lang[1]) {
+ default_language_context = &libusb_language_ctx[idx];
+ return (LIBUSB_SUCCESS);
+ }
+ }
+
+ return (LIBUSB_ERROR_INVALID_PARAM);
+}
+
+unsigned char *
+libusb_dev_mem_alloc(libusb_device_handle *devh)
+{
+ return (NULL);
+}
+
+int
+libusb_dev_mem_free(libusb_device_handle *devh, unsigned char *buffer,
+ size_t size)
+{
+ return (LIBUSB_ERROR_NOT_SUPPORTED);
+}
diff --git a/lib/libusb/libusb10.h b/lib/libusb/libusb10.h
index 544364386061..eced364ef857 100644
--- a/lib/libusb/libusb10.h
+++ b/lib/libusb/libusb10.h
@@ -29,7 +29,14 @@
#define __LIBUSB10_H__
#ifndef LIBUSB_GLOBAL_INCLUDE_FILE
+#include <sys/cdefs.h>
#include <sys/queue.h>
+#include <netlink/netlink.h>
+#include <netlink/netlink_generic.h>
+#include <netlink/netlink_snl.h>
+#include <netlink/netlink_snl_generic.h>
+#include <netlink/netlink_sysevent.h>
+
#endif
#define GET_CONTEXT(ctx) (((ctx) == NULL) ? usbi_default_context : (ctx))
@@ -40,24 +47,11 @@
#define HOTPLUG_LOCK(ctx) pthread_mutex_lock(&(ctx)->hotplug_lock)
#define HOTPLUG_UNLOCK(ctx) pthread_mutex_unlock(&(ctx)->hotplug_lock)
-#define DPRINTF(ctx, dbg, format, ...) do { \
- switch (dbg) { \
- case LIBUSB_DEBUG_FUNCTION: \
- if ((ctx)->debug & LIBUSB_DEBUG_FUNCTION) { \
- printf("LIBUSB_FUNCTION: " \
- format "\n", ## __VA_ARGS__); \
- } \
- break; \
- case LIBUSB_DEBUG_TRANSFER: \
- if ((ctx)->debug & LIBUSB_DEBUG_TRANSFER) { \
- printf("LIBUSB_TRANSFER: " \
- format "\n", ## __VA_ARGS__); \
- } \
- break; \
- default: \
- break; \
- } \
-} while (0)
+void libusb_log_va_args(struct libusb_context *ctx, enum libusb_log_level level,
+ const char *fmt, ...) __printflike(3, 4);
+
+#define DPRINTF(ctx, dbg, format, ...) \
+ libusb_log_va_args(ctx, dbg, format, ##__VA_ARGS__)
/* internal structures */
@@ -90,12 +84,22 @@ struct libusb_hotplug_callback_handle_struct {
TAILQ_HEAD(libusb_device_head, libusb_device);
+typedef enum {
+ usb_event_none,
+ usb_event_scan,
+ usb_event_devd,
+ usb_event_netlink
+} usb_event_mode_t;
+
struct libusb_context {
int debug;
int debug_fixed;
- int ctrl_pipe[2];
+ int event;
int tr_done_ref;
int tr_done_gen;
+ usb_event_mode_t usb_event_mode;
+ int devd_pipe;
+ struct snl_state ss;
pthread_mutex_t ctx_lock;
pthread_mutex_t hotplug_lock;
@@ -126,6 +130,7 @@ struct libusb_device {
struct libusb_super_pollfd dev_poll;
struct libusb_context *ctx;
+ struct libusb_device *parent_dev;
TAILQ_ENTRY(libusb_device) hotplug_entry;
@@ -134,6 +139,12 @@ struct libusb_device {
struct libusb20_device *os_priv;
};
+struct libusb_language_context {
+ const char *lang_name;
+ /* All error Plus 1 UNKNOWN */
+ const char *err_strs[LIBUSB_ERROR_COUNT + 1];
+};
+
extern struct libusb_context *usbi_default_context;
void libusb10_add_pollfd(libusb_context *ctx, struct libusb_super_pollfd *pollfd, struct libusb20_device *pdev, int fd, short events);
diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c
index 3e36009cbb3a..5f4c46740688 100644
--- a/lib/libusb/libusb10_desc.c
+++ b/lib/libusb/libusb10_desc.c
@@ -470,10 +470,11 @@ libusb_parse_bos_descriptor(const void *buf, int len,
ptr->bDescriptorType = dtype;
ptr->wTotalLength = ((const uint8_t *)buf)[2] |
(((const uint8_t *)buf)[3] << 8);
- ptr->bNumDeviceCapabilities = ((const uint8_t *)buf)[4];
+ ptr->bNumDeviceCaps = ((const uint8_t *)buf)[4];
ptr->usb_2_0_ext_cap = NULL;
ptr->ss_usb_cap = NULL;
- ptr->dev_capability = calloc(ptr->bNumDeviceCapabilities, sizeof(void *));
+ ptr->dev_capability = calloc(ptr->bNumDeviceCaps,
+ sizeof(void *));
if (ptr->dev_capability == NULL) {
free(ptr);
return (LIBUSB_ERROR_NO_MEM);
@@ -485,7 +486,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
if (dlen >= 3 &&
ptr != NULL &&
dtype == LIBUSB_DT_DEVICE_CAPABILITY) {
- if (index != ptr->bNumDeviceCapabilities) {
+ if (index != ptr->bNumDeviceCaps) {
ptr->dev_capability[index] = malloc(dlen);
if (ptr->dev_capability[index] == NULL) {
libusb_free_bos_descriptor(ptr);
@@ -542,7 +543,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
}
if (ptr != NULL) {
- ptr->bNumDeviceCapabilities = index;
+ ptr->bNumDeviceCaps = index;
return (0); /* success */
}
@@ -557,7 +558,7 @@ libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
if (bos == NULL)
return;
- for (i = 0; i != bos->bNumDeviceCapabilities; i++)
+ for (i = 0; i != bos->bNumDeviceCaps; i++)
free(bos->dev_capability[i]);
free(bos->dev_capability);
free(bos);
diff --git a/lib/libusb/libusb10_hotplug.c b/lib/libusb/libusb10_hotplug.c
index 9d00b1dbe5a0..9c46d4926bfa 100644
--- a/lib/libusb/libusb10_hotplug.c
+++ b/lib/libusb/libusb10_hotplug.c
@@ -23,6 +23,7 @@
* SUCH DAMAGE.
*/
+#include <netlink/netlink_snl_generic.h>
#ifdef LIBUSB_GLOBAL_INCLUDE_FILE
#include LIBUSB_GLOBAL_INCLUDE_FILE
#else
@@ -39,6 +40,10 @@
#include <sys/ioctl.h>
#include <sys/queue.h>
#include <sys/endian.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/module.h>
+#include <sys/linker.h>
#endif
#define libusb_device_handle libusb20_device
@@ -49,6 +54,110 @@
#include "libusb.h"
#include "libusb10.h"
+#define DEVDPIPE "/var/run/devd.seqpacket.pipe"
+#define DEVCTL_MAXBUF 1024
+
+typedef enum {
+ broken_event,
+ invalid_event,
+ valid_event,
+} event_t;
+
+static bool
+netlink_init(libusb_context *ctx)
+{
+ uint32_t group;
+
+ if (modfind("nlsysevent") < 0)
+ kldload("nlsysevent");
+ if (modfind("nlsysevent") < 0)
+ return (false);
+ if (!snl_init(&ctx->ss, NETLINK_GENERIC) || (group =
+ snl_get_genl_mcast_group(&ctx->ss, "nlsysevent", "USB", NULL)) == 0)
+ return (false);
+
+ if (setsockopt(ctx->ss.fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group,
+ sizeof(group)) == -1)
+ return (false);
+
+ ctx->usb_event_mode = usb_event_netlink;
+ return (true);
+}
+
+static bool
+devd_init(libusb_context *ctx)
+{
+ struct sockaddr_un devd_addr;
+
+ bzero(&devd_addr, sizeof(devd_addr));
+ if ((ctx->devd_pipe = socket(PF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK, 0)) < 0)
+ return (false);
+
+ devd_addr.sun_family = PF_LOCAL;
+ strlcpy(devd_addr.sun_path, DEVDPIPE, sizeof(devd_addr.sun_path));
+ if (connect(ctx->devd_pipe, (struct sockaddr *)&devd_addr,
+ sizeof(devd_addr)) == -1) {
+ close(ctx->devd_pipe);
+ ctx->devd_pipe = -1;
+ return (false);
+ }
+
+ ctx->usb_event_mode = usb_event_devd;
+ return (true);
+}
+
+struct nlevent {
+ const char *name;
+ const char *subsystem;
+ const char *type;
+ const char *data;
+};
+
+#define _OUT(_field) offsetof(struct nlevent, _field)
+static struct snl_attr_parser ap_nlevent_get[] = {
+ { .type = NLSE_ATTR_SYSTEM, .off = _OUT(name), .cb = snl_attr_get_string },
+ { .type = NLSE_ATTR_SUBSYSTEM, .off = _OUT(subsystem), .cb = snl_attr_get_string },
+ { .type = NLSE_ATTR_TYPE, .off = _OUT(type), .cb = snl_attr_get_string },
+ { .type = NLSE_ATTR_DATA, .off = _OUT(data), .cb = snl_attr_get_string },
+};
+#undef _OUT
+
+SNL_DECLARE_GENL_PARSER(nlevent_get_parser, ap_nlevent_get);
+
+static event_t
+verify_event_validity(libusb_context *ctx)
+{
+ if (ctx->usb_event_mode == usb_event_netlink) {
+ struct nlmsghdr *hdr;
+ struct nlevent ne;
+
+ hdr = snl_read_message(&ctx->ss);
+ if (hdr != NULL && hdr->nlmsg_type != NLMSG_ERROR) {
+ memset(&ne, 0, sizeof(ne));
+ if (!snl_parse_nlmsg(&ctx->ss, hdr, &nlevent_get_parser, &ne))
+ return (broken_event);
+ if (strcmp(ne.subsystem, "DEVICE") == 0)
+ return (valid_event);
+ return (invalid_event);
+ }
+ if (errno == EBADF)
+ return (broken_event);
+ return (invalid_event);
+ } else if (ctx->usb_event_mode == usb_event_devd) {
+ char buf[DEVCTL_MAXBUF];
+ ssize_t len;
+
+ len = read(ctx->devd_pipe, buf, sizeof(buf));
+ if (len == 0 || (len < 0 && errno != EWOULDBLOCK))
+ return (broken_event);
+ if (len > 0 && strstr(buf, "system=USB") != NULL &&
+ strstr(buf, "subsystem=DEVICE") != NULL)
+ return (valid_event);
+ return (invalid_event);
+ }
+ return (broken_event);
+}
+
static int
libusb_hotplug_equal(libusb_device *_adev, libusb_device *_bdev)
{
@@ -105,6 +214,7 @@ libusb_hotplug_enumerate(libusb_context *ctx, struct libusb_device_head *phead)
static void *
libusb_hotplug_scan(void *arg)
{
+ struct pollfd pfd;
struct libusb_device_head hotplug_devs;
libusb_hotplug_callback_handle acbh;
libusb_hotplug_callback_handle bcbh;
@@ -112,22 +222,71 @@ libusb_hotplug_scan(void *arg)
libusb_device *temp;
libusb_device *adev;
libusb_device *bdev;
- unsigned do_loop = 1;
+ int timeout = INFTIM;
+ int nfds;
- while (do_loop) {
- usleep(4000000);
+ memset(&pfd, 0, sizeof(pfd));
+ if (ctx->usb_event_mode == usb_event_devd) {
+ pfd.fd = ctx->devd_pipe;
+ pfd.events = POLLIN | POLLERR;
+ nfds = 1;
+ } else if (ctx->usb_event_mode == usb_event_netlink) {
+ pfd.fd = ctx->ss.fd;
+ pfd.events = POLLIN | POLLERR;
+ nfds = 1;
+ } else {
+ nfds = 0;
+ timeout = 4000;
+ }
+ for (;;) {
+ pfd.revents = 0;
+ if (poll(&pfd, nfds, timeout) > 0) {
+ switch (verify_event_validity(ctx)) {
+ case invalid_event:
+ continue;
+ case valid_event:
+ break;
+ case broken_event:
+ /* There are 2 cases for broken events:
+ * - devd and netlink sockets are not available
+ * anymore (devd restarted, nlsysevent unloaded)
+ * - libusb_exit has been called as it sets NO_THREAD
+ * this will result in exiting this loop and this thread
+ * immediately
+ */
+ nfds = 0;
+ if (ctx->usb_event_mode == usb_event_devd) {
+ if (ctx->devd_pipe != -1)
+ close(ctx->devd_pipe);
+ } else if (ctx->usb_event_mode == usb_event_netlink) {
+ if (ctx->ss.fd != -1)
+ close(ctx->ss.fd);
+ }
+ ctx->usb_event_mode = usb_event_scan;
+ timeout = 4000;
+ break;
+ }
+ }
HOTPLUG_LOCK(ctx);
+ if (ctx->hotplug_handler == NO_THREAD) {
+ while ((adev = TAILQ_FIRST(&ctx->hotplug_devs)) != NULL) {
+ TAILQ_REMOVE(&ctx->hotplug_devs, adev, hotplug_entry);
+ libusb_unref_device(adev);
+ }
+ if (ctx->usb_event_mode == usb_event_devd)
+ close(ctx->devd_pipe);
+ else if (ctx->usb_event_mode == usb_event_netlink)
+ close(ctx->ss.fd);
+ HOTPLUG_UNLOCK(ctx);
+ break;
+ }
TAILQ_INIT(&hotplug_devs);
- if (ctx->hotplug_handler != NO_THREAD) {
- if (libusb_hotplug_enumerate(ctx, &hotplug_devs) < 0) {
- HOTPLUG_UNLOCK(ctx);
- continue;
- }
- } else {
- do_loop = 0;
+ if (libusb_hotplug_enumerate(ctx, &hotplug_devs) < 0) {
+ HOTPLUG_UNLOCK(ctx);
+ continue;
}
/* figure out which devices are gone */
@@ -189,6 +348,13 @@ int libusb_hotplug_register_callback(libusb_context *ctx,
ctx = GET_CONTEXT(ctx);
+ if (ctx->usb_event_mode == usb_event_none) {
+ HOTPLUG_LOCK(ctx);
+ if (!netlink_init(ctx) && !devd_init(ctx))
+ ctx->usb_event_mode = usb_event_scan;
+ HOTPLUG_UNLOCK(ctx);
+ }
+
if (ctx == NULL || cb_fn == NULL || events == 0 ||
vendor_id < -1 || vendor_id > 0xffff ||
product_id < -1 || product_id > 0xffff ||
@@ -243,7 +409,26 @@ void libusb_hotplug_deregister_callback(libusb_context *ctx,
HOTPLUG_LOCK(ctx);
TAILQ_REMOVE(&ctx->hotplug_cbh, handle, entry);
+ libusb_interrupt_event_handler(ctx);
HOTPLUG_UNLOCK(ctx);
free(handle);
}
+
+void *
+libusb_hotplug_get_user_data(struct libusb_context *ctx,
+ libusb_hotplug_callback_handle callback_handle)
+{
+ libusb_hotplug_callback_handle handle;
+
+ ctx = GET_CONTEXT(ctx);
+
+ HOTPLUG_LOCK(ctx);
+ TAILQ_FOREACH(handle, &ctx->hotplug_cbh, entry) {
+ if (handle == callback_handle)
+ break;
+ }
+ HOTPLUG_UNLOCK(ctx);
+
+ return (handle);
+}
diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c
index 59bac60c4672..c99586ff650d 100644
--- a/lib/libusb/libusb10_io.c
+++ b/lib/libusb/libusb10_io.c
@@ -36,6 +36,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <sys/eventfd.h>
#include <sys/queue.h>
#include <sys/endian.h>
#endif
@@ -107,7 +108,7 @@ libusb10_handle_events_sub(struct libusb_context *ctx, struct timeval *tv)
int i;
int err;
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb10_handle_events_sub enter");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb10_handle_events_sub enter");
nfds = 0;
i = 0;
@@ -187,10 +188,8 @@ libusb10_handle_events_sub(struct libusb_context *ctx, struct timeval *tv)
CTX_LOCK(ctx);
} else {
- uint8_t dummy;
+ eventfd_read(fds[i].fd, &(eventfd_t){0});
- while (read(fds[i].fd, &dummy, 1) == 1)
- ;
}
}
@@ -231,6 +230,7 @@ do_done:
/* Wakeup other waiters */
pthread_cond_broadcast(&ctx->ctx_cond);
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb10_handle_events_sub complete");
return (err);
}
@@ -314,7 +314,7 @@ libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
int err;
ctx = GET_CONTEXT(ctx);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event enter");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_wait_for_event enter");
if (tv == NULL) {
pthread_cond_wait(&ctx->ctx_cond,
@@ -358,7 +358,7 @@ libusb_handle_events_timeout_completed(libusb_context *ctx,
ctx = GET_CONTEXT(ctx);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout_completed enter");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_handle_events_timeout_completed enter");
libusb_lock_events(ctx);
@@ -374,7 +374,7 @@ libusb_handle_events_timeout_completed(libusb_context *ctx,
libusb_unlock_events(ctx);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout_completed exit");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_handle_events_timeout_completed exit");
return (err);
}
@@ -523,7 +523,7 @@ libusb10_do_transfer_cb(struct libusb_transfer *transfer)
ctx = libusb10_get_context_by_device_handle(transfer->dev_handle);
- DPRINTF(ctx, LIBUSB_DEBUG_TRANSFER, "sync I/O done");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "sync I/O done");
pdone = transfer->user_data;
*pdone = 1;
@@ -613,12 +613,12 @@ libusb_bulk_transfer(libusb_device_handle *devh,
ctx = libusb10_get_context_by_device_handle(devh);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_bulk_transfer enter");
ret = libusb10_do_transfer(devh, endpoint, data, length, transferred,
timeout, LIBUSB_TRANSFER_TYPE_BULK);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer leave");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_bulk_transfer leave");
return (ret);
}
@@ -632,12 +632,12 @@ libusb_interrupt_transfer(libusb_device_handle *devh,
ctx = libusb10_get_context_by_device_handle(devh);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_interrupt_transfer enter");
ret = libusb10_do_transfer(devh, endpoint, data, length, transferred,
timeout, LIBUSB_TRANSFER_TYPE_INTERRUPT);
- DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer leave");
+ DPRINTF(ctx, LIBUSB_LOG_LEVEL_DEBUG, "libusb_interrupt_transfer leave");
return (ret);
}
@@ -781,6 +781,19 @@ libusb_fill_interrupt_transfer(struct libusb_transfer *transfer,
}
void
+libusb_fill_bulk_stream_transfer(struct libusb_transfer *transfer,
+ libusb_device_handle *dev_handle, unsigned char endpoint,
+ uint32_t stream_id, unsigned char *buffer, int length,
+ libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout)
+{
+ libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
+ length, callback, user_data, timeout);
+ transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
+
+ libusb_transfer_set_stream_id(transfer, stream_id);
+}
+
+void
libusb_fill_iso_transfer(struct libusb_transfer *transfer,
libusb_device_handle *devh, uint8_t endpoint, uint8_t *buf,
int length, int npacket, libusb_transfer_cb_fn callback,
@@ -842,3 +855,12 @@ libusb_transfer_get_stream_id(struct libusb_transfer *transfer)
/* get stream ID */
return (sxfer->stream_id);
}
+
+void
+libusb_free_pollfds(const struct libusb_pollfd **pollfds)
+{
+ if (pollfds == NULL)
+ return;
+
+ free(pollfds);
+}
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3
index 1d07db8f32a4..7854b0f8ed7e 100644
--- a/lib/libusb/libusb20.3
+++ b/lib/libusb/libusb20.3
@@ -858,6 +858,7 @@ returns the current speed of the given USB device.
.It LIBUSB20_SPEED_HIGH
.It LIBUSB20_SPEED_VARIABLE
.It LIBUSB20_SPEED_SUPER
+.It LIBUSB20_SPEED_SUPER_PLUS
.El
.
.Pp
diff --git a/lib/libusb/libusb20.h b/lib/libusb/libusb20.h
index 7bca2f7508c7..c132c58a9f69 100644
--- a/lib/libusb/libusb20.h
+++ b/lib/libusb/libusb20.h
@@ -159,6 +159,7 @@ enum {
LIBUSB20_SPEED_HIGH,
LIBUSB20_SPEED_VARIABLE,
LIBUSB20_SPEED_SUPER,
+ LIBUSB20_SPEED_SUPER_PLUS,
};
/** \ingroup misc
diff --git a/lib/libusb/libusb20_desc.h b/lib/libusb/libusb20_desc.h
index 017148a34b1c..0f7c9294ebc8 100644
--- a/lib/libusb/libusb20_desc.h
+++ b/lib/libusb/libusb20_desc.h
@@ -298,11 +298,15 @@ LIBUSB20_MAKE_STRUCT(LIBUSB20_USB_20_DEVCAP_DESC);
LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_USB_DEVCAP_DESC);
+#ifndef bNumDeviceCapabilities
+#define bNumDeviceCapabilities bNumDeviceCaps
+#endif
+
#define LIBUSB20_BOS_DESCRIPTOR(m,n) \
m(n, UINT8_T, bLength, ) \
m(n, UINT8_T, bDescriptorType, ) \
m(n, UINT16_T, wTotalLength, ) \
- m(n, UINT8_T, bNumDeviceCapabilities, ) \
+ m(n, UINT8_T, bNumDeviceCaps, ) \
LIBUSB20_MAKE_STRUCT(LIBUSB20_BOS_DESCRIPTOR);
diff --git a/lib/libusbhid/data.c b/lib/libusbhid/data.c
index cc7bf99f9c5d..0fc2f4e4d840 100644
--- a/lib/libusbhid/data.c
+++ b/lib/libusbhid/data.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <assert.h>
#include <stdlib.h>
diff --git a/lib/libusbhid/descr.c b/lib/libusbhid/descr.c
index aade28f28293..74491df53f6c 100644
--- a/lib/libusbhid/descr.c
+++ b/lib/libusbhid/descr.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libusbhid/descr_compat.c b/lib/libusbhid/descr_compat.c
index 03efe7bc945e..c861d2f4d253 100644
--- a/lib/libusbhid/descr_compat.c
+++ b/lib/libusbhid/descr_compat.c
@@ -32,7 +32,6 @@
*/
#ifdef HID_COMPAT7
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
diff --git a/lib/libusbhid/usage.c b/lib/libusbhid/usage.c
index 1a12ee35c91b..3233044b5bff 100644
--- a/lib/libusbhid/usage.c
+++ b/lib/libusbhid/usage.c
@@ -28,7 +28,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
diff --git a/lib/libusbhid/usbhid.h b/lib/libusbhid/usbhid.h
index 15d4f1613746..637fb3d846f7 100644
--- a/lib/libusbhid/usbhid.h
+++ b/lib/libusbhid/usbhid.h
@@ -29,6 +29,9 @@
*
*/
+#ifndef _USBHID_H_
+#define _USBHID_H_
+
#include <stdint.h>
typedef struct report_desc *report_desc_t;
@@ -111,3 +114,5 @@ int hid_set_report(int fd, enum hid_kind k,
unsigned char *data, unsigned int size);
__END_DECLS
+
+#endif /* !_USBHID_H_ */
diff --git a/lib/libutil++/Makefile b/lib/libutil++/Makefile
new file mode 100644
index 000000000000..df3074c2278e
--- /dev/null
+++ b/lib/libutil++/Makefile
@@ -0,0 +1,20 @@
+PACKAGE= lib${LIB}
+LIB_CXX= util++
+INTERNALLIB= true
+SHLIB_MAJOR= 1
+SRCS= stringf.cc
+
+MAN+= freebsd::FILE_up.3 \
+ freebsd::addrinfo_up.3 \
+ freebsd::fd_up.3 \
+ freebsd::malloc_up.3 \
+ freebsd::nvlist_up.3 \
+ freebsd::pidfile.3 \
+ freebsd::stringf.3
+
+.include <src.opts.mk>
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.lib.mk>
diff --git a/lib/libutil++/freebsd::FILE_up.3 b/lib/libutil++/freebsd::FILE_up.3
new file mode 100644
index 000000000000..ea63b1233b43
--- /dev/null
+++ b/lib/libutil++/freebsd::FILE_up.3
@@ -0,0 +1,41 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::FILE_UP 3
+.Os
+.Sh NAME
+.Nm freebsd::FILE_up
+.Nd std::unique_ptr specialization for stdio FILE objects
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Ft using FILE_up = std::unique_ptr<FILE, fclose_deleter>;
+.Sh DESCRIPTION
+This class is a specialization of
+.Vt std::unique_ptr
+for stdio
+.Vt FILE
+objects.
+When a
+.Vt FILE
+object managed by an instance of this class is disposed,
+.Xr fclose 3
+is invoked to dispose of the
+.Vt FILE
+object.
+.Sh EXAMPLES
+.Bd -literal -offset indent
+freebsd::FILE_up fp(fopen("foo.txt", "w"));
+if (!fp)
+ err(1, "fopen");
+fprintf(fp.get(), "hello\n");
+// `fp' is implicitly closed on destruction
+.Ed
+.Sh SEE ALSO
+.Xr fclose 3 ,
+.Xr fopen 3
diff --git a/lib/libutil++/freebsd::addrinfo_up.3 b/lib/libutil++/freebsd::addrinfo_up.3
new file mode 100644
index 000000000000..4845a76bfb61
--- /dev/null
+++ b/lib/libutil++/freebsd::addrinfo_up.3
@@ -0,0 +1,45 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::ADDRINFO_UP 3
+.Os
+.Sh NAME
+.Nm freebsd::addrinfo_up
+.Nd std::unique_ptr specialization for lists of socket addresses
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Ft using addrinfo_up = std::unique_ptr<addrinfo, freeaddrinfo_deleter>;
+.Sh DESCRIPTION
+This class is a specialization of
+.Vt std::unique_ptr
+for socket addresses returned by
+.Xr getaddrinfo 3 .
+When a list of socket addresses managed by an instance of this class is
+disposed,
+.Xr freeaddrinfo 3
+is invoked to dispose of the list.
+.Sh EXAMPLES
+.Bd -literal -offset indent
+freebsd::addrinfo_up
+resolve_address(const char *address, const char *port)
+{
+ struct addrinfo hints, *ai;
+ int error;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ error = getaddrinfo(address, port, &hints, &ai);
+ if (error != 0)
+ return {};
+ return freebsd::addrinfo_up(ai);
+}
+.Ed
+.Sh SEE ALSO
+.Xr getaddrinfo 3
diff --git a/lib/libutil++/freebsd::fd_up.3 b/lib/libutil++/freebsd::fd_up.3
new file mode 100644
index 000000000000..2ef2241a5c40
--- /dev/null
+++ b/lib/libutil++/freebsd::fd_up.3
@@ -0,0 +1,78 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::STRINGF 3
+.Os
+.Sh NAME
+.Nm freebsd::fd_up
+.Nd own a file descriptor
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Pp
+.Vt class freebsd::fd_up
+{
+.Bd -ragged -offset indent
+.Fn fd_up
+.Fn fd_up "int fd"
+.Fn fd_up "fd_up &&other"
+.Fn ~fd_up
+.Ft int
+.Fn get
+.Ft int
+.Fn release
+.Ft void
+.Fn reset "int newfd = -1"
+.Ft "fd_up &"
+.Fn operator= "fd_up &&other"
+.Ft "fd_up &"
+.Fn operator= "int fd"
+.Fn "explicit operator bool"
+.Fn "operator int"
+.Ed
+};
+.Sh DESCRIPTION
+Each instance of this class owns a file descriptor.
+This class is patterned on std::unique_ptr,
+but instead of owning a pointer to an object,
+this class owns a file descriptor.
+The currently-owned file descriptor is disposed by invoking
+.Xr close 2
+when an instance of this class is destroyed.
+The currently-owned file descriptor is also disposed if it is replaced by the
+.Fn reset
+method or assignment operators.
+.Pp
+The
+.Fn get
+method returns the current file descriptor value while retaining ownership.
+.Pp
+The
+.Fn release
+method relinquishes ownership of the current file descriptor and returns the
+value of the previously-owned file descriptor.
+.Pp
+The explicit
+.Vt bool
+conversion operator permits testing the validity of an object.
+The operator returns true if the instance owns a valid file descriptor.
+.Pp
+The implicit
+.Vt int
+conversion operator permits passing an instance of this class directly as
+an argument to existing functions which expect a file descriptor.
+.Sh EXAMPLES
+.Bd -literal -offset indent
+freebsd::fd_up fd(open("/dev/null", O_RDWR));
+if (!fd)
+ err(1, "open");
+write(fd, "test", 4);
+// `fd' is implicitly closed on destruction
+.Ed
+.Sh SEE ALSO
+.Xr close 2
diff --git a/lib/libutil++/freebsd::malloc_up.3 b/lib/libutil++/freebsd::malloc_up.3
new file mode 100644
index 000000000000..b18e7854213a
--- /dev/null
+++ b/lib/libutil++/freebsd::malloc_up.3
@@ -0,0 +1,50 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::MALLOC_UP 3
+.Os
+.Sh NAME
+.Nm freebsd::malloc_up
+.Nd std::unique_ptr specialization for objects allocated via malloc
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Ft using malloc_up = std::unique_ptr<T, free_deleter<T>>;
+.Sh DESCRIPTION
+This class is a specialization of
+.Vt std::unique_ptr
+which invokes
+.Xr free 3
+instead of
+.Fn delete
+when an object is disposed.
+While explicit calls to
+.Xr malloc 3
+should be avoided in C++ code,
+this class can be useful to manage an object allocated by an existing API
+which uses
+.Xr malloc 3
+internally such as
+.Xr scandir 3 .
+Note that the type of the underlying object must be used as the first
+template argument similar to std::unique_ptr.
+.Sh EXAMPLES
+This example uses
+.Xr strdup 3
+for simplicity,
+but new C++ code should generally not use
+.Xr strdup 3 :
+.Bd -literal -offset indent
+freebsd::malloc_up<char> my_string(strdup("foo"));
+// `mystring' is implicitly freed on destruction
+.Ed
+.Sh SEE ALSO
+.Xr free 3 ,
+.Xr malloc 3 ,
+.Xr scandir 3 ,
+.Xr strdup 3
diff --git a/lib/libutil++/freebsd::nvlist_up.3 b/lib/libutil++/freebsd::nvlist_up.3
new file mode 100644
index 000000000000..43f76cf3ead3
--- /dev/null
+++ b/lib/libutil++/freebsd::nvlist_up.3
@@ -0,0 +1,37 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::NVLIST_UP 3
+.Os
+.Sh NAME
+.Nm freebsd::nvlist_up
+.Nd std::unique_ptr specialization for name/value pairs
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Ft using nvlist_up = std::unique_ptr<nvlist, nvlist_deleter>;
+.Sh DESCRIPTION
+This class is a specialization of
+.Vt std::unique_ptr
+for
+.Vt nvlist_t
+objects.
+When an
+.Vt nvlist_t
+object managed by an instance of this class is disposed,
+.Xr nvlist_destroy 3
+is invoked to dispose of the object.
+.Sh EXAMPLES
+.Bd -literal -offset indent
+freebsd::nvlist_up nvl(nvlist_create(0));
+nvlist_add_number(nvl.get(), "answer", 42);
+nvlist_add_bool(nvl.get(), "valid", true);
+// `nvl' is implicitly destroyed
+.Ed
+.Sh SEE ALSO
+.Xr nvlist_destroy 3
diff --git a/lib/libutil++/freebsd::pidfile.3 b/lib/libutil++/freebsd::pidfile.3
new file mode 100644
index 000000000000..fb67253f5c02
--- /dev/null
+++ b/lib/libutil++/freebsd::pidfile.3
@@ -0,0 +1,110 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::STRINGF 3
+.Os
+.Sh NAME
+.Nm freebsd::pidfile
+.Nd own a PID file handle
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Pp
+.Vt class freebsd::pidfile
+{
+.Bd -ragged -offset indent
+.Fn pidfile
+.Fn pidfile "struct pidfh *pfh"
+.Fn pidfile "pidfile &&other"
+.Fn ~pidfile
+.Ft struct pidfh *
+.Fn release
+.Ft void
+.Fn reset "struct pidfh *newpfh = nullptr"
+.Ft int
+.Fn write
+.Ft int
+.Fn close
+.Ft int
+.Fn fileno
+.Ft "pidfile &"
+.Fn operator= "pidfile &&other"
+.Ft "pidfile &"
+.Fn operator= "struct pidfh *pfh"
+.Fn "explicit operator bool"
+.Ed
+};
+.Sh DESCRIPTION
+Each instance of this class owns a PID file handle created by
+.Xr pidfile_open 3 .
+This class is patterned on std::unique_ptr;
+however,
+rather than exporting the raw pointer via a
+.Fn get
+method,
+this class provides wrapper methods for each of the other
+.Xr pidfile 3
+functions.
+The currently-owned PID file is removed by invoking
+.Xr pidfile_remove 3
+when an instance of this class is destroyed.
+The currently-owned PID file is also removed if it is replaced by the
+.Fn reset
+method or assignment operators.
+.Pp
+The
+.Fn release
+method relinquishes ownership of the current PID file handle and returns the
+value of the previously-owned PID file handle.
+.Pp
+The
+.Fn write
+method writes out the PID of the current process to the PID file via
+.Xr pidfile_write 3 .
+.Pp
+The
+.Fn close
+method closes the current PID file without removing it via
+.Xr pidfile_close 3 .
+If the close succeeds, the PID file handle is no longer valid.
+.Pp
+The
+.Fn fileno
+method returns the underlying file descriptor for the current PID file via
+.Xr pidfile_fileno 3 .
+.Pp
+The explicit
+.Vt bool
+conversion operator permits testing the validity of an object.
+The operator returns true if the instance owns a valid PID file handle.
+.Sh EXAMPLES
+.Bd -literal -offset indent
+int
+main()
+{
+ freebsd::pidfile pf(pidfile_open("/var/run/daemon.pid",
+ 0600, NULL));
+ if (!pf)
+ err(1, "pidfile_open");
+
+ if (daemon(0, 0) == -1) {
+ warn("daemon");
+ return 1;
+ }
+
+ pf->write();
+
+ for (;;) {
+ /* Do Work */
+ }
+
+ return 0;
+}
+.Ed
+.Sh SEE ALSO
+.Xr pidfile 3
diff --git a/lib/libutil++/freebsd::stringf.3 b/lib/libutil++/freebsd::stringf.3
new file mode 100644
index 000000000000..341fedef4343
--- /dev/null
+++ b/lib/libutil++/freebsd::stringf.3
@@ -0,0 +1,48 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2025 Chelsio Communications, Inc.
+.\" Written by: John Baldwin <jhb@FreeBSD.org>
+.\"
+.Dd July 31, 2025
+.Dt FREEBSD::STRINGF 3
+.Os
+.Sh NAME
+.Nm freebsd::stringf
+.Nd build a std::string using stdio formatting
+.Sh LIBRARY
+.Lb libutil++
+.Sh SYNOPSIS
+.In libutil++.hh
+.Ft std::string
+.Fn freebsd::stringf "const char *fmt" "..."
+.Ft std::string
+.Fn freebsd::stringf "const char *fmt" "va_list ap"
+.Sh DESCRIPTION
+These functions construct a
+.Vt std::string
+object containing a formatted string.
+The output of the string is dictated by the
+.Fa fmt
+argument and additional arguments using the same conventions documented in
+.Xr printf 3 .
+The first form provides functionality similar to
+.Xr asprintf 3
+and the second form is similar to
+.Xr vasprintf 3 .
+.Sh RETURN VALUES
+These functions return a std::string object.
+.Sh EXCEPTIONS
+These functions may throw one of the following exceptions:
+.Bl -tag -width Er
+.It Bq Er std::bad_alloc
+Failed to allocate memory.
+.It Bq Er std::length_error
+The result would exceeed the maximum possible string size.
+.El
+.Sh EXAMPLES
+.Bd -literal -offset indent
+std::string s = freebsd::stringf("hello %s", "world");
+.Ed
+.Sh SEE ALSO
+.Xr asprintf 3
diff --git a/lib/libutil++/libutil++.hh b/lib/libutil++/libutil++.hh
new file mode 100644
index 000000000000..ecf737f2fcb0
--- /dev/null
+++ b/lib/libutil++/libutil++.hh
@@ -0,0 +1,230 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#ifndef __LIBUTILPP_HH__
+#define __LIBUTILPP_HH__
+
+#include <sys/nv.h>
+#include <libutil.h>
+#include <netdb.h>
+#include <unistd.h>
+
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <memory>
+
+namespace freebsd {
+ /*
+ * FILE_up is a std::unique_ptr<> for FILE objects which uses
+ * fclose() to destroy the wrapped pointer.
+ */
+ struct fclose_deleter {
+ void operator() (std::FILE *fp) const
+ {
+ std::fclose(fp);
+ }
+ };
+
+ using FILE_up = std::unique_ptr<std::FILE, fclose_deleter>;
+
+ /*
+ * addrinfo_up is a std::unique_ptr<> which uses
+ * freeaddrinfo() to destroy the wrapped pointer. It is
+ * intended to wrap arrays allocated by getaddrinfo().
+ */
+ struct freeaddrinfo_deleter {
+ void operator() (struct addrinfo *ai) const
+ {
+ freeaddrinfo(ai);
+ }
+ };
+
+ using addrinfo_up = std::unique_ptr<addrinfo, freeaddrinfo_deleter>;
+
+ /*
+ * This class is intended to function similar to unique_ptr<>,
+ * but it contains a file descriptor rather than a pointer to
+ * an object. On destruction the descriptor is closed via
+ * close(2).
+ *
+ * Similar to unique_ptr<>, release() returns ownership of the
+ * file descriptor to the caller. reset() closes the current
+ * file descriptor and takes ownership of a new one. A move
+ * constructor permits ownership to be transferred via
+ * std::move(). An integer file descriptor can be assigned
+ * directly which is equivalent to calling reset().
+ *
+ * An explicit bool conversion operator permits testing this
+ * class in logical expressions. It returns true if it
+ * contains a valid descriptor.
+ *
+ * An implicit int conversion operator returns the underlying
+ * file descriptor allowing objects of this type to be passed
+ * directly to APIs such as connect(), listen(), etc.
+ */
+ class fd_up {
+ public:
+ fd_up() : fd(-1) {}
+ fd_up(int fd) : fd(fd) {}
+ fd_up(fd_up &&other) : fd(other.release()) {}
+ fd_up(fd_up const &) = delete;
+
+ ~fd_up() { reset(); }
+
+ int get() const { return (fd); }
+
+ int release()
+ {
+ int oldfd = fd;
+
+ fd = -1;
+ return (oldfd);
+ }
+
+ void reset(int newfd = -1)
+ {
+ if (fd >= 0)
+ close(fd);
+ fd = newfd;
+ }
+
+ fd_up &operator=(fd_up &&other) noexcept
+ {
+ if (this == &other)
+ return *this;
+
+ reset(other.release());
+ return *this;
+ }
+
+ fd_up &operator=(fd_up const &) = delete;
+
+ fd_up &operator=(int newfd)
+ {
+ reset(newfd);
+ return *this;
+ }
+
+ explicit operator bool() const { return fd >= 0; }
+ operator int() const { return fd; }
+ private:
+ int fd;
+ };
+
+ /*
+ * malloc_up<T> is a std::unique_ptr<> which uses free() to
+ * destroy the wrapped pointer. This can be used to wrap
+ * pointers allocated implicitly by malloc() such as those
+ * returned by strdup().
+ */
+ template <class T>
+ struct free_deleter {
+ void operator() (T *p) const
+ {
+ std::free(p);
+ }
+ };
+
+ template <class T>
+ using malloc_up = std::unique_ptr<T, free_deleter<T>>;
+
+ /*
+ * nvlist_up is a std::unique_ptr<> for nvlist_t objects which
+ * uses nvlist_destroy() to destroy the wrapped pointer.
+ */
+ struct nvlist_deleter {
+ void operator() (nvlist_t *nvl) const
+ {
+ nvlist_destroy(nvl);
+ }
+ };
+
+ using nvlist_up = std::unique_ptr<nvlist_t, nvlist_deleter>;
+
+ /*
+ * A wrapper class for the pidfile_* API. The destructor
+ * calls pidfile_remove() when an object is destroyed. This
+ * class is similar to std::unique_ptr<> in that it retains
+ * exclusive ownership of the pidfh object.
+ *
+ * In addition to release() and reset methods(), write(),
+ * close(), and fileno() methods are provided as wrappers for
+ * pidfile_*.
+ */
+ class pidfile {
+ public:
+ pidfile() = default;
+ pidfile(struct pidfh *pfh) : pfh(pfh) {}
+ pidfile(pidfile &&other) : pfh(other.release()) {}
+ pidfile(pidfile const &) = delete;
+
+ ~pidfile() { reset(); }
+
+ struct pidfh *release()
+ {
+ struct pidfh *oldpfh = pfh;
+
+ pfh = nullptr;
+ return (oldpfh);
+ }
+
+ void reset(struct pidfh *newpfh = nullptr)
+ {
+ if (pfh != nullptr)
+ pidfile_remove(pfh);
+ pfh = newpfh;
+ }
+
+ int write()
+ {
+ return (pidfile_write(pfh));
+ }
+
+ int close()
+ {
+ int rv = pidfile_close(pfh);
+ if (rv == 0)
+ pfh = nullptr;
+ return (rv);
+ }
+
+ int fileno()
+ {
+ return (pidfile_fileno(pfh));
+ }
+
+ pidfile &operator=(pidfile &&other) noexcept
+ {
+ if (this == &other)
+ return *this;
+ reset(other.release());
+ return *this;
+ }
+
+ pidfile &operator=(pidfile const &) = delete;
+
+ pidfile &operator=(struct pidfh *newpfh)
+ {
+ reset(newpfh);
+ return *this;
+ }
+
+ explicit operator bool() const { return pfh != nullptr; }
+ private:
+ struct pidfh *pfh = nullptr;
+ };
+
+ /*
+ * Returns a std::string containing the same output as
+ * sprintf(). Throws std::bad_alloc if an error occurs.
+ */
+ std::string stringf(const char *fmt, ...) __printflike(1, 2);
+ std::string stringf(const char *fmt, std::va_list ap);
+}
+
+#endif /* !__LIBUTILPP_HH__ */
diff --git a/lib/libutil++/stringf.cc b/lib/libutil++/stringf.cc
new file mode 100644
index 000000000000..8c24167d70ac
--- /dev/null
+++ b/lib/libutil++/stringf.cc
@@ -0,0 +1,57 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <cstdarg>
+#include <cstdio>
+#include <string>
+
+#include "libutil++.hh"
+
+static int
+stringf_write(void *cookie, const char *buf, int len)
+{
+ std::string *str = reinterpret_cast<std::string *>(cookie);
+ try {
+ str->append(buf, len);
+ } catch (std::bad_alloc) {
+ errno = ENOMEM;
+ return (-1);
+ } catch (std::length_error) {
+ errno = EFBIG;
+ return (-1);
+ }
+ return (len);
+}
+
+std::string
+freebsd::stringf(const char *fmt, va_list ap)
+{
+ std::string str;
+ freebsd::FILE_up fp(fwopen(reinterpret_cast<void *>(&str),
+ stringf_write));
+
+ vfprintf(fp.get(), fmt, ap);
+
+ if (ferror(fp.get()))
+ throw std::bad_alloc();
+ fp.reset(nullptr);
+
+ return str;
+}
+
+std::string
+freebsd::stringf(const char *fmt, ...)
+{
+ std::va_list ap;
+ std::string str;
+
+ va_start(ap, fmt);
+ str = freebsd::stringf(fmt, ap);
+ va_end(ap);
+
+ return str;
+}
diff --git a/lib/libutil++/tests/Makefile b/lib/libutil++/tests/Makefile
new file mode 100644
index 000000000000..e7720d122f36
--- /dev/null
+++ b/lib/libutil++/tests/Makefile
@@ -0,0 +1,12 @@
+PACKAGE= tests
+
+ATF_TESTS_CXX+= pidfile_test
+ATF_TESTS_CXX+= stringf_test
+ATF_TESTS_CXX+= up_test
+
+CFLAGS+= -I${SRCTOP}/lib/libutil++
+LIBADD+= util++
+
+LIBADD.pidfile_test+= util
+
+.include <bsd.test.mk>
diff --git a/lib/libutil++/tests/pidfile_test.cc b/lib/libutil++/tests/pidfile_test.cc
new file mode 100644
index 000000000000..067f10e8fab8
--- /dev/null
+++ b/lib/libutil++/tests/pidfile_test.cc
@@ -0,0 +1,44 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <atf-c++.hpp>
+#include <sys/stat.h>
+#include <libutil.h>
+
+#include <libutil++.hh>
+
+ATF_TEST_CASE_WITHOUT_HEAD(basic);
+ATF_TEST_CASE_BODY(basic)
+{
+ pid_t other;
+ struct pidfh *pfh = pidfile_open("test_pidfile", 0600, &other);
+ ATF_REQUIRE(pfh != nullptr);
+ ATF_REQUIRE(pidfile_fileno(pfh) >= 0);
+
+ struct stat sb;
+ ATF_REQUIRE(fstat(pidfile_fileno(pfh), &sb) == 0);
+ ATF_REQUIRE_EQ(0, sb.st_size);
+
+ freebsd::pidfile pf(pfh);
+ ATF_REQUIRE_EQ(pidfile_fileno(pfh), pf.fileno());
+
+ ATF_REQUIRE(pf.write() == 0);
+
+ ATF_REQUIRE(fstat(pf.fileno(), &sb) == 0);
+ ATF_REQUIRE(sb.st_size > 0);
+
+ ATF_REQUIRE(pf.close() == 0);
+ ATF_REQUIRE(pf.fileno() == -1);
+ ATF_REQUIRE_EQ(EDOOFUS, errno);
+
+ ATF_REQUIRE(unlink("test_pidfile") == 0);
+}
+
+ATF_INIT_TEST_CASES(tcs)
+{
+ ATF_ADD_TEST_CASE(tcs, basic);
+}
diff --git a/lib/libutil++/tests/stringf_test.cc b/lib/libutil++/tests/stringf_test.cc
new file mode 100644
index 000000000000..5b8ef4ad54a9
--- /dev/null
+++ b/lib/libutil++/tests/stringf_test.cc
@@ -0,0 +1,52 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <atf-c++.hpp>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <libutil++.hh>
+
+ATF_TEST_CASE_WITHOUT_HEAD(basic);
+ATF_TEST_CASE_BODY(basic)
+{
+ ATF_REQUIRE_EQ("foo", freebsd::stringf("foo"));
+ ATF_REQUIRE_EQ("bar", freebsd::stringf("%s", "bar"));
+ ATF_REQUIRE_EQ("42", freebsd::stringf("%u", 42));
+ ATF_REQUIRE_EQ("0xdeadbeef", freebsd::stringf("%#x", 0xdeadbeef));
+ ATF_REQUIRE_EQ("", freebsd::stringf(""));
+ ATF_REQUIRE_EQ("this is a test", freebsd::stringf("this %s test",
+ "is a"));
+}
+
+static std::string
+stringv(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ std::string str = freebsd::stringf(fmt, ap);
+ va_end(ap);
+ return (str);
+}
+
+ATF_TEST_CASE_WITHOUT_HEAD(va_list);
+ATF_TEST_CASE_BODY(va_list)
+{
+ ATF_REQUIRE_EQ("foo", stringv("foo"));
+ ATF_REQUIRE_EQ("bar", stringv("%s", "bar"));
+ ATF_REQUIRE_EQ("42", stringv("%u", 42));
+ ATF_REQUIRE_EQ("0xdeadbeef", stringv("%#x", 0xdeadbeef));
+ ATF_REQUIRE_EQ("", stringv(""));
+ ATF_REQUIRE_EQ("this is a test", stringv("this %s test", "is a"));
+}
+
+ATF_INIT_TEST_CASES(tcs)
+{
+ ATF_ADD_TEST_CASE(tcs, basic);
+ ATF_ADD_TEST_CASE(tcs, va_list);
+}
diff --git a/lib/libutil++/tests/up_test.cc b/lib/libutil++/tests/up_test.cc
new file mode 100644
index 000000000000..3f344054c334
--- /dev/null
+++ b/lib/libutil++/tests/up_test.cc
@@ -0,0 +1,33 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2025 Chelsio Communications, Inc.
+ * Written by: John Baldwin <jhb@FreeBSD.org>
+ */
+
+#include <atf-c++.hpp>
+#include <libutil.h>
+
+#include <libutil++.hh>
+
+ATF_TEST_CASE_WITHOUT_HEAD(FILE_up);
+ATF_TEST_CASE_BODY(FILE_up)
+{
+ FILE *fp = fopen("/dev/null", "r");
+ ATF_REQUIRE(fp != NULL);
+ ATF_REQUIRE(fileno(fp) != -1);
+
+ freebsd::FILE_up f(fp);
+ ATF_REQUIRE_EQ(fileno(fp), fileno(f.get()));
+
+ f.reset();
+ ATF_REQUIRE_EQ(f.get(), nullptr);
+
+ ATF_REQUIRE_EQ(-1, fileno(fp));
+ ATF_REQUIRE_EQ(EBADF, errno);
+}
+
+ATF_INIT_TEST_CASES(tcs)
+{
+ ATF_ADD_TEST_CASE(tcs, FILE_up);
+}
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 889a81747c82..f8c566ca731a 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -9,18 +7,19 @@ PACKAGE= runtime
.PATH: ${SRCTOP}/lib/libc/gen # for pw_scan.c
LIB= util
-SHLIB_MAJOR= 9
+SHLIB_MAJOR= 10
-SRCS= _secure_path.c auth.c cpuset.c expand_number.c flopen.c fparseln.c \
- getlocalbase.c gr_util.c \
+SRCS= _secure_path.c cpuset.c expand_number.c flopen.c fparseln.c \
+ ftime.c getlocalbase.c gr_util.c \
hexdump.c humanize_number.c kinfo_getfile.c \
kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \
kinfo_getvmobject.c kld.c \
login_auth.c login_cap.c \
login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
+ mntopts.c \
pidfile.c property.c pty.c pw_scan.c pw_util.c quotafile.c \
realhostname.c stub.c trimdomain.c uucplock.c
-INCS= libutil.h login_cap.h
+INCS= libutil.h login_cap.h mntopts.h
CFLAGS+= -DNO__SCCSID
@@ -30,64 +29,126 @@ CFLAGS+= -DINET6
CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/
-MAN+= cpuset.3 expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \
- humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \
- kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \
- login_auth.3 login_cap.3 \
- login_class.3 login_ok.3 login_times.3 login_tty.3 pidfile.3 \
- property.3 pty.3 quotafile.3 realhostname.3 realhostname_sa.3 \
- _secure_path.3 trimdomain.3 uucplock.3 pw_util.3
-MAN+= login.conf.5
+VERSION_DEF= ${SRCTOP}/lib/libc/Versions.def
+SYMBOL_MAPS= ${.CURDIR}/Symbol.map
+
+MAN+= cpuset.3
+MLINKS+=cpuset.3 cpuset_parselist.3
+MLINKS+=cpuset.3 domainset_parselist.3
+MAN+= expand_number.3
+MAN+= flopen.3
MLINKS+=flopen.3 flopenat.3
-MLINKS+=kld.3 kld_isloaded.3 kld.3 kld_load.3
-MLINKS+=login_auth.3 auth_cat.3 login_auth.3 auth_checknologin.3
-MLINKS+=login_cap.3 login_close.3 login_cap.3 login_getcapbool.3 \
- login_cap.3 login_getcaplist.3 login_cap.3 login_getcapnum.3 \
- login_cap.3 login_getcapsize.3 login_cap.3 login_getcapstr.3 \
- login_cap.3 login_getcaptime.3 login_cap.3 login_getclass.3 \
- login_cap.3 login_getclassbyname.3 login_cap.3 login_getpath.3 \
- login_cap.3 login_getpwclass.3 login_cap.3 login_getstyle.3 \
- login_cap.3 login_getuserclass.3 login_cap.3 login_setcryptfmt.3
-MLINKS+=login_class.3 setclasscontext.3 login_class.3 setclassenvironment.3 \
- login_class.3 setclassresources.3 login_class.3 setusercontext.3
-MLINKS+=login_ok.3 auth_hostok.3 login_ok.3 auth_timeok.3 \
- login_ok.3 auth_ttyok.3
-MLINKS+=login_times.3 in_lt.3 login_times.3 in_ltm.3 \
- login_times.3 in_ltms.3 \
- login_times.3 in_lts.3 \
- login_times.3 parse_lt.3
-MLINKS+=pidfile.3 pidfile_close.3 \
- pidfile.3 pidfile_fileno.3 \
- pidfile.3 pidfile_open.3 \
- pidfile.3 pidfile_remove.3 \
- pidfile.3 pidfile_write.3
-MLINKS+=property.3 property_find.3 property.3 properties_free.3
+MAN+= fparseln.3
+MAN+= ftime.3
+MAN+= getlocalbase.3
+MAN+= hexdump.3
+MAN+= humanize_number.3
+MAN+= kinfo_getallproc.3
+MAN+= kinfo_getfile.3
+MAN+= kinfo_getproc.3
+MAN+= kinfo_getvmmap.3
+MAN+= kinfo_getvmobject.3
+MAN+= kld.3
+MLINKS+=kld.3 kld_isloaded.3
+MLINKS+=kld.3 kld_load.3
+MAN+= login_auth.3
+MLINKS+=login_auth.3 auth_cat.3
+MLINKS+=login_auth.3 auth_checknologin.3
+MAN+= login_cap.3
+MLINKS+=login_cap.3 login_close.3
+MLINKS+=login_cap.3 login_getcapbool.3
+MLINKS+=login_cap.3 login_getcapenum.3
+MLINKS+=login_cap.3 login_getcaplist.3
+MLINKS+=login_cap.3 login_getcapnum.3
+MLINKS+=login_cap.3 login_getcapsize.3
+MLINKS+=login_cap.3 login_getcapstr.3
+MLINKS+=login_cap.3 login_getcaptime.3
+MLINKS+=login_cap.3 login_getclass.3
+MLINKS+=login_cap.3 login_getclassbyname.3
+MLINKS+=login_cap.3 login_getpath.3
+MLINKS+=login_cap.3 login_getpwclass.3
+MLINKS+=login_cap.3 login_getstyle.3
+MLINKS+=login_cap.3 login_getuserclass.3
+MLINKS+=login_cap.3 login_setcryptfmt.3
+MAN+= login_class.3
+MLINKS+=login_class.3 setclasscontext.3
+MLINKS+=login_class.3 setclasscpumask.3
+MLINKS+=login_class.3 setclassenvironment.3
+MLINKS+=login_class.3 setclassresources.3
+MLINKS+=login_class.3 setusercontext.3
+MAN+= login_ok.3
+MLINKS+=login_ok.3 auth_hostok.3
+MLINKS+=login_ok.3 auth_timeok.3
+MLINKS+=login_ok.3 auth_ttyok.3
+MAN+= login_times.3
+MLINKS+=login_times.3 in_lt.3
+MLINKS+=login_times.3 in_ltm.3
+MLINKS+=login_times.3 in_ltms.3
+MLINKS+=login_times.3 in_lts.3
+MLINKS+=login_times.3 parse_lt.3
+MAN+= login_tty.3
+MAN+= mntopts.3
+MLINKS+=mntopts.3 build_iovec.3
+MLINKS+=mntopts.3 build_iovec_argf.3
+MLINKS+=mntopts.3 checkpath.3
+MLINKS+=mntopts.3 chkdoreload.3
+MLINKS+=mntopts.3 free_iovec.3
+MLINKS+=mntopts.3 getmntopts.3
+MLINKS+=mntopts.3 getmntpoint.3
+MLINKS+=mntopts.3 rmslashes.3
+MAN+= pidfile.3
+MLINKS+=pidfile.3 pidfile_close.3
+MLINKS+=pidfile.3 pidfile_fileno.3
+MLINKS+=pidfile.3 pidfile_open.3
+MLINKS+=pidfile.3 pidfile_remove.3
+MLINKS+=pidfile.3 pidfile_signal.3
+MLINKS+=pidfile.3 pidfile_write.3
+MAN+= property.3
+MLINKS+=property.3 property_find.3
+MLINKS+=property.3 properties_free.3
MLINKS+=property.3 properties_read.3
-MLINKS+=pty.3 forkpty.3 pty.3 openpty.3
-MLINKS+=quotafile.3 quota_close.3 \
- quotafile.3 quota_fsname.3 \
- quotafile.3 quota_open.3 \
- quotafile.3 quota_qfname.3 \
- quotafile.3 quota_read.3 \
- quotafile.3 quota_statfs.3 \
- quotafile.3 quota_write_limits.3 \
- quotafile.3 quota_write_usage.3
-MLINKS+=uucplock.3 uu_lock.3 uucplock.3 uu_lock_txfr.3 \
- uucplock.3 uu_lockerr.3 uucplock.3 uu_unlock.3
-MLINKS+=pw_util.3 pw_copy.3 \
- pw_util.3 pw_dup.3 \
- pw_util.3 pw_edit.3 \
- pw_util.3 pw_equal.3 \
- pw_util.3 pw_fini.3 \
- pw_util.3 pw_init.3 \
- pw_util.3 pw_make.3 \
- pw_util.3 pw_make_v7.3 \
- pw_util.3 pw_mkdb.3 \
- pw_util.3 pw_lock.3 \
- pw_util.3 pw_scan.3 \
- pw_util.3 pw_tempname.3 \
- pw_util.3 pw_tmp.3
-MLINKS+=cpuset.3 cpuset_parselist.3
+MAN+= pty.3
+MLINKS+=pty.3 forkpty.3
+MLINKS+=pty.3 openpty.3
+MAN+= pw_util.3
+MLINKS+=pw_util.3 pw_copy.3
+MLINKS+=pw_util.3 pw_dup.3
+MLINKS+=pw_util.3 pw_edit.3
+MLINKS+=pw_util.3 pw_equal.3
+MLINKS+=pw_util.3 pw_fini.3
+MLINKS+=pw_util.3 pw_init.3
+MLINKS+=pw_util.3 pw_initpwd.3
+MLINKS+=pw_util.3 pw_make.3
+MLINKS+=pw_util.3 pw_make_v7.3
+MLINKS+=pw_util.3 pw_mkdb.3
+MLINKS+=pw_util.3 pw_lock.3
+MLINKS+=pw_util.3 pw_scan.3
+MLINKS+=pw_util.3 pw_tempname.3
+MLINKS+=pw_util.3 pw_tmp.3
+MAN+= quotafile.3
+MLINKS+=quotafile.3 quota_check_path.3
+MLINKS+=quotafile.3 quota_close.3
+MLINKS+=quotafile.3 quota_convert.3
+MLINKS+=quotafile.3 quota_fsname.3
+MLINKS+=quotafile.3 quota_maxid.3
+MLINKS+=quotafile.3 quota_off.3
+MLINKS+=quotafile.3 quota_on.3
+MLINKS+=quotafile.3 quota_open.3
+MLINKS+=quotafile.3 quota_qfname.3
+MLINKS+=quotafile.3 quota_read.3
+MLINKS+=quotafile.3 quota_statfs.3
+MLINKS+=quotafile.3 quota_write_limits.3
+MLINKS+=quotafile.3 quota_write_usage.3
+MAN+= realhostname.3
+MAN+= realhostname_sa.3
+MAN+= _secure_path.3
+MAN+= trimdomain.3
+MAN+= uucplock.3
+MLINKS+=uucplock.3 uu_lock.3
+MLINKS+=uucplock.3 uu_lock_txfr.3
+MLINKS+=uucplock.3 uu_lockerr.3
+MLINKS+=uucplock.3 uu_unlock.3
+MAN+= login.conf.5
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/lib/libutil/Symbol.map b/lib/libutil/Symbol.map
new file mode 100644
index 000000000000..8c8fff451cd1
--- /dev/null
+++ b/lib/libutil/Symbol.map
@@ -0,0 +1,126 @@
+FBSD_1.8 {
+ _secure_path;
+ auth_cat;
+ auth_checknologin;
+ auth_hostok;
+ auth_timeok;
+ auth_ttyok;
+ build_iovec_argf;
+ build_iovec;
+ checkpath_allow_file;
+ checkpath;
+ chkdoreload;
+ cpuset_parselist;
+ domainset_parselist;
+ expand_number;
+ flopen;
+ flopenat;
+ forkpty;
+ fparseln;
+ free_iovec;
+ ftime;
+ getlocalbase;
+ getmnt_silent;
+ getmntopts;
+ getmntpoint;
+ gr_add;
+ gr_copy;
+ gr_dup;
+ gr_equal;
+ gr_fini;
+ gr_init;
+ gr_lock;
+ gr_make;
+ gr_mkdb;
+ gr_scan;
+ gr_tmp;
+ hexdump;
+ humanize_number;
+ in_lt;
+ in_ltm;
+ in_ltms;
+ in_lts;
+ kinfo_getallproc;
+ kinfo_getfile;
+ kinfo_getproc;
+ kinfo_getswapvmobject;
+ kinfo_getvmmap;
+ kinfo_getvmobject;
+ kld_isloaded;
+ kld_load;
+ login_close;
+ login_getcapbool;
+ login_getcapenum;
+ login_getcaplist;
+ login_getcapnum;
+ login_getcapsize;
+ login_getcapstr;
+ login_getcaptime;
+ login_getclass;
+ login_getclassbyname;
+ login_getpath;
+ login_getpwclass;
+ login_getstyle;
+ login_getuserclass;
+ login_hostok;
+ login_setcryptfmt;
+ login_str2inlist;
+ login_strinlist;
+ login_timelist;
+ login_tty;
+ login_ttyok;
+ openpty;
+ parse_lt;
+ pidfile_close;
+ pidfile_fileno;
+ pidfile_open;
+ pidfile_remove;
+ pidfile_signal;
+ pidfile_write;
+ properties_free;
+ properties_read;
+ property_find;
+ pw_copy;
+ pw_dup;
+ pw_edit;
+ pw_equal;
+ pw_fini;
+ pw_init;
+ pw_initpwd;
+ pw_lock;
+ pw_make_v7;
+ pw_make;
+ pw_mkdb;
+ pw_scan;
+ pw_tempname;
+ pw_tmp;
+ quota_check_path;
+ quota_close;
+ quota_convert;
+ quota_fsname;
+ quota_maxid;
+ quota_off;
+ quota_on;
+ quota_open;
+ quota_qfname;
+ quota_read;
+ quota_write_limits;
+ quota_write_usage;
+ realhostname_sa;
+ realhostname;
+ rmslashes;
+ setclasscontext;
+ setclasscpumask;
+ setclassenvironment;
+ setclassresources;
+ setusercontext;
+ trimdomain;
+ uu_lock_txfr;
+ uu_lock;
+ uu_lockerr;
+ uu_unlock;
+};
+
+FBSDprivate_1.0 {
+ __pw_initpwd;
+};
diff --git a/lib/libutil/_secure_path.c b/lib/libutil/_secure_path.c
index 3deee78abc87..f55b191e89bb 100644
--- a/lib/libutil/_secure_path.c
+++ b/lib/libutil/_secure_path.c
@@ -19,7 +19,6 @@
* conditions are met.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/lib/libutil/auth.c b/lib/libutil/auth.c
deleted file mode 100644
index 3414fc8e26e7..000000000000
--- a/lib/libutil/auth.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Simple authentication database handling code.
- *
- * Copyright (c) 1998
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 OR HIS PETS 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, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <stdlib.h>
-
-#include <libutil.h>
-
-char *
-auth_getval(const char *name)
-{
-
- (void)name;
- return (NULL);
-}
diff --git a/lib/libutil/cpuset.3 b/lib/libutil/cpuset.3
index be29d5309ef0..47dffd209ee6 100644
--- a/lib/libutil/cpuset.3
+++ b/lib/libutil/cpuset.3
@@ -22,21 +22,22 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 31, 2017
+.Dd June 24, 2025
.Dt CPUSET 3
.Os
.Sh NAME
-.Nm cpuset_parselist
-.Nd utility functions for
-.Xr cpuset 2
-handling
+.Nm cpuset_parselist ,
+.Nm domainset_parselist
+.Nd utility functions for cpuset(2) handling
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
.In sys/cpuset.h
.In libutil.h
.Ft int
-.Fn cpuset_parselist "const char *cpu-list" "cpuset_t *mask"
+.Fn cpuset_parselist "const char *cpu_list" "cpuset_t *mask"
+.Ft int
+.Fn domainset_parselist "const char *domain_policy" "domainset_t *domain_mask" "int *policyp"
.Sh DESCRIPTION
The
.Fn cpuset_parselist
@@ -52,6 +53,27 @@ numbers.
A special list of
.Dq all
may be specified in which case the list includes all CPUs from the root set.
+.Pp
+The
+.Fn domainset_parselist
+function parses a
+.Xr domainset 9
+memory domain allocation policy
+specified by
+.Va domain_policy
+filling the
+.Va domain_mask
+and the
+.Va policyp .
+A valid
+.Va domain_policy
+is formatted as
+.Ar policy:domain-list .
+See the
+.Ar -n
+flag in
+.Xr cpuset 1
+for a list of valid domain policies.
.Sh RETURN VALUES
Return values can be the following
.Bl -tag -width Er
@@ -60,19 +82,30 @@ The parsing was successful
.It Dv CPUSET_PARSE_ERROR
The
.Va cpu-list
+or
+.Va domain-policy
format is invalid
.It Dv CPUSET_PARSE_GETAFFINITY
The
.Xr cpuset_getaffinity 2
call has failed
.It Dv CPUSET_PARSE_INVALID_CPU
-The number of supported CPUs has been exceeded.
+The number of supported CPUs or NUMA domains has been exceeded.
The maximum number being
-.Va CPU_SETSIZE .
+.Va CPU_SETSIZE
+and
+.Va DOMAINSET_SETSIZE
+respectively.
+.It Dv CPUSET_PARSE_GETDOMAIN
+The
+.Xr cpuset_getdomain 2
+call has failed
.El
.Sh SEE ALSO
.Xr cpuset 1 ,
.Xr cpuset 2 ,
-.Xr cpuset 9
+.Xr numa 4 ,
+.Xr cpuset 9 ,
+.Xr domainset 9
.Sh AUTHORS
.An Jeffrey Roberson Aq Mt jeff@FreeBSD.org
diff --git a/lib/libutil/cpuset.c b/lib/libutil/cpuset.c
index 3c374bfa6cac..d4840af7e175 100644
--- a/lib/libutil/cpuset.c
+++ b/lib/libutil/cpuset.c
@@ -27,34 +27,48 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+#define _WANT_FREEBSD_BITSET
+
#include <sys/types.h>
#include <sys/cpuset.h>
+#include <sys/domainset.h>
#include <stdlib.h>
#include <string.h>
#include <libutil.h>
#include <ctype.h>
-int
-cpuset_parselist(const char *list, cpuset_t *mask)
+struct numa_policy {
+ const char *name;
+ int policy;
+};
+
+static const struct numa_policy policies[] = {
+ { "round-robin", DOMAINSET_POLICY_ROUNDROBIN },
+ { "rr", DOMAINSET_POLICY_ROUNDROBIN },
+ { "first-touch", DOMAINSET_POLICY_FIRSTTOUCH },
+ { "ft", DOMAINSET_POLICY_FIRSTTOUCH },
+ { "prefer", DOMAINSET_POLICY_PREFER },
+ { "interleave", DOMAINSET_POLICY_INTERLEAVE},
+ { "il", DOMAINSET_POLICY_INTERLEAVE},
+ { NULL, DOMAINSET_POLICY_INVALID }
+};
+
+static int
+parselist(const char *list, struct bitset *mask, int size)
{
enum { NONE, NUM, DASH } state;
int lastnum;
int curnum;
const char *l;
- if (strcasecmp(list, "all") == 0) {
- if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
- sizeof(*mask), mask) != 0)
- return (CPUSET_PARSE_GETAFFINITY);
- return (CPUSET_PARSE_OK);
- }
state = NONE;
curnum = lastnum = 0;
for (l = list; *l != '\0';) {
if (isdigit(*l)) {
curnum = atoi(l);
- if (curnum > CPU_SETSIZE)
+ if (curnum >= size)
return (CPUSET_PARSE_INVALID_CPU);
while (isdigit(*l))
l++;
@@ -65,7 +79,7 @@ cpuset_parselist(const char *list, cpuset_t *mask)
break;
case DASH:
for (; lastnum <= curnum; lastnum++)
- CPU_SET(lastnum, mask);
+ BIT_SET(size, lastnum, mask);
state = NONE;
break;
case NUM:
@@ -80,7 +94,7 @@ cpuset_parselist(const char *list, cpuset_t *mask)
case NONE:
break;
case NUM:
- CPU_SET(curnum, mask);
+ BIT_SET(size, curnum, mask);
state = NONE;
break;
case DASH:
@@ -102,7 +116,7 @@ cpuset_parselist(const char *list, cpuset_t *mask)
case NONE:
break;
case NUM:
- CPU_SET(curnum, mask);
+ BIT_SET(size, curnum, mask);
break;
case DASH:
goto parserr;
@@ -111,3 +125,63 @@ cpuset_parselist(const char *list, cpuset_t *mask)
parserr:
return (CPUSET_PARSE_ERROR);
}
+
+/*
+ * permissively parse policy:domain list
+ * allow:
+ * round-robin:0-4 explicit
+ * round-robin:all explicit root domains
+ * 0-4 implicit root policy
+ * round-robin implicit root domains
+ * all explicit root domains and implicit policy
+ */
+int
+domainset_parselist(const char *list, domainset_t *mask, int *policyp)
+{
+ domainset_t rootmask;
+ const struct numa_policy *policy;
+ const char *l;
+ int p;
+
+ /*
+ * Use the rootset's policy as the default for unspecified policies.
+ */
+ if (cpuset_getdomain(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
+ sizeof(rootmask), &rootmask, &p) != 0)
+ return (CPUSET_PARSE_GETDOMAIN);
+
+ if (list == NULL || strcasecmp(list, "all") == 0 || *list == '\0') {
+ *policyp = p;
+ DOMAINSET_COPY(&rootmask, mask);
+ return (CPUSET_PARSE_OK);
+ }
+
+ l = list;
+ for (policy = &policies[0]; policy->name != NULL; policy++) {
+ if (strncasecmp(l, policy->name, strlen(policy->name)) == 0) {
+ p = policy->policy;
+ l += strlen(policy->name);
+ if (*l != ':' && *l != '\0')
+ return (CPUSET_PARSE_ERROR);
+ if (*l == ':')
+ l++;
+ break;
+ }
+ }
+ *policyp = p;
+
+ return (parselist(l, (struct bitset *)mask, DOMAINSET_SETSIZE));
+}
+
+int
+cpuset_parselist(const char *list, cpuset_t *mask)
+{
+ if (strcasecmp(list, "all") == 0) {
+ if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
+ sizeof(*mask), mask) != 0)
+ return (CPUSET_PARSE_GETAFFINITY);
+ return (CPUSET_PARSE_OK);
+ }
+
+ return (parselist(list, (struct bitset *)mask, CPU_SETSIZE));
+}
diff --git a/lib/libutil/expand_number.3 b/lib/libutil/expand_number.3
index 3609b1ad3939..1b932400de69 100644
--- a/lib/libutil/expand_number.3
+++ b/lib/libutil/expand_number.3
@@ -1,5 +1,6 @@
.\" Copyright (c) 2007 Eric Anderson <anderson@FreeBSD.org>
.\" Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+.\" Copyright (c) 2025 Dag-Erling Smørgrav <des@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -23,43 +24,49 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 13, 2023
+.Dd July 25, 2025
.Dt EXPAND_NUMBER 3
.Os
.Sh NAME
.Nm expand_number
-.Nd format a number from human readable form
+.Nd parse a number from human readable form
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
.In libutil.h
.Ft int
.Fo expand_number
-.Fa "const char *buf" "uint64_t *num"
+.Fa "const char *buf" "int64_t *num"
.Fc
.Sh DESCRIPTION
The
.Fn expand_number
-function parses the
+function parses the number in the string pointed to by its
.Fa buf
-string and stores a unsigned 64-bit quantity at
-.Fa *num .
+argument and stores the number it represents as a signed 64-bit
+quantity in the location pointed to by its
+.Fa *num
+argument.
.Pp
-The
-.Fn expand_number
-function
-is case-insensitive and
-follows the SI power of two convention.
+The input string must consist of a decimal number, optionally preceded
+by a
+.Sq +
+or
+.Sq -
+sign, and optionally followed, without intervening whitespace, by a
+suffix indicating a power-of-two multiplier to apply.
+Any amount of whitespace at the beginning of the string will be
+ignored.
.Pp
-The suffixes are:
+Recognized suffixes are:
.Bl -column "Suffix" "Description" "1000000000000000000" -offset indent
.It Sy "Suffix" Ta Sy "Description" Ta Sy "Multiplier"
-.It Li K Ta No kilo Ta 1024
-.It Li M Ta No mega Ta 1048576
-.It Li G Ta No giga Ta 1073741824
-.It Li T Ta No tera Ta 1099511627776
-.It Li P Ta No peta Ta 1125899906842624
-.It Li E Ta No exa Ta 1152921504606846976
+.It Li K Ta No kilo Ta 1,024
+.It Li M Ta No mega Ta 1,048,576
+.It Li G Ta No giga Ta 1,073,741,824
+.It Li T Ta No tera Ta 1,099,511,627,776
+.It Li P Ta No peta Ta 1,125,899,906,842,624
+.It Li E Ta No exa Ta 1,152,921,504,606,846,976
.El
.Pp
For historical reasons, the
@@ -68,7 +75,11 @@ function accepts and ignores a single
.Dq B
suffix at the end of the
.Fa buf
-string.
+string (i.e.
+.Dq 5b
+is interpreted as 5, and
+.Dq 5kb
+is interpreted as 5,120).
However, the usage of this suffix is discouraged.
.Sh RETURN VALUES
.Rv -std
@@ -78,11 +89,12 @@ The
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
-The given string contains no digits.
+The given string does not contain a valid number.
.It Bq Er EINVAL
-An unrecognized suffix was given.
+An unrecognized suffix was encountered.
.It Bq Er ERANGE
-Result doesn't fit into 64 bits.
+The given string represents a number which does not fit into a
+.Vt int64_t .
.El
.Sh SEE ALSO
.Xr humanize_number 3
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c
index 8346a2e5f079..f4c19d7867a3 100644
--- a/lib/libutil/expand_number.c
+++ b/lib/libutil/expand_number.c
@@ -3,6 +3,7 @@
*
* Copyright (c) 2007 Eric Anderson <anderson@FreeBSD.org>
* Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+ * Copyright (c) 2025 Dag-Erling Smørgrav <des@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,81 +28,121 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
+
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <libutil.h>
+#include <stdbool.h>
#include <stdint.h>
int
-expand_number(const char *buf, uint64_t *num)
+expand_number(const char *buf, int64_t *num)
{
char *endptr;
- uintmax_t umaxval;
- uint64_t number;
- unsigned shift;
+ uintmax_t number;
+ unsigned int shift;
+ bool neg;
int serrno;
+ /*
+ * Skip whitespace and optional sign.
+ */
+ while (isspace((unsigned char)*buf))
+ buf++;
+ if (*buf == '-') {
+ neg = true;
+ buf++;
+ } else {
+ neg = false;
+ if (*buf == '+')
+ buf++;
+ }
+
+ /*
+ * The next character should be the first digit of the number. If
+ * we don't enforce this ourselves, strtoumax() will allow further
+ * whitespace and a (second?) sign.
+ */
+ if (!isdigit((unsigned char)*buf)) {
+ errno = EINVAL;
+ return (-1);
+ }
+
serrno = errno;
errno = 0;
- umaxval = strtoumax(buf, &endptr, 0);
- if (umaxval > UINT64_MAX)
- errno = ERANGE;
+ number = strtoumax(buf, &endptr, 0);
if (errno != 0)
return (-1);
errno = serrno;
- number = umaxval;
switch (tolower((unsigned char)*endptr)) {
case 'e':
shift = 60;
+ endptr++;
break;
case 'p':
shift = 50;
+ endptr++;
break;
case 't':
shift = 40;
+ endptr++;
break;
case 'g':
shift = 30;
+ endptr++;
break;
case 'm':
shift = 20;
+ endptr++;
break;
case 'k':
shift = 10;
+ endptr++;
break;
- case 'b':
- shift = 0;
- break;
- case '\0': /* No unit. */
- *num = number;
- return (0);
default:
- /* Unrecognized unit. */
- errno = EINVAL;
- return (-1);
+ shift = 0;
}
/*
* Treat 'b' as an ignored suffix for all unit except 'b',
* otherwise there should be no remaining character(s).
*/
- endptr++;
- if (shift != 0 && tolower((unsigned char)*endptr) == 'b')
+ if (tolower((unsigned char)*endptr) == 'b')
endptr++;
if (*endptr != '\0') {
errno = EINVAL;
return (-1);
}
+ /*
+ * Apply the shift and check for overflow.
+ */
if ((number << shift) >> shift != number) {
/* Overflow */
errno = ERANGE;
return (-1);
}
- *num = number << shift;
+ number <<= shift;
+
+ /*
+ * Apply the sign and check for overflow.
+ */
+ if (neg) {
+ if (number > 0x8000000000000000LLU /* -INT64_MIN */) {
+ errno = ERANGE;
+ return (-1);
+ }
+ *num = -number;
+ } else {
+ if (number > INT64_MAX) {
+ errno = ERANGE;
+ return (-1);
+ }
+ *num = number;
+ }
+
return (0);
}
diff --git a/lib/libutil/fparseln.3 b/lib/libutil/fparseln.3
index 7ddfaefcc943..2f7ebcbf4d68 100644
--- a/lib/libutil/fparseln.3
+++ b/lib/libutil/fparseln.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: fparseln.3,v 1.7 1999/07/02 15:49:12 simonb Exp $
+.\" $NetBSD: fparseln.3,v 1.4 2009/10/21 01:07:45 snj Exp $
.\"
.\" Copyright (c) 1997 Christos Zoulas. All rights reserved.
.\"
@@ -10,11 +10,6 @@
.\" 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 Christos Zoulas.
-.\" 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
@@ -52,8 +47,7 @@ returns a pointer to the next logical line from the stream referenced by
This string is
.Dv NUL
terminated and it is dynamically allocated on each invocation.
-It is the
-responsibility of the caller to free the pointer.
+It is the responsibility of the caller to free the pointer.
.Pp
By default, if a character is escaped, both it and the preceding escape
character will be present in the returned string.
diff --git a/lib/libutil/fparseln.c b/lib/libutil/fparseln.c
index 170080f8aec3..256ee5b04cea 100644
--- a/lib/libutil/fparseln.c
+++ b/lib/libutil/fparseln.c
@@ -1,7 +1,7 @@
-/* $NetBSD: fparseln.c,v 1.7 2007/03/08 19:57:53 drochner Exp $ */
+/* $NetBSD: fparseln.c,v 1.10 2009/10/21 01:07:45 snj Exp $ */
/*-
- * SPDX-License-Identifier: BSD-4-Clause
+ * SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
*
@@ -13,11 +13,6 @@
* 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 Christos Zoulas.
- * 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
@@ -31,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
diff --git a/lib/libutil/ftime.3 b/lib/libutil/ftime.3
new file mode 100644
index 000000000000..e5770367f022
--- /dev/null
+++ b/lib/libutil/ftime.3
@@ -0,0 +1,78 @@
+.\" Copyright (c) 1980, 1991, 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.
+.\"
+.Dd May 28, 2024
+.Dt FTIME 3
+.Os
+.Sh NAME
+.Nm ftime
+.Nd get date and time
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/timeb.h
+.Ft int
+.Fn ftime "struct timeb *tp"
+.Sh DESCRIPTION
+.Bf -symbolic
+This interface is obsoleted by
+.Xr gettimeofday 2 .
+.Ef
+.Pp
+The
+.Fn ftime
+routine fills in a structure pointed to by its argument,
+as defined by
+.In sys/timeb.h :
+.Bd -literal -offset indent
+/*
+ * Structure returned by ftime system call
+ */
+struct timeb
+{
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+.Ed
+.Pp
+The structure contains the time since the epoch in seconds,
+up to 1000 milliseconds of more-precise interval,
+The kernel no longer maintains the timezone and dstflag info, so 0 is
+always returned for these fields.
+.Sh SEE ALSO
+.Xr gettimeofday 2 ,
+.Xr settimeofday 2 ,
+.Xr ctime 3 ,
+.Xr time 3
+.Sh HISTORY
+The
+.Nm
+function appeared in
+.At v7 .
diff --git a/lib/libutil/ftime.c b/lib/libutil/ftime.c
new file mode 100644
index 000000000000..2e72b5ef30f3
--- /dev/null
+++ b/lib/libutil/ftime.c
@@ -0,0 +1,53 @@
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 1994 Christopher G. Demetriou
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christopher G. Demetriou.
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#define _IN_LIBUITL
+#include <sys/timeb.h>
+
+int
+ftime(struct timeb *tbp)
+{
+ struct timezone tz;
+ struct timeval t;
+
+ if (gettimeofday(&t, &tz) < 0)
+ return (-1);
+ tbp->millitm = t.tv_usec / 1000;
+ tbp->time = t.tv_sec;
+ tbp->timezone = tz.tz_minuteswest;
+ tbp->dstflag = tz.tz_dsttime;
+
+ return (0);
+}
diff --git a/lib/libutil/getlocalbase.c b/lib/libutil/getlocalbase.c
index 2cbee6b5b237..e8aabbab1e14 100644
--- a/lib/libutil/getlocalbase.c
+++ b/lib/libutil/getlocalbase.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/limits.h>
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c
index 23be3324d129..c683ea69cfe2 100644
--- a/lib/libutil/gr_util.c
+++ b/lib/libutil/gr_util.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/stat.h>
diff --git a/lib/libutil/hexdump.3 b/lib/libutil/hexdump.3
index 677bf92680a6..e5a18e201bbd 100644
--- a/lib/libutil/hexdump.3
+++ b/lib/libutil/hexdump.3
@@ -32,6 +32,8 @@
.Sh NAME
.Nm hexdump
.Nd "dump a block of bytes to standard out in hexadecimal form"
+.Sh LIBRARY
+.Lb libutil
.Sh SYNOPSIS
.In libutil.h
.Ft void
diff --git a/lib/libutil/hexdump.c b/lib/libutil/hexdump.c
index 5627400d5b48..26ec2df66fcb 100644
--- a/lib/libutil/hexdump.c
+++ b/lib/libutil/hexdump.c
@@ -32,11 +32,8 @@
* 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.
- *
- * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <libutil.h>
#include <stdio.h>
diff --git a/lib/libutil/humanize_number.c b/lib/libutil/humanize_number.c
index 7b51bd5f2383..6a66f2c4305a 100644
--- a/lib/libutil/humanize_number.c
+++ b/lib/libutil/humanize_number.c
@@ -33,7 +33,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <inttypes.h>
diff --git a/lib/libutil/kinfo_getallproc.c b/lib/libutil/kinfo_getallproc.c
index b4d6bfa56328..43f00be890b5 100644
--- a/lib/libutil/kinfo_getallproc.c
+++ b/lib/libutil/kinfo_getallproc.c
@@ -27,7 +27,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
diff --git a/lib/libutil/kinfo_getfile.c b/lib/libutil/kinfo_getfile.c
index f1441bdf771a..345da657df81 100644
--- a/lib/libutil/kinfo_getfile.c
+++ b/lib/libutil/kinfo_getfile.c
@@ -27,6 +27,10 @@ kinfo_getfile(pid_t pid, int *cntp)
error = sysctl(mib, nitems(mib), NULL, &len, NULL, 0);
if (error)
return (NULL);
+ /*
+ * Add extra space as the table may grow between requesting the size
+ * and fetching the data.
+ */
len = len * 4 / 3;
buf = malloc(len);
if (buf == NULL)
diff --git a/lib/libutil/kinfo_getproc.c b/lib/libutil/kinfo_getproc.c
index f519e1ab083e..b214012f8f7b 100644
--- a/lib/libutil/kinfo_getproc.c
+++ b/lib/libutil/kinfo_getproc.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
diff --git a/lib/libutil/kinfo_getvmobject.c b/lib/libutil/kinfo_getvmobject.c
index 433adb6690fe..d4cad5e91a4f 100644
--- a/lib/libutil/kinfo_getvmobject.c
+++ b/lib/libutil/kinfo_getvmobject.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/user.h>
diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h
index 919855184caf..d27262e44daf 100644
--- a/lib/libutil/libutil.h
+++ b/lib/libutil/libutil.h
@@ -86,10 +86,9 @@ struct termios;
struct winsize;
__BEGIN_DECLS
-char *auth_getval(const char *_name);
void clean_environment(const char * const *_white,
const char * const *_more_white);
-int expand_number(const char *_buf, uint64_t *_num);
+int expand_number(const char *_buf, int64_t *_num);
int extattr_namespace_to_string(int _attrnamespace, char **_string);
int extattr_string_to_namespace(const char *_string, int *_attrnamespace);
int flopen(const char *_path, int _flags, ...);
@@ -213,7 +212,13 @@ int cpuset_parselist(const char *list, cpuset_t *mask);
#define CPUSET_PARSE_OK 0
#define CPUSET_PARSE_GETAFFINITY -1
#define CPUSET_PARSE_ERROR -2
-#define CPUSET_PARSE_INVALID_CPU -3
+#define CPUSET_PARSE_OUT_OF_RANGE -3
+#define CPUSET_PARSE_GETDOMAIN -4
+#define CPUSET_PARSE_INVALID_CPU CPUSET_PARSE_OUT_OF_RANGE /* backwards compat */
+#endif
+
+#ifdef _SYS_DOMAINSET_H_
+int domainset_parselist(const char *list, domainset_t *mask, int *policyp);
#endif
__END_DECLS
diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5
index a0b46debbfd1..d43fdfb761f3 100644
--- a/lib/libutil/login.conf.5
+++ b/lib/libutil/login.conf.5
@@ -181,9 +181,15 @@ are considered infinite values.
The usual convention to interpolate capability entries using the special
.Em tc=value
notation may be used.
+.Pp
+Default values are specified in the
+.Ql Default
+column.
+If there is no default, the value is inherited from the process setting up the
+login environment.
.Sh RESOURCE LIMITS
.Bl -column pseudoterminals indent indent
-.It Sy "Name Type Notes Description"
+.It Sy "Name Type Default Description"
.It "coredumpsize size Maximum coredump size limit."
.It "cputime time CPU usage limit."
.It "datasize size Maximum data size limit."
@@ -198,6 +204,7 @@ notation may be used.
.It "pseudoterminals number Maximum number of pseudo-terminals."
.It "swapuse size Maximum swap space size limit."
.It "umtxp number Maximum number of process-shared pthread locks."
+.It "pipebuf size Maximum size of pipe buffers."
.El
.Pp
These resource limit entries actually specify both the maximum
@@ -209,7 +216,7 @@ The maximum and current limits may be specified individually by appending a
-max or -cur to the capability name.
.Sh ENVIRONMENT
.Bl -column ignorenologin indent xbinxxusrxbin
-.It Sy "Name Type Notes Description"
+.It Sy "Name Type Default Description"
.It "charset string Set $MM_CHARSET environment variable to the specified"
value.
.It "cpumask string List of cpus to bind the user to."
@@ -241,7 +248,24 @@ for details.
.It "nologin file If the file exists it will be displayed and"
the login session will be terminated.
.It "path path /bin /usr/bin Default search path."
-.It "priority number Initial priority (nice) level."
+.It "priority number 0 Initial priority level."
+A value in the nice range
+.Pq -20 to 20 included ,
+extended below with the 32 real-time class priorities
+.Po
+so -52 maps to priority 0 in the real-time class, -51 to 1, and so on until -21
+which maps to 31; see
+.Xr rtprio 1
+.Pc
+and above with the 32 idle class priorities
+.Po
+so 21 maps to priority 0 in the idle class, 22 to 1, and so on until 52 which
+maps to 31; see
+.Xr idprio 1
+.Pc .
+Special value
+.Ql inherit
+prevents resetting the priority.
.It "requirehome bool false Require a valid home directory to login."
.It "setenv list A comma-separated list of environment variables and"
values to which they are to be set.
@@ -253,13 +277,16 @@ contain the shell specified in the password file.
.It "term string Default terminal type if not able to determine"
from other means.
.It "timezone string Default value of $TZ environment variable."
-.It "umask number 022 Initial umask. Should always have a leading 0 to"
+.It "umask number Initial umask. Should always have a leading 0 to"
ensure octal interpretation.
+Special value
+.Ql inherit
+explicitly indicates not to change the umask.
.It "welcome file /etc/motd File containing welcome message."
.El
.Sh AUTHENTICATION
.Bl -column passwd_prompt indent indent
-.It Sy "Name Type Notes Description"
+.It Sy "Name Type Default Description"
.\" .It "approve program Program to approve login.
.It "copyright file File containing additional copyright information"
.It "host.allow list List of remote host wildcards from which users in"
@@ -403,7 +430,7 @@ The following capabilities are reserved for the purposes indicated and
may be supported by third-party software.
They are not implemented in the base system.
.Bl -column host.accounted indent indent
-.It Sy "Name Type Notes Description"
+.It Sy "Name Type Default Description"
.It "accounted bool false Enable session time accounting for all users"
in this class.
.It "auth list passwd Allowed authentication styles."
diff --git a/lib/libutil/login_auth.c b/lib/libutil/login_auth.c
index 5accfbabe57a..1911a3376e18 100644
--- a/lib/libutil/login_auth.c
+++ b/lib/libutil/login_auth.c
@@ -26,7 +26,6 @@
* Low-level routines relating to the user capabilities database
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/lib/libutil/login_cap.3 b/lib/libutil/login_cap.3
index 0281c8428ed5..86142c3b19f9 100644
--- a/lib/libutil/login_cap.3
+++ b/lib/libutil/login_cap.3
@@ -25,6 +25,7 @@
.Nm login_getcapbool ,
.Nm login_getcaplist ,
.Nm login_getcapnum ,
+.Nm login_getcapenum ,
.Nm login_getcapstr ,
.Nm login_getcapsize ,
.Nm login_getcaptime ,
@@ -60,6 +61,8 @@
.Fn login_getcaptime "login_cap_t *lc" "const char *cap" "rlim_t def" "rlim_t error"
.Ft rlim_t
.Fn login_getcapnum "login_cap_t *lc" "const char *cap" "rlim_t def" "rlim_t error"
+.Ft int
+.Fn login_getcapenum "login_cap_t *lc" "const char *cap" "const char * const *values"
.Ft rlim_t
.Fn login_getcapsize "login_cap_t *lc" "const char *cap" "rlim_t def" "rlim_t error"
.Ft int
@@ -459,6 +462,31 @@ If the given capability tag cannot be found, the
parameter is returned, and if an error occurs, the
.Fa error
parameter is returned.
+.It Fn login_getcapenum
+This function returns whether the searched capability is a string with value
+among a predefined set passed in argument
+.Fa values
+as a NULL-terminated array of strings.
+.Pp
+A non-negative value indicates a match and is the index of the capability's
+value in array
+.Fa values .
+Other possible return values are:
+.Bl -tag -width "-4"
+.It -4
+Returned if
+.Fa lc
+or
+.Fa cap
+are insufficiently initialized or invalid.
+.It -3
+Returned on allocation failure (out of memory).
+.It -2
+Returned if the capability isn't specified or its value is not a string.
+.It -1
+Returned if the capability is specified and a string but its value is not among
+.Fa values .
+.El
.It Fn login_getcapsize
.Fn login_getcapsize
returns a value representing a size (typically, file or memory)
diff --git a/lib/libutil/login_cap.c b/lib/libutil/login_cap.c
index e71d38d2d93b..0d7becacbfc7 100644
--- a/lib/libutil/login_cap.c
+++ b/lib/libutil/login_cap.c
@@ -26,7 +26,6 @@
* Low-level routines relating to the user capabilities database
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -650,10 +649,8 @@ login_getcaptime(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
if ((r = cgetstr(lc->lc_cap, cap, &res)) == -1)
return def;
- else if (r < 0) {
- errno = ERANGE;
+ else if (r < 0)
return error;
- }
/* "inf" and "infinity" are special cases */
if (isinfinite(res))
@@ -735,19 +732,18 @@ login_getcapnum(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
/*
* For BSDI compatibility, try for the tag=<val> first
*/
- if ((r = cgetstr(lc->lc_cap, cap, &res)) == -1) {
+ r = cgetstr(lc->lc_cap, cap, &res);
+ if (r == -1) {
long lval;
/* string capability not present, so try for tag#<val> as numeric */
if ((r = cgetnum(lc->lc_cap, cap, &lval)) == -1)
return def; /* Not there, so return default */
- else if (r >= 0)
+ else if (r < 0)
+ return error;
+ else
return (rlim_t)lval;
- }
-
- if (r < 0) {
- errno = ERANGE;
+ } else if (r < 0)
return error;
- }
if (isinfinite(res))
return RLIM_INFINITY;
@@ -764,6 +760,52 @@ login_getcapnum(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
return val;
}
+/*
+ * Extract a string capability expected to hold a specific value from a list.
+ *
+ * 'values' must be a NULL-terminated array of strings listing the possible
+ * values.
+ *
+ * A non-negative return code indicates success, and is the index of the value
+ * in 'values' the capability is set to.
+ *
+ * Negative return codes indicate an error:
+ * -4: 'lc' or 'cap' insufficiently initialized or not valid.
+ * -3: System error (allocation failure).
+ * -2: Capability not found or not a string.
+ * -1: Capability has a string value, but not one listed in 'values'.
+ */
+int
+login_getcapenum(login_cap_t *lc, const char *cap, const char * const *values)
+{
+ int ret, i;
+ char *cand;
+ const char * const *val;
+
+ if (lc == NULL || lc->lc_cap == NULL || cap == NULL || *cap == '\0')
+ return (-4);
+
+ ret = cgetstr(lc->lc_cap, cap, &cand);
+
+ if (ret == -1)
+ /* Cap not found. */
+ return (-2);
+ else if (ret < 0)
+ /* System error (normally, allocation failure). */
+ return (-3);
+
+ ret = -1;
+
+ for (i = 0, val = values; *val != NULL; val++)
+ if (strcmp(cand, *val) == 0) {
+ ret = i;
+ break;
+ }
+
+ free(cand);
+ return (ret);
+}
+
/*
@@ -786,10 +828,8 @@ login_getcapsize(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
if ((r = cgetstr(lc->lc_cap, cap, &res)) == -1)
return def;
- else if (r < 0) {
- errno = ERANGE;
+ else if (r < 0)
return error;
- }
if (isinfinite(res))
return RLIM_INFINITY;
diff --git a/lib/libutil/login_cap.h b/lib/libutil/login_cap.h
index 7312914900a8..316d6e62d790 100644
--- a/lib/libutil/login_cap.h
+++ b/lib/libutil/login_cap.h
@@ -32,8 +32,6 @@
#define LOGIN_MECLASS "me"
#define LOGIN_DEFSTYLE "passwd"
#define LOGIN_DEFSERVICE "login"
-#define LOGIN_DEFUMASK 022
-#define LOGIN_DEFPRI 0
#define _PATH_LOGIN_CONF "/etc/login.conf"
#define _FILE_LOGIN_CONF ".login_conf"
#define _PATH_AUTHPROG "/usr/libexec/login_"
@@ -110,6 +108,8 @@ const char **login_getcaplist(login_cap_t *, const char *, const char *);
const char *login_getstyle(login_cap_t *, const char *, const char *);
rlim_t login_getcaptime(login_cap_t *, const char *, rlim_t, rlim_t);
rlim_t login_getcapnum(login_cap_t *, const char *, rlim_t, rlim_t);
+int login_getcapenum(login_cap_t *lc, const char *cap,
+ const char * const *values);
rlim_t login_getcapsize(login_cap_t *, const char *, rlim_t, rlim_t);
const char *login_getpath(login_cap_t *, const char *, const char *);
int login_getcapbool(login_cap_t *, const char *, int);
diff --git a/lib/libutil/login_class.3 b/lib/libutil/login_class.3
index b67301f5a5a6..46e6a70f8ca8 100644
--- a/lib/libutil/login_class.3
+++ b/lib/libutil/login_class.3
@@ -118,6 +118,7 @@ pseudoterminals RLIMIT_NPTS
swapuse RLIMIT_SWAP
kqueues RLIMIT_KQUEUES
umtxp RLIMIT_UMTXP
+pipebuf RLIMIT_PIPEBUF
.Ed
.It LOGIN_SETPRIORITY
Set the scheduling priority for the current process based on the
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c
index f561479690c1..c3c1b0ddda27 100644
--- a/lib/libutil/login_class.c
+++ b/lib/libutil/login_class.c
@@ -22,7 +22,6 @@
* High-level routines relating to use of the user capabilities database
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/mac.h>
@@ -38,6 +37,7 @@
#include <login_cap.h>
#include <paths.h>
#include <pwd.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -65,6 +65,7 @@ static struct login_res {
{ "swapuse", login_getcapsize, RLIMIT_SWAP },
{ "kqueues", login_getcapsize, RLIMIT_KQUEUES },
{ "umtxp", login_getcapnum, RLIMIT_UMTXP },
+ { "pipebuf", login_getcapnum, RLIMIT_PIPEBUF },
{ NULL, 0, 0 }
};
@@ -380,36 +381,137 @@ setclasscontext(const char *classname, unsigned int flags)
}
+static const char * const inherit_enum[] = {
+ "inherit",
+ NULL
+};
+
+/*
+ * Private function setting umask from the login class.
+ */
+static void
+setclassumask(login_cap_t *lc, const struct passwd *pwd)
+{
+ /*
+ * Make it unlikely that someone would input our default sentinel
+ * indicating no specification.
+ */
+ const rlim_t def_val = INT64_MIN + 1, err_val = INT64_MIN;
+ rlim_t val;
+
+ /* If value is "inherit", nothing to change. */
+ if (login_getcapenum(lc, "umask", inherit_enum) == 0)
+ return;
+
+ val = login_getcapnum(lc, "umask", def_val, err_val);
+
+ if (val != def_val) {
+ if (val < 0 || val > UINT16_MAX) {
+ /* We get here also on 'err_val'. */
+ syslog(LOG_WARNING,
+ "%s%s%sLogin class '%s': "
+ "Invalid umask specification: '%s'",
+ pwd ? "Login '" : "",
+ pwd ? pwd->pw_name : "",
+ pwd ? "': " : "",
+ lc->lc_class,
+ login_getcapstr(lc, "umask", "", ""));
+ } else {
+ const mode_t mode = val;
+
+ umask(mode);
+ }
+ }
+}
/*
* Private function which takes care of processing
*/
-static mode_t
-setlogincontext(login_cap_t *lc, const struct passwd *pwd,
- mode_t mymask, unsigned long flags)
+static void
+setlogincontext(login_cap_t *lc, const struct passwd *pwd, unsigned long flags)
{
- if (lc) {
- /* Set resources */
- if (flags & LOGIN_SETRESOURCES)
- setclassresources(lc);
- /* See if there's a umask override */
- if (flags & LOGIN_SETUMASK)
- mymask = (mode_t)login_getcapnum(lc, "umask", mymask, mymask);
- /* Set paths */
- if (flags & LOGIN_SETPATH)
- setclassenvironment(lc, pwd, 1);
- /* Set environment */
- if (flags & LOGIN_SETENV)
- setclassenvironment(lc, pwd, 0);
- /* Set cpu affinity */
- if (flags & LOGIN_SETCPUMASK)
- setclasscpumask(lc);
- }
- return (mymask);
+ if (lc == NULL)
+ return;
+
+ /* Set resources. */
+ if ((flags & LOGIN_SETRESOURCES) != 0)
+ setclassresources(lc);
+
+ /* See if there's a umask override. */
+ if ((flags & LOGIN_SETUMASK) != 0)
+ setclassumask(lc, pwd);
+
+ /* Set paths. */
+ if ((flags & LOGIN_SETPATH) != 0)
+ setclassenvironment(lc, pwd, 1);
+
+ /* Set environment. */
+ if ((flags & LOGIN_SETENV) != 0)
+ setclassenvironment(lc, pwd, 0);
+
+ /* Set cpu affinity. */
+ if ((flags & LOGIN_SETCPUMASK) != 0)
+ setclasscpumask(lc);
}
+/*
+ * Private function to set process priority.
+ */
+static void
+setclasspriority(login_cap_t * const lc, struct passwd const * const pwd)
+{
+ const rlim_t def_val = 0, err_val = INT64_MIN;
+ rlim_t p;
+ int rc;
+
+ /* If value is "inherit", nothing to change. */
+ if (login_getcapenum(lc, "priority", inherit_enum) == 0)
+ return;
+
+ p = login_getcapnum(lc, "priority", def_val, err_val);
+
+ if (p == err_val) {
+ /* Invariant: 'lc' != NULL. */
+ syslog(LOG_WARNING,
+ "%s%s%sLogin class '%s': "
+ "Invalid priority specification: '%s'",
+ pwd ? "Login '" : "",
+ pwd ? pwd->pw_name : "",
+ pwd ? "': " : "",
+ lc->lc_class,
+ login_getcapstr(lc, "priority", "", ""));
+ /* Reset the priority, as if the capability was not present. */
+ p = def_val;
+ }
+
+ if (p > PRIO_MAX) {
+ struct rtprio rtp;
+
+ rtp.type = RTP_PRIO_IDLE;
+ p += RTP_PRIO_MIN - (PRIO_MAX + 1);
+ rtp.prio = p > RTP_PRIO_MAX ? RTP_PRIO_MAX : p;
+ rc = rtprio(RTP_SET, 0, &rtp);
+ } else if (p < PRIO_MIN) {
+ struct rtprio rtp;
+
+ rtp.type = RTP_PRIO_REALTIME;
+ p += RTP_PRIO_MAX - (PRIO_MIN - 1);
+ rtp.prio = p < RTP_PRIO_MIN ? RTP_PRIO_MIN : p;
+ rc = rtprio(RTP_SET, 0, &rtp);
+ } else
+ rc = setpriority(PRIO_PROCESS, 0, (int)p);
+
+ if (rc != 0)
+ syslog(LOG_WARNING,
+ "%s%s%sLogin class '%s': "
+ "Setting priority failed: %m",
+ pwd ? "Login '" : "",
+ pwd ? pwd->pw_name : "",
+ pwd ? "': " : "",
+ lc ? lc->lc_class : "<none>");
+}
/*
* setusercontext()
@@ -428,10 +530,7 @@ setlogincontext(login_cap_t *lc, const struct passwd *pwd,
int
setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned int flags)
{
- rlim_t p;
- mode_t mymask;
login_cap_t *llc = NULL;
- struct rtprio rtp;
int error;
if (lc == NULL) {
@@ -447,32 +546,8 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in
flags &= ~(LOGIN_SETGROUP | LOGIN_SETLOGIN | LOGIN_SETMAC);
/* Set the process priority */
- if (flags & LOGIN_SETPRIORITY) {
- p = login_getcapnum(lc, "priority", LOGIN_DEFPRI, LOGIN_DEFPRI);
-
- if (p > PRIO_MAX) {
- rtp.type = RTP_PRIO_IDLE;
- p -= PRIO_MAX + 1;
- rtp.prio = p > RTP_PRIO_MAX ? RTP_PRIO_MAX : p;
- if (rtprio(RTP_SET, 0, &rtp))
- syslog(LOG_WARNING, "rtprio '%s' (%s): %m",
- pwd ? pwd->pw_name : "-",
- lc ? lc->lc_class : LOGIN_DEFCLASS);
- } else if (p < PRIO_MIN) {
- rtp.type = RTP_PRIO_REALTIME;
- p -= PRIO_MIN - RTP_PRIO_MAX;
- rtp.prio = p < RTP_PRIO_MIN ? RTP_PRIO_MIN : p;
- if (rtprio(RTP_SET, 0, &rtp))
- syslog(LOG_WARNING, "rtprio '%s' (%s): %m",
- pwd ? pwd->pw_name : "-",
- lc ? lc->lc_class : LOGIN_DEFCLASS);
- } else {
- if (setpriority(PRIO_PROCESS, 0, (int)p) != 0)
- syslog(LOG_WARNING, "setpriority '%s' (%s): %m",
- pwd ? pwd->pw_name : "-",
- lc ? lc->lc_class : LOGIN_DEFCLASS);
- }
- }
+ if (flags & LOGIN_SETPRIORITY)
+ setclasspriority(lc, pwd);
/* Setup the user's group permissions */
if (flags & LOGIN_SETGROUP) {
@@ -533,8 +608,7 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in
}
}
- mymask = (flags & LOGIN_SETUMASK) ? umask(LOGIN_DEFUMASK) : 0;
- mymask = setlogincontext(lc, pwd, mymask, flags);
+ setlogincontext(lc, pwd, flags);
login_close(llc);
/* This needs to be done after anything that needs root privs */
@@ -546,14 +620,12 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in
/*
* Now, we repeat some of the above for the user's private entries
*/
- if (getuid() == uid && (lc = login_getuserclass(pwd)) != NULL) {
- mymask = setlogincontext(lc, pwd, mymask, flags);
+ if (geteuid() == uid && (lc = login_getuserclass(pwd)) != NULL) {
+ setlogincontext(lc, pwd, flags);
+ if (flags & LOGIN_SETPRIORITY)
+ setclasspriority(lc, pwd);
login_close(lc);
}
- /* Finally, set any umask we've found */
- if (flags & LOGIN_SETUMASK)
- umask(mymask);
-
return (0);
}
diff --git a/lib/libutil/login_crypt.c b/lib/libutil/login_crypt.c
index f82bdbc7258d..6525da9ee6a6 100644
--- a/lib/libutil/login_crypt.c
+++ b/lib/libutil/login_crypt.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <login_cap.h>
diff --git a/lib/libutil/login_ok.c b/lib/libutil/login_ok.c
index 22464ce2ada1..e5bec9e86bfc 100644
--- a/lib/libutil/login_ok.c
+++ b/lib/libutil/login_ok.c
@@ -21,7 +21,6 @@
* Support allow/deny lists in login class capabilities
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/lib/libutil/login_times.c b/lib/libutil/login_times.c
index 1f5b2e2742c5..f240460cdb4c 100644
--- a/lib/libutil/login_times.c
+++ b/lib/libutil/login_times.c
@@ -21,7 +21,6 @@
* Login period parsing and comparison functions.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ctype.h>
#include <login_cap.h>
diff --git a/lib/libutil/login_tty.c b/lib/libutil/login_tty.c
index 705ab0bad20e..1e5ade32c920 100644
--- a/lib/libutil/login_tty.c
+++ b/lib/libutil/login_tty.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)login_tty.c 8.1 (Berkeley) 6/4/93");
#include <sys/param.h>
diff --git a/lib/libutil/mntopts.3 b/lib/libutil/mntopts.3
new file mode 100644
index 000000000000..35f6d476fcec
--- /dev/null
+++ b/lib/libutil/mntopts.3
@@ -0,0 +1,377 @@
+.\" Copyright (c) 2023 Marshall Kirk McKusick
+.\" Copyright (c) 1994 The Regents of the University of California.
+.\"
+.\" 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 AUTHORS 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 AUTHORS 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.
+.\"
+.Dd April 21, 2025
+.Dt MNTOPTS 3
+.Os
+.Sh NAME
+.Nm getmntopts ,
+.Nm getmntpoint ,
+.Nm chkdoreload ,
+.Nm build_iovec ,
+.Nm build_iovec_argf ,
+.Nm free_iovec ,
+.Nm checkpath ,
+.Nm rmslashes
+.Nd "mount point operations"
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.In mntopts.h
+.Ft void
+.Fo getmntopts
+.Fa "const char *options" "const struct mntopt *mopts"
+.Fa "int *flagp" "int *altflagp"
+.Fc
+.Ft struct statfs *
+.Fn getmntpoint "const char *name"
+.Ft int
+.Fo chkdoreload
+.Fa "struct statfs *mntp"
+.Fa "void (*prtmsg)(const char *fmt, ...)"
+.Fc
+.Ft void
+.Fo build_iovec
+.Fa "struct iovec **iov" "int *iovlen" "const char *name" "void *val"
+.Fa "size_t len"
+.Fc
+.Ft void
+.Fo build_iovec_argf
+.Fa "struct iovec **iov" "int *iovlen" "const char *name"
+.Fa "const char *fmt" "..."
+.Fc
+.Ft void
+.Fn free_iovec "struct iovec **iov" "int *iovlen"
+.Ft int
+.Fn checkpath "const char *path" "char *resolved"
+.Ft void
+.Fn rmslashes "char *rrpin" "char *rrpout"
+.Sh DESCRIPTION
+The
+.Nm mntopts
+functions support operations associated with a mount point.
+.Pp
+The
+.Fn getmntopts
+function takes a comma separated option list and a list
+of valid option names, and computes the bitmask
+corresponding to the requested set of options.
+.Pp
+The string
+.Fa options
+is broken down into a sequence of comma separated tokens.
+Each token is looked up in the table described by
+.Fa mopts
+and the bits in
+the word referenced by either
+.Fa flagp
+or
+.Fa altflagp
+(depending on the
+.Va m_altloc
+field of the option's table entry)
+are updated.
+The flag words are not initialized by
+.Fn getmntopts .
+The table,
+.Fa mopts ,
+has the following format:
+.Bd -literal
+struct mntopt {
+ char *m_option; /* option name */
+ int m_inverse; /* is this a negative option, e.g., "dev" */
+ int m_flag; /* bit to set, e.g., MNT_RDONLY */
+ int m_altloc; /* non-zero to use altflagp rather than flagp */
+};
+.Ed
+.Pp
+The members of this structure are:
+.Bl -tag -width m_inverse
+.It Va m_option
+the option name,
+for example
+.Dq Li suid .
+.It Va m_inverse
+tells
+.Fn getmntopts
+that the name has the inverse meaning of the
+bit.
+For example,
+.Dq Li suid
+is the string, whereas the
+mount flag is
+.Dv MNT_NOSUID .
+In this case, the sense of the string and the flag
+are inverted, so the
+.Va m_inverse
+flag should be set.
+.It Va m_flag
+the value of the bit to be set or cleared in
+the flag word when the option is recognized.
+The bit is set when the option is discovered,
+but cleared if the option name was preceded
+by the letters
+.Dq Li no .
+The
+.Va m_inverse
+flag causes these two operations to be reversed.
+.It Va m_altloc
+the bit should be set or cleared in
+.Fa altflagp
+rather than
+.Fa flagp .
+.El
+.Pp
+Each of the user visible
+.Dv MNT_
+flags has a corresponding
+.Dv MOPT_
+macro which defines an appropriate
+.Vt "struct mntopt"
+entry.
+To simplify the program interface and ensure consistency across all
+programs, a general purpose macro,
+.Dv MOPT_STDOPTS ,
+is defined which
+contains an entry for all the generic VFS options.
+In addition, the macros
+.Dv MOPT_FORCE
+and
+.Dv MOPT_UPDATE
+exist to enable the
+.Dv MNT_FORCE
+and
+.Dv MNT_UPDATE
+flags to be set.
+Finally, the table must be terminated by an entry with a
+.Dv NULL
+first element.
+.Pp
+The
+.Fn getmntpoint
+function takes the pathname of a possible mount point
+or of a device (with or without
+.Pa /dev/
+prepended to it).
+If the pathname is a directory or a file,
+.Fn getmntpoint
+checks to see if the mount point currently has a filesystem
+mounted on it.
+If the pathname is a device,
+.Fn getmntpoint
+checks to see if it is currently mounted.
+If there is an associated mount, a pointer to a
+.Vt "struct statfs"
+is returned.
+The returned result is stored in a static buffer that is over-written
+each time the
+.Fn getmntpoint
+function or the
+.Xr getmntinfo 3
+library routine is called.
+If no mount is found, NULL is returned.
+.Pp
+The
+.Fn chkdoreload
+function takes a pointer to a
+.Vt "struct statfs" .
+If the filesystem associated with the mount point is mounted read-only,
+.Fn chkdoreload
+requests the filesystem to reload all of its metadata from its backing store.
+The second parameter is the function to call to print an error message
+if the reload fails.
+If no error message is desired, a
+.Dv NULL
+can be passed as the second argument.
+The
+.Fn chkdoreload
+function returns zero on success or non-zero on failure.
+.Pp
+The
+.Fn build_iovec
+function adds a parameter to a list of parameters to be passed to the
+.Xr nmount 2
+system call.
+The parameter list is built up in
+.Va iov
+and its length is kept in
+.Va iovlen .
+Before the first call to
+.Fn build_iovec ,
+.Va iov
+should be set to
+.Dv NULL
+and
+.Va iovlen
+should be set to 0.
+The parameter name is passed in
+.Va name .
+The value of the parameter name is pointed to by
+.Va val .
+The size of the value is passed in
+.Va len .
+If the value is a string, a
+.Va len
+of -1 is passed to indicate that the length should be determined using
+.Xr strlen 3 .
+If the parameter has no value,
+.Va name
+should be
+.Dv NULL
+and
+.Va len
+should be 0.
+.Pp
+The
+.Fn build_iovec_argf
+function adds a formatted parameter to a list of parameters to be passed
+to the
+.Xr nmount 2
+system call.
+The parameter list is built up in
+.Va iov
+and its length is kept in
+.Va iovlen .
+Before the first call to
+.Fn build_iovec_argf ,
+.Va iov
+should be set to
+.Dv NULL
+and
+.Va iovlen
+should be set to 0.
+The parameter name is passed in
+.Va name .
+The value of the parameter name is described by a format string pointed to by
+.Va fmt .
+If the parameter has no value,
+.Va name
+should be
+.Dv NULL .
+.Pp
+The
+.Fn free_iovec
+function frees the memory in the
+.Va iov
+vector of the length specified in
+.Va iovlen
+that was previously allocated by the
+.Fn build_iovec
+and / or
+.Fn build_iovec_argf
+functions.
+The
+.Va iov
+is set to
+.Dv NULL
+and the
+.Va iovlen
+is set to 0 to indicate that the space has been freed.
+.Pp
+The
+.Fn checkpath
+function uses
+.Xr realpath 3
+to verify that its
+.Va path
+argument is valid and references a directory.
+The
+.Fn checkpath
+function returns zero on success or non-zero on failure.
+.Pp
+The
+.Fn rmslashes
+function removes all double slashes and trailing slashes from its
+.Va rrpin
+pathname parameter and returns the resulting pathname in its
+.Va rrpout
+parameter.
+.Sh EXAMPLES
+Most commands will use the standard option set.
+Local file systems which support the
+.Dv MNT_UPDATE
+flag, would also have an
+.Dv MOPT_UPDATE
+entry.
+This can be declared and used as follows:
+.Bd -literal
+#include <mntopts.h>
+
+struct mntopt mopts[] = {
+ MOPT_STDOPTS,
+ MOPT_UPDATE,
+ { NULL }
+};
+
+ ...
+ mntflags = mntaltflags = 0;
+ ...
+ getmntopts(options, mopts, &mntflags, &mntaltflags);
+ ...
+.Ed
+.Sh DIAGNOSTICS
+If the external integer variable
+.Va getmnt_silent
+is zero, then the
+.Fn getmntopts
+function displays an error message and exits if an
+unrecognized option is encountered.
+Otherwise unrecognized options are silently ignored.
+By default
+.Va getmnt_silent
+is zero.
+.Sh SEE ALSO
+.Xr err 3 ,
+.Xr mount 8 ,
+.Xr nmount 8
+.Sh HISTORY
+The
+.Fn getmntopts
+function appeared in
+.Bx 4.4 .
+The
+.Fn build_iovec ,
+.Fn build_iovec_argf ,
+.Fn free_iovec ,
+.Fn checkpath ,
+and
+.Fn rmslashes
+functions were added with
+.Xr nmount 8
+in
+.Fx 5.0 .
+The
+.Fn getmntpoint
+and
+.Fn chkdoreload
+functions were added in
+.Fx 13.2 .
+.Pp
+Historically, these functions were found in getmntopts.c in the sources for the
+.Xr mount 8
+program.
+As of
+.Fx 15.0
+they are part of
+.Nm libutil .
diff --git a/lib/libutil/mntopts.c b/lib/libutil/mntopts.c
new file mode 100644
index 000000000000..1d9347e3108a
--- /dev/null
+++ b/lib/libutil/mntopts.c
@@ -0,0 +1,300 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1994
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/uio.h>
+
+#include <err.h>
+#include <errno.h>
+#include <mntopts.h>
+#include <paths.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int getmnt_silent = 0;
+
+void
+getmntopts(const char *options, const struct mntopt *m0, int *flagp,
+ int *altflagp)
+{
+ const struct mntopt *m;
+ int negative, len;
+ char *opt, *optbuf, *p;
+ int *thisflagp;
+
+ /* Copy option string, since it is about to be torn asunder... */
+ if ((optbuf = strdup(options)) == NULL)
+ err(1, NULL);
+
+ for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
+ /* Check for "no" prefix. */
+ if (opt[0] == 'n' && opt[1] == 'o') {
+ negative = 1;
+ opt += 2;
+ } else
+ negative = 0;
+
+ /*
+ * for options with assignments in them (ie. quotas)
+ * ignore the assignment as it's handled elsewhere
+ */
+ p = strchr(opt, '=');
+ if (p != NULL)
+ *++p = '\0';
+
+ /* Scan option table. */
+ for (m = m0; m->m_option != NULL; ++m) {
+ len = strlen(m->m_option);
+ if (strncasecmp(opt, m->m_option, len) == 0)
+ if (opt[len] == '\0' || opt[len] == '=')
+ break;
+ }
+
+ /* Save flag, or fail if option is not recognized. */
+ if (m->m_option) {
+ thisflagp = m->m_altloc ? altflagp : flagp;
+ if (negative == m->m_inverse)
+ *thisflagp |= m->m_flag;
+ else
+ *thisflagp &= ~m->m_flag;
+ } else if (!getmnt_silent) {
+ errx(1, "-o %s: option not supported", opt);
+ }
+ }
+
+ free(optbuf);
+}
+
+void
+rmslashes(char *rrpin, char *rrpout)
+{
+ char *rrpoutstart;
+
+ *rrpout = *rrpin;
+ for (rrpoutstart = rrpout; *rrpin != '\0'; *rrpout++ = *rrpin++) {
+
+ /* skip all double slashes */
+ while (*rrpin == '/' && *(rrpin + 1) == '/')
+ rrpin++;
+ }
+
+ /* remove trailing slash if necessary */
+ if (rrpout - rrpoutstart > 1 && *(rrpout - 1) == '/')
+ *(rrpout - 1) = '\0';
+ else
+ *rrpout = '\0';
+}
+
+int
+checkpath(const char *path, char *resolved)
+{
+ struct stat sb;
+
+ if (realpath(path, resolved) == NULL || stat(resolved, &sb) != 0)
+ return (1);
+ if (!S_ISDIR(sb.st_mode)) {
+ errno = ENOTDIR;
+ return (1);
+ }
+ return (0);
+}
+
+int
+checkpath_allow_file(const char *path, char *resolved)
+{
+ struct stat sb;
+
+ if (realpath(path, resolved) == NULL || stat(resolved, &sb) != 0)
+ return (1);
+ if (!S_ISDIR(sb.st_mode) && !S_ISREG(sb.st_mode)) {
+ errno = ENOTDIR;
+ return (1);
+ }
+ return (0);
+}
+
+/*
+ * Get the mount point information for name. Name may be mount point name
+ * or device name (with or without /dev/ preprended).
+ */
+struct statfs *
+getmntpoint(const char *name)
+{
+ struct stat devstat, mntdevstat;
+ char device[sizeof(_PATH_DEV) - 1 + MNAMELEN];
+ char *ddevname;
+ struct statfs *mntbuf, *statfsp;
+ int i, mntsize, isdev;
+ u_long len;
+
+ if (stat(name, &devstat) != 0)
+ return (NULL);
+ if (S_ISCHR(devstat.st_mode) || S_ISBLK(devstat.st_mode))
+ isdev = 1;
+ else
+ isdev = 0;
+ mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+ for (i = 0; i < mntsize; i++) {
+ statfsp = &mntbuf[i];
+ if (isdev == 0) {
+ if (strcmp(name, statfsp->f_mntonname))
+ continue;
+ return (statfsp);
+ }
+ ddevname = statfsp->f_mntfromname;
+ if (*ddevname != '/') {
+ if ((len = strlen(_PATH_DEV) + strlen(ddevname) + 1) >
+ sizeof(statfsp->f_mntfromname) ||
+ len > sizeof(device))
+ continue;
+ strncpy(device, _PATH_DEV, len);
+ strncat(device, ddevname, len);
+ if (stat(device, &mntdevstat) == 0)
+ strncpy(statfsp->f_mntfromname, device, len);
+ }
+ if (stat(ddevname, &mntdevstat) == 0 &&
+ mntdevstat.st_rdev == devstat.st_rdev)
+ return (statfsp);
+ }
+ return (NULL);
+}
+
+/*
+ * If possible reload a mounted filesystem.
+ * When prtmsg != NULL print a warning if a reload is attempted, but fails.
+ * Return 0 on success, 1 on failure.
+ */
+int
+chkdoreload(struct statfs *mntp,
+ void (*prtmsg)(const char *, ...) __printflike(1,2))
+{
+ struct iovec *iov;
+ int iovlen, error;
+ char errmsg[255];
+
+ /*
+ * If the filesystem is not mounted it does not need to be reloaded.
+ * If it is mounted for writing, then it could not have been opened
+ * for writing by a utility, so does not need to be reloaded.
+ */
+ if (mntp == NULL || (mntp->f_flags & MNT_RDONLY) == 0)
+ return (0);
+
+ /*
+ * We modified a mounted file system. Do a mount update on
+ * it so we can continue using it as safely as possible.
+ */
+ iov = NULL;
+ iovlen = 0;
+ errmsg[0] = '\0';
+ build_iovec(&iov, &iovlen, "fstype", __DECONST(void *, "ffs"), 4);
+ build_iovec(&iov, &iovlen, "from", mntp->f_mntfromname, (size_t)-1);
+ build_iovec(&iov, &iovlen, "fspath", mntp->f_mntonname, (size_t)-1);
+ build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
+ build_iovec(&iov, &iovlen, "update", NULL, 0);
+ build_iovec(&iov, &iovlen, "reload", NULL, 0);
+ /*
+ * XX: We need the following line until we clean up
+ * nmount parsing of root mounts and NFS root mounts.
+ */
+ build_iovec(&iov, &iovlen, "ro", NULL, 0);
+ error = nmount(iov, iovlen, mntp->f_flags);
+ free_iovec(&iov, &iovlen);
+ if (error == 0)
+ return (0);
+ if (prtmsg != NULL)
+ prtmsg("mount reload of '%s' failed: %s %s\n\n",
+ mntp->f_mntonname, strerror(errno), errmsg);
+ return (1);
+}
+
+void
+build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val,
+ size_t len)
+{
+ int i;
+
+ if (*iovlen < 0)
+ return;
+ i = *iovlen;
+ *iov = realloc(*iov, sizeof **iov * (i + 2));
+ if (*iov == NULL) {
+ *iovlen = -1;
+ return;
+ }
+ (*iov)[i].iov_base = strdup(name);
+ (*iov)[i].iov_len = strlen(name) + 1;
+ i++;
+ (*iov)[i].iov_base = val;
+ if (len == (size_t)-1) {
+ if (val != NULL)
+ len = strlen(val) + 1;
+ else
+ len = 0;
+ }
+ (*iov)[i].iov_len = (int)len;
+ *iovlen = ++i;
+}
+
+/*
+ * This function is needed for compatibility with parameters
+ * which used to use the mount_argf() command for the old mount() syscall.
+ */
+void
+build_iovec_argf(struct iovec **iov, int *iovlen, const char *name,
+ const char *fmt, ...)
+{
+ va_list ap;
+ char val[255] = { 0 };
+
+ va_start(ap, fmt);
+ vsnprintf(val, sizeof(val), fmt, ap);
+ va_end(ap);
+ build_iovec(iov, iovlen, name, strdup(val), (size_t)-1);
+}
+
+/*
+ * Free the iovec and reset to NULL with zero length. Useful for calling
+ * nmount in a loop.
+ */
+void
+free_iovec(struct iovec **iov, int *iovlen)
+{
+ int i;
+
+ for (i = 0; i < *iovlen; i += 2)
+ free((*iov)[i].iov_base);
+ free(*iov);
+}
diff --git a/lib/libutil/mntopts.h b/lib/libutil/mntopts.h
new file mode 100644
index 000000000000..0027b8ca7155
--- /dev/null
+++ b/lib/libutil/mntopts.h
@@ -0,0 +1,114 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1994
+ * 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.
+ */
+
+#ifndef _MNTOPTS_H_
+#define _MNTOPTS_H_
+
+struct mntopt {
+ const char *m_option; /* option name */
+ int m_inverse; /* if a negative option, e.g. "atime" */
+ long long m_flag; /* bit to set, e.g. MNT_RDONLY */
+ int m_altloc; /* 1 => set bit in altflags */
+};
+
+/* User-visible MNT_ flags. */
+#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 }
+#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 }
+#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 }
+#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 }
+#define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 }
+#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 }
+#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 }
+#define MOPT_UNION { "union", 0, MNT_UNION, 0 }
+#define MOPT_USERQUOTA { "userquota", 0, 0, 0 }
+#define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 }
+#define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 }
+#define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 }
+#define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 }
+#define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 }
+#define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 }
+#define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 }
+#define MOPT_NFS4ACLS { "nfsv4acls", 0, MNT_NFS4ACLS, 0 }
+#define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 }
+#define MOPT_UNTRUSTED { "untrusted", 0, MNT_UNTRUSTED, 0 }
+
+/* Control flags. */
+#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
+#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
+#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
+#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
+#define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 }
+#define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 }
+/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
+#define MOPT_AUTO { "auto", 0, 0, 0 }
+
+/* A handy macro as terminator of MNT_ array. */
+#define MOPT_END { NULL, 0, 0, 0 }
+
+#define MOPT_FSTAB_COMPAT \
+ MOPT_RO, \
+ MOPT_RW, \
+ MOPT_AUTO
+
+/* Standard options which all mounts can understand. */
+#define MOPT_STDOPTS \
+ MOPT_USERQUOTA, \
+ MOPT_GROUPQUOTA, \
+ MOPT_FSTAB_COMPAT, \
+ MOPT_NOATIME, \
+ MOPT_NOEXEC, \
+ MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \
+ MOPT_NOSUID, \
+ MOPT_NOSYMFOLLOW, \
+ MOPT_RDONLY, \
+ MOPT_UNION, \
+ MOPT_NOCLUSTERR, \
+ MOPT_NOCLUSTERW, \
+ MOPT_MULTILABEL, \
+ MOPT_ACLS, \
+ MOPT_NFS4ACLS, \
+ MOPT_AUTOMOUNTED, \
+ MOPT_UNTRUSTED, \
+ MOPT_NOCOVER, \
+ MOPT_EMPTYDIR
+
+void getmntopts(const char *, const struct mntopt *, int *, int *);
+void rmslashes(char *, char *);
+int checkpath(const char *, char resolved_path[]);
+int checkpath_allow_file(const char *, char resolved_path[]);
+struct statfs *getmntpoint(const char *);
+int chkdoreload(struct statfs *, void (*)(const char *, ...) __printflike(1,2));
+extern int getmnt_silent;
+void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len);
+void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...);
+void free_iovec(struct iovec **iovec, int *iovlen);
+
+#endif /* !_MNTOPTS_H_ */
diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3
index c4786736d28f..d28d5ed8eccb 100644
--- a/lib/libutil/pidfile.3
+++ b/lib/libutil/pidfile.3
@@ -22,14 +22,16 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 10, 2020
+.Dd August 2, 2025
.Dt PIDFILE 3
.Os
.Sh NAME
.Nm pidfile_open ,
.Nm pidfile_write ,
.Nm pidfile_close ,
-.Nm pidfile_remove
+.Nm pidfile_remove ,
+.Nm pidfile_fileno ,
+.Nm pidfile_signal
.Nd "library for PID files handling"
.Sh LIBRARY
.Lb libutil
@@ -45,6 +47,8 @@
.Fn pidfile_remove "struct pidfh *pfh"
.Ft int
.Fn pidfile_fileno "struct pidfh *pfh"
+.Ft int
+.Fn pidfile_signal "const char *path" "int sig" "pid_t *pidptr"
.Sh DESCRIPTION
The
.Nm pidfile
@@ -101,6 +105,26 @@ function closes and removes a pidfile.
The
.Fn pidfile_fileno
function returns the file descriptor for the open pidfile.
+.Pp
+The
+.Fn pidfile_signal
+function looks for the pidfile specified by
+.Va path ,
+and if it exists and is locked, sends the signal specified by
+.Va sig
+to the PID it contains.
+If
+.Va pidptr
+is not
+.Dv NULL ,
+the PID that was found in the pidfile is stored in the location it
+points to.
+Note that calling
+.Fn pidfile_signal
+with
+.Va sig
+set to zero is an effective way to verify the existence of a pidfile
+and of the process that owns it.
.Sh RETURN VALUES
The
.Fn pidfile_open
@@ -125,6 +149,13 @@ and sets
if a NULL
.Vt pidfh
is specified, or if the pidfile is no longer open.
+.Pp
+The
+.Fn pidfile_signal
+function returns 0 if it successfully signaled a process, and an
+appropriate
+.Va errno
+value otherwise.
.Sh EXAMPLES
The following example shows in which order these functions should be used.
Note that it is safe to pass
@@ -132,7 +163,7 @@ Note that it is safe to pass
to
.Fn pidfile_write ,
.Fn pidfile_remove ,
-.Fn pidfile_close
+.Fn pidfile_close ,
and
.Fn pidfile_fileno
functions.
@@ -280,7 +311,28 @@ Improper function use.
Probably called not from the process which used
.Fn pidfile_open .
.El
+.Pp
+The
+.Fn pidfile_signal
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er ENOENT
+The pidfile does not exist, or exists but is not locked.
+.It Bq Er EDOM
+The pidfile contains a negative number.
+.El
+.Pp
+The
+.Fn pidfile_signal
+function may also fail and return any of the
+.Va errno
+values specified for the
+.Fn pidfile_read
+function and the
+.Xr kill 2
+system call.
.Sh SEE ALSO
+.Xr kill 2 ,
.Xr open 2 ,
.Xr daemon 3 ,
.Xr flopen 3
@@ -288,11 +340,19 @@ Probably called not from the process which used
The functions
.Fn pidfile_open ,
.Fn pidfile_write ,
-.Fn pidfile_close
+.Fn pidfile_close ,
and
.Fn pidfile_remove
first appeared in
.Fx 5.5 .
+The
+.Fn pidfile_fileno
+function was added in
+.Fx 9.1 .
+The
+.Fn pidfile_signal
+function was added in
+.Fx 14.0 .
.Sh AUTHORS
.An -nosplit
The
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index 0563175b97c9..4c365a55842c 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/capsicum.h>
diff --git a/lib/libutil/property.c b/lib/libutil/property.c
index 45e1cd85f940..34a7381c7f75 100644
--- a/lib/libutil/property.c
+++ b/lib/libutil/property.c
@@ -31,7 +31,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
diff --git a/lib/libutil/pty.c b/lib/libutil/pty.c
index e5b42a666c7f..28252af57abf 100644
--- a/lib/libutil/pty.c
+++ b/lib/libutil/pty.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)pty.c 8.3 (Berkeley) 5/16/94");
#include <sys/types.h>
#include <sys/ioctl.h>
diff --git a/lib/libutil/pw_util.3 b/lib/libutil/pw_util.3
index ed05818cd16a..a6bb71600441 100644
--- a/lib/libutil/pw_util.3
+++ b/lib/libutil/pw_util.3
@@ -31,6 +31,7 @@
.Nm pw_edit ,
.Nm pw_equal ,
.Nm pw_fini ,
+.Nm pw_initpwd ,
.Nm pw_init ,
.Nm pw_make ,
.Nm pw_make_v7 ,
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index 24e7e3bd6d36..f08b763e4991 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -36,8 +36,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)pw_util.c 8.3 (Berkeley) 4/2/94");
/*
* This file is used by all the "password" programs; vipw(8), chpass(1),
diff --git a/lib/libutil/realhostname.c b/lib/libutil/realhostname.c
index 02dca54af7a5..aa50a5835195 100644
--- a/lib/libutil/realhostname.c
+++ b/lib/libutil/realhostname.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/lib/libutil/tests/Makefile b/lib/libutil/tests/Makefile
index d29045d78a10..cdcf3466aec8 100644
--- a/lib/libutil/tests/Makefile
+++ b/lib/libutil/tests/Makefile
@@ -1,4 +1,3 @@
-
TAP_TESTS_C+= flopen_test
TAP_TESTS_C+= grp_test
TAP_TESTS_C+= humanize_number_test
diff --git a/lib/libutil/tests/expand_number_test.c b/lib/libutil/tests/expand_number_test.c
index 6bf3ff082ee4..8e7458994de4 100644
--- a/lib/libutil/tests/expand_number_test.c
+++ b/lib/libutil/tests/expand_number_test.c
@@ -1,7 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2023 Google LLC
+ * Copyright (c) 2019 John Baldwin <jhb@FreeBSD.org>
+ * Copyright (c) 2025 Dag-Erling Smørgrav <des@FreeBSD.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,60 +26,190 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#include <atf-c.h>
#include <errno.h>
#include <libutil.h>
+#include <stdint.h>
-#include <atf-c.h>
+static void
+require_success(const char *str, int64_t exp_val)
+{
+ int64_t val;
-ATF_TC_WITHOUT_HEAD(positivetests);
-ATF_TC_BODY(positivetests, tc)
+ ATF_REQUIRE_MSG(expand_number(str, &val) == 0,
+ "Failed to parse '%s': %m", str);
+ ATF_REQUIRE_MSG(val == exp_val,
+ "String '%s' parsed as %jd instead of expected %jd", str,
+ (intmax_t)val, (intmax_t)exp_val);
+}
+
+static void
+require_error(const char *str, int exp_errno)
{
- int retval;
- uint64_t num;
-
-#define positive_tc(string, value) \
- do { \
- ATF_CHECK_ERRNO(0, (retval = expand_number((string), &num)) == 0); \
- ATF_CHECK_EQ(retval, 0); \
- ATF_CHECK_EQ(num, (value)); \
- } while (0)
-
- positive_tc("123456", 123456);
- positive_tc("123456b", 123456);
- positive_tc("1k", 1024);
- positive_tc("1kb", 1024);
- positive_tc("1K", 1024);
- positive_tc("1KB", 1024);
- positive_tc("1m", 1048576);
- positive_tc("1M", 1048576);
- positive_tc("1g", 1073741824);
- positive_tc("1G", 1073741824);
- positive_tc("1t", 1099511627776);
- positive_tc("1T", 1099511627776);
- positive_tc("1p", 1125899906842624);
- positive_tc("1P", 1125899906842624);
- positive_tc("1e", 1152921504606846976);
- positive_tc("1E", 1152921504606846976);
- positive_tc("15E", 17293822569102704640ULL);
+ int64_t val;
+
+ ATF_REQUIRE_MSG(expand_number(str, &val) == -1,
+ "String '%s' parsed as %jd instead of error", str, (intmax_t)val);
+ ATF_REQUIRE_MSG(errno == exp_errno,
+ "String '%s' failed with %d instead of expected %d", str, errno,
+ exp_errno);
+}
+
+ATF_TC_WITHOUT_HEAD(expand_number__ok);
+ATF_TC_BODY(expand_number__ok, tp)
+{
+ /* Bare numbers. */
+ require_success("-0", 0);
+ require_success(" 0", 0);
+ require_success("+0", 0);
+ require_success("-1", -1);
+ require_success(" 1", 1);
+ require_success("+1", 1);
+ require_success("-10", -10);
+ require_success(" 10", 10);
+ require_success("+10", 10);
+
+ /* Uppercase suffixes. */
+ require_success("1B", 1);
+ require_success("1K", 1LL << 10);
+ require_success("1M", 1LL << 20);
+ require_success("1G", 1LL << 30);
+ require_success("1T", 1LL << 40);
+ require_success("1P", 1LL << 50);
+ require_success("1E", 1LL << 60);
+
+ /* Lowercase suffixes. */
+ require_success("2b", 2);
+ require_success("2k", 2LL << 10);
+ require_success("2m", 2LL << 20);
+ require_success("2g", 2LL << 30);
+ require_success("2t", 2LL << 40);
+ require_success("2p", 2LL << 50);
+ require_success("2e", 2LL << 60);
+
+ /* Suffixes with a trailing 'b'. */
+ require_success("3KB", 3LL << 10);
+ require_success("3MB", 3LL << 20);
+ require_success("3GB", 3LL << 30);
+ require_success("3TB", 3LL << 40);
+ require_success("3PB", 3LL << 50);
+ require_success("3EB", 3LL << 60);
+
+ /* Negative numbers. */
+ require_success("-1", -1);
+ require_success("-10", -10);
+ require_success("-1B", -1);
+ require_success("-1K", -(1LL << 10));
+ require_success("-1M", -(1LL << 20));
+ require_success("-1G", -(1LL << 30));
+ require_success("-1T", -(1LL << 40));
+ require_success("-1P", -(1LL << 50));
+ require_success("-1E", -(1LL << 60));
+ require_success("-2b", -2);
+ require_success("-2k", -(2LL << 10));
+ require_success("-2m", -(2LL << 20));
+ require_success("-2g", -(2LL << 30));
+ require_success("-2t", -(2LL << 40));
+ require_success("-2p", -(2LL << 50));
+ require_success("-2e", -(2LL << 60));
+ require_success("-3KB", -(3LL << 10));
+ require_success("-3MB", -(3LL << 20));
+ require_success("-3GB", -(3LL << 30));
+ require_success("-3TB", -(3LL << 40));
+ require_success("-3PB", -(3LL << 50));
+ require_success("-3EB", -(3LL << 60));
+
+ /* Maximum values. */
+ require_success("7E", 7LL << 60);
+ require_success("8191P", 8191LL << 50);
+ require_success("8388607T", 8388607LL << 40);
+ require_success("8589934591G", 8589934591LL << 30);
+ require_success("8796093022207M", 8796093022207LL << 20);
+ require_success("9007199254740991K", 9007199254740991LL << 10);
+ require_success("9223372036854775807", INT64_MAX);
+
+ /* Minimum values. */
+ require_success("-7E", -(7LL << 60));
+ require_success("-8191P", -(8191LL << 50));
+ require_success("-8388607T", -(8388607LL << 40));
+ require_success("-8589934591G", -(8589934591LL << 30));
+ require_success("-8796093022207M", -(8796093022207LL << 20));
+ require_success("-9007199254740991K", -(9007199254740991LL << 10));
+ require_success("-9223372036854775808", INT64_MIN);
}
-ATF_TC_WITHOUT_HEAD(negativetests);
-ATF_TC_BODY(negativetests, tc)
+ATF_TC_WITHOUT_HEAD(expand_number__bad);
+ATF_TC_BODY(expand_number__bad, tp)
{
- uint64_t num;
-
- ATF_CHECK_ERRNO(EINVAL, expand_number("", &num));
- ATF_CHECK_ERRNO(EINVAL, expand_number("x", &num));
- ATF_CHECK_ERRNO(EINVAL, expand_number("1bb", &num));
- ATF_CHECK_ERRNO(EINVAL, expand_number("1x", &num));
- ATF_CHECK_ERRNO(EINVAL, expand_number("1kx", &num));
- ATF_CHECK_ERRNO(ERANGE, expand_number("16E", &num));
+ /* No digits. */
+ require_error("", EINVAL);
+ require_error("b", EINVAL);
+ require_error("k", EINVAL);
+ require_error("m", EINVAL);
+ require_error("g", EINVAL);
+ require_error("t", EINVAL);
+ require_error("p", EINVAL);
+ require_error("e", EINVAL);
+ require_error("-", EINVAL);
+ require_error("-b", EINVAL);
+ require_error("-k", EINVAL);
+ require_error("-m", EINVAL);
+ require_error("-g", EINVAL);
+ require_error("-t", EINVAL);
+ require_error("-p", EINVAL);
+ require_error("-e", EINVAL);
+
+ require_error("not_a_number", EINVAL);
+
+ /* Invalid suffixes. */
+ require_error("1a", EINVAL);
+ require_error("1c", EINVAL);
+ require_error("1d", EINVAL);
+ require_error("1f", EINVAL);
+ require_error("1h", EINVAL);
+ require_error("1i", EINVAL);
+ require_error("1j", EINVAL);
+ require_error("1l", EINVAL);
+ require_error("1n", EINVAL);
+ require_error("1o", EINVAL);
+ require_error("1q", EINVAL);
+ require_error("1r", EINVAL);
+ require_error("1s", EINVAL);
+ require_error("1u", EINVAL);
+ require_error("1v", EINVAL);
+ require_error("1w", EINVAL);
+ require_error("1x", EINVAL);
+ require_error("1y", EINVAL);
+ require_error("1z", EINVAL);
+
+ /* Trailing garbage. */
+ require_error("1K foo", EINVAL);
+ require_error("1Mfoo", EINVAL);
+
+ /* Overflow. */
+ require_error("8E", ERANGE);
+ require_error("8192P", ERANGE);
+ require_error("8388608T", ERANGE);
+ require_error("8589934592G", ERANGE);
+ require_error("8796093022208M", ERANGE);
+ require_error("9007199254740992K", ERANGE);
+ require_error("9223372036854775808", ERANGE);
+
+ /* Multiple signs */
+ require_error("--1", EINVAL);
+ require_error("-+1", EINVAL);
+ require_error("+-1", EINVAL);
+ require_error("++1", EINVAL);
+
+ /* Whitespace after the sign */
+ require_error(" - 1", EINVAL);
+ require_error(" + 1", EINVAL);
}
ATF_TP_ADD_TCS(tp)
{
- ATF_TP_ADD_TC(tp, positivetests);
- ATF_TP_ADD_TC(tp, negativetests);
+ ATF_TP_ADD_TC(tp, expand_number__ok);
+ ATF_TP_ADD_TC(tp, expand_number__bad);
+
return (atf_no_error());
}
diff --git a/lib/libutil/tests/flopen_test.c b/lib/libutil/tests/flopen_test.c
index 94129ebfac46..bb810b27f3cc 100644
--- a/lib/libutil/tests/flopen_test.c
+++ b/lib/libutil/tests/flopen_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/fcntl.h>
diff --git a/lib/libutil/tests/grp_test.c b/lib/libutil/tests/grp_test.c
index 824600905289..291e1feabaf0 100644
--- a/lib/libutil/tests/grp_test.c
+++ b/lib/libutil/tests/grp_test.c
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <grp.h>
diff --git a/lib/libutil/tests/pidfile_test.c b/lib/libutil/tests/pidfile_test.c
index bb11d6a19b79..602bc6cea983 100644
--- a/lib/libutil/tests/pidfile_test.c
+++ b/lib/libutil/tests/pidfile_test.c
@@ -25,7 +25,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/wait.h>
#include <sys/event.h>
diff --git a/lib/libutil/tests/trimdomain-nodomain_test.c b/lib/libutil/tests/trimdomain-nodomain_test.c
index ecbfe96e8c3a..b2dfaa4ae9af 100644
--- a/lib/libutil/tests/trimdomain-nodomain_test.c
+++ b/lib/libutil/tests/trimdomain-nodomain_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <errno.h>
@@ -33,6 +32,8 @@
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
+
#define TESTDOMAIN ""
#define TESTHOST "testhost"
#define TESTFQDN "testhost" TESTDOMAIN
@@ -46,7 +47,7 @@ int tests = 0;
* oddly configured systems.
*/
int
-gethostname(char *name, size_t namelen)
+__ssp_real(gethostname)(char *name, size_t namelen)
{
if (strlcpy(name, TESTFQDN, namelen) > namelen) {
errno = ENAMETOOLONG;
diff --git a/lib/libutil/tests/trimdomain_test.c b/lib/libutil/tests/trimdomain_test.c
index 6ae55d7e8756..ad5b92b0ce1e 100644
--- a/lib/libutil/tests/trimdomain_test.c
+++ b/lib/libutil/tests/trimdomain_test.c
@@ -23,7 +23,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <errno.h>
@@ -33,6 +32,8 @@
#include <string.h>
#include <unistd.h>
+#include <ssp/ssp.h>
+
#define TESTDOMAIN ".domain.example.com"
#define TESTHOST "testhost"
#define TESTFQDN "testhost" TESTDOMAIN
@@ -46,7 +47,7 @@ int tests = 0;
* oddly configured systems.
*/
int
-gethostname(char *name, size_t namelen)
+__ssp_real(gethostname)(char *name, size_t namelen)
{
if (strlcpy(name, TESTFQDN, namelen) > namelen) {
errno = ENAMETOOLONG;
diff --git a/lib/libutil/trimdomain.c b/lib/libutil/trimdomain.c
index ce91ac64babe..77518a389419 100644
--- a/lib/libutil/trimdomain.c
+++ b/lib/libutil/trimdomain.c
@@ -28,7 +28,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <libutil.h>
diff --git a/lib/libutil/uucplock.c b/lib/libutil/uucplock.c
index c9103536d916..20141041e3f6 100644
--- a/lib/libutil/uucplock.c
+++ b/lib/libutil/uucplock.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__SCCSID("@(#)uucplock.c 8.1 (Berkeley) 6/6/93");
#include <sys/types.h>
#include <sys/file.h>
diff --git a/lib/libveriexec/Makefile b/lib/libveriexec/Makefile
index 154605142074..9cef42a7cf58 100644
--- a/lib/libveriexec/Makefile
+++ b/lib/libveriexec/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
LIB= veriexec
diff --git a/lib/libveriexec/veriexec.3 b/lib/libveriexec/veriexec.3
index 8fd5822c8067..b367fc5ea40f 100644
--- a/lib/libveriexec/veriexec.3
+++ b/lib/libveriexec/veriexec.3
@@ -59,5 +59,5 @@ If the signature does not match,
.Va errno
is set to the reason for the mismatch.
.Sh SEE ALSO
-.Xr mac_veriexec 4
+.Xr mac_veriexec 4 ,
.Xr veriexec 4
diff --git a/lib/libveriexec/veriexec_check.c b/lib/libveriexec/veriexec_check.c
index 98fec427987d..311eb307f25d 100644
--- a/lib/libveriexec/veriexec_check.c
+++ b/lib/libveriexec/veriexec_check.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/mac.h>
diff --git a/lib/libveriexec/veriexec_get.c b/lib/libveriexec/veriexec_get.c
index 4cfa81de210c..0707e184a983 100644
--- a/lib/libveriexec/veriexec_get.c
+++ b/lib/libveriexec/veriexec_get.c
@@ -27,7 +27,6 @@
*
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/mac.h>
diff --git a/lib/libvgl/bitmap.c b/lib/libvgl/bitmap.c
index 0b0e75128296..2beeb8ee68c4 100644
--- a/lib/libvgl/bitmap.c
+++ b/lib/libvgl/bitmap.c
@@ -28,7 +28,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/fbio.h>
diff --git a/lib/libvgl/main.c b/lib/libvgl/main.c
index b98e59ff801f..13e376c48417 100644
--- a/lib/libvgl/main.c
+++ b/lib/libvgl/main.c
@@ -91,7 +91,7 @@ struct vt_mode smode;
if (VGLOldModeInfo.vi_flags & V_INFO_GRAPHICS) {
size[0] = VGLOldVInfo.mv_csz;
size[1] = VGLOldVInfo.mv_rsz;
- size[2] = VGLOldVInfo.font_size;;
+ size[2] = VGLOldVInfo.font_size;
ioctl(0, KDRASTER, size);
}
if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT)
diff --git a/lib/libvmmapi/Makefile b/lib/libvmmapi/Makefile
index d871ffef9120..6dd0deeaa9c0 100644
--- a/lib/libvmmapi/Makefile
+++ b/lib/libvmmapi/Makefile
@@ -1,12 +1,15 @@
-
PACKAGE=lib${LIB}
LIB= vmmapi
-SHLIB_MAJOR= 6
-SRCS= vmmapi.c vmmapi_freebsd.c
+SHLIB_MAJOR= 7
+SRCS= vmmapi.c
INCS= vmmapi.h
-LIBADD= util
-
CFLAGS+= -I${.CURDIR}
+.PATH: ${.CURDIR}/${MACHINE_CPUARCH}
+
+.include "${MACHINE_CPUARCH}/Makefile.inc"
+
+LIBADD= util
+
.include <bsd.lib.mk>
diff --git a/lib/libvmmapi/aarch64/Makefile.inc b/lib/libvmmapi/aarch64/Makefile.inc
new file mode 100644
index 000000000000..663ea0ab90a3
--- /dev/null
+++ b/lib/libvmmapi/aarch64/Makefile.inc
@@ -0,0 +1 @@
+SRCS+= vmmapi_machdep.c
diff --git a/lib/libvmmapi/aarch64/vmmapi_machdep.c b/lib/libvmmapi/aarch64/vmmapi_machdep.c
new file mode 100644
index 000000000000..fb2556af3be2
--- /dev/null
+++ b/lib/libvmmapi/aarch64/vmmapi_machdep.c
@@ -0,0 +1,127 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * 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 NETAPP, INC ``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 NETAPP, INC 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <machine/vmm.h>
+#include <machine/vmm_dev.h>
+#include <machine/vmm_snapshot.h>
+
+#include <assert.h>
+#include <string.h>
+
+#include "vmmapi.h"
+#include "internal.h"
+
+const char *vm_capstrmap[] = {
+ [VM_CAP_MAX] = NULL,
+};
+
+#define VM_MD_IOCTLS \
+ VM_GET_VGIC_VERSION, \
+ VM_ATTACH_VGIC, \
+ VM_ASSERT_IRQ, \
+ VM_DEASSERT_IRQ, \
+ VM_RAISE_MSI
+
+const cap_ioctl_t vm_ioctl_cmds[] = {
+ VM_COMMON_IOCTLS,
+ VM_MD_IOCTLS,
+};
+size_t vm_ioctl_ncmds = nitems(vm_ioctl_cmds);
+
+int
+vm_attach_vgic(struct vmctx *ctx, uint64_t dist_start, size_t dist_size,
+ uint64_t redist_start, size_t redist_size)
+{
+ struct vm_vgic_descr vgic;
+ int error;
+
+ bzero(&vgic, sizeof(vgic));
+ error = ioctl(ctx->fd, VM_GET_VGIC_VERSION, &vgic.ver);
+ if (error != 0)
+ return (error);
+ assert(vgic.ver.version == 3);
+ vgic.v3_regs.dist_start = dist_start;
+ vgic.v3_regs.dist_size = dist_size;
+ vgic.v3_regs.redist_start = redist_start;
+ vgic.v3_regs.redist_size = redist_size;
+
+ return (ioctl(ctx->fd, VM_ATTACH_VGIC, &vgic));
+}
+
+int
+vm_assert_irq(struct vmctx *ctx, uint32_t irq)
+{
+ struct vm_irq vi;
+
+ bzero(&vi, sizeof(vi));
+ vi.irq = irq;
+
+ return (ioctl(ctx->fd, VM_ASSERT_IRQ, &vi));
+}
+
+int
+vm_deassert_irq(struct vmctx *ctx, uint32_t irq)
+{
+ struct vm_irq vi;
+
+ bzero(&vi, sizeof(vi));
+ vi.irq = irq;
+
+ return (ioctl(ctx->fd, VM_DEASSERT_IRQ, &vi));
+}
+
+int
+vm_raise_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg,
+ int bus, int slot, int func)
+{
+ struct vm_msi vmsi;
+
+ bzero(&vmsi, sizeof(vmsi));
+ vmsi.addr = addr;
+ vmsi.msg = msg;
+ vmsi.bus = bus;
+ vmsi.slot = slot;
+ vmsi.func = func;
+
+ return (ioctl(ctx->fd, VM_RAISE_MSI, &vmsi));
+}
+
+int
+vm_inject_exception(struct vcpu *vcpu, uint64_t esr, uint64_t far)
+{
+ struct vm_exception vmexc;
+
+ bzero(&vmexc, sizeof(vmexc));
+ vmexc.esr = esr;
+ vmexc.far = far;
+
+ return (vcpu_ioctl(vcpu, VM_INJECT_EXCEPTION, &vmexc));
+}
diff --git a/lib/libvmmapi/amd64/Makefile.inc b/lib/libvmmapi/amd64/Makefile.inc
new file mode 100644
index 000000000000..a3da271433a1
--- /dev/null
+++ b/lib/libvmmapi/amd64/Makefile.inc
@@ -0,0 +1,5 @@
+SRCS+= ppt.c \
+ vmmapi_machdep.c \
+ vmmapi_freebsd_machdep.c
+
+CFLAGS+= -DWITH_VMMAPI_SNAPSHOT
diff --git a/lib/libvmmapi/amd64/vmmapi_freebsd_machdep.c b/lib/libvmmapi/amd64/vmmapi_freebsd_machdep.c
new file mode 100644
index 000000000000..a1d39ac3795e
--- /dev/null
+++ b/lib/libvmmapi/amd64/vmmapi_freebsd_machdep.c
@@ -0,0 +1,343 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * 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 NETAPP, INC ``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 NETAPP, INC 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.
+ */
+
+#include <sys/types.h>
+
+#include <machine/specialreg.h>
+#include <machine/segments.h>
+#include <machine/vmm.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include "vmmapi.h"
+#include "internal.h"
+
+#define I386_TSS_SIZE 104
+
+#define DESC_PRESENT 0x00000080
+#define DESC_LONGMODE 0x00002000
+#define DESC_DEF32 0x00004000
+#define DESC_GRAN 0x00008000
+#define DESC_UNUSABLE 0x00010000
+
+#define GUEST_NULL_SEL 0
+#define GUEST_CODE_SEL 1
+#define GUEST_DATA_SEL 2
+#define GUEST_TSS_SEL 3
+#define GUEST_GDTR_LIMIT64 (3 * 8 - 1)
+
+static struct segment_descriptor i386_gdt[] = {
+ {}, /* NULL */
+ { .sd_lolimit = 0xffff, .sd_type = SDT_MEMER, /* CODE */
+ .sd_p = 1, .sd_hilimit = 0xf, .sd_def32 = 1, .sd_gran = 1 },
+ { .sd_lolimit = 0xffff, .sd_type = SDT_MEMRW, /* DATA */
+ .sd_p = 1, .sd_hilimit = 0xf, .sd_def32 = 1, .sd_gran = 1 },
+ { .sd_lolimit = I386_TSS_SIZE - 1, /* TSS */
+ .sd_type = SDT_SYS386TSS, .sd_p = 1 }
+};
+
+/*
+ * Setup the 'vcpu' register set such that it will begin execution at
+ * 'eip' in flat mode.
+ */
+int
+vm_setup_freebsd_registers_i386(struct vcpu *vcpu, uint32_t eip,
+ uint32_t gdtbase, uint32_t esp)
+{
+ uint64_t cr0, rflags, desc_base;
+ uint32_t desc_access, desc_limit, tssbase;
+ uint16_t gsel;
+ struct segment_descriptor *gdt;
+ int error, tmp;
+
+ /* A 32-bit guest requires unrestricted mode. */
+ error = vm_get_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, &tmp);
+ if (error)
+ goto done;
+ error = vm_set_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, 1);
+ if (error)
+ goto done;
+
+ cr0 = CR0_PE | CR0_NE;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, 0)) != 0)
+ goto done;
+
+ /*
+ * Forcing EFER to 0 causes bhyve to clear the "IA-32e guest
+ * mode" entry control.
+ */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, 0)))
+ goto done;
+
+ gdt = vm_map_gpa(vcpu->ctx, gdtbase, 0x1000);
+ if (gdt == NULL)
+ return (EFAULT);
+ memcpy(gdt, i386_gdt, sizeof(i386_gdt));
+ desc_base = gdtbase;
+ desc_limit = sizeof(i386_gdt) - 1;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
+ desc_base, desc_limit, 0);
+ if (error != 0)
+ goto done;
+
+ /* Place the TSS one page above the GDT. */
+ tssbase = gdtbase + 0x1000;
+ gdt[3].sd_lobase = tssbase;
+
+ rflags = 0x2;
+ error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags);
+ if (error)
+ goto done;
+
+ desc_base = 0;
+ desc_limit = 0xffffffff;
+ desc_access = DESC_GRAN | DESC_DEF32 | DESC_PRESENT | SDT_MEMERA;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
+ desc_base, desc_limit, desc_access);
+
+ desc_access = DESC_GRAN | DESC_DEF32 | DESC_PRESENT | SDT_MEMRWA;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ desc_base = tssbase;
+ desc_limit = I386_TSS_SIZE - 1;
+ desc_access = DESC_PRESENT | SDT_SYS386BSY;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_TR,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, 0, 0,
+ DESC_UNUSABLE);
+ if (error)
+ goto done;
+
+ gsel = GSEL(GUEST_CODE_SEL, SEL_KPL);
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, gsel)) != 0)
+ goto done;
+
+ gsel = GSEL(GUEST_DATA_SEL, SEL_KPL);
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, gsel)) != 0)
+ goto done;
+
+ gsel = GSEL(GUEST_TSS_SEL, SEL_KPL);
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, gsel)) != 0)
+ goto done;
+
+ /* LDTR is pointing to the null selector */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0)
+ goto done;
+
+ /* entry point */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, eip)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, esp)) != 0)
+ goto done;
+
+ error = 0;
+done:
+ return (error);
+}
+
+void
+vm_setup_freebsd_gdt(uint64_t *gdtr)
+{
+ gdtr[GUEST_NULL_SEL] = 0;
+ gdtr[GUEST_CODE_SEL] = 0x0020980000000000;
+ gdtr[GUEST_DATA_SEL] = 0x0000900000000000;
+}
+
+/*
+ * Setup the 'vcpu' register set such that it will begin execution at
+ * 'rip' in long mode.
+ */
+int
+vm_setup_freebsd_registers(struct vcpu *vcpu,
+ uint64_t rip, uint64_t cr3, uint64_t gdtbase,
+ uint64_t rsp)
+{
+ int error;
+ uint64_t cr0, cr4, efer, rflags, desc_base;
+ uint32_t desc_access, desc_limit;
+ uint16_t gsel;
+
+ cr0 = CR0_PE | CR0_PG | CR0_NE;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0)
+ goto done;
+
+ cr4 = CR4_PAE;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4)) != 0)
+ goto done;
+
+ efer = EFER_LME | EFER_LMA;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, efer)))
+ goto done;
+
+ rflags = 0x2;
+ error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags);
+ if (error)
+ goto done;
+
+ desc_base = 0;
+ desc_limit = 0;
+ desc_access = 0x0000209B;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ desc_access = 0x00000093;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ /*
+ * XXX TR is pointing to null selector even though we set the
+ * TSS segment to be usable with a base address and limit of 0.
+ */
+ desc_access = 0x0000008b;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_TR, 0, 0, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, 0, 0,
+ DESC_UNUSABLE);
+ if (error)
+ goto done;
+
+ gsel = GSEL(GUEST_CODE_SEL, SEL_KPL);
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, gsel)) != 0)
+ goto done;
+
+ gsel = GSEL(GUEST_DATA_SEL, SEL_KPL);
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, gsel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, gsel)) != 0)
+ goto done;
+
+ /* XXX TR is pointing to the null selector */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, 0)) != 0)
+ goto done;
+
+ /* LDTR is pointing to the null selector */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0)
+ goto done;
+
+ /* entry point */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip)) != 0)
+ goto done;
+
+ /* page table base */
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR3, cr3)) != 0)
+ goto done;
+
+ desc_base = gdtbase;
+ desc_limit = GUEST_GDTR_LIMIT64;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
+ desc_base, desc_limit, 0);
+ if (error != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, rsp)) != 0)
+ goto done;
+
+ error = 0;
+done:
+ return (error);
+}
diff --git a/lib/libvmmapi/amd64/vmmapi_machdep.c b/lib/libvmmapi/amd64/vmmapi_machdep.c
new file mode 100644
index 000000000000..806c31abf426
--- /dev/null
+++ b/lib/libvmmapi/amd64/vmmapi_machdep.c
@@ -0,0 +1,607 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * 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 NETAPP, INC ``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 NETAPP, INC 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <machine/specialreg.h>
+#include <machine/vmm.h>
+#include <machine/vmm_dev.h>
+#include <machine/vmm_snapshot.h>
+
+#include <string.h>
+
+#include "vmmapi.h"
+#include "internal.h"
+
+const char *vm_capstrmap[] = {
+ [VM_CAP_HALT_EXIT] = "hlt_exit",
+ [VM_CAP_MTRAP_EXIT] = "mtrap_exit",
+ [VM_CAP_PAUSE_EXIT] = "pause_exit",
+ [VM_CAP_UNRESTRICTED_GUEST] = "unrestricted_guest",
+ [VM_CAP_ENABLE_INVPCID] = "enable_invpcid",
+ [VM_CAP_BPT_EXIT] = "bpt_exit",
+ [VM_CAP_RDPID] = "rdpid",
+ [VM_CAP_RDTSCP] = "rdtscp",
+ [VM_CAP_IPI_EXIT] = "ipi_exit",
+ [VM_CAP_MASK_HWINTR] = "mask_hwintr",
+ [VM_CAP_RFLAGS_TF] = "rflags_tf",
+ [VM_CAP_MAX] = NULL,
+};
+
+#define VM_MD_IOCTLS \
+ VM_SET_SEGMENT_DESCRIPTOR, \
+ VM_GET_SEGMENT_DESCRIPTOR, \
+ VM_SET_KERNEMU_DEV, \
+ VM_GET_KERNEMU_DEV, \
+ VM_LAPIC_IRQ, \
+ VM_LAPIC_LOCAL_IRQ, \
+ VM_LAPIC_MSI, \
+ VM_IOAPIC_ASSERT_IRQ, \
+ VM_IOAPIC_DEASSERT_IRQ, \
+ VM_IOAPIC_PULSE_IRQ, \
+ VM_IOAPIC_PINCOUNT, \
+ VM_ISA_ASSERT_IRQ, \
+ VM_ISA_DEASSERT_IRQ, \
+ VM_ISA_PULSE_IRQ, \
+ VM_ISA_SET_IRQ_TRIGGER, \
+ VM_INJECT_NMI, \
+ VM_SET_X2APIC_STATE, \
+ VM_GET_X2APIC_STATE, \
+ VM_GET_HPET_CAPABILITIES, \
+ VM_RTC_WRITE, \
+ VM_RTC_READ, \
+ VM_RTC_SETTIME, \
+ VM_RTC_GETTIME, \
+ VM_GET_GPA_PMAP, \
+ VM_GLA2GPA, \
+ VM_SET_INTINFO, \
+ VM_GET_INTINFO, \
+ VM_RESTART_INSTRUCTION, \
+ VM_SNAPSHOT_REQ, \
+ VM_RESTORE_TIME
+
+const cap_ioctl_t vm_ioctl_cmds[] = {
+ VM_COMMON_IOCTLS,
+ VM_PPT_IOCTLS,
+ VM_MD_IOCTLS,
+};
+size_t vm_ioctl_ncmds = nitems(vm_ioctl_cmds);
+
+int
+vm_set_desc(struct vcpu *vcpu, int reg,
+ uint64_t base, uint32_t limit, uint32_t access)
+{
+ int error;
+ struct vm_seg_desc vmsegdesc;
+
+ bzero(&vmsegdesc, sizeof(vmsegdesc));
+ vmsegdesc.regnum = reg;
+ vmsegdesc.desc.base = base;
+ vmsegdesc.desc.limit = limit;
+ vmsegdesc.desc.access = access;
+
+ error = vcpu_ioctl(vcpu, VM_SET_SEGMENT_DESCRIPTOR, &vmsegdesc);
+ return (error);
+}
+
+int
+vm_get_desc(struct vcpu *vcpu, int reg, uint64_t *base, uint32_t *limit,
+ uint32_t *access)
+{
+ int error;
+ struct vm_seg_desc vmsegdesc;
+
+ bzero(&vmsegdesc, sizeof(vmsegdesc));
+ vmsegdesc.regnum = reg;
+
+ error = vcpu_ioctl(vcpu, VM_GET_SEGMENT_DESCRIPTOR, &vmsegdesc);
+ if (error == 0) {
+ *base = vmsegdesc.desc.base;
+ *limit = vmsegdesc.desc.limit;
+ *access = vmsegdesc.desc.access;
+ }
+ return (error);
+}
+
+int
+vm_get_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *seg_desc)
+{
+ int error;
+
+ error = vm_get_desc(vcpu, reg, &seg_desc->base, &seg_desc->limit,
+ &seg_desc->access);
+ return (error);
+}
+
+int
+vm_lapic_irq(struct vcpu *vcpu, int vector)
+{
+ struct vm_lapic_irq vmirq;
+
+ bzero(&vmirq, sizeof(vmirq));
+ vmirq.vector = vector;
+
+ return (vcpu_ioctl(vcpu, VM_LAPIC_IRQ, &vmirq));
+}
+
+int
+vm_lapic_local_irq(struct vcpu *vcpu, int vector)
+{
+ struct vm_lapic_irq vmirq;
+
+ bzero(&vmirq, sizeof(vmirq));
+ vmirq.vector = vector;
+
+ return (vcpu_ioctl(vcpu, VM_LAPIC_LOCAL_IRQ, &vmirq));
+}
+
+int
+vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg)
+{
+ struct vm_lapic_msi vmmsi;
+
+ bzero(&vmmsi, sizeof(vmmsi));
+ vmmsi.addr = addr;
+ vmmsi.msg = msg;
+
+ return (ioctl(ctx->fd, VM_LAPIC_MSI, &vmmsi));
+}
+
+int
+vm_raise_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg,
+ int bus __unused, int slot __unused, int func __unused)
+{
+ return (vm_lapic_msi(ctx, addr, msg));
+}
+
+int
+vm_apicid2vcpu(struct vmctx *ctx __unused, int apicid)
+{
+ /*
+ * The apic id associated with the 'vcpu' has the same numerical value
+ * as the 'vcpu' itself.
+ */
+ return (apicid);
+}
+
+int
+vm_ioapic_assert_irq(struct vmctx *ctx, int irq)
+{
+ struct vm_ioapic_irq ioapic_irq;
+
+ bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
+ ioapic_irq.irq = irq;
+
+ return (ioctl(ctx->fd, VM_IOAPIC_ASSERT_IRQ, &ioapic_irq));
+}
+
+int
+vm_ioapic_deassert_irq(struct vmctx *ctx, int irq)
+{
+ struct vm_ioapic_irq ioapic_irq;
+
+ bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
+ ioapic_irq.irq = irq;
+
+ return (ioctl(ctx->fd, VM_IOAPIC_DEASSERT_IRQ, &ioapic_irq));
+}
+
+int
+vm_ioapic_pulse_irq(struct vmctx *ctx, int irq)
+{
+ struct vm_ioapic_irq ioapic_irq;
+
+ bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
+ ioapic_irq.irq = irq;
+
+ return (ioctl(ctx->fd, VM_IOAPIC_PULSE_IRQ, &ioapic_irq));
+}
+
+int
+vm_ioapic_pincount(struct vmctx *ctx, int *pincount)
+{
+
+ return (ioctl(ctx->fd, VM_IOAPIC_PINCOUNT, pincount));
+}
+
+int
+vm_isa_assert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
+{
+ struct vm_isa_irq isa_irq;
+
+ bzero(&isa_irq, sizeof(struct vm_isa_irq));
+ isa_irq.atpic_irq = atpic_irq;
+ isa_irq.ioapic_irq = ioapic_irq;
+
+ return (ioctl(ctx->fd, VM_ISA_ASSERT_IRQ, &isa_irq));
+}
+
+int
+vm_isa_deassert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
+{
+ struct vm_isa_irq isa_irq;
+
+ bzero(&isa_irq, sizeof(struct vm_isa_irq));
+ isa_irq.atpic_irq = atpic_irq;
+ isa_irq.ioapic_irq = ioapic_irq;
+
+ return (ioctl(ctx->fd, VM_ISA_DEASSERT_IRQ, &isa_irq));
+}
+
+int
+vm_isa_pulse_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
+{
+ struct vm_isa_irq isa_irq;
+
+ bzero(&isa_irq, sizeof(struct vm_isa_irq));
+ isa_irq.atpic_irq = atpic_irq;
+ isa_irq.ioapic_irq = ioapic_irq;
+
+ return (ioctl(ctx->fd, VM_ISA_PULSE_IRQ, &isa_irq));
+}
+
+int
+vm_isa_set_irq_trigger(struct vmctx *ctx, int atpic_irq,
+ enum vm_intr_trigger trigger)
+{
+ struct vm_isa_irq_trigger isa_irq_trigger;
+
+ bzero(&isa_irq_trigger, sizeof(struct vm_isa_irq_trigger));
+ isa_irq_trigger.atpic_irq = atpic_irq;
+ isa_irq_trigger.trigger = trigger;
+
+ return (ioctl(ctx->fd, VM_ISA_SET_IRQ_TRIGGER, &isa_irq_trigger));
+}
+
+int
+vm_inject_nmi(struct vcpu *vcpu)
+{
+ struct vm_nmi vmnmi;
+
+ bzero(&vmnmi, sizeof(vmnmi));
+
+ return (vcpu_ioctl(vcpu, VM_INJECT_NMI, &vmnmi));
+}
+
+int
+vm_inject_exception(struct vcpu *vcpu, int vector, int errcode_valid,
+ uint32_t errcode, int restart_instruction)
+{
+ struct vm_exception exc;
+
+ exc.vector = vector;
+ exc.error_code = errcode;
+ exc.error_code_valid = errcode_valid;
+ exc.restart_instruction = restart_instruction;
+
+ return (vcpu_ioctl(vcpu, VM_INJECT_EXCEPTION, &exc));
+}
+
+int
+vm_readwrite_kernemu_device(struct vcpu *vcpu, vm_paddr_t gpa,
+ bool write, int size, uint64_t *value)
+{
+ struct vm_readwrite_kernemu_device irp = {
+ .access_width = fls(size) - 1,
+ .gpa = gpa,
+ .value = write ? *value : ~0ul,
+ };
+ long cmd = (write ? VM_SET_KERNEMU_DEV : VM_GET_KERNEMU_DEV);
+ int rc;
+
+ rc = vcpu_ioctl(vcpu, cmd, &irp);
+ if (rc == 0 && !write)
+ *value = irp.value;
+ return (rc);
+}
+
+int
+vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *state)
+{
+ int error;
+ struct vm_x2apic x2apic;
+
+ bzero(&x2apic, sizeof(x2apic));
+
+ error = vcpu_ioctl(vcpu, VM_GET_X2APIC_STATE, &x2apic);
+ *state = x2apic.state;
+ return (error);
+}
+
+int
+vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state state)
+{
+ int error;
+ struct vm_x2apic x2apic;
+
+ bzero(&x2apic, sizeof(x2apic));
+ x2apic.state = state;
+
+ error = vcpu_ioctl(vcpu, VM_SET_X2APIC_STATE, &x2apic);
+
+ return (error);
+}
+
+int
+vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities)
+{
+ int error;
+ struct vm_hpet_cap cap;
+
+ bzero(&cap, sizeof(struct vm_hpet_cap));
+ error = ioctl(ctx->fd, VM_GET_HPET_CAPABILITIES, &cap);
+ if (capabilities != NULL)
+ *capabilities = cap.capabilities;
+ return (error);
+}
+
+int
+vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value)
+{
+ struct vm_rtc_data rtcdata;
+ int error;
+
+ bzero(&rtcdata, sizeof(struct vm_rtc_data));
+ rtcdata.offset = offset;
+ rtcdata.value = value;
+ error = ioctl(ctx->fd, VM_RTC_WRITE, &rtcdata);
+ return (error);
+}
+
+int
+vm_rtc_read(struct vmctx *ctx, int offset, uint8_t *retval)
+{
+ struct vm_rtc_data rtcdata;
+ int error;
+
+ bzero(&rtcdata, sizeof(struct vm_rtc_data));
+ rtcdata.offset = offset;
+ error = ioctl(ctx->fd, VM_RTC_READ, &rtcdata);
+ if (error == 0)
+ *retval = rtcdata.value;
+ return (error);
+}
+
+int
+vm_rtc_settime(struct vmctx *ctx, time_t secs)
+{
+ struct vm_rtc_time rtctime;
+ int error;
+
+ bzero(&rtctime, sizeof(struct vm_rtc_time));
+ rtctime.secs = secs;
+ error = ioctl(ctx->fd, VM_RTC_SETTIME, &rtctime);
+ return (error);
+}
+
+int
+vm_rtc_gettime(struct vmctx *ctx, time_t *secs)
+{
+ struct vm_rtc_time rtctime;
+ int error;
+
+ bzero(&rtctime, sizeof(struct vm_rtc_time));
+ error = ioctl(ctx->fd, VM_RTC_GETTIME, &rtctime);
+ if (error == 0)
+ *secs = rtctime.secs;
+ return (error);
+}
+
+/*
+ * From Intel Vol 3a:
+ * Table 9-1. IA-32 Processor States Following Power-up, Reset or INIT
+ */
+int
+vcpu_reset(struct vcpu *vcpu)
+{
+ int error;
+ uint64_t rflags, rip, cr0, cr4, zero, desc_base, rdx;
+ uint32_t desc_access, desc_limit;
+ uint16_t sel;
+
+ zero = 0;
+
+ rflags = 0x2;
+ error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags);
+ if (error)
+ goto done;
+
+ rip = 0xfff0;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip)) != 0)
+ goto done;
+
+ /*
+ * According to Intels Software Developer Manual CR0 should be
+ * initialized with CR0_ET | CR0_NW | CR0_CD but that crashes some
+ * guests like Windows.
+ */
+ cr0 = CR0_NE;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR2, zero)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR3, zero)) != 0)
+ goto done;
+
+ cr4 = 0;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4)) != 0)
+ goto done;
+
+ /*
+ * CS: present, r/w, accessed, 16-bit, byte granularity, usable
+ */
+ desc_base = 0xffff0000;
+ desc_limit = 0xffff;
+ desc_access = 0x0093;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ sel = 0xf000;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, sel)) != 0)
+ goto done;
+
+ /*
+ * SS,DS,ES,FS,GS: present, r/w, accessed, 16-bit, byte granularity
+ */
+ desc_base = 0;
+ desc_limit = 0xffff;
+ desc_access = 0x0093;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
+ desc_base, desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ sel = 0;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, sel)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, sel)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, sel)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, sel)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, sel)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, zero)) != 0)
+ goto done;
+
+ /* General purpose registers */
+ rdx = 0xf00;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RAX, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBX, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RCX, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDX, rdx)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSI, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDI, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBP, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R8, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R9, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R10, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R11, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R12, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R13, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R14, zero)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_R15, zero)) != 0)
+ goto done;
+
+ /* GDTR, IDTR */
+ desc_base = 0;
+ desc_limit = 0xffff;
+ desc_access = 0;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
+ desc_base, desc_limit, desc_access);
+ if (error != 0)
+ goto done;
+
+ error = vm_set_desc(vcpu, VM_REG_GUEST_IDTR,
+ desc_base, desc_limit, desc_access);
+ if (error != 0)
+ goto done;
+
+ /* TR */
+ desc_base = 0;
+ desc_limit = 0xffff;
+ desc_access = 0x0000008b;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_TR, 0, 0, desc_access);
+ if (error)
+ goto done;
+
+ sel = 0;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, sel)) != 0)
+ goto done;
+
+ /* LDTR */
+ desc_base = 0;
+ desc_limit = 0xffff;
+ desc_access = 0x00000082;
+ error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, desc_base,
+ desc_limit, desc_access);
+ if (error)
+ goto done;
+
+ sel = 0;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR6,
+ 0xffff0ff0)) != 0)
+ goto done;
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR7, 0x400)) !=
+ 0)
+ goto done;
+
+ if ((error = vm_set_register(vcpu, VM_REG_GUEST_INTR_SHADOW,
+ zero)) != 0)
+ goto done;
+
+ error = 0;
+done:
+ return (error);
+}
diff --git a/lib/libvmmapi/internal.h b/lib/libvmmapi/internal.h
index 142026e76345..4afe1cab3460 100644
--- a/lib/libvmmapi/internal.h
+++ b/lib/libvmmapi/internal.h
@@ -7,11 +7,69 @@
#ifndef __VMMAPI_INTERNAL_H__
#define __VMMAPI_INTERNAL_H__
-struct vmctx;
+#include <sys/types.h>
+#include <dev/vmm/vmm_mem.h>
+
+struct vmctx {
+ int fd; /* device file descriptor */
+ int ctlfd; /* vmm control descriptor */
+ struct {
+ vm_paddr_t base;
+ vm_size_t size;
+ } memsegs[VM_MAX_MEMSEGS];
+ size_t lowmem_size;
+ size_t highmem_size;
+ int memflags;
+ char *baseaddr;
+ char *name;
+};
struct vcpu {
struct vmctx *ctx;
int vcpuid;
};
+int vcpu_ioctl(struct vcpu *vcpu, u_long cmd, void *arg);
+
+extern const char *vm_capstrmap[];
+
+#define VM_COMMON_IOCTLS \
+ VM_RUN, \
+ VM_SUSPEND, \
+ VM_REINIT, \
+ VM_ALLOC_MEMSEG, \
+ VM_GET_MEMSEG, \
+ VM_MMAP_MEMSEG, \
+ VM_MMAP_MEMSEG, \
+ VM_MMAP_GETNEXT, \
+ VM_MUNMAP_MEMSEG, \
+ VM_SET_REGISTER, \
+ VM_GET_REGISTER, \
+ VM_SET_REGISTER_SET, \
+ VM_GET_REGISTER_SET, \
+ VM_INJECT_EXCEPTION, \
+ VM_SET_CAPABILITY, \
+ VM_GET_CAPABILITY, \
+ VM_STATS, \
+ VM_STAT_DESC, \
+ VM_GLA2GPA_NOFAULT, \
+ VM_ACTIVATE_CPU, \
+ VM_GET_CPUS, \
+ VM_SUSPEND_CPU, \
+ VM_RESUME_CPU, \
+ VM_SET_TOPOLOGY, \
+ VM_GET_TOPOLOGY
+
+#define VM_PPT_IOCTLS \
+ VM_BIND_PPTDEV, \
+ VM_UNBIND_PPTDEV, \
+ VM_MAP_PPTDEV_MMIO, \
+ VM_PPTDEV_MSI, \
+ VM_PPTDEV_MSIX, \
+ VM_UNMAP_PPTDEV_MMIO, \
+ VM_PPTDEV_DISABLE_MSIX
+
+extern const cap_ioctl_t vm_ioctl_cmds[];
+extern size_t vm_ioctl_ncmds;
+
#endif /* !__VMMAPI_INTERNAL_H__ */
diff --git a/lib/libvmmapi/ppt.c b/lib/libvmmapi/ppt.c
new file mode 100644
index 000000000000..fd49f8eed168
--- /dev/null
+++ b/lib/libvmmapi/ppt.c
@@ -0,0 +1,144 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * 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 NETAPP, INC ``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 NETAPP, INC 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <machine/vmm.h>
+
+#include <string.h>
+
+#include "vmmapi.h"
+#include "internal.h"
+
+int
+vm_assign_pptdev(struct vmctx *ctx, int bus, int slot, int func)
+{
+ struct vm_pptdev pptdev;
+
+ bzero(&pptdev, sizeof(pptdev));
+ pptdev.bus = bus;
+ pptdev.slot = slot;
+ pptdev.func = func;
+
+ return (ioctl(ctx->fd, VM_BIND_PPTDEV, &pptdev));
+}
+
+int
+vm_unassign_pptdev(struct vmctx *ctx, int bus, int slot, int func)
+{
+ struct vm_pptdev pptdev;
+
+ bzero(&pptdev, sizeof(pptdev));
+ pptdev.bus = bus;
+ pptdev.slot = slot;
+ pptdev.func = func;
+
+ return (ioctl(ctx->fd, VM_UNBIND_PPTDEV, &pptdev));
+}
+
+int
+vm_map_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
+ vm_paddr_t gpa, size_t len, vm_paddr_t hpa)
+{
+ struct vm_pptdev_mmio pptmmio;
+
+ bzero(&pptmmio, sizeof(pptmmio));
+ pptmmio.bus = bus;
+ pptmmio.slot = slot;
+ pptmmio.func = func;
+ pptmmio.gpa = gpa;
+ pptmmio.len = len;
+ pptmmio.hpa = hpa;
+
+ return (ioctl(ctx->fd, VM_MAP_PPTDEV_MMIO, &pptmmio));
+}
+
+int
+vm_unmap_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
+ vm_paddr_t gpa, size_t len)
+{
+ struct vm_pptdev_mmio pptmmio;
+
+ bzero(&pptmmio, sizeof(pptmmio));
+ pptmmio.bus = bus;
+ pptmmio.slot = slot;
+ pptmmio.func = func;
+ pptmmio.gpa = gpa;
+ pptmmio.len = len;
+
+ return (ioctl(ctx->fd, VM_UNMAP_PPTDEV_MMIO, &pptmmio));
+}
+
+int
+vm_setup_pptdev_msi(struct vmctx *ctx, int bus, int slot, int func,
+ uint64_t addr, uint64_t msg, int numvec)
+{
+ struct vm_pptdev_msi pptmsi;
+
+ bzero(&pptmsi, sizeof(pptmsi));
+ pptmsi.bus = bus;
+ pptmsi.slot = slot;
+ pptmsi.func = func;
+ pptmsi.msg = msg;
+ pptmsi.addr = addr;
+ pptmsi.numvec = numvec;
+
+ return (ioctl(ctx->fd, VM_PPTDEV_MSI, &pptmsi));
+}
+
+int
+vm_setup_pptdev_msix(struct vmctx *ctx, int bus, int slot, int func,
+ int idx, uint64_t addr, uint64_t msg, uint32_t vector_control)
+{
+ struct vm_pptdev_msix pptmsix;
+
+ bzero(&pptmsix, sizeof(pptmsix));
+ pptmsix.bus = bus;
+ pptmsix.slot = slot;
+ pptmsix.func = func;
+ pptmsix.idx = idx;
+ pptmsix.msg = msg;
+ pptmsix.addr = addr;
+ pptmsix.vector_control = vector_control;
+
+ return (ioctl(ctx->fd, VM_PPTDEV_MSIX, &pptmsix));
+}
+
+int
+vm_disable_pptdev_msix(struct vmctx *ctx, int bus, int slot, int func)
+{
+ struct vm_pptdev ppt;
+
+ bzero(&ppt, sizeof(ppt));
+ ppt.bus = bus;
+ ppt.slot = slot;
+ ppt.func = func;
+
+ return (ioctl(ctx->fd, VM_PPTDEV_DISABLE_MSIX, &ppt));
+}
diff --git a/lib/libvmmapi/riscv/Makefile.inc b/lib/libvmmapi/riscv/Makefile.inc
new file mode 100644
index 000000000000..663ea0ab90a3
--- /dev/null
+++ b/lib/libvmmapi/riscv/Makefile.inc
@@ -0,0 +1 @@
+SRCS+= vmmapi_machdep.c
diff --git a/lib/libvmmapi/riscv/vmmapi_machdep.c b/lib/libvmmapi/riscv/vmmapi_machdep.c
new file mode 100644
index 000000000000..4da2fb909f61
--- /dev/null
+++ b/lib/libvmmapi/riscv/vmmapi_machdep.c
@@ -0,0 +1,118 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2011 NetApp, Inc.
+ * 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 NETAPP, INC ``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 NETAPP, INC 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.
+ */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <machine/vmm.h>
+#include <machine/vmm_dev.h>
+#include <machine/vmm_snapshot.h>
+
+#include <assert.h>
+#include <string.h>
+
+#include "vmmapi.h"
+#include "internal.h"
+
+const char *vm_capstrmap[] = {
+ [VM_CAP_SSTC] = "sstc",
+ [VM_CAP_MAX] = NULL,
+};
+
+#define VM_MD_IOCTLS \
+ VM_ATTACH_APLIC, \
+ VM_ASSERT_IRQ, \
+ VM_DEASSERT_IRQ, \
+ VM_RAISE_MSI
+
+const cap_ioctl_t vm_ioctl_cmds[] = {
+ VM_COMMON_IOCTLS,
+ VM_MD_IOCTLS,
+};
+size_t vm_ioctl_ncmds = nitems(vm_ioctl_cmds);
+
+int
+vm_attach_aplic(struct vmctx *ctx, uint64_t mem_start, size_t mem_size)
+{
+ struct vm_aplic_descr aplic;
+
+ bzero(&aplic, sizeof(aplic));
+ aplic.mem_start = mem_start;
+ aplic.mem_size = mem_size;
+
+ return (ioctl(ctx->fd, VM_ATTACH_APLIC, &aplic));
+}
+
+int
+vm_assert_irq(struct vmctx *ctx, uint32_t irq)
+{
+ struct vm_irq vi;
+
+ bzero(&vi, sizeof(vi));
+ vi.irq = irq;
+
+ return (ioctl(ctx->fd, VM_ASSERT_IRQ, &vi));
+}
+
+int
+vm_deassert_irq(struct vmctx *ctx, uint32_t irq)
+{
+ struct vm_irq vi;
+
+ bzero(&vi, sizeof(vi));
+ vi.irq = irq;
+
+ return (ioctl(ctx->fd, VM_DEASSERT_IRQ, &vi));
+}
+
+int
+vm_raise_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg,
+ int bus, int slot, int func)
+{
+ struct vm_msi vmsi;
+
+ bzero(&vmsi, sizeof(vmsi));
+ vmsi.addr = addr;
+ vmsi.msg = msg;
+ vmsi.bus = bus;
+ vmsi.slot = slot;
+ vmsi.func = func;
+
+ return (ioctl(ctx->fd, VM_RAISE_MSI, &vmsi));
+}
+
+int
+vm_inject_exception(struct vcpu *vcpu, uint64_t scause)
+{
+ struct vm_exception vmexc;
+
+ bzero(&vmexc, sizeof(vmexc));
+ vmexc.scause = scause;
+
+ return (vcpu_ioctl(vcpu, VM_INJECT_EXCEPTION, &vmexc));
+}
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index d1470a4aed6e..77f0f8f5c581 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -26,18 +26,19 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/capsicum.h>
+#include <sys/cpuset.h>
+#include <sys/domainset.h>
#include <sys/sysctl.h>
#include <sys/ioctl.h>
-#include <sys/linker.h>
#include <sys/mman.h>
+#include <sys/linker.h>
#include <sys/module.h>
#include <sys/_iovec.h>
-#include <sys/cpuset.h>
#include <capsicum_helpers.h>
+#include <err.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
@@ -51,8 +52,11 @@
#include <vm/vm.h>
#include <machine/vmm.h>
-#include <machine/vmm_dev.h>
+#ifdef WITH_VMMAPI_SNAPSHOT
#include <machine/vmm_snapshot.h>
+#endif
+
+#include <dev/vmm/vmm_dev.h>
#include "vmmapi.h"
#include "internal.h"
@@ -60,6 +64,13 @@
#define MB (1024 * 1024UL)
#define GB (1024 * 1024 * 1024UL)
+#ifdef __amd64__
+#define VM_LOWMEM_LIMIT (3 * GB)
+#else
+#define VM_LOWMEM_LIMIT 0
+#endif
+#define VM_HIGHMEM_BASE (4 * GB)
+
/*
* Size of the guard region before and after the virtual address space
* mapping the guest physical memory. This must be a multiple of the
@@ -70,68 +81,106 @@
#define PROT_RW (PROT_READ | PROT_WRITE)
#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
-struct vmctx {
- int fd;
- uint32_t lowmem_limit;
- int memflags;
- size_t lowmem;
- size_t highmem;
- char *baseaddr;
- char *name;
-};
-
-#define CREATE(x) sysctlbyname("hw.vmm.create", NULL, NULL, (x), strlen((x)))
-#define DESTROY(x) sysctlbyname("hw.vmm.destroy", NULL, NULL, (x), strlen((x)))
-
static int
vm_device_open(const char *name)
{
- int fd, len;
- char *vmfile;
+ char devpath[PATH_MAX];
- len = strlen("/dev/vmm/") + strlen(name) + 1;
- vmfile = malloc(len);
- assert(vmfile != NULL);
- snprintf(vmfile, len, "/dev/vmm/%s", name);
+ assert(strlen(name) <= VM_MAX_NAMELEN);
+ (void)snprintf(devpath, sizeof(devpath), "/dev/vmm/%s", name);
+ return (open(devpath, O_RDWR));
+}
+
+static int
+vm_ctl_open(void)
+{
+ if (modfind("vmm") < 0)
+ (void)kldload("vmm");
+ return (open("/dev/vmmctl", O_RDWR, 0));
+}
- /* Open the device file */
- fd = open(vmfile, O_RDWR, 0);
+static int
+vm_ctl_create(const char *name, int ctlfd)
+{
+ struct vmmctl_vm_create vmc;
- free(vmfile);
- return (fd);
+ memset(&vmc, 0, sizeof(vmc));
+ if (strlcpy(vmc.name, name, sizeof(vmc.name)) >= sizeof(vmc.name)) {
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
+ return (ioctl(ctlfd, VMMCTL_VM_CREATE, &vmc));
}
int
vm_create(const char *name)
{
- /* Try to load vmm(4) module before creating a guest. */
- if (modfind("vmm") < 0)
- kldload("vmm");
- return (CREATE(name));
+ int error, fd;
+
+ fd = vm_ctl_open();
+ if (fd < 0)
+ return (-1);
+
+ error = vm_ctl_create(name, fd);
+ if (error != 0) {
+ error = errno;
+ (void)close(fd);
+ errno = error;
+ return (-1);
+ }
+ (void)close(fd);
+ return (0);
}
struct vmctx *
vm_open(const char *name)
{
+ return (vm_openf(name, 0));
+}
+
+struct vmctx *
+vm_openf(const char *name, int flags)
+{
struct vmctx *vm;
int saved_errno;
+ bool created;
+
+ created = false;
vm = malloc(sizeof(struct vmctx) + strlen(name) + 1);
assert(vm != NULL);
- vm->fd = -1;
+ vm->fd = vm->ctlfd = -1;
vm->memflags = 0;
- vm->lowmem_limit = 3 * GB;
vm->name = (char *)(vm + 1);
strcpy(vm->name, name);
+ memset(vm->memsegs, 0, sizeof(vm->memsegs));
+
+ if ((vm->ctlfd = vm_ctl_open()) < 0)
+ goto err;
+
+ vm->fd = vm_device_open(vm->name);
+ if (vm->fd < 0 && errno == ENOENT) {
+ if (flags & VMMAPI_OPEN_CREATE) {
+ if (vm_ctl_create(vm->name, vm->ctlfd) != 0)
+ goto err;
+ vm->fd = vm_device_open(vm->name);
+ created = true;
+ }
+ }
+ if (vm->fd < 0)
+ goto err;
- if ((vm->fd = vm_device_open(vm->name)) < 0)
+ if (!created && (flags & VMMAPI_OPEN_REINIT) != 0 && vm_reinit(vm) != 0)
goto err;
return (vm);
err:
saved_errno = errno;
- free(vm);
+ if (created)
+ vm_destroy(vm);
+ else
+ vm_close(vm);
errno = saved_errno;
return (NULL);
}
@@ -141,20 +190,24 @@ vm_close(struct vmctx *vm)
{
assert(vm != NULL);
- close(vm->fd);
+ if (vm->fd >= 0)
+ (void)close(vm->fd);
+ if (vm->ctlfd >= 0)
+ (void)close(vm->ctlfd);
free(vm);
}
void
vm_destroy(struct vmctx *vm)
{
- assert(vm != NULL);
+ struct vmmctl_vm_destroy vmd;
- if (vm->fd >= 0)
- close(vm->fd);
- DESTROY(vm->name);
+ memset(&vmd, 0, sizeof(vmd));
+ (void)strlcpy(vmd.name, vm->name, sizeof(vmd.name));
+ if (ioctl(vm->ctlfd, VMMCTL_VM_DESTROY, &vmd) != 0)
+ warn("ioctl(VMMCTL_VM_DESTROY)");
- free(vm);
+ vm_close(vm);
}
struct vcpu *
@@ -205,17 +258,10 @@ vm_parse_memsize(const char *opt, size_t *ret_memsize)
}
uint32_t
-vm_get_lowmem_limit(struct vmctx *ctx)
+vm_get_lowmem_limit(struct vmctx *ctx __unused)
{
- return (ctx->lowmem_limit);
-}
-
-void
-vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit)
-{
-
- ctx->lowmem_limit = limit;
+ return (VM_LOWMEM_LIMIT);
}
void
@@ -277,8 +323,8 @@ vm_get_guestmem_from_ctx(struct vmctx *ctx, char **guest_baseaddr,
{
*guest_baseaddr = ctx->baseaddr;
- *lowmem_size = ctx->lowmem;
- *highmem_size = ctx->highmem;
+ *lowmem_size = ctx->lowmem_size;
+ *highmem_size = ctx->highmem_size;
return (0);
}
@@ -334,7 +380,8 @@ cmpseg(size_t len, const char *str, size_t len2, const char *str2)
}
static int
-vm_alloc_memseg(struct vmctx *ctx, int segid, size_t len, const char *name)
+vm_alloc_memseg(struct vmctx *ctx, int segid, size_t len, const char *name,
+ int ds_policy, domainset_t *ds_mask, size_t ds_size)
{
struct vm_memseg memseg;
size_t n;
@@ -362,6 +409,13 @@ vm_alloc_memseg(struct vmctx *ctx, int segid, size_t len, const char *name)
bzero(&memseg, sizeof(struct vm_memseg));
memseg.segid = segid;
memseg.len = len;
+ if (ds_mask == NULL) {
+ memseg.ds_policy = DOMAINSET_POLICY_INVALID;
+ } else {
+ memseg.ds_policy = ds_policy;
+ memseg.ds_mask = ds_mask;
+ memseg.ds_mask_size = ds_size;
+ }
if (name != NULL) {
n = strlcpy(memseg.name, name, sizeof(memseg.name));
if (n >= sizeof(memseg.name)) {
@@ -382,6 +436,7 @@ vm_get_memseg(struct vmctx *ctx, int segid, size_t *lenp, char *namebuf,
size_t n;
int error;
+ bzero(&memseg, sizeof(memseg));
memseg.segid = segid;
error = ioctl(ctx->fd, VM_GET_MEMSEG, &memseg);
if (error == 0) {
@@ -396,13 +451,14 @@ vm_get_memseg(struct vmctx *ctx, int segid, size_t *lenp, char *namebuf,
}
static int
-setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char *base)
+map_memory_segment(struct vmctx *ctx, int segid, vm_paddr_t gpa, size_t len,
+ size_t segoff, char *base)
{
char *ptr;
int error, flags;
/* Map 'len' bytes starting at 'gpa' in the guest address space */
- error = vm_mmap_memseg(ctx, gpa, VM_SYSMEM, gpa, len, PROT_ALL);
+ error = vm_mmap_memseg(ctx, gpa, segid, segoff, len, PROT_ALL);
if (error)
return (error);
@@ -418,65 +474,136 @@ setup_memory_segment(struct vmctx *ctx, vm_paddr_t gpa, size_t len, char *base)
return (0);
}
+/*
+ * Allocates and maps virtual machine memory segments according
+ * to the NUMA topology specified by the 'doms' array.
+ *
+ * The domains are laid out sequentially in the guest's physical address space.
+ * The [VM_LOWMEM_LIMIT, VM_HIGHMEM_BASE) address range is skipped and
+ * left unmapped.
+ */
int
-vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
+vm_setup_memory_domains(struct vmctx *ctx, enum vm_mmap_style vms,
+ struct vm_mem_domain *doms, int ndoms)
{
- size_t objsize, len;
- vm_paddr_t gpa;
+ size_t low_len, len, totalsize;
+ struct vm_mem_domain *dom;
+ struct vm_memseg memseg;
char *baseaddr, *ptr;
- int error;
+ int error, i, segid;
+ vm_paddr_t gpa;
+ /* Sanity checks. */
assert(vms == VM_MMAP_ALL);
-
- /*
- * If 'memsize' cannot fit entirely in the 'lowmem' segment then
- * create another 'highmem' segment above 4GB for the remainder.
- */
- if (memsize > ctx->lowmem_limit) {
- ctx->lowmem = ctx->lowmem_limit;
- ctx->highmem = memsize - ctx->lowmem_limit;
- objsize = 4*GB + ctx->highmem;
- } else {
- ctx->lowmem = memsize;
- ctx->highmem = 0;
- objsize = ctx->lowmem;
+ if (doms == NULL || ndoms <= 0 || ndoms > VM_MAXMEMDOM) {
+ errno = EINVAL;
+ return (-1);
}
- error = vm_alloc_memseg(ctx, VM_SYSMEM, objsize, NULL);
- if (error)
- return (error);
+ /* Calculate total memory size. */
+ totalsize = 0;
+ for (i = 0; i < ndoms; i++)
+ totalsize += doms[i].size;
+
+ if (totalsize > VM_LOWMEM_LIMIT)
+ totalsize = VM_HIGHMEM_BASE + (totalsize - VM_LOWMEM_LIMIT);
/*
* Stake out a contiguous region covering the guest physical memory
* and the adjoining guard regions.
*/
- len = VM_MMAP_GUARD_SIZE + objsize + VM_MMAP_GUARD_SIZE;
+ len = VM_MMAP_GUARD_SIZE + totalsize + VM_MMAP_GUARD_SIZE;
ptr = mmap(NULL, len, PROT_NONE, MAP_GUARD | MAP_ALIGNED_SUPER, -1, 0);
if (ptr == MAP_FAILED)
return (-1);
-
baseaddr = ptr + VM_MMAP_GUARD_SIZE;
- if (ctx->highmem > 0) {
- gpa = 4*GB;
- len = ctx->highmem;
- error = setup_memory_segment(ctx, gpa, len, baseaddr);
- if (error)
- return (error);
- }
- if (ctx->lowmem > 0) {
- gpa = 0;
- len = ctx->lowmem;
- error = setup_memory_segment(ctx, gpa, len, baseaddr);
- if (error)
- return (error);
- }
+ /*
+ * Allocate and map memory segments for the virtual machine.
+ */
+ gpa = VM_LOWMEM_LIMIT > 0 ? 0 : VM_HIGHMEM_BASE;
+ ctx->lowmem_size = 0;
+ ctx->highmem_size = 0;
+ for (i = 0; i < ndoms; i++) {
+ segid = VM_SYSMEM + i;
+ dom = &doms[i];
+ /*
+ * Check if the memory segment already exists.
+ * If 'ndoms' is greater than one, refuse to proceed if the
+ * memseg already exists. If only one domain was requested, use
+ * the existing segment to preserve the behaviour of the previous
+ * implementation.
+ *
+ * Splitting existing memory segments is tedious and
+ * error-prone, which is why we don't support NUMA
+ * domains for bhyveload(8)-loaded VMs.
+ */
+ error = vm_get_memseg(ctx, segid, &len, memseg.name,
+ sizeof(memseg.name));
+ if (error == 0 && len != 0) {
+ if (ndoms != 1) {
+ errno = EEXIST;
+ return (-1);
+ } else
+ doms[0].size = len;
+ } else {
+ error = vm_alloc_memseg(ctx, segid, dom->size, NULL,
+ dom->ds_policy, dom->ds_mask, dom->ds_size);
+ if (error)
+ return (error);
+ }
+
+ /*
+ * If a domain is split by VM_LOWMEM_LIMIT then break
+ * its segment mapping into two parts, one below VM_LOWMEM_LIMIT
+ * and one above VM_HIGHMEM_BASE.
+ */
+ if (gpa <= VM_LOWMEM_LIMIT &&
+ gpa + dom->size > VM_LOWMEM_LIMIT) {
+ low_len = VM_LOWMEM_LIMIT - gpa;
+ error = map_memory_segment(ctx, segid, gpa, low_len, 0,
+ baseaddr);
+ if (error)
+ return (error);
+ ctx->lowmem_size = VM_LOWMEM_LIMIT;
+ /* Map the remainder. */
+ gpa = VM_HIGHMEM_BASE;
+ len = dom->size - low_len;
+ error = map_memory_segment(ctx, segid, gpa, len,
+ low_len, baseaddr);
+ if (error)
+ return (error);
+ } else {
+ len = dom->size;
+ error = map_memory_segment(ctx, segid, gpa, len, 0,
+ baseaddr);
+ if (error)
+ return (error);
+ }
+ if (gpa <= VM_LOWMEM_LIMIT)
+ ctx->lowmem_size += len;
+ else
+ ctx->highmem_size += len;
+ gpa += len;
+ }
ctx->baseaddr = baseaddr;
return (0);
}
+int
+vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
+{
+ struct vm_mem_domain dom0;
+
+ memset(&dom0, 0, sizeof(dom0));
+ dom0.ds_policy = DOMAINSET_POLICY_INVALID;
+ dom0.size = memsize;
+
+ return (vm_setup_memory_domains(ctx, vms, &dom0, 1));
+}
+
/*
* Returns a non-NULL pointer if [gaddr, gaddr+len) is entirely contained in
* the lowmem or highmem regions.
@@ -487,20 +614,19 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize, enum vm_mmap_style vms)
void *
vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len)
{
+ vm_size_t lowsize, highsize;
- if (ctx->lowmem > 0) {
- if (gaddr < ctx->lowmem && len <= ctx->lowmem &&
- gaddr + len <= ctx->lowmem)
+ lowsize = ctx->lowmem_size;
+ if (lowsize > 0) {
+ if (gaddr < lowsize && len <= lowsize && gaddr + len <= lowsize)
return (ctx->baseaddr + gaddr);
}
- if (ctx->highmem > 0) {
- if (gaddr >= 4*GB) {
- if (gaddr < 4*GB + ctx->highmem &&
- len <= ctx->highmem &&
- gaddr + len <= 4*GB + ctx->highmem)
- return (ctx->baseaddr + gaddr);
- }
+ highsize = ctx->highmem_size;
+ if (highsize > 0 && gaddr >= VM_HIGHMEM_BASE) {
+ if (gaddr < VM_HIGHMEM_BASE + highsize && len <= highsize &&
+ gaddr + len <= VM_HIGHMEM_BASE + highsize)
+ return (ctx->baseaddr + gaddr);
}
return (NULL);
@@ -510,15 +636,19 @@ vm_paddr_t
vm_rev_map_gpa(struct vmctx *ctx, void *addr)
{
vm_paddr_t offaddr;
+ vm_size_t lowsize, highsize;
offaddr = (char *)addr - ctx->baseaddr;
- if (ctx->lowmem > 0)
- if (offaddr <= ctx->lowmem)
+ lowsize = ctx->lowmem_size;
+ if (lowsize > 0)
+ if (offaddr <= lowsize)
return (offaddr);
- if (ctx->highmem > 0)
- if (offaddr >= 4*GB && offaddr < 4*GB + ctx->highmem)
+ highsize = ctx->highmem_size;
+ if (highsize > 0)
+ if (offaddr >= VM_HIGHMEM_BASE &&
+ offaddr < VM_HIGHMEM_BASE + highsize)
return (offaddr);
return ((vm_paddr_t)-1);
@@ -534,15 +664,20 @@ vm_get_name(struct vmctx *ctx)
size_t
vm_get_lowmem_size(struct vmctx *ctx)
{
+ return (ctx->lowmem_size);
+}
+
+vm_paddr_t
+vm_get_highmem_base(struct vmctx *ctx __unused)
+{
- return (ctx->lowmem);
+ return (VM_HIGHMEM_BASE);
}
size_t
vm_get_highmem_size(struct vmctx *ctx)
{
-
- return (ctx->highmem);
+ return (ctx->highmem_size);
}
void *
@@ -560,7 +695,7 @@ vm_create_devmem(struct vmctx *ctx, int segid, const char *name, size_t len)
goto done;
}
- error = vm_alloc_memseg(ctx, segid, len, name);
+ error = vm_alloc_memseg(ctx, segid, len, name, 0, NULL, 0);
if (error)
goto done;
@@ -595,7 +730,7 @@ done:
return (ptr);
}
-static int
+int
vcpu_ioctl(struct vcpu *vcpu, u_long cmd, void *arg)
{
/*
@@ -608,52 +743,6 @@ vcpu_ioctl(struct vcpu *vcpu, u_long cmd, void *arg)
}
int
-vm_set_desc(struct vcpu *vcpu, int reg,
- uint64_t base, uint32_t limit, uint32_t access)
-{
- int error;
- struct vm_seg_desc vmsegdesc;
-
- bzero(&vmsegdesc, sizeof(vmsegdesc));
- vmsegdesc.regnum = reg;
- vmsegdesc.desc.base = base;
- vmsegdesc.desc.limit = limit;
- vmsegdesc.desc.access = access;
-
- error = vcpu_ioctl(vcpu, VM_SET_SEGMENT_DESCRIPTOR, &vmsegdesc);
- return (error);
-}
-
-int
-vm_get_desc(struct vcpu *vcpu, int reg, uint64_t *base, uint32_t *limit,
- uint32_t *access)
-{
- int error;
- struct vm_seg_desc vmsegdesc;
-
- bzero(&vmsegdesc, sizeof(vmsegdesc));
- vmsegdesc.regnum = reg;
-
- error = vcpu_ioctl(vcpu, VM_GET_SEGMENT_DESCRIPTOR, &vmsegdesc);
- if (error == 0) {
- *base = vmsegdesc.desc.base;
- *limit = vmsegdesc.desc.limit;
- *access = vmsegdesc.desc.access;
- }
- return (error);
-}
-
-int
-vm_get_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *seg_desc)
-{
- int error;
-
- error = vm_get_desc(vcpu, reg, &seg_desc->base, &seg_desc->limit,
- &seg_desc->access);
- return (error);
-}
-
-int
vm_set_register(struct vcpu *vcpu, int reg, uint64_t val)
{
int error;
@@ -737,196 +826,13 @@ vm_reinit(struct vmctx *ctx)
}
int
-vm_inject_exception(struct vcpu *vcpu, int vector, int errcode_valid,
- uint32_t errcode, int restart_instruction)
-{
- struct vm_exception exc;
-
- exc.vector = vector;
- exc.error_code = errcode;
- exc.error_code_valid = errcode_valid;
- exc.restart_instruction = restart_instruction;
-
- return (vcpu_ioctl(vcpu, VM_INJECT_EXCEPTION, &exc));
-}
-
-int
-vm_apicid2vcpu(struct vmctx *ctx __unused, int apicid)
-{
- /*
- * The apic id associated with the 'vcpu' has the same numerical value
- * as the 'vcpu' itself.
- */
- return (apicid);
-}
-
-int
-vm_lapic_irq(struct vcpu *vcpu, int vector)
-{
- struct vm_lapic_irq vmirq;
-
- bzero(&vmirq, sizeof(vmirq));
- vmirq.vector = vector;
-
- return (vcpu_ioctl(vcpu, VM_LAPIC_IRQ, &vmirq));
-}
-
-int
-vm_lapic_local_irq(struct vcpu *vcpu, int vector)
-{
- struct vm_lapic_irq vmirq;
-
- bzero(&vmirq, sizeof(vmirq));
- vmirq.vector = vector;
-
- return (vcpu_ioctl(vcpu, VM_LAPIC_LOCAL_IRQ, &vmirq));
-}
-
-int
-vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg)
-{
- struct vm_lapic_msi vmmsi;
-
- bzero(&vmmsi, sizeof(vmmsi));
- vmmsi.addr = addr;
- vmmsi.msg = msg;
-
- return (ioctl(ctx->fd, VM_LAPIC_MSI, &vmmsi));
-}
-
-int
-vm_ioapic_assert_irq(struct vmctx *ctx, int irq)
-{
- struct vm_ioapic_irq ioapic_irq;
-
- bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
- ioapic_irq.irq = irq;
-
- return (ioctl(ctx->fd, VM_IOAPIC_ASSERT_IRQ, &ioapic_irq));
-}
-
-int
-vm_ioapic_deassert_irq(struct vmctx *ctx, int irq)
-{
- struct vm_ioapic_irq ioapic_irq;
-
- bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
- ioapic_irq.irq = irq;
-
- return (ioctl(ctx->fd, VM_IOAPIC_DEASSERT_IRQ, &ioapic_irq));
-}
-
-int
-vm_ioapic_pulse_irq(struct vmctx *ctx, int irq)
-{
- struct vm_ioapic_irq ioapic_irq;
-
- bzero(&ioapic_irq, sizeof(struct vm_ioapic_irq));
- ioapic_irq.irq = irq;
-
- return (ioctl(ctx->fd, VM_IOAPIC_PULSE_IRQ, &ioapic_irq));
-}
-
-int
-vm_ioapic_pincount(struct vmctx *ctx, int *pincount)
-{
-
- return (ioctl(ctx->fd, VM_IOAPIC_PINCOUNT, pincount));
-}
-
-int
-vm_readwrite_kernemu_device(struct vcpu *vcpu, vm_paddr_t gpa,
- bool write, int size, uint64_t *value)
-{
- struct vm_readwrite_kernemu_device irp = {
- .access_width = fls(size) - 1,
- .gpa = gpa,
- .value = write ? *value : ~0ul,
- };
- long cmd = (write ? VM_SET_KERNEMU_DEV : VM_GET_KERNEMU_DEV);
- int rc;
-
- rc = vcpu_ioctl(vcpu, cmd, &irp);
- if (rc == 0 && !write)
- *value = irp.value;
- return (rc);
-}
-
-int
-vm_isa_assert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
-{
- struct vm_isa_irq isa_irq;
-
- bzero(&isa_irq, sizeof(struct vm_isa_irq));
- isa_irq.atpic_irq = atpic_irq;
- isa_irq.ioapic_irq = ioapic_irq;
-
- return (ioctl(ctx->fd, VM_ISA_ASSERT_IRQ, &isa_irq));
-}
-
-int
-vm_isa_deassert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
-{
- struct vm_isa_irq isa_irq;
-
- bzero(&isa_irq, sizeof(struct vm_isa_irq));
- isa_irq.atpic_irq = atpic_irq;
- isa_irq.ioapic_irq = ioapic_irq;
-
- return (ioctl(ctx->fd, VM_ISA_DEASSERT_IRQ, &isa_irq));
-}
-
-int
-vm_isa_pulse_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq)
-{
- struct vm_isa_irq isa_irq;
-
- bzero(&isa_irq, sizeof(struct vm_isa_irq));
- isa_irq.atpic_irq = atpic_irq;
- isa_irq.ioapic_irq = ioapic_irq;
-
- return (ioctl(ctx->fd, VM_ISA_PULSE_IRQ, &isa_irq));
-}
-
-int
-vm_isa_set_irq_trigger(struct vmctx *ctx, int atpic_irq,
- enum vm_intr_trigger trigger)
-{
- struct vm_isa_irq_trigger isa_irq_trigger;
-
- bzero(&isa_irq_trigger, sizeof(struct vm_isa_irq_trigger));
- isa_irq_trigger.atpic_irq = atpic_irq;
- isa_irq_trigger.trigger = trigger;
-
- return (ioctl(ctx->fd, VM_ISA_SET_IRQ_TRIGGER, &isa_irq_trigger));
-}
-
-int
-vm_inject_nmi(struct vcpu *vcpu)
-{
- struct vm_nmi vmnmi;
-
- bzero(&vmnmi, sizeof(vmnmi));
-
- return (vcpu_ioctl(vcpu, VM_INJECT_NMI, &vmnmi));
-}
-
-static const char *capstrmap[] = {
- [VM_CAP_HALT_EXIT] = "hlt_exit",
- [VM_CAP_MTRAP_EXIT] = "mtrap_exit",
- [VM_CAP_PAUSE_EXIT] = "pause_exit",
- [VM_CAP_UNRESTRICTED_GUEST] = "unrestricted_guest",
- [VM_CAP_ENABLE_INVPCID] = "enable_invpcid",
- [VM_CAP_BPT_EXIT] = "bpt_exit",
-};
-
-int
vm_capability_name2type(const char *capname)
{
int i;
- for (i = 0; i < (int)nitems(capstrmap); i++) {
- if (strcmp(capstrmap[i], capname) == 0)
+ for (i = 0; i < VM_CAP_MAX; i++) {
+ if (vm_capstrmap[i] != NULL &&
+ strcmp(vm_capstrmap[i], capname) == 0)
return (i);
}
@@ -936,8 +842,8 @@ vm_capability_name2type(const char *capname)
const char *
vm_capability_type2name(int type)
{
- if (type >= 0 && type < (int)nitems(capstrmap))
- return (capstrmap[type]);
+ if (type >= 0 && type < VM_CAP_MAX)
+ return (vm_capstrmap[type]);
return (NULL);
}
@@ -968,113 +874,6 @@ vm_set_capability(struct vcpu *vcpu, enum vm_cap_type cap, int val)
return (vcpu_ioctl(vcpu, VM_SET_CAPABILITY, &vmcap));
}
-int
-vm_assign_pptdev(struct vmctx *ctx, int bus, int slot, int func)
-{
- struct vm_pptdev pptdev;
-
- bzero(&pptdev, sizeof(pptdev));
- pptdev.bus = bus;
- pptdev.slot = slot;
- pptdev.func = func;
-
- return (ioctl(ctx->fd, VM_BIND_PPTDEV, &pptdev));
-}
-
-int
-vm_unassign_pptdev(struct vmctx *ctx, int bus, int slot, int func)
-{
- struct vm_pptdev pptdev;
-
- bzero(&pptdev, sizeof(pptdev));
- pptdev.bus = bus;
- pptdev.slot = slot;
- pptdev.func = func;
-
- return (ioctl(ctx->fd, VM_UNBIND_PPTDEV, &pptdev));
-}
-
-int
-vm_map_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
- vm_paddr_t gpa, size_t len, vm_paddr_t hpa)
-{
- struct vm_pptdev_mmio pptmmio;
-
- bzero(&pptmmio, sizeof(pptmmio));
- pptmmio.bus = bus;
- pptmmio.slot = slot;
- pptmmio.func = func;
- pptmmio.gpa = gpa;
- pptmmio.len = len;
- pptmmio.hpa = hpa;
-
- return (ioctl(ctx->fd, VM_MAP_PPTDEV_MMIO, &pptmmio));
-}
-
-int
-vm_unmap_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,
- vm_paddr_t gpa, size_t len)
-{
- struct vm_pptdev_mmio pptmmio;
-
- bzero(&pptmmio, sizeof(pptmmio));
- pptmmio.bus = bus;
- pptmmio.slot = slot;
- pptmmio.func = func;
- pptmmio.gpa = gpa;
- pptmmio.len = len;
-
- return (ioctl(ctx->fd, VM_UNMAP_PPTDEV_MMIO, &pptmmio));
-}
-
-int
-vm_setup_pptdev_msi(struct vmctx *ctx, int bus, int slot, int func,
- uint64_t addr, uint64_t msg, int numvec)
-{
- struct vm_pptdev_msi pptmsi;
-
- bzero(&pptmsi, sizeof(pptmsi));
- pptmsi.bus = bus;
- pptmsi.slot = slot;
- pptmsi.func = func;
- pptmsi.msg = msg;
- pptmsi.addr = addr;
- pptmsi.numvec = numvec;
-
- return (ioctl(ctx->fd, VM_PPTDEV_MSI, &pptmsi));
-}
-
-int
-vm_setup_pptdev_msix(struct vmctx *ctx, int bus, int slot, int func,
- int idx, uint64_t addr, uint64_t msg, uint32_t vector_control)
-{
- struct vm_pptdev_msix pptmsix;
-
- bzero(&pptmsix, sizeof(pptmsix));
- pptmsix.bus = bus;
- pptmsix.slot = slot;
- pptmsix.func = func;
- pptmsix.idx = idx;
- pptmsix.msg = msg;
- pptmsix.addr = addr;
- pptmsix.vector_control = vector_control;
-
- return ioctl(ctx->fd, VM_PPTDEV_MSIX, &pptmsix);
-}
-
-int
-vm_disable_pptdev_msix(struct vmctx *ctx, int bus, int slot, int func)
-{
- struct vm_pptdev ppt;
-
- bzero(&ppt, sizeof(ppt));
- ppt.bus = bus;
- ppt.slot = slot;
- ppt.func = func;
-
- return ioctl(ctx->fd, VM_PPTDEV_DISABLE_MSIX, &ppt);
-}
-
uint64_t *
vm_get_stats(struct vcpu *vcpu, struct timeval *ret_tv,
int *ret_entries)
@@ -1132,226 +931,7 @@ vm_get_stat_desc(struct vmctx *ctx, int index)
return (NULL);
}
-int
-vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *state)
-{
- int error;
- struct vm_x2apic x2apic;
-
- bzero(&x2apic, sizeof(x2apic));
-
- error = vcpu_ioctl(vcpu, VM_GET_X2APIC_STATE, &x2apic);
- *state = x2apic.state;
- return (error);
-}
-
-int
-vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state state)
-{
- int error;
- struct vm_x2apic x2apic;
-
- bzero(&x2apic, sizeof(x2apic));
- x2apic.state = state;
-
- error = vcpu_ioctl(vcpu, VM_SET_X2APIC_STATE, &x2apic);
-
- return (error);
-}
-
-/*
- * From Intel Vol 3a:
- * Table 9-1. IA-32 Processor States Following Power-up, Reset or INIT
- */
-int
-vcpu_reset(struct vcpu *vcpu)
-{
- int error;
- uint64_t rflags, rip, cr0, cr4, zero, desc_base, rdx;
- uint32_t desc_access, desc_limit;
- uint16_t sel;
-
- zero = 0;
-
- rflags = 0x2;
- error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags);
- if (error)
- goto done;
-
- rip = 0xfff0;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip)) != 0)
- goto done;
-
- /*
- * According to Intels Software Developer Manual CR0 should be
- * initialized with CR0_ET | CR0_NW | CR0_CD but that crashes some
- * guests like Windows.
- */
- cr0 = CR0_NE;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR2, zero)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR3, zero)) != 0)
- goto done;
-
- cr4 = 0;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4)) != 0)
- goto done;
-
- /*
- * CS: present, r/w, accessed, 16-bit, byte granularity, usable
- */
- desc_base = 0xffff0000;
- desc_limit = 0xffff;
- desc_access = 0x0093;
- error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- sel = 0xf000;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, sel)) != 0)
- goto done;
-
- /*
- * SS,DS,ES,FS,GS: present, r/w, accessed, 16-bit, byte granularity
- */
- desc_base = 0;
- desc_limit = 0xffff;
- desc_access = 0x0093;
- error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- sel = 0;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, sel)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, sel)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, sel)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, sel)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, sel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, zero)) != 0)
- goto done;
-
- /* General purpose registers */
- rdx = 0xf00;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RAX, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBX, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RCX, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDX, rdx)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSI, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RDI, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RBP, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R8, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R9, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R10, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R11, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R12, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R13, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R14, zero)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_R15, zero)) != 0)
- goto done;
-
- /* GDTR, IDTR */
- desc_base = 0;
- desc_limit = 0xffff;
- desc_access = 0;
- error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
- desc_base, desc_limit, desc_access);
- if (error != 0)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_IDTR,
- desc_base, desc_limit, desc_access);
- if (error != 0)
- goto done;
-
- /* TR */
- desc_base = 0;
- desc_limit = 0xffff;
- desc_access = 0x0000008b;
- error = vm_set_desc(vcpu, VM_REG_GUEST_TR, 0, 0, desc_access);
- if (error)
- goto done;
-
- sel = 0;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, sel)) != 0)
- goto done;
-
- /* LDTR */
- desc_base = 0;
- desc_limit = 0xffff;
- desc_access = 0x00000082;
- error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, desc_base,
- desc_limit, desc_access);
- if (error)
- goto done;
-
- sel = 0;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR6,
- 0xffff0ff0)) != 0)
- goto done;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_DR7, 0x400)) !=
- 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_INTR_SHADOW,
- zero)) != 0)
- goto done;
-
- error = 0;
-done:
- return (error);
-}
-
+#ifdef __amd64__
int
vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num)
{
@@ -1373,19 +953,6 @@ vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num)
}
int
-vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities)
-{
- int error;
- struct vm_hpet_cap cap;
-
- bzero(&cap, sizeof(struct vm_hpet_cap));
- error = ioctl(ctx->fd, VM_GET_HPET_CAPABILITIES, &cap);
- if (capabilities != NULL)
- *capabilities = cap.capabilities;
- return (error);
-}
-
-int
vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, int prot, uint64_t *gpa, int *fault)
{
@@ -1404,6 +971,7 @@ vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging,
}
return (error);
}
+#endif
int
vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging,
@@ -1429,6 +997,7 @@ vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging,
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
+#ifdef __amd64__
int
vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt,
@@ -1466,6 +1035,7 @@ vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging,
}
return (0);
}
+#endif
void
vm_copy_teardown(struct iovec *iov __unused, int iovcnt __unused)
@@ -1610,6 +1180,7 @@ vm_resume_all_cpus(struct vmctx *ctx)
return (error);
}
+#ifdef __amd64__
int
vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2)
{
@@ -1636,59 +1207,9 @@ vm_set_intinfo(struct vcpu *vcpu, uint64_t info1)
error = vcpu_ioctl(vcpu, VM_SET_INTINFO, &vmii);
return (error);
}
+#endif
-int
-vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value)
-{
- struct vm_rtc_data rtcdata;
- int error;
-
- bzero(&rtcdata, sizeof(struct vm_rtc_data));
- rtcdata.offset = offset;
- rtcdata.value = value;
- error = ioctl(ctx->fd, VM_RTC_WRITE, &rtcdata);
- return (error);
-}
-
-int
-vm_rtc_read(struct vmctx *ctx, int offset, uint8_t *retval)
-{
- struct vm_rtc_data rtcdata;
- int error;
-
- bzero(&rtcdata, sizeof(struct vm_rtc_data));
- rtcdata.offset = offset;
- error = ioctl(ctx->fd, VM_RTC_READ, &rtcdata);
- if (error == 0)
- *retval = rtcdata.value;
- return (error);
-}
-
-int
-vm_rtc_settime(struct vmctx *ctx, time_t secs)
-{
- struct vm_rtc_time rtctime;
- int error;
-
- bzero(&rtctime, sizeof(struct vm_rtc_time));
- rtctime.secs = secs;
- error = ioctl(ctx->fd, VM_RTC_SETTIME, &rtctime);
- return (error);
-}
-
-int
-vm_rtc_gettime(struct vmctx *ctx, time_t *secs)
-{
- struct vm_rtc_time rtctime;
- int error;
-
- bzero(&rtctime, sizeof(struct vm_rtc_time));
- error = ioctl(ctx->fd, VM_RTC_GETTIME, &rtctime);
- if (error == 0)
- *secs = rtctime.secs;
- return (error);
-}
-
+#ifdef WITH_VMMAPI_SNAPSHOT
int
vm_restart_instruction(struct vcpu *vcpu)
{
@@ -1719,6 +1240,7 @@ vm_restore_time(struct vmctx *ctx)
dummy = 0;
return (ioctl(ctx->fd, VM_RESTORE_TIME, &dummy));
}
+#endif
int
vm_set_topology(struct vmctx *ctx,
@@ -1752,42 +1274,15 @@ vm_get_topology(struct vmctx *ctx,
return (error);
}
-/* Keep in sync with machine/vmm_dev.h. */
-static const cap_ioctl_t vm_ioctl_cmds[] = { VM_RUN, VM_SUSPEND, VM_REINIT,
- VM_ALLOC_MEMSEG, VM_GET_MEMSEG, VM_MMAP_MEMSEG, VM_MMAP_MEMSEG,
- VM_MMAP_GETNEXT, VM_MUNMAP_MEMSEG, VM_SET_REGISTER, VM_GET_REGISTER,
- VM_SET_SEGMENT_DESCRIPTOR, VM_GET_SEGMENT_DESCRIPTOR,
- VM_SET_REGISTER_SET, VM_GET_REGISTER_SET,
- VM_SET_KERNEMU_DEV, VM_GET_KERNEMU_DEV,
- VM_INJECT_EXCEPTION, VM_LAPIC_IRQ, VM_LAPIC_LOCAL_IRQ,
- VM_LAPIC_MSI, VM_IOAPIC_ASSERT_IRQ, VM_IOAPIC_DEASSERT_IRQ,
- VM_IOAPIC_PULSE_IRQ, VM_IOAPIC_PINCOUNT, VM_ISA_ASSERT_IRQ,
- VM_ISA_DEASSERT_IRQ, VM_ISA_PULSE_IRQ, VM_ISA_SET_IRQ_TRIGGER,
- VM_SET_CAPABILITY, VM_GET_CAPABILITY, VM_BIND_PPTDEV,
- VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_PPTDEV_MSI,
- VM_PPTDEV_MSIX, VM_UNMAP_PPTDEV_MMIO, VM_PPTDEV_DISABLE_MSIX,
- VM_INJECT_NMI, VM_STATS, VM_STAT_DESC,
- VM_SET_X2APIC_STATE, VM_GET_X2APIC_STATE,
- VM_GET_HPET_CAPABILITIES, VM_GET_GPA_PMAP, VM_GLA2GPA,
- VM_GLA2GPA_NOFAULT,
- VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU,
- VM_SET_INTINFO, VM_GET_INTINFO,
- VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME,
- VM_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY,
- VM_SNAPSHOT_REQ, VM_RESTORE_TIME
-};
-
int
vm_limit_rights(struct vmctx *ctx)
{
cap_rights_t rights;
- size_t ncmds;
cap_rights_init(&rights, CAP_IOCTL, CAP_MMAP_RW);
if (caph_rights_limit(ctx->fd, &rights) != 0)
return (-1);
- ncmds = nitems(vm_ioctl_cmds);
- if (caph_ioctls_limit(ctx->fd, vm_ioctl_cmds, ncmds) != 0)
+ if (caph_ioctls_limit(ctx->fd, vm_ioctl_cmds, vm_ioctl_ncmds) != 0)
return (-1);
return (0);
}
@@ -1808,15 +1303,17 @@ const cap_ioctl_t *
vm_get_ioctls(size_t *len)
{
cap_ioctl_t *cmds;
+ size_t sz;
if (len == NULL) {
- cmds = malloc(sizeof(vm_ioctl_cmds));
+ sz = vm_ioctl_ncmds * sizeof(vm_ioctl_cmds[0]);
+ cmds = malloc(sz);
if (cmds == NULL)
return (NULL);
- bcopy(vm_ioctl_cmds, cmds, sizeof(vm_ioctl_cmds));
+ bcopy(vm_ioctl_cmds, cmds, sz);
return (cmds);
}
- *len = nitems(vm_ioctl_cmds);
+ *len = vm_ioctl_ncmds;
return (NULL);
}
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index 986b23759d87..b637c45d1eff 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -29,7 +29,6 @@
#ifndef _VMMAPI_H_
#define _VMMAPI_H_
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#include <machine/vmm.h>
@@ -41,7 +40,7 @@
* API version for out-of-tree consumers like grub-bhyve for making compile
* time decisions.
*/
-#define VMMAPI_VERSION 0200 /* 2 digit major followed by 2 digit minor */
+#define VMMAPI_VERSION 0300 /* 2 digit major followed by 2 digit minor */
struct iovec;
struct vcpu;
@@ -65,16 +64,12 @@ enum vm_mmap_style {
#define VM_MEM_F_INCORE 0x01 /* include guest memory in core file */
#define VM_MEM_F_WIRED 0x02 /* guest memory is wired */
-/*
- * Identifiers for memory segments:
- * - vm_setup_memory() uses VM_SYSMEM for the system memory segment.
- * - the remaining identifiers can be used to create devmem segments.
- */
-enum {
- VM_SYSMEM,
- VM_BOOTROM,
- VM_FRAMEBUFFER,
- VM_PCIROM,
+/* Memory size and allocation policy for a single NUMA domain. */
+struct vm_mem_domain {
+ size_t size;
+ int ds_policy;
+ domainset_t *ds_mask;
+ size_t ds_size;
};
__BEGIN_DECLS
@@ -118,6 +113,9 @@ int vm_munmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, size_t len);
int vm_create(const char *name);
struct vmctx *vm_open(const char *name);
+#define VMMAPI_OPEN_CREATE 0x01 /* create if the VM does not exist */
+#define VMMAPI_OPEN_REINIT 0x02 /* reinitialize the VM if it exists */
+struct vmctx *vm_openf(const char *name, int flags);
void vm_close(struct vmctx *ctx);
void vm_destroy(struct vmctx *ctx);
int vm_limit_rights(struct vmctx *ctx);
@@ -125,28 +123,34 @@ struct vcpu *vm_vcpu_open(struct vmctx *ctx, int vcpuid);
void vm_vcpu_close(struct vcpu *vcpu);
int vcpu_id(struct vcpu *vcpu);
int vm_parse_memsize(const char *optarg, size_t *memsize);
-int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s);
+int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s);
+int vm_setup_memory_domains(struct vmctx *ctx, enum vm_mmap_style s,
+ struct vm_mem_domain *doms, int ndoms);
void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len);
/* inverse operation to vm_map_gpa - extract guest address from host pointer */
vm_paddr_t vm_rev_map_gpa(struct vmctx *ctx, void *addr);
+#ifdef __amd64__
int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num);
int vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, int prot, uint64_t *gpa, int *fault);
+#endif
int vm_gla2gpa_nofault(struct vcpu *vcpu,
struct vm_guest_paging *paging, uint64_t gla, int prot,
uint64_t *gpa, int *fault);
uint32_t vm_get_lowmem_limit(struct vmctx *ctx);
-void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit);
void vm_set_memflags(struct vmctx *ctx, int flags);
int vm_get_memflags(struct vmctx *ctx);
const char *vm_get_name(struct vmctx *ctx);
size_t vm_get_lowmem_size(struct vmctx *ctx);
+vm_paddr_t vm_get_highmem_base(struct vmctx *ctx);
size_t vm_get_highmem_size(struct vmctx *ctx);
+#ifdef __amd64__
int vm_set_desc(struct vcpu *vcpu, int reg,
uint64_t base, uint32_t limit, uint32_t access);
int vm_get_desc(struct vcpu *vcpu, int reg,
uint64_t *base, uint32_t *limit, uint32_t *access);
int vm_get_seg_desc(struct vcpu *vcpu, int reg, struct seg_desc *seg_desc);
+#endif
int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
int vm_set_register_set(struct vcpu *vcpu, unsigned int count,
@@ -156,6 +160,21 @@ int vm_get_register_set(struct vcpu *vcpu, unsigned int count,
int vm_run(struct vcpu *vcpu, struct vm_run *vmrun);
int vm_suspend(struct vmctx *ctx, enum vm_suspend_how how);
int vm_reinit(struct vmctx *ctx);
+int vm_raise_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg,
+ int bus, int slot, int func);
+#if defined(__aarch64__)
+int vm_attach_vgic(struct vmctx *ctx, uint64_t dist_start, size_t dist_size,
+ uint64_t redist_start, size_t redist_size);
+int vm_inject_exception(struct vcpu *vcpu, uint64_t esr, uint64_t far);
+#elif defined(__riscv)
+int vm_attach_aplic(struct vmctx *ctx, uint64_t mem_start, size_t mem_size);
+int vm_inject_exception(struct vcpu *vcpu, uint64_t scause);
+#endif
+#if defined(__aarch64__) || defined(__riscv)
+int vm_assert_irq(struct vmctx *ctx, uint32_t irq);
+int vm_deassert_irq(struct vmctx *ctx, uint32_t irq);
+#endif
+#ifdef __amd64__
int vm_apicid2vcpu(struct vmctx *ctx, int apicid);
int vm_inject_exception(struct vcpu *vcpu, int vector,
int errcode_valid, uint32_t errcode, int restart_instruction);
@@ -166,14 +185,15 @@ int vm_ioapic_assert_irq(struct vmctx *ctx, int irq);
int vm_ioapic_deassert_irq(struct vmctx *ctx, int irq);
int vm_ioapic_pulse_irq(struct vmctx *ctx, int irq);
int vm_ioapic_pincount(struct vmctx *ctx, int *pincount);
-int vm_readwrite_kernemu_device(struct vcpu *vcpu,
- vm_paddr_t gpa, bool write, int size, uint64_t *value);
int vm_isa_assert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq);
int vm_isa_deassert_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq);
int vm_isa_pulse_irq(struct vmctx *ctx, int atpic_irq, int ioapic_irq);
int vm_isa_set_irq_trigger(struct vmctx *ctx, int atpic_irq,
enum vm_intr_trigger trigger);
int vm_inject_nmi(struct vcpu *vcpu);
+int vm_readwrite_kernemu_device(struct vcpu *vcpu,
+ vm_paddr_t gpa, bool write, int size, uint64_t *value);
+#endif
int vm_capability_name2type(const char *capname);
const char *vm_capability_type2name(int type);
int vm_get_capability(struct vcpu *vcpu, enum vm_cap_type cap,
@@ -203,6 +223,7 @@ uint64_t *vm_get_stats(struct vcpu *vcpu, struct timeval *ret_tv,
int *ret_entries);
const char *vm_get_stat_desc(struct vmctx *ctx, int index);
+#ifdef __amd64__
int vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *s);
int vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state s);
@@ -220,15 +241,18 @@ int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities);
int vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *pg,
uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt,
int *fault);
+#endif
void vm_copyin(struct iovec *guest_iov, void *host_dst, size_t len);
void vm_copyout(const void *host_src, struct iovec *guest_iov, size_t len);
void vm_copy_teardown(struct iovec *iov, int iovcnt);
+#ifdef __amd64__
/* RTC */
int vm_rtc_write(struct vmctx *ctx, int offset, uint8_t value);
int vm_rtc_read(struct vmctx *ctx, int offset, uint8_t *retval);
int vm_rtc_settime(struct vmctx *ctx, time_t secs);
int vm_rtc_gettime(struct vmctx *ctx, time_t *secs);
+#endif
/* Reset vcpu register state */
int vcpu_reset(struct vcpu *vcpu);
diff --git a/lib/libvmmapi/vmmapi_freebsd.c b/lib/libvmmapi/vmmapi_freebsd.c
deleted file mode 100644
index e829febf0157..000000000000
--- a/lib/libvmmapi/vmmapi_freebsd.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2011 NetApp, Inc.
- * 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 NETAPP, INC ``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 NETAPP, INC 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.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <machine/specialreg.h>
-#include <machine/segments.h>
-#include <machine/vmm.h>
-
-#include <errno.h>
-#include <string.h>
-
-#include "vmmapi.h"
-#include "internal.h"
-
-#define I386_TSS_SIZE 104
-
-#define DESC_PRESENT 0x00000080
-#define DESC_LONGMODE 0x00002000
-#define DESC_DEF32 0x00004000
-#define DESC_GRAN 0x00008000
-#define DESC_UNUSABLE 0x00010000
-
-#define GUEST_NULL_SEL 0
-#define GUEST_CODE_SEL 1
-#define GUEST_DATA_SEL 2
-#define GUEST_TSS_SEL 3
-#define GUEST_GDTR_LIMIT64 (3 * 8 - 1)
-
-static struct segment_descriptor i386_gdt[] = {
- {}, /* NULL */
- { .sd_lolimit = 0xffff, .sd_type = SDT_MEMER, /* CODE */
- .sd_p = 1, .sd_hilimit = 0xf, .sd_def32 = 1, .sd_gran = 1 },
- { .sd_lolimit = 0xffff, .sd_type = SDT_MEMRW, /* DATA */
- .sd_p = 1, .sd_hilimit = 0xf, .sd_def32 = 1, .sd_gran = 1 },
- { .sd_lolimit = I386_TSS_SIZE - 1, /* TSS */
- .sd_type = SDT_SYS386TSS, .sd_p = 1 }
-};
-
-/*
- * Setup the 'vcpu' register set such that it will begin execution at
- * 'eip' in flat mode.
- */
-int
-vm_setup_freebsd_registers_i386(struct vcpu *vcpu, uint32_t eip,
- uint32_t gdtbase, uint32_t esp)
-{
- uint64_t cr0, rflags, desc_base;
- uint32_t desc_access, desc_limit, tssbase;
- uint16_t gsel;
- struct segment_descriptor *gdt;
- int error, tmp;
-
- /* A 32-bit guest requires unrestricted mode. */
- error = vm_get_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, &tmp);
- if (error)
- goto done;
- error = vm_set_capability(vcpu, VM_CAP_UNRESTRICTED_GUEST, 1);
- if (error)
- goto done;
-
- cr0 = CR0_PE | CR0_NE;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, 0)) != 0)
- goto done;
-
- /*
- * Forcing EFER to 0 causes bhyve to clear the "IA-32e guest
- * mode" entry control.
- */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, 0)))
- goto done;
-
- gdt = vm_map_gpa(vcpu->ctx, gdtbase, 0x1000);
- if (gdt == NULL)
- return (EFAULT);
- memcpy(gdt, i386_gdt, sizeof(i386_gdt));
- desc_base = gdtbase;
- desc_limit = sizeof(i386_gdt) - 1;
- error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
- desc_base, desc_limit, 0);
- if (error != 0)
- goto done;
-
- /* Place the TSS one page above the GDT. */
- tssbase = gdtbase + 0x1000;
- gdt[3].sd_lobase = tssbase;
-
- rflags = 0x2;
- error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags);
- if (error)
- goto done;
-
- desc_base = 0;
- desc_limit = 0xffffffff;
- desc_access = DESC_GRAN | DESC_DEF32 | DESC_PRESENT | SDT_MEMERA;
- error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
- desc_base, desc_limit, desc_access);
-
- desc_access = DESC_GRAN | DESC_DEF32 | DESC_PRESENT | SDT_MEMRWA;
- error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- desc_base = tssbase;
- desc_limit = I386_TSS_SIZE - 1;
- desc_access = DESC_PRESENT | SDT_SYS386BSY;
- error = vm_set_desc(vcpu, VM_REG_GUEST_TR,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, 0, 0,
- DESC_UNUSABLE);
- if (error)
- goto done;
-
- gsel = GSEL(GUEST_CODE_SEL, SEL_KPL);
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, gsel)) != 0)
- goto done;
-
- gsel = GSEL(GUEST_DATA_SEL, SEL_KPL);
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, gsel)) != 0)
- goto done;
-
- gsel = GSEL(GUEST_TSS_SEL, SEL_KPL);
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, gsel)) != 0)
- goto done;
-
- /* LDTR is pointing to the null selector */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0)
- goto done;
-
- /* entry point */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, eip)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, esp)) != 0)
- goto done;
-
- error = 0;
-done:
- return (error);
-}
-
-void
-vm_setup_freebsd_gdt(uint64_t *gdtr)
-{
- gdtr[GUEST_NULL_SEL] = 0;
- gdtr[GUEST_CODE_SEL] = 0x0020980000000000;
- gdtr[GUEST_DATA_SEL] = 0x0000900000000000;
-}
-
-/*
- * Setup the 'vcpu' register set such that it will begin execution at
- * 'rip' in long mode.
- */
-int
-vm_setup_freebsd_registers(struct vcpu *vcpu,
- uint64_t rip, uint64_t cr3, uint64_t gdtbase,
- uint64_t rsp)
-{
- int error;
- uint64_t cr0, cr4, efer, rflags, desc_base;
- uint32_t desc_access, desc_limit;
- uint16_t gsel;
-
- cr0 = CR0_PE | CR0_PG | CR0_NE;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR0, cr0)) != 0)
- goto done;
-
- cr4 = CR4_PAE;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR4, cr4)) != 0)
- goto done;
-
- efer = EFER_LME | EFER_LMA;
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_EFER, efer)))
- goto done;
-
- rflags = 0x2;
- error = vm_set_register(vcpu, VM_REG_GUEST_RFLAGS, rflags);
- if (error)
- goto done;
-
- desc_base = 0;
- desc_limit = 0;
- desc_access = 0x0000209B;
- error = vm_set_desc(vcpu, VM_REG_GUEST_CS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- desc_access = 0x00000093;
- error = vm_set_desc(vcpu, VM_REG_GUEST_DS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_ES,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_FS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_GS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_SS,
- desc_base, desc_limit, desc_access);
- if (error)
- goto done;
-
- /*
- * XXX TR is pointing to null selector even though we set the
- * TSS segment to be usable with a base address and limit of 0.
- */
- desc_access = 0x0000008b;
- error = vm_set_desc(vcpu, VM_REG_GUEST_TR, 0, 0, desc_access);
- if (error)
- goto done;
-
- error = vm_set_desc(vcpu, VM_REG_GUEST_LDTR, 0, 0,
- DESC_UNUSABLE);
- if (error)
- goto done;
-
- gsel = GSEL(GUEST_CODE_SEL, SEL_KPL);
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CS, gsel)) != 0)
- goto done;
-
- gsel = GSEL(GUEST_DATA_SEL, SEL_KPL);
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_DS, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_ES, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_FS, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_GS, gsel)) != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_SS, gsel)) != 0)
- goto done;
-
- /* XXX TR is pointing to the null selector */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_TR, 0)) != 0)
- goto done;
-
- /* LDTR is pointing to the null selector */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_LDTR, 0)) != 0)
- goto done;
-
- /* entry point */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RIP, rip)) != 0)
- goto done;
-
- /* page table base */
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_CR3, cr3)) != 0)
- goto done;
-
- desc_base = gdtbase;
- desc_limit = GUEST_GDTR_LIMIT64;
- error = vm_set_desc(vcpu, VM_REG_GUEST_GDTR,
- desc_base, desc_limit, 0);
- if (error != 0)
- goto done;
-
- if ((error = vm_set_register(vcpu, VM_REG_GUEST_RSP, rsp)) != 0)
- goto done;
-
- error = 0;
-done:
- return (error);
-}
diff --git a/lib/libxo/Makefile b/lib/libxo/Makefile
index 051dce646286..97172d0e8637 100644
--- a/lib/libxo/Makefile
+++ b/lib/libxo/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
HAS_TESTS=
diff --git a/lib/libxo/encoder/Makefile b/lib/libxo/encoder/Makefile
index 8b70fbed97b8..1b479d065d90 100644
--- a/lib/libxo/encoder/Makefile
+++ b/lib/libxo/encoder/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
diff --git a/lib/libxo/encoder/csv/Makefile b/lib/libxo/encoder/csv/Makefile
index b828e64c8143..442883a61998 100644
--- a/lib/libxo/encoder/csv/Makefile
+++ b/lib/libxo/encoder/csv/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
PACKAGE= runtime
diff --git a/lib/libxo/encoder/csv/Makefile.depend b/lib/libxo/encoder/csv/Makefile.depend
index e69de29bb2d1..b915f0b12d3b 100644
--- a/lib/libxo/encoder/csv/Makefile.depend
+++ b/lib/libxo/encoder/csv/Makefile.depend
@@ -0,0 +1,17 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libutil \
+ lib/libxo/libxo \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libxo/libxo/Makefile b/lib/libxo/libxo/Makefile
index f51ec506da45..38e6ff031c7f 100644
--- a/lib/libxo/libxo/Makefile
+++ b/lib/libxo/libxo/Makefile
@@ -1,4 +1,3 @@
-
SHLIBDIR?= /lib
.include <src.opts.mk>
@@ -29,6 +28,7 @@ MAN+= xo_attr.3 \
xo_create.3 \
xo_emit.3 \
xo_emit_err.3 \
+ xo_emit_f.3 \
xo_err.3 \
xo_error.3 \
xo_finish.3 \
diff --git a/lib/libxo/libxo/Makefile.depend b/lib/libxo/libxo/Makefile.depend
index e69de29bb2d1..678747db6f2c 100644
--- a/lib/libxo/libxo/Makefile.depend
+++ b/lib/libxo/libxo/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libxo/tests/Makefile b/lib/libxo/tests/Makefile
index 74af945b7244..a53dbea685a6 100644
--- a/lib/libxo/tests/Makefile
+++ b/lib/libxo/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
PACKAGE= tests
diff --git a/lib/libxo/tests/Makefile.depend b/lib/libxo/tests/Makefile.depend
index 1032566579a2..5d2f1f63e4fc 100644
--- a/lib/libxo/tests/Makefile.depend
+++ b/lib/libxo/tests/Makefile.depend
@@ -1,14 +1,11 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
- include \
- include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
lib/libutil \
- lib/libxo \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/lib/libxo/tests/encoder/Makefile b/lib/libxo/tests/encoder/Makefile
index 81d6e0a051d6..7522328b0818 100644
--- a/lib/libxo/tests/encoder/Makefile
+++ b/lib/libxo/tests/encoder/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= tests
LIBXOSRC= ${SRCTOP}/contrib/libxo
diff --git a/lib/libxo/tests/encoder/Makefile.depend b/lib/libxo/tests/encoder/Makefile.depend
index 07e2f00360c2..b95024e29443 100644
--- a/lib/libxo/tests/encoder/Makefile.depend
+++ b/lib/libxo/tests/encoder/Makefile.depend
@@ -1,12 +1,12 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
include \
+ include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libxo \
+ lib/libxo/libxo \
.include <dirdeps.mk>
diff --git a/lib/liby/Makefile b/lib/liby/Makefile
index bb53c79cd05c..93f72ee440f8 100644
--- a/lib/liby/Makefile
+++ b/lib/liby/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE=lib${LIB}
LIB= y
SRCS= main.c yyerror.c
diff --git a/lib/liby/main.c b/lib/liby/main.c
index 5e7ae6fa8f0d..c6a0439a139e 100644
--- a/lib/liby/main.c
+++ b/lib/liby/main.c
@@ -30,9 +30,6 @@
*/
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
#include <stdlib.h>
diff --git a/lib/liby/yyerror.c b/lib/liby/yyerror.c
index 2b67cfcf0fa2..fccf24347f41 100644
--- a/lib/liby/yyerror.c
+++ b/lib/liby/yyerror.c
@@ -30,9 +30,6 @@
*/
#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)yyerror.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
diff --git a/lib/libyaml/Makefile b/lib/libyaml/Makefile
new file mode 100644
index 000000000000..6acd34f178a9
--- /dev/null
+++ b/lib/libyaml/Makefile
@@ -0,0 +1,29 @@
+LIBYAML_DIR= ${SRCTOP}/contrib/libyaml
+
+PACKAGE=lib${LIB}
+LIB= yaml
+PRIVATELIB= true
+SHLIB_MAJOR= 1
+SRCS= api.c \
+ dumper.c \
+ emitter.c \
+ loader.c \
+ parser.c \
+ reader.c \
+ scanner.c \
+ writer.c
+
+.PATH: ${LIBYAML_DIR}/src \
+ ${LIBYAML_DIR}/include
+
+INCS= yaml.h
+
+WARNS?= 1
+CFLAGS+= -I${LIBYAML_DIR}/include \
+ -I${LIBYAML_DIR}/src \
+ -DYAML_VERSION_STRING=\"0.2.5\" \
+ -DYAML_VERSION_MAJOR=0 \
+ -DYAML_VERSION_MINOR=2 \
+ -DYAML_VERSION_PATCH=5
+
+.include <bsd.lib.mk>
diff --git a/lib/libypclnt/Makefile b/lib/libypclnt/Makefile
index 74d18d4b77ee..899e301f4608 100644
--- a/lib/libypclnt/Makefile
+++ b/lib/libypclnt/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= runtime
LIB= ypclnt
SHLIB_MAJOR= 4
diff --git a/lib/libz/Makefile b/lib/libz/Makefile
index 7dd1204c5435..6a135158e134 100644
--- a/lib/libz/Makefile
+++ b/lib/libz/Makefile
@@ -51,7 +51,6 @@ CFLAGS+= -DUNALIGNED_OK
VERSION_DEF= ${.CURDIR}/Versions.def
SYMBOL_MAPS= ${.CURDIR}/Symbol.map
-CFLAGS+= -DSYMBOL_VERSIONING
INCS= zconf.h zlib.h
diff --git a/lib/libzstd/Makefile b/lib/libzstd/Makefile
index 080b6247fee8..0e25f01d4881 100644
--- a/lib/libzstd/Makefile
+++ b/lib/libzstd/Makefile
@@ -1,4 +1,3 @@
-
LIB= zstd
SRCS= entropy_common.c \
error_private.c \
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 8bc984c2c342..24989749a502 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -1,5 +1,3 @@
-# @(#)Makefile 5.1beta 93/09/24
-#
# ====================================================
# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
#
@@ -28,7 +26,7 @@ CFLAGS+= -I${.CURDIR}/x86
CFLAGS+= -I${.CURDIR}/ld80
.elif ${LDBL_PREC} == 113
.PATH: ${.CURDIR}/ld128
-CFLAGS+= -I${.CURDIR}/ld128
+CFLAGS+= -I${.CURDIR}/ld128 -I${SRCTOP}/contrib/arm-optimized-routines/math
.endif
CFLAGS+= -I${.CURDIR}/${ARCH_SUBDIR}
@@ -97,17 +95,27 @@ COMMON_SRCS+= s_cospi.c s_cospif.c \
s_sinpi.c s_sinpif.c \
s_tanpi.c s_tanpif.c
+# LIBCSRCDIR is defined lazily, so can't be used for exists() below
+LIBC_SRCTOP=${SRCTOP}/lib/libc
# Location of fpmath.h and _fpmath.h
-.if exists(${LIBCSRCDIR}/${MACHINE_ARCH})
-LIBC_ARCH=${MACHINE_ARCH}
+
+# Pick the current architecture directory for libc. In general, this is named
+# MACHINE_CPUARCH, but some ABIs are different enough to require their own libc,
+# so allow a directory named MACHINE_ARCH to override this (though treat
+# powerpc64le and powerpc64 the same).
+# Note: This is copied from libc/Makefile
+M=${MACHINE_ARCH:S/powerpc64le/powerpc64/}
+.if exists(${LIBC_SRCTOP}/${M})
+LIBC_ARCH=${M}
.else
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
-CFLAGS+= -I${.CURDIR}/src -I${LIBCSRCDIR}/include \
- -I${LIBCSRCDIR}/${LIBC_ARCH}
+
+CFLAGS+= -I${.CURDIR}/src -I${LIBC_SRCTOP}/include \
+ -I${LIBC_SRCTOP}/${LIBC_ARCH}
SYM_MAPS+= ${.CURDIR}/Symbol.map
-VERSION_DEF= ${LIBCSRCDIR}/Versions.def
+VERSION_DEF= ${LIBC_SRCTOP}/Versions.def
SYMBOL_MAPS= ${SYM_MAPS}
# C99 long double functions
@@ -146,7 +154,8 @@ COMMON_SRCS+= catrig.c catrigf.c \
s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c \
s_csinh.c s_csinhf.c s_ctanh.c s_ctanhf.c
-# FreeBSD's C library supplies these functions:
+# FreeBSD's C library supplies these functions (but note we still have s_frexp.c
+# and s_isnan.c enabled above, so they are duplicated):
#COMMON_SRCS+= s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c
# Exclude the generic versions of what we provide in the MD area.
diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map
index 6e74918ade6e..4d5a5e4d7e6e 100644
--- a/lib/msun/Symbol.map
+++ b/lib/msun/Symbol.map
@@ -88,7 +88,6 @@ FBSD_1.0 {
exp2f;
expm1;
expm1f;
- fabs;
fabsf;
fabsl;
fdim;
diff --git a/lib/msun/aarch64/Makefile.inc b/lib/msun/aarch64/Makefile.inc
index 82463110f1bb..fcc744878220 100644
--- a/lib/msun/aarch64/Makefile.inc
+++ b/lib/msun/aarch64/Makefile.inc
@@ -1,4 +1,3 @@
-
LDBL_PREC = 113
# Use a builtin when it generates the needed instruction
diff --git a/lib/msun/aarch64/fenv.h b/lib/msun/aarch64/fenv.h
index 2148a68b053b..a435a9de5223 100644
--- a/lib/msun/aarch64/fenv.h
+++ b/lib/msun/aarch64/fenv.h
@@ -31,6 +31,7 @@
#ifndef _FENV_H_
#define _FENV_H_
+#include <sys/cdefs.h>
#include <sys/_types.h>
#ifndef __fenv_static
diff --git a/lib/msun/amd64/Makefile.inc b/lib/msun/amd64/Makefile.inc
index 6a99005f6701..dcdc2495d690 100644
--- a/lib/msun/amd64/Makefile.inc
+++ b/lib/msun/amd64/Makefile.inc
@@ -1,4 +1,3 @@
-
ARCH_SRCS = e_fmod.S e_fmodf.S e_fmodl.S \
e_remainder.S e_remainderf.S e_remainderl.S \
e_sqrt.S e_sqrtf.S e_sqrtl.S \
diff --git a/lib/msun/amd64/fenv.c b/lib/msun/amd64/fenv.c
index 2aea6a4cf036..4d271f8d456a 100644
--- a/lib/msun/amd64/fenv.c
+++ b/lib/msun/amd64/fenv.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/fpu.h>
diff --git a/lib/msun/arm/Makefile.inc b/lib/msun/arm/Makefile.inc
index a52552766e36..6e3ddb351dd3 100644
--- a/lib/msun/arm/Makefile.inc
+++ b/lib/msun/arm/Makefile.inc
@@ -1,4 +1,3 @@
-
LDBL_PREC = 53
SYM_MAPS += ${.CURDIR}/arm/Symbol.map
diff --git a/lib/msun/arm/fenv.c b/lib/msun/arm/fenv.c
index 9f172d5fd7c9..05b3adb05f81 100644
--- a/lib/msun/arm/fenv.c
+++ b/lib/msun/arm/fenv.c
@@ -32,10 +32,6 @@
#include <machine/acle-compat.h>
-#if __ARM_ARCH >= 6
-#define FENV_ARMv6
-#endif
-
/* When SOFTFP_ABI is defined we are using the softfp ABI. */
#if defined(__VFP_FP__) && !defined(__ARM_PCS_VFP)
#define SOFTFP_ABI
@@ -52,7 +48,7 @@ const fenv_t __fe_dfl_env = 0;
/* If this is a non-mangled softfp version special processing is required */
-#if defined(FENV_MANGLE) || !defined(SOFTFP_ABI) || !defined(FENV_ARMv6)
+#if defined(FENV_MANGLE) || !defined(SOFTFP_ABI)
/*
* The following macros map between the softfloat emulator's flags and
diff --git a/lib/msun/arm/fenv.h b/lib/msun/arm/fenv.h
index 5dded5d744fd..e8a30fcf496f 100644
--- a/lib/msun/arm/fenv.h
+++ b/lib/msun/arm/fenv.h
@@ -29,6 +29,7 @@
#ifndef _FENV_H_
#define _FENV_H_
+#include <sys/cdefs.h>
#include <sys/_types.h>
#ifndef __fenv_static
diff --git a/lib/msun/bsdsrc/b_exp.c b/lib/msun/bsdsrc/b_exp.c
index 398755a0aaeb..44cd5190de92 100644
--- a/lib/msun/bsdsrc/b_exp.c
+++ b/lib/msun/bsdsrc/b_exp.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-/* @(#)exp.c 8.1 (Berkeley) 6/4/93 */
-#include <sys/cdefs.h>
/* EXP(X)
* RETURN THE EXPONENTIAL OF X
* DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
diff --git a/lib/msun/bsdsrc/b_log.c b/lib/msun/bsdsrc/b_log.c
index aeec29368412..a82140bb98b5 100644
--- a/lib/msun/bsdsrc/b_log.c
+++ b/lib/msun/bsdsrc/b_log.c
@@ -29,8 +29,6 @@
* SUCH DAMAGE.
*/
-/* @(#)log.c 8.2 (Berkeley) 11/30/93 */
-#include <sys/cdefs.h>
/* Table-driven natural logarithm.
*
* This code was derived, with minor modifications, from:
diff --git a/lib/msun/bsdsrc/b_tgamma.c b/lib/msun/bsdsrc/b_tgamma.c
index cc9f8f70297e..8369477c18b7 100644
--- a/lib/msun/bsdsrc/b_tgamma.c
+++ b/lib/msun/bsdsrc/b_tgamma.c
@@ -42,8 +42,6 @@
* porting to other precisions.
*/
-/* @(#)gamma.c 8.1 (Berkeley) 6/4/93 */
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/bsdsrc/mathimpl.h b/lib/msun/bsdsrc/mathimpl.h
index 3d6554747dac..a4d081c3f02f 100644
--- a/lib/msun/bsdsrc/mathimpl.h
+++ b/lib/msun/bsdsrc/mathimpl.h
@@ -31,14 +31,11 @@
* 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.
- *
- * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93
*/
#ifndef _MATHIMPL_H_
#define _MATHIMPL_H_
-#include <sys/cdefs.h>
#include <math.h>
#include "../src/math_private.h"
diff --git a/lib/msun/i387/Makefile.inc b/lib/msun/i387/Makefile.inc
index d0f22572b36d..73feb52de6a2 100644
--- a/lib/msun/i387/Makefile.inc
+++ b/lib/msun/i387/Makefile.inc
@@ -1,4 +1,3 @@
-
ARCH_SRCS = e_exp.S e_fmod.S e_log.S e_log10.S \
e_remainder.S e_sqrt.S s_ceil.S s_copysign.S \
s_finite.S s_floor.S s_llrint.S s_logb.S s_lrint.S \
diff --git a/lib/msun/i387/fenv.c b/lib/msun/i387/fenv.c
index 958c8a87b2fa..ebb4111a5fa6 100644
--- a/lib/msun/i387/fenv.c
+++ b/lib/msun/i387/fenv.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/npx.h>
diff --git a/lib/msun/i387/invtrig.c b/lib/msun/i387/invtrig.c
index 523f022e0546..50d8d3af9343 100644
--- a/lib/msun/i387/invtrig.c
+++ b/lib/msun/i387/invtrig.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <stdint.h>
#define STRUCT_DECLS
diff --git a/lib/msun/ld128/b_tgammal.c b/lib/msun/ld128/b_tgammal.c
index 4bae4f3aded6..6df7264a4c9e 100644
--- a/lib/msun/ld128/b_tgammal.c
+++ b/lib/msun/ld128/b_tgammal.c
@@ -1,55 +1,12 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2013 David Chisnall
- * 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.
+ * Copyright (c) 2024 The FreeBSD Foundation
*/
-#include <float.h>
-#include <math.h>
-
/*
- * If long double is not the same size as double, then these will lose
- * precision and we should emit a warning whenever something links against
- * them.
+ * This is a pure C function generously donated by ARM.
+ * See src/contrib/arm-optimized-routines/math/tgamma128.[ch].
*/
-#if (LDBL_MANT_DIG > 53)
-#define WARN_IMPRECISE(x) \
- __warn_references(x, # x " has lower than advertised precision");
-#else
-#define WARN_IMPRECISE(x)
-#endif
-/*
- * Declare the functions as weak variants so that other libraries providing
- * real versions can override them.
- */
-#define DECLARE_WEAK(x)\
- __weak_reference(imprecise_## x, x);\
- WARN_IMPRECISE(x)
-
-#define DECLARE_IMPRECISE(f) \
- long double imprecise_ ## f ## l(long double v) { return f(v); }\
- DECLARE_WEAK(f ## l)
-
-DECLARE_IMPRECISE(tgamma);
+#define tgamma128 tgammal
+#include "tgamma128.c"
diff --git a/lib/msun/ld128/e_lgammal_r.c b/lib/msun/ld128/e_lgammal_r.c
index e3d97b6d18b7..f8079b79d7fa 100644
--- a/lib/msun/ld128/e_lgammal_r.c
+++ b/lib/msun/ld128/e_lgammal_r.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_lgamma_r.c for complete comments.
*
diff --git a/lib/msun/ld128/e_powl.c b/lib/msun/ld128/e_powl.c
index fd8b57b66bd5..f5a993cf0054 100644
--- a/lib/msun/ld128/e_powl.c
+++ b/lib/msun/ld128/e_powl.c
@@ -59,7 +59,6 @@
*
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/ld128/e_rem_pio2l.h b/lib/msun/ld128/e_rem_pio2l.h
index 35ed0b865a7c..0ea1a706f3aa 100644
--- a/lib/msun/ld128/e_rem_pio2l.h
+++ b/lib/msun/ld128/e_rem_pio2l.h
@@ -1,4 +1,3 @@
-/* From: @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,7 +12,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/* ld128 version of __ieee754_rem_pio2l(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
@@ -56,7 +54,7 @@ pio2_2t = 2.0670321098263988236496903051604844e-43L, /* 0x127044533e63a0105df5
pio2_3 = 2.0670321098263988236499468110329591e-43L, /* 0x127044533e63a0105e00000000000.0p-254 */
pio2_3t = -2.5650587247459238361625433492959285e-65L; /* -0x159c4ec64ddaeb5f78671cbfb2210.0p-327 */
-static inline __always_inline int
+static __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;
diff --git a/lib/msun/ld128/invtrig.c b/lib/msun/ld128/invtrig.c
index cd9a276b68d1..75aef7b5166a 100644
--- a/lib/msun/ld128/invtrig.c
+++ b/lib/msun/ld128/invtrig.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "invtrig.h"
/*
diff --git a/lib/msun/ld128/k_cosl.c b/lib/msun/ld128/k_cosl.c
index 8280378c429c..c7562664bd3c 100644
--- a/lib/msun/ld128/k_cosl.c
+++ b/lib/msun/ld128/k_cosl.c
@@ -1,4 +1,3 @@
-/* From: @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ld128 version of k_cos.c. See ../src/k_cos.c for most comments.
*/
diff --git a/lib/msun/ld128/k_expl.h b/lib/msun/ld128/k_expl.h
index 71924f16c8a4..86811dd8e089 100644
--- a/lib/msun/ld128/k_expl.h
+++ b/lib/msun/ld128/k_expl.h
@@ -30,7 +30,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/*
* ld128 version of k_expl.h. See ../ld80/s_expl.c for most comments.
*
diff --git a/lib/msun/ld128/k_sinl.c b/lib/msun/ld128/k_sinl.c
index ca54f9f1a630..f2b17ba0eeb3 100644
--- a/lib/msun/ld128/k_sinl.c
+++ b/lib/msun/ld128/k_sinl.c
@@ -1,4 +1,3 @@
-/* From: @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ld128 version of k_sin.c. See ../src/k_sin.c for most comments.
*/
diff --git a/lib/msun/ld128/k_tanl.c b/lib/msun/ld128/k_tanl.c
index daff6b2bde8c..8aff0d1fc0d3 100644
--- a/lib/msun/ld128/k_tanl.c
+++ b/lib/msun/ld128/k_tanl.c
@@ -1,5 +1,3 @@
-/* From: @(#)k_tan.c 1.5 04/04/22 SMI */
-
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
@@ -11,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ld128 version of k_tan.c. See ../src/k_tan.c for most comments.
*/
diff --git a/lib/msun/ld128/s_cexpl.c b/lib/msun/ld128/s_cexpl.c
index 1e4141f162c5..9e3eebfa750e 100644
--- a/lib/msun/ld128/s_cexpl.c
+++ b/lib/msun/ld128/s_cexpl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/ld128/s_erfl.c b/lib/msun/ld128/s_erfl.c
index 43ba2f0bed8b..227c31fd096b 100644
--- a/lib/msun/ld128/s_erfl.c
+++ b/lib/msun/ld128/s_erfl.c
@@ -1,4 +1,3 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See s_erf.c for complete comments.
*
diff --git a/lib/msun/ld128/s_exp2l.c b/lib/msun/ld128/s_exp2l.c
index 74ae8c2daad8..249cb4cb8bb0 100644
--- a/lib/msun/ld128/s_exp2l.c
+++ b/lib/msun/ld128/s_exp2l.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <stdint.h>
diff --git a/lib/msun/ld128/s_expl.c b/lib/msun/ld128/s_expl.c
index 6d6c22d917fe..e1358e2213a0 100644
--- a/lib/msun/ld128/s_expl.c
+++ b/lib/msun/ld128/s_expl.c
@@ -28,7 +28,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/*
* ld128 version of s_expl.c. See ../ld80/s_expl.c for most comments.
*/
diff --git a/lib/msun/ld128/s_logl.c b/lib/msun/ld128/s_logl.c
index 8961dd0c96db..e9133ec66fd2 100644
--- a/lib/msun/ld128/s_logl.c
+++ b/lib/msun/ld128/s_logl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/**
* Implementation of the natural logarithm of x for 128-bit format.
*
@@ -445,7 +444,7 @@ struct ld {
#endif
#ifdef STRUCT_RETURN
-static inline __always_inline void
+static __always_inline void
k_logl(long double x, struct ld *rp)
#else
long double
diff --git a/lib/msun/ld80/e_lgammal_r.c b/lib/msun/ld80/e_lgammal_r.c
index cfd73b408b87..9f8b8f0f98bb 100644
--- a/lib/msun/ld80/e_lgammal_r.c
+++ b/lib/msun/ld80/e_lgammal_r.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_lgamma_r.c for complete comments.
*
diff --git a/lib/msun/ld80/e_powl.c b/lib/msun/ld80/e_powl.c
index 2daf26aab93b..d04d77a5ee98 100644
--- a/lib/msun/ld80/e_powl.c
+++ b/lib/msun/ld80/e_powl.c
@@ -14,7 +14,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#include "math_private.h"
@@ -24,10 +23,10 @@
* P[0] x^n + P[1] x^(n-1) + ... + P[n]
*/
static inline long double
-__polevll(long double x, long double *PP, int n)
+__polevll(long double x, const long double *PP, int n)
{
long double y;
- long double *P;
+ const long double *P;
P = PP;
y = *P++;
@@ -43,10 +42,10 @@ __polevll(long double x, long double *PP, int n)
* x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n]
*/
static inline long double
-__p1evll(long double x, long double *PP, int n)
+__p1evll(long double x, const long double *PP, int n)
{
long double y;
- long double *P;
+ const long double *P;
P = PP;
n -= 1;
@@ -114,7 +113,6 @@ __p1evll(long double x, long double *PP, int n)
*
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <math.h>
@@ -128,13 +126,13 @@ __p1evll(long double x, long double *PP, int n)
/* log(1+x) = x - .5x^2 + x^3 * P(z)/Q(z)
* on the domain 2^(-1/32) - 1 <= x <= 2^(1/32) - 1
*/
-static long double P[] = {
+static const long double P[] = {
8.3319510773868690346226E-4L,
4.9000050881978028599627E-1L,
1.7500123722550302671919E0L,
1.4000100839971580279335E0L,
};
-static long double Q[] = {
+static const long double Q[] = {
/* 1.0000000000000000000000E0L,*/
5.2500282295834889175431E0L,
8.4000598057587009834666E0L,
@@ -143,7 +141,7 @@ static long double Q[] = {
/* A[i] = 2^(-i/32), rounded to IEEE long double precision.
* If i is even, A[i] + B[i/2] gives additional accuracy.
*/
-static long double A[33] = {
+static const long double A[33] = {
1.0000000000000000000000E0L,
9.7857206208770013448287E-1L,
9.5760328069857364691013E-1L,
@@ -178,7 +176,7 @@ static long double A[33] = {
5.1094857432705833910408E-1L,
5.0000000000000000000000E-1L,
};
-static long double B[17] = {
+static const long double B[17] = {
0.0000000000000000000000E0L,
2.6176170809902549338711E-20L,
-1.0126791927256478897086E-20L,
@@ -201,7 +199,7 @@ static long double B[17] = {
/* 2^x = 1 + x P(x),
* on the interval -1/32 <= x <= 0
*/
-static long double R[] = {
+static const long double R[] = {
1.5089970579127659901157E-5L,
1.5402715328927013076125E-4L,
1.3333556028915671091390E-3L,
@@ -232,13 +230,13 @@ static long double R[] = {
static const long double MAXLOGL = 1.1356523406294143949492E4L;
static const long double MINLOGL = -1.13994985314888605586758E4L;
static const long double LOGE2L = 6.9314718055994530941723E-1L;
-static volatile long double z;
-static long double w, W, Wa, Wb, ya, yb, u;
+static _Thread_local volatile long double z;
+static _Thread_local long double w, W, Wa, Wb, ya, yb, u;
static const long double huge = 0x1p10000L;
#if 0 /* XXX Prevent gcc from erroneously constant folding this. */
static const long double twom10000 = 0x1p-10000L;
#else
-static volatile long double twom10000 = 0x1p-10000L;
+static _Thread_local volatile long double twom10000 = 0x1p-10000L;
#endif
static long double reducl( long double );
diff --git a/lib/msun/ld80/e_rem_pio2l.h b/lib/msun/ld80/e_rem_pio2l.h
index d9e4d3a0941f..b39e63b72afc 100644
--- a/lib/msun/ld80/e_rem_pio2l.h
+++ b/lib/msun/ld80/e_rem_pio2l.h
@@ -1,4 +1,3 @@
-/* From: @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,7 +12,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/* ld80 version of __ieee754_rem_pio2l(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
@@ -68,7 +66,7 @@ pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */
pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
#endif
-static inline __always_inline int
+static __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;
diff --git a/lib/msun/ld80/invtrig.c b/lib/msun/ld80/invtrig.c
index 0e2d49546391..76eb681454d3 100644
--- a/lib/msun/ld80/invtrig.c
+++ b/lib/msun/ld80/invtrig.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "invtrig.h"
/*
diff --git a/lib/msun/ld80/k_cosl.c b/lib/msun/ld80/k_cosl.c
index e76d429b90ef..371c360aa2ce 100644
--- a/lib/msun/ld80/k_cosl.c
+++ b/lib/msun/ld80/k_cosl.c
@@ -1,4 +1,3 @@
-/* From: @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ld80 version of k_cos.c. See ../src/k_cos.c for most comments.
*/
diff --git a/lib/msun/ld80/k_expl.h b/lib/msun/ld80/k_expl.h
index 8c3617e4b177..fabf5a792205 100644
--- a/lib/msun/ld80/k_expl.h
+++ b/lib/msun/ld80/k_expl.h
@@ -30,7 +30,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/*
* See s_expl.c for more comments about __k_expl().
*
diff --git a/lib/msun/ld80/k_sinl.c b/lib/msun/ld80/k_sinl.c
index 21c1946b5e1b..ffc00be23f1c 100644
--- a/lib/msun/ld80/k_sinl.c
+++ b/lib/msun/ld80/k_sinl.c
@@ -1,4 +1,3 @@
-/* From: @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ld80 version of k_sin.c. See ../src/k_sin.c for most comments.
*/
diff --git a/lib/msun/ld80/k_tanl.c b/lib/msun/ld80/k_tanl.c
index 4965c669979f..b3a4d9e05255 100644
--- a/lib/msun/ld80/k_tanl.c
+++ b/lib/msun/ld80/k_tanl.c
@@ -1,5 +1,3 @@
-/* From: @(#)k_tan.c 1.5 04/04/22 SMI */
-
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
@@ -11,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ld80 version of k_tan.c. See ../src/k_tan.c for most comments.
*/
diff --git a/lib/msun/ld80/s_cexpl.c b/lib/msun/ld80/s_cexpl.c
index 81a4d727561b..cbe9dcd64099 100644
--- a/lib/msun/ld80/s_cexpl.c
+++ b/lib/msun/ld80/s_cexpl.c
@@ -28,7 +28,6 @@
* src/s_cexp.c converted to long double complex by Steven G. Kargl
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#ifdef __i386__
diff --git a/lib/msun/ld80/s_erfl.c b/lib/msun/ld80/s_erfl.c
index 362b4f07d6bc..047077ca4470 100644
--- a/lib/msun/ld80/s_erfl.c
+++ b/lib/msun/ld80/s_erfl.c
@@ -1,4 +1,3 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See s_erf.c for complete comments.
*
diff --git a/lib/msun/ld80/s_exp2l.c b/lib/msun/ld80/s_exp2l.c
index 94aecf1843cd..9d979994ece8 100644
--- a/lib/msun/ld80/s_exp2l.c
+++ b/lib/msun/ld80/s_exp2l.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <stdint.h>
diff --git a/lib/msun/ld80/s_expl.c b/lib/msun/ld80/s_expl.c
index 065e02fae1b0..03d7b366151a 100644
--- a/lib/msun/ld80/s_expl.c
+++ b/lib/msun/ld80/s_expl.c
@@ -28,7 +28,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/**
* Compute the exponential of x for Intel 80-bit format. This is based on:
*
diff --git a/lib/msun/ld80/s_logl.c b/lib/msun/ld80/s_logl.c
index 459374d7d164..7141abe086d5 100644
--- a/lib/msun/ld80/s_logl.c
+++ b/lib/msun/ld80/s_logl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/**
* Implementation of the natural logarithm of x for Intel 80-bit format.
*
@@ -445,7 +444,7 @@ struct ld {
#endif
#ifdef STRUCT_RETURN
-static inline __always_inline void
+static __always_inline void
k_logl(long double x, struct ld *rp)
#else
long double
diff --git a/lib/msun/man/acos.3 b/lib/msun/man/acos.3
index b7b3a2eb7f17..e21687c1bb66 100644
--- a/lib/msun/man/acos.3
+++ b/lib/msun/man/acos.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)acos.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd July 31, 2008
.Dt ACOS 3
.Os
diff --git a/lib/msun/man/acosh.3 b/lib/msun/man/acosh.3
index db0104b0bdd2..0268bde8e092 100644
--- a/lib/msun/man/acosh.3
+++ b/lib/msun/man/acosh.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)acosh.3 5.2 (Berkeley) 5/6/91
-.\"
.Dd June 9, 2013
.Dt ACOSH 3
.Os
diff --git a/lib/msun/man/asin.3 b/lib/msun/man/asin.3
index 03a9145ce065..20dc7ac1f54c 100644
--- a/lib/msun/man/asin.3
+++ b/lib/msun/man/asin.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)asin.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd July 31, 2008
.Dt ASIN 3
.Os
diff --git a/lib/msun/man/asinh.3 b/lib/msun/man/asinh.3
index c706f2c14e46..66515fa6ac0b 100644
--- a/lib/msun/man/asinh.3
+++ b/lib/msun/man/asinh.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)asinh.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd June 9, 2013
.Dt ASINH 3
.Os
diff --git a/lib/msun/man/atan.3 b/lib/msun/man/atan.3
index 0cda6fb2d8f9..d04787ce8bfe 100644
--- a/lib/msun/man/atan.3
+++ b/lib/msun/man/atan.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)atan.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd July 31, 2008
.Dt ATAN 3
.Os
diff --git a/lib/msun/man/atan2.3 b/lib/msun/man/atan2.3
index df67200a002f..df023777ce71 100644
--- a/lib/msun/man/atan2.3
+++ b/lib/msun/man/atan2.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd July 31, 2008
.Dt ATAN2 3
.Os
diff --git a/lib/msun/man/atanh.3 b/lib/msun/man/atanh.3
index a4c1061bd014..3fd9d2977d8f 100644
--- a/lib/msun/man/atanh.3
+++ b/lib/msun/man/atanh.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)atanh.3 5.2 (Berkeley) 5/6/91
-.\"
.Dd June 9, 2013
.Dt ATANH 3
.Os
diff --git a/lib/msun/man/ceil.3 b/lib/msun/man/ceil.3
index 61a63e2c5fd1..9a0a5be89f64 100644
--- a/lib/msun/man/ceil.3
+++ b/lib/msun/man/ceil.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ceil.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd January 13, 2005
.Dt CEIL 3
.Os
diff --git a/lib/msun/man/copysign.3 b/lib/msun/man/copysign.3
index 5d08bd5dd559..091164fbeda9 100644
--- a/lib/msun/man/copysign.3
+++ b/lib/msun/man/copysign.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd January 26, 2005
.Dt COPYSIGN 3
.Os
diff --git a/lib/msun/man/cos.3 b/lib/msun/man/cos.3
index 68036ab7bb99..4b5223b37261 100644
--- a/lib/msun/man/cos.3
+++ b/lib/msun/man/cos.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)cos.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd April 1, 2020
.Dt COS 3
.Os
diff --git a/lib/msun/man/cosh.3 b/lib/msun/man/cosh.3
index 45af312bd025..22105f259817 100644
--- a/lib/msun/man/cosh.3
+++ b/lib/msun/man/cosh.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)cosh.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd April 3, 2022
.Dt COSH 3
.Os
diff --git a/lib/msun/man/cospi.3 b/lib/msun/man/cospi.3
index 5b33fe2555a1..86e63fb77498 100644
--- a/lib/msun/man/cospi.3
+++ b/lib/msun/man/cospi.3
@@ -62,27 +62,21 @@ where p is the floating\(enpoint precision of
.Ar x ,
then the returned value is 1 and it has no significance.
.Sh SPECIAL VALUES
-.Bl -tag
-.It
-.Fn cospi \*(Pm0
+.Bl -tag -width "cospi(+n/2)"
+.It Fn cospi \*(Pm0
returns 1.
-.It
-.Fn cospi \*(Pmn/2
+.It Fn cospi \*(Pmn/2
returns 0 for positive integers
.Ar n .
-.It
-.Fn cospi n
+.It Fn cospi n
returns 1 for even integers
.Ar n .
-.It
-.Fn cospi n
+.It Fn cospi n
returns \-1 for odd integers
.Ar n .
-.It
-.Fn cospi \*(Pm\(if
+.It Fn cospi \*(Pm\(if
return an \*(Na and raises an FE_INVALID exception.
-.It
-.Fn cospi \*(Na
+.It Fn cospi \*(Na
return an \*(Na and raises an FE_INVALID exception.
.El
.Sh SEE ALSO
diff --git a/lib/msun/man/erf.3 b/lib/msun/man/erf.3
index e0771863cca1..8d66017ed11c 100644
--- a/lib/msun/man/erf.3
+++ b/lib/msun/man/erf.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)erf.3 6.4 (Berkeley) 4/20/91
-.\"
-.Dd July 13, 2014
+.Dd June 23, 2024
.Dt ERF 3
.Os
.Sh NAME
@@ -88,6 +86,17 @@ subtracts the result of the error function
from 1.0.
.Sh SEE ALSO
.Xr math 3
+.Sh STANDARDS
+The
+.Fn erf ,
+.Fn erff ,
+.Fn erfl ,
+.Fn erfc ,
+.Fn erfcf
+and
+.Fn erfcl
+functions conform to
+.St -isoC-99 .
.Sh HISTORY
The
.Fn erf
diff --git a/lib/msun/man/exp.3 b/lib/msun/man/exp.3
index b918f32dba6a..a94c372fa0f5 100644
--- a/lib/msun/man/exp.3
+++ b/lib/msun/man/exp.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
-.\"
.Dd April 1, 2020
.Dt EXP 3
.Os
diff --git a/lib/msun/man/fabs.3 b/lib/msun/man/fabs.3
index 3ddf68ed2ef3..031b6aa54d18 100644
--- a/lib/msun/man/fabs.3
+++ b/lib/msun/man/fabs.3
@@ -1,7 +1,5 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
-.\"
-.\" @(#)fabs.3 5.1 (Berkeley) 5/2/91
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -26,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)fabs.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd October 25, 2003
.Dt FABS 3
.Os
diff --git a/lib/msun/man/floor.3 b/lib/msun/man/floor.3
index 4bf3f4ddd971..b295d013035f 100644
--- a/lib/msun/man/floor.3
+++ b/lib/msun/man/floor.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)floor.3 6.5 (Berkeley) 4/19/91
-.\"
.Dd April 3, 2022
.Dt FLOOR 3
.Os
diff --git a/lib/msun/man/fmod.3 b/lib/msun/man/fmod.3
index bf7288d1a9c3..a7a5ae86df58 100644
--- a/lib/msun/man/fmod.3
+++ b/lib/msun/man/fmod.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)fmod.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd April 3, 2022
.Dt FMOD 3
.Os
diff --git a/lib/msun/man/hypot.3 b/lib/msun/man/hypot.3
index 4ff901b14af5..7b8498757955 100644
--- a/lib/msun/man/hypot.3
+++ b/lib/msun/man/hypot.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)hypot.3 6.7 (Berkeley) 5/6/91
-.\"
.Dd March 30, 2008
.Dt HYPOT 3
.Os
diff --git a/lib/msun/man/ieee.3 b/lib/msun/man/ieee.3
index 398287da8606..aaf73efe6bf9 100644
--- a/lib/msun/man/ieee.3
+++ b/lib/msun/man/ieee.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd January 26, 2005
.Dt IEEE 3
.Os
diff --git a/lib/msun/man/ieee_test.3 b/lib/msun/man/ieee_test.3
index 7a5b2abb2573..bae704eb22df 100644
--- a/lib/msun/man/ieee_test.3
+++ b/lib/msun/man/ieee_test.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd November 6, 2005
.Dt IEEE_TEST 3
.Os
diff --git a/lib/msun/man/ilogb.3 b/lib/msun/man/ilogb.3
index e263f4f0a262..4d4523316afd 100644
--- a/lib/msun/man/ilogb.3
+++ b/lib/msun/man/ilogb.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd December 16, 2007
.Dt ILOGB 3
.Os
diff --git a/lib/msun/man/j0.3 b/lib/msun/man/j0.3
index 804bc3678e8f..a5c58f03977a 100644
--- a/lib/msun/man/j0.3
+++ b/lib/msun/man/j0.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)j0.3 6.7 (Berkeley) 4/19/91
-.\"
.Dd March 10, 2015
.Dt J0 3
.Os
diff --git a/lib/msun/man/lgamma.3 b/lib/msun/man/lgamma.3
index cf80c9e7f365..41d680e41bda 100644
--- a/lib/msun/man/lgamma.3
+++ b/lib/msun/man/lgamma.3
@@ -25,9 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92
-.\"
-.Dd December 8, 2017
+.Dd April 12, 2024
.Dt LGAMMA 3
.Os
.Sh NAME
@@ -169,15 +167,6 @@ non-positive integers.
For large non-integer negative values,
.Fn tgamma
will underflow.
-.Sh BUGS
-To conform with newer C/C++ standards, a stub implementation for
-.Nm tgammal
-was committed to the math library, where
-.Nm tgammal
-is mapped to
-.Nm tgamma .
-Thus, the numerical accuracy is at most that of the 53-bit double
-precision implementation.
.Sh SEE ALSO
.Xr math 3
.Sh STANDARDS
@@ -214,3 +203,11 @@ The
.Fn tgamma
function appeared in
.Fx 5.0 .
+The 128-bit
+.Ft long double
+version of
+.Fn tgammal
+replaced the 80-bit stub version in
+version in
+.Fx 14.1 ,
+thanks to an appropriate implementation from Arm.
diff --git a/lib/msun/man/math.3 b/lib/msun/man/math.3
index 0704918846a8..47353298bb54 100644
--- a/lib/msun/man/math.3
+++ b/lib/msun/man/math.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)math.3 6.10 (Berkeley) 5/6/91
-.\"
.Dd December 7, 2017
.Dt MATH 3
.Os
diff --git a/lib/msun/man/nextafter.3 b/lib/msun/man/nextafter.3
index 970e029b46b6..3282050f1d2e 100644
--- a/lib/msun/man/nextafter.3
+++ b/lib/msun/man/nextafter.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd May 4, 2005
.Dt NEXTAFTER 3
.Os
diff --git a/lib/msun/man/remainder.3 b/lib/msun/man/remainder.3
index 9b8962b4907e..9c2d92f5e90c 100644
--- a/lib/msun/man/remainder.3
+++ b/lib/msun/man/remainder.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd March 30, 2008
.Dt REMAINDER 3
.Os
diff --git a/lib/msun/man/rint.3 b/lib/msun/man/rint.3
index 385b5b51dc8a..399a0720b324 100644
--- a/lib/msun/man/rint.3
+++ b/lib/msun/man/rint.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)rint.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd January 13, 2008
.Dt RINT 3
.Os
diff --git a/lib/msun/man/scalbn.3 b/lib/msun/man/scalbn.3
index 2c56f57f6793..9b14e1fcb3d4 100644
--- a/lib/msun/man/scalbn.3
+++ b/lib/msun/man/scalbn.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd March 4, 2005
.Dt SCALBN 3
.Os
diff --git a/lib/msun/man/sin.3 b/lib/msun/man/sin.3
index a007be7fac31..376fc706dd2b 100644
--- a/lib/msun/man/sin.3
+++ b/lib/msun/man/sin.3
@@ -1,7 +1,5 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
-.\"
-.\" @(#)sin.3 6.7 (Berkeley) 4/19/91
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -26,8 +24,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)sin.3 6.7 (Berkeley) 4/19/91
-.\"
.Dd April 1, 2020
.Dt SIN 3
.Os
diff --git a/lib/msun/man/sinh.3 b/lib/msun/man/sinh.3
index 71dcfbd59b10..7fb928028371 100644
--- a/lib/msun/man/sinh.3
+++ b/lib/msun/man/sinh.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)sinh.3 6.6 (Berkeley) 4/19/91
-.\"
.Dd April 3, 2022
.Dt SINH 3
.Os
diff --git a/lib/msun/man/sinpi.3 b/lib/msun/man/sinpi.3
index a5f514d3979f..63a1e3010de5 100644
--- a/lib/msun/man/sinpi.3
+++ b/lib/msun/man/sinpi.3
@@ -62,19 +62,15 @@ where p is the floating\(enpoint precision of
.Ar x ,
then the returned value is \*(Pm0 and it has no significance.
.Sh SPECIAL VALUES
-.Bl -tag
-.It
-.Fn sinpi \*(Pm0
+.Bl -tag -width "sinpi(NaN)"
+.It Fn sinpi \*(Pm0
returns \*(Pm0.
-.It
-.Fn sinpi \*(Pmn
+.It Fn sinpi \*(Pmn
returns \*(Pm0 for positive integers
.Ar n .
-.It
-.Fn sinpi \*(Pm\(if
+.It Fn sinpi \*(Pm\(if
return an \*(Na and raises an FE_INVALID exception.
-.It
-.Fn sinpi \*(Na
+.It Fn sinpi \*(Na
return an \*(Na and raises an FE_INVALID exception.
.El
.Sh SEE ALSO
diff --git a/lib/msun/man/sqrt.3 b/lib/msun/man/sqrt.3
index 9645160dfdae..f4a217353af0 100644
--- a/lib/msun/man/sqrt.3
+++ b/lib/msun/man/sqrt.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)sqrt.3 6.4 (Berkeley) 5/6/91
-.\"
.Dd February 15, 2020
.Dt SQRT 3
.Os
diff --git a/lib/msun/man/tan.3 b/lib/msun/man/tan.3
index 5a0226cf1156..8714d2429c2a 100644
--- a/lib/msun/man/tan.3
+++ b/lib/msun/man/tan.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)tan.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd January 24, 2008
.Dt TAN 3
.Os
diff --git a/lib/msun/man/tanh.3 b/lib/msun/man/tanh.3
index 61ae7a0920b8..e795d0e7eba6 100644
--- a/lib/msun/man/tanh.3
+++ b/lib/msun/man/tanh.3
@@ -25,8 +25,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)tanh.3 5.1 (Berkeley) 5/2/91
-.\"
.Dd April 3, 2022
.Dt TANH 3
.Os
diff --git a/lib/msun/man/tanpi.3 b/lib/msun/man/tanpi.3
index 2b95f5daa8b1..b11d54031b71 100644
--- a/lib/msun/man/tanpi.3
+++ b/lib/msun/man/tanpi.3
@@ -62,22 +62,17 @@ where p is the floating\(enpoint precision of
.Ar x ,
then the returned value is \*(Pm0 and it has no significance.
.Sh SPECIAL VALUES
-.Bl -tag
-.It
-.Fn tanpi \*(Pm0
+.Bl -tag -width "tanpi(+n/2)"
+.It Fn tanpi \*(Pm0
returns \*(Pm0.
-.It
-.Fn tanpi \*(Pmn
+.It Fn tanpi \*(Pmn
returns \*(Pm0 for positive integers
.Ar n .
-.It
-.Fn tanpi \*(Pmn/2
+.It Fn tanpi \*(Pmn/2
returns \*(Na for n > 0 and raises an FE_INVALID exception.
-.It
-.Fn tanpi \*(Pm\(if
+.It Fn tanpi \*(Pm\(if
return an \*(Na and raises an FE_INVALID exception.
-.It
-.Fn tanpi \*(Na
+.It Fn tanpi \*(Na
return an \*(Na and raises an FE_INVALID exception.
.El
.Sh SEE ALSO
diff --git a/lib/msun/powerpc/Makefile.inc b/lib/msun/powerpc/Makefile.inc
index c1088659f2b0..35747abb7087 100644
--- a/lib/msun/powerpc/Makefile.inc
+++ b/lib/msun/powerpc/Makefile.inc
@@ -1,3 +1,2 @@
-
LDBL_PREC = 53
SYM_MAPS += ${.CURDIR}/powerpc/Symbol.map
diff --git a/lib/msun/riscv/Makefile.inc b/lib/msun/riscv/Makefile.inc
index e83e57a743ac..6262cfd6981e 100644
--- a/lib/msun/riscv/Makefile.inc
+++ b/lib/msun/riscv/Makefile.inc
@@ -1,3 +1,2 @@
-
LDBL_PREC = 113
SYM_MAPS += ${.CURDIR}/riscv/Symbol.map
diff --git a/lib/msun/riscv/Symbol.map b/lib/msun/riscv/Symbol.map
index 2bc6215688bb..65157d0de9c1 100644
--- a/lib/msun/riscv/Symbol.map
+++ b/lib/msun/riscv/Symbol.map
@@ -1,15 +1,12 @@
-/*
- */
-FBSD_1.0 {
-};
-
FBSD_1.3 {
fesetexceptflag;
feraiseexcept;
fegetenv;
feholdexcept;
feupdateenv;
+};
+
+FBSD_1.8 {
feenableexcept;
fedisableexcept;
- fegetexcept;
};
diff --git a/lib/msun/riscv/fenv.c b/lib/msun/riscv/fenv.c
index 9d7ae3d3fdaf..a4dde02a6ddc 100644
--- a/lib/msun/riscv/fenv.c
+++ b/lib/msun/riscv/fenv.c
@@ -37,14 +37,6 @@
*/
const fenv_t __fe_dfl_env = 0;
-#ifdef __riscv_float_abi_soft
-#define __set_env(env, flags, mask, rnd) env = ((flags) | (rnd) << 5)
-#define __env_flags(env) ((env) & FE_ALL_EXCEPT)
-#define __env_mask(env) (0) /* No exception traps. */
-#define __env_round(env) (((env) >> 5) & _ROUND_MASK)
-#include "fenv-softfloat.h"
-#endif
-
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
diff --git a/lib/msun/riscv/fenv.h b/lib/msun/riscv/fenv.h
index 1971e976645c..fd50463d479e 100644
--- a/lib/msun/riscv/fenv.h
+++ b/lib/msun/riscv/fenv.h
@@ -36,6 +36,7 @@
#ifndef _FENV_H_
#define _FENV_H_
+#include <sys/cdefs.h>
#include <sys/_types.h>
#ifndef __fenv_static
@@ -71,32 +72,13 @@ __BEGIN_DECLS
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
-#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double)
-#if defined(__riscv_float_abi_single)
-#error single precision floating point ABI not supported
-#else
-#error compiler did not set soft/hard float macros
-#endif
+#ifndef __riscv_float_abi_double
+#error only double hard float ABI supported
#endif
-#ifndef __riscv_float_abi_soft
#define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr))
#define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr))
-#endif
-#ifdef __riscv_float_abi_soft
-int feclearexcept(int __excepts);
-int fegetexceptflag(fexcept_t *__flagp, int __excepts);
-int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
-int feraiseexcept(int __excepts);
-int fetestexcept(int __excepts);
-int fegetround(void);
-int fesetround(int __round);
-int fegetenv(fenv_t *__envp);
-int feholdexcept(fenv_t *__envp);
-int fesetenv(const fenv_t *__envp);
-int feupdateenv(const fenv_t *__envp);
-#else
__fenv_static inline int
feclearexcept(int __excepts)
{
@@ -212,18 +194,10 @@ feupdateenv(const fenv_t *__envp)
return (0);
}
-#endif /* !__riscv_float_abi_soft */
#if __BSD_VISIBLE
-/* We currently provide no external definitions of the functions below. */
-
-#ifdef __riscv_float_abi_soft
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
-int fegetexcept(void);
-#else
-static inline int
+__fenv_static inline int
feenableexcept(int __mask __unused)
{
@@ -232,7 +206,7 @@ feenableexcept(int __mask __unused)
return (0);
}
-static inline int
+__fenv_static inline int
fedisableexcept(int __mask __unused)
{
@@ -241,6 +215,7 @@ fedisableexcept(int __mask __unused)
return (0);
}
+/* We currently provide no external definition of fegetexcept(). */
static inline int
fegetexcept(void)
{
@@ -249,7 +224,6 @@ fegetexcept(void)
return (0);
}
-#endif /* !__riscv_float_abi_soft */
#endif /* __BSD_VISIBLE */
diff --git a/lib/msun/src/catrig.c b/lib/msun/src/catrig.c
index 929811a09a3b..45af164a66c5 100644
--- a/lib/msun/src/catrig.c
+++ b/lib/msun/src/catrig.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
diff --git a/lib/msun/src/catrigf.c b/lib/msun/src/catrigf.c
index 7feecfc5de38..da90629ec076 100644
--- a/lib/msun/src/catrigf.c
+++ b/lib/msun/src/catrigf.c
@@ -40,7 +40,6 @@
* a few comments on the right of declarations remain.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
diff --git a/lib/msun/src/catrigl.c b/lib/msun/src/catrigl.c
index 7cc3c1431731..faf9d299670e 100644
--- a/lib/msun/src/catrigl.c
+++ b/lib/msun/src/catrigl.c
@@ -39,7 +39,6 @@
* a few comments on the right of declarations remain.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
diff --git a/lib/msun/src/e_acos.c b/lib/msun/src/e_acos.c
index 275d0ebb7756..af51fe1ecddc 100644
--- a/lib/msun/src/e_acos.c
+++ b/lib/msun/src/e_acos.c
@@ -1,5 +1,4 @@
-/* @(#)e_acos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* acos(x)
* Method :
* acos(x) = pi/2 - asin(x)
diff --git a/lib/msun/src/e_acosf.c b/lib/msun/src/e_acosf.c
index 29f6d4a78495..ede552e7055a 100644
--- a/lib/msun/src/e_acosf.c
+++ b/lib/msun/src/e_acosf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
@@ -23,11 +22,17 @@ pi = 3.1415925026e+00, /* 0x40490fda */
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
static volatile float
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
+
+/*
+ * The coefficients for the rational approximation were generated over
+ * 0x1p-12f <= x <= 0.5f. The maximum error satisfies log2(e) < -30.084.
+ */
static const float
-pS0 = 1.6666586697e-01,
-pS1 = -4.2743422091e-02,
-pS2 = -8.6563630030e-03,
-qS1 = -7.0662963390e-01;
+pS0 = 1.66666672e-01f, /* 0x3e2aaaab */
+pS1 = -1.19510300e-01f, /* 0xbdf4c1d1 */
+pS2 = 5.47002675e-03f, /* 0x3bb33de9 */
+qS1 = -1.16706085e+00f, /* 0xbf956240 */
+qS2 = 2.90115148e-01f; /* 0x3e9489f9 */
float
acosf(float x)
@@ -47,13 +52,13 @@ acosf(float x)
if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<2**-26*/
z = x*x;
p = z*(pS0+z*(pS1+z*pS2));
- q = one+z*qS1;
+ q = one+z*(qS1+z*qS2);
r = p/q;
return pio2_hi - (x - (pio2_lo-x*r));
} else if (hx<0) { /* x < -0.5 */
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*pS2));
- q = one+z*qS1;
+ q = one+z*(qS1+z*qS2);
s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
@@ -67,7 +72,7 @@ acosf(float x)
SET_FLOAT_WORD(df,idf&0xfffff000);
c = (z-df*df)/(s+df);
p = z*(pS0+z*(pS1+z*pS2));
- q = one+z*qS1;
+ q = one+z*(qS1+z*qS2);
r = p/q;
w = r*s+c;
return (float)2.0*(df+w);
diff --git a/lib/msun/src/e_acosh.c b/lib/msun/src/e_acosh.c
index d50f5513ee59..0e5640b623d9 100644
--- a/lib/msun/src/e_acosh.c
+++ b/lib/msun/src/e_acosh.c
@@ -1,5 +1,4 @@
-/* @(#)e_acosh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
*
*/
-#include <sys/cdefs.h>
/* acosh(x)
* Method :
* Based on
diff --git a/lib/msun/src/e_acoshf.c b/lib/msun/src/e_acoshf.c
index df12609671cf..b6fbd2c14cb4 100644
--- a/lib/msun/src/e_acoshf.c
+++ b/lib/msun/src/e_acoshf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_acoshl.c b/lib/msun/src/e_acoshl.c
index 8f3d3963e7cf..6bfa6244df09 100644
--- a/lib/msun/src/e_acoshl.c
+++ b/lib/msun/src/e_acoshl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
-/* @(#)e_acosh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,7 +12,6 @@
*
*/
-#include <sys/cdefs.h>
/*
* See e_acosh.c for complete comments.
*
diff --git a/lib/msun/src/e_acosl.c b/lib/msun/src/e_acosl.c
index 524fa756a103..209814383e51 100644
--- a/lib/msun/src/e_acosl.c
+++ b/lib/msun/src/e_acosl.c
@@ -1,5 +1,4 @@
-/* @(#)e_acos.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_acos.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -12,7 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See comments in e_acos.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/lib/msun/src/e_asin.c b/lib/msun/src/e_asin.c
index ae6e496850e1..530bf7910756 100644
--- a/lib/msun/src/e_asin.c
+++ b/lib/msun/src/e_asin.c
@@ -1,5 +1,4 @@
-/* @(#)e_asin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* asin(x)
* Method :
* Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
diff --git a/lib/msun/src/e_asinf.c b/lib/msun/src/e_asinf.c
index 391c15870f84..8d1aca27df83 100644
--- a/lib/msun/src/e_asinf.c
+++ b/lib/msun/src/e_asinf.c
@@ -13,18 +13,23 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
-huge = 1.000e+30,
- /* coefficient for R(x^2) */
-pS0 = 1.6666586697e-01,
-pS1 = -4.2743422091e-02,
-pS2 = -8.6563630030e-03,
-qS1 = -7.0662963390e-01;
+huge = 1.000e+30;
+
+/*
+ * The coefficients for the rational approximation were generated over
+ * 0x1p-12f <= x <= 0.5f. The maximum error satisfies log2(e) < -30.084.
+ */
+static const float
+pS0 = 1.66666672e-01f, /* 0x3e2aaaab */
+pS1 = -1.19510300e-01f, /* 0xbdf4c1d1 */
+pS2 = 5.47002675e-03f, /* 0x3bb33de9 */
+qS1 = -1.16706085e+00f, /* 0xbf956240 */
+qS2 = 2.90115148e-01f; /* 0x3e9489f9 */
static const double
pio2 = 1.570796326794896558e+00;
@@ -47,7 +52,7 @@ asinf(float x)
}
t = x*x;
p = t*(pS0+t*(pS1+t*pS2));
- q = one+t*qS1;
+ q = one+t*(qS1+t*qS2);
w = p/q;
return x+x*w;
}
@@ -55,7 +60,7 @@ asinf(float x)
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*pS2));
- q = one+t*qS1;
+ q = one+t*(qS1+t*qS2);
s = sqrt(t);
w = p/q;
t = pio2-2.0*(s+s*w);
diff --git a/lib/msun/src/e_asinl.c b/lib/msun/src/e_asinl.c
index d0cff2f536fa..bb2320e129e7 100644
--- a/lib/msun/src/e_asinl.c
+++ b/lib/msun/src/e_asinl.c
@@ -1,5 +1,4 @@
-/* @(#)e_asin.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -12,7 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See comments in e_asin.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/lib/msun/src/e_atan2.c b/lib/msun/src/e_atan2.c
index f4d3ed2e00db..ab5fc72dbabf 100644
--- a/lib/msun/src/e_atan2.c
+++ b/lib/msun/src/e_atan2.c
@@ -1,5 +1,4 @@
-/* @(#)e_atan2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
*
*/
-#include <sys/cdefs.h>
/* atan2(y,x)
* Method :
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
diff --git a/lib/msun/src/e_atan2f.c b/lib/msun/src/e_atan2f.c
index af8c00851476..408f3646f612 100644
--- a/lib/msun/src/e_atan2f.c
+++ b/lib/msun/src/e_atan2f.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_atan2l.c b/lib/msun/src/e_atan2l.c
index 722334f76791..a27fd3efc141 100644
--- a/lib/msun/src/e_atan2l.c
+++ b/lib/msun/src/e_atan2l.c
@@ -1,5 +1,4 @@
-/* @(#)e_atan2.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_atan2.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -13,7 +12,6 @@
*
*/
-#include <sys/cdefs.h>
/*
* See comments in e_atan2.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/lib/msun/src/e_atanh.c b/lib/msun/src/e_atanh.c
index 3eabaaf82403..0cc0b9248b6b 100644
--- a/lib/msun/src/e_atanh.c
+++ b/lib/msun/src/e_atanh.c
@@ -1,5 +1,4 @@
-/* @(#)e_atanh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
*
*/
-#include <sys/cdefs.h>
/* atanh(x)
* Method :
* 1.Reduced x to positive by atanh(-x) = -atanh(x)
diff --git a/lib/msun/src/e_atanhf.c b/lib/msun/src/e_atanhf.c
index 134513e5b817..a2d6b69a6812 100644
--- a/lib/msun/src/e_atanhf.c
+++ b/lib/msun/src/e_atanhf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_atanhl.c b/lib/msun/src/e_atanhl.c
index 66a301f52ab6..cb707272a66c 100644
--- a/lib/msun/src/e_atanhl.c
+++ b/lib/msun/src/e_atanhl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/e_atanh.c 176451 2008-02-22 02:30:36Z das */
-/* @(#)e_atanh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,7 +12,6 @@
*
*/
-#include <sys/cdefs.h>
/*
* See e_atanh.c for complete comments.
*
diff --git a/lib/msun/src/e_cosh.c b/lib/msun/src/e_cosh.c
index 56ec7d56093d..5c3614efbf47 100644
--- a/lib/msun/src/e_cosh.c
+++ b/lib/msun/src/e_cosh.c
@@ -1,5 +1,4 @@
-/* @(#)e_cosh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* cosh(x)
* Method :
* mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
diff --git a/lib/msun/src/e_coshf.c b/lib/msun/src/e_coshf.c
index 8c5457e24a51..40443b8b84d3 100644
--- a/lib/msun/src/e_coshf.c
+++ b/lib/msun/src/e_coshf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_coshl.c b/lib/msun/src/e_coshl.c
index de54b8183bbb..efb5094d39f9 100644
--- a/lib/msun/src/e_coshl.c
+++ b/lib/msun/src/e_coshl.c
@@ -11,7 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_cosh.c for complete comments.
*
diff --git a/lib/msun/src/e_exp.c b/lib/msun/src/e_exp.c
index afbcdb3db7b6..6401556a44e4 100644
--- a/lib/msun/src/e_exp.c
+++ b/lib/msun/src/e_exp.c
@@ -1,5 +1,4 @@
-/* @(#)e_exp.c 1.6 04/04/22 */
/*
* ====================================================
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* exp(x)
* Returns the exponential of x.
*
diff --git a/lib/msun/src/e_expf.c b/lib/msun/src/e_expf.c
index 2dbce9dd870d..fe2e6779469f 100644
--- a/lib/msun/src/e_expf.c
+++ b/lib/msun/src/e_expf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/e_fmod.c b/lib/msun/src/e_fmod.c
index fdfb56c2a475..77afd116c658 100644
--- a/lib/msun/src/e_fmod.c
+++ b/lib/msun/src/e_fmod.c
@@ -1,5 +1,4 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* fmod(x,y)
* Return x mod y in exact arithmetic
diff --git a/lib/msun/src/e_fmodf.c b/lib/msun/src/e_fmodf.c
index 0e6633fbe739..a7d1a0c22acd 100644
--- a/lib/msun/src/e_fmodf.c
+++ b/lib/msun/src/e_fmodf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* fmodf(x,y)
* Return x mod y in exact arithmetic
diff --git a/lib/msun/src/e_fmodl.c b/lib/msun/src/e_fmodl.c
index 8a348ee117e7..d5997e1f4e47 100644
--- a/lib/msun/src/e_fmodl.c
+++ b/lib/msun/src/e_fmodl.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <stdint.h>
diff --git a/lib/msun/src/e_gamma.c b/lib/msun/src/e_gamma.c
index 7757337b59af..43541ad935bd 100644
--- a/lib/msun/src/e_gamma.c
+++ b/lib/msun/src/e_gamma.c
@@ -1,5 +1,4 @@
-/* @(#)e_gamma.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
*
*/
-#include <sys/cdefs.h>
/* gamma(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/lib/msun/src/e_gamma_r.c b/lib/msun/src/e_gamma_r.c
index f204685c3f7a..f317ae435cdc 100644
--- a/lib/msun/src/e_gamma_r.c
+++ b/lib/msun/src/e_gamma_r.c
@@ -1,5 +1,4 @@
-/* @(#)e_gamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
*
*/
-#include <sys/cdefs.h>
/* gamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
diff --git a/lib/msun/src/e_gammaf.c b/lib/msun/src/e_gammaf.c
index 3afef79de53a..98da5711e811 100644
--- a/lib/msun/src/e_gammaf.c
+++ b/lib/msun/src/e_gammaf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* gammaf(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/lib/msun/src/e_gammaf_r.c b/lib/msun/src/e_gammaf_r.c
index 5b3bd535aa42..ae80c1bae2cc 100644
--- a/lib/msun/src/e_gammaf_r.c
+++ b/lib/msun/src/e_gammaf_r.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* gammaf_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
diff --git a/lib/msun/src/e_hypot.c b/lib/msun/src/e_hypot.c
index 8d9c2b11dd97..a291af575521 100644
--- a/lib/msun/src/e_hypot.c
+++ b/lib/msun/src/e_hypot.c
@@ -1,5 +1,4 @@
-/* @(#)e_hypot.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* hypot(x,y)
*
* Method :
diff --git a/lib/msun/src/e_hypotf.c b/lib/msun/src/e_hypotf.c
index c976fd33014d..e45486ee912f 100644
--- a/lib/msun/src/e_hypotf.c
+++ b/lib/msun/src/e_hypotf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_hypotl.c b/lib/msun/src/e_hypotl.c
index 0a89e3a0e218..d8e060a66184 100644
--- a/lib/msun/src/e_hypotl.c
+++ b/lib/msun/src/e_hypotl.c
@@ -1,4 +1,3 @@
-/* From: @(#)e_hypot.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* long double version of hypot(). See e_hypot.c for most comments. */
#include <float.h>
diff --git a/lib/msun/src/e_j0.c b/lib/msun/src/e_j0.c
index 20e0d36b162e..b19661c82534 100644
--- a/lib/msun/src/e_j0.c
+++ b/lib/msun/src/e_j0.c
@@ -1,4 +1,3 @@
-/* @(#)e_j0.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* j0(x), y0(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j0(x):
diff --git a/lib/msun/src/e_j0f.c b/lib/msun/src/e_j0f.c
index 1cb318d80851..de04a9fadf6b 100644
--- a/lib/msun/src/e_j0f.c
+++ b/lib/msun/src/e_j0f.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_j0.c for complete comments.
*/
diff --git a/lib/msun/src/e_j1.c b/lib/msun/src/e_j1.c
index 7c7812325cc2..06a74b0673c3 100644
--- a/lib/msun/src/e_j1.c
+++ b/lib/msun/src/e_j1.c
@@ -1,4 +1,3 @@
-/* @(#)e_j1.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* j1(x), y1(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j1(x):
diff --git a/lib/msun/src/e_j1f.c b/lib/msun/src/e_j1f.c
index c022557c4d6b..28cee8e37479 100644
--- a/lib/msun/src/e_j1f.c
+++ b/lib/msun/src/e_j1f.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_j1.c for complete comments.
*/
diff --git a/lib/msun/src/e_jn.c b/lib/msun/src/e_jn.c
index 9735b03429ff..0a715661faf4 100644
--- a/lib/msun/src/e_jn.c
+++ b/lib/msun/src/e_jn.c
@@ -1,4 +1,3 @@
-/* @(#)e_jn.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* jn(n, x), yn(n, x)
* floating point Bessel's function of the 1st and 2nd kind
diff --git a/lib/msun/src/e_jnf.c b/lib/msun/src/e_jnf.c
index 2eadaa1cc07b..b55eaf56679a 100644
--- a/lib/msun/src/e_jnf.c
+++ b/lib/msun/src/e_jnf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_jn.c for complete comments.
*/
diff --git a/lib/msun/src/e_lgamma.c b/lib/msun/src/e_lgamma.c
index 1d74db1c6af8..46e7c25b19c7 100644
--- a/lib/msun/src/e_lgamma.c
+++ b/lib/msun/src/e_lgamma.c
@@ -1,5 +1,4 @@
-/* @(#)e_lgamma.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
*
*/
-#include <sys/cdefs.h>
/* lgamma(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/lib/msun/src/e_lgamma_r.c b/lib/msun/src/e_lgamma_r.c
index 38efe4385631..30edd65d9354 100644
--- a/lib/msun/src/e_lgamma_r.c
+++ b/lib/msun/src/e_lgamma_r.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* lgamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
diff --git a/lib/msun/src/e_lgammaf.c b/lib/msun/src/e_lgammaf.c
index b3073557c92d..cc34e440e398 100644
--- a/lib/msun/src/e_lgammaf.c
+++ b/lib/msun/src/e_lgammaf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* lgammaf(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/lib/msun/src/e_lgammaf_r.c b/lib/msun/src/e_lgammaf_r.c
index 86f554f3bd38..3f863ce77a51 100644
--- a/lib/msun/src/e_lgammaf_r.c
+++ b/lib/msun/src/e_lgammaf_r.c
@@ -14,7 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_lgammal.c b/lib/msun/src/e_lgammal.c
index c45a62a7268e..51e3216a8220 100644
--- a/lib/msun/src/e_lgammal.c
+++ b/lib/msun/src/e_lgammal.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_log.c b/lib/msun/src/e_log.c
index 5dff93c66c5e..48b6e71d8ae5 100644
--- a/lib/msun/src/e_log.c
+++ b/lib/msun/src/e_log.c
@@ -1,5 +1,4 @@
-/* @(#)e_log.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* log(x)
* Return the logrithm of x
*
diff --git a/lib/msun/src/e_log10.c b/lib/msun/src/e_log10.c
index 89efd791265d..3647fb08f873 100644
--- a/lib/msun/src/e_log10.c
+++ b/lib/msun/src/e_log10.c
@@ -1,5 +1,4 @@
-/* @(#)e_log10.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* Return the base 10 logarithm of x. See e_log.c and k_log.h for most
* comments.
diff --git a/lib/msun/src/e_log10f.c b/lib/msun/src/e_log10f.c
index f240d14fca27..ee01d6f5b75b 100644
--- a/lib/msun/src/e_log10f.c
+++ b/lib/msun/src/e_log10f.c
@@ -9,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* Float version of e_log10.c. See the latter for most comments.
*/
diff --git a/lib/msun/src/e_log2.c b/lib/msun/src/e_log2.c
index eb099171f669..54be1b847381 100644
--- a/lib/msun/src/e_log2.c
+++ b/lib/msun/src/e_log2.c
@@ -1,5 +1,4 @@
-/* @(#)e_log10.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* Return the base 2 logarithm of x. See e_log.c and k_log.h for most
* comments.
diff --git a/lib/msun/src/e_log2f.c b/lib/msun/src/e_log2f.c
index 7c1b5c032bdc..52fa411bae8e 100644
--- a/lib/msun/src/e_log2f.c
+++ b/lib/msun/src/e_log2f.c
@@ -9,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* Float version of e_log2.c. See the latter for most comments.
*/
diff --git a/lib/msun/src/e_logf.c b/lib/msun/src/e_logf.c
index 2bbdd068591c..aad9db3a496c 100644
--- a/lib/msun/src/e_logf.c
+++ b/lib/msun/src/e_logf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_pow.c b/lib/msun/src/e_pow.c
index 8b62c49abe4a..85d1d551b6fb 100644
--- a/lib/msun/src/e_pow.c
+++ b/lib/msun/src/e_pow.c
@@ -1,4 +1,3 @@
-/* @(#)e_pow.c 1.5 04/04/22 SMI */
/*
* ====================================================
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
@@ -9,7 +8,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* pow(x,y) return x**y
*
* n
@@ -301,7 +299,11 @@ pow(double x, double y)
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
GET_HIGH_WORD(j,z);
- j += (n<<20);
+ /*
+ * sign bit of z is 0.
+ * sign bit of j will indicate sign of 0x3ff-biased exponent.
+ */
+ j += (int32_t)((u_int32_t)n<<20);
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */
else SET_HIGH_WORD(z,j);
return s*z;
diff --git a/lib/msun/src/e_powf.c b/lib/msun/src/e_powf.c
index ff872ab46327..9f670bcd1caa 100644
--- a/lib/msun/src/e_powf.c
+++ b/lib/msun/src/e_powf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
@@ -243,7 +242,11 @@ powf(float x, float y)
r = (z*t1)/(t1-two)-(w+z*w);
z = one-(r-z);
GET_FLOAT_WORD(j,z);
- j += (n<<23);
+ /*
+ * sign bit of z is 0.
+ * sign bit of j will indicate sign of 0x7f-biased exponent.
+ */
+ j += (int32_t)((u_int32_t)n<<23);
if((j>>23)<=0) z = scalbnf(z,n); /* subnormal output */
else SET_FLOAT_WORD(z,j);
return sn*z;
diff --git a/lib/msun/src/e_rem_pio2.c b/lib/msun/src/e_rem_pio2.c
index ef4107af94cb..16a57a018c59 100644
--- a/lib/msun/src/e_rem_pio2.c
+++ b/lib/msun/src/e_rem_pio2.c
@@ -1,5 +1,4 @@
-/* @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,7 +12,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
/* __ieee754_rem_pio2(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
@@ -47,7 +45,7 @@ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
#ifdef INLINE_REM_PIO2
-static __inline __always_inline
+static __always_inline
#endif
int
__ieee754_rem_pio2(double x, double *y)
@@ -164,7 +162,7 @@ medium:
/* set z = scalbn(|x|,ilogb(x)-23) */
GET_LOW_WORD(low,x);
e0 = (ix>>20)-1046; /* e0 = ilogb(z)-23; */
- INSERT_WORDS(z, ix - ((int32_t)(e0<<20)), low);
+ INSERT_WORDS(z, ix - ((int32_t)((u_int32_t)e0<<20)), low);
for(i=0;i<2;i++) {
tx[i] = (double)((int32_t)(z));
z = (z-tx[i])*two24;
diff --git a/lib/msun/src/e_rem_pio2f.c b/lib/msun/src/e_rem_pio2f.c
index 26f6bc85791b..84cd9bf43d90 100644
--- a/lib/msun/src/e_rem_pio2f.c
+++ b/lib/msun/src/e_rem_pio2f.c
@@ -14,7 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* __ieee754_rem_pio2f(x,y)
*
* return the remainder of x rem pi/2 in *y
@@ -39,7 +38,7 @@ pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
#ifdef INLINE_REM_PIO2F
-static __inline __always_inline
+static __always_inline
#endif
int
__ieee754_rem_pio2f(float x, double *y)
@@ -68,7 +67,7 @@ __ieee754_rem_pio2f(float x, double *y)
}
/* set z = scalbn(|x|,ilogb(|x|)-23) */
e0 = (ix>>23)-150; /* e0 = ilogb(|x|)-23; */
- SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23)));
+ SET_FLOAT_WORD(z, ix - ((int32_t)((u_int32_t)e0<<23)));
tx[0] = z;
n = __kernel_rem_pio2(tx,ty,e0,1,0);
if(hx<0) {*y = -ty[0]; return -n;}
diff --git a/lib/msun/src/e_remainder.c b/lib/msun/src/e_remainder.c
index bd1ce8950619..a5fb7141d01a 100644
--- a/lib/msun/src/e_remainder.c
+++ b/lib/msun/src/e_remainder.c
@@ -1,5 +1,4 @@
-/* @(#)e_remainder.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* remainder(x,p)
* Return :
* returns x REM p = x - [x/p]*p as if in infinite
diff --git a/lib/msun/src/e_remainderf.c b/lib/msun/src/e_remainderf.c
index 053ae45c4a10..4a6ff6345fcd 100644
--- a/lib/msun/src/e_remainderf.c
+++ b/lib/msun/src/e_remainderf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_remainderl.c b/lib/msun/src/e_remainderl.c
index 4606cf874d75..7a681cdb1289 100644
--- a/lib/msun/src/e_remainderl.c
+++ b/lib/msun/src/e_remainderl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
long double
diff --git a/lib/msun/src/e_scalb.c b/lib/msun/src/e_scalb.c
index 8a38ddb68d81..28d2ae6ff477 100644
--- a/lib/msun/src/e_scalb.c
+++ b/lib/msun/src/e_scalb.c
@@ -1,5 +1,4 @@
-/* @(#)e_scalb.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* scalb(x, fn) is provide for
* passing various standard test suite. One
diff --git a/lib/msun/src/e_scalbf.c b/lib/msun/src/e_scalbf.c
index ca94a9fb1634..557a5a007053 100644
--- a/lib/msun/src/e_scalbf.c
+++ b/lib/msun/src/e_scalbf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_sinh.c b/lib/msun/src/e_sinh.c
index b19a4a2f7d48..5eec75e943e3 100644
--- a/lib/msun/src/e_sinh.c
+++ b/lib/msun/src/e_sinh.c
@@ -1,5 +1,4 @@
-/* @(#)e_sinh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* sinh(x)
* Method :
* mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
diff --git a/lib/msun/src/e_sinhf.c b/lib/msun/src/e_sinhf.c
index 7aa177b69f11..e9fe7320d449 100644
--- a/lib/msun/src/e_sinhf.c
+++ b/lib/msun/src/e_sinhf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_sinhl.c b/lib/msun/src/e_sinhl.c
index 121bace1d6c1..cf481b2abd96 100644
--- a/lib/msun/src/e_sinhl.c
+++ b/lib/msun/src/e_sinhl.c
@@ -11,7 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See e_sinh.c for complete comments.
*
diff --git a/lib/msun/src/e_sqrt.c b/lib/msun/src/e_sqrt.c
index ea588c97f5d1..97b778b980be 100644
--- a/lib/msun/src/e_sqrt.c
+++ b/lib/msun/src/e_sqrt.c
@@ -1,5 +1,4 @@
-/* @(#)e_sqrt.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/e_sqrtf.c b/lib/msun/src/e_sqrtf.c
index 1fd0cec447fb..f9e2a320f20e 100644
--- a/lib/msun/src/e_sqrtf.c
+++ b/lib/msun/src/e_sqrtf.c
@@ -13,10 +13,6 @@
* ====================================================
*/
-#ifndef lint
-static char rcsid[] = "$FreeBSD$";
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/e_sqrtl.c b/lib/msun/src/e_sqrtl.c
index beb4e7a9c948..a785536ea7e2 100644
--- a/lib/msun/src/e_sqrtl.c
+++ b/lib/msun/src/e_sqrtl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <float.h>
diff --git a/lib/msun/src/k_cos.c b/lib/msun/src/k_cos.c
index 8cc9a0e83efe..2eb5e040c6c9 100644
--- a/lib/msun/src/k_cos.c
+++ b/lib/msun/src/k_cos.c
@@ -1,5 +1,4 @@
-/* @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* __kernel_cos( x, y )
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
diff --git a/lib/msun/src/k_cosf.c b/lib/msun/src/k_cosf.c
index a93011b52c0d..934c1c7a785e 100644
--- a/lib/msun/src/k_cosf.c
+++ b/lib/msun/src/k_cosf.c
@@ -14,10 +14,6 @@
* ====================================================
*/
-#ifndef INLINE_KERNEL_COSDF
-#include <sys/cdefs.h>
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/k_exp.c b/lib/msun/src/k_exp.c
index ce8e3591827a..383616d64d55 100644
--- a/lib/msun/src/k_exp.c
+++ b/lib/msun/src/k_exp.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include "math.h"
diff --git a/lib/msun/src/k_expf.c b/lib/msun/src/k_expf.c
index 61478214e736..2af0c6dd3543 100644
--- a/lib/msun/src/k_expf.c
+++ b/lib/msun/src/k_expf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include "math.h"
diff --git a/lib/msun/src/k_log.h b/lib/msun/src/k_log.h
index f15227139324..da8f00802054 100644
--- a/lib/msun/src/k_log.h
+++ b/lib/msun/src/k_log.h
@@ -1,5 +1,4 @@
-/* @(#)e_log.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* k_log1p(f):
* Return log(1+f) - f for 1+f in ~[sqrt(2)/2, sqrt(2)].
diff --git a/lib/msun/src/k_logf.h b/lib/msun/src/k_logf.h
index 3f637cd6a9ec..72b675143d26 100644
--- a/lib/msun/src/k_logf.h
+++ b/lib/msun/src/k_logf.h
@@ -9,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* Float version of k_log.h. See the latter for most comments.
*/
diff --git a/lib/msun/src/k_rem_pio2.c b/lib/msun/src/k_rem_pio2.c
index 952bebb6ed2d..3d49d14db19d 100644
--- a/lib/msun/src/k_rem_pio2.c
+++ b/lib/msun/src/k_rem_pio2.c
@@ -1,5 +1,4 @@
-/* @(#)k_rem_pio2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* __kernel_rem_pio2(x,y,e0,nx,prec)
* double x[],y[]; int e0,nx,prec;
diff --git a/lib/msun/src/k_sin.c b/lib/msun/src/k_sin.c
index 6d24a0f21d92..5b97d86e1cf3 100644
--- a/lib/msun/src/k_sin.c
+++ b/lib/msun/src/k_sin.c
@@ -1,5 +1,4 @@
-/* @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* __kernel_sin( x, y, iy)
* kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
diff --git a/lib/msun/src/k_sincos.h b/lib/msun/src/k_sincos.h
index a29a57c06342..796e72af89e5 100644
--- a/lib/msun/src/k_sincos.h
+++ b/lib/msun/src/k_sincos.h
@@ -11,7 +11,6 @@
* k_sin.c and k_cos.c merged by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
static const double
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
diff --git a/lib/msun/src/k_sincosf.h b/lib/msun/src/k_sincosf.h
index 01f5d48b23ee..f031016b79d0 100644
--- a/lib/msun/src/k_sincosf.h
+++ b/lib/msun/src/k_sincosf.h
@@ -11,7 +11,6 @@
* k_sinf.c and k_cosf.c merged by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
diff --git a/lib/msun/src/k_sincosl.h b/lib/msun/src/k_sincosl.h
index 918d49f54f54..cf8536c8e27e 100644
--- a/lib/msun/src/k_sincosl.h
+++ b/lib/msun/src/k_sincosl.h
@@ -12,7 +12,6 @@
* k_sinl.c and k_cosl.c merged by Steven G. Kargl
*/
-#include <sys/cdefs.h>
#if LDBL_MANT_DIG == 64 /* ld80 version of k_sincosl.c. */
#if defined(__amd64__) || defined(__i386__)
diff --git a/lib/msun/src/k_sinf.c b/lib/msun/src/k_sinf.c
index ef547e36bf50..ebebd9663b10 100644
--- a/lib/msun/src/k_sinf.c
+++ b/lib/msun/src/k_sinf.c
@@ -14,10 +14,6 @@
* ====================================================
*/
-#ifndef INLINE_KERNEL_SINDF
-#include <sys/cdefs.h>
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/k_tan.c b/lib/msun/src/k_tan.c
index 5ebcddda09e6..92f30a6a6adf 100644
--- a/lib/msun/src/k_tan.c
+++ b/lib/msun/src/k_tan.c
@@ -1,5 +1,3 @@
-/* @(#)k_tan.c 1.5 04/04/22 SMI */
-
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
@@ -10,8 +8,6 @@
* ====================================================
*/
-/* INDENT OFF */
-#include <sys/cdefs.h>
/* __kernel_tan( x, y, k )
* kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
diff --git a/lib/msun/src/k_tanf.c b/lib/msun/src/k_tanf.c
index 6ab7be71e323..83bfad9bbb9a 100644
--- a/lib/msun/src/k_tanf.c
+++ b/lib/msun/src/k_tanf.c
@@ -13,10 +13,6 @@
* ====================================================
*/
-#ifndef INLINE_KERNEL_TANDF
-#include <sys/cdefs.h>
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
index 8e72beb757f8..aecc652ea08a 100644
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -10,7 +10,6 @@
*/
/*
- * from: @(#)fdlibm.h 5.1 93/09/24
*/
#ifndef _MATH_H_
@@ -33,13 +32,8 @@ extern const union __nan_un {
float __uf;
} __nan;
-#if __GNUC_PREREQ__(3, 3)
#define __MATH_BUILTIN_CONSTANTS
-#endif
-
-#if __GNUC_PREREQ__(3, 0)
#define __MATH_BUILTIN_RELOPS
-#endif
#ifdef __MATH_BUILTIN_CONSTANTS
#define HUGE_VAL __builtin_huge_val()
@@ -78,10 +72,10 @@ extern const union __nan_un {
#if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections)
#define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \
- float: f(x), \
- double: d(x), \
- long double: ld(x))
-#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
+ float: f, \
+ double: d, \
+ long double: ld)(x)
+#elif !defined(__cplusplus)
#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
__builtin_types_compatible_p(__typeof(x), long double), ld(x), \
__builtin_choose_expr( \
@@ -144,6 +138,22 @@ typedef __float_t float_t;
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
+#if __BSD_VISIBLE || __XSI_VISIBLE >= 800
+#define M_El 2.718281828459045235360287471352662498L /* e */
+#define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */
+#define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */
+#define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */
+#define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */
+#define M_PIl 3.141592653589793238462643383279502884L /* pi */
+#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
+#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
+#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
+#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
+#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
+#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
+#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
+#endif /* __BSD_VISIBLE || __XSI_VISIBLE >= 800 */
+
#define MAXFLOAT ((float)3.40282346638528860e+38)
extern int signgam;
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
@@ -183,21 +193,21 @@ int __signbitf(float) __pure2;
int __signbitl(long double) __pure2;
static __inline int
-__inline_isnan(__const double __x)
+__inline_isnan(const double __x)
{
return (__x != __x);
}
static __inline int
-__inline_isnanf(__const float __x)
+__inline_isnanf(const float __x)
{
return (__x != __x);
}
static __inline int
-__inline_isnanl(__const long double __x)
+__inline_isnanl(const long double __x)
{
return (__x != __x);
diff --git a/lib/msun/src/math_private.h b/lib/msun/src/math_private.h
index eae2a2a317b4..1595f902846c 100644
--- a/lib/msun/src/math_private.h
+++ b/lib/msun/src/math_private.h
@@ -10,7 +10,6 @@
*/
/*
- * from: @(#)fdlibm.h 5.1 93/09/24
*/
#ifndef _MATH_PRIVATE_H_
@@ -406,7 +405,7 @@ do { \
* any extra precision into the type of 'a' -- 'a' should have type float_t,
* double_t or long double. b's type should be no larger than 'a's type.
* Callers should use these types with scopes as large as possible, to
- * reduce their own extra-precision and efficiciency problems. In
+ * reduce their own extra-precision and efficiency problems. In
* particular, they shouldn't convert back and forth just to call here.
*/
#ifdef DEBUG
diff --git a/lib/msun/src/s_asinh.c b/lib/msun/src/s_asinh.c
index a8bad118f6b3..daebf2145960 100644
--- a/lib/msun/src/s_asinh.c
+++ b/lib/msun/src/s_asinh.c
@@ -1,4 +1,3 @@
-/* @(#)s_asinh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* asinh(x)
* Method :
* Based on
diff --git a/lib/msun/src/s_asinhf.c b/lib/msun/src/s_asinhf.c
index 822b0187ad09..4e622d5f6242 100644
--- a/lib/msun/src/s_asinhf.c
+++ b/lib/msun/src/s_asinhf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_asinhl.c b/lib/msun/src/s_asinhl.c
index d80405821ff4..b939fae8fbef 100644
--- a/lib/msun/src/s_asinhl.c
+++ b/lib/msun/src/s_asinhl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
-/* @(#)s_asinh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See s_asinh.c for complete comments.
*
diff --git a/lib/msun/src/s_atan.c b/lib/msun/src/s_atan.c
index d2bfacf52ab6..bff8b5cad9d0 100644
--- a/lib/msun/src/s_atan.c
+++ b/lib/msun/src/s_atan.c
@@ -1,4 +1,3 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* atan(x)
* Method
* 1. Reduce x to positive by atan(x) = -atan(-x).
diff --git a/lib/msun/src/s_atanf.c b/lib/msun/src/s_atanf.c
index 30666fe0b66a..2c38014ac6c8 100644
--- a/lib/msun/src/s_atanf.c
+++ b/lib/msun/src/s_atanf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_atanl.c b/lib/msun/src/s_atanl.c
index b85cb131035f..d9e617455499 100644
--- a/lib/msun/src/s_atanl.c
+++ b/lib/msun/src/s_atanl.c
@@ -1,4 +1,3 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
/* FreeBSD: head/lib/msun/src/s_atan.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -11,7 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See comments in s_atan.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/lib/msun/src/s_carg.c b/lib/msun/src/s_carg.c
index 45714bbdb18a..ea7edfdf0835 100644
--- a/lib/msun/src/s_carg.c
+++ b/lib/msun/src/s_carg.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_cargf.c b/lib/msun/src/s_cargf.c
index c4d53006b542..25ab65ef7f9f 100644
--- a/lib/msun/src/s_cargf.c
+++ b/lib/msun/src/s_cargf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_cargl.c b/lib/msun/src/s_cargl.c
index d7f8206e9608..8a1a108705d4 100644
--- a/lib/msun/src/s_cargl.c
+++ b/lib/msun/src/s_cargl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_cbrt.c b/lib/msun/src/s_cbrt.c
index afb601bf0fb6..568a36545216 100644
--- a/lib/msun/src/s_cbrt.c
+++ b/lib/msun/src/s_cbrt.c
@@ -1,4 +1,3 @@
-/* @(#)s_cbrt.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
#include "math_private.h"
@@ -92,7 +90,7 @@ cbrt(double x)
* the result is larger in magnitude than cbrt(x) but not much more than
* 2 23-bit ulps larger). With rounding towards zero, the error bound
* would be ~5/6 instead of ~4/6. With a maximum error of 2 23-bit ulps
- * in the rounded t, the infinite-precision error in the Newton
+ * in the rounded t, the infinite-precision error in the Halley
* approximation barely affects third digit in the final error
* 0.667; the error in the rounded t can be up to about 3 23-bit ulps
* before the final error is larger than 0.667 ulps.
@@ -101,7 +99,7 @@ cbrt(double x)
u.bits=(u.bits+0x80000000)&0xffffffffc0000000ULL;
t=u.value;
- /* one step Newton iteration to 53 bits with error < 0.667 ulps */
+ /* one step Halley iteration to 53 bits with error < 0.667 ulps */
s=t*t; /* t*t is exact */
r=x/s; /* error <= 0.5 ulps; |r| < |t| */
w=t+t; /* t+t is exact */
diff --git a/lib/msun/src/s_cbrtf.c b/lib/msun/src/s_cbrtf.c
index f013e1f1eb6f..c69e0fa5be12 100644
--- a/lib/msun/src/s_cbrtf.c
+++ b/lib/msun/src/s_cbrtf.c
@@ -14,7 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
@@ -51,7 +50,7 @@ cbrtf(float x)
SET_FLOAT_WORD(t,sign|(hx/3+B1));
/*
- * First step Newton iteration (solving t*t-x/t == 0) to 16 bits. In
+ * First step Halley iteration (solving t*t-x/t == 0) to 16 bits. In
* double precision so that its terms can be arranged for efficiency
* without causing overflow or underflow.
*/
@@ -60,7 +59,7 @@ cbrtf(float x)
T=T*((double)x+x+r)/(x+r+r);
/*
- * Second step Newton iteration to 47 bits. In double precision for
+ * Second step Halley iteration to 47 bits. In double precision for
* efficiency and accuracy.
*/
r=T*T*T;
diff --git a/lib/msun/src/s_cbrtl.c b/lib/msun/src/s_cbrtl.c
index 3ed939cccf92..ff527cc5e5e7 100644
--- a/lib/msun/src/s_cbrtl.c
+++ b/lib/msun/src/s_cbrtl.c
@@ -14,7 +14,6 @@
* and David A. Schultz.
*/
-#include <sys/cdefs.h>
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
@@ -127,7 +126,7 @@ cbrtl(long double x)
#endif
/*
- * Final step Newton iteration to 64 or 113 bits with
+ * Final step Halley iteration to 64 or 113 bits with
* error < 0.667 ulps
*/
s=t*t; /* t*t is exact */
diff --git a/lib/msun/src/s_ccosh.c b/lib/msun/src/s_ccosh.c
index 95ed3a32ddd7..3d46c993c6f1 100644
--- a/lib/msun/src/s_ccosh.c
+++ b/lib/msun/src/s_ccosh.c
@@ -38,7 +38,6 @@
* must satisfy both cosh(conj(z)) == conj(cosh(z)) and cosh(-z) == cosh(z).
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_ccoshf.c b/lib/msun/src/s_ccoshf.c
index ba97a390c832..aeb2dec23677 100644
--- a/lib/msun/src/s_ccoshf.c
+++ b/lib/msun/src/s_ccoshf.c
@@ -30,7 +30,6 @@
* Float version of ccosh(). See s_ccosh.c for details.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_ceil.c b/lib/msun/src/s_ceil.c
index 9c041b2a94e1..e6699bcb52d0 100644
--- a/lib/msun/src/s_ceil.c
+++ b/lib/msun/src/s_ceil.c
@@ -1,4 +1,3 @@
-/* @(#)s_ceil.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* ceil(x)
* Return x rounded toward -inf to integral value
diff --git a/lib/msun/src/s_ceilf.c b/lib/msun/src/s_ceilf.c
index 3cb0e11688bf..cc19afa9dd96 100644
--- a/lib/msun/src/s_ceilf.c
+++ b/lib/msun/src/s_ceilf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_ceill.c b/lib/msun/src/s_ceill.c
index 28c0881e8da6..ded36c1ebe1b 100644
--- a/lib/msun/src/s_ceill.c
+++ b/lib/msun/src/s_ceill.c
@@ -7,11 +7,8 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * From: @(#)s_ceil.c 5.1 93/09/24
*/
-#include <sys/cdefs.h>
/*
* ceill(x)
* Return x rounded toward -inf to integral value
diff --git a/lib/msun/src/s_cexp.c b/lib/msun/src/s_cexp.c
index 056d273f6932..0151768473c7 100644
--- a/lib/msun/src/s_cexp.c
+++ b/lib/msun/src/s_cexp.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_cexpf.c b/lib/msun/src/s_cexpf.c
index 872e9253daa5..a6c0c995cf5e 100644
--- a/lib/msun/src/s_cexpf.c
+++ b/lib/msun/src/s_cexpf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_clog.c b/lib/msun/src/s_clog.c
index e51ff5230e45..2129890f43de 100644
--- a/lib/msun/src/s_clog.c
+++ b/lib/msun/src/s_clog.c
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
diff --git a/lib/msun/src/s_clogf.c b/lib/msun/src/s_clogf.c
index 761f91b12efa..2204e1e59bb6 100644
--- a/lib/msun/src/s_clogf.c
+++ b/lib/msun/src/s_clogf.c
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
diff --git a/lib/msun/src/s_clogl.c b/lib/msun/src/s_clogl.c
index 78244961df5c..075bdb49f851 100644
--- a/lib/msun/src/s_clogl.c
+++ b/lib/msun/src/s_clogl.c
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#ifdef __i386__
diff --git a/lib/msun/src/s_copysign.c b/lib/msun/src/s_copysign.c
index 2a9923a2480a..8d913a37a6d7 100644
--- a/lib/msun/src/s_copysign.c
+++ b/lib/msun/src/s_copysign.c
@@ -1,4 +1,3 @@
-/* @(#)s_copysign.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* copysign(double x, double y)
* copysign(x,y) returns a value with the magnitude of x and
diff --git a/lib/msun/src/s_copysignf.c b/lib/msun/src/s_copysignf.c
index a35b07ccbb5b..68964e509b6c 100644
--- a/lib/msun/src/s_copysignf.c
+++ b/lib/msun/src/s_copysignf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* copysignf(float x, float y)
* copysignf(x,y) returns a value with the magnitude of x and
diff --git a/lib/msun/src/s_cos.c b/lib/msun/src/s_cos.c
index 97f72a15ce4d..44ecad9394f7 100644
--- a/lib/msun/src/s_cos.c
+++ b/lib/msun/src/s_cos.c
@@ -1,4 +1,3 @@
-/* @(#)s_cos.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* cos(x)
* Return cosine function of x.
*
diff --git a/lib/msun/src/s_cosf.c b/lib/msun/src/s_cosf.c
index a0ba8598f7e6..6fc53f7b874f 100644
--- a/lib/msun/src/s_cosf.c
+++ b/lib/msun/src/s_cosf.c
@@ -14,7 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_cosl.c b/lib/msun/src/s_cosl.c
index 00c24ce13d12..32fc8b26a206 100644
--- a/lib/msun/src/s_cosl.c
+++ b/lib/msun/src/s_cosl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/*
* Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows
* an accuracy of <= 0.7412 ULP.
diff --git a/lib/msun/src/s_cpow.c b/lib/msun/src/s_cpow.c
index 735d38956380..b887db51aa2a 100644
--- a/lib/msun/src/s_cpow.c
+++ b/lib/msun/src/s_cpow.c
@@ -43,7 +43,6 @@
*
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_cpowf.c b/lib/msun/src/s_cpowf.c
index aefcd7619de1..144291079f97 100644
--- a/lib/msun/src/s_cpowf.c
+++ b/lib/msun/src/s_cpowf.c
@@ -43,7 +43,6 @@
*
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
#include "math_private.h"
diff --git a/lib/msun/src/s_cpowl.c b/lib/msun/src/s_cpowl.c
index 342dfcff8481..39797cadcfcb 100644
--- a/lib/msun/src/s_cpowl.c
+++ b/lib/msun/src/s_cpowl.c
@@ -43,7 +43,6 @@
*
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
#include "math_private.h"
diff --git a/lib/msun/src/s_cproj.c b/lib/msun/src/s_cproj.c
index 75cb083baf17..9eebb450ae11 100644
--- a/lib/msun/src/s_cproj.c
+++ b/lib/msun/src/s_cproj.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_cprojf.c b/lib/msun/src/s_cprojf.c
index aadc5ef35cbd..13d90ba6fb5e 100644
--- a/lib/msun/src/s_cprojf.c
+++ b/lib/msun/src/s_cprojf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_cprojl.c b/lib/msun/src/s_cprojl.c
index 78e3e9a6fdca..083b5fa1c8f3 100644
--- a/lib/msun/src/s_cprojl.c
+++ b/lib/msun/src/s_cprojl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_csinh.c b/lib/msun/src/s_csinh.c
index 1bd78b1e49bf..e7ed10e7d885 100644
--- a/lib/msun/src/s_csinh.c
+++ b/lib/msun/src/s_csinh.c
@@ -38,7 +38,6 @@
* must satisfy both sinh(conj(z)) == conj(sinh(z)) and sinh(-z) == -sinh(z).
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_csinhf.c b/lib/msun/src/s_csinhf.c
index b1f333955e53..c4392755c482 100644
--- a/lib/msun/src/s_csinhf.c
+++ b/lib/msun/src/s_csinhf.c
@@ -30,7 +30,6 @@
* Float version of csinh(). See s_csinh.c for details.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_csqrt.c b/lib/msun/src/s_csqrt.c
index afac4db17b61..c40b5a6de907 100644
--- a/lib/msun/src/s_csqrt.c
+++ b/lib/msun/src/s_csqrt.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_csqrtf.c b/lib/msun/src/s_csqrtf.c
index ece9f6c13657..b57245166078 100644
--- a/lib/msun/src/s_csqrtf.c
+++ b/lib/msun/src/s_csqrtf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_csqrtl.c b/lib/msun/src/s_csqrtl.c
index b0fc37c902f1..0f375f3c2349 100644
--- a/lib/msun/src/s_csqrtl.c
+++ b/lib/msun/src/s_csqrtl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_ctanh.c b/lib/msun/src/s_ctanh.c
index 33186510a8a3..690436343437 100644
--- a/lib/msun/src/s_ctanh.c
+++ b/lib/msun/src/s_ctanh.c
@@ -65,7 +65,6 @@
* precision. I also handle large x differently.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_ctanhf.c b/lib/msun/src/s_ctanhf.c
index c2fb2f8618f6..551e143a3d27 100644
--- a/lib/msun/src/s_ctanhf.c
+++ b/lib/msun/src/s_ctanhf.c
@@ -30,7 +30,6 @@
* Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/src/s_erf.c b/lib/msun/src/s_erf.c
index 6fc9e56d11af..a9de12274b50 100644
--- a/lib/msun/src/s_erf.c
+++ b/lib/msun/src/s_erf.c
@@ -1,4 +1,3 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* double erf(double x)
* double erfc(double x)
* x
diff --git a/lib/msun/src/s_erff.c b/lib/msun/src/s_erff.c
index bf011b312bfb..6c8f4060c802 100644
--- a/lib/msun/src/s_erff.c
+++ b/lib/msun/src/s_erff.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_exp2.c b/lib/msun/src/s_exp2.c
index 5bf9d65975e0..2064d22f44f3 100644
--- a/lib/msun/src/s_exp2.c
+++ b/lib/msun/src/s_exp2.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
@@ -315,7 +314,7 @@ static const double tbl[TBLSIZE * 2] = {
* Method: (accurate tables)
*
* Reduce x:
- * x = 2**k + y, for integer k and |y| <= 1/2.
+ * x = k + y, for integer k and |y| <= 1/2.
* Thus we have exp2(x) = 2**k * exp2(y).
*
* Reduce y:
diff --git a/lib/msun/src/s_exp2f.c b/lib/msun/src/s_exp2f.c
index f94cfaf9ce96..c863b7512194 100644
--- a/lib/msun/src/s_exp2f.c
+++ b/lib/msun/src/s_exp2f.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
@@ -73,7 +72,7 @@ static const double exp2ft[TBLSIZE] = {
* Method: (equally-spaced tables)
*
* Reduce x:
- * x = 2**k + y, for integer k and |y| <= 1/2.
+ * x = k + y, for integer k and |y| <= 1/2.
* Thus we have exp2f(x) = 2**k * exp2(y).
*
* Reduce y:
diff --git a/lib/msun/src/s_expm1.c b/lib/msun/src/s_expm1.c
index 154a5d8148a5..cdc225e8c001 100644
--- a/lib/msun/src/s_expm1.c
+++ b/lib/msun/src/s_expm1.c
@@ -1,4 +1,3 @@
-/* @(#)s_expm1.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* expm1(x)
* Returns exp(x)-1, the exponential of x minus 1.
*
diff --git a/lib/msun/src/s_expm1f.c b/lib/msun/src/s_expm1f.c
index 831c0caa6db8..6887bf265272 100644
--- a/lib/msun/src/s_expm1f.c
+++ b/lib/msun/src/s_expm1f.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_fabs.c b/lib/msun/src/s_fabs.c
index ec071d481ac6..1f1ce64a8a1c 100644
--- a/lib/msun/src/s_fabs.c
+++ b/lib/msun/src/s_fabs.c
@@ -1,4 +1,3 @@
-/* @(#)s_fabs.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* fabs(x) returns the absolute value of x.
*/
diff --git a/lib/msun/src/s_fabsf.c b/lib/msun/src/s_fabsf.c
index 501676253385..66d09534dbc5 100644
--- a/lib/msun/src/s_fabsf.c
+++ b/lib/msun/src/s_fabsf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* fabsf(x) returns the absolute value of x.
*/
diff --git a/lib/msun/src/s_fdim.c b/lib/msun/src/s_fdim.c
index 580ab4605f92..4f56ee4b3482 100644
--- a/lib/msun/src/s_fdim.c
+++ b/lib/msun/src/s_fdim.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#define DECL(type, fn) \
diff --git a/lib/msun/src/s_finite.c b/lib/msun/src/s_finite.c
index c6b1cfa6d111..a3fd5994c100 100644
--- a/lib/msun/src/s_finite.c
+++ b/lib/msun/src/s_finite.c
@@ -1,4 +1,3 @@
-/* @(#)s_finite.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* finite(x) returns 1 is x is finite, else 0;
* no branching!
diff --git a/lib/msun/src/s_finitef.c b/lib/msun/src/s_finitef.c
index 94e527257c06..9a4a876a791f 100644
--- a/lib/msun/src/s_finitef.c
+++ b/lib/msun/src/s_finitef.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* finitef(x) returns 1 is x is finite, else 0;
* no branching!
diff --git a/lib/msun/src/s_floor.c b/lib/msun/src/s_floor.c
index 1746cf27f016..7ca65b1ebfb7 100644
--- a/lib/msun/src/s_floor.c
+++ b/lib/msun/src/s_floor.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* floor(x)
* Return x rounded toward -inf to integral value
diff --git a/lib/msun/src/s_floorf.c b/lib/msun/src/s_floorf.c
index 145a50321046..d49715781428 100644
--- a/lib/msun/src/s_floorf.c
+++ b/lib/msun/src/s_floorf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* floorf(x)
* Return x rounded toward -inf to integral value
diff --git a/lib/msun/src/s_floorl.c b/lib/msun/src/s_floorl.c
index ee9a391ffe41..3b54cabe7237 100644
--- a/lib/msun/src/s_floorl.c
+++ b/lib/msun/src/s_floorl.c
@@ -7,11 +7,8 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * From: @(#)s_floor.c 5.1 93/09/24
*/
-#include <sys/cdefs.h>
/*
* floorl(x)
* Return x rounded toward -inf to integral value
diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c
index 0788bb2d47e8..23a84491dd2a 100644
--- a/lib/msun/src/s_fma.c
+++ b/lib/msun/src/s_fma.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
@@ -223,17 +222,17 @@ fma(double x, double y, double z)
case FE_TONEAREST:
return (z);
case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
+ if ((x > 0.0) ^ (y < 0.0) ^ (z < 0.0))
return (z);
else
return (nextafter(z, 0));
case FE_DOWNWARD:
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (z);
else
return (nextafter(z, -INFINITY));
default: /* FE_UPWARD */
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (nextafter(z, INFINITY));
else
return (z);
@@ -245,7 +244,7 @@ fma(double x, double y, double z)
zs = copysign(DBL_MIN, zs);
fesetround(FE_TONEAREST);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile double vxs = xs;
/*
@@ -261,14 +260,14 @@ fma(double x, double y, double z)
spread = ex + ey;
- if (r.hi == 0.0) {
+ if (r.hi == 0.0 && xy.lo == 0) {
/*
* When the addends cancel to 0, ensure that the result has
* the correct sign.
*/
fesetround(oround);
volatile double vzs = zs; /* XXX gcc CSE bug workaround */
- return (xy.hi + vzs + ldexp(xy.lo, spread));
+ return (xy.hi + vzs);
}
if (oround != FE_TONEAREST) {
@@ -277,7 +276,7 @@ fma(double x, double y, double z)
* rounding modes.
*/
fesetround(oround);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile double vrlo = r.lo;
adj = vrlo + xy.lo;
return (ldexp(r.hi + adj, spread));
diff --git a/lib/msun/src/s_fmaf.c b/lib/msun/src/s_fmaf.c
index c433f523fe08..5f3d5d1b1b99 100644
--- a/lib/msun/src/s_fmaf.c
+++ b/lib/msun/src/s_fmaf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include "math.h"
diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c
index 0d5e2c0bc98f..2fca20610157 100644
--- a/lib/msun/src/s_fmal.c
+++ b/lib/msun/src/s_fmal.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
@@ -204,17 +203,17 @@ fmal(long double x, long double y, long double z)
case FE_TONEAREST:
return (z);
case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
+ if ((x > 0.0) ^ (y < 0.0) ^ (z < 0.0))
return (z);
else
return (nextafterl(z, 0));
case FE_DOWNWARD:
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (z);
else
return (nextafterl(z, -INFINITY));
default: /* FE_UPWARD */
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (nextafterl(z, INFINITY));
else
return (z);
@@ -226,7 +225,7 @@ fmal(long double x, long double y, long double z)
zs = copysignl(LDBL_MIN, zs);
fesetround(FE_TONEAREST);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile long double vxs = xs;
/*
@@ -242,14 +241,14 @@ fmal(long double x, long double y, long double z)
spread = ex + ey;
- if (r.hi == 0.0) {
+ if (r.hi == 0.0 && xy.lo == 0) {
/*
* When the addends cancel to 0, ensure that the result has
* the correct sign.
*/
fesetround(oround);
volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
- return (xy.hi + vzs + ldexpl(xy.lo, spread));
+ return (xy.hi + vzs);
}
if (oround != FE_TONEAREST) {
@@ -258,7 +257,7 @@ fmal(long double x, long double y, long double z)
* rounding modes.
*/
fesetround(oround);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile long double vrlo = r.lo;
adj = vrlo + xy.lo;
return (ldexpl(r.hi + adj, spread));
diff --git a/lib/msun/src/s_fmax.c b/lib/msun/src/s_fmax.c
index aca4e0585cdd..5d437fcefc9b 100644
--- a/lib/msun/src/s_fmax.c
+++ b/lib/msun/src/s_fmax.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_fmaxf.c b/lib/msun/src/s_fmaxf.c
index 8684fb6bb68c..1572572e43a6 100644
--- a/lib/msun/src/s_fmaxf.c
+++ b/lib/msun/src/s_fmaxf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#include "fpmath.h"
diff --git a/lib/msun/src/s_fmaxl.c b/lib/msun/src/s_fmaxl.c
index d0c1a806bdaf..73e2a4bb19fd 100644
--- a/lib/msun/src/s_fmaxl.c
+++ b/lib/msun/src/s_fmaxl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#include "fpmath.h"
diff --git a/lib/msun/src/s_fmin.c b/lib/msun/src/s_fmin.c
index aa67d161ec34..a349e5ddaf0e 100644
--- a/lib/msun/src/s_fmin.c
+++ b/lib/msun/src/s_fmin.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_fminf.c b/lib/msun/src/s_fminf.c
index 01e52d9becdc..5c2537e32d25 100644
--- a/lib/msun/src/s_fminf.c
+++ b/lib/msun/src/s_fminf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#include "fpmath.h"
diff --git a/lib/msun/src/s_fminl.c b/lib/msun/src/s_fminl.c
index f79a08d6c774..7ac17e313440 100644
--- a/lib/msun/src/s_fminl.c
+++ b/lib/msun/src/s_fminl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#include "fpmath.h"
diff --git a/lib/msun/src/s_frexp.c b/lib/msun/src/s_frexp.c
index ee234d247300..90aea67e06e3 100644
--- a/lib/msun/src/s_frexp.c
+++ b/lib/msun/src/s_frexp.c
@@ -1,4 +1,3 @@
-/* @(#)s_frexp.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* for non-zero x
* x = frexp(arg,&exp);
diff --git a/lib/msun/src/s_frexpf.c b/lib/msun/src/s_frexpf.c
index 6b39e6ff8b2b..bca27b5147d8 100644
--- a/lib/msun/src/s_frexpf.c
+++ b/lib/msun/src/s_frexpf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_ilogb.c b/lib/msun/src/s_ilogb.c
index 0b076edbd9b5..27e0bbb8735b 100644
--- a/lib/msun/src/s_ilogb.c
+++ b/lib/msun/src/s_ilogb.c
@@ -1,4 +1,3 @@
-/* @(#)s_ilogb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* ilogb(double x)
* return the binary exponent of non-zero x
* ilogb(0) = FP_ILOGB0
diff --git a/lib/msun/src/s_ilogbf.c b/lib/msun/src/s_ilogbf.c
index ff3df1fc5b90..e0f8fee26ac8 100644
--- a/lib/msun/src/s_ilogbf.c
+++ b/lib/msun/src/s_ilogbf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <limits.h>
#include "math.h"
diff --git a/lib/msun/src/s_ilogbl.c b/lib/msun/src/s_ilogbl.c
index f45cd7b67159..4d8fb8fa3cde 100644
--- a/lib/msun/src/s_ilogbl.c
+++ b/lib/msun/src/s_ilogbl.c
@@ -1,5 +1,4 @@
/*
- * From: @(#)s_ilogb.c 5.1 93/09/24
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/lib/msun/src/s_llrint.c b/lib/msun/src/s_llrint.c
index 460c4a07d5e3..5e2760381b8c 100644
--- a/lib/msun/src/s_llrint.c
+++ b/lib/msun/src/s_llrint.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type double
#define roundit rint
#define dtype long long
diff --git a/lib/msun/src/s_llrintf.c b/lib/msun/src/s_llrintf.c
index 3ed16799f47f..b117f7c99dbc 100644
--- a/lib/msun/src/s_llrintf.c
+++ b/lib/msun/src/s_llrintf.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type float
#define roundit rintf
#define dtype long long
diff --git a/lib/msun/src/s_llrintl.c b/lib/msun/src/s_llrintl.c
index fed23f32fd6f..82f4529dc815 100644
--- a/lib/msun/src/s_llrintl.c
+++ b/lib/msun/src/s_llrintl.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type long double
#define roundit rintl
#define dtype long long
diff --git a/lib/msun/src/s_llround.c b/lib/msun/src/s_llround.c
index f8e76134b654..3983ce1edfca 100644
--- a/lib/msun/src/s_llround.c
+++ b/lib/msun/src/s_llround.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type double
#define roundit round
#define dtype long long
diff --git a/lib/msun/src/s_llroundf.c b/lib/msun/src/s_llroundf.c
index 753fd96265aa..827d915ded9b 100644
--- a/lib/msun/src/s_llroundf.c
+++ b/lib/msun/src/s_llroundf.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type float
#define roundit roundf
#define dtype long long
diff --git a/lib/msun/src/s_llroundl.c b/lib/msun/src/s_llroundl.c
index b5a97d97f2ae..40cad84c56f5 100644
--- a/lib/msun/src/s_llroundl.c
+++ b/lib/msun/src/s_llroundl.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type long double
#define roundit roundl
#define dtype long long
diff --git a/lib/msun/src/s_log1p.c b/lib/msun/src/s_log1p.c
index 61b03f00f33b..7131beac1f3a 100644
--- a/lib/msun/src/s_log1p.c
+++ b/lib/msun/src/s_log1p.c
@@ -1,4 +1,3 @@
-/* @(#)s_log1p.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* double log1p(double x)
*
* Method :
diff --git a/lib/msun/src/s_log1pf.c b/lib/msun/src/s_log1pf.c
index d53fc7144e1d..dad567b58573 100644
--- a/lib/msun/src/s_log1pf.c
+++ b/lib/msun/src/s_log1pf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_logb.c b/lib/msun/src/s_logb.c
index b5ffff4fd11a..ec777fd26277 100644
--- a/lib/msun/src/s_logb.c
+++ b/lib/msun/src/s_logb.c
@@ -1,4 +1,3 @@
-/* @(#)s_logb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* double logb(x)
* IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
diff --git a/lib/msun/src/s_logbf.c b/lib/msun/src/s_logbf.c
index 658c7d3a15c3..0416a9c4d101 100644
--- a/lib/msun/src/s_logbf.c
+++ b/lib/msun/src/s_logbf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_logbl.c b/lib/msun/src/s_logbl.c
index 280c302ac014..1641dfb1a951 100644
--- a/lib/msun/src/s_logbl.c
+++ b/lib/msun/src/s_logbl.c
@@ -1,5 +1,4 @@
/*
- * From: @(#)s_ilogb.c 5.1 93/09/24
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/lib/msun/src/s_lrint.c b/lib/msun/src/s_lrint.c
index f4e56ac34b69..b1e96546db52 100644
--- a/lib/msun/src/s_lrint.c
+++ b/lib/msun/src/s_lrint.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <math.h>
diff --git a/lib/msun/src/s_lrintf.c b/lib/msun/src/s_lrintf.c
index ca7cb99a3cf2..1c040e8d882b 100644
--- a/lib/msun/src/s_lrintf.c
+++ b/lib/msun/src/s_lrintf.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type float
#define roundit rintf
#define dtype long
diff --git a/lib/msun/src/s_lrintl.c b/lib/msun/src/s_lrintl.c
index 7eedbc707c6e..91614e8ad264 100644
--- a/lib/msun/src/s_lrintl.c
+++ b/lib/msun/src/s_lrintl.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type long double
#define roundit rintl
#define dtype long
diff --git a/lib/msun/src/s_lround.c b/lib/msun/src/s_lround.c
index 0b305918adc3..ae2f5ce7136a 100644
--- a/lib/msun/src/s_lround.c
+++ b/lib/msun/src/s_lround.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/limits.h>
#include <fenv.h>
#include <math.h>
diff --git a/lib/msun/src/s_lroundf.c b/lib/msun/src/s_lroundf.c
index e27e6a2fe187..86e63cc1d05c 100644
--- a/lib/msun/src/s_lroundf.c
+++ b/lib/msun/src/s_lroundf.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type float
#define roundit roundf
#define dtype long
diff --git a/lib/msun/src/s_lroundl.c b/lib/msun/src/s_lroundl.c
index cfd43bc7fbf1..57a2e90fc48e 100644
--- a/lib/msun/src/s_lroundl.c
+++ b/lib/msun/src/s_lroundl.c
@@ -1,4 +1,3 @@
-#include <sys/cdefs.h>
#define type long double
#define roundit roundl
#define dtype long
diff --git a/lib/msun/src/s_modf.c b/lib/msun/src/s_modf.c
index ab13191b9004..6ee2d5a0c112 100644
--- a/lib/msun/src/s_modf.c
+++ b/lib/msun/src/s_modf.c
@@ -1,4 +1,3 @@
-/* @(#)s_modf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#ifndef lint
-static char rcsid[] = "$FreeBSD$";
-#endif
-
/*
* modf(double x, double *iptr)
* return fraction part of x, and return x's integral part in *iptr.
diff --git a/lib/msun/src/s_modff.c b/lib/msun/src/s_modff.c
index 57f59117a878..39f6c1c9f917 100644
--- a/lib/msun/src/s_modff.c
+++ b/lib/msun/src/s_modff.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_nearbyint.c b/lib/msun/src/s_nearbyint.c
index 96604594c499..3dcaf98b369a 100644
--- a/lib/msun/src/s_nearbyint.c
+++ b/lib/msun/src/s_nearbyint.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <math.h>
diff --git a/lib/msun/src/s_nextafter.c b/lib/msun/src/s_nextafter.c
index 99c65b11aeba..1b394e5109c2 100644
--- a/lib/msun/src/s_nextafter.c
+++ b/lib/msun/src/s_nextafter.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
diff --git a/lib/msun/src/s_nextafterf.c b/lib/msun/src/s_nextafterf.c
index 18e046324957..418b126a27ab 100644
--- a/lib/msun/src/s_nextafterf.c
+++ b/lib/msun/src/s_nextafterf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_nextafterl.c b/lib/msun/src/s_nextafterl.c
index 168dbb4ed093..fe5a010e89f5 100644
--- a/lib/msun/src/s_nextafterl.c
+++ b/lib/msun/src/s_nextafterl.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
diff --git a/lib/msun/src/s_nexttoward.c b/lib/msun/src/s_nexttoward.c
index d876ba2bfebc..5482dc21606d 100644
--- a/lib/msun/src/s_nexttoward.c
+++ b/lib/msun/src/s_nexttoward.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* We assume that a long double has a 15-bit exponent. On systems
* where long double is the same as double, nexttoward() is an alias
diff --git a/lib/msun/src/s_nexttowardf.c b/lib/msun/src/s_nexttowardf.c
index 03d8cc5e4729..05c89f4554ec 100644
--- a/lib/msun/src/s_nexttowardf.c
+++ b/lib/msun/src/s_nexttowardf.c
@@ -9,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "fpmath.h"
diff --git a/lib/msun/src/s_remquo.c b/lib/msun/src/s_remquo.c
index e3aac25230e0..206d2903cd86 100644
--- a/lib/msun/src/s_remquo.c
+++ b/lib/msun/src/s_remquo.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_remquof.c b/lib/msun/src/s_remquof.c
index c42bd8c4320d..9cd148586796 100644
--- a/lib/msun/src/s_remquof.c
+++ b/lib/msun/src/s_remquof.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_remquol.c b/lib/msun/src/s_remquol.c
index a0f93d4fcae0..0dadceaf5aa7 100644
--- a/lib/msun/src/s_remquol.c
+++ b/lib/msun/src/s_remquol.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <stdint.h>
diff --git a/lib/msun/src/s_rint.c b/lib/msun/src/s_rint.c
index 96faf6a007ee..d82a9d0abb69 100644
--- a/lib/msun/src/s_rint.c
+++ b/lib/msun/src/s_rint.c
@@ -1,4 +1,3 @@
-/* @(#)s_rint.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* rint(x)
* Return x rounded to integral value according to the prevailing
diff --git a/lib/msun/src/s_rintf.c b/lib/msun/src/s_rintf.c
index 328738f0ba0c..3f0cb906ae85 100644
--- a/lib/msun/src/s_rintf.c
+++ b/lib/msun/src/s_rintf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <stdint.h>
diff --git a/lib/msun/src/s_rintl.c b/lib/msun/src/s_rintl.c
index 15bce02e219d..72c9cabd1a91 100644
--- a/lib/msun/src/s_rintl.c
+++ b/lib/msun/src/s_rintl.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/s_round.c b/lib/msun/src/s_round.c
index 04d49c220973..c1b55f58765e 100644
--- a/lib/msun/src/s_round.c
+++ b/lib/msun/src/s_round.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_roundf.c b/lib/msun/src/s_roundf.c
index 795d88df3050..7c09e090ff9a 100644
--- a/lib/msun/src/s_roundf.c
+++ b/lib/msun/src/s_roundf.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_roundl.c b/lib/msun/src/s_roundl.c
index 05cb3e9f4918..bc5dfe550165 100644
--- a/lib/msun/src/s_roundl.c
+++ b/lib/msun/src/s_roundl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/lib/msun/src/s_scalbln.c b/lib/msun/src/s_scalbln.c
index ff402b0f8fab..42e4669b3986 100644
--- a/lib/msun/src/s_scalbln.c
+++ b/lib/msun/src/s_scalbln.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
#define NMAX 65536
diff --git a/lib/msun/src/s_significand.c b/lib/msun/src/s_significand.c
index 29ff0cc29807..62571bb464dd 100644
--- a/lib/msun/src/s_significand.c
+++ b/lib/msun/src/s_significand.c
@@ -1,4 +1,3 @@
-/* @(#)s_signif.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* significand(x) computes just
* scalb(x, (double) -ilogb(x)),
diff --git a/lib/msun/src/s_significandf.c b/lib/msun/src/s_significandf.c
index 9fd919d65a91..3cdaa4daa753 100644
--- a/lib/msun/src/s_significandf.c
+++ b/lib/msun/src/s_significandf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_sin.c b/lib/msun/src/s_sin.c
index e9cd928d300b..614bcc2056f3 100644
--- a/lib/msun/src/s_sin.c
+++ b/lib/msun/src/s_sin.c
@@ -1,4 +1,3 @@
-/* @(#)s_sin.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* sin(x)
* Return sine function of x.
*
diff --git a/lib/msun/src/s_sincos.c b/lib/msun/src/s_sincos.c
index 028ce416280a..4e819ea89128 100644
--- a/lib/msun/src/s_sincos.c
+++ b/lib/msun/src/s_sincos.c
@@ -12,7 +12,6 @@
* algorithms are contained in the original files.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_sincosf.c b/lib/msun/src/s_sincosf.c
index ee9f03444944..eaf7be84ee35 100644
--- a/lib/msun/src/s_sincosf.c
+++ b/lib/msun/src/s_sincosf.c
@@ -15,7 +15,6 @@
* Merged s_sinf.c and s_cosf.c by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_sincosl.c b/lib/msun/src/s_sincosl.c
index 2d3833c93d46..7fb69aa4d4dd 100644
--- a/lib/msun/src/s_sincosl.c
+++ b/lib/msun/src/s_sincosl.c
@@ -26,7 +26,6 @@
* s_sinl.c and s_cosl.c merged by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/lib/msun/src/s_sinf.c b/lib/msun/src/s_sinf.c
index 9837e80bb6ff..85fb11540a7d 100644
--- a/lib/msun/src/s_sinf.c
+++ b/lib/msun/src/s_sinf.c
@@ -14,7 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_sinl.c b/lib/msun/src/s_sinl.c
index 605a4b4b6272..d0b7b34718f8 100644
--- a/lib/msun/src/s_sinl.c
+++ b/lib/msun/src/s_sinl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/lib/msun/src/s_tan.c b/lib/msun/src/s_tan.c
index be5154e89468..20b95163e4a7 100644
--- a/lib/msun/src/s_tan.c
+++ b/lib/msun/src/s_tan.c
@@ -1,4 +1,3 @@
-/* @(#)s_tan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* tan(x)
* Return tangent function of x.
*
diff --git a/lib/msun/src/s_tanf.c b/lib/msun/src/s_tanf.c
index 1b72cd6cae91..2462f96ba45f 100644
--- a/lib/msun/src/s_tanf.c
+++ b/lib/msun/src/s_tanf.c
@@ -14,7 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include <float.h>
#include "math.h"
diff --git a/lib/msun/src/s_tanh.c b/lib/msun/src/s_tanh.c
index 1dbd1d4630eb..cc8daeddda0b 100644
--- a/lib/msun/src/s_tanh.c
+++ b/lib/msun/src/s_tanh.c
@@ -1,4 +1,3 @@
-/* @(#)s_tanh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/* Tanh(x)
* Return the Hyperbolic Tangent of x
*
diff --git a/lib/msun/src/s_tanhf.c b/lib/msun/src/s_tanhf.c
index 986404f52f5a..e56813adfdc2 100644
--- a/lib/msun/src/s_tanhf.c
+++ b/lib/msun/src/s_tanhf.c
@@ -13,7 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
#include "math.h"
#include "math_private.h"
diff --git a/lib/msun/src/s_tanhl.c b/lib/msun/src/s_tanhl.c
index 3ee5b50bd2c8..3285b9afd0bd 100644
--- a/lib/msun/src/s_tanhl.c
+++ b/lib/msun/src/s_tanhl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/s_tanhl.c XXX */
-/* @(#)s_tanh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,7 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* See s_tanh.c for complete comments.
*
diff --git a/lib/msun/src/s_tanl.c b/lib/msun/src/s_tanl.c
index 1e9d7263c289..3736477922dc 100644
--- a/lib/msun/src/s_tanl.c
+++ b/lib/msun/src/s_tanl.c
@@ -26,7 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/*
* Limited testing on pseudorandom numbers drawn within [0:4e8] shows
* an accuracy of <= 1.5 ULP where 247024 values of x out of 40 million
diff --git a/lib/msun/src/s_tgammaf.c b/lib/msun/src/s_tgammaf.c
index 3bf937ce958d..9fa9df9ece72 100644
--- a/lib/msun/src/s_tgammaf.c
+++ b/lib/msun/src/s_tgammaf.c
@@ -26,7 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <math.h>
/*
diff --git a/lib/msun/src/s_trunc.c b/lib/msun/src/s_trunc.c
index 4bd1249544ea..3ec59f22ead3 100644
--- a/lib/msun/src/s_trunc.c
+++ b/lib/msun/src/s_trunc.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* trunc(x)
* Return x rounded toward 0 to integral value
diff --git a/lib/msun/src/s_truncf.c b/lib/msun/src/s_truncf.c
index 8d15c78d69da..3f4db30b5646 100644
--- a/lib/msun/src/s_truncf.c
+++ b/lib/msun/src/s_truncf.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,7 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
/*
* truncf(x)
* Return x rounded toward 0 to integral value
diff --git a/lib/msun/src/s_truncl.c b/lib/msun/src/s_truncl.c
index f54608ac7ab0..81e794d71b79 100644
--- a/lib/msun/src/s_truncl.c
+++ b/lib/msun/src/s_truncl.c
@@ -7,11 +7,8 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * From: @(#)s_floor.c 5.1 93/09/24
*/
-#include <sys/cdefs.h>
/*
* truncl(x)
* Return x rounded toward 0 to integral value
diff --git a/lib/msun/src/w_cabs.c b/lib/msun/src/w_cabs.c
index dfae649b9906..49864619b072 100644
--- a/lib/msun/src/w_cabs.c
+++ b/lib/msun/src/w_cabs.c
@@ -5,7 +5,6 @@
* Placed into the Public Domain, 1994.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/lib/msun/src/w_cabsf.c b/lib/msun/src/w_cabsf.c
index b5065c8a5683..aedbdef217ca 100644
--- a/lib/msun/src/w_cabsf.c
+++ b/lib/msun/src/w_cabsf.c
@@ -5,11 +5,6 @@
* Placed into the Public Domain, 1994.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <complex.h>
#include <math.h>
#include "math_private.h"
diff --git a/lib/msun/src/w_cabsl.c b/lib/msun/src/w_cabsl.c
index 943413c31106..1539944faf6c 100644
--- a/lib/msun/src/w_cabsl.c
+++ b/lib/msun/src/w_cabsl.c
@@ -7,7 +7,6 @@
* Modified by Steven G. Kargl for the long double type.
*/
-#include <sys/cdefs.h>
#include <complex.h>
#include <math.h>
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index ccea2ad82fc3..d2a3ebffadb3 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -1,4 +1,3 @@
-
.include <bsd.own.mk>
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libm
diff --git a/lib/msun/tests/cexp_test.c b/lib/msun/tests/cexp_test.c
index a23e448ee62a..35b23990a3f3 100644
--- a/lib/msun/tests/cexp_test.c
+++ b/lib/msun/tests/cexp_test.c
@@ -28,7 +28,6 @@
* Tests for corner cases in cexp*().
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <complex.h>
diff --git a/lib/msun/tests/csqrt_test.c b/lib/msun/tests/csqrt_test.c
index 1154c0fc016a..b9ae2b3b6ae7 100644
--- a/lib/msun/tests/csqrt_test.c
+++ b/lib/msun/tests/csqrt_test.c
@@ -28,7 +28,6 @@
* Tests for csqrt{,f}()
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <complex.h>
diff --git a/lib/msun/tests/ctrig_test.c b/lib/msun/tests/ctrig_test.c
index dd03d11fdbd1..ac1b79f2a1ce 100644
--- a/lib/msun/tests/ctrig_test.c
+++ b/lib/msun/tests/ctrig_test.c
@@ -28,7 +28,6 @@
* Tests for csin[h](), ccos[h](), and ctan[h]().
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <complex.h>
#include <fenv.h>
diff --git a/lib/msun/tests/fenv_test.c b/lib/msun/tests/fenv_test.c
index 9069921d8eaf..d85671827d37 100644
--- a/lib/msun/tests/fenv_test.c
+++ b/lib/msun/tests/fenv_test.c
@@ -28,7 +28,6 @@
* Test the correctness and C99-compliance of various fenv.h features.
*/
-#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <assert.h>
diff --git a/lib/msun/tests/fma_test.c b/lib/msun/tests/fma_test.c
index e6a34e0f2afa..f1aa855df6f2 100644
--- a/lib/msun/tests/fma_test.c
+++ b/lib/msun/tests/fma_test.c
@@ -28,7 +28,6 @@
* Tests for fma{,f,l}().
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <fenv.h>
#include <float.h>
diff --git a/lib/msun/tests/invctrig_test.c b/lib/msun/tests/invctrig_test.c
index 170fb1cad3a3..18d59e6f5416 100644
--- a/lib/msun/tests/invctrig_test.c
+++ b/lib/msun/tests/invctrig_test.c
@@ -28,7 +28,6 @@
* Tests for casin[h](), cacos[h](), and catan[h]().
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <complex.h>
#include <fenv.h>
diff --git a/lib/msun/tests/logarithm_test.c b/lib/msun/tests/logarithm_test.c
index 9da4ad3ba407..de80b5b45615 100644
--- a/lib/msun/tests/logarithm_test.c
+++ b/lib/msun/tests/logarithm_test.c
@@ -28,7 +28,6 @@
* Tests for corner cases in log*().
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <fenv.h>
#include <float.h>
diff --git a/lib/msun/tests/nan_test.c b/lib/msun/tests/nan_test.c
index 75c28d45fb78..32c5c39af0c1 100644
--- a/lib/msun/tests/nan_test.c
+++ b/lib/msun/tests/nan_test.c
@@ -29,7 +29,6 @@
* and sscanf("nan(...)", ...) work identically.
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <fenv.h>
#include <float.h>
diff --git a/lib/msun/tests/nearbyint_test.c b/lib/msun/tests/nearbyint_test.c
index 9dcdbdf6b852..749c2bb23c99 100644
--- a/lib/msun/tests/nearbyint_test.c
+++ b/lib/msun/tests/nearbyint_test.c
@@ -32,7 +32,6 @@
* - tests for harder values (more mantissa bits than float)
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <fenv.h>
#include <math.h>
diff --git a/lib/msun/tests/rem_test.c b/lib/msun/tests/rem_test.c
index 9e5b8c302948..c96dc5ecd074 100644
--- a/lib/msun/tests/rem_test.c
+++ b/lib/msun/tests/rem_test.c
@@ -30,7 +30,6 @@
* Missing tests: fmod, fmodf.
*/
-#include <sys/cdefs.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
diff --git a/lib/msun/tests/trig_test.c b/lib/msun/tests/trig_test.c
index d1d831e07c71..fe8c5298093a 100644
--- a/lib/msun/tests/trig_test.c
+++ b/lib/msun/tests/trig_test.c
@@ -33,7 +33,6 @@
* available at http://www.cs.berkeley.edu/~wkahan/testpi/ .
*/
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <fenv.h>
diff --git a/lib/ncurses/Makefile b/lib/ncurses/Makefile
index b6b416138a18..862a6aba0bb7 100644
--- a/lib/ncurses/Makefile
+++ b/lib/ncurses/Makefile
@@ -1,4 +1,3 @@
-
SUBDIR= tinfo ncurses form menu panel
SUBDIR_PARALLEL=
diff --git a/lib/ncurses/Makefile.inc b/lib/ncurses/Makefile.inc
index 666f8a74396f..f2ed84e2e38f 100644
--- a/lib/ncurses/Makefile.inc
+++ b/lib/ncurses/Makefile.inc
@@ -1,4 +1,3 @@
-
# This is to include src/lib/Makefile.inc
WARNS?= 3
diff --git a/lib/ncurses/config.mk b/lib/ncurses/config.mk
index 0016dc97a72f..50f333a547c9 100644
--- a/lib/ncurses/config.mk
+++ b/lib/ncurses/config.mk
@@ -3,8 +3,10 @@
NCURSES_DIR= ${SRCTOP}/contrib/ncurses
NCURSES_MAJOR= 6
-NCURSES_MINOR= 2
-NCURSES_PATCH= 20210220
+NCURSES_MINOR= 5
+NCURSES_PATCH= 20240407
+
+TINFO_OBJDIR?= ${.OBJDIR:H}/tinfo
CFLAGS+= -D_XOPEN_SOURCE_EXTENDED
NCURSES_CFG_H= ${.CURDIR}/ncurses_cfg.h
@@ -17,7 +19,7 @@ CFLAGS+= -I${.CURDIR:H}/ncurses
CFLAGS+= -I${NCURSES_DIR}/include
CFLAGS+= -I${NCURSES_DIR}/ncurses
-CFLAGS+= -I${.OBJDIR:H}/tinfo/
+CFLAGS+= -I${TINFO_OBJDIR}
CFLAGS+= -Wall
@@ -27,7 +29,7 @@ CFLAGS+= -DHAVE_CONFIG_H
# everyone needs this
.PATH: ${NCURSES_DIR}/include
-.PATH: ${.OBJDIR:H}/tinfo/
+.PATH: ${TINFO_OBJDIR}
# tools and directories
AWK?= awk
diff --git a/lib/ncurses/form/Makefile b/lib/ncurses/form/Makefile
index 0c163e05e07f..d4774a5f51a8 100644
--- a/lib/ncurses/form/Makefile
+++ b/lib/ncurses/form/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
.include "${.CURDIR:H}/config.mk"
@@ -167,9 +166,6 @@ SYMLINKS+= libformw.a ${LIBDIR}/libform.a
.if !defined(NO_PIC)
SYMLINKS+= libformw.so ${LIBDIR}/libform.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+= libformw_p.a ${LIBDIR}/libform_p.a
-.endif
.include <bsd.lib.mk>
diff --git a/lib/ncurses/form/Makefile.depend b/lib/ncurses/form/Makefile.depend
index 04dbb4f44313..534afd77673d 100644
--- a/lib/ncurses/form/Makefile.depend
+++ b/lib/ncurses/form/Makefile.depend
@@ -1,6 +1,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/ncurses/menu/Makefile b/lib/ncurses/menu/Makefile
index 840a41e80224..793ee60c3a3e 100644
--- a/lib/ncurses/menu/Makefile
+++ b/lib/ncurses/menu/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
.include "${.CURDIR:H}/config.mk"
@@ -136,9 +135,6 @@ SYMLINKS+= libmenuw.a ${LIBDIR}/libmenu.a
.if !defined(NO_PIC)
SYMLINKS+= libmenuw.so ${LIBDIR}/libmenu.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+= libmenuw_p.a ${LIBDIR}/libmenu_p.a
-.endif
.include <bsd.lib.mk>
diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
index b52085780952..512a452ad6d0 100644
--- a/lib/ncurses/ncurses/Makefile
+++ b/lib/ncurses/ncurses/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= clibs
SHLIBDIR?= /lib
@@ -9,8 +8,6 @@ SHLIBDIR?= /lib
LIB= ncursesw
SHLIB_MAJOR= 9
-NO_LINT=
-
GENSRCS= \
expanded.c \
lib_gen.c
@@ -161,12 +158,6 @@ SYMLINKS+= libncursesw.so ${LIBDIR}/libcursesw.so
SYMLINKS+= libncursesw.so ${LIBDIR}/libncurses.so
SYMLINKS+= libncursesw.so ${LIBDIR}/libcurses.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+= libncursesw_p.a ${LIBDIR}/libcursesw_p.a
-# backward compat
-SYMLINKS+= libncursesw_p.a ${LIBDIR}/libncurses_p.a
-SYMLINKS+= libncursesw_p.a ${LIBDIR}/libcurses_p.a
-.endif
LIBADD+= tinfow
SHLIB_LDSCRIPT= libncursesw.ldscript
@@ -180,9 +171,9 @@ libncursesw.ald: ${.CURDIR}/${STATIC_LDSCRIPT}
-e 's,@@STATICLIB_SUFFIX@@,${_STATICLIB_SUFFIX},g' \
${.ALLSRC} > ${.TARGET}
-lib_gen.c: MKlib_gen.sh ${.OBJDIR:H}/tinfo/curses.h ncurses_dll.h
+lib_gen.c: MKlib_gen.sh ${TINFO_OBJDIR}/curses.h ncurses_dll.h
LC_ALL=C sh ${NCURSES_DIR}/ncurses/base/MKlib_gen.sh "${CPP:N${CCACHE_BIN}} ${CFLAGS}" \
- "${AWK}" generated < ${.OBJDIR:H}/tinfo/curses.h >$@
+ "${AWK}" generated < ${TINFO_OBJDIR}/curses.h >$@
expanded.c: MKexpanded.sh
sh ${NCURSES_DIR}/ncurses/tty/MKexpanded.sh "${CC:N${CCACHE_BIN}} -E" ${CFLAGS} >expanded.c
diff --git a/lib/ncurses/ncurses/Makefile.depend b/lib/ncurses/ncurses/Makefile.depend
index dd06faaab7bf..c6788a7857d3 100644
--- a/lib/ncurses/ncurses/Makefile.depend
+++ b/lib/ncurses/ncurses/Makefile.depend
@@ -1,6 +1,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/ncurses/ncurses/pathnames.h b/lib/ncurses/ncurses/pathnames.h
index 4a5b8840c2b7..1c007ef6e943 100644
--- a/lib/ncurses/ncurses/pathnames.h
+++ b/lib/ncurses/ncurses/pathnames.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/4/93
*/
#define _PATH_DEF ".termcap /usr/share/misc/termcap /etc/termcap.small"
diff --git a/lib/ncurses/panel/Makefile b/lib/ncurses/panel/Makefile
index 808b31105979..a51129df42e3 100644
--- a/lib/ncurses/panel/Makefile
+++ b/lib/ncurses/panel/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
.include "${.CURDIR:H}/config.mk"
@@ -63,9 +62,6 @@ SYMLINKS+= libpanelw.a ${LIBDIR}/libpanel.a
.if !defined(NO_PIC)
SYMLINKS+= libpanelw.so ${LIBDIR}/libpanel.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+= libpanelw_p.a ${LIBDIR}/libpanel_p.a
-.endif
INCS= panel.h
.include <bsd.lib.mk>
diff --git a/lib/ncurses/panel/Makefile.depend b/lib/ncurses/panel/Makefile.depend
index 04dbb4f44313..534afd77673d 100644
--- a/lib/ncurses/panel/Makefile.depend
+++ b/lib/ncurses/panel/Makefile.depend
@@ -1,6 +1,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/ncurses/tinfo/Makefile b/lib/ncurses/tinfo/Makefile
index c1ea75d3aacd..476df54bb72a 100644
--- a/lib/ncurses/tinfo/Makefile
+++ b/lib/ncurses/tinfo/Makefile
@@ -1,4 +1,3 @@
-
PACKAGE= clibs
SHLIBDIR?= /lib
@@ -9,8 +8,6 @@ SHLIBDIR?= /lib
LIB= tinfow
SHLIB_MAJOR= 9
-NO_LINT=
-
NCURSES_MAJOR!= egrep 'NCURSES_MAJOR[ ]*=' ${NCURSES_DIR}/dist.mk | sed -e 's%^[^0-9]*%%'
NCURSES_MINOR!= egrep 'NCURSES_MINOR[ ]*=' ${NCURSES_DIR}/dist.mk | sed -e 's%^[^0-9]*%%'
NCURSES_PATCH!= egrep 'NCURSES_PATCH[ ]*=' ${NCURSES_DIR}/dist.mk | sed -e 's%^[^0-9]*%%'
@@ -54,6 +51,8 @@ HAVE_TERMIO_H= 0
HAVE_VSSCANF= 1
HAVE_STDINT_H= 1
HEADER_STDBOOL= 1
+HAVE_STDNORETURN_H= 0
+ENABLE_SIGWINCH= 1
# XXX amd64 1L and int
ONEUL= 1U
TYPEOF_CHTYPE= uint32_t
@@ -74,6 +73,7 @@ GENHDRS= \
hashsize.h \
init_keytry.h \
ncurses_def.h \
+ ncurses_dll.h \
nomacros.h \
parametrized.h \
term.h \
@@ -170,9 +170,8 @@ CWARNFLAGS.comp_parse.c= ${NO_WUNUSED_BUT_SET_VARIABLE}
CWARNFLAGS.read_entry.c= ${NO_WUNUSED_BUT_SET_VARIABLE}
# Installed
-HEADERS= curses.h term.h termcap.h unctrl.h
-SRCHDRS= ncurses_dll.h
-CLEANFILES+= ncurses_dll.h
+HEADERS= curses.h ncurses_dll.h term.h termcap.h unctrl.h
+SRCHDRS=
INCS= ${HEADERS} ${SRCHDRS}
INCSLINKS= curses.h ${INCLUDEDIR}/ncurses.h
@@ -194,14 +193,6 @@ SYMLINKS+= libtinfow.so ${LIBDIR}/libtermcap.so
SYMLINKS+= libtinfow.so ${LIBDIR}/libtermlib.so
SYMLINKS+= libtinfow.so ${LIBDIR}/libtinfo.so
.endif
-.if ${MK_PROFILE} != "no"
-SYMLINKS+= libtinfow_p.a ${LIBDIR}/libtermcapw_p.a
-SYMLINKS+= libtinfow_p.a ${LIBDIR}/libtermlibw_p.a
-# backward compat
-SYMLINKS+= libtinfow_p.a ${LIBDIR}/libtermcap_p.a
-SYMLINKS+= libtinfow_p.a ${LIBDIR}/libtermlib_p.a
-SYMLINKS+= libtinfow_p.a ${LIBDIR}/libtinfo_p.a
-.endif
DOCSDIR= ${SHAREDIR}/doc/ncurses
DOCS= ncurses-intro.html hackguide.html
@@ -214,6 +205,14 @@ FILESGROUPS= DOCS
# Generated source
.ORDER: names.c codes.c
+# Serialize the build just a little bit; there's nothing stopping the build from
+# proceeding before ncurses_dll.h and curses.h are actually generated on a clean
+# build since we have no dependency information to prevent it.
+.ORDER: ncurses_dll.h curses.h
+.for f in ${SRCS:M*.c}
+.ORDER: curses.h ${f}
+.endfor
+
names.c: MKnames.awk
${AWK} -f ${NCURSES_DIR}/ncurses/tinfo/MKnames.awk bigstrings=${USE_BIG_STRINGS} ${NCURSES_DIR}/include/Caps > names.c
@@ -221,7 +220,8 @@ codes.c: MKcodes.awk
${AWK} -f ${NCURSES_DIR}/ncurses/tinfo/MKcodes.awk bigstrings=${USE_BIG_STRINGS} ${NCURSES_DIR}/include/Caps > codes.c
lib_keyname.c: keys.list MKkeyname.awk
- ${AWK} -f ${NCURSES_DIR}/ncurses/base/MKkeyname.awk bigstrings=${USE_BIG_STRINGS} keys.list > lib_keyname.c
+ ${AWK} -f ${NCURSES_DIR}/ncurses/base/MKkeyname.awk use_sigwinch=${ENABLE_SIGWINCH} \
+ bigstrings=${USE_BIG_STRINGS} keys.list > lib_keyname.c
unctrl.c: MKunctrl.awk
echo | ${AWK} -f ${NCURSES_DIR}/ncurses/base/MKunctrl.awk bigstrings=${USE_BIG_STRINGS} > unctrl.c
@@ -259,17 +259,25 @@ term.h: MKterm.h.awk edit_cfg.sh Caps Caps-ncurses
sh ${NCURSES_DIR}/include/edit_cfg.sh ${NCURSES_CFG_H} $@.new
mv -f $@.new $@
+# Avoid hard-coding absolute source paths if requested.
+.if ${MK_REPRODUCIBLE_BUILD} != "no"
+NCURSES_SRCTOP=/usr/src
+.else
+NCURSES_SRCTOP=${SRCTOP}
+.endif
+
curses.h: curses.head MKkey_defs.sh Caps Caps-ncurses
cat curses.head > $@.new
AWK=${AWK} _POSIX2_VERSION=199209 sh ${NCURSES_DIR}/include/MKkey_defs.sh \
${NCURSES_DIR}/include/Caps ${NCURSES_DIR}/include/Caps-ncurses >> $@.new
+ sed -i '' 's|${SRCTOP}|${NCURSES_SRCTOP}|g' $@.new
cat ${NCURSES_DIR}/include/curses.wide >> $@.new
cat ${NCURSES_DIR}/include/curses.tail >> $@.new
mv -f $@.new $@
# Generated intermediate files
keys.list: MKkeys_list.sh Caps Caps-ncurses
- AWK=${AWK} sh ${NCURSES_DIR}/ncurses/tinfo/MKkeys_list.sh \
+ AWK=${AWK} USE_SIGWINCH=${ENABLE_SIGWINCH} sh ${NCURSES_DIR}/ncurses/tinfo/MKkeys_list.sh \
${NCURSES_DIR}/include/Caps ${NCURSES_DIR}/include/Caps-ncurses | LC_ALL=C sort > keys.list
.if ${MK_DIRDEPS_BUILD} == "yes" && ${MACHINE} != "host"
@@ -332,6 +340,7 @@ curses.head: curses.h.in
-e "/@BROKEN_LINKER@/s%%${BROKEN_LINKER}%" \
-e "/@HAVE_VSSCANF@/s%%${HAVE_VSSCANF}%" \
-e "/@HAVE_STDINT_H@/s%%${HAVE_STDINT_H}%" \
+ -e "/@HAVE_STDNORETURN_H@/s%%${HAVE_STDNORETURN_H}%" \
-e "/@NCURSES_CH_T@/s%%${NCURSES_CH_T}%" \
-e "/@NCURSES_CONST@/s%%${NCURSES_CONST}%" \
-e "/@NCURSES_EXT_COLORS@/s%%${NCURSES_EXT_COLORS}%" \
@@ -342,6 +351,7 @@ curses.head: curses.h.in
-e "/@NCURSES_MBSTATE_T@/s%%${NCURSES_MBSTATE_T}%" \
-e "/@NCURSES_MINOR@/s%%${NCURSES_MINOR}%" \
-e "/@NCURSES_MOUSE_VERSION@/s%%${NCURSES_MOUSE_VERSION}%" \
+ -e "/@NCURSES_XNAMES@/s%%${NCURSES_XNAMES}%" \
-e "/@NCURSES_OK_WCHAR_T@/s%%${NCURSES_OK_WCHAR_T}%" \
-e "/@NCURSES_OPAQUE@/s%%${NCURSES_OPAQUE}%" \
-e "/@NCURSES_OPAQUE_FORM@/s%%${NCURSES_OPAQUE_FORM}%" \
@@ -367,6 +377,7 @@ curses.head: curses.h.in
-e "s%@cf_cv_enable_lp64@%${ENABLE_LP64}%g" \
-e "s%@cf_cv_enable_opaque@%${ENABLE_OPAQUE}%g" \
-e "s%@cf_cv_enable_reentrant@%${ENABLE_REENTRANT}%g" \
+ -e "s%@cf_cv_enable_sigwinch@%${ENABLE_SIGWINCH}%g" \
-e "s%@cf_cv_header_stdbool_h@%${HEADER_STDBOOL}%g" \
-e "s%@cf_cv_type_of_bool@%${TYPE_OF_BOOL}%g" \
-e "s%@cf_cv_typeof_chtype@%${TYPEOF_CHTYPE}%g" \
@@ -384,6 +395,7 @@ unctrl.h: unctrl.h.in
terminfo.5: MKterminfo.sh terminfo.head Caps
sh ${NCURSES_DIR}/man/MKterminfo.sh ${NCURSES_DIR}/man/terminfo.head \
${NCURSES_DIR}/include/Caps ${NCURSES_DIR}/man/terminfo.tail >$@
+ sed -i '' 's|${SRCTOP}|${NCURSES_SRCTOP}|g' $@
CLEANFILES+= terminfo.5
diff --git a/lib/ncurses/tinfo/Makefile.depend b/lib/ncurses/tinfo/Makefile.depend
index be2eeefbac96..996a149f6041 100644
--- a/lib/ncurses/tinfo/Makefile.depend
+++ b/lib/ncurses/tinfo/Makefile.depend
@@ -1,6 +1,7 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
+ bin/sh.host \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/lib/ncurses/tinfo/ncurses_cfg.h b/lib/ncurses/tinfo/ncurses_cfg.h
index 556938aaa586..33890f300310 100644
--- a/lib/ncurses/tinfo/ncurses_cfg.h
+++ b/lib/ncurses/tinfo/ncurses_cfg.h
@@ -47,35 +47,47 @@
* https://invisible-island.net/autoconf/
* ftp://ftp.invisible-island.net/autoconf/
*/
-
-
#ifndef NC_CONFIG_H
#define NC_CONFIG_H
#define PACKAGE "ncurses"
-#define NCURSES_VERSION "6.2"
-#define NCURSES_PATCHDATE 20210220
+#define NCURSES_VERSION "6.5"
+#define NCURSES_PATCHDATE 20240427
#define SYSTEM_NAME "FreeBSD"
#if 0
#include <stdlib.h>
#endif
#define HAVE_LONG_FILE_NAMES 1
#define MIXEDCASE_FILENAMES 1
-#ifdef __FreeBSD__
+#define STDC_HEADERS 1
+#define USE_GETCAP 1
+#define USE_BSD_TPUTS 1
+#define HAVE_BSD_CGETENT 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_DIRENT_H 1
#define USE_SYSMOUSE 1
-#endif
#define TERMINFO_DIRS "/usr/share/terminfo:/usr/local/share/terminfo:/usr/local/share/site-terminfo"
#define TERMINFO "/usr/share/terminfo"
#define HAVE_BIG_CORE 1
#define TERMPATH "/etc/termcap:/usr/share/misc/termcap"
-#define USE_GETCAP 1
+#define USE_HOME_TERMINFO 1
+#define USE_ROOT_ENVIRON 1
+#define USE_ROOT_ACCESS 1
+#define USE_SETUID_ENVIRON 1
#define HAVE_UNISTD_H 1
#define HAVE_REMOVE 1
#define HAVE_UNLINK 1
#define HAVE_LINK 1
#define HAVE_SYMLINK 1
#define USE_LINKS 1
-#define BSD_TPUTS 1
#define HAVE_LANGINFO_CODESET 1
#define USE_WIDEC_SUPPORT 1
#define NCURSES_WIDECHAR 1
@@ -84,6 +96,7 @@
#define HAVE_PUTWC 1
#define HAVE_BTOWC 1
#define HAVE_WCTOB 1
+#define HAVE_WMEMCHR 1
#define HAVE_MBTOWC 1
#define HAVE_WCTOMB 1
#define HAVE_MBLEN 1
@@ -95,16 +108,7 @@
#define HAVE_MBSTOWCS 1
#define NEED_WCHAR_H 1
#define HAVE_FSEEKO 1
-#define STDC_HEADERS 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRING_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_UNISTD_H 1
+#define RGB_PATH "no"
#define SIZEOF_SIGNED_CHAR 1
#define NCURSES_EXT_FUNCS 1
#define HAVE_ASSUME_DEFAULT_COLORS 1
@@ -114,7 +118,6 @@
#define HAVE_RESIZE_TERM 1
#define HAVE_TERM_ENTRY_H 1
#define HAVE_USE_DEFAULT_COLORS 1
-#define HAVE_USE_EXTENDED_NAMES 1
#define HAVE_USE_SCREEN 1
#define HAVE_USE_WINDOW 1
#define HAVE_WRESIZE 1
@@ -127,10 +130,10 @@
#define NCURSES_EXT_PUTWIN 1
#define NCURSES_NO_PADDING 1
#define USE_SIGWINCH 1
+#define NCURSES_XNAMES 1
#define NCURSES_WRAP_PREFIX "_nc_"
#define USE_ASSUMED_COLOR 1
#define USE_HASHMAP 1
-#define USE_COLORFGBG 1
#define GCC_SCANF 1
#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
#define GCC_PRINTF 1
@@ -138,9 +141,7 @@
#define GCC_UNUSED __attribute__((unused))
#define GCC_NORETURN __attribute__((noreturn))
#define HAVE_NC_ALLOC_H 1
-#define HAVE_GETTIMEOFDAY 1
-#define STDC_HEADERS 1
-#define HAVE_DIRENT_H 1
+#define HAVE_MATH_FUNCS 1
#define TIME_WITH_SYS_TIME 1
#define HAVE_REGEX_H_FUNCS 1
#define HAVE_FCNTL_H 1
@@ -149,13 +150,13 @@
#define HAVE_LOCALE_H 1
#define HAVE_MATH_H 1
#define HAVE_POLL_H 1
+#define HAVE_SYS_AUXV_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_PARAM_H 1
#define HAVE_SYS_POLL_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TIMES_H 1
-#define HAVE_TTYENT_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WCTYPE_H 1
#define HAVE_UNISTD_H 1
@@ -169,20 +170,20 @@
#define HAVE_SYS_TIME_SELECT 1
#define SIG_ATOMIC_T volatile sig_atomic_t
#define HAVE_ERRNO 1
+#define HAVE_CLOCK_GETTIME 1
+#define HAVE_FPATHCONF 1
#define HAVE_GETCWD 1
#define HAVE_GETEGID 1
#define HAVE_GETEUID 1
#define HAVE_GETOPT 1
-#define HAVE_GETTTYNAM 1
+#define HAVE_GETUID 1
#define HAVE_ISSETUGID 1
#define HAVE_LOCALECONV 1
#define HAVE_POLL 1
-#define HAVE_PUTENV 1
#define HAVE_REMOVE 1
#define HAVE_SELECT 1
#define HAVE_SETBUF 1
#define HAVE_SETBUFFER 1
-#define HAVE_SETENV 1
#define HAVE_SETVBUF 1
#define HAVE_SIGACTION 1
#define HAVE_SIGVEC 1
@@ -194,7 +195,8 @@
#define HAVE_TIMES 1
#define HAVE_TSEARCH 1
#define HAVE_VSNPRINTF 1
-#define HAVE_BSD_CGETENT 1
+#define HAVE_PATH_TTYS 1
+#define HAVE_GETTTYNAM 1
#define HAVE_ISASCII 1
#define HAVE_NANOSLEEP 1
#define HAVE_TERMIOS_H 1
@@ -206,6 +208,7 @@
#define HAVE_MKSTEMP 1
#define HAVE_SIZECHANGE 1
#define HAVE_WORKING_POLL 1
+#define HAVE_CONSISTENT_MB_LEN_MAX 1
#define HAVE_VA_COPY 1
#define HAVE_UNISTD_H 1
#define HAVE_FORK 1
@@ -219,6 +222,7 @@
#define HAVE_IOSTREAM 1
#define IOSTREAM_NAMESPACE 1
#define SIZEOF_BOOL 1
+#define CPP_HAS_OVERRIDE 1
#define CPP_HAS_STATIC_CAST 1
#define SIZEOF_WCHAR_T 4
#define HAVE_SLK_COLOR 1
@@ -229,9 +233,8 @@
#define HAVE_FORM_H 1
#define HAVE_LIBFORM 1
#define NCURSES_PATHSEP ':'
-#define NCURSES_VERSION_STRING "6.2.20210220"
+#define NCURSES_VERSION_STRING "6.5.20240427"
#define NCURSES_OSPEED_COMPAT 1
-#define HAVE_CURSES_DATA_BOOLNAMES 1
#include <ncurses_def.h>
diff --git a/lib/ncurses/tinfo/pathnames.h b/lib/ncurses/tinfo/pathnames.h
index 4a5b8840c2b7..1c007ef6e943 100644
--- a/lib/ncurses/tinfo/pathnames.h
+++ b/lib/ncurses/tinfo/pathnames.h
@@ -27,8 +27,6 @@
* 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/4/93
*/
#define _PATH_DEF ".termcap /usr/share/misc/termcap /etc/termcap.small"
diff --git a/lib/ofed/Makefile b/lib/ofed/Makefile
index ea3ecabf95bb..a16e93adc149 100644
--- a/lib/ofed/Makefile
+++ b/lib/ofed/Makefile
@@ -1,4 +1,3 @@
-
SUBDIR= \
include \
libibverbs \
diff --git a/lib/ofed/Makefile.inc b/lib/ofed/Makefile.inc
index 069272ab8104..1b911c451c01 100644
--- a/lib/ofed/Makefile.inc
+++ b/lib/ofed/Makefile.inc
@@ -1,2 +1 @@
-
WARNS?= 0
diff --git a/lib/ofed/complib/Makefile b/lib/ofed/complib/Makefile
index c0e333afc5d7..43019e6ba5e0 100644
--- a/lib/ofed/complib/Makefile
+++ b/lib/ofed/complib/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/opensm/complib
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= osmcomp
SHLIB_MAJOR= 3
-MK_PROFILE= no
SRCS= \
cl_complib.c \
diff --git a/lib/ofed/include/Makefile b/lib/ofed/include/Makefile
index a7ed635a4881..dc6271de734d 100644
--- a/lib/ofed/include/Makefile
+++ b/lib/ofed/include/Makefile
@@ -1,4 +1,3 @@
-
OFEDINCS= ${SRCTOP}/contrib/ofed/include
IBVERBS= ${SRCTOP}/contrib/ofed/libibverbs
IBMAD= ${SRCTOP}/contrib/ofed/libibmad
diff --git a/lib/ofed/libbnxtre/Makefile b/lib/ofed/libbnxtre/Makefile
new file mode 100755
index 000000000000..f73099a44915
--- /dev/null
+++ b/lib/ofed/libbnxtre/Makefile
@@ -0,0 +1,13 @@
+SPATH= ${SRCTOP}/contrib/ofed/libbnxtre
+.PATH: ${SPATH}
+
+SHLIBDIR?= /lib
+LIB= bnxtre
+SHLIB_MAJOR= 1
+
+SRCS= main.c db.c memory.c verbs.c
+
+LIBADD= ibverbs pthread
+CFLAGS+= -I${SPATH}
+
+.include <bsd.lib.mk>
diff --git a/lib/ofed/libcxgb4/Makefile b/lib/ofed/libcxgb4/Makefile
index 7d184308fea0..7c50e47ceec7 100644
--- a/lib/ofed/libcxgb4/Makefile
+++ b/lib/ofed/libcxgb4/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libcxgb4
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= cxgb4
SHLIB_MAJOR= 1
-MK_PROFILE= no
SRCS= \
cq.c \
diff --git a/lib/ofed/libibcm/Makefile b/lib/ofed/libibcm/Makefile
index d684811a311b..04f124d06167 100644
--- a/lib/ofed/libibcm/Makefile
+++ b/lib/ofed/libibcm/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libibcm
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= ibcm
SHLIB_MAJOR= 1
-MK_PROFILE= no
SRCS= cm.c
LIBADD= ibverbs
CFLAGS+= -I${_spath}
diff --git a/lib/ofed/libibmad/Makefile b/lib/ofed/libibmad/Makefile
index 0a1e40096d90..298bb7dffbfe 100644
--- a/lib/ofed/libibmad/Makefile
+++ b/lib/ofed/libibmad/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libibmad
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= ibmad
SHLIB_MAJOR= 5
-MK_PROFILE= no
SRCS= \
bm.c \
diff --git a/lib/ofed/libibnetdisc/Makefile b/lib/ofed/libibnetdisc/Makefile
index 47470132a2b6..aac0bf0f5971 100644
--- a/lib/ofed/libibnetdisc/Makefile
+++ b/lib/ofed/libibnetdisc/Makefile
@@ -1,4 +1,3 @@
-
.include <src.opts.mk>
_spath= ${SRCTOP}/contrib/ofed/libibnetdisc
@@ -7,7 +6,6 @@ _spath= ${SRCTOP}/contrib/ofed/libibnetdisc
SHLIBDIR?= /usr/lib
LIB_CXX= ibnetdisc
SHLIB_MAJOR= 5
-MK_PROFILE= no
SRCS= \
chassis.c \
@@ -31,7 +29,6 @@ LIBADD= osmcomp ibmad ibumad
CFLAGS+= -DHAVE_CONFIG_H=1
CFLAGS+= -I${_spath}
CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
-CXXSTD= c++11
VERSION_MAP= ${_spath}/libibnetdisc.map
.include <bsd.lib.mk>
diff --git a/lib/ofed/libibumad/Makefile b/lib/ofed/libibumad/Makefile
index 3097ac846c46..46e69012ba72 100644
--- a/lib/ofed/libibumad/Makefile
+++ b/lib/ofed/libibumad/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libibumad
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= ibumad
SHLIB_MAJOR= 1
-MK_PROFILE= no
SRCS= \
umad.c \
umad_str.c \
diff --git a/lib/ofed/libibverbs/Makefile b/lib/ofed/libibverbs/Makefile
index 6a5f6a50bbb7..96e90c6615e2 100644
--- a/lib/ofed/libibverbs/Makefile
+++ b/lib/ofed/libibverbs/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libibverbs
.PATH: ${_spath} ${_spath}/man
LIB= ibverbs
SHLIB_MAJOR= 1
SHLIBDIR?= /lib
-MK_PROFILE= no
VERSION_MAP= ${_spath}/libibverbs.map
CFLAGS+= -I${_spath}
diff --git a/lib/ofed/libirdma/Makefile b/lib/ofed/libirdma/Makefile
index 368bd536c587..6629e8c2d6aa 100644
--- a/lib/ofed/libirdma/Makefile
+++ b/lib/ofed/libirdma/Makefile
@@ -1,5 +1,3 @@
-# $FreeBSD: releng/12.1/lib/ofed/libirdma/Makefile 336568 2018-07-20 23:49:57Z kib $
-
_spath= ${SRCTOP}/contrib/ofed/libirdma
_ipath= ${SRCTOP}/contrib/ofed/include
lin_inc=/usr/src/sys/compat/linuxkpi/common/include
@@ -8,7 +6,6 @@ lin_inc=/usr/src/sys/compat/linuxkpi/common/include
SHLIBDIR?= /lib
LIB= irdma
SHLIB_MAJOR= 1
-MK_PROFILE= no
SRCS= \
irdma_umain.c \
diff --git a/lib/ofed/libirdma/Makefile.depend b/lib/ofed/libirdma/Makefile.depend
new file mode 100644
index 000000000000..a13ef992ecf9
--- /dev/null
+++ b/lib/ofed/libirdma/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libthr \
+ lib/ofed/include \
+ lib/ofed/libibverbs \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/ofed/libmlx4/Makefile b/lib/ofed/libmlx4/Makefile
index 09571f159dca..1b1dd07dbc23 100644
--- a/lib/ofed/libmlx4/Makefile
+++ b/lib/ofed/libmlx4/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libmlx4
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= mlx4
SHLIB_MAJOR= 1
-MK_PROFILE= no
SRCS= \
buf.c \
diff --git a/lib/ofed/libmlx5/Makefile b/lib/ofed/libmlx5/Makefile
index 57959a1cd027..72981091bed8 100644
--- a/lib/ofed/libmlx5/Makefile
+++ b/lib/ofed/libmlx5/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/libmlx5
.PATH: ${_spath}
SHLIBDIR?= /lib
LIB= mlx5
SHLIB_MAJOR= 1
-MK_PROFILE= no
SRCS= \
buf.c \
diff --git a/lib/ofed/libopensm/Makefile b/lib/ofed/libopensm/Makefile
index 8ba51f034aaa..a7133064977b 100644
--- a/lib/ofed/libopensm/Makefile
+++ b/lib/ofed/libopensm/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/opensm/opensm
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= opensm
SHLIB_MAJOR= 5
-MK_PROFILE= no
SRCS= \
osm_log.c \
diff --git a/lib/ofed/librdmacm/Makefile b/lib/ofed/librdmacm/Makefile
index cb37008f5851..8c86bada22f9 100644
--- a/lib/ofed/librdmacm/Makefile
+++ b/lib/ofed/librdmacm/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/librdmacm
.PATH: ${_spath} ${_spath}/man
SHLIBDIR?= /usr/lib
LIB= rdmacm
SHLIB_MAJOR= 1
-MK_PROFILE= no
CFLAGS+= -I${_spath}
SRCS= \
diff --git a/lib/ofed/libvendor/Makefile b/lib/ofed/libvendor/Makefile
index baa50ff8cab7..c78e9da07e5f 100644
--- a/lib/ofed/libvendor/Makefile
+++ b/lib/ofed/libvendor/Makefile
@@ -1,11 +1,9 @@
-
_spath= ${SRCTOP}/contrib/ofed/opensm/libvendor
.PATH: ${_spath}
SHLIBDIR?= /usr/lib
LIB= osmvendor
SHLIB_MAJOR= 4
-MK_PROFILE= no
SRCS= \
osm_vendor_ibumad.c \
diff --git a/lib/tests/Makefile b/lib/tests/Makefile
index b8996030aafc..29b1b564beca 100644
--- a/lib/tests/Makefile
+++ b/lib/tests/Makefile
@@ -1,4 +1,3 @@
-
.PATH: ${SRCTOP}/tests
KYUAFILE= yes